Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/haskell-wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,3 @@ jobs:
else
echo 'Build complete'
fi

25 changes: 13 additions & 12 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ repository cardano-haskell-packages
-- See CONTRIBUTING for information about these, including some Nix commands
-- you need to run if you change them
index-state:
, hackage.haskell.org 2026-02-06T20:27:32Z
, cardano-haskell-packages 2026-03-02T22:40:26Z
, hackage.haskell.org 2026-02-17T10:15:41Z
, cardano-haskell-packages 2026-03-13T13:31:40Z

packages:
cardano-api
Expand Down Expand Up @@ -134,23 +134,15 @@ if arch(wasm32)
source-repository-package
type: git
location: https://github.com/palas/mempack.git
tag: 0211addbbbf51011e5348d3696566eb12ccbef07
--sha256: sha256-iLc+foF2AM3vG6deuZ51+faI6buMkubMP75md51hMe8=
tag: 3514811b33741c4ac37d6f78b01f5d33088f6303
--sha256: sha256-fATs5q/l+gs5qJnzqxW0pe/EqjdwxKYcBcGKrbU4L+Y=

source-repository-package
type: git
location: https://github.com/haskell-wasm/network
tag: ab92e48e9fdf3abe214f85fdbe5301c1280e14e9
--sha256: sha256-U+ln/gbXoQZpNjZHydNa0FG/9GdJFgL1+T3+7KTzDWo=

source-repository-package
type: git
location: https://github.com/palas/fs-sim
tag: c39efe618cf63df909e8e0acab31684b10223550
--sha256: sha256-zHJfVFEzdeq9WhInEIRCJ1OQTYM06k++9gzfUaG//S8=
subdir:
fs-sim

package cardano-crypto-praos
flags: -external-libsodium-vrf

Expand Down Expand Up @@ -190,3 +182,12 @@ source-repository-package
-- IMPORTANT
-- Do NOT add more source-repository-package stanzas here unless they are strictly
-- temporary! Please read the section in CONTRIBUTING about updating dependencies.

