@@ -2448,3 +2448,66 @@ async def start_subnet(
2448
2448
await get_start_schedule (subtensor , netuid )
2449
2449
print_error (f":cross_mark: Failed to start subnet: { error_msg } " )
2450
2450
return False
2451
+
2452
+
2453
+ async def set_symbol (
2454
+ wallet : "Wallet" ,
2455
+ subtensor : "SubtensorInterface" ,
2456
+ netuid : int ,
2457
+ symbol : str ,
2458
+ prompt : bool = False ,
2459
+ json_output : bool = False ,
2460
+ ) -> bool :
2461
+ """Set a subtensor's symbol"""
2462
+ if not await subtensor .subnet_exists (netuid ):
2463
+ err = f"Subnet { netuid } does not exist."
2464
+ if json_output :
2465
+ json_console .print_json (data = {"success" : False , "message" : err })
2466
+ else :
2467
+ err_console .print (err )
2468
+ return False
2469
+
2470
+ if prompt and not json_output :
2471
+ sn_info = await subtensor .subnet (netuid = netuid )
2472
+ if not Confirm .ask (
2473
+ f"Your current subnet symbol for SN{ netuid } is { sn_info .symbol } . Do you want to update it to { symbol } ?"
2474
+ ):
2475
+ return False
2476
+
2477
+ if not (unlock_status := unlock_key (wallet , print_out = False )).success :
2478
+ err = unlock_status .message
2479
+ if json_output :
2480
+ json_console .print_json (data = {"success" : False , "message" : err })
2481
+ else :
2482
+ console .print (err )
2483
+ return False
2484
+
2485
+ start_call = await subtensor .substrate .compose_call (
2486
+ call_module = "SubtensorModule" ,
2487
+ call_function = "update_symbol" ,
2488
+ call_params = {"netuid" : netuid , "symbol" : symbol },
2489
+ )
2490
+
2491
+ signed_ext = await subtensor .substrate .create_signed_extrinsic (
2492
+ call = start_call ,
2493
+ keypair = wallet .coldkey ,
2494
+ )
2495
+
2496
+ response = await subtensor .substrate .submit_extrinsic (
2497
+ extrinsic = signed_ext ,
2498
+ wait_for_inclusion = True ,
2499
+ )
2500
+ if await response .is_success :
2501
+ message = f"Successfully updated SN{ netuid } 's symbol to { symbol } ."
2502
+ if json_output :
2503
+ json_console .print_json (data = {"success" : True , "message" : message })
2504
+ else :
2505
+ console .print (f":white_heavy_check_mark:[dark_sea_green3] { message } \n " )
2506
+ return True
2507
+ else :
2508
+ err = format_error_message (await response .error_message )
2509
+ if json_output :
2510
+ json_console .print_json (data = {"success" : False , "message" : err })
2511
+ else :
2512
+ err_console .print (f":cross_mark: [red]Failed[/red]: { err } " )
2513
+ return False
0 commit comments