@@ -430,14 +430,92 @@ async def register_subnet_extrinsic(
430
430
if not wait_for_finalization and not wait_for_inclusion :
431
431
return True
432
432
433
- await response .process_events ()
434
433
if not await response .is_success :
435
434
logging .error (
436
- f"Failed to register subnet: { format_error_message (await response .error_message , subtensor . substrate )} "
435
+ f"Failed to register subnet: { format_error_message (await response .error_message )} "
437
436
)
438
437
return False
439
438
440
439
logging .success (
441
440
":white_heavy_check_mark: [green]Successfully registered subnet[/green]"
442
441
)
443
442
return True
443
+
444
+
445
+ async def set_subnet_identity_extrinsic (
446
+ subtensor : "AsyncSubtensor" ,
447
+ wallet : "Wallet" ,
448
+ netuid : int ,
449
+ subnet_name : str ,
450
+ github_repo : str ,
451
+ subnet_contact : str ,
452
+ subnet_url : str ,
453
+ discord : str ,
454
+ description : str ,
455
+ additional : str ,
456
+ wait_for_inclusion : bool = False ,
457
+ wait_for_finalization : bool = True ,
458
+ ) -> tuple [bool , str ]:
459
+ """
460
+ Set the identity information for a given subnet.
461
+
462
+ Arguments:
463
+ subtensor (AsyncSubtensor): An instance of the Subtensor class to interact with the blockchain.
464
+ wallet (Wallet): A wallet instance used to sign and submit the extrinsic.
465
+ netuid (int): The unique ID for the subnet.
466
+ subnet_name (str): The name of the subnet to assign the identity information.
467
+ github_repo (str): URL of the GitHub repository related to the subnet.
468
+ subnet_contact (str): Subnet's contact information, e.g., email or contact link.
469
+ subnet_url (str): The URL of the subnet's primary web portal.
470
+ discord (str): Discord server or contact for the subnet.
471
+ description (str): A textual description of the subnet.
472
+ additional (str): Any additional metadata or information related to the subnet.
473
+ wait_for_inclusion (bool): Whether to wait for the extrinsic inclusion in a block (default: False).
474
+ wait_for_finalization (bool): Whether to wait for the extrinsic finalization in a block (default: True).
475
+
476
+ Returns:
477
+ tuple[bool, str]: A tuple where the first element indicates success or failure (True/False), and the second
478
+ element contains a descriptive message.
479
+ """
480
+
481
+ if not (unlock := unlock_key (wallet )).success :
482
+ logging .error (unlock .message )
483
+ return False , unlock .message
484
+
485
+ call = await subtensor .substrate .compose_call (
486
+ call_module = "SubtensorModule" ,
487
+ call_function = "set_subnet_identity" ,
488
+ call_params = {
489
+ "hotkey" : wallet .hotkey .ss58_address ,
490
+ "netuid" : netuid ,
491
+ "subnet_name" : subnet_name ,
492
+ "github_repo" : github_repo ,
493
+ "subnet_contact" : subnet_contact ,
494
+ "subnet_url" : subnet_url ,
495
+ "discord" : discord ,
496
+ "description" : description ,
497
+ "additional" : additional ,
498
+ },
499
+ )
500
+
501
+ response = await subtensor .substrate .submit_extrinsic (
502
+ call = call ,
503
+ wallet = wallet ,
504
+ wait_for_inclusion = wait_for_inclusion ,
505
+ wait_for_finalization = wait_for_finalization ,
506
+ )
507
+
508
+ if not wait_for_finalization and not wait_for_inclusion :
509
+ return True , f"Identities for subnet { netuid } are sent to the chain."
510
+
511
+ if await response .is_success :
512
+ logging .success (
513
+ f":white_heavy_check_mark: [green]Identities for subnet[/green] [blue]{ netuid } [/blue] [green]are set.[/green]"
514
+ )
515
+ return True , f"Identities for subnet { netuid } are set."
516
+ else :
517
+ error_message = await response .error_message
518
+ logging .error (
519
+ f":cross_mark: Failed to set identity for subnet [blue]{ netuid } [/blue]: { error_message } "
520
+ )
521
+ return False , f"Failed to set identity for subnet { netuid } : { error_message } "
0 commit comments