|
6 | 6 | import requests
|
7 | 7 | import scalecodec
|
8 | 8 | from async_substrate_interface.errors import SubstrateRequestException
|
| 9 | +from async_substrate_interface.types import ScaleObj |
9 | 10 | from async_substrate_interface.sync_substrate import SubstrateInterface
|
10 | 11 | from async_substrate_interface.utils import json
|
11 | 12 | from numpy.typing import NDArray
|
|
91 | 92 | if TYPE_CHECKING:
|
92 | 93 | from bittensor_wallet import Wallet
|
93 | 94 | from async_substrate_interface.sync_substrate import QueryMapResult
|
94 |
| - from async_substrate_interface.types import ScaleObj |
95 | 95 | from scalecodec.types import GenericCall
|
96 | 96 |
|
97 | 97 |
|
@@ -1281,6 +1281,28 @@ def get_stake_for_coldkey(
|
1281 | 1281 |
|
1282 | 1282 | get_stake_info_for_coldkey = get_stake_for_coldkey
|
1283 | 1283 |
|
| 1284 | + def get_stake_for_hotkey( |
| 1285 | + self, hotkey_ss58: str, netuid: int, block: Optional[int] = None |
| 1286 | + ) -> Balance: |
| 1287 | + """ |
| 1288 | + Retrieves the stake information for a given hotkey. |
| 1289 | +
|
| 1290 | + Args: |
| 1291 | + hotkey_ss58: The SS58 address of the hotkey. |
| 1292 | + netuid: The subnet ID to query for. |
| 1293 | + block: The block number at which to query the stake information. Do not specify if also specifying |
| 1294 | + block_hash or reuse_block |
| 1295 | + """ |
| 1296 | + hotkey_alpha_query = self.query_subtensor( |
| 1297 | + name="TotalHotkeyAlpha", params=[hotkey_ss58, netuid], block=block |
| 1298 | + ) |
| 1299 | + hotkey_alpha = cast(ScaleObj, hotkey_alpha_query) |
| 1300 | + balance = Balance.from_rao(hotkey_alpha.value) |
| 1301 | + balance.set_unit(netuid=netuid) |
| 1302 | + return balance |
| 1303 | + |
| 1304 | + get_hotkey_stake = get_stake_for_hotkey |
| 1305 | + |
1284 | 1306 | def get_subnet_burn_cost(self, block: Optional[int] = None) -> Optional[Balance]:
|
1285 | 1307 | """
|
1286 | 1308 | Retrieves the burn cost for registering a new subnet within the Bittensor network. This cost represents the
|
|
0 commit comments