From fb9e7987580038e1a24ebf07641d311eb461ea70 Mon Sep 17 00:00:00 2001 From: Martin Kourim Date: Wed, 11 Sep 2024 16:21:45 +0200 Subject: [PATCH] fix(transaction): handle fee parsing for newer CLI output Updated the fee parsing logic to handle the new CLI output format where the fee is followed by "Lovelace". This ensures compatibility with both the new and old versions of the `build` command. --- cardano_clusterlib/transaction_group.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cardano_clusterlib/transaction_group.py b/cardano_clusterlib/transaction_group.py index adaf40b..7f5af62 100644 --- a/cardano_clusterlib/transaction_group.py +++ b/cardano_clusterlib/transaction_group.py @@ -1013,13 +1013,15 @@ def build_tx( # noqa: C901 *self._clusterlib_obj.magic_args, *self._clusterlib_obj.socket_args, ] - stdout = self._clusterlib_obj.cli(cli_args).stdout + stdout = self._clusterlib_obj.cli(cli_args).stdout.strip() stdout_dec = stdout.decode("utf-8") if stdout else "" - # check for the presence of fee information so compatibility with older versions - # of the `build` command is preserved + # Check for the presence of fee information. No fee information was provided in older + # versions of the `build` command. estimated_fee = -1 - if "transaction fee" in stdout_dec: + if stdout_dec.endswith("Lovelace"): + estimated_fee = int(stdout_dec.split()[-2]) + elif "transaction fee" in stdout_dec: estimated_fee = int(stdout_dec.split()[-1]) return structs.TxRawOutput(