rocketh 0.15.0-testing.16 → 0.15.0-testing.2
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 +0 -84
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/environment/deployments.d.ts +1 -1
- package/dist/environment/deployments.d.ts.map +1 -1
- package/dist/environment/index.d.ts +6 -2
- package/dist/environment/index.d.ts.map +1 -1
- package/dist/environment/index.js +60 -42
- package/dist/environment/index.js.map +1 -1
- package/dist/environment/types.d.ts +75 -33
- package/dist/environment/types.d.ts.map +1 -1
- package/dist/environment/utils/artifacts.d.ts +1 -1
- package/dist/environment/utils/artifacts.d.ts.map +1 -1
- package/dist/environment/utils/chains.d.ts +5 -6
- package/dist/environment/utils/chains.d.ts.map +1 -1
- package/dist/environment/utils/chains.js +19 -85
- package/dist/environment/utils/chains.js.map +1 -1
- package/dist/executor/index.d.ts +84 -13
- package/dist/executor/index.d.ts.map +1 -1
- package/dist/executor/index.js +216 -167
- package/dist/executor/index.js.map +1 -1
- package/dist/executor/setup.test.d.ts +3 -3
- package/dist/executor/setup.test.d.ts.map +1 -1
- package/dist/executor/setup.test.js +1 -1
- package/dist/executor/setup.test.js.map +1 -1
- package/dist/executor/types.d.ts +0 -92
- package/dist/executor/types.d.ts.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/utils/extensions.d.ts +2 -1
- package/dist/utils/extensions.d.ts.map +1 -1
- package/dist/utils/extensions.test.d.ts +2 -2
- package/dist/utils/extensions.test.d.ts.map +1 -1
- package/dist/utils/fs.d.ts +1 -1
- package/dist/utils/fs.d.ts.map +1 -1
- package/dist/utils/fs.js.map +1 -1
- package/package.json +3 -3
- package/src/cli.ts +3 -3
- package/src/environment/deployments.ts +1 -1
- package/src/environment/index.ts +72 -56
- package/src/environment/types.ts +380 -0
- package/src/environment/utils/artifacts.ts +1 -1
- package/src/environment/utils/chains.ts +22 -113
- package/src/executor/index.ts +341 -218
- package/src/executor/setup.test.ts +2 -2
- package/src/executor/types.ts +176 -0
- package/src/index.ts +6 -14
- package/src/utils/extensions.test.ts +1 -1
- package/src/utils/extensions.ts +2 -2
- package/src/utils/fs.ts +1 -1
- package/dist/types.d.ts +0 -472
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/src/types.ts +0 -600
package/src/executor/index.ts
CHANGED
|
@@ -5,27 +5,29 @@ import prompts from 'prompts';
|
|
|
5
5
|
import {tsImport as tsImport_} from 'tsx/esm/api';
|
|
6
6
|
import {formatEther} from 'viem';
|
|
7
7
|
import type {
|
|
8
|
+
Config,
|
|
8
9
|
Environment,
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
JSONTypePlusBigInt,
|
|
11
|
+
ResolvedConfig,
|
|
12
|
+
TargetConfig,
|
|
11
13
|
UnknownDeployments,
|
|
12
14
|
UnresolvedNetworkSpecificData,
|
|
13
15
|
UnresolvedUnknownNamedAccounts,
|
|
16
|
+
} from '../environment/types.js';
|
|
17
|
+
import {createEnvironment, SignerProtocolFunction} from '../environment/index.js';
|
|
18
|
+
import {
|
|
19
|
+
ChainInfo,
|
|
20
|
+
DeployScriptFunction,
|
|
14
21
|
DeployScriptModule,
|
|
15
22
|
EnhancedDeployScriptFunction,
|
|
16
23
|
EnhancedEnvironment,
|
|
17
|
-
|
|
18
|
-
ConfigOverrides,
|
|
19
|
-
UserConfig,
|
|
20
|
-
ChainConfig,
|
|
21
|
-
} from '../types.js';
|
|
24
|
+
} from './types.js';
|
|
22
25
|
import {withEnvironment} from '../utils/extensions.js';
|
|
23
26
|
import {logger, setLogLevel, spin} from '../internal/logging.js';
|
|
24
27
|
import {getRoughGasPriceEstimate} from '../utils/eth.js';
|
|
25
28
|
import {traverseMultipleDirectory} from '../utils/fs.js';
|
|
26
|
-
import {
|
|
29
|
+
import {getChain, getChainByName} from '../environment/utils/chains.js';
|
|
27
30
|
import {JSONRPCHTTPProvider} from 'eip-1193-jsonrpc-provider';
|
|
28
|
-
import {createEnvironment} from '../environment/index.js';
|
|
29
31
|
|
|
30
32
|
// @ts-ignore
|
|
31
33
|
const tsImport = (path: string, opts: any) => (typeof Bun !== 'undefined' ? import(path) : tsImport_(path, opts));
|
|
@@ -90,21 +92,18 @@ export function setup<
|
|
|
90
92
|
return scriptModule;
|
|
91
93
|
}
|
|
92
94
|
|
|
93
|
-
async function loadAndExecuteDeploymentsWithExtensions<
|
|
94
|
-
|
|
95
|
-
ArgumentsType = undefined
|
|
96
|
-
>(
|
|
97
|
-
executionParams: ExecutionParams<Extra>,
|
|
95
|
+
async function loadAndExecuteDeploymentsWithExtensions<ArgumentsType = undefined>(
|
|
96
|
+
options: ConfigOptions<Extra>,
|
|
98
97
|
args?: ArgumentsType
|
|
99
98
|
): Promise<EnhancedEnvironment<NamedAccounts, Data, UnknownDeployments, Extensions>> {
|
|
100
|
-
const env = await loadAndExecuteDeployments<NamedAccounts, Data, ArgumentsType, Extra>(
|
|
99
|
+
const env = await loadAndExecuteDeployments<NamedAccounts, Data, ArgumentsType, Extra>(options, args);
|
|
101
100
|
return enhanceEnvIfNeeded(env, extensions);
|
|
102
101
|
}
|
|
103
102
|
|
|
104
103
|
async function loadEnvironmentWithExtensions(
|
|
105
|
-
|
|
104
|
+
options: ConfigOptions<Extra>
|
|
106
105
|
): Promise<EnhancedEnvironment<NamedAccounts, Data, UnknownDeployments, Extensions>> {
|
|
107
|
-
const env = await loadEnvironment<NamedAccounts, Data, Extra>(
|
|
106
|
+
const env = await loadEnvironment<NamedAccounts, Data, Extra>(options);
|
|
108
107
|
return enhanceEnvIfNeeded(env, extensions);
|
|
109
108
|
}
|
|
110
109
|
|
|
@@ -140,10 +139,253 @@ export function enhanceEnvIfNeeded<
|
|
|
140
139
|
return enhancedEnv;
|
|
141
140
|
}
|
|
142
141
|
|
|
143
|
-
export
|
|
142
|
+
export type NamedAccountExecuteFunction<
|
|
144
143
|
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
145
144
|
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData
|
|
146
|
-
>
|
|
145
|
+
> = <ArgumentsType = undefined, Deployments extends UnknownDeployments = UnknownDeployments>(
|
|
146
|
+
callback: DeployScriptFunction<NamedAccounts, Data, ArgumentsType, Deployments>,
|
|
147
|
+
options: {tags?: string[]; dependencies?: string[]; id?: string}
|
|
148
|
+
) => DeployScriptModule<NamedAccounts, Data, ArgumentsType, Deployments>;
|
|
149
|
+
|
|
150
|
+
export interface UntypedRequestArguments {
|
|
151
|
+
readonly method: string;
|
|
152
|
+
readonly params?: readonly unknown[] | object;
|
|
153
|
+
}
|
|
154
|
+
export type UntypedEIP1193Provider = {
|
|
155
|
+
request(requestArguments: UntypedRequestArguments): Promise<unknown>;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export type ConfigOptions<Extra extends Record<string, unknown> = Record<string, unknown>> = {
|
|
159
|
+
target?: string | {fork: string};
|
|
160
|
+
deployments?: string;
|
|
161
|
+
scripts?: string | string[];
|
|
162
|
+
tags?: string;
|
|
163
|
+
logLevel?: number;
|
|
164
|
+
provider?: EIP1193ProviderWithoutEvents | EIP1193GenericRequestProvider | UntypedEIP1193Provider;
|
|
165
|
+
ignoreMissingRPC?: boolean;
|
|
166
|
+
saveDeployments?: boolean;
|
|
167
|
+
askBeforeProceeding?: boolean;
|
|
168
|
+
reportGasUse?: boolean;
|
|
169
|
+
extra?: Extra;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export type Create2DeterministicDeploymentInfo = {
|
|
173
|
+
factory: `0x${string}`;
|
|
174
|
+
deployer: `0x${string}`;
|
|
175
|
+
funding: string;
|
|
176
|
+
signedTx: `0x${string}`;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export type Create3DeterministicDeploymentInfo = {
|
|
180
|
+
salt?: `0x${string}`;
|
|
181
|
+
factory: `0x${string}`;
|
|
182
|
+
bytecode: `0x${string}`;
|
|
183
|
+
proxyBytecode: `0x${string}`;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export type DeterministicDeploymentInfo =
|
|
187
|
+
| Create2DeterministicDeploymentInfo
|
|
188
|
+
| {
|
|
189
|
+
create2?: Create2DeterministicDeploymentInfo;
|
|
190
|
+
create3?: Create3DeterministicDeploymentInfo;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
export type ChainUserConfig = {
|
|
194
|
+
rpcUrl?: string;
|
|
195
|
+
tags?: string[];
|
|
196
|
+
deterministicDeployment?: DeterministicDeploymentInfo;
|
|
197
|
+
info?: ChainInfo;
|
|
198
|
+
pollingInterval?: number;
|
|
199
|
+
properties?: Record<string, JSONTypePlusBigInt>;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
export type DeploymentTargetConfig = {
|
|
203
|
+
chainId: number;
|
|
204
|
+
scripts?: string | string[];
|
|
205
|
+
overrides: Omit<ChainUserConfig, 'info'>;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
export type Chains = {
|
|
209
|
+
[idOrName: number | string]: ChainUserConfig;
|
|
210
|
+
};
|
|
211
|
+
export type UserConfig<
|
|
212
|
+
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
213
|
+
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData
|
|
214
|
+
> = {
|
|
215
|
+
targets: {[name: string]: DeploymentTargetConfig};
|
|
216
|
+
chains?: Chains;
|
|
217
|
+
deployments?: string;
|
|
218
|
+
scripts?: string | string[];
|
|
219
|
+
accounts?: NamedAccounts;
|
|
220
|
+
data?: Data;
|
|
221
|
+
signerProtocols?: Record<string, SignerProtocolFunction>;
|
|
222
|
+
defaultPollingInterval?: number;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
export async function transformUserConfig<
|
|
226
|
+
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
227
|
+
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData,
|
|
228
|
+
Extra extends Record<string, unknown> = Record<string, unknown>
|
|
229
|
+
>(
|
|
230
|
+
configFile: UserConfig<NamedAccounts, Data> | undefined,
|
|
231
|
+
options: ConfigOptions<Extra>
|
|
232
|
+
): Promise<Config<NamedAccounts, Data>> {
|
|
233
|
+
if (configFile) {
|
|
234
|
+
if (!options.deployments && configFile.deployments) {
|
|
235
|
+
options.deployments = configFile.deployments;
|
|
236
|
+
}
|
|
237
|
+
if (!options.scripts && configFile.scripts) {
|
|
238
|
+
options.scripts = configFile.scripts;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const targetProvided = options.target || (options as any).network; // fallback on network
|
|
243
|
+
const fork = typeof targetProvided !== 'string';
|
|
244
|
+
let targetName = 'memory';
|
|
245
|
+
if (options.target) {
|
|
246
|
+
if (typeof options.target === 'string') {
|
|
247
|
+
targetName = options.target;
|
|
248
|
+
} else if ('fork' in options.target) {
|
|
249
|
+
targetName = options.target.fork;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
let chainInfo: ChainInfo;
|
|
254
|
+
|
|
255
|
+
let chainId: number;
|
|
256
|
+
|
|
257
|
+
if (configFile?.targets?.[targetName]) {
|
|
258
|
+
chainId = configFile.targets[targetName].chainId;
|
|
259
|
+
} else {
|
|
260
|
+
const chainFound = getChainByName(targetName);
|
|
261
|
+
if (chainFound) {
|
|
262
|
+
chainInfo = chainFound;
|
|
263
|
+
chainId = chainInfo.id;
|
|
264
|
+
} else {
|
|
265
|
+
if (options.provider) {
|
|
266
|
+
const chainIdAsHex = await (options.provider as EIP1193ProviderWithoutEvents).request({method: 'eth_chainId'});
|
|
267
|
+
chainId = Number(chainIdAsHex);
|
|
268
|
+
} else {
|
|
269
|
+
throw new Error(`target ${targetName} is unknown`);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const chainConfigFromChainId = configFile?.chains?.[chainId];
|
|
275
|
+
const chainConfigFromChainName = configFile?.chains?.[targetName];
|
|
276
|
+
if (chainConfigFromChainId && chainConfigFromChainName) {
|
|
277
|
+
throw new Error(
|
|
278
|
+
`conflicting config for chain, choose to configure via its chainId (${chainId}) or via its name ${targetName} but not both`
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
const chainConfig = chainConfigFromChainId || chainConfigFromChainName;
|
|
282
|
+
|
|
283
|
+
const targetConfig = configFile?.targets?.[targetName];
|
|
284
|
+
const actualChainConfig = targetConfig?.overrides
|
|
285
|
+
? {
|
|
286
|
+
...chainConfig,
|
|
287
|
+
...targetConfig.overrides,
|
|
288
|
+
properties: {
|
|
289
|
+
...chainConfig?.properties,
|
|
290
|
+
...targetConfig.overrides.properties,
|
|
291
|
+
},
|
|
292
|
+
}
|
|
293
|
+
: chainConfig;
|
|
294
|
+
|
|
295
|
+
const defaultTags: string[] = [];
|
|
296
|
+
|
|
297
|
+
const chainFound = actualChainConfig?.info || getChain(chainId);
|
|
298
|
+
if (chainFound) {
|
|
299
|
+
chainInfo = chainFound;
|
|
300
|
+
} else {
|
|
301
|
+
throw new Error(`chain with id ${chainId} has no chainInfo associated with it`);
|
|
302
|
+
}
|
|
303
|
+
if (chainInfo.testnet) {
|
|
304
|
+
defaultTags.push('testnet');
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
let targetTags: string[] = actualChainConfig?.tags || defaultTags;
|
|
308
|
+
|
|
309
|
+
let networkScripts: string | string[] | undefined = targetConfig?.scripts;
|
|
310
|
+
|
|
311
|
+
// no default for publicInfo
|
|
312
|
+
const defaultPollingInterval = configFile?.defaultPollingInterval;
|
|
313
|
+
const pollingInterval = actualChainConfig?.pollingInterval;
|
|
314
|
+
const deterministicDeployment = actualChainConfig?.deterministicDeployment;
|
|
315
|
+
const properties = actualChainConfig?.properties;
|
|
316
|
+
|
|
317
|
+
let resolvedTargetConfig: TargetConfig;
|
|
318
|
+
|
|
319
|
+
if (!options.provider) {
|
|
320
|
+
let rpcURL = actualChainConfig?.rpcUrl;
|
|
321
|
+
if (!rpcURL) {
|
|
322
|
+
rpcURL = chainInfo.rpcUrls.default.http[0];
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
const fromEnv = process.env['ETH_NODE_URI_' + targetName];
|
|
326
|
+
let nodeUrl: string;
|
|
327
|
+
if (typeof fromEnv === 'string' && fromEnv) {
|
|
328
|
+
nodeUrl = fromEnv;
|
|
329
|
+
} else {
|
|
330
|
+
if (rpcURL) {
|
|
331
|
+
nodeUrl = rpcURL;
|
|
332
|
+
} else if (options?.ignoreMissingRPC) {
|
|
333
|
+
nodeUrl = '';
|
|
334
|
+
} else if (options.target === 'localhost') {
|
|
335
|
+
nodeUrl = 'http://127.0.0.1:8545';
|
|
336
|
+
} else {
|
|
337
|
+
console.error(`network "${options.target}" is not configured. Please add it to the rocketh.js/ts file`);
|
|
338
|
+
process.exit(1);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
resolvedTargetConfig = {
|
|
343
|
+
nodeUrl,
|
|
344
|
+
name: targetName,
|
|
345
|
+
tags: targetTags,
|
|
346
|
+
fork,
|
|
347
|
+
deterministicDeployment,
|
|
348
|
+
scripts: networkScripts,
|
|
349
|
+
chainInfo,
|
|
350
|
+
pollingInterval,
|
|
351
|
+
properties,
|
|
352
|
+
};
|
|
353
|
+
} else {
|
|
354
|
+
resolvedTargetConfig = {
|
|
355
|
+
provider: options.provider as EIP1193ProviderWithoutEvents,
|
|
356
|
+
name: targetName,
|
|
357
|
+
tags: targetTags,
|
|
358
|
+
fork,
|
|
359
|
+
deterministicDeployment,
|
|
360
|
+
scripts: networkScripts,
|
|
361
|
+
chainInfo,
|
|
362
|
+
pollingInterval,
|
|
363
|
+
properties,
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
return {
|
|
368
|
+
target: resolvedTargetConfig,
|
|
369
|
+
deployments: options.deployments,
|
|
370
|
+
saveDeployments: options.saveDeployments,
|
|
371
|
+
scripts: options.scripts,
|
|
372
|
+
data: configFile?.data,
|
|
373
|
+
tags: typeof options.tags === 'undefined' ? undefined : options.tags.split(','),
|
|
374
|
+
logLevel: options.logLevel,
|
|
375
|
+
askBeforeProceeding: options.askBeforeProceeding,
|
|
376
|
+
reportGasUse: options.reportGasUse,
|
|
377
|
+
accounts: configFile?.accounts,
|
|
378
|
+
signerProtocols: configFile?.signerProtocols,
|
|
379
|
+
extra: options.extra,
|
|
380
|
+
defaultPollingInterval,
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
export async function readConfig<
|
|
385
|
+
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
386
|
+
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData,
|
|
387
|
+
Extra extends Record<string, unknown> = Record<string, unknown>
|
|
388
|
+
>(options: ConfigOptions<Extra>): Promise<Config<NamedAccounts, Data>> {
|
|
147
389
|
type ConfigFile = UserConfig<NamedAccounts, Data>;
|
|
148
390
|
let configFile: ConfigFile | undefined;
|
|
149
391
|
|
|
@@ -182,192 +424,101 @@ export async function readConfig<
|
|
|
182
424
|
configFile = moduleLoaded.config;
|
|
183
425
|
}
|
|
184
426
|
|
|
185
|
-
return configFile
|
|
427
|
+
return transformUserConfig(configFile, options);
|
|
186
428
|
}
|
|
187
429
|
|
|
188
|
-
export function
|
|
430
|
+
export async function readAndResolveConfig<
|
|
189
431
|
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
190
|
-
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
defaultPollingInterval: 1,
|
|
195
|
-
...configFile,
|
|
196
|
-
scripts: configFile?.scripts
|
|
197
|
-
? typeof configFile.scripts === 'string'
|
|
198
|
-
? [configFile.scripts]
|
|
199
|
-
: configFile.scripts.length == 0
|
|
200
|
-
? ['deploy']
|
|
201
|
-
: configFile.scripts
|
|
202
|
-
: ['deploy'],
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
if (overrides) {
|
|
206
|
-
for (const key of Object.keys(overrides)) {
|
|
207
|
-
if ((overrides as any)[key] !== undefined) {
|
|
208
|
-
(config as any)[key] = (overrides as any)[key];
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
return config;
|
|
432
|
+
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData,
|
|
433
|
+
Extra extends Record<string, unknown> = Record<string, unknown>
|
|
434
|
+
>(options: ConfigOptions<Extra>): Promise<ResolvedConfig<NamedAccounts, Data>> {
|
|
435
|
+
return resolveConfig<NamedAccounts, Data>(await readConfig<NamedAccounts, Data>(options));
|
|
214
436
|
}
|
|
215
437
|
|
|
216
|
-
export
|
|
438
|
+
export function resolveConfig<
|
|
217
439
|
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
218
440
|
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData
|
|
219
|
-
>(
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
const fork = typeof environmentProvided !== 'string';
|
|
269
|
-
return {name: environmentName, fork};
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
export function resolveExecutionParams<Extra extends Record<string, unknown> = Record<string, unknown>>(
|
|
273
|
-
config: ResolvedUserConfig,
|
|
274
|
-
executionParameters: ExecutionParams<Extra>,
|
|
275
|
-
chainId: number
|
|
276
|
-
): ResolvedExecutionParams<Extra> {
|
|
277
|
-
const {name: environmentName, fork} = getEnvironmentName(executionParameters);
|
|
278
|
-
|
|
279
|
-
// TODO fork chainId resolution option to keep the network being used
|
|
280
|
-
let chainConfig: ChainConfig = getChainConfig(fork ? 31337 : chainId, config);
|
|
281
|
-
|
|
282
|
-
let chainInfo = chainConfig.info;
|
|
283
|
-
const environmentConfig = config?.environments?.[environmentName];
|
|
284
|
-
const actualChainConfig = environmentConfig?.overrides
|
|
285
|
-
? {
|
|
286
|
-
...chainConfig,
|
|
287
|
-
...environmentConfig.overrides,
|
|
288
|
-
properties: {
|
|
289
|
-
...chainConfig?.properties,
|
|
290
|
-
...environmentConfig.overrides.properties,
|
|
291
|
-
},
|
|
292
|
-
}
|
|
293
|
-
: chainConfig;
|
|
294
|
-
|
|
295
|
-
if (actualChainConfig?.properties) {
|
|
296
|
-
chainInfo = {...chainInfo, properties: actualChainConfig.properties};
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
// let environmentTags: string[] = actualChainConfig.tags.concat(environmentConfig?.tags); // TODO
|
|
300
|
-
const environmentTags = actualChainConfig.tags;
|
|
441
|
+
>(config: Config<NamedAccounts, Data>): ResolvedConfig<NamedAccounts, Data> {
|
|
442
|
+
const create2Info = {
|
|
443
|
+
factory: '0x4e59b44847b379578588920ca78fbf26c0b4956c',
|
|
444
|
+
deployer: '0x3fab184622dc19b6109349b94811493bf2a45362',
|
|
445
|
+
funding: '10000000000000000',
|
|
446
|
+
signedTx:
|
|
447
|
+
'0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222',
|
|
448
|
+
} as const;
|
|
449
|
+
const create3Info = {
|
|
450
|
+
factory: '0x000000000004d4f168daE7DB3C610F408eE22F57',
|
|
451
|
+
salt: '0x5361109ca02853ca8e22046b7125306d9ec4ae4cdecc393c567b6be861df3db6',
|
|
452
|
+
bytecode:
|
|
453
|
+
'0x6080604052348015600f57600080fd5b506103ca8061001f6000396000f3fe6080604052600436106100295760003560e01c8063360d0fad1461002e5780639881d19514610077575b600080fd5b34801561003a57600080fd5b5061004e610049366004610228565b61008a565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61004e61008536600461029c565b6100ee565b6040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606084901b166020820152603481018290526000906054016040516020818303038152906040528051906020012091506100e78261014c565b9392505050565b6040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b166020820152603481018290526000906054016040516020818303038152906040528051906020012091506100e734848461015e565b600061015882306101ce565b92915050565b60006f67363d3d37363d34f03d5260086018f3600052816010806000f58061018e5763301164256000526004601cfd5b8060145261d69460005260016034536017601e20915060008085516020870188855af1823b026101c65763301164256000526004601cfd5b509392505050565b60006040518260005260ff600b53836020527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f6040526055600b20601452806040525061d694600052600160345350506017601e20919050565b6000806040838503121561023b57600080fd5b823573ffffffffffffffffffffffffffffffffffffffff8116811461025f57600080fd5b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080604083850312156102af57600080fd5b823567ffffffffffffffff8111156102c657600080fd5b8301601f810185136102d757600080fd5b803567ffffffffffffffff8111156102f1576102f161026d565b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8501160116810181811067ffffffffffffffff8211171561035d5761035d61026d565b60405281815282820160200187101561037557600080fd5b816020840160208301376000602092820183015296940135945050505056fea264697066735822122059dcc5dc6453397d13ff28021e28472a80a45bbd97f3135f69bd2650773aeb0164736f6c634300081a0033',
|
|
454
|
+
proxyBytecode: '0x67363d3d37363d34f03d5260086018f3',
|
|
455
|
+
} as const;
|
|
456
|
+
|
|
457
|
+
const defaultPollingInterval = config.defaultPollingInterval || 1;
|
|
458
|
+
const networkPollingInterval = config.target.pollingInterval || defaultPollingInterval;
|
|
459
|
+
|
|
460
|
+
let deterministicDeployment: {
|
|
461
|
+
create2: Create2DeterministicDeploymentInfo;
|
|
462
|
+
create3: Create3DeterministicDeploymentInfo;
|
|
463
|
+
} = {
|
|
464
|
+
create2: (() => {
|
|
465
|
+
if (!config.target.deterministicDeployment) return create2Info;
|
|
466
|
+
if (
|
|
467
|
+
!('create3' in config.target.deterministicDeployment) &&
|
|
468
|
+
!('create2' in config.target.deterministicDeployment)
|
|
469
|
+
)
|
|
470
|
+
return create2Info;
|
|
471
|
+
return config.target.deterministicDeployment.create2 || create2Info;
|
|
472
|
+
})(),
|
|
473
|
+
create3:
|
|
474
|
+
config.target.deterministicDeployment &&
|
|
475
|
+
'create3' in config.target.deterministicDeployment &&
|
|
476
|
+
config.target.deterministicDeployment.create3
|
|
477
|
+
? config.target.deterministicDeployment.create3
|
|
478
|
+
: create3Info,
|
|
479
|
+
};
|
|
301
480
|
|
|
302
481
|
let scripts = ['deploy'];
|
|
303
482
|
if (config.scripts) {
|
|
304
483
|
if (typeof config.scripts === 'string') {
|
|
305
484
|
scripts = [config.scripts];
|
|
306
485
|
} else {
|
|
307
|
-
scripts =
|
|
486
|
+
scripts = config.scripts;
|
|
308
487
|
}
|
|
309
488
|
}
|
|
310
489
|
|
|
311
|
-
if (
|
|
312
|
-
if (typeof
|
|
313
|
-
scripts = [
|
|
490
|
+
if (config.target.scripts) {
|
|
491
|
+
if (typeof config.target.scripts === 'string') {
|
|
492
|
+
scripts = [config.target.scripts];
|
|
314
493
|
} else {
|
|
315
|
-
scripts =
|
|
494
|
+
scripts = config.target.scripts;
|
|
316
495
|
}
|
|
317
496
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
let saveDeployments = executionParameters.saveDeployments;
|
|
323
|
-
|
|
324
|
-
if (saveDeployments === undefined) {
|
|
325
|
-
if (!executionParameters.provider) {
|
|
326
|
-
saveDeployments = true;
|
|
327
|
-
} else {
|
|
328
|
-
if (environmentName === 'memory' || environmentName === 'hardhat' || environmentName === 'default') {
|
|
329
|
-
// networkTags['memory'] = true;
|
|
330
|
-
saveDeployments = false;
|
|
331
|
-
} else {
|
|
332
|
-
saveDeployments = true;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
return {
|
|
338
|
-
askBeforeProceeding: executionParameters.askBeforeProceeding || false,
|
|
339
|
-
chain: chainInfo,
|
|
340
|
-
logLevel: executionParameters.logLevel || 0, // TODO
|
|
341
|
-
pollingInterval: actualChainConfig.pollingInterval,
|
|
342
|
-
reportGasUse: executionParameters.reportGasUse || false,
|
|
343
|
-
saveDeployments,
|
|
344
|
-
tags: executionParameters.tags || [],
|
|
345
|
-
environment: {
|
|
346
|
-
name: environmentName,
|
|
347
|
-
tags: environmentTags,
|
|
348
|
-
fork,
|
|
349
|
-
deterministicDeployment: actualChainConfig.deterministicDeployment,
|
|
350
|
-
},
|
|
351
|
-
extra: executionParameters.extra,
|
|
352
|
-
provider,
|
|
497
|
+
const resolvedConfig: ResolvedConfig<NamedAccounts, Data> = {
|
|
498
|
+
...config,
|
|
499
|
+
target: {...config.target, deterministicDeployment, pollingInterval: networkPollingInterval},
|
|
500
|
+
deployments: config.deployments || 'deployments',
|
|
353
501
|
scripts,
|
|
502
|
+
tags: config.tags || [],
|
|
503
|
+
targetTags: config.targetTags || [],
|
|
504
|
+
saveDeployments: config.saveDeployments,
|
|
505
|
+
accounts: config.accounts || ({} as NamedAccounts),
|
|
506
|
+
data: config.data || ({} as Data),
|
|
507
|
+
signerProtocols: config.signerProtocols || {},
|
|
508
|
+
extra: config.extra || {},
|
|
509
|
+
defaultPollingInterval,
|
|
354
510
|
};
|
|
511
|
+
return resolvedConfig;
|
|
355
512
|
}
|
|
356
513
|
|
|
357
514
|
export async function loadEnvironment<
|
|
358
515
|
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
359
516
|
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData,
|
|
360
517
|
Extra extends Record<string, unknown> = Record<string, unknown>
|
|
361
|
-
>(
|
|
362
|
-
const
|
|
363
|
-
const {name: environmentName, fork} = getEnvironmentName(executionParams);
|
|
364
|
-
const chainId = await getChainIdForEnvironment(userConfig, environmentName, executionParams.provider);
|
|
365
|
-
const resolvedExecutionParams = resolveExecutionParams(userConfig, executionParams, chainId);
|
|
518
|
+
>(options: ConfigOptions<Extra>): Promise<Environment<NamedAccounts, Data, UnknownDeployments>> {
|
|
519
|
+
const resolvedConfig = await readAndResolveConfig<NamedAccounts, Data>(options);
|
|
366
520
|
// console.log(JSON.stringify(resolvedConfig, null, 2));
|
|
367
|
-
const {external, internal} = await createEnvironment
|
|
368
|
-
userConfig,
|
|
369
|
-
resolvedExecutionParams
|
|
370
|
-
);
|
|
521
|
+
const {external, internal} = await createEnvironment(resolvedConfig);
|
|
371
522
|
return external;
|
|
372
523
|
}
|
|
373
524
|
|
|
@@ -376,35 +527,11 @@ export async function loadAndExecuteDeployments<
|
|
|
376
527
|
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData,
|
|
377
528
|
ArgumentsType = undefined,
|
|
378
529
|
Extra extends Record<string, unknown> = Record<string, unknown>
|
|
379
|
-
>(
|
|
380
|
-
|
|
381
|
-
args?: ArgumentsType
|
|
382
|
-
): Promise<Environment<NamedAccounts, Data, UnknownDeployments>> {
|
|
383
|
-
const userConfig = await readAndResolveConfig<NamedAccounts, Data>(executionParams.config);
|
|
384
|
-
const {name: environmentName, fork} = getEnvironmentName(executionParams);
|
|
385
|
-
const chainId = await getChainIdForEnvironment(userConfig, environmentName, executionParams.provider);
|
|
386
|
-
const resolvedExecutionParams = resolveExecutionParams(userConfig, executionParams, chainId);
|
|
530
|
+
>(options: ConfigOptions<Extra>, args?: ArgumentsType): Promise<Environment<NamedAccounts, Data, UnknownDeployments>> {
|
|
531
|
+
const resolvedConfig = await readAndResolveConfig<NamedAccounts, Data>(options);
|
|
387
532
|
// console.log(JSON.stringify(options, null, 2));
|
|
388
533
|
// console.log(JSON.stringify(resolvedConfig, null, 2));
|
|
389
|
-
return executeDeployScripts<NamedAccounts, Data, ArgumentsType>(
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
export async function executeDeployScriptsDirectly<
|
|
393
|
-
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
394
|
-
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData,
|
|
395
|
-
ArgumentsType = undefined,
|
|
396
|
-
Extra extends Record<string, unknown> = Record<string, unknown>
|
|
397
|
-
>(
|
|
398
|
-
userConfig: UserConfig,
|
|
399
|
-
executionParams?: ExecutionParams<Extra>,
|
|
400
|
-
args?: ArgumentsType
|
|
401
|
-
): Promise<Environment<NamedAccounts, Data, UnknownDeployments>> {
|
|
402
|
-
executionParams = executionParams || {};
|
|
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);
|
|
406
|
-
const resolvedExecutionParams = resolveExecutionParams(resolveduserConfig, executionParams, chainId);
|
|
407
|
-
return executeDeployScripts<NamedAccounts, Data, ArgumentsType>(resolveduserConfig, resolvedExecutionParams, args);
|
|
534
|
+
return executeDeployScripts<NamedAccounts, Data, ArgumentsType>(resolvedConfig, args);
|
|
408
535
|
}
|
|
409
536
|
|
|
410
537
|
export async function executeDeployScripts<
|
|
@@ -412,14 +539,13 @@ export async function executeDeployScripts<
|
|
|
412
539
|
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData,
|
|
413
540
|
ArgumentsType = undefined
|
|
414
541
|
>(
|
|
415
|
-
|
|
416
|
-
resolvedExecutionParams: ResolvedExecutionParams,
|
|
542
|
+
config: ResolvedConfig<NamedAccounts, Data>,
|
|
417
543
|
args?: ArgumentsType
|
|
418
544
|
): Promise<Environment<NamedAccounts, Data, UnknownDeployments>> {
|
|
419
|
-
setLogLevel(typeof
|
|
545
|
+
setLogLevel(typeof config.logLevel === 'undefined' ? 0 : config.logLevel);
|
|
420
546
|
|
|
421
547
|
let filepaths;
|
|
422
|
-
filepaths = traverseMultipleDirectory(
|
|
548
|
+
filepaths = traverseMultipleDirectory(config.scripts);
|
|
423
549
|
filepaths = filepaths
|
|
424
550
|
.filter((v) => !path.basename(v).startsWith('_'))
|
|
425
551
|
.sort((a: string, b: string) => {
|
|
@@ -474,10 +600,10 @@ export async function executeDeployScripts<
|
|
|
474
600
|
}
|
|
475
601
|
}
|
|
476
602
|
|
|
477
|
-
if (
|
|
603
|
+
if (config.tags !== undefined && config.tags.length > 0) {
|
|
478
604
|
let found = false;
|
|
479
605
|
if (scriptTags !== undefined) {
|
|
480
|
-
for (const tagToFind of
|
|
606
|
+
for (const tagToFind of config.tags) {
|
|
481
607
|
for (const tag of scriptTags) {
|
|
482
608
|
if (tag === tagToFind) {
|
|
483
609
|
scriptFilePaths.push(scriptFilePath);
|
|
@@ -495,10 +621,7 @@ export async function executeDeployScripts<
|
|
|
495
621
|
}
|
|
496
622
|
}
|
|
497
623
|
|
|
498
|
-
const {internal, external} = await createEnvironment
|
|
499
|
-
userConfig,
|
|
500
|
-
resolvedExecutionParams
|
|
501
|
-
);
|
|
624
|
+
const {internal, external} = await createEnvironment(config);
|
|
502
625
|
|
|
503
626
|
await internal.recoverTransactionsIfAny();
|
|
504
627
|
|
|
@@ -545,10 +668,10 @@ export async function executeDeployScripts<
|
|
|
545
668
|
recurseDependencies(scriptFilePath);
|
|
546
669
|
}
|
|
547
670
|
|
|
548
|
-
if (
|
|
671
|
+
if (config.askBeforeProceeding) {
|
|
549
672
|
console.log(
|
|
550
|
-
`Network: ${external.name} \n \t Chain: ${external.network.chain.name} \n \t Tags: ${Object.keys(
|
|
551
|
-
external.tags
|
|
673
|
+
`Network: ${external.network.name} \n \t Chain: ${external.network.chain.name} \n \t Tags: ${Object.keys(
|
|
674
|
+
external.network.tags
|
|
552
675
|
).join(',')}`
|
|
553
676
|
);
|
|
554
677
|
const gasPriceEstimate = await getRoughGasPriceEstimate(external.network.provider);
|
|
@@ -614,7 +737,7 @@ Do you want to proceed (note that gas price can change for each tx)`,
|
|
|
614
737
|
}
|
|
615
738
|
}
|
|
616
739
|
|
|
617
|
-
if (
|
|
740
|
+
if (config.reportGasUse) {
|
|
618
741
|
const provider = external.network.provider;
|
|
619
742
|
const transactionHashes = provider.transactionHashes;
|
|
620
743
|
|