Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rebuild without traces and do another e2e #6

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions complete_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ rm -fr build/ || true
echo -e "\033[1;34m Building Contracts \033[0m"

# remove all traces for production
aiken build --trace-level silent --filter-traces user-defined
# aiken build --trace-level silent --filter-traces user-defined

# keep the traces for testing
# aiken build --trace-level verbose --filter-traces all
aiken build --trace-level verbose --filter-traces all

ran=$(jq -r '.random_string' config.json)
ran_cbor=$(python3 -c "import cbor2;hex_string='${ran}';data = bytes.fromhex(hex_string);encoded = cbor2.dumps(data);print(encoded.hex())")
Expand Down
8 changes: 5 additions & 3 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"__comment1__": "Genesis UTxO From Starter Wallet",
"genesis_tx_id": "d91cc6ef03ac89d5534535f236b40d9933a438a09cdc468ed878ad7a197e61fe",
"genesis_tx_idx": 1,
"genesis_tx_id": "57d3a65415bc240fafbd636afde43ae32a42fdf0b46edced0666953cbe161cf1",
"genesis_tx_idx": 0,
"__comment2__": "Random String For Data Reference",
"random_string": "10"
"random_string": "11",
"__comment3__": "Change address for reference and genesis",
"change_address": "addr_test1qrvnxkaylr4upwxfxctpxpcumj0fl6fdujdc72j8sgpraa9l4gu9er4t0w7udjvt2pqngddn6q4h8h3uv38p8p9cq82qav4lmp"
}
49 changes: 43 additions & 6 deletions headless/00_createScriptReferences.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ reference_address=$(cat ./wallets/reference-wallet/payment.addr)
reference_script_path="../contracts/reference_contract.plutus"
script_reference_address=$(${cli} address build --payment-script-file ${reference_script_path} ${network})

# address to send the leftover ada too
change_address=$(jq -r '.change_address' ../config.json)


echo -e "\033[0;35m\nGathering UTxO Information \033[0m"
${cli} query utxo \
${network} \
Expand Down Expand Up @@ -62,12 +66,9 @@ do
--tx-out-reference-script-file ${contract} \
--fee 900000

