From 66d76d5f702471395e408b199f23f34c4cc4ed9a Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Wed, 1 Jan 2025 01:58:21 +0000 Subject: [PATCH] add new bolierplate to all scripts --- scripts/cc/authorize-hot-key.sh | 15 +++++++++- scripts/cc/generate-cc-keys.sh | 15 +++++++++- scripts/cc/generate-new-hot-key.sh | 15 +++++++++- scripts/cc/resign-cold-key.sh | 15 +++++++++- scripts/cc/vote.sh | 15 +++++++++- scripts/drep/create-and-register-multisig.sh | 15 +++++++++- scripts/drep/delegate-to-self.sh | 15 +++++++++- scripts/drep/retire.sh | 15 +++++++++- scripts/drep/vote.sh | 15 +++++++++- scripts/ga/hardfork.sh | 15 +++++++++- scripts/ga/info.sh | 15 +++++++++- scripts/ga/new-committee.sh | 15 +++++++++- scripts/ga/new-consitution.sh | 15 +++++++++- scripts/ga/no-confidence.sh | 15 +++++++++- scripts/ga/parameter.sh | 15 +++++++++- scripts/ga/treasury.sh | 15 +++++++++- scripts/generate-keys.sh | 15 +++++++++- scripts/multi-sig/create-info-action.sh | 15 +++++++++- scripts/multi-sig/create-param-action.sh | 30 +++++++++++++++++-- scripts/multi-sig/generate-keys-and-script.sh | 15 +++++++++- scripts/multi-sig/query-multisig.sh | 15 +++++++++- scripts/multi-sig/send-ada-from-script.sh | 15 +++++++++- scripts/multi-sig/send-ada-to-script.sh | 15 +++++++++- scripts/query/dump-node-state.sh | 15 +++++++++- scripts/query/own-utxos.sh | 15 +++++++++- scripts/query/stake-pools.sh | 15 +++++++++- scripts/stake/delegate-to-drep.sh | 15 +++++++++- scripts/stake/delegate-to-spo.sh | 15 +++++++++- scripts/stake/key-deregister.sh | 15 +++++++++- scripts/stake/key-register.sh | 15 +++++++++- start-node.sh | 2 +- 31 files changed, 435 insertions(+), 32 deletions(-) diff --git a/scripts/cc/authorize-hot-key.sh b/scripts/cc/authorize-hot-key.sh index 850b27c..f3f9f2c 100755 --- a/scripts/cc/authorize-hot-key.sh +++ b/scripts/cc/authorize-hot-key.sh @@ -4,9 +4,22 @@ keys_dir="./keys" txs_dir="./txs/cc" +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } echo "Authorizing hot key for the constitutional committee." diff --git a/scripts/cc/generate-cc-keys.sh b/scripts/cc/generate-cc-keys.sh index 479eb19..576cd5e 100755 --- a/scripts/cc/generate-cc-keys.sh +++ b/scripts/cc/generate-cc-keys.sh @@ -3,9 +3,22 @@ # Define directories keys_dir="./keys" +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } # Check if CC keys already exist diff --git a/scripts/cc/generate-new-hot-key.sh b/scripts/cc/generate-new-hot-key.sh index ffcbb35..6b71f8f 100755 --- a/scripts/cc/generate-new-hot-key.sh +++ b/scripts/cc/generate-new-hot-key.sh @@ -3,9 +3,22 @@ # Define directories keys_dir="./keys" +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } # Generate hot CC keys diff --git a/scripts/cc/resign-cold-key.sh b/scripts/cc/resign-cold-key.sh index 8d71974..fbbe8d9 100755 --- a/scripts/cc/resign-cold-key.sh +++ b/scripts/cc/resign-cold-key.sh @@ -4,9 +4,22 @@ keys_dir="./keys" txs_dir="./txs/cc" +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } echo "Resigning your CC cold key." diff --git a/scripts/cc/vote.sh b/scripts/cc/vote.sh index 797cec6..83996cf 100755 --- a/scripts/cc/vote.sh +++ b/scripts/cc/vote.sh @@ -4,9 +4,22 @@ keys_dir="./keys" txs_dir="./txs/cc" +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } # Function to display script usage diff --git a/scripts/drep/create-and-register-multisig.sh b/scripts/drep/create-and-register-multisig.sh index 2033816..68a5d0e 100755 --- a/scripts/drep/create-and-register-multisig.sh +++ b/scripts/drep/create-and-register-multisig.sh @@ -4,9 +4,22 @@ keys_dir="./keys" txs_dir="./txs/drep" +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } # Registering you as a drep diff --git a/scripts/drep/delegate-to-self.sh b/scripts/drep/delegate-to-self.sh index 33450a7..11ebea1 100755 --- a/scripts/drep/delegate-to-self.sh +++ b/scripts/drep/delegate-to-self.sh @@ -4,9 +4,22 @@ keys_dir="./keys" txs_dir="./txs/drep" +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } echo "Delegating your voting rights to your DRep ID." diff --git a/scripts/drep/retire.sh b/scripts/drep/retire.sh index e9f1923..6620283 100755 --- a/scripts/drep/retire.sh +++ b/scripts/drep/retire.sh @@ -4,9 +4,22 @@ keys_dir="./keys" txs_dir="./txs/drep" +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } # Retiring you as a drep diff --git a/scripts/drep/vote.sh b/scripts/drep/vote.sh index 8808d39..792b1c2 100755 --- a/scripts/drep/vote.sh +++ b/scripts/drep/vote.sh @@ -4,9 +4,22 @@ keys_dir="./keys" txs_dir="./txs/drep" +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } # Function to display script usage diff --git a/scripts/ga/hardfork.sh b/scripts/ga/hardfork.sh index 8a20414..028ac76 100755 --- a/scripts/ga/hardfork.sh +++ b/scripts/ga/hardfork.sh @@ -12,9 +12,22 @@ METADATA_HASH="8a1bd37caa6b914a8b569adb63a0f41d8f159c110dc5c8409118a3f087fffb43" keys_dir="./keys" txs_dir="./txs/ga" +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } # Building, signing and submitting an hardfork change governance action diff --git a/scripts/ga/info.sh b/scripts/ga/info.sh index 08d7b4f..905030f 100755 --- a/scripts/ga/info.sh +++ b/scripts/ga/info.sh @@ -11,9 +11,22 @@ METADATA_HASH="93106d082a93e94df5aff74f678438bae3a647dac63465fbfcde6a3058f41a1e" keys_dir="./keys" txs_dir="./txs/ga" +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } # Building, signing and submitting an info governance action diff --git a/scripts/ga/new-committee.sh b/scripts/ga/new-committee.sh index 28e9b9a..ba96a36 100755 --- a/scripts/ga/new-committee.sh +++ b/scripts/ga/new-committee.sh @@ -17,9 +17,22 @@ METADATA_HASH="01318fd6815453f35a4daac80cbbe3bf46c35dc070eb7dc817f26dfee5042eb8" keys_dir="./keys" txs_dir="./txs/ga" +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } # Building, signing and submitting an new-committee change governance action diff --git a/scripts/ga/new-consitution.sh b/scripts/ga/new-consitution.sh index 1605645..a086ea5 100755 --- a/scripts/ga/new-consitution.sh +++ b/scripts/ga/new-consitution.sh @@ -17,9 +17,22 @@ METADATA_HASH="4b2649556c838497ee2923bdff0f05b48fb2f0c3c5cceb450200f8bd6868ac5b" keys_dir="./keys" txs_dir="./txs/ga" +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } # Building, signing and submitting an new-constitution change governance action diff --git a/scripts/ga/no-confidence.sh b/scripts/ga/no-confidence.sh index 8b35438..8e3d795 100755 --- a/scripts/ga/no-confidence.sh +++ b/scripts/ga/no-confidence.sh @@ -12,9 +12,22 @@ METADATA_HASH="ab901c3aeeca631ee5c70147a558fbf191a4af245d8ca001e845d8569d7c38f9" keys_dir="./keys" txs_dir="./$txs_dir/ga" +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } # Building, signing and submitting an no-confidence change governance action diff --git a/scripts/ga/parameter.sh b/scripts/ga/parameter.sh index b98be91..47716b2 100755 --- a/scripts/ga/parameter.sh +++ b/scripts/ga/parameter.sh @@ -12,9 +12,22 @@ METADATA_HASH="3e6b1083a637a740d5b84bb6edf1a5119b81440b31ea84907311b6543ebd39eb" keys_dir="./keys" txs_dir="./txs/ga" +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } # Building, signing and submitting an parameter change governance action diff --git a/scripts/ga/treasury.sh b/scripts/ga/treasury.sh index fb158f9..e8e1547 100755 --- a/scripts/ga/treasury.sh +++ b/scripts/ga/treasury.sh @@ -14,9 +14,22 @@ METADATA_HASH="633e6f25fea857662d1542921f1fa2cab5f90a9e4cb51bdae8946f823e403ea8" keys_dir="./keys" txs_dir="./txs/ga" +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } # Building, signing and submitting an treasury governance action diff --git a/scripts/generate-keys.sh b/scripts/generate-keys.sh index e85cca1..d3da310 100755 --- a/scripts/generate-keys.sh +++ b/scripts/generate-keys.sh @@ -3,9 +3,22 @@ # Define the keys directory keys_dir="./keys" +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } # Check if keys already exist diff --git a/scripts/multi-sig/create-info-action.sh b/scripts/multi-sig/create-info-action.sh index 060bc92..aac7b95 100755 --- a/scripts/multi-sig/create-info-action.sh +++ b/scripts/multi-sig/create-info-action.sh @@ -9,9 +9,22 @@ METADATA_HASH="0000000000000000000000000000000000000000000000000000000000000000" keys_dir="./keys" txs_dir="./txs/ga" +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } # Building, signing and submitting an info governance action diff --git a/scripts/multi-sig/create-param-action.sh b/scripts/multi-sig/create-param-action.sh index 33fb9f9..12596d6 100755 --- a/scripts/multi-sig/create-param-action.sh +++ b/scripts/multi-sig/create-param-action.sh @@ -9,9 +9,22 @@ METADATA_HASH="0000000000000000000000000000000000000000000000000000000000000000" keys_dir="./keys" txs_dir="./txs/ga" +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } echo "\nPull the latest guardrails script." @@ -24,9 +37,22 @@ echo "Script hash: $SCRIPT_HASH" # Building, signing and submitting an parameter update governance action echo "Creating and submitting protocol param update governance action, using the multi-sig's ada." +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } container_cli conway governance action create-protocol-parameters-update \ diff --git a/scripts/multi-sig/generate-keys-and-script.sh b/scripts/multi-sig/generate-keys-and-script.sh index be065ba..2cd8e7d 100755 --- a/scripts/multi-sig/generate-keys-and-script.sh +++ b/scripts/multi-sig/generate-keys-and-script.sh @@ -3,9 +3,22 @@ # Define directories keys_dir="./keys" +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } echo "Creating three keys to control a multi-sig script." diff --git a/scripts/multi-sig/query-multisig.sh b/scripts/multi-sig/query-multisig.sh index 34268a5..0097665 100755 --- a/scripts/multi-sig/query-multisig.sh +++ b/scripts/multi-sig/query-multisig.sh @@ -3,9 +3,22 @@ # Define directories keys_dir="./keys" +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } echo "Querying UTXOs for your multisig script address: $(cat ./$keys_dir/multi-sig/script.addr)" diff --git a/scripts/multi-sig/send-ada-from-script.sh b/scripts/multi-sig/send-ada-from-script.sh index 799e10f..1fd2fe2 100755 --- a/scripts/multi-sig/send-ada-from-script.sh +++ b/scripts/multi-sig/send-ada-from-script.sh @@ -8,9 +8,22 @@ LOVELACE_AMOUNT=1000000 keys_dir="./keys" txs_dir="./txs/ga" +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } # Send ada to the multisig payment script diff --git a/scripts/multi-sig/send-ada-to-script.sh b/scripts/multi-sig/send-ada-to-script.sh index c5dd662..6a771d3 100755 --- a/scripts/multi-sig/send-ada-to-script.sh +++ b/scripts/multi-sig/send-ada-to-script.sh @@ -8,9 +8,22 @@ LOVELACE_AMOUNT=10000000 keys_dir="./keys" txs_dir="./txs/ga" +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } # Send ada to the multisig payment script diff --git a/scripts/query/dump-node-state.sh b/scripts/query/dump-node-state.sh index d813496..b855b86 100755 --- a/scripts/query/dump-node-state.sh +++ b/scripts/query/dump-node-state.sh @@ -1,8 +1,21 @@ #!/bin/sh +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } # Query DReps from ledger state diff --git a/scripts/query/own-utxos.sh b/scripts/query/own-utxos.sh index f5143e8..3fc6666 100755 --- a/scripts/query/own-utxos.sh +++ b/scripts/query/own-utxos.sh @@ -3,9 +3,22 @@ # Define directories keys_dir="./keys" +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } # Check if you have a address created diff --git a/scripts/query/stake-pools.sh b/scripts/query/stake-pools.sh index 8fc6c12..0ddd4bc 100755 --- a/scripts/query/stake-pools.sh +++ b/scripts/query/stake-pools.sh @@ -1,8 +1,21 @@ #!/bin/sh +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } # Query the stake pools diff --git a/scripts/stake/delegate-to-drep.sh b/scripts/stake/delegate-to-drep.sh index addbcc7..b94a78a 100755 --- a/scripts/stake/delegate-to-drep.sh +++ b/scripts/stake/delegate-to-drep.sh @@ -8,9 +8,22 @@ drep_id="3f3d4a84b800b34eb84c6151a955cdd823a0b99e3b886c725b8769e5" # keyhash of keys_dir="./keys" txs_dir="./txs/stake" +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } # Delegating to an DRep diff --git a/scripts/stake/delegate-to-spo.sh b/scripts/stake/delegate-to-spo.sh index 217789d..cbdf059 100755 --- a/scripts/stake/delegate-to-spo.sh +++ b/scripts/stake/delegate-to-spo.sh @@ -8,9 +8,22 @@ spo_id="pool104flte3y29dprxcntacsuyznhduvlaza38gvp8yyhy2vvmfenxa" # keyhash of t keys_dir="./keys" txs_dir="./txs/stake" +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } # Delegating to an SPO diff --git a/scripts/stake/key-deregister.sh b/scripts/stake/key-deregister.sh index 597d428..de5c039 100755 --- a/scripts/stake/key-deregister.sh +++ b/scripts/stake/key-deregister.sh @@ -4,9 +4,22 @@ keys_dir="./keys" txs_dir="./txs/stake" +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } # Unregistering your stake key diff --git a/scripts/stake/key-register.sh b/scripts/stake/key-register.sh index de953ae..d2f65df 100755 --- a/scripts/stake/key-register.sh +++ b/scripts/stake/key-register.sh @@ -4,9 +4,22 @@ keys_dir="./keys" txs_dir="./txs/stake" +# Get the script's directory +script_dir=$(dirname "$0") + +# Get the container name from the get-container script +container_name="$("$script_dir/../helper/get-container.sh")" + +if [ -z "$container_name" ]; then + echo "Failed to determine a running container." + exit 1 +fi + +echo "Using running container: $container_name" + # Function to execute cardano-cli commands inside the container container_cli() { - docker exec -ti sancho-node cardano-cli "$@" + docker exec -ti $container_name cardano-cli "$@" } # Registering your stake key diff --git a/start-node.sh b/start-node.sh index b9366bb..c98f714 100755 --- a/start-node.sh +++ b/start-node.sh @@ -71,7 +71,7 @@ export NETWORK=$network # Get the network magic from the shelley-genesis.json file and pass it into the container export NETWORK_ID=$(jq -r '.networkMagic' "$config_dir/shelley-genesis.json") -# Substitute the NETWORK variable in the docker-compose.yml file and start the Docker container +# Substitute the variables in the docker-compose.yml file and start the Docker container envsubst < docker-compose.yml | docker-compose -f - up -d --build # Forward the logs to the terminal