Skip to content

Commit 25dce8c

Browse files
committed
fix: use js for generate abi script
1 parent 8221064 commit 25dce8c

File tree

4 files changed

+89
-44
lines changed

4 files changed

+89
-44
lines changed

package-lock.json

Lines changed: 22 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { execSync } from "child_process";
2+
import { existsSync, rmSync } from "fs";
3+
import { dirname, join } from "path";
4+
import process from "process";
5+
import { fileURLToPath } from "url";
6+
7+
// Get script directory (equivalent to BASH_SOURCE in bash)
8+
const __filename = fileURLToPath(import.meta.url);
9+
const __dirname = dirname(__filename);
10+
11+
const CONTRACT_DIR = join(__dirname, "waku-rlnv2-contract");
12+
const REPO_URL = "[email protected]:waku-org/waku-rlnv2-contract.git";
13+
14+
/**
15+
* Execute a shell command and print output in real-time
16+
* @param {string} command - The command to execute
17+
* @param {object} options - Options for execSync
18+
*/
19+
function exec(command, options = {}) {
20+
execSync(command, {
21+
stdio: "inherit",
22+
cwd: options.cwd || __dirname,
23+
...options
24+
});
25+
}
26+
27+
async function main() {
28+
try {
29+
console.log("📦 Setting up waku-rlnv2-contract...");
30+
31+
// Remove existing directory if it exists
32+
if (existsSync(CONTRACT_DIR)) {
33+
console.log("🗑️ Removing existing waku-rlnv2-contract directory...");
34+
rmSync(CONTRACT_DIR, { recursive: true, force: true });
35+
}
36+
37+
// Clone the repository
38+
console.log("📥 Cloning waku-rlnv2-contract...");
39+
exec(`git clone ${REPO_URL} ${CONTRACT_DIR}`);
40+
41+
// Install dependencies
42+
console.log("📦 Installing dependencies...");
43+
exec("npm install", { cwd: CONTRACT_DIR });
44+
45+
// Build contracts with Foundry
46+
console.log("🔨 Building contracts with Foundry...");
47+
exec("forge build", { cwd: CONTRACT_DIR });
48+
49+
// Generate ABIs with wagmi
50+
console.log("⚙️ Generating ABIs with wagmi...");
51+
exec("npx wagmi generate");
52+
53+
console.log("✅ Contract ABIs generated successfully!");
54+
} catch (error) {
55+
console.log(
56+
"❌ Error generating contract ABIs:",
57+
error instanceof Error ? error.message : error
58+
);
59+
process.exit(1);
60+
}
61+
}
62+
63+
main().catch((error) => {
64+
console.log(error);
65+
process.exit(1);
66+
});

packages/rln/generate_contract_abi.sh

Lines changed: 0 additions & 42 deletions
This file was deleted.

packages/rln/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"watch:test": "mocha --watch",
4545
"prepublish": "npm run build",
4646
"reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build",
47-
"setup:contract-abi": "./generate_contract_abi.sh"
47+
"setup:contract-abi": "node generate_contract_abi.js"
4848
},
4949
"engines": {
5050
"node": ">=22"

0 commit comments

Comments
 (0)