module Hydra.Tx.BlueprintTx where

import Hydra.Tx.IsTx (IsTx, UTxOType, txSpendingUTxO)

-- | _Blueprint/Draft_ transaction paired with the related 'UTxO' and used for
-- resolving the inputs and committing/depositing into a Head.
-- Deposit behaviour:
-- - In case blueprint transaction contains outputs then these outputs will be taken into account.
-- - If the blueprint tx contains only inputs then the whole provided UTxO will get deposited into a Head.
-- Commit behaviour:
-- - Only inputs would be considered ignoring any outputs and complete UTxO gets committed.
data CommitBlueprintTx tx = CommitBlueprintTx {forall tx. CommitBlueprintTx tx -> UTxOType tx
lookupUTxO :: UTxOType tx, forall tx. CommitBlueprintTx tx -> tx
blueprintTx :: tx}

mkSimpleBlueprintTx :: IsTx tx => UTxOType tx -> CommitBlueprintTx tx
mkSimpleBlueprintTx :: forall tx. IsTx tx => UTxOType tx -> CommitBlueprintTx tx
mkSimpleBlueprintTx UTxOType tx
utxo =
  CommitBlueprintTx
    { $sel:lookupUTxO:CommitBlueprintTx :: UTxOType tx
lookupUTxO = UTxOType tx
utxo
    , $sel:blueprintTx:CommitBlueprintTx :: tx
blueprintTx = UTxOType tx -> tx
forall tx. IsTx tx => UTxOType tx -> tx
txSpendingUTxO UTxOType tx
utxo
    }