Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
caike committed Jul 12, 2024
1 parent afbee63 commit 77f8b94
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 1 addition & 3 deletions validators/mint.ak
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ validator(token_name: ByteArray, utxo_ref: OutputReference) {

let Transaction { inputs, mint, .. } = transaction

let asset_pairs =
expect [Pair(asset_name, amount)] =
mint
|> value.from_minted_value
|> value.tokens(policy_id)
|> dict.to_pairs()

expect [Pair(asset_name, amount)] = asset_pairs

when rdmr is {
Mint -> {
expect Some(_input) =
Expand Down
4 changes: 1 addition & 3 deletions validators/ppp_mint.ak
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ validator(utxo_ref: OutputReference, token_name: ByteArray) {
let ScriptContext { transaction: Transaction { inputs, mint, .. }, .. } =
ctx
// Pattern-match to get the minted tokens and Fail if it's not a single asset minted
let asset_pairs =
expect [Pair(asset_name, amount)] =
mint |> from_minted_value() |> tokens(policy_id) |> to_pairs()

expect [Pair(asset_name, amount)] = asset_pairs

// Check if the transaction consumes the utxo_ref passed as parameter
let is_ouput_consumed =
list.any(inputs, fn(input) { input.output_reference == utxo_ref })
Expand Down

0 comments on commit 77f8b94

Please sign in to comment.