1
- const eutil = require ( "@nomicfoundation/ethereumjs-util" ) ;
2
- const fs = require ( "fs" ) ;
1
+ import fs from "fs" ;
2
+ import { bytesToInt } from "@nomicfoundation/ethereumjs-util" ;
3
3
4
- const { keccak256 } = require ( "../internal/util/keccak" ) ;
4
+ import { keccak256 } from "../src/ internal/util/keccak" ;
5
5
6
6
const functionPrefix = " function" ;
7
7
const functionBody =
@@ -12,7 +12,7 @@ const functionSuffix = "));" + "\n }" + "\n" + "\n";
12
12
let logger =
13
13
"// ------------------------------------\n" +
14
14
"// This code was autogenerated using\n" +
15
- "// scripts/console-library-generator.js \n" +
15
+ "// scripts/console-library-generator.ts \n" +
16
16
"// ------------------------------------\n\n" ;
17
17
18
18
const singleTypes = [
@@ -85,9 +85,7 @@ logger +=
85
85
"export const ConsoleLogs = {\n" ;
86
86
87
87
// Add the empty log() first
88
- const sigInt = eutil . bufferToInt (
89
- keccak256 ( Buffer . from ( "log" + "()" ) ) . slice ( 0 , 4 )
90
- ) ;
88
+ const sigInt = bytesToInt ( keccak256 ( Buffer . from ( "log" + "()" ) ) . slice ( 0 , 4 ) ) ;
91
89
logger += " " + sigInt + ": [],\n" ;
92
90
93
91
for ( let i = 0 ; i < singleTypes . length ; i ++ ) {
@@ -98,7 +96,7 @@ for (let i = 0; i < singleTypes.length; i++) {
98
96
const nameSuffix =
99
97
typeAliasedInt . charAt ( 0 ) . toUpperCase ( ) + typeAliasedInt . slice ( 1 ) ;
100
98
101
- const sigInt = eutil . bufferToInt (
99
+ const sigInt = bytesToInt (
102
100
keccak256 ( Buffer . from ( "log" + "(" + type + ")" ) ) . slice ( 0 , 4 )
103
101
) ;
104
102
logger +=
@@ -109,7 +107,7 @@ for (let i = 0; i < singleTypes.length; i++) {
109
107
type . slice ( 1 ) +
110
108
"Ty],\n" ;
111
109
112
- const sigIntAliasedInt = eutil . bufferToInt (
110
+ const sigIntAliasedInt = bytesToInt (
113
111
keccak256 ( Buffer . from ( "log" + "(" + typeAliasedInt + ")" ) ) . slice ( 0 , 4 )
114
112
) ;
115
113
if ( sigIntAliasedInt !== sigInt ) {
@@ -137,9 +135,9 @@ for (let i = 0; i < singleTypes.length; i++) {
137
135
}
138
136
139
137
const maxNumberOfParameters = 4 ;
140
- const numberOfPermutations = { } ;
141
- const dividers = { } ;
142
- const paramsNames = { } ;
138
+ const numberOfPermutations : Record < number , number > = { } ;
139
+ const dividers : Record < number , number > = { } ;
140
+ const paramsNames : Record < number , string [ ] > = { } ;
143
141
144
142
for ( let i = 0 ; i < maxNumberOfParameters ; i ++ ) {
145
143
dividers [ i ] = Math . pow ( maxNumberOfParameters , i ) ;
@@ -188,12 +186,12 @@ for (let i = 0; i < maxNumberOfParameters; i++) {
188
186
functionSuffix ;
189
187
190
188
if ( sigParams . length !== 1 ) {
191
- const sigInt = eutil . bufferToInt (
189
+ const sigInt = bytesToInt (
192
190
keccak256 ( Buffer . from ( "log(" + sigParams . join ( "," ) + ")" ) ) . slice ( 0 , 4 )
193
191
) ;
194
192
logger += " " + sigInt + ": [" + constParams . join ( ", " ) + "],\n" ;
195
193
196
- const sigIntAliasedInt = eutil . bufferToInt (
194
+ const sigIntAliasedInt = bytesToInt (
197
195
keccak256 (
198
196
Buffer . from ( "log(" + sigParamsAliasedInt . join ( "," ) + ")" )
199
197
) . slice ( 0 , 4 )
0 commit comments