Skip to content

Commit

Permalink
Add LedgerStateBabbage and LedgerStateConway pattern synonyms
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Mar 18, 2023
1 parent 0345419 commit 4fd2edf
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
16 changes: 15 additions & 1 deletion cardano-api/src/Cardano/Api/LedgerState.hs
Expand Up @@ -23,6 +23,8 @@ module Cardano.Api.LedgerState
, LedgerStateAllegra
, LedgerStateMary
, LedgerStateAlonzo
, LedgerStateBabbage
, LedgerStateConway
)
, encodeLedgerState
, decodeLedgerState
Expand Down Expand Up @@ -284,11 +286,23 @@ pattern LedgerStateAlonzo
-> LedgerState
pattern LedgerStateAlonzo st <- LedgerState (Consensus.LedgerStateAlonzo st)

pattern LedgerStateBabbage
:: Ledger.LedgerState (Shelley.ShelleyBlock protocol (Shelley.BabbageEra Shelley.StandardCrypto))
-> LedgerState
pattern LedgerStateBabbage st <- LedgerState (Consensus.LedgerStateBabbage st)

pattern LedgerStateConway
:: Ledger.LedgerState (Shelley.ShelleyBlock protocol (Shelley.ConwayEra Shelley.StandardCrypto))
-> LedgerState
pattern LedgerStateConway st <- LedgerState (Consensus.LedgerStateConway st)

{-# COMPLETE LedgerStateByron
, LedgerStateShelley
, LedgerStateAllegra
, LedgerStateMary
, LedgerStateAlonzo #-}
, LedgerStateAlonzo
, LedgerStateBabbage
, LedgerStateConway #-}

data FoldBlocksError
= FoldBlocksInitialLedgerStateError InitialLedgerStateError
Expand Down
14 changes: 7 additions & 7 deletions cardano-api/src/Cardano/Api/Orphans.hs
Expand Up @@ -47,28 +47,28 @@ import Cardano.Api.Script
import qualified Cardano.Binary as CBOR
import qualified Cardano.Crypto.Hash.Class as Crypto
import qualified Cardano.Ledger.Alonzo.Data as Alonzo
import Cardano.Ledger.Alonzo.Scripts (AlonzoScript)
import Cardano.Ledger.Babbage.PParams (BabbagePParams, BabbagePParamsUpdate)
import qualified Cardano.Ledger.Babbage.PParams as Babbage
import Cardano.Ledger.Babbage.PParams (BabbagePParamsUpdate, BabbagePParams)
import qualified Cardano.Ledger.Babbage.TxBody as Babbage
import qualified Cardano.Ledger.Coin as Shelley
import Cardano.Ledger.Core (EraTxOut)
import qualified Cardano.Ledger.Core as Core
import qualified Cardano.Ledger.Crypto as Crypto
import Cardano.Ledger.Mary.Value (MaryValue (..))
import qualified Cardano.Ledger.Mary.Value as Mary
import qualified Cardano.Ledger.PoolDistr as Ledger
import qualified Cardano.Ledger.SafeHash as SafeHash
import Cardano.Ledger.Val (Val)
import Cardano.Ledger.Shelley.API (ShelleyTxOut (..))
import qualified Cardano.Ledger.Shelley.API as Shelley
import qualified Cardano.Ledger.Mary.Value as Mary
import Cardano.Ledger.Mary.Value (MaryValue(..))
import Cardano.Ledger.Alonzo.Scripts (AlonzoScript)
import Cardano.Ledger.Shelley.API (ShelleyTxOut(..))
import Cardano.Ledger.Val (Val)

import Cardano.Ledger.Babbage.TxBody (BabbageTxOut (..))
import qualified Cardano.Ledger.Shelley.EpochBoundary as ShelleyEpoch
import qualified Cardano.Ledger.Shelley.LedgerState as ShelleyLedger
import Cardano.Ledger.Shelley.PParams (ShelleyPParamsUpdate)
import qualified Cardano.Ledger.Shelley.Rewards as Shelley
import qualified Cardano.Ledger.Shelley.RewardUpdate as Shelley
import Cardano.Ledger.Babbage.TxBody (BabbageTxOut(..))
import qualified Ouroboros.Consensus.Shelley.Eras as Consensus
import qualified Ouroboros.Consensus.Shelley.Ledger.Query as Consensus

Expand Down
11 changes: 9 additions & 2 deletions cardano-client-demo/StakeCredentialHistory.hs
Expand Up @@ -7,15 +7,20 @@

import Cardano.Api
import Cardano.Api.Shelley

import Cardano.Ledger.Address (getRewardAcnt)
import Cardano.Ledger.Alonzo.PParams (AlonzoPParamsHKD (..))
import Cardano.Ledger.Babbage.PParams (BabbagePParamsHKD (..))
import qualified Cardano.Ledger.BaseTypes as L
import Cardano.Ledger.Compactible (Compactible (..))
import qualified Cardano.Ledger.Core as LC
import qualified Cardano.Ledger.Shelley.API as L
import qualified Cardano.Ledger.Shelley.Rewards as L
import qualified Cardano.Ledger.Shelley.RewardUpdate as L
import qualified Cardano.Ledger.UnifiedMap as UM
import Ouroboros.Consensus.Shelley.Eras (StandardCrypto)
import qualified Ouroboros.Consensus.Shelley.Ledger as Shelley

import qualified Codec.Binary.Bech32 as Bech32
import Control.Monad.Trans.Except (runExceptT)
import qualified Data.Binary.Get as B
Expand All @@ -34,8 +39,6 @@ import qualified Data.VMap as VMap
import GHC.Records (HasField (..))
import Options.Applicative (Parser, (<**>), (<|>))
import qualified Options.Applicative as Opt
import Ouroboros.Consensus.Shelley.Eras (StandardCrypto)
import qualified Ouroboros.Consensus.Shelley.Ledger as Shelley

data State = State
{ lastCheckpoint :: SlotNo
Expand Down Expand Up @@ -278,6 +281,10 @@ main = do
("mary", L.nesEL ls, Just (L.nesRu ls, getGoSnapshot ls, getBalances ls, getPV ls))
LedgerStateAlonzo (Shelley.ShelleyLedgerState _ ls _) ->
("alonzo", L.nesEL ls, Just (L.nesRu ls, getGoSnapshot ls, getBalances ls, getPV ls))
LedgerStateBabbage (Shelley.ShelleyLedgerState _ ls _) ->
("babbage", L.nesEL ls, Just (L.nesRu ls, getGoSnapshot ls, getBalances ls, getPV ls))
LedgerStateConway (Shelley.ShelleyLedgerState _ ls _) ->
("conway", L.nesEL ls, Just (L.nesRu ls, getGoSnapshot ls, getBalances ls, getPV ls))

let txBodyComponents = map ( (\(TxBody txbc) -> txbc) . getTxBody ) transactions

Expand Down
1 change: 1 addition & 0 deletions cardano-client-demo/cardano-client-demo.cabal
Expand Up @@ -102,6 +102,7 @@ executable stake-credential-history
cardano-ledger-alonzo,
cardano-api,
cardano-data,
cardano-ledger-babbage,
cardano-ledger-core,
cardano-ledger-shelley,
vector-map,
Expand Down

0 comments on commit 4fd2edf

Please sign in to comment.