-
Notifications
You must be signed in to change notification settings - Fork 2
optimized bulk inspect names #164
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
optimized bulk inspect names #164
Conversation
|
This pull request has been linked to Shortcut Story #22889: Optimize bulk inspect names. |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
api/nameguard/nameguard.py
Outdated
| SIMPLE_NAME_REGEX = re.compile(r'^[a-z0-9]+\.eth$') | ||
|
|
||
|
|
||
| def simple_name(name: str) -> bool: | ||
| return SIMPLE_NAME_REGEX.match(name) is not None | ||
|
|
||
|
|
||
| def consolidated_report_from_simple_name(name: str) -> ConsolidatedNameGuardReport: | ||
| return ConsolidatedNameGuardReport( | ||
| name=name, | ||
| namehash=namehash_from_name(name), | ||
| normalization=Normalization.NORMALIZED, | ||
| rating=Rating.PASS, | ||
| risk_count=0, | ||
| highest_risk=None, | ||
| ) |
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.
@lightwalker-eth @Carbon225 Please review the regex and fields in the report - is it always true for any name matching the regex?
TODO: Now I see that Punycode and NameWrapper checks can fail for too long name.
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.
For Puny and NameWrapper each label's length must be <= 253 and <=255. The simplest solution is:
| SIMPLE_NAME_REGEX = re.compile(r'^[a-z0-9]+\.eth$') | |
| def simple_name(name: str) -> bool: | |
| return SIMPLE_NAME_REGEX.match(name) is not None | |
| def consolidated_report_from_simple_name(name: str) -> ConsolidatedNameGuardReport: | |
| return ConsolidatedNameGuardReport( | |
| name=name, | |
| namehash=namehash_from_name(name), | |
| normalization=Normalization.NORMALIZED, | |
| rating=Rating.PASS, | |
| risk_count=0, | |
| highest_risk=None, | |
| ) | |
| SIMPLE_NAME_REGEX = re.compile(r'^[a-z0-9]{1,253}\.eth$') | |
| def simple_name(name: str) -> bool: | |
| return SIMPLE_NAME_REGEX.match(name) is not None | |
| def consolidated_report_from_simple_name(name: str) -> ConsolidatedNameGuardReport: | |
| return ConsolidatedNameGuardReport( | |
| name=name, | |
| namehash=namehash_from_name(name), | |
| normalization=Normalization.NORMALIZED, | |
| rating=Rating.PASS, | |
| risk_count=0, | |
| highest_risk=None, | |
| ) |
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.
NameWrapper (Punycode) label is <=63
lightwalker-eth
left a comment
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.
Great ! 👍
No description provided.