Skip to content

Commit

Permalink
Merge pull request #1358 from input-output-hk/lc/cardano-api-8.40
Browse files Browse the repository at this point in the history
cardano-api: 8.39 -> 8.40
  • Loading branch information
locallycompact authored Mar 15, 2024
2 parents da73c47 + fbc27eb commit 7e56603
Show file tree
Hide file tree
Showing 25 changed files with 76 additions and 106 deletions.
4 changes: 2 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ repository cardano-haskell-packages

-- See CONTRIBUTING.md for information about when and how to update these.
index-state:
, hackage.haskell.org 2024-02-22T15:07:04Z
, cardano-haskell-packages 2024-02-22T19:04:02Z
, hackage.haskell.org 2024-03-14T15:07:04Z
, cardano-haskell-packages 2024-03-14T19:04:02Z

packages:
cardano-api-classy
Expand Down
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 @@ -52,7 +52,7 @@ library

build-depends:
, base >=4.16
, cardano-api >=8.39.0 && <8.40
, cardano-api >=8.40.0 && <8.41
, cardano-ledger-alonzo >=1.6 && <1.7
, cardano-ledger-conway >=1.12 && <1.13
, cardano-ledger-core >=1.10 && <1.11
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions hydra-cardano-api/hydra-cardano-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ library
Hydra.Cardano.Api.ExecutionUnits
Hydra.Cardano.Api.Hash
Hydra.Cardano.Api.KeyWitness
Hydra.Cardano.Api.Lovelace
Hydra.Cardano.Api.Network
Hydra.Cardano.Api.NetworkId
Hydra.Cardano.Api.PlutusScript
Expand Down Expand Up @@ -83,7 +82,7 @@ library
, base >=4.16
, base16-bytestring
, bytestring
, cardano-api >=8.39.0 && <8.40
, cardano-api >=8.40.0 && <8.41
, cardano-api-classy
, cardano-binary >=1.7.0 && <1.8
, cardano-crypto-class >=2.1.1 && <2.2
Expand All @@ -93,7 +92,6 @@ library
, cardano-ledger-babbage >=1.6 && <1.7
, cardano-ledger-binary >=1.3 && <1.4
, cardano-ledger-byron >=1.0.0 && <1.1
, cardano-ledger-conway >=1.12 && <1.13
, cardano-ledger-core >=1.10 && <1.11
, cardano-ledger-mary >=1.5 && <1.6
, cardano-ledger-shelley >=1.9 && <1.10
Expand Down
6 changes: 3 additions & 3 deletions hydra-cardano-api/src/Hydra/Cardano/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ import Cardano.Api.UTxO (
UTxO,
UTxO' (..),
)
import Cardano.Ledger.Coin as X (Coin (..))
import Hydra.Cardano.Api.Prelude (
Era,
LedgerEra,
Expand All @@ -128,7 +129,6 @@ import Hydra.Cardano.Api.CtxUTxO as Extras
import Hydra.Cardano.Api.ExecutionUnits as Extras
import Hydra.Cardano.Api.Hash as Extras
import Hydra.Cardano.Api.KeyWitness as Extras
import Hydra.Cardano.Api.Lovelace as Extras
import Hydra.Cardano.Api.NetworkId ()
import Hydra.Cardano.Api.PlutusScript as Extras
import Hydra.Cardano.Api.PolicyId as Extras
Expand Down Expand Up @@ -202,7 +202,7 @@ pattern ShelleyAddressInAnyEra <-
type BalancedTxBody = Cardano.Api.BalancedTxBody Era
{-# COMPLETE BalancedTxBody #-}

pattern BalancedTxBody :: TxBodyContent BuildTx -> TxBody -> TxOut CtxTx -> Lovelace -> BalancedTxBody
pattern BalancedTxBody :: TxBodyContent BuildTx -> TxBody -> TxOut CtxTx -> Coin -> BalancedTxBody
pattern BalancedTxBody{balancedTxBodyContent, balancedTxBody, balancedTxChangeOutput, balancedTxFee} <-
Cardano.Api.BalancedTxBody balancedTxBodyContent balancedTxBody balancedTxChangeOutput balancedTxFee
where
Expand Down Expand Up @@ -493,7 +493,7 @@ pattern TxExtraKeyWitnesses{txExtraKeyWitnesses} <-
type TxFee = Cardano.Api.TxFee Era
{-# COMPLETE TxFeeExplicit #-}

pattern TxFeeExplicit :: Lovelace -> TxFee
pattern TxFeeExplicit :: Coin -> TxFee
pattern TxFeeExplicit{txFeeExplicit} <-
Cardano.Api.TxFeeExplicit _ txFeeExplicit
where
Expand Down
21 changes: 0 additions & 21 deletions hydra-cardano-api/src/Hydra/Cardano/Api/Lovelace.hs

This file was deleted.

3 changes: 2 additions & 1 deletion hydra-cardano-api/src/Hydra/Cardano/Api/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Cardano.Api.UTxO qualified as UTxO
import Cardano.Ledger.Alonzo.TxWits qualified as Ledger
import Cardano.Ledger.Babbage.Tx qualified as Ledger
import Cardano.Ledger.BaseTypes (maybeToStrictMaybe, strictMaybeToMaybe)
import Cardano.Ledger.Coin (Coin (..))
import Cardano.Ledger.Core qualified as Ledger (Tx, hashScript)
import Data.Bifunctor (bimap)
import Data.Functor ((<&>))
Expand Down Expand Up @@ -62,7 +63,7 @@ utxoProducedByTx tx =
TxBody body = getTxBody tx

-- | Get explicit fees allocated to a transaction.
txFee' :: Tx era -> Lovelace
txFee' :: Tx era -> Coin
txFee' (getTxBody -> TxBody body) =
case txFee body of
TxFeeExplicit _ y -> y
Expand Down
7 changes: 2 additions & 5 deletions hydra-cardano-api/src/Hydra/Cardano/Api/Value.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ minUTxOValue ::
TxOut CtxTx Era ->
Value
minUTxOValue pparams (TxOut addr val dat ref) =
fromLedgerLovelace $
lovelaceToValue $
getMinCoinTxOut
pparams
(toShelleyTxOut shelleyBasedEra (toUTxOContext out'))
Expand All @@ -43,10 +43,7 @@ minUTxOValue pparams (TxOut addr val dat ref) =
-- already large enough lovelace to acknowledge for the increase in size to
-- come.
defaultHighEnoughValue =
lovelaceToValue $ Lovelace $ toInteger $ maxBound @Word64

fromLedgerLovelace =
lovelaceToValue . fromShelleyLovelace
lovelaceToValue $ Coin $ toInteger $ maxBound @Word64

-- | Count number of assets in a 'Value'.
valueSize :: Value -> Int
Expand Down
1 change: 1 addition & 0 deletions hydra-chain-observer/hydra-chain-observer.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ common project-config
OverloadedStrings
PartialTypeSignatures
PatternGuards
PatternSynonyms
RankNTypes
ScopedTypeVariables
StandaloneDeriving
Expand Down
4 changes: 2 additions & 2 deletions hydra-chain-observer/src/Hydra/ChainObserver.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module Hydra.ChainObserver where
import Hydra.Prelude

import Hydra.Cardano.Api (
Block (..),
BlockHeader (BlockHeader),
BlockInMode (..),
BlockNo,
Expand All @@ -28,6 +27,7 @@ import Hydra.Cardano.Api (
getChainPoint,
getTxBody,
getTxId,
pattern Block,
)
import Hydra.Cardano.Api.Prelude (TxId)
import Hydra.Chain (OnChainTx (..))
Expand Down Expand Up @@ -165,7 +165,7 @@ chainSyncClient tracer networkId startingPoint observerHandler =
}

clientStIdle :: UTxO -> ClientStIdle BlockType ChainPoint ChainTip m ()
clientStIdle utxo = SendMsgRequestNext (clientStNext utxo) (pure $ clientStNext utxo)
clientStIdle utxo = SendMsgRequestNext (pure ()) (clientStNext utxo)

clientStNext :: UTxO -> ClientStNext BlockType ChainPoint ChainTip m ()
clientStNext utxo =
Expand Down
10 changes: 5 additions & 5 deletions hydra-cluster/src/CardanoClient.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ buildScriptAddress script networkId =
in makeShelleyAddress networkId (PaymentCredentialByScript hashed) NoStakeAddress

-- | Build a "raw" transaction from a bunch of inputs, outputs and fees.
buildRaw :: [TxIn] -> [TxOut CtxTx] -> Lovelace -> Either TxBodyError TxBody
buildRaw :: [TxIn] -> [TxOut CtxTx] -> Coin -> Either TxBodyError TxBody
buildRaw ins outs fee =
createAndValidateTransactionBody $
defaultTxBodyContent
& setTxIns (map (,BuildTxWith $ KeyWitness KeyWitnessForSpending) ins)
& setTxOuts outs
& setTxFee (TxFeeExplicit fee)

calculateMinFee :: NetworkId -> TxBody -> Sizes -> ProtocolParameters -> Lovelace
calculateMinFee :: NetworkId -> TxBody -> Sizes -> ProtocolParameters -> Coin
calculateMinFee networkId body Sizes{inputs, outputs, witnesses} pparams =
let tx = makeSignedTransaction [] body
noByronWitnesses = 0
Expand Down Expand Up @@ -88,7 +88,7 @@ submitTx RunningNode{networkId, nodeSocket} =
waitForPayments ::
NetworkId ->
SocketPath ->
Lovelace ->
Coin ->
Address ShelleyAddr ->
IO UTxO
waitForPayments networkId socket amount addr =
Expand Down Expand Up @@ -130,9 +130,9 @@ mkGenesisTx ::
-- | Owner of the 'initialFund'.
SigningKey PaymentKey ->
-- | Amount of initialFunds
Lovelace ->
Coin ->
-- | Recipients and amounts to pay in this transaction.
[(VerificationKey PaymentKey, Lovelace)] ->
[(VerificationKey PaymentKey, Coin)] ->
Tx
mkGenesisTx networkId pparams signingKey initialAmount recipients =
case buildRaw [initialInput] (recipientOutputs <> [changeOutput]) fee of
Expand Down
14 changes: 7 additions & 7 deletions hydra-cluster/src/Hydra/Cluster/Faucet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ instance Exception FaucetException

data FaucetLog
= TraceResourceExhaustedHandled Text
| ReturnedFunds {actor :: String, returnAmount :: Lovelace}
| ReturnedFunds {actor :: String, returnAmount :: Coin}
deriving stock (Eq, Show, Generic)
deriving anyclass (ToJSON, FromJSON)

Expand All @@ -50,7 +50,7 @@ seedFromFaucet ::
-- | Recipient of the funds
VerificationKey PaymentKey ->
-- | Amount to get from faucet
Lovelace ->
Coin ->
Tracer IO FaucetLog ->
IO UTxO
seedFromFaucet node@RunningNode{networkId, nodeSocket} receivingVerificationKey lovelace tracer = do
Expand Down Expand Up @@ -78,11 +78,11 @@ seedFromFaucet node@RunningNode{networkId, nodeSocket} receivingVerificationKey
TxOutDatumNone
ReferenceScriptNone

findFaucetUTxO :: RunningNode -> Lovelace -> IO UTxO
findFaucetUTxO :: RunningNode -> Coin -> IO UTxO
findFaucetUTxO RunningNode{networkId, nodeSocket} lovelace = do
(faucetVk, _) <- keysFor Faucet
faucetUTxO <- queryUTxO networkId nodeSocket QueryTip [buildAddress faucetVk networkId]
let foundUTxO = UTxO.filter (\o -> txOutLovelace o >= lovelace) faucetUTxO
let foundUTxO = UTxO.filter (\o -> (selectLovelace . txOutValue) o >= lovelace) faucetUTxO
when (null foundUTxO) $
throwIO $
FaucetHasNotEnoughFunds{faucetUTxO}
Expand All @@ -94,7 +94,7 @@ seedFromFaucet_ ::
-- | Recipient of the funds
VerificationKey PaymentKey ->
-- | Amount to get from faucet
Lovelace ->
Coin ->
Tracer IO FaucetLog ->
IO ()
seedFromFaucet_ node vk ll tracer =
Expand Down Expand Up @@ -183,8 +183,8 @@ calculateTxFee ::
SigningKey PaymentKey ->
UTxO ->
AddressInEra ->
Lovelace ->
IO Lovelace
Coin ->
IO Coin
calculateTxFee RunningNode{networkId, nodeSocket} secretKey utxo addr lovelace =
let theOutput = TxOut addr (lovelaceToValue lovelace) TxOutDatumNone ReferenceScriptNone
in buildTransaction networkId nodeSocket addr utxo [] [theOutput] >>= \case
Expand Down
8 changes: 4 additions & 4 deletions hydra-cluster/src/Hydra/Cluster/Scenarios.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import Hydra.API.HTTPServer (
TxOutWithWitness (..),
)
import Hydra.Cardano.Api (
Coin (..),
File (File),
Lovelace (..),
PlutusScriptV2,
Tx,
TxId,
Expand Down Expand Up @@ -108,7 +108,7 @@ data EndToEndLog
| FromHydraNode HydraNodeLog
| FromMithril MithrilLog
| StartingFunds {actor :: String, utxo :: UTxO}
| RefueledFunds {actor :: String, refuelingAmount :: Lovelace, utxo :: UTxO}
| RefueledFunds {actor :: String, refuelingAmount :: Coin, utxo :: UTxO}
| RemainingFunds {actor :: String, utxo :: UTxO}
| PublishedHydraScriptsAt {hydraScriptsTxId :: TxId}
| UsingHydraScriptsAt {hydraScriptsTxId :: TxId}
Expand Down Expand Up @@ -518,7 +518,7 @@ canSubmitTransactionThroughAPI tracer workDir node hydraScriptsTxId =
carolsOutput =
TxOut
carolsAddress
(lovelaceToValue $ Lovelace 2_000_000)
(lovelaceToValue $ Coin 2_000_000)
TxOutDatumNone
ReferenceScriptNone
-- prepare fully balanced tx body
Expand Down Expand Up @@ -630,7 +630,7 @@ refuelIfNeeded ::
Tracer IO EndToEndLog ->
RunningNode ->
Actor ->
Lovelace ->
Coin ->
IO ()
refuelIfNeeded tracer node actor amount = do
(actorVk, _) <- keysFor actor
Expand Down
4 changes: 2 additions & 2 deletions hydra-cluster/src/Hydra/Generator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ genDatasetConstantUTxO faucetSk pparams nClients nTxs = do
-- 'externalSigningKey' "some" lovelace. The internal 'signingKey' will get
-- funded in the beginning of the benchmark run.
clientFunds <- forM clientKeys $ \ClientKeys{externalSigningKey} -> do
amount <- Lovelace <$> choose (1, availableInitialFunds `div` fromIntegral nClients)
amount <- Coin <$> choose (1, availableInitialFunds `div` fromIntegral nClients)
pure (getVerificationKey externalSigningKey, amount)
let fundingTransaction =
mkGenesisTx
networkId
pparams
faucetSk
(Lovelace availableInitialFunds)
(Coin availableInitialFunds)
clientFunds
clientDatasets <- forM clientKeys (generateClientDataset fundingTransaction)
pure Dataset{fundingTransaction, clientDatasets, title = Nothing, description = Nothing}
Expand Down
Loading

0 comments on commit 7e56603

Please sign in to comment.