From c444f269b9843df6dde8b91373b4fb52ca781034 Mon Sep 17 00:00:00 2001 From: John Ky Date: Wed, 11 Oct 2023 23:27:38 +1100 Subject: [PATCH] Support --proposal-file in transaction build-raw --- .../CLI/EraBased/Commands/Transaction.hs | 1 + .../CLI/EraBased/Options/Transaction.hs | 1 + .../Cardano/CLI/EraBased/Run/Transaction.hs | 45 +++++++++++-------- .../src/Cardano/CLI/Legacy/Run/Transaction.hs | 8 +++- .../cardano-cli-golden/files/golden/help.cli | 7 +++ .../help/allegra_transaction_build-raw.cli | 2 + .../help/alonzo_transaction_build-raw.cli | 2 + .../help/babbage_transaction_build-raw.cli | 2 + .../help/conway_transaction_build-raw.cli | 2 + .../help/latest_transaction_build-raw.cli | 2 + .../help/mary_transaction_build-raw.cli | 2 + .../help/shelley_transaction_build-raw.cli | 2 + 12 files changed, 57 insertions(+), 19 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Transaction.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Transaction.hs index 7be8b8a2aa..2c972d8496 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Transaction.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Transaction.hs @@ -48,6 +48,7 @@ data TransactionCmds era [MetadataFile] (Maybe ProtocolParamsFile) (Maybe UpdateProposalFile) + [ProposalFile 'In] (TxBodyFile Out) -- | Like 'TxBuildRaw' but without the fee, and with a change output. diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Transaction.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Transaction.hs index 513f41739b..87d9f3b984 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Transaction.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Transaction.hs @@ -211,6 +211,7 @@ pTransactionBuildRaw era = <*> many pMetadataFile <*> optional pProtocolParamsFile <*> optional pUpdateProposalFile + <*> many (pFileInDirection "proposal-file" "Filepath of the proposal.") <*> pTxBodyFileOut pTransactionSign :: EnvCli -> Parser (TransactionCmds era) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs index 2d46b43bf1..1dfb3f2732 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs @@ -79,20 +79,22 @@ 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 mconwayVote - mNewConstitution outputOptions -> + mUpperBound certs wdrls metadataSchema scriptFiles metadataFiles mUpProp votingProcedureFiles + 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 mconwayVote - mNewConstitution outputOptions + mUpperBound certs wdrls metadataSchema scriptFiles metadataFiles mUpProp votingProcedureFiles + proposalFiles outputOptions TxBuildRaw era mScriptValidity txins readOnlyRefIns txinsc mReturnColl mTotColl reqSigners txouts mValue mLowBound mUpperBound fee certs wdrls - metadataSchema scriptFiles metadataFiles mProtocolParamsFile mUpProp out -> + metadataSchema scriptFiles metadataFiles mProtocolParamsFile mUpProp proposalFiles + out -> runTxBuildRawCmd era mScriptValidity txins readOnlyRefIns txinsc mReturnColl mTotColl reqSigners txouts mValue mLowBound mUpperBound fee certs wdrls - metadataSchema scriptFiles metadataFiles mProtocolParamsFile mUpProp out + metadataSchema scriptFiles metadataFiles mProtocolParamsFile mUpProp proposalFiles + out TxSign txinfile skfiles network txoutfile -> runTxSignCmd txinfile skfiles network txoutfile TxSubmit mNodeSocketPath anyConsensusModeParams network txFp -> @@ -150,7 +152,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 - conwayVotes newProposals outputOptions = do + votingProcedureFiles 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 @@ -192,14 +194,14 @@ runTxBuildCmd txOuts <- mapM (toTxOutInAnyEra era) txouts -- Conway related - votes <- + votingProcedures <- inEonForEra (pure emptyVotingProcedures) - (\w -> firstExceptT TxCmdVoteError $ ExceptT (readVotingProceduresFiles w conwayVotes)) + (\w -> firstExceptT TxCmdVoteError $ ExceptT (readVotingProceduresFiles w votingProcedureFiles)) era proposals <- newExceptT $ first TxCmdConstitutionError - <$> readTxGovernanceActions era newProposals + <$> readTxGovernanceActions era proposalFiles -- the same collateral input can be used for several plutus scripts let filteredTxinsc = Set.toList $ Set.fromList txinsc @@ -210,7 +212,7 @@ runTxBuildCmd era socketPath consensusModeParams nid mScriptValidity inputsAndMaybeScriptWits readOnlyRefIns filteredTxinsc mReturnCollateral mTotCollateral txOuts changeAddr valuesWithScriptWits mLowBound mUpperBound certsAndMaybeScriptWits withdrawalsAndMaybeScriptWits - requiredSigners txAuxScripts txMetadata mProp mOverrideWits votes proposals outputOptions + requiredSigners txAuxScripts txMetadata mProp mOverrideWits votingProcedures proposals outputOptions let mScriptWits = forEraInEon era [] $ \sbe -> collectTxBodyScriptWitnesses sbe txBodyContent @@ -305,12 +307,14 @@ runTxBuildRawCmd -> [MetadataFile] -> Maybe ProtocolParamsFile -> Maybe UpdateProposalFile + -> [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 out = do + metadataSchema scriptFiles metadataFiles mpParamsFile mUpProp + proposalFiles out = do inputsAndMaybeScriptWits <- firstExceptT TxCmdScriptWitnessError $ readScriptWitnessFiles era txins certFilesAndMaybeScriptWits <- firstExceptT TxCmdScriptWitnessError @@ -357,10 +361,14 @@ runTxBuildRawCmd -- the same collateral input can be used for several plutus scripts let filteredTxinsc = Set.toList $ Set.fromList txinsc + 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 + txMetadata mLedgerPParams mProp proposals let noWitTx = makeSignedTransaction [] txBody lift (cardanoEraConstraints era $ writeTxFileTextEnvelopeCddl out noWitTx) @@ -399,6 +407,7 @@ runTxBuildRaw :: () -> TxMetadataInEra era -> Maybe (LedgerProtocolParameters era) -> Maybe UpdateProposal + -> [Proposal era] -> Either TxCmdError (TxBody era) runTxBuildRaw era mScriptValidity inputsAndMaybeScriptWits @@ -407,7 +416,7 @@ runTxBuildRaw era mLowerBound mUpperBound mFee valuesWithScriptWits certsAndMaybeSriptWits withdrawals reqSigners - txAuxScripts txMetadata mpparams mUpdateProp = do + txAuxScripts txMetadata mpparams mUpdateProp proposals = do let allReferenceInputs = getAllReferenceInputs inputsAndMaybeScriptWits @@ -440,7 +449,7 @@ runTxBuildRaw era <- createTxMintValue era valuesWithScriptWits validatedTxScriptValidity <- first TxCmdScriptValidityValidationError $ validateTxScriptValidity era mScriptValidity - let validatedTxProposalProcedures = Nothing -- TODO: Conwary era + let validatedTxProposal = proposals validatedTxVotes = Nothing -- TODO: Conwary era let txBodyContent = TxBodyContent @@ -461,7 +470,7 @@ runTxBuildRaw era , txUpdateProposal = validatedTxUpProp , txMintValue = validatedMintValue , txScriptValidity = validatedTxScriptValidity - , txProposalProcedures = validatedTxProposalProcedures + , txProposalProcedures = forEraInEonMaybe era (`Featured` validatedTxProposal) , txVotingProcedures = validatedTxVotes } @@ -513,7 +522,7 @@ runTxBuild inputsAndMaybeScriptWits readOnlyRefIns txinsc mReturnCollateral mTotCollateral txouts (TxOutChangeAddress changeAddr) valuesWithScriptWits mLowerBound mUpperBound certsAndMaybeScriptWits withdrawals reqSigners txAuxScripts txMetadata - mUpdatePropF mOverrideWits votes proposals outputOptions = do + mUpdatePropF mOverrideWits votingProcedures proposals outputOptions = do let consensusMode = consensusModeOnly cModeParams dummyFee = Just $ Lovelace 0 @@ -575,7 +584,7 @@ runTxBuild $ validateProtocolParameters era (Just pparams) let validatedTxProposalProcedures = proposals - validatedTxVotes = votes + validatedTxVotes = votingProcedures txBodyContent = TxBodyContent { txIns = validateTxIns inputsAndMaybeScriptWits diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Run/Transaction.hs b/cardano-cli/src/Cardano/CLI/Legacy/Run/Transaction.hs index bf2aeda9ca..9e34bd0be8 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Run/Transaction.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Run/Transaction.hs @@ -114,7 +114,13 @@ runLegacyTxBuildRawCmd :: () -> Maybe UpdateProposalFile -> TxBodyFile Out -> ExceptT TxCmdError IO () -runLegacyTxBuildRawCmd (AnyCardanoEra era) = runTxBuildRawCmd era +runLegacyTxBuildRawCmd + (AnyCardanoEra era) mScriptValidity txins readOnlyRefIns txinsc mReturnColl + mTotColl reqSigners txouts mValue mLowBound mUpperBound fee certs wdrls + 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 [] runLegacyTxSignCmd :: InputTxBodyOrTxFile -> [WitnessSigningData] diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli index ce0ad90f3a..fb926bc293 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli @@ -945,6 +945,7 @@ Usage: cardano-cli shelley transaction build-raw ] [--protocol-params-file FILE] [--update-proposal-file FILE] + [--proposal-file FILE] --out-file FILE Build a transaction (low-level, inconvenient) @@ -2129,6 +2130,7 @@ Usage: cardano-cli allegra transaction build-raw ] [--protocol-params-file FILE] [--update-proposal-file FILE] + [--proposal-file FILE] --out-file FILE Build a transaction (low-level, inconvenient) @@ -3300,6 +3302,7 @@ Usage: cardano-cli mary transaction build-raw ] [--protocol-params-file FILE] [--update-proposal-file FILE] + [--proposal-file FILE] --out-file FILE Build a transaction (low-level, inconvenient) @@ -4476,6 +4479,7 @@ Usage: cardano-cli alonzo transaction build-raw ] [--protocol-params-file FILE] [--update-proposal-file FILE] + [--proposal-file FILE] --out-file FILE Build a transaction (low-level, inconvenient) @@ -5688,6 +5692,7 @@ Usage: cardano-cli babbage transaction build-raw ] [--protocol-params-file FILE] [--update-proposal-file FILE] + [--proposal-file FILE] --out-file FILE Build a transaction (low-level, inconvenient) @@ -7244,6 +7249,7 @@ Usage: cardano-cli conway transaction build-raw ] [--protocol-params-file FILE] [--update-proposal-file FILE] + [--proposal-file FILE] --out-file FILE Build a transaction (low-level, inconvenient) @@ -8453,6 +8459,7 @@ Usage: cardano-cli latest transaction build-raw ] [--protocol-params-file FILE] [--update-proposal-file FILE] + [--proposal-file FILE] --out-file FILE Build a transaction (low-level, inconvenient) diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/allegra_transaction_build-raw.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/allegra_transaction_build-raw.cli index 7f572f4072..6080031cf5 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/allegra_transaction_build-raw.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/allegra_transaction_build-raw.cli @@ -113,6 +113,7 @@ Usage: cardano-cli allegra transaction build-raw ] [--protocol-params-file FILE] [--update-proposal-file FILE] + [--proposal-file FILE] --out-file FILE Build a transaction (low-level, inconvenient) @@ -381,5 +382,6 @@ Available options: Filepath of the JSON-encoded protocol parameters file --update-proposal-file FILE Filepath of the update proposal. + --proposal-file FILE Filepath of the proposal. --out-file FILE Output filepath of the JSON TxBody. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/alonzo_transaction_build-raw.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/alonzo_transaction_build-raw.cli index a65e1d688f..8179fd8b30 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/alonzo_transaction_build-raw.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/alonzo_transaction_build-raw.cli @@ -113,6 +113,7 @@ Usage: cardano-cli alonzo transaction build-raw ] [--protocol-params-file FILE] [--update-proposal-file FILE] + [--proposal-file FILE] --out-file FILE Build a transaction (low-level, inconvenient) @@ -381,5 +382,6 @@ Available options: Filepath of the JSON-encoded protocol parameters file --update-proposal-file FILE Filepath of the update proposal. + --proposal-file FILE Filepath of the proposal. --out-file FILE Output filepath of the JSON TxBody. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_transaction_build-raw.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_transaction_build-raw.cli index ed95c2f2b5..77a75d86e9 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_transaction_build-raw.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_transaction_build-raw.cli @@ -113,6 +113,7 @@ Usage: cardano-cli babbage transaction build-raw ] [--protocol-params-file FILE] [--update-proposal-file FILE] + [--proposal-file FILE] --out-file FILE Build a transaction (low-level, inconvenient) @@ -381,5 +382,6 @@ Available options: Filepath of the JSON-encoded protocol parameters file --update-proposal-file FILE Filepath of the update proposal. + --proposal-file FILE Filepath of the proposal. --out-file FILE Output filepath of the JSON TxBody. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_transaction_build-raw.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_transaction_build-raw.cli index 27848902ff..f986701818 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_transaction_build-raw.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_transaction_build-raw.cli @@ -113,6 +113,7 @@ Usage: cardano-cli conway transaction build-raw ] [--protocol-params-file FILE] [--update-proposal-file FILE] + [--proposal-file FILE] --out-file FILE Build a transaction (low-level, inconvenient) @@ -381,5 +382,6 @@ Available options: Filepath of the JSON-encoded protocol parameters file --update-proposal-file FILE Filepath of the update proposal. + --proposal-file FILE Filepath of the proposal. --out-file FILE Output filepath of the JSON TxBody. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_transaction_build-raw.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_transaction_build-raw.cli index 3eb197e97a..c7a34f0e6c 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_transaction_build-raw.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_transaction_build-raw.cli @@ -113,6 +113,7 @@ Usage: cardano-cli latest transaction build-raw ] [--protocol-params-file FILE] [--update-proposal-file FILE] + [--proposal-file FILE] --out-file FILE Build a transaction (low-level, inconvenient) @@ -381,5 +382,6 @@ Available options: Filepath of the JSON-encoded protocol parameters file --update-proposal-file FILE Filepath of the update proposal. + --proposal-file FILE Filepath of the proposal. --out-file FILE Output filepath of the JSON TxBody. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/mary_transaction_build-raw.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/mary_transaction_build-raw.cli index b01ccb528d..39340040e0 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/mary_transaction_build-raw.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/mary_transaction_build-raw.cli @@ -113,6 +113,7 @@ Usage: cardano-cli mary transaction build-raw ] [--protocol-params-file FILE] [--update-proposal-file FILE] + [--proposal-file FILE] --out-file FILE Build a transaction (low-level, inconvenient) @@ -381,5 +382,6 @@ Available options: Filepath of the JSON-encoded protocol parameters file --update-proposal-file FILE Filepath of the update proposal. + --proposal-file FILE Filepath of the proposal. --out-file FILE Output filepath of the JSON TxBody. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/shelley_transaction_build-raw.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/shelley_transaction_build-raw.cli index 6f4ad45c3a..b6479e7b1b 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/shelley_transaction_build-raw.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/shelley_transaction_build-raw.cli @@ -113,6 +113,7 @@ Usage: cardano-cli shelley transaction build-raw ] [--protocol-params-file FILE] [--update-proposal-file FILE] + [--proposal-file FILE] --out-file FILE Build a transaction (low-level, inconvenient) @@ -381,5 +382,6 @@ Available options: Filepath of the JSON-encoded protocol parameters file --update-proposal-file FILE Filepath of the update proposal. + --proposal-file FILE Filepath of the proposal. --out-file FILE Output filepath of the JSON TxBody. -h,--help Show this help text