-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: added deeplinking to the NFT screen #25426
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
Merged
+149
−0
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
cafe5ff
feat: added deeplinking to the NFT screen
juanmigdr c3291eb
chore: solved comments
juanmigdr 8ea9bf9
fix: issues
juanmigdr 2c86fad
Merge branch 'main' into feat/nft-deeplink
juanmigdr c77e32b
Merge branch 'main' into feat/nft-deeplink
juanmigdr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
91 changes: 91 additions & 0 deletions
91
app/core/DeeplinkManager/handlers/legacy/__tests__/handleNftUrl.test.ts
This file contains hidden or 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,91 @@ | ||
| import { handleNftUrl } from '../handleNftUrl'; | ||
| import NavigationService from '../../../../NavigationService'; | ||
| import Routes from '../../../../../constants/navigation/Routes'; | ||
| import DevLogger from '../../../../SDKConnect/utils/DevLogger'; | ||
| import Logger from '../../../../../util/Logger'; | ||
|
|
||
| jest.mock('../../../../NavigationService'); | ||
| jest.mock('../../../../SDKConnect/utils/DevLogger'); | ||
| jest.mock('../../../../../util/Logger'); | ||
|
|
||
| describe('handleNftUrl', () => { | ||
| let mockNavigate: jest.Mock; | ||
|
|
||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
|
|
||
| mockNavigate = jest.fn(); | ||
| NavigationService.navigation = { | ||
| navigate: mockNavigate, | ||
| } as unknown as typeof NavigationService.navigation; | ||
|
|
||
| (DevLogger.log as jest.Mock) = jest.fn(); | ||
| (Logger.error as jest.Mock) = jest.fn(); | ||
| }); | ||
|
|
||
| it('navigates to NFTS_FULL_VIEW', () => { | ||
| handleNftUrl(); | ||
|
|
||
| expect(mockNavigate).toHaveBeenCalledWith(Routes.WALLET.NFTS_FULL_VIEW); | ||
| }); | ||
|
|
||
| it('logs start of deeplink handling', () => { | ||
| handleNftUrl(); | ||
|
|
||
| expect(DevLogger.log).toHaveBeenCalledWith( | ||
| '[handleNftUrl] Starting NFT deeplink handling', | ||
| ); | ||
| }); | ||
|
|
||
| it('falls back to WALLET.HOME on navigation error', () => { | ||
| mockNavigate.mockImplementationOnce(() => { | ||
| throw new Error('Navigation error'); | ||
| }); | ||
|
|
||
| handleNftUrl(); | ||
|
|
||
| expect(mockNavigate).toHaveBeenCalledTimes(2); | ||
| expect(mockNavigate).toHaveBeenLastCalledWith(Routes.WALLET.HOME); | ||
| }); | ||
|
|
||
| it('logs error when navigation fails', () => { | ||
| const error = new Error('Navigation error'); | ||
| mockNavigate.mockImplementationOnce(() => { | ||
| throw error; | ||
| }); | ||
|
|
||
| handleNftUrl(); | ||
|
|
||
| expect(DevLogger.log).toHaveBeenCalledWith( | ||
| '[handleNftUrl] Failed to handle NFT deeplink:', | ||
| error, | ||
| ); | ||
| expect(Logger.error).toHaveBeenCalledWith( | ||
| error, | ||
| '[handleNftUrl] Error handling NFT deeplink', | ||
| ); | ||
| }); | ||
|
|
||
| it('logs error when fallback navigation also fails', () => { | ||
| const primaryError = new Error('Primary navigation error'); | ||
| const fallbackError = new Error('Fallback navigation error'); | ||
| mockNavigate | ||
| .mockImplementationOnce(() => { | ||
| throw primaryError; | ||
| }) | ||
| .mockImplementationOnce(() => { | ||
| throw fallbackError; | ||
| }); | ||
|
|
||
| handleNftUrl(); | ||
|
|
||
| expect(Logger.error).toHaveBeenCalledWith( | ||
| primaryError, | ||
| '[handleNftUrl] Error handling NFT deeplink', | ||
| ); | ||
| expect(Logger.error).toHaveBeenCalledWith( | ||
| fallbackError, | ||
| '[handleNftUrl] Failed to navigate to fallback screen', | ||
| ); | ||
| }); | ||
| }); |
This file contains hidden or 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,31 @@ | ||
| import NavigationService from '../../../NavigationService'; | ||
| import Routes from '../../../../constants/navigation/Routes'; | ||
| import DevLogger from '../../../SDKConnect/utils/DevLogger'; | ||
| import Logger from '../../../../util/Logger'; | ||
|
|
||
| /** | ||
| * NFT deeplink handler | ||
| * | ||
| * Supported URL formats: | ||
| * - https://link.metamask.io/nft | ||
| * - https://metamask.io/nft (mapped via Branch) | ||
| */ | ||
| export const handleNftUrl = () => { | ||
| DevLogger.log('[handleNftUrl] Starting NFT deeplink handling'); | ||
|
|
||
| try { | ||
| NavigationService.navigation.navigate(Routes.WALLET.NFTS_FULL_VIEW); | ||
| } catch (error) { | ||
| DevLogger.log('[handleNftUrl] Failed to handle NFT deeplink:', error); | ||
| Logger.error(error as Error, '[handleNftUrl] Error handling NFT deeplink'); | ||
|
|
||
| try { | ||
| NavigationService.navigation.navigate(Routes.WALLET.HOME); | ||
| } catch (navError) { | ||
| Logger.error( | ||
| navError as Error, | ||
| '[handleNftUrl] Failed to navigate to fallback screen', | ||
| ); | ||
| } | ||
| } | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.