Skip to content

feat: add confirm_blocks property to ClusterLib #280

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

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all 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: 3 additions & 1 deletion cardano_clusterlib/clusterlib_klass.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ def __init__(
msg = f"Unknown command era `{command_era}`."
raise exceptions.CLIError(msg) from excp

self.cluster_id = 0 # can be used for identifying cluster instance
self.cluster_id = 0 # Can be used for identifying cluster instance
# Number of new blocks before the Tx is considered confirmed
self.confirm_blocks = consts.CONFIRM_BLOCKS_NUM
self.cli_coverage: dict = {}
self._rand_str = helpers.get_rand_str(4)
self._cli_log = ""
Expand Down
25 changes: 13 additions & 12 deletions cardano_clusterlib/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

DEFAULT_COIN: tp.Final[str] = "lovelace"
MAINNET_MAGIC: tp.Final[int] = 764824073
CONFIRM_BLOCKS_NUM: tp.Final[int] = 2

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


class Eras(enum.Enum):
BYRON: int = 1
SHELLEY: int = 2
ALLEGRA: int = 3
MARY: int = 4
ALONZO: int = 6
BABBAGE: int = 8
CONWAY: int = 9
DEFAULT: int = CONWAY
LATEST: int = CONWAY
BYRON = 1
SHELLEY = 2
ALLEGRA = 3
MARY = 4
ALONZO = 6
BABBAGE = 8
CONWAY = 9
DEFAULT = CONWAY
LATEST = CONWAY # noqa: PIE796


class MultiSigTypeArgs:
Expand All @@ -54,6 +55,6 @@ class ScriptTypes:


class Votes(enum.Enum):
YES: int = 1
NO: int = 2
ABSTAIN: int = 3
YES = 1
NO = 2
ABSTAIN = 3
7 changes: 6 additions & 1 deletion cardano_clusterlib/transaction_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ def submit_tx_bare(self, tx_file: itp.FileType) -> str:
return txhash

def submit_tx(
self, tx_file: itp.FileType, txins: list[structs.UTXOData], wait_blocks: int = 2
self, tx_file: itp.FileType, txins: list[structs.UTXOData], wait_blocks: int | None = None
) -> str:
"""Submit a transaction, resubmit if the transaction didn't make it to the chain.

Expand All @@ -1166,6 +1166,11 @@ def submit_tx(
Returns:
str: A transaction ID.
"""
wait_blocks = (
self._clusterlib_obj.confirm_blocks
if wait_blocks is None or wait_blocks < 1
else wait_blocks
)
txid = ""
for r in range(20):
err = None
Expand Down
Loading