hardhat 3.0.0-next.4 → 3.0.0-next.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/src/internal/builtin-plugins/coverage/index.d.ts +1 -0
- package/dist/src/internal/builtin-plugins/coverage/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/index.js +12 -6
- package/dist/src/internal/builtin-plugins/coverage/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/type-extensions.d.ts +7 -0
- package/dist/src/internal/builtin-plugins/coverage/type-extensions.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/coverage/type-extensions.js +2 -0
- package/dist/src/internal/builtin-plugins/coverage/type-extensions.js.map +1 -0
- package/dist/src/internal/builtin-plugins/index.d.ts +1 -0
- package/dist/src/internal/builtin-plugins/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/index.js +2 -0
- package/dist/src/internal/builtin-plugins/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/base-provider.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/base-provider.js +2 -5
- package/dist/src/internal/builtin-plugins/network-manager/base-provider.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/config-resolution.d.ts +2 -1
- package/dist/src/internal/builtin-plugins/network-manager/config-resolution.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/config-resolution.js +76 -75
- package/dist/src/internal/builtin-plugins/network-manager/config-resolution.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-context.js +2 -2
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-context.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.d.ts +2 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js +6 -7
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/types/hardfork.d.ts +18 -3
- package/dist/src/internal/builtin-plugins/network-manager/edr/types/hardfork.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/types/hardfork.js +78 -25
- package/dist/src/internal/builtin-plugins/network-manager/edr/types/hardfork.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.d.ts +3 -5
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.js +71 -81
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/hardfork.d.ts +3 -2
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/hardfork.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/hardfork.js +9 -4
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/hardfork.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/local-accounts.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/local-accounts.js +5 -3
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/local-accounts.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/config.d.ts +2 -0
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/config.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-validation.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-validation.js +60 -26
- package/dist/src/internal/builtin-plugins/network-manager/type-validation.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/reporter.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/reporter.js +2 -2
- package/dist/src/internal/builtin-plugins/solidity-test/reporter.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/stack-trace-solidity-errors.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/stack-trace-solidity-errors.js +4 -2
- package/dist/src/internal/builtin-plugins/solidity-test/stack-trace-solidity-errors.js.map +1 -1
- package/dist/src/internal/builtin-plugins/telemetry/index.d.ts +4 -0
- package/dist/src/internal/builtin-plugins/telemetry/index.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/telemetry/index.js +20 -0
- package/dist/src/internal/builtin-plugins/telemetry/index.js.map +1 -0
- package/dist/src/internal/builtin-plugins/telemetry/task-action.d.ts +8 -0
- package/dist/src/internal/builtin-plugins/telemetry/task-action.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/telemetry/task-action.js +25 -0
- package/dist/src/internal/builtin-plugins/telemetry/task-action.js.map +1 -0
- package/dist/src/internal/cli/init/init.d.ts.map +1 -1
- package/dist/src/internal/cli/init/init.js +0 -4
- package/dist/src/internal/cli/init/init.js.map +1 -1
- package/dist/src/internal/cli/main.d.ts.map +1 -1
- package/dist/src/internal/cli/main.js +0 -3
- package/dist/src/internal/cli/main.js.map +1 -1
- package/dist/src/internal/cli/telemetry/analytics/analytics.d.ts +1 -1
- package/dist/src/internal/cli/telemetry/analytics/analytics.d.ts.map +1 -1
- package/dist/src/internal/cli/telemetry/analytics/analytics.js +7 -7
- package/dist/src/internal/cli/telemetry/analytics/analytics.js.map +1 -1
- package/dist/src/internal/cli/telemetry/analytics/types.d.ts +3 -3
- package/dist/src/internal/cli/telemetry/analytics/types.d.ts.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/subprocess.js +1 -0
- package/dist/src/internal/cli/telemetry/sentry/subprocess.js.map +1 -1
- package/dist/src/internal/cli/telemetry/telemetry-permissions.d.ts +5 -15
- package/dist/src/internal/cli/telemetry/telemetry-permissions.d.ts.map +1 -1
- package/dist/src/internal/cli/telemetry/telemetry-permissions.js +29 -65
- package/dist/src/internal/cli/telemetry/telemetry-permissions.js.map +1 -1
- package/dist/src/types/utils.d.ts +6 -0
- package/dist/src/types/utils.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/internal/builtin-plugins/coverage/index.ts +13 -6
- package/src/internal/builtin-plugins/coverage/type-extensions.ts +6 -0
- package/src/internal/builtin-plugins/index.ts +3 -0
- package/src/internal/builtin-plugins/network-manager/base-provider.ts +2 -7
- package/src/internal/builtin-plugins/network-manager/config-resolution.ts +86 -73
- package/src/internal/builtin-plugins/network-manager/edr/edr-context.ts +4 -4
- package/src/internal/builtin-plugins/network-manager/edr/edr-provider.ts +17 -17
- package/src/internal/builtin-plugins/network-manager/edr/types/hardfork.ts +75 -8
- package/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.ts +98 -91
- package/src/internal/builtin-plugins/network-manager/edr/utils/hardfork.ts +19 -5
- package/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/local-accounts.ts +44 -33
- package/src/internal/builtin-plugins/network-manager/type-extensions/config.ts +2 -0
- package/src/internal/builtin-plugins/network-manager/type-validation.ts +79 -37
- package/src/internal/builtin-plugins/solidity-test/reporter.ts +4 -3
- package/src/internal/builtin-plugins/solidity-test/stack-trace-solidity-errors.ts +4 -2
- package/src/internal/builtin-plugins/telemetry/index.ts +23 -0
- package/src/internal/builtin-plugins/telemetry/task-action.ts +45 -0
- package/src/internal/cli/init/init.ts +0 -5
- package/src/internal/cli/main.ts +0 -5
- package/src/internal/cli/telemetry/analytics/analytics.ts +11 -11
- package/src/internal/cli/telemetry/analytics/types.ts +3 -3
- package/src/internal/cli/telemetry/sentry/subprocess.ts +1 -0
- package/src/internal/cli/telemetry/telemetry-permissions.ts +35 -84
- package/src/types/utils.ts +7 -0
- package/templates/01-node-test-runner-viem/package.json +2 -2
- package/templates/02-mocha-ethers/package.json +2 -2
- package/dist/src/internal/builtin-plugins/coverage/task-action.d.ts +0 -2
- package/dist/src/internal/builtin-plugins/coverage/task-action.d.ts.map +0 -1
- package/dist/src/internal/builtin-plugins/coverage/task-action.js +0 -5
- package/dist/src/internal/builtin-plugins/coverage/task-action.js.map +0 -1
- package/dist/src/internal/cli/prompt/prompt.d.ts +0 -9
- package/dist/src/internal/cli/prompt/prompt.d.ts.map +0 -1
- package/dist/src/internal/cli/prompt/prompt.js +0 -43
- package/dist/src/internal/cli/prompt/prompt.js.map +0 -1
- package/src/internal/builtin-plugins/coverage/task-action.ts +0 -9
- package/src/internal/cli/prompt/prompt.ts +0 -53
|
@@ -18,6 +18,7 @@ import type {
|
|
|
18
18
|
HttpNetworkConfig,
|
|
19
19
|
HttpNetworkUserConfig,
|
|
20
20
|
} from "../../../types/config.js";
|
|
21
|
+
import type { ChainType } from "../../../types/network.js";
|
|
21
22
|
|
|
22
23
|
import path from "node:path";
|
|
23
24
|
|
|
@@ -26,12 +27,22 @@ import {
|
|
|
26
27
|
normalizeHexString,
|
|
27
28
|
} from "@nomicfoundation/hardhat-utils/hex";
|
|
28
29
|
|
|
30
|
+
import {
|
|
31
|
+
L1_CHAIN_TYPE,
|
|
32
|
+
OPTIMISM_CHAIN_TYPE,
|
|
33
|
+
GENERIC_CHAIN_TYPE,
|
|
34
|
+
} from "../../constants.js";
|
|
35
|
+
|
|
29
36
|
import { DEFAULT_HD_ACCOUNTS_CONFIG_PARAMS } from "./accounts/constants.js";
|
|
30
37
|
import {
|
|
31
38
|
DEFAULT_EDR_NETWORK_HD_ACCOUNTS_CONFIG_PARAMS,
|
|
32
39
|
EDR_NETWORK_DEFAULT_COINBASE,
|
|
33
40
|
} from "./edr/edr-provider.js";
|
|
34
|
-
import {
|
|
41
|
+
import {
|
|
42
|
+
getCurrentHardfork,
|
|
43
|
+
L1HardforkName,
|
|
44
|
+
OpHardforkName,
|
|
45
|
+
} from "./edr/types/hardfork.js";
|
|
35
46
|
import { isHttpNetworkHdAccountsUserConfig } from "./type-validation.js";
|
|
36
47
|
|
|
37
48
|
export function resolveHttpNetwork(
|
|
@@ -90,6 +101,7 @@ export function resolveEdrNetwork(
|
|
|
90
101
|
),
|
|
91
102
|
hardfork: resolveHardfork(
|
|
92
103
|
networkConfig.hardfork,
|
|
104
|
+
networkConfig.chainType,
|
|
93
105
|
networkConfig.enableTransientStorage,
|
|
94
106
|
),
|
|
95
107
|
initialBaseFeePerGas: resolveInitialBaseFeePerGas(
|
|
@@ -219,117 +231,116 @@ export function resolveCoinbase(
|
|
|
219
231
|
export function resolveChains(
|
|
220
232
|
chains: EdrNetworkChainsUserConfig | undefined,
|
|
221
233
|
): EdrNetworkChainsConfig {
|
|
234
|
+
/**
|
|
235
|
+
* Block numbers / timestamps were taken from:
|
|
236
|
+
*
|
|
237
|
+
* L1 / Generic:
|
|
238
|
+
* https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/common/src/chains.ts
|
|
239
|
+
* Op:
|
|
240
|
+
* https://github.com/ethereum-optimism/superchain-registry/tree/main/superchain/configs/mainnet
|
|
241
|
+
*
|
|
242
|
+
* To find hardfork activation blocks by timestamp, use:
|
|
243
|
+
* https://api-TESTNET.etherscan.io/api?module=block&action=getblocknobytime×tamp=TIMESTAMP&closest=before&apikey=APIKEY
|
|
244
|
+
*/
|
|
222
245
|
const resolvedChains: EdrNetworkChainsConfig = new Map([
|
|
223
246
|
[
|
|
224
|
-
// block numbers below were taken from https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/common/src/chains
|
|
225
247
|
1, // mainnet
|
|
226
248
|
{
|
|
249
|
+
chainType: L1_CHAIN_TYPE,
|
|
227
250
|
hardforkHistory: new Map([
|
|
228
|
-
[
|
|
229
|
-
[
|
|
230
|
-
[
|
|
231
|
-
[
|
|
232
|
-
[
|
|
233
|
-
[
|
|
234
|
-
[
|
|
235
|
-
[
|
|
236
|
-
[
|
|
237
|
-
[
|
|
238
|
-
[
|
|
239
|
-
[
|
|
240
|
-
[
|
|
241
|
-
[
|
|
242
|
-
[
|
|
243
|
-
[
|
|
244
|
-
[
|
|
251
|
+
[L1HardforkName.FRONTIER, 0],
|
|
252
|
+
[L1HardforkName.HOMESTEAD, 1_150_000],
|
|
253
|
+
[L1HardforkName.DAO, 1_920_000],
|
|
254
|
+
[L1HardforkName.TANGERINE_WHISTLE, 2_463_000],
|
|
255
|
+
[L1HardforkName.SPURIOUS_DRAGON, 2_675_000],
|
|
256
|
+
[L1HardforkName.BYZANTIUM, 4_370_000],
|
|
257
|
+
[L1HardforkName.CONSTANTINOPLE, 7_280_000],
|
|
258
|
+
[L1HardforkName.PETERSBURG, 7_280_000],
|
|
259
|
+
[L1HardforkName.ISTANBUL, 9_069_000],
|
|
260
|
+
[L1HardforkName.MUIR_GLACIER, 9_200_000],
|
|
261
|
+
[L1HardforkName.BERLIN, 1_2244_000],
|
|
262
|
+
[L1HardforkName.LONDON, 12_965_000],
|
|
263
|
+
[L1HardforkName.ARROW_GLACIER, 13_773_000],
|
|
264
|
+
[L1HardforkName.GRAY_GLACIER, 15_050_000],
|
|
265
|
+
[L1HardforkName.MERGE, 15_537_394],
|
|
266
|
+
[L1HardforkName.SHANGHAI, 17_034_870],
|
|
267
|
+
[L1HardforkName.CANCUN, 19_426_589],
|
|
245
268
|
]),
|
|
246
269
|
},
|
|
247
270
|
],
|
|
248
271
|
[
|
|
249
|
-
|
|
272
|
+
5, // goerli
|
|
250
273
|
{
|
|
274
|
+
chainType: L1_CHAIN_TYPE,
|
|
251
275
|
hardforkHistory: new Map([
|
|
252
|
-
[
|
|
253
|
-
[
|
|
254
|
-
[
|
|
255
|
-
[HardforkName.ISTANBUL, 6485846],
|
|
256
|
-
[HardforkName.MUIR_GLACIER, 7117117],
|
|
257
|
-
[HardforkName.BERLIN, 9812189],
|
|
258
|
-
[HardforkName.LONDON, 10499401],
|
|
276
|
+
[L1HardforkName.ISTANBUL, 1_561_651],
|
|
277
|
+
[L1HardforkName.BERLIN, 4_460_644],
|
|
278
|
+
[L1HardforkName.LONDON, 5_062_605],
|
|
259
279
|
]),
|
|
260
280
|
},
|
|
261
281
|
],
|
|
262
282
|
[
|
|
263
|
-
|
|
283
|
+
17000, // holesky
|
|
264
284
|
{
|
|
285
|
+
chainType: L1_CHAIN_TYPE,
|
|
265
286
|
hardforkHistory: new Map([
|
|
266
|
-
[
|
|
267
|
-
[
|
|
268
|
-
[
|
|
269
|
-
[HardforkName.ISTANBUL, 5435345],
|
|
270
|
-
[HardforkName.BERLIN, 8290928],
|
|
271
|
-
[HardforkName.LONDON, 8897988],
|
|
287
|
+
[L1HardforkName.MERGE, 0],
|
|
288
|
+
[L1HardforkName.SHANGHAI, 6_698],
|
|
289
|
+
[L1HardforkName.CANCUN, 894_732],
|
|
272
290
|
]),
|
|
273
291
|
},
|
|
274
292
|
],
|
|
275
293
|
[
|
|
276
|
-
|
|
294
|
+
560048, // hoodi
|
|
277
295
|
{
|
|
296
|
+
chainType: L1_CHAIN_TYPE,
|
|
278
297
|
hardforkHistory: new Map([
|
|
279
|
-
[
|
|
280
|
-
[
|
|
281
|
-
[
|
|
298
|
+
[L1HardforkName.MERGE, 0],
|
|
299
|
+
[L1HardforkName.SHANGHAI, 0],
|
|
300
|
+
[L1HardforkName.CANCUN, 0],
|
|
282
301
|
]),
|
|
283
302
|
},
|
|
284
303
|
],
|
|
285
304
|
[
|
|
286
|
-
|
|
305
|
+
11155111, // sepolia
|
|
287
306
|
{
|
|
307
|
+
chainType: L1_CHAIN_TYPE,
|
|
288
308
|
hardforkHistory: new Map([
|
|
289
|
-
[
|
|
290
|
-
[
|
|
291
|
-
[
|
|
292
|
-
[
|
|
293
|
-
[HardforkName.BERLIN, 24770900],
|
|
294
|
-
[HardforkName.LONDON, 26741100],
|
|
309
|
+
[L1HardforkName.GRAY_GLACIER, 0],
|
|
310
|
+
[L1HardforkName.MERGE, 1_450_409],
|
|
311
|
+
[L1HardforkName.SHANGHAI, 2_990_908],
|
|
312
|
+
[L1HardforkName.CANCUN, 5_187_023],
|
|
295
313
|
]),
|
|
296
314
|
},
|
|
297
315
|
],
|
|
298
316
|
[
|
|
299
|
-
|
|
317
|
+
10, // op mainnet
|
|
300
318
|
{
|
|
319
|
+
chainType: OPTIMISM_CHAIN_TYPE,
|
|
301
320
|
hardforkHistory: new Map([
|
|
302
|
-
[
|
|
303
|
-
[
|
|
304
|
-
[
|
|
305
|
-
[
|
|
321
|
+
[OpHardforkName.BEDROCK, 105_235_063],
|
|
322
|
+
[OpHardforkName.REGOLITH, 105_235_063],
|
|
323
|
+
[OpHardforkName.CANYON, 114_696_812],
|
|
324
|
+
[OpHardforkName.ECOTONE, 117_387_812],
|
|
325
|
+
[OpHardforkName.FJORD, 122_514_212],
|
|
326
|
+
[OpHardforkName.GRANITE, 125_235_812],
|
|
327
|
+
[OpHardforkName.HOLOCENE, 130_423_412],
|
|
306
328
|
]),
|
|
307
329
|
},
|
|
308
330
|
],
|
|
309
|
-
// TODO: the rest of this config is a temporary workaround,
|
|
310
|
-
// see https://github.com/NomicFoundation/edr/issues/522
|
|
311
|
-
[
|
|
312
|
-
10, // optimism mainnet
|
|
313
|
-
{
|
|
314
|
-
hardforkHistory: new Map([[HardforkName.SHANGHAI, 0]]),
|
|
315
|
-
},
|
|
316
|
-
],
|
|
317
331
|
[
|
|
318
|
-
11155420, //
|
|
332
|
+
11155420, // op sepolia
|
|
319
333
|
{
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
421614, // arbitrum sepolia
|
|
331
|
-
{
|
|
332
|
-
hardforkHistory: new Map([[HardforkName.SHANGHAI, 0]]),
|
|
334
|
+
chainType: OPTIMISM_CHAIN_TYPE,
|
|
335
|
+
hardforkHistory: new Map([
|
|
336
|
+
[OpHardforkName.BEDROCK, 0],
|
|
337
|
+
[OpHardforkName.REGOLITH, 0],
|
|
338
|
+
[OpHardforkName.CANYON, 4_089_330],
|
|
339
|
+
[OpHardforkName.ECOTONE, 8_366_130],
|
|
340
|
+
[OpHardforkName.FJORD, 12_597_930],
|
|
341
|
+
[OpHardforkName.GRANITE, 15_837_930],
|
|
342
|
+
[OpHardforkName.HOLOCENE, 20_415_330],
|
|
343
|
+
]),
|
|
333
344
|
},
|
|
334
345
|
],
|
|
335
346
|
]);
|
|
@@ -340,6 +351,7 @@ export function resolveChains(
|
|
|
340
351
|
|
|
341
352
|
chains.forEach((chainConfig, chainId) => {
|
|
342
353
|
const resolvedChainConfig: EdrNetworkChainConfig = {
|
|
354
|
+
chainType: chainConfig.chainType ?? GENERIC_CHAIN_TYPE,
|
|
343
355
|
hardforkHistory: new Map(),
|
|
344
356
|
};
|
|
345
357
|
if (chainConfig.hardforkHistory !== undefined) {
|
|
@@ -355,13 +367,14 @@ export function resolveChains(
|
|
|
355
367
|
|
|
356
368
|
export function resolveHardfork(
|
|
357
369
|
hardfork: string | undefined,
|
|
370
|
+
chainType: ChainType | undefined = GENERIC_CHAIN_TYPE,
|
|
358
371
|
_enableTransientStorage: boolean | undefined,
|
|
359
372
|
): string {
|
|
360
373
|
if (hardfork !== undefined) {
|
|
361
374
|
return hardfork;
|
|
362
375
|
}
|
|
363
376
|
|
|
364
|
-
return
|
|
377
|
+
return getCurrentHardfork(chainType);
|
|
365
378
|
}
|
|
366
379
|
|
|
367
380
|
export function resolveInitialBaseFeePerGas(
|
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
genericChainProviderFactory,
|
|
5
5
|
L1_CHAIN_TYPE,
|
|
6
6
|
l1ProviderFactory,
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
OP_CHAIN_TYPE,
|
|
8
|
+
opProviderFactory,
|
|
9
9
|
} from "@ignored/edr-optimism";
|
|
10
10
|
|
|
11
11
|
let _globalEdrContext: EdrContext | undefined;
|
|
@@ -22,8 +22,8 @@ export async function getGlobalEdrContext(): Promise<EdrContext> {
|
|
|
22
22
|
l1ProviderFactory(),
|
|
23
23
|
);
|
|
24
24
|
await _globalEdrContext.registerProviderFactory(
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
OP_CHAIN_TYPE,
|
|
26
|
+
opProviderFactory(),
|
|
27
27
|
);
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -11,6 +11,7 @@ import type {
|
|
|
11
11
|
RequestArguments,
|
|
12
12
|
SuccessfulJsonRpcResponse,
|
|
13
13
|
} from "../../../../types/providers.js";
|
|
14
|
+
import type { RequireField } from "../../../../types/utils.js";
|
|
14
15
|
import type { DefaultHDAccountsConfigParams } from "../accounts/constants.js";
|
|
15
16
|
import type { JsonRpcRequestWrapperFunction } from "../network-manager.js";
|
|
16
17
|
import type {
|
|
@@ -22,8 +23,8 @@ import type {
|
|
|
22
23
|
} from "@ignored/edr-optimism";
|
|
23
24
|
|
|
24
25
|
import {
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
opGenesisState,
|
|
27
|
+
opHardforkFromString,
|
|
27
28
|
l1GenesisState,
|
|
28
29
|
l1HardforkFromString,
|
|
29
30
|
} from "@ignored/edr-optimism";
|
|
@@ -125,7 +126,7 @@ export const EDR_NETWORK_DEFAULT_PRIVATE_KEYS: string[] = [
|
|
|
125
126
|
];
|
|
126
127
|
|
|
127
128
|
interface EdrProviderConfig {
|
|
128
|
-
networkConfig: EdrNetworkConfig
|
|
129
|
+
networkConfig: RequireField<EdrNetworkConfig, "chainType">;
|
|
129
130
|
loggerConfig?: LoggerConfig;
|
|
130
131
|
tracingConfig?: TracingConfigWithBuffers;
|
|
131
132
|
jsonRpcRequestWrapper?: JsonRpcRequestWrapperFunction;
|
|
@@ -382,23 +383,19 @@ export class EdrProvider extends BaseProvider {
|
|
|
382
383
|
}
|
|
383
384
|
|
|
384
385
|
async function getProviderConfig(
|
|
385
|
-
networkConfig: EdrNetworkConfig,
|
|
386
|
+
networkConfig: RequireField<EdrNetworkConfig, "chainType">,
|
|
386
387
|
): Promise<ProviderConfig> {
|
|
388
|
+
const specId = hardhatHardforkToEdrSpecId(
|
|
389
|
+
networkConfig.hardfork,
|
|
390
|
+
networkConfig.chainType,
|
|
391
|
+
);
|
|
392
|
+
|
|
387
393
|
const genesisState =
|
|
388
394
|
networkConfig.forking !== undefined
|
|
389
395
|
? [] // TODO: Add support for overriding remote fork state when the local fork is different
|
|
390
396
|
: networkConfig.chainType === "optimism"
|
|
391
|
-
?
|
|
392
|
-
|
|
393
|
-
// TODO: Optimism conversion is not implemented yet
|
|
394
|
-
hardhatHardforkToEdrSpecId(networkConfig.hardfork),
|
|
395
|
-
),
|
|
396
|
-
)
|
|
397
|
-
: l1GenesisState(
|
|
398
|
-
l1HardforkFromString(
|
|
399
|
-
hardhatHardforkToEdrSpecId(networkConfig.hardfork),
|
|
400
|
-
),
|
|
401
|
-
);
|
|
397
|
+
? opGenesisState(opHardforkFromString(specId))
|
|
398
|
+
: l1GenesisState(l1HardforkFromString(specId));
|
|
402
399
|
|
|
403
400
|
return {
|
|
404
401
|
allowBlocksWithSameTimestamp: networkConfig.allowBlocksWithSameTimestamp,
|
|
@@ -408,13 +405,16 @@ async function getProviderConfig(
|
|
|
408
405
|
blockGasLimit: networkConfig.blockGasLimit,
|
|
409
406
|
cacheDir: networkConfig.forking?.cacheDir,
|
|
410
407
|
chainId: BigInt(networkConfig.chainId),
|
|
411
|
-
chains: hardhatChainsToEdrChains(
|
|
408
|
+
chains: hardhatChainsToEdrChains(
|
|
409
|
+
networkConfig.chains,
|
|
410
|
+
networkConfig.chainType,
|
|
411
|
+
),
|
|
412
412
|
// TODO: remove this cast when EDR updates the interface to accept Uint8Array
|
|
413
413
|
coinbase: Buffer.from(networkConfig.coinbase),
|
|
414
414
|
enableRip7212: networkConfig.enableRip7212,
|
|
415
415
|
fork: await hardhatForkingConfigToEdrForkConfig(networkConfig.forking),
|
|
416
416
|
genesisState,
|
|
417
|
-
hardfork:
|
|
417
|
+
hardfork: specId,
|
|
418
418
|
initialBaseFeePerGas: networkConfig.initialBaseFeePerGas,
|
|
419
419
|
initialDate: BigInt(toSeconds(networkConfig.initialDate)),
|
|
420
420
|
minGasPrice: networkConfig.minGasPrice,
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ChainType } from "../../../../../types/network.js";
|
|
2
|
+
|
|
3
|
+
import { OPTIMISM_CHAIN_TYPE } from "../../../../constants.js";
|
|
4
|
+
|
|
5
|
+
export enum L1HardforkName {
|
|
2
6
|
FRONTIER = "chainstart",
|
|
3
7
|
HOMESTEAD = "homestead",
|
|
4
8
|
DAO = "dao",
|
|
@@ -18,21 +22,84 @@ export enum HardforkName {
|
|
|
18
22
|
CANCUN = "cancun",
|
|
19
23
|
}
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
export enum OpHardforkName {
|
|
26
|
+
BEDROCK = "bedrock",
|
|
27
|
+
REGOLITH = "regolith",
|
|
28
|
+
CANYON = "canyon",
|
|
29
|
+
ECOTONE = "ecotone",
|
|
30
|
+
FJORD = "fjord",
|
|
31
|
+
GRANITE = "granite",
|
|
32
|
+
HOLOCENE = "holocene",
|
|
33
|
+
}
|
|
22
34
|
|
|
23
|
-
|
|
24
|
-
|
|
35
|
+
const L1_HARDFORK_ORDER = Object.values(L1HardforkName);
|
|
36
|
+
const OP_HARDFORK_ORDER = Object.values(OpHardforkName);
|
|
37
|
+
|
|
38
|
+
export function getHardforks(chainType: ChainType): string[] {
|
|
39
|
+
return chainType === OPTIMISM_CHAIN_TYPE
|
|
40
|
+
? OP_HARDFORK_ORDER
|
|
41
|
+
: L1_HARDFORK_ORDER;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const L1_LATEST_HARDFORK: L1HardforkName =
|
|
45
|
+
L1_HARDFORK_ORDER[L1_HARDFORK_ORDER.length - 1];
|
|
46
|
+
const OP_LATEST_HARDFORK: OpHardforkName =
|
|
47
|
+
OP_HARDFORK_ORDER[OP_HARDFORK_ORDER.length - 1];
|
|
48
|
+
|
|
49
|
+
export function getCurrentHardfork(chainType: ChainType): string {
|
|
50
|
+
return chainType === OPTIMISM_CHAIN_TYPE
|
|
51
|
+
? OP_LATEST_HARDFORK
|
|
52
|
+
: L1_LATEST_HARDFORK;
|
|
53
|
+
}
|
|
25
54
|
|
|
26
55
|
/**
|
|
27
56
|
* Check if `hardforkA` is greater than or equal to `hardforkB`,
|
|
28
57
|
* that is, if it includes all its changes.
|
|
58
|
+
*
|
|
59
|
+
* This function is not type-safe, as it accepts any string as hardfork name.
|
|
60
|
+
* It is the caller's responsibility to ensure that the hardfork names are valid.
|
|
29
61
|
*/
|
|
30
62
|
export function hardforkGte(
|
|
31
|
-
hardforkA:
|
|
32
|
-
hardforkB:
|
|
63
|
+
hardforkA: string,
|
|
64
|
+
hardforkB: string,
|
|
65
|
+
chainType: ChainType,
|
|
33
66
|
): boolean {
|
|
34
|
-
|
|
35
|
-
|
|
67
|
+
return chainType === OPTIMISM_CHAIN_TYPE
|
|
68
|
+
? opHardforkGte(hardforkA, hardforkB)
|
|
69
|
+
: l1HardforkGte(hardforkA, hardforkB);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function opHardforkGte(hardforkA: string, hardforkB: string): boolean {
|
|
73
|
+
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
74
|
+
-- Cast is safe, as the function is only called with valid hardfork names. */
|
|
75
|
+
const indexA = OP_HARDFORK_ORDER.indexOf(hardforkA as OpHardforkName);
|
|
76
|
+
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
77
|
+
-- Cast is safe, as the function is only called with valid hardfork names. */
|
|
78
|
+
const indexB = OP_HARDFORK_ORDER.indexOf(hardforkB as OpHardforkName);
|
|
79
|
+
|
|
80
|
+
return indexA >= indexB;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function l1HardforkGte(hardforkA: string, hardforkB: string): boolean {
|
|
84
|
+
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
85
|
+
-- Cast is safe, as the function is only called with valid hardfork names. */
|
|
86
|
+
const indexA = L1_HARDFORK_ORDER.indexOf(hardforkA as L1HardforkName);
|
|
87
|
+
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
88
|
+
-- Cast is safe, as the function is only called with valid hardfork names. */
|
|
89
|
+
const indexB = L1_HARDFORK_ORDER.indexOf(hardforkB as L1HardforkName);
|
|
36
90
|
|
|
37
91
|
return indexA >= indexB;
|
|
38
92
|
}
|
|
93
|
+
|
|
94
|
+
export function isValidHardforkName(
|
|
95
|
+
hardfork: string,
|
|
96
|
+
chainType: ChainType,
|
|
97
|
+
): boolean {
|
|
98
|
+
return chainType === OPTIMISM_CHAIN_TYPE
|
|
99
|
+
? /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
100
|
+
-- Cast is safe, as we're validating the hardfork name. */
|
|
101
|
+
OP_HARDFORK_ORDER.includes(hardfork as OpHardforkName)
|
|
102
|
+
: /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
103
|
+
-- Cast is safe, as we're validating the hardfork name. */
|
|
104
|
+
L1_HARDFORK_ORDER.includes(hardfork as L1HardforkName);
|
|
105
|
+
}
|