@@ -660,12 +660,8 @@ def fix_decoded_values(cls, decoded: dict) -> "DynamicInfo":
660
660
alpha_out = Balance .from_rao (decoded ["alpha_out" ]).set_unit (netuid )
661
661
alpha_in = Balance .from_rao (decoded ["alpha_in" ]).set_unit (netuid )
662
662
tao_in = Balance .from_rao (decoded ["tao_in" ]).set_unit (0 )
663
- total_locked = Balance .from_rao (decoded ["total_locked" ]).set_unit (
664
- netuid
665
- )
666
- owner_locked = Balance .from_rao (decoded ["owner_locked" ]).set_unit (
667
- netuid
668
- )
663
+ total_locked = Balance .from_rao (decoded ["total_locked" ]).set_unit (netuid )
664
+ owner_locked = Balance .from_rao (decoded ["owner_locked" ]).set_unit (netuid )
669
665
price = (
670
666
Balance .from_tao (tao_in .tao / alpha_in .tao )
671
667
if alpha_in .tao > 0
@@ -766,6 +762,7 @@ def alpha_to_tao_with_slippage(self, alpha: Balance) -> tuple[Balance, Balance]:
766
762
@dataclass
767
763
class DynamicPoolInfoV2 :
768
764
"""Dataclass for dynamic pool info."""
765
+
769
766
netuid : int
770
767
alpha_issuance : int
771
768
alpha_outstanding : int
@@ -836,10 +833,12 @@ def __init__(
836
833
self .price = Balance .from_tao (1.0 )
837
834
838
835
def __str__ (self ) -> str :
839
- return (f"DynamicPool( alpha_issuance={ self .alpha_issuance } , "
840
- f"alpha_outstanding={ self .alpha_outstanding } , "
841
- f"alpha_reserve={ self .alpha_reserve } , "
842
- f"tao_reserve={ self .tao_reserve } , k={ self .k } , price={ self .price } )" )
836
+ return (
837
+ f"DynamicPool( alpha_issuance={ self .alpha_issuance } , "
838
+ f"alpha_outstanding={ self .alpha_outstanding } , "
839
+ f"alpha_reserve={ self .alpha_reserve } , "
840
+ f"tao_reserve={ self .tao_reserve } , k={ self .k } , price={ self .price } )"
841
+ )
843
842
844
843
def __repr__ (self ) -> str :
845
844
return self .__str__ ()
@@ -922,6 +921,7 @@ def alpha_to_tao_with_slippage(self, alpha: Balance) -> Tuple[Balance, Balance]:
922
921
@dataclass
923
922
class ScheduledColdkeySwapInfo :
924
923
"""Dataclass for scheduled coldkey swap information."""
924
+
925
925
old_coldkey : str
926
926
new_coldkey : str
927
927
arbitration_block : int
@@ -966,9 +966,7 @@ def decode_account_id_list(cls, vec_u8: list[int]) -> Optional[list[str]]:
966
966
)
967
967
if decoded is None :
968
968
return None
969
- return [
970
- ss58_encode (account_id , SS58_FORMAT ) for account_id in decoded
971
- ]
969
+ return [ss58_encode (account_id , SS58_FORMAT ) for account_id in decoded ]
972
970
973
971
974
972
@dataclass
@@ -994,42 +992,56 @@ class SubnetState:
994
992
995
993
@classmethod
996
994
def from_vec_u8 (cls , vec_u8 : list [int ]) -> Optional ["SubnetState" ]:
997
- if len (vec_u8 ) == 0 : return None
995
+ if len (vec_u8 ) == 0 :
996
+ return None
998
997
decoded = from_scale_encoding (vec_u8 , ChainDataType .SubnetState , is_option = True )
999
- if decoded is None : return None
998
+ if decoded is None :
999
+ return None
1000
1000
return SubnetState .fix_decoded_values (decoded )
1001
1001
1002
1002
@classmethod
1003
1003
def list_from_vec_u8 (cls , vec_u8 : list [int ]) -> list ["SubnetState" ]:
1004
- decoded = from_scale_encoding ( vec_u8 , ChainDataType .SubnetState , is_vec = True , is_option = True )
1005
- if decoded is None :return []
1004
+ decoded = from_scale_encoding (
1005
+ vec_u8 , ChainDataType .SubnetState , is_vec = True , is_option = True
1006
+ )
1007
+ if decoded is None :
1008
+ return []
1006
1009
decoded = [SubnetState .fix_decoded_values (d ) for d in decoded ]
1007
1010
return decoded
1008
1011
1009
1012
@classmethod
1010
1013
def fix_decoded_values (cls , decoded : dict ) -> "SubnetState" :
1011
1014
netuid = decoded ["netuid" ]
1012
1015
return SubnetState (
1013
- netuid = netuid ,
1014
- hotkeys = [ss58_encode (val , SS58_FORMAT ) for val in decoded ["hotkeys" ]],
1015
- coldkeys = [ss58_encode (val , SS58_FORMAT ) for val in decoded ["coldkeys" ]],
1016
- active = decoded ["active" ],
1017
- validator_permit = decoded ["validator_permit" ],
1018
- pruning_score = [u16_normalized_float (val ) for val in decoded ["pruning_score" ]],
1019
- last_update = decoded ["last_update" ],
1020
- emission = [Balance .from_rao ( val ).set_unit (netuid ) for val in decoded ["emission" ]],
1021
- dividends = [u16_normalized_float (val ) for val in decoded ["dividends" ]],
1022
- incentives = [u16_normalized_float (val ) for val in decoded ["incentives" ]],
1023
- consensus = [u16_normalized_float (val ) for val in decoded ["consensus" ]],
1024
- trust = [u16_normalized_float (val ) for val in decoded ["trust" ]],
1025
- rank = [u16_normalized_float (val ) for val in decoded ["rank" ]],
1026
- block_at_registration = decoded ["block_at_registration" ],
1027
- local_stake = [Balance .from_rao ( val ).set_unit (netuid ) for val in decoded ["local_stake" ]],
1028
- global_stake = [Balance .from_rao ( val ).set_unit (0 ) for val in decoded ["global_stake" ]],
1029
- stake_weight = [u16_normalized_float (val ) for val in decoded ["stake_weight" ]],
1030
- emission_history = decoded ["emission_history" ]
1016
+ netuid = netuid ,
1017
+ hotkeys = [ss58_encode (val , SS58_FORMAT ) for val in decoded ["hotkeys" ]],
1018
+ coldkeys = [ss58_encode (val , SS58_FORMAT ) for val in decoded ["coldkeys" ]],
1019
+ active = decoded ["active" ],
1020
+ validator_permit = decoded ["validator_permit" ],
1021
+ pruning_score = [
1022
+ u16_normalized_float (val ) for val in decoded ["pruning_score" ]
1023
+ ],
1024
+ last_update = decoded ["last_update" ],
1025
+ emission = [
1026
+ Balance .from_rao (val ).set_unit (netuid ) for val in decoded ["emission" ]
1027
+ ],
1028
+ dividends = [u16_normalized_float (val ) for val in decoded ["dividends" ]],
1029
+ incentives = [u16_normalized_float (val ) for val in decoded ["incentives" ]],
1030
+ consensus = [u16_normalized_float (val ) for val in decoded ["consensus" ]],
1031
+ trust = [u16_normalized_float (val ) for val in decoded ["trust" ]],
1032
+ rank = [u16_normalized_float (val ) for val in decoded ["rank" ]],
1033
+ block_at_registration = decoded ["block_at_registration" ],
1034
+ local_stake = [
1035
+ Balance .from_rao (val ).set_unit (netuid ) for val in decoded ["local_stake" ]
1036
+ ],
1037
+ global_stake = [
1038
+ Balance .from_rao (val ).set_unit (0 ) for val in decoded ["global_stake" ]
1039
+ ],
1040
+ stake_weight = [u16_normalized_float (val ) for val in decoded ["stake_weight" ]],
1041
+ emission_history = decoded ["emission_history" ],
1031
1042
)
1032
1043
1044
+
1033
1045
class SubstakeElements :
1034
1046
@staticmethod
1035
1047
def decode (result : list [int ]) -> list [dict ]:
@@ -1049,7 +1061,6 @@ def decode(result: list[int]) -> list[dict]:
1049
1061
return result
1050
1062
1051
1063
1052
-
1053
1064
custom_rpc_type_registry = {
1054
1065
"types" : {
1055
1066
"SubnetInfo" : {
0 commit comments