Skip to content

Commit ef3402e

Browse files
committed
chore: mode deployment
1 parent ad9cd27 commit ef3402e

3 files changed

Lines changed: 276 additions & 0 deletions

File tree

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#!/bin/bash
2+
3+
# Check if $1 is provided
4+
if [ -z "$1" ]; then
5+
echo "Usage: $0 <network>"
6+
echo "Example: $0 eth_mainnet"
7+
exit 1
8+
fi
9+
10+
# check if the ETHERSCAN_API_KEY is set
11+
if [ -z "$ETHERSCAN_API_KEY" ]; then
12+
echo "Please set the ETHERSCAN_API_KEY environment variable."
13+
exit 1
14+
fi
15+
16+
red=$(tput setaf 1)
17+
green=$(tput setaf 2)
18+
reset=$(tput sgr0)
19+
20+
# Get globals file
21+
globals="$(dirname "$0")/globals_$1.json"
22+
if [ ! -f $globals ]; then
23+
echo "${red}!!! $globals is not found${reset}"
24+
exit 0
25+
fi
26+
27+
# Read variables using jq
28+
contractVerification=$(jq -r '.contractVerification' $globals)
29+
useLedger=$(jq -r '.useLedger' $globals)
30+
derivationPath=$(jq -r '.derivationPath' $globals)
31+
chainId=$(jq -r '.chainId' $globals)
32+
networkURL=$(jq -r '.networkURL' $globals)
33+
34+
olasAddress=$(jq -r '.olasAddress' $globals)
35+
depositoryProxyAddress=$(jq -r '.depositoryProxyAddress' $globals)
36+
modeL1StandardBridgeProxyAddress=$(jq -r '.modeL1StandardBridgeProxyAddress' $globals)
37+
modeL1CrossDomainMessengerProxyAddress=$(jq -r '.modeL1CrossDomainMessengerProxyAddress' $globals)
38+
modeOLASAddress=$(jq -r '.modeOLASAddress' $globals)
39+
40+
# Getting L1 API key
41+
if [ $chainId == 1 ]; then
42+
API_KEY=$ALCHEMY_API_KEY_MAINNET
43+
if [ "$API_KEY" == "" ]; then
44+
echo "set ALCHEMY_API_KEY_MAINNET env variable"
45+
exit 0
46+
fi
47+
elif [ $chainId == 11155111 ]; then
48+
API_KEY=$ALCHEMY_API_KEY_SEPOLIA
49+
if [ "$API_KEY" == "" ]; then
50+
echo "set ALCHEMY_API_KEY_SEPOLIA env variable"
51+
exit 0
52+
fi
53+
fi
54+
55+
contractName="BaseDepositProcessorL1"
56+
contractPath="contracts/l1/bridging/$contractName.sol:$contractName"
57+
constructorArgs="$olasAddress $depositoryProxyAddress $modeL1StandardBridgeProxyAddress $modeL1CrossDomainMessengerProxyAddress $modeOLASAddress"
58+
contractArgs="$contractPath --constructor-args $constructorArgs"
59+
60+
# Get deployer based on the ledger flag
61+
if [ "$useLedger" == "true" ]; then
62+
walletArgs="-l --mnemonic-derivation-path $derivationPath"
63+
deployer=$(cast wallet address $walletArgs)
64+
else
65+
echo "Using PRIVATE_KEY: ${PRIVATE_KEY:0:6}..."
66+
walletArgs="--private-key $PRIVATE_KEY"
67+
deployer=$(cast wallet address $walletArgs)
68+
fi
69+
70+
# Deployment message
71+
echo "${green}Deploying from: $deployer${reset}"
72+
echo "RPC: $networkURL"
73+
echo "${green}Deployment of: $contractArgs${reset}"
74+
75+
# Deploy the contract and capture the address
76+
execCmd="forge create --broadcast --rpc-url $networkURL$API_KEY $walletArgs $contractArgs"
77+
deploymentOutput=$($execCmd)
78+
modeDepositProcessorL1Address=$(echo "$deploymentOutput" | grep 'Deployed to:' | awk '{print $3}')
79+
80+
# Get output length
81+
outputLength=${#modeDepositProcessorL1Address}
82+
83+
# Check for the deployed address
84+
if [ $outputLength != 42 ]; then
85+
echo "${red}!!! The contract was not deployed...${reset}"
86+
exit 0
87+
fi
88+
89+
90+
# Write new deployed contract back into deployment file
91+
echo "$(jq '. += {"modeDepositProcessorL1Address":"'$modeDepositProcessorL1Address'"}' $globals)" > $globals
92+
93+
# Verify contract
94+
if [ "$contractVerification" == "true" ]; then
95+
contractParams="$modeDepositProcessorL1Address $contractPath --constructor-args $(cast abi-encode "constructor(address,address,address,address,address)" $constructorArgs)"
96+
echo "Verification contract params: $contractParams"
97+
98+
echo "${green}Verifying contract on Etherscan...${reset}"
99+
forge verify-contract --chain-id "$chainId" --etherscan-api-key "$ETHERSCAN_API_KEY" $contractParams
100+
101+
blockscoutURL=$(jq -r '.blockscoutURL' $globals)
102+
if [ "$blockscoutURL" != "null" ]; then
103+
echo "${green}Verifying contract on Blockscout...${reset}"
104+
forge verify-contract --verifier blockscout --verifier-url "$blockscoutURL/api" $contractParams
105+
fi
106+
fi
107+
108+
echo "${green}$contractName deployed at: $modeDepositProcessorL1Address${reset}"
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#!/bin/bash
2+
3+
# Check if $1 is provided
4+
if [ -z "$1" ]; then
5+
echo "Usage: $0 <network>"
6+
echo "Example: $0 base_mainnet"
7+
exit 1
8+
fi
9+
10+
# check if the ETHERSCAN_API_KEY is set
11+
if [ -z "$ETHERSCAN_API_KEY" ]; then
12+
echo "Please set the ETHERSCAN_API_KEY environment variable."
13+
exit 1
14+
fi
15+
16+
red=$(tput setaf 1)
17+
green=$(tput setaf 2)
18+
reset=$(tput sgr0)
19+
20+
# Get globals file
21+
globals="$(dirname "$0")/globals_$1.json"
22+
if [ ! -f $globals ]; then
23+
echo "${red}!!! $globals is not found${reset}"
24+
exit 0
25+
fi
26+
27+
# Read variables using jq
28+
contractVerification=$(jq -r '.contractVerification' $globals)
29+
useLedger=$(jq -r '.useLedger' $globals)
30+
derivationPath=$(jq -r '.derivationPath' $globals)
31+
chainId=$(jq -r '.chainId' $globals)
32+
networkURL=$(jq -r '.networkURL' $globals)
33+
34+
olasAddress=$(jq -r '.olasAddress' $globals)
35+
stakingManagerProxyAddress=$(jq -r '.stakingManagerProxyAddress' $globals)
36+
externalStakingDistributorProxyAddress=$(jq -r '.externalStakingDistributorProxyAddress' $globals)
37+
collectorProxyAddress=$(jq -r '.collectorProxyAddress' $globals)
38+
modeL2StandardBridgeProxyAddress=$(jq -r '.modeL2StandardBridgeProxyAddress' $globals)
39+
modeL2CrossDomainMessengerProxyAddress=$(jq -r '.modeL2CrossDomainMessengerProxyAddress' $globals)
40+
modeDepositProcessorL1Address=$(jq -r '.modeDepositProcessorL1Address' $globals)
41+
l1ChainId=$(jq -r '.l1ChainId' $globals)
42+
43+
44+
# Check for Polygon keys only since on other networks those are not needed
45+
if [ $chainId == 137 ]; then
46+
API_KEY=$ALCHEMY_API_KEY_MATIC
47+
if [ "$API_KEY" == "" ]; then
48+
echo "set ALCHEMY_API_KEY_MATIC env variable"
49+
exit 0
50+
fi
51+
elif [ $chainId == 80002 ]; then
52+
API_KEY=$ALCHEMY_API_KEY_AMOY
53+
if [ "$API_KEY" == "" ]; then
54+
echo "set ALCHEMY_API_KEY_AMOY env variable"
55+
exit 0
56+
fi
57+
fi
58+
59+
contractName="BaseStakingProcessorL2"
60+
contractPath="contracts/l2/bridging/$contractName.sol:$contractName"
61+
constructorArgs="$olasAddress $stakingManagerProxyAddress $externalStakingDistributorProxyAddress $collectorProxyAddress $modeL2StandardBridgeProxyAddress $modeL2CrossDomainMessengerProxyAddress $modeDepositProcessorL1Address $l1ChainId"
62+
contractArgs="$contractPath --constructor-args $constructorArgs"
63+
64+
# Get deployer based on the ledger flag
65+
if [ "$useLedger" == "true" ]; then
66+
walletArgs="-l --mnemonic-derivation-path $derivationPath"
67+
deployer=$(cast wallet address $walletArgs)
68+
else
69+
echo "Using PRIVATE_KEY: ${PRIVATE_KEY:0:6}..."
70+
walletArgs="--private-key $PRIVATE_KEY"
71+
deployer=$(cast wallet address $walletArgs)
72+
fi
73+
74+
# Deployment message
75+
echo "${green}Deploying from: $deployer${reset}"
76+
echo "RPC: $networkURL"
77+
echo "${green}Deployment of: $contractArgs${reset}"
78+
79+
# Deploy the contract and capture the address
80+
execCmd="forge create --broadcast --rpc-url $networkURL$API_KEY $walletArgs $contractArgs"
81+
deploymentOutput=$($execCmd)
82+
modeStakingProcessorL2Address=$(echo "$deploymentOutput" | grep 'Deployed to:' | awk '{print $3}')
83+
84+
# Get output length
85+
outputLength=${#modeStakingProcessorL2Address}
86+
87+
# Check for the deployed address
88+
if [ $outputLength != 42 ]; then
89+
echo "${red}!!! The contract was not deployed...${reset}"
90+
exit 0
91+
fi
92+
93+
94+
# Write new deployed contract back into deployment file
95+
echo "$(jq '. += {"modeStakingProcessorL2Address":"'$modeStakingProcessorL2Address'"}' $globals)" > $globals
96+
97+
# Verify contract
98+
if [ "$contractVerification" == "true" ]; then
99+
contractParams="$modeStakingProcessorL2Address $contractPath --constructor-args $(cast abi-encode "constructor(address,address,address,address,address,address,address,uint256)" $constructorArgs)"
100+
echo "Verification contract params: $contractParams"
101+
102+
echo "${green}Verifying contract on Etherscan...${reset}"
103+
forge verify-contract --chain-id "$chainId" --etherscan-api-key "$ETHERSCAN_API_KEY" $contractParams
104+
105+
blockscoutURL=$(jq -r '.blockscoutURL' $globals)
106+
if [ "$blockscoutURL" != "null" ]; then
107+
echo "${green}Verifying contract on Blockscout...${reset}"
108+
forge verify-contract --verifier blockscout --verifier-url "$blockscoutURL/api" $contractParams
109+
fi
110+
fi
111+
112+
echo "${green}$contractName deployed at: $modeStakingProcessorL2Address${reset}"
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"contractVerification": true,
3+
"useLedger": true,
4+
"derivationPath": "m/44'/60'/2'/0/0",
5+
"providerName": "mode",
6+
"chainId": "34443",
7+
"networkURL": "https://mainnet.mode.network",
8+
"blockscoutURL": "https://explorer.mode.network",
9+
"gnosisSafeAddress": "0xd9Db270c1B5E3Bd161E8c8503c55cEABeE709552",
10+
"gnosisSafeL2Address": "0x3E5c63644E683549055b9Be8653de26E0B4CD36E",
11+
"gnosisSafeProxyFactoryAddress": "0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2",
12+
"multiSendCallOnlyAddress": "0x40A2aCCbd92BCA938b02010E17A5b8929b49130D",
13+
"fallbackHandlerAddress": "0xf48f2B2d2a534e402487b3ee7C18c33Aec0Fe5e4",
14+
"safeToL2SetupAddress": "0xBD89A1CE4DDe368FFAB0eC35506eEcE0b1fFdc54",
15+
"baseURI": "https://gateway.autonolas.tech/ipfs/",
16+
"serviceRegistryName": "Service Registry L2",
17+
"serviceRegistrySymbol": "AUTONOLAS-SERVICE-L2-V1",
18+
"olasAddress": "0xcfD1D50ce23C46D3Cf6407487B2F8934e96DC8f9",
19+
"modeL2StandardBridgeProxyAddress": "0x4200000000000000000000000000000000000010",
20+
"modeL2CrossDomainMessengerProxyAddress": "0x4200000000000000000000000000000000000007",
21+
"multisigProxyHash130": "0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000",
22+
"stakingImplementationBytecodeHash": "0xfaa25679442cc1708855bb2e9a6cf2464aa44435009791cb122ce941c25672c7",
23+
"agentId": "85",
24+
"configHash": "0xca0a2dda805c401808b21b8fdf86eb8b1b4117931cb6dbf8226c38dfd0214068",
25+
"l1ChainId": "1",
26+
"livenessRatio": "1",
27+
"distributorProxyAddress": "0x64003846B67D66AfdFb03325fa4292b76FCF182F",
28+
"unstakeRelayerProxyAddress": "0xaC7eA9478E0e1186E7D1c82b8d8dc80AEe0F79F6",
29+
"treasuryProxyAddress": "0xcfA10d192c3999b5CA59aD3c7512c40f1B919e01",
30+
"serviceRegistryAddress": "0x3C1fF68f5aa342D296d4DEe4Bb1cACCA912D95fE",
31+
"operatorWhitelistAddress": "0x3d77596beb0f130a4415df3D2D8232B3d3D31e44",
32+
"serviceRegistryTokenUtilityAddress": "0x34C895f302D0b5cf52ec0Edd3945321EB0f83dd5",
33+
"serviceManagerAddress": "0x984cf72FDe8B5aA910e9e508aC5e007ae5BDcC9C",
34+
"serviceManagerProxyAddress": "0xcDdD9D9ABaB36fFa882530D69c73FeE5D4001C2d",
35+
"gnosisSafeMultisigImplementationAddress": "0xBb7e1D6Cb6F243D6bdE81CE92a9f2aFF7Fbe7eac",
36+
"gnosisSafeSameAddressMultisigImplementationAddress": "0xFbBEc0C8b13B38a9aC0499694A69a10204c5E2aB",
37+
"safeMultisigWithRecoveryModuleAddress": "0x7Fd1F4b764fA41d19fe3f63C85d12bf64d2bbf68",
38+
"recoveryModuleAddress": "0x1d79e0a600B61FAC1B8F40c27347e48962Ed2f23",
39+
"stakingVerifierAddress": "0x87c511c8aE3fAF0063b3F3CF9C6ab96c4AA5C60c",
40+
"stakingFactoryAddress": "0x75D529FAe220bC8db714F0202193726b46881B76",
41+
"stakingHelperAddress": "",
42+
"stakingTokenLockedAddress": "",
43+
"moduleActivityCheckerAddress": "0x4A26F79b9dd73a48d57ce4DF70295A875afa006c",
44+
"collectorAddress": "0xA8e739a8A5D56b9ccF612020204B9C90A1b55099",
45+
"collectorProxyAddress": "0x60b9dA6E2431E16262d5193035B0a2887ce3c8fA",
46+
"activityModuleAddress": "0xab4C5BB0797Ca25e93a4af2E8FECD7Fcac0F2c9b",
47+
"beaconAddress": "0x62a7033dCB94486F3dA962BfC10631C9f5eF311e",
48+
"stakingManagerAddress": "0x535e274Ef8447B112c3d12CFA33D73b6fd693AaA",
49+
"stakingManagerProxyAddress": "0xC6d6b164d81AeE4fCe59D7c74a4e857ac29bc398",
50+
"externalStakingDistributorAddress": "0x64003846B67D66AfdFb03325fa4292b76FCF182F",
51+
"externalStakingDistributorProxyAddress": "0x14c85A5A21a26542B672eD53e80e3EEf4cE9394D",
52+
"multisigGuardAddress": "0xEfF4A1D9faF5c750d5E32754c40Cf163767C63A4",
53+
"multisigGuardProxyAddress": "0x327F1da21255d1d02cF2e7155659F8FBf12dB4ee",
54+
"modeDepositProcessorL1Address": "0xB6e7f6633B3b6F319284C66131731c8A090e98F2",
55+
"modeStakingProcessorL2Address": "0x40abf47B926181148000DbCC7c8DE76A3a61a66f"
56+
}

0 commit comments

Comments
 (0)