Skip to content

Commit 8b0619f

Browse files
authored
Merge pull request #280 from input-output-hk/confirm_blocks_property
feat: add confirm_blocks property to ClusterLib
2 parents a3e8905 + 3cfe01f commit 8b0619f

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

cardano_clusterlib/clusterlib_klass.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ def __init__(
5858
msg = f"Unknown command era `{command_era}`."
5959
raise exceptions.CLIError(msg) from excp
6060

61-
self.cluster_id = 0 # can be used for identifying cluster instance
61+
self.cluster_id = 0 # Can be used for identifying cluster instance
62+
# Number of new blocks before the Tx is considered confirmed
63+
self.confirm_blocks = consts.CONFIRM_BLOCKS_NUM
6264
self.cli_coverage: dict = {}
6365
self._rand_str = helpers.get_rand_str(4)
6466
self._cli_log = ""

cardano_clusterlib/consts.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
DEFAULT_COIN: tp.Final[str] = "lovelace"
55
MAINNET_MAGIC: tp.Final[int] = 764824073
6+
CONFIRM_BLOCKS_NUM: tp.Final[int] = 2
67

78
# The SUBCOMMAND_MARK is used to mark the beginning of a subcommand. It is used to differentiate
89
# between options and subcommands. That is needed for CLI coverage recording.
@@ -23,15 +24,15 @@ class CommandEras:
2324

2425

2526
class Eras(enum.Enum):
26-
BYRON: int = 1
27-
SHELLEY: int = 2
28-
ALLEGRA: int = 3
29-
MARY: int = 4
30-
ALONZO: int = 6
31-
BABBAGE: int = 8
32-
CONWAY: int = 9
33-
DEFAULT: int = CONWAY
34-
LATEST: int = CONWAY
27+
BYRON = 1
28+
SHELLEY = 2
29+
ALLEGRA = 3
30+
MARY = 4
31+
ALONZO = 6
32+
BABBAGE = 8
33+
CONWAY = 9
34+
DEFAULT = CONWAY
35+
LATEST = CONWAY # noqa: PIE796
3536

3637

3738
class MultiSigTypeArgs:
@@ -54,6 +55,6 @@ class ScriptTypes:
5455

5556

5657
class Votes(enum.Enum):
57-
YES: int = 1
58-
NO: int = 2
59-
ABSTAIN: int = 3
58+
YES = 1
59+
NO = 2
60+
ABSTAIN = 3

cardano_clusterlib/transaction_group.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,7 @@ def submit_tx_bare(self, tx_file: itp.FileType) -> str:
11541154
return txhash
11551155

11561156
def submit_tx(
1157-
self, tx_file: itp.FileType, txins: list[structs.UTXOData], wait_blocks: int = 2
1157+
self, tx_file: itp.FileType, txins: list[structs.UTXOData], wait_blocks: int | None = None
11581158
) -> str:
11591159
"""Submit a transaction, resubmit if the transaction didn't make it to the chain.
11601160
@@ -1166,6 +1166,11 @@ def submit_tx(
11661166
Returns:
11671167
str: A transaction ID.
11681168
"""
1169+
wait_blocks = (
1170+
self._clusterlib_obj.confirm_blocks
1171+
if wait_blocks is None or wait_blocks < 1
1172+
else wait_blocks
1173+
)
11691174
txid = ""
11701175
for r in range(20):
11711176
err = None

0 commit comments

Comments
 (0)