@@ -1400,30 +1400,47 @@ async def set_id(
1400
1400
):
1401
1401
"""Create a new or update existing identity on-chain."""
1402
1402
1403
+ id_dict = {
1404
+ "additional" : [[]],
1405
+ "display" : display_name ,
1406
+ "legal" : legal_name ,
1407
+ "web" : web_url ,
1408
+ "pgp_fingerprint" : pgp_fingerprint ,
1409
+ "riot" : riot_handle ,
1410
+ "email" : email ,
1411
+ "image" : image ,
1412
+ "twitter" : twitter ,
1413
+ "info" : info_ ,
1414
+ }
1415
+
1416
+ for field , string in id_dict .items ():
1417
+ if (size := getsizeof (string )) > 113 : # 64 + 49 overhead bytes for string
1418
+ err_console .print (
1419
+ f"[red]Error:[/red] Identity field [white]{ field } [/white] must be <= 64 raw bytes.\n "
1420
+ f"Value: '{ string } ' currently [white]{ size } bytes[/white]."
1421
+ )
1422
+ return False
1423
+
1403
1424
identified = (
1404
1425
wallet .hotkey .ss58_address if validator_id else wallet .coldkey .ss58_address
1405
1426
)
1406
- id_dict = {
1427
+ encoded_id_dict = {
1407
1428
"info" : {
1408
1429
"additional" : [[]],
1409
- "display" : display_name ,
1410
- "legal" : legal_name ,
1411
- "web" : web_url ,
1412
- "pgp_fingerprint " : pgp_fingerprint ,
1413
- "riot " : riot_handle ,
1414
- "email " : email ,
1415
- "image" : image ,
1416
- "twitter " : twitter ,
1417
- "info " : info_ ,
1430
+ "display" : { f"Raw { len ( display_name . encode ()) } " : display_name . encode ()} ,
1431
+ "legal" : { f"Raw { len ( legal_name . encode ()) } " : legal_name . encode ()} ,
1432
+ "web" : { f"Raw { len ( web_url . encode ()) } " : web_url . encode ()} ,
1433
+ "riot " : { f"Raw { len ( riot_handle . encode ()) } " : riot_handle . encode ()} ,
1434
+ "email " : { f"Raw { len ( email . encode ()) } " : email . encode ()} ,
1435
+ "pgp_fingerprint " : pgp_fingerprint . encode () if pgp_fingerprint else None ,
1436
+ "image" : { f"Raw { len ( image . encode ()) } " : image . encode ()} ,
1437
+ "info " : { f"Raw { len ( info_ . encode ()) } " : info_ . encode ()} ,
1438
+ "twitter " : { f"Raw { len ( twitter . encode ()) } " : twitter . encode ()} ,
1418
1439
},
1419
1440
"identified" : identified ,
1420
1441
}
1421
1442
1422
- for field , string in id_dict ["info" ].items ():
1423
- if getsizeof (string ) > 113 : # 64 + 49 overhead bytes for string
1424
- raise ValueError (f"Identity value `{ field } ` must be <= 64 raw bytes" )
1425
-
1426
- if not Confirm (
1443
+ if not Confirm .ask (
1427
1444
"Cost to register an Identity is [bold white italic]0.1 Tao[/bold white italic],"
1428
1445
" are you sure you wish to continue?"
1429
1446
):
@@ -1436,7 +1453,7 @@ async def set_id(
1436
1453
call = await subtensor .substrate .compose_call (
1437
1454
call_module = "Registry" ,
1438
1455
call_function = "set_identity" ,
1439
- call_params = id_dict ,
1456
+ call_params = encoded_id_dict ,
1440
1457
)
1441
1458
success , err_msg = await subtensor .sign_and_send_extrinsic (call , wallet )
1442
1459
@@ -1466,6 +1483,13 @@ async def get_id(subtensor: SubtensorInterface, ss58_address: str):
1466
1483
with console .status (":satellite: [bold green]Querying chain identity..." ):
1467
1484
identity = await subtensor .query_identity (ss58_address )
1468
1485
1486
+ if not identity :
1487
+ err_console .print (
1488
+ f"[red]Identity not found[/red]"
1489
+ f" for [light_goldenrod3]{ ss58_address } [/light_goldenrod3]"
1490
+ f" on [white]{ subtensor } [/white]"
1491
+ )
1492
+ return
1469
1493
table = Table (
1470
1494
Column ("Item" , justify = "right" , style = "cyan" , no_wrap = True ),
1471
1495
Column ("Value" , style = "magenta" ),
0 commit comments