Skip to content

Commit 081cbb3

Browse files
committed
scripts: add a fund-deleg-utxo script
1 parent ca1a69e commit 081cbb3

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
# shellcheck disable=SC2031
3+
set -euo pipefail
4+
5+
[ -n "${DEBUG:-}" ] && set -x
6+
[ -z "${ENV:-}" ] && { echo "ENV var must be set"; exit 1; }
7+
8+
SCRIPT_PATH=$(readlink -f "$0")
9+
SCRIPT_DIR=$(dirname "$SCRIPT_PATH")
10+
11+
# shellcheck disable=SC1091
12+
source "$SCRIPT_DIR/../bash-fns.sh"
13+
14+
FUND_DELEGATE() {
15+
NAME="$1"
16+
SEND_ADDR="$2"
17+
18+
read -p "Do you wish to fund $NAME [yY]? " -n 1 -r
19+
echo
20+
if [[ $REPLY =~ ^[Yy]$ ]]; then
21+
read -r -p "Enter in lovelace what the funding UTXO should be: " LOVELACE
22+
just fund-transfer "$ENV" "$SEND_ADDR" "$LOVELACE"
23+
fi
24+
echo
25+
}
26+
27+
echo "In env $ENV, pool1 currently has UTXO of:"
28+
cardano-cli latest query utxo --address "$(just sops-decrypt-binary "secrets/groups/${ENV}1/no-deploy/${ENV}1-bp-a-1-owner-payment-stake.addr")" | jq
29+
echo
30+
FUND_DELEGATE "pool1" "$(just sops-decrypt-binary "secrets/groups/${ENV}1/no-deploy/${ENV}1-bp-a-1-owner-payment-stake.addr")"
31+
32+
echo "In env $ENV, pool2 currently has UTXO of:"
33+
cardano-cli latest query utxo --address "$(just sops-decrypt-binary "secrets/groups/${ENV}2/no-deploy/${ENV}2-bp-b-1-owner-payment-stake.addr")" | jq
34+
echo
35+
FUND_DELEGATE "pool2" "$(just sops-decrypt-binary "secrets/groups/${ENV}2/no-deploy/${ENV}2-bp-b-1-owner-payment-stake.addr")"
36+
37+
echo "In env $ENV, pool3 currently has UTXO of:"
38+
cardano-cli latest query utxo --address "$(just sops-decrypt-binary "secrets/groups/${ENV}3/no-deploy/${ENV}3-bp-c-1-owner-payment-stake.addr")" | jq
39+
echo
40+
FUND_DELEGATE "pool3" "$(just sops-decrypt-binary "secrets/groups/${ENV}3/no-deploy/${ENV}3-bp-c-1-owner-payment-stake.addr")"
41+
42+
echo "In env $ENV, drep-0 currently has UTXO of:"
43+
cardano-cli latest query utxo --address "$(just sops-decrypt-binary "secrets/envs/${ENV}/drep/drep-0.addr")" | jq
44+
echo
45+
FUND_DELEGATE "drep-0" "$(just sops-decrypt-binary "secrets/envs/${ENV}/drep/drep-0.addr")"

scripts/recipes/custom.just

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ fund-transfer ENV SEND_ADDR LOVELACE UTXO="auto":
121121
}
122122

123123
echo "For environment $ENV, the SEND_TO address of $SEND_ADDR contains the following UTxOs:"
124-
eval "$CARDANO_CLI" latest query utxo --address "$SEND_ADDR"
124+
eval "$CARDANO_CLI" latest query utxo --address "$SEND_ADDR" | jq
125125
PROMPT
126126

127127
CHANGE_ADDR=$(just sops-decrypt-binary secrets/envs/$ENV/utxo-keys/rich-utxo.addr)
128-
echo "For environment $ENV, the rich key address of $CHANGE_ADDR contains the following UTxOs:"
129-
eval "$CARDANO_CLI" latest query utxo --address "$CHANGE_ADDR"
128+
echo "For environment $ENV, the rich key address of $CHANGE_ADDR contains the following lovelace only UTxOs:"
129+
eval "$CARDANO_CLI" latest query utxo --address "$CHANGE_ADDR" | jq 'to_entries | map(select(.value.value | length == 1)) | sort_by(.value.value.lovelace) | from_entries'
130130
PROMPT
131131

132132
if [ "$UTXO" = "auto" ]; then

0 commit comments

Comments
 (0)