-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* namehash -> safeNamehash where necessary * cleanup * address comment
- Loading branch information
1 parent
596ea03
commit b967b1b
Showing
6 changed files
with
45 additions
and
29 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
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,21 @@ | ||
import { namehash } from '@ethersproject/hash' | ||
|
||
import { safeNamehash } from './safeNamehash' | ||
|
||
describe('#safeNamehash', () => { | ||
const emoji = '🤔' | ||
|
||
it('#namehash fails', () => { | ||
expect(() => namehash(emoji)).toThrow('STRINGPREP_CONTAINS_UNASSIGNED') | ||
}) | ||
|
||
// suppress console.debug for the next test | ||
beforeEach(() => { | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
jest.spyOn(console, 'debug').mockImplementation(() => {}) | ||
}) | ||
|
||
it('works', () => { | ||
expect(safeNamehash(emoji)).toEqual(undefined) | ||
}) | ||
}) |
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,12 @@ | ||
import { namehash } from '@ethersproject/hash' | ||
|
||
export function safeNamehash(name?: string): string | undefined { | ||
if (name === undefined) return undefined | ||
|
||
try { | ||
return namehash(name) | ||
} catch (error) { | ||
console.debug(error) | ||
return undefined | ||
} | ||
} |
b967b1b
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.
Successfully deployed to the following URLs:
interface – ./
interface-git-main-uniswap.vercel.app
interface-uniswap.vercel.app
b967b1b
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.
Successfully deployed to the following URLs:
widgets – ./
widgets-git-main-uniswap.vercel.app
widgets-uniswap.vercel.app