Skip to content

Commit 38baca9

Browse files
committed
Add abi generation
1 parent fc9aff7 commit 38baca9

File tree

8 files changed

+11250
-1
lines changed

8 files changed

+11250
-1
lines changed

abi/11155111.json

Lines changed: 2441 additions & 0 deletions
Large diffs are not rendered by default.

abi/11155420.json

Lines changed: 1730 additions & 0 deletions
Large diffs are not rendered by default.

abi/300.json

Lines changed: 1730 additions & 0 deletions
Large diffs are not rendered by default.

abi/33111.json

Lines changed: 1730 additions & 0 deletions
Large diffs are not rendered by default.

abi/421614.json

Lines changed: 1847 additions & 0 deletions
Large diffs are not rendered by default.

abi/4801.json

Lines changed: 1730 additions & 0 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
"compile:zksync": "bun hardhat compile --network zkSyncSepolia",
2828
"connection:register": "bun run scripts/connect.ts",
2929
"satellite:deploy": "bun run scripts/deploy.ts",
30-
"satellite:upgrade": "bun run compile && bun run scripts/SatelliteUpgrade.ts"
30+
"satellite:upgrade": "bun run compile && bun run scripts/SatelliteUpgrade.ts",
31+
"erase_deployed_satellites": "echo \"{\n\t\\\"satellites\\\": [],\n\t\\\"connections\\\": []\n}\" > deployed_satellites.json",
32+
"generate_abi": "bun run scripts/generate-abi.ts"
3133
},
3234
"devDependencies": {
3335
"@nomicfoundation/hardhat-chai-matchers": "^2.0.0",

scripts/generate-abi.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import hre from "hardhat";
2+
import fs from "fs";
3+
4+
async function main() {
5+
const chains = fs.readdirSync("ignition/modules");
6+
7+
for (const chain of chains) {
8+
const modules = require(`../ignition/modules/${chain}`).modules;
9+
modules.push("SatelliteMaintenanceModule");
10+
const outFile = `abi/${chain.replace(".ts", "")}.json`;
11+
12+
const mergedAbi = [];
13+
for (const module of modules) {
14+
const abi = hre.artifacts.readArtifactSync(module).abi;
15+
mergedAbi.push(...abi);
16+
}
17+
18+
const dedupedAbi = [];
19+
const nameToJsonString = new Map<string, string>();
20+
for (const abi of mergedAbi) {
21+
const abiJsonString = JSON.stringify(abi);
22+
if (nameToJsonString.has(abi.name)) {
23+
if (nameToJsonString.get(abi.name) !== abiJsonString) {
24+
throw new Error(
25+
`Duplicate function ${abi.name} with different parameters`,
26+
);
27+
} else {
28+
continue;
29+
}
30+
}
31+
nameToJsonString.set(abi.name, abiJsonString);
32+
dedupedAbi.push(abi);
33+
}
34+
35+
fs.writeFileSync(outFile, JSON.stringify(dedupedAbi, null, 2));
36+
}
37+
}
38+
39+
main();

0 commit comments

Comments
 (0)