rocketh 0.15.14 → 0.16.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 +17 -0
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/environment/deployment-store.d.ts +3 -0
- package/dist/environment/deployment-store.d.ts.map +1 -0
- package/dist/environment/deployment-store.js +49 -0
- package/dist/environment/deployment-store.js.map +1 -0
- package/dist/environment/utils/artifacts.d.ts +4 -4
- package/dist/executor/index.d.ts +15 -6
- package/dist/executor/index.d.ts.map +1 -1
- package/dist/executor/index.js +42 -320
- package/dist/executor/index.js.map +1 -1
- package/dist/index.d.ts +9 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -7
- package/dist/index.js.map +1 -1
- package/dist/internal/logging.d.ts +1 -1
- package/dist/internal/logging.d.ts.map +1 -1
- package/package.json +9 -12
- package/src/cli.ts +2 -1
- package/src/environment/deployment-store.ts +72 -0
- package/src/executor/index.ts +92 -404
- package/src/index.ts +10 -11
- package/src/environment/deployments.ts +0 -135
- package/src/environment/index.ts +0 -696
- package/src/environment/providers/BaseProvider.ts +0 -13
- package/src/environment/providers/TransactionHashTracker.ts +0 -22
- package/src/environment/utils/artifacts.ts +0 -176
- package/src/environment/utils/chains.ts +0 -192
- package/src/executor/setup.test.ts +0 -151
- package/src/internal/logging.ts +0 -80
- package/src/internal/types.ts +0 -5
- package/src/types.ts +0 -601
- package/src/utils/eth.ts +0 -96
- package/src/utils/extensions.test.ts +0 -53
- package/src/utils/extensions.ts +0 -72
- package/src/utils/json.ts +0 -33
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type {Environment} from '../types.js';
|
|
2
|
-
import {withEnvironment} from './extensions.js';
|
|
3
|
-
|
|
4
|
-
// Mock environment for testing
|
|
5
|
-
const mockEnv = {} as Environment;
|
|
6
|
-
|
|
7
|
-
// Example functions that take environment as first parameter
|
|
8
|
-
const exampleExtensions = {
|
|
9
|
-
deploy:
|
|
10
|
-
(env: Environment) =>
|
|
11
|
-
async (contractName: string, args: any[]): Promise<void> => {
|
|
12
|
-
return Promise.resolve();
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
verify:
|
|
16
|
-
(env: Environment) =>
|
|
17
|
-
async (address: string): Promise<boolean> => {
|
|
18
|
-
return Promise.resolve(true);
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
getBalance:
|
|
22
|
-
(env: Environment) =>
|
|
23
|
-
async (address: string): Promise<bigint> => {
|
|
24
|
-
return Promise.resolve(BigInt(0));
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
syncFunction:
|
|
28
|
-
(env: Environment) =>
|
|
29
|
-
(value: number): number => {
|
|
30
|
-
return value * 2;
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
provider: (env: Environment) => env.network.provider,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
// Test the currying function
|
|
37
|
-
const enhancedEnv = withEnvironment(mockEnv, exampleExtensions);
|
|
38
|
-
|
|
39
|
-
// Type tests - these should compile without errors
|
|
40
|
-
async function testTypes() {
|
|
41
|
-
// These calls should work without passing env
|
|
42
|
-
await enhancedEnv.deploy('MyContract', []);
|
|
43
|
-
const isVerified = await enhancedEnv.verify('0x123...');
|
|
44
|
-
const balance = await enhancedEnv.getBalance('0x456...');
|
|
45
|
-
const doubled = enhancedEnv.syncFunction(42);
|
|
46
|
-
const provider = enhancedEnv.provider;
|
|
47
|
-
|
|
48
|
-
console.log('Type tests passed!');
|
|
49
|
-
console.log({isVerified, balance, doubled, provider});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// Export for potential use in actual tests
|
|
53
|
-
export {testTypes, enhancedEnv, exampleExtensions};
|
package/src/utils/extensions.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
Environment,
|
|
3
|
-
UnknownDeployments,
|
|
4
|
-
UnresolvedNetworkSpecificData,
|
|
5
|
-
UnresolvedUnknownNamedAccounts,
|
|
6
|
-
CurriedFunctions,
|
|
7
|
-
} from '../types.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @param env - The environment object to inject as the first parameter
|
|
11
|
-
* @param functionsAndGetters - An object containing functions that expect the environment as their first parameter,
|
|
12
|
-
* or getter functions that return a value from the environment
|
|
13
|
-
* @returns An object with the same function/property names, but with the environment parameter removed
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* const functionsAndGetters = {
|
|
18
|
-
* // Functions that expect env as first parameter
|
|
19
|
-
* deploy: (env: Environment, contractName: string, args: any[]) => Promise<void>,
|
|
20
|
-
* verify: (env: Environment, address: string) => Promise<boolean>,
|
|
21
|
-
*
|
|
22
|
-
* // Getter properties that can be accessed directly
|
|
23
|
-
* myValue: (env: Environment) => env.someValue,
|
|
24
|
-
* networkId: (env: Environment) => env.network.id
|
|
25
|
-
* };
|
|
26
|
-
*
|
|
27
|
-
* const enhancedEnv = withEnvironment(env, functionsAndGetters);
|
|
28
|
-
*
|
|
29
|
-
* // Now you can call functions without passing env:
|
|
30
|
-
* await enhancedEnv.deploy('MyContract', []);
|
|
31
|
-
* await enhancedEnv.verify('0x123...');
|
|
32
|
-
*
|
|
33
|
-
* // And access getter properties directly:
|
|
34
|
-
* console.log(enhancedEnv.myValue);
|
|
35
|
-
* console.log(enhancedEnv.networkId);
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export function withEnvironment<
|
|
39
|
-
NamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,
|
|
40
|
-
Data extends UnresolvedNetworkSpecificData = UnresolvedNetworkSpecificData,
|
|
41
|
-
Deployments extends UnknownDeployments = UnknownDeployments,
|
|
42
|
-
Extra extends Record<string, unknown> = Record<string, unknown>,
|
|
43
|
-
T extends Record<
|
|
44
|
-
string,
|
|
45
|
-
| ((env: Environment<NamedAccounts, Data, Deployments, Extra>) => (...args: any[]) => any)
|
|
46
|
-
| ((env: Environment<NamedAccounts, Data, Deployments, Extra>) => any)
|
|
47
|
-
> = Record<
|
|
48
|
-
string,
|
|
49
|
-
| ((env: Environment<NamedAccounts, Data, Deployments>) => (...args: any[]) => any)
|
|
50
|
-
| ((env: Environment<NamedAccounts, Data, Deployments>) => any)
|
|
51
|
-
>
|
|
52
|
-
>(env: Environment<NamedAccounts, Data, Deployments, Extra>, functionsAndGetters: T): CurriedFunctions<T> {
|
|
53
|
-
const result = {} as CurriedFunctions<T>;
|
|
54
|
-
|
|
55
|
-
for (const [key, func] of Object.entries(functionsAndGetters)) {
|
|
56
|
-
// Check if the function is a getter or a regular function
|
|
57
|
-
const value = func(env);
|
|
58
|
-
|
|
59
|
-
if (typeof value === 'function') {
|
|
60
|
-
// Regular function case: Create a function that automatically passes the environment
|
|
61
|
-
(result as any)[key] = (...args: any[]) => func(env)(...args);
|
|
62
|
-
} else {
|
|
63
|
-
// Getter case: Define property with getter that returns the value
|
|
64
|
-
Object.defineProperty(result, key, {
|
|
65
|
-
get: () => func(env),
|
|
66
|
-
enumerable: true,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return result;
|
|
72
|
-
}
|
package/src/utils/json.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// TODO share with db-utils
|
|
2
|
-
export function postfixBigIntReplacer(k: string, v: any): any {
|
|
3
|
-
if (typeof v === 'bigint') {
|
|
4
|
-
return v.toString() + 'n';
|
|
5
|
-
}
|
|
6
|
-
return v;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function bigIntToStringReplacer(k: string, v: any): any {
|
|
10
|
-
if (typeof v === 'bigint') {
|
|
11
|
-
return v.toString();
|
|
12
|
-
}
|
|
13
|
-
return v;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function postfixBigIntReviver(k: string, v: any): any {
|
|
17
|
-
if (
|
|
18
|
-
typeof v === 'string' &&
|
|
19
|
-
(v.startsWith('-') ? !isNaN(parseInt(v.charAt(1))) : !isNaN(parseInt(v.charAt(0)))) &&
|
|
20
|
-
v.charAt(v.length - 1) === 'n'
|
|
21
|
-
) {
|
|
22
|
-
return BigInt(v.slice(0, -1));
|
|
23
|
-
}
|
|
24
|
-
return v;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function JSONToString<T = unknown>(json: unknown, space?: string | number) {
|
|
28
|
-
return JSON.stringify(json, bigIntToStringReplacer, space);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function stringToJSON<T = unknown>(str: string): T {
|
|
32
|
-
return JSON.parse(str);
|
|
33
|
-
}
|