Skip to content

Commit

Permalink
Try to reduce this diff
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimbo4350 committed Jan 17, 2025
1 parent e59973c commit 3e41196
Showing 1 changed file with 34 additions and 24 deletions.
58 changes: 34 additions & 24 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1034,35 +1034,30 @@ pPlutusMintScriptWitnessData _sbe _witctx autoBalanceExecUnits =


pPlutusSpendingScriptWitness
:: BalanceTxExecUnits
:: ShelleyBasedEra era
-> BalanceTxExecUnits
-- ^ Use the @execution-units@ flag.
-> String
-- ^ Script flag prefix
-> Maybe String
-> String
-> Parser CliSpendScriptRequirements
pPlutusSpendingScriptWitness autoBalanceExecUnits scriptFlagPrefix scriptFlagPrefixDeprecated help =
pPlutusSpendingScriptWitness sbe autoBalanceExecUnits scriptFlagPrefix scriptFlagPrefixDeprecated help =
PlutusSpend.createPlutusScriptFromCliArgs
<$> pScriptFor
(scriptFlagPrefix ++ "-script-file")
((++ "-script-file") <$> scriptFlagPrefixDeprecated)
("The file containing the script to witness " ++ help)
<*>
( optional ((,,)
<$> pScriptDatumOrFileSpendingCipi69 scriptFlagPrefix
<$> pScriptDatumOrFileSpendingCip69 sbe scriptFlagPrefix
<*> pScriptRedeemerOrFile scriptFlagPrefix
<*> ( case autoBalanceExecUnits of
AutoBalance -> pure (ExecutionUnits 0 0)
ManualBalance -> pExecutionUnits scriptFlagPrefix
))
)

Check notice

Code scanning / HLint

Redundant bracket Note

cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs:(1052,10)-(1059,10): Suggestion: Redundant bracket
  
Found:
  PlutusSpend.createPlutusScriptFromCliArgs
    <$>
      pScriptFor
        (scriptFlagPrefix ++ "-script-file")
        ((++ "-script-file") <$> scriptFlagPrefixDeprecated)
        ("The file containing the script to witness " ++ help)
    <>
      (optional
         ((,,) <$> pScriptDatumOrFileSpendingCip69 sbe scriptFlagPrefix
            <> pScriptRedeemerOrFile scriptFlagPrefix
            <>
              (case autoBalanceExecUnits of
                 AutoBalance -> pure (ExecutionUnits 0 0)
                 ManualBalance -> pExecutionUnits scriptFlagPrefix)))
  
Perhaps:
  PlutusSpend.createPlutusScriptFromCliArgs
    <$>
      pScriptFor
        (scriptFlagPrefix ++ "-script-file")
        ((++ "-script-file") <$> scriptFlagPrefixDeprecated)
        ("The file containing the script to witness " ++ help)
    <>
      optional
        ((,,) <$> pScriptDatumOrFileSpendingCip69 sbe scriptFlagPrefix
           <> pScriptRedeemerOrFile scriptFlagPrefix
           <>
             (case autoBalanceExecUnits of
                AutoBalance -> pure (ExecutionUnits 0 0)
                ManualBalance -> pExecutionUnits scriptFlagPrefix))







pScriptWitnessFiles
:: forall witctx era
. ShelleyBasedEra era
Expand All @@ -1082,20 +1077,14 @@ pScriptWitnessFiles sbe witctx autoBalanceExecUnits scriptFlagPrefix scriptFlagP
("The file containing the script to witness " ++ help)
<*> optional
( (,,)
<$> cip69Modification sbe
<$> cip69Modification sbe witctx scriptFlagPrefix
<*> pScriptRedeemerOrFile scriptFlagPrefix
<*> ( case autoBalanceExecUnits of
AutoBalance -> pure (ExecutionUnits 0 0)
ManualBalance -> pExecutionUnits scriptFlagPrefix
)
)
where
cip69Modification :: ShelleyBasedEra era -> Parser (ScriptDatumOrFile witctx)
cip69Modification =
caseShelleyToBabbageOrConwayEraOnwards
(const $ pScriptDatumOrFile scriptFlagPrefix witctx)
(const $ pScriptDatumOrFileCip69 scriptFlagPrefix witctx)

toScriptWitnessFiles
:: ScriptFile
-> Maybe
Expand All @@ -1107,6 +1096,14 @@ pScriptWitnessFiles sbe witctx autoBalanceExecUnits scriptFlagPrefix scriptFlagP
toScriptWitnessFiles sf Nothing = SimpleScriptWitnessFile sf
toScriptWitnessFiles sf (Just (d, r, e)) = PlutusScriptWitnessFiles sf d r e


cip69Modification :: ShelleyBasedEra era -> WitCtx witctx -> String -> Parser (ScriptDatumOrFile witctx)
cip69Modification sbe witctx scriptFlagPrefix =
caseShelleyToBabbageOrConwayEraOnwards
(const $ pScriptDatumOrFile scriptFlagPrefix witctx)
(const $ pScriptDatumOrFileCip69 scriptFlagPrefix witctx)
sbe

