bittensor-cli 9.1.1__py3-none-any.whl → 9.1.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
bittensor_cli/cli.py CHANGED
@@ -2682,23 +2682,29 @@ class CLIManager:
2682
2682
  [bold]Note[/bold]: This command is primarily used for informational purposes and has no side effects on the blockchain network state.
2683
2683
  """
2684
2684
  wallet = None
2685
- if coldkey_ss58:
2686
- if not is_valid_ss58_address(coldkey_ss58):
2687
- print_error("You entered an invalid ss58 address")
2688
- raise typer.Exit()
2689
- else:
2690
- coldkey_or_ss58 = Prompt.ask(
2691
- "Enter the [blue]wallet name[/blue] or [blue]coldkey ss58 address[/blue]",
2692
- default=self.config.get("wallet_name") or defaults.wallet.name,
2693
- )
2694
- if is_valid_ss58_address(coldkey_or_ss58):
2695
- coldkey_ss58 = coldkey_or_ss58
2685
+ if not wallet_name:
2686
+ if coldkey_ss58:
2687
+ if not is_valid_ss58_address(coldkey_ss58):
2688
+ print_error("You entered an invalid ss58 address")
2689
+ raise typer.Exit()
2696
2690
  else:
2697
- wallet_name = coldkey_or_ss58 if coldkey_or_ss58 else wallet_name
2698
- wallet = self.wallet_ask(
2699
- wallet_name, wallet_path, wallet_hotkey, ask_for=[WO.NAME]
2691
+ coldkey_or_ss58 = Prompt.ask(
2692
+ "Enter the [blue]wallet name[/blue] or [blue]coldkey ss58 address[/blue]",
2693
+ default=self.config.get("wallet_name") or defaults.wallet.name,
2700
2694
  )
2701
- coldkey_ss58 = wallet.coldkeypub.ss58_address
2695
+ if is_valid_ss58_address(coldkey_or_ss58):
2696
+ coldkey_ss58 = coldkey_or_ss58
2697
+ else:
2698
+ wallet_name = coldkey_or_ss58 if coldkey_or_ss58 else wallet_name
2699
+ wallet = self.wallet_ask(
2700
+ wallet_name, wallet_path, wallet_hotkey, ask_for=[WO.NAME]
2701
+ )
2702
+ coldkey_ss58 = wallet.coldkeypub.ss58_address
2703
+ else:
2704
+ wallet = self.wallet_ask(
2705
+ wallet_name, wallet_path, wallet_hotkey, ask_for=[WO.NAME]
2706
+ )
2707
+ coldkey_ss58 = wallet.coldkeypub.ss58_address
2702
2708
 
2703
2709
  self.verbosity_handler(quiet, verbose)
2704
2710
  return self._run_command(
@@ -1097,38 +1097,30 @@ def prompt_for_identity(
1097
1097
  identity_fields = {}
1098
1098
 
1099
1099
  fields = [
1100
- ("name", "[blue]Display name[/blue]", name),
1101
- ("url", "[blue]Web URL[/blue]", web_url),
1102
- ("image", "[blue]Image URL[/blue]", image_url),
1103
- ("discord", "[blue]Discord handle[/blue]", discord),
1104
- ("description", "[blue]Description[/blue]", description),
1105
- ("additional", "[blue]Additional information[/blue]", additional),
1106
- ("github_repo", "[blue]GitHub repository URL[/blue]", github_repo),
1100
+ ("name", "[blue]Display name[/blue]", name, 256),
1101
+ ("url", "[blue]Web URL[/blue]", web_url, 256),
1102
+ ("image", "[blue]Image URL[/blue]", image_url, 1024),
1103
+ ("discord", "[blue]Discord handle[/blue]", discord, 256),
1104
+ ("description", "[blue]Description[/blue]", description, 1024),
1105
+ ("additional", "[blue]Additional information[/blue]", additional, 1024),
1106
+ ("github_repo", "[blue]GitHub repository URL[/blue]", github_repo, 256),
1107
1107
  ]
1108
1108
 
1109
- text_rejection = partial(
1110
- retry_prompt,
1111
- rejection=lambda x: sys.getsizeof(x) > 113,
1112
- rejection_text="[red]Error:[/red] Identity field must be <= 64 raw bytes.",
1113
- )
1114
-
1115
1109
  if not any(
1116
- [
1117
- name,
1118
- web_url,
1119
- image_url,
1120
- discord,
1121
- description,
1122
- additional,
1123
- github_repo,
1124
- ]
1110
+ [name, web_url, image_url, discord, description, additional, github_repo]
1125
1111
  ):
1126
1112
  console.print(
1127
1113
  "\n[yellow]All fields are optional. Press Enter to skip and keep the default/existing value.[/yellow]\n"
1128
1114
  "[dark_sea_green3]Tip: Entering a space and pressing Enter will clear existing default value.\n"
1129
1115
  )
1130
1116
 
1131
- for key, prompt, value in fields:
1117
+ for key, prompt, value, byte_limit in fields:
1118
+ text_rejection = partial(
1119
+ retry_prompt,
1120
+ rejection=lambda x: len(x.encode("utf-8")) > byte_limit,
1121
+ rejection_text=f"[red]Error:[/red] {key} field must be <= {byte_limit} bytes.",
1122
+ )
1123
+
1132
1124
  if value:
1133
1125
  identity_fields[key] = value
1134
1126
  else:
@@ -1170,50 +1162,51 @@ def prompt_for_subnet_identity(
1170
1162
  "subnet_name",
1171
1163
  "[blue]Subnet name [dim](optional)[/blue]",
1172
1164
  subnet_name,
1173
- lambda x: x and sys.getsizeof(x) > 113,
1174
- "[red]Error:[/red] Subnet name must be <= 64 raw bytes.",
1165
+ lambda x: x and len(x.encode("utf-8")) > 256,
1166
+ "[red]Error:[/red] Subnet name must be <= 256 bytes.",
1175
1167
  ),
1176
1168
  (
1177
1169
  "github_repo",
1178
1170
  "[blue]GitHub repository URL [dim](optional)[/blue]",
1179
1171
  github_repo,
1180
- lambda x: x and not is_valid_github_url(x),
1172
+ lambda x: x
1173
+ and (not is_valid_github_url(x) or len(x.encode("utf-8")) > 1024),
1181
1174
  "[red]Error:[/red] Please enter a valid GitHub repository URL (e.g., https://github.com/username/repo).",
1182
1175
  ),
1183
1176
  (
1184
1177
  "subnet_contact",
1185
1178
  "[blue]Contact email [dim](optional)[/blue]",
1186
1179
  subnet_contact,
1187
- lambda x: x and not is_valid_contact(x),
1180
+ lambda x: x and (not is_valid_contact(x) or len(x.encode("utf-8")) > 1024),
1188
1181
  "[red]Error:[/red] Please enter a valid email address.",
1189
1182
  ),
1190
1183
  (
1191
1184
  "subnet_url",
1192
1185
  "[blue]Subnet URL [dim](optional)[/blue]",
1193
1186
  subnet_url,
1194
- lambda x: x and sys.getsizeof(x) > 113,
1195
- "[red]Error:[/red] Please enter a valid URL.",
1187
+ lambda x: x and len(x.encode("utf-8")) > 1024,
1188
+ "[red]Error:[/red] Please enter a valid URL <= 1024 bytes.",
1196
1189
  ),
1197
1190
  (
1198
1191
  "discord",
1199
1192
  "[blue]Discord handle [dim](optional)[/blue]",
1200
1193
  discord,
1201
- lambda x: x and sys.getsizeof(x) > 113,
1202
- "[red]Error:[/red] Please enter a valid Discord handle.",
1194
+ lambda x: x and len(x.encode("utf-8")) > 256,
1195
+ "[red]Error:[/red] Please enter a valid Discord handle <= 256 bytes.",
1203
1196
  ),
1204
1197
  (
1205
1198
  "description",
1206
1199
  "[blue]Description [dim](optional)[/blue]",
1207
1200
  description,
1208
- lambda x: x and sys.getsizeof(x) > 113,
1209
- "[red]Error:[/red] Description must be <= 64 raw bytes.",
1201
+ lambda x: x and len(x.encode("utf-8")) > 1024,
1202
+ "[red]Error:[/red] Description must be <= 1024 bytes.",
1210
1203
  ),
1211
1204
  (
1212
1205
  "additional",
1213
1206
  "[blue]Additional information [dim](optional)[/blue]",
1214
1207
  additional,
1215
- lambda x: x and sys.getsizeof(x) > 113,
1216
- "[red]Error:[/red] Additional information must be <= 64 raw bytes.",
1208
+ lambda x: x and len(x.encode("utf-8")) > 1024,
1209
+ "[red]Error:[/red] Additional information must be <= 1024 bytes.",
1217
1210
  ),
1218
1211
  ]
1219
1212
 
@@ -1273,16 +1266,18 @@ def is_valid_contact(contact: str) -> bool:
1273
1266
  return bool(re.match(email_pattern, contact))
1274
1267
 
1275
1268
 
1276
- def get_subnet_name(subnet_info) -> str:
1269
+ def get_subnet_name(subnet_info, max_length: int = 20) -> str:
1277
1270
  """Get the subnet name, prioritizing subnet_identity.subnet_name over subnet.subnet_name.
