From becb8af290d145d9cbad551c7a8c47546af11ac8 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Wed, 24 Jul 2024 11:30:35 +0000 Subject: [PATCH] Fetch account holdings from bridge in a separate script (#6) Part of [laconicd testnet validator enrollment](https://www.notion.so/laconicd-testnet-validator-enrollment-6fc1d3cafcc64fef8c5ed3affa27c675) Reviewed-on: https://git.vdb.to/cerc-io/fixturenet-laconicd-stack/pulls/6 Co-authored-by: Prathamesh Musale Co-committed-by: Prathamesh Musale --- .../scripts/fetch-account-holdings.sh | 20 +++++++++++++++++++ .../scripts/generate-stage1-genesis.sh | 12 +++++------ 2 files changed, 25 insertions(+), 7 deletions(-) create mode 100755 stack-orchestrator/stacks/fixturenet-laconicd/scripts/fetch-account-holdings.sh diff --git a/stack-orchestrator/stacks/fixturenet-laconicd/scripts/fetch-account-holdings.sh b/stack-orchestrator/stacks/fixturenet-laconicd/scripts/fetch-account-holdings.sh new file mode 100755 index 0000000..343420b --- /dev/null +++ b/stack-orchestrator/stacks/fixturenet-laconicd/scripts/fetch-account-holdings.sh @@ -0,0 +1,20 @@ + +#!/bin/bash + +# Exit on error +set -e +set -u + +# Check args +if [ "$#" -ne 2 ]; then + echo "Usage: $0 " + exit 1 +fi + +BRIDGE_DEPLOYMENT_DIR="$1" +OUTPUT_FILE="$2" + +# Run the nitro-rpc-client command and process the output with jq +laconic-so deployment --dir $BRIDGE_DEPLOYMENT_DIR 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}]' > "$OUTPUT_FILE" + +echo "Ethereum account holdings exported to $OUTPUT_FILE" diff --git a/stack-orchestrator/stacks/fixturenet-laconicd/scripts/generate-stage1-genesis.sh b/stack-orchestrator/stacks/fixturenet-laconicd/scripts/generate-stage1-genesis.sh index 6f827b9..53fac02 100755 --- a/stack-orchestrator/stacks/fixturenet-laconicd/scripts/generate-stage1-genesis.sh +++ b/stack-orchestrator/stacks/fixturenet-laconicd/scripts/generate-stage1-genesis.sh @@ -6,12 +6,12 @@ set -u # Check args if [ "$#" -ne 2 ]; then - echo "Usage: $0 " + echo "Usage: $0 " exit 1 fi -BRIDGE_DEPLOYMENT_DIR="$1" -STAGE0_DEPLOYMENT_DIR="$2" +STAGE0_DEPLOYMENT_DIR="$1" +ETH_ACCOUNT_HOLDINGS_FILE="$2" STAGE1_GENESIS_DIR=stage1-genesis # Create a temporary target directory @@ -19,10 +19,8 @@ mkdir -p $STAGE1_GENESIS_DIR # -------- -# Fetch ETH account holdings from the bridge node - -# Run the nitro-rpc-client command and process the output with jq -eth_account_holdings=$(laconic-so deployment --dir $BRIDGE_DEPLOYMENT_DIR 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}]') +# ETH account holdings fetched from the bridge node +eth_account_holdings=$(cat $ETH_ACCOUNT_HOLDINGS_FILE) echo "Fetched Ethereum account holdings"