opentensor / btcli

Bittensor command line tool
https://docs.bittensor.com/btcli
13 stars 3 forks source link

Add support for hotkey names in `-in` and `-ex` in stake add/remove #191

Open UselessXiaoYao opened 2 weeks ago

UselessXiaoYao commented 2 weeks ago
(.venv) ubuntu@c2-large-x86-syd-1:~/workspace/yzp$ python3 --version
Python 3.10.12
(.venv) ubuntu@c2-large-x86-syd-1:~/workspace/yzp$ pip show bittensor
Name: bittensor
Version: 8.2.0
Summary: bittensor
Home-page: https://github.com/opentensor/bittensor
Author: bittensor.com
Author-email: 
License: MIT
Location: /home/ubuntu/workspace/yzp/.venv/lib/python3.10/site-packages
Requires: aiohttp, bittensor-cli, bittensor-wallet, bt-decode, colorama, fastapi, msgpack-numpy-opentensor, munch, nest-asyncio, netaddr, numpy, packaging, pydantic, python-Levenshtein, python-statemachine, pyyaml, requests, retry, rich, scalecodec, setuptools, substrate-interface, uvicorn, wheel
Required-by: 
(.venv) ubuntu@c2-large-x86-syd-1:~/workspace/yzp$ pip show bittensor_cli
Name: bittensor-cli
Version: 8.2.0
Summary: Bittensor CLI
Home-page: https://github.com/opentensor/btcli
Author: bittensor.com
Author-email: 
License: MIT
Location: /home/ubuntu/workspace/yzp/.venv/lib/python3.10/site-packages
Requires: aiohttp, async-property, backoff, bittensor-wallet, bt-decode, fuzzywuzzy, GitPython, Jinja2, netaddr, numpy, pycryptodome, pytest, python-Levenshtein, PyYAML, rich, scalecodec, substrate-interface, typer, websockets, wheel
Required-by: bittensor
(.venv) ubuntu@c2-large-x86-syd-1:~/workspace/yzp$ pip show bittensor_wallet
Name: bittensor-wallet
Version: 2.0.2
Summary: 
Home-page: 
Author: 
Author-email: Roman Chkhaidze <roman@opentensor.dev>
License: 
Location: /home/ubuntu/workspace/yzp/.venv/lib/python3.10/site-packages
Requires: ansible, ansible-vault, cryptography, eth-utils, munch, password-strength, py-bip39-bindings, rich, termcolor
Required-by: bittensor, bittensor-cli

When I use "btcli st remove --wallet.name mywallet --in hk1,hk2 --all", it report error, "Invalid value: Invalid SS58 address: hk1"

thewhaleking commented 4 days ago

Caused by this function:

def parse_to_list(
    raw_list: str, list_type: type, error_message: str, is_ss58: bool = False
) -> list:
    try:
        # Split the string by commas and convert each part to according to type
        parsed_list = [
            list_type(uid.strip()) for uid in raw_list.split(",") if uid.strip()
        ]

        # Validate in-case of ss58s
        if is_ss58:
            for item in parsed_list:
                if not is_valid_ss58_address(item):
                    raise typer.BadParameter(f"Invalid SS58 address: {item}")

        return parsed_list
    except ValueError:
        raise typer.BadParameter(error_message)

We must change the way we're handling this on items for include/exclude hotkeys on:

thewhaleking commented 1 day ago

Hey @UselessXiaoYao We're currently discussing whether or not to add support for hotkey names in this. Currently, as he help text for that option indicates, only the ss58 addresses are considered valid for that option.

thewhaleking commented 1 day ago

PR #216 adds support for this.