Skip to content

Commit

Permalink
Remove use of AnyConsensusMode
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Oct 26, 2023
1 parent dc5ed4e commit 3c32641
Show file tree
Hide file tree
Showing 12 changed files with 130 additions and 220 deletions.
36 changes: 18 additions & 18 deletions cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ data QueryCmds era

data QueryLeadershipScheduleCmdArgs = QueryLeadershipScheduleCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, consensusModeParams :: !(ConsensusModeParams CardanoMode)
, networkId :: !NetworkId
, genesisFp :: !GenesisFile
, poolColdVerKeyFile :: !(VerificationKeyOrHashOrFile StakePoolKey)
Expand All @@ -71,95 +71,95 @@ data QueryLeadershipScheduleCmdArgs = QueryLeadershipScheduleCmdArgs

data QueryProtocolParametersCmdArgs = QueryProtocolParametersCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, consensusModeParams :: !(ConsensusModeParams CardanoMode)
, networkId :: !NetworkId
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

data QueryConstitutionHashCmdArgs = QueryConstitutionHashCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, consensusModeParams :: !(ConsensusModeParams CardanoMode)
, networkId :: !NetworkId
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

data QueryTipCmdArgs = QueryTipCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, consensusModeParams :: !(ConsensusModeParams CardanoMode)
, networkId :: !NetworkId
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

data QueryStakePoolsCmdArgs = QueryStakePoolsCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, consensusModeParams :: !(ConsensusModeParams CardanoMode)
, networkId :: !NetworkId
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

data QueryStakeDistributionCmdArgs = QueryStakeDistributionCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, consensusModeParams :: !(ConsensusModeParams CardanoMode)
, networkId :: !NetworkId
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

data QueryStakeAddressInfoCmdArgs = QueryStakeAddressInfoCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, consensusModeParams :: !(ConsensusModeParams CardanoMode)
, addr :: !StakeAddress
, networkId :: !NetworkId
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

data QueryUTxOCmdArgs = QueryUTxOCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, consensusModeParams :: !(ConsensusModeParams CardanoMode)
, queryFilter :: !QueryUTxOFilter
, networkId :: !NetworkId
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

data QueryLedgerStateCmdArgs = QueryLedgerStateCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, consensusModeParams :: !(ConsensusModeParams CardanoMode)
, networkId :: !NetworkId
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

data QueryProtocolStateCmdArgs = QueryProtocolStateCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, consensusModeParams :: !(ConsensusModeParams CardanoMode)
, networkId :: !NetworkId
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

data QueryStakeSnapshotCmdArgs = QueryStakeSnapshotCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, consensusModeParams :: !(ConsensusModeParams CardanoMode)
, networkId :: !NetworkId
, allOrOnlyPoolIds :: !(AllOrOnly [Hash StakePoolKey])
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

data QueryKesPeriodInfoCmdArgs = QueryKesPeriodInfoCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, consensusModeParams :: !(ConsensusModeParams CardanoMode)
, networkId :: !NetworkId
, nodeOpCertFp :: !(File () In) -- ^ Node operational certificate
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

data QueryPoolStateCmdArgs = QueryPoolStateCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, consensusModeParams :: !(ConsensusModeParams CardanoMode)
, networkId :: !NetworkId
, poolIds :: ![Hash StakePoolKey]
} deriving (Generic, Show)

data QueryTxMempoolCmdArgs = QueryTxMempoolCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, consensusModeParams :: !(ConsensusModeParams CardanoMode)
, networkId :: !NetworkId
, query :: !TxMempoolQuery
, mOutFile :: !(Maybe (File () Out))
Expand All @@ -168,23 +168,23 @@ data QueryTxMempoolCmdArgs = QueryTxMempoolCmdArgs

data QuerySlotNumberCmdArgs = QuerySlotNumberCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, consensusModeParams :: !(ConsensusModeParams CardanoMode)
, networkId :: !NetworkId
, utcTime :: !UTCTime
} deriving (Generic, Show)

