Skip to content

Commit

Permalink
fix: total output count was passed by mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
keyan-m committed Apr 18, 2024
1 parent 34138c9 commit 9bc8585
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/aiken-design-patterns/singular-utxo-indexer-one-to-many.ak
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,18 @@ pub fn spend(

expect input_validator(input)?

let output_count = list.length(outputs)

let (_, out_utxos) =
let (_, out_utxos, output_count) =
list.foldr(
out_ixs,
(output_count, []),
fn(curr_ix, acc_tuple) {
let (prev_ix, acc) = acc_tuple
(list.length(outputs), [], 0),
fn(curr_ix, acc_triplet) {
let (prev_ix, acc, count) = acc_triplet
// Folding from right and expecting ascending order from head to tail
// (for a more intuitive API) to disallow duplicates.
if curr_ix < prev_ix {
expect Some(out_utxo) = outputs |> list.at(curr_ix)
expect input_output_validator(in_utxo, out_utxo)?
(curr_ix, acc |> list.push(out_utxo))
(curr_ix, acc |> list.push(out_utxo), count + 1)
} else {
fail @"Output indices must be in ascending order"
}
Expand Down

0 comments on commit 9bc8585

Please sign in to comment.