Skip to content

Commit 2227e40

Browse files
authored
Merge pull request #297 from input-output-hk/conditional_txid_format_out
feat(transaction): add conditional `--output-text` flag
2 parents 8edbb53 + f881045 commit 2227e40

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

cardano_clusterlib/transaction_group.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,24 @@ def get_txid(self, tx_body_file: itp.FileType = "", tx_file: itp.FileType = "")
5757
Returns:
5858
str: A transaction ID.
5959
"""
60+
cli_args = []
61+
62+
# The `--output-text` option is available since 10.3.0.0 and is the default
63+
# until about 10.8.0.0. Then the JSON format became the default.
64+
# Adding the option for cli >= 10.7.0.0, because the option was already available.
65+
if self._clusterlib_obj.cli_version >= version.parse("10.7.0.0"):
66+
cli_args.append("--output-text")
67+
6068
if tx_body_file:
61-
cli_args = ["--tx-body-file", str(tx_body_file)]
69+
cli_args.extend(["--tx-body-file", str(tx_body_file)])
6270
elif tx_file:
63-
cli_args = ["--tx-file", str(tx_file)]
71+
cli_args.extend(["--tx-file", str(tx_file)])
6472
else:
6573
msg = "Either `tx_body_file` or `tx_file` is needed."
6674
raise AssertionError(msg)
6775

6876
return (
69-
self._clusterlib_obj.cli(["transaction", "txid", "--output-text", *cli_args])
77+
self._clusterlib_obj.cli(["transaction", "txid", *cli_args])
7078
.stdout.rstrip()
7179
.decode("ascii")
7280
)

0 commit comments

Comments
 (0)