diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index 296d30527a..edf6bb5568 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -360,6 +360,7 @@ test-suite cardano-cli-test Test.Cli.Shelley.Run.Hash Test.Cli.Shelley.Run.Query Test.Cli.Shelley.Transaction.Build + Test.Cli.Shelley.Transaction.Compatible.Build Test.Cli.VerificationKey ghc-options: diff --git a/cardano-cli/src/Cardano/CLI/Compatible/Transaction.hs b/cardano-cli/src/Cardano/CLI/Compatible/Transaction.hs index b1f35324b6..caffc91761 100644 --- a/cardano-cli/src/Cardano/CLI/Compatible/Transaction.hs +++ b/cardano-cli/src/Cardano/CLI/Compatible/Transaction.hs @@ -260,7 +260,9 @@ runCompatibleTransactionCmd ] -- TODO is this missing something? see EraBased.Run.Transaction L907 validatedRefInputs <- liftEither . first CompatibleTxCmdError $ validateTxInsReference refInputs + let txCerts = convertCertificates certsAndMaybeScriptWits + -- this body is only for witnesses apiTxBody <- firstExceptT CompatibleTxBodyError $ hoistEither $ @@ -269,14 +271,14 @@ runCompatibleTransactionCmd & setTxIns (map (,BuildTxWith (KeyWitness KeyWitnessForSpending)) ins) & setTxOuts allOuts & setTxFee (TxFeeExplicit sbe fee) - & setTxCertificates (convertCertificates certsAndMaybeScriptWits) + & setTxCertificates txCerts & setTxInsReference validatedRefInputs let (sksByron, sksShelley) = partitionSomeWitnesses $ map categoriseSomeSigningWitness sks byronWitnesses <- - firstExceptT CompatibleBootstrapWitnessError $ - hoistEither (mkShelleyBootstrapWitnesses sbe mNetworkId apiTxBody sksByron) + firstExceptT CompatibleBootstrapWitnessError . hoistEither $ + mkShelleyBootstrapWitnesses sbe mNetworkId apiTxBody sksByron let newShelleyKeyWits = map (makeShelleyKeyWitness sbe apiTxBody) sksShelley allKeyWits = newShelleyKeyWits ++ byronWitnesses @@ -284,21 +286,24 @@ runCompatibleTransactionCmd (protocolUpdates, votes) <- caseShelleyToBabbageOrConwayEraOnwards ( const $ do - prop <- maybe (return $ NoPParamsUpdate sbe) readUpdateProposalFile mUpdateProposal + prop <- maybe (pure $ NoPParamsUpdate sbe) readUpdateProposalFile mUpdateProposal return (prop, NoVotes) ) ( \w -> do - prop <- maybe (return $ NoPParamsUpdate sbe) readProposalProcedureFile mProposalProcedure - votesAndWits <- firstExceptT CompatibleVoteError $ newExceptT $ readVotingProceduresFiles w mVotes + prop <- maybe (pure $ NoPParamsUpdate sbe) readProposalProcedureFile mProposalProcedure + votesAndWits <- + firstExceptT CompatibleVoteError . newExceptT $ + readVotingProceduresFiles w mVotes votingProcedures <- - firstExceptT CompatibleVoteMergeError $ hoistEither $ mkTxVotingProcedures votesAndWits + firstExceptT CompatibleVoteMergeError . hoistEither $ + mkTxVotingProcedures votesAndWits return (prop, VotingProcedures w votingProcedures) ) sbe signedTx <- firstExceptT CompatiblePParamsConversionError . hoistEither $ - createCompatibleSignedTx sbe ins allOuts allKeyWits fee protocolUpdates votes + createCompatibleSignedTx sbe ins allOuts allKeyWits fee protocolUpdates votes txCerts firstExceptT CompatibleFileError $ newExceptT $ 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 14e47f6556..5a0309bd13 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli @@ -10787,6 +10787,25 @@ Usage: cardano-cli compatible shelley transaction signed-transaction | --testnet-magic NATURAL ] --fee LOVELACE + [ + --certificate-file FILEPATH + [ --certificate-script-file FILEPATH + [ + ( --certificate-redeemer-cbor-file CBOR_FILE + | --certificate-redeemer-file JSON_FILE + | --certificate-redeemer-value JSON_VALUE + ) + --certificate-execution-units (INT, INT)] + | --certificate-tx-in-reference TX-IN + ( --certificate-plutus-script-v2 + | --certificate-plutus-script-v3 + ) + ( --certificate-reference-tx-in-redeemer-cbor-file CBOR_FILE + | --certificate-reference-tx-in-redeemer-file JSON_FILE + | --certificate-reference-tx-in-redeemer-value JSON_VALUE + ) + --certificate-reference-tx-in-execution-units (INT, INT) + ]] --out-file FILEPATH Create a simple signed transaction. @@ -10901,6 +10920,25 @@ Usage: cardano-cli compatible allegra transaction signed-transaction | --testnet-magic NATURAL ] --fee LOVELACE + [ + --certificate-file FILEPATH + [ --certificate-script-file FILEPATH + [ + ( --certificate-redeemer-cbor-file CBOR_FILE + | --certificate-redeemer-file JSON_FILE + | --certificate-redeemer-value JSON_VALUE + ) + --certificate-execution-units (INT, INT)] + | --certificate-tx-in-reference TX-IN + ( --certificate-plutus-script-v2 + | --certificate-plutus-script-v3 + ) + ( --certificate-reference-tx-in-redeemer-cbor-file CBOR_FILE + | --certificate-reference-tx-in-redeemer-file JSON_FILE + | --certificate-reference-tx-in-redeemer-value JSON_VALUE + ) + --certificate-reference-tx-in-execution-units (INT, INT) + ]] --out-file FILEPATH Create a simple signed transaction. @@ -11015,6 +11053,25 @@ Usage: cardano-cli compatible mary transaction signed-transaction | --testnet-magic NATURAL ] --fee LOVELACE + [ + --certificate-file FILEPATH + [ --certificate-script-file FILEPATH + [ + ( --certificate-redeemer-cbor-file CBOR_FILE + | --certificate-redeemer-file JSON_FILE + | --certificate-redeemer-value JSON_VALUE + ) + --certificate-execution-units (INT, INT)] + | --certificate-tx-in-reference TX-IN + ( --certificate-plutus-script-v2 + | --certificate-plutus-script-v3 + ) + ( --certificate-reference-tx-in-redeemer-cbor-file CBOR_FILE + | --certificate-reference-tx-in-redeemer-file JSON_FILE + | --certificate-reference-tx-in-redeemer-value JSON_VALUE + ) + --certificate-reference-tx-in-execution-units (INT, INT) + ]] --out-file FILEPATH Create a simple signed transaction. @@ -11137,6 +11194,25 @@ Usage: cardano-cli compatible alonzo transaction signed-transaction | --testnet-magic NATURAL ] --fee LOVELACE + [ + --certificate-file FILEPATH + [ --certificate-script-file FILEPATH + [ + ( --certificate-redeemer-cbor-file CBOR_FILE + | --certificate-redeemer-file JSON_FILE + | --certificate-redeemer-value JSON_VALUE + ) + --certificate-execution-units (INT, INT)] + | --certificate-tx-in-reference TX-IN + ( --certificate-plutus-script-v2 + | --certificate-plutus-script-v3 + ) + ( --certificate-reference-tx-in-redeemer-cbor-file CBOR_FILE + | --certificate-reference-tx-in-redeemer-file JSON_FILE + | --certificate-reference-tx-in-redeemer-value JSON_VALUE + ) + --certificate-reference-tx-in-execution-units (INT, INT) + ]] --out-file FILEPATH Create a simple signed transaction. @@ -11269,6 +11345,25 @@ Usage: cardano-cli compatible babbage transaction signed-transaction | --testnet-magic NATURAL ] --fee LOVELACE + [ + --certificate-file FILEPATH + [ --certificate-script-file FILEPATH + [ + ( --certificate-redeemer-cbor-file CBOR_FILE + | --certificate-redeemer-file JSON_FILE + | --certificate-redeemer-value JSON_VALUE + ) + --certificate-execution-units (INT, INT)] + | --certificate-tx-in-reference TX-IN + ( --certificate-plutus-script-v2 + | --certificate-plutus-script-v3 + ) + ( --certificate-reference-tx-in-redeemer-cbor-file CBOR_FILE + | --certificate-reference-tx-in-redeemer-file JSON_FILE + | --certificate-reference-tx-in-redeemer-value JSON_VALUE + ) + --certificate-reference-tx-in-execution-units (INT, INT) + ]] --out-file FILEPATH Create a simple signed transaction. @@ -11452,6 +11547,25 @@ Usage: cardano-cli compatible conway transaction signed-transaction | --testnet-magic NATURAL ] --fee LOVELACE + [ + --certificate-file FILEPATH + [ --certificate-script-file FILEPATH + [ + ( --certificate-redeemer-cbor-file CBOR_FILE + | --certificate-redeemer-file JSON_FILE + | --certificate-redeemer-value JSON_VALUE + ) + --certificate-execution-units (INT, INT)] + | --certificate-tx-in-reference TX-IN + ( --certificate-plutus-script-v2 + | --certificate-plutus-script-v3 + ) + ( --certificate-reference-tx-in-redeemer-cbor-file CBOR_FILE + | --certificate-reference-tx-in-redeemer-file JSON_FILE + | --certificate-reference-tx-in-redeemer-value JSON_VALUE + ) + --certificate-reference-tx-in-execution-units (INT, INT) + ]] --out-file FILEPATH Create a simple signed transaction. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_allegra_transaction_signed-transaction.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_allegra_transaction_signed-transaction.cli index 7fa52d36d8..027999d93e 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_allegra_transaction_signed-transaction.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_allegra_transaction_signed-transaction.cli @@ -8,6 +8,25 @@ Usage: cardano-cli compatible allegra transaction signed-transaction | --testnet-magic NATURAL ] --fee LOVELACE + [ + --certificate-file FILEPATH + [ --certificate-script-file FILEPATH + [ + ( --certificate-redeemer-cbor-file CBOR_FILE + | --certificate-redeemer-file JSON_FILE + | --certificate-redeemer-value JSON_VALUE + ) + --certificate-execution-units (INT, INT)] + | --certificate-tx-in-reference TX-IN + ( --certificate-plutus-script-v2 + | --certificate-plutus-script-v3 + ) + ( --certificate-reference-tx-in-redeemer-cbor-file CBOR_FILE + | --certificate-reference-tx-in-redeemer-file JSON_FILE + | --certificate-reference-tx-in-redeemer-value JSON_VALUE + ) + --certificate-reference-tx-in-execution-units (INT, INT) + ]] --out-file FILEPATH Create a simple signed transaction. @@ -28,5 +47,44 @@ Available options: --testnet-magic NATURAL Specify a testnet magic id. This overrides the CARDANO_NODE_NETWORK_ID environment variable --fee LOVELACE The fee amount in Lovelace. + --certificate-file FILEPATH + Filepath of the certificate. This encompasses all + types of certificates (stake pool certificates, stake + key certificates etc). Optionally specify a script + witness. + --certificate-script-file FILEPATH + The file containing the script to witness the use of + the certificate. + --certificate-redeemer-cbor-file CBOR_FILE + The script redeemer file. The file has to be in CBOR + format. + --certificate-redeemer-file JSON_FILE + The script redeemer file. The file must follow the + detailed JSON schema for script data. + --certificate-redeemer-value JSON_VALUE + The script redeemer value. There is no schema: + (almost) any JSON value is supported, including + top-level strings and numbers. + --certificate-execution-units (INT, INT) + The time and space units needed by the script. + --certificate-tx-in-reference TX-IN + TxId#TxIx - Specify a reference input. The reference + input must have a plutus reference script attached. + --certificate-plutus-script-v2 + Specify a plutus script v2 reference script. + --certificate-plutus-script-v3 + Specify a plutus script v3 reference script. + --certificate-reference-tx-in-redeemer-cbor-file CBOR_FILE + The script redeemer file. The file has to be in CBOR + format. + --certificate-reference-tx-in-redeemer-file JSON_FILE + The script redeemer file. The file must follow the + detailed JSON schema for script data. + --certificate-reference-tx-in-redeemer-value JSON_VALUE + The script redeemer value. There is no schema: + (almost) any JSON value is supported, including + top-level strings and numbers. + --certificate-reference-tx-in-execution-units (INT, INT) + The time and space units needed by the script. --out-file FILEPATH The output file. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_alonzo_transaction_signed-transaction.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_alonzo_transaction_signed-transaction.cli index 5e647a582e..2de56e22fd 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_alonzo_transaction_signed-transaction.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_alonzo_transaction_signed-transaction.cli @@ -16,6 +16,25 @@ Usage: cardano-cli compatible alonzo transaction signed-transaction | --testnet-magic NATURAL ] --fee LOVELACE + [ + --certificate-file FILEPATH + [ --certificate-script-file FILEPATH + [ + ( --certificate-redeemer-cbor-file CBOR_FILE + | --certificate-redeemer-file JSON_FILE + | --certificate-redeemer-value JSON_VALUE + ) + --certificate-execution-units (INT, INT)] + | --certificate-tx-in-reference TX-IN + ( --certificate-plutus-script-v2 + | --certificate-plutus-script-v3 + ) + ( --certificate-reference-tx-in-redeemer-cbor-file CBOR_FILE + | --certificate-reference-tx-in-redeemer-file JSON_FILE + | --certificate-reference-tx-in-redeemer-value JSON_VALUE + ) + --certificate-reference-tx-in-execution-units (INT, INT) + ]] --out-file FILEPATH Create a simple signed transaction. @@ -63,5 +82,44 @@ Available options: --testnet-magic NATURAL Specify a testnet magic id. This overrides the CARDANO_NODE_NETWORK_ID environment variable --fee LOVELACE The fee amount in Lovelace. + --certificate-file FILEPATH + Filepath of the certificate. This encompasses all + types of certificates (stake pool certificates, stake + key certificates etc). Optionally specify a script + witness. + --certificate-script-file FILEPATH + The file containing the script to witness the use of + the certificate. + --certificate-redeemer-cbor-file CBOR_FILE + The script redeemer file. The file has to be in CBOR + format. + --certificate-redeemer-file JSON_FILE + The script redeemer file. The file must follow the + detailed JSON schema for script data. + --certificate-redeemer-value JSON_VALUE + The script redeemer value. There is no schema: + (almost) any JSON value is supported, including + top-level strings and numbers. + --certificate-execution-units (INT, INT) + The time and space units needed by the script. + --certificate-tx-in-reference TX-IN + TxId#TxIx - Specify a reference input. The reference + input must have a plutus reference script attached. + --certificate-plutus-script-v2 + Specify a plutus script v2 reference script. + --certificate-plutus-script-v3 + Specify a plutus script v3 reference script. + --certificate-reference-tx-in-redeemer-cbor-file CBOR_FILE + The script redeemer file. The file has to be in CBOR + format. + --certificate-reference-tx-in-redeemer-file JSON_FILE + The script redeemer file. The file must follow the + detailed JSON schema for script data. + --certificate-reference-tx-in-redeemer-value JSON_VALUE + The script redeemer value. There is no schema: + (almost) any JSON value is supported, including + top-level strings and numbers. + --certificate-reference-tx-in-execution-units (INT, INT) + The time and space units needed by the script. --out-file FILEPATH The output file. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_babbage_transaction_signed-transaction.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_babbage_transaction_signed-transaction.cli index d33e357626..69b7bddb79 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_babbage_transaction_signed-transaction.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_babbage_transaction_signed-transaction.cli @@ -19,6 +19,25 @@ Usage: cardano-cli compatible babbage transaction signed-transaction | --testnet-magic NATURAL ] --fee LOVELACE + [ + --certificate-file FILEPATH + [ --certificate-script-file FILEPATH + [ + ( --certificate-redeemer-cbor-file CBOR_FILE + | --certificate-redeemer-file JSON_FILE + | --certificate-redeemer-value JSON_VALUE + ) + --certificate-execution-units (INT, INT)] + | --certificate-tx-in-reference TX-IN + ( --certificate-plutus-script-v2 + | --certificate-plutus-script-v3 + ) + ( --certificate-reference-tx-in-redeemer-cbor-file CBOR_FILE + | --certificate-reference-tx-in-redeemer-file JSON_FILE + | --certificate-reference-tx-in-redeemer-value JSON_VALUE + ) + --certificate-reference-tx-in-execution-units (INT, INT) + ]] --out-file FILEPATH Create a simple signed transaction. @@ -79,5 +98,44 @@ Available options: --testnet-magic NATURAL Specify a testnet magic id. This overrides the CARDANO_NODE_NETWORK_ID environment variable --fee LOVELACE The fee amount in Lovelace. + --certificate-file FILEPATH + Filepath of the certificate. This encompasses all + types of certificates (stake pool certificates, stake + key certificates etc). Optionally specify a script + witness. + --certificate-script-file FILEPATH + The file containing the script to witness the use of + the certificate. + --certificate-redeemer-cbor-file CBOR_FILE + The script redeemer file. The file has to be in CBOR + format. + --certificate-redeemer-file JSON_FILE + The script redeemer file. The file must follow the + detailed JSON schema for script data. + --certificate-redeemer-value JSON_VALUE + The script redeemer value. There is no schema: + (almost) any JSON value is supported, including + top-level strings and numbers. + --certificate-execution-units (INT, INT) + The time and space units needed by the script. + --certificate-tx-in-reference TX-IN + TxId#TxIx - Specify a reference input. The reference + input must have a plutus reference script attached. + --certificate-plutus-script-v2 + Specify a plutus script v2 reference script. + --certificate-plutus-script-v3 + Specify a plutus script v3 reference script. + --certificate-reference-tx-in-redeemer-cbor-file CBOR_FILE + The script redeemer file. The file has to be in CBOR + format. + --certificate-reference-tx-in-redeemer-file JSON_FILE + The script redeemer file. The file must follow the + detailed JSON schema for script data. + --certificate-reference-tx-in-redeemer-value JSON_VALUE + The script redeemer value. There is no schema: + (almost) any JSON value is supported, including + top-level strings and numbers. + --certificate-reference-tx-in-execution-units (INT, INT) + The time and space units needed by the script. --out-file FILEPATH The output file. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_conway_transaction_signed-transaction.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_conway_transaction_signed-transaction.cli index ac1af03a73..0f8d10407c 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_conway_transaction_signed-transaction.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_conway_transaction_signed-transaction.cli @@ -51,6 +51,25 @@ Usage: cardano-cli compatible conway transaction signed-transaction | --testnet-magic NATURAL ] --fee LOVELACE + [ + --certificate-file FILEPATH + [ --certificate-script-file FILEPATH + [ + ( --certificate-redeemer-cbor-file CBOR_FILE + | --certificate-redeemer-file JSON_FILE + | --certificate-redeemer-value JSON_VALUE + ) + --certificate-execution-units (INT, INT)] + | --certificate-tx-in-reference TX-IN + ( --certificate-plutus-script-v2 + | --certificate-plutus-script-v3 + ) + ( --certificate-reference-tx-in-redeemer-cbor-file CBOR_FILE + | --certificate-reference-tx-in-redeemer-file JSON_FILE + | --certificate-reference-tx-in-redeemer-value JSON_VALUE + ) + --certificate-reference-tx-in-execution-units (INT, INT) + ]] --out-file FILEPATH Create a simple signed transaction. @@ -174,5 +193,44 @@ Available options: --testnet-magic NATURAL Specify a testnet magic id. This overrides the CARDANO_NODE_NETWORK_ID environment variable --fee LOVELACE The fee amount in Lovelace. + --certificate-file FILEPATH + Filepath of the certificate. This encompasses all + types of certificates (stake pool certificates, stake + key certificates etc). Optionally specify a script + witness. + --certificate-script-file FILEPATH + The file containing the script to witness the use of + the certificate. + --certificate-redeemer-cbor-file CBOR_FILE + The script redeemer file. The file has to be in CBOR + format. + --certificate-redeemer-file JSON_FILE + The script redeemer file. The file must follow the + detailed JSON schema for script data. + --certificate-redeemer-value JSON_VALUE + The script redeemer value. There is no schema: + (almost) any JSON value is supported, including + top-level strings and numbers. + --certificate-execution-units (INT, INT) + The time and space units needed by the script. + --certificate-tx-in-reference TX-IN + TxId#TxIx - Specify a reference input. The reference + input must have a plutus reference script attached. + --certificate-plutus-script-v2 + Specify a plutus script v2 reference script. + --certificate-plutus-script-v3 + Specify a plutus script v3 reference script. + --certificate-reference-tx-in-redeemer-cbor-file CBOR_FILE + The script redeemer file. The file has to be in CBOR + format. + --certificate-reference-tx-in-redeemer-file JSON_FILE + The script redeemer file. The file must follow the + detailed JSON schema for script data. + --certificate-reference-tx-in-redeemer-value JSON_VALUE + The script redeemer value. There is no schema: + (almost) any JSON value is supported, including + top-level strings and numbers. + --certificate-reference-tx-in-execution-units (INT, INT) + The time and space units needed by the script. --out-file FILEPATH The output file. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_mary_transaction_signed-transaction.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_mary_transaction_signed-transaction.cli index e745bab720..8ae77ecdcb 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_mary_transaction_signed-transaction.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_mary_transaction_signed-transaction.cli @@ -8,6 +8,25 @@ Usage: cardano-cli compatible mary transaction signed-transaction | --testnet-magic NATURAL ] --fee LOVELACE + [ + --certificate-file FILEPATH + [ --certificate-script-file FILEPATH + [ + ( --certificate-redeemer-cbor-file CBOR_FILE + | --certificate-redeemer-file JSON_FILE + | --certificate-redeemer-value JSON_VALUE + ) + --certificate-execution-units (INT, INT)] + | --certificate-tx-in-reference TX-IN + ( --certificate-plutus-script-v2 + | --certificate-plutus-script-v3 + ) + ( --certificate-reference-tx-in-redeemer-cbor-file CBOR_FILE + | --certificate-reference-tx-in-redeemer-file JSON_FILE + | --certificate-reference-tx-in-redeemer-value JSON_VALUE + ) + --certificate-reference-tx-in-execution-units (INT, INT) + ]] --out-file FILEPATH Create a simple signed transaction. @@ -28,5 +47,44 @@ Available options: --testnet-magic NATURAL Specify a testnet magic id. This overrides the CARDANO_NODE_NETWORK_ID environment variable --fee LOVELACE The fee amount in Lovelace. + --certificate-file FILEPATH + Filepath of the certificate. This encompasses all + types of certificates (stake pool certificates, stake + key certificates etc). Optionally specify a script + witness. + --certificate-script-file FILEPATH + The file containing the script to witness the use of + the certificate. + --certificate-redeemer-cbor-file CBOR_FILE + The script redeemer file. The file has to be in CBOR + format. + --certificate-redeemer-file JSON_FILE + The script redeemer file. The file must follow the + detailed JSON schema for script data. + --certificate-redeemer-value JSON_VALUE + The script redeemer value. There is no schema: + (almost) any JSON value is supported, including + top-level strings and numbers. + --certificate-execution-units (INT, INT) + The time and space units needed by the script. + --certificate-tx-in-reference TX-IN + TxId#TxIx - Specify a reference input. The reference + input must have a plutus reference script attached. + --certificate-plutus-script-v2 + Specify a plutus script v2 reference script. + --certificate-plutus-script-v3 + Specify a plutus script v3 reference script. + --certificate-reference-tx-in-redeemer-cbor-file CBOR_FILE + The script redeemer file. The file has to be in CBOR + format. + --certificate-reference-tx-in-redeemer-file JSON_FILE + The script redeemer file. The file must follow the + detailed JSON schema for script data. + --certificate-reference-tx-in-redeemer-value JSON_VALUE + The script redeemer value. There is no schema: + (almost) any JSON value is supported, including + top-level strings and numbers. + --certificate-reference-tx-in-execution-units (INT, INT) + The time and space units needed by the script. --out-file FILEPATH The output file. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_shelley_transaction_signed-transaction.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_shelley_transaction_signed-transaction.cli index 3489c81c35..3644cd9167 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_shelley_transaction_signed-transaction.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_shelley_transaction_signed-transaction.cli @@ -8,6 +8,25 @@ Usage: cardano-cli compatible shelley transaction signed-transaction | --testnet-magic NATURAL ] --fee LOVELACE + [ + --certificate-file FILEPATH + [ --certificate-script-file FILEPATH + [ + ( --certificate-redeemer-cbor-file CBOR_FILE + | --certificate-redeemer-file JSON_FILE + | --certificate-redeemer-value JSON_VALUE + ) + --certificate-execution-units (INT, INT)] + | --certificate-tx-in-reference TX-IN + ( --certificate-plutus-script-v2 + | --certificate-plutus-script-v3 + ) + ( --certificate-reference-tx-in-redeemer-cbor-file CBOR_FILE + | --certificate-reference-tx-in-redeemer-file JSON_FILE + | --certificate-reference-tx-in-redeemer-value JSON_VALUE + ) + --certificate-reference-tx-in-execution-units (INT, INT) + ]] --out-file FILEPATH Create a simple signed transaction. @@ -28,5 +47,44 @@ Available options: --testnet-magic NATURAL Specify a testnet magic id. This overrides the CARDANO_NODE_NETWORK_ID environment variable --fee LOVELACE The fee amount in Lovelace. + --certificate-file FILEPATH + Filepath of the certificate. This encompasses all + types of certificates (stake pool certificates, stake + key certificates etc). Optionally specify a script + witness. + --certificate-script-file FILEPATH + The file containing the script to witness the use of + the certificate. + --certificate-redeemer-cbor-file CBOR_FILE + The script redeemer file. The file has to be in CBOR + format. + --certificate-redeemer-file JSON_FILE + The script redeemer file. The file must follow the + detailed JSON schema for script data. + --certificate-redeemer-value JSON_VALUE + The script redeemer value. There is no schema: + (almost) any JSON value is supported, including + top-level strings and numbers. + --certificate-execution-units (INT, INT) + The time and space units needed by the script. + --certificate-tx-in-reference TX-IN + TxId#TxIx - Specify a reference input. The reference + input must have a plutus reference script attached. + --certificate-plutus-script-v2 + Specify a plutus script v2 reference script. + --certificate-plutus-script-v3 + Specify a plutus script v3 reference script. + --certificate-reference-tx-in-redeemer-cbor-file CBOR_FILE + The script redeemer file. The file has to be in CBOR + format. + --certificate-reference-tx-in-redeemer-file JSON_FILE + The script redeemer file. The file must follow the + detailed JSON schema for script data. + --certificate-reference-tx-in-redeemer-value JSON_VALUE + The script redeemer value. There is no schema: + (almost) any JSON value is supported, including + top-level strings and numbers. + --certificate-reference-tx-in-execution-units (INT, INT) + The time and space units needed by the script. --out-file FILEPATH The output file. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-test/Test/Cli/Shelley/Transaction/Compatible/Build.hs b/cardano-cli/test/cardano-cli-test/Test/Cli/Shelley/Transaction/Compatible/Build.hs new file mode 100644 index 0000000000..056fbc96d2 --- /dev/null +++ b/cardano-cli/test/cardano-cli-test/Test/Cli/Shelley/Transaction/Compatible/Build.hs @@ -0,0 +1,90 @@ +{-# LANGUAGE ScopedTypeVariables #-} + +module Test.Cli.Shelley.Transaction.Compatible.Build where + +import Control.Monad.Catch (MonadCatch) +import Control.Monad.IO.Class +import Data.Aeson (Value) +import qualified Data.Aeson as A +import Data.String (IsString (..)) +import GHC.Stack + +import Test.Cardano.CLI.Util + +import Hedgehog +import qualified Hedgehog as H +import qualified Hedgehog.Extras as H + +inputDir :: FilePath +inputDir = "test/cardano-cli-test/files/input/shelley/transaction" + +-- | Execute me with: +-- @cabal test cardano-cli-test --test-options '-p "/conway transaction build one voter many votes/"'@ +hprop_compatible_conway_transaction_build_one_voter_many_votes :: Property +hprop_compatible_conway_transaction_build_one_voter_many_votes = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do + refOutFile <- H.noteTempFile tempDir "reference_tx.traw" + outFile <- H.noteTempFile tempDir "tx.traw" + + let args = + [ "--tx-in" + , "6e8c947816e82627aeccb55300074f2894a2051332f62a1c8954e7b588a18be7#0" + , "--tx-out" + , "addr_test1vpfwv0ezc5g8a4mkku8hhy3y3vp92t7s3ul8g778g5yegsgalc6gc+24910487859" + , "--fee" + , "178569" + , "--certificate-file" + , "test/cardano-cli-golden/files/golden/shelley/stake-address/reg-certificate-2.json" + , "--certificate-script-file" + , "test/cardano-cli-golden/files/input/AlwaysSucceeds.plutus" + , "--certificate-redeemer-value" + , "0" + , "--certificate-execution-units" + , "(0,0)" + ] + + _ <- + execCardanoCLI $ + [ "conway" + , "transaction" + , "build-raw" + ] + <> args + <> [ "--out-file" + , refOutFile + ] + + _ <- + execCardanoCLI $ + [ "compatible" + , "conway" + , "transaction" + , "signed-transaction" + ] + <> args + <> [ "--out-file" + , outFile + ] + + assertTxFilesEqual refOutFile outFile + H.failure + +assertTxFilesEqual + :: forall m. (HasCallStack, MonadIO m, MonadTest m, MonadCatch m) => FilePath -> FilePath -> m () +assertTxFilesEqual f1 f2 = withFrozenCallStack $ do + tx1 <- viewTx f1 + tx2 <- viewTx f2 + + tx1 === tx2 + where + viewTx :: HasCallStack => FilePath -> m Value + viewTx f = + withFrozenCallStack $ + H.leftFailM $ + A.eitherDecode . fromString + <$> execCardanoCLI + [ "debug" + , "transaction" + , "view" + , "--tx-body-file" + , f + ]