Skip to content

Commit cfce55b

Browse files
Compatible group... Include group.
1 parent ddf4102 commit cfce55b

File tree

4 files changed

+130
-91
lines changed

4 files changed

+130
-91
lines changed
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
"""Alonzo era compatible commands for `cardano-cli compatible alonzo`."""
2+
3+
import logging
4+
from typing import TYPE_CHECKING
5+
6+
from cardano_clusterlib import types as itp
7+
8+
if TYPE_CHECKING:
9+
from cardano_clusterlib.clusterlib_klass import ClusterLib
10+
11+
LOGGER = logging.getLogger(__name__)
12+
13+
14+
class CompatibleAlonzoGroup:
15+
"""
16+
A Single container for ALL Alonzo compatible commands.
17+
18+
"""
19+
20+
def __init__(self, clusterlib_obj: "ClusterLib") -> None:
21+
self._clusterlib_obj = clusterlib_obj
22+
self._base_args = ("compatible", "alonzo")
23+
24+
self.stake_address = _StakeAddressGroup(clusterlib_obj, self._base_args)
25+
self.stake_pool = _StakePoolGroup(clusterlib_obj, self._base_args)
26+
self.governance = _GovernanceGroup(clusterlib_obj, self._base_args)
27+
self.transaction = _TransactionGroup(clusterlib_obj, self._base_args)
28+
29+
def __repr__(self) -> str:
30+
return (
31+
f"<{self.__class__.__name__}: base_args={self._base_args} "
32+
f"clusterlib_obj={id(self._clusterlib_obj)}>"
33+
)
34+
35+
36+
class _StakeAddressGroup:
37+
"""`cardano-cli compatible alonzo stake-address` commands."""
38+
39+
def __init__(self, clusterlib_obj: "ClusterLib", base_args: tuple[str, str]) -> None:
40+
self._clusterlib_obj = clusterlib_obj
41+
self._group_args = (*base_args, "stake-address")
42+
43+
def run_raw(self, cli_args: itp.UnpackableSequence) -> None:
44+
"""Generic low-level wrapper for stake-address commands."""
45+
full_args = [*self._group_args, *cli_args]
46+
47+
LOGGER.debug("Running compatible alonzo stake-address: %s", " ".join(full_args))
48+
self._clusterlib_obj.cli(full_args)
49+
50+
def __repr__(self) -> str:
51+
return f"<StakeAddressGroup base={self._group_args}>"
52+
53+
54+
class _StakePoolGroup:
55+
"""`cardano-cli compatible alonzo stake-pool` commands."""
56+
57+
def __init__(self, clusterlib_obj: "ClusterLib", base_args: tuple[str, str]) -> None:
58+
self._clusterlib_obj = clusterlib_obj
59+
self._group_args = (*base_args, "stake-pool")
60+
61+
def run_raw(self, cli_args: itp.UnpackableSequence) -> None:
62+
"""Generic low-level wrapper."""
63+
full_args = [*self._group_args, *cli_args]
64+
65+
LOGGER.debug("Running compatible alonzo stake-pool: %s", " ".join(full_args))
66+
self._clusterlib_obj.cli(full_args)
67+
68+
def __repr__(self) -> str:
69+
return f"<StakePoolGroup base={self._group_args}>"
70+
71+
72+
class _GovernanceGroup:
73+
"""`cardano-cli compatible alonzo governance` commands."""
74+
75+
def __init__(self, clusterlib_obj: "ClusterLib", base_args: tuple[str, str]) -> None:
76+
self._clusterlib_obj = clusterlib_obj
77+
self._group_args = (*base_args, "governance")
78+
79+
def run_raw(self, cli_args: itp.UnpackableSequence) -> None:
80+
"""Low-level wrapper."""
81+
full_args = [*self._group_args, *cli_args]
82+
83+
LOGGER.debug("Running compatible alonzo governance: %s", " ".join(full_args))
84+
self._clusterlib_obj.cli(full_args)
85+
86+
def __repr__(self) -> str:
87+
return f"<GovernanceGroup base={self._group_args}>"
88+
89+
90+
class _TransactionGroup:
91+
"""Transaction commands for `cardano-cli compatible alonzo transaction`."""
92+
93+
def __init__(self, clusterlib_obj: "ClusterLib", base_args: tuple[str, str]) -> None:
94+
"""Group for 'compatible alonzo transaction' commands.
95+
96+
Args:
97+
clusterlib_obj: Main ClusterLib instance.
98+
group_args: Fixed CLI prefix, e.g. ("compatible", "alonzo").
99+
"""
100+
self._clusterlib_obj = clusterlib_obj
101+
self._group_args = (*base_args, "transaction") # corrected: append “transaction” here
102+
103+
def signed_transaction(
104+
self,
105+
cli_args: itp.UnpackableSequence,
106+
) -> None:
107+
"""Low-level wrapper for `cardano-cli compatible alonzo transaction signed-transaction`."""
108+
full_args: list[str] = [
109+
*self._group_args,
110+
"transaction",
111+
"signed-transaction",
112+
*cli_args,
113+
]
114+
115+
LOGGER.debug(
116+
"Running compatible Alonzo signed-transaction: %s",
117+
" ".join(str(a) for a in full_args),
118+
)
119+
120+
self._clusterlib_obj.cli(full_args)
121+
122+
def __repr__(self) -> str:
123+
return (
124+
f"<CompatibleAlonzoTransactionGroup group_args={self._group_args} "
125+
f"clusterlib_obj={id(self._clusterlib_obj)}>"
126+
)

cardano_clusterlib/compatilbe_group/compatible_group.py renamed to cardano_clusterlib/compat_group.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import logging
44

5+
from cardano_clusterlib import compat_alonzo_group
56
from cardano_clusterlib import types as itp
6-
from cardano_clusterlib.compatilbe_group import compatible_alonzo_group
77

88
LOGGER = logging.getLogger(__name__)
99

@@ -13,16 +13,15 @@ def __init__(self, clusterlib_obj: "itp.ClusterLib") -> None:
1313
self._clusterlib_obj = clusterlib_obj
1414

1515
# Groups of commands per era
16-
self._alonzo_group: compatible_alonzo_group.CompatibleAlonzoGroup | None = None
16+
self._alonzo_group: compat_alonzo_group.CompatibleAlonzoGroup | None = None
1717
# self._mary_group: compatible_mary_group.CompatibleMaryGroup | None = None
1818
# self._shelley_group: compatible_shelley_group.CompatibleShelleyGroup | None = None
1919
# ...
2020

2121
@property
22-
def alonzo(self) -> "compatible_alonzo_group.CompatibleAlonzoGroup":
23-
"""Alonzo compatible era group."""
22+
def alonzo(self) -> compat_alonzo_group.CompatibleAlonzoGroup:
2423
if not self._alonzo_group:
25-
self._alonzo_group = compatible_alonzo_group.CompatibleAlonzoGroup(
24+
self._alonzo_group = compat_alonzo_group.CompatibleAlonzoGroup(
2625
clusterlib_obj=self._clusterlib_obj
2726
)
2827
return self._alonzo_group

cardano_clusterlib/compatilbe_group/compatible_alonzo_group.py

Lines changed: 0 additions & 41 deletions
This file was deleted.

cardano_clusterlib/compatilbe_group/compatible_alonzo_transaction_group.py

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)