pExecutionUnits :: String -> Parser ExecutionUnits
pExecutionUnits scriptFlagPrefix =
fmap (uncurry ExecutionUnits) $
Expand Down Expand Up @@ -1172,8 +1169,8 @@ pScriptDatumOrFile scriptFlagPrefix witctx =
, Opt.help "Inline datum present at transaction input."
]

pScriptDatumOrFileSpending :: String -> Parser PlutusSpend.ScriptDatumOrFileSpending
pScriptDatumOrFileSpending scriptFlagPrefix =
pScriptDatumOrFileSpendingNotOptional :: String -> Parser PlutusSpend.ScriptDatumOrFileSpending
pScriptDatumOrFileSpendingNotOptional scriptFlagPrefix =
asum
[ PlutusSpend.PotentialDatum . Just <$> (pScriptDataOrFile
(scriptFlagPrefix ++ "-datum")
Expand All @@ -1190,16 +1187,28 @@ pScriptDatumOrFileSpending scriptFlagPrefix =
, Opt.help "Inline datum present at transaction input."
]

pScriptDatumOrFileSpendingCipi69 :: String -> Parser PlutusSpend.ScriptDatumOrFileSpending
pScriptDatumOrFileSpendingCipi69 scriptFlagPrefix =
asum
pScriptDatumOrFileSpendingCip69 :: ShelleyBasedEra era -> String -> Parser PlutusSpend.ScriptDatumOrFileSpending
pScriptDatumOrFileSpendingCip69 sbe scriptFlagPrefix =
caseShelleyToBabbageOrConwayEraOnwards
(const $ datumMandatory)

Check notice

Code scanning / HLint

Redundant $ Note

cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs:1193:12: Suggestion: Redundant $
  
Found:
  const $ datumMandatory
  
Perhaps:
  const datumMandatory
(const $ datumOptional)

Check notice

Code scanning / HLint

Redundant $ Note

cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs:1194:12: Suggestion: Redundant $
  
Found:
  const $ datumOptional
  
Perhaps:
  const datumOptional
sbe
where
datumMandatory =
asum
[ PlutusSpend.PotentialDatum . Just <$> (pScriptDataOrFile
(scriptFlagPrefix ++ "-datum")
"The script datum."
"The script datum file.")

Check notice

Code scanning / HLint

Redundant bracket Note

cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs:(1199,49)-(1202,39): Suggestion: Redundant bracket
  
Found:
  PlutusSpend.PotentialDatum . Just
    <$>
      (pScriptDataOrFile
         (scriptFlagPrefix ++ "-datum") "The script datum."
         "The script datum file.")
  
Perhaps:
  PlutusSpend.PotentialDatum . Just
    <$>
      pScriptDataOrFile
        (scriptFlagPrefix ++ "-datum") "The script datum."
        "The script datum file."
, pInlineDatumPresent
]
datumOptional = asum
[ PlutusSpend.PotentialDatum <$> optional (pScriptDataOrFile
(scriptFlagPrefix ++ "-datum")
"The script datum."
"The script datum file.")
, pInlineDatumPresent
]
where
pInlineDatumPresent :: Parser PlutusSpend.ScriptDatumOrFileSpending
pInlineDatumPresent =
flag' PlutusSpend.InlineDatum $
Expand Down Expand Up @@ -2041,7 +2050,7 @@ pTxIn sbe balance =
PlutusSpend.createPlutusReferenceScriptFromCliArgs
<$> pReferenceTxIn "spending-" "plutus"
<*> pPlutusScriptLanguage "spending-"
<*> pScriptDatumOrFileSpending "spending-reference-tx-in"
<*> pScriptDatumOrFileSpendingNotOptional "spending-reference-tx-in"
<*> pScriptRedeemerOrFile "spending-reference-tx-in"
<*> ( case autoBalanceExecUnits of
AutoBalance -> pure (ExecutionUnits 0 0)
Expand All @@ -2052,7 +2061,7 @@ pTxIn sbe balance =
PlutusSpend.createPlutusReferenceScriptFromCliArgs
<$> pReferenceTxIn "spending-" "plutus"
<*> pPlutusScriptLanguage "spending-"
<*> pScriptDatumOrFileSpendingCipi69 "spending-reference-tx-in"
<*> pScriptDatumOrFileSpendingCip69 sbe "spending-reference-tx-in"
<*> pScriptRedeemerOrFile "spending-reference-tx-in"
<*> ( case autoBalanceExecUnits of
AutoBalance -> pure (ExecutionUnits 0 0)
Expand All @@ -2064,6 +2073,7 @@ pTxIn sbe balance =
pOnDiskPlutusScriptWitness :: Parser CliSpendScriptRequirements
pOnDiskPlutusScriptWitness =
pPlutusSpendingScriptWitness
sbe
balance
"tx-in"
(Just "txin")
Expand Down

0 comments on commit 3e41196

Please sign in to comment.