Skip to content

Commit f1f1a2c

Browse files
Add new flags to disable metadata checks on proposals and votes to build cmd.
Add new flags to disable metadata checks on proposals and votes to build cmd. The build cmd automatically runs checks on the metadata hashes on proposals and votes included in the transaction. The new flags allow the user to disable such checks. Useful for testing purposes and for users that may want to avoid CLI reaching out to the internet. --disable-metadata-checks-on-proposals --disable-metadata-checks-on-votes fix formatting Fix haskell formatting
1 parent bb8b3b9 commit f1f1a2c

File tree

8 files changed

+64
-2
lines changed

8 files changed

+64
-2
lines changed

cardano-cli/src/Cardano/CLI/EraBased/Commands/Transaction.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ data TransactionBuildCmdArgs era = TransactionBuildCmdArgs
133133
, mUpdateProposalFile :: !(Maybe (Featured ShelleyToBabbageEra era (Maybe UpdateProposalFile)))
134134
, voteFiles :: ![(VoteFile In, Maybe CliVoteScriptRequirements)]
135135
, proposalFiles :: ![(ProposalFile In, Maybe CliProposalScriptRequirements)]
136+
, metadataChecksOnProposals :: !MetadataCheck
137+
, metadataChecksOnVotes :: !MetadataCheck
136138
, treasuryDonation :: !(Maybe TxTreasuryDonation)
137139
, buildOutputOptions :: !TxBuildOutputOptions
138140
}

cardano-cli/src/Cardano/CLI/EraBased/Options/Transaction.hs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import Cardano.CLI.EraBased.Commands.Transaction
1717
import Cardano.CLI.EraBased.Options.Common
1818
import Cardano.CLI.Parser
1919
import Cardano.CLI.Types.Common
20+
import Cardano.CLI.Types.Governance
2021

2122
import Data.Foldable
2223
import Options.Applicative hiding (help, str)
@@ -200,6 +201,8 @@ pTransactionBuildCmd sbe envCli = do
200201
<*> pFeatured (toCardanoEra sbe) (optional pUpdateProposalFile)
201202
<*> pVoteFiles sbe AutoBalance
202203
<*> pProposalFiles sbe AutoBalance
204+
<*> pMetadataChecksOnProposals
205+
<*> pMetadataChecksOnVotes
203206
<*> pTreasuryDonation sbe
204207
<*> pTxBuildOutputOptions
205208

@@ -384,3 +387,19 @@ pTransactionId =
384387
TransactionTxIdCmdArgs
385388
<$> pInputTxOrTxBodyFile
386389
<*> pTxIdOutputFormatJsonOrText
390+
391+
pMetadataChecksOnProposals :: Parser MetadataCheck
392+
pMetadataChecksOnProposals =
393+
Opt.flag EnableMetadataCheck DisableMetadataCheck $
394+
mconcat
395+
[ Opt.long "disable-metadata-checks-on-proposals"
396+
, Opt.help "Disable automatic metadata-hash checks on proposals included in the transaction."
397+
]
398+
399+
pMetadataChecksOnVotes :: Parser MetadataCheck
400+
pMetadataChecksOnVotes =
401+
Opt.flag EnableMetadataCheck DisableMetadataCheck $
402+
mconcat
403+
[ Opt.long "disable-metadata-checks-on-votes"
404+
, Opt.help "Disable automatic metadata-hash checks on votes included in the transaction."
405+
]

cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import Cardano.CLI.Types.Errors.BootstrapWitnessError
6767
import Cardano.CLI.Types.Errors.NodeEraMismatchError
6868
import Cardano.CLI.Types.Errors.TxCmdError
6969
import Cardano.CLI.Types.Errors.TxValidationError
70+
import Cardano.CLI.Types.Governance
7071
import Cardano.CLI.Types.Output (renderScriptCosts)
7172
import Cardano.CLI.Types.TxFeature
7273

@@ -147,6 +148,8 @@ runTransactionBuildCmd
147148
, mUpdateProposalFile
148149
, voteFiles
149150
, proposalFiles
151+
, metadataChecksOnProposals
152+
, metadataChecksOnVotes
150153
, treasuryDonation -- Maybe TxTreasuryDonation
151154
, buildOutputOptions
152155
} = do
@@ -209,14 +212,19 @@ runTransactionBuildCmd
209212
(\w -> firstExceptT TxCmdVoteError $ ExceptT (readVotingProceduresFiles w voteFiles))
210213
era'
211214

212-
forM_ votingProceduresAndMaybeScriptWits (checkVotingProcedureHashes eon . fst)
215+
unless (metadataChecksOnVotes == DisableMetadataCheck) $
216+
forM_ votingProceduresAndMaybeScriptWits (checkVotingProcedureHashes eon . fst)
217+
218+
-- unless disableMetadataChecksOnVotes $
219+
-- forM_ votingProceduresAndMaybeScriptWits (checkVotingProcedureHashes eon . fst)
213220

214221
proposals <-
215222
newExceptT $
216223
first TxCmdProposalError
217224
<$> readTxGovernanceActions eon proposalFiles
218225

219-
forM_ proposals (checkProposalHashes eon . fst)
226+
unless (metadataChecksOnProposals == DisableMetadataCheck) $
227+
forM_ proposals (checkProposalHashes eon . fst)
220228

