Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
68f6d4c
Uses the disk-cached async-substrate-interface. Must be used with htt…
thewhaleking Mar 7, 2025
8a0dba5
Makes the disk cache optional (requires env var "DISK_CACHE=1") for t…
thewhaleking Mar 12, 2025
9939e4d
Merge remote-tracking branch 'origin/staging' into feat/thewhaleking/…
thewhaleking Mar 12, 2025
a19755c
Bump required async-substrate-interface version.
thewhaleking Mar 12, 2025
739e3d2
Name shadowing and general cleanup.
thewhaleking Mar 12, 2025
cf8bef2
Bump version
thewhaleking Mar 12, 2025
6474543
Merge branch 'staging' into fix/thewhaleking/name-shadowing
ibraheem-abe Mar 12, 2025
96dc5d0
Merge remote-tracking branch 'origin/staging' into fix/thewhaleking/n…
thewhaleking Mar 13, 2025
a882f88
Merge remote-tracking branch 'origin/fix/thewhaleking/name-shadowing'…
thewhaleking Mar 13, 2025
0c5bcf5
Type return + docstring
thewhaleking Mar 13, 2025
6abcd27
Merge pull request #368 from opentensor/feat/thewhaleking/disk-cache
thewhaleking Mar 13, 2025
5fd1104
Bumps version and changelog
ibraheem-abe Mar 13, 2025
814e376
Converts COLOR_PALETTE dict to class with getitem property
thewhaleking Mar 13, 2025
7d3ee18
Added examples
thewhaleking Mar 13, 2025
9650e65
Adds rate-tolerance alias
ibraheem-abe Mar 13, 2025
d63e404
Merge pull request #386 from opentensor/feat/thewhaleking/color-palle…
thewhaleking Mar 13, 2025
9cf7abd
Merge pull request #381 from opentensor/fix/thewhaleking/name-shadowing
thewhaleking Mar 13, 2025
064df63
Merge pull request #387 from opentensor/update/rate-tolerance-alias
ibraheem-abe Mar 13, 2025
d2e9c18
Updates changelog
ibraheem-abe Mar 13, 2025
e5df987
Merge pull request #385 from opentensor/changelog/914
ibraheem-abe Mar 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 9.1.4 /2025-03-13

## What's Changed
* Disk-Cache Async-Substrate-Interface Calls by @thewhaleking in https://github.com/opentensor/btcli/pull/368
* COLOR_PALETTE refactor by @thewhaleking in https://github.com/opentensor/btcli/pull/386
* Code Cleanup by @thewhaleking in https://github.com/opentensor/btcli/pull/381
* Adds rate-tolerance alias by @ibraheem-opentensor in https://github.com/opentensor/btcli/pull/387

**Full Changelog**: https://github.com/opentensor/btcli/compare/v9.1.3...v9.1.4

## 9.1.3 /2025-03-12

