Skip to content

Commit

Permalink
Upgrade to cardano-api-8.21.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Sep 27, 2023
1 parent 23b02a2 commit d93346e
Show file tree
Hide file tree
Showing 22 changed files with 362 additions and 243 deletions.
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repository cardano-haskell-packages
-- you need to run if you change them
index-state:
, hackage.haskell.org 2023-08-08T19:56:09Z
, cardano-haskell-packages 2023-09-19T21:43:40Z
, cardano-haskell-packages 2023-09-26T01:42:03Z

packages:
cardano-cli
Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ library
, binary
, bytestring
, canonical-json
, cardano-api ^>= 8.20.2
, cardano-api ^>= 8.21
, cardano-binary
, cardano-crypto
, cardano-crypto-class ^>= 2.1.2
Expand Down
4 changes: 2 additions & 2 deletions cardano-cli/src/Cardano/CLI/Byron/Parsers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ parseTxOut =
pLovelaceTxOut :: Word64 -> TxOutValue ByronEra
pLovelaceTxOut l =
if l > (maxBound :: Word64)
then error $ show l <> " lovelace exceeds the Word64 upper bound"
else TxOutAdaOnly AdaOnlyInByronEra . Lovelace $ toInteger l
then error $ show l <> " lovelace exceeds the Word64 upper bound"
else TxOutAdaOnly ByronToAllegraEraByron . Lovelace $ toInteger l

readerFromAttoParser :: Atto.Parser a -> Opt.ReadM a
readerFromAttoParser p =
Expand Down
4 changes: 2 additions & 2 deletions cardano-cli/src/Cardano/CLI/Byron/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ txSpendGenesisUTxOByronPBFT gc nId sk (ByronAddress bAddr) outs = do
, txOuts = outs
, txTotalCollateral = TxTotalCollateralNone
, txReturnCollateral = TxReturnCollateralNone
, txFee = TxFeeImplicit TxFeesImplicitInByronEra
, txFee = TxFeeImplicit ByronEraOnlyByron
, txValidityRange =
( TxValidityNoLowerBound
, TxValidityNoUpperBound ValidityNoUpperBoundInByronEra
Expand Down Expand Up @@ -206,7 +206,7 @@ txSpendUTxOByronPBFT nId sk txIns outs = do
, txOuts = outs
, txTotalCollateral = TxTotalCollateralNone
, txReturnCollateral = TxReturnCollateralNone
, txFee = TxFeeImplicit TxFeesImplicitInByronEra
, txFee = TxFeeImplicit ByronEraOnlyByron
, txValidityRange =
( TxValidityNoLowerBound
, TxValidityNoUpperBound ValidityNoUpperBoundInByronEra
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ data NewCommitteeCmd
, ebReturnAddress :: AnyStakeIdentifier
, ebProposalUrl :: ProposalUrl
, ebProposalHashSource :: ProposalHashSource
, ebOldCommittee :: [AnyStakeIdentifier]
, ebNewCommittee :: [(AnyStakeIdentifier, EpochNo)]
, ebOldCommittee :: [VerificationKeyOrHashOrFile CommitteeColdKey]
, ebNewCommittee :: [(VerificationKeyOrHashOrFile CommitteeColdKey, EpochNo)]
, ebRequiredQuorum :: Rational
, ebPreviousGovActionId :: Maybe (TxId, Word32)
, ebFilePath :: File () Out
Expand Down
107 changes: 107 additions & 0 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,113 @@ pOperatorCertIssueCounterFile =
]
]

---

pAddCommitteeColdVerificationKeyOrHashOrFile :: Parser (VerificationKeyOrHashOrFile CommitteeColdKey)
pAddCommitteeColdVerificationKeyOrHashOrFile =
asum
[ VerificationKeyOrFile <$> pAddCommitteeColdVerificationKeyOrFile
, VerificationKeyHash <$> pAddCommitteeColdVerificationKeyHash
]