1271
+ Truncates the name if it exceeds max_length.
1278
1272
 
1279
1273
  Args:
1280
- subnet: The subnet dynamic info
1274
+ subnet_info: The subnet dynamic info
1275
+ max_length: Maximum length of the returned name. Names longer than this will be truncated with '...'
1281
1276
 
1282
1277
  Returns:
1283
- str: The subnet name or empty string if no name is found
1278
+ str: The subnet name (truncated if necessary) or empty string if no name is found
1284
1279
  """
1285
- return (
1280
+ name = (
1286
1281
  subnet_info.subnet_identity.subnet_name
1287
1282
  if hasattr(subnet_info, "subnet_identity")
1288
1283
  and subnet_info.subnet_identity is not None
@@ -1290,6 +1285,10 @@ def get_subnet_name(subnet_info) -> str:
1290
1285
  else (subnet_info.subnet_name if subnet_info.subnet_name is not None else "")
1291
1286
  )
1292
1287
 
1288
+ if len(name) > max_length:
1289
+ return name[: max_length - 3] + "..."
1290
+ return name
1291
+
1293
1292
 
1294
1293
  def print_linux_dependency_message():
1295
1294
  """Prints the WebKit dependency message for Linux systems."""
@@ -190,7 +190,7 @@ async def set_childkey_take_extrinsic(
190
190
  f":satellite: Setting childkey take on [white]{subtensor.network}[/white] ..."
191
191
  ):
192
192
  try:
193
- if 0 < take <= 0.18:
193
+ if 0 <= take <= 0.18:
194
194
  take_u16 = float_to_u16(take)
195
195
  else:
196
196
  return False, "Invalid take value"
@@ -1417,6 +1417,7 @@ async def pow_register(
1417
1417
  use_cuda,
1418
1418
  dev_id,
1419
1419
  threads_per_block,
1420
+ prompt: bool
1420
1421
  ):
1421
1422
  """Register neuron."""
1422
1423
 
@@ -1424,7 +1425,7 @@ async def pow_register(
1424
1425
  subtensor,
1425
1426
  wallet=wallet,
1426
1427
  netuid=netuid,
1427
- prompt=True,
1428
+ prompt=prompt,
1428
1429
  tpb=threads_per_block,
1429
1430
  update_interval=update_interval,
1430
1431
  num_processes=processors,
@@ -1361,15 +1361,6 @@ async def set_id(
1361
1361
  "github_repo": github_repo.encode(),
1362
1362
  }
1363
1363
 
1364
- for field, value in identity_data.items():
1365
- max_size = 64 # bytes
1366
- if len(value) > max_size:
1367
- err_console.print(
1368
- f"[red]Error:[/red] Identity field [white]{field}[/white] must be <= {max_size} bytes.\n"
1369
- f"Value '{value.decode()}' is {len(value)} bytes."
1370
- )
1371
- return False
1372
-
1373
1364
  if not unlock_key(wallet).success:
1374
1365
  return False
1375
1366
 
bittensor_cli/version.py CHANGED
@@ -15,5 +15,6 @@ def version_as_int(version):
15
15
  __new_signature_version__ = 360
16
16
  return __version_as_int__
17
17
 
18
- __version__ = "9.1.1"
18
+
19
+ __version__ = "9.1.3"
19
20
  __version_as_int__ = version_as_int(__version__)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bittensor-cli
3
- Version: 9.1.1
3
+ Version: 9.1.3
4
4
  Summary: Bittensor CLI
5
5
  Author: bittensor.com
6
6
  Project-URL: homepage, https://github.com/opentensor/btcli
@@ -1,7 +1,7 @@
1
1
  bittensor_cli/__init__.py,sha256=Lpv4NkbAQgwrfqFOnTMuR_S-fqGdaWCSLhxnFnGTHM0,1232
2
- bittensor_cli/cli.py,sha256=O-OpylnZz8hlksmbVaQExMFxEIdKZUSQx_chmcupkak,198158
2
+ bittensor_cli/cli.py,sha256=b74SuigzFMoGItVfdkpWoIOktTBLx1ALc-oHb7nprvs,198453
3
3
  bittensor_cli/doc_generation_helper.py,sha256=GexqjEIKulWg84hpNBEchJ840oOgOi7DWpt447nsdNI,91
4
- bittensor_cli/version.py,sha256=DiUmF2Gu0FJ5u1e-0Hyps6GtiaQqWVV6FaxHg1CUylo,622
4
+ bittensor_cli/version.py,sha256=rEVJnYbpsCLoerFYGs5hlQWusewL7n5JfAa3G1B_BeQ,623
5
5
  bittensor_cli/src/__init__.py,sha256=9JLmK4Z-auboWXX74sMkJiFSvcjw3jcRUUw5lRRABy8,26553
6
6
  bittensor_cli/src/bittensor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  bittensor_cli/src/bittensor/balances.py,sha256=q5KkxF8wmUguWAFddEKstfDKTxPe5ISHpT6br8x32rc,11148
@@ -9,7 +9,7 @@ bittensor_cli/src/bittensor/chain_data.py,sha256=hG61nRpp_4A1NkmEQcbmL89Z1UqL1IF
9
9
  bittensor_cli/src/bittensor/minigraph.py,sha256=BIzmSVLfBYiRAeGD_i1LAC8Cw7zxp38a91SIFEPMqYc,10479
10
10
  bittensor_cli/src/bittensor/networking.py,sha256=pZLMs8YXpZzDMLXWMBb_Bj6TVkm_q9khyY-lnbwVMuE,462
11
11
  bittensor_cli/src/bittensor/subtensor_interface.py,sha256=tOhQEkjO03J7YJNYdUOmmH333SR5wNybmgYNZ7aoygk,54507
12
- bittensor_cli/src/bittensor/utils.py,sha256=nEI1qDvKpBFc2YxO1MybnqRTrV2OPzvyqbwMazNaz7k,47108
12
+ bittensor_cli/src/bittensor/utils.py,sha256=z3KsDpOVgL1O16aXYJWDspaK1UFgei-eXxX2biZZ98s,47539
13
13
  bittensor_cli/src/bittensor/extrinsics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  bittensor_cli/src/bittensor/extrinsics/registration.py,sha256=3mJZ3hw_wZEa-8I0R8WVuKjMQi4Y9EV5FjTCvbY37Iw,63780
15
15
  bittensor_cli/src/bittensor/extrinsics/root.py,sha256=N9Fg4VaveRRP1ZN4EZjIWCe04FpTNBKWFqx8USKp9uQ,19062
@@ -17,19 +17,19 @@ bittensor_cli/src/bittensor/extrinsics/transfer.py,sha256=FyrRo3yk-065toN4f-1Xes
17
17
  bittensor_cli/src/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  bittensor_cli/src/commands/sudo.py,sha256=GICsjDYvaoJpq5zAUHb3gIcXvD0t1VNOkz8hghz_AUs,31475
19
19
  bittensor_cli/src/commands/view.py,sha256=2MdhWWbY9rwGqDilzs8r2ioa0l2GzrYxe8pKkavEVWs,109517
20
- bittensor_cli/src/commands/wallets.py,sha256=JioSUJC8DmT_OecOy0GJjrk9AompUt2lzfiwOLiMR6E,51067
20
+ bittensor_cli/src/commands/wallets.py,sha256=DuG3LQx75NRsi-f0-8Y-FriOSqj57nViNf1xryHHFV0,50711
21
21
  bittensor_cli/src/commands/weights.py,sha256=uI7aACKD90JOtYt61VdKL76z7Fe_wh4WtdwMXL6ydD4,16269
22
22
  bittensor_cli/src/commands/stake/__init__.py,sha256=uxomMv_QrYt5Qn3_X5UWFFh45ISjB0JmDmCFxVyX8nQ,6495
23
23
  bittensor_cli/src/commands/stake/add.py,sha256=aVdBEdrfJ5-IK9MpQ00lYQylw_e6BgimCsxMFJZe75E,24911
24
- bittensor_cli/src/commands/stake/children_hotkeys.py,sha256=STUeMc9PdzJPx_nfFzPLBUkSc4Wf9b40PJZZZEAKHfI,29630
24
+ bittensor_cli/src/commands/stake/children_hotkeys.py,sha256=udpomkjeNb8MTEFm2p2BxHG1RSunOUamHSdWpQWvvXY,29631
25
25
  bittensor_cli/src/commands/stake/list.py,sha256=TfoFrXsYRTQeTiDd6pHu-f6rZ2ev0VK9fMybQ295X7Q,28600
26
26
  bittensor_cli/src/commands/stake/move.py,sha256=RSFtMgpBlK82U9CtCcijeZWBOABABnaPzyIgC2ug_Tc,34635
27
27
  bittensor_cli/src/commands/stake/remove.py,sha256=iEVV79RmhA2mCL2UGydc98pcCNTO6dpP7gJeq6OfbG0,46884
28
28
  bittensor_cli/src/commands/subnets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
29
  bittensor_cli/src/commands/subnets/price.py,sha256=TWcRXUFeS_Q-pfyv0YIluAL8SE7d2gzTODK-9M2J5pw,29878
30
- bittensor_cli/src/commands/subnets/subnets.py,sha256=vEhCB756458KstHDSS1nEahympyGWNEmjujUhZ-6NSg,83936
31
- bittensor_cli-9.1.1.dist-info/METADATA,sha256=uU97T8N_abOATaMxXC_0hX2mmhIjpfJwnQRSUk1RaO4,6145
32
- bittensor_cli-9.1.1.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
33
- bittensor_cli-9.1.1.dist-info/entry_points.txt,sha256=hBTLGLbVxmAKy69XSKaUZvjTCmyEzDGZKq4S8UOto8I,49
34
- bittensor_cli-9.1.1.dist-info/top_level.txt,sha256=DvgvXpmTtI_Q1BbDZMlK90LFcGFCreN1daViEPV2iFw,14
35
- bittensor_cli-9.1.1.dist-info/RECORD,,
30
+ bittensor_cli/src/commands/subnets/subnets.py,sha256=e2QeuaAQZg0S-uHvDUejy82wJPe1_njb9_qeoLcrKf0,83955
31
+ bittensor_cli-9.1.3.dist-info/METADATA,sha256=Z7pEVMLdBIfcdSPMijRgi1SsA1zIXKcaJ6KB526tzsw,6145
32
+ bittensor_cli-9.1.3.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
33
+ bittensor_cli-9.1.3.dist-info/entry_points.txt,sha256=hBTLGLbVxmAKy69XSKaUZvjTCmyEzDGZKq4S8UOto8I,49
34
+ bittensor_cli-9.1.3.dist-info/top_level.txt,sha256=DvgvXpmTtI_Q1BbDZMlK90LFcGFCreN1daViEPV2iFw,14
35
+ bittensor_cli-9.1.3.dist-info/RECORD,,