Skip to content

feat: add home path for new deeplinks #15275

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/constants/deeplinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export enum ACTIONS {
BUY_CRYPTO = 'buy-crypto',
SELL = 'sell',
SELL_CRYPTO = 'sell-crypto',
HOME = 'home',
EMPTY = '',
}

Expand All @@ -43,5 +44,6 @@ export const PREFIXES = {
[ACTIONS.SELL]: '',
[ACTIONS.BUY_CRYPTO]: '',
[ACTIONS.SELL_CRYPTO]: '',
[ACTIONS.HOME]: '',
METAMASK: 'metamask://',
};
1 change: 1 addition & 0 deletions app/core/AppConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default {
},
},
MM_UNIVERSAL_LINK_HOST: 'metamask.app.link',
MM_IO_UNIVERSAL_LINK_HOST: 'link.metamask.io',
MM_DEEP_ITMS_APP_LINK: 'https://metamask.app.link/skAH3BaF99',
SAI_ADDRESS: '0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359',
HOMEPAGE_URL: 'https://portfolio.metamask.io/explore?MetaMaskEntry=mobile/',
Expand Down
5 changes: 5 additions & 0 deletions app/core/DeeplinkManager/DeeplinkManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import switchNetwork from './Handlers/switchNetwork';
import parseDeeplink from './ParseManager/parseDeeplink';
import approveTransaction from './TransactionManager/approveTransaction';
import { RampType } from '../../reducers/fiatOrders/types';
import Routes from '../../constants/navigation/Routes';

class DeeplinkManager {
public navigation: NavigationProp<ParamListBase>;
Expand Down Expand Up @@ -87,6 +88,10 @@ class DeeplinkManager {
rampType: RampType.SELL,
});
}
// FRANK: *Step 7: open the home screen
_handleOpenHome() {
this.navigation.navigate(Routes.WALLET.HOME);
}

parse(
url: string,
Expand Down
29 changes: 25 additions & 4 deletions app/core/DeeplinkManager/ParseManager/handleUniversalLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,21 @@
wcURL: string;
url: string;
}) {
const { MM_UNIVERSAL_LINK_HOST, MM_DEEP_ITMS_APP_LINK } = AppConstants;
const { MM_UNIVERSAL_LINK_HOST, MM_DEEP_ITMS_APP_LINK, MM_IO_UNIVERSAL_LINK_HOST } = AppConstants;
const DEEP_LINK_BASE = `${PROTOCOLS.HTTPS}://${MM_UNIVERSAL_LINK_HOST}`;

// Universal links
handled();

if (urlObj.hostname === MM_UNIVERSAL_LINK_HOST) {
// action is the first part of the pathname
const action: ACTIONS = urlObj.pathname.split('/')[1] as ACTIONS;
// action is the first part of the pathname
const action: ACTIONS = urlObj.pathname.split('/')[1] as ACTIONS;

if (urlObj.hostname === MM_UNIVERSAL_LINK_HOST) { // FRANK: *Step 5: deeplinks are currently caught here
// Placeholder for testing new actions navigation for new subdomain
if (action === ACTIONS.HOME) {
instance._handleOpenHome();
return;
}
if (action === ACTIONS.ANDROID_SDK) {
DevLogger.log(
`DeeplinkManager:: metamask launched via android sdk universal link`,
Expand Down Expand Up @@ -145,6 +150,22 @@
// Normal links (same as dapp)
instance._handleBrowserUrl(urlObj.href, browserCallBack);
}
} else if (urlObj.hostname === MM_IO_UNIVERSAL_LINK_HOST) {
// FRANK: *Step 6: branch off here for new subdomain
// The new actions will be handled when there is a new subdomain
if (action === ACTIONS.HOME) {
instance._handleOpenHome();
} else if (action === ACTIONS.BUY || action === ACTIONS.BUY_CRYPTO) {
const rampPath = urlObj.href
.replace(`${DEEP_LINK_BASE}/${ACTIONS.BUY_CRYPTO}`, '')
.replace(`${DEEP_LINK_BASE}/${ACTIONS.BUY}`, '');
instance._handleBuyCrypto(rampPath);
} else if (action === ACTIONS.SWAP) {

Check failure on line 163 in app/core/DeeplinkManager/ParseManager/handleUniversalLink.ts

View workflow job for this annotation

GitHub Actions / scripts (lint:tsc)

Property 'SWAP' does not exist on type 'typeof ACTIONS'.
instance._handleOpenSwap();

Check failure on line 164 in app/core/DeeplinkManager/ParseManager/handleUniversalLink.ts

View workflow job for this annotation

GitHub Actions / scripts (lint:tsc)

Property '_handleOpenSwap' does not exist on type 'DeeplinkManager'.
} else {
// Default to home if no action specified
instance._handleOpenHome();
}
} else {
// Normal links (same as dapp)
instance._handleBrowserUrl(urlObj.href, browserCallBack);
Expand Down
Loading