bittensor.core.chain_data.utils#
Chain data helper functions and data.
Attributes#
Classes#
Create a collection of name/value pairs. |
Functions#
|
Decodes input_ data from SCALE encoding based on the specified type name and modifiers. |
|
Decodes SCALE encoded data to a dictionary based on the provided type string. |
|
Decodes an AccountId from bytes to a Base64 string using SS58 encoding. |
|
Processes stake data to decode account IDs and convert stakes from rao to Balance objects. |
Module Contents#
- class bittensor.core.chain_data.utils.ChainDataType(*args, **kwds)[source]#
Bases:
enum.Enum
Create a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- NeuronInfo = 1#
- SubnetInfo = 2#
- DelegateInfo = 3#
- NeuronInfoLite = 4#
- DelegatedInfo = 5#
- StakeInfo = 6#
- IPInfo = 7#
- SubnetHyperparameters = 8#
- ScheduledColdkeySwapInfo = 9#
- AccountId = 10#
- bittensor.core.chain_data.utils.from_scale_encoding(input_, type_name, is_vec=False, is_option=False)[source]#
Decodes input_ data from SCALE encoding based on the specified type name and modifiers.
- Parameters:
input (Union[List[int], bytes, ScaleBytes]) – The input_ data to decode.
type_name (ChainDataType) – The type of data being decoded.
is_vec (bool) – Whether the data is a vector of the specified type. Default is
False
.is_option (bool) – Whether the data is an optional value of the specified type. Default is
False
.input_ (Union[list[int], bytes, scalecodec.base.ScaleBytes])
- Returns:
The decoded data as a dictionary, or
None
if the decoding fails.- Return type:
Optional[dict]
- bittensor.core.chain_data.utils.from_scale_encoding_using_type_string(input_, type_string)[source]#
Decodes SCALE encoded data to a dictionary based on the provided type string.
- bittensor.core.chain_data.utils.custom_rpc_type_registry#
- bittensor.core.chain_data.utils.decode_account_id(account_id_bytes)[source]#
Decodes an AccountId from bytes to a Base64 string using SS58 encoding.