Skip to content

Commit

Permalink
feat: verify with sourcify natively for forge script
Browse files Browse the repository at this point in the history
  • Loading branch information
TuDo1403 committed Jul 25, 2024
1 parent f9a3695 commit 80a2583
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 2,922 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ docs/
*.env
.vscode

node_modules/
yarn-error.log
.yarn
.yarnrc.yml
deployments/**/exported_address
dependencies
deployments
Expand Down
28 changes: 0 additions & 28 deletions hardhat.config.ts

This file was deleted.

28 changes: 20 additions & 8 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
# Install foundryup
curl -L https://foundry.paradigm.xyz | bash
# Install foundry
$HOME/.foundry/bin/foundryup -v nightly-de33b6af53005037b463318d2628b5cfcaf39916 # Stable version
# Install rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Check if foundry is installed
if ! command -v $HOME/.foundry/bin/forge &>/dev/null; then
# Install foundryup
curl -L https://foundry.paradigm.xyz | bash
# Install foundry
$HOME/.foundry/bin/foundryup -v nightly-de33b6af53005037b463318d2628b5cfcaf39916 # Stable version
fi

# Check if rustup is installed
if ! command -v rustup &>/dev/null; then
# Install rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
fi

# Update rustup
$HOME/.cargo/bin/rustup update stable
# Install soldeer
Expand All @@ -12,5 +20,9 @@ $HOME/.cargo/bin/cargo install soldeer
$HOME/.cargo/bin/soldeer update
# Run forge build
$HOME/.foundry/bin/forge build
# Install jq
brew install jq

# Check if rustup is installed
if ! command -v jq &>/dev/null; then
# Install jq
brew install jq
fi
28 changes: 0 additions & 28 deletions package.json

This file was deleted.

33 changes: 8 additions & 25 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ done
export_address

echo "\033[33mTrying to compile contracts ...\033[0m"
forge build # Ensure the contracts are compiled before running the script
forge build --offline # Ensure the contracts are compiled before running the script

should_verify=$([[ $should_verify == true && $is_broadcast == true ]] && echo true || echo false)

Expand All @@ -153,8 +153,12 @@ if [[ $should_verify == true ]] && [[ $force_generate_artifact == false ]]; then
extra_argument+=generate-artifact@
fi

if [[ $should_verify == true ]] && [[ ! $network_name == "ronin-mainnet" ]] && [[ ! $network_name == "ronin-testnet" ]]; then
verify_arg="--verify --retries 5"
if [[ $should_verify == true ]]; then
if [[ $network_name == "ronin-mainnet" ]] || [[ $network_name == "ronin-testnet" ]]; then
verify_arg="--verify --retries 5 --verifier sourcify --verifier-url https://sourcify.roninchain.com/server/"
else
verify_arg="--verify --retries 5"
fi
fi

echo "Should Verify Contract: $should_verify"
Expand Down Expand Up @@ -191,29 +195,8 @@ fi

start_time=$(date +%s)

${op_command} forge script ${verify_arg} ${@} -g 200 --sig 'run(bytes,string)' $(cast calldata 'run()') "${extra_argument}"

# Check if the command was successful
if [ $? -eq 0 ]; then
if [[ $should_verify == true ]]; then
if [[ $network_name == "ronin-mainnet" ]] || [[ $network_name == "ronin-testnet" ]]; then
echo "Verifying contract..."
# Remove .env content
env_data=$(cat .env)
>.env

while IFS=',' read -r deployed; do
yarn hardhat sourcify --endpoint https://sourcify.roninchain.com/server --network ${network_name} --contract-name $deployed
done <./logs/deployed-contracts

# Restore the .env content
echo $env_data >.env
fi
fi
fi
${op_command} forge script --offline ${verify_arg} ${@} -g 200 --sig 'run(bytes,string)' $(cast calldata 'run()') "${extra_argument}"

end_time=$(date +%s)

# Remove the deployed-contracts file
rm -rf ./logs/deployed-contracts
echo "Execution time: $((end_time - start_time))s"
Loading

0 comments on commit 80a2583

Please sign in to comment.