Skip to content

Commit 4e26e74

Browse files
committed
Refresh hardhat-core/scripts/console-library-generators.ts
It was not type-checked previously and thus missed some renames and dependencies' updates.
1 parent 11f13e5 commit 4e26e74

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

packages/hardhat-core/scripts/console-library-generator.js packages/hardhat-core/scripts/console-library-generator.ts

+12-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const eutil = require("@nomicfoundation/ethereumjs-util");
2-
const fs = require("fs");
1+
import fs from "fs";
2+
import { bytesToInt } from "@nomicfoundation/ethereumjs-util";
33

4-
const { keccak256 } = require("../internal/util/keccak");
4+
import { keccak256 } from "../src/internal/util/keccak";
55

66
const functionPrefix = " function";
77
const functionBody =
@@ -12,7 +12,7 @@ const functionSuffix = "));" + "\n }" + "\n" + "\n";
1212
let logger =
1313
"// ------------------------------------\n" +
1414
"// This code was autogenerated using\n" +
15-
"// scripts/console-library-generator.js\n" +
15+
"// scripts/console-library-generator.ts\n" +
1616
"// ------------------------------------\n\n";
1717

1818
const singleTypes = [
@@ -85,9 +85,7 @@ logger +=
8585
"export const ConsoleLogs = {\n";
8686

8787
// 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));
9189
logger += " " + sigInt + ": [],\n";
9290

9391
for (let i = 0; i < singleTypes.length; i++) {
@@ -98,7 +96,7 @@ for (let i = 0; i < singleTypes.length; i++) {
9896
const nameSuffix =
9997
typeAliasedInt.charAt(0).toUpperCase() + typeAliasedInt.slice(1);
10098

101-
const sigInt = eutil.bufferToInt(
99+
const sigInt = bytesToInt(
102100
keccak256(Buffer.from("log" + "(" + type + ")")).slice(0, 4)
103101
);
104102
logger +=
@@ -109,7 +107,7 @@ for (let i = 0; i < singleTypes.length; i++) {
109107
type.slice(1) +
110108
"Ty],\n";
111109

112-
const sigIntAliasedInt = eutil.bufferToInt(
110+
const sigIntAliasedInt = bytesToInt(
113111
keccak256(Buffer.from("log" + "(" + typeAliasedInt + ")")).slice(0, 4)
114112
);
115113
if (sigIntAliasedInt !== sigInt) {
@@ -137,9 +135,9 @@ for (let i = 0; i < singleTypes.length; i++) {
137135
}
138136

139137
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[]> = {};
143141

144142
for (let i = 0; i < maxNumberOfParameters; i++) {
145143
dividers[i] = Math.pow(maxNumberOfParameters, i);
@@ -188,12 +186,12 @@ for (let i = 0; i < maxNumberOfParameters; i++) {
188186
functionSuffix;
189187

190188
if (sigParams.length !== 1) {
191-
const sigInt = eutil.bufferToInt(
189+
const sigInt = bytesToInt(
192190
keccak256(Buffer.from("log(" + sigParams.join(",") + ")")).slice(0, 4)
193191
);
194192
logger += " " + sigInt + ": [" + constParams.join(", ") + "],\n";
195193

196-
const sigIntAliasedInt = eutil.bufferToInt(
194+
const sigIntAliasedInt = bytesToInt(
197195
keccak256(
198196
Buffer.from("log(" + sigParamsAliasedInt.join(",") + ")")
199197
).slice(0, 4)

packages/hardhat-core/src/internal/hardhat-network/stack-traces/logger.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ------------------------------------
22
// This code was autogenerated using
3-
// scripts/console-library-generator.js
3+
// scripts/console-library-generator.ts
44
// ------------------------------------
55

66
export const Int256Ty = "Int256";

packages/hardhat-core/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"rootDirs": ["./test"],
66
"composite": true
77
},
8-
"include": ["./test/**/*.ts"],
8+
"include": ["./test/**/*.ts", "scripts"],
99
"exclude": [
1010
"./test/**/hardhat.config.ts",
1111
"./node_modules",

0 commit comments

Comments
 (0)