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,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};
@@ -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/fs.ts DELETED
@@ -1,70 +0,0 @@
1
- // taken from https://github.com/vitejs/vite/blob/63524bac878e8d3771d34ad7ad2e10cd16870ff4/packages/vite/src/node/utils.ts#L371-L400
2
- import fs from 'node:fs';
3
- import path from 'node:path';
4
-
5
- interface LookupFileOptions {
6
- pathOnly?: boolean;
7
- rootDir?: string;
8
- predicate?: (file: string) => boolean;
9
- }
10
-
11
- export function lookupFile(dir: string, formats: string[], options?: LookupFileOptions): string | undefined {
12
- for (const format of formats) {
13
- const fullPath = path.join(dir, format);
14
- if (fs.existsSync(fullPath) && fs.statSync(fullPath).isFile()) {
15
- const result = options?.pathOnly ? fullPath : fs.readFileSync(fullPath, 'utf-8');
16
- if (!options?.predicate || options.predicate(result)) {
17
- return result;
18
- }
19
- }
20
- }
21
- const parentDir = path.dirname(dir);
22
- if (parentDir !== dir && (!options?.rootDir || parentDir.startsWith(options?.rootDir))) {
23
- return lookupFile(parentDir, formats, options);
24
- }
25
- }
26
-
27
- export function traverseMultipleDirectory(dirs: readonly string[]): string[] {
28
- const filepaths = [];
29
- for (const dir of dirs) {
30
- let filesStats = traverse(dir);
31
- filesStats = filesStats.filter((v) => !v.directory);
32
- for (const filestat of filesStats) {
33
- filepaths.push(path.join(dir, filestat.relativePath));
34
- }
35
- }
36
- return filepaths;
37
- }
38
-
39
- export const traverse = function (
40
- dir: string,
41
- result: any[] = [],
42
- topDir?: string,
43
- filter?: (name: string, stats: any) => boolean // TODO any is Stats
44
- ): Array<{
45
- name: string;
46
- path: string;
47
- relativePath: string;
48
- mtimeMs: number;
49
- directory: boolean;
50
- }> {
51
- fs.readdirSync(dir).forEach((name) => {
52
- const fPath = path.resolve(dir, name);
53
- const stats = fs.statSync(fPath);
54
- if ((!filter && !name.startsWith('.')) || (filter && filter(name, stats))) {
55
- const fileStats = {
56
- name,
57
- path: fPath,
58
- relativePath: path.relative(topDir || dir, fPath),
59
- mtimeMs: stats.mtimeMs,
60
- directory: stats.isDirectory(),
61
- };
62
- if (fileStats.directory) {
63
- result.push(fileStats);
64
- return traverse(fPath, result, topDir || dir, filter);
65
- }
66
- result.push(fileStats);
67
- }
68
- });
69
- return result;
70
- };
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
- }
package/tsconfig.json DELETED
@@ -1,18 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "strict": true,
4
- "strictNullChecks": true,
5
- "target": "ESNext",
6
- "module": "NodeNext",
7
- "lib": ["ESNext", "dom"],
8
- "moduleResolution": "NodeNext",
9
- "resolveJsonModule": true,
10
- "skipLibCheck": true,
11
- "sourceMap": true,
12
- "declaration": true,
13
- "declarationMap": true,
14
- "rootDir": "./src",
15
- "outDir": "./dist"
16
- },
17
- "include": ["src/**/*.ts"]
18
- }