Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose AcquireFailure and SystemStart from Cardano.Api.Shelley #4199

Merged
merged 1 commit into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cardano-api/src/Cardano/Api/Shelley.hs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ module Cardano.Api.Shelley
SerialisedPoolState(..),
decodePoolState,
UTxO(..),
AcquireFailure(..),
SystemStart(..),


-- ** Various calculations
LeadershipError(..),
Expand All @@ -232,8 +235,8 @@ import Cardano.Api.Address
import Cardano.Api.Block
import Cardano.Api.Certificate
import Cardano.Api.Eras
import Cardano.Api.InMode
import Cardano.Api.IPC
import Cardano.Api.InMode
import Cardano.Api.KeysByron
import Cardano.Api.KeysPraos
import Cardano.Api.KeysShelley
Expand Down
2 changes: 0 additions & 2 deletions cardano-cli/src/Cardano/CLI/Shelley/Commands.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ import Cardano.Api.Shelley

import Data.Text (Text)

import Ouroboros.Consensus.BlockchainTime (SystemStart (..))

import Cardano.CLI.Shelley.Key (PaymentVerifier, StakeVerifier, VerificationKeyOrFile,
VerificationKeyOrHashOrFile, VerificationKeyTextOrFile)
import Cardano.CLI.Types
Expand Down
1 change: 0 additions & 1 deletion cardano-cli/src/Cardano/CLI/Shelley/Output.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import Prelude

import Cardano.Api
import Cardano.Api.Shelley
import Cardano.Slotting.Time (SystemStart (..))
import Data.Aeson
import qualified Data.Aeson.Key as Aeson
import qualified Data.List as List
Expand Down
1 change: 0 additions & 1 deletion cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import qualified Text.Parsec.Token as Parsec

import qualified Cardano.Ledger.BaseTypes as Shelley
import qualified Cardano.Ledger.Shelley.TxBody as Shelley
import Ouroboros.Consensus.BlockchainTime (SystemStart (..))

import Cardano.Api
import Cardano.Api.Shelley
Expand Down
36 changes: 19 additions & 17 deletions cardano-cli/src/Cardano/CLI/Shelley/Run/Genesis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module Cardano.CLI.Shelley.Run.Genesis
) where

import Cardano.Prelude hiding (unlines)
import Prelude (id, unlines, zip3, error)
import Prelude (error, id, unlines, zip3)

import Data.Aeson hiding (Key)
import qualified Data.Aeson as Aeson
Expand All @@ -42,14 +42,15 @@ import qualified Data.Sequence.Strict as Seq
import Data.String (fromString)
import qualified Data.Text as Text
import qualified Data.Text.IO as Text
import Data.Time.Clock (NominalDiffTime, UTCTime, addUTCTime, getCurrentTime, secondsToNominalDiffTime)
import Data.Time.Clock (NominalDiffTime, UTCTime, addUTCTime, getCurrentTime,
secondsToNominalDiffTime)

import Cardano.Binary (ToCBOR (..), Annotated(Annotated))
import Cardano.Binary (Annotated (Annotated), ToCBOR (..))

import qualified Cardano.Crypto as CC
import Cardano.Crypto.Hash (HashAlgorithm)
import qualified Cardano.Crypto.Hash as Hash
import qualified Cardano.Crypto.Random as Crypto
import qualified Cardano.Crypto as CC
import Crypto.Random as Crypto

import System.Directory (createDirectoryIfMissing, listDirectory)
Expand All @@ -62,10 +63,10 @@ import Control.Monad.Trans.Except.Extra (firstExceptT, handleIOExceptT
import qualified Cardano.Crypto.Hash as Crypto

import Cardano.Api
import Cardano.Api.Byron (toByronRequiresNetworkMagic, toByronProtocolMagicId, toByronLovelace)
import Cardano.Api.Byron (toByronLovelace, toByronProtocolMagicId,
toByronRequiresNetworkMagic)
import Cardano.Api.Shelley

import Ouroboros.Consensus.BlockchainTime (SystemStart (..))
import Ouroboros.Consensus.Shelley.Eras (StandardShelley)
import Ouroboros.Consensus.Shelley.Node (ShelleyGenesisStaking (..))

Expand All @@ -92,29 +93,30 @@ import Cardano.CLI.Shelley.Run.StakeAddress (ShelleyStakeAddressCmdErr
import Cardano.CLI.Types

import Cardano.CLI.Byron.Delegation
import Cardano.CLI.Byron.Genesis as Byron
import qualified Cardano.CLI.Byron.Key as Byron
import qualified Cardano.Chain.Common as Byron (KeyHash, mkKnownLovelace, rationalToLovelacePortion)
import Cardano.Chain.Genesis (FakeAvvmOptions (..), TestnetBalanceOptions (..),
gdProtocolParameters, gsDlgIssuersSecrets, gsPoorSecrets, gsRichSecrets)
import qualified Cardano.Crypto.Signing as Byron
import Cardano.CLI.Byron.Genesis as Byron
import Cardano.Chain.Genesis (FakeAvvmOptions (..), TestnetBalanceOptions (..), gsDlgIssuersSecrets, gsRichSecrets, gsPoorSecrets, gdProtocolParameters)
import qualified Cardano.Chain.Common as Byron (rationalToLovelacePortion, mkKnownLovelace, KeyHash)

import Cardano.Chain.Common (BlockCount(unBlockCount))
import qualified Cardano.Chain.Genesis as Genesis
import Cardano.Chain.Delegation (delegateVK)
import Cardano.Api.SerialiseTextEnvelope (textEnvelopeToJSON)
import Cardano.Chain.Common (BlockCount (unBlockCount))
import Cardano.Chain.Delegation (delegateVK)
import qualified Cardano.Chain.Delegation as Dlg
import Cardano.Slotting.Slot (EpochSize(EpochSize))
import qualified Cardano.Chain.Genesis as Genesis
import Cardano.Chain.Update
import Data.Fixed (Fixed(MkFixed))
import Cardano.Slotting.Slot (EpochSize (EpochSize))
import Data.Fixed (Fixed (MkFixed))
import qualified Data.Yaml as Yaml
import Text.JSON.Canonical (parseCanonicalJSON, renderCanonicalJSON)

import Data.ListMap (ListMap(..))
import Data.ListMap (ListMap (..))

import qualified Cardano.CLI.IO.Lazy as Lazy

import System.Random (StdGen)
import qualified System.Random as Random
import System.Random (StdGen)

data ShelleyGenesisCmdError
= ShelleyGenesisCmdAesonDecodeError !FilePath !Text
Expand Down Expand Up @@ -917,7 +919,7 @@ writeBulkPoolCredentials dir bulkIx poolIxs = do
Aeson.eitherDecodeStrict' content

-- | This function should only be used for testing purposes.
-- Keys returned by this function are not cryptographically secure.
-- Keys returned by this function are not cryptographically secure.
computeInsecureDelegation
:: StdGen
-> NetworkId
Expand Down
50 changes: 26 additions & 24 deletions cardano-cli/src/Cardano/CLI/Shelley/Run/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module Cardano.CLI.Shelley.Run.Query
, renderShelleyQueryCmdError
, renderLocalStateQueryError
, runQueryCmd
, determineEra
, mergeDelegsAndRewards
, percentage
, executeQuery
Expand All @@ -32,6 +33,30 @@ import qualified Cardano.Api as Api
import Cardano.Api.Byron
import Cardano.Api.Orphans ()
import Cardano.Api.Shelley

import Control.Monad.Trans.Except (except)
import Control.Monad.Trans.Except.Extra (firstExceptT, handleIOExceptT, hoistEither,
hoistMaybe, left, newExceptT)
import Data.Aeson.Encode.Pretty (encodePretty)
import Data.Aeson.Types as Aeson
import qualified Data.ByteString.Lazy.Char8 as LBS
import Data.Coerce (coerce)
import Data.List (nub)
import qualified Data.Map.Strict as Map
import qualified Data.Set as Set
import Data.Sharing (Interns, Share)
import qualified Data.Text as Text
import qualified Data.Text.Encoding as Text
import qualified Data.Text.IO as T
import qualified Data.Text.IO as Text
import Data.Text.Lazy.Builder (toLazyText)
import Data.Time.Clock
import qualified Data.VMap as VMap
import qualified Data.Vector as Vector
import Formatting.Buildable (build)
import Numeric (showEFloat)
import Text.Printf (printf)

import Cardano.Binary (DecoderError)
import Cardano.CLI.Environment (EnvSocketError, readEnvSocketPath, renderEnvSocketError)
import Cardano.CLI.Helpers (HelpersError (..), hushM, pPrintCBOR, renderHelpersError)
Expand Down Expand Up @@ -64,36 +89,13 @@ import qualified Cardano.Ledger.Shelley.LedgerState as SL
import qualified Cardano.Ledger.Shelley.PParams as Shelley
import Cardano.Ledger.Shelley.Scripts ()
import Cardano.Slotting.EpochInfo (EpochInfo (..), epochInfoSlotToUTCTime, hoistEpochInfo)
import Control.Monad.Trans.Except (except)
import Control.Monad.Trans.Except.Extra (firstExceptT, handleIOExceptT, hoistEither,
hoistMaybe, left, newExceptT)
import Data.Aeson.Encode.Pretty (encodePretty)
import Data.Aeson.Types as Aeson
import Data.Coerce (coerce)
import Data.List (nub)
import Data.Sharing (Interns, Share)
import Data.Text.Lazy.Builder (toLazyText)
import Data.Time.Clock

import Ouroboros.Consensus.BlockchainTime.WallClock.Types (RelativeTime (..),
SystemStart (..), toRelativeTime)
toRelativeTime)
import Ouroboros.Consensus.Cardano.Block as Consensus (EraMismatch (..))
import Ouroboros.Consensus.Protocol.TPraos
import Ouroboros.Network.Block (Serialised (..))
import Ouroboros.Network.Protocol.LocalStateQuery.Type (AcquireFailure (..))
import Text.Printf (printf)

import qualified Data.ByteString.Lazy.Char8 as LBS
import qualified Data.Map.Strict as Map
import qualified Data.Set as Set
import qualified Data.Text as Text
import qualified Data.Text.Encoding as Text
import qualified Data.Text.IO as T
import qualified Data.Text.IO as Text
import qualified Data.Vector as Vector
import qualified Data.VMap as VMap
import Formatting.Buildable (build)
import Numeric (showEFloat)
import qualified Ouroboros.Consensus.HardFork.History as Consensus
import qualified Ouroboros.Consensus.Protocol.Abstract as Consensus
import qualified Ouroboros.Consensus.Protocol.Praos.Common as Consensus
Expand Down
4 changes: 2 additions & 2 deletions cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}

module Cardano.CLI.Shelley.Run.Transaction
( ShelleyTxCmdError
( ShelleyTxCmdError(..)
, renderShelleyTxCmdError
, runTransactionCmd
, readFileTx
) where

import Cardano.Prelude hiding (All, Any)
Expand Down Expand Up @@ -60,7 +61,6 @@ import Ouroboros.Consensus.Cardano.Block (EraMismatch (..))
import Ouroboros.Consensus.Ledger.SupportsMempool (ApplyTxErr)
import qualified Ouroboros.Consensus.Protocol.TPraos as TPraos
import Ouroboros.Consensus.Shelley.Ledger (ShelleyBlock)
import Ouroboros.Network.Protocol.LocalStateQuery.Type (AcquireFailure (..))
import qualified Ouroboros.Network.Protocol.LocalTxSubmission.Client as Net.Tx

import qualified System.IO as IO
Expand Down