| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Cometa.Transaction.Plan
Description
Compose transaction requirements as owned values, then pass the complete
plan to build. Plans form an ordered monoid:
payTo first <> payTo second preserves payment order, and mempty adds no
requirements. Conflicts are reported when building.
payment output = payTo output <> validUntil 1000000
Synopsis
- data Plan
- payTo :: Output -> Plan
- spend :: Utxo -> Plan
- spendWith :: Utxo -> Maybe EncodedPlutusData -> Maybe EncodedPlutusData -> Plan
- type DeferredRedeemer = Transaction -> [Utxo] -> Either Error EncodedPlutusData
- spendWithDeferredRedeemer :: Utxo -> DeferredRedeemer -> Maybe EncodedPlutusData -> Plan
- mintWithDeferredRedeemer :: PolicyId -> [(AssetName, Int64)] -> DeferredRedeemer -> Plan
- certificateWithDeferredRedeemer :: Certificate -> DeferredRedeemer -> Plan
- withdrawWithDeferredRedeemer :: RewardAddress -> Word64 -> DeferredRedeemer -> Plan
- referenceInput :: Utxo -> Plan
- attachScript :: Script -> Plan
- mint :: AssetId -> Int64 -> Plan
- mintWithRedeemer :: AssetId -> Int64 -> EncodedPlutusData -> Plan
- metadata :: Word64 -> Metadatum -> Plan
- attachDatum :: EncodedPlutusData -> Plan
- certificate :: Certificate -> Plan
- certificateWithRedeemer :: Certificate -> EncodedPlutusData -> Plan
- withdraw :: RewardAddress -> Word64 -> Plan
- withdrawWithRedeemer :: RewardAddress -> Word64 -> EncodedPlutusData -> Plan
- requireSigner :: KeyHash Payment -> Plan
- validFrom :: Word64 -> Plan
- validUntil :: Word64 -> Plan
- requireGuard :: Credential Guard -> Plan
- guardWithRedeemer :: ScriptHash -> EncodedPlutusData -> Plan
- directDeposit :: RewardAddress -> Word64 -> Plan
- accountBalance :: RewardAddress -> BalanceInterval -> Plan
- startingAccountBalance :: RewardAddress -> BalanceInterval -> Plan
- donate :: Word64 -> Plan
- currentTreasuryValue :: Word64 -> Plan
- propose :: RewardAddress -> Action -> Anchor -> Plan
- proposeWithRedeemer :: RewardAddress -> Action -> Anchor -> EncodedPlutusData -> Plan
- proposeWithDeferredRedeemer :: RewardAddress -> Action -> Anchor -> DeferredRedeemer -> Plan
- vote :: Voter -> ActionId -> VotingProcedure -> Plan
- voteWithRedeemer :: Voter -> [(ActionId, VotingProcedure)] -> EncodedPlutusData -> Plan
- voteWithDeferredRedeemer :: Voter -> [(ActionId, VotingProcedure)] -> DeferredRedeemer -> Plan
- attachSubTransaction :: SubTransaction -> [Utxo] -> Plan
Documentation
Ordered immutable instructions. Composition preserves output order and combines requirements; conflicts are reported by the single build boundary. Function values have no structural equality or printable representation. Plan intentionally has neither Eq nor Show; its monoid laws concern behavior.
spendWith :: Utxo -> Maybe EncodedPlutusData -> Maybe EncodedPlutusData -> Plan Source #
Spend a resolved output with optional redeemer argument followed by optional datum witness. Inline datums do not need a separate datum witness.
type DeferredRedeemer = Transaction -> [Utxo] -> Either Error EncodedPlutusData Source #
Compute an argument from the balanced draft and its selected spending inputs in canonical order. The callback may run on every balancing iteration. It must be pure and deterministic; return an explicit error to abort the build. Values are ordinary owned snapshots and may be inspected without resource scopes.
spendWithDeferredRedeemer :: Utxo -> DeferredRedeemer -> Maybe EncodedPlutusData -> Plan Source #
Spend a resolved script output using a late argument and optional datum witness. Register each spending input once when using a deferred argument.
mintWithDeferredRedeemer :: PolicyId -> [(AssetName, Int64)] -> DeferredRedeemer -> Plan Source #
Mint or burn several assets under one policy using one late argument. Quantities for repeated names are combined; zero totals are omitted. Empty or entirely cancelled groups never call the callback. Register each policy once; combining separate deferred groups for one policy fails at build.
certificateWithDeferredRedeemer :: Certificate -> DeferredRedeemer -> Plan Source #
Append a certificate authorized by a late Plutus argument.
withdrawWithDeferredRedeemer :: RewardAddress -> Word64 -> DeferredRedeemer -> Plan Source #
Withdraw rewards using a late argument. Register each reward account once when using a deferred argument.
referenceInput :: Utxo -> Plan Source #
Resolve a reference input without consuming its value.
attachScript :: Script -> Plan Source #
Attach a native or Plutus script witness. Repeated attachments of the same language and script bytes contribute one witness, ordered by the first attachment. Different Plutus versions remain distinct.
mint :: AssetId -> Int64 -> Plan Source #
Mint positive or burn negative token units under a native policy. Ada and overflowing combined quantities are rejected when building.
mintWithRedeemer :: AssetId -> Int64 -> EncodedPlutusData -> Plan Source #
Mint or burn units under a Plutus policy using its redeemer argument.
metadata :: Word64 -> Metadatum -> Plan Source #
Require metadata under a label. Conflicting values fail when building.
attachDatum :: EncodedPlutusData -> Plan Source #
Attach a datum witness. Repeated exact CBOR encodings contribute one witness, including data supplied to spending inputs. First occurrence order is retained; different encodings remain distinct because their hashes differ.
certificate :: Certificate -> Plan Source #
Append a certificate without a script argument.
certificateWithRedeemer :: Certificate -> EncodedPlutusData -> Plan Source #
Append a certificate authorized by the supplied Plutus argument.
withdraw :: RewardAddress -> Word64 -> Plan Source #
Withdraw lovelace from a key-controlled reward account. Amounts above Int64 are rejected when building.
withdrawWithRedeemer :: RewardAddress -> Word64 -> EncodedPlutusData -> Plan Source #
Withdraw lovelace from a script reward account using its Plutus argument.
requireSigner :: KeyHash Payment -> Plan Source #
Require a payment key hash to sign the completed transaction.
validFrom :: Word64 -> Plan Source #
Inclusive lower validity slot. Composition takes the greatest lower bound.
validUntil :: Word64 -> Plan Source #
Exclusive upper validity slot. Composition takes the least upper bound.
requireGuard :: Credential Guard -> Plan Source #
Require a key or script guard. Key guards require signatures; script guards require a supplied script. Identical requirements are idempotent.
guardWithRedeemer :: ScriptHash -> EncodedPlutusData -> Plan Source #
Require a script guard with its guarding argument. Guard positions preserve insertion order, including ordinary required signers. Supply a Plutus V4 script for a top-level guard; attaching the script remains explicit.
directDeposit :: RewardAddress -> Word64 -> Plan Source #
Pay positive lovelace directly into a reward account. Repeated amounts add; each amount and their total must fit the native signed 64-bit balance range.
accountBalance :: RewardAddress -> BalanceInterval -> Plan Source #
Require the account balance when this transaction is applied. Identical intervals compose idempotently; differing intervals fail at build time.
startingAccountBalance :: RewardAddress -> BalanceInterval -> Plan Source #
Require the account balance before any subtransaction of the batch applies.
donate :: Word64 -> Plan Source #
Contribute lovelace to the treasury. Amounts add under composition, including explicit zero; the total must fit the native signed 64-bit balance range.
currentTreasuryValue :: Word64 -> Plan Source #
Declare the current treasury balance in lovelace. This is a ledger-state assertion, not a donation or a source of transaction funds. Repeating the same value is idempotent; conflicting values fail when building. Zero is explicit.
propose :: RewardAddress -> Action -> Anchor -> Plan Source #
Append a governance proposal using the configured protocol deposit. A
parameter-change or treasury-withdrawal action with a guardrails policy uses
the unit redeemer Constr 0 []. An action without a policy needs no redeemer.
Attach the policy script or resolve its reference input separately.
proposeWithRedeemer :: RewardAddress -> Action -> Anchor -> EncodedPlutusData -> Plan Source #
Append a proposal with an explicit guardrails argument. The action must name a policy; other actions fail when building. Proposal order determines the proposing redeemer index. Duplicate proposals fail rather than gaining a second index. The configured protocol snapshot supplies the deposit.
proposeWithDeferredRedeemer :: RewardAddress -> Action -> Anchor -> DeferredRedeemer -> Plan Source #
Append a proposal whose guardrails argument is computed from the balanced draft. The action must name a policy. The callback sees the proposal with its configured deposit and may run repeatedly as balancing converges.
vote :: Voter -> ActionId -> VotingProcedure -> Plan Source #
Cast a key-authorized vote. Identical voter/action instructions are idempotent; conflicting choices fail when building.
voteWithRedeemer :: Voter -> [(ActionId, VotingProcedure)] -> EncodedPlutusData -> Plan Source #
Cast several votes authorized by one voter and one immediate argument. A voter has one voting redeemer across all of its governance actions.
voteWithDeferredRedeemer :: Voter -> [(ActionId, VotingProcedure)] -> DeferredRedeemer -> Plan Source #
Cast several votes using one late argument for the voter. Empty groups do not invoke the callback. Register each deferred voter once per plan.
attachSubTransaction :: SubTransaction -> [Utxo] -> Plan Source #
Carry an independently built subtransaction, retaining its exact bytes and signatures. Supply every spending and reference input as a resolved snapshot. Spending inputs of different transaction levels must be disjoint. The parent funds the batch's net deficit and supplies the fee and collateral.