pAddCommitteeColdVerificationKeyHash :: Parser (Hash CommitteeColdKey)
pAddCommitteeColdVerificationKeyHash =
Opt.option (Opt.eitherReader deserialiseFromHex) $ mconcat
[ Opt.long "add-cc-cold-verification-key-hash"
, Opt.metavar "STRING"
, Opt.help "Constitutional Committee key hash (hex-encoded)."
]
where
deserialiseFromHex :: String -> Either String (Hash CommitteeColdKey)
deserialiseFromHex =
first (\e -> "Invalid Consitutional Committee cold key hash: " ++ displayError e)
. deserialiseFromRawBytesHex (AsHash AsCommitteeColdKey)
. BSC.pack

pAddCommitteeColdVerificationKeyOrFile :: Parser (VerificationKeyOrFile CommitteeColdKey)
pAddCommitteeColdVerificationKeyOrFile =
asum
[ VerificationKeyValue <$> pAddCommitteeColdVerificationKey
, VerificationKeyFilePath <$> pAddCommitteeColdVerificationKeyFile
]

pAddCommitteeColdVerificationKey :: Parser (VerificationKey CommitteeColdKey)
pAddCommitteeColdVerificationKey =
Opt.option (Opt.eitherReader deserialiseFromHex) $ mconcat
[ Opt.long "add-cc-cold-verification-key"
, Opt.metavar "STRING"
, Opt.help "Constitutional Committee cold key (hex-encoded)."
]
where
deserialiseFromHex :: String -> Either String (VerificationKey CommitteeColdKey)
deserialiseFromHex =
first (\e -> "Invalid Constitutional Committee cold key: " ++ displayError e)
. deserialiseFromRawBytesHex (AsVerificationKey AsCommitteeColdKey)
. BSC.pack

pAddCommitteeColdVerificationKeyFile :: Parser (File (VerificationKey keyrole) In)
pAddCommitteeColdVerificationKeyFile =
fmap File $ Opt.strOption $ mconcat
[ Opt.long "add-cc-cold-verification-key-file"
, Opt.metavar "FILE"
, Opt.help "Filepath of the Consitutional Committee cold key."
, Opt.completer (Opt.bashCompleter "file")
]

---
pRemoveCommitteeColdVerificationKeyOrHashOrFile :: Parser (VerificationKeyOrHashOrFile CommitteeColdKey)
pRemoveCommitteeColdVerificationKeyOrHashOrFile =
asum
[ VerificationKeyOrFile <$> pRemoveCommitteeColdVerificationKeyOrFile
, VerificationKeyHash <$> pRemoveCommitteeColdVerificationKeyHash
]

pRemoveCommitteeColdVerificationKeyHash :: Parser (Hash CommitteeColdKey)
pRemoveCommitteeColdVerificationKeyHash =
Opt.option (Opt.eitherReader deserialiseFromHex) $ mconcat
[ Opt.long "remove-cc-cold-verification-key-hash"
, Opt.metavar "STRING"
, Opt.help "Constitutional Committee key hash (hex-encoded)."
]
where
deserialiseFromHex :: String -> Either String (Hash CommitteeColdKey)
deserialiseFromHex =
first (\e -> "Invalid Consitutional Committee cold key hash: " ++ displayError e)
. deserialiseFromRawBytesHex (AsHash AsCommitteeColdKey)
. BSC.pack

pRemoveCommitteeColdVerificationKeyOrFile :: Parser (VerificationKeyOrFile CommitteeColdKey)
pRemoveCommitteeColdVerificationKeyOrFile =
asum
[ VerificationKeyValue <$> pRemoveCommitteeColdVerificationKey
, VerificationKeyFilePath <$> pRemoveCommitteeColdVerificationKeyFile
]

