rocketh 0.15.15 → 0.17.0-next.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.
Files changed (55) hide show
  1. package/dist/environment/index.d.ts +12 -2
  2. package/dist/environment/index.d.ts.map +1 -1
  3. package/dist/environment/index.js +94 -48
  4. package/dist/environment/index.js.map +1 -1
  5. package/dist/executor/index.d.ts +11 -9
  6. package/dist/executor/index.d.ts.map +1 -1
  7. package/dist/executor/index.js +144 -238
  8. package/dist/executor/index.js.map +1 -1
  9. package/dist/index.d.ts +5 -5
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +5 -4
  12. package/dist/index.js.map +1 -1
  13. package/dist/internal/types.d.ts +0 -1
  14. package/dist/internal/types.d.ts.map +1 -1
  15. package/dist/types.d.ts +25 -0
  16. package/dist/types.d.ts.map +1 -1
  17. package/package.json +18 -20
  18. package/.prettierignore +0 -3
  19. package/.prettierrc +0 -7
  20. package/CHANGELOG.md +0 -950
  21. package/dist/cli.d.ts +0 -3
  22. package/dist/cli.d.ts.map +0 -1
  23. package/dist/cli.js +0 -30
  24. package/dist/cli.js.map +0 -1
  25. package/dist/environment/deployments.d.ts +0 -12
  26. package/dist/environment/deployments.d.ts.map +0 -1
  27. package/dist/environment/deployments.js +0 -108
  28. package/dist/environment/deployments.js.map +0 -1
  29. package/dist/executor/setup.test.d.ts +0 -14
  30. package/dist/executor/setup.test.d.ts.map +0 -1
  31. package/dist/executor/setup.test.js +0 -107
  32. package/dist/executor/setup.test.js.map +0 -1
  33. package/dist/utils/fs.d.ts +0 -16
  34. package/dist/utils/fs.d.ts.map +0 -1
  35. package/dist/utils/fs.js +0 -52
  36. package/dist/utils/fs.js.map +0 -1
  37. package/src/cli.ts +0 -34
  38. package/src/environment/deployments.ts +0 -135
  39. package/src/environment/index.ts +0 -696
  40. package/src/environment/providers/BaseProvider.ts +0 -13
  41. package/src/environment/providers/TransactionHashTracker.ts +0 -22
  42. package/src/environment/utils/artifacts.ts +0 -176
  43. package/src/environment/utils/chains.ts +0 -192
  44. package/src/executor/index.ts +0 -638
  45. package/src/executor/setup.test.ts +0 -151
  46. package/src/index.ts +0 -17
  47. package/src/internal/logging.ts +0 -80
  48. package/src/internal/types.ts +0 -5
  49. package/src/types.ts +0 -601
  50. package/src/utils/eth.ts +0 -96
  51. package/src/utils/extensions.test.ts +0 -53
  52. package/src/utils/extensions.ts +0 -72
  53. package/src/utils/fs.ts +0 -70
  54. package/src/utils/json.ts +0 -33
  55. package/tsconfig.json +0 -18