-- geo2a/bump-ntc
source-repository-package
type: git
location: https://github.com/IntersectMBO/ouroboros-consensus
tag: 250801097384604ebb926dabdbc5a94255822377
--sha256: sha256-bGhdMYf9rnVn235mI2EIccqLODPwZR90Ft6HXTu5cdY=
subdir:
.
48 changes: 21 additions & 27 deletions cardano-api/cardano-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,18 @@ library
cardano-addresses ^>=4.0.0,
cardano-binary,
cardano-crypto,
cardano-crypto-class ^>=2.2.3.2,
cardano-crypto-wrapper ^>=1.6,
cardano-crypto-class ^>=2.3,
cardano-crypto-wrapper ^>=1.7,
cardano-data >=1.0,
cardano-diffusion:{api, cardano-diffusion} ^>=1.0,
cardano-ledger-allegra >=1.7,
cardano-ledger-alonzo >=1.13,
cardano-ledger-api ^>=1.12.1,
cardano-ledger-alonzo >=1.15,
cardano-ledger-api ^>=1.13,
cardano-ledger-babbage >=1.11,
cardano-ledger-binary >=1.6,
cardano-ledger-byron >=1.2,
cardano-ledger-conway >=1.19,
cardano-ledger-core >=1.17 && <1.19,
cardano-ledger-core >=1.17 && <1.20,
cardano-ledger-dijkstra >=0.1,
cardano-ledger-mary >=1.8,
cardano-ledger-shelley >=1.16,
Expand All @@ -158,21 +159,16 @@ library
groups,
iproute,
memory,
microlens,
mempack,
microlens <0.5,
mono-traversable,
mtl,
network,
network-mux,
nothunks,
ordered-containers,
ouroboros-consensus ^>=0.30.0.1,
ouroboros-consensus-cardano ^>=0.26,
ouroboros-consensus-diffusion ^>=0.26,
ouroboros-consensus-protocol ^>=0.13,
ouroboros-network ^>=0.22.6.0,
ouroboros-network-api >=0.15,
ouroboros-network-framework,
ouroboros-network-protocols >=0.15,
ouroboros-consensus:{cardano, diffusion, ouroboros-consensus, protocol} ^>=1.0,
ouroboros-network:{api, framework, ouroboros-network, protocols} ^>=1.0,
parsec,
plutus-core ^>=1.59,
plutus-ledger-api ^>=1.59,
Expand All @@ -193,7 +189,7 @@ library
time,
transformers,
transformers-except ^>=0.1.3,
typed-protocols >=1.0,
typed-protocols ^>=1.2,
validation,
vector,
yaml,
Expand Down Expand Up @@ -324,13 +320,13 @@ library gen
base16-bytestring,
bytestring,
cardano-api,
cardano-binary >=1.6 && <1.8,
cardano-crypto-class,
cardano-crypto-test ^>=1.6,
cardano-binary >=1.6 && <1.9,
cardano-crypto-class ^>=2.3,
cardano-crypto-wrapper:testlib ^>=1.7,
cardano-ledger-alonzo:{cardano-ledger-alonzo, testlib} >=1.8.1,
cardano-ledger-byron:testlib,
cardano-ledger-conway:testlib,
cardano-ledger-core:{cardano-ledger-core, testlib} >=1.14,
cardano-ledger-core:{cardano-ledger-core, testlib} >=1.17,
cardano-ledger-dijkstra:testlib >=0.1,
cardano-ledger-shelley >=1.13,
cardano-strict-containers,
Expand Down Expand Up @@ -362,15 +358,14 @@ test-suite cardano-api-test
cardano-api:gen,
cardano-binary,
cardano-crypto,
cardano-crypto-class,
cardano-crypto-tests ^>=2.2,
cardano-crypto-class:{cardano-crypto-class, testlib} ^>=2.3,
cardano-crypto-wrapper:testlib,
cardano-ledger-alonzo,
cardano-ledger-api ^>=1.12.1,
cardano-ledger-api ^>=1.13,
cardano-ledger-babbage,
cardano-ledger-binary,
cardano-ledger-conway,
cardano-ledger-core >=1.14,
cardano-ledger-core,
cardano-ledger-mary,
cardano-ledger-shelley,
cardano-protocol-tpraos,
Expand All @@ -386,8 +381,7 @@ test-suite cardano-api-test
microlens,
mtl,
ordered-containers,
ouroboros-consensus,
ouroboros-consensus-protocol,
ouroboros-consensus:{ouroboros-consensus, protocol},
raw-strings-qq,
tasty,
tasty-hedgehog,
Expand Down Expand Up @@ -444,9 +438,9 @@ test-suite cardano-api-golden
cardano-crypto-class,
cardano-data >=1.0,
cardano-ledger-alonzo,
cardano-ledger-api ^>=1.12.1,
cardano-ledger-api ^>=1.13,
cardano-ledger-binary,
cardano-ledger-core >=1.14,
cardano-ledger-core,
cardano-ledger-shelley,
cardano-protocol-tpraos,
containers,
Expand Down
38 changes: 27 additions & 11 deletions cardano-api/gen/Test/Gen/Cardano/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ module Test.Gen.Cardano.Api
)
where

import Cardano.Api.Genesis (defaultV1CostModel)

import Cardano.Ledger.Alonzo.Core qualified as Ledger
import Cardano.Ledger.Alonzo.Genesis qualified as Alonzo
import Cardano.Ledger.Alonzo.Scripts qualified as Alonzo
import Cardano.Ledger.Alonzo.Scripts qualified as L
import Cardano.Ledger.BaseTypes qualified as Ledger
import Cardano.Ledger.Coin qualified as Ledger
import Cardano.Ledger.Plutus.CostModels qualified as Plutus
Expand Down Expand Up @@ -97,22 +100,35 @@ genAlonzoGenesis :: Gen Alonzo.AlonzoGenesis
genAlonzoGenesis = do
coinsPerUTxOWord <- genCoin (Range.linear 0 5)
-- TODO: Babbage: Figure out how to deal with the asymmetric cost model JSON
_costmdls' <- genCostModels
costmdls' <- genCostModels
v1CostModel <- case Map.lookup Alonzo.PlutusV1 $ L.costModelsValid costmdls' of
Just cm -> return cm
Nothing -> return defaultV1CostModel

let v2OnwardsCostModels =
mconcat $
map
( \l -> case l `Map.lookup` L.costModelsValid costmdls' of
Just cm -> Map.singleton l cm
Nothing -> Map.empty
)
[Alonzo.PlutusV2 .. maxBound]
extraConfig = Just $ Alonzo.AlonzoExtraConfig $ Just $ L.mkCostModels v2OnwardsCostModels
prices' <- genPrices
maxTxExUnits' <- genExUnits
maxBlockExUnits' <- genExUnits
maxValSize' <- Gen.integral (Range.linear 0 10)
collateralPercentage' <- Gen.integral (Range.linear 0 10)
maxCollateralInputs' <- Gen.integral (Range.linear 0 10)

