52 lines
1.1 KiB
Plaintext
52 lines
1.1 KiB
Plaintext
use aiken/list
|
|
use aiken/string
|
|
use aiken/hash.{Blake2b_224, Hash}
|
|
use aiken/transaction.{ScriptContext}
|
|
use aiken/transaction/credential.{VerificationKey}
|
|
|
|
pub type Datum {
|
|
owner: Hash<Blake2b_224, VerificationKey>,
|
|
}
|
|
|
|
pub type Redeemer {
|
|
msg: ByteArray,
|
|
}
|
|
|
|
pub type Dummy {
|
|
Mannequin {
|
|
hands: ByteArray,
|
|
feet: Int,
|
|
}
|
|
Doll {
|
|
hands: ByteArray,
|
|
datum: Datum,
|
|
feet: Int,
|
|
}
|
|
Puppet {
|
|
hands: ByteArray,
|
|
dummy: Dummy,
|
|
}
|
|
Statue {
|
|
hands: ByteArray,
|
|
boots: ByteArray,
|
|
}
|
|
}
|
|
|
|
pub fn spending(datum: Datum, redeemer: Redeemer, context: Dummy) -> Bool {
|
|
let must_say_hello = string.from_bytearray(redeemer.msg) == "Hello, World!"
|
|
let must_be_signed = #(1, datum, #(redeemer, context ))
|
|
// context.transaction.extra_signatories
|
|
// |> list.any(fn(vk) { vk == datum.owner })
|
|
|
|
when must_be_signed is {
|
|
#(a, b, #(c, Mannequin{ feet, ..})) -> feet == 2
|
|
_ -> False
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
test spend_1(){
|
|
spending(Datum{ owner: #[254]}, Redeemer{msg: string.to_bytearray("Hello, World!")}, Mannequin{hands: #[], feet: 2}) == True
|
|
} |