Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make "[era] transaction view" command fail and advice to use "debug transaction view" instead #858

Merged
merged 6 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions cardano-cli/src/Cardano/CLI/EraBased/Commands/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,6 @@ newtype TransactionTxIdCmdArgs = TransactionTxIdCmdArgs
deriving Show

data TransactionViewCmdArgs = TransactionViewCmdArgs
{ outputFormat :: !ViewOutputFormat
, mOutFile :: !(Maybe (File () Out))
, inputTxBodyOrTxFile :: !InputTxBodyOrTxFile
}
deriving Show

renderTransactionCmds :: TransactionCmds era -> Text
Expand Down
13 changes: 3 additions & 10 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ pTransactionCmds era envCli =
Opt.progDesc "Print a transaction identifier."
, Just $
subParser "view" $
Opt.info pTransactionView $
Opt.progDesc "Print a transaction."
Opt.info
(pure $ TransactionViewCmd TransactionViewCmdArgs)
(Opt.progDesc "This command has been removed. Please use \"debug transaction view\" instead.")
]

-- Backwards compatible parsers
Expand Down Expand Up @@ -376,11 +377,3 @@ pTransactionId =
fmap TransactionTxIdCmd $
TransactionTxIdCmdArgs
<$> pInputTxOrTxBodyFile

pTransactionView :: Parser (TransactionCmds era)
pTransactionView =
fmap TransactionViewCmd $
TransactionViewCmdArgs
<$> pTxViewOutputFormat
<*> pMaybeOutputFile
<*> pInputTxOrTxBodyFile
32 changes: 6 additions & 26 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ import qualified Cardano.Chain.Common as Byron
import qualified Cardano.CLI.EraBased.Commands.Transaction as Cmd
import Cardano.CLI.EraBased.Run.Genesis.Common (readProtocolParameters)
import Cardano.CLI.EraBased.Run.Query
import Cardano.CLI.Json.Friendly (friendlyTx, friendlyTxBody,
viewOutputFormatToFriendlyFormat)
import Cardano.CLI.Read
import Cardano.CLI.Types.Common
import Cardano.CLI.Types.Errors.BootstrapWitnessError
Expand Down Expand Up @@ -79,6 +77,7 @@ import qualified Data.Text as Text
import qualified Data.Text.IO as Text
import Data.Type.Equality (TestEquality (..))
import Lens.Micro ((^.))
import qualified System.Exit as IO
import qualified System.IO as IO

runTransactionCmds :: Cmd.TransactionCmds era -> ExceptT TxCmdError IO ()
Expand Down Expand Up @@ -1698,30 +1697,11 @@ runTransactionViewCmd
=> Cmd.TransactionViewCmdArgs
-> ExceptT TxCmdError IO ()
runTransactionViewCmd
Cmd.TransactionViewCmdArgs
{ outputFormat
, mOutFile
, inputTxBodyOrTxFile
} =
case inputTxBodyOrTxFile of
InputTxBodyFile (File txbodyFilePath) -> do
txbodyFile <- liftIO $ fileOrPipe txbodyFilePath
unwitnessed <-
firstExceptT TxCmdTextEnvCddlError . newExceptT $
readFileTxBody txbodyFile
InAnyShelleyBasedEra era txbody <- pure $ unIncompleteCddlTxBody unwitnessed
-- Why are we differentiating between a transaction body and a transaction?
-- In the case of a transaction body, we /could/ simply call @makeSignedTransaction []@
-- to get a transaction which would allow us to reuse friendlyTxBS. However,
-- this would mean that we'd have an empty list of witnesses mentioned in the output, which
-- is arguably not part of the transaction body.
firstExceptT TxCmdWriteFileError . newExceptT $
friendlyTxBody (viewOutputFormatToFriendlyFormat outputFormat) mOutFile (toCardanoEra era) txbody
InputTxFile (File txFilePath) -> do
txFile <- liftIO $ fileOrPipe txFilePath
InAnyShelleyBasedEra era tx <- lift (readFileTx txFile) & onLeft (left . TxCmdTextEnvCddlError)
firstExceptT TxCmdWriteFileError . newExceptT $
friendlyTx (viewOutputFormatToFriendlyFormat outputFormat) mOutFile (toCardanoEra era) tx
Cmd.TransactionViewCmdArgs =
liftIO $ do
putStrLn
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that should go to stderr instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, changed 👍

"Command \"era transaction view\" has been removed. Please use \"debug transaction view\" instead."
IO.exitWith (IO.ExitFailure 1)

-- ----------------------------------------------------------------------------
-- Witness commands
Expand Down
3 changes: 0 additions & 3 deletions cardano-cli/src/Cardano/CLI/Legacy/Commands/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,6 @@ data LegacyTransactionCmds
| TransactionTxIdCmd
InputTxBodyOrTxFile
| TransactionViewCmd
ViewOutputFormat
(Maybe (File () Out))
InputTxBodyOrTxFile

