Skip to content

Commit

Permalink
chore: update some parts of the code for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
MicroProofs committed Jun 17, 2023
1 parent ae5bd9a commit 06f6310
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions validators/stakinator3000.ak
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ type State {
stake_registration: PosixTime,
}

type OwnerCheck {
owner: Owner,
field1: Data,
field2: Data,
}

type NFTAsset {
policy: PolicyId,
asset: AssetName,
Expand Down Expand Up @@ -89,6 +95,7 @@ validator(state_token: NFTAsset) {

let Address { payment_credential, .. } = in_address

// Some destructuring fields in the script context
expect ScriptCredential(own_pkh) = payment_credential

let State { owner, redelegation_condition, .. } = state
Expand Down Expand Up @@ -136,6 +143,7 @@ validator(state_token: NFTAsset) {
// Check input contains parameterized NFT
expect True = quantity_of(in_value, nft_policy, nft_asset) == 1

// Validates non-recursive conditions
let tx_condition_runner =
fn(cond: TxCondition) -> Bool {
when cond is {
Expand Down Expand Up @@ -241,14 +249,16 @@ validator(state_token: NFTAsset) {
) == 1
}

// State token is spent and spend validator will perform owner check
if list.any(inputs, find_predicate) {
True
} else {
// Not spend so we must check for owner
expect Some(Input { output: Output { datum, .. }, .. }) =
list.find(reference_inputs, find_predicate)

expect InlineDatum(datum) = datum
expect State { owner, .. }: State = datum
expect OwnerCheck { owner, .. }: OwnerCheck = datum

// Checks current owner is valid
when owner is {
Expand Down Expand Up @@ -480,12 +490,6 @@ fn validate_other_conditions(
}
}

type OwnerCheck {
owner: Owner,
field1: Data,
field2: Data,
}

// Check each minted token name is in the expected list, has quantity of 1,
// and has a corresponding ouput with datum containing token name.
// Alternatively allow for token burning
Expand Down

0 comments on commit 06f6310

Please sign in to comment.