Skip to content

Commit

Permalink
Support --vote-file in transaction build-raw
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Oct 11, 2023
1 parent c444f26 commit 8470ba7
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 13 deletions.
3 changes: 2 additions & 1 deletion cardano-cli/src/Cardano/CLI/EraBased/Commands/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ data TransactionCmds era
[MetadataFile]
(Maybe ProtocolParamsFile)
(Maybe UpdateProposalFile)
[ProposalFile 'In]
[VoteFile In]
[ProposalFile In]
(TxBodyFile Out)

-- | Like 'TxBuildRaw' but without the fee, and with a change output.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ pTransactionBuildRaw era =
<*> many pMetadataFile
<*> optional pProtocolParamsFile
<*> optional pUpdateProposalFile
<*> many (pFileInDirection "vote-file" "Filepath of the vote.")
<*> many (pFileInDirection "proposal-file" "Filepath of the proposal.")
<*> pTxBodyFileOut

Expand Down
33 changes: 22 additions & 11 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,23 @@ runTransactionCmds cmd =
TxBuild
era mNodeSocketPath consensusModeParams nid mScriptValidity mOverrideWits txins readOnlyRefIns
reqSigners txinsc mReturnColl mTotCollateral txouts changeAddr mValue mLowBound
mUpperBound certs wdrls metadataSchema scriptFiles metadataFiles mUpProp votingProcedureFiles
mUpperBound certs wdrls metadataSchema scriptFiles metadataFiles mUpProp voteFiles
proposalFiles outputOptions ->
runTxBuildCmd
era mNodeSocketPath consensusModeParams nid mScriptValidity mOverrideWits txins readOnlyRefIns
reqSigners txinsc mReturnColl mTotCollateral txouts changeAddr mValue mLowBound
mUpperBound certs wdrls metadataSchema scriptFiles metadataFiles mUpProp votingProcedureFiles
mUpperBound certs wdrls metadataSchema scriptFiles metadataFiles mUpProp voteFiles
proposalFiles outputOptions
TxBuildRaw
era mScriptValidity txins readOnlyRefIns txinsc mReturnColl
mTotColl reqSigners txouts mValue mLowBound mUpperBound fee certs wdrls
metadataSchema scriptFiles metadataFiles mProtocolParamsFile mUpProp proposalFiles
metadataSchema scriptFiles metadataFiles mProtocolParamsFile mUpProp
voteFiles proposalFiles
out ->
runTxBuildRawCmd era mScriptValidity txins readOnlyRefIns txinsc mReturnColl
mTotColl reqSigners txouts mValue mLowBound mUpperBound fee certs wdrls
metadataSchema scriptFiles metadataFiles mProtocolParamsFile mUpProp proposalFiles
metadataSchema scriptFiles metadataFiles mProtocolParamsFile mUpProp
voteFiles proposalFiles
out
TxSign txinfile skfiles network txoutfile ->
runTxSignCmd txinfile skfiles network txoutfile
Expand Down Expand Up @@ -152,7 +154,7 @@ runTxBuildCmd
era socketPath consensusModeParams@(AnyConsensusModeParams cModeParams) nid
mScriptValidity mOverrideWits txins readOnlyRefIns reqSigners txinsc mReturnColl mTotCollateral txouts
changeAddr mValue mLowBound mUpperBound certs wdrls metadataSchema scriptFiles metadataFiles mUpProp
votingProcedureFiles proposalFiles outputOptions = do
voteFiles proposalFiles outputOptions = do

-- The user can specify an era prior to the era that the node is currently in.
-- We cannot use the user specified era to construct a query against a node because it may differ
Expand Down Expand Up @@ -197,7 +199,7 @@ runTxBuildCmd
votingProcedures <-
inEonForEra
(pure emptyVotingProcedures)
(\w -> firstExceptT TxCmdVoteError $ ExceptT (readVotingProceduresFiles w votingProcedureFiles))
(\w -> firstExceptT TxCmdVoteError $ ExceptT (readVotingProceduresFiles w voteFiles))
era

proposals <- newExceptT $ first TxCmdConstitutionError
Expand Down Expand Up @@ -307,14 +309,15 @@ runTxBuildRawCmd
-> [MetadataFile]
-> Maybe ProtocolParamsFile
-> Maybe UpdateProposalFile
-> [VoteFile In]
-> [ProposalFile In]
-> TxBodyFile Out
-> ExceptT TxCmdError IO ()
runTxBuildRawCmd
era mScriptValidity txins readOnlyRefIns txinsc mReturnColl
mTotColl reqSigners txouts mValue mLowBound mUpperBound fee certs wdrls
metadataSchema scriptFiles metadataFiles mpParamsFile mUpProp
proposalFiles out = do
voteFiles proposalFiles out = do
inputsAndMaybeScriptWits <- firstExceptT TxCmdScriptWitnessError
$ readScriptWitnessFiles era txins
certFilesAndMaybeScriptWits <- firstExceptT TxCmdScriptWitnessError
Expand Down Expand Up @@ -361,14 +364,21 @@ runTxBuildRawCmd
-- the same collateral input can be used for several plutus scripts
let filteredTxinsc = Set.toList $ Set.fromList txinsc

-- Conway related
votingProcedures <-
inEonForEra
(pure emptyVotingProcedures)
(\w -> firstExceptT TxCmdVoteError $ ExceptT (readVotingProceduresFiles w voteFiles))
era

proposals <-
lift (readTxGovernanceActions era proposalFiles)
& onLeft (left . TxCmdConstitutionError)

txBody <- hoistEither $ runTxBuildRaw era mScriptValidity inputsAndMaybeScriptWits readOnlyRefIns filteredTxinsc
mReturnCollateral mTotColl txOuts mLowBound mUpperBound fee valuesWithScriptWits
certsAndMaybeScriptWits withdrawalsAndMaybeScriptWits requiredSigners txAuxScripts
txMetadata mLedgerPParams mProp proposals
txMetadata mLedgerPParams mProp votingProcedures proposals

let noWitTx = makeSignedTransaction [] txBody
lift (cardanoEraConstraints era $ writeTxFileTextEnvelopeCddl out noWitTx)
Expand Down Expand Up @@ -407,6 +417,7 @@ runTxBuildRaw :: ()
-> TxMetadataInEra era
-> Maybe (LedgerProtocolParameters era)
-> Maybe UpdateProposal
-> VotingProcedures era
-> [Proposal era]
-> Either TxCmdError (TxBody era)
runTxBuildRaw era
Expand All @@ -416,7 +427,7 @@ runTxBuildRaw era
mLowerBound mUpperBound
mFee valuesWithScriptWits
certsAndMaybeSriptWits withdrawals reqSigners
txAuxScripts txMetadata mpparams mUpdateProp proposals = do
txAuxScripts txMetadata mpparams mUpdateProp votingProcedures proposals = do

let allReferenceInputs = getAllReferenceInputs
inputsAndMaybeScriptWits
Expand Down Expand Up @@ -450,7 +461,7 @@ runTxBuildRaw era
validatedTxScriptValidity
<- first TxCmdScriptValidityValidationError $ validateTxScriptValidity era mScriptValidity
let validatedTxProposal = proposals
validatedTxVotes = Nothing -- TODO: Conwary era
validatedTxVotes = votingProcedures -- TODO: Conwary era
let txBodyContent =
TxBodyContent
{ txIns = validateTxIns inputsAndMaybeScriptWits
Expand All @@ -471,7 +482,7 @@ runTxBuildRaw era
, txMintValue = validatedMintValue
, txScriptValidity = validatedTxScriptValidity
, txProposalProcedures = forEraInEonMaybe era (`Featured` validatedTxProposal)
, txVotingProcedures = validatedTxVotes
, txVotingProcedures = forEraInEonMaybe era (`Featured` validatedTxVotes)
}

first TxCmdTxBodyError $
Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/Legacy/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ runLegacyTxBuildRawCmd
metadataSchema scriptFiles metadataFiles mProtocolParamsFile mUpProp =
runTxBuildRawCmd era mScriptValidity txins readOnlyRefIns txinsc mReturnColl
mTotColl reqSigners txouts mValue mLowBound mUpperBound fee certs wdrls
metadataSchema scriptFiles metadataFiles mProtocolParamsFile mUpProp []
metadataSchema scriptFiles metadataFiles mProtocolParamsFile mUpProp [] []

runLegacyTxSignCmd :: InputTxBodyOrTxFile
-> [WitnessSigningData]
Expand Down
7 changes: 7 additions & 0 deletions cardano-cli/test/cardano-cli-golden/files/golden/help.cli
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,7 @@ Usage: cardano-cli shelley transaction build-raw
]
[--protocol-params-file FILE]
[--update-proposal-file FILE]
[--vote-file FILE]
[--proposal-file FILE]
--out-file FILE