renderLegacyTransactionCmds :: LegacyTransactionCmds -> Text
renderLegacyTransactionCmds = \case
Expand Down
7 changes: 2 additions & 5 deletions cardano-cli/src/Cardano/CLI/Legacy/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ pTransaction envCli =
(Opt.info pTransactionId $ Opt.progDesc "Print a transaction identifier.")
, subParser "view" $
Opt.info pTransactionView $
Opt.progDesc "Print a transaction."
Opt.progDesc "This command has been removed. Please use \"debug transaction view\" instead."
]
where
-- Backwards compatible parsers
Expand Down Expand Up @@ -488,10 +488,7 @@ pTransaction envCli =

pTransactionView :: Parser LegacyTransactionCmds
pTransactionView =
TransactionViewCmd
<$> pTxViewOutputFormat
<*> pMaybeOutputFile
<*> pInputTxOrTxBodyFile
pure TransactionViewCmd

pNodeCmds :: Parser LegacyNodeCmds
pNodeCmds =
Expand Down
20 changes: 6 additions & 14 deletions cardano-cli/src/Cardano/CLI/Legacy/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ runLegacyTransactionCmds = \case
runLegacyTransactionHashScriptDataCmd scriptDataOrFile
TransactionTxIdCmd txinfile ->
runLegacyTransactionTxIdCmd txinfile
TransactionViewCmd yamlOrJson mOutFile txinfile ->
runLegacyTransactionViewCmd yamlOrJson mOutFile txinfile
TransactionViewCmd ->
runLegacyTransactionViewCmd
TransactionPolicyIdCmd sFile ->
runLegacyTransactionPolicyIdCmd sFile
TransactionWitnessCmd txBodyfile witSignData mbNw outFile ->
Expand Down Expand Up @@ -508,18 +508,10 @@ runLegacyTransactionTxIdCmd txfile =
txfile
)

runLegacyTransactionViewCmd
:: ViewOutputFormat -> Maybe (File () Out) -> InputTxBodyOrTxFile -> ExceptT TxCmdError IO ()
runLegacyTransactionViewCmd
yamlOrJson
mOutFile
inputTxBodyOrTxFile =
runTransactionViewCmd
( Cmd.TransactionViewCmdArgs
yamlOrJson
mOutFile
inputTxBodyOrTxFile
)
runLegacyTransactionViewCmd :: ExceptT TxCmdError IO ()
runLegacyTransactionViewCmd =
runTransactionViewCmd
Cmd.TransactionViewCmdArgs

runLegacyTransactionWitnessCmd
:: ()
Expand Down
70 changes: 18 additions & 52 deletions cardano-cli/test/cardano-cli-golden/files/golden/help.cli
Original file line number Diff line number Diff line change
Expand Up @@ -1206,13 +1206,9 @@ Usage: cardano-cli shelley transaction txid

Print a transaction identifier.

Usage: cardano-cli shelley transaction view [--output-json | --output-yaml]
[--out-file FILE]
( --tx-body-file FILE
| --tx-file FILE
)
Usage: cardano-cli shelley transaction view

Print a transaction.
This command has been removed. Please use "debug transaction view" instead.

