From 2b929b53cef923800a4df4b13873b64bc4306a14 Mon Sep 17 00:00:00 2001 From: Daniel Firth Date: Sun, 8 Dec 2024 11:58:08 +0000 Subject: [PATCH] Match nomenclature from Cardano.Api.Tx.Body and use upstream functions where possibly --- hydra-cluster/src/Hydra/Cluster/Scenarios.hs | 4 +- hydra-node/test/Hydra/Chain/Direct/TxSpec.hs | 8 +- hydra-tx/src/Hydra/Ledger/Cardano/Builder.hs | 96 ++++++++++---------- hydra-tx/src/Hydra/Tx/Abort.hs | 16 ++-- hydra-tx/src/Hydra/Tx/Close.hs | 22 ++--- hydra-tx/src/Hydra/Tx/CollectCom.hs | 16 ++-- hydra-tx/src/Hydra/Tx/Contest.hs | 19 ++-- hydra-tx/src/Hydra/Tx/Decrement.hs | 16 ++-- hydra-tx/src/Hydra/Tx/Fanout.hs | 15 ++- hydra-tx/src/Hydra/Tx/Increment.hs | 19 ++-- hydra-tx/src/Hydra/Tx/Init.hs | 6 +- hydra-tx/src/Hydra/Tx/Recover.hs | 11 +-- 12 files changed, 122 insertions(+), 126 deletions(-) diff --git a/hydra-cluster/src/Hydra/Cluster/Scenarios.hs b/hydra-cluster/src/Hydra/Cluster/Scenarios.hs index a27029efd37..4fb792ee6e8 100644 --- a/hydra-cluster/src/Hydra/Cluster/Scenarios.hs +++ b/hydra-cluster/src/Hydra/Cluster/Scenarios.hs @@ -72,7 +72,7 @@ import Hydra.Cluster.Fixture (Actor (..), actorName, alice, aliceSk, aliceVk, bo import Hydra.Cluster.Mithril (MithrilLog) import Hydra.Cluster.Options (Options) import Hydra.Cluster.Util (chainConfigFor, keysFor, modifyConfig, setNetworkId) -import Hydra.Ledger.Cardano (addInputs, mkSimpleTx, mkTransferTx, unsafeBuildTransaction) +import Hydra.Ledger.Cardano (addTxIns, mkSimpleTx, mkTransferTx, unsafeBuildTransaction) import Hydra.Logging (Tracer, traceWith) import Hydra.Options (DirectChainConfig (..), networkId, startChainFrom) import Hydra.Tx (HeadId, IsTx (balance), Party, txId) @@ -459,7 +459,7 @@ singlePartyCommitsScriptBlueprint tracer workDir node hydraScriptsTxId = let spendingTx = unsafeBuildTransaction $ defaultTxBodyContent - & addInputs [(scriptIn, scriptWitness)] + & addTxIns [(scriptIn, scriptWitness)] pure ( Aeson.object [ "blueprintTx" .= spendingTx diff --git a/hydra-node/test/Hydra/Chain/Direct/TxSpec.hs b/hydra-node/test/Hydra/Chain/Direct/TxSpec.hs index d4b603484b7..81806e45dab 100644 --- a/hydra-node/test/Hydra/Chain/Direct/TxSpec.hs +++ b/hydra-node/test/Hydra/Chain/Direct/TxSpec.hs @@ -44,7 +44,7 @@ import Hydra.Chain.Direct.Tx ( ) import Hydra.Contract.Dummy (dummyValidatorScript) import Hydra.Contract.HeadTokens (headPolicyId) -import Hydra.Ledger.Cardano.Builder (addInputs, addReferenceInputs, addVkInputs, unsafeBuildTransaction) +import Hydra.Ledger.Cardano.Builder (addTxIns, addTxInsReference, addTxInsSpending, unsafeBuildTransaction) import Hydra.Ledger.Cardano.Evaluate (propTransactionEvaluates) import Hydra.Tx.BlueprintTx (CommitBlueprintTx (..)) import Hydra.Tx.Commit (commitTx) @@ -234,7 +234,7 @@ genBlueprintTxWithUTxO = utxoToSpend <- genUTxOAdaOnlyOfSize =<< choose (0, 3) pure ( utxo <> utxoToSpend - , txbody & addVkInputs (toList $ UTxO.inputSet utxoToSpend) + , txbody & addTxInsSpending (toList $ UTxO.inputSet utxoToSpend) ) spendSomeScriptInputs (utxo, txbody) = do @@ -249,7 +249,7 @@ genBlueprintTxWithUTxO = pure ( utxo <> utxoToSpend , txbody - & addInputs + & addTxIns ( UTxO.pairs $ ( \_ -> BuildTxWith $ @@ -263,7 +263,7 @@ genBlueprintTxWithUTxO = addSomeReferenceInputs (utxo, txbody) = do txout <- genTxOutWithReferenceScript txin <- arbitrary - pure (utxo <> UTxO.singleton (txin, txout), txbody & addReferenceInputs [txin]) + pure (utxo <> UTxO.singleton (txin, txout), txbody & addTxInsReference [txin]) addValidityRange (utxo, txbody) = do (start, end) <- arbitrary diff --git a/hydra-tx/src/Hydra/Ledger/Cardano/Builder.hs b/hydra-tx/src/Hydra/Ledger/Cardano/Builder.hs index 256c06f79a4..a0e8f3023be 100644 --- a/hydra-tx/src/Hydra/Ledger/Cardano/Builder.hs +++ b/hydra-tx/src/Hydra/Ledger/Cardano/Builder.hs @@ -4,7 +4,6 @@ module Hydra.Ledger.Cardano.Builder where import Hydra.Cardano.Api import Hydra.Prelude -import Data.Default (def) import Data.Map qualified as Map -- * Executing @@ -34,42 +33,55 @@ data InvalidTransactionException = InvalidTransactionException instance Exception InvalidTransactionException --- | Add new inputs to an ongoing builder. -addInputs :: TxIns BuildTx -> TxBodyContent BuildTx -> TxBodyContent BuildTx -addInputs ins tx = - tx{txIns = txIns tx <> ins} - -addReferenceInputs :: [TxIn] -> TxBodyContent BuildTx -> TxBodyContent BuildTx -addReferenceInputs refs' tx = - tx - { txInsReference = case txInsReference tx of - TxInsReferenceNone -> - TxInsReference refs' - TxInsReference refs -> - TxInsReference (refs <> refs') - } - --- | Like 'addInputs' but only for vk inputs which requires no additional data. -addVkInputs :: [TxIn] -> TxBodyContent BuildTx -> TxBodyContent BuildTx -addVkInputs ins = - addInputs ((,BuildTxWith $ KeyWitness KeyWitnessForSpending) <$> ins) - --- | Append new outputs to an ongoing builder. -addOutputs :: [TxOut CtxTx] -> TxBodyContent BuildTx -> TxBodyContent BuildTx -addOutputs outputs tx = - tx{txOuts = txOuts tx <> outputs} - --- | Add extra required key witnesses to a transaction. -addExtraRequiredSigners :: [Hash PaymentKey] -> TxBodyContent BuildTx -> TxBodyContent BuildTx -addExtraRequiredSigners vks tx = - tx{txExtraKeyWits = txExtraKeyWits'} - where - txExtraKeyWits' = - case txExtraKeyWits tx of - TxExtraKeyWitnessesNone -> - TxExtraKeyWitnesses vks - TxExtraKeyWitnesses vks' -> - TxExtraKeyWitnesses (vks' <> vks) +addTxIns :: TxIns build -> TxBodyContent build -> TxBodyContent build +addTxIns txIns = modTxIns (<> txIns) + +addTxInsSpending :: [TxIn] -> TxBodyContent BuildTx -> TxBodyContent BuildTx +addTxInsSpending txIns = addTxIns ((,BuildTxWith $ KeyWitness KeyWitnessForSpending) <$> txIns) + +modTxInsReference :: (TxInsReference -> TxInsReference) -> TxBodyContent build -> TxBodyContent build +modTxInsReference f txBodyContent = txBodyContent{txInsReference = f (txInsReference txBodyContent)} + +addTxInsReference :: [TxIn] -> TxBodyContent build -> TxBodyContent build +addTxInsReference txInsReference = + modTxInsReference + ( \case + TxInsReferenceNone -> TxInsReference txInsReference + TxInsReference xs -> TxInsReference (xs <> txInsReference) + ) + +addTxInReference :: TxIn -> TxBodyContent build -> TxBodyContent build +addTxInReference txInReference = addTxInsReference [txInReference] + +addTxOuts :: [TxOut CtxTx] -> TxBodyContent build -> TxBodyContent build +addTxOuts txOuts = modTxOuts (<> txOuts) + +modTxInsCollateral :: (TxInsCollateral -> TxInsCollateral) -> TxBodyContent build -> TxBodyContent build +modTxInsCollateral f txBodyContent = txBodyContent{txInsCollateral = f (txInsCollateral txBodyContent)} + +addTxInsCollateral :: [TxIn] -> TxBodyContent build -> TxBodyContent build +addTxInsCollateral txInsCollateral = + modTxInsCollateral + ( \case + TxInsCollateralNone -> TxInsCollateral txInsCollateral + TxInsCollateral xs -> TxInsCollateral (xs <> txInsCollateral) + ) + +addTxInCollateral :: TxIn -> TxBodyContent build -> TxBodyContent build +addTxInCollateral txInCollateral = addTxInsCollateral [txInCollateral] + +modExtraKeyWits :: (TxExtraKeyWitnesses -> TxExtraKeyWitnesses) -> TxBodyContent build -> TxBodyContent build +modExtraKeyWits f txBodyContent = txBodyContent{txExtraKeyWits = f (txExtraKeyWits txBodyContent)} + +addExtraKeyWits :: [Hash PaymentKey] -> TxBodyContent build -> TxBodyContent build +addExtraKeyWits vks = + modExtraKeyWits + ( \case + TxExtraKeyWitnessesNone -> + TxExtraKeyWitnesses vks + TxExtraKeyWitnesses vks' -> + TxExtraKeyWitnesses (vks' <> vks) + ) -- | Mint tokens with given plutus minting script and redeemer. mintTokens :: ToScriptData redeemer => PlutusScript -> redeemer -> [(AssetName, Quantity)] -> TxBodyContent BuildTx -> TxBodyContent BuildTx @@ -100,13 +112,3 @@ mintTokens script redeemer assets tx = burnTokens :: ToScriptData redeemer => PlutusScript -> redeemer -> [(AssetName, Quantity)] -> TxBodyContent BuildTx -> TxBodyContent BuildTx burnTokens script redeemer assets = mintTokens script redeemer (fmap (second negate) assets) - --- | Set the upper validity bound for this transaction to some 'SlotNo'. -setValidityUpperBound :: SlotNo -> TxBodyContent BuildTx -> TxBodyContent BuildTx -setValidityUpperBound slotNo tx = - tx{txValidityUpperBound = TxValidityUpperBound slotNo} - --- | Set the lower validity bound for this transaction to some 'SlotNo'. -setValidityLowerBound :: SlotNo -> TxBodyContent BuildTx -> TxBodyContent BuildTx -setValidityLowerBound slotNo tx = - tx{txValidityLowerBound = TxValidityLowerBound slotNo} diff --git a/hydra-tx/src/Hydra/Tx/Abort.hs b/hydra-tx/src/Hydra/Tx/Abort.hs index 64034792d3c..fc9df5a68a3 100644 --- a/hydra-tx/src/Hydra/Tx/Abort.hs +++ b/hydra-tx/src/Hydra/Tx/Abort.hs @@ -11,10 +11,10 @@ import Hydra.Contract.HeadState qualified as Head import Hydra.Contract.Initial qualified as Initial import Hydra.Contract.MintAction (MintAction (Burn)) import Hydra.Ledger.Cardano.Builder ( - addExtraRequiredSigners, - addInputs, - addOutputs, - addReferenceInputs, + addExtraKeyWits, + addTxIns, + addTxInsReference, + addTxOuts, burnTokens, unsafeBuildTransaction, ) @@ -54,11 +54,11 @@ abortTx committedUTxO scriptRegistry vk (headInput, initialHeadOutput) headToken Right $ unsafeBuildTransaction $ defaultTxBodyContent - & addInputs ((headInput, headWitness) : initialInputs <> commitInputs) - & addReferenceInputs ([headScriptRef, initialScriptRef] <> [commitScriptRef | not $ null commitInputs]) - & addOutputs reimbursedOutputs + & addTxIns ((headInput, headWitness) : initialInputs <> commitInputs) + & addTxInsReference ([headScriptRef, initialScriptRef] <> [commitScriptRef | not $ null commitInputs]) + & addTxOuts reimbursedOutputs & burnTokens headTokenScript Burn headTokens - & addExtraRequiredSigners [verificationKeyHash vk] + & addExtraKeyWits [verificationKeyHash vk] where headWitness = BuildTxWith $ diff --git a/hydra-tx/src/Hydra/Tx/Close.hs b/hydra-tx/src/Hydra/Tx/Close.hs index d183f34b145..5be18f0ca83 100644 --- a/hydra-tx/src/Hydra/Tx/Close.hs +++ b/hydra-tx/src/Hydra/Tx/Close.hs @@ -12,12 +12,10 @@ import Hydra.Data.ContestationPeriod (addContestationPeriod) import Hydra.Data.ContestationPeriod qualified as OnChain import Hydra.Data.Party qualified as OnChain import Hydra.Ledger.Cardano.Builder ( - addExtraRequiredSigners, - addInputs, - addOutputs, - addReferenceInputs, - setValidityLowerBound, - setValidityUpperBound, + addExtraKeyWits, + addTxIns, + addTxInsReference, + addTxOuts, unsafeBuildTransaction, ) import Hydra.Plutus.Extras.Time (posixFromUTCTime) @@ -69,12 +67,12 @@ closeTx :: closeTx scriptRegistry vk headId openVersion confirmedSnapshot startSlotNo (endSlotNo, utcTime) openThreadOutput = unsafeBuildTransaction $ defaultTxBodyContent - & addInputs [(headInput, headWitness)] - & addReferenceInputs [headScriptRef] - & addOutputs [headOutputAfter] - & addExtraRequiredSigners [verificationKeyHash vk] - & setValidityLowerBound startSlotNo - & setValidityUpperBound endSlotNo + & addTxIns [(headInput, headWitness)] + & addTxInsReference [headScriptRef] + & addTxOuts [headOutputAfter] + & addExtraKeyWits [verificationKeyHash vk] + & setTxValidityLowerBound (TxValidityLowerBound startSlotNo) + & setTxValidityUpperBound (TxValidityUpperBound endSlotNo) & setTxMetadata (TxMetadataInEra $ mkHydraHeadV1TxName "CloseTx") where OpenThreadOutput diff --git a/hydra-tx/src/Hydra/Tx/CollectCom.hs b/hydra-tx/src/Hydra/Tx/CollectCom.hs index 0becda0a34a..0b37ab38fbd 100644 --- a/hydra-tx/src/Hydra/Tx/CollectCom.hs +++ b/hydra-tx/src/Hydra/Tx/CollectCom.hs @@ -11,10 +11,10 @@ import Hydra.Contract.Commit qualified as Commit import Hydra.Contract.Head qualified as Head import Hydra.Contract.HeadState qualified as Head import Hydra.Ledger.Cardano.Builder ( - addExtraRequiredSigners, - addInputs, - addOutputs, - addReferenceInputs, + addExtraKeyWits, + addTxIns, + addTxInsReference, + addTxOuts, unsafeBuildTransaction, ) import Hydra.Plutus (commitValidatorScript) @@ -51,10 +51,10 @@ collectComTx :: collectComTx networkId scriptRegistry vk headId headParameters (headInput, initialHeadOutput) commits utxoToCollect = unsafeBuildTransaction $ defaultTxBodyContent - & addInputs ((headInput, headWitness) : (mkCommit <$> Map.keys commits)) - & addReferenceInputs [commitScriptRef, headScriptRef] - & addOutputs [headOutput] - & addExtraRequiredSigners [verificationKeyHash vk] + & addTxIns ((headInput, headWitness) : (mkCommit <$> Map.keys commits)) + & addTxInsReference [commitScriptRef, headScriptRef] + & addTxOuts [headOutput] + & addExtraKeyWits [verificationKeyHash vk] & setTxMetadata (TxMetadataInEra $ mkHydraHeadV1TxName "CollectComTx") where HeadParameters{parties, contestationPeriod} = headParameters diff --git a/hydra-tx/src/Hydra/Tx/Contest.hs b/hydra-tx/src/Hydra/Tx/Contest.hs index 7156b18564d..d14afe260b1 100644 --- a/hydra-tx/src/Hydra/Tx/Contest.hs +++ b/hydra-tx/src/Hydra/Tx/Contest.hs @@ -8,11 +8,10 @@ import Hydra.Contract.HeadState qualified as Head import Hydra.Data.ContestationPeriod (addContestationPeriod) import Hydra.Data.Party qualified as OnChain import Hydra.Ledger.Cardano.Builder ( - addExtraRequiredSigners, - addInputs, - addOutputs, - addReferenceInputs, - setValidityUpperBound, + addExtraKeyWits, + addTxIns, + addTxInsReference, + addTxOuts, unsafeBuildTransaction, ) import Hydra.Plutus.Orphans () @@ -62,11 +61,11 @@ contestTx :: contestTx scriptRegistry vk headId contestationPeriod openVersion Snapshot{number, utxo, utxoToDecommit, version} sig (slotNo, _) closedThreadOutput = unsafeBuildTransaction $ defaultTxBodyContent - & addInputs [(headInput, headWitness)] - & addReferenceInputs [headScriptRef] - & addOutputs [headOutputAfter] - & addExtraRequiredSigners [verificationKeyHash vk] - & setValidityUpperBound slotNo + & addTxIns [(headInput, headWitness)] + & addTxInsReference [headScriptRef] + & addTxOuts [headOutputAfter] + & addExtraKeyWits [verificationKeyHash vk] + & setTxValidityUpperBound (TxValidityUpperBound slotNo) & setTxMetadata (TxMetadataInEra $ mkHydraHeadV1TxName "ContestTx") where ClosedThreadOutput diff --git a/hydra-tx/src/Hydra/Tx/Decrement.hs b/hydra-tx/src/Hydra/Tx/Decrement.hs index 6c130faf07d..9f7f4b989ea 100644 --- a/hydra-tx/src/Hydra/Tx/Decrement.hs +++ b/hydra-tx/src/Hydra/Tx/Decrement.hs @@ -6,10 +6,10 @@ import Hydra.Prelude import Hydra.Contract.Head qualified as Head import Hydra.Contract.HeadState qualified as Head import Hydra.Ledger.Cardano.Builder ( - addExtraRequiredSigners, - addInputs, - addOutputs, - addReferenceInputs, + addExtraKeyWits, + addTxIns, + addTxInsReference, + addTxOuts, unsafeBuildTransaction, ) import Hydra.Tx.ContestationPeriod (toChain) @@ -43,10 +43,10 @@ decrementTx :: decrementTx scriptRegistry vk headId headParameters (headInput, headOutput) snapshot signatures = unsafeBuildTransaction $ defaultTxBodyContent - & addInputs [(headInput, headWitness)] - & addReferenceInputs [headScriptRef] - & addOutputs (headOutput' : map toTxContext decommitOutputs) - & addExtraRequiredSigners [verificationKeyHash vk] + & addTxIns [(headInput, headWitness)] + & addTxInsReference [headScriptRef] + & addTxOuts (headOutput' : map toTxContext decommitOutputs) + & addExtraKeyWits [verificationKeyHash vk] & setTxMetadata (TxMetadataInEra $ mkHydraHeadV1TxName "DecrementTx") where headRedeemer = diff --git a/hydra-tx/src/Hydra/Tx/Fanout.hs b/hydra-tx/src/Hydra/Tx/Fanout.hs index f60e37a9b1a..a7809f795f5 100644 --- a/hydra-tx/src/Hydra/Tx/Fanout.hs +++ b/hydra-tx/src/Hydra/Tx/Fanout.hs @@ -7,11 +7,10 @@ import Hydra.Contract.Head qualified as Head import Hydra.Contract.HeadState qualified as Head import Hydra.Contract.MintAction (MintAction (..)) import Hydra.Ledger.Cardano.Builder ( - addInputs, - addOutputs, - addReferenceInputs, + addTxIns, + addTxInsReference, + addTxOuts, burnTokens, - setValidityLowerBound, unsafeBuildTransaction, ) import Hydra.Tx.ScriptRegistry (ScriptRegistry (..)) @@ -37,11 +36,11 @@ fanoutTx :: fanoutTx scriptRegistry utxo utxoToDecommit (headInput, headOutput) deadlineSlotNo headTokenScript = unsafeBuildTransaction $ defaultTxBodyContent - & addInputs [(headInput, headWitness)] - & addReferenceInputs [headScriptRef] - & addOutputs (orderedTxOutsToFanout <> orderedTxOutsToDecommit) + & addTxIns [(headInput, headWitness)] + & addTxInsReference [headScriptRef] + & addTxOuts (orderedTxOutsToFanout <> orderedTxOutsToDecommit) & burnTokens headTokenScript Burn headTokens - & setValidityLowerBound (deadlineSlotNo + 1) + & setTxValidityLowerBound (TxValidityLowerBound $ deadlineSlotNo + 1) & setTxMetadata (TxMetadataInEra $ mkHydraHeadV1TxName "FanoutTx") where headWitness = diff --git a/hydra-tx/src/Hydra/Tx/Increment.hs b/hydra-tx/src/Hydra/Tx/Increment.hs index c34e4d7441e..a5b17941c3b 100644 --- a/hydra-tx/src/Hydra/Tx/Increment.hs +++ b/hydra-tx/src/Hydra/Tx/Increment.hs @@ -9,11 +9,10 @@ import Hydra.Contract.Deposit qualified as Deposit import Hydra.Contract.Head qualified as Head import Hydra.Contract.HeadState qualified as Head import Hydra.Ledger.Cardano.Builder ( - addExtraRequiredSigners, - addInputs, - addOutputs, - addReferenceInputs, - setValidityUpperBound, + addExtraKeyWits, + addTxIns, + addTxInsReference, + addTxOuts, unsafeBuildTransaction, ) import Hydra.Tx.ContestationPeriod (toChain) @@ -48,11 +47,11 @@ incrementTx :: incrementTx scriptRegistry vk headId headParameters (headInput, headOutput) snapshot depositScriptUTxO upperValiditySlot = unsafeBuildTransaction $ defaultTxBodyContent - & addInputs [(headInput, headWitness), (depositIn, depositWitness)] - & addReferenceInputs [headScriptRef] - & addOutputs [headOutput'] - & addExtraRequiredSigners [verificationKeyHash vk] - & setValidityUpperBound upperValiditySlot + & addTxIns [(headInput, headWitness), (depositIn, depositWitness)] + & addTxInsReference [headScriptRef] + & addTxOuts [headOutput'] + & addExtraKeyWits [verificationKeyHash vk] + & setTxValidityUpperBound (TxValidityUpperBound upperValiditySlot) & setTxMetadata (TxMetadataInEra $ mkHydraHeadV1TxName "IncrementTx") where headRedeemer = diff --git a/hydra-tx/src/Hydra/Tx/Init.hs b/hydra-tx/src/Hydra/Tx/Init.hs index 9c5aa03dc4d..87b66206598 100644 --- a/hydra-tx/src/Hydra/Tx/Init.hs +++ b/hydra-tx/src/Hydra/Tx/Init.hs @@ -8,7 +8,7 @@ import Hydra.Contract.HeadState qualified as Head import Hydra.Contract.HeadTokens qualified as HeadTokens import Hydra.Contract.Initial qualified as Initial import Hydra.Contract.MintAction (MintAction (..)) -import Hydra.Ledger.Cardano.Builder (addOutputs, addVkInputs, mintTokens, unsafeBuildTransaction) +import Hydra.Ledger.Cardano.Builder (addTxInsSpending, addTxOuts, mintTokens, unsafeBuildTransaction) import Hydra.Plutus (initialValidatorScript) import Hydra.Tx.ContestationPeriod (toChain) import Hydra.Tx.HeadParameters (HeadParameters (..)) @@ -29,8 +29,8 @@ initTx :: initTx networkId seedTxIn participants parameters = unsafeBuildTransaction $ defaultTxBodyContent - & addVkInputs [seedTxIn] - & addOutputs + & addTxInsSpending [seedTxIn] + & addTxOuts ( mkHeadOutputInitial networkId seedTxIn parameters : map (mkInitialOutput networkId seedTxIn) participants ) diff --git a/hydra-tx/src/Hydra/Tx/Recover.hs b/hydra-tx/src/Hydra/Tx/Recover.hs index 10d2146e60b..9d3484c4745 100644 --- a/hydra-tx/src/Hydra/Tx/Recover.hs +++ b/hydra-tx/src/Hydra/Tx/Recover.hs @@ -7,9 +7,8 @@ import Hydra.Cardano.Api import Hydra.Contract.Commit qualified as Commit import Hydra.Contract.Deposit qualified as Deposit import Hydra.Ledger.Cardano.Builder ( - addInputs, - addOutputs, - setValidityLowerBound, + addTxIns, + addTxOuts, unsafeBuildTransaction, ) import Hydra.Tx (HeadId, mkHeadId) @@ -27,9 +26,9 @@ recoverTx :: recoverTx depositTxId deposited lowerBoundSlot = unsafeBuildTransaction $ defaultTxBodyContent - & addInputs recoverInputs - & addOutputs depositOutputs - & setValidityLowerBound lowerBoundSlot + & addTxIns recoverInputs + & addTxOuts depositOutputs + & setTxValidityLowerBound (TxValidityLowerBound lowerBoundSlot) & setTxMetadata (TxMetadataInEra $ mkHydraHeadV1TxName "RecoverTx") where recoverInputs = (,depositWitness) <$> [TxIn depositTxId (TxIx 0)]