Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deploy-and-test.sh script #171

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 11 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 "<CUSTOM_SALT_HERE>"
```

## Core Dependencies
Expand Down
2 changes: 1 addition & 1 deletion dao.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///// Home chain /////

export const homeChain = 11155111
export const homeChain = 11155420

///// Membership NFT /////

Expand Down
6 changes: 5 additions & 1 deletion deploy/deploy-crosschain-gov.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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\"",
Expand Down
26 changes: 21 additions & 5 deletions scripts/claim-burn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 21 additions & 5 deletions scripts/claim-delegation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 21 additions & 5 deletions scripts/claim-manifesto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
27 changes: 21 additions & 6 deletions scripts/claim-membership.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 21 additions & 5 deletions scripts/claim-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 21 additions & 5 deletions scripts/claim-voting-delay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
64 changes: 64 additions & 0 deletions scripts/deploy-and-test.sh
Original file line number Diff line number Diff line change
@@ -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
```
Loading