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

Upgrade to cardano-api-8.21.0.0 #304

Merged
merged 1 commit into from
Sep 27, 2023
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
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not ByronEraOnly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do that. I'll put a PR to remove the era suffix for all the Only eons.

, 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)
smelc marked this conversation as resolved.
Show resolved Hide resolved
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
Copy link
Contributor

@Jimbo4350 Jimbo4350 Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to rethink these names. They are confusing. maybeEonInEra does not make sense and we're going to have to break the API again :(

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