rocketh 0.15.0-testing.9 → 0.15.1
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 +80 -0
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/environment/index.d.ts.map +1 -1
- package/dist/environment/index.js +27 -21
- package/dist/environment/index.js.map +1 -1
- package/dist/environment/utils/chains.d.ts +3 -1
- package/dist/environment/utils/chains.d.ts.map +1 -1
- package/dist/environment/utils/chains.js +3 -3
- package/dist/environment/utils/chains.js.map +1 -1
- package/dist/executor/index.d.ts +2 -3
- package/dist/executor/index.d.ts.map +1 -1
- package/dist/executor/index.js +56 -43
- package/dist/executor/index.js.map +1 -1
- package/dist/executor/setup.test.js +1 -1
- package/dist/executor/setup.test.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +36 -33
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/cli.ts +1 -1
- package/src/environment/index.ts +35 -22
- package/src/environment/utils/chains.ts +4 -4
- package/src/executor/index.ts +57 -44
- package/src/executor/setup.test.ts +1 -1
- package/src/index.ts +3 -2
- package/src/types.ts +34 -31
package/src/executor/index.ts
CHANGED
|
@@ -221,15 +221,27 @@ export async function readAndResolveConfig<
|
|
|
221
221
|
return resolveConfig(configFile, overrides);
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
export async function
|
|
224
|
+
export async function getChainIdForEnvironment(
|
|
225
225
|
config: ResolvedUserConfig,
|
|
226
|
-
|
|
226
|
+
environmentName: string,
|
|
227
227
|
provider?: EIP1193ProviderWithoutEvents
|
|
228
228
|
) {
|
|
229
|
-
if (config?.
|
|
230
|
-
|
|
229
|
+
if (config?.environments?.[environmentName]?.chain) {
|
|
230
|
+
const chainAsNumber =
|
|
231
|
+
typeof config.environments[environmentName].chain === 'number'
|
|
232
|
+
? config.environments[environmentName].chain
|
|
233
|
+
: parseInt(config.environments[environmentName].chain);
|
|
234
|
+
if (!isNaN(chainAsNumber)) {
|
|
235
|
+
return chainAsNumber;
|
|
236
|
+
}
|
|
237
|
+
const chainFound = getChainByName(config.environments[environmentName].chain as string);
|
|
238
|
+
if (chainFound) {
|
|
239
|
+
return chainFound.id;
|
|
240
|
+
} else {
|
|
241
|
+
throw new Error(`environment ${environmentName} chain id cannot be found, specify it in the rocketh config`);
|
|
242
|
+
}
|
|
231
243
|
} else {
|
|
232
|
-
const chainFound = getChainByName(
|
|
244
|
+
const chainFound = getChainByName(environmentName);
|
|
233
245
|
if (chainFound) {
|
|
234
246
|
return chainFound.id;
|
|
235
247
|
} else {
|
|
@@ -237,24 +249,24 @@ export async function getChainIdForTarget(
|
|
|
237
249
|
const chainIdAsHex = await provider.request({method: 'eth_chainId'});
|
|
238
250
|
return Number(chainIdAsHex);
|
|
239
251
|
} else {
|
|
240
|
-
throw new Error(`
|
|
252
|
+
throw new Error(`environment ${environmentName} chain id cannot be found, specify it in the rocketh config`);
|
|
241
253
|
}
|
|
242
254
|
}
|
|
243
255
|
}
|
|
244
256
|
}
|
|
245
257
|
|
|
246
|
-
function
|
|
247
|
-
const
|
|
248
|
-
let
|
|
249
|
-
if (
|
|
250
|
-
if (typeof
|
|
251
|
-
|
|
252
|
-
} else if ('fork' in
|
|
253
|
-
|
|
258
|
+
function getEnvironmentName(executionParams: ExecutionParams): {name: string; fork: boolean} {
|
|
259
|
+
const environmentProvided = executionParams.environment || (executionParams as any).network;
|
|
260
|
+
let environmentName = 'memory';
|
|
261
|
+
if (environmentProvided) {
|
|
262
|
+
if (typeof environmentProvided === 'string') {
|
|
263
|
+
environmentName = environmentProvided;
|
|
264
|
+
} else if ('fork' in environmentProvided) {
|
|
265
|
+
environmentName = environmentProvided.fork;
|
|
254
266
|
}
|
|
255
267
|
}
|
|
256
|
-
const fork = typeof
|
|
257
|
-
return {name:
|
|
268
|
+
const fork = typeof environmentProvided !== 'string';
|
|
269
|
+
return {name: environmentName, fork};
|
|
258
270
|
}
|
|
259
271
|
|
|
260
272
|
export function resolveExecutionParams<Extra extends Record<string, unknown> = Record<string, unknown>>(
|
|
@@ -262,19 +274,20 @@ export function resolveExecutionParams<Extra extends Record<string, unknown> = R
|
|
|
262
274
|
executionParameters: ExecutionParams<Extra>,
|
|
263
275
|
chainId: number
|
|
264
276
|
): ResolvedExecutionParams<Extra> {
|
|
265
|
-
const {name:
|
|
277
|
+
const {name: environmentName, fork} = getEnvironmentName(executionParameters);
|
|
266
278
|
|
|
267
|
-
|
|
279
|
+
// TODO fork chainId resolution option to keep the network being used
|
|
280
|
+
let chainConfig: ChainConfig = getChainConfig(fork ? 31337 : chainId, config);
|
|
268
281
|
|
|
269
282
|
let chainInfo = chainConfig.info;
|
|
270
|
-
const
|
|
271
|
-
const actualChainConfig =
|
|
283
|
+
const environmentConfig = config?.environments?.[environmentName];
|
|
284
|
+
const actualChainConfig = environmentConfig?.overrides
|
|
272
285
|
? {
|
|
273
286
|
...chainConfig,
|
|
274
|
-
...
|
|
287
|
+
...environmentConfig.overrides,
|
|
275
288
|
properties: {
|
|
276
289
|
...chainConfig?.properties,
|
|
277
|
-
...
|
|
290
|
+
...environmentConfig.overrides.properties,
|
|
278
291
|
},
|
|
279
292
|
}
|
|
280
293
|
: chainConfig;
|
|
@@ -283,23 +296,23 @@ export function resolveExecutionParams<Extra extends Record<string, unknown> = R
|
|
|
283
296
|
chainInfo = {...chainInfo, properties: actualChainConfig.properties};
|
|
284
297
|
}
|
|
285
298
|
|
|
286
|
-
// let
|
|
287
|
-
const
|
|
299
|
+
// let environmentTags: string[] = actualChainConfig.tags.concat(environmentConfig?.tags); // TODO
|
|
300
|
+
const environmentTags = actualChainConfig.tags;
|
|
288
301
|
|
|
289
302
|
let scripts = ['deploy'];
|
|
290
303
|
if (config.scripts) {
|
|
291
304
|
if (typeof config.scripts === 'string') {
|
|
292
305
|
scripts = [config.scripts];
|
|
293
306
|
} else {
|
|
294
|
-
scripts = config.scripts;
|
|
307
|
+
scripts = [...config.scripts];
|
|
295
308
|
}
|
|
296
309
|
}
|
|
297
310
|
|
|
298
|
-
if (
|
|
299
|
-
if (typeof
|
|
300
|
-
scripts = [
|
|
311
|
+
if (environmentConfig?.scripts) {
|
|
312
|
+
if (typeof environmentConfig.scripts === 'string') {
|
|
313
|
+
scripts = [environmentConfig.scripts];
|
|
301
314
|
} else {
|
|
302
|
-
scripts =
|
|
315
|
+
scripts = [...environmentConfig.scripts];
|
|
303
316
|
}
|
|
304
317
|
}
|
|
305
318
|
|
|
@@ -312,7 +325,7 @@ export function resolveExecutionParams<Extra extends Record<string, unknown> = R
|
|
|
312
325
|
if (!executionParameters.provider) {
|
|
313
326
|
saveDeployments = true;
|
|
314
327
|
} else {
|
|
315
|
-
if (
|
|
328
|
+
if (environmentName === 'memory' || environmentName === 'hardhat' || environmentName === 'default') {
|
|
316
329
|
// networkTags['memory'] = true;
|
|
317
330
|
saveDeployments = false;
|
|
318
331
|
} else {
|
|
@@ -329,9 +342,9 @@ export function resolveExecutionParams<Extra extends Record<string, unknown> = R
|
|
|
329
342
|
reportGasUse: executionParameters.reportGasUse || false,
|
|
330
343
|
saveDeployments,
|
|
331
344
|
tags: executionParameters.tags || [],
|
|
332
|
-
|
|
333
|
-
name:
|
|
334
|
-
tags:
|
|
345
|
+
environment: {
|
|
346
|
+
name: environmentName,
|
|
347
|
+
tags: environmentTags,
|
|
335
348
|
fork,
|
|
336
349
|
deterministicDeployment: actualChainConfig.deterministicDeployment,
|
|
337
350
|
},
|
|
@@ -347,8 +360,8 @@ export async function loadEnvironment<
|
|
|
347
360
|
Extra extends Record<string, unknown> = Record<string, unknown>
|
|
348
361
|
>(executionParams: ExecutionParams<Extra>): Promise<Environment<NamedAccounts, Data, UnknownDeployments>> {
|
|
349
362
|
const userConfig = await readAndResolveConfig<NamedAccounts, Data>(executionParams.config);
|
|
350
|
-
const {name:
|
|
351
|
-
const chainId = await
|
|
363
|
+
const {name: environmentName, fork} = getEnvironmentName(executionParams);
|
|
364
|
+
const chainId = await getChainIdForEnvironment(userConfig, environmentName, executionParams.provider);
|
|
352
365
|
const resolvedExecutionParams = resolveExecutionParams(userConfig, executionParams, chainId);
|
|
353
366
|
// console.log(JSON.stringify(resolvedConfig, null, 2));
|
|
354
367
|
const {external, internal} = await createEnvironment<NamedAccounts, Data, UnknownDeployments>(
|
|
@@ -368,15 +381,15 @@ export async function loadAndExecuteDeployments<
|
|
|
368
381
|
args?: ArgumentsType
|
|
369
382
|
): Promise<Environment<NamedAccounts, Data, UnknownDeployments>> {
|
|
370
383
|
const userConfig = await readAndResolveConfig<NamedAccounts, Data>(executionParams.config);
|
|
371
|
-
const {name:
|
|
372
|
-
const chainId = await
|
|
384
|
+
const {name: environmentName, fork} = getEnvironmentName(executionParams);
|
|
385
|
+
const chainId = await getChainIdForEnvironment(userConfig, environmentName, executionParams.provider);
|
|
373
386
|
const resolvedExecutionParams = resolveExecutionParams(userConfig, executionParams, chainId);
|
|
374
387
|
// console.log(JSON.stringify(options, null, 2));
|
|
375
388
|
// console.log(JSON.stringify(resolvedConfig, null, 2));
|
|
376
|
-
return
|
|
389
|
+
return _executeDeployScripts<NamedAccounts, Data, ArgumentsType>(userConfig, resolvedExecutionParams, args);
|
|
377
390
|
}
|
|
378
391
|
|
|
379
|
-
export async function
|
|
392
|
+
export async function executeDeployScripts<
|
|
380
393
|
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
381
394
|
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData,
|
|
382
395
|
ArgumentsType = undefined,
|
|
@@ -387,14 +400,14 @@ export async function executeDeployScriptsDirectly<
|
|
|
387
400
|
args?: ArgumentsType
|
|
388
401
|
): Promise<Environment<NamedAccounts, Data, UnknownDeployments>> {
|
|
389
402
|
executionParams = executionParams || {};
|
|
390
|
-
const resolveduserConfig = resolveConfig<NamedAccounts, Data>(userConfig);
|
|
391
|
-
const {name:
|
|
392
|
-
const chainId = await
|
|
403
|
+
const resolveduserConfig = resolveConfig<NamedAccounts, Data>(userConfig, executionParams.config);
|
|
404
|
+
const {name: environmentName, fork} = getEnvironmentName(executionParams);
|
|
405
|
+
const chainId = await getChainIdForEnvironment(resolveduserConfig, environmentName, executionParams.provider);
|
|
393
406
|
const resolvedExecutionParams = resolveExecutionParams(resolveduserConfig, executionParams, chainId);
|
|
394
|
-
return
|
|
407
|
+
return _executeDeployScripts<NamedAccounts, Data, ArgumentsType>(resolveduserConfig, resolvedExecutionParams, args);
|
|
395
408
|
}
|
|
396
409
|
|
|
397
|
-
|
|
410
|
+
async function _executeDeployScripts<
|
|
398
411
|
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
399
412
|
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData,
|
|
400
413
|
ArgumentsType = undefined
|
|
@@ -134,7 +134,7 @@ export const exampleUsage = () => {
|
|
|
134
134
|
await env.verifyOnEtherscan(tokenAddress, ['MyToken', 'MTK']);
|
|
135
135
|
|
|
136
136
|
// Original environment is still fully accessible
|
|
137
|
-
console.log(`Deployed on
|
|
137
|
+
console.log(`Deployed on environment: ${env.name}`);
|
|
138
138
|
const deployment = env.get('MyToken');
|
|
139
139
|
|
|
140
140
|
return true;
|
package/src/index.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
export {
|
|
2
2
|
setup,
|
|
3
3
|
loadAndExecuteDeployments,
|
|
4
|
-
|
|
4
|
+
executeDeployScripts,
|
|
5
5
|
readAndResolveConfig,
|
|
6
6
|
enhanceEnvIfNeeded,
|
|
7
7
|
loadEnvironment,
|
|
8
8
|
} from './executor/index.js';
|
|
9
9
|
|
|
10
|
-
export {getChainConfig} from './environment/utils/chains.js';
|
|
10
|
+
export {getChainConfig, chainByCanonicalName} from './environment/utils/chains.js';
|
|
11
11
|
export * from './types.js';
|
|
12
12
|
export {loadDeployments} from './environment/deployments.js';
|
|
13
13
|
export {mergeArtifacts} from './environment/utils/artifacts.js';
|
|
14
14
|
export {getGasPriceEstimate, getRoughGasPriceEstimate} from './utils/eth.js';
|
|
15
|
+
export {bigIntToStringReplacer} from './utils/json.js';
|
package/src/types.ts
CHANGED
|
@@ -158,7 +158,7 @@ export type ChainInfo = {
|
|
|
158
158
|
/** Flag for test networks */
|
|
159
159
|
testnet?: boolean | undefined;
|
|
160
160
|
|
|
161
|
-
chainType
|
|
161
|
+
chainType?: 'zksync' | 'op-stack' | 'celo' | 'default';
|
|
162
162
|
|
|
163
163
|
genesisHash?: string;
|
|
164
164
|
|
|
@@ -223,31 +223,31 @@ export type DeterministicDeploymentInfo =
|
|
|
223
223
|
};
|
|
224
224
|
|
|
225
225
|
export type ChainUserConfig = {
|
|
226
|
-
rpcUrl?: string;
|
|
227
|
-
tags?: string[];
|
|
228
|
-
deterministicDeployment?: DeterministicDeploymentInfo;
|
|
229
|
-
info?: ChainInfo;
|
|
230
|
-
pollingInterval?: number;
|
|
231
|
-
properties?: Record<string, JSONTypePlusBigInt>;
|
|
226
|
+
readonly rpcUrl?: string;
|
|
227
|
+
readonly tags?: readonly string[];
|
|
228
|
+
readonly deterministicDeployment?: DeterministicDeploymentInfo;
|
|
229
|
+
readonly info?: ChainInfo;
|
|
230
|
+
readonly pollingInterval?: number;
|
|
231
|
+
readonly properties?: Record<string, JSONTypePlusBigInt>;
|
|
232
232
|
};
|
|
233
233
|
|
|
234
234
|
export type ChainConfig = {
|
|
235
|
-
rpcUrl: string;
|
|
236
|
-
tags: string[];
|
|
237
|
-
deterministicDeployment: DeterministicDeploymentInfo;
|
|
238
|
-
info: ChainInfo;
|
|
239
|
-
pollingInterval: number;
|
|
240
|
-
properties: Record<string, JSONTypePlusBigInt>;
|
|
235
|
+
readonly rpcUrl: string;
|
|
236
|
+
readonly tags: readonly string[];
|
|
237
|
+
readonly deterministicDeployment: DeterministicDeploymentInfo;
|
|
238
|
+
readonly info: ChainInfo;
|
|
239
|
+
readonly pollingInterval: number;
|
|
240
|
+
readonly properties: Record<string, JSONTypePlusBigInt>;
|
|
241
241
|
};
|
|
242
242
|
|
|
243
|
-
export type
|
|
244
|
-
|
|
245
|
-
scripts?: string | string[];
|
|
246
|
-
overrides
|
|
243
|
+
export type DeploymentEnvironmentConfig = {
|
|
244
|
+
readonly chain?: string | number;
|
|
245
|
+
readonly scripts?: string | readonly string[];
|
|
246
|
+
readonly overrides?: Omit<ChainUserConfig, 'info'>;
|
|
247
247
|
};
|
|
248
248
|
|
|
249
249
|
export type Chains = {
|
|
250
|
-
[idOrName: number | string]: ChainUserConfig;
|
|
250
|
+
readonly [idOrName: number | string]: ChainUserConfig;
|
|
251
251
|
};
|
|
252
252
|
|
|
253
253
|
export type SignerProtocolFunction = (protocolString: string) => Promise<Signer>;
|
|
@@ -259,27 +259,27 @@ export type UserConfig<
|
|
|
259
259
|
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
260
260
|
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData
|
|
261
261
|
> = {
|
|
262
|
-
|
|
263
|
-
chains?: Chains;
|
|
264
|
-
deployments?: string;
|
|
265
|
-
scripts?: string | string[];
|
|
266
|
-
accounts?: NamedAccounts;
|
|
267
|
-
data?: Data;
|
|
268
|
-
signerProtocols?: Record<string, SignerProtocolFunction>;
|
|
269
|
-
defaultPollingInterval?: number;
|
|
262
|
+
readonly environments?: {readonly [name: string]: DeploymentEnvironmentConfig};
|
|
263
|
+
readonly chains?: Chains;
|
|
264
|
+
readonly deployments?: string;
|
|
265
|
+
readonly scripts?: string | readonly string[];
|
|
266
|
+
readonly accounts?: NamedAccounts;
|
|
267
|
+
readonly data?: Data;
|
|
268
|
+
readonly signerProtocols?: Record<string, SignerProtocolFunction>;
|
|
269
|
+
readonly defaultPollingInterval?: number;
|
|
270
270
|
};
|
|
271
271
|
|
|
272
272
|
export type ResolvedUserConfig<
|
|
273
273
|
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
274
274
|
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData
|
|
275
275
|
> = UserConfig & {
|
|
276
|
-
deployments: string;
|
|
277
|
-
scripts: string[];
|
|
278
|
-
defaultPollingInterval: number;
|
|
276
|
+
readonly deployments: string;
|
|
277
|
+
readonly scripts: readonly string[];
|
|
278
|
+
readonly defaultPollingInterval: number;
|
|
279
279
|
};
|
|
280
280
|
|
|
281
281
|
export type ExecutionParams<Extra extends Record<string, unknown> = Record<string, unknown>> = {
|
|
282
|
-
|
|
282
|
+
environment?: string | {fork: string};
|
|
283
283
|
tags?: string[];
|
|
284
284
|
saveDeployments?: boolean;
|
|
285
285
|
askBeforeProceeding?: boolean;
|
|
@@ -504,7 +504,7 @@ export type ResolvedNamedSigners<T extends UnknownNamedAccounts> = {
|
|
|
504
504
|
export type UnknownDeploymentsAcrossNetworks = Record<string, UnknownDeployments>;
|
|
505
505
|
|
|
506
506
|
export type ResolvedExecutionParams<Extra extends Record<string, unknown> = Record<string, unknown>> = {
|
|
507
|
-
readonly
|
|
507
|
+
readonly environment: {
|
|
508
508
|
readonly name: string;
|
|
509
509
|
readonly tags: readonly string[];
|
|
510
510
|
readonly fork?: boolean;
|
|
@@ -529,6 +529,9 @@ export interface Environment<
|
|
|
529
529
|
Extra extends Record<string, unknown> = Record<string, unknown>
|
|
530
530
|
> {
|
|
531
531
|
readonly name: string;
|
|
532
|
+
readonly context: {
|
|
533
|
+
readonly saveDeployments: boolean;
|
|
534
|
+
};
|
|
532
535
|
readonly tags: {readonly [tag: string]: boolean};
|
|
533
536
|
readonly network: {
|
|
534
537
|
readonly chain: Chain;
|