|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | 3 | import logging |
| 4 | +import warnings |
4 | 5 | from typing import Any |
5 | 6 |
|
6 | 7 | from hiero_sdk_python.account.account_balance import AccountBalance |
|
18 | 19 |
|
19 | 20 | class CryptoGetAccountBalanceQuery(Query): |
20 | 21 | """ |
21 | | - A query to retrieve the balance of a specific account from the Hedera network. |
| 22 | + Query an account's balance. |
22 | 23 |
|
23 | | - This class constructs and executes a query to obtain the balance of an account, |
24 | | - including hbars and tokens. |
| 24 | + .. deprecated:: |
| 25 | + The CryptoGetBalance endpoint is scheduled for removal with the |
| 26 | + consensus node release 77 (estimated September 2026). Use the Mirror |
| 27 | + Node REST API to retrieve account balances instead. |
25 | 28 | """ |
26 | 29 |
|
27 | 30 | def __init__( |
28 | 31 | self, |
29 | 32 | account_id: AccountId | None = None, |
30 | 33 | contract_id: ContractId | None = None, |
31 | 34 | ) -> None: |
32 | | - """ |
33 | | - Initializes a new instance of the CryptoGetAccountBalanceQuery class. |
34 | | -
|
35 | | - Args: |
36 | | - account_id (AccountId, optional): The ID of the account to retrieve the balance for. |
37 | | - contract_id (ContractId, optional): The ID of the contract to retrieve the balance for. |
38 | | - """ |
| 35 | + warnings.warn( |
| 36 | + "Deprecated: AccountBalanceQuery will stop working when the Hedera network removes the CryptoGetBalance endpoint (estimated September 2026, consensus node release 77). Use the mirror node REST API to retrieve account balances.", |
| 37 | + DeprecationWarning, |
| 38 | + stacklevel=2, |
| 39 | + ) |
39 | 40 | super().__init__() |
40 | 41 | self.account_id: AccountId | None = None |
41 | 42 | self.contract_id: ContractId | None = None |
@@ -133,25 +134,20 @@ def _get_method(self, channel: _Channel) -> _Method: |
133 | 134 |
|
134 | 135 | def execute(self, client: Client, timeout: int | float | None = None) -> AccountBalance: |
135 | 136 | """ |
136 | | - Executes the account balance query. |
137 | | -
|
138 | | - This function delegates the core logic to `_execute()`, and may propagate exceptions raised by it. |
| 137 | + Execute the account balance query. |
139 | 138 |
|
140 | | - Sends the query to the Hedera network and processes the response |
141 | | - to return an AccountBalance object. |
142 | | -
|
143 | | - Args: |
144 | | - client (Client): The client instance to use for execution |
145 | | - timeout (Optional[Union[int, float]]): The total execution timeout (in seconds) for this execution. |
146 | | -
|
147 | | - Returns: |
148 | | - AccountBalance: The account balance from the network |
| 139 | + .. deprecated:: |
| 140 | + The CryptoGetBalance endpoint is scheduled for removal with the |
| 141 | + consensus node release 77 (estimated September 2026). Use the Mirror |
| 142 | + Node REST API to retrieve account balances instead. |
149 | 143 |
|
150 | 144 | Raises: |
151 | | - PrecheckError: If the query fails with a non-retryable error |
152 | | - MaxAttemptsError: If the query fails after the maximum number of attempts |
153 | | - ReceiptStatusError: If the query fails with a receipt status error |
| 145 | + RuntimeError: Always, because the AccountBalanceQuery is no longer |
| 146 | + supported. |
154 | 147 | """ |
| 148 | + raise RuntimeError( |
| 149 | + "Error: AccountBalanceQuery is no longer supported. Use the mirror node REST API to retrieve account balances." |
| 150 | + ) |
155 | 151 | self._before_execute(client) |
156 | 152 | response = self._execute(client, timeout) |
157 | 153 |
|
|
0 commit comments