Skip to content

Commit

Permalink
Remove HashCheckParamInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
palas committed Oct 3, 2024
1 parent 7c06325 commit 31212c8
Showing 1 changed file with 27 additions and 56 deletions.
83 changes: 27 additions & 56 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3569,66 +3569,37 @@ 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.")
]
]
pMustCheckHash :: String -> String -> String -> String -> Parser (MustCheckHash anchorData)
pMustCheckHash flagSuffix' dataName' hashParamName' 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.")
]
]

pMustCheckProposalHash :: Parser (MustCheckHash ProposalUrl)
pMustCheckProposalHash =
pMustCheckHash
HashCheckParamInfo
{ flagSuffix = "anchor-data"
, dataName = "proposal"
, hashParamName = "--anchor-data-hash"
, urlParamName = "--anchor-url"
}
pMustCheckProposalHash = pMustCheckHash "anchor-data" "proposal" "--anchor-data-hash" "--anchor-url"

pMustCheckConstitutionHash :: Parser (MustCheckHash ConstitutionUrl)
pMustCheckConstitutionHash =
pMustCheckHash
HashCheckParamInfo
{ flagSuffix = "constitution-hash"
, dataName = "constitution"
, hashParamName = "--constitution-hash"
, urlParamName = "--constitution-url"
}
pMustCheckConstitutionHash = pMustCheckHash "constitution-hash" "constitution" "--constitution-hash" "--constitution-url"

pPreviousGovernanceAction :: Parser (Maybe (TxId, Word16))
pPreviousGovernanceAction =
Expand Down

0 comments on commit 31212c8

Please sign in to comment.