mirror of
https://github.com/logos-messaging/logos-messaging-js.git
synced 2026-01-17 23:43:07 +00:00
fix: use js for generate abi script
This commit is contained in:
parent
5d9ddad191
commit
525bdcf68c
23
package-lock.json
generated
23
package-lock.json
generated
@ -31414,6 +31414,26 @@
|
||||
"devOptional": true,
|
||||
"license": "0BSD"
|
||||
},
|
||||
"node_modules/tsx": {
|
||||
"version": "4.20.6",
|
||||
"resolved": "https://registry.npmjs.org/tsx/-/tsx-4.20.6.tgz",
|
||||
"integrity": "sha512-ytQKuwgmrrkDTFP4LjR0ToE2nqgy886GpvRSpU0JAnrdBYppuY5rLkRUYPU1yCryb24SsKBTL/hlDQAEFVwtZg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"esbuild": "~0.25.0",
|
||||
"get-tsconfig": "^4.7.5"
|
||||
},
|
||||
"bin": {
|
||||
"tsx": "dist/cli.mjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"fsevents": "~2.3.3"
|
||||
}
|
||||
},
|
||||
"node_modules/tweetnacl": {
|
||||
"version": "0.14.5",
|
||||
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz",
|
||||
@ -34761,7 +34781,8 @@
|
||||
"@waku/message-encryption": "^0.0.37",
|
||||
"deep-equal-in-any-order": "^2.0.6",
|
||||
"fast-check": "^3.23.2",
|
||||
"rollup-plugin-copy": "^3.5.0"
|
||||
"rollup-plugin-copy": "^3.5.0",
|
||||
"tsx": "^4.19.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=22"
|
||||
|
||||
66
packages/rln/generate_contract_abi.js
Normal file
66
packages/rln/generate_contract_abi.js
Normal file
@ -0,0 +1,66 @@
|
||||
import { execSync } from "child_process";
|
||||
import { existsSync, rmSync } from "fs";
|
||||
import { dirname, join } from "path";
|
||||
import process from "process";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
// Get script directory (equivalent to BASH_SOURCE in bash)
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
const CONTRACT_DIR = join(__dirname, "waku-rlnv2-contract");
|
||||
const REPO_URL = "git@github.com:waku-org/waku-rlnv2-contract.git";
|
||||
|
||||
/**
|
||||
* Execute a shell command and print output in real-time
|
||||
* @param {string} command - The command to execute
|
||||
* @param {object} options - Options for execSync
|
||||
*/
|
||||
function exec(command, options = {}) {
|
||||
execSync(command, {
|
||||
stdio: "inherit",
|
||||
cwd: options.cwd || __dirname,
|
||||
...options
|
||||
});
|
||||
}
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
console.log("📦 Setting up waku-rlnv2-contract...");
|
||||
|
||||
// Remove existing directory if it exists
|
||||
if (existsSync(CONTRACT_DIR)) {
|
||||
console.log("🗑️ Removing existing waku-rlnv2-contract directory...");
|
||||
rmSync(CONTRACT_DIR, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
// Clone the repository
|
||||
console.log("📥 Cloning waku-rlnv2-contract...");
|
||||
exec(`git clone ${REPO_URL} ${CONTRACT_DIR}`);
|
||||
|
||||
// Install dependencies
|
||||
console.log("📦 Installing dependencies...");
|
||||
exec("npm install", { cwd: CONTRACT_DIR });
|
||||
|
||||
// Build contracts with Foundry
|
||||
console.log("🔨 Building contracts with Foundry...");
|
||||
exec("forge build", { cwd: CONTRACT_DIR });
|
||||
|
||||
// Generate ABIs with wagmi
|
||||
console.log("⚙️ Generating ABIs with wagmi...");
|
||||
exec("npx wagmi generate");
|
||||
|
||||
console.log("✅ Contract ABIs generated successfully!");
|
||||
} catch (error) {
|
||||
console.log(
|
||||
"❌ Error generating contract ABIs:",
|
||||
error instanceof Error ? error.message : error
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
console.log(error);
|
||||
process.exit(1);
|
||||
});
|
||||
@ -1,42 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# Script to generate contract ABIs from waku-rlnv2-contract
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
CONTRACT_DIR="$SCRIPT_DIR/waku-rlnv2-contract"
|
||||
REPO_URL="git@github.com:waku-org/waku-rlnv2-contract.git"
|
||||
|
||||
echo "📦 Setting up waku-rlnv2-contract..."
|
||||
|
||||
# Remove existing directory if it exists
|
||||
if [ -d "$CONTRACT_DIR" ]; then
|
||||
echo "🗑️ Removing existing waku-rlnv2-contract directory..."
|
||||
rm -rf "$CONTRACT_DIR"
|
||||
fi
|
||||
|
||||
# Clone the repository
|
||||
echo "📥 Cloning waku-rlnv2-contract..."
|
||||
git clone "$REPO_URL" "$CONTRACT_DIR"
|
||||
|
||||
# Navigate to contract directory
|
||||
cd "$CONTRACT_DIR"
|
||||
|
||||
# Install dependencies
|
||||
echo "📦 Installing dependencies..."
|
||||
npm install
|
||||
|
||||
# Build contracts with Foundry
|
||||
echo "🔨 Building contracts with Foundry..."
|
||||
forge build
|
||||
|
||||
# Navigate back to rln package
|
||||
cd "$SCRIPT_DIR"
|
||||
|
||||
# Generate ABIs with wagmi
|
||||
echo "⚙️ Generating ABIs with wagmi..."
|
||||
npx wagmi generate
|
||||
|
||||
echo "✅ Contract ABIs generated successfully!"
|
||||
echo "📄 Output: src/contract/wagmi/generated.ts"
|
||||
@ -44,7 +44,7 @@
|
||||
"watch:test": "mocha --watch",
|
||||
"prepublish": "npm run build",
|
||||
"reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build",
|
||||
"setup:contract-abi": "./generate_contract_abi.sh"
|
||||
"setup:contract-abi": "node generate_contract_abi.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=22"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user