Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimbo4350 committed Dec 19, 2023
1 parent 7f246bb commit 4fc8aae
Show file tree
Hide file tree
Showing 17 changed files with 186 additions and 154 deletions.
10 changes: 5 additions & 5 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ packages:
cardano-api
cardano-api-gen

-- package cardano-api
-- ghc-options: -Werror
--
-- package cardano-api-gen
-- ghc-options: -Werror
package cardano-api
ghc-options: -Werror

package cardano-api-gen
ghc-options: -Werror

package cryptonite
-- Using RDRAND instead of /dev/urandom as an entropy source for key
Expand Down
8 changes: 6 additions & 2 deletions cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ import qualified Cardano.Crypto.Hash as Crypto
import qualified Cardano.Crypto.Hash.Class as CRYPTO
import qualified Cardano.Crypto.Seed as Crypto
import qualified Cardano.Ledger.Alonzo.Scripts as Alonzo
import qualified Cardano.Ledger.BaseTypes as Ledger
import qualified Cardano.Ledger.Core as Ledger
import Cardano.Ledger.SafeHash (unsafeMakeSafeHash)

Expand Down Expand Up @@ -897,6 +898,9 @@ genRationalInt64 =
genEpochNo :: Gen EpochNo
genEpochNo = EpochNo <$> Gen.word64 (Range.linear 0 10)

genEpochInterval :: Gen Ledger.EpochInterval
genEpochInterval = Ledger.EpochInterval <$> Gen.word32 (Range.linear 0 10)

genPraosNonce :: Gen PraosNonce
genPraosNonce = makePraosNonce <$> Gen.bytes (Range.linear 0 32)

Expand All @@ -917,7 +921,7 @@ genProtocolParameters era = do
protocolParamStakeAddressDeposit <- genLovelace
protocolParamStakePoolDeposit <- genLovelace
protocolParamMinPoolCost <- genLovelace
protocolParamPoolRetireMaxEpoch <- genEpochNo
protocolParamPoolRetireMaxEpoch <- genEpochInterval
protocolParamStakePoolTargetNum <- genNat
protocolParamPoolPledgeInfluence <- genRationalInt64
protocolParamMonetaryExpansion <- genRational
Expand Down Expand Up @@ -953,7 +957,7 @@ genProtocolParametersUpdate era = do
protocolUpdateStakeAddressDeposit <- Gen.maybe genLovelace
protocolUpdateStakePoolDeposit <- Gen.maybe genLovelace
protocolUpdateMinPoolCost <- Gen.maybe genLovelace
protocolUpdatePoolRetireMaxEpoch <- Gen.maybe genEpochNo
protocolUpdatePoolRetireMaxEpoch <- Gen.maybe genEpochInterval
protocolUpdateStakePoolTargetNum <- Gen.maybe genNat
protocolUpdatePoolPledgeInfluence <- Gen.maybe genRationalInt64
protocolUpdateMonetaryExpansion <- Gen.maybe genRational
Expand Down
6 changes: 3 additions & 3 deletions cardano-api/internal/Cardano/Api/Address.hs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ instance SerialiseAsRawBytes (Address ByronAddr) where
$ addr

deserialiseFromRawBytes (AsAddress AsByronAddr) bs =
case Shelley.deserialiseAddr bs :: Maybe (Shelley.Addr StandardCrypto) of
case Shelley.decodeAddr bs :: Maybe (Shelley.Addr StandardCrypto) of
Nothing -> Left (SerialiseAsRawBytesError "Unable to deserialise Address ByronAddr")
Just Shelley.Addr{} -> Left (SerialiseAsRawBytesError "Unable to deserialise Address ByronAddr")
Just (Shelley.AddrBootstrap (Shelley.BootstrapAddress addr)) ->
Expand All @@ -235,7 +235,7 @@ instance SerialiseAsRawBytes (Address ShelleyAddr) where
Shelley.serialiseAddr (Shelley.Addr nw pc scr)

deserialiseFromRawBytes (AsAddress AsShelleyAddr) bs =
case Shelley.deserialiseAddr bs of
case Shelley.decodeAddr bs of
Nothing -> Left (SerialiseAsRawBytesError "Unable to deserialise bootstrap Address ShelleyAddr")
Just Shelley.AddrBootstrap{} -> Left (SerialiseAsRawBytesError "Unable to deserialise bootstrap Address ShelleyAddr")
Just (Shelley.Addr nw pc scr) -> Right (ShelleyAddress nw pc scr)
Expand Down Expand Up @@ -330,7 +330,7 @@ instance SerialiseAsRawBytes AddressAny where
serialiseToRawBytes (AddressShelley addr) = serialiseToRawBytes addr

