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

adding embeded and inline, fixing case in variable names #3

Merged
merged 1 commit into from
Jul 11, 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
2 changes: 1 addition & 1 deletion lib/newm-minter/types/minter.ak
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub type MintRedeemer {
MintTokens
BurnTokens { burn_amt: Int }
BurnTokens(Int)
}
5 changes: 2 additions & 3 deletions lib/newm-minter/types/reference.ak
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use aiken/transaction/credential.{PoolId}
use assist/types/hashes.{PublicKeyHash, ValidatorHash}
use assist/types/wallet.{Wallet}

// staking info
pub type Staking {
pool_id: PoolId,
reward_wallet: Wallet,
Expand All @@ -16,7 +15,6 @@ fn has_valid_staking(staking: Staking) -> Bool {
}
}

// keepers are like admins
pub type Keepers {
pkhs: List<PublicKeyHash>,
threshold: Int,
Expand All @@ -37,7 +35,9 @@ fn do_has_valid_keepers(
) -> Bool {
when keepers is {
[] -> and {
// some amount of keepers must exist
counter > 0,
// must be equal or greater than threshold
counter >= threshold,
}
[pkh, ..pkhs] ->
Expand All @@ -51,7 +51,6 @@ fn do_has_valid_keepers(
}
}

// contract validator hashes
pub type Contracts {
storage: ValidatorHash,
stake: ValidatorHash,
Expand Down
1 change: 0 additions & 1 deletion lib/newm-minter/types/storage.ak
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// only can remove or update
pub type CIP68Redeemer {
RemoveMeta
UpdateMeta
Expand Down
2 changes: 1 addition & 1 deletion lib/newm-minter/util.ak
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use assist/find
/// If nothing is found then fail else return data.
///
/// ```aiken
/// util.output_datum(tx.outputs, this_addr, tx.datums)
/// util.output_datum(outputs, this_addr, datums)
/// ```
pub fn output_datum(
outputs: List<Output>,
Expand Down
14 changes: 7 additions & 7 deletions scripts/00_createScriptReferences.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ ${cli} query utxo \
--address ${reference_address} \
--out-file ./tmp/reference_utxo.json

TXNS=$(jq length ./tmp/reference_utxo.json)
if [ "${TXNS}" -eq "0" ]; then
txns=$(jq length ./tmp/reference_utxo.json)
if [ "${txns}" -eq "0" ]; then
echo -e "\n \033[0;31m NO UTxOs Found At ${reference_address} \033[0m \n";
exit;
fi
alltxin=""
TXIN=$(jq -r --arg alltxin "" 'to_entries[] | select(.value.value | length < 2) | .key | . + $alltxin + " --tx-in"' ./tmp/reference_utxo.json)
ref_tx_in=${TXIN::-8}
txin=$(jq -r --arg alltxin "" 'to_entries[] | select(.value.value | length < 2) | .key | . + $alltxin + " --tx-in"' ./tmp/reference_utxo.json)
ref_tx_in=${txin::-8}
changeAmount=$(jq '[.. | objects | .lovelace] | add' ./tmp/reference_utxo.json)

counter=0
Expand Down Expand Up @@ -63,15 +63,15 @@ do
--tx-out-reference-script-file ${contract} \
--fee 900000

FEE=$(cardano-cli transaction calculate-min-fee \
fee=$(cardano-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)
echo -e "\033[0;35mfee: ${fee} \033[0m"
fee=$(echo $fee | rev | cut -c 9- | rev)

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

Expand Down
42 changes: 23 additions & 19 deletions scripts/mint/01_mintTokens.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ ${cli} query utxo \
--address ${newm_address} \
--out-file ../tmp/newm_utxo.json

TXNS=$(jq length ../tmp/newm_utxo.json)
if [ "${TXNS}" -eq "0" ]; then
txns=$(jq length ../tmp/newm_utxo.json)
if [ "${txns}" -eq "0" ]; then
echo -e "\n \033[0;31m NO UTxOs Found At ${newm_address} \033[0m \n";
exit;
fi
Expand All @@ -60,25 +60,27 @@ echo -n $ref_name > ../tmp/reference.token
echo -n $frac_name > ../tmp/fraction.token


REFERENCE_ASSET="1 ${policy_id}.${ref_name}"
FRACTION_ASSET="100000000 ${policy_id}.${frac_name}"
reference_asset="1 ${policy_id}.${ref_name}"
fraction_asset="100000000 ${policy_id}.${frac_name}"

MINT_ASSET="1 ${policy_id}.${ref_name} + 100000000 ${policy_id}.${frac_name}"
mint_asset="1 ${policy_id}.${ref_name} + 100000000 ${policy_id}.${frac_name}"

# echo Minting: ${MINT_ASSET}
# echo Minting: ${mint_asset}

UTXO_VALUE=$(${cli} transaction calculate-min-required-utxo \
min_ada=$(${cli} transaction calculate-min-required-utxo \
--babbage-era \
--protocol-params-file ../tmp/protocol.json \
--tx-out-inline-datum-file ../data/storage/empty.metadata-datum.json \
--tx-out="${storage_script_address} + 5000000 + ${REFERENCE_ASSET}" | tr -dc '0-9')
reference_address_out="${storage_script_address} + ${UTXO_VALUE} + ${REFERENCE_ASSET}"
--tx-out="${storage_script_address} + 5000000 + ${reference_asset}" | tr -dc '0-9')
reference_address_out="${storage_script_address} + ${min_ada} + ${reference_asset}"

# --tx-out-datum-embed-file ../data/storage/empty.metadata-datum.json \

min_ada=$(${cli} transaction calculate-min-required-utxo \
--babbage-era \
--protocol-params-file ../tmp/protocol.json \
--tx-out="${receiver_address} + 5000000 + ${FRACTION_ASSET}" | tr -dc '0-9')
fraction_address_out="${receiver_address} + ${min_ada} + ${FRACTION_ASSET}"
--tx-out="${receiver_address} + 5000000 + ${fraction_asset}" | tr -dc '0-9')
fraction_address_out="${receiver_address} + ${min_ada} + ${fraction_asset}"

echo "Reference Mint OUTPUT:" ${reference_address_out}
echo "Fraction Mint OUTPUT:" ${fraction_address_out}
Expand All @@ -90,8 +92,8 @@ ${cli} query utxo \
--testnet-magic ${testnet_magic} \
--address ${collat_address} \
--out-file ../tmp/collat_utxo.json
TXNS=$(jq length ../tmp/collat_utxo.json)
if [ "${TXNS}" -eq "0" ]; then
txns=$(jq length ../tmp/collat_utxo.json)
if [ "${txns}" -eq "0" ]; then
echo -e "\n \033[0;31m NO UTxOs Found At ${collat_address} \033[0m \n";
exit;
fi
Expand All @@ -102,7 +104,7 @@ data_ref_utxo=$(${cli} transaction txid --tx-file ../tmp/referenceable-tx.signed

# Add metadata to this build function for nfts with data
echo -e "\033[0;36m Building Tx \033[0m"
FEE=$(${cli} transaction build \
fee=$(${cli} transaction build \
--babbage-era \
--out-file ../tmp/tx.draft \
--change-address ${newm_address} \
Expand All @@ -114,17 +116,19 @@ FEE=$(${cli} transaction build \
--tx-out="${fraction_address_out}" \
--required-signer-hash ${collat_pkh} \
--required-signer-hash ${newm_pkh} \
--mint="${MINT_ASSET}" \
--mint="${mint_asset}" \
--mint-tx-in-reference="${script_ref_utxo}#1" \
--mint-plutus-script-v2 \
--policy-id="${policy_id}" \
--mint-reference-tx-in-redeemer-file ../data/mint/mint-redeemer.json \
--testnet-magic ${testnet_magic})

IFS=':' read -ra VALUE <<< "${FEE}"
IFS=' ' read -ra FEE <<< "${VALUE[1]}"
FEE=${FEE[1]}
echo -e "\033[1;32m Fee: \033[0m" $FEE
# --tx-out-datum-embed-file ../data/storage/empty.metadata-datum.json \

IFS=':' read -ra VALUE <<< "${fee}"
IFS=' ' read -ra fee <<< "${VALUE[1]}"
fee=${fee[1]}
echo -e "\033[1;32m Fee: \033[0m" $fee
#
# exit
#
Expand Down
42 changes: 21 additions & 21 deletions scripts/mint/02_burnFractions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ ${cli} query utxo \
--address ${artist_address} \
--out-file ../tmp/artist_utxo.json

TXNS=$(jq length ../tmp/artist_utxo.json)
if [ "${TXNS}" -eq "0" ]; then
txns=$(jq length ../tmp/artist_utxo.json)
if [ "${txns}" -eq "0" ]; then
echo -e "\n \033[0;31m NO UTxOs Found At ${artist_address} \033[0m \n";
exit;
fi
Expand All @@ -60,31 +60,31 @@ artist_tx_in=${TXIN::-8}

# echo "Artist UTxO:" $artist_tx_in

CURRENT_VALUE=$(jq -r --arg policy_id "${policy_id}" --arg token_name "${token_name}" 'to_entries[] | select(.value.value[$policy_id][$token_name]) | .value.value[$policy_id][$token_name]' ../tmp/artist_utxo.json)
# echo $CURRENT_VALUE
current_value=$(jq -r --arg policy_id "${policy_id}" --arg token_name "${token_name}" 'to_entries[] | select(.value.value[$policy_id][$token_name]) | .value.value[$policy_id][$token_name]' ../tmp/artist_utxo.json)
# echo $current_value

BURN_ASSET="-${burnAmt} ${policy_id}.${token_name}"
burn_asset="-${burnAmt} ${policy_id}.${token_name}"

# echo $BURN_ASSET
# echo $burn_asset

retAmt=$((${CURRENT_VALUE} - ${burnAmt}))
retAmt=$((${current_value} - ${burnAmt}))

if [[ CURRENT_VALUE -lt burnAmt ]] ; then
if [[ current_value -lt burnAmt ]] ; then
echo "Not Enough Tokens For The Burn"
exit
fi

RETURN_ASSET="${retAmt} ${policy_id}.${token_name}"
return_asset="${retAmt} ${policy_id}.${token_name}"

UTXO_VALUE=$(${cli} transaction calculate-min-required-utxo \
min_ada=$(${cli} transaction calculate-min-required-utxo \
--babbage-era \
--protocol-params-file ../tmp/protocol.json \
--tx-out="${artist_address} + 5000000 + ${RETURN_ASSET}" | tr -dc '0-9')
--tx-out="${artist_address} + 5000000 + ${return_asset}" | tr -dc '0-9')

if [[ retAmt -eq 0 ]] ; then
artist_address_out="${artist_address} + ${UTXO_VALUE}"
artist_address_out="${artist_address} + ${min_ada}"
else
artist_address_out="${artist_address} + ${UTXO_VALUE} + ${RETURN_ASSET}"
artist_address_out="${artist_address} + ${min_ada} + ${return_asset}"
fi

echo "Artist Return OUTPUT:" ${artist_address_out}
Expand All @@ -96,8 +96,8 @@ ${cli} query utxo \
--testnet-magic ${testnet_magic} \
--address ${collat_address} \
--out-file ../tmp/collat_utxo.json
TXNS=$(jq length ../tmp/collat_utxo.json)
if [ "${TXNS}" -eq "0" ]; then
txns=$(jq length ../tmp/collat_utxo.json)
if [ "${txns}" -eq "0" ]; then
echo -e "\n \033[0;31m NO UTxOs Found At ${collat_address} \033[0m \n";
exit;
fi
Expand All @@ -108,7 +108,7 @@ data_ref_utxo=$(${cli} transaction txid --tx-file ../tmp/referenceable-tx.signed

# Add metadata to this build function for nfts with data
echo -e "\033[0;36m Building Tx \033[0m"
FEE=$(${cli} transaction build \
fee=$(${cli} transaction build \
--babbage-era \
--out-file ../tmp/tx.draft \
--change-address ${artist_address} \
Expand All @@ -120,17 +120,17 @@ FEE=$(${cli} transaction build \
--required-signer-hash ${keeper1_pkh} \
--required-signer-hash ${keeper2_pkh} \
--required-signer-hash ${keeper3_pkh} \
--mint="${BURN_ASSET}" \
--mint="${burn_asset}" \
--mint-tx-in-reference="${script_ref_utxo}#1" \
--mint-plutus-script-v2 \
--policy-id="${policy_id}" \
--mint-reference-tx-in-redeemer-file ../data/mint/burn-redeemer.json \
--testnet-magic ${testnet_magic})

IFS=':' read -ra VALUE <<< "${FEE}"
IFS=' ' read -ra FEE <<< "${VALUE[1]}"
FEE=${FEE[1]}
echo -e "\033[1;32m Fee: \033[0m" $FEE
IFS=':' read -ra VALUE <<< "${fee}"
IFS=' ' read -ra fee <<< "${VALUE[1]}"
fee=${fee[1]}
echo -e "\033[1;32m Fee: \033[0m" $fee
#
# exit
#
Expand Down
22 changes: 11 additions & 11 deletions scripts/mint/03_burnReference.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ ${cli} query utxo \
--address ${artist_address} \
--out-file ../tmp/artist_utxo.json

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

BURN_ASSET="-1 ${policy_id}.${token_name}"
burn_asset="-1 ${policy_id}.${token_name}"

#
# exit
Expand All @@ -54,8 +54,8 @@ ${cli} query utxo \
--testnet-magic ${testnet_magic} \
--address ${collat_address} \
--out-file ../tmp/collat_utxo.json
TXNS=$(jq length ../tmp/collat_utxo.json)
if [ "${TXNS}" -eq "0" ]; then
txns=$(jq length ../tmp/collat_utxo.json)
if [ "${txns}" -eq "0" ]; then
echo -e "\n \033[0;31m NO UTxOs Found At ${collat_address} \033[0m \n";
exit;
fi
Expand All @@ -66,7 +66,7 @@ data_ref_utxo=$(${cli} transaction txid --tx-file ../tmp/referenceable-tx.signed

# Add metadata to this build function for nfts with data
echo -e "\033[0;36m Building Tx \033[0m"
FEE=$(${cli} transaction build \
fee=$(${cli} transaction build \
--babbage-era \
--out-file ../tmp/tx.draft \
--change-address ${artist_address} \
Expand All @@ -77,17 +77,17 @@ FEE=$(${cli} transaction build \
--required-signer-hash ${keeper1_pkh} \
--required-signer-hash ${keeper2_pkh} \
--required-signer-hash ${keeper3_pkh} \
--mint="${BURN_ASSET}" \
--mint="${burn_asset}" \
--mint-tx-in-reference="${script_ref_utxo}#1" \
--mint-plutus-script-v2 \
--policy-id="${policy_id}" \
--mint-reference-tx-in-redeemer-file ../data/mint/burn-redeemer.json \
--testnet-magic ${testnet_magic})

IFS=':' read -ra VALUE <<< "${FEE}"
IFS=' ' read -ra FEE <<< "${VALUE[1]}"
FEE=${FEE[1]}
echo -e "\033[1;32m Fee: \033[0m" $FEE
IFS=':' read -ra VALUE <<< "${fee}"
IFS=' ' read -ra fee <<< "${VALUE[1]}"
fee=${fee[1]}
echo -e "\033[1;32m Fee: \033[0m" $fee
#
# exit
#
Expand Down
18 changes: 9 additions & 9 deletions scripts/reference/01_createReferenceUTxO.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ ${cli} query utxo \
--out-file ../tmp/starter_utxo.json

# transaction variables
TXNS=$(jq length ../tmp/starter_utxo.json)
if [ "${TXNS}" -eq "0" ]; then
txns=$(jq length ../tmp/starter_utxo.json)
if [ "${txns}" -eq "0" ]; then
echo -e "\n \033[0;31m NO UTxOs Found At ${starter_address} \033[0m \n";
exit;
fi
alltxin=""
TXIN=$(jq -r --arg alltxin "" --arg policy_id "$policy_id" --arg token_name "$token_name" 'to_entries[] | select((.value.value | length < 2) or .value.value[$policy_id][$token_name] == 1) | .key | . + $alltxin + " --tx-in"' ../tmp/starter_utxo.json)
starter_tx_in=${TXIN::-8}
txin=$(jq -r --arg alltxin "" --arg policy_id "$policy_id" --arg token_name "$token_name" 'to_entries[] | select((.value.value | length < 2) or .value.value[$policy_id][$token_name] == 1) | .key | . + $alltxin + " --tx-in"' ../tmp/starter_utxo.json)
starter_tx_in=${txin::-8}

echo -e "\033[0;36m Building Tx \033[0m"
FEE=$(${cli} transaction build \
fee=$(${cli} transaction build \
--babbage-era \
--out-file ../tmp/tx.draft \
--change-address ${change_address} \
Expand All @@ -61,10 +61,10 @@ FEE=$(${cli} transaction build \
--tx-out-inline-datum-file ../data/reference/reference-datum.json \
--testnet-magic ${testnet_magic})

IFS=':' read -ra VALUE <<< "${FEE}"
IFS=' ' read -ra FEE <<< "${VALUE[1]}"
FEE=${FEE[1]}
echo -e "\033[1;32m Fee: \033[0m" $FEE
IFS=':' read -ra VALUE <<< "${fee}"
IFS=' ' read -ra fee <<< "${VALUE[1]}"
fee=${fee[1]}
echo -e "\033[1;32m Fee: \033[0m" $fee
#
# exit
#
Expand Down
Loading
Loading