Skip to content

Commit

Permalink
chore: update deploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
Doge-is-Dope committed Nov 16, 2024
1 parent 70597df commit 6458309
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 63 deletions.
74 changes: 74 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash

# Predefined configurations
CONFIGS=(
"base-sepolia|https://base-sepolia.blockscout.com"
"mantle-sepolia|https://explorer.sepolia.mantle.xyz"
)

# Function to display usage
usage() {
echo "Usage: $0 [file-name] [option-number]"
echo "Arguments:"
echo " file-name: (Optional) Name of the script file (default: Deploy)"
echo " option-number: (Optional) Select a configuration from the list below (default: 0):"
echo " 0: Deploy to all chains"
for i in "${!CONFIGS[@]}"; do
RPC_URL=$(echo "${CONFIGS[$i]}" | cut -d'|' -f1)
VERIFIER_URL=$(echo "${CONFIGS[$i]}" | cut -d'|' -f2)
echo " $((i + 1)): RPC_URL=$RPC_URL, VERIFIER_URL=$VERIFIER_URL"
done
exit 1
}

# Set default values
FILE_NAME=${1:-Deploy}
OPTION=${2:-0}


deploy_to_chain() {
local rpc_url=$1
local verifier_url=$2
echo "Deploying to:"
echo " RPC URL: $rpc_url"
echo " Verifier URL: $verifier_url"

rm -rf cache

# Execute the deployment command
forge script script/${FILE_NAME}.s.sol:${FILE_NAME} \
--broadcast \
--rpc-url "$rpc_url" \
--verify \
--verifier blockscout \
--verifier-url "$verifier_url/api/"
}

# Validate the option number
if ! [[ "$OPTION" =~ ^[0-9]+$ ]] || [ "$OPTION" -lt 0 ] || [ "$OPTION" -gt "${#CONFIGS[@]}" ]; then
echo "Error: Invalid option number."
usage
fi

# Deploy to all chains if option is 0
if [ "$OPTION" -eq 0 ]; then
for CONFIG in "${CONFIGS[@]}"; do
RPC_URL=$(echo "$CONFIG" | cut -d'|' -f1)
VERIFIER_URL=$(echo "$CONFIG" | cut -d'|' -f2)
deploy_to_chain "$RPC_URL" "$VERIFIER_URL"
done
else
# Deploy to the selected chain
SELECTED_CONFIG="${CONFIGS[$((OPTION - 1))]}"
RPC_URL=$(echo "$SELECTED_CONFIG" | cut -d'|' -f1)
VERIFIER_URL=$(echo "$SELECTED_CONFIG" | cut -d'|' -f2)
deploy_to_chain "$RPC_URL" "$VERIFIER_URL"
fi



# Usage
# All: ./deploy.sh <file-name> 0
# Base Sepolia: ./deploy.sh <file-name> 1
# Mantle Sepolia: ./deploy.sh <file-name> 2

55 changes: 0 additions & 55 deletions deployMock.sh

This file was deleted.

5 changes: 1 addition & 4 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,4 @@ libs = ["lib"]
[rpc_endpoints]
sepolia = "${RPC_SEPOLIA}"
base-sepolia = "${RPC_BASE_SEPOLIA}"
world-sepolia = "${RPC_WORLD_SEPOLIA}"
mantle-sepolia = "${RPC_MANTLE_SEPOLIA}"
polygonzkevm-cardona = "${RPC_POLYGONZKEVM_CARDONA}"
hedera-testnet = "${RPC_HEDERA_TESTNET}"
mantle-sepolia = "${RPC_MANTLE_SEPOLIA}"
5 changes: 2 additions & 3 deletions script/BaseDeploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity ^0.8.28;

import "../lib/forge-std/src/Script.sol";
import {console} from "forge-std/console.sol";

contract BaseDeploy is Script {
uint256 internal immutable deployerPrivateKey = vm.envUint("PRIVATE_KEY");
Expand All @@ -14,7 +13,7 @@ contract BaseDeploy is Script {
vm.stopBroadcast();
}

function calculateSalt(string memory input) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(input)) & ~bytes32(uint256(0xfff));
function _calculateSalt(string memory input) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(input)) & ~bytes32(uint256(0xffff));
}
}
2 changes: 1 addition & 1 deletion script/DeployMock.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {BaseDeploy} from "./BaseDeploy.s.sol";
contract DeployMock is BaseDeploy {
function run() public {
// Calculate salt
bytes32 salt = calculateSalt("Drip.Erc20Mock");
bytes32 salt = _calculateSalt("Drip.Erc20Mock");
// Deploy contracts on all supported chains
address deployed = _deployContract(salt);
console.log("ERC20Mock deployed to", deployed);
Expand Down

0 comments on commit 6458309

Please sign in to comment.