rocketh 0.17.13 → 0.17.15
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/README.md +340 -1
- package/dist/environment/chains.d.ts +7 -1
- package/dist/environment/chains.d.ts.map +1 -1
- package/dist/environment/chains.js +6 -3
- package/dist/environment/chains.js.map +1 -1
- package/dist/environment/index.js.map +1 -1
- package/dist/executor/index.d.ts.map +1 -1
- package/dist/executor/index.js +6 -3
- package/dist/executor/index.js.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
- package/src/environment/chains.ts +240 -0
- package/src/environment/index.ts +833 -0
- package/src/executor/index.ts +540 -0
- package/src/index.ts +20 -0
- package/src/internal/logging.ts +35 -0
- package/src/internal/types.ts +4 -0
- package/src/types.ts +3 -0
- package/src/utils/eth.ts +120 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rocketh",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.15",
|
|
4
4
|
"description": "core functionality of rocketh",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"files": [
|
|
27
|
-
"dist"
|
|
27
|
+
"dist",
|
|
28
|
+
"src"
|
|
28
29
|
],
|
|
29
30
|
"dependencies": {
|
|
30
31
|
"abitype": "^1.2.3",
|
|
@@ -33,11 +34,11 @@
|
|
|
33
34
|
"eip-1193-jsonrpc-provider": "^0.4.3",
|
|
34
35
|
"ldenv": "^0.3.16",
|
|
35
36
|
"named-logs": "^0.4.1",
|
|
36
|
-
"viem": "^2.44.
|
|
37
|
-
"@rocketh/core": "0.17.
|
|
37
|
+
"viem": "^2.44.4",
|
|
38
|
+
"@rocketh/core": "0.17.9"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
|
-
"as-soon": "^0.
|
|
41
|
+
"as-soon": "^0.1.4",
|
|
41
42
|
"typescript": "^5.9.3"
|
|
42
43
|
},
|
|
43
44
|
"scripts": {
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import * as chains from 'viem/chains';
|
|
2
|
+
import {kebabCase} from 'change-case';
|
|
3
|
+
import type {
|
|
4
|
+
ChainConfig,
|
|
5
|
+
ChainInfo,
|
|
6
|
+
ChainUserConfig,
|
|
7
|
+
Create2DeterministicDeploymentInfo,
|
|
8
|
+
Create3DeterministicDeploymentInfo,
|
|
9
|
+
ResolvedUserConfig,
|
|
10
|
+
} from '@rocketh/core/types';
|
|
11
|
+
|
|
12
|
+
export type ChainType = 'zksync' | 'op-stack' | 'celo' | 'default';
|
|
13
|
+
|
|
14
|
+
const chainTypesByNames: {[chainExportName: string]: ChainType} = {
|
|
15
|
+
base: 'op-stack',
|
|
16
|
+
baseGoerli: 'op-stack',
|
|
17
|
+
baseSepolia: 'op-stack',
|
|
18
|
+
optimism: 'op-stack',
|
|
19
|
+
optimismGoerli: 'op-stack',
|
|
20
|
+
optimismSepolia: 'op-stack',
|
|
21
|
+
pgn: 'op-stack',
|
|
22
|
+
pgnTestnet: 'op-stack',
|
|
23
|
+
zora: 'op-stack',
|
|
24
|
+
zoraSepolia: 'op-stack',
|
|
25
|
+
zoraTestnet: 'op-stack',
|
|
26
|
+
ancient8: 'op-stack',
|
|
27
|
+
ancient8Sepolia: 'op-stack',
|
|
28
|
+
celoAlfajores: 'celo',
|
|
29
|
+
celo: 'celo',
|
|
30
|
+
zkSync: 'zksync',
|
|
31
|
+
zkSyncTestnet: 'zksync',
|
|
32
|
+
zkSyncSepoliaTestnet: 'zksync',
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const chainTypes: {[chainId: string]: ChainType} = {};
|
|
36
|
+
|
|
37
|
+
const chainById: {[chainId: string]: ChainInfo[]} = {};
|
|
38
|
+
const allChains: {[chainExportName: string]: ChainInfo} = {...((chains as any).default || chains)};
|
|
39
|
+
allChains['localhost'] = {...allChains['hardhat'], name: 'localhost'};
|
|
40
|
+
|
|
41
|
+
for (const key of Object.keys(allChains)) {
|
|
42
|
+
const chain = (allChains as any)[key] as ChainInfo;
|
|
43
|
+
const chainId = chain.id.toString();
|
|
44
|
+
const specificChainType = chainTypesByNames[key];
|
|
45
|
+
if (specificChainType) {
|
|
46
|
+
chainTypes[chainId] = specificChainType;
|
|
47
|
+
}
|
|
48
|
+
const list = (chainById[chainId] = chainById[chainId] || []);
|
|
49
|
+
list.push({...chain, chainType: specificChainType});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const chainByCanonicalName: {[canonicalName: string]: ChainInfo} = {};
|
|
53
|
+
for (const key of Object.keys(allChains)) {
|
|
54
|
+
const chain = (allChains as any)[key] as ChainInfo;
|
|
55
|
+
const canonicalName = kebabCase(chain.name);
|
|
56
|
+
chainByCanonicalName[canonicalName] = chain;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function getChainsById(id: string | number): ChainInfo[] | undefined {
|
|
60
|
+
const chains = chainById['' + id];
|
|
61
|
+
|
|
62
|
+
return chains;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function getDefaultChainInfoByName(name: string): ChainInfo | undefined {
|
|
66
|
+
const chain = chainByCanonicalName[name];
|
|
67
|
+
return chain;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// function getCanonicalNameFromChainId(id: string | number): string | undefined {
|
|
71
|
+
// let defaultChainInfo: ChainInfo | undefined;
|
|
72
|
+
// const defaultChainInfos = getChainsById(id);
|
|
73
|
+
// if (defaultChainInfos && defaultChainInfos.length > 1) {
|
|
74
|
+
// console.error(
|
|
75
|
+
// `chainId ${id} refers to different chain, please specific it by name or provide the chainConfig yourself`
|
|
76
|
+
// );
|
|
77
|
+
// } else {
|
|
78
|
+
// defaultChainInfo = defaultChainInfos ? defaultChainInfos[0] : undefined;
|
|
79
|
+
// }
|
|
80
|
+
// const canonicalName = defaultChainInfo ? kebabCase(defaultChainInfo.name) : undefined;
|
|
81
|
+
// return canonicalName;
|
|
82
|
+
// }
|
|
83
|
+
|
|
84
|
+
export function getDefaultChainInfoFromChainId(
|
|
85
|
+
id: string | number,
|
|
86
|
+
): {success: true; chainInfo: ChainInfo} | {success: false; error?: string} {
|
|
87
|
+
let defaultChainInfo: ChainInfo | undefined;
|
|
88
|
+
const defaultChainInfos = getChainsById(id);
|
|
89
|
+
if (defaultChainInfos && defaultChainInfos.length > 1) {
|
|
90
|
+
return {
|
|
91
|
+
success: false,
|
|
92
|
+
error: `chainId ${id} refers to different chains, please specify it by name or provide the chainConfig yourself`,
|
|
93
|
+
};
|
|
94
|
+
} else {
|
|
95
|
+
defaultChainInfo = defaultChainInfos ? defaultChainInfos[0] : undefined;
|
|
96
|
+
}
|
|
97
|
+
return defaultChainInfo ? {success: true, chainInfo: defaultChainInfo} : {success: false};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function getChainConfigFromUserConfigAndDefaultChainInfo(
|
|
101
|
+
config: ResolvedUserConfig,
|
|
102
|
+
chainDetails: {
|
|
103
|
+
id: number;
|
|
104
|
+
chainInfo?: ChainInfo;
|
|
105
|
+
canonicalName?: string;
|
|
106
|
+
doNotRequireRpcURL?: boolean;
|
|
107
|
+
},
|
|
108
|
+
): ChainConfig {
|
|
109
|
+
const canonicalName = chainDetails?.canonicalName;
|
|
110
|
+
let chainInfo = chainDetails?.chainInfo ? {...chainDetails.chainInfo} : undefined;
|
|
111
|
+
if (chainInfo?.id && chainDetails.id != chainInfo.id) {
|
|
112
|
+
console.warn(
|
|
113
|
+
`default chainInfo has a different chainId (${chainInfo.id}) != ${chainDetails.id}, we thus assign it`,
|
|
114
|
+
);
|
|
115
|
+
// we ensure the chainInfo has the correct id
|
|
116
|
+
chainInfo.id = chainDetails.id;
|
|
117
|
+
}
|
|
118
|
+
if (canonicalName) {
|
|
119
|
+
if (config.chains?.[chainDetails.id] && config.chains?.[canonicalName]) {
|
|
120
|
+
throw new Error(
|
|
121
|
+
`chain should be configured by chainId or name but not both, remove either ${chainDetails.id} or ${canonicalName}`,
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
let chainConfig: ChainUserConfig | undefined = canonicalName ? config.chains?.[canonicalName] : undefined;
|
|
127
|
+
if (!chainConfig) {
|
|
128
|
+
chainConfig = config.chains?.[chainDetails.id];
|
|
129
|
+
}
|
|
130
|
+
if (!chainConfig) {
|
|
131
|
+
chainConfig = {info: chainInfo};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
chainInfo = chainConfig?.info || chainInfo;
|
|
135
|
+
|
|
136
|
+
// let rpcUrl = process.env['ETH_NODE_URI_' + id];
|
|
137
|
+
// if (canonicalName) {
|
|
138
|
+
// const fromEnv = process.env['ETH_NODE_URI_' + canonicalName];
|
|
139
|
+
// if (fromEnv) {
|
|
140
|
+
// rpcUrl = fromEnv;
|
|
141
|
+
// }
|
|
142
|
+
// }
|
|
143
|
+
// if (!rpcUrl) {
|
|
144
|
+
// rpcUrl = chainConfig.rpcUrl;
|
|
145
|
+
// }
|
|
146
|
+
|
|
147
|
+
let rpcUrl = chainConfig.rpcUrl;
|
|
148
|
+
|
|
149
|
+
if (!rpcUrl) {
|
|
150
|
+
rpcUrl = chainConfig.info?.rpcUrls.default.http[0];
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// TODO remove ?
|
|
154
|
+
if (!rpcUrl) {
|
|
155
|
+
if (chainDetails.id === 31337 || chainDetails.id === 1337) {
|
|
156
|
+
rpcUrl = 'http://127.0.0.1:8545';
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (!chainInfo) {
|
|
161
|
+
if (!rpcUrl && !chainDetails.doNotRequireRpcURL) {
|
|
162
|
+
throw new Error(`chain with id ${chainDetails.id} has no public info and no rpc url known to fallback on`);
|
|
163
|
+
} else {
|
|
164
|
+
console.error(`chain with id ${chainDetails.id} has no public info`);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
chainInfo = {
|
|
168
|
+
id: chainDetails.id,
|
|
169
|
+
name: 'unknown',
|
|
170
|
+
nativeCurrency: {
|
|
171
|
+
name: 'Unknown Currency',
|
|
172
|
+
symbol: 'UNKNOWN',
|
|
173
|
+
decimals: 18,
|
|
174
|
+
},
|
|
175
|
+
rpcUrls: {
|
|
176
|
+
default: {
|
|
177
|
+
http: rpcUrl ? [rpcUrl] : [],
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
chainType: 'default',
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const create2Info = {
|
|
185
|
+
factory: '0x4e59b44847b379578588920ca78fbf26c0b4956c',
|
|
186
|
+
deployer: '0x3fab184622dc19b6109349b94811493bf2a45362',
|
|
187
|
+
funding: '10000000000000000',
|
|
188
|
+
signedTx:
|
|
189
|
+
'0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222',
|
|
190
|
+
} as const;
|
|
191
|
+
const create3Info = {
|
|
192
|
+
factory: '0x000000000004d4f168daE7DB3C610F408eE22F57',
|
|
193
|
+
salt: '0x5361109ca02853ca8e22046b7125306d9ec4ae4cdecc393c567b6be861df3db6',
|
|
194
|
+
bytecode:
|
|
195
|
+
'0x6080604052348015600f57600080fd5b506103ca8061001f6000396000f3fe6080604052600436106100295760003560e01c8063360d0fad1461002e5780639881d19514610077575b600080fd5b34801561003a57600080fd5b5061004e610049366004610228565b61008a565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61004e61008536600461029c565b6100ee565b6040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606084901b166020820152603481018290526000906054016040516020818303038152906040528051906020012091506100e78261014c565b9392505050565b6040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b166020820152603481018290526000906054016040516020818303038152906040528051906020012091506100e734848461015e565b600061015882306101ce565b92915050565b60006f67363d3d37363d34f03d5260086018f3600052816010806000f58061018e5763301164256000526004601cfd5b8060145261d69460005260016034536017601e20915060008085516020870188855af1823b026101c65763301164256000526004601cfd5b509392505050565b60006040518260005260ff600b53836020527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f6040526055600b20601452806040525061d694600052600160345350506017601e20919050565b6000806040838503121561023b57600080fd5b823573ffffffffffffffffffffffffffffffffffffffff8116811461025f57600080fd5b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080604083850312156102af57600080fd5b823567ffffffffffffffff8111156102c657600080fd5b8301601f810185136102d757600080fd5b803567ffffffffffffffff8111156102f1576102f161026d565b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8501160116810181811067ffffffffffffffff8211171561035d5761035d61026d565b60405281815282820160200187101561037557600080fd5b816020840160208301376000602092820183015296940135945050505056fea264697066735822122059dcc5dc6453397d13ff28021e28472a80a45bbd97f3135f69bd2650773aeb0164736f6c634300081a0033',
|
|
196
|
+
proxyBytecode: '0x67363d3d37363d34f03d5260086018f3',
|
|
197
|
+
} as const;
|
|
198
|
+
|
|
199
|
+
const pollingInterval = chainConfig.pollingInterval || config.defaultPollingInterval;
|
|
200
|
+
|
|
201
|
+
let deterministicDeployment: {
|
|
202
|
+
create2: Create2DeterministicDeploymentInfo;
|
|
203
|
+
create3: Create3DeterministicDeploymentInfo;
|
|
204
|
+
} = {
|
|
205
|
+
create2: (() => {
|
|
206
|
+
const deterministicDeployment = chainConfig.deterministicDeployment;
|
|
207
|
+
if (!deterministicDeployment) {
|
|
208
|
+
return create2Info;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return 'create2' in deterministicDeployment && deterministicDeployment.create2
|
|
212
|
+
? deterministicDeployment.create2
|
|
213
|
+
: !('create2' in deterministicDeployment) && !('create3' in deterministicDeployment)
|
|
214
|
+
? (deterministicDeployment as Create2DeterministicDeploymentInfo)
|
|
215
|
+
: create2Info;
|
|
216
|
+
})(),
|
|
217
|
+
create3:
|
|
218
|
+
chainConfig.deterministicDeployment &&
|
|
219
|
+
'create3' in chainConfig.deterministicDeployment &&
|
|
220
|
+
chainConfig.deterministicDeployment.create3
|
|
221
|
+
? chainConfig.deterministicDeployment.create3
|
|
222
|
+
: create3Info,
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
const defaultTags: string[] = [];
|
|
226
|
+
if (chainInfo.testnet) {
|
|
227
|
+
defaultTags.push('testnet');
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const properties = chainConfig.properties || config.defaultChainProperties || {};
|
|
231
|
+
|
|
232
|
+
return {
|
|
233
|
+
info: {...chainInfo},
|
|
234
|
+
deterministicDeployment,
|
|
235
|
+
pollingInterval,
|
|
236
|
+
properties,
|
|
237
|
+
rpcUrl: rpcUrl || chainInfo.rpcUrls.default.http[0],
|
|
238
|
+
tags: chainConfig.tags || [...defaultTags],
|
|
239
|
+
};
|
|
240
|
+
}
|