FEE=$(cardano-cli transaction calculate-min-fee \
FEE=$(${cli} transaction calculate-min-fee \
--tx-body-file ./tmp/tx.draft \
${network} \
--protocol-params-file ./tmp/protocol.json \
--tx-in-count 1 \
--tx-out-count 2 \
--witness-count 1)
echo -e "\033[0;35mFEE: ${FEE} \033[0m"
fee=$(echo $FEE | rev | cut -c 9- | rev)
Expand All @@ -90,12 +91,44 @@ do
--out-file ./tmp/utxo-${file_name}.signed \
${network}

ref_tx_in=$(${cli} transaction txid --tx-body-file ./tmp/tx.draft)#0
tx_id=$(${cli} transaction txid --tx-body-file ./tmp/tx.draft)
ref_tx_in=${tx_id}#0
echo
echo -e "\033[0;36mNext UTxO: $ref_tx_in \033[0m"
echo -e "\033[0;36m$file_name: $tx_id#1 \033[0m"

done

${cli} transaction build-raw \
--babbage-era \
--protocol-params-file ./tmp/protocol.json \
--out-file ./tmp/tx.draft \
--tx-in ${ref_tx_in} \
--tx-out="${change_address} + ${changeAmount}" \
--fee 900000

FEE=$(${cli} transaction calculate-min-fee \
--tx-body-file ./tmp/tx.draft \
--protocol-params-file ./tmp/protocol.json \
--witness-count 1)
echo -e "\033[0;35mFEE: ${FEE} \033[0m"
fee=$(echo $FEE | rev | cut -c 9- | rev)

changeAmount=$((${changeAmount} - ${fee}))

${cli} transaction build-raw \
--babbage-era \
--protocol-params-file ./tmp/protocol.json \
--out-file ./tmp/tx.draft \
--tx-in ${ref_tx_in} \
--tx-out="${change_address} + ${changeAmount}" \
--fee ${fee}

${cli} transaction sign \
--signing-key-file ./wallets/reference-wallet/payment.skey \
--tx-body-file ./tmp/tx.draft \
--out-file ./tmp/change-tx.signed \
${network}

echo -e "\033[1;37m --------------------------------------------------------------------------------\033[0m"
# now submit them in that order
for contract in $(ls "../contracts"/* | sort -V)
Expand All @@ -108,4 +141,8 @@ do
--tx-file ./tmp/utxo-${file_name}.signed
done

${cli} transaction submit \
${network} \
--tx-file ./tmp/change-tx.signed

echo -e "\033[0;32m\nDone!\033[0m"
9 changes: 1 addition & 8 deletions headless/01_genesisMint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ genesis_policy_id=$(cat ../hashes/genesis_contract.hash)
starter_address=$(cat wallets/starter-wallet/payment.addr)
starter_pkh=$(${cli} address key-hash --payment-verification-key-file wallets/starter-wallet/payment.vkey)

change_address="addr_test1qrvnxkaylr4upwxfxctpxpcumj0fl6fdujdc72j8sgpraa9l4gu9er4t0w7udjvt2pqngddn6q4h8h3uv38p8p9cq82qav4lmp"
change_address=$(jq -r '.change_address' ../config.json)

# collat wallet
collat_address=$(cat wallets/collat-wallet/payment.addr)
Expand Down Expand Up @@ -80,17 +80,10 @@ collat_utxo=$(jq -r 'keys[0]' tmp/collat_utxo.json)

genesis_ref_utxo=$(${cli} transaction txid --tx-file tmp/utxo-genesis_contract.plutus.signed )

# slot contraints
slot=$(${cli} query tip ${network} | jq .slot)
current_slot=$(($slot - 1))
final_slot=$(($slot + 2500))

echo -e "\033[0;36m Building Tx \033[0m"
FEE=$(${cli} transaction build \
--babbage-era \
--out-file tmp/tx.draft \
--invalid-before ${current_slot} \
--invalid-hereafter ${final_slot} \
--change-address ${change_address} \
--tx-in-collateral="${collat_utxo}" \
--tx-in ${starter_tx_in} \
Expand Down
1 change: 0 additions & 1 deletion headless/cogno/01_createCogno.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ UTXO_VALUE=$(${cli} transaction calculate-min-required-utxo \
--tx-out="${cogno_script_address} + 5000000 + ${MINT_ASSET}" | tr -dc '0-9')
cogno_address_out="${cogno_script_address} + ${UTXO_VALUE} + ${MINT_ASSET}"


echo "Cogno OUTPUT:" ${cogno_address_out}
#
# exit
Expand Down
2 changes: 1 addition & 1 deletion headless/data/cogno/token.name
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cafebabe00ac8e5e2f504e19d70a15539d99f863bb0bebc3f5c445fa9b42a566
cafebabe0035b6040bb1810776a1bea50e956e754fffd48f95bb53f01558c945
8 changes: 4 additions & 4 deletions headless/data/reference/reference-datum.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
"constructor": 0,
"fields": [
{
"bytes": "cfa60e85f9dcd52a44c4552e1c9d692deaa43837dff2097546914389"
"bytes": "bf06b7349e9f67106d10fa677ab0d3fcd6a6f25cd4bd73e42118c376"
},
{
"bytes": "cdab6680f11d19226419cd9012d3f57dbb1d775cb5d0d80f18b6a361"
"bytes": "5b5aca6197430cdf2e6e4158dbda759807b3ffb7df3a348ebf686025"
},
{
"bytes": "9da1352787785d38a71d4eb715a68517d4a00729dfa1cd28ed72f99f"
"bytes": "a52f3dcacf39c033f3da45f02432cc98dacd87cedd63ed4e240e2533"
},
{
"bytes": "35653ce5fea9d0bd92ea079b9d7b8bd03f980936bf4fb9c5c62babaf"
"bytes": "e8b4169efe8424a182637c33e663628fc03f89c39a6e531d24a5fef2"
}
]
}
2 changes: 1 addition & 1 deletion headless/data/thread/thread-datum.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
]
},
{
"bytes": "cafebabe00ac8e5e2f504e19d70a15539d99f863bb0bebc3f5c445fa9b42a566"
"bytes": "cafebabe0035b6040bb1810776a1bea50e956e754fffd48f95bb53f01558c945"
}
]
}
2 changes: 1 addition & 1 deletion headless/data/thread/token.name
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1abe11ed007c7a9687a042efabf5acecce82030b010ce630e87c264981e183b2
1abe11ed00bc76a2013c2b81ac62a6cf0ae1b1338cae024eb6375b5658f3e452
2 changes: 1 addition & 1 deletion headless/data/thread/updated-thread-datum.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
]
},
{
"bytes": "cafebabe00ac8e5e2f504e19d70a15539d99f863bb0bebc3f5c445fa9b42a566"
"bytes": "cafebabe0035b6040bb1810776a1bea50e956e754fffd48f95bb53f01558c945"
}
]
}
4 changes: 2 additions & 2 deletions headless/trade_token.sh → headless/send_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ rm ./tmp/tx.signed || true
${cli} query protocol-parameters ${network} --out-file ./tmp/protocol.json

# Sender Address
sender_path="wallets/user-1-wallet/"
sender_path="wallets/reference-wallet/"
sender_address=$(cat ${sender_path}payment.addr)

# Receiver Address
# receiver_address=$(cat ${sender_path}payment.addr)
receiver_address="addr_test1qrvnxkaylr4upwxfxctpxpcumj0fl6fdujdc72j8sgpraa9l4gu9er4t0w7udjvt2pqngddn6q4h8h3uv38p8p9cq82qav4lmp"
receiver_address=$(jq -r '.change_address' ../config.json)
#
# exit
#
Expand Down
2 changes: 1 addition & 1 deletion validators/cogno_minter.ak
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ validator(
value.from_asset(currency_symbol, token_name, 1),
outputs,
)?,
// can not spend anything from cogno address
// single output going to the cogno address
count.outputs_by_addr(outputs, cogno_addr, 1)?,
}
}
Expand Down