Skip to content

Conversation

@djstrong
Copy link
Collaborator

No description provided.

@shortcut-integration
Copy link

This pull request has been linked to Shortcut Story #22889: Optimize bulk inspect names.

@vercel
Copy link

vercel bot commented Nov 25, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nameguard-website ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 25, 2023 1:07pm

Comment on lines 97 to 112
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,
)
Copy link
Collaborator Author

@djstrong djstrong Nov 25, 2023

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.

Copy link
Collaborator Author

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:

Suggested change
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,
)

Copy link
Collaborator Author

@djstrong djstrong Nov 25, 2023

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

Copy link
Member

@lightwalker-eth lightwalker-eth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great ! 👍

@lightwalker-eth lightwalker-eth merged commit 1be2947 into main Nov 27, 2023
@lightwalker-eth lightwalker-eth deleted the krzysztofwrobel/sc-22889/optimize-bulk-inspect-names branch November 27, 2023 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants