-
Notifications
You must be signed in to change notification settings - Fork 0
Deployment Automation and Documentation Improvements #15
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Path to your keystore file (JSON) | ||
| KEYSTORE=/absolute/path/to/keystore.json | ||
|
|
||
| # Password for your keystore | ||
| PASSWORD=your_keystore_password | ||
|
|
||
| # Optionally override the RPC URL (defaults set by network in deploy script) | ||
| # RPC_URL=https://api.calibration.node.glif.io/rpc/v1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| .PHONY: build deploy-mupay deploy-multisig deploy-all clean chmod-deploy | ||
|
|
||
| chmod-deploy: | ||
| chmod +x ./tools/deploy.sh | ||
|
|
||
| build: | ||
| @echo "Building contracts..." | ||
| forge build | ||
| forge test | ||
|
|
||
| deploy-mupay: chmod-deploy | ||
| @echo "Deploying MuPay contract..." | ||
| ./tools/deploy.sh mupay 314159 | ||
|
|
||
| deploy-multisig: chmod-deploy | ||
| @echo "Deploying Multisig contract..." | ||
| ./tools/deploy.sh multisig 314159 | ||
|
|
||
| deploy-all: deploy-mupay deploy-multisig | ||
|
|
||
| clean: | ||
| forge clean |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| #!/bin/bash | ||
| # deploy.sh - Deploys MuPay or Multisig contracts to a specified network | ||
| # Usage: ./tools/deploy.sh <contract> <chain_id> | ||
| # <contract>: mupay | multisig | both (default: both) | ||
| # <chain_id>: 314159 (calibnet), 314 (mainnet), etc. (default: 314159) | ||
| # | ||
| # Example: | ||
| # ./tools/deploy.sh mupay 314159 | ||
| # ./tools/deploy.sh multisig 314159 | ||
| # ./tools/deploy.sh both 314159 | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| CONTRACT="${1}" | ||
| CHAIN_ID="${2:-314159}" # Default to calibnet | ||
|
|
||
| if [ $# -lt 1 ]; then | ||
| echo "Usage: $0 <mupay|multisig> [chain_id]" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Load environment variables from .env if present | ||
| if [ -f ".env" ]; then | ||
| export $(grep -v '^#' .env | xargs) | ||
| fi | ||
|
|
||
| # Set default RPC_URL if not set | ||
| if [ -z "${RPC_URL:-}" ]; then | ||
| if [ "$CHAIN_ID" = "314159" ]; then | ||
| export RPC_URL="https://api.calibration.node.glif.io/rpc/v1" | ||
| elif [ "$CHAIN_ID" = "314" ]; then | ||
| export RPC_URL="https://api.node.glif.io/rpc/v1" | ||
| else | ||
| echo "Error: RPC_URL must be set for CHAIN_ID $CHAIN_ID" | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| if [ -z "${KEYSTORE:-}" ]; then | ||
| echo "Error: KEYSTORE is not set" | ||
| exit 1 | ||
| fi | ||
| if [ -z "${PASSWORD:-}" ]; then | ||
| echo "Error: PASSWORD is not set" | ||
| exit 1 | ||
| fi | ||
|
|
||
| ADDR=$(cast wallet address --keystore "$KEYSTORE" --password "$PASSWORD") | ||
| echo "Deploying from address $ADDR to chain $CHAIN_ID" | ||
| NONCE="$(cast nonce --rpc-url "$RPC_URL" "$ADDR")" | ||
|
|
||
| deploy_contract() { | ||
| local contract_path="$1" | ||
| local contract_name="$2" | ||
|
|
||
| echo "Deploying $contract_name ($contract_path)" | ||
| DEPLOYED_ADDRESS=$( | ||
| forge create --rpc-url "$RPC_URL" \ | ||
| --keystore "$KEYSTORE" \ | ||
| --password "$PASSWORD" \ | ||
| --broadcast \ | ||
| --nonce $NONCE \ | ||
| --chain-id $CHAIN_ID \ | ||
| "$contract_path" \ | ||
| | grep "Deployed to" | awk '{print $3}' | ||
| ) | ||
|
|
||
| if [ -z "$DEPLOYED_ADDRESS" ]; then | ||
| echo "Error: Failed to extract $contract_name contract address" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "$contract_name deployed at: $DEPLOYED_ADDRESS" | ||
| NONCE=$((NONCE + 1)) # Increment nonce for next contract, if any | ||
| } | ||
|
|
||
| case "$CONTRACT" in | ||
| mupay) | ||
| deploy_contract "src/MuPay.sol:MuPay" "MuPay" | ||
| ;; | ||
| multisig) | ||
| deploy_contract "src/Multisig_2of2.sol:Multisig" "Multisig" | ||
| ;; | ||
| *) | ||
| echo "Invalid contract option: $CONTRACT" | ||
| echo "Usage: $0 <mupay|multisig|both> [chain_id]" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| echo "Deployment complete." | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.