Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 27 additions & 4 deletions bittensor_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2340,7 +2340,7 @@ def wallet_set_id(
"--image",
help="The image URL for the identity.",
),
discord_handle: str = typer.Option(
discord: str = typer.Option(
"",
"--discord",
help="The Discord handle for the identity.",
Expand All @@ -2350,11 +2350,16 @@ def wallet_set_id(
"--description",
help="The description for the identity.",
),
additional_info: str = typer.Option(
additional: str = typer.Option(
"",
"--additional",
help="Additional details for the identity.",
),
github_repo: str = typer.Option(
"",
"--github",
help="The GitHub repository for the identity.",
),
quiet: bool = Options.quiet,
verbose: bool = Options.verbose,
prompt: bool = Options.prompt,
Expand Down Expand Up @@ -2407,9 +2412,10 @@ def wallet_set_id(
name,
web_url,
image_url,
discord_handle,
discord,
description,
additional_info,
additional,
github_repo,
)

return self._run_command(
Expand All @@ -2422,6 +2428,7 @@ def wallet_set_id(
identity["discord"],
identity["description"],
identity["additional"],
identity["github_repo"],
prompt,
)
)
Expand Down Expand Up @@ -4103,6 +4110,18 @@ def subnets_create(
"--email",
help="Contact email for subnet",
),
subnet_url: Optional[str] = typer.Option(
None, "--subnet-url", "--url", help="Subnet URL"
),
discord: Optional[str] = typer.Option(
None, "--discord-handle", "--discord", help="Discord handle"
),
description: Optional[str] = typer.Option(
None, "--description", help="Description"
),
additional_info: Optional[str] = typer.Option(
None, "--additional-info", help="Additional information"
),
prompt: bool = Options.prompt,
quiet: bool = Options.quiet,
verbose: bool = Options.verbose,
Expand Down Expand Up @@ -4130,6 +4149,10 @@ def subnets_create(
subnet_name=subnet_name,
github_repo=github_repo,
subnet_contact=subnet_contact,
subnet_url=subnet_url,
discord=discord,
description=description,
additional=additional_info,
)
success = self._run_command(
subnets.create(wallet, self.initialize_chain(network), identity, prompt),
Expand Down
12 changes: 10 additions & 2 deletions bittensor_cli/src/bittensor/chain_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def _fix_decoded(
max_validators=decoded.get("max_validators"),
adjustment_alpha=decoded.get("adjustment_alpha"),
difficulty=decoded.get("difficulty"),
commit_reveal_period=decoded.get("commit_reveal_weights_interval"),
commit_reveal_period=decoded.get("commit_reveal_period"),
commit_reveal_weights_enabled=decoded.get("commit_reveal_weights_enabled"),
alpha_high=decoded.get("alpha_high"),
alpha_low=decoded.get("alpha_low"),
Expand Down Expand Up @@ -574,7 +574,7 @@ def _fix_decoded(cls, decoded: "SubnetInfo") -> "SubnetInfo":
str(int(netuid)): u16_normalized_float(int(req))
for (netuid, req) in decoded.get("network_connect")
},
emission_value=decoded.get("emission_values"),
emission_value=decoded.get("emission_value"),
burn=Balance.from_rao(decoded.get("burn")),
owner_ss58=decode_account_id(decoded.get("owner")),
)
Expand All @@ -587,13 +587,21 @@ class SubnetIdentity(InfoBase):
subnet_name: str
github_repo: str
subnet_contact: str
subnet_url: str
discord: str
description: str
additional: str

@classmethod
def _fix_decoded(cls, decoded: dict) -> "SubnetIdentity":
return SubnetIdentity(
subnet_name=bytes(decoded["subnet_name"]).decode(),
github_repo=bytes(decoded["github_repo"]).decode(),
subnet_contact=bytes(decoded["subnet_contact"]).decode(),
subnet_url=bytes(decoded["subnet_url"]).decode(),
discord=bytes(decoded["discord"]).decode(),
description=bytes(decoded["description"]).decode(),
additional=bytes(decoded["additional"]).decode(),
)


Expand Down
4 changes: 2 additions & 2 deletions bittensor_cli/src/bittensor/subtensor_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ async def query_all_identities(

identities = await self.substrate.query_map(
module="SubtensorModule",
storage_function="Identities",
storage_function="IdentitiesV2",
block_hash=block_hash,
reuse_block_hash=reuse_block,
)
Expand Down Expand Up @@ -877,7 +877,7 @@ async def query_identity(
"""
identity_info = await self.query(
module="SubtensorModule",
storage_function="Identities",
storage_function="IdentitiesV2",
params=[key],
block_hash=block_hash,
reuse_block_hash=reuse_block,
Expand Down
47 changes: 41 additions & 6 deletions bittensor_cli/src/bittensor/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,9 +1039,10 @@ def prompt_for_identity(
name: Optional[str],
web_url: Optional[str],
image_url: Optional[str],
discord_handle: Optional[str],
discord: Optional[str],
description: Optional[str],
additional_info: Optional[str],
additional: Optional[str],
github_repo: Optional[str],
):
"""
Prompts the user for identity fields with validation.
Expand All @@ -1053,9 +1054,10 @@ def prompt_for_identity(
("name", "[blue]Display name[/blue]", name),
("url", "[blue]Web URL[/blue]", web_url),
("image", "[blue]Image URL[/blue]", image_url),
("discord", "[blue]Discord handle[/blue]", discord_handle),
("discord", "[blue]Discord handle[/blue]", discord),
("description", "[blue]Description[/blue]", description),
("additional", "[blue]Additional information[/blue]", additional_info),
("additional", "[blue]Additional information[/blue]", additional),
("github_repo", "[blue]GitHub repository URL[/blue]", github_repo),
]

text_rejection = partial(
Expand All @@ -1069,9 +1071,10 @@ def prompt_for_identity(
name,
web_url,
image_url,
discord_handle,
discord,
description,
additional_info,
additional,
github_repo,
]
):
console.print(
Expand All @@ -1096,6 +1099,10 @@ def prompt_for_subnet_identity(
subnet_name: Optional[str],
github_repo: Optional[str],
subnet_contact: Optional[str],
subnet_url: Optional[str],
discord: Optional[str],
description: Optional[str],
additional: Optional[str],
):
"""
Prompts the user for required subnet identity fields with validation.
Expand Down Expand Up @@ -1133,6 +1140,34 @@ def prompt_for_subnet_identity(
lambda x: x and not is_valid_contact(x),
"[red]Error:[/red] Please enter a valid email address.",
),
(
"subnet_url",
"[blue]Subnet URL [dim](optional)[/blue]",
subnet_url,
lambda x: x and sys.getsizeof(x) > 113,
"[red]Error:[/red] Please enter a valid URL.",
),
(
"discord",
"[blue]Discord handle [dim](optional)[/blue]",
discord,
lambda x: x and sys.getsizeof(x) > 113,
"[red]Error:[/red] Please enter a valid Discord handle.",
),
(
"description",
"[blue]Description [dim](optional)[/blue]",
description,
lambda x: x and sys.getsizeof(x) > 113,
"[red]Error:[/red] Description must be <= 64 raw bytes.",
),
(
"additional",
"[blue]Additional information [dim](optional)[/blue]",
additional,
lambda x: x and sys.getsizeof(x) > 113,
"[red]Error:[/red] Additional information must be <= 64 raw bytes.",
),
]

for key, prompt, value, rejection_func, rejection_msg in fields:
Expand Down
18 changes: 16 additions & 2 deletions bittensor_cli/src/commands/subnets/subnets.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@ async def _find_event_attributes_in_extrinsic_receipt(
"subnet_contact": subnet_identity["subnet_contact"].encode()
if subnet_identity.get("subnet_contact")
else b"",
"subnet_url": subnet_identity["subnet_url"].encode()
if subnet_identity.get("subnet_url")
else b"",
"discord": subnet_identity["discord"].encode()
if subnet_identity.get("discord")
else b"",
"description": subnet_identity["description"].encode()
if subnet_identity.get("description")
else b"",
"additional": subnet_identity["additional"].encode()
if subnet_identity.get("additional")
else b"",
}
for field, value in identity_data.items():
max_size = 64 # bytes
Expand Down Expand Up @@ -1391,9 +1403,10 @@ async def create(
name=None,
web_url=None,
image_url=None,
discord_handle=None,
discord=None,
description=None,
additional_info=None,
additional=None,
github_repo=None,
)

await set_id(
Expand All @@ -1405,6 +1418,7 @@ async def create(
identity["discord"],
identity["description"],
identity["additional"],
identity["github_repo"],
prompt,
)

Expand Down
10 changes: 6 additions & 4 deletions bittensor_cli/src/commands/wallets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1296,9 +1296,10 @@ async def set_id(
name: str,
web_url: str,
image_url: str,
discord_handle: str,
discord: str,
description: str,
additional_info: str,
additional: str,
github_repo: str,
prompt: bool,
):
"""Create a new or update existing identity on-chain."""
Expand All @@ -1307,9 +1308,10 @@ async def set_id(
"name": name.encode(),
"url": web_url.encode(),
"image": image_url.encode(),
"discord": discord_handle.encode(),
"discord": discord.encode(),
"description": description.encode(),
"additional": additional_info.encode(),
"additional": additional.encode(),
"github_repo": github_repo.encode(),
}

for field, value in identity_data.items():
Expand Down
2 changes: 1 addition & 1 deletion bittensor_cli/src/commands/weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ async def _commit_reveal(
) -> tuple[bool, str]:
interval = int(
await self.subtensor.get_hyperparameter(
param_name="get_commit_reveal_weights_interval",
param_name="get_commit_reveal_period",
netuid=self.netuid,
reuse_block=False,
)
Expand Down