From 74d8dba6fd34188f2062accb306b32df02f3b8fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20B=C3=A9ranger?= Date: Wed, 18 Dec 2024 12:24:39 +0100 Subject: [PATCH] Fix `deploy-and-test.sh` script (#171) fix scripts --- README.md | 45 ++++++----------------- dao.config.ts | 2 +- deploy/deploy-crosschain-gov.ts | 6 +++- package.json | 2 +- scripts/claim-burn.ts | 26 +++++++++++--- scripts/claim-delegation.ts | 26 +++++++++++--- scripts/claim-manifesto.ts | 26 +++++++++++--- scripts/claim-membership.ts | 27 ++++++++++---- scripts/claim-metadata.ts | 26 +++++++++++--- scripts/claim-voting-delay.ts | 26 +++++++++++--- scripts/deploy-and-test.sh | 64 +++++++++++++++++++++++++++++++++ 11 files changed, 208 insertions(+), 68 deletions(-) create mode 100755 scripts/deploy-and-test.sh diff --git a/README.md b/README.md index efa55df..56dad88 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,12 @@ cp .env.template .env - Add your own keys in your `.env` file - Edit the `dao.config.ts` file (optional) +- Check if the main account has a sufficient wallet balance: + +``` +pnpm bal +``` + - Then deploy to Sepolia: ```bash @@ -94,42 +100,13 @@ The following functions are `onlyOwner`, and since the NFT contract ownership is ### Crosschain -Make sure the main account, Bob and Alice have sufficient balance on OP Sepolia and Arbitrum Sepolia: +- Make sure the main account, as well as Alice and Bob accounts have a sufficient balance on OP Sepolia, Arbitrum Sepolia and Base Sepolia +- Set the initial parameters of the test DAO in `dao.config.ts` +- Run the `deploy-and-test.sh` script: ``` -# Deploy to OP Sepolia and Arbitrum Sepolia -pnpm deploy:op-sepolia -pnpm deploy:arbitrum-sepolia - -# Add a new member -npx hardhat run scripts/propose.ts --network op-sepolia -npx hardhat run scripts/verify-proof.ts --network op-sepolia -npx hardhat run scripts/claim-membership.ts --network arbitrum-sepolia - -# Ban a member -npx hardhat run scripts/propose-burn.ts --network op-sepolia -npx hardhat run scripts/verify-burn-proof.ts --network op-sepolia -npx hardhat run scripts/claim-burn.ts --network arbitrum-sepolia - -# Edit 1 membership NFT metadata -npx hardhat run scripts/propose-metadata.ts --network op-sepolia -npx hardhat run scripts/verify-metadata-proof.ts --network op-sepolia -npx hardhat run scripts/claim-metadata.ts --network arbitrum-sepolia - -# Edit the manifesto -npx hardhat run scripts/propose-manifesto.ts --network op-sepolia -npx hardhat run scripts/verify-manifesto-proof.ts --network op-sepolia -npx hardhat run scripts/claim-manifesto.ts --network arbitrum-sepolia - -# Change 1 voting parameter -npx hardhat run scripts/propose-voting-delay.ts --network op-sepolia -npx hardhat run scripts/verify-voting-delay-proof.ts --network op-sepolia -npx hardhat run scripts/claim-voting-delay.ts --network arbitrum-sepolia - -# Change delegation -npx hardhat run scripts/propose-delegation.ts --network op-sepolia -npx hardhat run scripts/verify-delegation-proof.ts --network op-sepolia -npx hardhat run scripts/claim-delegation.ts --network arbitrum-sepolia +chmod +x scripts/deploy-and-test.sh +./scripts/deploy-and-test.sh --salt "" ``` ## Core Dependencies diff --git a/dao.config.ts b/dao.config.ts index 30ca919..2e8125a 100644 --- a/dao.config.ts +++ b/dao.config.ts @@ -1,6 +1,6 @@ ///// Home chain ///// -export const homeChain = 11155111 +export const homeChain = 11155420 ///// Membership NFT ///// diff --git a/deploy/deploy-crosschain-gov.ts b/deploy/deploy-crosschain-gov.ts index 422a689..6df5977 100644 --- a/deploy/deploy-crosschain-gov.ts +++ b/deploy/deploy-crosschain-gov.ts @@ -19,7 +19,11 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const { deployments, getNamedAccounts } = hre const { deterministic } = deployments const { deployer } = await getNamedAccounts() - const salt = hre.ethers.id("Dec-17-v1") + + const saltArg = process.env.SALT || "Dec-25-v1" + const salt = hre.ethers.id(saltArg) + + console.log(`Using salt: ${saltArg} (ID: ${salt})`) const homeChainId = 11155420 function wait(ms: number): Promise { diff --git a/package.json b/package.json index 255a325..26e5205 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "crosschain:sepolia": "hardhat deploy --network sepolia --tags CrosschainGov --reset", "crosschain:op-sepolia": "hardhat deploy --network op-sepolia --tags CrosschainGov --reset", "crosschain:arbitrum-sepolia": "hardhat deploy --network arbitrum-sepolia --tags CrosschainGov --reset", - "deploy:all": "./scripts/deploy.sh", + "crosschain:base-sepolia": "hardhat deploy --network base-sepolia --tags CrosschainGov --reset", "bal": "npx hardhat run scripts/check-my-balance.ts", "verify:setup": "hardhat run scripts/verify-crosschain-setup.ts", "prettier": "prettier --write \"**/*.ts\"", diff --git a/scripts/claim-burn.ts b/scripts/claim-burn.ts index 4ca1405..ac97d16 100644 --- a/scripts/claim-burn.ts +++ b/scripts/claim-burn.ts @@ -43,11 +43,27 @@ async function main() { const NFT_ADDRESS = getDeployedAddress(networkName, "CrosschainNFT") console.log("Using NFT contract address:", NFT_ADDRESS) - let provider = new ethers.JsonRpcProvider( - networkName === "op-sepolia" - ? process.env.OP_SEPOLIA_RPC_ENDPOINT_URL - : process.env.ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL - ) + function getRpcUrl(networkName: string): string { + switch (networkName) { + case "sepolia": + return process.env.SEPOLIA_RPC_ENDPOINT_URL || "" + case "op-sepolia": + return process.env.OP_SEPOLIA_RPC_ENDPOINT_URL || "" + case "base-sepolia": + return process.env.BASE_SEPOLIA_RPC_ENDPOINT_URL || "" + case "arbitrum-sepolia": + return process.env.ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL || "" + default: + throw new Error(`Unsupported network: ${networkName}`) + } + } + const rpcUrl = getRpcUrl(networkName) + if (!rpcUrl) { + throw new Error(`RPC URL is not configured for network: ${networkName}`) + } + console.log(`Using RPC URL: ${rpcUrl}`) + const provider = new ethers.JsonRpcProvider(rpcUrl) + const signerZero = new ethers.Wallet(SIGNER_PRIVATE_KEY, provider) console.log("Using address:", signerZero.address) diff --git a/scripts/claim-delegation.ts b/scripts/claim-delegation.ts index 4d4cd0e..02c5bd5 100644 --- a/scripts/claim-delegation.ts +++ b/scripts/claim-delegation.ts @@ -47,11 +47,27 @@ async function main() { const NFT_ADDRESS = getDeployedAddress(networkName, "CrosschainNFT") console.log("Using NFT contract address:", msg(NFT_ADDRESS)) - const provider = new ethers.JsonRpcProvider( - networkName === "op-sepolia" - ? process.env.OP_SEPOLIA_RPC_ENDPOINT_URL - : process.env.ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL - ) + function getRpcUrl(networkName: string): string { + switch (networkName) { + case "sepolia": + return process.env.SEPOLIA_RPC_ENDPOINT_URL || "" + case "op-sepolia": + return process.env.OP_SEPOLIA_RPC_ENDPOINT_URL || "" + case "base-sepolia": + return process.env.BASE_SEPOLIA_RPC_ENDPOINT_URL || "" + case "arbitrum-sepolia": + return process.env.ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL || "" + default: + throw new Error(`Unsupported network: ${networkName}`) + } + } + const rpcUrl = getRpcUrl(networkName) + if (!rpcUrl) { + throw new Error(`RPC URL is not configured for network: ${networkName}`) + } + console.log(`Using RPC URL: ${rpcUrl}`) + const provider = new ethers.JsonRpcProvider(rpcUrl) + const signer = new ethers.Wallet(SIGNER_PRIVATE_KEY, provider) const nft = NFT__factory.connect(NFT_ADDRESS, signer) diff --git a/scripts/claim-manifesto.ts b/scripts/claim-manifesto.ts index 36a9b8b..392da31 100644 --- a/scripts/claim-manifesto.ts +++ b/scripts/claim-manifesto.ts @@ -43,11 +43,27 @@ async function main() { const GOV_ADDRESS = getDeployedAddress(networkName, "CrosschainGov") console.log("Using Gov contract address:", GOV_ADDRESS) - const provider = new ethers.JsonRpcProvider( - networkName === "op-sepolia" - ? process.env.OP_SEPOLIA_RPC_ENDPOINT_URL - : process.env.ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL - ) + function getRpcUrl(networkName: string): string { + switch (networkName) { + case "sepolia": + return process.env.SEPOLIA_RPC_ENDPOINT_URL || "" + case "op-sepolia": + return process.env.OP_SEPOLIA_RPC_ENDPOINT_URL || "" + case "base-sepolia": + return process.env.BASE_SEPOLIA_RPC_ENDPOINT_URL || "" + case "arbitrum-sepolia": + return process.env.ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL || "" + default: + throw new Error(`Unsupported network: ${networkName}`) + } + } + const rpcUrl = getRpcUrl(networkName) + if (!rpcUrl) { + throw new Error(`RPC URL is not configured for network: ${networkName}`) + } + console.log(`Using RPC URL: ${rpcUrl}`) + const provider = new ethers.JsonRpcProvider(rpcUrl) + const signer = new ethers.Wallet(SIGNER_PRIVATE_KEY, provider) const gov = Gov__factory.connect(GOV_ADDRESS, signer) diff --git a/scripts/claim-membership.ts b/scripts/claim-membership.ts index 534c26c..b7dca22 100644 --- a/scripts/claim-membership.ts +++ b/scripts/claim-membership.ts @@ -46,12 +46,27 @@ async function main() { const NFT_ADDRESS = getDeployedAddress(networkName, "CrosschainNFT") console.log("Using NFT contract address:", NFT_ADDRESS) - // Get RPC URL based on network - let provider = new ethers.JsonRpcProvider( - networkName === "op-sepolia" - ? process.env.OP_SEPOLIA_RPC_ENDPOINT_URL - : process.env.ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL - ) + function getRpcUrl(networkName: string): string { + switch (networkName) { + case "sepolia": + return process.env.SEPOLIA_RPC_ENDPOINT_URL || "" + case "op-sepolia": + return process.env.OP_SEPOLIA_RPC_ENDPOINT_URL || "" + case "base-sepolia": + return process.env.BASE_SEPOLIA_RPC_ENDPOINT_URL || "" + case "arbitrum-sepolia": + return process.env.ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL || "" + default: + throw new Error(`Unsupported network: ${networkName}`) + } + } + const rpcUrl = getRpcUrl(networkName) + if (!rpcUrl) { + throw new Error(`RPC URL is not configured for network: ${networkName}`) + } + console.log(`Using RPC URL: ${rpcUrl}`) + const provider = new ethers.JsonRpcProvider(rpcUrl) + const signerZero = new ethers.Wallet(SIGNER_PRIVATE_KEY, provider) console.log("Using address:", signerZero.address) diff --git a/scripts/claim-metadata.ts b/scripts/claim-metadata.ts index 965548f..8c53429 100644 --- a/scripts/claim-metadata.ts +++ b/scripts/claim-metadata.ts @@ -43,11 +43,27 @@ async function main() { const NFT_ADDRESS = getDeployedAddress(networkName, "CrosschainNFT") console.log("Using NFT contract address:", NFT_ADDRESS) - const provider = new ethers.JsonRpcProvider( - networkName === "op-sepolia" - ? process.env.OP_SEPOLIA_RPC_ENDPOINT_URL - : process.env.ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL - ) + function getRpcUrl(networkName: string): string { + switch (networkName) { + case "sepolia": + return process.env.SEPOLIA_RPC_ENDPOINT_URL || "" + case "op-sepolia": + return process.env.OP_SEPOLIA_RPC_ENDPOINT_URL || "" + case "base-sepolia": + return process.env.BASE_SEPOLIA_RPC_ENDPOINT_URL || "" + case "arbitrum-sepolia": + return process.env.ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL || "" + default: + throw new Error(`Unsupported network: ${networkName}`) + } + } + const rpcUrl = getRpcUrl(networkName) + if (!rpcUrl) { + throw new Error(`RPC URL is not configured for network: ${networkName}`) + } + console.log(`Using RPC URL: ${rpcUrl}`) + const provider = new ethers.JsonRpcProvider(rpcUrl) + const signerZero = new ethers.Wallet(SIGNER_PRIVATE_KEY, provider) console.log("Using address:", signerZero.address) diff --git a/scripts/claim-voting-delay.ts b/scripts/claim-voting-delay.ts index dcfe3b9..17e70df 100644 --- a/scripts/claim-voting-delay.ts +++ b/scripts/claim-voting-delay.ts @@ -43,11 +43,27 @@ async function main() { const GOV_ADDRESS = getDeployedAddress(networkName, "CrosschainGov") console.log("Using Gov contract address:", GOV_ADDRESS) - const provider = new ethers.JsonRpcProvider( - networkName === "op-sepolia" - ? process.env.OP_SEPOLIA_RPC_ENDPOINT_URL - : process.env.ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL - ) + function getRpcUrl(networkName: string): string { + switch (networkName) { + case "sepolia": + return process.env.SEPOLIA_RPC_ENDPOINT_URL || "" + case "op-sepolia": + return process.env.OP_SEPOLIA_RPC_ENDPOINT_URL || "" + case "base-sepolia": + return process.env.BASE_SEPOLIA_RPC_ENDPOINT_URL || "" + case "arbitrum-sepolia": + return process.env.ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL || "" + default: + throw new Error(`Unsupported network: ${networkName}`) + } + } + const rpcUrl = getRpcUrl(networkName) + if (!rpcUrl) { + throw new Error(`RPC URL is not configured for network: ${networkName}`) + } + console.log(`Using RPC URL: ${rpcUrl}`) + const provider = new ethers.JsonRpcProvider(rpcUrl) + const signer = new ethers.Wallet(SIGNER_PRIVATE_KEY, provider) const gov = Gov__factory.connect(GOV_ADDRESS, signer) diff --git a/scripts/deploy-and-test.sh b/scripts/deploy-and-test.sh new file mode 100755 index 0000000..c5fc64d --- /dev/null +++ b/scripts/deploy-and-test.sh @@ -0,0 +1,64 @@ +#!/bin/bash +set -e + +# Default salt +SALT="Dec-25-v1" + +# Parse arguments +while [[ "$#" -gt 0 ]]; do + case $1 in + --salt) SALT="$2"; shift ;; + *) echo "Unknown parameter passed: $1"; exit 1 ;; + esac + shift +done + +# Export salt as an environment variable +export SALT + +echo "Deploying with salt: $SALT" + +# Deploy to OP Sepolia and Arbitrum Sepolia +pnpm crosschain:op-sepolia +pnpm crosschain:arbitrum-sepolia +pnpm crosschain:base-sepolia + +# Verify setup +pnpm verify:setup + +# Add a new member +npx hardhat run scripts/propose.ts --network op-sepolia +npx hardhat run scripts/verify-proof.ts --network op-sepolia +npx hardhat run scripts/claim-membership.ts --network arbitrum-sepolia +npx hardhat run scripts/claim-membership.ts --network base-sepolia + +# Ban a member +npx hardhat run scripts/propose-burn.ts --network op-sepolia +npx hardhat run scripts/verify-burn-proof.ts --network op-sepolia +npx hardhat run scripts/claim-burn.ts --network arbitrum-sepolia +npx hardhat run scripts/claim-burn.ts --network base-sepolia + +# Edit 1 membership NFT metadata +npx hardhat run scripts/propose-metadata.ts --network op-sepolia +npx hardhat run scripts/verify-metadata-proof.ts --network op-sepolia +npx hardhat run scripts/claim-metadata.ts --network arbitrum-sepolia +npx hardhat run scripts/claim-metadata.ts --network base-sepolia + +# Edit the manifesto +npx hardhat run scripts/propose-manifesto.ts --network op-sepolia +npx hardhat run scripts/verify-manifesto-proof.ts --network op-sepolia +npx hardhat run scripts/claim-manifesto.ts --network arbitrum-sepolia +npx hardhat run scripts/claim-manifesto.ts --network base-sepolia + +# Change 1 voting parameter +npx hardhat run scripts/propose-voting-delay.ts --network op-sepolia +npx hardhat run scripts/verify-voting-delay-proof.ts --network op-sepolia +npx hardhat run scripts/claim-voting-delay.ts --network arbitrum-sepolia +npx hardhat run scripts/claim-voting-delay.ts --network base-sepolia + +# Change delegation +npx hardhat run scripts/propose-delegation.ts --network op-sepolia +npx hardhat run scripts/verify-delegation-proof.ts --network op-sepolia +npx hardhat run scripts/claim-delegation.ts --network arbitrum-sepolia +npx hardhat run scripts/claim-delegation.ts --network base-sepolia +``` \ No newline at end of file