Skip to content

Commit ccb6416

Browse files
[SDK] fix: Force redirect to phantom app on mobile (#6507)
1 parent aa9d858 commit ccb6416

File tree

84 files changed

+3302
-2546
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+3302
-2546
lines changed

.changeset/orange-rockets-reply.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Force redirect to phantom app on mobile

apps/playground-web/src/app/connect/sign-in/button/RightSection.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ export function RightSection(props: {
158158
<div
159159
className={cn(
160160
"relative flex min-h-[300px] grow justify-center rounded-lg",
161-
previewTab === "modal" && "scale-75 lg:scale-100",
162161
previewTab !== "code" && "items-center",
163162
)}
164163
>

packages/thirdweb/scripts/wallets/generate.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ const deepLinkSupportedWalletsRecord: Record<
3838
"io.metamask": {
3939
mobile: "https://metamask.app.link/dapp/",
4040
},
41+
"app.phantom": {
42+
mobile: "https://phantom.app/ul/browse/",
43+
},
4144
};
4245

4346
type Wallet = {

packages/thirdweb/src/react/web/ui/ConnectWallet/Modal/AnyWalletConnectUI.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,15 @@ export function AnyWalletConnectUI(props: {
156156
);
157157
}
158158

159-
if (
159+
const shouldDeeplink =
160160
walletInfo.data.deepLink &&
161161
!isInstalled &&
162-
(wallet as Wallet<DeepLinkSupportedWalletIds>).getConfig()
163-
?.preferDeepLink &&
164-
isMobile()
165-
) {
162+
isMobile() &&
163+
((wallet as Wallet<DeepLinkSupportedWalletIds>).getConfig()
164+
?.preferDeepLink ||
165+
wallet.id === "app.phantom"); // always deeplink phantom on mobile, does not support remote connection
166+
167+
if (walletInfo.data.deepLink?.mobile && shouldDeeplink) {
166168
return (
167169
<DeepLinkConnectUI
168170
wallet={props.wallet as Wallet<InjectedSupportedWalletIds>}

packages/thirdweb/src/react/web/ui/ConnectWallet/Modal/DeepLinkConnectUI.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export const DeepLinkConnectUI = (props: {
2525
onBack?: () => void;
2626
client: ThirdwebClient;
2727
}) => {
28+
const link = encodeURIComponent(window.location.toString());
29+
const deeplink = `${props.deepLinkPrefix}${link}?ref=${link}`;
2830
return (
2931
<Container animate="fadein">
3032
<Container p="lg">
@@ -38,14 +40,7 @@ export const DeepLinkConnectUI = (props: {
3840
</Container>
3941

4042
<Container p="lg">
41-
<ButtonLink
42-
fullWidth
43-
variant="accent"
44-
href={`${props.deepLinkPrefix}${window.location
45-
.toString()
46-
.replace("https://", "")}`}
47-
gap="xs"
48-
>
43+
<ButtonLink fullWidth variant="accent" href={deeplink} gap="xs">
4944
Continue in {props.walletInfo.name}
5045
<ExternalLinkIcon width={iconSize.sm} height={iconSize.sm} />
5146
</ButtonLink>

0 commit comments

Comments
 (0)