-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathretryVerificationFromMulti.sh
More file actions
executable file
·81 lines (64 loc) · 3 KB
/
retryVerificationFromMulti.sh
File metadata and controls
executable file
·81 lines (64 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
#
# Note: This script is in beta and may not work as expected.
# Known issue: The latest-run CREATE transaction may lack constructor arguments even if it's present in the deployment file.
# Improvement suggestion: Extract constructor data from Transactions.transaction.input, that will cut 70% of the file size and fix the issues.
#
echo "Available subfolders in ./broadcast:"
select folder in ./broadcast/*; do
if [ -n "$folder" ]; then
echo "You have selected the folder: $folder"
break
fi
echo "Invalid selection. Please try again."
done
while true; do
echo "Please enter the subfolder you want to use in '$folder':"
select subfolder in "$folder"/*; do
if [ -n "$subfolder" ]; then
echo "You have selected the subfolder: $subfolder"
folder="$subfolder"
break 2
fi
echo "Invalid selection. Please try again."
done
done
run_latest_file="$folder/run.json"
if [ ! -f "$run_latest_file" ]; then
echo "'run-latest.json' not found in '$folder'."
exit 1
fi
deployments=$(jq -c '.deployments[]' "$run_latest_file")
echo "$deployments" | while IFS= read -r deployment; do
transactions=$(echo "$deployment" | jq -c '.transactions[] | select(.transactionType == "CREATE") | {arguments: (.arguments // []), contractName: .contractName, contractAddress: .contractAddress}')
echo "Number of 'CREATE' transactions: $(echo "$transactions" | jq -s 'length')"
chainId=$(echo "$deployment" | jq -r '.chain')
echo "Chain ID: $chainId"
if [ -z "$transactions" ]; then
echo "No 'CREATE' transactions found in the current deployment."
continue
fi
echo "$transactions" | while IFS= read -r transaction; do
contractName=$(echo "$transaction" | jq -r '.contractName')
contractAddress=$(echo "$transaction" | jq -r '.contractAddress')
args=$(echo "$transaction" | jq -r '.arguments // [] | map(if test("^0x[0-9a-fA-F]+$") or test("^[0-9]+$") then . else @sh end) | join(" ")')
contract_json="./out/${contractName}.sol/${contractName}.json"
if [ ! -f "$contract_json" ]; then
echo "JSON file for contract $contractName not found at $contract_json."
continue
fi
constructor_inputs=$(jq -c '.abi[] | select(.type == "constructor") | .inputs' "$contract_json")
if [ -z "$constructor_inputs" ]; then
echo "No constructor inputs found for contract $contractName."
forge verify-contract "$contractAddress" "$contractName" --chain-id "$chainId" --watch || echo "Error verifying contract $contractName at address $contractAddress on chain $chainId."
continue
fi
input_types=$(echo "$constructor_inputs" | jq -r 'map(.type) | join(",")')
constructor_string="constructor($input_types)"
if ! encoded_args=$(cast abi-encode "$constructor_string" $args 2>/dev/null); then
echo "Error encoding arguments for $contractName with constructor $constructor_string."
continue
fi
forge verify-contract "$contractAddress" "$contractName" --constructor-args $encoded_args --chain-id "$chainId" --watch
done
done