Skip to content

Commit 74d8dba

Browse files
authored
Fix deploy-and-test.sh script (#171)
fix scripts
1 parent fbb1e8f commit 74d8dba

11 files changed

+208
-68
lines changed

README.md

+11-34
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ cp .env.template .env
4040

4141
- Add your own keys in your `.env` file
4242
- Edit the `dao.config.ts` file (optional)
43+
- Check if the main account has a sufficient wallet balance:
44+
45+
```
46+
pnpm bal
47+
```
48+
4349
- Then deploy to Sepolia:
4450

4551
```bash
@@ -94,42 +100,13 @@ The following functions are `onlyOwner`, and since the NFT contract ownership is
94100

95101
### Crosschain
96102

97-
Make sure the main account, Bob and Alice have sufficient balance on OP Sepolia and Arbitrum Sepolia:
103+
- Make sure the main account, as well as Alice and Bob accounts have a sufficient balance on OP Sepolia, Arbitrum Sepolia and Base Sepolia
104+
- Set the initial parameters of the test DAO in `dao.config.ts`
105+
- Run the `deploy-and-test.sh` script:
98106

99107
```
100-
# Deploy to OP Sepolia and Arbitrum Sepolia
101-
pnpm deploy:op-sepolia
102-
pnpm deploy:arbitrum-sepolia
103-
104-
# Add a new member
105-
npx hardhat run scripts/propose.ts --network op-sepolia
106-
npx hardhat run scripts/verify-proof.ts --network op-sepolia
107-
npx hardhat run scripts/claim-membership.ts --network arbitrum-sepolia
108-
109-
# Ban a member
110-
npx hardhat run scripts/propose-burn.ts --network op-sepolia
111-
npx hardhat run scripts/verify-burn-proof.ts --network op-sepolia
112-
npx hardhat run scripts/claim-burn.ts --network arbitrum-sepolia
113-
114-
# Edit 1 membership NFT metadata
115-
npx hardhat run scripts/propose-metadata.ts --network op-sepolia
116-
npx hardhat run scripts/verify-metadata-proof.ts --network op-sepolia
117-
npx hardhat run scripts/claim-metadata.ts --network arbitrum-sepolia
118-
119-
# Edit the manifesto
120-
npx hardhat run scripts/propose-manifesto.ts --network op-sepolia
121-
npx hardhat run scripts/verify-manifesto-proof.ts --network op-sepolia
122-
npx hardhat run scripts/claim-manifesto.ts --network arbitrum-sepolia
123-
124-
# Change 1 voting parameter
125-
npx hardhat run scripts/propose-voting-delay.ts --network op-sepolia
126-
npx hardhat run scripts/verify-voting-delay-proof.ts --network op-sepolia
127-
npx hardhat run scripts/claim-voting-delay.ts --network arbitrum-sepolia
128-
129-
# Change delegation
130-
npx hardhat run scripts/propose-delegation.ts --network op-sepolia
131-
npx hardhat run scripts/verify-delegation-proof.ts --network op-sepolia
132-
npx hardhat run scripts/claim-delegation.ts --network arbitrum-sepolia
108+
chmod +x scripts/deploy-and-test.sh
109+
./scripts/deploy-and-test.sh --salt "<CUSTOM_SALT_HERE>"
133110
```
134111

135112
## Core Dependencies

dao.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
///// Home chain /////
22

3-
export const homeChain = 11155111
3+
export const homeChain = 11155420
44

55
///// Membership NFT /////
66

deploy/deploy-crosschain-gov.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
1919
const { deployments, getNamedAccounts } = hre
2020
const { deterministic } = deployments
2121
const { deployer } = await getNamedAccounts()
22-
const salt = hre.ethers.id("Dec-17-v1")
22+
23+
const saltArg = process.env.SALT || "Dec-25-v1"
24+
const salt = hre.ethers.id(saltArg)
25+
26+
console.log(`Using salt: ${saltArg} (ID: ${salt})`)
2327
const homeChainId = 11155420
2428

2529
function wait(ms: number): Promise<void> {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"crosschain:sepolia": "hardhat deploy --network sepolia --tags CrosschainGov --reset",
1717
"crosschain:op-sepolia": "hardhat deploy --network op-sepolia --tags CrosschainGov --reset",
1818
"crosschain:arbitrum-sepolia": "hardhat deploy --network arbitrum-sepolia --tags CrosschainGov --reset",
19-
"deploy:all": "./scripts/deploy.sh",
19+
"crosschain:base-sepolia": "hardhat deploy --network base-sepolia --tags CrosschainGov --reset",
2020
"bal": "npx hardhat run scripts/check-my-balance.ts",
2121
"verify:setup": "hardhat run scripts/verify-crosschain-setup.ts",
2222
"prettier": "prettier --write \"**/*.ts\"",

scripts/claim-burn.ts

+21-5
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,27 @@ async function main() {
4343
const NFT_ADDRESS = getDeployedAddress(networkName, "CrosschainNFT")
4444
console.log("Using NFT contract address:", NFT_ADDRESS)
4545

46-
let provider = new ethers.JsonRpcProvider(
47-
networkName === "op-sepolia"
48-
? process.env.OP_SEPOLIA_RPC_ENDPOINT_URL
49-
: process.env.ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL
50-
)
46+
function getRpcUrl(networkName: string): string {
47+
switch (networkName) {
48+
case "sepolia":
49+
return process.env.SEPOLIA_RPC_ENDPOINT_URL || ""
50+
case "op-sepolia":
51+
return process.env.OP_SEPOLIA_RPC_ENDPOINT_URL || ""
52+
case "base-sepolia":
53+
return process.env.BASE_SEPOLIA_RPC_ENDPOINT_URL || ""
54+
case "arbitrum-sepolia":
55+
return process.env.ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL || ""
56+
default:
57+
throw new Error(`Unsupported network: ${networkName}`)
58+
}
59+
}
60+
const rpcUrl = getRpcUrl(networkName)
61+
if (!rpcUrl) {
62+
throw new Error(`RPC URL is not configured for network: ${networkName}`)
63+
}
64+
console.log(`Using RPC URL: ${rpcUrl}`)
65+
const provider = new ethers.JsonRpcProvider(rpcUrl)
66+
5167
const signerZero = new ethers.Wallet(SIGNER_PRIVATE_KEY, provider)
5268

5369
console.log("Using address:", signerZero.address)

scripts/claim-delegation.ts

+21-5
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,27 @@ async function main() {
4747
const NFT_ADDRESS = getDeployedAddress(networkName, "CrosschainNFT")
4848
console.log("Using NFT contract address:", msg(NFT_ADDRESS))
4949

50-
const provider = new ethers.JsonRpcProvider(
51-
networkName === "op-sepolia"
52-
? process.env.OP_SEPOLIA_RPC_ENDPOINT_URL
53-
: process.env.ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL
54-
)
50+
function getRpcUrl(networkName: string): string {
51+
switch (networkName) {
52+
case "sepolia":
53+
return process.env.SEPOLIA_RPC_ENDPOINT_URL || ""
54+
case "op-sepolia":
55+
return process.env.OP_SEPOLIA_RPC_ENDPOINT_URL || ""
56+
case "base-sepolia":
57+
return process.env.BASE_SEPOLIA_RPC_ENDPOINT_URL || ""
58+
case "arbitrum-sepolia":
59+
return process.env.ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL || ""
60+
default:
61+
throw new Error(`Unsupported network: ${networkName}`)
62+
}
63+
}
64+
const rpcUrl = getRpcUrl(networkName)
65+
if (!rpcUrl) {
66+
throw new Error(`RPC URL is not configured for network: ${networkName}`)
67+
}
68+
console.log(`Using RPC URL: ${rpcUrl}`)
69+
const provider = new ethers.JsonRpcProvider(rpcUrl)
70+
5571
const signer = new ethers.Wallet(SIGNER_PRIVATE_KEY, provider)
5672

5773
const nft = NFT__factory.connect(NFT_ADDRESS, signer)

scripts/claim-manifesto.ts

+21-5
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,27 @@ async function main() {
4343
const GOV_ADDRESS = getDeployedAddress(networkName, "CrosschainGov")
4444
console.log("Using Gov contract address:", GOV_ADDRESS)
4545

46-
const provider = new ethers.JsonRpcProvider(
47-
networkName === "op-sepolia"
48-
? process.env.OP_SEPOLIA_RPC_ENDPOINT_URL
49-
: process.env.ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL
50-
)
46+
function getRpcUrl(networkName: string): string {
47+
switch (networkName) {
48+
case "sepolia":
49+
return process.env.SEPOLIA_RPC_ENDPOINT_URL || ""
50+
case "op-sepolia":
51+
return process.env.OP_SEPOLIA_RPC_ENDPOINT_URL || ""
52+
case "base-sepolia":
53+
return process.env.BASE_SEPOLIA_RPC_ENDPOINT_URL || ""
54+
case "arbitrum-sepolia":
55+
return process.env.ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL || ""
56+
default:
57+
throw new Error(`Unsupported network: ${networkName}`)
58+
}
59+
}
60+
const rpcUrl = getRpcUrl(networkName)
61+
if (!rpcUrl) {
62+
throw new Error(`RPC URL is not configured for network: ${networkName}`)
63+
}
64+
console.log(`Using RPC URL: ${rpcUrl}`)
65+
const provider = new ethers.JsonRpcProvider(rpcUrl)
66+
5167
const signer = new ethers.Wallet(SIGNER_PRIVATE_KEY, provider)
5268
const gov = Gov__factory.connect(GOV_ADDRESS, signer)
5369

scripts/claim-membership.ts

+21-6
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,27 @@ async function main() {
4646
const NFT_ADDRESS = getDeployedAddress(networkName, "CrosschainNFT")
4747
console.log("Using NFT contract address:", NFT_ADDRESS)
4848

49-
// Get RPC URL based on network
50-
let provider = new ethers.JsonRpcProvider(
51-
networkName === "op-sepolia"
52-
? process.env.OP_SEPOLIA_RPC_ENDPOINT_URL
53-
: process.env.ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL
54-
)
49+
function getRpcUrl(networkName: string): string {
50+
switch (networkName) {
51+
case "sepolia":
52+
return process.env.SEPOLIA_RPC_ENDPOINT_URL || ""
53+
case "op-sepolia":
54+
return process.env.OP_SEPOLIA_RPC_ENDPOINT_URL || ""
55+
case "base-sepolia":
56+
return process.env.BASE_SEPOLIA_RPC_ENDPOINT_URL || ""
57+
case "arbitrum-sepolia":
58+
return process.env.ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL || ""
59+
default:
60+
throw new Error(`Unsupported network: ${networkName}`)
61+
}
62+
}
63+
const rpcUrl = getRpcUrl(networkName)
64+
if (!rpcUrl) {
65+
throw new Error(`RPC URL is not configured for network: ${networkName}`)
66+
}
67+
console.log(`Using RPC URL: ${rpcUrl}`)
68+
const provider = new ethers.JsonRpcProvider(rpcUrl)
69+
5570
const signerZero = new ethers.Wallet(SIGNER_PRIVATE_KEY, provider)
5671

5772
console.log("Using address:", signerZero.address)

scripts/claim-metadata.ts

+21-5
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,27 @@ async function main() {
4343
const NFT_ADDRESS = getDeployedAddress(networkName, "CrosschainNFT")
4444
console.log("Using NFT contract address:", NFT_ADDRESS)
4545

46-
const provider = new ethers.JsonRpcProvider(
47-
networkName === "op-sepolia"
48-
? process.env.OP_SEPOLIA_RPC_ENDPOINT_URL
49-
: process.env.ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL
50-
)
46+
function getRpcUrl(networkName: string): string {
47+
switch (networkName) {
48+
case "sepolia":
49+
return process.env.SEPOLIA_RPC_ENDPOINT_URL || ""
50+
case "op-sepolia":
51+
return process.env.OP_SEPOLIA_RPC_ENDPOINT_URL || ""
52+
case "base-sepolia":
53+
return process.env.BASE_SEPOLIA_RPC_ENDPOINT_URL || ""
54+
case "arbitrum-sepolia":
55+
return process.env.ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL || ""
56+
default:
57+
throw new Error(`Unsupported network: ${networkName}`)
58+
}
59+
}
60+
const rpcUrl = getRpcUrl(networkName)
61+
if (!rpcUrl) {
62+
throw new Error(`RPC URL is not configured for network: ${networkName}`)
63+
}
64+
console.log(`Using RPC URL: ${rpcUrl}`)
65+
const provider = new ethers.JsonRpcProvider(rpcUrl)
66+
5167
const signerZero = new ethers.Wallet(SIGNER_PRIVATE_KEY, provider)
5268

5369
console.log("Using address:", signerZero.address)

scripts/claim-voting-delay.ts

+21-5
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,27 @@ async function main() {
4343
const GOV_ADDRESS = getDeployedAddress(networkName, "CrosschainGov")
4444
console.log("Using Gov contract address:", GOV_ADDRESS)
4545

46-
const provider = new ethers.JsonRpcProvider(
47-
networkName === "op-sepolia"
48-
? process.env.OP_SEPOLIA_RPC_ENDPOINT_URL
49-
: process.env.ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL
50-
)
46+
function getRpcUrl(networkName: string): string {
47+
switch (networkName) {
48+
case "sepolia":
49+
return process.env.SEPOLIA_RPC_ENDPOINT_URL || ""
50+
case "op-sepolia":
51+
return process.env.OP_SEPOLIA_RPC_ENDPOINT_URL || ""
52+
case "base-sepolia":
53+
return process.env.BASE_SEPOLIA_RPC_ENDPOINT_URL || ""
54+
case "arbitrum-sepolia":
55+
return process.env.ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL || ""
56+
default:
57+
throw new Error(`Unsupported network: ${networkName}`)
58+
}
59+
}
60+
const rpcUrl = getRpcUrl(networkName)
61+
if (!rpcUrl) {
62+
throw new Error(`RPC URL is not configured for network: ${networkName}`)
63+
}
64+
console.log(`Using RPC URL: ${rpcUrl}`)
65+
const provider = new ethers.JsonRpcProvider(rpcUrl)
66+
5167
const signer = new ethers.Wallet(SIGNER_PRIVATE_KEY, provider)
5268
const gov = Gov__factory.connect(GOV_ADDRESS, signer)
5369

scripts/deploy-and-test.sh

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Default salt
5+
SALT="Dec-25-v1"
6+
7+
# Parse arguments
8+
while [[ "$#" -gt 0 ]]; do
9+
case $1 in
10+
--salt) SALT="$2"; shift ;;
11+
*) echo "Unknown parameter passed: $1"; exit 1 ;;
12+
esac
13+
shift
14+
done
15+
16+
# Export salt as an environment variable
17+
export SALT
18+
19+
echo "Deploying with salt: $SALT"
20+
21+
# Deploy to OP Sepolia and Arbitrum Sepolia
22+
pnpm crosschain:op-sepolia
23+
pnpm crosschain:arbitrum-sepolia
24+
pnpm crosschain:base-sepolia
25+
26+
# Verify setup
27+
pnpm verify:setup
28+
29+
# Add a new member
30+
npx hardhat run scripts/propose.ts --network op-sepolia
31+
npx hardhat run scripts/verify-proof.ts --network op-sepolia
32+
npx hardhat run scripts/claim-membership.ts --network arbitrum-sepolia
33+
npx hardhat run scripts/claim-membership.ts --network base-sepolia
34+
35+
# Ban a member
36+
npx hardhat run scripts/propose-burn.ts --network op-sepolia
37+
npx hardhat run scripts/verify-burn-proof.ts --network op-sepolia
38+
npx hardhat run scripts/claim-burn.ts --network arbitrum-sepolia
39+
npx hardhat run scripts/claim-burn.ts --network base-sepolia
40+
41+
# Edit 1 membership NFT metadata
42+
npx hardhat run scripts/propose-metadata.ts --network op-sepolia
43+
npx hardhat run scripts/verify-metadata-proof.ts --network op-sepolia
44+
npx hardhat run scripts/claim-metadata.ts --network arbitrum-sepolia
45+
npx hardhat run scripts/claim-metadata.ts --network base-sepolia
46+
47+
# Edit the manifesto
48+
npx hardhat run scripts/propose-manifesto.ts --network op-sepolia
49+
npx hardhat run scripts/verify-manifesto-proof.ts --network op-sepolia
50+
npx hardhat run scripts/claim-manifesto.ts --network arbitrum-sepolia
51+
npx hardhat run scripts/claim-manifesto.ts --network base-sepolia
52+
53+
# Change 1 voting parameter
54+
npx hardhat run scripts/propose-voting-delay.ts --network op-sepolia
55+
npx hardhat run scripts/verify-voting-delay-proof.ts --network op-sepolia
56+
npx hardhat run scripts/claim-voting-delay.ts --network arbitrum-sepolia
57+
npx hardhat run scripts/claim-voting-delay.ts --network base-sepolia
58+
59+
# Change delegation
60+
npx hardhat run scripts/propose-delegation.ts --network op-sepolia
61+
npx hardhat run scripts/verify-delegation-proof.ts --network op-sepolia
62+
npx hardhat run scripts/claim-delegation.ts --network arbitrum-sepolia
63+
npx hardhat run scripts/claim-delegation.ts --network base-sepolia
64+
```

0 commit comments

Comments
 (0)