## What's Changed
Expand Down
40 changes: 22 additions & 18 deletions bittensor_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
WalletOptions as WO,
WalletValidationTypes as WV,
Constants,
COLOR_PALETTE,
COLORS,
HYPERPARAMS,
)
from bittensor_cli.version import __version__, __version_as_int__
Expand Down Expand Up @@ -241,6 +241,7 @@ class Options:
"--slippage",
"--slippage-tolerance",
"--tolerance",
"--rate-tolerance",
help="Set the rate tolerance percentage for transactions (default: 0.05%).",
callback=validate_rate_tolerance,
)
Expand Down Expand Up @@ -341,8 +342,8 @@ def get_optional_netuid(netuid: Optional[int], all_netuids: bool) -> Optional[in
return None
elif netuid is None and all_netuids is False:
answer = Prompt.ask(
f"Enter the [{COLOR_PALETTE['GENERAL']['SUBHEADING_MAIN']}]netuid"
f"[/{COLOR_PALETTE['GENERAL']['SUBHEADING_MAIN']}] to use. Leave blank for all netuids",
f"Enter the [{COLORS.G.SUBHEAD_MAIN}]netuid"
f"[/{COLORS.G.SUBHEAD_MAIN}] to use. Leave blank for all netuids",
default=None,
show_default=False,
)
Expand Down Expand Up @@ -950,7 +951,8 @@ def initialize_chain(
elif self.config["network"]:
self.subtensor = SubtensorInterface(self.config["network"])
console.print(
f"Using the specified network [{COLOR_PALETTE['GENERAL']['LINKS']}]{self.config['network']}[/{COLOR_PALETTE['GENERAL']['LINKS']}] from config"
f"Using the specified network [{COLORS.G.LINKS}]{self.config['network']}"
f"[/{COLORS.G.LINKS}] from config"
)
else:
self.subtensor = SubtensorInterface(defaults.subtensor.network)
Expand Down Expand Up @@ -1523,7 +1525,7 @@ def wallet_ask(
else:
wallet_name = Prompt.ask(
"Enter the [blue]wallet name[/blue]"
+ f" [{COLOR_PALETTE['GENERAL']['HINT']} italic](Hint: You can set this with `btcli config set --wallet-name`)",
+ f" [{COLORS.G.HINT} italic](Hint: You can set this with `btcli config set --wallet-name`)",
default=defaults.wallet.name,
)

Expand Down Expand Up @@ -2049,7 +2051,7 @@ def wallet_regen_coldkey(

if not wallet_name:
wallet_name = Prompt.ask(
f"Enter the name of the [{COLOR_PALETTE['GENERAL']['COLDKEY']}]new wallet (coldkey)",
f"Enter the name of the [{COLORS.G.CK}]new wallet (coldkey)",
default=defaults.wallet.name,
)

Expand Down Expand Up @@ -2106,7 +2108,7 @@ def wallet_regen_coldkey_pub(

if not wallet_name:
wallet_name = Prompt.ask(
f"Enter the name of the [{COLOR_PALETTE['GENERAL']['COLDKEY']}]new wallet (coldkey)",
f"Enter the name of the [{COLORS.G.CK}]new wallet (coldkey)",
default=defaults.wallet.name,
)
wallet = Wallet(wallet_name, wallet_hotkey, wallet_path)
Expand Down Expand Up @@ -2223,13 +2225,13 @@ def wallet_new_hotkey(

if not wallet_name:
wallet_name = Prompt.ask(
f"Enter the [{COLOR_PALETTE['GENERAL']['COLDKEY']}]wallet name",
f"Enter the [{COLORS.G.CK}]wallet name",
default=defaults.wallet.name,
)

if not wallet_hotkey:
wallet_hotkey = Prompt.ask(
f"Enter the name of the [{COLOR_PALETTE['GENERAL']['HOTKEY']}]new hotkey",
f"Enter the name of the [{COLORS.G.HK}]new hotkey",
default=defaults.wallet.hotkey,
)

Expand Down Expand Up @@ -2285,7 +2287,7 @@ def wallet_new_coldkey(

if not wallet_name:
wallet_name = Prompt.ask(
f"Enter the name of the [{COLOR_PALETTE['GENERAL']['COLDKEY']}]new wallet (coldkey)",
f"Enter the name of the [{COLORS.G.CK}]new wallet (coldkey)",
default=defaults.wallet.name,
)

Expand Down Expand Up @@ -2359,12 +2361,12 @@ def wallet_create_wallet(

if not wallet_name:
wallet_name = Prompt.ask(
f"Enter the name of the [{COLOR_PALETTE['GENERAL']['COLDKEY']}]new wallet (coldkey)",
f"Enter the name of the [{COLORS.G.CK}]new wallet (coldkey)",
default=defaults.wallet.name,
)
if not wallet_hotkey:
wallet_hotkey = Prompt.ask(
f"Enter the the name of the [{COLOR_PALETTE['GENERAL']['HOTKEY']}]new hotkey",
f"Enter the the name of the [{COLORS.G.HK}]new hotkey",
default=defaults.wallet.hotkey,
)

Expand Down Expand Up @@ -2742,9 +2744,10 @@ def wallet_sign(
self.verbosity_handler(quiet, verbose)
if use_hotkey is None:
use_hotkey = Confirm.ask(
f"Would you like to sign the transaction using your [{COLOR_PALETTE['GENERAL']['HOTKEY']}]hotkey[/{COLOR_PALETTE['GENERAL']['HOTKEY']}]?"
f"\n[Type [{COLOR_PALETTE['GENERAL']['HOTKEY']}]y[/{COLOR_PALETTE['GENERAL']['HOTKEY']}] for [{COLOR_PALETTE['GENERAL']['HOTKEY']}]hotkey[/{COLOR_PALETTE['GENERAL']['HOTKEY']}]"
f" and [{COLOR_PALETTE['GENERAL']['COLDKEY']}]n[/{COLOR_PALETTE['GENERAL']['COLDKEY']}] for [{COLOR_PALETTE['GENERAL']['COLDKEY']}]coldkey[/{COLOR_PALETTE['GENERAL']['COLDKEY']}]] (default is [{COLOR_PALETTE['GENERAL']['COLDKEY']}]coldkey[/{COLOR_PALETTE['GENERAL']['COLDKEY']}])",
f"Would you like to sign the transaction using your [{COLORS.G.HK}]hotkey[/{COLORS.G.HK}]?"
f"\n[Type [{COLORS.G.HK}]y[/{COLORS.G.HK}] for [{COLORS.G.HK}]hotkey[/{COLORS.G.HK}]"
f" and [{COLORS.G.CK}]n[/{COLORS.G.CK}] for [{COLORS.G.CK}]coldkey[/{COLORS.G.CK}]] "
f"(default is [{COLORS.G.CK}]coldkey[/{COLORS.G.CK}])",
default=False,
)

Expand Down Expand Up @@ -3035,11 +3038,11 @@ def stake_add(
raise typer.Exit()
if netuid is not None:
amount = FloatPrompt.ask(
f"Amount to [{COLOR_PALETTE['GENERAL']['SUBHEADING_MAIN']}]stake (TAO τ)"
f"Amount to [{COLORS.G.SUBHEAD_MAIN}]stake (TAO τ)"
)
else:
amount = FloatPrompt.ask(
f"Amount to [{COLOR_PALETTE['GENERAL']['SUBHEADING_MAIN']}]stake to each netuid (TAO τ)"
f"Amount to [{COLORS.G.SUBHEAD_MAIN}]stake to each netuid (TAO τ)"
)

if amount <= 0:
Expand Down Expand Up @@ -4112,7 +4115,8 @@ def sudo_set(
if not param_value:
if HYPERPARAMS.get(param_name):
param_value = Prompt.ask(
f"Enter the new value for [{COLOR_PALETTE['GENERAL']['SUBHEADING']}]{param_name}[/{COLOR_PALETTE['GENERAL']['SUBHEADING']}] in the VALUE column format"
f"Enter the new value for [{COLORS.G.SUBHEAD}]{param_name}[/{COLORS.G.SUBHEAD}] "
f"in the VALUE column format"
)
else:
param_value = None
Expand Down
163 changes: 105 additions & 58 deletions bittensor_cli/src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,64 +721,111 @@ class WalletValidationTypes(Enum):
},
}

COLOR_PALETTE = {
"GENERAL": {
"HEADER": "#4196D6", # Light Blue
"LINKS": "#8CB9E9", # Sky Blue
"HINT": "#A2E5B8", # Mint Green
"COLDKEY": "#9EF5E4", # Aqua
"HOTKEY": "#ECC39D", # Light Orange/Peach
"SUBHEADING_MAIN": "#7ECFEC", # Light Cyan
"SUBHEADING": "#AFEFFF", # Pale Blue
"SUBHEADING_EXTRA_1": "#96A3C5", # Grayish Blue
"SUBHEADING_EXTRA_2": "#6D7BAF", # Slate Blue
"CONFIRMATION_Y_N_Q": "#EE8DF8", # Light Purple/Pink
"SYMBOL": "#E7CC51", # Gold
"BALANCE": "#4F91C6", # Medium Blue
"COST": "#53B5A0", # Teal
"SUCCESS": "#53B5A0", # Teal
"NETUID": "#CBA880", # Tan
"NETUID_EXTRA": "#DDD5A9", # Light Khaki
"TEMPO": "#67A3A5", # Grayish Teal
},
"STAKE": {
"STAKE_AMOUNT": "#53B5A0", # Teal
"STAKE_ALPHA": "#53B5A0", # Teal
"STAKE_SWAP": "#67A3A5", # Grayish Teal
"TAO": "#4F91C6", # Medium Blue
"SLIPPAGE_TEXT": "#C25E7C", # Rose
"SLIPPAGE_PERCENT": "#E7B195", # Light Coral
"NOT_REGISTERED": "#EB6A6C", # Salmon Red
"EXTRA_1": "#D781BB", # Pink
},
"POOLS": {
"TAO": "#4F91C6", # Medium Blue
"ALPHA_IN": "#D09FE9", # Light Purple
"ALPHA_OUT": "#AB7CC8", # Medium Purple
"RATE": "#F8D384", # Light Orange
"TAO_EQUIV": "#8CB9E9", # Sky Blue
"EMISSION": "#F8D384", # Light Orange
"EXTRA_1": "#CAA8FB", # Lavender
"EXTRA_2": "#806DAF", # Dark Purple
},
"GREY": {
"GREY_100": "#F8F9FA", # Almost White
"GREY_200": "#F1F3F4", # Very Light Grey
"GREY_300": "#DBDDE1", # Light Grey
"GREY_400": "#BDC1C6", # Medium Light Grey
"GREY_500": "#5F6368", # Medium Grey
"GREY_600": "#2E3134", # Medium Dark Grey
"GREY_700": "#282A2D", # Dark Grey
"GREY_800": "#17181B", # Very Dark Grey
"GREY_900": "#0E1013", # Almost Black
"BLACK": "#000000", # Pure Black
},
"SUDO": {
"HYPERPARAMETER": "#4F91C6", # Medium Blue
"VALUE": "#D09FE9", # Light Purple
"NORMALIZED": "#AB7CC8", # Medium Purple
},
}

class Gettable:
def __getitem__(self, item):
return getattr(self, item)


class ColorPalette(Gettable):
def __init__(self):
self.GENERAL = self.General()
self.STAKE = self.Stake()
self.POOLS = self.Pools()
self.GREY = self.Grey()
self.SUDO = self.Sudo()
# aliases
self.G = self.GENERAL
self.S = self.STAKE
self.P = self.POOLS
self.GR = self.GREY
self.SU = self.SUDO

class General(Gettable):
HEADER = "#4196D6" # Light Blue
LINKS = "#8CB9E9" # Sky Blue
HINT = "#A2E5B8" # Mint Green
COLDKEY = "#9EF5E4" # Aqua
HOTKEY = "#ECC39D" # Light Orange/Peach
SUBHEADING_MAIN = "#7ECFEC" # Light Cyan
SUBHEADING = "#AFEFFF" # Pale Blue
SUBHEADING_EXTRA_1 = "#96A3C5" # Grayish Blue
SUBHEADING_EXTRA_2 = "#6D7BAF" # Slate Blue
CONFIRMATION_Y_N_Q = "#EE8DF8" # Light Purple/Pink
SYMBOL = "#E7CC51" # Gold
BALANCE = "#4F91C6" # Medium Blue
COST = "#53B5A0" # Teal
SUCCESS = "#53B5A0" # Teal
NETUID = "#CBA880" # Tan
NETUID_EXTRA = "#DDD5A9" # Light Khaki
TEMPO = "#67A3A5" # Grayish Teal
# aliases
CK = COLDKEY
HK = HOTKEY
SUBHEAD_MAIN = SUBHEADING_MAIN
SUBHEAD = SUBHEADING
SUBHEAD_EX_1 = SUBHEADING_EXTRA_1
SUBHEAD_EX_2 = SUBHEADING_EXTRA_2
SYM = SYMBOL
BAL = BALANCE

class Stake(Gettable):
STAKE_AMOUNT = "#53B5A0" # Teal
STAKE_ALPHA = "#53B5A0" # Teal
STAKE_SWAP = "#67A3A5" # Grayish Teal
TAO = "#4F91C6" # Medium Blue
SLIPPAGE_TEXT = "#C25E7C" # Rose
SLIPPAGE_PERCENT = "#E7B195" # Light Coral
NOT_REGISTERED = "#EB6A6C" # Salmon Red
EXTRA_1 = "#D781BB" # Pink
# aliases
AMOUNT = STAKE_AMOUNT
ALPHA = STAKE_ALPHA
SWAP = STAKE_SWAP

class Pools(Gettable):
TAO = "#4F91C6" # Medium Blue
ALPHA_IN = "#D09FE9" # Light Purple
ALPHA_OUT = "#AB7CC8" # Medium Purple
RATE = "#F8D384" # Light Orange
TAO_EQUIV = "#8CB9E9" # Sky Blue
EMISSION = "#F8D384" # Light Orange
EXTRA_1 = "#CAA8FB" # Lavender
EXTRA_2 = "#806DAF" # Dark Purple

class Grey(Gettable):
GREY_100 = "#F8F9FA" # Almost White
GREY_200 = "#F1F3F4" # Very Light Grey
GREY_300 = "#DBDDE1" # Light Grey
GREY_400 = "#BDC1C6" # Medium Light Grey
GREY_500 = "#5F6368" # Medium Grey
GREY_600 = "#2E3134" # Medium Dark Grey
GREY_700 = "#282A2D" # Dark Grey
GREY_800 = "#17181B" # Very Dark Grey
GREY_900 = "#0E1013" # Almost Black
BLACK = "#000000" # Pure Black
# aliases
G_100 = GREY_100
G_200 = GREY_200
G_300 = GREY_300
G_400 = GREY_400
G_500 = GREY_500
G_600 = GREY_600
G_700 = GREY_700
G_800 = GREY_800
G_900 = GREY_900

class Sudo(Gettable):
HYPERPARAMETER = "#4F91C6" # Medium Blue
VALUE = "#D09FE9" # Light Purple
NORMALIZED = "#AB7CC8" # Medium Purple
# aliases
HYPERPARAM = HYPERPARAMETER
NORMAL = NORMALIZED


COLOR_PALETTE = ColorPalette()
COLORS = COLOR_PALETTE


SUBNETS = {
Expand Down
4 changes: 3 additions & 1 deletion bittensor_cli/src/bittensor/chain_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,9 @@ def tao_to_alpha(self, tao: Balance) -> Balance:
def alpha_to_tao(self, alpha: Balance) -> Balance:
return Balance.from_tao(alpha.tao * self.price.tao)

def tao_to_alpha_with_slippage(self, tao: Balance) -> tuple[Balance, Balance]:
def tao_to_alpha_with_slippage(
self, tao: Balance
) -> tuple[Balance, Balance, float]:
"""
Returns an estimate of how much Alpha would a staker receive if they stake their tao using the current pool state.
Args:
Expand Down
Loading
Loading