rocketh 0.15.0-testing.17 → 0.15.0-testing.3
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 -12
- 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
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import type {Abi, AbiConstructor, AbiError, AbiEvent, AbiFallback, AbiFunction, AbiReceive, Narrow} from 'abitype';
|
|
2
|
+
import {
|
|
3
|
+
EIP1193Account,
|
|
4
|
+
EIP1193DATA,
|
|
5
|
+
EIP1193ProviderWithoutEvents,
|
|
6
|
+
EIP1193QUANTITY,
|
|
7
|
+
EIP1193SignerProvider,
|
|
8
|
+
EIP1193TransactionReceipt,
|
|
9
|
+
EIP1193WalletProvider,
|
|
10
|
+
} from 'eip-1193';
|
|
11
|
+
import type {Address, Chain, DeployContractParameters} from 'viem';
|
|
12
|
+
import {
|
|
13
|
+
DeterministicDeploymentInfo,
|
|
14
|
+
type Create2DeterministicDeploymentInfo,
|
|
15
|
+
type Create3DeterministicDeploymentInfo,
|
|
16
|
+
} from '../executor/index.js';
|
|
17
|
+
import {ProgressIndicator} from '../internal/logging.js';
|
|
18
|
+
import {TransactionHashTracker} from './providers/TransactionHashTracker.js';
|
|
19
|
+
import {SignerProtocolFunction} from './index.js';
|
|
20
|
+
import {ChainInfo} from '../executor/types.js';
|
|
21
|
+
|
|
22
|
+
export type {Abi, AbiConstructor, AbiError, AbiEvent, AbiFallback, AbiFunction, AbiReceive};
|
|
23
|
+
export type Libraries = {readonly [libraryName: string]: EIP1193Account};
|
|
24
|
+
|
|
25
|
+
export type GasEstimate = 'infinite' | `${number}`;
|
|
26
|
+
export type CreationGasEstimate = {
|
|
27
|
+
readonly codeDepositCost: GasEstimate;
|
|
28
|
+
readonly executionCost: GasEstimate;
|
|
29
|
+
readonly totalCost: GasEstimate;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type GasEstimates = {
|
|
33
|
+
readonly creation?: CreationGasEstimate;
|
|
34
|
+
readonly external?: {
|
|
35
|
+
readonly [signature: string]: GasEstimate;
|
|
36
|
+
};
|
|
37
|
+
readonly internal?: {
|
|
38
|
+
readonly [signature: string]: GasEstimate;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type Storage = {
|
|
43
|
+
readonly astId: number;
|
|
44
|
+
readonly contract: string; // canonical name <path>:<name>
|
|
45
|
+
readonly label: string; // variable name
|
|
46
|
+
readonly offset: number;
|
|
47
|
+
readonly slot: `${number}`; // slot bytes32
|
|
48
|
+
readonly type: string; // "t_mapping(t_uint256,t_struct(Cell)12382_storage)"
|
|
49
|
+
};
|
|
50
|
+
export type TypeDef = {
|
|
51
|
+
readonly encoding: 'inplace' | string; // TODO
|
|
52
|
+
readonly label: 'address' | 'byte24' | string; // TODO
|
|
53
|
+
readonly numberOfBytes: `${number}`;
|
|
54
|
+
readonly key?: string; // ref to another typedef
|
|
55
|
+
readonly value?: string;
|
|
56
|
+
readonly members?: readonly Storage[];
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export type DevEventDoc = {
|
|
60
|
+
readonly details?: string;
|
|
61
|
+
readonly params?: {readonly [name: string]: string};
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export type DevErrorDoc = {
|
|
65
|
+
readonly details?: string; // TODO check if it can exists
|
|
66
|
+
readonly params?: {readonly [name: string]: string};
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export type DevMethodDoc = {
|
|
70
|
+
readonly details?: string; // TODO check if it can exists
|
|
71
|
+
readonly params?: {readonly [name: string]: string};
|
|
72
|
+
readonly returns?: {
|
|
73
|
+
readonly [key: string | `_${number}`]: string; // description
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export type NoticeUserDoc = {
|
|
78
|
+
readonly notice?: string;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export type DevDoc = {
|
|
82
|
+
readonly events?: {
|
|
83
|
+
[signature: string]: DevEventDoc;
|
|
84
|
+
};
|
|
85
|
+
readonly errors?: {
|
|
86
|
+
[signature: string]: readonly DevErrorDoc[];
|
|
87
|
+
};
|
|
88
|
+
readonly methods: {
|
|
89
|
+
[signature: string]: DevMethodDoc;
|
|
90
|
+
};
|
|
91
|
+
readonly kind?: 'dev';
|
|
92
|
+
readonly version?: number;
|
|
93
|
+
readonly title?: string;
|
|
94
|
+
readonly author?: string;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export type UserDoc = {
|
|
98
|
+
readonly events?: {
|
|
99
|
+
readonly [signature: string]: NoticeUserDoc;
|
|
100
|
+
};
|
|
101
|
+
readonly errors?: {
|
|
102
|
+
readonly [signature: string]: readonly NoticeUserDoc[];
|
|
103
|
+
};
|
|
104
|
+
readonly kind?: 'user';
|
|
105
|
+
readonly methods: {
|
|
106
|
+
readonly [signature: string]: NoticeUserDoc;
|
|
107
|
+
};
|
|
108
|
+
readonly version?: number;
|
|
109
|
+
readonly notice?: string;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export type JSONTypePlusBigInt =
|
|
113
|
+
| bigint
|
|
114
|
+
| string
|
|
115
|
+
| number
|
|
116
|
+
| boolean
|
|
117
|
+
| null
|
|
118
|
+
| JSONTypePlusBigInt[]
|
|
119
|
+
| {[key: string]: JSONTypePlusBigInt};
|
|
120
|
+
export type LinkedData = Record<string, JSONTypePlusBigInt>;
|
|
121
|
+
|
|
122
|
+
export type StorageLayout = {
|
|
123
|
+
readonly storage: readonly Storage[];
|
|
124
|
+
readonly types: {
|
|
125
|
+
readonly [name: string]: TypeDef;
|
|
126
|
+
} | null;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export type MinimalDeployment<TAbi extends Abi = Abi> = {
|
|
130
|
+
readonly address: EIP1193Account;
|
|
131
|
+
readonly abi: Narrow<TAbi>;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export type Deployment<TAbi extends Abi> = MinimalDeployment<TAbi> & {
|
|
135
|
+
readonly bytecode: EIP1193DATA;
|
|
136
|
+
readonly argsData: EIP1193DATA;
|
|
137
|
+
readonly metadata: string;
|
|
138
|
+
|
|
139
|
+
readonly transaction?: {
|
|
140
|
+
readonly hash: EIP1193DATA;
|
|
141
|
+
readonly origin?: EIP1193Account;
|
|
142
|
+
readonly nonce?: EIP1193DATA;
|
|
143
|
+
};
|
|
144
|
+
readonly receipt?: {
|
|
145
|
+
blockHash: EIP1193DATA;
|
|
146
|
+
blockNumber: EIP1193QUANTITY;
|
|
147
|
+
transactionIndex: EIP1193QUANTITY;
|
|
148
|
+
};
|
|
149
|
+
readonly numDeployments?: number;
|
|
150
|
+
readonly libraries?: Libraries;
|
|
151
|
+
readonly linkedData?: LinkedData;
|
|
152
|
+
readonly deployedBytecode?: EIP1193DATA;
|
|
153
|
+
readonly linkReferences?: any; // TODO
|
|
154
|
+
readonly deployedLinkReferences?: any; // TODO
|
|
155
|
+
readonly contractName?: string;
|
|
156
|
+
readonly sourceName?: string; // relative path
|
|
157
|
+
readonly devdoc?: DevDoc;
|
|
158
|
+
readonly evm?: {
|
|
159
|
+
readonly gasEstimates?: GasEstimates | null;
|
|
160
|
+
} & any;
|
|
161
|
+
readonly storageLayout?: StorageLayout;
|
|
162
|
+
readonly userdoc?: UserDoc;
|
|
163
|
+
} & Record<string, unknown>;
|
|
164
|
+
|
|
165
|
+
export type Artifact<TAbi extends Abi = Abi> = {
|
|
166
|
+
readonly abi: TAbi;
|
|
167
|
+
readonly bytecode: EIP1193DATA;
|
|
168
|
+
readonly metadata: string;
|
|
169
|
+
readonly deployedBytecode?: EIP1193DATA;
|
|
170
|
+
readonly linkReferences?: any; // TODO
|
|
171
|
+
readonly deployedLinkReferences?: any; // TODO
|
|
172
|
+
readonly contractName?: string;
|
|
173
|
+
readonly sourceName?: string; // relative path
|
|
174
|
+
readonly devdoc?: DevDoc;
|
|
175
|
+
readonly evm?: {
|
|
176
|
+
readonly gasEstimates?: GasEstimates | null;
|
|
177
|
+
} & any;
|
|
178
|
+
readonly storageLayout?: StorageLayout;
|
|
179
|
+
readonly userdoc?: UserDoc;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
export type AccountDefinition = EIP1193Account | string | number;
|
|
183
|
+
|
|
184
|
+
export type AccountType =
|
|
185
|
+
| AccountDefinition
|
|
186
|
+
| {
|
|
187
|
+
[networkOrChainId: string | number]: AccountDefinition;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export type ResolvedAccount = {
|
|
191
|
+
address: EIP1193Account;
|
|
192
|
+
} & Signer;
|
|
193
|
+
|
|
194
|
+
export type UnknownDeployments = Record<string, Deployment<Abi>>;
|
|
195
|
+
export type UnknownNamedAccounts = {
|
|
196
|
+
[name: string]: EIP1193Account;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export type UnresolvedUnknownNamedAccounts = {
|
|
200
|
+
[name: string]: AccountType;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
export type ResolvedNamedAccounts<T extends UnresolvedUnknownNamedAccounts> = {
|
|
204
|
+
[Property in keyof T]: EIP1193Account;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
export type DataType<T> = {
|
|
208
|
+
[networkOrChainId: string | number]: T;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
export type UnknownData = {
|
|
212
|
+
[name: string]: unknown;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export type UnresolvedNetworkSpecificData = {
|
|
216
|
+
[name: string]: DataType<unknown>;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
export type ResolvedNetworkSpecificData<T extends UnresolvedNetworkSpecificData> = {
|
|
220
|
+
[Property in keyof T]: T[Property] extends DataType<infer U> ? U : never;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
export type Signer =
|
|
224
|
+
| {type: 'signerOnly'; signer: EIP1193SignerProvider}
|
|
225
|
+
| {type: 'remote'; signer: EIP1193ProviderWithoutEvents}
|
|
226
|
+
| {type: 'wallet'; signer: EIP1193WalletProvider};
|
|
227
|
+
|
|
228
|
+
export type ResolvedNamedSigners<T extends UnknownNamedAccounts> = {
|
|
229
|
+
[Property in keyof T]: Signer;
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
export type UnknownDeploymentsAcrossNetworks = Record<string, UnknownDeployments>;
|
|
233
|
+
|
|
234
|
+
type TargetConfigBase = {
|
|
235
|
+
name: string;
|
|
236
|
+
tags: string[];
|
|
237
|
+
fork?: boolean;
|
|
238
|
+
deterministicDeployment?: DeterministicDeploymentInfo;
|
|
239
|
+
scripts?: string | string[];
|
|
240
|
+
chainInfo?: ChainInfo;
|
|
241
|
+
pollingInterval?: number;
|
|
242
|
+
properties?: Record<string, JSONTypePlusBigInt>;
|
|
243
|
+
};
|
|
244
|
+
type TargetConfigForJSONRPC = TargetConfigBase & {
|
|
245
|
+
nodeUrl: string;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
type TargetConfigForEIP1193Provider = TargetConfigBase & {
|
|
249
|
+
provider: EIP1193ProviderWithoutEvents;
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
export type TargetConfig = TargetConfigForJSONRPC | TargetConfigForEIP1193Provider;
|
|
253
|
+
|
|
254
|
+
export type Config<
|
|
255
|
+
AccountsType extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
256
|
+
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData
|
|
257
|
+
> = {
|
|
258
|
+
target: TargetConfig;
|
|
259
|
+
targetTags?: string[];
|
|
260
|
+
scripts?: string | string[];
|
|
261
|
+
deployments?: string;
|
|
262
|
+
saveDeployments?: boolean;
|
|
263
|
+
|
|
264
|
+
tags?: string[];
|
|
265
|
+
askBeforeProceeding?: boolean;
|
|
266
|
+
reportGasUse?: boolean;
|
|
267
|
+
|
|
268
|
+
logLevel?: number;
|
|
269
|
+
// TODO
|
|
270
|
+
gasPricing?: {};
|
|
271
|
+
accounts?: AccountsType;
|
|
272
|
+
|
|
273
|
+
data?: Data;
|
|
274
|
+
signerProtocols?: Record<string, SignerProtocolFunction>;
|
|
275
|
+
extra?: Record<string, unknown>;
|
|
276
|
+
defaultPollingInterval?: number;
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
export type ResolvedConfig<
|
|
280
|
+
AccountsType extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
281
|
+
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData
|
|
282
|
+
> = Config & {
|
|
283
|
+
deployments: string;
|
|
284
|
+
scripts: string[];
|
|
285
|
+
tags: string[];
|
|
286
|
+
target: {
|
|
287
|
+
pollingInterval: number;
|
|
288
|
+
name: string;
|
|
289
|
+
tags: string[];
|
|
290
|
+
fork?: boolean;
|
|
291
|
+
deterministicDeployment: {
|
|
292
|
+
create2: Create2DeterministicDeploymentInfo;
|
|
293
|
+
create3: Create3DeterministicDeploymentInfo;
|
|
294
|
+
};
|
|
295
|
+
nodeUrl?: string;
|
|
296
|
+
chain?: ChainInfo;
|
|
297
|
+
properties?: Record<string, JSONTypePlusBigInt>;
|
|
298
|
+
};
|
|
299
|
+
saveDeployments?: boolean;
|
|
300
|
+
askBeforeProceeding?: boolean;
|
|
301
|
+
reportGasUse?: boolean;
|
|
302
|
+
accounts: AccountsType;
|
|
303
|
+
data: Data;
|
|
304
|
+
signerProtocols: Record<string, SignerProtocolFunction>;
|
|
305
|
+
extra: Record<string, unknown>;
|
|
306
|
+
defaultPollingInterval: number;
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
export interface Environment<
|
|
310
|
+
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
311
|
+
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData,
|
|
312
|
+
Deployments extends UnknownDeployments = UnknownDeployments,
|
|
313
|
+
Extra extends Record<string, unknown> = Record<string, unknown>
|
|
314
|
+
> {
|
|
315
|
+
config: ResolvedConfig;
|
|
316
|
+
network: {
|
|
317
|
+
chain: Chain;
|
|
318
|
+
name: string;
|
|
319
|
+
tags: {[tag: string]: boolean};
|
|
320
|
+
provider: TransactionHashTracker;
|
|
321
|
+
};
|
|
322
|
+
deployments: Deployments;
|
|
323
|
+
namedAccounts: ResolvedNamedAccounts<NamedAccounts>;
|
|
324
|
+
data: ResolvedNetworkSpecificData<Data>;
|
|
325
|
+
namedSigners: ResolvedNamedSigners<ResolvedNamedAccounts<NamedAccounts>>;
|
|
326
|
+
unnamedAccounts: EIP1193Account[];
|
|
327
|
+
// unnamedSigners: {type: 'remote'; signer: EIP1193ProviderWithoutEvents}[];
|
|
328
|
+
addressSigners: {[name: `0x${string}`]: Signer};
|
|
329
|
+
save<TAbi extends Abi = Abi>(
|
|
330
|
+
name: string,
|
|
331
|
+
deployment: Deployment<TAbi>,
|
|
332
|
+
options?: {doNotCountAsNewDeployment?: boolean}
|
|
333
|
+
): Promise<Deployment<TAbi>>;
|
|
334
|
+
savePendingDeployment<TAbi extends Abi = Abi>(pendingDeployment: PendingDeployment<TAbi>): Promise<Deployment<TAbi>>;
|
|
335
|
+
savePendingExecution(pendingExecution: PendingExecution): Promise<EIP1193TransactionReceipt>;
|
|
336
|
+
get<TAbi extends Abi>(name: string): Deployment<TAbi>;
|
|
337
|
+
getOrNull<TAbi extends Abi>(name: string): Deployment<TAbi> | null;
|
|
338
|
+
fromAddressToNamedABI<TAbi extends Abi>(address: Address): {mergedABI: TAbi; names: string[]};
|
|
339
|
+
fromAddressToNamedABIOrNull<TAbi extends Abi>(address: Address): {mergedABI: TAbi; names: string[]} | null;
|
|
340
|
+
showMessage(message: string): void;
|
|
341
|
+
showProgress(message?: string): ProgressIndicator;
|
|
342
|
+
|
|
343
|
+
hasMigrationBeenDone(id: string): boolean;
|
|
344
|
+
extra?: Extra;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
export type DeploymentConstruction<TAbi extends Abi> = Omit<
|
|
348
|
+
DeployContractParameters<TAbi>,
|
|
349
|
+
'bytecode' | 'account' | 'abi' | 'chain'
|
|
350
|
+
> & {account: string | EIP1193Account; artifact: Artifact<TAbi>};
|
|
351
|
+
|
|
352
|
+
export type PartialDeployment<TAbi extends Abi = Abi> = Artifact<TAbi> & {
|
|
353
|
+
argsData: EIP1193DATA;
|
|
354
|
+
libraries?: Libraries;
|
|
355
|
+
linkedData?: LinkedData;
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
export type PendingDeployment<TAbi extends Abi = Abi> = {
|
|
359
|
+
type: 'deployment';
|
|
360
|
+
name?: string;
|
|
361
|
+
transaction: {
|
|
362
|
+
hash: `0x${string}`;
|
|
363
|
+
nonce?: `0x${string}`;
|
|
364
|
+
origin?: `0x${string}`;
|
|
365
|
+
};
|
|
366
|
+
partialDeployment: PartialDeployment<TAbi>;
|
|
367
|
+
expectedAddress?: `0x${string}`; // TODO we could make that a event specification so we can get address from factory event
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
export type PendingExecution = {
|
|
371
|
+
type: 'execution';
|
|
372
|
+
description?: string;
|
|
373
|
+
transaction: {
|
|
374
|
+
hash: `0x${string}`;
|
|
375
|
+
nonce?: `0x${string}`;
|
|
376
|
+
origin?: `0x${string}`;
|
|
377
|
+
};
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
export type PendingTransaction = PendingDeployment | PendingExecution;
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
+
import type {Chain} from 'viem/chains';
|
|
1
2
|
import * as chains from 'viem/chains';
|
|
3
|
+
import {ResolvedConfig} from '../types.js';
|
|
2
4
|
import {kebabCase} from 'change-case';
|
|
3
|
-
import {
|
|
4
|
-
ChainConfig,
|
|
5
|
-
ChainInfo,
|
|
6
|
-
ChainUserConfig,
|
|
7
|
-
Create2DeterministicDeploymentInfo,
|
|
8
|
-
Create3DeterministicDeploymentInfo,
|
|
9
|
-
ResolvedUserConfig,
|
|
10
|
-
} from '../../types.js';
|
|
5
|
+
import {ChainInfo} from '../../executor/types.js';
|
|
11
6
|
|
|
12
7
|
export type ChainType = 'zksync' | 'op-stack' | 'celo' | 'default';
|
|
13
8
|
|
|
@@ -35,9 +30,7 @@ const chainTypesByNames: {[chainExportName: string]: ChainType} = {
|
|
|
35
30
|
export const chainTypes: {[chainId: string]: ChainType} = {};
|
|
36
31
|
|
|
37
32
|
export const chainById: {[chainId: string]: ChainInfo} = {};
|
|
38
|
-
export const allChains
|
|
39
|
-
allChains['localhost'] = allChains['hardhat'];
|
|
40
|
-
|
|
33
|
+
export const allChains = (chains as any).default || chains;
|
|
41
34
|
for (const key of Object.keys(allChains)) {
|
|
42
35
|
const chain = (allChains as any)[key] as ChainInfo;
|
|
43
36
|
const chainId = chain.id.toString();
|
|
@@ -45,17 +38,17 @@ for (const key of Object.keys(allChains)) {
|
|
|
45
38
|
if (specificChainType) {
|
|
46
39
|
chainTypes[chainId] = specificChainType;
|
|
47
40
|
}
|
|
48
|
-
chainById[chainId] =
|
|
41
|
+
chainById[chainId] = chain;
|
|
49
42
|
}
|
|
50
43
|
|
|
51
44
|
export const chainByCanonicalName: {[canonicalName: string]: ChainInfo} = {};
|
|
52
|
-
for (const key of Object.keys(
|
|
53
|
-
const chain = (
|
|
45
|
+
for (const key of Object.keys(allChains)) {
|
|
46
|
+
const chain = (allChains as any)[key] as ChainInfo;
|
|
54
47
|
const canonicalName = kebabCase(chain.name);
|
|
55
48
|
chainByCanonicalName[canonicalName] = chain;
|
|
56
49
|
}
|
|
57
50
|
|
|
58
|
-
export function
|
|
51
|
+
export function getChain(id: string | number): ChainInfo | undefined {
|
|
59
52
|
const chain = chainById['' + id];
|
|
60
53
|
|
|
61
54
|
return chain;
|
|
@@ -66,58 +59,22 @@ export function getChainByName(name: string): ChainInfo | undefined {
|
|
|
66
59
|
return chain;
|
|
67
60
|
}
|
|
68
61
|
|
|
69
|
-
export function
|
|
70
|
-
const
|
|
71
|
-
const canonicalName = defaultChainInfo ? kebabCase(defaultChainInfo.name) : undefined;
|
|
72
|
-
if (canonicalName) {
|
|
73
|
-
if (config.chains?.[id] && config.chains?.[canonicalName]) {
|
|
74
|
-
throw new Error(
|
|
75
|
-
`chain should be configured by chainId or name but not both, remove either ${id} or ${canonicalName}`
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
let chainConfig: ChainUserConfig | undefined = config.chains?.[id];
|
|
81
|
-
if (!chainConfig && canonicalName) {
|
|
82
|
-
chainConfig = config.chains?.[canonicalName];
|
|
83
|
-
}
|
|
84
|
-
if (!chainConfig) {
|
|
85
|
-
chainConfig = {info: defaultChainInfo};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
let chainInfo = chainConfig?.info || defaultChainInfo;
|
|
89
|
-
|
|
90
|
-
let rpcUrl = process.env['ETH_NODE_URI_' + id];
|
|
91
|
-
if (canonicalName) {
|
|
92
|
-
const fromEnv = process.env['ETH_NODE_URI_' + canonicalName];
|
|
93
|
-
if (fromEnv) {
|
|
94
|
-
rpcUrl = fromEnv;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (!rpcUrl) {
|
|
99
|
-
rpcUrl = chainConfig.rpcUrl;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (!rpcUrl) {
|
|
103
|
-
rpcUrl = chainConfig.info?.rpcUrls.default.http[0];
|
|
104
|
-
}
|
|
62
|
+
export function getChainWithConfig(id: string, config: ResolvedConfig): ChainInfo {
|
|
63
|
+
const chain = getChain(id);
|
|
105
64
|
|
|
106
|
-
if (!
|
|
107
|
-
if (
|
|
108
|
-
|
|
65
|
+
if (!chain) {
|
|
66
|
+
if (config.target.chain) {
|
|
67
|
+
return config.target.chain;
|
|
109
68
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
throw new Error(`no chain info found for chain with id ${id}`);
|
|
69
|
+
console.error(`network ${config.target.name} has no public info`);
|
|
70
|
+
let nodeUrl: string | undefined;
|
|
71
|
+
if (!config.target.nodeUrl) {
|
|
72
|
+
console.error(`no nodeUrl found either for ${config.target.name}`);
|
|
115
73
|
} else {
|
|
116
|
-
|
|
74
|
+
nodeUrl = config.target.nodeUrl;
|
|
117
75
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
id,
|
|
76
|
+
return {
|
|
77
|
+
id: parseInt(id),
|
|
121
78
|
name: 'unkwown',
|
|
122
79
|
nativeCurrency: {
|
|
123
80
|
name: 'Unknown Currency',
|
|
@@ -126,59 +83,11 @@ export function getChainConfig(id: number, config: ResolvedUserConfig): ChainCon
|
|
|
126
83
|
},
|
|
127
84
|
rpcUrls: {
|
|
128
85
|
default: {
|
|
129
|
-
http: [
|
|
86
|
+
http: nodeUrl ? [nodeUrl] : [],
|
|
130
87
|
},
|
|
131
88
|
},
|
|
132
89
|
chainType: 'default',
|
|
133
90
|
};
|
|
134
91
|
}
|
|
135
|
-
|
|
136
|
-
const create2Info = {
|
|
137
|
-
factory: '0x4e59b44847b379578588920ca78fbf26c0b4956c',
|
|
138
|
-
deployer: '0x3fab184622dc19b6109349b94811493bf2a45362',
|
|
139
|
-
funding: '10000000000000000',
|
|
140
|
-
signedTx:
|
|
141
|
-
'0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222',
|
|
142
|
-
} as const;
|
|
143
|
-
const create3Info = {
|
|
144
|
-
factory: '0x000000000004d4f168daE7DB3C610F408eE22F57',
|
|
145
|
-
salt: '0x5361109ca02853ca8e22046b7125306d9ec4ae4cdecc393c567b6be861df3db6',
|
|
146
|
-
bytecode:
|
|
147
|
-
'0x6080604052348015600f57600080fd5b506103ca8061001f6000396000f3fe6080604052600436106100295760003560e01c8063360d0fad1461002e5780639881d19514610077575b600080fd5b34801561003a57600080fd5b5061004e610049366004610228565b61008a565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61004e61008536600461029c565b6100ee565b6040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606084901b166020820152603481018290526000906054016040516020818303038152906040528051906020012091506100e78261014c565b9392505050565b6040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b166020820152603481018290526000906054016040516020818303038152906040528051906020012091506100e734848461015e565b600061015882306101ce565b92915050565b60006f67363d3d37363d34f03d5260086018f3600052816010806000f58061018e5763301164256000526004601cfd5b8060145261d69460005260016034536017601e20915060008085516020870188855af1823b026101c65763301164256000526004601cfd5b509392505050565b60006040518260005260ff600b53836020527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f6040526055600b20601452806040525061d694600052600160345350506017601e20919050565b6000806040838503121561023b57600080fd5b823573ffffffffffffffffffffffffffffffffffffffff8116811461025f57600080fd5b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080604083850312156102af57600080fd5b823567ffffffffffffffff8111156102c657600080fd5b8301601f810185136102d757600080fd5b803567ffffffffffffffff8111156102f1576102f161026d565b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8501160116810181811067ffffffffffffffff8211171561035d5761035d61026d565b60405281815282820160200187101561037557600080fd5b816020840160208301376000602092820183015296940135945050505056fea264697066735822122059dcc5dc6453397d13ff28021e28472a80a45bbd97f3135f69bd2650773aeb0164736f6c634300081a0033',
|
|
148
|
-
proxyBytecode: '0x67363d3d37363d34f03d5260086018f3',
|
|
149
|
-
} as const;
|
|
150
|
-
|
|
151
|
-
const pollingInterval = chainConfig.pollingInterval || config.defaultPollingInterval;
|
|
152
|
-
|
|
153
|
-
let deterministicDeployment: {
|
|
154
|
-
create2: Create2DeterministicDeploymentInfo;
|
|
155
|
-
create3: Create3DeterministicDeploymentInfo;
|
|
156
|
-
} = {
|
|
157
|
-
create2: (() => {
|
|
158
|
-
if (!chainConfig.deterministicDeployment) return create2Info;
|
|
159
|
-
if (!('create3' in chainConfig.deterministicDeployment) && !('create2' in chainConfig.deterministicDeployment))
|
|
160
|
-
return create2Info;
|
|
161
|
-
return chainConfig.deterministicDeployment.create2 || create2Info;
|
|
162
|
-
})(),
|
|
163
|
-
create3:
|
|
164
|
-
chainConfig.deterministicDeployment &&
|
|
165
|
-
'create3' in chainConfig.deterministicDeployment &&
|
|
166
|
-
chainConfig.deterministicDeployment.create3
|
|
167
|
-
? chainConfig.deterministicDeployment.create3
|
|
168
|
-
: create3Info,
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
const defaultTags: string[] = [];
|
|
172
|
-
if (chainInfo.testnet) {
|
|
173
|
-
defaultTags.push('testnet');
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return {
|
|
177
|
-
info: {...chainInfo},
|
|
178
|
-
deterministicDeployment,
|
|
179
|
-
pollingInterval,
|
|
180
|
-
properties: chainConfig.properties || {},
|
|
181
|
-
rpcUrl: rpcUrl || chainInfo.rpcUrls.default.http[0],
|
|
182
|
-
tags: chainConfig.tags || [...defaultTags],
|
|
183
|
-
};
|
|
92
|
+
return chain;
|
|
184
93
|
}
|