@@ -27,8 +27,8 @@ import {
27
27
DEFAULT_EDR_NETWORK_HD_ACCOUNTS_CONFIG_PARAMS ,
28
28
EDR_NETWORK_DEFAULT_COINBASE ,
29
29
} from "./edr/edr-provider.js" ;
30
- import { HardforkName } from "./edr/types/hardfork.js" ;
31
- import { isHdAccountsConfig } from "./type-validation.js" ;
30
+ import { HardforkName , LATEST_HARDFORK } from "./edr/types/hardfork.js" ;
31
+ import { isHdAccountsUserConfig } from "./type-validation.js" ;
32
32
33
33
export function resolveGasConfig ( value : GasUserConfig = "auto" ) : GasConfig {
34
34
return value === "auto" ? value : BigInt ( value ) ;
@@ -48,10 +48,16 @@ export function resolveHttpNetworkAccounts(
48
48
} ) ;
49
49
}
50
50
51
- if ( isHdAccountsConfig ( accounts ) ) {
51
+ if ( isHdAccountsUserConfig ( accounts ) ) {
52
+ const { passphrase : defaultPassphrase , ...defaultHdAccountRest } =
53
+ DEFAULT_HD_ACCOUNTS_CONFIG_PARAMS ;
54
+ const { mnemonic, passphrase, ...hdAccountRest } = accounts ;
55
+
52
56
return {
53
- ...DEFAULT_HD_ACCOUNTS_CONFIG_PARAMS ,
54
- ...accounts ,
57
+ ...defaultHdAccountRest ,
58
+ ...hdAccountRest ,
59
+ mnemonic : resolveConfigurationVariable ( mnemonic ) ,
60
+ passphrase : resolveConfigurationVariable ( passphrase ?? defaultPassphrase ) ,
55
61
} ;
56
62
}
57
63
@@ -62,27 +68,41 @@ export function resolveEdrNetworkAccounts(
62
68
accounts :
63
69
| EdrNetworkAccountsUserConfig
64
70
| undefined = DEFAULT_EDR_NETWORK_HD_ACCOUNTS_CONFIG_PARAMS ,
71
+ resolveConfigurationVariable : ConfigurationResolver ,
65
72
) : EdrNetworkAccountsConfig {
66
73
if ( Array . isArray ( accounts ) ) {
67
- return accounts . map ( ( { privateKey, balance } ) => ( {
68
- privateKey : normalizeHexString ( privateKey ) ,
69
- balance : BigInt ( balance ) ,
70
- } ) ) ;
74
+ return accounts . map ( ( { privateKey, balance } ) => {
75
+ if ( typeof privateKey === "string" ) {
76
+ privateKey = normalizeHexString ( privateKey ) ;
77
+ }
78
+
79
+ return {
80
+ privateKey : resolveConfigurationVariable ( privateKey ) ,
81
+ balance : BigInt ( balance ) ,
82
+ } ;
83
+ } ) ;
71
84
}
72
85
86
+ const {
87
+ mnemonic : defaultMnemonic ,
88
+ accountsBalance : defaultAccountsBalance ,
89
+ passphrase : defaultPassphrase ,
90
+ ...defaultHdAccountRest
91
+ } = DEFAULT_EDR_NETWORK_HD_ACCOUNTS_CONFIG_PARAMS ;
92
+ const { mnemonic, passphrase, accountsBalance, ...hdAccountRest } = accounts ;
73
93
return {
74
- ...DEFAULT_EDR_NETWORK_HD_ACCOUNTS_CONFIG_PARAMS ,
75
- ...accounts ,
76
- accountsBalance : BigInt (
77
- accounts . accountsBalance ??
78
- DEFAULT_EDR_NETWORK_HD_ACCOUNTS_CONFIG_PARAMS . accountsBalance ,
79
- ) ,
94
+ ...defaultHdAccountRest ,
95
+ ...hdAccountRest ,
96
+ mnemonic : resolveConfigurationVariable ( mnemonic ?? defaultMnemonic ) ,
97
+ accountsBalance : BigInt ( accountsBalance ?? defaultAccountsBalance ) ,
98
+ passphrase : resolveConfigurationVariable ( passphrase ?? defaultPassphrase ) ,
80
99
} ;
81
100
}
82
101
83
102
export function resolveForkingConfig (
84
103
forkingUserConfig : EdrNetworkForkingUserConfig | undefined ,
85
104
cacheDir : string ,
105
+ resolveConfigurationVariable : ConfigurationResolver ,
86
106
) : EdrNetworkForkingConfig | undefined {
87
107
if ( forkingUserConfig === undefined ) {
88
108
return undefined ;
@@ -98,7 +118,7 @@ export function resolveForkingConfig(
98
118
99
119
return {
100
120
enabled : forkingUserConfig . enabled ?? true ,
101
- url : forkingUserConfig . url ,
121
+ url : resolveConfigurationVariable ( forkingUserConfig . url ) ,
102
122
cacheDir : path . join ( cacheDir , "edr-fork-cache" ) ,
103
123
blockNumber :
104
124
forkingUserConfig . blockNumber !== undefined
@@ -274,7 +294,7 @@ export function resolveHardfork(
274
294
}
275
295
276
296
if ( enableTransientStorage === true ) {
277
- return HardforkName . CANCUN ;
297
+ return LATEST_HARDFORK ;
278
298
} else {
279
299
return HardforkName . SHANGHAI ;
280
300
}
0 commit comments