cometa-0.1.0.0: Idiomatic Haskell bindings to cardano-c
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cometa.SubTransaction.Plan

Description

Compose a sub-transaction intent with explicit resolved inputs. Building preserves the specified inputs and outputs; it adds no fee, collateral or change. Sign and attach the resulting sub-transaction separately.

import qualified Cometa.SubTransaction.Plan as Plan

payment input output = Plan.spend input <> Plan.payTo output
Synopsis

Documentation

data Plan Source #

Ordered intent instructions. Composition combines mint quantities and validity requirements, preserving outputs and certificate order. Conflicting arguments or snapshots fail when building. Plans contain functions, so their monoid laws concern behavior rather than structural equality.

Instances

Instances details
Monoid Plan Source # 
Instance details

Defined in Cometa.Internal.SubTransactionPlan

Methods

mempty :: Plan #

mappend :: Plan -> Plan -> Plan #

mconcat :: [Plan] -> Plan #

Semigroup Plan Source # 
Instance details

Defined in Cometa.Internal.SubTransactionPlan

Methods

(<>) :: Plan -> Plan -> Plan #

sconcat :: NonEmpty Plan -> Plan #

stimes :: Integral b => b -> Plan -> Plan #

type DeferredRedeemer = Transaction -> [Utxo] -> Either Error EncodedPlutusData Source #

Compute an argument once from the local draft: its fee is zero, inputs and redeemer indices are local to the sub-transaction, and resolved spending inputs are in canonical order. Reference inputs are available in the draft body but absent from the supplied spending snapshot. Return an error to abort. The callback must be pure and deterministic. Snapshots are ordinary owned values; no pointer or resource scope escapes the build.

payTo :: Output -> Plan Source #

Append an output in creation order. Building preserves its exact value.

spend :: Utxo -> Plan Source #

Spend exactly this resolved key-controlled output.

spendWith :: Utxo -> Maybe EncodedPlutusData -> Maybe EncodedPlutusData -> Plan Source #

Spend a script output with optional argument and datum witness.

spendWithDeferredRedeemer :: Utxo -> DeferredRedeemer -> Maybe EncodedPlutusData -> Plan Source #

Spend a script output with a local deferred argument and optional datum witness. Register each input once.

referenceInput :: Utxo -> Plan Source #

Make a resolved reference output available without spending it.

attachScript :: Script -> Plan Source #

Attach a native or compiled Plutus script. Executed sub-level scripts require V4. Repeated attachments with the same language and script bytes contribute one witness, ordered by the first attachment.

mint :: AssetId -> Int64 -> Plan Source #

Mint or burn a native asset. Ada and combined quantity overflow fail at build.

mintWithRedeemer :: AssetId -> Int64 -> EncodedPlutusData -> Plan Source #

Mint or burn a Plutus-policy asset with an immediate argument.

mintWithDeferredRedeemer :: PolicyId -> [(AssetName, Int64)] -> DeferredRedeemer -> Plan Source #

Mint or burn a group of names under one policy with one local deferred argument. Repeated names combine and zero totals disappear. Register each policy once.

metadata :: Word64 -> Metadatum -> Plan Source #

Attach a metadata label; conflicting values fail at build.

attachDatum :: EncodedPlutusData -> Plan Source #

Attach an exact datum witness. Repeated exact CBOR encodings contribute one witness, including data supplied to spending inputs, in first occurrence order. Different encodings remain distinct because their hashes differ.

certificate :: Certificate -> Plan Source #

Append a typed certificate without a script argument.

certificateWithRedeemer :: Certificate -> EncodedPlutusData -> Plan Source #

Append a typed certificate authorized by an immediate argument.

certificateWithDeferredRedeemer :: Certificate -> DeferredRedeemer -> Plan Source #

Append a typed certificate authorized by a local deferred argument.

withdraw :: RewardAddress -> Word64 -> Plan Source #

Withdraw rewards from a key-controlled account. Amounts must fit signed 64-bit.

withdrawWithRedeemer :: RewardAddress -> Word64 -> EncodedPlutusData -> Plan Source #

Withdraw rewards with an immediate Plutus argument.

withdrawWithDeferredRedeemer :: RewardAddress -> Word64 -> DeferredRedeemer -> Plan Source #

Withdraw rewards with a local deferred argument. Register each account once.

requireSigner :: KeyHash Payment -> Plan Source #

Require a payment key hash as a local guard.

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.

requireTopLevelGuard :: Credential Guard -> Maybe EncodedPlutusData -> Plan Source #

Require an outer guard and optional datum for this intent. This records a requirement; the enclosing transaction must satisfy it when assembled.

requireGuard :: Credential Guard -> Plan Source #

Require a key or native-script guard. Use guardWithRedeemer for Plutus guards.

guardWithRedeemer :: ScriptHash -> EncodedPlutusData -> Plan Source #

Require a local Plutus guard with its immediate argument.

directDeposit :: RewardAddress -> Word64 -> Plan Source #

Deposit lovelace directly into a reward account. Repeated amounts combine.

accountBalance :: RewardAddress -> BalanceInterval -> Plan Source #

Require a reward-account balance interval for this intent.

donate :: Word64 -> Plan Source #

Donate lovelace to the treasury; repeated donations combine.

propose :: RewardAddress -> Action -> Anchor -> Plan Source #

Append a governance proposal, using the configured governance deposit. Parameter changes and treasury withdrawals naming a guardrails policy use the unit argument Constr 0 [] and require a supplied Plutus V4 script. Actions without a policy do not create a proposing redeemer.

proposeWithRedeemer :: RewardAddress -> Action -> Anchor -> EncodedPlutusData -> Plan Source #

Append a proposal with a guardrails argument. The action must name a policy; the configured protocol snapshot supplies its deposit. Attach the script or resolve its reference input separately. Duplicate proposals fail at build.

proposeWithDeferredRedeemer :: RewardAddress -> Action -> Anchor -> DeferredRedeemer -> Plan Source #

Compute a proposal's guardrails argument from the local draft. Proposal indices and resolved inputs belong to this subtransaction. The action must name a policy; duplicate proposals fail at build.

vote :: Voter -> ActionId -> VotingProcedure -> Plan Source #

Cast a key-authorized governance vote.

voteWithRedeemer :: Voter -> [(ActionId, VotingProcedure)] -> EncodedPlutusData -> Plan Source #

Cast several votes under one voter with one immediate argument.

voteWithDeferredRedeemer :: Voter -> [(ActionId, VotingProcedure)] -> DeferredRedeemer -> Plan Source #

Cast several votes under one voter with one local deferred argument. Register each voter once; empty groups do not invoke the callback.

resolvedInputs :: Plan -> [Utxo] Source #

Unique spending and reference snapshots in ascending input-reference order. Conflicting original snapshots are rejected when building. Supply this result alongside a successfully built intent when attaching it to an outer plan.