Usage: cardano-cli allegra
( address
Expand Down Expand Up @@ -2405,13 +2401,9 @@ Usage: cardano-cli allegra transaction txid

Print a transaction identifier.

Usage: cardano-cli allegra transaction view [--output-json | --output-yaml]
[--out-file FILE]
( --tx-body-file FILE
| --tx-file FILE
)
Usage: cardano-cli allegra transaction view

Print a transaction.
This command has been removed. Please use "debug transaction view" instead.

Usage: cardano-cli mary
( address
Expand Down Expand Up @@ -3718,13 +3710,9 @@ Usage: cardano-cli mary transaction txid (--tx-body-file FILE | --tx-file FILE)

Print a transaction identifier.

Usage: cardano-cli mary transaction view [--output-json | --output-yaml]
[--out-file FILE]
( --tx-body-file FILE
| --tx-file FILE
)
Usage: cardano-cli mary transaction view

Print a transaction.
This command has been removed. Please use "debug transaction view" instead.

Usage: cardano-cli alonzo
( address
Expand Down Expand Up @@ -5054,13 +5042,9 @@ Usage: cardano-cli alonzo transaction txid

Print a transaction identifier.

Usage: cardano-cli alonzo transaction view [--output-json | --output-yaml]
[--out-file FILE]
( --tx-body-file FILE
| --tx-file FILE
)
Usage: cardano-cli alonzo transaction view

Print a transaction.
This command has been removed. Please use "debug transaction view" instead.

Usage: cardano-cli babbage
( address
Expand Down Expand Up @@ -6412,13 +6396,9 @@ Usage: cardano-cli babbage transaction txid

Print a transaction identifier.

Usage: cardano-cli babbage transaction view [--output-json | --output-yaml]
[--out-file FILE]
( --tx-body-file FILE
| --tx-file FILE
)
Usage: cardano-cli babbage transaction view

Print a transaction.
This command has been removed. Please use "debug transaction view" instead.

Usage: cardano-cli conway
( address
Expand Down Expand Up @@ -8301,13 +8281,9 @@ Usage: cardano-cli conway transaction txid

Print a transaction identifier.

Usage: cardano-cli conway transaction view [--output-json | --output-yaml]
[--out-file FILE]
( --tx-body-file FILE
| --tx-file FILE
)
Usage: cardano-cli conway transaction view

Print a transaction.
This command has been removed. Please use "debug transaction view" instead.

Usage: cardano-cli latest
( address
Expand Down Expand Up @@ -9656,13 +9632,9 @@ Usage: cardano-cli latest transaction txid

Print a transaction identifier.

Usage: cardano-cli latest transaction view [--output-json | --output-yaml]
[--out-file FILE]
( --tx-body-file FILE
| --tx-file FILE
)
Usage: cardano-cli latest transaction view

Print a transaction.
This command has been removed. Please use "debug transaction view" instead.

Usage: cardano-cli legacy Legacy commands

Expand Down Expand Up @@ -10755,13 +10727,9 @@ Usage: cardano-cli legacy transaction txid

Print a transaction identifier.

Usage: cardano-cli legacy transaction view [--output-json | --output-yaml]
[--out-file FILE]
( --tx-body-file FILE
| --tx-file FILE
)
Usage: cardano-cli legacy transaction view

Print a transaction.
This command has been removed. Please use "debug transaction view" instead.

Usage: cardano-cli legacy key
( verification-key
Expand Down Expand Up @@ -12016,11 +11984,9 @@ Usage: cardano-cli transaction txid (--tx-body-file FILE | --tx-file FILE)

Print a transaction identifier.

Usage: cardano-cli transaction view [--output-json | --output-yaml]
[--out-file FILE]
(--tx-body-file FILE | --tx-file FILE)
Usage: cardano-cli transaction view

Print a transaction.
This command has been removed. Please use "debug transaction view" instead.

Usage: cardano-cli key
( verification-key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ Available commands:
output.
hash-script-data Calculate the hash of script data.
txid Print a transaction identifier.
view Print a transaction.
view This command has been removed. Please use "debug
transaction view" instead.
Original file line number Diff line number Diff line change
@@ -1,16 +0,0 @@
Usage: cardano-cli allegra transaction view [--output-json | --output-yaml]
[--out-file FILE]
( --tx-body-file FILE
| --tx-file FILE
)

Print a transaction.

Available options:
--output-json Format transaction view output to JSON.
--output-yaml Format transaction view output to YAML. Defaults to
JSON if unspecified.
--out-file FILE Optional output file. Default is to write to stdout.
--tx-body-file FILE Input filepath of the JSON TxBody.
--tx-file FILE Input filepath of the JSON Tx.
-h,--help Show this help text
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ Available commands:
output.
hash-script-data Calculate the hash of script data.
txid Print a transaction identifier.
view Print a transaction.
view This command has been removed. Please use "debug
transaction view" instead.
Original file line number Diff line number Diff line change
@@ -1,16 +0,0 @@
Usage: cardano-cli alonzo transaction view [--output-json | --output-yaml]
[--out-file FILE]
( --tx-body-file FILE
| --tx-file FILE
)

Print a transaction.

Available options:
--output-json Format transaction view output to JSON.
--output-yaml Format transaction view output to YAML. Defaults to
JSON if unspecified.
--out-file FILE Optional output file. Default is to write to stdout.
--tx-body-file FILE Input filepath of the JSON TxBody.
--tx-file FILE Input filepath of the JSON Tx.
-h,--help Show this help text
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ Available commands:
output.
hash-script-data Calculate the hash of script data.
txid Print a transaction identifier.
view Print a transaction.
view This command has been removed. Please use "debug
transaction view" instead.
Original file line number Diff line number Diff line change
@@ -1,16 +0,0 @@
Usage: cardano-cli babbage transaction view [--output-json | --output-yaml]
[--out-file FILE]
( --tx-body-file FILE
| --tx-file FILE
)

Print a transaction.

Available options:
--output-json Format transaction view output to JSON.
--output-yaml Format transaction view output to YAML. Defaults to
JSON if unspecified.
--out-file FILE Optional output file. Default is to write to stdout.
--tx-body-file FILE Input filepath of the JSON TxBody.
--tx-file FILE Input filepath of the JSON Tx.
-h,--help Show this help text
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ Available commands:
output.
hash-script-data Calculate the hash of script data.
txid Print a transaction identifier.
view Print a transaction.
view This command has been removed. Please use "debug
transaction view" instead.
Original file line number Diff line number Diff line change
@@ -1,16 +0,0 @@
Usage: cardano-cli conway transaction view [--output-json | --output-yaml]
[--out-file FILE]
( --tx-body-file FILE
| --tx-file FILE
)

Print a transaction.

Available options:
--output-json Format transaction view output to JSON.
--output-yaml Format transaction view output to YAML. Defaults to
JSON if unspecified.
--out-file FILE Optional output file. Default is to write to stdout.
--tx-body-file FILE Input filepath of the JSON TxBody.
--tx-file FILE Input filepath of the JSON Tx.
-h,--help Show this help text
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ Available commands:
output.
hash-script-data Calculate the hash of script data.
txid Print a transaction identifier.
view Print a transaction.
view This command has been removed. Please use "debug
transaction view" instead.
Loading
Loading