Skip to content

Commit

Permalink
Merge pull request #244 from input-output-hk/newhoggy/delete-TxFeesEx…
Browse files Browse the repository at this point in the history
…plicitInEra-and-TxFeesImplicitInEra

Delete `TxFeesExplicitInEra` and `TxFeesImplicitInEra`
  • Loading branch information
newhoggy authored Sep 20, 2023
2 parents ee39ce5 + 37d672e commit 039693b
Show file tree
Hide file tree
Showing 38 changed files with 515 additions and 423 deletions.
2 changes: 2 additions & 0 deletions cardano-api/cardano-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ library internal
Cardano.Api.Eon.AlonzoEraOnly
Cardano.Api.Eon.AlonzoEraOnwards
Cardano.Api.Eon.BabbageEraOnwards
Cardano.Api.Eon.ByronEraOnly
Cardano.Api.Eon.ConwayEraOnwards
Cardano.Api.Eon.ShelleyBasedEra
Cardano.Api.Eon.ShelleyToAllegraEra
Cardano.Api.Eon.ShelleyToAlonzoEra
Cardano.Api.Eon.ShelleyToBabbageEra
Expand Down
8 changes: 4 additions & 4 deletions cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -720,10 +720,10 @@ genTxTotalCollateral era =
TxTotalCollateral supp <$> genPositiveLovelace

genTxFee :: CardanoEra era -> Gen (TxFee era)
genTxFee era =
case txFeesExplicitInEra era of
Left supported -> pure (TxFeeImplicit supported)
Right supported -> TxFeeExplicit supported <$> genLovelace
genTxFee =
caseByronOrShelleyBasedEra
(pure . TxFeeImplicit)
(\w -> TxFeeExplicit w <$> genLovelace)

genTxBody :: IsCardanoEra era => CardanoEra era -> Gen (TxBody era)
genTxBody era = do
Expand Down
1 change: 1 addition & 0 deletions cardano-api/internal/Cardano/Api/Address.hs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ module Cardano.Api.Address (
isKeyAddress
) where

import Cardano.Api.Eon.ShelleyBasedEra
import Cardano.Api.EraCast
import Cardano.Api.Eras
import Cardano.Api.Hash
Expand Down
2 changes: 2 additions & 0 deletions cardano-api/internal/Cardano/Api/Block.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ module Cardano.Api.Block (
makeChainTip,
) where

import Cardano.Api.Eon.ShelleyBasedEra
import Cardano.Api.Eras
import Cardano.Api.Eras.Constraints
import Cardano.Api.Hash
import Cardano.Api.HasTypeProxy
import Cardano.Api.Keys.Shelley
Expand Down
2 changes: 2 additions & 0 deletions cardano-api/internal/Cardano/Api/Certificate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ module Cardano.Api.Certificate (
import Cardano.Api.Address
import Cardano.Api.DRepMetadata
import Cardano.Api.Eon.ConwayEraOnwards
import Cardano.Api.Eon.ShelleyBasedEra
import Cardano.Api.Eon.ShelleyToBabbageEra
import Cardano.Api.EraCast
import Cardano.Api.Eras
import Cardano.Api.Eras.Constraints
import Cardano.Api.Governance.Actions.VotingProcedure
import Cardano.Api.HasTypeProxy
import Cardano.Api.Keys.Praos
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module Cardano.Api.Convenience.Construction (

import Cardano.Api.Address
import Cardano.Api.Certificate
import Cardano.Api.Eras
import Cardano.Api.Eon.ShelleyBasedEra
import Cardano.Api.Fees
import Cardano.Api.ProtocolParameters
import Cardano.Api.Query
Expand Down
1 change: 1 addition & 0 deletions cardano-api/internal/Cardano/Api/Convenience/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import Cardano.Api.Address
import Cardano.Api.Certificate
import Cardano.Api.Convenience.Constraints
import Cardano.Api.Eon.ConwayEraOnwards (ConwayEraOnwards)
import Cardano.Api.Eon.ShelleyBasedEra
import Cardano.Api.Eras
import Cardano.Api.IO
import Cardano.Api.IPC
Expand Down
1 change: 1 addition & 0 deletions cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnly.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module Cardano.Api.Eon.AlonzoEraOnly
, AlonzoEraOnlyConstraints
) where

import Cardano.Api.Eon.ShelleyBasedEra
import Cardano.Api.Eras.Core
import Cardano.Api.Modes
import Cardano.Api.Query.Types
Expand Down
1 change: 1 addition & 0 deletions cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnwards.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module Cardano.Api.Eon.AlonzoEraOnwards
, AlonzoEraOnwardsConstraints
) where

import Cardano.Api.Eon.ShelleyBasedEra
import Cardano.Api.Eras.Core
import Cardano.Api.Modes
import Cardano.Api.Query.Types
Expand Down
1 change: 1 addition & 0 deletions cardano-api/internal/Cardano/Api/Eon/BabbageEraOnwards.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module Cardano.Api.Eon.BabbageEraOnwards
, BabbageEraOnwardsConstraints
) where

import Cardano.Api.Eon.ShelleyBasedEra
import Cardano.Api.Eras.Core
import Cardano.Api.Modes
import Cardano.Api.Query.Types
Expand Down
69 changes: 69 additions & 0 deletions cardano-api/internal/Cardano/Api/Eon/ByronEraOnly.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}

module Cardano.Api.Eon.ByronEraOnly
( ByronEraOnly(..)
, IsByronEraOnly(..)
, AnyByronEraOnly(..)
, byronEraOnlyConstraints
, byronEraOnlyToCardanoEra

, ByronEraOnlyConstraints
) where

import Cardano.Api.Eras.Core

import Data.Typeable (Typeable)

class IsByronEraOnly era where
byronEraOnly :: ByronEraOnly era

data ByronEraOnly era where
ByronEraOnlyByron :: ByronEraOnly ByronEra

deriving instance Show (ByronEraOnly era)
deriving instance Eq (ByronEraOnly era)

instance IsByronEraOnly ByronEra where
byronEraOnly = ByronEraOnlyByron

instance Eon ByronEraOnly where
inEonForEra no yes = \case
ByronEra -> yes ByronEraOnlyByron
ShelleyEra -> no
AllegraEra -> no
MaryEra -> no
AlonzoEra -> no
BabbageEra -> no
ConwayEra -> no

instance ToCardanoEra ByronEraOnly where
toCardanoEra = \case
ByronEraOnlyByron -> ByronEra

data AnyByronEraOnly where
AnyByronEraOnly :: ByronEraOnly era -> AnyByronEraOnly

deriving instance Show AnyByronEraOnly

type ByronEraOnlyConstraints era =
( IsByronEraOnly era
, IsCardanoEra era
, Typeable era
)

byronEraOnlyConstraints :: ()
=> ByronEraOnly era
-> (ByronEraOnlyConstraints era => a)
-> a
byronEraOnlyConstraints = \case
ByronEraOnlyByron -> id

byronEraOnlyToCardanoEra :: ByronEraOnly era -> CardanoEra era
byronEraOnlyToCardanoEra = \case
ByronEraOnlyByron -> ByronEra
1 change: 1 addition & 0 deletions cardano-api/internal/Cardano/Api/Eon/ConwayEraOnwards.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module Cardano.Api.Eon.ConwayEraOnwards
, ConwayEraOnwardsConstraints
) where

import Cardano.Api.Eon.ShelleyBasedEra
import Cardano.Api.Eras.Core
import Cardano.Api.Modes
import Cardano.Api.Query.Types
Expand Down
Loading

0 comments on commit 039693b

Please sign in to comment.