diff --git a/CHANGELOG.md b/CHANGELOG.md index 011e73b..745313d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ - **cogno-project**: added text to the landing README in the parent directory - **cogno-project**: added text to the headless README - **headless**: added script reference tx, contracts, and hashes +- **headless**: added guardrails to parent level headless scripts +- **headless**: added wallet protections ### Fixed diff --git a/headless/00_createScriptReferences.sh b/headless/00_createScriptReferences.sh index f26ab3d..88d14ca 100755 --- a/headless/00_createScriptReferences.sh +++ b/headless/00_createScriptReferences.sh @@ -17,6 +17,18 @@ change_address=$(jq -r '.change_address' ../config.json) reference_script_path="../contracts/reference_contract.plutus" script_reference_address=$(${cli} address build --payment-script-file ${reference_script_path} ${network}) +# Prompt user for confirmation +read -p "$(echo -e "\033[1;37\033[1;36m\nPress\033[0m \033[1;32mEnter\033[0m \033[1;36mTo Create Script Reference UTxOs Or Any Other Key To Exit:\n\033[0m")" -n 1 -r +echo -ne '\033[1A\033[2K\r' + +# Check if input is empty (user pressed Enter) +if [[ -z $REPLY ]]; then + echo "Creating script reference UTxOs..." +else + echo "Operation cancelled." + exit; +fi + echo -e "\033[0;35m\nGathering UTxO Information \033[0m" ${cli} query utxo \ ${network} \ diff --git a/headless/01_genesisMint.sh b/headless/01_genesisMint.sh index 821d177..e84186f 100755 --- a/headless/01_genesisMint.sh +++ b/headless/01_genesisMint.sh @@ -25,7 +25,19 @@ change_address=$(jq -r '.change_address' ../config.json) collat_address=$(cat wallets/collat-wallet/payment.addr) collat_pkh=$(${cli} address key-hash --payment-verification-key-file wallets/collat-wallet/payment.vkey) -echo -e "\033[0;36m Gathering Starter UTxO Information \033[0m" +# Prompt user for confirmation +read -p "$(echo -e "\033[1;37\033[1;36m\nPress\033[0m \033[1;32mEnter\033[0m \033[1;36mTo Mint Genesis Token Or Any Other Key To Exit:\n\033[0m")" -n 1 -r +echo -ne '\033[1A\033[2K\r' + +# Check if input is empty (user pressed Enter) +if [[ -z $REPLY ]]; then + echo "Minting Genesis Token..." +else + echo "Operation cancelled." + exit; +fi + +echo -e "\033[0;36m Gathering Starter UTxO Information\033[0m" ${cli} query utxo \ ${network} \ --address ${starter_address} \ diff --git a/headless/create_wallet.sh b/headless/create_wallet.sh index ef80e8b..6aa7ab1 100755 --- a/headless/create_wallet.sh +++ b/headless/create_wallet.sh @@ -5,8 +5,8 @@ set -e source .env if [[ $# -eq 0 ]] ; then - echo 'Please Supply A Wallet Folder' - exit 1 + echo 'Please Supply A Wallet Folder: wallet/name-wallet' + exit 1; fi folder=${1} @@ -17,7 +17,9 @@ if [ ! -d ${folder} ]; then ${cli} address key-gen --verification-key-file ${folder}/payment.vkey --signing-key-file ${folder}/payment.skey ${cli} address build --payment-verification-key-file ${folder}/payment.vkey --out-file ${folder}/payment.addr ${network} ${cli} address key-hash --payment-verification-key-file ${folder}/payment.vkey --out-file ${folder}/payment.hash + echo "${folder} folder created" + exit; else - echo "Folder already exists" + echo "${folder} folder already exists" exit 1; fi diff --git a/headless/send_all.sh b/headless/send_all.sh index b8acf3a..3c9de89 100755 --- a/headless/send_all.sh +++ b/headless/send_all.sh @@ -4,8 +4,6 @@ set -e # SET UP VARS HERE source .env -rm ./tmp/tx.signed || true - # get params ${cli} query protocol-parameters ${network} --out-file ./tmp/protocol.json @@ -16,6 +14,19 @@ sender_address=$(cat ${sender_path}payment.addr) # Receiver Address # receiver_address=$(cat ${sender_path}payment.addr) receiver_address=$(jq -r '.change_address' ../config.json) + +# Prompt user for confirmation +echo -e "\033[1;37mSending All UTxOs From \033[1;34m${sender_path}\033[0m\033[1;37m to \033[1;35m${receiver_address}\033[0m" +read -p "$(echo -e "\033[1;37m\033[1;36m\nPress\033[0m \033[1;32mEnter\033[0m \033[1;36mTo Send All UTxOs Or Any Other Key To Exit:\n\033[0m")" -n 1 -r +echo -ne '\033[1A\033[2K\r' + +# Check if input is empty (user pressed Enter) +if [[ -z $REPLY ]]; then + echo "Sending all UTxOs..." +else + echo "Operation cancelled." + exit; +fi # # exit # @@ -32,14 +43,14 @@ if [ "${TXNS}" -eq "0" ]; then fi alltxin="" TXIN=$(jq -r --arg alltxin "" 'keys[] | . + $alltxin + " --tx-in"' tmp/sender_utxo.json) -seller_tx_in=${TXIN::-8} +sender_tx_in=${TXIN::-8} echo -e "\033[0;36m Building Tx \033[0m" FEE=$(${cli} transaction build \ --babbage-era \ --out-file ./tmp/tx.draft \ --change-address ${receiver_address} \ - --tx-in ${seller_tx_in} \ + --tx-in ${sender_tx_in} \ ${network}) IFS=':' read -ra VALUE <<< "${FEE}"