pRemoveCommitteeColdVerificationKey :: Parser (VerificationKey CommitteeColdKey)
pRemoveCommitteeColdVerificationKey =
Opt.option (Opt.eitherReader deserialiseFromHex) $ mconcat
[ Opt.long "remove-cc-cold-verification-key"
, Opt.metavar "STRING"
, Opt.help "Constitutional Committee cold key (hex-encoded)."
]
where
deserialiseFromHex :: String -> Either String (VerificationKey CommitteeColdKey)
deserialiseFromHex =
first (\e -> "Invalid Constitutional Committee cold key: " ++ displayError e)
. deserialiseFromRawBytesHex (AsVerificationKey AsCommitteeColdKey)
. BSC.pack

pRemoveCommitteeColdVerificationKeyFile :: Parser (File (VerificationKey keyrole) In)
pRemoveCommitteeColdVerificationKeyFile =
fmap File $ Opt.strOption $ mconcat
[ Opt.long "remove-cc-cold-verification-key-file"
, Opt.metavar "FILE"
, Opt.help "Filepath of the Consitutional Committee cold key."
, Opt.completer (Opt.bashCompleter "file")
]

---

pCommitteeColdVerificationKeyOrHashOrFile :: Parser (VerificationKeyOrHashOrFile CommitteeColdKey)
pCommitteeColdVerificationKeyOrHashOrFile =
asum
Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/EraBased/Options/Governance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pGovernanceCmds era envCli =

pCreateMirCertificatesCmds :: CardanoEra era -> Maybe (Parser (GovernanceCmds era))
pCreateMirCertificatesCmds era = do
w <- maybeFeatureInEra era
w <- maybeEonInEra era
pure
$ subParser "create-mir-certificate"
$ Opt.info (pMIRPayStakeAddresses w <|> mirCertParsers w)
Expand Down
19 changes: 11 additions & 8 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pGovernanceActionNewInfoCmd
:: CardanoEra era
-> Maybe (Parser (GovernanceActionCmds era))
pGovernanceActionNewInfoCmd era = do
cOn <- maybeFeatureInEra era
cOn <- maybeEonInEra era
pure
$ subParser "create-info"
$ Opt.info
Expand All @@ -63,7 +63,7 @@ pGovernanceActionNewConstitutionCmd
:: CardanoEra era
-> Maybe (Parser (GovernanceActionCmds era))
pGovernanceActionNewConstitutionCmd era = do
cOn <- maybeFeatureInEra era
cOn <- maybeEonInEra era
pure
$ subParser "create-constitution"
$ Opt.info
Expand All @@ -85,7 +85,7 @@ pGovernanceActionNewCommitteeCmd
:: CardanoEra era
-> Maybe (Parser (GovernanceActionCmds era))
pGovernanceActionNewCommitteeCmd era = do
cOn <- maybeFeatureInEra era
cOn <- maybeEonInEra era
pure
$ subParser "create-new-committee"
$ Opt.info
Expand All @@ -102,8 +102,11 @@ pNewCommitteeCmd =
<*> pAnyStakeIdentifier Nothing
<*> pProposalUrl
<*> pProposalHashSource
<*> many (pAnyStakeIdentifier (Just "remove-cc"))
<*> many ((,) <$> pAnyStakeIdentifier (Just "add-cc") <*> pEpochNo "Committee member expiry epoch")
<*> many pRemoveCommitteeColdVerificationKeyOrHashOrFile
<*> many
( (,)
<$> pAddCommitteeColdVerificationKeyOrHashOrFile
<*> pEpochNo "Committee member expiry epoch")
<*> pRational "quorum" "Quorum of the committee that is necessary for a successful vote."
<*> pPreviousGovernanceAction
<*> pOutputFile
Expand All @@ -113,7 +116,7 @@ pGovernanceActionNoConfidenceCmd
:: CardanoEra era
-> Maybe (Parser (GovernanceActionCmds era))
pGovernanceActionNoConfidenceCmd era = do
cOn <- maybeFeatureInEra era
cOn <- maybeEonInEra era
pure
$ subParser "create-no-confidence"
$ Opt.info
Expand Down Expand Up @@ -142,7 +145,7 @@ pGovernanceActionProtocolParametersUpdateCmd :: ()
=> CardanoEra era
-> Maybe (Parser (GovernanceActionCmds era))
pGovernanceActionProtocolParametersUpdateCmd era = do
w <- maybeFeatureInEra era
w <- maybeEonInEra era
pure
$ subParser "create-protocol-parameters-update"
$ Opt.info
Expand Down Expand Up @@ -277,7 +280,7 @@ dpGovActionProtocolParametersUpdate = \case

