Skip to content

Commit 50a070b

Browse files
committed
feat(conway_gov_query_group): return dict for drep_stake_distribution
Update the `drep_stake_distribution` method to return a dictionary instead of a list of lists. The new `cardano-cli` returns dict instead of list of list, and this change unifies the output of the old and new `cardano-cli` versions.
1 parent 51687af commit 50a070b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

cardano_clusterlib/conway_gov_query_group.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def drep_stake_distribution(
9999
drep_vkey: str = "",
100100
drep_vkey_file: itp.FileType | None = None,
101101
drep_key_hash: str = "",
102-
) -> list[list]:
102+
) -> dict[str, tp.Any]:
103103
"""Get the DRep stake distribution.
104104
105105
When no key is provided, query all DReps.
@@ -111,7 +111,7 @@ def drep_stake_distribution(
111111
drep_key_hash: DRep verification key hash (either Bech32-encoded or hex-encoded).
112112
113113
Returns:
114-
List[List[Dict[str, Any]]]: DRep stake distribution.
114+
dict[str, Any]: DRep stake distribution.
115115
"""
116116
cred_args = self._get_cred_args(
117117
drep_script_hash=drep_script_hash,
@@ -122,10 +122,11 @@ def drep_stake_distribution(
122122
if not cred_args:
123123
cred_args = ["--all-dreps"]
124124

125-
out: list[list[dict[str, tp.Any]]] = json.loads(
125+
out: list[list] | dict[str, tp.Any] = json.loads(
126126
self.query_cli(["drep-stake-distribution", *cred_args])
127127
)
128-
return out
128+
recs: dict[str, tp.Any] = {i[0]: i[1] for i in out} if isinstance(out, list) else out
129+
return recs
129130

130131
def committee_state(self) -> dict[str, tp.Any]:
131132
"""Get the committee state."""

0 commit comments

Comments
 (0)