-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add anchor data hash checks to remaining governance action commands #915
Changes from all commits
34e586d
f303853
6d868b5
19eab4e
fdb7f25
93027e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
cardano-cli/test/cardano-cli-golden/files/input/example_anchor_data.txt -text | ||
cardano-cli/test/cardano-cli-golden/files/input/example_anchor_data2.txt -text | ||
cardano-cli/test/cardano-cli-test/files/input/example_anchor_data.txt -text | ||
cardano-cli/test/cardano-cli-test/files/input/example_anchor_data2.txt -text |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3569,6 +3569,65 @@ pAnchorDataHash = | |
, Opt.help "Proposal anchor data hash (obtain it with \"cardano-cli hash anchor-data ...\")" | ||
] | ||
|
||
data HashCheckParamInfo anchorData | ||
= HashCheckParamInfo | ||
{ flagSuffix :: String | ||
, dataName :: String | ||
, hashParamName :: String | ||
, urlParamName :: String | ||
} | ||
|
||
pMustCheckHash :: HashCheckParamInfo anchorData -> Parser (MustCheckHash anchorData) | ||
pMustCheckHash | ||
( HashCheckParamInfo | ||
{ flagSuffix = flagSuffix' | ||
, dataName = dataName' | ||
, hashParamName = hashParamName' | ||
, urlParamName = urlParamName' | ||
} | ||
) = | ||
asum | ||
[ Opt.flag' CheckHash $ | ||
mconcat | ||
[ Opt.long ("check-" ++ flagSuffix') | ||
, Opt.help | ||
( "Check the " | ||
++ dataName' | ||
++ " hash (from " | ||
++ hashParamName' | ||
++ ") by downloading " | ||
++ dataName' | ||
++ " data (from " | ||
++ urlParamName' | ||
++ ")." | ||
) | ||
] | ||
, Opt.flag' TrustHash $ | ||
mconcat | ||
[ Opt.long ("trust-" ++ flagSuffix') | ||
, Opt.help | ||
("Do not check the " ++ dataName' ++ " hash (from " ++ hashParamName' ++ ") and trust it is correct.") | ||
] | ||
] | ||
|
||
proposalHashCheckInfo :: HashCheckParamInfo ProposalUrl | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please turn these into stand alone parsers. You can create a function that creates a parser which is the usual style we have. |
||
proposalHashCheckInfo = | ||
HashCheckParamInfo | ||
{ flagSuffix = "anchor-data" | ||
, dataName = "proposal" | ||
, hashParamName = "--anchor-data-hash" | ||
, urlParamName = "--anchor-url" | ||
} | ||
|
||
constitutionHashCheckInfo :: HashCheckParamInfo ConstitutionUrl | ||
constitutionHashCheckInfo = | ||
HashCheckParamInfo | ||
{ flagSuffix = "constitution-hash" | ||
, dataName = "constitution" | ||
, hashParamName = "--constitution-hash" | ||
, urlParamName = "--constitution-url" | ||
} | ||
|
||
pPreviousGovernanceAction :: Parser (Maybe (TxId, Word16)) | ||
pPreviousGovernanceAction = | ||
optional $ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,8 +70,11 @@ instance Error GovernanceActionsError where | |
<+> "hash:" | ||
<+> pretty (displayException fetchErr) | ||
|
||
data AnchorDataTypeCheck = ProposalCheck | ||
data AnchorDataTypeCheck | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be commented. |
||
= ProposalCheck | ||
| ConstitutionCheck | ||
deriving Show | ||
|
||
anchorDataTypeCheckName :: AnchorDataTypeCheck -> String | ||
anchorDataTypeCheckName ProposalCheck = "proposal" | ||
anchorDataTypeCheckName ConstitutionCheck = "constitution" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type has incredibly poor type safety.