| License | Apache-2.0 |
|---|---|
| Safe Haskell | None |
| Language | GHC2021 |
Singular.Registry.TxBuilder.Internal.Lookup
Description
One owner for where a builder finds its inputs and closes its
transaction: UTxO lookup by input, state and request
(findUtxoByTxIn, findStateUtxo, findRequestUtxos), spending-index
computation, script evaluation and balancing (evaluateAndBalance),
script-integrity hashing, rejected-row refund outputs
(computeRefund), and POSIX-time to slot conversion
(currentPosixMs, trySlots).
This is the lookup-and-balance owner extracted from
Singular.Registry.TxBuilder.Internal; the public module re-exports
it and is its only intended consumer surface.
Synopsis
- findUtxoByTxIn :: TxIn -> [(TxIn, TxOut ConwayEra)] -> Maybe (TxIn, TxOut ConwayEra)
- findStateUtxo :: PolicyID -> TokenId -> [(TxIn, TxOut ConwayEra)] -> Maybe (TxIn, TxOut ConwayEra)
- findRequestUtxos :: TokenId -> [(TxIn, TxOut ConwayEra)] -> [(TxIn, TxOut ConwayEra)]
- spendingIndex :: TxIn -> Set TxIn -> Word32
- computeScriptIntegrity :: PParams ConwayEra -> Redeemers ConwayEra -> StrictMaybe ScriptIntegrityHash
- evaluateAndBalance :: Session NoWitness IO -> PParams ConwayEra -> [(TxIn, TxOut ConwayEra)] -> Addr -> ConwayTx -> IO ConwayTx
- evaluateAndBalanceReferencing :: Session NoWitness IO -> PParams ConwayEra -> [(TxIn, TxOut ConwayEra)] -> [(TxIn, TxOut ConwayEra)] -> Addr -> ConwayTx -> IO ConwayTx
- placeholderExUnits :: ExUnits
- currentPosixMs :: IO Integer
- trySlots :: Session NoWitness IO -> [Integer] -> IO SlotNo
- tryUpperSlots :: Session NoWitness IO -> [Integer] -> IO SlotNo
- trySync :: IO a -> IO (Either SomeException a)
- computeRefund :: PParams ConwayEra -> Network -> Integer -> TxOut ConwayEra -> TxOut ConwayEra
UTxO lookup
findUtxoByTxIn :: TxIn -> [(TxIn, TxOut ConwayEra)] -> Maybe (TxIn, TxOut ConwayEra) Source #
Find a UTxO by its TxIn.
findStateUtxo :: PolicyID -> TokenId -> [(TxIn, TxOut ConwayEra)] -> Maybe (TxIn, TxOut ConwayEra) Source #
Find the state UTxO for a token.
findRequestUtxos :: TokenId -> [(TxIn, TxOut ConwayEra)] -> [(TxIn, TxOut ConwayEra)] Source #
Find all request UTxOs for a token.
Indexing
spendingIndex :: TxIn -> Set TxIn -> Word32 Source #
Compute the spending index of a TxIn.
Script integrity
computeScriptIntegrity :: PParams ConwayEra -> Redeemers ConwayEra -> StrictMaybe ScriptIntegrityHash Source #
Compute the ScriptIntegrityHash.
Evaluate and balance
Arguments
| :: Session NoWitness IO | |
| -> PParams ConwayEra | |
| -> [(TxIn, TxOut ConwayEra)] | All input UTxOs (fee + script) |
| -> Addr | Change address |
| -> ConwayTx | Unbalanced tx with placeholder ExUnits |
| -> IO ConwayTx |
Evaluate script execution units and balance a transaction.
evaluateAndBalanceReferencing Source #
Arguments
| :: Session NoWitness IO | |
| -> PParams ConwayEra | |
| -> [(TxIn, TxOut ConwayEra)] | All input UTxOs (fee + script) |
| -> [(TxIn, TxOut ConwayEra)] | The resolved reference outputs |
| -> Addr | Change address |
| -> ConwayTx | Unbalanced tx with placeholder ExUnits |
| -> IO ConwayTx |
evaluateAndBalance for a transaction that reads scripts from
reference outputs (#300): the resolved outputs are handed to the balancer,
which charges the ledger's per-byte tier for every reference-script byte the
transaction references, exactly as the node will.
placeholderExUnits :: ExUnits Source #
Placeholder execution units used in the initial unbalanced transaction.
Time and slot helpers
currentPosixMs :: IO Integer Source #
Get current POSIX time in milliseconds.
trySlots :: Session NoWitness IO -> [Integer] -> IO SlotNo Source #
Try converting successive POSIX ms values to slots, returning the first that succeeds.
tryUpperSlots :: Session NoWitness IO -> [Integer] -> IO SlotNo Source #
Try converting successive POSIX ms values to slots, rounding down, and return the first that succeeds: an upper validity bound.
trySlots rounds up, which is right for a lower bound but not for an upper
one. Rounding down never puts the upper bound later than its chosen POSIX
candidate. NOTE030 opens the pinned final era, preserving this rounding rule
and the caller's candidate windows. Synchronous conversion failures still
try the next candidate; cancellation escapes.
trySync :: IO a -> IO (Either SomeException a) Source #
Run an action, returning its synchronous failure; an asynchronous exception — a cancellation, a timeout — is rethrown, never taken for a conversion that failed and so never answered by a fallback.
Refund computation
computeRefund :: PParams ConwayEra -> Network -> Integer -> TxOut ConwayEra -> TxOut ConwayEra Source #
Compute a rejected row's refund output (NOTE-014 item A2, delegated
routing): exactly `input lovelace − tip`, floored at min-UTxO with the
top-up funded visibly. No fee share is deducted here and none is
invented (fees ride funding inputs; the validator pins per-owner floors
and exact lock accumulation instead of an aggregate envelope). THE shared
helper for every rejected-refund emission — Reject and manual paths
call it; processed rows emit no refunds at all (their bond locks).