Skip to content

Commit 85ef6b3

Browse files
cardano-api: 10.8
1 parent 1291e6a commit 85ef6b3

File tree

12 files changed

+32
-36
lines changed

12 files changed

+32
-36
lines changed

cabal.project

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ repository cardano-haskell-packages
1212

1313
-- See CONTRIBUTING.md for information about when and how to update these.
1414
index-state:
15-
, hackage.haskell.org 2025-01-15T13:32:16Z
16-
, cardano-haskell-packages 2025-01-15T09:59:24Z
15+
, hackage.haskell.org 2025-02-01T08:30:11Z
16+
, cardano-haskell-packages 2025-02-01T07:12:29Z
1717

1818
packages:
1919
hydra-prelude

flake.lock

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hydra-cardano-api/hydra-cardano-api.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ library
7878
, aeson >=2
7979
, base >=4.16
8080
, bytestring
81-
, cardano-api ^>=10.6
81+
, cardano-api ^>=10.8
8282
, cardano-api:gen
8383
, cardano-binary
8484
, cardano-crypto-class

hydra-cardano-api/src/Hydra/Cardano/Api.hs

-6
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,6 @@ pattern TxAuxScripts{txAuxScripts'} <-
360360
-- ** TxBody
361361

362362
type TxBody = Cardano.Api.TxBody Era
363-
{-# COMPLETE TxBody #-}
364-
365-
pattern TxBody :: TxBodyContent ViewTx -> TxBody
366-
pattern TxBody{txBodyContent} <-
367-
Cardano.Api.TxBody txBodyContent
368-
{-# COMPLETE TxBody #-}
369363

370364
createAndValidateTransactionBody :: TxBodyContent BuildTx -> Either TxBodyError TxBody
371365
createAndValidateTransactionBody = Cardano.Api.createTransactionBody shelleyBasedEra

hydra-cardano-api/src/Hydra/Cardano/Api/Pretty.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ renderTxWithUTxO utxo (Tx body _wits) =
4848
where
4949
Api.ShelleyTxBody _lbody scripts scriptsData _auxData _validity = body
5050
outs = txOuts content
51-
TxBody content = body
51+
content = getTxBodyContent body
5252

5353
inputLines =
5454
"== INPUTS (" <> show (length (txIns content)) <> ")"

hydra-cardano-api/src/Hydra/Cardano/Api/Tx.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ utxoProducedByTx tx =
5656
zip [0 ..] (txOuts body)
5757
<&> bimap (mkTxIn tx) toCtxUTxOTxOut
5858
where
59-
TxBody body = getTxBody tx
59+
body = getTxBodyContent $ getTxBody tx
6060

6161
-- * Type Conversions
6262

hydra-cardano-api/src/Hydra/Cardano/Api/TxIn.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ withWitness txIn =
2727

2828
-- | Access inputs of a transaction, as an ordered list.
2929
txIns' :: Tx era -> [TxIn]
30-
txIns' (getTxBody -> txBody) =
31-
let TxBody TxBodyContent{txIns} = txBody
30+
txIns' (getTxBodyContent . getTxBody -> txBodyContent) =
31+
let TxBodyContent{txIns} = txBodyContent
3232
in fst <$> txIns
3333

3434
-- | Access inputs of a transaction, as an ordered set.

hydra-cardano-api/src/Hydra/Cardano/Api/TxOut.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import PlutusLedgerApi.V3 qualified as Plutus
2020
-- * Extras
2121

2222
txOuts' :: Tx era -> [TxOut CtxTx era]
23-
txOuts' (getTxBody -> txBody) =
24-
let TxBody TxBodyContent{txOuts} = txBody
23+
txOuts' (getTxBodyContent . getTxBody -> txBody) =
24+
let TxBodyContent{txOuts} = txBody
2525
in txOuts
2626

2727
-- | Modify a 'TxOut' to set the minimum ada on the value.

hydra-chain-observer/src/Hydra/Ouroborus/ChainObserver.hs

+10-11
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ import Hydra.Cardano.Api (
2020
SocketPath,
2121
UTxO,
2222
connectToLocalNode,
23+
getBlockHeader,
24+
getBlockTxs,
2325
getChainPoint,
2426
getTxBody,
2527
getTxId,
26-
pattern Block,
2728
)
2829
import Hydra.Chain.CardanoClient (queryTip)
2930
import Hydra.Chain.Direct.Handlers (convertObservation)
@@ -131,21 +132,19 @@ chainSyncClient tracer networkId startingPoint observerHandler =
131132
clientStNext utxo =
132133
ClientStNext
133134
{ recvMsgRollForward = \blockInMode _tip -> ChainSyncClient $ do
134-
let receivedTxIds = case blockInMode of
135-
BlockInMode ConwayEra (Block _ conwayTxs) -> getTxId . getTxBody <$> conwayTxs
136-
_ -> []
135+
let block = case blockInMode of
136+
BlockInMode ConwayEra block -> Just block
137+
_ -> Nothing
137138

138-
(BlockInMode _ (Block bh@(BlockHeader _ _ blockNo) _)) = blockInMode
139+
txs = getBlockTxs <$> maybeToList block
140+
bh@(BlockHeader _ _ blockNo) = getBlockHeader block
139141
point = getChainPoint bh
140-
traceWith tracer RollForward{point, receivedTxIds}
141-
142-
let txs = case blockInMode of
143-
BlockInMode ConwayEra (Block _ conwayTxs) -> conwayTxs
144-
_ -> []
145-
142+
receivedTxIds = getTxId . getTxBody <$> txs
146143
(utxo', observations) = observeAll networkId utxo txs
147144
onChainTxs = mapMaybe convertObservation observations
148145

146+
traceWith tracer RollForward{point, receivedTxIds}
147+
149148
forM_ onChainTxs (traceWith tracer . logOnChainTx)
150149
let observationsAt = ChainObservation point blockNo . Just <$> onChainTxs
151150
observerHandler $

hydra-node/src/Hydra/Chain/Direct.hs

+5-2
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ import Hydra.Cardano.Api (
4343
TxValidationErrorInCardanoMode,
4444
chainTipToChainPoint,
4545
connectToLocalNode,
46+
getBlockHeader,
47+
getBlockTxs,
4648
getTxBody,
4749
getTxId,
4850
toLedgerUTxO,
49-
pattern Block,
5051
)
5152
import Hydra.Chain (
5253
ChainComponent,
@@ -320,7 +321,9 @@ chainSyncClient handler wallet startingPoint =
320321
ClientStNext
321322
{ recvMsgRollForward = \blockInMode _tip -> ChainSyncClient $ do
322323
case blockInMode of
323-
BlockInMode ConwayEra (Block header txs) -> do
324+
BlockInMode ConwayEra block -> do
325+
let header = getBlockHeader block
326+
let txs = getBlockTxs block
324327
-- Update the tiny wallet
325328
update wallet header txs
326329
-- Observe Hydra transactions

hydra-tx/test/Hydra/Tx/Contract/FanOut.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ genFanoutMutation (tx, _utxo) =
148148
]
149149
where
150150
burntTokens =
151-
case toList . txMintValueToValue . txMintValue $ txBodyContent $ txBody tx of
151+
case toList . txMintValueToValue . txMintValue $ getTxBodyContent $ txBody tx of
152152
[] -> error "expected minted value"
153153
v -> v
154154

hydra-tx/testlib/Test/Hydra/Tx/Mutation.hs

+4-4
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ changeMintedValueQuantityFrom tx exclude = do
671671
someQuantity <- fromInteger <$> arbitrary `suchThat` (/= exclude) `suchThat` (/= 0)
672672
pure $ ChangeMintedValue $ fromList $ map (second $ const someQuantity) $ toList mintedValue
673673
where
674-
mintedValue = txMintValueToValue $ txMintValue $ txBodyContent $ txBody tx
674+
mintedValue = txMintValueToValue $ txMintValue $ getTxBodyContent $ txBody tx
675675

676676
-- | A 'Mutation' that changes the minted/burned quantity of tokens like this:
677677
-- - when no value is being minted/burned -> add a value
@@ -680,7 +680,7 @@ changeMintedTokens :: Tx -> Value -> Gen Mutation
680680
changeMintedTokens tx mintValue =
681681
pure $ ChangeMintedValue $ mintedValue <> mintValue
682682
where
683-
mintedValue = txMintValueToValue $ txMintValue $ txBodyContent $ txBody tx
683+
mintedValue = txMintValueToValue $ txMintValue $ getTxBodyContent $ txBody tx
684684

685685
-- | A `Mutation` that adds an `Arbitrary` participation token with some quantity.
686686
-- As usual the quantity can be positive for minting, or negative for burning.
@@ -697,7 +697,7 @@ addPTWithQuantity tx quantity =
697697
pkh <- arbitrary
698698
pure $ mintedValue <> fromList [(AssetId pid pkh, quantity)]
699699
where
700-
mintedValue = txMintValueToValue $ txMintValue $ txBodyContent $ txBody tx
700+
mintedValue = txMintValueToValue $ txMintValue $ getTxBodyContent $ txBody tx
701701

702702
-- | Replace first given 'PolicyId' with the second argument in the whole 'TxOut' value.
703703
replacePolicyIdWith :: PolicyId -> PolicyId -> TxOut a -> TxOut a
@@ -928,7 +928,7 @@ replaceContesters contesters = \case
928928

929929
removePTFromMintedValue :: TxOut CtxUTxO -> Tx -> Value
930930
removePTFromMintedValue output tx =
931-
case toList $ txMintValueToValue $ txMintValue $ txBodyContent $ txBody tx of
931+
case toList $ txMintValueToValue $ txMintValue $ getTxBodyContent $ txBody tx of
932932
[] -> error "expected minted value"
933933
v -> fromList $ filter (not . isPT) v
934934
where

0 commit comments

Comments
 (0)