|
82 | 82 |
|
83 | 83 | # --------------------------------------------------------------------------- |
84 | 84 | echo "=== deploying the 4 new implementations ===" |
85 | | -deploy(){ cast send --rpc-url "$RPC" --private-key "$DEPLOY_KEY" $SEND_EXTRA --create "$1" --json 2>/dev/null | jq -r .contractAddress; } |
86 | | -A_IMPL=$(deploy "$(jq -r .bytecode artifacts/contracts/Account.sol/Account.json)") |
87 | | -M_IMPL=$(deploy "$(jq -r .bytecode artifacts/contracts/Manager.sol/Manager.json)") |
88 | | -S_IMPL=$(deploy "$(jq -r .bytecode artifacts/contracts/SpecificGroupStrategy.sol/SpecificGroupStrategy.json)") |
89 | | -LIB=$(deploy "$(jq -r .bytecode artifacts/contracts/common/linkedlists/AddressSortedLinkedList.sol/AddressSortedLinkedList.json)") |
90 | | -DBC=$(jq -r .bytecode artifacts/contracts/DefaultStrategy.sol/DefaultStrategy.json | sed "s/__\$[0-9a-f]*\$__/$(norm "$LIB")/g") |
91 | | -D_IMPL=$(deploy "$DBC") |
| 85 | +# Deploy creation bytecode; surface the cast error (and abort) on failure. |
| 86 | +deploy(){ |
| 87 | + local out addr |
| 88 | + out=$(cast send --rpc-url "$RPC" --private-key "$DEPLOY_KEY" $SEND_EXTRA --create "$1" --json 2>/tmp/deploy-err.log) |
| 89 | + addr=$(echo "$out" | jq -r '.contractAddress // empty' 2>/dev/null) |
| 90 | + if [ -z "$addr" ] || [ "$addr" = "null" ]; then |
| 91 | + echo "DEPLOY FAILED:" >&2; tail -5 /tmp/deploy-err.log >&2; return 1 |
| 92 | + fi |
| 93 | + echo "$addr" |
| 94 | +} |
| 95 | +A_IMPL=$(deploy "$(jq -r .bytecode artifacts/contracts/Account.sol/Account.json)") || exit 1 |
| 96 | +M_IMPL=$(deploy "$(jq -r .bytecode artifacts/contracts/Manager.sol/Manager.json)") || exit 1 |
| 97 | +S_IMPL=$(deploy "$(jq -r .bytecode artifacts/contracts/SpecificGroupStrategy.sol/SpecificGroupStrategy.json)") || exit 1 |
| 98 | +LIB=$(deploy "$(jq -r .bytecode artifacts/contracts/common/linkedlists/AddressSortedLinkedList.sol/AddressSortedLinkedList.json)") || exit 1 |
| 99 | +# Link DefaultStrategy to the deployed library. The placeholder must be replaced |
| 100 | +# by the full 40-hex address (lowercased, 0x stripped, LEADING ZEROS PRESERVED). |
| 101 | +LIB_HEX=$(echo "${LIB#0x}" | tr 'A-Z' 'a-z') |
| 102 | +DBC=$(jq -r .bytecode artifacts/contracts/DefaultStrategy.sol/DefaultStrategy.json | sed "s/__\$[0-9a-f]*\$__/$LIB_HEX/g") |
| 103 | +case "$DBC" in *'__$'*) echo "ERROR: DefaultStrategy bytecode still has an unlinked library placeholder" >&2; exit 1;; esac |
| 104 | +D_IMPL=$(deploy "$DBC") || exit 1 |
92 | 105 | for v in "$A_IMPL:Account" "$M_IMPL:Manager" "$S_IMPL:SpecificGroupStrategy" "$D_IMPL:DefaultStrategy" "$LIB:AddressSortedLinkedList"; do |
93 | 106 | [ -n "${v%%:*}" ] && [ "${v%%:*}" != null ] || { echo "deploy failed: ${v##*:}"; exit 1; } |
94 | 107 | echo " ${v##*:}: ${v%%:*}" |
|
0 commit comments