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
package/dist/cli.d.ts DELETED
@@ -1,3 +0,0 @@
1
- #! /usr/bin/env node
2
- export {};
3
- //# sourceMappingURL=cli.d.ts.map
package/dist/cli.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js DELETED
@@ -1,30 +0,0 @@
1
- #! /usr/bin/env node
2
- import { loadEnv } from 'ldenv';
3
- import { loadAndExecuteDeployments } from './index.js';
4
- import { Command } from 'commander';
5
- import pkg from '../package.json' with { type: 'json' };
6
- loadEnv();
7
- const commandName = "rocketh";
8
- const program = new Command();
9
- program
10
- .name(commandName)
11
- .version(pkg.version)
12
- .usage(`${commandName}`)
13
- .description('execute deploy scripts and store the deployments')
14
- .option('-s, --scripts <value>', 'path the folder containing the deploy scripts to execute')
15
- .option('-t, --tags <value>', 'comma separated list of tags to execute')
16
- .option('-d, --deployments <value>', 'folder where deployments are saved')
17
- .option('--skip-gas-report', 'if set skip gas report')
18
- .option('--skip-prompts', 'if set skip any prompts')
19
- .option('--save-deployments', 'if set, save deployments')
20
- .requiredOption('-e, --environment <value>', 'environment to use')
21
- .parse(process.argv);
22
- const options = program.opts();
23
- loadAndExecuteDeployments({
24
- ...options,
25
- logLevel: 1,
26
- askBeforeProceeding: options.skipPrompts ? false : true,
27
- reportGasUse: options.skipGasReport ? false : true,
28
- saveDeployments: options.saveDeployments,
29
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AAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;IAClD,eAAe,EAAE,OAAO,CAAC,eAAe;CACxC,CAAC,CAAC"}
@@ -1,12 +0,0 @@
1
- import { UnknownDeployments } from '../types.js';
2
- export declare function loadDeployments(deploymentsPath: string, networkName: string, onlyABIAndAddress?: boolean, expectedChain?: {
3
- chainId: string;
4
- genesisHash?: `0x${string}`;
5
- deleteDeploymentsIfDifferentGenesisHash?: boolean;
6
- }): {
7
- deployments: UnknownDeployments;
8
- migrations: Record<string, number>;
9
- chainId?: string;
10
- genesisHash?: `0x${string}`;
11
- };
12
- //# sourceMappingURL=deployments.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deployments.d.ts","sourceRoot":"","sources":["../../src/environment/deployments.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAC;AAE/C,wBAAgB,eAAe,CAC9B,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,EACnB,iBAAiB,CAAC,EAAE,OAAO,EAC3B,aAAa,CAAC,EAAE;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IAAC,uCAAuC,CAAC,EAAE,OAAO,CAAA;CAAC,GAC/G;IACF,WAAW,EAAE,kBAAkB,CAAC;IAChC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;CAC5B,CAuHA"}
@@ -1,108 +0,0 @@
1
- import path from 'node:path';
2
- import fs from 'node:fs';
3
- import { traverse } from '../utils/fs.js';
4
- export function loadDeployments(deploymentsPath, networkName, onlyABIAndAddress, expectedChain) {
5
- const deploymentsFound = {};
6
- const deployPath = path.join(deploymentsPath, networkName);
7
- let filesStats;
8
- try {
9
- filesStats = traverse(deployPath, undefined, undefined, (name) => !(name.startsWith('.') && name !== '.migrations.json') && name !== 'solcInputs');
10
- }
11
- catch (e) {
12
- // console.log('no folder at ' + deployPath);
13
- return { deployments: {}, migrations: {} };
14
- }
15
- let chainId;
16
- let genesisHash;
17
- if (filesStats.length > 0) {
18
- const chainIdFilepath = path.join(deployPath, '.chainId');
19
- const chainFilepath = path.join(deployPath, '.chain');
20
- if (fs.existsSync(chainFilepath)) {
21
- const chainSTR = fs.readFileSync(chainFilepath, 'utf-8');
22
- const chainData = JSON.parse(chainSTR);
23
- chainId = chainData.chainId;
24
- genesisHash = chainData.genesisHash;
25
- }
26
- else if (fs.existsSync(chainIdFilepath)) {
27
- chainId = fs.readFileSync(chainIdFilepath, 'utf-8').trim();
28
- }
29
- else {
30
- throw new Error(`A '.chain' or '.chainId' file is expected to be present in the deployment folder for network ${networkName}`);
31
- }
32
- if (expectedChain) {
33
- if (expectedChain.chainId !== chainId) {
34
- throw new Error(`Loading deployment in folder '${deployPath}' (with chainId: ${chainId}) for a different chainId (${expectedChain.chainId})`);
35
- }
36
- if (genesisHash) {
37
- if (expectedChain.genesisHash && expectedChain.genesisHash !== genesisHash) {
38
- if (expectedChain.deleteDeploymentsIfDifferentGenesisHash) {
39
- // we delete the old folder
40
- fs.rmSync(deployPath, { recursive: true, force: true });
41
- return { deployments: {}, migrations: {} };
42
- }
43
- else {
44
- throw new Error(`Loading deployment in folder '${deployPath}' (with genesisHash: ${genesisHash}) for a different genesisHash (${expectedChain.genesisHash})`);
45
- }
46
- }
47
- }
48
- else {
49
- console.warn(`genesisHash not found in folder '${deployPath}' (with chainId: ${chainId}), writing .chain with expected one...`);
50
- fs.writeFileSync(chainFilepath, JSON.stringify({ chainId: expectedChain.chainId, genesisHash: expectedChain.genesisHash }));
51
- try {
52
- fs.unlinkSync(chainIdFilepath);
53
- }
54
- catch { }
55
- }
56
- }
57
- }
58
- else {
59
- return { deployments: {}, migrations: {} };
60
- }
61
- let migrations = {};
62
- const migrationsFilepath = path.join(deployPath, '.migrations.json');
63
- if (fs.existsSync(migrationsFilepath)) {
64
- try {
65
- migrations = JSON.parse(fs.readFileSync(migrationsFilepath, 'utf-8'));
66
- }
67
- catch (err) {
68
- console.error(`failed to parse .migrations.json`);
69
- }
70
- }
71
- let fileNames = filesStats.map((a) => a.relativePath);
72
- fileNames = fileNames.sort((a, b) => {
73
- if (a < b) {
74
- return -1;
75
- }
76
- if (a > b) {
77
- return 1;
78
- }
79
- return 0;
80
- });
81
- for (const fileName of fileNames) {
82
- if (fileName.substring(fileName.length - 5) === '.json' && fileName !== '.migrations.json') {
83
- const deploymentFileName = path.join(deployPath, fileName);
84
- let deployment = JSON.parse(fs.readFileSync(deploymentFileName).toString());
85
- // truffleChainId argument:
86
- // if (!deployment.address && deployment.networks) {
87
- // if (truffleChainId && deployment.networks[truffleChainId]) {
88
- // // TRUFFLE support
89
- // const truffleDeployment = deployment as any; // TruffleDeployment;
90
- // deployment.address = truffleDeployment.networks[truffleChainId].address;
91
- // deployment.transactionHash = truffleDeployment.networks[truffleChainId].transactionHash;
92
- // }
93
- // }
94
- if (onlyABIAndAddress) {
95
- deployment = {
96
- address: deployment.address,
97
- abi: deployment.abi,
98
- linkedData: deployment.linkedData,
99
- };
100
- }
101
- const name = fileName.slice(0, fileName.length - 5);
102
- // console.log('fetching ' + deploymentFileName + ' for ' + name);
103
- deploymentsFound[name] = deployment;
104
- }
105
- }
106
- return { deployments: deploymentsFound, migrations, chainId, genesisHash };
107
- }
108
- //# sourceMappingURL=deployments.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deployments.js","sourceRoot":"","sources":["../../src/environment/deployments.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAGxC,MAAM,UAAU,eAAe,CAC9B,eAAuB,EACvB,WAAmB,EACnB,iBAA2B,EAC3B,aA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CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC5E,2BAA2B;YAC3B,oDAAoD;YACpD,gEAAgE;YAChE,uBAAuB;YACvB,uEAAuE;YACvE,6EAA6E;YAC7E,6FAA6F;YAC7F,KAAK;YACL,IAAI;YACJ,IAAI,iBAAiB,EAAE,CAAC;gBACvB,UAAU,GAAG;oBACZ,OAAO,EAAE,UAAU,CAAC,OAAO;oBAC3B,GAAG,EAAE,UAAU,CAAC,GAAG;oBACnB,UAAU,EAAE,UAAU,CAAC,UAAU;iBACjC,CAAC;YACH,CAAC;YACD,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACpD,mEAAmE;YAEnE,gBAAgB,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC;QACrC,CAAC;IACF,CAAC;IACD,OAAO,EAAC,WAAW,EAAE,gBAAgB,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAC,CAAC;AAC1E,CAAC"}
@@ -1,14 +0,0 @@
1
- import type { Environment } from '../types.js';
2
- declare const utilityFunctions: {
3
- deployContract: (env: Environment) => (contractName: string, args?: any[]) => Promise<string>;
4
- verifyContract: (env: Environment) => (address: string) => Promise<boolean>;
5
- getBalance: (env: Environment) => (address: string) => Promise<bigint>;
6
- calculateGas: (env: Environment) => (operation: string) => number;
7
- isDeployed: (env: Environment) => (contractName: string) => boolean;
8
- test: (env: Environment) => boolean;
9
- };
10
- declare const testScript: import("../types.js").DeployScriptModule<import("../types.js").UnresolvedUnknownNamedAccounts, import("../types.js").UnresolvedNetworkSpecificData, undefined, import("../types.js").UnknownDeployments, Record<string, unknown>>;
11
- declare function testTypes(): Promise<void>;
12
- export declare const exampleUsage: () => import("../types.js").DeployScriptModule<import("../types.js").UnresolvedUnknownNamedAccounts, import("../types.js").UnresolvedNetworkSpecificData, undefined, import("../types.js").UnknownDeployments, Record<string, unknown>>;
13
- export { testTypes, testScript, utilityFunctions };
14
- //# sourceMappingURL=setup.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup.test.d.ts","sourceRoot":"","sources":["../../src/executor/setup.test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AAO7C,QAAA,MAAM,gBAAgB;0BAEd,WAAW,MACV,cAAc,MAAM,EAAE,OAAM,GAAG,EAAO,KAAG,OAAO,CAAC,MAAM,CAAC;0BAMzD,WAAW,MACV,SAAS,MAAM,KAAG,OAAO,CAAC,OAAO,CAAC;sBAMnC,WAAW,MACV,SAAS,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC;wBAMlC,WAAW,MAChB,WAAW,MAAM,KAAG,MAAM;sBAMrB,WAAW,MAChB,cAAc,MAAM,KAAG,OAAO;gBAKpB,WAAW;CACvB,CAAC;AAMF,QAAA,MAAM,UAAU,mOA+Bf,CAAC;AAGF,iBAAe,SAAS,kBAavB;AAGD,eAAO,MAAM,YAAY,yOA+CxB,CAAC;AAGF,OAAO,EAAC,SAAS,EAAE,UAAU,EAAE,gBAAgB,EAAC,CAAC"}
@@ -1,107 +0,0 @@
1
- import { setup } from './index.js';
2
- // Mock environment for testing
3
- const mockEnv = {};
4
- // Example utility functions that take Environment as first parameter
5
- const utilityFunctions = {
6
- deployContract: (env) => async (contractName, args = []) => {
7
- console.log(`Deploying ${contractName} with args:`, args);
8
- return '0x1234567890123456789012345678901234567890';
9
- },
10
- verifyContract: (env) => async (address) => {
11
- console.log(`Verifying contract at ${address}`);
12
- return true;
13
- },
14
- getBalance: (env) => async (address) => {
15
- console.log(`Getting balance for ${address}`);
16
- return BigInt('1000000000000000000'); // 1 ETH
17
- },
18
- calculateGas: (env) => (operation) => {
19
- console.log(`Calculating gas for ${operation}`);
20
- return 21000;
21
- },
22
- isDeployed: (env) => (contractName) => {
23
- console.log(`Checking if ${contractName} is deployed`);
24
- return false;
25
- },
26
- test: (env) => true,
27
- };
28
- // Create the enhanced execute function using setup
29
- const { deployScript } = setup(utilityFunctions);
30
- // Test the enhanced execute function
31
- const testScript = deployScript(async (env, args) => {
32
- // Type test: env should have both original Environment properties AND curried functions
33
- // Test curried functions (no need to pass env)
34
- const address = await env.deployContract('MyToken', ['TokenName', 'TKN']);
35
- const isVerified = await env.verifyContract(address);
36
- const balance = await env.getBalance(address);
37
- const gasEstimate = env.calculateGas('transfer');
38
- const deployed = env.isDeployed('MyToken');
39
- // Test that original environment properties are still accessible
40
- // (These would normally be available on a real environment)
41
- // console.log('Network name:', env.network?.name);
42
- // console.log('Chain ID:', env.network?.chain?.id);
43
- console.log('Test results:', {
44
- address,
45
- isVerified,
46
- balance: balance.toString(),
47
- gasEstimate,
48
- deployed,
49
- });
50
- return true; // Return true to indicate successful completion
51
- }, {
52
- tags: ['test'],
53
- dependencies: [],
54
- id: 'test-setup-function',
55
- });
56
- // Type tests - these should compile without errors
57
- async function testTypes() {
58
- // The script should be a valid DeployScriptModule
59
- console.log('Script tags:', testScript.tags);
60
- console.log('Script dependencies:', testScript.dependencies);
61
- console.log('Script ID:', testScript.id);
62
- // The script should be callable with an environment
63
- try {
64
- const result = await testScript(mockEnv, undefined);
65
- console.log('Script execution result:', result);
66
- }
67
- catch (error) {
68
- console.log('Script execution test completed (expected with mock env)');
69
- }
70
- }
71
- // Example of how this would be used in a real deployment script
72
- export const exampleUsage = () => {
73
- // Define your utility functions
74
- const myFunctions = {
75
- deployERC20: (env) => async (name, symbol) => {
76
- // Implementation would use env.save, env.network.provider, etc.
77
- return '0x...';
78
- },
79
- setupPermissions: (env) => async (contractAddress, admin) => {
80
- // Implementation would interact with contracts
81
- },
82
- verifyOnEtherscan: (env) => async (address, constructorArgs) => {
83
- // Implementation would call verification service
84
- return true;
85
- },
86
- };
87
- // Create the enhanced execute function
88
- const { deployScript } = setup(myFunctions);
89
- // Export your deployment script
90
- return deployScript(async (env, args) => {
91
- // Now you can use the functions without passing env each time
92
- const tokenAddress = await env.deployERC20('MyToken', 'MTK');
93
- await env.setupPermissions(tokenAddress, env.namedAccounts.deployer);
94
- await env.verifyOnEtherscan(tokenAddress, ['MyToken', 'MTK']);
95
- // Original environment is still fully accessible
96
- console.log(`Deployed on environment: ${env.name}`);
97
- const deployment = env.get('MyToken');
98
- return true;
99
- }, {
100
- tags: ['token', 'deploy'],
101
- dependencies: ['setup'],
102
- id: 'deploy-my-token',
103
- });
104
- };
105
- // Export for potential use in actual tests
106
- export { testTypes, testScript, utilityFunctions };
107
- //# sourceMappingURL=setup.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup.test.js","sourceRoot":"","sources":["../../src/executor/setup.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AAEjC,+BAA+B;AAC/B,MAAM,OAAO,GAAG,EAAiB,CAAC;AAElC,qEAAqE;AACrE,MAAM,gBAAgB,GAAG;IACxB,cAAc,EACb,CAAC,GAAgB,EAAE,EAAE,CACrB,KAAK,EAAE,YAAoB,EAAE,OAAc,EAAE,EAAmB,EAAE;QACjE,OAAO,CAAC,GAAG,CAAC,aAAa,YAAY,aAAa,EAAE,IAAI,CAAC,CAAC;QAC1D,OAAO,4CAA4C,CAAC;IACrD,CAAC;IAEF,cAAc,EACb,CAAC,GAAgB,EAAE,EAAE,CACrB,KAAK,EAAE,OAAe,EAAoB,EAAE;QAC3C,OAAO,CAAC,GAAG,CAAC,yBAAyB,OAAO,EAAE,CAAC,CAAC;QAChD,OAAO,IAAI,CAAC;IACb,CAAC;IAEF,UAAU,EACT,CAAC,GAAgB,EAAE,EAAE,CACrB,KAAK,EAAE,OAAe,EAAmB,EAAE;QAC1C,OAAO,CAAC,GAAG,CAAC,uBAAuB,OAAO,EAAE,CAAC,CAAC;QAC9C,OAAO,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC,QAAQ;IAC/C,CAAC;IAEF,YAAY,EACX,CAAC,GAAgB,EAAE,EAAE,CACrB,CAAC,SAAiB,EAA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AAC;IAE1C,gCAAgC;IAChC,OAAO,YAAY,CAClB,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QACnB,8DAA8D;QAC9D,MAAM,YAAY,GAAG,MAAM,GAAG,CAAC,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAC7D,MAAM,GAAG,CAAC,gBAAgB,CAAC,YAAY,EAAE,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QACrE,MAAM,GAAG,CAAC,iBAAiB,CAAC,YAAY,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;QAE9D,iDAAiD;QACjD,OAAO,CAAC,GAAG,CAAC,4BAA4B,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;QACpD,MAAM,UAAU,GAAG,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAEtC,OAAO,IAAI,CAAC;IACb,CAAC,EACD;QACC,IAAI,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC;QACzB,YAAY,EAAE,CAAC,OAAO,CAAC;QACvB,EAAE,EAAE,iBAAiB;KACrB,CACD,CAAC;AACH,CAAC,CAAC;AAEF,2CAA2C;AAC3C,OAAO,EAAC,SAAS,EAAE,UAAU,EAAE,gBAAgB,EAAC,CAAC"}
@@ -1,16 +0,0 @@
1
- interface LookupFileOptions {
2
- pathOnly?: boolean;
3
- rootDir?: string;
4
- predicate?: (file: string) => boolean;
5
- }
6
- export declare function lookupFile(dir: string, formats: string[], options?: LookupFileOptions): string | undefined;
7
- export declare function traverseMultipleDirectory(dirs: readonly string[]): string[];
8
- export declare const traverse: (dir: string, result?: any[], topDir?: string, filter?: (name: string, stats: any) => boolean) => Array<{
9
- name: string;
10
- path: string;
11
- relativePath: string;
12
- mtimeMs: number;
13
- directory: boolean;
14
- }>;
15
- export {};
16
- //# sourceMappingURL=fs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../src/utils/fs.ts"],"names":[],"mappings":"AAIA,UAAU,iBAAiB;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CACtC;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,MAAM,GAAG,SAAS,CAc1G;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAU3E;AAED,eAAO,MAAM,QAAQ,GACpB,KAAK,MAAM,EACX,SAAQ,GAAG,EAAO,EAClB,SAAS,MAAM,EACf,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,OAAO,KAC5C,KAAK,CAAC;IACR,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;CACnB,CAoBA,CAAC"}
package/dist/utils/fs.js DELETED
@@ -1,52 +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
- export function lookupFile(dir, formats, options) {
5
- for (const format of formats) {
6
- const fullPath = path.join(dir, format);
7
- if (fs.existsSync(fullPath) && fs.statSync(fullPath).isFile()) {
8
- const result = options?.pathOnly ? fullPath : fs.readFileSync(fullPath, 'utf-8');
9
- if (!options?.predicate || options.predicate(result)) {
10
- return result;
11
- }
12
- }
13
- }
14
- const parentDir = path.dirname(dir);
15
- if (parentDir !== dir && (!options?.rootDir || parentDir.startsWith(options?.rootDir))) {
16
- return lookupFile(parentDir, formats, options);
17
- }
18
- }
19
- export function traverseMultipleDirectory(dirs) {
20
- const filepaths = [];
21
- for (const dir of dirs) {
22
- let filesStats = traverse(dir);
23
- filesStats = filesStats.filter((v) => !v.directory);
24
- for (const filestat of filesStats) {
25
- filepaths.push(path.join(dir, filestat.relativePath));
26
- }
27
- }
28
- return filepaths;
29
- }
30
- export const traverse = function (dir, result = [], topDir, filter // TODO any is Stats
31
- ) {
32
- fs.readdirSync(dir).forEach((name) => {
33
- const fPath = path.resolve(dir, name);
34
- const stats = fs.statSync(fPath);
35
- if ((!filter && !name.startsWith('.')) || (filter && filter(name, stats))) {
36
- const fileStats = {
37
- name,
38
- path: fPath,
39
- relativePath: path.relative(topDir || dir, fPath),
40
- mtimeMs: stats.mtimeMs,
41
- directory: stats.isDirectory(),
42
- };
43
- if (fileStats.directory) {
44
- result.push(fileStats);
45
- return traverse(fPath, result, topDir || dir, filter);
46
- }
47
- result.push(fileStats);
48
- }
49
- });
50
- return result;
51
- };
52
- //# sourceMappingURL=fs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fs.js","sourceRoot":"","sources":["../../src/utils/fs.ts"],"names":[],"mappings":"AAAA,oIAAoI;AACpI,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAQ7B,MAAM,UAAU,UAAU,CAAC,GAAW,EAAE,OAAiB,EAAE,OAA2B;IACrF,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACxC,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;YAC/D,MAAM,MAAM,GAAG,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,YAAY,CAAC,QAAQ,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QACtC,MAAM,KAAK,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACjC,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;YAC3E,MAAM,SAAS,GAAG;gBACjB,IAAI;gBACJ,IAAI,EAAE,KAAK;gBACX,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAI,GAAG,EAAE,KAAK,CAAC;gBACjD,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,SAAS,EAAE,KAAK,CAAC,WAAW,EAAE;aAC9B,CAAC;YACF,IAAI,SAAS,CAAC,SAAS,EAAE,CAAC;gBACzB,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;gBACvB,OAAO,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,IAAI,GAAG,EAAE,MAAM,CAAC,CAAC;YACvD,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACxB,CAAC;IACF,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AACf,CAAC,CAAC"}
package/src/cli.ts DELETED
@@ -1,34 +0,0 @@
1
- #! /usr/bin/env node
2
- import {loadEnv} from 'ldenv';
3
- import {ExecutionParams, loadAndExecuteDeployments} from './index.js';
4
- import {Command} from 'commander';
5
- import pkg from '../package.json' with {type: 'json'};
6
-
7
- loadEnv();
8
-
9
- const commandName = "rocketh";
10
- const program = new Command();
11
- program
12
- .name(commandName)
13
- .version(pkg.version)
14
- .usage(`${commandName}`)
15
- .description('execute deploy scripts and store the deployments')
16
- .option('-s, --scripts <value>', 'path the folder containing the deploy scripts to execute')
17
- .option('-t, --tags <value>', 'comma separated list of tags to execute')
18
- .option('-d, --deployments <value>', 'folder where deployments are saved')
19
- .option('--skip-gas-report', 'if set skip gas report')
20
- .option('--skip-prompts', 'if set skip any prompts')
21
- .option('--save-deployments', 'if set, save deployments')
22
- .requiredOption('-e, --environment <value>', 'environment to use')
23
- .parse(process.argv);
24
-
25
- const options = program.opts();
26
-
27
-
28
- loadAndExecuteDeployments({
29
- ...(options as ExecutionParams),
30
- logLevel: 1,
31
- askBeforeProceeding: options.skipPrompts ? false : true,
32
- reportGasUse: options.skipGasReport ? false : true,
33
- saveDeployments: options.saveDeployments,
34
- });
@@ -1,135 +0,0 @@
1
- import path from 'node:path';
2
- import fs from 'node:fs';
3
- import {traverse} from '../utils/fs.js';
4
- import {UnknownDeployments} from '../types.js';
5
-
6
- export function loadDeployments(
7
- deploymentsPath: string,
8
- networkName: string,
9
- onlyABIAndAddress?: boolean,
10
- expectedChain?: {chainId: string; genesisHash?: `0x${string}`; deleteDeploymentsIfDifferentGenesisHash?: boolean}
11
- ): {
12
- deployments: UnknownDeployments;
13
- migrations: Record<string, number>;
14
- chainId?: string;
15
- genesisHash?: `0x${string}`;
16
- } {
17
- const deploymentsFound: UnknownDeployments = {};
18
- const deployPath = path.join(deploymentsPath, networkName);
19
-
20
- let filesStats;
21
- try {
22
- filesStats = traverse(
23
- deployPath,
24
- undefined,
25
- undefined,
26
- (name) => !(name.startsWith('.') && name !== '.migrations.json') && name !== 'solcInputs'
27
- );
28
- } catch (e) {
29
- // console.log('no folder at ' + deployPath);
30
- return {deployments: {}, migrations: {}};
31
- }
32
- let chainId: string;
33
- let genesisHash: `0x${string}` | undefined;
34
- if (filesStats.length > 0) {
35
- const chainIdFilepath = path.join(deployPath, '.chainId');
36
- const chainFilepath = path.join(deployPath, '.chain');
37
- if (fs.existsSync(chainFilepath)) {
38
- const chainSTR = fs.readFileSync(chainFilepath, 'utf-8');
39
- const chainData = JSON.parse(chainSTR);
40
- chainId = chainData.chainId;
41
- genesisHash = chainData.genesisHash;
42
- } else if (fs.existsSync(chainIdFilepath)) {
43
- chainId = fs.readFileSync(chainIdFilepath, 'utf-8').trim();
44
- } else {
45
- throw new Error(
46
- `A '.chain' or '.chainId' file is expected to be present in the deployment folder for network ${networkName}`
47
- );
48
- }
49
-
50
- if (expectedChain) {
51
- if (expectedChain.chainId !== chainId) {
52
- throw new Error(
53
- `Loading deployment in folder '${deployPath}' (with chainId: ${chainId}) for a different chainId (${expectedChain.chainId})`
54
- );
55
- }
56
-
57
- if (genesisHash) {
58
- if (expectedChain.genesisHash && expectedChain.genesisHash !== genesisHash) {
59
- if (expectedChain.deleteDeploymentsIfDifferentGenesisHash) {
60
- // we delete the old folder
61
-
62
- fs.rmSync(deployPath, {recursive: true, force: true});
63
- return {deployments: {}, migrations: {}};
64
- } else {
65
- throw new Error(
66
- `Loading deployment in folder '${deployPath}' (with genesisHash: ${genesisHash}) for a different genesisHash (${expectedChain.genesisHash})`
67
- );
68
- }
69
- }
70
- } else {
71
- console.warn(
72
- `genesisHash not found in folder '${deployPath}' (with chainId: ${chainId}), writing .chain with expected one...`
73
- );
74
- fs.writeFileSync(
75
- chainFilepath,
76
- JSON.stringify({chainId: expectedChain.chainId, genesisHash: expectedChain.genesisHash})
77
- );
78
- try {
79
- fs.unlinkSync(chainIdFilepath);
80
- } catch {}
81
- }
82
- }
83
- } else {
84
- return {deployments: {}, migrations: {}};
85
- }
86
-
87
- let migrations: Record<string, number> = {};
88
- const migrationsFilepath = path.join(deployPath, '.migrations.json');
89
- if (fs.existsSync(migrationsFilepath)) {
90
- try {
91
- migrations = JSON.parse(fs.readFileSync(migrationsFilepath, 'utf-8'));
92
- } catch (err) {
93
- console.error(`failed to parse .migrations.json`);
94
- }
95
- }
96
-
97
- let fileNames = filesStats.map((a) => a.relativePath);
98
- fileNames = fileNames.sort((a, b) => {
99
- if (a < b) {
100
- return -1;
101
- }
102
- if (a > b) {
103
- return 1;
104
- }
105
- return 0;
106
- });
107
-
108
- for (const fileName of fileNames) {
109
- if (fileName.substring(fileName.length - 5) === '.json' && fileName !== '.migrations.json') {
110
- const deploymentFileName = path.join(deployPath, fileName);
111
- let deployment = JSON.parse(fs.readFileSync(deploymentFileName).toString());
112
- // truffleChainId argument:
113
- // if (!deployment.address && deployment.networks) {
114
- // if (truffleChainId && deployment.networks[truffleChainId]) {
115
- // // TRUFFLE support
116
- // const truffleDeployment = deployment as any; // TruffleDeployment;
117
- // deployment.address = truffleDeployment.networks[truffleChainId].address;
118
- // deployment.transactionHash = truffleDeployment.networks[truffleChainId].transactionHash;
119
- // }
120
- // }
121
- if (onlyABIAndAddress) {
122
- deployment = {
123
- address: deployment.address,
124
- abi: deployment.abi,
125
- linkedData: deployment.linkedData,
126
- };
127
- }
128
- const name = fileName.slice(0, fileName.length - 5);
129
- // console.log('fetching ' + deploymentFileName + ' for ' + name);
130
-
131
- deploymentsFound[name] = deployment;
132
- }
133
- }
134
- return {deployments: deploymentsFound, migrations, chainId, genesisHash};
135
- }