From 4695347bcedf9e9f14a4f4a14912bc1c669314e1 Mon Sep 17 00:00:00 2001 From: twwu123 Date: Fri, 13 Dec 2024 11:08:55 +0800 Subject: [PATCH] fix oracle utxo to only mint 1 --- validators/oracle_nft.ak | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/validators/oracle_nft.ak b/validators/oracle_nft.ak index 81c4c1d..df23139 100644 --- a/validators/oracle_nft.ak +++ b/validators/oracle_nft.ak @@ -2,23 +2,21 @@ use aiken/collection/list use aiken_virtual_dex/types.{MintPolarity, RBurn, RMint} use cardano/assets.{PolicyId} use cardano/transaction.{Input, OutputReference, Transaction} -use vodka_mints.{check_policy_only_burn} +use vodka_mints.{check_policy_only_burn, only_minted_token} validator oracle_nft(utxo_ref: OutputReference) { mint(redeemer: MintPolarity, policy_id: PolicyId, tx: Transaction) { when redeemer is { RMint -> { - let Transaction { inputs, .. } = tx + let Transaction { inputs, mint, .. } = tx let hash_equal = fn(input: Input) { let hash = input.output_reference utxo_ref == hash } - let target_input_exist = list.find(inputs, hash_equal) - when target_input_exist is { - Some(_) -> True - None -> False - } + let target_input_exist = list.any(inputs, hash_equal) + let check_only_minted_token = only_minted_token(mint, policy_id, #"", 1) + target_input_exist && check_only_minted_token } RBurn -> check_policy_only_burn(tx.mint, policy_id) }