Fix remaining acceptance tests to be V3-compatible
This commit is contained in:
@@ -1,29 +1,33 @@
|
||||
use aiken/dict
|
||||
use aiken/list
|
||||
use aiken/transaction.{Output, OutputReference, ScriptContext}
|
||||
use aiken/transaction/value.{PolicyId}
|
||||
use aiken/collection/dict
|
||||
use aiken/collection/list
|
||||
use cardano/assets.{PolicyId}
|
||||
use cardano/transaction.{Output, OutputReference, Transaction}
|
||||
|
||||
const my_policy_id: PolicyId = #"0000000000"
|
||||
|
||||
pub fn has_policy_id(self: Output, policy_id: PolicyId) -> Bool {
|
||||
self.value
|
||||
|> value.tokens(policy_id)
|
||||
|> assets.tokens(policy_id)
|
||||
|> dict.is_empty
|
||||
|> not
|
||||
}
|
||||
|
||||
validator foo {
|
||||
spend(_datum: Data, _redeemer: Data, o_ref: Data, tx: Transaction) -> Bool {
|
||||
ctx.transaction.outputs
|
||||
spend(_datum: Option<Data>, _redeemer: Data, _o_ref: Data, self: Transaction) {
|
||||
self.outputs
|
||||
|> list.any(has_policy_id(_, my_policy_id))
|
||||
}
|
||||
|
||||
else(_) {
|
||||
fail
|
||||
}
|
||||
}
|
||||
|
||||
validator bar(output_reference: OutputReference) {
|
||||
mint(_redeemer: Void, _policy_id: Data, tx: Transaction) -> Bool {
|
||||
mint(_redeemer: Void, _policy_id, self: Transaction) {
|
||||
when
|
||||
list.find(
|
||||
ctx.transaction.inputs,
|
||||
self.inputs,
|
||||
fn(input) { input.output_reference == output_reference },
|
||||
)
|
||||
is {
|
||||
@@ -31,4 +35,8 @@ validator bar(output_reference: OutputReference) {
|
||||
None -> False
|
||||
}
|
||||
}
|
||||
|
||||
else(_) {
|
||||
fail
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user