Skip to content

Commit

Permalink
cardano-api: 8.46 -> 8.47
Browse files Browse the repository at this point in the history
  • Loading branch information
locallycompact committed Jul 15, 2024
1 parent 0d5b516 commit 63c6404
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 23 deletions.
2 changes: 1 addition & 1 deletion cardano-api-classy/cardano-api-classy.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ library
-- dependencies on cardano-ledger* follow.
build-depends:
, base >=4.16
, cardano-api ^>=8.46
, cardano-api ^>=8.47
, cardano-ledger-alonzo
, cardano-ledger-conway
, cardano-ledger-core
2 changes: 1 addition & 1 deletion hydra-cardano-api/hydra-cardano-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ library
, base >=4.16
, base16-bytestring
, bytestring
, cardano-api ^>=8.46
, cardano-api ^>=8.47
, cardano-api-classy
, cardano-binary
, cardano-crypto-class
Expand Down
6 changes: 6 additions & 0 deletions hydra-cardano-api/src/Hydra/Cardano/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@ pattern TxBodyContent ::
TxScriptValidity ->
Maybe (Featured ConwayEraOnwards Era (TxProposalProcedures buidl Era)) ->
Maybe (Featured ConwayEraOnwards Era (TxVotingProcedures buidl Era)) ->
Maybe (Featured ConwayEraOnwards Era Coin) ->
Maybe (Featured ConwayEraOnwards Era Coin) ->
TxBodyContent buidl
pattern TxBodyContent
{ txIns
Expand All @@ -425,6 +427,8 @@ pattern TxBodyContent
, txScriptValidity
, txProposalProcedures
, txVotingProcedures
, txCurrentTreasuryValue
, txTreasuryDonation
} <-
Cardano.Api.TxBodyContent
txIns
Expand All @@ -447,6 +451,8 @@ pattern TxBodyContent
txScriptValidity
txProposalProcedures
txVotingProcedures
txCurrentTreasuryValue
txTreasuryDonation
where
TxBodyContent = Cardano.Api.TxBodyContent

Expand Down
1 change: 1 addition & 0 deletions hydra-cluster/hydra-cluster.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ library
, async
, base >=4.7 && <5
, bytestring
, cardano-api
, cardano-slotting
, containers
, contra-tracer
Expand Down
5 changes: 3 additions & 2 deletions hydra-cluster/src/Hydra/Generator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Hydra.Generator where
import Hydra.Cardano.Api
import Hydra.Prelude hiding (size)

import Cardano.Api.Ledger (PParams)
import Cardano.Api.UTxO qualified as UTxO
import CardanoClient (mkGenesisTx)
import Control.Monad (foldM)
Expand Down Expand Up @@ -72,8 +73,8 @@ data ClientDataset = ClientDataset
deriving stock (Show, Generic)
deriving anyclass (ToJSON, FromJSON)

defaultProtocolParameters :: ProtocolParameters
defaultProtocolParameters = fromLedgerPParams ShelleyBasedEraShelley def
defaultProtocolParameters :: PParams LedgerEra
defaultProtocolParameters = def

-- | Generate 'Dataset' which does not grow the per-client UTXO set over time.
-- The sequence of transactions generated consist only of simple payments from
Expand Down
5 changes: 1 addition & 4 deletions hydra-node/src/Hydra/API/HTTPServer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import Hydra.API.APIServerLog (APIServerLog (..), Method (..), PathInfo (..))
import Hydra.Cardano.Api (
LedgerEra,
Tx,
fromLedgerPParams,
shelleyBasedEra,
)
import Hydra.Chain (Chain (..), CommitBlueprintTx (..), IsChainState, PostTxError (..), draftCommitTx)
import Hydra.Chain.Direct.State ()
Expand Down Expand Up @@ -148,8 +146,7 @@ httpApp tracer directChain pparams getInitializingHeadId getConfirmedUTxO reques
>>= handleDraftCommitUtxo directChain getInitializingHeadId
>>= respond
("GET", ["protocol-parameters"]) ->
respond . responseLBS status200 [] . Aeson.encode $
fromLedgerPParams shelleyBasedEra pparams
respond . responseLBS status200 [] . Aeson.encode $ pparams
("POST", ["cardano-transaction"]) ->
consumeRequestBodyStrict request
>>= handleSubmitUserTx directChain
Expand Down
2 changes: 2 additions & 0 deletions hydra-node/src/Hydra/Chain/CardanoClient.hs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ buildTransaction networkId socket changeAddress utxoToSpend collateral outs = do
TxScriptValidityNone
Nothing
Nothing
Nothing
Nothing

