@getpara/react-sdk-lite 2.20.0 → 2.22.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/aa/hooks/alchemy.d.ts +5 -2
- package/dist/aa/hooks/biconomy.d.ts +5 -2
- package/dist/aa/hooks/cdp.d.ts +5 -2
- package/dist/aa/hooks/gelato.d.ts +5 -2
- package/dist/aa/hooks/pimlico.d.ts +5 -2
- package/dist/aa/hooks/porto.d.ts +5 -2
- package/dist/aa/hooks/rhinestone.d.ts +5 -2
- package/dist/aa/hooks/safe.d.ts +5 -2
- package/dist/aa/hooks/thirdweb.d.ts +6 -1
- package/dist/aa/hooks/zerodev.d.ts +5 -2
- package/dist/chains/cosmos.d.ts +62 -0
- package/dist/chains/cosmos.js +10 -0
- package/dist/chains/evm.d.ts +74 -0
- package/dist/chains/evm.js +14 -0
- package/dist/chains/solana.d.ts +33 -0
- package/dist/chains/solana.js +8 -0
- package/dist/chains/stellar.d.ts +2 -0
- package/dist/chains/stellar.js +14 -0
- package/dist/chains/useGrazEnhancer.d.ts +7 -0
- package/dist/chains/useGrazEnhancer.js +28 -0
- package/dist/chains/useSolanaWalletEnhancer.d.ts +7 -0
- package/dist/chains/useSolanaWalletEnhancer.js +53 -0
- package/dist/chains/useWagmiEthersEnhancer.d.ts +7 -0
- package/dist/chains/useWagmiEthersEnhancer.js +67 -0
- package/dist/chains/useWagmiViemEnhancer.d.ts +7 -0
- package/dist/chains/useWagmiViemEnhancer.js +56 -0
- package/dist/modal/ParaModal.js +1 -1
- package/dist/modal/components/shared/ConnectExternalWallet/ConnectExternalWallet.js +27 -22
- package/dist/provider/ParaProviderMin.js +119 -112
- package/dist/provider/hooks/mutations/useAddAuthMethod.d.ts +1 -1
- package/dist/provider/hooks/mutations/useExportPrivateKey.d.ts +1 -1
- package/dist/provider/hooks/mutations/useSwitchWallets.d.ts +1 -1
- package/dist/provider/hooks/mutations/useVerifyNewAccount.d.ts +1 -1
- package/dist/provider/providers/ExternalWalletProvider.d.ts +1 -0
- package/dist/provider/providers/ExternalWalletProvider.js +21 -2
- package/dist/provider/types/provider.d.ts +8 -53
- package/package.json +52 -20
package/dist/modal/ParaModal.js
CHANGED
|
@@ -5,27 +5,14 @@ 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
|
|
15
|
-
|
|
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
|
-
};
|
|
14
|
+
const IN_APP_BROWSER_POLL_INTERVAL = 200;
|
|
15
|
+
const IN_APP_BROWSER_POLL_MAX_WAIT = 3e3;
|
|
29
16
|
const ExternalWalletMobileConnect = ({
|
|
30
17
|
wallet,
|
|
31
18
|
onConnectWc,
|
|
@@ -37,6 +24,24 @@ const ExternalWalletMobileConnect = ({
|
|
|
37
24
|
const appName = useStore((state) => state.appName);
|
|
38
25
|
const isWalletConnect = wallet.id === "WalletConnect";
|
|
39
26
|
const { qrUri } = useExternalWallets();
|
|
27
|
+
const [isInAppBrowser, setIsInAppBrowser] = useState(() => !!isSolanaWalletInAppBrowser(wallet.internalId));
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (isSolanaWalletInAppBrowser(wallet.internalId)) {
|
|
30
|
+
setIsInAppBrowser(true);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
let elapsed = 0;
|
|
34
|
+
const timer = setInterval(() => {
|
|
35
|
+
elapsed += IN_APP_BROWSER_POLL_INTERVAL;
|
|
36
|
+
if (isSolanaWalletInAppBrowser(wallet.internalId)) {
|
|
37
|
+
setIsInAppBrowser(true);
|
|
38
|
+
clearInterval(timer);
|
|
39
|
+
} else if (elapsed >= IN_APP_BROWSER_POLL_MAX_WAIT) {
|
|
40
|
+
clearInterval(timer);
|
|
41
|
+
}
|
|
42
|
+
}, IN_APP_BROWSER_POLL_INTERVAL);
|
|
43
|
+
return () => clearInterval(timer);
|
|
44
|
+
}, [wallet.internalId]);
|
|
40
45
|
const handleCopy = () => {
|
|
41
46
|
if (qrUri) {
|
|
42
47
|
copy(qrUri);
|
|
@@ -52,7 +57,7 @@ const ExternalWalletMobileConnect = ({
|
|
|
52
57
|
});
|
|
53
58
|
if (wallet.type === "SOLANA" || isMobile() && !isTablet()) {
|
|
54
59
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
55
|
-
wallet.type === "SOLANA" && !!qrUri && !
|
|
60
|
+
wallet.type === "SOLANA" && !!qrUri && !isInAppBrowser && /* @__PURE__ */ jsx(InnerStepContainer, { children: /* @__PURE__ */ jsx(
|
|
56
61
|
HeroSpinner,
|
|
57
62
|
{
|
|
58
63
|
icon: /* @__PURE__ */ jsx(HeroAccountTypeIcon, { accountType: wallet.internalId, src: wallet ? wallet.iconUrl : void 0 }),
|
|
@@ -66,12 +71,12 @@ const ExternalWalletMobileConnect = ({
|
|
|
66
71
|
HeroSpinner,
|
|
67
72
|
{
|
|
68
73
|
icon: /* @__PURE__ */ jsx(HeroAccountTypeIcon, { accountType: wallet.internalId, src: wallet ? wallet.iconUrl : void 0 }),
|
|
69
|
-
status: wallet.type === "SOLANA" && !
|
|
70
|
-
text: wallet.type === "SOLANA" && (!
|
|
74
|
+
status: wallet.type === "SOLANA" && !isInAppBrowser ? "idle" : isError ? "error" : "pending",
|
|
75
|
+
text: wallet.type === "SOLANA" && (!isInAppBrowser || wallet.hasIosSafariExtension) ? "" : isError ? externalWalletError[0] : `Confirm connection request in the ${wallet.name} app.`,
|
|
71
76
|
secondaryText: externalWalletError == null ? void 0 : externalWalletError[1]
|
|
72
77
|
}
|
|
73
78
|
),
|
|
74
|
-
wallet.type === "SOLANA" &&
|
|
79
|
+
wallet.type === "SOLANA" && isInAppBrowser && !wallet.hasIosSafariExtension || wallet.type !== "SOLANA" ? /* @__PURE__ */ jsx(
|
|
75
80
|
CpslButton,
|
|
76
81
|
{
|
|
77
82
|
onClick: handleRetryClick,
|
|
@@ -80,7 +85,7 @@ const ExternalWalletMobileConnect = ({
|
|
|
80
85
|
children: isError ? "Retry" : "Connect Wallet"
|
|
81
86
|
}
|
|
82
87
|
) : /* @__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: [
|
|
88
|
+
!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
89
|
`Get ${wallet.name}`,
|
|
85
90
|
/* @__PURE__ */ jsx(ExternalIcon, { icon: "linkExternal" })
|
|
86
91
|
] }) })
|
|
@@ -18,122 +18,129 @@ import { AccountLinkProvider } from "./providers/AccountLinkProvider.js";
|
|
|
18
18
|
import { AssetsProvider } from "./providers/AssetsProvider.js";
|
|
19
19
|
import { AuthProvider } from "./providers/AuthProvider/AuthProvider.js";
|
|
20
20
|
const coreStoreRef = storeInstance;
|
|
21
|
-
const ParaProviderMin = forwardRef(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
throw new Error("Invalid Para config");
|
|
37
|
-
}, [paraClientConfig]);
|
|
38
|
-
const configureClient = useCallback(
|
|
39
|
-
(client2) => {
|
|
40
|
-
client2.setModalError = setModalError;
|
|
41
|
-
if (typeof globalThis !== "undefined" && globalThis.__PARA_PORTAL_URL_OVERRIDE__) {
|
|
42
|
-
client2.ctx.portalUrlOverride = globalThis.__PARA_PORTAL_URL_OVERRIDE__;
|
|
21
|
+
const ParaProviderMin = forwardRef(
|
|
22
|
+
({ children, paraClientConfig, callbacks, config, externalWalletConfig, paraModalConfig, waitForReady, fallback }, ref) => {
|
|
23
|
+
var _a;
|
|
24
|
+
useEventListeners(callbacks);
|
|
25
|
+
useAutoSessionKeepAlive({ disabled: config.disableAutoSessionKeepAlive });
|
|
26
|
+
const setModalError = useStore((state) => state.setModalError);
|
|
27
|
+
const paraClient = useMemo(() => {
|
|
28
|
+
if (isParaWeb(paraClientConfig)) return paraClientConfig;
|
|
29
|
+
if (isConfigType(paraClientConfig)) {
|
|
30
|
+
return {
|
|
31
|
+
apiKey: paraClientConfig.apiKey,
|
|
32
|
+
env: paraClientConfig.env,
|
|
33
|
+
opts: paraClientConfig.opts,
|
|
34
|
+
createClient: (apiKey, env, opts) => env ? new ParaWeb(env, apiKey, opts) : new ParaWeb(apiKey, opts)
|
|
35
|
+
};
|
|
43
36
|
}
|
|
44
|
-
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
37
|
+
throw new Error("Invalid Para config");
|
|
38
|
+
}, [paraClientConfig]);
|
|
39
|
+
const configureClient = useCallback(
|
|
40
|
+
(client2) => {
|
|
41
|
+
client2.setModalError = setModalError;
|
|
42
|
+
if (typeof globalThis !== "undefined" && globalThis.__PARA_PORTAL_URL_OVERRIDE__) {
|
|
43
|
+
client2.ctx.portalUrlOverride = globalThis.__PARA_PORTAL_URL_OVERRIDE__;
|
|
44
|
+
}
|
|
45
|
+
client2.portalTheme = paraModalConfig == null ? void 0 : paraModalConfig.theme;
|
|
46
|
+
},
|
|
47
|
+
[setModalError, paraModalConfig == null ? void 0 : paraModalConfig.theme]
|
|
48
|
+
);
|
|
49
|
+
const client = useStore((state) => state.client);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
if (client) {
|
|
52
|
+
client.portalTheme = paraModalConfig == null ? void 0 : paraModalConfig.theme;
|
|
53
|
+
}
|
|
54
|
+
}, [paraModalConfig == null ? void 0 : paraModalConfig.theme, client]);
|
|
55
|
+
const setExternalWallets = useStore((state) => state.setExternalWallets);
|
|
56
|
+
const externalWallets = useStore((state) => state.externalWallets);
|
|
57
|
+
const setExternalWalletsWithFullAuth = useStore((state) => state.setExternalWalletsWithFullAuth);
|
|
58
|
+
const externalWalletsWithFullAuth = useStore((state) => state.externalWalletsWithFullAuth);
|
|
59
|
+
const setIncludeWalletVerification = useStore((state) => state.setIncludeWalletVerification);
|
|
60
|
+
const includeWalletVerification = useStore((state) => state.includeWalletVerification);
|
|
61
|
+
const setConnectionOnly = useStore((state) => state.setConnectionOnly);
|
|
62
|
+
const connectionOnly = useStore((state) => state.connectionOnly);
|
|
63
|
+
const setModalConfig = useStore((state) => state.setModalConfig);
|
|
64
|
+
const modalConfig = useStore((state) => state.modalConfig);
|
|
65
|
+
const setProviderProps = useStore((state) => state.setProviderProps);
|
|
66
|
+
const paraState = useStore((state) => state.paraState);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
setProviderProps(__spreadProps(__spreadValues(__spreadValues(__spreadValues({}, config), externalWalletConfig), paraModalConfig), {
|
|
69
|
+
walletConnect: void 0
|
|
70
|
+
}));
|
|
71
|
+
}, [config, externalWalletConfig, paraModalConfig]);
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (modalConfig !== paraModalConfig) setModalConfig(paraModalConfig);
|
|
74
|
+
}, [paraModalConfig]);
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
var _a2;
|
|
77
|
+
if (connectionOnly !== (externalWalletConfig == null ? void 0 : externalWalletConfig.connectionOnly)) {
|
|
78
|
+
setConnectionOnly((_a2 = externalWalletConfig == null ? void 0 : externalWalletConfig.connectionOnly) != null ? _a2 : false);
|
|
79
|
+
}
|
|
80
|
+
}, [externalWalletConfig == null ? void 0 : externalWalletConfig.connectionOnly]);
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
var _a2, _b;
|
|
83
|
+
if (includeWalletVerification !== (externalWalletConfig == null ? void 0 : externalWalletConfig.includeWalletVerification)) {
|
|
84
|
+
if ((externalWalletConfig == null ? void 0 : externalWalletConfig.connectionOnly) || (isParaWeb(paraClientConfig) ? paraClientConfig.externalWalletConnectionOnly : (_a2 = paraClientConfig.opts) == null ? void 0 : _a2.externalWalletConnectionOnly)) {
|
|
85
|
+
console.warn("includeWalletVerification has no effect when using connection only external wallets");
|
|
86
|
+
setIncludeWalletVerification(false);
|
|
87
|
+
} else {
|
|
88
|
+
setIncludeWalletVerification((_b = externalWalletConfig == null ? void 0 : externalWalletConfig.includeWalletVerification) != null ? _b : false);
|
|
89
|
+
}
|
|
88
90
|
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
setExternalWallets((_a2 = externalWalletConfig == null ? void 0 : externalWalletConfig.wallets) != null ? _a2 : [...EXTERNAL_WALLET_TYPES]);
|
|
95
|
-
}
|
|
96
|
-
}, [externalWalletConfig == null ? void 0 : externalWalletConfig.wallets]);
|
|
97
|
-
useEffect(() => {
|
|
98
|
-
var _a2, _b;
|
|
99
|
-
if (externalWalletsWithFullAuth !== (externalWalletConfig == null ? void 0 : externalWalletConfig.createLinkedEmbeddedForExternalWallets)) {
|
|
100
|
-
if ((externalWalletConfig == null ? void 0 : externalWalletConfig.connectionOnly) || (isParaWeb(paraClientConfig) ? paraClientConfig.externalWalletConnectionOnly : (_a2 = paraClientConfig.opts) == null ? void 0 : _a2.externalWalletConnectionOnly)) {
|
|
101
|
-
console.warn("createLinkedEmbeddedForExternalWallets has no effect when using connection only external wallets");
|
|
102
|
-
setExternalWalletsWithFullAuth([]);
|
|
103
|
-
} else {
|
|
104
|
-
setExternalWalletsWithFullAuth((_b = externalWalletConfig == null ? void 0 : externalWalletConfig.createLinkedEmbeddedForExternalWallets) != null ? _b : []);
|
|
91
|
+
}, [externalWalletConfig == null ? void 0 : externalWalletConfig.includeWalletVerification]);
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
var _a2;
|
|
94
|
+
if (externalWallets !== (externalWalletConfig == null ? void 0 : externalWalletConfig.wallets)) {
|
|
95
|
+
setExternalWallets((_a2 = externalWalletConfig == null ? void 0 : externalWalletConfig.wallets) != null ? _a2 : [...EXTERNAL_WALLET_TYPES]);
|
|
105
96
|
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
!config.disableEmbeddedModal && /* @__PURE__ */ jsx(ParaModal, { ref })
|
|
116
|
-
] });
|
|
117
|
-
}, [isReady, children, config.disableEmbeddedModal, ref]);
|
|
118
|
-
return /* @__PURE__ */ jsx(
|
|
119
|
-
ParaProviderCore,
|
|
120
|
-
{
|
|
121
|
-
paraClientConfig: paraClient,
|
|
122
|
-
config,
|
|
123
|
-
configureClient,
|
|
124
|
-
store: coreStoreRef,
|
|
125
|
-
waitForReady: false,
|
|
126
|
-
children: /* @__PURE__ */ jsx(
|
|
127
|
-
AuthProvider,
|
|
128
|
-
{
|
|
129
|
-
isTwoFactorAuthEnabled: paraModalConfig == null ? void 0 : paraModalConfig.twoFactorAuthEnabled,
|
|
130
|
-
defaultAuthIdentifier: paraModalConfig == null ? void 0 : paraModalConfig.defaultAuthIdentifier,
|
|
131
|
-
children: /* @__PURE__ */ jsx(AssetsProvider, { children: /* @__PURE__ */ jsx(ExternalWalletWrapper, { config: externalWalletConfig, children: /* @__PURE__ */ jsx(AccountLinkProvider, { children: ChildrenComponents }) }) })
|
|
97
|
+
}, [externalWalletConfig == null ? void 0 : externalWalletConfig.wallets]);
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
var _a2, _b;
|
|
100
|
+
if (externalWalletsWithFullAuth !== (externalWalletConfig == null ? void 0 : externalWalletConfig.createLinkedEmbeddedForExternalWallets)) {
|
|
101
|
+
if ((externalWalletConfig == null ? void 0 : externalWalletConfig.connectionOnly) || (isParaWeb(paraClientConfig) ? paraClientConfig.externalWalletConnectionOnly : (_a2 = paraClientConfig.opts) == null ? void 0 : _a2.externalWalletConnectionOnly)) {
|
|
102
|
+
console.warn("createLinkedEmbeddedForExternalWallets has no effect when using connection only external wallets");
|
|
103
|
+
setExternalWalletsWithFullAuth([]);
|
|
104
|
+
} else {
|
|
105
|
+
setExternalWalletsWithFullAuth((_b = externalWalletConfig == null ? void 0 : externalWalletConfig.createLinkedEmbeddedForExternalWallets) != null ? _b : []);
|
|
132
106
|
}
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
107
|
+
}
|
|
108
|
+
}, [externalWalletConfig == null ? void 0 : externalWalletConfig.createLinkedEmbeddedForExternalWallets]);
|
|
109
|
+
const isReady = (_a = paraState == null ? void 0 : paraState.isReady) != null ? _a : false;
|
|
110
|
+
const shouldWait = waitForReady !== false;
|
|
111
|
+
const ChildrenComponents = useMemo(() => {
|
|
112
|
+
if (shouldWait && !isReady) {
|
|
113
|
+
if (!!(paraState == null ? void 0 : paraState.error)) {
|
|
114
|
+
return children || null;
|
|
115
|
+
}
|
|
116
|
+
return fallback != null ? fallback : null;
|
|
117
|
+
}
|
|
118
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
119
|
+
children,
|
|
120
|
+
!config.disableEmbeddedModal && isReady && /* @__PURE__ */ jsx(ParaModal, { ref })
|
|
121
|
+
] });
|
|
122
|
+
}, [shouldWait, isReady, paraState == null ? void 0 : paraState.error, fallback, children, config.disableEmbeddedModal, ref]);
|
|
123
|
+
return /* @__PURE__ */ jsx(
|
|
124
|
+
ParaProviderCore,
|
|
125
|
+
{
|
|
126
|
+
paraClientConfig: paraClient,
|
|
127
|
+
config,
|
|
128
|
+
configureClient,
|
|
129
|
+
store: coreStoreRef,
|
|
130
|
+
waitForReady: false,
|
|
131
|
+
fallback,
|
|
132
|
+
children: /* @__PURE__ */ jsx(
|
|
133
|
+
AuthProvider,
|
|
134
|
+
{
|
|
135
|
+
isTwoFactorAuthEnabled: paraModalConfig == null ? void 0 : paraModalConfig.twoFactorAuthEnabled,
|
|
136
|
+
defaultAuthIdentifier: paraModalConfig == null ? void 0 : paraModalConfig.defaultAuthIdentifier,
|
|
137
|
+
children: /* @__PURE__ */ jsx(AssetsProvider, { children: /* @__PURE__ */ jsx(ExternalWalletWrapper, { config: externalWalletConfig, children: /* @__PURE__ */ jsx(AccountLinkProvider, { children: ChildrenComponents }) }) })
|
|
138
|
+
}
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
);
|
|
137
144
|
export {
|
|
138
145
|
ParaProviderMin
|
|
139
146
|
};
|
|
@@ -18,10 +18,10 @@ export declare const ADD_CREDENTIAL_KEY = "ADD_CREDENTIAL";
|
|
|
18
18
|
export declare const useAddAuthMethod: ({ openPopup }?: {
|
|
19
19
|
openPopup: boolean;
|
|
20
20
|
}) => {
|
|
21
|
-
error: Error | null;
|
|
22
21
|
isSuccess: boolean;
|
|
23
22
|
data: string | undefined;
|
|
24
23
|
variables: void | AddCredentialParams | undefined;
|
|
24
|
+
error: Error | null;
|
|
25
25
|
isError: boolean;
|
|
26
26
|
isIdle: boolean;
|
|
27
27
|
isPending: boolean;
|
|
@@ -11,10 +11,10 @@ export declare const EXPORT_PRIVATE_KEY_KEY = "EXPORT_PRIVATE_KEY";
|
|
|
11
11
|
* await exportPrivateKeyAsync({ walletId: '...' });
|
|
12
12
|
*/
|
|
13
13
|
export declare const useExportPrivateKey: () => {
|
|
14
|
-
error: Error | null;
|
|
15
14
|
isSuccess: boolean;
|
|
16
15
|
data: ExportPrivateKeyResponse | undefined;
|
|
17
16
|
variables: ExportPrivateKeyParams;
|
|
17
|
+
error: Error | null;
|
|
18
18
|
isError: boolean;
|
|
19
19
|
isIdle: boolean;
|
|
20
20
|
isPending: boolean;
|
|
@@ -15,10 +15,10 @@ export declare const SWITCH_WALLETS_KEY = "SWITCH_WALLETS";
|
|
|
15
15
|
* await switchWalletsAsync({ authMethod: 'PASSKEY' });
|
|
16
16
|
*/
|
|
17
17
|
export declare const useSwitchWallets: () => {
|
|
18
|
-
error: Error | null;
|
|
19
18
|
isSuccess: boolean;
|
|
20
19
|
data: WaitForLoginResponse | undefined;
|
|
21
20
|
variables: void | WaitForLoginParams | undefined;
|
|
21
|
+
error: Error | null;
|
|
22
22
|
isError: boolean;
|
|
23
23
|
isIdle: boolean;
|
|
24
24
|
isPending: boolean;
|
|
@@ -15,10 +15,10 @@ export declare const VERIFY_NEW_ACCOUNT_KEY = "VERIFY_NEW_ACCOUNT";
|
|
|
15
15
|
* await verifyNewAccountAsync({ ...params });
|
|
16
16
|
*/
|
|
17
17
|
export declare const useVerifyNewAccount: () => {
|
|
18
|
-
error: Error | null;
|
|
19
18
|
isSuccess: boolean;
|
|
20
19
|
data: import("@getpara/web-sdk").AuthStateSignup | undefined;
|
|
21
20
|
variables: VerifyNewAccountParams | undefined;
|
|
21
|
+
error: Error | null;
|
|
22
22
|
isError: boolean;
|
|
23
23
|
isIdle: boolean;
|
|
24
24
|
isPending: boolean;
|
|
@@ -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
|
};
|
|
@@ -1,47 +1,26 @@
|
|
|
1
1
|
import { ParaWagmiProviderProps } from '@getpara/evm-wallet-connectors';
|
|
2
|
-
import ParaWeb, {
|
|
3
|
-
import { PropsWithChildren } from 'react';
|
|
2
|
+
import ParaWeb, { ExternalWalletChangeEvent, PregenWalletClaimedEvent, GuestWalletsCreatedEvent } from '@getpara/web-sdk';
|
|
4
3
|
import { Chain, Transport } from 'viem';
|
|
5
4
|
import { ParaModalProps } from '../../modal/index.js';
|
|
6
5
|
import { ParaGrazProviderProps } from '@getpara/cosmos-wallet-connectors';
|
|
7
6
|
import { ParaCosmosProviderConfigNoWallets, ParaEvmProviderConfigNoWallets, ParaSolanaProviderConfigNoWallets } from './externalWalletProviders.js';
|
|
8
7
|
import { type TExternalWallet } from '@getpara/react-common';
|
|
9
|
-
import {
|
|
10
|
-
export
|
|
11
|
-
onLogout?: (event: LogoutEvent) => void;
|
|
12
|
-
onLogin?: (event: LoginEvent) => void;
|
|
13
|
-
onAccountSetup?: (event: AccountSetupEvent) => void;
|
|
14
|
-
onAccountCreation?: (event: AccountCreationEvent) => void;
|
|
15
|
-
onSignMessage?: (event: SignMessageEvent) => void;
|
|
16
|
-
onSignTransaction?: (event: SignTransactionEvent) => void;
|
|
8
|
+
import type { ParaProviderBaseProps, CoreProviderConfig, CoreCallbacks } from '@getpara/react-core/internal';
|
|
9
|
+
export interface Callbacks extends CoreCallbacks {
|
|
17
10
|
onExternalWalletChange?: (event: ExternalWalletChangeEvent) => void;
|
|
18
|
-
onWalletsChange?: (event: WalletsChangeEvent) => void;
|
|
19
|
-
onWalletCreated?: (event: WalletCreatedEvent) => void;
|
|
20
11
|
onPregenWalletClaimed?: (event: PregenWalletClaimedEvent) => void;
|
|
21
12
|
onGuestWalletsCreated?: (event: GuestWalletsCreatedEvent) => void;
|
|
22
|
-
}
|
|
23
|
-
export
|
|
24
|
-
/**
|
|
25
|
-
* The name of your app, used throughout the modal and any configured external wallets.
|
|
26
|
-
*/
|
|
27
|
-
appName: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ParaProviderConfig extends CoreProviderConfig {
|
|
28
15
|
/**
|
|
29
16
|
* Disables the automatic session keep alive that's provided by ParaProvider.
|
|
30
17
|
*/
|
|
31
18
|
disableAutoSessionKeepAlive?: boolean;
|
|
32
19
|
/**
|
|
33
|
-
* Disables the ParaModal that's provided by ParaProvider. Use this
|
|
20
|
+
* Disables the ParaModal that's provided by ParaProvider. Use this if you're providing a separate modal in another location in your app.
|
|
34
21
|
*/
|
|
35
22
|
disableEmbeddedModal?: boolean;
|
|
36
|
-
|
|
37
|
-
* RPC url to use for retrieving the embedded wallet balance
|
|
38
|
-
*/
|
|
39
|
-
rpcUrl?: string;
|
|
40
|
-
/**
|
|
41
|
-
* Configuration options for Farcaster mini-apps.
|
|
42
|
-
*/
|
|
43
|
-
farcasterMiniAppConfig?: FarcasterMiniAppConfig;
|
|
44
|
-
};
|
|
23
|
+
}
|
|
45
24
|
export type ExternalWalletConfig<chains extends readonly [Chain, ...Chain[]], transports extends Record<chains[number]['id'], Transport>> = {
|
|
46
25
|
/**
|
|
47
26
|
* A description of your app, displayed in some external wallets.
|
|
@@ -130,35 +109,11 @@ export type ExternalWalletConfig<chains extends readonly [Chain, ...Chain[]], tr
|
|
|
130
109
|
*/
|
|
131
110
|
connectionOnly?: boolean;
|
|
132
111
|
};
|
|
133
|
-
export interface ParaProviderProps<chains extends readonly [Chain, ...Chain[]], transports extends Record<chains[number]['id'], Transport>> extends
|
|
134
|
-
/**
|
|
135
|
-
* Arguments to setup a new Para instance, or a Para instance you have already instantiated.
|
|
136
|
-
*/
|
|
137
|
-
paraClientConfig: {
|
|
138
|
-
/**
|
|
139
|
-
* Environment for your Para instance.
|
|
140
|
-
*/
|
|
141
|
-
env?: Environment;
|
|
142
|
-
/**
|
|
143
|
-
* API key for you Para instance.
|
|
144
|
-
*
|
|
145
|
-
* NOTE: Be sure this key matches the environment.
|
|
146
|
-
*/
|
|
147
|
-
apiKey: string;
|
|
148
|
-
opts?: ConstructorOpts;
|
|
149
|
-
} | ParaWeb;
|
|
112
|
+
export interface ParaProviderProps<chains extends readonly [Chain, ...Chain[]], transports extends Record<chains[number]['id'], Transport>> extends ParaProviderBaseProps<ParaWeb, ParaProviderConfig, Callbacks> {
|
|
150
113
|
/**
|
|
151
114
|
* Configuration used for the Para modal.
|
|
152
115
|
*/
|
|
153
116
|
paraModalConfig?: ParaModalProps;
|
|
154
|
-
/**
|
|
155
|
-
* Callbacks fired for events from the Para instance.
|
|
156
|
-
*/
|
|
157
|
-
callbacks?: Callbacks;
|
|
158
|
-
/**
|
|
159
|
-
* Config for the ParaProvider.
|
|
160
|
-
*/
|
|
161
|
-
config: ParaProviderConfig;
|
|
162
117
|
/**
|
|
163
118
|
* Config for any external wallets.
|
|
164
119
|
*/
|