data QueryNoArgCmdArgs era = QueryNoArgCmdArgs
{ eon :: !(ConwayEraOnwards era)
, nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, consensusModeParams :: !(ConsensusModeParams CardanoMode)
, networkId :: !NetworkId
, mOutFile :: !(Maybe (File () Out))
} deriving Show

data QueryDRepStateCmdArgs era = QueryDRepStateCmdArgs
{ eon :: !(ConwayEraOnwards era)
, nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, consensusModeParams :: !(ConsensusModeParams CardanoMode)
, networkId :: !NetworkId
, drepKeys :: ![VerificationKeyOrHashOrFile DRepKey]
, mOutFile :: !(Maybe (File () Out))
Expand All @@ -193,7 +193,7 @@ data QueryDRepStateCmdArgs era = QueryDRepStateCmdArgs
data QueryDRepStakeDistributionCmdArgs era = QueryDRepStakeDistributionCmdArgs
{ eon :: !(ConwayEraOnwards era)
, nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, consensusModeParams :: !(ConsensusModeParams CardanoMode)
, networkId :: !NetworkId
, drepKeys :: ![VerificationKeyOrHashOrFile DRepKey]
, mOutFile :: !(Maybe (File () Out))
Expand Down
4 changes: 2 additions & 2 deletions cardano-cli/src/Cardano/CLI/EraBased/Commands/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ data TransactionBuildRawCmdArgs era = TransactionBuildRawCmdArgs
data TransactionBuildCmdArgs era = TransactionBuildCmdArgs
{ eon :: !(ShelleyBasedEra era)
, nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, consensusModeParams :: !(ConsensusModeParams CardanoMode)
, networkId :: !NetworkId
, mScriptValidity :: !(Maybe ScriptValidity)
-- ^ Mark script as expected to pass or fail validation
Expand Down Expand Up @@ -148,7 +148,7 @@ data TransactionSignWitnessCmdArgs = TransactionSignWitnessCmdArgs

data TransactionSubmitCmdArgs = TransactionSubmitCmdArgs
{ nodeSocketPath :: !SocketPath
, anyConsensusModeParams :: !AnyConsensusModeParams
, anyConsensusModeParams :: !(ConsensusModeParams CardanoMode)
, networkId :: !NetworkId
, txFile :: !FilePath
} deriving Show
Expand Down
10 changes: 5 additions & 5 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ toUnitIntervalOrErr r = case Ledger.boundRational r of
]
Just n -> n

pConsensusModeParams :: Parser AnyConsensusModeParams
pConsensusModeParams :: Parser (ConsensusModeParams CardanoMode)
pConsensusModeParams = asum
[ pCardanoMode *> pCardanoConsensusMode
, pDefaultConsensusMode
Expand All @@ -122,12 +122,12 @@ pConsensusModeParams = asum
, Opt.help "For talking to a node running in full Cardano mode (default)."
]

pCardanoConsensusMode :: Parser AnyConsensusModeParams
pCardanoConsensusMode = AnyConsensusModeParams . CardanoModeParams <$> pEpochSlots
pCardanoConsensusMode :: Parser (ConsensusModeParams CardanoMode)
pCardanoConsensusMode = CardanoModeParams <$> pEpochSlots

pDefaultConsensusMode :: Parser AnyConsensusModeParams
pDefaultConsensusMode :: Parser (ConsensusModeParams CardanoMode)
pDefaultConsensusMode =
pure . AnyConsensusModeParams . CardanoModeParams $ EpochSlots defaultByronEpochSlots
pure . CardanoModeParams $ EpochSlots defaultByronEpochSlots

defaultByronEpochSlots :: Word64
defaultByronEpochSlots = 21600
Expand Down
Loading

0 comments on commit 3c32641

Please sign in to comment.