Skip to content

Commit

Permalink
Create an Era-specific wrapper for defaultTxBodyContent
Browse files Browse the repository at this point in the history
This avoids mentioning "Babbage" in downstream packages like
hydra-cluster and will reduce the number of places to switch.
  • Loading branch information
ch1bo committed Dec 6, 2023
1 parent 67e685a commit ccbb69a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions hydra-cardano-api/src/Hydra/Cardano/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import Cardano.Api as X hiding (
UTxO (..),
Witness (..),
createAndValidateTransactionBody,
defaultTxBodyContent,
makeShelleyKeyWitness,
policyId,
queryEraHistory,
Expand Down Expand Up @@ -369,6 +370,9 @@ pattern TxBody{txBodyContent} <-
createAndValidateTransactionBody :: TxBodyContent BuildTx -> Either TxBodyError TxBody
createAndValidateTransactionBody = Cardano.Api.createAndValidateTransactionBody cardanoEra

defaultTxBodyContent :: TxBodyContent BuildTx
defaultTxBodyContent = Cardano.Api.defaultTxBodyContent cardanoEra

-- ** TxBodyContent

type TxBodyContent build = Cardano.Api.TxBodyContent build Era
Expand Down
2 changes: 1 addition & 1 deletion hydra-cluster/src/CardanoClient.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ buildScriptAddress script networkId =
buildRaw :: [TxIn] -> [TxOut CtxTx] -> Lovelace -> Either TxBodyError TxBody
buildRaw ins outs fee =
createAndValidateTransactionBody $
defaultTxBodyContent BabbageEra
defaultTxBodyContent
& setTxIns (map (,BuildTxWith $ KeyWitness KeyWitnessForSpending) ins)
& setTxOuts outs
& setTxFee (TxFeeExplicit fee)
Expand Down
2 changes: 1 addition & 1 deletion hydra-test-utils/src/Test/Plutus/Validator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ transactionBodyFromScript validatorScript redeemer =
body =
either (error . show) id $
createAndValidateTransactionBody $
defaultTxBodyContent BabbageEra
defaultTxBodyContent
& addTxIn (defaultTxIn, scriptWitness)
& setTxInsCollateral (TxInsCollateral mempty)
& setTxProtocolParams (BuildTxWith $ Just $ LedgerProtocolParameters pparams)
Expand Down
2 changes: 1 addition & 1 deletion hydraw/src/Hydra/Painter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ mkPaintTx (txin, txOut) sk Pixel{x, y, red, green, blue} = do
pure $ signShelleyTransaction ShelleyBasedEraBabbage body [WitnessPaymentKey sk]
where
bodyContent =
defaultTxBodyContent BabbageEra
defaultTxBodyContent
& addTxIn (txin, BuildTxWith $ KeyWitness KeyWitnessForSpending)
& addTxOut (toTxContext txOut)
& setTxFee (TxFeeExplicit $ Lovelace 0)
Expand Down

0 comments on commit ccbb69a

Please sign in to comment.