@getpara/react-sdk-lite 2.20.0 → 2.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/modal/ParaModal.js
CHANGED
|
@@ -5,27 +5,12 @@ import {
|
|
|
5
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { CpslButton, CpslIcon, CpslQrCode, CpslSpinner, CpslText } from "@getpara/react-components";
|
|
7
7
|
import { CenteredText, HeroAccountTypeIcon, InnerStepContainer, QRContainer, StepContainer } from "../../common.js";
|
|
8
|
-
import { useCallback, useMemo } from "react";
|
|
8
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
9
9
|
import { HeroSpinner, openMobileUrl, safeStyled } from "@getpara/react-common";
|
|
10
10
|
import { useCopyToClipboard } from "@getpara/react-common";
|
|
11
11
|
import { isMobile, isTablet } from "@getpara/web-sdk";
|
|
12
|
-
import { useExternalWallets } from "../../../../provider/providers/ExternalWalletProvider.js";
|
|
12
|
+
import { isSolanaWalletInAppBrowser, useExternalWallets } from "../../../../provider/providers/ExternalWalletProvider.js";
|
|
13
13
|
import { useStore } from "../../../../provider/stores/useStore.js";
|
|
14
|
-
const isSolanaWalletInAppBrowser = (wallet) => {
|
|
15
|
-
var _a;
|
|
16
|
-
switch (wallet) {
|
|
17
|
-
case "PHANTOM":
|
|
18
|
-
return !!((_a = window == null ? void 0 : window.phantom) == null ? void 0 : _a.solana);
|
|
19
|
-
case "SOLFLARE":
|
|
20
|
-
return !!(window == null ? void 0 : window.solflare);
|
|
21
|
-
case "BACKPACK":
|
|
22
|
-
return !!(window == null ? void 0 : window.backpack);
|
|
23
|
-
case "GLOW":
|
|
24
|
-
return !!(window == null ? void 0 : window.glowSolana);
|
|
25
|
-
default:
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
14
|
const ExternalWalletMobileConnect = ({
|
|
30
15
|
wallet,
|
|
31
16
|
onConnectWc,
|
|
@@ -37,6 +22,16 @@ const ExternalWalletMobileConnect = ({
|
|
|
37
22
|
const appName = useStore((state) => state.appName);
|
|
38
23
|
const isWalletConnect = wallet.id === "WalletConnect";
|
|
39
24
|
const { qrUri } = useExternalWallets();
|
|
25
|
+
const [isInAppBrowser, setIsInAppBrowser] = useState(() => !!isSolanaWalletInAppBrowser(wallet.internalId));
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
setIsInAppBrowser(!!isSolanaWalletInAppBrowser(wallet.internalId));
|
|
28
|
+
const timer = setTimeout(() => {
|
|
29
|
+
if (isSolanaWalletInAppBrowser(wallet.internalId)) {
|
|
30
|
+
setIsInAppBrowser(true);
|
|
31
|
+
}
|
|
32
|
+
}, 500);
|
|
33
|
+
return () => clearTimeout(timer);
|
|
34
|
+
}, [wallet.internalId]);
|
|
40
35
|
const handleCopy = () => {
|
|
41
36
|
if (qrUri) {
|
|
42
37
|
copy(qrUri);
|
|
@@ -52,7 +47,7 @@ const ExternalWalletMobileConnect = ({
|
|
|
52
47
|
});
|
|
53
48
|
if (wallet.type === "SOLANA" || isMobile() && !isTablet()) {
|
|
54
49
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
55
|
-
wallet.type === "SOLANA" && !!qrUri && !
|
|
50
|
+
wallet.type === "SOLANA" && !!qrUri && !isInAppBrowser && /* @__PURE__ */ jsx(InnerStepContainer, { children: /* @__PURE__ */ jsx(
|
|
56
51
|
HeroSpinner,
|
|
57
52
|
{
|
|
58
53
|
icon: /* @__PURE__ */ jsx(HeroAccountTypeIcon, { accountType: wallet.internalId, src: wallet ? wallet.iconUrl : void 0 }),
|
|
@@ -66,12 +61,12 @@ const ExternalWalletMobileConnect = ({
|
|
|
66
61
|
HeroSpinner,
|
|
67
62
|
{
|
|
68
63
|
icon: /* @__PURE__ */ jsx(HeroAccountTypeIcon, { accountType: wallet.internalId, src: wallet ? wallet.iconUrl : void 0 }),
|
|
69
|
-
status: wallet.type === "SOLANA" && !
|
|
70
|
-
text: wallet.type === "SOLANA" && (!
|
|
64
|
+
status: wallet.type === "SOLANA" && !isInAppBrowser ? "idle" : isError ? "error" : "pending",
|
|
65
|
+
text: wallet.type === "SOLANA" && (!isInAppBrowser || wallet.hasIosSafariExtension) ? "" : isError ? externalWalletError[0] : `Confirm connection request in the ${wallet.name} app.`,
|
|
71
66
|
secondaryText: externalWalletError == null ? void 0 : externalWalletError[1]
|
|
72
67
|
}
|
|
73
68
|
),
|
|
74
|
-
wallet.type === "SOLANA" &&
|
|
69
|
+
wallet.type === "SOLANA" && isInAppBrowser && !wallet.hasIosSafariExtension || wallet.type !== "SOLANA" ? /* @__PURE__ */ jsx(
|
|
75
70
|
CpslButton,
|
|
76
71
|
{
|
|
77
72
|
onClick: handleRetryClick,
|
|
@@ -80,7 +75,7 @@ const ExternalWalletMobileConnect = ({
|
|
|
80
75
|
children: isError ? "Retry" : "Connect Wallet"
|
|
81
76
|
}
|
|
82
77
|
) : /* @__PURE__ */ jsx(Text, { weight: "semiBold", children: wallet.hasIosSafariExtension ? `Please install and use the ${wallet.name} extension for iOS Safari.` : `Please navigate to ${appName} in the ${wallet.name} wallet.` }),
|
|
83
|
-
!wallet.hasIosSafariExtension && /* @__PURE__ */ jsx(Link, { href: (_a = wallet.downloadUrl) != null ? _a : "", target: "_blank", children: /* @__PURE__ */ jsxs(ExternalButton, { variant: "secondary", "data-testid": "para-wallet-get", children: [
|
|
78
|
+
!wallet.hasIosSafariExtension && !isInAppBrowser && /* @__PURE__ */ jsx(Link, { href: (_a = wallet.downloadUrl) != null ? _a : "", target: "_blank", children: /* @__PURE__ */ jsxs(ExternalButton, { variant: "secondary", "data-testid": "para-wallet-get", children: [
|
|
84
79
|
`Get ${wallet.name}`,
|
|
85
80
|
/* @__PURE__ */ jsx(ExternalIcon, { icon: "linkExternal" })
|
|
86
81
|
] }) })
|
|
@@ -3,6 +3,7 @@ import { TWalletType } from '@getpara/web-sdk';
|
|
|
3
3
|
import { BalanceManagement, ChainManagement, CommonWallet, DisconnectBaseOptions, ExternalWalletContextType, MutationStatus } from '@getpara/react-common';
|
|
4
4
|
import { ExternalWalletInfo } from '@getpara/web-sdk';
|
|
5
5
|
import { CosmosSignResult } from '@getpara/cosmos-wallet-connectors';
|
|
6
|
+
export declare const isSolanaWalletInAppBrowser: (walletId: string) => boolean;
|
|
6
7
|
export declare const useWalletDisplayHelpers: (wallet: CommonWallet | undefined) => {
|
|
7
8
|
showExtension: boolean;
|
|
8
9
|
showMobile: boolean;
|
|
@@ -23,6 +23,23 @@ import {
|
|
|
23
23
|
import { useGoBack } from "../../modal/hooks/useGoBack.js";
|
|
24
24
|
import { validatePortalOrigin } from "../../modal/utils/validatePortalOrigin.js";
|
|
25
25
|
import { DEFAULTS } from "../../modal/constants/defaults.js";
|
|
26
|
+
const isSolanaWalletInAppBrowser = (walletId) => {
|
|
27
|
+
var _a;
|
|
28
|
+
if (typeof window === "undefined") return false;
|
|
29
|
+
const w = window;
|
|
30
|
+
switch (walletId) {
|
|
31
|
+
case "PHANTOM":
|
|
32
|
+
return !!((_a = w == null ? void 0 : w.phantom) == null ? void 0 : _a.solana);
|
|
33
|
+
case "SOLFLARE":
|
|
34
|
+
return !!(w == null ? void 0 : w.solflare);
|
|
35
|
+
case "BACKPACK":
|
|
36
|
+
return !!(w == null ? void 0 : w.backpack);
|
|
37
|
+
case "GLOW":
|
|
38
|
+
return !!(w == null ? void 0 : w.glowSolana);
|
|
39
|
+
default:
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
26
43
|
const useWalletDisplayHelpers = (wallet) => {
|
|
27
44
|
const isUsingMobileConnector = useStore((state) => state.isUsingMobileConnector);
|
|
28
45
|
return {
|
|
@@ -642,9 +659,10 @@ function ExternalWalletProvider({ children }) {
|
|
|
642
659
|
clearExternalWalletConnectionRetryListener();
|
|
643
660
|
handlePostConnectRetry();
|
|
644
661
|
}
|
|
645
|
-
|
|
662
|
+
const isInDappBrowser = isSolanaWalletInAppBrowser(wallet2.internalId);
|
|
663
|
+
if (!(isMobile() || isInDappBrowser) && isWithFullAuth(wallet2) && !isManualWalletConnect) {
|
|
646
664
|
const popupUrl = yield para.constructPortalUrl("connectExternalWallet");
|
|
647
|
-
if (typeof window !==
|
|
665
|
+
if (typeof window !== "undefined") {
|
|
648
666
|
refs.popupWindow.current = openPopup({
|
|
649
667
|
url: popupUrl,
|
|
650
668
|
type: "LOGIN_EXTERNAL_WALLET",
|
|
@@ -962,6 +980,7 @@ export {
|
|
|
962
980
|
ExternalWalletContext,
|
|
963
981
|
ExternalWalletProvider,
|
|
964
982
|
defaultExternalWallet,
|
|
983
|
+
isSolanaWalletInAppBrowser,
|
|
965
984
|
useExternalWallets,
|
|
966
985
|
useWalletDisplayHelpers
|
|
967
986
|
};
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/react-sdk-lite",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.21.0",
|
|
4
4
|
"bin": {
|
|
5
5
|
"setup-para": "dist/cli/cli.mjs"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@getpara/react-common": "2.
|
|
9
|
-
"@getpara/react-components": "2.
|
|
10
|
-
"@getpara/react-core": "2.
|
|
11
|
-
"@getpara/web-sdk": "2.
|
|
8
|
+
"@getpara/react-common": "2.21.0",
|
|
9
|
+
"@getpara/react-components": "2.21.0",
|
|
10
|
+
"@getpara/react-core": "2.21.0",
|
|
11
|
+
"@getpara/web-sdk": "2.21.0",
|
|
12
12
|
"date-fns": "^3.6.0",
|
|
13
13
|
"detect-browser": "^5.3.0",
|
|
14
14
|
"framer-motion": "^11.3.31",
|
|
@@ -19,19 +19,19 @@
|
|
|
19
19
|
"zustand-sync-tabs": "^0.2.2"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@getpara/aa-alchemy": "2.
|
|
23
|
-
"@getpara/aa-biconomy": "2.
|
|
24
|
-
"@getpara/aa-cdp": "2.
|
|
25
|
-
"@getpara/aa-gelato": "2.
|
|
26
|
-
"@getpara/aa-pimlico": "2.
|
|
27
|
-
"@getpara/aa-porto": "2.
|
|
28
|
-
"@getpara/aa-rhinestone": "2.
|
|
29
|
-
"@getpara/aa-safe": "2.
|
|
30
|
-
"@getpara/aa-thirdweb": "2.
|
|
31
|
-
"@getpara/aa-zerodev": "2.
|
|
32
|
-
"@getpara/cosmos-wallet-connectors": "2.
|
|
33
|
-
"@getpara/evm-wallet-connectors": "2.
|
|
34
|
-
"@getpara/solana-wallet-connectors": "2.
|
|
22
|
+
"@getpara/aa-alchemy": "2.21.0",
|
|
23
|
+
"@getpara/aa-biconomy": "2.21.0",
|
|
24
|
+
"@getpara/aa-cdp": "2.21.0",
|
|
25
|
+
"@getpara/aa-gelato": "2.21.0",
|
|
26
|
+
"@getpara/aa-pimlico": "2.21.0",
|
|
27
|
+
"@getpara/aa-porto": "2.21.0",
|
|
28
|
+
"@getpara/aa-rhinestone": "2.21.0",
|
|
29
|
+
"@getpara/aa-safe": "2.21.0",
|
|
30
|
+
"@getpara/aa-thirdweb": "2.21.0",
|
|
31
|
+
"@getpara/aa-zerodev": "2.21.0",
|
|
32
|
+
"@getpara/cosmos-wallet-connectors": "2.21.0",
|
|
33
|
+
"@getpara/evm-wallet-connectors": "2.21.0",
|
|
34
|
+
"@getpara/solana-wallet-connectors": "2.21.0",
|
|
35
35
|
"@tanstack/react-query": "^5.74.0",
|
|
36
36
|
"@testing-library/dom": "^10.4.0",
|
|
37
37
|
"@testing-library/react": "^16.3.0",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"package.json",
|
|
52
52
|
"styles.css"
|
|
53
53
|
],
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "61f68bb1344dcec458f9016db39f631bb630b8f4",
|
|
55
55
|
"main": "dist/index.js",
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"@getpara/aa-alchemy": ">=2.15.0",
|