-
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
Co-authored-by: Alexey Kuleshevich <[email protected]>
- Loading branch information
Showing
12 changed files
with
141 additions
and
60 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,30 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
|
||
module Cardano.Ledger.Alonzo.Core | ||
( AlonzoEraTxBody (..), | ||
ScriptIntegrityHash, | ||
module Cardano.Ledger.ShelleyMA.Core, | ||
) | ||
where | ||
|
||
import Cardano.Ledger.Alonzo.TxOut (AlonzoEraTxOut) | ||
import Cardano.Ledger.BaseTypes (Network) | ||
import Cardano.Ledger.Keys (KeyHash (..), KeyRole (..)) | ||
import Cardano.Ledger.SafeHash (SafeHash) | ||
import Cardano.Ledger.ShelleyMA.Core | ||
import Cardano.Ledger.TxIn (TxIn (..)) | ||
import Data.Maybe.Strict (StrictMaybe) | ||
import Data.Set (Set) | ||
import Lens.Micro (Lens') | ||
|
||
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 (..), | ||
module Cardano.Ledger.Alonzo.Core, | ||
) | ||
where | ||
|
||
import Cardano.Ledger.Alonzo.Core | ||
import Cardano.Ledger.Babbage.TxOut (BabbageEraTxOut) | ||
import Cardano.Ledger.Coin (Coin (..)) | ||
import Cardano.Ledger.Serialization (Sized (..)) | ||
import Cardano.Ledger.TxIn (TxIn (..)) | ||
import Data.Maybe.Strict (StrictMaybe) | ||
import Data.Sequence.Strict (StrictSeq) | ||
import Data.Set (Set) | ||
import Lens.Micro (Lens', SimpleGetter) | ||
|
||
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
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,26 @@ | ||
{-# LANGUAGE FlexibleContexts #-} | ||
|
||
module Cardano.Ledger.ShelleyMA.Core | ||
( ShelleyMAEraTxBody (..), | ||
module Cardano.Ledger.Shelley.Core, | ||
) | ||
where | ||
|
||
import Cardano.Ledger.Mary.Value (MultiAsset (..)) | ||
import Cardano.Ledger.Shelley.Core | ||
import Cardano.Ledger.ShelleyMA.Timelocks (ValidityInterval (..)) | ||
import Cardano.Ledger.Val (DecodeMint, EncodeMint) | ||
import Data.Set (Set) | ||
import Lens.Micro (Lens', SimpleGetter) | ||
|
||
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) | ||
|
||
mintedTxBodyF :: SimpleGetter (TxBody era) (Set (ScriptHash (EraCrypto 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,49 @@ | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE DerivingVia #-} | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE FlexibleInstances #-} | ||
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | ||
|
||
module Cardano.Ledger.Shelley.Core | ||
( ShelleyEraTxBody (..), | ||
Wdrl (..), | ||
module Cardano.Ledger.Core, | ||
) | ||
where | ||
|
||
import Cardano.Binary (FromCBOR (..), ToCBOR (..)) | ||
import Cardano.Ledger.Address (RewardAcnt (..)) | ||
import Cardano.Ledger.Coin (Coin (..)) | ||
import Cardano.Ledger.Core | ||
import Cardano.Ledger.Crypto (Crypto) | ||
import Cardano.Ledger.Serialization (mapFromCBOR, mapToCBOR) | ||
import Cardano.Ledger.Shelley.Delegation.Certificates (DCert) | ||
import Cardano.Ledger.Shelley.Era (ShelleyEra) | ||
import Cardano.Ledger.Shelley.PParams (Update) | ||
import Cardano.Ledger.Slot (SlotNo (..)) | ||
import Control.DeepSeq (NFData) | ||
import Data.Map.Strict (Map) | ||
import Data.Maybe.Strict (StrictMaybe) | ||
import Data.Sequence.Strict (StrictSeq) | ||
import GHC.Generics (Generic) | ||
import Lens.Micro (Lens') | ||
import NoThunks.Class (NoThunks) | ||
|
||
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