From 601d88f86aa153ba8212a44e00f76effd8f3e696 Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Wed, 24 Jul 2024 13:48:08 +0200 Subject: [PATCH] TODO: Move me before previous commit Implement parser for proposing or voting reference script witnesses --- .../Cardano/CLI/EraBased/Options/Common.hs | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs index 9879140195..560ad915ae 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs @@ -1720,6 +1720,23 @@ pWithdrawal balance = parseWithdrawal = (,) <$> parseStakeAddress <* Parsec.char '+' <*> parseLovelace +pPlutusStakeReferenceScriptWitnessFilesVotingProposing + :: String + -> BalanceTxExecUnits + -- ^ Use the @execution-units@ flag. + -> Parser (ScriptWitnessFiles WitCtxStake) +pPlutusStakeReferenceScriptWitnessFilesVotingProposing prefix autoBalanceExecUnits = + PlutusReferenceScriptWitnessFiles + <$> pReferenceTxIn prefix "plutus" + <*> plutusP prefix PlutusScriptV3 "v3" + <*> pure NoScriptDatumOrFileForStake + <*> pScriptRedeemerOrFile (prefix ++ "reference-tx-in") + <*> ( case autoBalanceExecUnits of + AutoBalance -> pure (ExecutionUnits 0 0) + ManualBalance -> pExecutionUnits $ prefix ++ "reference-tx-in" + ) + <*> pure Nothing + pPlutusStakeReferenceScriptWitnessFiles :: String -> BalanceTxExecUnits @@ -1738,15 +1755,15 @@ pPlutusStakeReferenceScriptWitnessFiles prefix autoBalanceExecUnits = <*> pure Nothing pPlutusScriptLanguage :: String -> Parser AnyScriptLanguage -pPlutusScriptLanguage prefix = plutusP PlutusScriptV2 "v2" <|> plutusP PlutusScriptV3 "v3" - where - plutusP :: PlutusScriptVersion lang -> String -> Parser AnyScriptLanguage - plutusP plutusVersion versionString = - Opt.flag' - (AnyScriptLanguage $ PlutusScriptLanguage plutusVersion) - ( Opt.long (prefix <> "plutus-script-" <> versionString) - <> Opt.help ("Specify a plutus script " <> versionString <> " reference script.") - ) +pPlutusScriptLanguage prefix = plutusP prefix PlutusScriptV2 "v2" <|> plutusP prefix PlutusScriptV3 "v3" + +plutusP :: String -> PlutusScriptVersion lang -> String -> Parser AnyScriptLanguage +plutusP prefix plutusVersion versionString = + Opt.flag' + (AnyScriptLanguage $ PlutusScriptLanguage plutusVersion) + ( Opt.long (prefix <> "plutus-script-" <> versionString) + <> Opt.help ("Specify a plutus script " <> versionString <> " reference script.") + ) pUpdateProposalFile :: Parser UpdateProposalFile pUpdateProposalFile =