-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Core.hs to each era that has a TxBody class
- Loading branch information
Showing
13 changed files
with
144 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
|
||
module Cardano.Ledger.Alonzo.Core | ||
( AlonzoEraTxBody (..) | ||
, ScriptIntegrityHash | ||
) where | ||
|
||
import Cardano.Ledger.ShelleyMA.Core (ShelleyMAEraTxBody) | ||
import Cardano.Ledger.Alonzo.TxOut (AlonzoEraTxOut) | ||
import Lens.Micro (Lens') | ||
import Cardano.Ledger.Core (EraTxBody(..), Era (..), EraIndependentScriptIntegrity) | ||
import Data.Set (Set) | ||
import Cardano.Ledger.TxIn (TxIn(..)) | ||
import Cardano.Ledger.Keys (KeyHash(..), KeyRole (..)) | ||
import Data.Maybe.Strict (StrictMaybe) | ||
import Cardano.Ledger.SafeHash (SafeHash) | ||
import Cardano.Ledger.BaseTypes (Network) | ||
|
||
type ScriptIntegrityHash c = SafeHash c EraIndependentScriptIntegrity | ||
|
||
class (ShelleyMAEraTxBody era, AlonzoEraTxOut era) => AlonzoEraTxBody era where | ||
collateralInputsTxBodyL :: Lens' (TxBody era) (Set (TxIn (EraCrypto era))) | ||
|
||
reqSignerHashesTxBodyL :: Lens' (TxBody era) (Set (KeyHash 'Witness (EraCrypto era))) | ||
|
||
scriptIntegrityHashTxBodyL :: | ||
Lens' (TxBody era) (StrictMaybe (ScriptIntegrityHash (EraCrypto era))) | ||
|
||
networkIdTxBodyL :: Lens' (TxBody era) (StrictMaybe Network) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module Cardano.Ledger.Babbage.Core | ||
( BabbageEraTxBody (..), | ||
) | ||
where | ||
|
||
import Cardano.Ledger.Alonzo.Core (AlonzoEraTxBody) | ||
import Cardano.Ledger.Babbage.TxOut (BabbageEraTxOut) | ||
import Cardano.Ledger.Core (EraTxBody (..), EraTxOut (..), Era (..)) | ||
import Cardano.Ledger.Serialization (Sized (..)) | ||
import Data.Sequence.Strict (StrictSeq) | ||
import Lens.Micro (Lens', SimpleGetter) | ||
import Data.Set (Set) | ||
import Cardano.Ledger.TxIn (TxIn(..)) | ||
import Data.Maybe.Strict (StrictMaybe) | ||
import Cardano.Ledger.Coin (Coin(..)) | ||
|
||
class (AlonzoEraTxBody era, BabbageEraTxOut era) => BabbageEraTxBody era where | ||
sizedOutputsTxBodyL :: Lens' (TxBody era) (StrictSeq (Sized (TxOut era))) | ||
|
||
referenceInputsTxBodyL :: Lens' (TxBody era) (Set (TxIn (EraCrypto era))) | ||
|
||
totalCollateralTxBodyL :: Lens' (TxBody era) (StrictMaybe Coin) | ||
|
||
collateralReturnTxBodyL :: Lens' (TxBody era) (StrictMaybe (TxOut era)) | ||
|
||
sizedCollateralReturnTxBodyL :: Lens' (TxBody era) (StrictMaybe (Sized (TxOut era))) | ||
|
||
allSizedOutputsTxBodyF :: SimpleGetter (TxBody era) (StrictSeq (Sized (TxOut era))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module Cardano.Ledger.Conway.Core | ||
( | ||
) where |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{-# LANGUAGE FlexibleContexts #-} | ||
|
||
module Cardano.Ledger.ShelleyMA.Core | ||
( ShelleyMAEraTxBody (..) | ||
) where | ||
|
||
import Cardano.Ledger.Shelley.Core (ShelleyEraTxBody) | ||
import Cardano.Ledger.Val (EncodeMint, DecodeMint) | ||
import Cardano.Ledger.Core (Value, EraTxBody (..), Era (..)) | ||
import Lens.Micro (Lens', SimpleGetter) | ||
import Cardano.Ledger.ShelleyMA.Timelocks (ValidityInterval(..)) | ||
import Cardano.Ledger.Mary.Value (MultiAsset(..)) | ||
|
||
class | ||
(ShelleyEraTxBody era, EncodeMint (Value era), DecodeMint (Value era)) => | ||
ShelleyMAEraTxBody era | ||
where | ||
vldtTxBodyL :: Lens' (TxBody era) ValidityInterval | ||
|
||
mintTxBodyL :: Lens' (TxBody era) (MultiAsset (EraCrypto era)) | ||
|
||
mintValueTxBodyF :: SimpleGetter (TxBody era) (Value era) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE DerivingVia #-} | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE FlexibleInstances #-} | ||
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | ||
{-# LANGUAGE MultiParamTypeClasses #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE TypeFamilies #-} | ||
{-# LANGUAGE UndecidableInstances #-} | ||
{-# OPTIONS_GHC -Wno-orphans #-} | ||
|
||
module Cardano.Ledger.Shelley.Core | ||
( ShelleyEraTxBody (..), | ||
Wdrl (..), | ||
) | ||
where | ||
|
||
import Cardano.Ledger.Core (Era (..), EraTxBody (..), ExactEra) | ||
import Lens.Micro (Lens') | ||
import Cardano.Ledger.Shelley.Era (ShelleyEra) | ||
import Cardano.Ledger.Slot (SlotNo(..)) | ||
import Data.Maybe.Strict (StrictMaybe) | ||
import Cardano.Ledger.Shelley.PParams (Update) | ||
import Data.Map.Strict (Map) | ||
import Cardano.Ledger.Address (RewardAcnt(..)) | ||
import Cardano.Ledger.Coin (Coin(..)) | ||
import GHC.Generics (Generic) | ||
import NoThunks.Class (NoThunks) | ||
import Control.DeepSeq (NFData) | ||
import Cardano.Ledger.Crypto (Crypto) | ||
import Cardano.Binary (ToCBOR (..), FromCBOR (..)) | ||
import Cardano.Ledger.Serialization (mapToCBOR, mapFromCBOR) | ||
import Data.Sequence.Strict (StrictSeq) | ||
import Cardano.Ledger.Shelley.Delegation.Certificates (DCert) | ||
|
||
class EraTxBody era => ShelleyEraTxBody era where | ||
wdrlsTxBodyL :: Lens' (TxBody era) (Wdrl (EraCrypto era)) | ||
|
||
ttlTxBodyL :: ExactEra ShelleyEra era => Lens' (TxBody era) SlotNo | ||
|
||
updateTxBodyL :: Lens' (TxBody era) (StrictMaybe (Update era)) | ||
|
||
certsTxBodyL :: Lens' (TxBody era) (StrictSeq (DCert (EraCrypto era))) | ||
|
||
newtype Wdrl c = Wdrl {unWdrl :: Map (RewardAcnt c) Coin} | ||
deriving (Show, Eq, Generic) | ||
deriving newtype (NoThunks, NFData) | ||
|
||
instance Crypto c => ToCBOR (Wdrl c) where | ||
toCBOR = mapToCBOR . unWdrl | ||
|
||
instance Crypto c => FromCBOR (Wdrl c) where | ||
fromCBOR = Wdrl <$> mapFromCBOR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters