Skip to content

Commit 7d0ee47

Browse files
Include get future pparams
1 parent 8d8bacd commit 7d0ee47

File tree

1 file changed

+3
-50
lines changed

1 file changed

+3
-50
lines changed

cardano_clusterlib/query_group.py

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -710,56 +710,9 @@ def get_treasury(self) -> int:
710710
return int(self.query_cli(["treasury"]))
711711

712712
def get_future_pparams(self) -> dict[str, tp.Any]:
713-
"""
714-
Return the protocol parameters that will apply at the next epoch.
715-
716-
Equivalent CLI:
717-
cardano-cli latest query future-pparams --testnet-magic <n> --socket-path <socket>
718-
719-
Returns:
720-
dict[str, Any]: Parameters scheduled for the next epoch, or {} if none.
721-
"""
722-
socket_path = str(self._clusterlib_obj.socket_path or "")
723-
if not socket_path:
724-
possible_socket = pl.Path(self._clusterlib_obj.state_dir) / "bft1.socket"
725-
if possible_socket.exists():
726-
socket_path = str(possible_socket)
727-
else:
728-
msg = "Socket path not set or found. Make sure the cluster is running."
729-
raise RuntimeError(msg)
730-
731-
cmd_args: list[str] = [
732-
"cardano-cli",
733-
"latest",
734-
"query",
735-
"future-pparams",
736-
*map(str, self._clusterlib_obj.magic_args),
737-
"--socket-path",
738-
socket_path,
739-
"--output-json",
740-
]
741-
742-
cli_out = self._clusterlib_obj.cli(cmd_args, add_default_args=False)
743-
out_str = cli_out.stdout.decode().strip()
744-
745-
if not out_str or out_str.lower() == "null":
746-
LOGGER.debug("No future protocol parameters scheduled.")
747-
return {}
748-
749-
try:
750-
result = json.loads(out_str)
751-
except json.JSONDecodeError as err:
752-
LOGGER.warning(f"Could not decode future-pparams output as JSON: {err}")
753-
return {}
754-
755-
# Type-safe
756-
if isinstance(result, dict):
757-
return result
758-
if isinstance(result, list):
759-
LOGGER.warning(f"Unexpected list returned from future-pparams query: {result}")
760-
return {"_list_result": result}
761-
LOGGER.warning(f"Unexpected output type for future-pparams: {type(result).__name__}")
762-
return {}
713+
"""Get the future protocol parameters that will apply at the next epoch."""
714+
out: dict[str, tp.Any] = json.loads(self.query_cli(["future-pparams"]))
715+
return out
763716

764717
def __repr__(self) -> str:
765718
return f"<{self.__class__.__name__}: clusterlib_obj={id(self._clusterlib_obj)}>"

0 commit comments

Comments
 (0)