221229
-- Extract return addresses from proposals and check that the return address in each proposal is registered
222230

cardano-cli/src/Cardano/CLI/Types/Governance.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ data VoteDelegationTarget
3232
| VoteDelegationTargetOfAbstain
3333
| VoteDelegationTargetOfNoConfidence
3434
deriving (Eq, Show)
35+
36+
data MetadataCheck = EnableMetadataCheck | DisableMetadataCheck
37+
deriving (Eq, Show)

cardano-cli/test/cardano-cli-golden/files/golden/help.cli

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6435,6 +6435,8 @@ Usage: cardano-cli babbage transaction build
64356435
| --metadata-cbor-file FILEPATH
64366436
]
64376437
[--update-proposal-file FILEPATH]
6438+
[--disable-metadata-checks-on-proposals]
6439+
[--disable-metadata-checks-on-votes]
64386440
( --out-file FILEPATH
64396441
| --calculate-plutus-script-cost FILEPATH
64406442
)
@@ -8489,6 +8491,8 @@ Usage: cardano-cli conway transaction build
84898491
| --proposal-reference-tx-in-redeemer-value JSON_VALUE
84908492
)
84918493
]]
8494+
[--disable-metadata-checks-on-proposals]
8495+
[--disable-metadata-checks-on-votes]
84928496
[--treasury-donation LOVELACE]
84938497
( --out-file FILEPATH
84948498
| --calculate-plutus-script-cost FILEPATH
@@ -10577,6 +10581,8 @@ Usage: cardano-cli latest transaction build
1057710581
| --proposal-reference-tx-in-redeemer-value JSON_VALUE
1057810582
)
1057910583
]]
10584+
[--disable-metadata-checks-on-proposals]
10585+
[--disable-metadata-checks-on-votes]
1058010586
[--treasury-donation LOVELACE]
1058110587
( --out-file FILEPATH
1058210588
| --calculate-plutus-script-cost FILEPATH

cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_transaction_build.cli

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ Usage: cardano-cli babbage transaction build
115115
| --metadata-cbor-file FILEPATH
116116
]
117117
[--update-proposal-file FILEPATH]
118+
[--disable-metadata-checks-on-proposals]
119+
[--disable-metadata-checks-on-votes]
118120
( --out-file FILEPATH
119121
| --calculate-plutus-script-cost FILEPATH
120122
)
@@ -391,6 +393,12 @@ Available options:
391393
Filepath of the metadata, in raw CBOR format.
392394
--update-proposal-file FILEPATH
393395
Filepath of the update proposal.
396+
--disable-metadata-checks-on-proposals
397+
Disable automatic metadata-hash checks on proposals
398+
included in the transaction.
399+
--disable-metadata-checks-on-votes
400+
Disable automatic metadata-hash checks on votes
401+
included in the transaction.
394402
--out-file FILEPATH Output filepath of the JSON TxBody.
395403
--calculate-plutus-script-cost FILEPATH
396404
Where to write the script cost information.

cardano-cli/test/cardano-cli-golden/files/golden/help/conway_transaction_build.cli

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ Usage: cardano-cli conway transaction build
140140
| --proposal-reference-tx-in-redeemer-value JSON_VALUE
141141
)
142142
]]
143+
[--disable-metadata-checks-on-proposals]
144+
[--disable-metadata-checks-on-votes]
143145
[--treasury-donation LOVELACE]
144146
( --out-file FILEPATH
145147
| --calculate-plutus-script-cost FILEPATH
@@ -470,6 +472,12 @@ Available options:
470472
The script redeemer value. There is no schema:
471473
(almost) any JSON value is supported, including
472474
top-level strings and numbers.
475+
--disable-metadata-checks-on-proposals
476+
Disable automatic metadata-hash checks on proposals
477+
included in the transaction.
478+
--disable-metadata-checks-on-votes
479+
Disable automatic metadata-hash checks on votes
480+
included in the transaction.
473481
--treasury-donation LOVELACE
474482
The donation to the treasury to perform.
475483
--out-file FILEPATH Output filepath of the JSON TxBody.

cardano-cli/test/cardano-cli-golden/files/golden/help/latest_transaction_build.cli

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ Usage: cardano-cli latest transaction build
140140
| --proposal-reference-tx-in-redeemer-value JSON_VALUE
141141
)
142142
]]
143+
[--disable-metadata-checks-on-proposals]
144+
[--disable-metadata-checks-on-votes]
143145
[--treasury-donation LOVELACE]
144146
( --out-file FILEPATH
145147
| --calculate-plutus-script-cost FILEPATH
@@ -470,6 +472,12 @@ Available options:
470472
The script redeemer value. There is no schema:
471473
(almost) any JSON value is supported, including
472474
top-level strings and numbers.
475+
--disable-metadata-checks-on-proposals
476+
Disable automatic metadata-hash checks on proposals
477+
included in the transaction.
478+
--disable-metadata-checks-on-votes
479+
Disable automatic metadata-hash checks on votes
480+
included in the transaction.
473481
--treasury-donation LOVELACE
474482
The donation to the treasury to perform.
475483
--out-file FILEPATH Output filepath of the JSON TxBody.

0 commit comments

Comments
 (0)