Skip to content

Commit

Permalink
Root commands (#3)
Browse files Browse the repository at this point in the history
* `root list` working

* Fixed help output

* Fixed help output

* Fixed the way config for network/chain is handled.

* [WIP] Check-in. Pausing on setting weights until I determine whether we're doing the metagraph approach still.

* Root get-weights

* Circular import temp fix.

* Added root boost command. Not finished as I need to confirm the use of metagraph on it.

* Ruff

* Root boost and root set-weights.

* Code cleanup.

* Code cleanup.

* Feedback from PR #1

* Feedback from PR #1. Docstrings mostly.

* Final PR #1 suggestions I will be implementing.

* In the arena, trying things.

* Boost and Slash created with new logic to parse old weights. Confirming this logic is correct in Discord.

* Senate vote added

* Added `root senate` command.

* Root register command.

* Root proposals

* Root `set-take`

* Root `set-delegate`

* Root `undelegate-stake`

* Docstring.

* [WIP] Check-in

* [WIP] Check-in

* Root `my-delegates`

* Root `list-delegates`

* Root `nominate`, made extrinsics more general for signing and such.

* Ruff and Mypy

* Ruff and Mypy

* Corrected type registry change.
  • Loading branch information
thewhaleking authored Aug 9, 2024
1 parent a1733da commit 0f27e30
Show file tree
Hide file tree
Showing 12 changed files with 4,110 additions and 196 deletions.
981 changes: 928 additions & 53 deletions cli.py

Large diffs are not rendered by default.

26 changes: 25 additions & 1 deletion src/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from dataclasses import dataclass
from typing import Any


class Constants:
Expand All @@ -24,7 +25,7 @@ class DelegatesDetails:
signature: str

@classmethod
def from_json(cls, json: dict[str, any]) -> "DelegatesDetails":
def from_json(cls, json: dict[str, Any]) -> "DelegatesDetails":
return cls(
name=json["name"],
url=json["url"],
Expand All @@ -36,6 +37,16 @@ def from_json(cls, json: dict[str, any]) -> "DelegatesDetails":
class Defaults:
netuid = 1

class config:
path = "~/.bittensor/config.yml"
dictionary = {
"network": None,
"chain": None,
"wallet_path": None,
"wallet_name": None,
"wallet_hotkey": None,
}

class subtensor:
network = "finney"
chain_endpoint = None
Expand Down Expand Up @@ -149,6 +160,19 @@ class logging:
"SubnetRegistrationRuntimeApi": {
"methods": {"get_network_registration_cost": {"params": [], "type": "u64"}}
},
"DelegateInfo": {
"methods": {
"get_delegated": {
"params": [
{
"name": "coldkey_account_vec",
"type": "Vec<u8>",
}
],
"type": "Vec<u8>",
}
}
},
},
}

Expand Down
21 changes: 17 additions & 4 deletions src/bittensor/async_substrate_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def add_response(self, item_id: int, response: dict, complete: bool):
self.responses[request_id]["complete"] = complete

@property
def is_complete(self):
def is_complete(self) -> bool:
"""
Returns whether all requests in the manager have completed
"""
Expand Down Expand Up @@ -481,7 +481,7 @@ async def get_block_runtime_version(self, block_hash: str) -> dict:
return response.get("result")

async def get_block_metadata(
self, block_hash=None, decode=True
self, block_hash: Optional[str] = None, decode: bool = True
) -> Union[dict, ScaleType]:
"""
A pass-though to existing JSONRPC method `state_getMetadata`.
Expand Down Expand Up @@ -578,6 +578,19 @@ async def _process_response(
runtime: Optional[Runtime] = None,
result_handler: Optional[ResultHandler] = None,
) -> tuple[Union[ScaleType, dict], bool]:
"""
Processes the RPC call response by decoding it, returning it as is, or setting a handler for subscriptions,
depending on the specific call.
:param response: the RPC call response
:param subscription_id: the subscription id for subscriptions, used only for subscriptions with a result handler
:param value_scale_type: Scale Type string used for decoding ScaleBytes results
:param storage_item: The ScaleType object used for decoding ScaleBytes results
:param runtime: the runtime object, used for decoding ScaleBytes results
:param result_handler: the result handler coroutine used for handling longer-running subscriptions
:return: (decoded response, completion)
"""
obj = response

if value_scale_type:
Expand Down Expand Up @@ -1088,8 +1101,8 @@ async def query_map(
storage_function: str,
params: Optional[list] = None,
block_hash: Optional[str] = None,
max_results: int = None,
start_key: str = None,
max_results: Optional[int] = None,
start_key: Optional[str] = None,
page_size: int = 100,
ignore_decoding_errors: bool = True,
reuse_block_hash: bool = False,
Expand Down
Loading

0 comments on commit 0f27e30

Please sign in to comment.