aiken_design_patterns/singular_utxo_indexer
Functions
one_to_one(
input_index: Int,
output_index: Int,
own_ref: OutputReference,
inputs: List<Input>,
outputs: List<Output>,
double_satisfaction_prevented: Bool,
validation_logic: fn(Input, Output) -> Bool,
) -> Bool
Helper function to be defined in the spending endpoint of your contract, for
appointing an input at input_index against an output at output_index. By
including this in your spending endpoint, you’ll get an efficient access to
your input, and its corresponding output.
Within the function you pass as validation_logic, you have access to the
picked input and output.
Apart from validation_logic, the only other validation this function
performs for you is the equality of the picked input’s output reference with
the one extracted from ScriptInfo.
double_satisfaction_prevented is a required Bool, which is just a
reminder that this function does NOT cover the
double satisfaction
vulnerability out-of-the-box.
one_to_many(
input_index: Int,
output_indices: List<Int>,
own_ref: OutputReference,
inputs: List<Input>,
outputs: List<Output>,
double_satisfaction_prevented: Bool,
input_collective_outputs_validator: fn(Input, List<Output>) -> Bool,
input_output_validator: fn(Input, Int, Output) -> Bool,
) -> Bool
Helper function for appointing an input against a set of outputs in a
transaction. Similar to one_to_one, this function also
validates the spent UTxO’s output reference matches the one found using the
input index.
Required validation functions are provided with:
Inputitself, output index, andOutputitself (this validation is executed for each output)Inputitself, and the list of allOutputs (this validation is executed only once)
Here we also have the double_satisfaction_prevented argument as a mere
reminder that this function does not cover double satisfaction on its own.