Skip to content

Commit

Permalink
Rename key_args to more fitting cred_args
Browse files Browse the repository at this point in the history
We now support also scripts, not only key credentials.
  • Loading branch information
mkoura committed Jun 18, 2024
1 parent 58f1043 commit 3742f60
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions cardano_clusterlib/conway_gov_query_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(self, clusterlib_obj: "itp.ClusterLib") -> None:
self._clusterlib_obj = clusterlib_obj
self._group_args = ("query",)

def _get_key_args(
def _get_cred_args(
self,
drep_script_hash: str = "",
drep_vkey: str = "",
Expand All @@ -23,17 +23,17 @@ def _get_key_args(
) -> tp.List[str]:
"""Get arguments for script or verification key."""
if drep_script_hash:
key_args = ["--drep-script-hash", str(drep_script_hash)]
cred_args = ["--drep-script-hash", str(drep_script_hash)]
elif drep_vkey:
key_args = ["--drep-verification-key", str(drep_vkey)]
cred_args = ["--drep-verification-key", str(drep_vkey)]
elif drep_vkey_file:
key_args = ["--drep-verification-key-file", str(drep_vkey_file)]
cred_args = ["--drep-verification-key-file", str(drep_vkey_file)]
elif drep_key_hash:
key_args = ["--drep-key-hash", str(drep_key_hash)]
cred_args = ["--drep-key-hash", str(drep_key_hash)]
else:
key_args = []
cred_args = []

return key_args
return cred_args

def query_cli(
self, cli_args: itp.UnpackableSequence, cli_sub_args: itp.UnpackableSequence = ()
Expand Down Expand Up @@ -81,17 +81,17 @@ def drep_state(
Returns:
List[List[Dict[str, Any]]]: DRep state.
"""
key_args = self._get_key_args(
cred_args = self._get_cred_args(
drep_script_hash=drep_script_hash,
drep_vkey=drep_vkey,
drep_vkey_file=drep_vkey_file,
drep_key_hash=drep_key_hash,
)
if not key_args:
key_args = ["--all-dreps"]
if not cred_args:
cred_args = ["--all-dreps"]

out: tp.List[tp.List[tp.Dict[str, tp.Any]]] = json.loads(
self.query_cli(["drep-state", *key_args])
self.query_cli(["drep-state", *cred_args])
)
return out

Expand All @@ -115,17 +115,17 @@ def drep_stake_distribution(
Returns:
List[List[Dict[str, Any]]]: DRep stake distribution.
"""
key_args = self._get_key_args(
cred_args = self._get_cred_args(
drep_script_hash=drep_script_hash,
drep_vkey=drep_vkey,
drep_vkey_file=drep_vkey_file,
drep_key_hash=drep_key_hash,
)
if not key_args:
key_args = ["--all-dreps"]
if not cred_args:
cred_args = ["--all-dreps"]

out: tp.List[tp.List[tp.Dict[str, tp.Any]]] = json.loads(
self.query_cli(["drep-stake-distribution", *key_args])
self.query_cli(["drep-stake-distribution", *cred_args])
)
return out

Expand Down

0 comments on commit 3742f60

Please sign in to comment.