-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TOOL-3009] Dashboard: Support all valid domains as ENS name and not …
…just .eth (#5937) <!-- start pr-codex --> ## PR-Codex overview This PR introduces the `isValidENSName` utility function to validate ENS names, replacing the previous `isEnsName` checks across multiple files. It refines address validation and enhances the overall handling of ENS names within the codebase. ### Detailed summary - Added `isValidENSName` utility function for ENS name validation. - Replaced occurrences of `isEnsName` with `isValidENSName` in various files. - Updated validation logic in components and utilities to improve address and ENS name handling. - Enhanced error messages and conditions related to ENS name checks. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
- Loading branch information
Showing
19 changed files
with
160 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
"thirdweb": patch | ||
--- | ||
|
||
Add `isValidENSName` utility function for checking if a string is a valid ENS name. It does not check if the name is actually registered, it only checks if the string is in a valid format. | ||
|
||
```ts | ||
import { isValidENSName } from "thirdweb/utils"; | ||
|
||
isValidENSName("thirdweb.eth"); // true | ||
isValidENSName("foo.bar.com"); // true | ||
isValidENSName("foo"); // false | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { describe, expect, it } from "vitest"; | ||
import { isValidENSName } from "./isValidENSName.js"; | ||
|
||
describe("isValidENSName", () => { | ||
it("should return true for a valid ENS name", () => { | ||
expect(isValidENSName("thirdweb.eth")).toBe(true); | ||
expect(isValidENSName("deployer.thirdweb.eth")).toBe(true); | ||
expect(isValidENSName("x.eth")).toBe(true); | ||
expect(isValidENSName("foo.bar.com")).toBe(true); | ||
expect(isValidENSName("foo.com")).toBe(true); | ||
expect(isValidENSName("somename.xyz")).toBe(true); | ||
expect(isValidENSName("_foo.bar")).toBe(true); | ||
expect(isValidENSName("-foo.bar.com")).toBe(true); | ||
}); | ||
|
||
it("should return false for an invalid ENS name", () => { | ||
// No TLD | ||
expect(isValidENSName("")).toBe(false); | ||
expect(isValidENSName("foo")).toBe(false); | ||
|
||
// parts with length < 2 | ||
expect(isValidENSName(".eth")).toBe(false); | ||
expect(isValidENSName("foo..com")).toBe(false); | ||
expect(isValidENSName("thirdweb.eth.")).toBe(false); | ||
|
||
// numeric TLD | ||
expect(isValidENSName("foo.123")).toBe(false); | ||
|
||
// whitespace in parts | ||
expect(isValidENSName("foo .com")).toBe(false); | ||
expect(isValidENSName("foo. com")).toBe(false); | ||
|
||
// full-width characters | ||
expect(isValidENSName("foo.bar.com")).toBe(false); | ||
|
||
// wildcard characters | ||
expect(isValidENSName("foo*bar.com")).toBe(false); | ||
}); | ||
}); |
Oops, something went wrong.