Run nitro-rpc-client command in the bridge-deployment

This commit is contained in:
Prathamesh Musale 2024-07-23 10:25:14 +05:30
parent 20f6d163d2
commit 03f4884018
2 changed files with 12 additions and 10 deletions

View File

@ -2,17 +2,16 @@
# Exit on error
set -e
# Prerequisite: nitro-rpc-client package installed globally
# https://github.com/cerc-io/go-nitro/blob/main/packages/nitro-rpc-client/readme.md#global-install
set -u
# Check args
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <stage0-deployment-dir-absolute>"
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <bridge-deployment-dir-absolute> <stage0-deployment-dir-absolute>"
exit 1
fi
STAGE0_DEPLOYMENT_DIR="$1"
BRIDGE_DEPLOYMENT_DIR="$1"
STAGE0_DEPLOYMENT_DIR="$2"
STAGE1_GENESIS_DIR=stage1-genesis
# Create a temporary target directory
@ -22,11 +21,13 @@ mkdir -p $STAGE1_GENESIS_DIR
# Fetch ETH account holdings from the bridge node
# Trust locally-trusted development certificates created by mkcert
export NODE_EXTRA_CA_CERTS="$(mkcert -CAROOT)/rootCA.pem"
# Run the nitro-rpc-client command and process the output with jq
eth_account_holdings=$(nitro-rpc-client get-all-l2-channels -p 4006 | jq -s '[.[] | {nitro_address: .Balance.Them, balance: .Balance.TheirBalance}]')
cd $BRIDGE_DEPLOYMENT_DIR
eth_account_holdings=$(laconic-so deployment --dir bridge-deployment exec nitro-rpc-client "nitro-rpc-client get-all-l2-channels -p 4006 -h nitro-bridge" | jq -s '[.[] | {nitro_address: .Balance.Them, balance: .Balance.TheirBalance}]')
# Change back to the original directory
cd -
echo "Fetched Ethereum account holdings"

View File

@ -2,6 +2,7 @@
# Exit on error
set -e
set -u
# Note: Needs to be run in a docker container with image cerc/laconicd:local