Skip to content

Commit

Permalink
creating better echos
Browse files Browse the repository at this point in the history
  • Loading branch information
logicalmechanism committed May 4, 2024
1 parent d7ba79f commit 01d7a06
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 43 deletions.
7 changes: 3 additions & 4 deletions scripts/wallet/02_burnAddress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ policy_id=$(cat ../../hashes/pointer.hash)

if [[ $# -eq 0 ]] ; then
echo -e "\n \033[0;31m Please Supply A Token Name \033[0m \n";
exit
exit;
fi

token_file_name="${1}.json"
echo $token_file_name
echo -e "\033[0;33m\nBurning Seed Elf: ${1}\n\033[0m"

# get script utxo
echo -e "\033[0;36m Gathering wallet UTxO Information \033[0m"
Expand All @@ -47,8 +47,7 @@ if [ "${TXNS}" -eq "0" ]; then
fi

secret_key=$(python -c "import json; print(json.load(open('addrs/${token_file_name}'))['secret'])")

echo Secret Key: ${secret_key}
echo -e "\033[0;33m\nSecret Key: ${secret_key}\n\033[0m"

generator=$(python3 -c "
import sys;
Expand Down
4 changes: 3 additions & 1 deletion scripts/wallet/03_sendToSeedElf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ if [[ $2 -lt 2000000 ]] ; then
exit 1
fi

echo -e "\033[0;33m\nSending Funds To Seed Elf: ${1}\n\033[0m"

# the minting script policy
policy_id=$(cat ../../hashes/pointer.hash)

Expand All @@ -49,7 +51,7 @@ ${cli} conway query utxo \
TXNS=$(jq length ../tmp/script_utxo.json)
if [ "${TXNS}" -eq "0" ]; then
echo -e "\n \033[0;31m NO UTxOs Found At ${wallet_script_address} \033[0m \n";
. exit;
exit;
fi

python3 -c "
Expand Down
52 changes: 14 additions & 38 deletions scripts/wallet/04_spendFunds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,31 @@ set -e
source ../.env

# get params
${cli} query protocol-parameters ${network} --out-file ../tmp/protocol.json

# user
user="user-1"
user_address=$(cat ../wallets/${user}-wallet/payment.addr)
user_pkh=$(${cli} address key-hash --payment-verification-key-file ../wallets/${user}-wallet/payment.vkey)
${cli} conway query protocol-parameters ${network} --out-file ../tmp/protocol.json

# walletscript
wallet_script_path="../../contracts/wallet_contract.plutus"
wallet_script_address=$(${cli} address build --payment-script-file ${wallet_script_path} ${network})
wallet_script_address=$(${cli} conway address build --payment-script-file ${wallet_script_path} ${network})

# collat
collat_address=$(cat ../wallets/collat-wallet/payment.addr)
collat_pkh=$(${cli} address key-hash --payment-verification-key-file ../wallets/collat-wallet/payment.vkey)
collat_pkh=$(${cli} conway address key-hash --payment-verification-key-file ../wallets/collat-wallet/payment.vkey)

# the minting script policy
policy_id=$(cat ../../hashes/pointer.hash)

if [[ $# -eq 0 ]] ; then
echo -e "\n \033[0;31m Please Supply A Token Name \033[0m \n";
if [[ $# -ne 2 ]] ; then
echo -e "\n \033[0;31m Please Supply A Source Token Name And Destination Token Name \033[0m \n"
echo -e "\n \033[0;31m ./04_spendFunds.sh your_seed_elf their_seed_elf \033[0m \n"
exit
fi

token_file_name="${1}.json"
echo $token_file_name
echo -e "\033[0;33m\nSending Funds To Seed Elf: ${1}\n\033[0m"

# get script utxo
echo -e "\033[0;36m Gathering wallet UTxO Information \033[0m"
${cli} query utxo \
${cli} conway query utxo \
--address ${wallet_script_address} \
${network} \
--out-file ../tmp/script_utxo.json
Expand All @@ -42,7 +38,6 @@ if [ "${TXNS}" -eq "0" ]; then
echo -e "\n \033[0;31m NO UTxOs Found At ${wallet_script_address} \033[0m \n";
. exit;
fi
TXIN=$(jq -r --arg alltxin "" 'keys[] | . + $alltxin + " --tx-in"' ../tmp/script_utxo.json)

x=$(python -c "import json; print(json.load(open('addrs/${token_file_name}'))['secret'])")

Expand All @@ -57,26 +52,9 @@ echo $wallet_tx_in
#
exit
#
# get user utxo
echo -e "\033[0;36m Gathering UTxO Information \033[0m"
${cli} query utxo \
${network} \
--address ${user_address} \
--out-file ../tmp/user_utxo.json

TXNS=$(jq length ../tmp/user_utxo.json)
if [ "${TXNS}" -eq "0" ]; then
echo -e "\n \033[0;31m NO UTxOs Found At ${user_address} \033[0m \n";
exit;
fi
alltxin=""
TXIN=$(jq -r --arg alltxin "" 'keys[] | . + $alltxin + " --tx-in"' ../tmp/user_utxo.json)
user_tx_in=${TXIN::-8}


# collat info
echo -e "\033[0;36m Gathering Collateral UTxO Information \033[0m"
${cli} query utxo \
${cli} conway query utxo \
${network} \
--address ${collat_address} \
--out-file ../tmp/collat_utxo.json
Expand All @@ -89,18 +67,16 @@ fi
collat_tx_in=$(jq -r 'keys[0]' ../tmp/collat_utxo.json)

# script reference utxo
wallet_ref_utxo=$(${cli} transaction txid --tx-file ../tmp/utxo-wallet_contract.plutus.signed)
wallet_ref_utxo=$(${cli} conway transaction txid --tx-file ../tmp/utxo-wallet_contract.plutus.signed)

echo -e "\033[0;36m Building Tx \033[0m"
FEE=$(${cli} transaction build \
--conway-era \
FEE=$(${cli} conway transaction build \
--out-file ../tmp/tx.draft \
--change-address ${user_address} \
--tx-in-collateral ${collat_tx_in} \
--tx-in ${user_tx_in} \
--tx-in ${wallet_tx_in} \
--spending-tx-in-reference="${wallet_ref_utxo}#1" \
--spending-plutus-script-v2 \
--spending-plutus-script-v3 \
--spending-reference-tx-in-inline-datum-present \
--spending-reference-tx-in-redeemer-file ../data/wallet/wallet-redeemer.json \
--required-signer-hash ${user_pkh} \
Expand All @@ -115,7 +91,7 @@ echo -e "\033[1;32m Fee: \033[0m" $FEE
# exit
#
echo -e "\033[0;36m Signing \033[0m"
${cli} transaction sign \
${cli} conway transaction sign \
--signing-key-file ../wallets/${user}-wallet/payment.skey \
--signing-key-file ../wallets/collat-wallet/payment.skey \
--tx-body-file ../tmp/tx.draft \
Expand All @@ -125,7 +101,7 @@ ${cli} transaction sign \
# exit
#
echo -e "\033[0;36m Submitting \033[0m"
${cli} transaction submit \
${cli} conway transaction submit \
${network} \
--tx-file ../tmp/tx.signed

Expand Down

0 comments on commit 01d7a06

Please sign in to comment.