diff --git a/lib/utils.ak b/lib/utils.ak index 1d65565..ebf8bf6 100644 --- a/lib/utils.ak +++ b/lib/utils.ak @@ -1,6 +1,6 @@ use aiken/hash.{Blake2b_224, Hash} use aiken/list.{filter} -use aiken/transaction.{Input, Output, ScriptContext, Spend, find_input} as tx +use aiken/transaction.{Input, Output, ScriptContext, Spend, find_input} use aiken/transaction/credential.{VerificationKey} pub type POSIXTime = @@ -25,14 +25,8 @@ pub fn find_own_input(ctx: ScriptContext) -> Option { } } -// getContinuingOutputs :: ScriptContext -> [TxOut] -// getContinuingOutputs ctx | Just TxInInfo{txInInfoResolved=TxOut{txOutAddress}} <- findOwnInput ctx = filter (f txOutAddress) (txInfoOutputs $ scriptContextTxInfo ctx) -// where -// f addr TxOut{txOutAddress=otherAddress} = addr == otherAddress -// getContinuingOutputs _ = traceError "Lf" -- "Can't get any continuing outputs" - pub fn get_continuing_outputs(ctx: ScriptContext) -> List { expect Some(input) = find_own_input(ctx) let script_address = input.output.address - filter(ctx.transaction.outputs, fn(o) { o.address == script_address }) + filter(ctx.transaction.outputs, fn(o: Output) { o.address == script_address }) } diff --git a/validators/samples/minting.ak b/validators/samples/minting.ak index 9b9fd32..8704130 100644 --- a/validators/samples/minting.ak +++ b/validators/samples/minting.ak @@ -1,5 +1,5 @@ use aiken/dict as dict -use aiken/list as list +use aiken/list.{any} as list use aiken/transaction.{Input, OutputReference, ScriptContext, Transaction} as tx use aiken/transaction/value.{AssetName, MintedValue, PolicyId} @@ -29,7 +29,7 @@ validator(token_name: ByteArray, oref: OutputReference) { } fn has_utxo(oref: OutputReference, inputs: List) { - list.any(inputs, fn(input) { input.output_reference == oref }) + any(inputs, fn(input) { input.output_reference == oref }) } fn check_mint(cs: PolicyId, tn: AssetName, mint: MintedValue, mint_qty: Int) { diff --git a/validators/samples/typed.ak b/validators/samples/typed.ak index 7d41db6..64be8af 100644 --- a/validators/samples/typed.ak +++ b/validators/samples/typed.ak @@ -1,5 +1,4 @@ use aiken/transaction.{ScriptContext} -use utils.{trace_if_false} validator { fn simple_typed(_datum: Void, redeemer: Int, _ctx: ScriptContext) -> Bool { diff --git a/validators/samples/vesting.ak b/validators/samples/vesting.ak index 9c07361..afa7e36 100644 --- a/validators/samples/vesting.ak +++ b/validators/samples/vesting.ak @@ -1,7 +1,7 @@ use aiken/interval.{Finite} use aiken/list use aiken/transaction.{ScriptContext, Transaction, ValidityRange} -use utils.{POSIXTime, PubKeyHash, trace_if_false} +use utils.{POSIXTime, PubKeyHash} type VestingDatum { beneficiary: PubKeyHash, @@ -33,13 +33,13 @@ fn must_start_after(range: ValidityRange, maturity: POSIXTime) { validator(beneficiary: PubKeyHash) { fn param_vesting( - datum: POSIXTime, + maturity: POSIXTime, _redeemer: Void, ctx: ScriptContext, ) -> Bool { - must_be_signed_by(ctx.transaction, datum.beneficiary)? && must_start_after( + must_be_signed_by(ctx.transaction, beneficiary)? && must_start_after( ctx.transaction.validity_range, - datum.maturity, + maturity, )? } }