Skip to content

Commit

Permalink
feat: more progress on Spend from account
Browse files Browse the repository at this point in the history
  • Loading branch information
MicroProofs committed Dec 23, 2023
1 parent 9b0c7a9 commit 808f66b
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions validators/account.ak
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ type State {

type Intention {
condition: IntentionCondition,
/// The Ints in value leaving should always be negative
value_leaving: List<(PolicyId, AssetName, Int)>,
nonce: OutputReference,
/// User to track ordering number. Useful for dexes to ensure
Expand Down Expand Up @@ -204,6 +205,48 @@ validator {
ref_input

if address.payment_credential == pc {
expect [(_, 1)] =
value |> value.tokens(own_policy_id) |> dict.to_list

expect InlineDatum(datum) = datum

expect ControlState { owner }: State = datum

expect [account_intention_list, ..other_account_intentions] =
acc

let account_value_used_nonces =
list.foldl(
inputs,
(value.zero(), 0),
fn(input: Input, acc) {
let Input { output, .. } = input
if output.address == address {
let Output { value, datum, .. } = output

expect InlineDatum(dat) = datum

let (acc_value, unused_nonces) = acc

let combined_value = value.merge(acc_value, value)

let non_datum_return =
fn() { (combined_value, unused_nonces) }

builtin.choose_data(
dat,
(combined_value, unused_nonces + 1),
non_datum_return(),
non_datum_return(),
non_datum_return(),
non_datum_return(),
)
} else {
acc
}
},
)

todo
} else {
acc
Expand Down

0 comments on commit 808f66b

Please sign in to comment.