| License | Apache-2.0 |
|---|---|
| Safe Haskell | None |
| Language | GHC2021 |
Singular.Registry.TxBuilder.Publication
Description
Funding selection, reference-script publication and configuration identity for the registry commands. The publication arithmetic is shared with the command preview; every input and amount is derived from the supplied view.
Synopsis
- type SubmitSigned = ConwayTx -> IO ConwayTx
- registryIdOf :: CageConfig -> ByteString
- witnessScriptOf :: CageConfig -> ApplicationCodes -> Integer -> Script ConwayEra
- applicationPins :: ApplicationCodes -> ByteString -> (ShortByteString, ShortByteString)
- publishRefScript :: (Network, LedgerProvider NoWitness IO) -> SubmitSigned -> Addr -> Script ConwayEra -> IO (TxIn, TxOut ConwayEra)
- publishRefScriptReserving :: Set TxIn -> (Network, LedgerProvider NoWitness IO) -> SubmitSigned -> Addr -> Script ConwayEra -> IO (TxIn, TxOut ConwayEra)
- publishRefScriptTx :: Set TxIn -> Session NoWitness IO -> Addr -> Script ConwayEra -> IO (ConwayTx, TxOut ConwayEra)
- data PublicationFundingError
- = PublicationShortfall {
- pfeNeeded :: Integer
- pfeHeld :: Integer
- pfeLargest :: Integer
- | PublicationOversize { }
- = PublicationShortfall {
- selectPublicationInputs :: PParams ConwayEra -> Addr -> Script ConwayEra -> [(k, TxOut ConwayEra)] -> Either PublicationFundingError ([(k, TxOut ConwayEra)], TxOut ConwayEra, Integer)
- firstPublicationChange :: PParams ConwayEra -> Addr -> Script ConwayEra -> [(TxIn, TxOut ConwayEra)] -> Either PublicationFundingError (TxIn, ConwayTx, TxOut ConwayEra, [(TxIn, TxOut ConwayEra)], Integer)
- publicationFee :: Integer
- publicationMinChange :: Integer
- publicationRefCoin :: PParams ConwayEra -> Addr -> Script ConwayEra -> Integer
- publishStateRef :: CageConfig -> (Network, LedgerProvider NoWitness IO) -> SubmitSigned -> Addr -> IO (TxIn, TxOut ConwayEra)
- publishStateRefReserving :: Set TxIn -> CageConfig -> (Network, LedgerProvider NoWitness IO) -> SubmitSigned -> Addr -> IO (TxIn, TxOut ConwayEra)
- stateRefIn :: CageConfig -> [(TxIn, TxOut ConwayEra)] -> Maybe (TxIn, TxOut ConwayEra)
- adaOnlyOut :: TxOut ConwayEra -> Bool
- selectFunding :: Maybe TxIn -> [(TxIn, TxOut ConwayEra)] -> Either String (TxIn, TxOut ConwayEra)
Submission
type SubmitSigned = ConwayTx -> IO ConwayTx Source #
Sign a built transaction with the payer's key, submit it, and wait for it. The caller owns its own signing key and its own confirmation discipline, so it supplies this rather than the module guessing either.
Derived identity
registryIdOf :: CageConfig -> ByteString Source #
The registry id a witness policy is parameterized by: the state policy plus the token name this cage's seed determined.
witnessScriptOf :: CageConfig -> ApplicationCodes -> Integer -> Script ConwayEra Source #
The witness policy script of one token kind.
Arguments
| :: ApplicationCodes | |
| -> ByteString | The registry id: state script hash then boot token name |
| -> (ShortByteString, ShortByteString) | Application, active |
The two pins a registry identity carries (#157 genesis-policy-pins), derived
from the supplied application and token-policy code: the application validator
for the approval, and witness(1, registry) for the active token.
The registry id the witness policies are parameterized by depends on the state script hash and the boot seed, so this takes them directly rather than a configuration that does not exist yet.
Reference outputs
publishRefScript :: (Network, LedgerProvider NoWitness IO) -> SubmitSigned -> Addr -> Script ConwayEra -> IO (TxIn, TxOut ConwayEra) Source #
Publish one script as a reference output at the payer's own address.
publishRefScriptReserving :: Set TxIn -> (Network, LedgerProvider NoWitness IO) -> SubmitSigned -> Addr -> Script ConwayEra -> IO (TxIn, TxOut ConwayEra) Source #
publishRefScript, never spending a reserved output (#299): a caller
that has chosen the seed of a later boot keeps it unspent while it
publishes. The largest ada-only output that is not reserved funds it.
publishRefScriptTx :: Set TxIn -> Session NoWitness IO -> Addr -> Script ConwayEra -> IO (ConwayTx, TxOut ConwayEra) Source #
The unsigned publication of one reference script, funded by the shortest largest-first prefix of the ada-only outputs outside the reservation, and the reference output it creates.
data PublicationFundingError Source #
Why one publication cannot be funded: too little in total, or a covering prefix too large for the protocol maximum transaction size.
Constructors
| PublicationShortfall | |
Fields
| |
| PublicationOversize | |
Instances
| Show PublicationFundingError Source # | |
Defined in Singular.Registry.TxBuilder.Publication Methods showsPrec :: Int -> PublicationFundingError -> ShowS Source # show :: PublicationFundingError -> String Source # showList :: [PublicationFundingError] -> ShowS Source # | |
| Eq PublicationFundingError Source # | |
Defined in Singular.Registry.TxBuilder.Publication Methods (==) :: PublicationFundingError -> PublicationFundingError -> Bool Source # (/=) :: PublicationFundingError -> PublicationFundingError -> Bool Source # | |
selectPublicationInputs :: PParams ConwayEra -> Addr -> Script ConwayEra -> [(k, TxOut ConwayEra)] -> Either PublicationFundingError ([(k, TxOut ConwayEra)], TxOut ConwayEra, Integer) Source #
One owner of the publication arithmetic (#406): the shortest largest-first prefix of the permitted outputs whose total covers the reference output plus the fee plus a change strictly above the minimum, with the inputs, the reference output and the change; or the shortfall it names (needed total, held total, largest output). A covering prefix whose transaction would exceed the protocol maximum size is refused up front, naming size and limit, so a wallet of many dust outputs never reaches submission.
The permitted outputs are ada-only with no reference script, the seed withheld before the boot. A covering output spends exactly one input and it is the largest; otherwise no output that is not needed is spent.
firstPublicationChange :: PParams ConwayEra -> Addr -> Script ConwayEra -> [(TxIn, TxOut ConwayEra)] -> Either PublicationFundingError (TxIn, ConwayTx, TxOut ConwayEra, [(TxIn, TxOut ConwayEra)], Integer) Source #
The change output a first publication makes from the whole wallet, and
the seed it becomes (#406 slice 2): the shortest largest-first prefix of
all the ada-only outputs (nothing withheld) funds the state publication,
its change at index 1 is the chained seed. The body is exactly the one
publishRefScriptTx builds from the same view (flat fee, no validity
interval), so the transaction id — and the token it derives — is the same
in preview and in create. The arithmetic is selectPublicationInputs's;
this accessor adds only the body and its id.
publicationFee :: Integer Source #
The flat fee a publication pays, and the change it must leave strictly above. One owner (#406): the builder and the whole-run judgement share these with the pure selection below, never a second copy.
publicationMinChange :: Integer Source #
publicationRefCoin :: PParams ConwayEra -> Addr -> Script ConwayEra -> Integer Source #
The reference output a publication creates at the payer's address: the ledger minimum for the script plus one million lovelace. One owner: both the selection and the whole-run need share it.
publishStateRef :: CageConfig -> (Network, LedgerProvider NoWitness IO) -> SubmitSigned -> Addr -> IO (TxIn, TxOut ConwayEra) Source #
Publish the state validator as a reference output, once, before any boot (#177).
A registry boots only by reference: the boot resolves the state
validator through a publication in the payer's wallet and is refused
StateValidatorNotPublished without one, because that validator is
fifteen kilobytes against a sixteen-kilobyte transaction cap. A session
calls this before its first boot.
Idempotent by discovery: a wallet that already holds the publication gets it back rather than a second one, so a harness that boots several cages publishes once.
publishStateRefReserving :: Set TxIn -> CageConfig -> (Network, LedgerProvider NoWitness IO) -> SubmitSigned -> Addr -> IO (TxIn, TxOut ConwayEra) Source #
publishStateRef, never spending a reserved output (#299): an
existing publication is returned as before, and a new one is funded
outside the reservation.
stateRefIn :: CageConfig -> [(TxIn, TxOut ConwayEra)] -> Maybe (TxIn, TxOut ConwayEra) Source #
An output among these that publishes this cage's state validator.
adaOnlyOut :: TxOut ConwayEra -> Bool Source #
Can this output fund a transaction? It must hold ada and nothing else, because it doubles as collateral, and it must not be one of the published reference outputs, because a transaction may not both spend an output and reference it.
selectFunding :: Maybe TxIn -> [(TxIn, TxOut ConwayEra)] -> Either String (TxIn, TxOut ConwayEra) Source #
The wallet output a transaction is funded and collateralised from: the one the caller chose, which must be an ada-only output of the wallet, or else the largest ada-only output. A caller that chose none still gets the output least likely to leave the change under its minimum.