-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprocess-abi.js
52 lines (47 loc) · 1.27 KB
/
process-abi.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const {
readdirSync,
removeSync,
lstatSync,
readJsonSync,
writeJsonSync,
} = require('fs-extra');
const _path = require('path');
async function main() {
const deploymentsDirPath = _path.resolve(__dirname, 'src', 'deployments');
removeMetadataFromDir(deploymentsDirPath);
}
main().catch(console.error);
function removeMetadataFromDir(currentDirPath) {
const dirs = readdirSync(currentDirPath);
dirs.forEach((childDirName) => {
const childPath = _path.resolve(currentDirPath, childDirName);
if (childDirName === 'solcInputs') {
removeSync(childPath);
return;
}
// if (childDirName === '.chainId') {
// removeSync(childPath);
// return;
// }
if (lstatSync(childPath).isDirectory()) {
removeMetadataFromDir(childPath);
} else {
removeMetadataFromFile(childPath);
}
});
}
function removeMetadataFromFile(path) {
const data = readJsonSync(path);
// only keep address, get rid of all other things, to reduce package size
const receipt = data?.receipt;
const newData = {
address: data.address,
};
if (receipt !== undefined) {
newData.receipt = {
blockNumber: receipt.blockNumber,
transactionHash: receipt.transactionHash,
};
}
writeJsonSync(path, newData, { spaces: 2 });
}