Skip to content

Commit b4c7249

Browse files
committed
PR comments
1 parent 4b291ad commit b4c7249

File tree

4 files changed

+28
-26
lines changed

4 files changed

+28
-26
lines changed

bittensor/core/async_subtensor.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ async def get_metagraph_info(
13311331
block: Optional[int] = None,
13321332
block_hash: Optional[str] = None,
13331333
reuse_block: bool = False,
1334-
) -> Optional[MetagraphInfo]:
1334+
) -> MetagraphInfo:
13351335
"""
13361336
Retrieves the MetagraphInfo dataclass from the node for a single subnet (netuid)
13371337
@@ -1342,6 +1342,9 @@ async def get_metagraph_info(
13421342
block_hash: The hash of blockchain block number for the query. Do not specify if using
13431343
block or reuse_block
13441344
reuse_block: Whether to reuse the last-used block hash. Do not set if using block_hash or block.
1345+
1346+
Returns:
1347+
MetagraphInfo dataclass
13451348
"""
13461349
block_hash = await self.determine_block_hash(block, block_hash, reuse_block)
13471350
if not block_hash and reuse_block:
@@ -1371,6 +1374,9 @@ async def get_all_metagraphs_info(
13711374
block_hash (Optional[str]): The hash of blockchain block number for the query. Do not specify if using
13721375
block or reuse_block
13731376
reuse_block (bool): Whether to reuse the last-used block hash. Do not set if using block_hash or block.
1377+
1378+
Returns:
1379+
MetagraphInfo dataclass
13741380
"""
13751381
block_hash = await self.determine_block_hash(block, block_hash.reuse_block)
13761382
if not block_hash and reuse_block:
@@ -3454,7 +3460,7 @@ async def swap_stake(
34543460
hotkey_ss58: str,
34553461
origin_netuid: int,
34563462
destination_netuid: int,
3457-
amount: Union[Balance, float],
3463+
amount: Balance,
34583464
wait_for_inclusion: bool = True,
34593465
wait_for_finalization: bool = False,
34603466
) -> bool:

bittensor/core/extrinsics/transfer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Union, TYPE_CHECKING
1+
from typing import TYPE_CHECKING
22

33
from bittensor.core.settings import NETWORK_EXPLORER_MAP
44
from bittensor.utils.balance import Balance
@@ -19,7 +19,7 @@ def _do_transfer(
1919
subtensor: "Subtensor",
2020
wallet: "Wallet",
2121
destination: str,
22-
amount: "Balance",
22+
amount: Balance,
2323
wait_for_inclusion: bool = True,
2424
wait_for_finalization: bool = False,
2525
) -> tuple[bool, str, str]:
@@ -68,7 +68,7 @@ def transfer_extrinsic(
6868
subtensor: "Subtensor",
6969
wallet: "Wallet",
7070
dest: str,
71-
amount: Union["Balance", float],
71+
amount: Balance,
7272
transfer_all: bool = False,
7373
wait_for_inclusion: bool = True,
7474
wait_for_finalization: bool = False,

bittensor/core/subtensor.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ def get_all_subnets_info(self, block: Optional[int] = None) -> list["SubnetInfo"
549549
else:
550550
return SubnetInfo.list_from_vec_u8(hex_to_bytes(hex_bytes_result))
551551

552-
def get_balance(self, address: str, block: Optional[int] = None) -> "Balance":
552+
def get_balance(self, address: str, block: Optional[int] = None) -> Balance:
553553
"""
554554
Retrieves the balance for given coldkey.
555555
@@ -574,7 +574,7 @@ def get_balances(
574574
self,
575575
*addresses: str,
576576
block: Optional[int] = None,
577-
) -> dict[str, "Balance"]:
577+
) -> dict[str, Balance]:
578578
"""
579579
Retrieves the balance for given coldkey(s)
580580
@@ -905,7 +905,7 @@ def get_delegate_take(
905905

906906
def get_delegated(
907907
self, coldkey_ss58: str, block: Optional[int] = None
908-
) -> list[tuple["DelegateInfo", "Balance"]]:
908+
) -> list[tuple["DelegateInfo", Balance]]:
909909
"""
910910
Retrieves a list of delegates and their associated stakes for a given coldkey. This function identifies the
911911
delegates that a specific account has staked tokens on.
@@ -954,9 +954,7 @@ def get_delegates(self, block: Optional[int] = None) -> list["DelegateInfo"]:
954954
else:
955955
return []
956956

