Skip to content

Commit

Permalink
Adjust haddocks
Browse files Browse the repository at this point in the history
  • Loading branch information
ffakenz committed Apr 16, 2024
1 parent 32f9b27 commit 2e29b3d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
5 changes: 3 additions & 2 deletions hydra-node/src/Hydra/Chain.hs
Expand Up @@ -244,8 +244,9 @@ data Chain tx m = Chain
UTxOType tx ->
tx ->
m (Either (PostTxError tx) tx)
-- ^ Create a commit transaction using user provided utxos (zero or many) and
-- a _blueprint_ transaction. Errors are handled at the call site.
-- ^ Create a commit transaction using either user provided utxos (zero or many) or
-- a _blueprint_ transaction together with a 'UTxO' which resolves it.
-- Errors are handled at the call site.
, submitTx :: MonadThrow m => tx -> m ()
-- ^ Submit a cardano transaction.
--
Expand Down
5 changes: 2 additions & 3 deletions hydra-node/src/Hydra/Chain/Direct/Handlers.hs
Expand Up @@ -157,7 +157,7 @@ mkChain tracer queryTimeHandle wallet@TinyWallet{getUTxO} ctx LocalChainState{ge
atomically (prepareTxToPost timeHandle wallet ctx spendableUTxO tx)
>>= finalizeTx wallet ctx spendableUTxO mempty
submitTx vtx
, -- Handle that creates a draft commit tx using the user utxo.
, -- Handle that creates a draft commit tx using the user utxo and a _blueprint_ transaction.
-- Possible errors are handled at the api server level.
draftCommitTx = \headId utxoToCommit blueprintTx -> do
ChainStateAt{spendableUTxO} <- atomically getLatest
Expand All @@ -167,7 +167,7 @@ mkChain tracer queryTimeHandle wallet@TinyWallet{getUTxO} ctx LocalChainState{ge
let matchedWalletUtxo = filter (`elem` walletTxIns) userTxIns
-- prevent trying to spend internal wallet's utxo
if null matchedWalletUtxo
then do
then
traverse (finalizeTx wallet ctx spendableUTxO utxoToCommit) $
commit' ctx headId spendableUTxO utxoToCommit blueprintTx
else pure $ Left SpendingNodeUtxoForbidden
Expand All @@ -177,7 +177,6 @@ mkChain tracer queryTimeHandle wallet@TinyWallet{getUTxO} ctx LocalChainState{ge
}

-- | Balance and sign the given partial transaction.
-- TODO: remove tracing
finalizeTx ::
MonadThrow m =>
TinyWallet m ->
Expand Down
12 changes: 6 additions & 6 deletions hydra-node/src/Hydra/Chain/Direct/State.hs
Expand Up @@ -344,7 +344,7 @@ commit ctx headId spendableUTxO utxoToCommit =
in commit' ctx headId spendableUTxO utxoToCommit blueprintTx

-- | Construct a commit transaction based on known, spendable UTxO and some
-- arbitrary UTxOs to commit. This does look for "our initial output" to spend
-- user UTxO inputs to commit. This does look for "our initial output" to spend
-- and check the given 'UTxO' to be compatible. Hence, this function does fail
-- if already committed or if the head is not initializing.
--
Expand All @@ -354,16 +354,16 @@ commit' ::
HeadId ->
-- | Spendable 'UTxO'
UTxO ->
-- | 'UTxO' to commit
-- | 'UTxO' inputs to commit.
UTxO ->
Tx ->
Either (PostTxError Tx) Tx
commit' ctx headId spendableUTxO utxoToCommit blueprintTx = do
commit' ctx headId spendableUTxO utxo blueprintTx = do
pid <- headIdToPolicyId headId ?> InvalidHeadId{headId}
(i, o) <- ownInitial pid ?> CannotFindOwnInitial{knownUTxO = spendableUTxO}
rejectByronAddress utxoToCommit
rejectMoreThanMainnetLimit networkId utxoToCommit
pure $ commitTx networkId scriptRegistry headId ownParty utxoToCommit blueprintTx (i, o, vkh)
rejectByronAddress utxo
rejectMoreThanMainnetLimit networkId utxo
pure $ commitTx networkId scriptRegistry headId ownParty utxo blueprintTx (i, o, vkh)
where
ChainContext{networkId, ownParty, scriptRegistry, ownVerificationKey} = ctx

Expand Down
14 changes: 7 additions & 7 deletions hydra-node/src/Hydra/Chain/Direct/Tx.hs
Expand Up @@ -242,15 +242,15 @@ commitTx ::
ScriptRegistry ->
HeadId ->
Party ->
-- | The UTxO to commit to the Head.
-- | The UTxO inputs to commit to the Head.
UTxO ->
-- | _Blueprint_ transaction.
Tx ->
-- | The initial output (sent to each party) which should contain the PT and is
-- locked by initial script
(TxIn, TxOut CtxUTxO, Hash PaymentKey) ->
Tx
commitTx networkId scriptRegistry headId party utxoToCommit blueprintTx (initialInput, out, vkh) =
commitTx networkId scriptRegistry headId party utxo blueprintTx (initialInput, out, vkh) =
let
ledgerBlueprintTx =
toLedgerTx blueprintTx
Expand All @@ -263,7 +263,7 @@ commitTx networkId scriptRegistry headId party utxoToCommit blueprintTx (initial
& auxDataTxL .~ addMetadata txAuxMetadata
existingWits = ledgerBlueprintTx ^. witsTxL
currentInputs = ledgerBlueprintTx ^. bodyTxL . inputsTxBodyL
commitInputs = Set.map toLedgerTxIn (UTxO.inputSet utxoToCommit)
commitInputs = Set.map toLedgerTxIn (UTxO.inputSet utxo)
blueprintRedeemers = unRedeemers $ toLedgerTx blueprintTx ^. witsTxL . rdmrsTxWitsL
wits =
witsTxL
Expand All @@ -285,7 +285,7 @@ commitTx networkId scriptRegistry headId party utxoToCommit blueprintTx (initial
(Map.union languageMap languageMap')

-- Re-Associate the redeemer indices present in some tx with the same inputs but different
-- indices in the current tx.
-- indices in the current (commit) tx.
--
-- We need this in order to be able to find the the _old_ tx redeemer and re-add
-- it to the tx witnesses using the appropriate index of the _new_ tx input
Expand Down Expand Up @@ -325,7 +325,7 @@ commitTx networkId scriptRegistry headId party utxoToCommit blueprintTx (initial
Initial.ViaCommit (toPlutusTxOutRef <$> committedTxIns)

committedTxIns =
fst <$> UTxO.pairs utxoToCommit
fst <$> UTxO.pairs utxo

commitOutput =
TxOut commitAddress commitValue commitDatum ReferenceScriptNone
Expand All @@ -337,10 +337,10 @@ commitTx networkId scriptRegistry headId party utxoToCommit blueprintTx (initial
mkScriptAddress @PlutusScriptV2 networkId commitScript

commitValue =
txOutValue out <> foldMap txOutValue utxoToCommit
txOutValue out <> foldMap txOutValue utxo

commitDatum =
mkTxOutDatumInline $ mkCommitDatum party utxoToCommit (headIdToCurrencySymbol headId)
mkTxOutDatumInline $ mkCommitDatum party utxo (headIdToCurrencySymbol headId)

TxMetadata metadataMap = mkHydraHeadV1TxName "CommitTx"

Expand Down

0 comments on commit 2e29b3d

Please sign in to comment.