return
return $
Alonzo.AlonzoGenesis
{ Alonzo.agCoinsPerUTxOWord = Ledger.CoinPerWord coinsPerUTxOWord
, Alonzo.agCostModels = mempty
, Alonzo.agPrices = prices'
, Alonzo.agMaxTxExUnits = maxTxExUnits'
, Alonzo.agMaxBlockExUnits = maxBlockExUnits'
, Alonzo.agMaxValSize = maxValSize'
, Alonzo.agCollateralPercentage = collateralPercentage'
, Alonzo.agMaxCollateralInputs = maxCollateralInputs'
}
(Ledger.CoinPerWord coinsPerUTxOWord)
v1CostModel
prices'
maxTxExUnits'
maxBlockExUnits'
maxValSize'
collateralPercentage'
maxCollateralInputs'
extraConfig
10 changes: 5 additions & 5 deletions cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ import Cardano.Crypto.Seed qualified as Crypto
import Cardano.Ledger.Alonzo.Scripts qualified as Alonzo
import Cardano.Ledger.BaseTypes qualified as Ledger
import Cardano.Ledger.Core qualified as Ledger
import Cardano.Ledger.Hashes (unsafeMakeSafeHash)
import Cardano.Ledger.Plutus.Language qualified as L
import Cardano.Ledger.SafeHash (unsafeMakeSafeHash)

import Control.Applicative (Alternative (..), optional)
import Control.Monad
Expand Down Expand Up @@ -736,7 +736,7 @@ genTxValidityLowerBound =
-- TODO: Accept a range for generating ttl.
genTxValidityUpperBound :: ShelleyBasedEra era -> Gen (TxValidityUpperBound era)
genTxValidityUpperBound sbe =
TxValidityUpperBound sbe <$> Gen.maybe genTtl
TxValidityUpperBound sbe . Ledger.maybeToStrictMaybe <$> Gen.maybe genTtl

genTxMetadataInEra :: CardanoEra era -> Gen (TxMetadataInEra era)
genTxMetadataInEra =
Expand Down Expand Up @@ -1338,9 +1338,9 @@ genProtocolParametersUpdate era = do
protocolUpdatePrices <- Gen.maybe genExecutionUnitPrices
protocolUpdateMaxTxExUnits <- Gen.maybe genExecutionUnits
protocolUpdateMaxBlockExUnits <- Gen.maybe genExecutionUnits
protocolUpdateMaxValueSize <- Gen.maybe genNat
protocolUpdateCollateralPercent <- Gen.maybe genNat
protocolUpdateMaxCollateralInputs <- Gen.maybe genNat
protocolUpdateMaxValueSize <- Gen.maybe genWord32
protocolUpdateCollateralPercent <- Gen.maybe genWord16
protocolUpdateMaxCollateralInputs <- Gen.maybe genWord16
protocolUpdateUTxOCostPerByte <-
inEonForEra @BabbageEraOnwards (pure Nothing) (const (Just <$> genLovelace)) era

Expand Down
31 changes: 16 additions & 15 deletions cardano-api/src/Cardano/Api/Address.hs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ import Cardano.Chain.Common qualified as Byron
import Cardano.Ledger.Address qualified as Shelley
import Cardano.Ledger.BaseTypes qualified as Shelley
import Cardano.Ledger.Credential qualified as Shelley
import Cardano.Ledger.Keys qualified as Shelley
import Cardano.Ledger.Plutus.TxInfo qualified as Plutus
import PlutusLedgerApi.V1 qualified as PlutusAPI

Expand Down Expand Up @@ -183,7 +184,7 @@ data Address addrtype where
-- in Shelley era and are thus supported from the Shelley era onwards
ShelleyAddress
:: Shelley.Network
-> Shelley.PaymentCredential
-> Shelley.Credential Shelley.Payment
-> Shelley.StakeReference
-> Address ShelleyAddr

Expand Down Expand Up @@ -527,7 +528,7 @@ makeShelleyAddressInEra sbe nw pc scr =
data StakeAddress where
StakeAddress
:: Shelley.Network
-> Shelley.StakeCredential
-> Shelley.Credential Shelley.Staking
-> StakeAddress
deriving (Eq, Ord, Show)

Expand Down Expand Up @@ -567,12 +568,12 @@ instance HasTypeProxy StakeAddress where

