Skip to content

Commit 8bc5fcb

Browse files
authored
Merge pull request #326 from input-output-hk/add_query_proposal
feat: add get_proposals to query governance proposals
2 parents 25ee3d9 + 785c64f commit 8bc5fcb

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

cardano_clusterlib/query_group.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,37 @@ def get_committee_state(self) -> dict[str, tp.Any]:
674674
out: dict[str, tp.Any] = json.loads(self.query_cli(["committee-state"]))
675675
return out
676676

677+
def get_proposals(
678+
self,
679+
action_txid: str = "",
680+
action_ix: int | None = None,
681+
) -> list[dict[str, tp.Any]]:
682+
"""Get the governance proposals that are eligible for ratification.
683+
684+
When no arguments are passed, query for all proposals.
685+
686+
Args:
687+
action_txid: TxId of the governance action.
688+
action_ix: Tx's governance action index.
689+
690+
Returns:
691+
list[dict[str, tp.Any]]: A list of governance proposals.
692+
"""
693+
if bool(action_txid) != (action_ix is not None):
694+
msg = "Both `action_txid` and `action_ix` must be specified together."
695+
raise ValueError(msg)
696+
697+
query_args = ["proposals"]
698+
699+
if action_txid and action_ix is not None:
700+
query_args.extend(["--governance-action-tx-id", action_txid])
701+
query_args.extend(["--governance-action-index", str(action_ix)])
702+
else:
703+
query_args.append("--all-proposals")
704+
705+
proposals: list[dict[str, tp.Any]] = json.loads(self.query_cli(query_args))
706+
return proposals
707+
677708
def get_treasury(self) -> int:
678709
"""Get the treasury value."""
679710
return int(self.query_cli(["treasury"]))

0 commit comments

Comments
 (0)