Skip to content

Commit

Permalink
feat: update deployment script
Browse files Browse the repository at this point in the history
  • Loading branch information
TuDo1403 committed Oct 17, 2023
1 parent e0d7c31 commit 0616777
Show file tree
Hide file tree
Showing 6 changed files with 6,538 additions and 387 deletions.
33 changes: 33 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import "hardhat-deploy";
import {
HardhatUserConfig,
NetworkUserConfig,
} from "hardhat/types";
import * as dotenv from 'dotenv';

dotenv.config();

const { TESTNET_URL, MAINNET_URL } = process.env;

const testnet: NetworkUserConfig = {
chainId: 2021,
url: TESTNET_URL || "https://saigon-testnet.roninchain.com/rpc",
};

const mainnet: NetworkUserConfig = {
chainId: 2020,
url: MAINNET_URL || "https://api.roninchain.com/rpc",
};

const config: HardhatUserConfig = {
paths: {
sources: "./src",
},

networks: {
"ronin-testnet": testnet,
"ronin-mainnet": mainnet,
},
};

export default config;
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@
"src/**/*.sol"
],
"devDependencies": {
"dotenv": "^16.3.1",
"hardhat": "^2.12.7",
"hardhat-deploy": "0.11.29",
"husky": "^8.0.3",
"lint-staged": "^14.0.1"
"lint-staged": "^14.0.1",
"ts-node": "^10.4.0",
"typescript": "^4.5.4"
},
"lint-staged": {
"{src,script,test}/**/*.sol": [
Expand All @@ -20,4 +25,4 @@
"scripts": {
"prepare": "husky install"
}
}
}
28 changes: 27 additions & 1 deletion run.sh
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
op run --env-file="./.env" -- forge script --legacy --sig "run(string)" "$@"
verify_arg=""
extra_argument=""
op_command=""

for arg in "$@"; do
case $arg in
--trezor)
op_command=""
extra_argument+=trezor@
;;
--broadcast)
op_command="op run --env-file="./.env" --"
# verify_arg="--verify --verifier sourcify --verifier-url https://sourcify.roninchain.com/server/"
;;
--log)
set -- "${@/#--log/}"
extra_argument+=log@
;;
*) ;;
esac
done

# Remove the @ character from the end of extra_argument
extra_argument="${extra_argument%%@}"

calldata=$(cast calldata 'run()')
${op_command} forge script ${verify_arg} --legacy ${@} --sig 'run(bytes,string)' ${calldata} "${extra_argument}"
64 changes: 36 additions & 28 deletions verify.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Default network value
network="2021"
networkName="ronin-testnet"
endpoint=https://sourcify.roninchain.com/server

# Function to print usage and exit
usage() {
Expand All @@ -16,10 +18,12 @@ while getopts "c:" opt; do
ronin-testnet)
child_folder="ronin-testnet"
network="2021"
networkName="ronin-testnet"
;;
ronin-mainnet)
child_folder="ronin-mainnet"
network="2020"
networkName="ronin-mainnet"
;;
*)
echo "Unknown network specified: $OPTARG"
Expand All @@ -33,35 +37,39 @@ while getopts "c:" opt; do
esac
done

# Shift the processed options out of the argument list
shift $((OPTIND - 1))
yarn hardhat sourcify --endpoint ${endpoint} --network ${networkName}

# Define the deployments folder by concatenating it with the child folder
folder="deployments/$child_folder"
# ToDo(TuDo): make foundry verification perfectly match using sourcify
# # Shift the processed options out of the argument list
# shift $((OPTIND - 1))

# Check if the specified folder exists
if [ ! -d "$folder" ]; then
echo "Error: The specified folder does not exist for the selected network."
exit 1
fi
# # Define the deployments folder by concatenating it with the child folder
# folder="deployments/$child_folder"

# Loop through JSON files in the selected folder
for file in "$folder"/*.json; do
# Check if the file exists and is a regular file
if [ -f "$file" ]; then
# Exclude the .chainId file
if [ "$(basename "$file")" != ".chainId" ]; then
# Extract contractName and address from the JSON file
contractName=$(jq -r '.contractName' "$file")
address=$(jq -r '.address' "$file")
# # Check if the specified folder exists
# if [ ! -d "$folder" ]; then
# echo "Error: The specified folder does not exist for the selected network."
# exit 1
# fi
# # Loop through JSON files in the selected folder
# for file in "$folder"/*.json; do
# # Check if the file exists and is a regular file
# if [ -f "$file" ]; then
# # Exclude the .chainId file
# if [ "$(basename "$file")" != ".chainId" ]; then
# # Extract contractName and address from the JSON file
# contractName=$(jq -r '.contractName' "$file")
# address=$(jq -r '.address' "$file")
# absolutePath=$(jq -r '.ast.absolutePath' "$file")

# Check if contractName and address are not empty
if [ -n "$contractName" ] && [ -n "$address" ]; then
# Call the forge command for verification with the specified network
forge verify-contract --verifier sourcify --verifier-url https://sourcify.roninchain.com/server/verify -c "$network" "$address" "$contractName"
else
echo "Error: Missing contractName or address in $file"
fi
fi
fi
done
# # Check if contractName and address are not empty
# if [ -n "$contractName" ] && [ -n "$address" ]; then
# echo "$absolutePath"
# # Call the forge command for verification with the specified network
# forge verify-contract --verifier sourcify --verifier-url ${endpoint} -c "$network" "$address" "$absolutePath:$contractName"
# else
# echo "Error: Missing contractName or address in $file"
# fi
# fi
# fi
# done
Loading

0 comments on commit 0616777

Please sign in to comment.