instance SerialiseAsRawBytes StakeAddress where
serialiseToRawBytes (StakeAddress nw sc) =
Shelley.serialiseRewardAccount (Shelley.RewardAccount nw sc)
Shelley.serialiseAccountAddress (Shelley.AccountAddress nw (Shelley.AccountId sc))

deserialiseFromRawBytes AsStakeAddress bs =
case Shelley.deserialiseRewardAccount bs of
case Shelley.deserialiseAccountAddress bs of
Nothing -> Left (SerialiseAsRawBytesError "Unable to deserialise StakeAddress")
Just (Shelley.RewardAccount nw sc) -> Right (StakeAddress nw sc)
Just (Shelley.AccountAddress nw (Shelley.AccountId sc)) -> Right (StakeAddress nw sc)

instance SerialiseAsBech32 StakeAddress where
bech32PrefixFor (StakeAddress Shelley.Mainnet _) = unsafeHumanReadablePartFromText "stake"
Expand Down Expand Up @@ -643,24 +644,24 @@ toShelleyAddr
) =
Shelley.Addr nw pc scr

toShelleyStakeAddr :: StakeAddress -> Shelley.RewardAccount
toShelleyStakeAddr :: StakeAddress -> Shelley.AccountAddress
toShelleyStakeAddr (StakeAddress nw sc) =
Shelley.RewardAccount
{ Shelley.raNetwork = nw
, Shelley.raCredential = sc
Shelley.AccountAddress
{ Shelley.aaNetworkId = nw
, Shelley.aaId = Shelley.AccountId sc
}

toShelleyPaymentCredential
:: PaymentCredential
-> Shelley.PaymentCredential
-> Shelley.Credential Shelley.Payment
toShelleyPaymentCredential (PaymentCredentialByKey (PaymentKeyHash kh)) =
Shelley.KeyHashObj kh
toShelleyPaymentCredential (PaymentCredentialByScript sh) =
Shelley.ScriptHashObj (toShelleyScriptHash sh)

toShelleyStakeCredential
:: StakeCredential
-> Shelley.StakeCredential
-> Shelley.Credential Shelley.Staking
toShelleyStakeCredential (StakeCredentialByKey (StakeKeyHash kh)) =
Shelley.KeyHashObj kh
toShelleyStakeCredential (StakeCredentialByScript sh) =
Expand Down Expand Up @@ -700,19 +701,19 @@ fromShelleyAddr sbe (Shelley.Addr nw pc scr) =
(ShelleyAddressInEra sbe)
(ShelleyAddress nw pc scr)

fromShelleyStakeAddr :: Shelley.RewardAccount -> StakeAddress
fromShelleyStakeAddr (Shelley.RewardAccount nw sc) = StakeAddress nw sc
fromShelleyStakeAddr :: Shelley.AccountAddress -> StakeAddress
fromShelleyStakeAddr (Shelley.AccountAddress nw (Shelley.AccountId sc)) = StakeAddress nw sc

fromShelleyStakeCredential
:: Shelley.StakeCredential
:: Shelley.Credential Shelley.Staking
-> StakeCredential
fromShelleyStakeCredential (Shelley.KeyHashObj kh) =
StakeCredentialByKey (StakeKeyHash kh)
fromShelleyStakeCredential (Shelley.ScriptHashObj sh) =
StakeCredentialByScript (fromShelleyScriptHash sh)

fromShelleyPaymentCredential
:: Shelley.PaymentCredential
:: Shelley.Credential Shelley.Payment
-> PaymentCredential
fromShelleyPaymentCredential (Shelley.KeyHashObj kh) =
PaymentCredentialByKey (PaymentKeyHash kh)
Expand Down
3 changes: 2 additions & 1 deletion cardano-api/src/Cardano/Api/Block.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import Data.ByteString qualified as BS
import Data.ByteString.Short qualified as SBS
import Data.Foldable (Foldable (toList))
import Data.Text (Text)
import Lens.Micro

-- ----------------------------------------------------------------------------
-- Blocks in an era
Expand Down Expand Up @@ -174,7 +175,7 @@ getShelleyBlockTxs
-> [Tx era]
getShelleyBlockTxs era (Ledger.Block _header txs) =
[ ShelleyTx era txinblock
| txinblock <- toList (Ledger.fromTxSeq txs)
| txinblock <- toList (txs ^. Ledger.txSeqBlockBodyL)
]

-- ----------------------------------------------------------------------------
Expand Down
Loading
Loading