rocketh 0.15.0-testing.7 → 0.15.0-testing.9
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 +12 -0
- package/dist/environment/deployments.d.ts +1 -1
- package/dist/environment/deployments.d.ts.map +1 -1
- package/dist/environment/index.d.ts +1 -6
- package/dist/environment/index.d.ts.map +1 -1
- package/dist/environment/index.js +1 -1
- package/dist/environment/index.js.map +1 -1
- package/dist/environment/types.d.ts +1 -15
- 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 +1 -2
- package/dist/environment/utils/chains.d.ts.map +1 -1
- package/dist/environment/utils/chains.js +1 -1
- package/dist/environment/utils/chains.js.map +1 -1
- package/dist/executor/index.d.ts +5 -77
- package/dist/executor/index.d.ts.map +1 -1
- package/dist/executor/index.js +36 -15
- 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/types.d.ts +92 -0
- package/dist/executor/types.d.ts.map +1 -1
- package/dist/index.d.ts +5 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -6
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +469 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/extensions.d.ts +1 -2
- 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/package.json +3 -3
- package/src/environment/deployments.ts +1 -1
- package/src/environment/index.ts +4 -9
- package/src/environment/utils/artifacts.ts +1 -1
- package/src/environment/utils/chains.ts +3 -4
- package/src/executor/index.ts +58 -120
- package/src/executor/setup.test.ts +1 -1
- package/src/index.ts +13 -6
- package/src/{environment/types.ts → types.ts} +281 -17
- package/src/utils/extensions.test.ts +1 -1
- package/src/utils/extensions.ts +2 -2
- package/src/executor/types.ts +0 -176
package/src/executor/index.ts
CHANGED
|
@@ -7,26 +7,25 @@ import {formatEther} from 'viem';
|
|
|
7
7
|
import type {
|
|
8
8
|
Environment,
|
|
9
9
|
ExecutionParams,
|
|
10
|
-
JSONTypePlusBigInt,
|
|
11
10
|
ResolvedExecutionParams,
|
|
12
11
|
UnknownDeployments,
|
|
13
12
|
UnresolvedNetworkSpecificData,
|
|
14
13
|
UnresolvedUnknownNamedAccounts,
|
|
15
|
-
} from '../environment/types.js';
|
|
16
|
-
import {createEnvironment, SignerProtocolFunction} from '../environment/index.js';
|
|
17
|
-
import {
|
|
18
|
-
ChainInfo,
|
|
19
|
-
DeployScriptFunction,
|
|
20
14
|
DeployScriptModule,
|
|
21
15
|
EnhancedDeployScriptFunction,
|
|
22
16
|
EnhancedEnvironment,
|
|
23
|
-
|
|
17
|
+
ResolvedUserConfig,
|
|
18
|
+
ConfigOverrides,
|
|
19
|
+
UserConfig,
|
|
20
|
+
ChainConfig,
|
|
21
|
+
} from '../types.js';
|
|
24
22
|
import {withEnvironment} from '../utils/extensions.js';
|
|
25
23
|
import {logger, setLogLevel, spin} from '../internal/logging.js';
|
|
26
24
|
import {getRoughGasPriceEstimate} from '../utils/eth.js';
|
|
27
25
|
import {traverseMultipleDirectory} from '../utils/fs.js';
|
|
28
26
|
import {getChainByName, getChainConfig} from '../environment/utils/chains.js';
|
|
29
27
|
import {JSONRPCHTTPProvider} from 'eip-1193-jsonrpc-provider';
|
|
28
|
+
import {createEnvironment} from '../environment/index.js';
|
|
30
29
|
|
|
31
30
|
// @ts-ignore
|
|
32
31
|
const tsImport = (path: string, opts: any) => (typeof Bun !== 'undefined' ? import(path) : tsImport_(path, opts));
|
|
@@ -141,102 +140,10 @@ export function enhanceEnvIfNeeded<
|
|
|
141
140
|
return enhancedEnv;
|
|
142
141
|
}
|
|
143
142
|
|
|
144
|
-
export type NamedAccountExecuteFunction<
|
|
145
|
-
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
146
|
-
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData
|
|
147
|
-
> = <ArgumentsType = undefined, Deployments extends UnknownDeployments = UnknownDeployments>(
|
|
148
|
-
callback: DeployScriptFunction<NamedAccounts, Data, ArgumentsType, Deployments>,
|
|
149
|
-
options: {tags?: string[]; dependencies?: string[]; id?: string}
|
|
150
|
-
) => DeployScriptModule<NamedAccounts, Data, ArgumentsType, Deployments>;
|
|
151
|
-
|
|
152
|
-
export interface UntypedRequestArguments {
|
|
153
|
-
readonly method: string;
|
|
154
|
-
readonly params?: readonly unknown[] | object;
|
|
155
|
-
}
|
|
156
|
-
export type UntypedEIP1193Provider = {
|
|
157
|
-
request(requestArguments: UntypedRequestArguments): Promise<unknown>;
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
export type ConfigOverrides = {
|
|
161
|
-
deployments?: string;
|
|
162
|
-
scripts?: string | string[];
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
export type Create2DeterministicDeploymentInfo = {
|
|
166
|
-
factory: `0x${string}`;
|
|
167
|
-
deployer: `0x${string}`;
|
|
168
|
-
funding: string;
|
|
169
|
-
signedTx: `0x${string}`;
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
export type Create3DeterministicDeploymentInfo = {
|
|
173
|
-
salt?: `0x${string}`;
|
|
174
|
-
factory: `0x${string}`;
|
|
175
|
-
bytecode: `0x${string}`;
|
|
176
|
-
proxyBytecode: `0x${string}`;
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
export type DeterministicDeploymentInfo =
|
|
180
|
-
| Create2DeterministicDeploymentInfo
|
|
181
|
-
| {
|
|
182
|
-
create2?: Create2DeterministicDeploymentInfo;
|
|
183
|
-
create3?: Create3DeterministicDeploymentInfo;
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
export type ChainUserConfig = {
|
|
187
|
-
rpcUrl?: string;
|
|
188
|
-
tags?: string[];
|
|
189
|
-
deterministicDeployment?: DeterministicDeploymentInfo;
|
|
190
|
-
info?: ChainInfo;
|
|
191
|
-
pollingInterval?: number;
|
|
192
|
-
properties?: Record<string, JSONTypePlusBigInt>;
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
export type ChainConfig = {
|
|
196
|
-
rpcUrl: string;
|
|
197
|
-
tags: string[];
|
|
198
|
-
deterministicDeployment: DeterministicDeploymentInfo;
|
|
199
|
-
info: ChainInfo;
|
|
200
|
-
pollingInterval: number;
|
|
201
|
-
properties: Record<string, JSONTypePlusBigInt>;
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
export type DeploymentTargetConfig = {
|
|
205
|
-
chainId: number;
|
|
206
|
-
scripts?: string | string[];
|
|
207
|
-
overrides: Omit<ChainUserConfig, 'info'>;
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
export type Chains = {
|
|
211
|
-
[idOrName: number | string]: ChainUserConfig;
|
|
212
|
-
};
|
|
213
|
-
export type UserConfig<
|
|
214
|
-
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
215
|
-
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData
|
|
216
|
-
> = {
|
|
217
|
-
targets?: {[name: string]: DeploymentTargetConfig};
|
|
218
|
-
chains?: Chains;
|
|
219
|
-
deployments?: string;
|
|
220
|
-
scripts?: string | string[];
|
|
221
|
-
accounts?: NamedAccounts;
|
|
222
|
-
data?: Data;
|
|
223
|
-
signerProtocols?: Record<string, SignerProtocolFunction>;
|
|
224
|
-
defaultPollingInterval?: number;
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
export type ResolvedUserConfig<
|
|
228
|
-
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
229
|
-
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData
|
|
230
|
-
> = UserConfig & {
|
|
231
|
-
deployments: string;
|
|
232
|
-
scripts: string[];
|
|
233
|
-
defaultPollingInterval: number;
|
|
234
|
-
};
|
|
235
|
-
|
|
236
143
|
export async function readConfig<
|
|
237
144
|
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
238
145
|
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData
|
|
239
|
-
>(
|
|
146
|
+
>(): Promise<UserConfig> {
|
|
240
147
|
type ConfigFile = UserConfig<NamedAccounts, Data>;
|
|
241
148
|
let configFile: ConfigFile | undefined;
|
|
242
149
|
|
|
@@ -275,6 +182,13 @@ export async function readConfig<
|
|
|
275
182
|
configFile = moduleLoaded.config;
|
|
276
183
|
}
|
|
277
184
|
|
|
185
|
+
return configFile || {};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export function resolveConfig<
|
|
189
|
+
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
190
|
+
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData
|
|
191
|
+
>(configFile: UserConfig, overrides?: ConfigOverrides): ResolvedUserConfig<NamedAccounts, Data> {
|
|
278
192
|
const config = {
|
|
279
193
|
deployments: 'deployments',
|
|
280
194
|
defaultPollingInterval: 1,
|
|
@@ -282,19 +196,31 @@ export async function readConfig<
|
|
|
282
196
|
scripts: configFile?.scripts
|
|
283
197
|
? typeof configFile.scripts === 'string'
|
|
284
198
|
? [configFile.scripts]
|
|
199
|
+
: configFile.scripts.length == 0
|
|
200
|
+
? ['deploy']
|
|
285
201
|
: configFile.scripts
|
|
286
202
|
: ['deploy'],
|
|
287
203
|
};
|
|
288
204
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
(
|
|
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
|
+
}
|
|
292
210
|
}
|
|
293
211
|
}
|
|
294
212
|
|
|
295
213
|
return config;
|
|
296
214
|
}
|
|
297
215
|
|
|
216
|
+
export async function readAndResolveConfig<
|
|
217
|
+
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
218
|
+
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData
|
|
219
|
+
>(overrides?: ConfigOverrides): Promise<ResolvedUserConfig<NamedAccounts, Data>> {
|
|
220
|
+
const configFile = await readConfig();
|
|
221
|
+
return resolveConfig(configFile, overrides);
|
|
222
|
+
}
|
|
223
|
+
|
|
298
224
|
export async function getChainIdForTarget(
|
|
299
225
|
config: ResolvedUserConfig,
|
|
300
226
|
targetName: string,
|
|
@@ -317,7 +243,8 @@ export async function getChainIdForTarget(
|
|
|
317
243
|
}
|
|
318
244
|
}
|
|
319
245
|
|
|
320
|
-
function getTargetName(
|
|
246
|
+
function getTargetName(executionParams: ExecutionParams): {name: string; fork: boolean} {
|
|
247
|
+
const targetProvided = executionParams.target || (executionParams as any).network;
|
|
321
248
|
let targetName = 'memory';
|
|
322
249
|
if (targetProvided) {
|
|
323
250
|
if (typeof targetProvided === 'string') {
|
|
@@ -326,7 +253,8 @@ function getTargetName(targetProvided?: string | {fork: string}) {
|
|
|
326
253
|
targetName = targetProvided.fork;
|
|
327
254
|
}
|
|
328
255
|
}
|
|
329
|
-
|
|
256
|
+
const fork = typeof targetProvided !== 'string';
|
|
257
|
+
return {name: targetName, fork};
|
|
330
258
|
}
|
|
331
259
|
|
|
332
260
|
export function resolveExecutionParams<Extra extends Record<string, unknown> = Record<string, unknown>>(
|
|
@@ -334,9 +262,7 @@ export function resolveExecutionParams<Extra extends Record<string, unknown> = R
|
|
|
334
262
|
executionParameters: ExecutionParams<Extra>,
|
|
335
263
|
chainId: number
|
|
336
264
|
): ResolvedExecutionParams<Extra> {
|
|
337
|
-
const
|
|
338
|
-
const fork = typeof targetProvided !== 'string';
|
|
339
|
-
let targetName = getTargetName(targetProvided);
|
|
265
|
+
const {name: targetName, fork} = getTargetName(executionParameters);
|
|
340
266
|
|
|
341
267
|
let chainConfig: ChainConfig = getChainConfig(chainId, config);
|
|
342
268
|
|
|
@@ -420,12 +346,9 @@ export async function loadEnvironment<
|
|
|
420
346
|
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData,
|
|
421
347
|
Extra extends Record<string, unknown> = Record<string, unknown>
|
|
422
348
|
>(executionParams: ExecutionParams<Extra>): Promise<Environment<NamedAccounts, Data, UnknownDeployments>> {
|
|
423
|
-
const userConfig = await
|
|
424
|
-
const
|
|
425
|
-
|
|
426
|
-
getTargetName(executionParams.target),
|
|
427
|
-
executionParams.provider
|
|
428
|
-
);
|
|
349
|
+
const userConfig = await readAndResolveConfig<NamedAccounts, Data>(executionParams.config);
|
|
350
|
+
const {name: targetName, fork} = getTargetName(executionParams);
|
|
351
|
+
const chainId = await getChainIdForTarget(userConfig, targetName, executionParams.provider);
|
|
429
352
|
const resolvedExecutionParams = resolveExecutionParams(userConfig, executionParams, chainId);
|
|
430
353
|
// console.log(JSON.stringify(resolvedConfig, null, 2));
|
|
431
354
|
const {external, internal} = await createEnvironment<NamedAccounts, Data, UnknownDeployments>(
|
|
@@ -444,18 +367,33 @@ export async function loadAndExecuteDeployments<
|
|
|
444
367
|
executionParams: ExecutionParams<Extra>,
|
|
445
368
|
args?: ArgumentsType
|
|
446
369
|
): Promise<Environment<NamedAccounts, Data, UnknownDeployments>> {
|
|
447
|
-
const userConfig = await
|
|
448
|
-
const
|
|
449
|
-
|
|
450
|
-
getTargetName(executionParams.target),
|
|
451
|
-
executionParams.provider
|
|
452
|
-
);
|
|
370
|
+
const userConfig = await readAndResolveConfig<NamedAccounts, Data>(executionParams.config);
|
|
371
|
+
const {name: targetName, fork} = getTargetName(executionParams);
|
|
372
|
+
const chainId = await getChainIdForTarget(userConfig, targetName, executionParams.provider);
|
|
453
373
|
const resolvedExecutionParams = resolveExecutionParams(userConfig, executionParams, chainId);
|
|
454
374
|
// console.log(JSON.stringify(options, null, 2));
|
|
455
375
|
// console.log(JSON.stringify(resolvedConfig, null, 2));
|
|
456
376
|
return executeDeployScripts<NamedAccounts, Data, ArgumentsType>(userConfig, resolvedExecutionParams, args);
|
|
457
377
|
}
|
|
458
378
|
|
|
379
|
+
export async function executeDeployScriptsDirectly<
|
|
380
|
+
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
381
|
+
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData,
|
|
382
|
+
ArgumentsType = undefined,
|
|
383
|
+
Extra extends Record<string, unknown> = Record<string, unknown>
|
|
384
|
+
>(
|
|
385
|
+
userConfig: UserConfig,
|
|
386
|
+
executionParams?: ExecutionParams<Extra>,
|
|
387
|
+
args?: ArgumentsType
|
|
388
|
+
): Promise<Environment<NamedAccounts, Data, UnknownDeployments>> {
|
|
389
|
+
executionParams = executionParams || {};
|
|
390
|
+
const resolveduserConfig = resolveConfig<NamedAccounts, Data>(userConfig);
|
|
391
|
+
const {name: targetName, fork} = getTargetName(executionParams);
|
|
392
|
+
const chainId = await getChainIdForTarget(resolveduserConfig, targetName, executionParams.provider);
|
|
393
|
+
const resolvedExecutionParams = resolveExecutionParams(resolveduserConfig, executionParams, chainId);
|
|
394
|
+
return executeDeployScripts<NamedAccounts, Data, ArgumentsType>(resolveduserConfig, resolvedExecutionParams, args);
|
|
395
|
+
}
|
|
396
|
+
|
|
459
397
|
export async function executeDeployScripts<
|
|
460
398
|
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
461
399
|
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData,
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export {
|
|
2
|
+
setup,
|
|
3
|
+
loadAndExecuteDeployments,
|
|
4
|
+
executeDeployScriptsDirectly,
|
|
5
|
+
readAndResolveConfig,
|
|
6
|
+
enhanceEnvIfNeeded,
|
|
7
|
+
loadEnvironment,
|
|
8
|
+
} from './executor/index.js';
|
|
9
|
+
|
|
10
|
+
export {getChainConfig} from './environment/utils/chains.js';
|
|
11
|
+
export * from './types.js';
|
|
4
12
|
export {loadDeployments} from './environment/deployments.js';
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export * from './utils/eth.js';
|
|
13
|
+
export {mergeArtifacts} from './environment/utils/artifacts.js';
|
|
14
|
+
export {getGasPriceEstimate, getRoughGasPriceEstimate} from './utils/eth.js';
|
|
@@ -9,10 +9,287 @@ import {
|
|
|
9
9
|
EIP1193WalletProvider,
|
|
10
10
|
} from 'eip-1193';
|
|
11
11
|
import type {Address, Chain, DeployContractParameters} from 'viem';
|
|
12
|
-
import {
|
|
13
|
-
import {ProgressIndicator} from '
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
import {TransactionHashTracker} from './environment/providers/TransactionHashTracker.js';
|
|
13
|
+
import {ProgressIndicator} from './internal/logging.js';
|
|
14
|
+
|
|
15
|
+
export type DeployScriptFunction<
|
|
16
|
+
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
17
|
+
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData,
|
|
18
|
+
ArgumentsTypes = undefined,
|
|
19
|
+
Deployments extends UnknownDeployments = UnknownDeployments,
|
|
20
|
+
Extra extends Record<string, unknown> = Record<string, unknown>
|
|
21
|
+
> = (env: Environment<NamedAccounts, Data, Deployments, Extra>, args?: ArgumentsTypes) => Promise<void | boolean>;
|
|
22
|
+
|
|
23
|
+
export interface DeployScriptModule<
|
|
24
|
+
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
25
|
+
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData,
|
|
26
|
+
ArgumentsTypes = undefined,
|
|
27
|
+
Deployments extends UnknownDeployments = UnknownDeployments,
|
|
28
|
+
Extra extends Record<string, unknown> = Record<string, unknown>
|
|
29
|
+
> {
|
|
30
|
+
(env: Environment<NamedAccounts, Data, Deployments, Extra>, args?: ArgumentsTypes): Promise<void | boolean>;
|
|
31
|
+
tags?: string[];
|
|
32
|
+
dependencies?: string[];
|
|
33
|
+
runAtTheEnd?: boolean;
|
|
34
|
+
id?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type ScriptCallback<
|
|
38
|
+
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
39
|
+
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData,
|
|
40
|
+
Deployments extends UnknownDeployments = UnknownDeployments,
|
|
41
|
+
Extra extends Record<string, unknown> = Record<string, unknown>
|
|
42
|
+
> = (env: Environment<NamedAccounts, Data, Deployments, Extra>) => Promise<void>;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Utility type to extract the return value from a higher-order function
|
|
46
|
+
* For functions of type (firstParam: T) => (...args: any[]) => V or (firstParam: T) => V
|
|
47
|
+
*/
|
|
48
|
+
export type ExtractReturnFunction<T> = T extends (first: any) => infer Return ? Return : never;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Utility type to transform an object of higher-order functions by extracting their return types
|
|
52
|
+
* This handles both regular functions and getter functions
|
|
53
|
+
*/
|
|
54
|
+
export type CurriedFunctions<T> = {
|
|
55
|
+
[K in keyof T]: ExtractReturnFunction<T[K]>;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Type for the enhanced environment proxy that includes both the original environment
|
|
60
|
+
* and the curried functions
|
|
61
|
+
*/
|
|
62
|
+
export type EnhancedEnvironment<
|
|
63
|
+
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
64
|
+
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData,
|
|
65
|
+
Deployments extends UnknownDeployments = UnknownDeployments,
|
|
66
|
+
Extensions extends Record<
|
|
67
|
+
string,
|
|
68
|
+
(env: Environment<NamedAccounts, Data, Deployments>, ...args: any[]) => any
|
|
69
|
+
> = Record<string, (env: Environment<NamedAccounts, Data, Deployments>, ...args: any[]) => any>,
|
|
70
|
+
Extra extends Record<string, unknown> = Record<string, unknown>
|
|
71
|
+
> = Environment<NamedAccounts, Data, Deployments, Extra> & CurriedFunctions<Extensions>;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Type for a deploy script function that receives an enhanced environment
|
|
75
|
+
*/
|
|
76
|
+
export type EnhancedDeployScriptFunction<
|
|
77
|
+
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
78
|
+
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData,
|
|
79
|
+
ArgumentsTypes = undefined,
|
|
80
|
+
Deployments extends UnknownDeployments = UnknownDeployments,
|
|
81
|
+
Functions extends Record<
|
|
82
|
+
string,
|
|
83
|
+
(env: Environment<NamedAccounts, Data, Deployments>, ...args: any[]) => any
|
|
84
|
+
> = Record<string, (env: Environment<NamedAccounts, Data, Deployments>, ...args: any[]) => any>,
|
|
85
|
+
Extra extends Record<string, unknown> = Record<string, unknown>
|
|
86
|
+
> = (
|
|
87
|
+
env: EnhancedEnvironment<NamedAccounts, Data, Deployments, Functions, Extra>,
|
|
88
|
+
args?: ArgumentsTypes
|
|
89
|
+
) => Promise<void | boolean>;
|
|
90
|
+
|
|
91
|
+
type ChainBlockExplorer = {
|
|
92
|
+
name: string;
|
|
93
|
+
url: string;
|
|
94
|
+
apiUrl?: string | undefined;
|
|
95
|
+
};
|
|
96
|
+
type ChainContract = {
|
|
97
|
+
address: Address;
|
|
98
|
+
blockCreated?: number | undefined;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
type ChainNativeCurrency = {
|
|
102
|
+
name: string;
|
|
103
|
+
/** 2-6 characters long */
|
|
104
|
+
symbol: string;
|
|
105
|
+
decimals: number;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
type ChainRpcUrls = {
|
|
109
|
+
http: readonly string[];
|
|
110
|
+
webSocket?: readonly string[] | undefined;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* @description Combines members of an intersection into a readable type.
|
|
115
|
+
*
|
|
116
|
+
* @see {@link https://twitter.com/mattpocockuk/status/1622730173446557697?s=20&t=NdpAcmEFXY01xkqU3KO0Mg}
|
|
117
|
+
* @example
|
|
118
|
+
* Prettify<{ a: string } & { b: string } & { c: number, d: bigint }>
|
|
119
|
+
* => { a: string, b: string, c: number, d: bigint }
|
|
120
|
+
*/
|
|
121
|
+
type Prettify<T> = {
|
|
122
|
+
[K in keyof T]: T[K];
|
|
123
|
+
} & {};
|
|
124
|
+
|
|
125
|
+
export type ChainInfo = {
|
|
126
|
+
/** ID in number form */
|
|
127
|
+
id: number;
|
|
128
|
+
/** Human-readable name */
|
|
129
|
+
name: string;
|
|
130
|
+
/** Collection of block explorers */
|
|
131
|
+
blockExplorers?:
|
|
132
|
+
| {
|
|
133
|
+
[key: string]: ChainBlockExplorer;
|
|
134
|
+
default: ChainBlockExplorer;
|
|
135
|
+
}
|
|
136
|
+
| undefined;
|
|
137
|
+
/** Collection of contracts */
|
|
138
|
+
contracts?:
|
|
139
|
+
| Prettify<
|
|
140
|
+
{
|
|
141
|
+
[key: string]: ChainContract | {[sourceId: number]: ChainContract | undefined} | undefined;
|
|
142
|
+
} & {
|
|
143
|
+
ensRegistry?: ChainContract | undefined;
|
|
144
|
+
ensUniversalResolver?: ChainContract | undefined;
|
|
145
|
+
multicall3?: ChainContract | undefined;
|
|
146
|
+
}
|
|
147
|
+
>
|
|
148
|
+
| undefined;
|
|
149
|
+
/** Currency used by chain */
|
|
150
|
+
nativeCurrency: ChainNativeCurrency;
|
|
151
|
+
/** Collection of RPC endpoints */
|
|
152
|
+
rpcUrls: {
|
|
153
|
+
[key: string]: ChainRpcUrls;
|
|
154
|
+
default: ChainRpcUrls;
|
|
155
|
+
};
|
|
156
|
+
/** Source Chain ID (ie. the L1 chain) */
|
|
157
|
+
sourceId?: number | undefined;
|
|
158
|
+
/** Flag for test networks */
|
|
159
|
+
testnet?: boolean | undefined;
|
|
160
|
+
|
|
161
|
+
chainType: 'zksync' | 'op-stack' | 'celo' | 'default';
|
|
162
|
+
|
|
163
|
+
genesisHash?: string;
|
|
164
|
+
|
|
165
|
+
properties?: Record<string, JSONTypePlusBigInt>;
|
|
166
|
+
|
|
167
|
+
// this will bring in the following when reconstructed from the data above
|
|
168
|
+
|
|
169
|
+
// /** Custom chain data. */
|
|
170
|
+
// custom?: any;
|
|
171
|
+
|
|
172
|
+
// /**
|
|
173
|
+
// * Modifies how chain data structures (ie. Blocks, Transactions, etc)
|
|
174
|
+
// * are formatted & typed.
|
|
175
|
+
// */
|
|
176
|
+
// formatters?: any | undefined;
|
|
177
|
+
// /** Modifies how data (ie. Transactions) is serialized. */
|
|
178
|
+
// serializers?: any | undefined;
|
|
179
|
+
// /** Modifies how fees are derived. */
|
|
180
|
+
// fees?: any | undefined;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export type NamedAccountExecuteFunction<
|
|
184
|
+
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
185
|
+
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData
|
|
186
|
+
> = <ArgumentsType = undefined, Deployments extends UnknownDeployments = UnknownDeployments>(
|
|
187
|
+
callback: DeployScriptFunction<NamedAccounts, Data, ArgumentsType, Deployments>,
|
|
188
|
+
options: {tags?: string[]; dependencies?: string[]; id?: string}
|
|
189
|
+
) => DeployScriptModule<NamedAccounts, Data, ArgumentsType, Deployments>;
|
|
190
|
+
|
|
191
|
+
export interface UntypedRequestArguments {
|
|
192
|
+
readonly method: string;
|
|
193
|
+
readonly params?: readonly unknown[] | object;
|
|
194
|
+
}
|
|
195
|
+
export type UntypedEIP1193Provider = {
|
|
196
|
+
request(requestArguments: UntypedRequestArguments): Promise<unknown>;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export type ConfigOverrides = {
|
|
200
|
+
deployments?: string;
|
|
201
|
+
scripts?: string | string[];
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
export type Create2DeterministicDeploymentInfo = {
|
|
205
|
+
factory: `0x${string}`;
|
|
206
|
+
deployer: `0x${string}`;
|
|
207
|
+
funding: string;
|
|
208
|
+
signedTx: `0x${string}`;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
export type Create3DeterministicDeploymentInfo = {
|
|
212
|
+
salt?: `0x${string}`;
|
|
213
|
+
factory: `0x${string}`;
|
|
214
|
+
bytecode: `0x${string}`;
|
|
215
|
+
proxyBytecode: `0x${string}`;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
export type DeterministicDeploymentInfo =
|
|
219
|
+
| Create2DeterministicDeploymentInfo
|
|
220
|
+
| {
|
|
221
|
+
create2?: Create2DeterministicDeploymentInfo;
|
|
222
|
+
create3?: Create3DeterministicDeploymentInfo;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
export type ChainUserConfig = {
|
|
226
|
+
rpcUrl?: string;
|
|
227
|
+
tags?: string[];
|
|
228
|
+
deterministicDeployment?: DeterministicDeploymentInfo;
|
|
229
|
+
info?: ChainInfo;
|
|
230
|
+
pollingInterval?: number;
|
|
231
|
+
properties?: Record<string, JSONTypePlusBigInt>;
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
export type ChainConfig = {
|
|
235
|
+
rpcUrl: string;
|
|
236
|
+
tags: string[];
|
|
237
|
+
deterministicDeployment: DeterministicDeploymentInfo;
|
|
238
|
+
info: ChainInfo;
|
|
239
|
+
pollingInterval: number;
|
|
240
|
+
properties: Record<string, JSONTypePlusBigInt>;
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
export type DeploymentTargetConfig = {
|
|
244
|
+
chainId: number;
|
|
245
|
+
scripts?: string | string[];
|
|
246
|
+
overrides: Omit<ChainUserConfig, 'info'>;
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
export type Chains = {
|
|
250
|
+
[idOrName: number | string]: ChainUserConfig;
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
export type SignerProtocolFunction = (protocolString: string) => Promise<Signer>;
|
|
254
|
+
export type SignerProtocol = {
|
|
255
|
+
getSigner: SignerProtocolFunction;
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
export type UserConfig<
|
|
259
|
+
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
260
|
+
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData
|
|
261
|
+
> = {
|
|
262
|
+
targets?: {[name: string]: DeploymentTargetConfig};
|
|
263
|
+
chains?: Chains;
|
|
264
|
+
deployments?: string;
|
|
265
|
+
scripts?: string | string[];
|
|
266
|
+
accounts?: NamedAccounts;
|
|
267
|
+
data?: Data;
|
|
268
|
+
signerProtocols?: Record<string, SignerProtocolFunction>;
|
|
269
|
+
defaultPollingInterval?: number;
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
export type ResolvedUserConfig<
|
|
273
|
+
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
274
|
+
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData
|
|
275
|
+
> = UserConfig & {
|
|
276
|
+
deployments: string;
|
|
277
|
+
scripts: string[];
|
|
278
|
+
defaultPollingInterval: number;
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
export type ExecutionParams<Extra extends Record<string, unknown> = Record<string, unknown>> = {
|
|
282
|
+
target?: string | {fork: string};
|
|
283
|
+
tags?: string[];
|
|
284
|
+
saveDeployments?: boolean;
|
|
285
|
+
askBeforeProceeding?: boolean;
|
|
286
|
+
reportGasUse?: boolean;
|
|
287
|
+
defaultPollingInterval?: number;
|
|
288
|
+
extra?: Extra;
|
|
289
|
+
logLevel?: number;
|
|
290
|
+
provider?: EIP1193ProviderWithoutEvents;
|
|
291
|
+
config?: ConfigOverrides;
|
|
292
|
+
};
|
|
16
293
|
|
|
17
294
|
export type {Abi, AbiConstructor, AbiError, AbiEvent, AbiFallback, AbiFunction, AbiReceive};
|
|
18
295
|
export type Libraries = {readonly [libraryName: string]: EIP1193Account};
|
|
@@ -226,19 +503,6 @@ export type ResolvedNamedSigners<T extends UnknownNamedAccounts> = {
|
|
|
226
503
|
|
|
227
504
|
export type UnknownDeploymentsAcrossNetworks = Record<string, UnknownDeployments>;
|
|
228
505
|
|
|
229
|
-
export type ExecutionParams<Extra extends Record<string, unknown> = Record<string, unknown>> = {
|
|
230
|
-
target?: string | {fork: string};
|
|
231
|
-
tags?: string[];
|
|
232
|
-
saveDeployments?: boolean;
|
|
233
|
-
askBeforeProceeding?: boolean;
|
|
234
|
-
reportGasUse?: boolean;
|
|
235
|
-
defaultPollingInterval?: number;
|
|
236
|
-
extra?: Extra;
|
|
237
|
-
logLevel?: number;
|
|
238
|
-
provider?: EIP1193ProviderWithoutEvents;
|
|
239
|
-
config: ConfigOverrides;
|
|
240
|
-
};
|
|
241
|
-
|
|
242
506
|
export type ResolvedExecutionParams<Extra extends Record<string, unknown> = Record<string, unknown>> = {
|
|
243
507
|
readonly target: {
|
|
244
508
|
readonly name: string;
|
package/src/utils/extensions.ts
CHANGED
|
@@ -3,8 +3,8 @@ import type {
|
|
|
3
3
|
UnknownDeployments,
|
|
4
4
|
UnresolvedNetworkSpecificData,
|
|
5
5
|
UnresolvedUnknownNamedAccounts,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
CurriedFunctions,
|
|
7
|
+
} from '../types.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @param env - The environment object to inject as the first parameter
|