|
1 |
| -from typing import List, Optional, Tuple |
| 1 | +from typing import Any, List, Optional, Tuple |
2 | 2 |
|
3 | 3 | class AxonInfo:
|
4 | 4 | # Axon serving block.
|
@@ -218,3 +218,69 @@ class DelegateInfo:
|
218 | 218 | @staticmethod
|
219 | 219 | def decode_delegated(encoded: bytes) -> List[Tuple["DelegateInfo", int]]:
|
220 | 220 | pass
|
| 221 | + |
| 222 | +class MetadataV15: |
| 223 | + """ |
| 224 | + MetadataV15 is the 15th version-style of metadata for the chain. |
| 225 | + It contains information about all the chain types, including the type signatures |
| 226 | + of the Runtime API functions. |
| 227 | +
|
| 228 | + Example: |
| 229 | + >>> import bittensor, bt_decode, scalecodec |
| 230 | + >>> sub = bittensor.subtensor() |
| 231 | + >>> v15_int = scalecodec.U32() |
| 232 | + >>> v15_int.value = 15 |
| 233 | + >>> metadata_rpc_result = sub.substrate.rpc_request("state_call", [ |
| 234 | + ... "Metadata_metadata_at_version", |
| 235 | + ... v15_int.encode().to_hex(), |
| 236 | + ... sub.substrate.get_chain_finalised_head() |
| 237 | + ]) |
| 238 | + >>> metadata_option_hex_str = metadata_rpc_result['result'] |
| 239 | + >>> metadata_option_bytes = bytes.fromhex(metadata_option_hex_str[2:]) |
| 240 | + >>> metadata_v15 = bt_decode.MetadataV15.decode_from_metadata_option(metadata_option_bytes) |
| 241 | + >>> print(metadata_v15.to_json()) |
| 242 | + """ |
| 243 | + |
| 244 | + @staticmethod |
| 245 | + def decode_from_metadata_option(encoded_metadata_v15: bytes) -> "MetadataV15": |
| 246 | + pass |
| 247 | + def to_json(self) -> str: |
| 248 | + """ |
| 249 | + Returns a JSON representation of the metadata. |
| 250 | + """ |
| 251 | + pass |
| 252 | + |
| 253 | +class PortableRegistry: |
| 254 | + """ |
| 255 | + PortableRegistry is a portable for of the chains registry that |
| 256 | + can be used to serialize and deserialize the registry to and from JSON. |
| 257 | +
|
| 258 | + Example: |
| 259 | + >>> import bittensor, bt_decode, scalecodec |
| 260 | + >>> sub = bittensor.subtensor() |
| 261 | + >>> v15_int = scalecodec.U32() |
| 262 | + >>> v15_int.value = 15 |
| 263 | + >>> metadata_rpc_result = sub.substrate.rpc_request("state_call", [ |
| 264 | + ... "Metadata_metadata_at_version", |
| 265 | + ... v15_int.encode().to_hex(), |
| 266 | + ... sub.substrate.get_chain_finalised_head() |
| 267 | + ]) |
| 268 | + >>> metadata_option_hex_str = metadata_rpc_result['result'] |
| 269 | + >>> metadata_option_bytes = bytes.fromhex(metadata_option_hex_str[2:]) |
| 270 | + >>> metadata_v15 = bt_decode.MetadataV15.decode_from_metadata_option(metadata_option_bytes) |
| 271 | + >>> bt_decode.PortableRegistry.from_metadata_v15( metadata_v15 ) |
| 272 | + """ |
| 273 | + |
| 274 | + registry: str # JSON encoded PortableRegistry |
| 275 | + |
| 276 | + @staticmethod |
| 277 | + def from_json(json_str: str) -> "PortableRegistry": |
| 278 | + pass |
| 279 | + @staticmethod |
| 280 | + def from_metadata_v15(metadata_v15: MetadataV15) -> "PortableRegistry": |
| 281 | + pass |
| 282 | + |
| 283 | +def decode( |
| 284 | + type_string: str, portable_registry: PortableRegistry, encoded: bytes |
| 285 | +) -> Any: |
| 286 | + pass |
0 commit comments