Skip to content

Commit 7bc8748

Browse files
fix(deploy): tolerate forge create progress noise when extracting addresses (#6)
`forge create --json` interleaves compile progress with the JSON payload on stdout, so piping straight to `jq -r '.deployedTo'` breaks intermittently (observed on the Stage 1b ERC1967Proxy deploy in a warm cache). Switch both Stage 1a and Stage 1b extractions to grep the human-readable "Deployed to: 0x…" line — stable across forge versions and cache states — and validate the captured address before continuing so a malformed extract can't silently propagate into ERC1967Proxy constructor args or the `definition.json` manager patch. Co-authored-by: Drew Stone <drewstone329@gmail.com>
1 parent 896032f commit 7bc8748

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

deploy/register-blueprint.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,19 @@ echo ""
6262
# construction time via ERC1967Proxy's `_data` argument.
6363
if [ -z "${BSM_ADDRESS:-}" ]; then
6464
echo "Stage 1a: deploying EmbeddingBSM implementation …"
65+
# `forge create --json` interleaves compile progress with JSON on stdout,
66+
# so jq parsing breaks intermittently. Grep the human-readable
67+
# "Deployed to:" line instead — it's stable across forge versions and
68+
# cache states.
6569
IMPL_ADDRESS=$(forge create \
6670
--root "$CONTRACTS_DIR" \
6771
--rpc-url "$RPC_URL" \
6872
--private-key "$PRIVATE_KEY" \
6973
--broadcast \
7074
"$CONTRACTS_DIR/src/EmbeddingBSM.sol:EmbeddingBSM" \
71-
--json | jq -r '.deployedTo')
75+
--json 2>&1 | grep -oE 'Deployed to: 0x[a-fA-F0-9]{40}' | tail -1 | awk '{print $3}')
76+
echo "$IMPL_ADDRESS" | grep -qE '^0x[a-fA-F0-9]{40}$' \
77+
|| { echo "failed to extract EmbeddingBSM impl address from forge create output"; exit 1; }
7278
echo "EmbeddingBSM impl deployed at: $IMPL_ADDRESS"
7379

7480
echo "Stage 1b: deploying ERC1967Proxy and invoking initialize(tsUSD) …"
@@ -81,7 +87,9 @@ if [ -z "${BSM_ADDRESS:-}" ]; then
8187
--broadcast \
8288
"$CONTRACTS_DIR/dependencies/@openzeppelin-contracts-5.1.0/proxy/ERC1967/ERC1967Proxy.sol:ERC1967Proxy" \
8389
--constructor-args "$IMPL_ADDRESS" "$INIT_CALLDATA" \
84-
--json | jq -r '.deployedTo')
90+
--json 2>&1 | grep -oE 'Deployed to: 0x[a-fA-F0-9]{40}' | tail -1 | awk '{print $3}')
91+
echo "$BSM_ADDRESS" | grep -qE '^0x[a-fA-F0-9]{40}$' \
92+
|| { echo "failed to extract ERC1967Proxy address from forge create output"; exit 1; }
8593
echo "EmbeddingBSM proxy deployed at: $BSM_ADDRESS"
8694
else
8795
echo "Stage 1 skipped — reusing existing BSM proxy at $BSM_ADDRESS"

0 commit comments

Comments
 (0)