deserialiseFromRawBytes AsAddressAny bs =
case Shelley.deserialiseAddr bs of
case Shelley.decodeAddr bs of
Nothing -> Left (SerialiseAsRawBytesError "Unable to deserialise AddressAny")
Just (Shelley.AddrBootstrap (Shelley.BootstrapAddress addr)) ->
Right (AddressByron (ByronAddress addr))
Expand Down
1 change: 0 additions & 1 deletion cardano-api/internal/Cardano/Api/Certificate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ImpredicativeTypes #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE ScopedTypeVariables #-}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ constructBalancedTx :: ()
-> Map.Map StakeCredential Lovelace
-> Map.Map (L.Credential L.DRepRole L.StandardCrypto) Lovelace
-> [ShelleyWitnessSigningKey]
-> Either TxBodyErrorAutoBalance (Tx era)
-> Either (TxBodyErrorAutoBalance era) (Tx era)
constructBalancedTx sbe txbodcontent changeAddr mOverrideWits utxo lpp
ledgerEpochInfo systemStart stakePools
stakeDelegDeposits drepDelegDeposits shelleyWitSigningKeys = do
Expand Down
20 changes: 16 additions & 4 deletions cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnwards.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
module Cardano.Api.Eon.AlonzoEraOnwards
( AlonzoEraOnwards(..)
, alonzoEraOnwardsConstraints
, alonzoEraOnwardsPlutusConstraints
, alonzoEraOnwardsToCardanoEra
, alonzoEraOnwardsToShelleyBasedEra

, AlonzoEraOnwardsConstraints
, AlonzoEraOnwardsPlutusConstraints
) where

import Cardano.Api.Eon.ShelleyBasedEra
Expand All @@ -26,7 +28,7 @@ import Cardano.Binary
import qualified Cardano.Crypto.Hash.Blake2b as Blake2b
import qualified Cardano.Crypto.Hash.Class as C
import qualified Cardano.Crypto.VRF as C
import qualified Cardano.Ledger.Alonzo.Plutus.TxInfo as L
import qualified Cardano.Ledger.Alonzo.Plutus.Context as Plutus
import qualified Cardano.Ledger.Alonzo.Scripts as L
import qualified Cardano.Ledger.Alonzo.Tx as L
import qualified Cardano.Ledger.Alonzo.TxWits as L
Expand All @@ -35,7 +37,6 @@ import qualified Cardano.Ledger.Api as L
import qualified Cardano.Ledger.BaseTypes as L
import qualified Cardano.Ledger.Core as L
import qualified Cardano.Ledger.Mary.Value as L
import qualified Cardano.Ledger.Plutus.Language as L
import qualified Cardano.Ledger.SafeHash as L
import qualified Cardano.Ledger.UTxO as L
import qualified Ouroboros.Consensus.Protocol.Abstract as Consensus
Expand Down Expand Up @@ -105,15 +106,26 @@ type AlonzoEraOnwardsConstraints era =
, Typeable era
)

alonzoEraOnwardsConstraints :: ()
=> AlonzoEraOnwards era
alonzoEraOnwardsConstraints
:: AlonzoEraOnwards era
-> (AlonzoEraOnwardsConstraints era => a)
-> a
alonzoEraOnwardsConstraints = \case
AlonzoEraOnwardsAlonzo -> id
AlonzoEraOnwardsBabbage -> id
AlonzoEraOnwardsConway -> id

type AlonzoEraOnwardsPlutusConstraints era = Plutus.EraPlutusContext (ShelleyLedgerEra era)

alonzoEraOnwardsPlutusConstraints
:: AlonzoEraOnwards era
-> (AlonzoEraOnwardsPlutusConstraints era => a)
-> a
alonzoEraOnwardsPlutusConstraints = \case
AlonzoEraOnwardsAlonzo -> id
AlonzoEraOnwardsBabbage -> id
AlonzoEraOnwardsConway -> id

alonzoEraOnwardsToCardanoEra :: AlonzoEraOnwards era -> CardanoEra era
alonzoEraOnwardsToCardanoEra = shelleyBasedToCardanoEra . alonzoEraOnwardsToShelleyBasedEra

Expand Down
2 changes: 0 additions & 2 deletions cardano-api/internal/Cardano/Api/Eon/ConwayEraOnwards.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import Cardano.Binary
import qualified Cardano.Crypto.Hash.Blake2b as Blake2b
import qualified Cardano.Crypto.Hash.Class as C
import qualified Cardano.Crypto.VRF as C
import qualified Cardano.Ledger.Alonzo.Plutus.TxInfo as L
import qualified Cardano.Ledger.Alonzo.Scripts as L
import qualified Cardano.Ledger.Alonzo.UTxO as L
import qualified Cardano.Ledger.Api as L
Expand All @@ -36,7 +35,6 @@ import qualified Cardano.Ledger.Conway.Governance as L
import qualified Cardano.Ledger.Conway.PParams as L
import qualified Cardano.Ledger.Conway.TxCert as L
import qualified Cardano.Ledger.Mary.Value as L
import qualified Cardano.Ledger.Plutus.Language as L
import qualified Cardano.Ledger.SafeHash as L
import qualified Cardano.Ledger.UTxO as L
import qualified Ouroboros.Consensus.Protocol.Abstract as Consensus
Expand Down
1 change: 1 addition & 0 deletions cardano-api/internal/Cardano/Api/Eon/ShelleyBasedEra.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE EmptyCase #-}

Check warning

Code scanning / HLint

Unused LANGUAGE pragma Warning

cardano-api/internal/Cardano/Api/Eon/ShelleyBasedEra.hs:3:1-26: Warning: Unused LANGUAGE pragma
  
Found:
  {-# LANGUAGE EmptyCase #-}
  
Perhaps you should remove it.
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
Expand Down
Loading

0 comments on commit 4fc8aae

Please sign in to comment.