-- | Submit a (signed) transaction to the node.
--
Expand Down
2 changes: 2 additions & 0 deletions hydra-node/src/Hydra/Ledger/Cardano/Builder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ emptyTxBody =
TxScriptValidityNone
Nothing
Nothing
Nothing
Nothing

-- | Add new inputs to an ongoing builder.
addInputs :: TxIns BuildTx -> TxBodyContent BuildTx -> TxBodyContent BuildTx
Expand Down
4 changes: 1 addition & 3 deletions hydra-node/test/Hydra/API/HTTPServerSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import Data.Aeson.Lens (key, nth)
import Hydra.API.HTTPServer (DraftCommitTxRequest (..), DraftCommitTxResponse (..), SubmitTxRequest (..), TransactionSubmitted, httpApp)
import Hydra.API.ServerSpec (dummyChainHandle)
import Hydra.Cardano.Api (
fromLedgerPParams,
serialiseToTextEnvelope,
shelleyBasedEra,
)
import Hydra.Chain (Chain (draftCommitTx), PostTxError (..))
import Hydra.Chain.Direct.Fixture (defaultPParams)
Expand Down Expand Up @@ -103,7 +101,7 @@ apiServerSpec = do
it "responds given parameters" $
get "/protocol-parameters"
`shouldRespondWith` 200
{ matchBody = matchJSON $ fromLedgerPParams shelleyBasedEra defaultPParams
{ matchBody = matchJSON defaultPParams
}

describe "GET /snapshot/utxo" $ do
Expand Down
19 changes: 7 additions & 12 deletions hydra-node/test/Hydra/Ledger/CardanoSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ spec =

prop "Roundtrip to and from Api" roundtripFromAndToApi

describe "ProtocolParameters" $
prop "Roundtrip JSON encoding" roundtripProtocolParameters
describe "PParamss" $
prop "Roundtrip JSON encoding" roundtripPParams

describe "Tx" $ do
roundtripAndGoldenSpecs (Proxy @(ReasonablySized Tx))
Expand Down Expand Up @@ -114,19 +114,14 @@ roundtripFromAndToApi :: UTxO -> Property
roundtripFromAndToApi utxo =
fromApi (toApi utxo) === utxo

-- | Test that the 'ProtocolParameters' To/FromJSON instances to roundtrip. Note
-- that we use the ledger 'PParams' type to generate values, but the cardano-api
-- type 'ProtocolParameters' is used for the serialization.
roundtripProtocolParameters :: PParams LedgerEra -> Property
roundtripProtocolParameters pparams = do
case Aeson.decode (Aeson.encode expected) of
-- | Test that the 'PParams' To/FromJSON instances to roundtrip.
roundtripPParams :: PParams LedgerEra -> Property
roundtripPParams pparams = do
case Aeson.decode (Aeson.encode pparams) of
Nothing ->
property False
Just actual ->
(expected === actual)
& counterexample ("ledger: " <> show pparams)
where
expected = fromLedgerPParams shelleyBasedEra pparams
pparams === actual

roundtripTxId :: Tx -> Property
roundtripTxId tx@(Tx body _) =
Expand Down

0 comments on commit 63c6404

Please sign in to comment.