pGovernanceActionTreasuryWithdrawalCmd :: CardanoEra era -> Maybe (Parser (GovernanceActionCmds era))
pGovernanceActionTreasuryWithdrawalCmd era = do
cOn <- maybeFeatureInEra era
cOn <- maybeEonInEra era
pure
$ subParser "create-treasury-withdrawal"
$ Opt.info
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pGovernanceCommitteeKeyGenColdCmd :: ()
=> CardanoEra era
-> Maybe (Parser (GovernanceCommitteeCmds era))
pGovernanceCommitteeKeyGenColdCmd era = do
w <- maybeFeatureInEra era
w <- maybeEonInEra era
pure
$ subParser "key-gen-cold"
$ Opt.info (pCmd w)
Expand All @@ -54,7 +54,7 @@ pGovernanceCommitteeKeyGenHotCmd :: ()
=> CardanoEra era
-> Maybe (Parser (GovernanceCommitteeCmds era))
pGovernanceCommitteeKeyGenHotCmd era = do
w <- maybeFeatureInEra era
w <- maybeEonInEra era
pure
$ subParser "key-gen-hot"
$ Opt.info (pCmd w)
Expand All @@ -75,7 +75,7 @@ pGovernanceCommitteeKeyHashCmd :: ()
=> CardanoEra era
-> Maybe (Parser (GovernanceCommitteeCmds era))
pGovernanceCommitteeKeyHashCmd era = do
w <- maybeFeatureInEra era
w <- maybeEonInEra era
pure
$ subParser "key-hash"
$ Opt.info
Expand All @@ -91,7 +91,7 @@ pGovernanceCommitteeCreateHotKeyAuthorizationCertificateCmd :: ()
=> CardanoEra era
-> Maybe (Parser (GovernanceCommitteeCmds era))
pGovernanceCommitteeCreateHotKeyAuthorizationCertificateCmd era = do
w <- maybeFeatureInEra era
w <- maybeEonInEra era
pure
$ subParser "create-hot-key-authorization-certificate"
$ Opt.info
Expand All @@ -109,7 +109,7 @@ pGovernanceCommitteeCreateColdKeyResignationCertificateCmd :: ()
=> CardanoEra era
-> Maybe (Parser (GovernanceCommitteeCmds era))
pGovernanceCommitteeCreateColdKeyResignationCertificateCmd era = do
w <- maybeFeatureInEra era
w <- maybeEonInEra era
pure
$ subParser "create-cold-key-resignation-certificate"
$ Opt.info
Expand Down
10 changes: 5 additions & 5 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/DRep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pGovernanceDRepKeyGenCmd :: ()
=> CardanoEra era
-> Maybe (Parser (GovernanceDRepCmds era))
pGovernanceDRepKeyGenCmd era = do
w <- maybeFeatureInEra era
w <- maybeEonInEra era
pure
$ subParser "key-gen"
$ Opt.info
Expand All @@ -57,7 +57,7 @@ pGovernanceDRepKeyIdCmd :: ()
=> CardanoEra era
-> Maybe (Parser (GovernanceDRepCmds era))
pGovernanceDRepKeyIdCmd era = do
w <- maybeFeatureInEra era
w <- maybeEonInEra era
pure
$ subParser "id"
$ Opt.info
Expand Down Expand Up @@ -87,7 +87,7 @@ pRegistrationCertificateCmd :: ()
-> EnvCli
-> Maybe (Parser (GovernanceDRepCmds era))
pRegistrationCertificateCmd era envCli = do
w <- maybeFeatureInEra era
w <- maybeEonInEra era
pure
$ subParser "registration-certificate"
$ Opt.info (pEraCmd envCli w)
Expand Down Expand Up @@ -123,8 +123,8 @@ data AnyEraDecider era where
AnyEraDeciderShelleyToBabbage :: ShelleyToBabbageEra era -> AnyEraDecider era
AnyEraDeciderConwayOnwards :: ConwayEraOnwards era -> AnyEraDecider era

