rocketh 0.15.15 → 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 +11 -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 +39 -316
- 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 +89 -398
- 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,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
|
-
}
|