-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
154 additions
and
85 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,93 +1,155 @@ | ||
# Function to print usage and exit | ||
source .env | ||
|
||
EXTRA_ARGS=() | ||
FROM= | ||
TARGET= | ||
CURRENT_NONCE= | ||
EXTRA_GAS_PRICE= | ||
CURRENT_GAS_PRICE= | ||
DEPLOYMENT_ROOT='deployments' | ||
|
||
# Function to display script usage | ||
usage() { | ||
echo "Usage: $0 -c <network>" | ||
echo " -c: Specify the network (ronin-testnet or ronin-mainnet)" | ||
echo "Usage: $0 -c <network> -m <mode> [-eg <extra_gas_price>] -f <from>" | ||
echo "Options:" | ||
echo " -c: Specify the network <ronin-mainnet|ronin-testnet>" | ||
echo " -m: Specify running mode <estimate|broadcast|trace>" | ||
echo " -f: Specify the sender address" | ||
echo " -eg: Extra gas price (default: 0)" | ||
exit 1 | ||
} | ||
|
||
# Function to load configuration based on network and mode | ||
loadConfig() { | ||
local network="$1" | ||
|
||
if [ "$network" == 'ronin-mainnet' ]; then | ||
RPC=https://api.roninchain.com/rpc | ||
EXPLORER=https://app.roninchain.com/tx | ||
FROM=0x968D0Cd7343f711216817E617d3f92a23dC91c07 | ||
|
||
RESOLVER=0xadb077d236d9E81fB24b96AE9cb8089aB9942d48 | ||
CONTROLLER=0x662852853614cbBb5D04BF2E29955b97E3C50B69 | ||
RNS_UNIFIED=0xf0c99c9677EDa0D13291C093b27E6512E4ACdF83 | ||
RNS_AUCTION=0xD55e6d80aeA1FF4650BC952C1653ab3CF1b940A9 | ||
RNS_DOMAIN_PRICE=0x2BdC555A87Db9207E5d175f0c12B237736181675 | ||
OWNED_MULTICALLER=0x8975923D01132bEB6c412F827f63D44712726E13 | ||
ERC721_BATCH_TRANSFER=0x2368dfed532842db89b470fde9fd584d48d4f644 | ||
if [ "$NETWORK" == 'ronin-mainnet' ]; then | ||
RPC=$MAINNET_URL | ||
EXPLORER=https://app.roninchain.com | ||
|
||
CURRENT_GAS_PRICE=$(cast gas-price --rpc-url $RPC) | ||
CURRENT_NONCE=$(cast nonce --rpc-url $RPC $FROM) | ||
ERC721_BATCH_TRANSFER=0x2368dfed532842db89b470fde9fd584d48d4f644 | ||
|
||
PK=$(op read "op://Private/Ronin Mainnet Deployer/private key") | ||
if [ "$MODE" == "broadcast" ]; then | ||
PK=$TESTNET_PK | ||
fi | ||
else | ||
RPC=https://saigon-archive.roninchain.com/rpc | ||
FROM=0x057B3862d021f8931c96f789f2A7c4d3eA3C665f | ||
EXPLORER=https://saigon-app.roninchain.com/tx | ||
|
||
RESOLVER=0x803c459dCB8771e5354D1fC567Ecc6885A9fd5E6 | ||
CONTROLLER=0x512699B52ac2dC2b2aD505d9f29DcDad078FA799 | ||
RNS_UNIFIED=0x67C409DaB0EE741A1B1Be874bd1333234cfDBF44 | ||
RNS_AUCTION=0xb962eddeD164f55D136E491a3022246815e1B5A8 | ||
RNS_DOMAIN_PRICE=0x51cAF51678f469e9DD4c878a7b0ceBEbbd4A4AB5 | ||
OWNED_MULTICALLER=0x8975923D01132bEB6c412F827f63D44712726E13 | ||
RPC=$TESTNET_URL | ||
EXPLORER=https://saigon-app.roninchain.com | ||
|
||
ERC721_BATCH_TRANSFER=0x2e889348bd37f192063bfec8ff39bd3635949e20 | ||
|
||
CURRENT_GAS_PRICE=$(cast gas-price --rpc-url $RPC) | ||
if [ "$MODE" == "broadcast" ]; then | ||
PK=$MAINNET_PK | ||
fi | ||
fi | ||
|
||
if [ "$MODE" == "broadcast" ]; then | ||
CURRENT_NONCE=$(cast nonce --rpc-url $RPC $FROM) | ||
CURRENT_GAS_PRICE=$(cast gas-price --rpc-url $RPC) | ||
|
||
PK=$(op read "op://SC Vault/Testnet Admin/private key") | ||
if [[ "$PK" == op://* ]]; then | ||
PK=$(op read "$PK") | ||
fi | ||
fi | ||
} | ||
|
||
estimate() { | ||
# Function to load address from deployment file | ||
loadAddress() { | ||
local contract="$1" | ||
echo $(jq -r '.address' ${DEPLOYMENT_ROOT}/${NETWORK}/${contract}.json) | ||
} | ||
|
||
# Function to execute based on the specified mode | ||
execute() { | ||
local nonce="$1" | ||
local target="$2" | ||
local args="$3" | ||
|
||
if [ "$MODE" == "broadcast" ]; then | ||
broadcast "$nonce" "$target" "$args" | ||
elif [ "$MODE" == "estimate" ]; then | ||
estimate "$target" "$args" | ||
elif [ "$MODE" == "trace" ]; then | ||
trace "$target" "$args" | ||
else | ||
echo "Error: Invalid mode option. Choose either 'broadcast', 'estimate', or 'trace'." | ||
fi | ||
} | ||
|
||
# Function to perform a trace | ||
trace() { | ||
local target="$1" | ||
local args="$2" | ||
cast c $EXTRA_ARGS --from $FROM --trace --rpc-url $RPC $target $args | ||
} | ||
|
||
gas=$(cast e --from $FROM --rpc-url $RPC $target $args) | ||
# Function to estimate gas | ||
estimate() { | ||
local target="$1" | ||
local args="$2" | ||
gas=$(cast e $EXTRA_ARGS --from $FROM --rpc-url $RPC $target $args) | ||
echo estimated gas: $gas | ||
} | ||
|
||
# Function to broadcast a transaction | ||
broadcast() { | ||
local gasPrice="$1" | ||
local nonce="$2" | ||
local target="$3" | ||
local args="$4" | ||
local nonce="$1" | ||
local target="$2" | ||
local args="$3" | ||
|
||
txHash=$(cast s --from $FROM --legacy --gas-price $gasPrice --async --confirmations 0 --nonce $nonce --private-key $PK --rpc-url $RPC $target $args) | ||
txHash=$(cast s $EXTRA_ARGS --from $FROM --legacy --gas-price $((CURRENT_GAS_PRICE + EXTRA_GAS_PRICE)) --async --confirmations 0 --nonce $nonce --private-key $PK --rpc-url $RPC $target $args) | ||
|
||
echo $EXPLORER/$txHash | ||
echo $EXPLORER/tx/$txHash | ||
} | ||
|
||
# Parse command-line options | ||
# Check if command-line arguments are provided | ||
if [ "$#" -eq 0 ]; then | ||
usage | ||
fi | ||
|
||
# Parse command-line options | ||
while getopts "c:" opt; do | ||
case $opt in | ||
c) | ||
case "$OPTARG" in | ||
ronin-testnet) | ||
loadConfig "ronin-testnet" | ||
;; | ||
ronin-mainnet) | ||
loadConfig "ronin-mainnet" | ||
;; | ||
*) | ||
echo "Unknown network specified: $OPTARG" | ||
usage | ||
;; | ||
esac | ||
# Parse command line arguments | ||
while [[ $# -gt 0 ]]; do | ||
case $1 in | ||
--from | -f) | ||
shift | ||
FROM="$1" | ||
;; | ||
--chain | -c) | ||
shift | ||
NETWORK="$1" | ||
;; | ||
--mode | -m) | ||
shift | ||
MODE="$1" | ||
;; | ||
--extra-gas | -eg) | ||
shift | ||
EXTRA_GAS_PRICE="$1" | ||
;; | ||
*) | ||
usage | ||
# Check if the next argument is present | ||
if [ -n "$2" ]; then | ||
# Add both the flag and its value to EXTRA_ARGS | ||
EXTRA_ARGS+=("$1 $2") | ||
shift | ||
else | ||
# Add only the flag to EXTRA_ARGS | ||
EXTRA_ARGS+=("$1") | ||
fi | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
# Check if all required arguments are provided | ||
if [ -z "$NETWORK" ] || [ -z "$MODE" ] || [ -z "$FROM" ]; then | ||
echo "Error: Missing required arguments!" | ||
usage | ||
fi | ||
|
||
# Validate network and mode options | ||
if [ "$NETWORK" != "ronin-testnet" ] && [ "$NETWORK" != "ronin-mainnet" ]; then | ||
echo "Error: Invalid network option. Choose either 'ronin-testnet' or 'ronin-mainnet'." | ||
usage | ||
fi | ||
|
||
# Load configuration based on network and mode | ||
loadConfig |
This file contains 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 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 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 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 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 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 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 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 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 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