Skip to content

Commit 032022a

Browse files
committed
fns: bash (zsh) sourceable helper fns
1 parent 89a22d1 commit 032022a

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

scripts/bash-fns.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# shellcheck disable=SC2148
2+
#
3+
# Various bash helper functions live here.
4+
5+
6+
# This can be used to simplify ssh sessions, rsync, ex:
7+
# ssh -o "$(ssm-proxy-cmd "$REGION")" "$INSTANCE_ID"
8+
ssm-proxy-cmd() {
9+
echo "ProxyCommand=sh -c 'aws --region $1 ssm start-session --target %h --document-name AWS-StartSSHSession --parameters portNumber=%p'"
10+
}
11+
12+
13+
# A handy transaction submission function with mempool monitoring.
14+
# CARDANO_NODE_{NETWORK_ID,SOCKET_PATH}, TESTNET_MAGIC should already be exported.
15+
submit() (
16+
set -euo pipefail
17+
TX_SIGNED="$1"
18+
19+
TXID=$(cardano-cli latest transaction txid --tx-file "$TX_SIGNED")
20+
21+
echo "Submitting $TX_SIGNED with txid $TXID..."
22+
cardano-cli latest transaction submit --tx-file "$TX_SIGNED"
23+
24+
EXISTS="true"
25+
while [ "$EXISTS" = "true" ]; do
26+
EXISTS=$(cardano-cli latest query tx-mempool tx-exists "$TXID" | jq -r .exists)
27+
if [ "$EXISTS" = "true" ]; then
28+
echo "The transaction still exists in the mempool, sleeping 5s: $TXID"
29+
else
30+
echo "The transaction has been removed from the mempool."
31+
fi
32+
sleep 5
33+
done
34+
echo "Transaction $TX_SIGNED with txid $TXID submitted successfully."
35+
echo
36+
)

0 commit comments

Comments
 (0)