fix: change in scope was applied in wrong place in pattern_ir for constr expect
This commit is contained in:
41
examples/acceptance_tests/077/validators/spend.ak
Normal file
41
examples/acceptance_tests/077/validators/spend.ak
Normal file
@@ -0,0 +1,41 @@
|
||||
use aiken/list.{find, foldr}
|
||||
use aiken/transaction.{Input, ScriptContext, Spend}
|
||||
use aiken/transaction/value.{add, zero}
|
||||
|
||||
validator staking {
|
||||
fn(_datum: Void, _redeemer: Void, context: ScriptContext) -> Bool {
|
||||
expect Spend(ref) = context.purpose
|
||||
|
||||
expect Some(i) =
|
||||
find(context.transaction.inputs, fn(x) { x.output_reference == ref })
|
||||
let Input { output, .. } = i
|
||||
let staking_addr = output.address
|
||||
|
||||
let v_in =
|
||||
foldr(
|
||||
context.transaction.inputs,
|
||||
fn(x, y) {
|
||||
if x.output.address == staking_addr {
|
||||
add(x.output.value, y)
|
||||
} else {
|
||||
y
|
||||
}
|
||||
},
|
||||
zero(),
|
||||
)
|
||||
|
||||
let v_out =
|
||||
foldr(
|
||||
context.transaction.outputs,
|
||||
fn(x, y) {
|
||||
if x.address == staking_addr {
|
||||
add(x.value, y)
|
||||
} else {
|
||||
y
|
||||
}
|
||||
},
|
||||
zero(),
|
||||
)
|
||||
v_in == v_out
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user