Skip to content

Commit dcf3037

Browse files
committed
fix: use numeric chainId in upgrade-payload.json for Safe import
Map chain names to EIP-155 IDs so Transaction Builder JSON validates; reject unknown chain names. Made-with: Cursor
1 parent 55a71a3 commit dcf3037

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

scripts/generate-upgrade-payload.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@ NEW_IMPL="${3:-${NEW_IMPLEMENTATION_ADDRESS:?}}"
2121
SAFE_ADDRESS="${4:-${SAFE_ADDRESS}}"
2222
CHAIN="${5:-${CHAIN:-mainnet}}"
2323

24+
# Numeric chain ID for Safe Transaction Builder JSON (must not be the chain name string)
25+
case "$CHAIN" in
26+
mainnet) CHAIN_ID_NUM=1 ;;
27+
sepolia) CHAIN_ID_NUM=11155111 ;;
28+
base) CHAIN_ID_NUM=8453 ;;
29+
arbitrum) CHAIN_ID_NUM=42161 ;;
30+
optimism) CHAIN_ID_NUM=10 ;;
31+
polygon) CHAIN_ID_NUM=137 ;;
32+
gnosis) CHAIN_ID_NUM=100 ;;
33+
celo) CHAIN_ID_NUM=42220 ;;
34+
*)
35+
echo "Unknown chain name: $CHAIN (expected mainnet, sepolia, base, arbitrum, optimism, polygon, gnosis, celo)" >&2
36+
exit 1
37+
;;
38+
esac
39+
2440
# Normalize chain to Safe app slug (eth, base, arbitrum, etc.)
2541
SAFE_CHAIN_SLUG="$CHAIN"
2642
case "$CHAIN" in
@@ -76,7 +92,7 @@ OUTPUT_JSON="${MULTISIG_PROPOSAL_JSON:-./upgrade-payload.json}"
7692
cat > "$OUTPUT_JSON" << EOF
7793
{
7894
"version": "1.0",
79-
"chainId": "$CHAIN",
95+
"chainId": $CHAIN_ID_NUM,
8096
"meta": {
8197
"name": "DonationHandler upgrade",
8298
"description": "ProxyAdmin.upgradeAndCall(proxy, implementation, 0x)"

0 commit comments

Comments
 (0)