instance FeatureInEra AnyEraDecider where
featureInEra no yes = \case
instance Eon AnyEraDecider where
inEonForEra no yes = \case
ByronEra -> no
ShelleyEra -> yes $ AnyEraDeciderShelleyToBabbage ShelleyToBabbageEraShelley
AllegraEra -> yes $ AnyEraDeciderShelleyToBabbage ShelleyToBabbageEraAllegra
Expand Down
10 changes: 5 additions & 5 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pGovernanceQueryGetConstitutionCmd :: ()
-> EnvCli
-> Maybe (Parser (GovernanceQueryCmds era))
pGovernanceQueryGetConstitutionCmd era env = do
cOn <- maybeFeatureInEra era
cOn <- maybeEonInEra era
pure
$ subParser "constitution"
$ Opt.info (GovernanceQueryConstitutionCmd cOn <$> pNoArgQueryCmd env)
Expand All @@ -44,7 +44,7 @@ pGovernanceQueryGetGovStateCmd :: ()
-> EnvCli
-> Maybe (Parser (GovernanceQueryCmds era))
pGovernanceQueryGetGovStateCmd era env = do
cOn <- maybeFeatureInEra era
cOn <- maybeEonInEra era
pure
$ subParser "gov-state"
$ Opt.info (GovernanceQueryGovStateCmd cOn <$> pNoArgQueryCmd env)
Expand All @@ -60,7 +60,7 @@ pGovernanceQueryDRepStateCmd :: ()
-> EnvCli
-> Maybe (Parser (GovernanceQueryCmds era))
pGovernanceQueryDRepStateCmd era env = do
cOn <- maybeFeatureInEra era
cOn <- maybeEonInEra era
pure
$ subParser "drep-state"
$ Opt.info (GovernanceQueryDRepStateCmd cOn <$> pDRepStateQueryCmd)
Expand All @@ -79,7 +79,7 @@ pGovernanceQueryDRepStakeDistributionCmd :: ()
-> EnvCli
-> Maybe (Parser (GovernanceQueryCmds era))
pGovernanceQueryDRepStakeDistributionCmd era env = do
cOn <- maybeFeatureInEra era
cOn <- maybeEonInEra era
pure
$ subParser "drep-stake-distribution"
$ Opt.info (GovernanceQueryDRepStakeDistributionCmd cOn <$> pDRepStakeDistributionQueryCmd)
Expand All @@ -98,7 +98,7 @@ pGovernanceQueryGetCommitteeStateCmd :: ()
-> EnvCli
-> Maybe (Parser (GovernanceQueryCmds era))
pGovernanceQueryGetCommitteeStateCmd era env = do
cOn <- maybeFeatureInEra era
cOn <- maybeEonInEra era
pure
$ subParser "committee-state"
$ Opt.info (GovernanceQueryCommitteeStateCmd cOn <$> pNoArgQueryCmd env)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pGovernanceVoteCreateCmd :: ()
=> CardanoEra era
-> Maybe (Parser (GovernanceVoteCmds era))
pGovernanceVoteCreateCmd era = do
w <- maybeFeatureInEra era
w <- maybeEonInEra era
pure
$ subParser "create"
$ Opt.info
Expand Down
Loading

0 comments on commit d93346e

Please sign in to comment.