Expand Down Expand Up @@ -2130,6 +2131,7 @@ Usage: cardano-cli allegra transaction build-raw
]
[--protocol-params-file FILE]
[--update-proposal-file FILE]
[--vote-file FILE]
[--proposal-file FILE]
--out-file FILE

Expand Down Expand Up @@ -3302,6 +3304,7 @@ Usage: cardano-cli mary transaction build-raw
]
[--protocol-params-file FILE]
[--update-proposal-file FILE]
[--vote-file FILE]
[--proposal-file FILE]
--out-file FILE

Expand Down Expand Up @@ -4479,6 +4482,7 @@ Usage: cardano-cli alonzo transaction build-raw
]
[--protocol-params-file FILE]
[--update-proposal-file FILE]
[--vote-file FILE]
[--proposal-file FILE]
--out-file FILE

Expand Down Expand Up @@ -5692,6 +5696,7 @@ Usage: cardano-cli babbage transaction build-raw
]
[--protocol-params-file FILE]
[--update-proposal-file FILE]
[--vote-file FILE]
[--proposal-file FILE]
--out-file FILE

Expand Down Expand Up @@ -7249,6 +7254,7 @@ Usage: cardano-cli conway transaction build-raw
]
[--protocol-params-file FILE]
[--update-proposal-file FILE]
[--vote-file FILE]
[--proposal-file FILE]
--out-file FILE

