From 9524c5b8d0e5a600f4583d47d18c0180a36c078f Mon Sep 17 00:00:00 2001 From: Daniel Firth Date: Sun, 8 Dec 2024 11:58:08 +0000 Subject: [PATCH] cardano-api: 10.5 --- cabal.project | 2 +- hydra-cardano-api/hydra-cardano-api.cabal | 2 +- hydra-cluster/src/Hydra/Cluster/Scenarios.hs | 8 +- hydra-node/src/Hydra/Ledger/Cardano.hs | 4 +- hydra-node/test/Hydra/Chain/Direct/TxSpec.hs | 10 +- hydra-tx/src/Hydra/Ledger/Cardano/Builder.hs | 103 +------------------ hydra-tx/src/Hydra/Tx/Abort.hs | 15 +-- hydra-tx/src/Hydra/Tx/Close.hs | 21 ++-- hydra-tx/src/Hydra/Tx/CollectCom.hs | 15 +-- hydra-tx/src/Hydra/Tx/Contest.hs | 18 ++-- hydra-tx/src/Hydra/Tx/Decrement.hs | 15 +-- hydra-tx/src/Hydra/Tx/Fanout.hs | 15 +-- hydra-tx/src/Hydra/Tx/Increment.hs | 18 ++-- hydra-tx/src/Hydra/Tx/Init.hs | 8 +- hydra-tx/src/Hydra/Tx/Recover.hs | 12 +-- 15 files changed, 65 insertions(+), 201 deletions(-) diff --git a/cabal.project b/cabal.project index f4357f0bc18..818f82bf657 100644 --- a/cabal.project +++ b/cabal.project @@ -13,7 +13,7 @@ repository cardano-haskell-packages -- See CONTRIBUTING.md for information about when and how to update these. index-state: , hackage.haskell.org 2024-11-22T14:59:16Z - , cardano-haskell-packages 2024-12-05T13:51:16Z + , cardano-haskell-packages 2024-12-20T15:52:56Z packages: hydra-prelude diff --git a/hydra-cardano-api/hydra-cardano-api.cabal b/hydra-cardano-api/hydra-cardano-api.cabal index 9584706cce8..35049d4853a 100644 --- a/hydra-cardano-api/hydra-cardano-api.cabal +++ b/hydra-cardano-api/hydra-cardano-api.cabal @@ -78,7 +78,7 @@ library , aeson >=2 , base >=4.16 , bytestring - , cardano-api ^>=10.4 + , cardano-api ^>=10.5 , cardano-binary , cardano-crypto-class , cardano-ledger-allegra diff --git a/hydra-cluster/src/Hydra/Cluster/Scenarios.hs b/hydra-cluster/src/Hydra/Cluster/Scenarios.hs index 583e2c588e9..6d545d3175b 100644 --- a/hydra-cluster/src/Hydra/Cluster/Scenarios.hs +++ b/hydra-cluster/src/Hydra/Cluster/Scenarios.hs @@ -41,6 +41,8 @@ import Hydra.Cardano.Api ( Tx, TxId, UTxO, + addTxIns, + defaultTxBodyContent, getTxBody, getTxId, getVerificationKey, @@ -71,7 +73,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, emptyTxBody, mkSimpleTx, mkTransferTx, unsafeBuildTransaction) +import Hydra.Ledger.Cardano (mkSimpleTx, mkTransferTx, unsafeBuildTransaction) import Hydra.Logging (Tracer, traceWith) import Hydra.Options (DirectChainConfig (..), networkId, startChainFrom) import Hydra.Tx (HeadId, IsTx (balance), Party, txId) @@ -457,8 +459,8 @@ singlePartyCommitsScriptBlueprint tracer workDir node hydraScriptsTxId = mkScriptWitness serializedScript (mkScriptDatum ()) (toScriptData ()) let spendingTx = unsafeBuildTransaction $ - emptyTxBody - & addInputs [(scriptIn, scriptWitness)] + defaultTxBodyContent + & addTxIns [(scriptIn, scriptWitness)] pure ( Aeson.object [ "blueprintTx" .= spendingTx diff --git a/hydra-node/src/Hydra/Ledger/Cardano.hs b/hydra-node/src/Hydra/Ledger/Cardano.hs index 7434abe338b..5b03ee33921 100644 --- a/hydra-node/src/Hydra/Ledger/Cardano.hs +++ b/hydra-node/src/Hydra/Ledger/Cardano.hs @@ -137,7 +137,7 @@ mkSimpleTx (txin, TxOut owner valueIn datum refScript) (recipient, valueOut) sk pure $ makeSignedTransaction witnesses body where bodyContent = - emptyTxBody + defaultTxBodyContent { txIns = [(txin, BuildTxWith $ KeyWitness KeyWitnessForSpending)] , txOuts = outs , txFee = TxFeeExplicit fee @@ -170,7 +170,7 @@ mkRangedTx (txin, TxOut owner valueIn datum refScript) (recipient, valueOut) sk pure $ makeSignedTransaction witnesses body where bodyContent = - emptyTxBody + defaultTxBodyContent { txIns = [(txin, BuildTxWith $ KeyWitness KeyWitnessForSpending)] , txOuts = TxOut @CtxTx recipient valueOut TxOutDatumNone ReferenceScriptNone diff --git a/hydra-node/test/Hydra/Chain/Direct/TxSpec.hs b/hydra-node/test/Hydra/Chain/Direct/TxSpec.hs index 193b81ead95..df42065bcae 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, emptyTxBody, unsafeBuildTransaction) +import Hydra.Ledger.Cardano.Builder (addTxInsSpending, unsafeBuildTransaction) import Hydra.Ledger.Cardano.Evaluate (propTransactionEvaluates) import Hydra.Tx.BlueprintTx (CommitBlueprintTx (..)) import Hydra.Tx.Commit (commitTx) @@ -222,7 +222,7 @@ propIsSubmapOf as bs = genBlueprintTxWithUTxO :: Gen (UTxO, Tx) genBlueprintTxWithUTxO = fmap (second unsafeBuildTransaction) $ - spendingPubKeyOutput (mempty, emptyTxBody) + spendingPubKeyOutput (mempty, defaultTxBodyContent) >>= spendSomeScriptInputs >>= addSomeReferenceInputs >>= addValidityRange @@ -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 8b6c340fc97..b9f089771d9 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,99 +33,15 @@ data InvalidTransactionException = InvalidTransactionException instance Exception InvalidTransactionException --- * Constructing - --- | An empty 'TxBodyContent' with all empty/zero values to be extended using --- record updates. --- --- NOTE: 'makeTransactionBody' throws when one tries to build a transaction --- with scripts but no collaterals. This is unfortunate because collaterals are --- currently added after by our integrated wallet. --- --- Similarly, 'makeTransactionBody' throws when building a transaction with --- scripts and no protocol parameters (needed to compute the script integrity --- hash). This is also added by our wallet at the moment and this ugly --- work-around will be removed eventually (related item --- [215](https://github.com/cardano-scaling/hydra/issues/215). --- --- So we currently bypass this by having default but seemingly innofensive --- values for collaterals and protocol params in the 'empty' value -emptyTxBody :: TxBodyContent BuildTx -emptyTxBody = - TxBodyContent - mempty -- inputs - (TxInsCollateral mempty) - TxInsReferenceNone - mempty -- outputs - TxTotalCollateralNone - TxReturnCollateralNone - (TxFeeExplicit 0) - TxValidityNoLowerBound - TxValidityNoUpperBound - TxMetadataNone - TxAuxScriptsNone - TxExtraKeyWitnessesNone - (BuildTxWith $ Just $ LedgerProtocolParameters def) - TxWithdrawalsNone - TxCertificatesNone - TxUpdateProposalNone - TxMintValueNone - TxScriptValidityNone - Nothing - Nothing - Nothing - Nothing - --- | 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) +addTxInsSpending :: [TxIn] -> TxBodyContent BuildTx -> TxBodyContent BuildTx +addTxInsSpending ins = + addTxIns ((,BuildTxWith $ KeyWitness KeyWitnessForSpending) <$> ins) -- | Mint tokens with given plutus minting script and redeemer. mintTokens :: ToScriptData redeemer => PlutusScript -> redeemer -> [(AssetName, Quantity)] -> TxBodyContent BuildTx -> TxBodyContent BuildTx -mintTokens script redeemer assets tx = - tx{txMintValue = TxMintValue mintedTokens'} +mintTokens script redeemer assets = addTxMintValue newTokens where - mintedTokens = - case txMintValue tx of - TxMintValueNone -> mempty - TxMintValue t -> t - - mintedTokens' = - Map.union mintedTokens newTokens - newTokens = Map.fromList [(policyId, fmap (\(x, y) -> (x, y, BuildTxWith mintingWitness)) assets)] @@ -141,13 +56,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 f6817c27368..7b86e39ecb2 100644 --- a/hydra-tx/src/Hydra/Tx/Abort.hs +++ b/hydra-tx/src/Hydra/Tx/Abort.hs @@ -11,12 +11,7 @@ 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, burnTokens, - emptyTxBody, unsafeBuildTransaction, ) import Hydra.Plutus (commitValidatorScript, initialValidatorScript) @@ -54,12 +49,12 @@ abortTx committedUTxO scriptRegistry vk (headInput, initialHeadOutput) headToken | otherwise = Right $ unsafeBuildTransaction $ - emptyTxBody - & addInputs ((headInput, headWitness) : initialInputs <> commitInputs) - & addReferenceInputs ([headScriptRef, initialScriptRef] <> [commitScriptRef | not $ null commitInputs]) - & addOutputs reimbursedOutputs + defaultTxBodyContent + & addTxIns ((headInput, headWitness) : initialInputs <> commitInputs) + & addTxInsReference ([headScriptRef, initialScriptRef] <> [commitScriptRef | not $ null commitInputs]) + & addTxOuts reimbursedOutputs & burnTokens headTokenScript Burn headTokens - & addExtraRequiredSigners [verificationKeyHash vk] + & addTxExtraKeyWits [verificationKeyHash vk] where headWitness = BuildTxWith $ diff --git a/hydra-tx/src/Hydra/Tx/Close.hs b/hydra-tx/src/Hydra/Tx/Close.hs index 76339b6421b..b334b6cdbf4 100644 --- a/hydra-tx/src/Hydra/Tx/Close.hs +++ b/hydra-tx/src/Hydra/Tx/Close.hs @@ -11,13 +11,6 @@ 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, - emptyTxBody, - setValidityLowerBound, - setValidityUpperBound, unsafeBuildTransaction, ) import Hydra.Plutus.Extras.Time (posixFromUTCTime) @@ -68,13 +61,13 @@ closeTx :: Tx closeTx scriptRegistry vk headId openVersion confirmedSnapshot startSlotNo (endSlotNo, utcTime) openThreadOutput incrementalAction = unsafeBuildTransaction $ - emptyTxBody - & addInputs [(headInput, headWitness)] - & addReferenceInputs [headScriptRef] - & addOutputs [headOutputAfter] - & addExtraRequiredSigners [verificationKeyHash vk] - & setValidityLowerBound startSlotNo - & setValidityUpperBound endSlotNo + defaultTxBodyContent + & addTxIns [(headInput, headWitness)] + & addTxInsReference [headScriptRef] + & addTxOuts [headOutputAfter] + & addTxExtraKeyWits [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 ad3848f5ab6..0776d8b80ee 100644 --- a/hydra-tx/src/Hydra/Tx/CollectCom.hs +++ b/hydra-tx/src/Hydra/Tx/CollectCom.hs @@ -11,11 +11,6 @@ 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, - emptyTxBody, unsafeBuildTransaction, ) import Hydra.Plutus (commitValidatorScript) @@ -51,11 +46,11 @@ collectComTx :: Tx collectComTx networkId scriptRegistry vk headId headParameters (headInput, initialHeadOutput) commits utxoToCollect = unsafeBuildTransaction $ - emptyTxBody - & addInputs ((headInput, headWitness) : (mkCommit <$> Map.keys commits)) - & addReferenceInputs [commitScriptRef, headScriptRef] - & addOutputs [headOutput] - & addExtraRequiredSigners [verificationKeyHash vk] + defaultTxBodyContent + & addTxIns ((headInput, headWitness) : (mkCommit <$> Map.keys commits)) + & addTxInsReference [commitScriptRef, headScriptRef] + & addTxOuts [headOutput] + & addTxExtraKeyWits [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 202179c5473..1c36c5e6f46 100644 --- a/hydra-tx/src/Hydra/Tx/Contest.hs +++ b/hydra-tx/src/Hydra/Tx/Contest.hs @@ -8,12 +8,6 @@ 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, - emptyTxBody, - setValidityUpperBound, unsafeBuildTransaction, ) import Hydra.Plutus.Orphans () @@ -63,12 +57,12 @@ contestTx :: Tx contestTx scriptRegistry vk headId contestationPeriod openVersion snapshot sig (slotNo, _) closedThreadOutput incrementalAction = unsafeBuildTransaction $ - emptyTxBody - & addInputs [(headInput, headWitness)] - & addReferenceInputs [headScriptRef] - & addOutputs [headOutputAfter] - & addExtraRequiredSigners [verificationKeyHash vk] - & setValidityUpperBound slotNo + defaultTxBodyContent + & addTxIns [(headInput, headWitness)] + & addTxInsReference [headScriptRef] + & addTxOuts [headOutputAfter] + & addTxExtraKeyWits [verificationKeyHash vk] + & setTxValidityUpperBound (TxValidityUpperBound slotNo) & setTxMetadata (TxMetadataInEra $ mkHydraHeadV1TxName "ContestTx") where Snapshot{number, version, utxo, utxoToCommit, utxoToDecommit} = snapshot diff --git a/hydra-tx/src/Hydra/Tx/Decrement.hs b/hydra-tx/src/Hydra/Tx/Decrement.hs index f1ea3b1793e..ea6d973eb50 100644 --- a/hydra-tx/src/Hydra/Tx/Decrement.hs +++ b/hydra-tx/src/Hydra/Tx/Decrement.hs @@ -6,11 +6,6 @@ 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, - emptyTxBody, unsafeBuildTransaction, ) import Hydra.Tx.ContestationPeriod (toChain) @@ -43,11 +38,11 @@ decrementTx :: Tx decrementTx scriptRegistry vk headId headParameters (headInput, headOutput) snapshot signatures = unsafeBuildTransaction $ - emptyTxBody - & addInputs [(headInput, headWitness)] - & addReferenceInputs [headScriptRef] - & addOutputs (headOutput' : map toTxContext decommitOutputs) - & addExtraRequiredSigners [verificationKeyHash vk] + defaultTxBodyContent + & addTxIns [(headInput, headWitness)] + & addTxInsReference [headScriptRef] + & addTxOuts (headOutput' : map toTxContext decommitOutputs) + & addTxExtraKeyWits [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 b0f88138dfa..5158c1f95e4 100644 --- a/hydra-tx/src/Hydra/Tx/Fanout.hs +++ b/hydra-tx/src/Hydra/Tx/Fanout.hs @@ -7,12 +7,7 @@ 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, burnTokens, - emptyTxBody, - setValidityLowerBound, unsafeBuildTransaction, ) import Hydra.Tx.ScriptRegistry (ScriptRegistry (..)) @@ -39,12 +34,12 @@ fanoutTx :: Tx fanoutTx scriptRegistry utxo utxoToCommit utxoToDecommit (headInput, headOutput) deadlineSlotNo headTokenScript = unsafeBuildTransaction $ - emptyTxBody - & addInputs [(headInput, headWitness)] - & addReferenceInputs [headScriptRef] - & addOutputs (orderedTxOutsToFanout <> orderedTxOutsToCommit <> orderedTxOutsToDecommit) + defaultTxBodyContent + & addTxIns [(headInput, headWitness)] + & addTxInsReference [headScriptRef] + & addTxOuts (orderedTxOutsToFanout <> orderedTxOutsToCommit <> 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 2a216556062..00395bd8bc5 100644 --- a/hydra-tx/src/Hydra/Tx/Increment.hs +++ b/hydra-tx/src/Hydra/Tx/Increment.hs @@ -9,12 +9,6 @@ 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, - emptyTxBody, - setValidityUpperBound, unsafeBuildTransaction, ) import Hydra.Plutus (depositValidatorScript) @@ -51,12 +45,12 @@ incrementTx :: Tx incrementTx scriptRegistry vk headId headParameters (headInput, headOutput) snapshot depositScriptUTxO upperValiditySlot sigs = unsafeBuildTransaction $ - emptyTxBody - & addInputs [(headInput, headWitness), (depositIn, depositWitness)] - & addReferenceInputs [headScriptRef] - & addOutputs [headOutput'] - & addExtraRequiredSigners [verificationKeyHash vk] - & setValidityUpperBound upperValiditySlot + defaultTxBodyContent + & addTxIns [(headInput, headWitness), (depositIn, depositWitness)] + & addTxInsReference [headScriptRef] + & addTxOuts [headOutput'] + & addTxExtraKeyWits [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 5edd0e859ac..e457fa4b166 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, emptyTxBody, mintTokens, unsafeBuildTransaction) +import Hydra.Ledger.Cardano.Builder (addTxInsSpending, mintTokens, unsafeBuildTransaction) import Hydra.Plutus (initialValidatorScript) import Hydra.Tx.ContestationPeriod (toChain) import Hydra.Tx.HeadParameters (HeadParameters (..)) @@ -28,9 +28,9 @@ initTx :: Tx initTx networkId seedTxIn participants parameters = unsafeBuildTransaction $ - emptyTxBody - & addVkInputs [seedTxIn] - & addOutputs + defaultTxBodyContent + & 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 8c0898b1eec..a18f03c6daa 100644 --- a/hydra-tx/src/Hydra/Tx/Recover.hs +++ b/hydra-tx/src/Hydra/Tx/Recover.hs @@ -7,10 +7,6 @@ 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, - emptyTxBody, - setValidityLowerBound, unsafeBuildTransaction, ) import Hydra.Plutus (depositValidatorScript) @@ -28,10 +24,10 @@ recoverTx :: Tx recoverTx depositTxId deposited lowerBoundSlot = unsafeBuildTransaction $ - emptyTxBody - & addInputs recoverInputs - & addOutputs depositOutputs - & setValidityLowerBound lowerBoundSlot + defaultTxBodyContent + & addTxIns recoverInputs + & addTxOuts depositOutputs + & setTxValidityLowerBound (TxValidityLowerBound lowerBoundSlot) & setTxMetadata (TxMetadataInEra $ mkHydraHeadV1TxName "RecoverTx") where recoverInputs = (,depositWitness) <$> [TxIn depositTxId (TxIx 0)]