fix: withdraw kinda

This commit is contained in:
rvcas 2024-08-15 16:43:45 -04:00 committed by KtorZ
parent f86d550ca0
commit be7c0c8012
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
6 changed files with 90 additions and 17 deletions

View File

@ -13,4 +13,4 @@ requirements = []
source = "github" source = "github"
[etags] [etags]
"aiken-lang/stdlib@v2" = [{ secs_since_epoch = 1723741708, nanos_since_epoch = 340365000 }, "cdbbce58b61deb385e7ea787a2e0fc2dc8fe94db9999e0e6275bc9c70e5796be"] "aiken-lang/stdlib@v2" = [{ secs_since_epoch = 1723751815, nanos_since_epoch = 69229000 }, "cdbbce58b61deb385e7ea787a2e0fc2dc8fe94db9999e0e6275bc9c70e5796be"]

View File

@ -1,7 +1,7 @@
[ [
{ 0: h'30{{ withdraw.spend.hash }}{{ withdraw.spend.hash }}' { 0: h'30{{ withdraw.thing_spend.hash }}{{ withdraw.thing_spend.hash }}'
, 1: 1000000 , 1: 1000000
, 2: [1, 24(h'd87980')] , 2: [1, 24(h'd87980')]
, 3: 24(h'8203{{ withdraw.spend.cbor }}') , 3: 24(h'8203{{ withdraw.thing_spend.cbor }}')
} }
] ]

View File

@ -23,7 +23,7 @@
, 5: , 5:
{ h'E000000000000000000000000000000000000000000000000000000000': 14 { h'E000000000000000000000000000000000000000000000000000000000': 14
, h'F0{{ withdraw.withdraw.hash }}': 0 , h'F0{{ withdraw.thing_withdraw.hash }}': 0
} }
, 14: , 14:

File diff suppressed because one or more lines are too long

View File

@ -2,8 +2,7 @@ use aiken/collection/dict
use cardano/assets use cardano/assets
use cardano/credential.{Address, Script} use cardano/credential.{Address, Script}
use cardano/transaction.{ use cardano/transaction.{
InlineDatum, Input, Output, OutputReference, ScriptContext, ScriptInfo, InlineDatum, Input, Output, OutputReference, ScriptPurpose, Spend, Transaction,
ScriptPurpose, Spend, Spending, Transaction,
} }
validator simple_spend { validator simple_spend {

View File

@ -1,24 +1,25 @@
use aiken/collection/list use aiken/collection/list
use aiken/interval use aiken/interval
use cardano/credential.{Address, Inline, Pointer, Script, VerificationKey} use cardano/credential.{
use cardano/transaction.{ScriptContext, Withdrawing} Address, Credential, Inline, Pointer, Script, VerificationKey,
}
use cardano/transaction.{Transaction}
const only0s = #"00000000000000000000000000000000000000000000000000000000" const only0s = #"00000000000000000000000000000000000000000000000000000000"
const only1s = #"11111111111111111111111111111111111111111111111111111111" const only1s = #"11111111111111111111111111111111111111111111111111111111"
validator { validator thing {
fn spend(_tmp0: Void, _tmp1: Void, _ctx: Data) { spend(_datum: Option<Void>, _rdmr: Void, _oref: Data, _tx: Data) {
True True
} }
fn withdraw(_tmp0: Void, ctx: ScriptContext) { withdraw(_rdmr: Void, credential: Credential, transaction: Transaction) {
expect Withdrawing(Script(my_script_hash)) = ctx.info expect Script(my_script_hash) = credential
expect expect interval.entirely_before(1596059092000) == transaction.validity_range
interval.entirely_before(1596059092000) == ctx.transaction.validity_range
let addresses = list.map(ctx.transaction.outputs, fn(out) { out.address }) let addresses = list.map(transaction.outputs, fn(out) { out.address })
expect expect
Some( Some(
@ -45,8 +46,12 @@ validator {
) == list.at(addresses, 2) ) == list.at(addresses, 2)
expect expect
[Pair(Script(my_script_hash), 0), Pair(VerificationKey(only0s), 14)] == ctx.transaction.withdrawals [Pair(Script(my_script_hash), 0), Pair(VerificationKey(only0s), 14)] == transaction.withdrawals
True True
} }
else(_ctx) {
fail
}
} }