Skip to content

Commit 7e8c1f5

Browse files
committed
fix: add support for latest command in transaction submission and ID retrieval
1 parent 67a215c commit 7e8c1f5

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

pycardano/backend/cardano_cli.py

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -520,22 +520,39 @@ def submit_tx_cbor(self, cbor: Union[bytes, str]) -> str:
520520

521521
try:
522522
self._run_command(
523-
["transaction", "submit", "--tx-file", tmp_tx_file.name]
523+
[
524+
"latest",
525+
"transaction",
526+
"submit",
527+
"--tx-file",
528+
tmp_tx_file.name,
529+
]
524530
+ self._network_args
525531
)
526-
except CardanoCliError as err:
527-
raise TransactionFailedException(
528-
"Failed to submit transaction"
529-
) from err
532+
except CardanoCliError:
533+
try:
534+
self._run_command(
535+
["transaction", "submit", "--tx-file", tmp_tx_file.name]
536+
+ self._network_args
537+
)
538+
except CardanoCliError as err:
539+
raise TransactionFailedException(
540+
"Failed to submit transaction"
541+
) from err
530542

531543
# Get the transaction ID
532544
try:
533545
txid = self._run_command(
534-
["transaction", "txid", "--tx-file", tmp_tx_file.name]
546+
["latest", "transaction", "txid", "--tx-file", tmp_tx_file.name]
535547
)
536-
except CardanoCliError as err:
537-
raise PyCardanoException(
538-
f"Unable to get transaction id for {tmp_tx_file.name}"
539-
) from err
548+
except CardanoCliError:
549+
try:
550+
txid = self._run_command(
551+
["transaction", "txid", "--tx-file", tmp_tx_file.name]
552+
)
553+
except CardanoCliError as err:
554+
raise PyCardanoException(
555+
f"Unable to get transaction id for {tmp_tx_file.name}"
556+
) from err
540557

541558
return txid

0 commit comments

Comments
 (0)