Skip to content

Commit

Permalink
fix: consumer chain registration error (#44)
Browse files Browse the repository at this point in the history
* fix: consumer chain registration error

* nit: log register tx output
  • Loading branch information
parketh authored Nov 18, 2024
1 parent 2b5da23 commit fdceb0c
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions scripts/babylon-integration/utils/register-consumer-chain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fi
# TODO: for now, we can use the consumer chain name as the consumer description,
# remove it after issue #255 (https://github.com/babylonlabs-io/babylon/issues/255) is fixed
echo "Registering consumer chain $CONSUMER_ID..."
CONSUMER_REGISTRATION_TX_HASH=$(babylond tx btcstkconsumer register-consumer \
CONSUMER_REGISTRATION_OUTPUT=$(babylond tx btcstkconsumer register-consumer \
"$CONSUMER_ID" \
"$CONSUMER_CHAIN_NAME" \
"$CONSUMER_CHAIN_NAME" \
Expand All @@ -33,7 +33,32 @@ CONSUMER_REGISTRATION_TX_HASH=$(babylond tx btcstkconsumer register-consumer \
--gas-prices 0.2ubbn \
--gas auto \
--gas-adjustment 2 \
-o json -y \
| jq -r '.txhash')
-o json -y)
echo "$CONSUMER_REGISTRATION_OUTPUT"
echo

CONSUMER_REGISTRATION_TX_HASH=$(echo "$CONSUMER_REGISTRATION_OUTPUT" | jq -r '.txhash')
echo "Consumer registration transaction hash: $CONSUMER_REGISTRATION_TX_HASH"
echo
echo

# wait for the transaction to be included in a block
echo "Waiting for the transaction to be included in a block..."
wait_for_tx "$CONSUMER_REGISTRATION_TX_HASH" 10 5

# check chain registered
echo "Checking if the chain is registered..."

# query all registered consumer chains
echo "Querying all registered consumer chains..."
CONSUMER_IDS=$(babylond query btcstkconsumer registered-consumers \
--chain-id $BABYLON_CHAIN_ID \
--node $BABYLON_RPC_URL \
-o json | jq -r '.consumer_ids[]')

# check if the consumer chain is registered, if not exit with error
if echo "$CONSUMER_IDS" | grep -q "^${CONSUMER_ID}$"; then
echo "Consumer chain $CONSUMER_ID successfully registered"
else
echo "Consumer chain $CONSUMER_ID failed to register"
exit 1
fi

0 comments on commit fdceb0c

Please sign in to comment.