1313module Cardano.CLI.EraBased.Common.Option where
1414
1515import Cardano.Api
16- import Cardano.Api.Ledger (StandardCrypto )
1716import Cardano.Api.Ledger qualified as L
1817import Cardano.Api.Network qualified as Consensus
1918import Cardano.Api.Shelley
@@ -36,6 +35,7 @@ import Cardano.CLI.Type.Common
3635import Cardano.CLI.Type.Governance
3736import Cardano.CLI.Type.Key
3837import Cardano.CLI.Type.Key.VerificationKey
38+ import Cardano.Ledger.BaseTypes (NonZero , nonZero )
3939
4040import Control.Monad (void , when )
4141import Data.Aeson qualified as Aeson
@@ -895,7 +895,7 @@ pConstitutionUrl =
895895 ConstitutionUrl
896896 <$> pUrl " constitution-url" " Constitution URL."
897897
898- pConstitutionHash :: Parser (L. SafeHash L. StandardCrypto L. AnchorData )
898+ pConstitutionHash :: Parser (L. SafeHash L. AnchorData )
899899pConstitutionHash =
900900 Opt. option readSafeHash $
901901 mconcat
@@ -2209,7 +2209,7 @@ pRefScriptFp =
22092209pMintMultiAsset
22102210 :: ShelleyBasedEra era
22112211 -> BalanceTxExecUnits
2212- -> Parser (Maybe (L. MultiAsset StandardCrypto , [CliMintScriptRequirements ]))
2212+ -> Parser (Maybe (L. MultiAsset , [CliMintScriptRequirements ]))
22132213pMintMultiAsset w balanceExecUnits =
22142214 caseShelleyToAllegraOrMaryEraOnwards
22152215 (const $ pure Nothing )
@@ -2926,6 +2926,16 @@ integralParsecParser = do
29262926 where
29272927 typeName = show $ typeRep (Proxy @ a )
29282928
2929+ nonZeroReader :: ReadM (NonZero Word64 )
2930+ nonZeroReader = readerFromParsecParser nonZeroParsecParser
2931+
2932+ nonZeroParsecParser :: Parsec. Parser (NonZero Word64 )
2933+ nonZeroParsecParser = do
2934+ i <- decimal -- Parses a non-negative whole number, so we only need to check for zero.
2935+ case nonZero $ fromIntegral i of
2936+ Nothing -> fail $ " Cannot parse " <> show i <> " as a (NonZero Word64)"
2937+ Just nz -> return nz
2938+
29292939pMaxBlockHeaderSize :: Parser Word16
29302940pMaxBlockHeaderSize =
29312941 Opt. option integralReader $
@@ -3439,12 +3449,12 @@ pAlwaysAbstain =
34393449 , Opt. help " Abstain from voting on all proposals."
34403450 ]
34413451
3442- pVoteAnchor :: Parser (VoteUrl , L. SafeHash L. StandardCrypto L. AnchorData )
3452+ pVoteAnchor :: Parser (VoteUrl , L. SafeHash L. AnchorData )
34433453pVoteAnchor =
34443454 ((,) . VoteUrl <$> pUrl " anchor-url" " Vote anchor URL" )
34453455 <*> pVoteAnchorDataHash
34463456
3447- pVoteAnchorDataHash :: Parser (L. SafeHash L. StandardCrypto L. AnchorData )
3457+ pVoteAnchorDataHash :: Parser (L. SafeHash L. AnchorData )
34483458pVoteAnchorDataHash =
34493459 Opt. option readSafeHash $
34503460 mconcat
@@ -3558,7 +3568,7 @@ pAllOrOnlySPOHashSource = pAll <|> pOnly
35583568pAllOrOnlyGovActionIds
35593569 :: ()
35603570 => ConwayEraOnwards era
3561- -> Parser (AllOrOnly ( L. GovActionId L. StandardCrypto ) )
3571+ -> Parser (AllOrOnly L. GovActionId )
35623572pAllOrOnlyGovActionIds era = pAll <|> pOnly
35633573 where
35643574 pOnly = Only <$> pGovActionIds era
@@ -3573,13 +3583,13 @@ pGovActionIds
35733583 :: forall era
35743584 . ()
35753585 => ConwayEraOnwards era
3576- -> Parser [L. GovActionId L. StandardCrypto ]
3586+ -> Parser [L. GovActionId ]
35773587pGovActionIds era = conwayEraOnwardsConstraints era (some pLedgerGovernanceAction)
35783588 where
3579- pLedgerGovernanceAction :: Parser ( L. GovActionId L. StandardCrypto )
3589+ pLedgerGovernanceAction :: Parser L. GovActionId
35803590 pLedgerGovernanceAction = uncurry L. GovActionId <$> pairParser
35813591
3582- pairParser :: Parser (L. TxId L. StandardCrypto , L. GovActionIx )
3592+ pairParser :: Parser (L. TxId , L. GovActionIx )
35833593 pairParser = bimap toShelleyTxId L. GovActionIx <$> pGovernanceActionId
35843594
35853595pDRepVerificationKeyHash :: Parser (Hash DRepKey )
@@ -3645,10 +3655,10 @@ pAnchorUrl =
36453655 ProposalUrl
36463656 <$> pUrl " anchor-url" " Anchor URL"
36473657
3648- pExpectedAnchorDataHash :: Parser (L. SafeHash L. StandardCrypto L. AnchorData )
3658+ pExpectedAnchorDataHash :: Parser (L. SafeHash L. AnchorData )
36493659pExpectedAnchorDataHash = pExpectedHash id " anchor data"
36503660
3651- pExpectedHash :: (L. SafeHash L. StandardCrypto L. AnchorData -> a ) -> String -> Parser a
3661+ pExpectedHash :: (L. SafeHash L. AnchorData -> a ) -> String -> Parser a
36523662pExpectedHash adaptor hashedDataName =
36533663 Opt. option (adaptor <$> readSafeHash) $
36543664 mconcat
@@ -3661,7 +3671,7 @@ pExpectedHash adaptor hashedDataName =
36613671 ]
36623672 ]
36633673
3664- pAnchorDataHash :: Parser (L. SafeHash L. StandardCrypto L. AnchorData )
3674+ pAnchorDataHash :: Parser (L. SafeHash L. AnchorData )
36653675pAnchorDataHash =
36663676 Opt. option readSafeHash $
36673677 mconcat
0 commit comments