-
Notifications
You must be signed in to change notification settings - Fork 349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subtensor Registry #1562
Subtensor Registry #1562
Changes from 1 commit
ea0d4b8
a154b24
7dabcb0
aa57e00
fd6cf2d
502123d
68220a8
105a95f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
# DEALINGS IN THE SOFTWARE. | ||
|
||
from substrateinterface.utils import ss58 | ||
from typing import Union | ||
from typing import Union, Optional | ||
|
||
from .. import __ss58_format__ | ||
from substrateinterface import Keypair as Keypair | ||
|
@@ -102,3 +102,61 @@ def is_valid_bittensor_address_or_public_key(address: Union[str, bytes]) -> bool | |
else: | ||
# Invalid address type | ||
return False | ||
|
||
|
||
|
||
def create_identity_dict( | ||
display: str = "", | ||
legal: str = "", | ||
web: str = "", | ||
riot: str = "", | ||
email: str = "", | ||
pgp_fingerprint: Optional[str] = None, | ||
image: str = "", | ||
info: str = "", | ||
twitter: str = "", | ||
) -> dict: | ||
""" | ||
Creates a dictionary with structure for identity extrinsic. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have the requirements for each parameter? Might be useful to document here if known. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nothing specific, but there is a max of 64bytes for each param. So there is a limit there |
||
|
||
Args: | ||
display (str): String to be converted and stored under 'display'. | ||
legal (str): String to be converted and stored under 'legal'. | ||
web (str): String to be converted and stored under 'web'. | ||
riot (str): String to be converted and stored under 'riot'. | ||
email (str): String to be converted and stored under 'email'. | ||
pgp_fingerprint (str): String to be converted and stored under 'pgp_fingerprint'. If None, it remains None. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This requires |
||
image (str): String to be converted and stored under 'image'. | ||
info (str): String to be converted and stored under 'info'. | ||
twitter (str): String to be converted and stored under 'twitter'. | ||
|
||
Returns: | ||
dict: A dictionary with the specified structure and byte string conversions. | ||
""" | ||
return { | ||
'info': { | ||
'additional': [[]], | ||
'display': {f'Raw{len(display.encode())}': display.encode()}, | ||
'legal': {f'Raw{len(legal.encode())}': legal.encode()}, | ||
'web': {f'Raw{len(web.encode())}': web.encode()}, | ||
'riot': {f'Raw{len(riot.encode())}': riot.encode()}, | ||
'email': {f'Raw{len(email.encode())}': email.encode()}, | ||
'pgp_fingerprint': pgp_fingerprint.encode() if pgp_fingerprint else None, | ||
'image': {f'Raw{len(image.encode())}': image.encode()}, | ||
'info': {f'Raw{len(info.encode())}': info.encode()}, | ||
'twitter': {f'Raw{len(twitter.encode())}': twitter.encode()}, | ||
} | ||
} | ||
|
||
def decode_hex_identity_dict(info_dictionary): | ||
for key, value in info_dictionary.items(): | ||
if isinstance(value, dict): | ||
item = list(value.values())[0] | ||
if isinstance(item, str) and item.startswith('0x'): | ||
try: | ||
info_dictionary[key] = bytes.fromhex(item[2:]).decode() | ||
except UnicodeDecodeError: | ||
print(f"Could not decode: {key}: {item}") | ||
else: | ||
info_dictionary[key] = item | ||
return info_dictionary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the wallet coldkey is not the subnet owner, this can essentially set identity for any coldkey on chain. Do we want to limit this to subnet owners only? (check the chain for current subnet coldkey owners)
E.g.:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeap, this is done by the chain, only subnet owners and root validators can set an identity