rocketh 0.9.2 → 0.10.0
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 +6 -0
- package/dist/{chunk-34ZUTWTW.js → chunk-4RQLWJEN.js} +107 -52
- package/dist/chunk-4RQLWJEN.js.map +1 -0
- package/dist/cli.cjs +122 -65
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +4 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +106 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -23
- package/dist/index.d.ts +36 -23
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/cli.ts +2 -3
- package/src/environment/deployments.ts +3 -3
- package/src/environment/index.ts +32 -12
- package/src/environment/types.ts +30 -13
- package/src/executor/index.ts +94 -39
- package/dist/chunk-34ZUTWTW.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EIP1193Account, EIP1193DATA, EIP1193QUANTITY, EIP1193SignerProvider, EIP1193ProviderWithoutEvents, EIP1193WalletProvider, EIP1193TransactionReceipt } from 'eip-1193';
|
|
1
|
+
import { EIP1193Account, EIP1193DATA, EIP1193QUANTITY, EIP1193SignerProvider, EIP1193ProviderWithoutEvents, EIP1193WalletProvider, EIP1193TransactionReceipt, EIP1193GenericRequestProvider } from 'eip-1193';
|
|
2
2
|
import * as abitype from 'abitype';
|
|
3
3
|
import { Abi, Narrow } from 'abitype';
|
|
4
4
|
export { Abi, AbiConstructor, AbiError, AbiEvent, AbiFallback, AbiFunction, AbiReceive } from 'abitype';
|
|
@@ -197,27 +197,38 @@ type Context<Artifacts extends UnknownArtifacts = UnknownArtifacts, NamedAccount
|
|
|
197
197
|
accounts: NamedAccounts;
|
|
198
198
|
artifacts: Artifacts;
|
|
199
199
|
};
|
|
200
|
-
type
|
|
201
|
-
|
|
200
|
+
type NetworkConfigBase = {
|
|
201
|
+
name: string;
|
|
202
|
+
tags: string[];
|
|
203
|
+
fork?: boolean;
|
|
204
|
+
};
|
|
205
|
+
type NetworkConfigForJSONRPC = NetworkConfigBase & {
|
|
206
|
+
nodeUrl: string;
|
|
207
|
+
};
|
|
208
|
+
type NetworkConfigForEIP1193Provider = NetworkConfigBase & {
|
|
209
|
+
provider: EIP1193ProviderWithoutEvents;
|
|
210
|
+
};
|
|
211
|
+
type NetworkConfig = NetworkConfigForJSONRPC | NetworkConfigForEIP1193Provider;
|
|
212
|
+
type Config = {
|
|
213
|
+
network: NetworkConfig;
|
|
214
|
+
networkTags?: string[];
|
|
202
215
|
scripts?: string;
|
|
203
216
|
deployments?: string;
|
|
217
|
+
saveDeployments?: boolean;
|
|
204
218
|
tags?: string[];
|
|
205
219
|
logLevel?: number;
|
|
206
220
|
gasPricing?: {};
|
|
207
221
|
};
|
|
208
|
-
type ConfigForJSONRPC = BaseConfig & {
|
|
209
|
-
networkName: string;
|
|
210
|
-
nodeUrl: string;
|
|
211
|
-
};
|
|
212
|
-
type ConfigForEIP1193Provider = BaseConfig & {
|
|
213
|
-
provider: EIP1193ProviderWithoutEvents;
|
|
214
|
-
};
|
|
215
|
-
type Config = ConfigForJSONRPC | ConfigForEIP1193Provider;
|
|
216
222
|
type ResolvedConfig = Config & {
|
|
217
223
|
deployments: string;
|
|
218
224
|
scripts: string;
|
|
219
225
|
tags: string[];
|
|
220
|
-
|
|
226
|
+
network: {
|
|
227
|
+
name: string;
|
|
228
|
+
tags: string[];
|
|
229
|
+
fork?: boolean;
|
|
230
|
+
};
|
|
231
|
+
saveDeployments?: boolean;
|
|
221
232
|
};
|
|
222
233
|
interface Environment<Artifacts extends UnknownArtifacts = UnknownArtifacts, NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts, Deployments extends UnknownDeployments = UnknownDeployments> {
|
|
223
234
|
config: ResolvedConfig;
|
|
@@ -304,20 +315,22 @@ declare function execute<Artifacts extends UnknownArtifacts = UnknownArtifacts,
|
|
|
304
315
|
dependencies?: string[];
|
|
305
316
|
}): DeployScriptModule<Artifacts, NamedAccounts, ArgumentsType, Deployments>;
|
|
306
317
|
type ConfigOptions = {
|
|
307
|
-
network
|
|
318
|
+
network?: string | {
|
|
319
|
+
fork: string;
|
|
320
|
+
};
|
|
308
321
|
deployments?: string;
|
|
309
322
|
scripts?: string;
|
|
310
323
|
tags?: string;
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
ignoreMissingRPC?: boolean;
|
|
314
|
-
}): Config;
|
|
315
|
-
declare function readAndResolveConfig(options: ConfigOptions, extra?: {
|
|
324
|
+
logLevel?: number;
|
|
325
|
+
provider?: EIP1193ProviderWithoutEvents | EIP1193GenericRequestProvider;
|
|
316
326
|
ignoreMissingRPC?: boolean;
|
|
317
|
-
|
|
327
|
+
saveDeployments?: boolean;
|
|
328
|
+
};
|
|
329
|
+
declare function readConfig(options: ConfigOptions): Config;
|
|
330
|
+
declare function readAndResolveConfig(options: ConfigOptions): ResolvedConfig;
|
|
318
331
|
declare function resolveConfig(config: Config): ResolvedConfig;
|
|
319
|
-
declare function loadEnvironment<Artifacts extends UnknownArtifacts = UnknownArtifacts, NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts>(
|
|
320
|
-
declare function loadAndExecuteDeployments<Artifacts extends UnknownArtifacts = UnknownArtifacts, NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts, ArgumentsType = undefined, Deployments extends UnknownDeployments = UnknownDeployments>(
|
|
332
|
+
declare function loadEnvironment<Artifacts extends UnknownArtifacts = UnknownArtifacts, NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts>(options: ConfigOptions, context: ProvidedContext<Artifacts, NamedAccounts>): Promise<Environment>;
|
|
333
|
+
declare function loadAndExecuteDeployments<Artifacts extends UnknownArtifacts = UnknownArtifacts, NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts, ArgumentsType = undefined, Deployments extends UnknownDeployments = UnknownDeployments>(options: ConfigOptions, args?: ArgumentsType): Promise<Environment>;
|
|
321
334
|
declare function executeDeployScripts<Artifacts extends UnknownArtifacts = UnknownArtifacts, NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts, ArgumentsType = undefined, Deployments extends UnknownDeployments = UnknownDeployments>(config: ResolvedConfig, args?: ArgumentsType): Promise<Environment>;
|
|
322
335
|
|
|
323
336
|
type EnvironmentExtenstion = (env: Environment) => Environment;
|
|
@@ -325,7 +338,7 @@ declare function extendEnvironment(extension: EnvironmentExtenstion): void;
|
|
|
325
338
|
type SignerProtocolFunction = (protocolString: string) => Promise<NamedSigner>;
|
|
326
339
|
declare function handleSignerProtocol(protocol: string, getSigner: SignerProtocolFunction): void;
|
|
327
340
|
|
|
328
|
-
declare function loadDeployments(deploymentsPath: string,
|
|
341
|
+
declare function loadDeployments(deploymentsPath: string, networkName: string, onlyABIAndAddress?: boolean, expectedChain?: {
|
|
329
342
|
chainId: string;
|
|
330
343
|
genesisHash?: `0x${string}`;
|
|
331
344
|
deleteDeploymentsIfDifferentGenesisHash?: boolean;
|
|
@@ -358,4 +371,4 @@ declare const chainById: {
|
|
|
358
371
|
};
|
|
359
372
|
declare function getChain(id: string): Chain$1;
|
|
360
373
|
|
|
361
|
-
export { type AccountDefinition, type AccountType, type Artifact, type Config, type ConfigOptions, type Context, type CreationGasEstimate, type DeployScriptFunction, type DeployScriptModule, type Deployment, type DeploymentConstruction, type DevDoc, type DevErrorDoc, type DevEventDoc, type DevMethodDoc, type Environment, type GasEstimate, type GasEstimates, type Libraries, type NamedSigner, type NoticeUserDoc, type PartialDeployment, type PendingDeployment, type PendingExecution, type PendingTransaction, type ProvidedContext, type ResolvedAccount, type ResolvedConfig, type ResolvedNamedAccounts, type ResolvedNamedSigners, type ScriptCallback, type Storage, type StorageLayout, type TypeDef, type UnknownArtifacts, type UnknownDeployments, type UnknownDeploymentsAcrossNetworks, type UnknownNamedAccounts, type UnresolvedUnknownNamedAccounts, type UserDoc, chainById, execute, executeDeployScripts, extendEnvironment, getChain, handleSignerProtocol, loadAndExecuteDeployments, loadDeployments, loadEnvironment, mergeArtifacts, readAndResolveConfig, readConfig, resolveConfig };
|
|
374
|
+
export { type AccountDefinition, type AccountType, type Artifact, type Config, type ConfigOptions, type Context, type CreationGasEstimate, type DeployScriptFunction, type DeployScriptModule, type Deployment, type DeploymentConstruction, type DevDoc, type DevErrorDoc, type DevEventDoc, type DevMethodDoc, type Environment, type GasEstimate, type GasEstimates, type Libraries, type NamedSigner, type NetworkConfig, type NoticeUserDoc, type PartialDeployment, type PendingDeployment, type PendingExecution, type PendingTransaction, type ProvidedContext, type ResolvedAccount, type ResolvedConfig, type ResolvedNamedAccounts, type ResolvedNamedSigners, type ScriptCallback, type Storage, type StorageLayout, type TypeDef, type UnknownArtifacts, type UnknownDeployments, type UnknownDeploymentsAcrossNetworks, type UnknownNamedAccounts, type UnresolvedUnknownNamedAccounts, type UserDoc, chainById, execute, executeDeployScripts, extendEnvironment, getChain, handleSignerProtocol, loadAndExecuteDeployments, loadDeployments, loadEnvironment, mergeArtifacts, readAndResolveConfig, readConfig, resolveConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EIP1193Account, EIP1193DATA, EIP1193QUANTITY, EIP1193SignerProvider, EIP1193ProviderWithoutEvents, EIP1193WalletProvider, EIP1193TransactionReceipt } from 'eip-1193';
|
|
1
|
+
import { EIP1193Account, EIP1193DATA, EIP1193QUANTITY, EIP1193SignerProvider, EIP1193ProviderWithoutEvents, EIP1193WalletProvider, EIP1193TransactionReceipt, EIP1193GenericRequestProvider } from 'eip-1193';
|
|
2
2
|
import * as abitype from 'abitype';
|
|
3
3
|
import { Abi, Narrow } from 'abitype';
|
|
4
4
|
export { Abi, AbiConstructor, AbiError, AbiEvent, AbiFallback, AbiFunction, AbiReceive } from 'abitype';
|
|
@@ -197,27 +197,38 @@ type Context<Artifacts extends UnknownArtifacts = UnknownArtifacts, NamedAccount
|
|
|
197
197
|
accounts: NamedAccounts;
|
|
198
198
|
artifacts: Artifacts;
|
|
199
199
|
};
|
|
200
|
-
type
|
|
201
|
-
|
|
200
|
+
type NetworkConfigBase = {
|
|
201
|
+
name: string;
|
|
202
|
+
tags: string[];
|
|
203
|
+
fork?: boolean;
|
|
204
|
+
};
|
|
205
|
+
type NetworkConfigForJSONRPC = NetworkConfigBase & {
|
|
206
|
+
nodeUrl: string;
|
|
207
|
+
};
|
|
208
|
+
type NetworkConfigForEIP1193Provider = NetworkConfigBase & {
|
|
209
|
+
provider: EIP1193ProviderWithoutEvents;
|
|
210
|
+
};
|
|
211
|
+
type NetworkConfig = NetworkConfigForJSONRPC | NetworkConfigForEIP1193Provider;
|
|
212
|
+
type Config = {
|
|
213
|
+
network: NetworkConfig;
|
|
214
|
+
networkTags?: string[];
|
|
202
215
|
scripts?: string;
|
|
203
216
|
deployments?: string;
|
|
217
|
+
saveDeployments?: boolean;
|
|
204
218
|
tags?: string[];
|
|
205
219
|
logLevel?: number;
|
|
206
220
|
gasPricing?: {};
|
|
207
221
|
};
|
|
208
|
-
type ConfigForJSONRPC = BaseConfig & {
|
|
209
|
-
networkName: string;
|
|
210
|
-
nodeUrl: string;
|
|
211
|
-
};
|
|
212
|
-
type ConfigForEIP1193Provider = BaseConfig & {
|
|
213
|
-
provider: EIP1193ProviderWithoutEvents;
|
|
214
|
-
};
|
|
215
|
-
type Config = ConfigForJSONRPC | ConfigForEIP1193Provider;
|
|
216
222
|
type ResolvedConfig = Config & {
|
|
217
223
|
deployments: string;
|
|
218
224
|
scripts: string;
|
|
219
225
|
tags: string[];
|
|
220
|
-
|
|
226
|
+
network: {
|
|
227
|
+
name: string;
|
|
228
|
+
tags: string[];
|
|
229
|
+
fork?: boolean;
|
|
230
|
+
};
|
|
231
|
+
saveDeployments?: boolean;
|
|
221
232
|
};
|
|
222
233
|
interface Environment<Artifacts extends UnknownArtifacts = UnknownArtifacts, NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts, Deployments extends UnknownDeployments = UnknownDeployments> {
|
|
223
234
|
config: ResolvedConfig;
|
|
@@ -304,20 +315,22 @@ declare function execute<Artifacts extends UnknownArtifacts = UnknownArtifacts,
|
|
|
304
315
|
dependencies?: string[];
|
|
305
316
|
}): DeployScriptModule<Artifacts, NamedAccounts, ArgumentsType, Deployments>;
|
|
306
317
|
type ConfigOptions = {
|
|
307
|
-
network
|
|
318
|
+
network?: string | {
|
|
319
|
+
fork: string;
|
|
320
|
+
};
|
|
308
321
|
deployments?: string;
|
|
309
322
|
scripts?: string;
|
|
310
323
|
tags?: string;
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
ignoreMissingRPC?: boolean;
|
|
314
|
-
}): Config;
|
|
315
|
-
declare function readAndResolveConfig(options: ConfigOptions, extra?: {
|
|
324
|
+
logLevel?: number;
|
|
325
|
+
provider?: EIP1193ProviderWithoutEvents | EIP1193GenericRequestProvider;
|
|
316
326
|
ignoreMissingRPC?: boolean;
|
|
317
|
-
|
|
327
|
+
saveDeployments?: boolean;
|
|
328
|
+
};
|
|
329
|
+
declare function readConfig(options: ConfigOptions): Config;
|
|
330
|
+
declare function readAndResolveConfig(options: ConfigOptions): ResolvedConfig;
|
|
318
331
|
declare function resolveConfig(config: Config): ResolvedConfig;
|
|
319
|
-
declare function loadEnvironment<Artifacts extends UnknownArtifacts = UnknownArtifacts, NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts>(
|
|
320
|
-
declare function loadAndExecuteDeployments<Artifacts extends UnknownArtifacts = UnknownArtifacts, NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts, ArgumentsType = undefined, Deployments extends UnknownDeployments = UnknownDeployments>(
|
|
332
|
+
declare function loadEnvironment<Artifacts extends UnknownArtifacts = UnknownArtifacts, NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts>(options: ConfigOptions, context: ProvidedContext<Artifacts, NamedAccounts>): Promise<Environment>;
|
|
333
|
+
declare function loadAndExecuteDeployments<Artifacts extends UnknownArtifacts = UnknownArtifacts, NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts, ArgumentsType = undefined, Deployments extends UnknownDeployments = UnknownDeployments>(options: ConfigOptions, args?: ArgumentsType): Promise<Environment>;
|
|
321
334
|
declare function executeDeployScripts<Artifacts extends UnknownArtifacts = UnknownArtifacts, NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts, ArgumentsType = undefined, Deployments extends UnknownDeployments = UnknownDeployments>(config: ResolvedConfig, args?: ArgumentsType): Promise<Environment>;
|
|
322
335
|
|
|
323
336
|
type EnvironmentExtenstion = (env: Environment) => Environment;
|
|
@@ -325,7 +338,7 @@ declare function extendEnvironment(extension: EnvironmentExtenstion): void;
|
|
|
325
338
|
type SignerProtocolFunction = (protocolString: string) => Promise<NamedSigner>;
|
|
326
339
|
declare function handleSignerProtocol(protocol: string, getSigner: SignerProtocolFunction): void;
|
|
327
340
|
|
|
328
|
-
declare function loadDeployments(deploymentsPath: string,
|
|
341
|
+
declare function loadDeployments(deploymentsPath: string, networkName: string, onlyABIAndAddress?: boolean, expectedChain?: {
|
|
329
342
|
chainId: string;
|
|
330
343
|
genesisHash?: `0x${string}`;
|
|
331
344
|
deleteDeploymentsIfDifferentGenesisHash?: boolean;
|
|
@@ -358,4 +371,4 @@ declare const chainById: {
|
|
|
358
371
|
};
|
|
359
372
|
declare function getChain(id: string): Chain$1;
|
|
360
373
|
|
|
361
|
-
export { type AccountDefinition, type AccountType, type Artifact, type Config, type ConfigOptions, type Context, type CreationGasEstimate, type DeployScriptFunction, type DeployScriptModule, type Deployment, type DeploymentConstruction, type DevDoc, type DevErrorDoc, type DevEventDoc, type DevMethodDoc, type Environment, type GasEstimate, type GasEstimates, type Libraries, type NamedSigner, type NoticeUserDoc, type PartialDeployment, type PendingDeployment, type PendingExecution, type PendingTransaction, type ProvidedContext, type ResolvedAccount, type ResolvedConfig, type ResolvedNamedAccounts, type ResolvedNamedSigners, type ScriptCallback, type Storage, type StorageLayout, type TypeDef, type UnknownArtifacts, type UnknownDeployments, type UnknownDeploymentsAcrossNetworks, type UnknownNamedAccounts, type UnresolvedUnknownNamedAccounts, type UserDoc, chainById, execute, executeDeployScripts, extendEnvironment, getChain, handleSignerProtocol, loadAndExecuteDeployments, loadDeployments, loadEnvironment, mergeArtifacts, readAndResolveConfig, readConfig, resolveConfig };
|
|
374
|
+
export { type AccountDefinition, type AccountType, type Artifact, type Config, type ConfigOptions, type Context, type CreationGasEstimate, type DeployScriptFunction, type DeployScriptModule, type Deployment, type DeploymentConstruction, type DevDoc, type DevErrorDoc, type DevEventDoc, type DevMethodDoc, type Environment, type GasEstimate, type GasEstimates, type Libraries, type NamedSigner, type NetworkConfig, type NoticeUserDoc, type PartialDeployment, type PendingDeployment, type PendingExecution, type PendingTransaction, type ProvidedContext, type ResolvedAccount, type ResolvedConfig, type ResolvedNamedAccounts, type ResolvedNamedSigners, type ScriptCallback, type Storage, type StorageLayout, type TypeDef, type UnknownArtifacts, type UnknownDeployments, type UnknownDeploymentsAcrossNetworks, type UnknownNamedAccounts, type UnresolvedUnknownNamedAccounts, type UserDoc, chainById, execute, executeDeployScripts, extendEnvironment, getChain, handleSignerProtocol, loadAndExecuteDeployments, loadDeployments, loadEnvironment, mergeArtifacts, readAndResolveConfig, readConfig, resolveConfig };
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
2
|
import {loadEnv} from 'ldenv';
|
|
3
|
-
import {loadAndExecuteDeployments, readConfig} from '.';
|
|
3
|
+
import {ConfigOptions, loadAndExecuteDeployments, readConfig} from '.';
|
|
4
4
|
import {Command} from 'commander';
|
|
5
5
|
import pkg from '../package.json';
|
|
6
6
|
|
|
@@ -20,6 +20,5 @@ program
|
|
|
20
20
|
.parse(process.argv);
|
|
21
21
|
|
|
22
22
|
const options = program.opts();
|
|
23
|
-
const config = readConfig(options as any);
|
|
24
23
|
|
|
25
|
-
loadAndExecuteDeployments({...
|
|
24
|
+
loadAndExecuteDeployments({...(options as ConfigOptions), logLevel: 1});
|
|
@@ -5,12 +5,12 @@ import {UnknownDeployments} from './types';
|
|
|
5
5
|
|
|
6
6
|
export function loadDeployments(
|
|
7
7
|
deploymentsPath: string,
|
|
8
|
-
|
|
8
|
+
networkName: string,
|
|
9
9
|
onlyABIAndAddress?: boolean,
|
|
10
10
|
expectedChain?: {chainId: string; genesisHash?: `0x${string}`; deleteDeploymentsIfDifferentGenesisHash?: boolean}
|
|
11
11
|
): {deployments: UnknownDeployments; chainId?: string; genesisHash?: `0x${string}`} {
|
|
12
12
|
const deploymentsFound: UnknownDeployments = {};
|
|
13
|
-
const deployPath = path.join(deploymentsPath,
|
|
13
|
+
const deployPath = path.join(deploymentsPath, networkName);
|
|
14
14
|
|
|
15
15
|
let filesStats;
|
|
16
16
|
try {
|
|
@@ -34,7 +34,7 @@ export function loadDeployments(
|
|
|
34
34
|
genesisHash = chainData.genesisHash;
|
|
35
35
|
} else {
|
|
36
36
|
throw new Error(
|
|
37
|
-
`A '.chain' or '.chainId' file is expected to be present in the deployment folder for network ${
|
|
37
|
+
`A '.chain' or '.chainId' file is expected to be present in the deployment folder for network ${networkName}`
|
|
38
38
|
);
|
|
39
39
|
}
|
|
40
40
|
}
|
package/src/environment/index.ts
CHANGED
|
@@ -85,7 +85,9 @@ export async function createEnvironment<
|
|
|
85
85
|
providedContext: ProvidedContext<Artifacts, NamedAccounts>
|
|
86
86
|
): Promise<{internal: InternalEnvironment; external: Environment<Artifacts, NamedAccounts, Deployments>}> {
|
|
87
87
|
const provider =
|
|
88
|
-
'provider' in config
|
|
88
|
+
'provider' in config.network
|
|
89
|
+
? config.network.provider
|
|
90
|
+
: (new JSONRPCHTTPProvider(config.network.nodeUrl) as EIP1193ProviderWithoutEvents);
|
|
89
91
|
|
|
90
92
|
const transport = custom(provider);
|
|
91
93
|
const viemClient = createPublicClient({transport});
|
|
@@ -100,24 +102,32 @@ export async function createEnvironment<
|
|
|
100
102
|
|
|
101
103
|
let networkName: string;
|
|
102
104
|
let saveDeployments: boolean;
|
|
103
|
-
let
|
|
105
|
+
let networkTags: {[tag: string]: boolean} = {};
|
|
106
|
+
for (const networkTag of config.network.tags) {
|
|
107
|
+
networkTags[networkTag] = true;
|
|
108
|
+
}
|
|
109
|
+
|
|
104
110
|
if ('nodeUrl' in config) {
|
|
105
|
-
networkName = config.
|
|
111
|
+
networkName = config.network.name;
|
|
106
112
|
saveDeployments = true;
|
|
107
113
|
} else {
|
|
108
|
-
if (config.
|
|
109
|
-
networkName = config.
|
|
114
|
+
if (config.network.name) {
|
|
115
|
+
networkName = config.network.name;
|
|
110
116
|
} else {
|
|
111
117
|
networkName = 'memory';
|
|
112
118
|
}
|
|
113
119
|
if (networkName === 'memory' || networkName === 'hardhat') {
|
|
114
|
-
|
|
120
|
+
networkTags['memory'] = true;
|
|
115
121
|
saveDeployments = false;
|
|
116
122
|
} else {
|
|
117
123
|
saveDeployments = true;
|
|
118
124
|
}
|
|
119
125
|
}
|
|
120
126
|
|
|
127
|
+
if (config.saveDeployments !== undefined) {
|
|
128
|
+
saveDeployments = config.saveDeployments;
|
|
129
|
+
}
|
|
130
|
+
|
|
121
131
|
const resolvedAccounts: {[name: string]: ResolvedAccount} = {};
|
|
122
132
|
|
|
123
133
|
const accountCache: {[name: string]: ResolvedAccount} = {};
|
|
@@ -205,16 +215,26 @@ export async function createEnvironment<
|
|
|
205
215
|
artifacts: providedContext.artifacts as Artifacts,
|
|
206
216
|
network: {
|
|
207
217
|
name: networkName,
|
|
218
|
+
fork: config.network.fork,
|
|
208
219
|
saveDeployments,
|
|
209
|
-
tags,
|
|
220
|
+
tags: networkTags,
|
|
210
221
|
},
|
|
211
222
|
};
|
|
212
223
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
224
|
+
// console.log(`context`, JSON.stringify(context.network, null, 2));
|
|
225
|
+
|
|
226
|
+
const {deployments} = loadDeployments(
|
|
227
|
+
config.deployments,
|
|
228
|
+
context.network.name,
|
|
229
|
+
false,
|
|
230
|
+
context.network.fork
|
|
231
|
+
? undefined
|
|
232
|
+
: {
|
|
233
|
+
chainId,
|
|
234
|
+
genesisHash,
|
|
235
|
+
deleteDeploymentsIfDifferentGenesisHash: true,
|
|
236
|
+
}
|
|
237
|
+
);
|
|
218
238
|
|
|
219
239
|
const namedAccounts: {[name: string]: EIP1193Account} = {};
|
|
220
240
|
const namedSigners: {[name: string]: NamedSigner} = {};
|
package/src/environment/types.ts
CHANGED
|
@@ -209,30 +209,47 @@ export type Context<
|
|
|
209
209
|
artifacts: Artifacts;
|
|
210
210
|
};
|
|
211
211
|
|
|
212
|
-
type
|
|
213
|
-
|
|
212
|
+
type NetworkConfigBase = {
|
|
213
|
+
name: string;
|
|
214
|
+
tags: string[];
|
|
215
|
+
fork?: boolean;
|
|
216
|
+
};
|
|
217
|
+
type NetworkConfigForJSONRPC = NetworkConfigBase & {
|
|
218
|
+
nodeUrl: string;
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
type NetworkConfigForEIP1193Provider = NetworkConfigBase & {
|
|
222
|
+
provider: EIP1193ProviderWithoutEvents;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
export type NetworkConfig = NetworkConfigForJSONRPC | NetworkConfigForEIP1193Provider;
|
|
226
|
+
|
|
227
|
+
export type Config = {
|
|
228
|
+
network: NetworkConfig;
|
|
229
|
+
networkTags?: string[];
|
|
214
230
|
scripts?: string;
|
|
215
231
|
deployments?: string;
|
|
232
|
+
saveDeployments?: boolean;
|
|
216
233
|
|
|
217
234
|
tags?: string[];
|
|
235
|
+
|
|
218
236
|
logLevel?: number;
|
|
219
237
|
// TODO
|
|
220
238
|
gasPricing?: {};
|
|
221
239
|
};
|
|
222
240
|
|
|
223
|
-
type
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
241
|
+
export type ResolvedConfig = Config & {
|
|
242
|
+
deployments: string;
|
|
243
|
+
scripts: string;
|
|
244
|
+
tags: string[];
|
|
245
|
+
network: {
|
|
246
|
+
name: string;
|
|
247
|
+
tags: string[];
|
|
248
|
+
fork?: boolean;
|
|
249
|
+
};
|
|
250
|
+
saveDeployments?: boolean;
|
|
230
251
|
};
|
|
231
252
|
|
|
232
|
-
export type Config = ConfigForJSONRPC | ConfigForEIP1193Provider;
|
|
233
|
-
|
|
234
|
-
export type ResolvedConfig = Config & {deployments: string; scripts: string; tags: string[]; networkName: string};
|
|
235
|
-
|
|
236
253
|
export interface Environment<
|
|
237
254
|
Artifacts extends UnknownArtifacts = UnknownArtifacts,
|
|
238
255
|
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
package/src/executor/index.ts
CHANGED
|
@@ -13,6 +13,7 @@ import type {
|
|
|
13
13
|
import {createEnvironment} from '../environment';
|
|
14
14
|
import {DeployScriptFunction, DeployScriptModule, ProvidedContext} from './types';
|
|
15
15
|
import {logger, setLogLevel, spin} from '../internal/logging';
|
|
16
|
+
import {EIP1193GenericRequestProvider, EIP1193ProviderWithoutEvents} from 'eip-1193';
|
|
16
17
|
|
|
17
18
|
if (!process.env['ROCKETH_SKIP_ESBUILD']) {
|
|
18
19
|
require('esbuild-register/dist/node').register();
|
|
@@ -39,28 +40,70 @@ export function execute<
|
|
|
39
40
|
return scriptModule as unknown as DeployScriptModule<Artifacts, NamedAccounts, ArgumentsType, Deployments>;
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
export type ConfigOptions = {
|
|
43
|
+
export type ConfigOptions = {
|
|
44
|
+
network?: string | {fork: string};
|
|
45
|
+
deployments?: string;
|
|
46
|
+
scripts?: string;
|
|
47
|
+
tags?: string;
|
|
48
|
+
logLevel?: number;
|
|
49
|
+
provider?: EIP1193ProviderWithoutEvents | EIP1193GenericRequestProvider;
|
|
50
|
+
ignoreMissingRPC?: boolean;
|
|
51
|
+
saveDeployments?: boolean;
|
|
52
|
+
};
|
|
43
53
|
|
|
44
|
-
export function readConfig(options: ConfigOptions
|
|
45
|
-
type Networks = {[name: string]: {rpcUrl
|
|
46
|
-
type ConfigFile = {networks: Networks};
|
|
54
|
+
export function readConfig(options: ConfigOptions): Config {
|
|
55
|
+
type Networks = {[name: string]: {rpcUrl?: string; tags?: string[]}};
|
|
56
|
+
type ConfigFile = {networks: Networks; deployments?: string; scripts?: string};
|
|
47
57
|
let configFile: ConfigFile | undefined;
|
|
48
58
|
try {
|
|
49
59
|
const configString = fs.readFileSync('./rocketh.json', 'utf-8');
|
|
50
60
|
configFile = JSON.parse(configString);
|
|
51
61
|
} catch {}
|
|
52
62
|
|
|
53
|
-
|
|
63
|
+
if (configFile) {
|
|
64
|
+
if (!options.deployments && configFile.deployments) {
|
|
65
|
+
options.deployments = configFile.deployments;
|
|
66
|
+
}
|
|
67
|
+
if (!options.scripts && configFile.scripts) {
|
|
68
|
+
options.scripts = configFile.scripts;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
54
72
|
const fromEnv = process.env['ETH_NODE_URI_' + options.network];
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
73
|
+
const fork = typeof options.network !== 'string';
|
|
74
|
+
let networkName = 'memory';
|
|
75
|
+
if (options.network) {
|
|
76
|
+
if (typeof options.network === 'string') {
|
|
77
|
+
networkName = options.network;
|
|
78
|
+
} else if ('fork' in options.network) {
|
|
79
|
+
networkName = options.network.fork;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
let networkTags: string[] = (configFile?.networks && configFile?.networks[networkName]?.tags) || [];
|
|
84
|
+
if (!options.provider) {
|
|
85
|
+
let nodeUrl: string;
|
|
86
|
+
if (typeof fromEnv === 'string') {
|
|
87
|
+
nodeUrl = fromEnv;
|
|
88
|
+
} else {
|
|
89
|
+
if (configFile) {
|
|
90
|
+
const network = configFile.networks && configFile.networks[networkName];
|
|
91
|
+
if (network && network.rpcUrl) {
|
|
92
|
+
nodeUrl = network.rpcUrl;
|
|
93
|
+
} else {
|
|
94
|
+
if (options?.ignoreMissingRPC) {
|
|
95
|
+
nodeUrl = '';
|
|
96
|
+
} else {
|
|
97
|
+
if (options.network === 'localhost') {
|
|
98
|
+
nodeUrl = 'http://127.0.0.1:8545';
|
|
99
|
+
} else {
|
|
100
|
+
logger.error(`network "${options.network}" is not configured. Please add it to the rocketh.json file`);
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
62
105
|
} else {
|
|
63
|
-
if (
|
|
106
|
+
if (options?.ignoreMissingRPC) {
|
|
64
107
|
nodeUrl = '';
|
|
65
108
|
} else {
|
|
66
109
|
if (options.network === 'localhost') {
|
|
@@ -71,40 +114,50 @@ export function readConfig(options: ConfigOptions, extra?: {ignoreMissingRPC?: b
|
|
|
71
114
|
}
|
|
72
115
|
}
|
|
73
116
|
}
|
|
74
|
-
} else {
|
|
75
|
-
if (extra?.ignoreMissingRPC) {
|
|
76
|
-
nodeUrl = '';
|
|
77
|
-
} else {
|
|
78
|
-
if (options.network === 'localhost') {
|
|
79
|
-
nodeUrl = 'http://127.0.0.1:8545';
|
|
80
|
-
} else {
|
|
81
|
-
logger.error(`network "${options.network}" is not configured. Please add it to the rocketh.json file`);
|
|
82
|
-
process.exit(1);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
117
|
}
|
|
118
|
+
return {
|
|
119
|
+
network: {
|
|
120
|
+
nodeUrl,
|
|
121
|
+
name: networkName,
|
|
122
|
+
tags: networkTags,
|
|
123
|
+
fork,
|
|
124
|
+
},
|
|
125
|
+
deployments: options.deployments,
|
|
126
|
+
saveDeployments: options.saveDeployments,
|
|
127
|
+
scripts: options.scripts,
|
|
128
|
+
tags: typeof options.tags === 'undefined' ? undefined : options.tags.split(','),
|
|
129
|
+
logLevel: options.logLevel,
|
|
130
|
+
};
|
|
131
|
+
} else {
|
|
132
|
+
return {
|
|
133
|
+
network: {
|
|
134
|
+
provider: options.provider as EIP1193ProviderWithoutEvents,
|
|
135
|
+
name: networkName,
|
|
136
|
+
tags: networkTags,
|
|
137
|
+
fork,
|
|
138
|
+
},
|
|
139
|
+
deployments: options.deployments,
|
|
140
|
+
saveDeployments: options.saveDeployments,
|
|
141
|
+
scripts: options.scripts,
|
|
142
|
+
tags: typeof options.tags === 'undefined' ? undefined : options.tags.split(','),
|
|
143
|
+
logLevel: options.logLevel,
|
|
144
|
+
};
|
|
86
145
|
}
|
|
87
|
-
|
|
88
|
-
return {
|
|
89
|
-
nodeUrl,
|
|
90
|
-
networkName: options.network,
|
|
91
|
-
deployments: options.deployments,
|
|
92
|
-
scripts: options.scripts,
|
|
93
|
-
tags: typeof options.tags === 'undefined' ? undefined : options.tags.split(','),
|
|
94
|
-
};
|
|
95
146
|
}
|
|
96
147
|
|
|
97
|
-
export function readAndResolveConfig(options: ConfigOptions
|
|
98
|
-
return resolveConfig(readConfig(options
|
|
148
|
+
export function readAndResolveConfig(options: ConfigOptions): ResolvedConfig {
|
|
149
|
+
return resolveConfig(readConfig(options));
|
|
99
150
|
}
|
|
100
151
|
|
|
101
152
|
export function resolveConfig(config: Config): ResolvedConfig {
|
|
102
153
|
const resolvedConfig: ResolvedConfig = {
|
|
103
154
|
...config,
|
|
104
|
-
|
|
155
|
+
network: config.network, // TODO default to || {name: 'memory'....}
|
|
105
156
|
deployments: config.deployments || 'deployments',
|
|
106
157
|
scripts: config.scripts || 'deploy',
|
|
107
158
|
tags: config.tags || [],
|
|
159
|
+
networkTags: config.networkTags || [],
|
|
160
|
+
saveDeployments: config.saveDeployments,
|
|
108
161
|
};
|
|
109
162
|
return resolvedConfig;
|
|
110
163
|
}
|
|
@@ -112,8 +165,8 @@ export function resolveConfig(config: Config): ResolvedConfig {
|
|
|
112
165
|
export async function loadEnvironment<
|
|
113
166
|
Artifacts extends UnknownArtifacts = UnknownArtifacts,
|
|
114
167
|
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts
|
|
115
|
-
>(
|
|
116
|
-
const resolvedConfig =
|
|
168
|
+
>(options: ConfigOptions, context: ProvidedContext<Artifacts, NamedAccounts>): Promise<Environment> {
|
|
169
|
+
const resolvedConfig = readAndResolveConfig(options);
|
|
117
170
|
const {external, internal} = await createEnvironment(resolvedConfig, context);
|
|
118
171
|
return external;
|
|
119
172
|
}
|
|
@@ -123,8 +176,10 @@ export async function loadAndExecuteDeployments<
|
|
|
123
176
|
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
124
177
|
ArgumentsType = undefined,
|
|
125
178
|
Deployments extends UnknownDeployments = UnknownDeployments
|
|
126
|
-
>(
|
|
127
|
-
const resolvedConfig =
|
|
179
|
+
>(options: ConfigOptions, args?: ArgumentsType): Promise<Environment> {
|
|
180
|
+
const resolvedConfig = readAndResolveConfig(options);
|
|
181
|
+
// console.log(JSON.stringify(options, null, 2));
|
|
182
|
+
// console.log(JSON.stringify(resolvedConfig, null, 2));
|
|
128
183
|
return executeDeployScripts<Artifacts, NamedAccounts, ArgumentsType, Deployments>(resolvedConfig, args);
|
|
129
184
|
}
|
|
130
185
|
|