957-
def get_existential_deposit(
958-
self, block: Optional[int] = None
959-
) -> Optional["Balance"]:
957+
def get_existential_deposit(self, block: Optional[int] = None) -> Optional[Balance]:
960958
"""
961959
Retrieves the existential deposit amount for the Bittensor blockchain.
962960
The existential deposit is the minimum amount of TAO required for an account to exist on the blockchain.
@@ -1012,7 +1010,7 @@ def get_hotkey_owner(
10121010
hotkey_owner = val if exists else None
10131011
return hotkey_owner
10141012

1015-
def get_minimum_required_stake(self) -> "Balance":
1013+
def get_minimum_required_stake(self) -> Balance:
10161014
"""
10171015
Returns the minimum required stake for nominators in the Subtensor network.
10181016
This method retries the substrate call up to three times with exponential backoff in case of failures.
@@ -1353,7 +1351,7 @@ def get_subnets(self, block: Optional[int] = None) -> list[int]:
13531351

13541352
def get_total_stake_for_coldkey(
13551353
self, ss58_address: str, block: Optional[int] = None
1356-
) -> "Balance":
1354+
) -> Balance:
13571355
"""
13581356
Returns the total stake held on a coldkey.
13591357
@@ -1374,7 +1372,7 @@ def get_total_stake_for_coldkey(
13741372

13751373
def get_total_stake_for_coldkeys(
13761374
self, *ss58_addresses: str, block: Optional[int] = None
1377-
) -> dict[str, "Balance"]:
1375+
) -> dict[str, Balance]:
13781376
"""
13791377
Returns the total stake held on multiple coldkeys.
13801378
@@ -1406,7 +1404,7 @@ def get_total_stake_for_coldkeys(
14061404

14071405
def get_total_stake_for_hotkey(
14081406
self, ss58_address: str, block: Optional[int] = None
1409-
) -> "Balance":
1407+
) -> Balance:
14101408
"""
14111409
Returns the total stake held on a hotkey.
14121410
@@ -1427,7 +1425,7 @@ def get_total_stake_for_hotkey(
14271425

14281426
def get_total_stake_for_hotkeys(
14291427
self, *ss58_addresses: str, block: Optional[int] = None
1430-
) -> dict[str, "Balance"]:
1428+
) -> dict[str, Balance]:
14311429
"""
14321430
Returns the total stake held on hotkeys.
14331431
@@ -1468,8 +1466,8 @@ def get_total_subnets(self, block: Optional[int] = None) -> Optional[int]:
14681466
return getattr(result, "value", None)
14691467

14701468
def get_transfer_fee(
1471-
self, wallet: "Wallet", dest: str, value: Union["Balance", float, int]
1472-
) -> "Balance":
1469+
self, wallet: "Wallet", dest: str, value: Union[Balance, float, int]
1470+
) -> Balance:
14731471
"""
14741472
Calculates the transaction fee for transferring tokens from a wallet to a specified destination address. This
14751473
function simulates the transfer to estimate the associated cost, taking into account the current network
@@ -1875,9 +1873,7 @@ def neurons_lite(
18751873
hex_bytes_result = self.query_runtime_api(
18761874
runtime_api="NeuronInfoRuntimeApi",
18771875
method="get_neurons_lite",
1878-
params=[
1879-
netuid
1880-
], # TODO check to see if this can accept more than one at a time
1876+
params=[netuid],
18811877
block=block,
18821878
)
18831879

@@ -1917,7 +1913,7 @@ def query_identity(self, key: str, block: Optional[int] = None) -> dict:
19171913
except TypeError:
19181914
return {}
19191915

1920-
def recycle(self, netuid: int, block: Optional[int] = None) -> Optional["Balance"]:
1916+
def recycle(self, netuid: int, block: Optional[int] = None) -> Optional[Balance]:
19211917
"""
19221918
Retrieves the 'Burn' hyperparameter for a specified subnet. The 'Burn' parameter represents the amount of Tao
19231919
that is effectively recycled within the Bittensor network.
@@ -2766,7 +2762,7 @@ def transfer(
27662762
self,
27672763
wallet: "Wallet",
27682764
dest: str,
2769-
amount: Union["Balance", float],
2765+
amount: Balance,
27702766
wait_for_inclusion: bool = True,
27712767
wait_for_finalization: bool = False,
27722768
transfer_all: bool = False,

requirements/prod.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ wheel
22
setuptools~=70.0.0
33
aiohttp~=3.9
44
asyncstdlib~=3.13.0
5-
# bittensor-cli
6-
bt-decode==0.5.0-a0
5+
bittensor-cli
6+
bt-decode==0.4.0
77
colorama~=0.4.6
88
fastapi~=0.110.1
99
munch~=2.5.0
@@ -25,4 +25,4 @@ uvicorn
2525
websockets>=14.1
2626
bittensor-commit-reveal>=0.2.0
2727
bittensor-wallet>=3.0.0
28-
async-substrate-interface==1.0.0rc7
28+
async-substrate-interface==1.0.0rc6

0 commit comments

Comments
 (0)