Skip to content

Commit

Permalink
update mint methods
Browse files Browse the repository at this point in the history
  • Loading branch information
shan501 committed Dec 16, 2024
1 parent 1f59e43 commit 94c8f05
Showing 1 changed file with 11 additions and 21 deletions.
32 changes: 11 additions & 21 deletions validators/forwards.ak
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,10 @@ fn cancel_forward_burn_valid(
policy_id: PolicyId,
issuer_address_hash: VerificationKeyHash,
) -> Bool {
let issuer_burnt = burn_valid(transaction, policy_id, issuer_address_hash, 1)
let asset_burnt = burn_valid(transaction, policy_id, asset_name, 1)
let expected_burnt =
[(policy_id, asset_name, -1), (policy_id, issuer_address_hash, -1)]

issuer_burnt && asset_burnt
expected_burnt == flatten(transaction.mint)
}

fn liquidate_burn_valid(
Expand All @@ -281,31 +281,21 @@ fn liquidate_burn_valid(
issuer_address_hash: VerificationKeyHash,
obligee_address_hash: VerificationKeyHash,
) -> Bool {
let issuer_burnt = burn_valid(transaction, policy_id, issuer_address_hash, 1)
let obligee_burnt =
burn_valid(transaction, policy_id, obligee_address_hash, 1)
let expected_burnt =
[
(policy_id, issuer_address_hash, -1),
(policy_id, obligee_address_hash, -1),
]

issuer_burnt && obligee_burnt
expected_burnt == flatten(transaction.mint)
}

fn consume_agreement_burn_valid(
transaction: Transaction,
policy_id: PolicyId,
address_hash: VerificationKeyHash,
) -> Bool {
burn_valid(transaction, policy_id, address_hash, 1)
}

fn burn_valid(
transaction: Transaction,
policy_id: PolicyId,
asset_name: AssetName,
burnt_amount: Int,
) -> Bool {
let Transaction { mint, .. } = transaction

let mint_asset = [(policy_id, asset_name, -burnt_amount)]
let valid_mint = mint_asset == flatten(mint)
let expected_burnt = [(policy_id, address_hash, -1)]

valid_mint
expected_burnt == flatten(transaction.mint)
}

0 comments on commit 94c8f05

Please sign in to comment.