@@ -1,22 +0,0 @@
1
- import {EIP1193GenericRequest, EIP1193ProviderWithoutEvents} from 'eip-1193';
2
- import {BaseProvider} from './BaseProvider.js';
3
-
4
- export class TransactionHashTrackerProvider extends BaseProvider implements EIP1193ProviderWithoutEvents {
5
- public transactionHashes: `0x${string}`[] = [];
6
-
7
- constructor(provider: EIP1193ProviderWithoutEvents) {
8
- super(provider);
9
- }
10
-
11
- protected async _request<T = unknown, V extends EIP1193GenericRequest = EIP1193GenericRequest>(args: V): Promise<T> {
12
- const response = await this.provider.request(args as any);
13
- if (args.method === 'eth_sendRawTransaction' || args.method === 'eth_sendTransaction') {
14
- this.transactionHashes.push(response as `0x${string}`);
15
- }
16
- return response as T;
17
- }
18
- }
19
-
20
- export type TransactionHashTracker = EIP1193ProviderWithoutEvents & {
21
- transactionHashes: `0x${string}`[];
22
- };
@@ -1,176 +0,0 @@
1
- import {Abi} from 'abitype';
2
- import {Artifact, DevDoc, UserDoc} from '../../types.js';
3
- import {FunctionFragment} from 'ethers';
4
-
5
- type CreateMutable<Type> = {
6
- -readonly [Property in keyof Type]: Type[Property];
7
- };
8
-
9
- type ArrayElement<ArrayType extends readonly unknown[]> = ArrayType extends readonly (infer ElementType)[]
10
- ? ElementType
11
- : never;
12
-
13
- // from https://gist.github.com/egardner/efd34f270cc33db67c0246e837689cb9
14
- function deepEqual(obj1: any, obj2: any): boolean {
15
- // Private
16
- function isObject(obj: any) {
17
- if (typeof obj === 'object' && obj != null) {
18
- return true;
19
- } else {
20
- return false;
21
- }
22
- }
23
-
24
- if (obj1 === obj2) {
25
- return true;
26
- } else if (isObject(obj1) && isObject(obj2)) {
27
- if (Object.keys(obj1).length !== Object.keys(obj2).length) {
28
- return false;
29
- }
30
- for (var prop in obj1) {
31
- if (!deepEqual(obj1[prop], obj2[prop])) {
32
- return false;
33
- }
34
- }
35
- return true;
36
- }
37
- return false;
38
- }
39
-
40
- function mergeDoc(values: any, mergedDevDocs: any, field: string) {
41
- if (values[field]) {
42
- const mergedEventDocs = (mergedDevDocs[field] = mergedDevDocs[field] || {});
43
- for (const signature of Object.keys(values[field])) {
44
- if (mergedEventDocs[signature] && !deepEqual(mergedEventDocs[signature], values[field][signature])) {
45
- throw new Error(`Doc ${field} conflict: "${signature}" `);
46
- }
47
- mergedEventDocs[signature] = values[field][signature];
48
- }
49
- }
50
- }
51
-
52
- export function mergeABIs(list: {name: string; abi: Abi}[], options?: {doNotCheckForConflicts?: boolean}) {
53
- const added: Map<string, ArrayElement<Abi>> = new Map();
54
- const mergedABI: CreateMutable<Abi> = [];
55
- const sigJSMap: Map<`0x${string}`, {index: number; routeName: string; functionName: string}> = new Map();
56
- for (let i = 0; i < list.length; i++) {
57
- const listElem = list[i];
58
- for (const element of listElem.abi) {
59
- if (element.type === 'function') {
60
- // const selector = getFunctionSelector(element);
61
- const selector = FunctionFragment.from(element).selector as `0x${string}`;
62
- if (sigJSMap.has(selector)) {
63
- if (!options?.doNotCheckForConflicts) {
64
- const existing = sigJSMap.get(selector);
65
- throw new Error(
66
- `ABI conflict: ${existing!.routeName} has function "${existing!.functionName}" which conflict with ${
67
- listElem.name
68
- }'s "${element.name}" (selector: "${selector}") `
69
- );
70
- } else {
71
- continue;
72
- }
73
- }
74
- sigJSMap.set(selector, {index: i, routeName: listElem.name, functionName: element.name});
75
-
76
- const exists = added.has(element.name);
77
- if (exists) {
78
- // TODO check if same
79
- } else {
80
- added.set(element.name, element);
81
- mergedABI.push(element);
82
- }
83
- } else if (element.type === 'constructor') {
84
- // we skip it
85
- } else if (element.type === 'error') {
86
- const exists = added.has(element.name);
87
- if (exists) {
88
- // TODO check if same
89
- } else {
90
- added.set(element.name, element);
91
- mergedABI.push(element);
92
- }
93
- } else if (element.type === 'event') {
94
- const exists = added.has(element.name);
95
- if (exists) {
96
- // TODO check if same
97
- } else {
98
- added.set(element.name, element);
99
- mergedABI.push(element);
100
- }
101
- } else if (element.type === 'fallback') {
102
- } else if (element.type === 'receive') {
103
- } else {
104
- // if ('name' in element) {
105
- // const exists = added.has(element.name);
106
- // if (exists) {
107
- // // TODO check if same
108
- // } else {
109
- // added.set(element.name, element);
110
- // mergedABI.push(element);
111
- // }
112
- // }
113
- }
114
- }
115
- }
116
-
117
- return {
118
- mergedABI,
119
- added,
120
- sigJSMap,
121
- };
122
- }
123
-
124
- export function mergeArtifacts(
125
- list: {name: string; artifact: Partial<Artifact<Abi>> & {abi: Abi}}[],
126
- options?: {doNotCheckForConflicts?: boolean}
127
- ) {
128
- const {mergedABI, added, sigJSMap} = mergeABIs(
129
- list.map((v) => ({name: v.name, abi: v.artifact.abi})),
130
- options
131
- );
132
-
133
- const mergedDevDocs: CreateMutable<DevDoc> = {kind: 'dev', version: 1, methods: {}};
134
- const mergedUserDocs: CreateMutable<UserDoc> = {kind: 'user', version: 1, methods: {}};
135
-
136
- for (let i = 0; i < list.length; i++) {
137
- const listElem = list[i];
138
-
139
- const devdoc = listElem.artifact.devdoc;
140
- if (devdoc) {
141
- mergeDoc(devdoc, mergedDevDocs, 'events');
142
- mergeDoc(devdoc, mergedDevDocs, 'errors');
143
- mergeDoc(devdoc, mergedDevDocs, 'methods');
144
- if (devdoc.author) {
145
- if (mergedDevDocs.author && mergedDevDocs.author != devdoc.author) {
146
- throw new Error(`DevDoc author conflict `);
147
- }
148
- mergedDevDocs.author = devdoc.author;
149
- if (mergedDevDocs.title && mergedDevDocs.title != devdoc.title) {
150
- throw new Error(`DevDoc title conflict `);
151
- }
152
- mergedDevDocs.title = devdoc.title;
153
- }
154
- }
155
-
156
- const userdoc = listElem.artifact.userdoc;
157
- if (userdoc) {
158
- mergeDoc(userdoc, mergedUserDocs, 'events');
159
- mergeDoc(userdoc, mergedUserDocs, 'errors');
160
- mergeDoc(userdoc, mergedUserDocs, 'methods');
161
- if (userdoc.notice) {
162
- if (mergedUserDocs.notice && mergedUserDocs.notice != userdoc.notice) {
163
- throw new Error(`UserDoc notice conflict `);
164
- }
165
- mergedUserDocs.notice = userdoc.notice;
166
- }
167
- }
168
- }
169
- return {
170
- mergedABI,
171
- added,
172
- mergedDevDocs,
173
- mergedUserDocs,
174
- sigJSMap,
175
- };
176
- }
@@ -1,192 +0,0 @@
1
- import * as chains from 'viem/chains';
2
- import {kebabCase} from 'change-case';
3
- import {
4
- ChainConfig,
5
- ChainInfo,
6
- ChainUserConfig,
7
- Create2DeterministicDeploymentInfo,
8
- Create3DeterministicDeploymentInfo,
9
- ResolvedUserConfig,
10
- } from '../../types.js';
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
- export const chainTypes: {[chainId: string]: ChainType} = {};
36
-
37
- export const chainById: {[chainId: string]: ChainInfo} = {};
38
- export const allChains: {[chainExportName: string]: ChainInfo} = {...((chains as any).default || chains)};
39
- allChains['localhost'] = allChains['hardhat'];
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
- chainById[chainId] = {...chain, chainType: specificChainType};
49
- }
50
-
51
- export const chainByCanonicalName: {[canonicalName: string]: ChainInfo} = {};
52
- for (const key of Object.keys(chainById)) {
53
- const chain = (chainById as any)[key] as ChainInfo;
54
- const canonicalName = kebabCase(chain.name);
55
- chainByCanonicalName[canonicalName] = chain;
56
- }
57
-
58
- export function getChainById(id: string | number): ChainInfo | undefined {
59
- const chain = chainById['' + id];
60
-
61
- return chain;
62
- }
63
-
64
- export function getChainByName(name: string): ChainInfo | undefined {
65
- const chain = chainByCanonicalName[name];
66
- return chain;
67
- }
68
-
69
- export function getChainConfig(id: number, config: ResolvedUserConfig): ChainConfig {
70
- const defaultChainInfo = getChainById(id);
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
- }
105
-
106
- if (!rpcUrl) {
107
- if (id === 31337 || id === 1337) {
108
- rpcUrl = 'http://127.0.0.1:8545';
109
- }
110
- }
111
-
112
- if (!chainInfo) {
113
- if (!rpcUrl) {
114
- throw new Error(`no chain info found for chain with id ${id}`);
115
- } else {
116
- console.error(`chain with id ${id} has no public info`);
117
- }
118
-
119
- chainInfo = {
120
- id,
121
- name: 'unkwown',
122
- nativeCurrency: {
123
- name: 'Unknown Currency',
124
- symbol: 'UNKNOWN',
125
- decimals: 18,
126
- },
127
- rpcUrls: {
128
- default: {
129
- http: [rpcUrl],
130
- },
131
- },
132
- chainType: 'default',
133
- };
134
- }
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
- const deterministicDeployment = chainConfig.deterministicDeployment;
159
- if (!deterministicDeployment) {
160
- return create2Info;
161
- }
162
-
163
- return 'create2' in deterministicDeployment && deterministicDeployment.create2
164
- ? deterministicDeployment.create2
165
- : !('create2' in deterministicDeployment) && !('create3' in deterministicDeployment)
166
- ? (deterministicDeployment as Create2DeterministicDeploymentInfo)
167
- : create2Info;
168
- })(),
169
- create3:
170
- chainConfig.deterministicDeployment &&
171
- 'create3' in chainConfig.deterministicDeployment &&
172
- chainConfig.deterministicDeployment.create3
173
- ? chainConfig.deterministicDeployment.create3
174
- : create3Info,
175
- };
176
-
177
- const defaultTags: string[] = [];
178
- if (chainInfo.testnet) {
179
- defaultTags.push('testnet');
180
- }
181
-
182
- const properties = chainConfig.properties || config.defaultChainProperties || {};
183
-
184
- return {
185
- info: {...chainInfo},
186
- deterministicDeployment,
187
- pollingInterval,
188
- properties,
189
- rpcUrl: rpcUrl || chainInfo.rpcUrls.default.http[0],
190
- tags: chainConfig.tags || [...defaultTags],
191
- };
192
- }