Expand Down Expand Up @@ -8459,6 +8465,7 @@ Usage: cardano-cli latest transaction build-raw
]
[--protocol-params-file FILE]
[--update-proposal-file FILE]
[--vote-file FILE]
[--proposal-file FILE]
--out-file FILE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Usage: cardano-cli allegra transaction build-raw
]
[--protocol-params-file FILE]
[--update-proposal-file FILE]
[--vote-file FILE]
[--proposal-file FILE]
--out-file FILE

Expand Down Expand Up @@ -382,6 +383,7 @@ Available options:
Filepath of the JSON-encoded protocol parameters file
--update-proposal-file FILE
Filepath of the update proposal.
--vote-file FILE Filepath of the vote.
--proposal-file FILE Filepath of the proposal.
--out-file FILE Output filepath of the JSON TxBody.
-h,--help Show this help text
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Usage: cardano-cli alonzo transaction build-raw
]
[--protocol-params-file FILE]
[--update-proposal-file FILE]
[--vote-file FILE]
[--proposal-file FILE]
--out-file FILE

Expand Down Expand Up @@ -382,6 +383,7 @@ Available options:
Filepath of the JSON-encoded protocol parameters file
--update-proposal-file FILE
Filepath of the update proposal.
--vote-file FILE Filepath of the vote.
--proposal-file FILE Filepath of the proposal.
--out-file FILE Output filepath of the JSON TxBody.
-h,--help Show this help text
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Usage: cardano-cli babbage transaction build-raw
]
[--protocol-params-file FILE]
[--update-proposal-file FILE]
[--vote-file FILE]
[--proposal-file FILE]
--out-file FILE

Expand Down Expand Up @@ -382,6 +383,7 @@ Available options:
Filepath of the JSON-encoded protocol parameters file
--update-proposal-file FILE
Filepath of the update proposal.
--vote-file FILE Filepath of the vote.
--proposal-file FILE Filepath of the proposal.
--out-file FILE Output filepath of the JSON TxBody.
-h,--help Show this help text
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Usage: cardano-cli conway transaction build-raw
]
[--protocol-params-file FILE]
[--update-proposal-file FILE]
[--vote-file FILE]
[--proposal-file FILE]
--out-file FILE

Expand Down Expand Up @@ -382,6 +383,7 @@ Available options:
Filepath of the JSON-encoded protocol parameters file
--update-proposal-file FILE
Filepath of the update proposal.
--vote-file FILE Filepath of the vote.
--proposal-file FILE Filepath of the proposal.
--out-file FILE Output filepath of the JSON TxBody.
-h,--help Show this help text
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Usage: cardano-cli latest transaction build-raw
]
[--protocol-params-file FILE]
[--update-proposal-file FILE]
[--vote-file FILE]
[--proposal-file FILE]
--out-file FILE

Expand Down Expand Up @@ -382,6 +383,7 @@ Available options:
Filepath of the JSON-encoded protocol parameters file
--update-proposal-file FILE
Filepath of the update proposal.
--vote-file FILE Filepath of the vote.
--proposal-file FILE Filepath of the proposal.
--out-file FILE Output filepath of the JSON TxBody.
-h,--help Show this help text
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Usage: cardano-cli mary transaction build-raw
]
[--protocol-params-file FILE]
[--update-proposal-file FILE]
[--vote-file FILE]
[--proposal-file FILE]
--out-file FILE

Expand Down Expand Up @@ -382,6 +383,7 @@ Available options:
Filepath of the JSON-encoded protocol parameters file
--update-proposal-file FILE
Filepath of the update proposal.
--vote-file FILE Filepath of the vote.
--proposal-file FILE Filepath of the proposal.
--out-file FILE Output filepath of the JSON TxBody.
-h,--help Show this help text
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Usage: cardano-cli shelley transaction build-raw
]
[--protocol-params-file FILE]
[--update-proposal-file FILE]
[--vote-file FILE]
[--proposal-file FILE]
--out-file FILE

Expand Down Expand Up @@ -382,6 +383,7 @@ Available options:
Filepath of the JSON-encoded protocol parameters file
--update-proposal-file FILE
Filepath of the update proposal.
--vote-file FILE Filepath of the vote.
--proposal-file FILE Filepath of the proposal.
--out-file FILE Output filepath of the JSON TxBody.
-h,--help Show this help text

0 comments on commit 8470ba7

Please sign in to comment.