aiken_design_patterns/multi_utxo_indexer_one_to_many

Functions

withdraw_no_redeemer(
  input_output_validator: fn(Int, Input, Int, Output) -> Bool,
  input_collective_outputs_validator: fn(Int, Input, List<Output>) -> Bool,
  collective_inputs_outputs_validator: fn(List<Input>, List<Output>) -> Bool,
  outer_indices: Pairs<Int, List<Int>>,
  total_input_count: Int,
  stake_cred: Credential,
  tx: Transaction,
) -> Bool

Use this function inside your withdrawal script to validate all the inputs coming from the script’s spend endpoint. This is an important detail, as the validator needs to guarantee an exact number of inputs are spent.

If you want to work with an external staking script, consider using withdraw_with_redeemer.

The arguments are:

  1. Validation function on each input, and each of its corresponding outputs
  2. Validation function on each input, against all its outputs
  3. Validation function on all the inputs and all the outputs
  4. Pairs of indices, mapping each input to multiple outputs
  5. Total number of inputs
  6. Staking credential of the wrapping validator (provided by withdraw). Note that in this variant, it can only validate spending the UTxOs from its own spending endpoint
  7. Transaction provided by the validator

For validation functions, corresponding indices of inputs/outputs are also provided in these functions.

withdraw_with_redeemer(
  spend_redeemer_coercer_and_stake_credential_extractor: fn(Redeemer) ->
    (a, Credential),
  input_output_validator: fn(Int, Input, a, Int, Output) -> Bool,
  input_collective_outputs_validator: fn(Int, Input, a, List<Output>) -> Bool,
  collective_inputs_outputs_validator: fn(List<Input>, List<Output>) -> Bool,
  indices: Pairs<Int, List<Int>>,
  total_script_inputs: Int,
  stake_cred: Credential,
  tx: Transaction,
) -> Bool

A variant of withdraw_no_redeemer. The difference here is that it gives access to the spend redeemers to your validation functions.

Note that your spend redeemers are expected to carry the Credential to the resulting staking script (which is the purpose of the first argument).

The arguments are:

  1. Validation function on each input, and each of its corresponding outputs
  2. Validation function on each input, against all its outputs
  3. Validation function on all the inputs and all the outputs
  4. Pairs of indices, mapping each input to multiple outputs
  5. Total number of script inputs
  6. Staking credential of the wrapping validator (provided by withdraw)
  7. Transaction provided by the validator

For validation functions, corresponding indices of inputs/outputs are also provided in these functions.

Under the hood, one other difference is that here, instead of traversing all the inputs, there are two traversals: one over the redeemers, and another over the indices.

Search Document