From 8d8bacd1344ab1541e22ad912888883cdd2d3454 Mon Sep 17 00:00:00 2001 From: femi Date: Wed, 29 Oct 2025 11:48:51 +0000 Subject: [PATCH 1/3] Include get future pparams --- cardano_clusterlib/query_group.py | 52 +++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/cardano_clusterlib/query_group.py b/cardano_clusterlib/query_group.py index 1e24c9f..025c882 100644 --- a/cardano_clusterlib/query_group.py +++ b/cardano_clusterlib/query_group.py @@ -709,5 +709,57 @@ def get_treasury(self) -> int: """Get the treasury value.""" return int(self.query_cli(["treasury"])) + def get_future_pparams(self) -> dict[str, tp.Any]: + """ + Return the protocol parameters that will apply at the next epoch. + + Equivalent CLI: + cardano-cli latest query future-pparams --testnet-magic --socket-path + + Returns: + dict[str, Any]: Parameters scheduled for the next epoch, or {} if none. + """ + socket_path = str(self._clusterlib_obj.socket_path or "") + if not socket_path: + possible_socket = pl.Path(self._clusterlib_obj.state_dir) / "bft1.socket" + if possible_socket.exists(): + socket_path = str(possible_socket) + else: + msg = "Socket path not set or found. Make sure the cluster is running." + raise RuntimeError(msg) + + cmd_args: list[str] = [ + "cardano-cli", + "latest", + "query", + "future-pparams", + *map(str, self._clusterlib_obj.magic_args), + "--socket-path", + socket_path, + "--output-json", + ] + + cli_out = self._clusterlib_obj.cli(cmd_args, add_default_args=False) + out_str = cli_out.stdout.decode().strip() + + if not out_str or out_str.lower() == "null": + LOGGER.debug("No future protocol parameters scheduled.") + return {} + + try: + result = json.loads(out_str) + except json.JSONDecodeError as err: + LOGGER.warning(f"Could not decode future-pparams output as JSON: {err}") + return {} + + # Type-safe + if isinstance(result, dict): + return result + if isinstance(result, list): + LOGGER.warning(f"Unexpected list returned from future-pparams query: {result}") + return {"_list_result": result} + LOGGER.warning(f"Unexpected output type for future-pparams: {type(result).__name__}") + return {} + def __repr__(self) -> str: return f"<{self.__class__.__name__}: clusterlib_obj={id(self._clusterlib_obj)}>" From 7d0ee479ce8d9d26453a1f81b97143d57cb62eb2 Mon Sep 17 00:00:00 2001 From: femi Date: Wed, 29 Oct 2025 17:06:20 +0000 Subject: [PATCH 2/3] Include get future pparams --- cardano_clusterlib/query_group.py | 53 ++----------------------------- 1 file changed, 3 insertions(+), 50 deletions(-) diff --git a/cardano_clusterlib/query_group.py b/cardano_clusterlib/query_group.py index 025c882..7111fb5 100644 --- a/cardano_clusterlib/query_group.py +++ b/cardano_clusterlib/query_group.py @@ -710,56 +710,9 @@ def get_treasury(self) -> int: return int(self.query_cli(["treasury"])) def get_future_pparams(self) -> dict[str, tp.Any]: - """ - Return the protocol parameters that will apply at the next epoch. - - Equivalent CLI: - cardano-cli latest query future-pparams --testnet-magic --socket-path - - Returns: - dict[str, Any]: Parameters scheduled for the next epoch, or {} if none. - """ - socket_path = str(self._clusterlib_obj.socket_path or "") - if not socket_path: - possible_socket = pl.Path(self._clusterlib_obj.state_dir) / "bft1.socket" - if possible_socket.exists(): - socket_path = str(possible_socket) - else: - msg = "Socket path not set or found. Make sure the cluster is running." - raise RuntimeError(msg) - - cmd_args: list[str] = [ - "cardano-cli", - "latest", - "query", - "future-pparams", - *map(str, self._clusterlib_obj.magic_args), - "--socket-path", - socket_path, - "--output-json", - ] - - cli_out = self._clusterlib_obj.cli(cmd_args, add_default_args=False) - out_str = cli_out.stdout.decode().strip() - - if not out_str or out_str.lower() == "null": - LOGGER.debug("No future protocol parameters scheduled.") - return {} - - try: - result = json.loads(out_str) - except json.JSONDecodeError as err: - LOGGER.warning(f"Could not decode future-pparams output as JSON: {err}") - return {} - - # Type-safe - if isinstance(result, dict): - return result - if isinstance(result, list): - LOGGER.warning(f"Unexpected list returned from future-pparams query: {result}") - return {"_list_result": result} - LOGGER.warning(f"Unexpected output type for future-pparams: {type(result).__name__}") - return {} + """Get the future protocol parameters that will apply at the next epoch.""" + out: dict[str, tp.Any] = json.loads(self.query_cli(["future-pparams"])) + return out def __repr__(self) -> str: return f"<{self.__class__.__name__}: clusterlib_obj={id(self._clusterlib_obj)}>" From 618a26b95262e423f69e621cb4f0350818dd2d5a Mon Sep 17 00:00:00 2001 From: femi Date: Thu, 30 Oct 2025 12:18:53 +0000 Subject: [PATCH 3/3] Include get future pparams --- cardano_clusterlib/query_group.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cardano_clusterlib/query_group.py b/cardano_clusterlib/query_group.py index 7111fb5..d96e04f 100644 --- a/cardano_clusterlib/query_group.py +++ b/cardano_clusterlib/query_group.py @@ -711,7 +711,7 @@ def get_treasury(self) -> int: def get_future_pparams(self) -> dict[str, tp.Any]: """Get the future protocol parameters that will apply at the next epoch.""" - out: dict[str, tp.Any] = json.loads(self.query_cli(["future-pparams"])) + out: dict[str, tp.Any] = json.loads(self.query_cli(["future-pparams"])) or {} return out def __repr__(self) -> str: