@getpara/react-sdk 2.0.0-alpha.27 → 2.0.0-alpha.28
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 +6 -6
- package/dist/modal/components/Account/Account.js +2 -2
- package/dist/modal/components/Account/AccountProfile.js +7 -8
- package/dist/modal/components/AddFunds/AddFunds.js +2 -2
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +2 -2
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +2 -2
- package/dist/modal/components/Controls/Controls.js +2 -2
- package/dist/modal/components/Controls/Selects.js +2 -2
- package/dist/modal/components/ExternalWalletVerificationStep/ExternalWalletVerificationStep.js +2 -2
- package/dist/modal/components/Footer/Footer.js +3 -3
- package/dist/modal/constants/constants.d.ts +1 -1
- package/dist/modal/constants/constants.js +1 -1
- package/dist/provider/actions/{getAccount.d.ts → getEmbeddedAccount.d.ts} +3 -3
- package/dist/provider/actions/{getAccount.js → getEmbeddedAccount.js} +11 -13
- package/dist/provider/external/getParaCosmosConnector.js +4 -7
- package/dist/provider/external/getParaCosmosLib.d.ts +4 -0
- package/dist/provider/external/getParaCosmosLib.js +16 -0
- package/dist/provider/external/getParaEvmConnector.js +4 -7
- package/dist/provider/external/getParaEvmLib.d.ts +4 -0
- package/dist/provider/external/getParaEvmLib.js +16 -0
- package/dist/provider/external/getParaSolanaConnector.js +4 -7
- package/dist/provider/external/getParaSolanaLib.d.ts +4 -0
- package/dist/provider/external/getParaSolanaLib.js +16 -0
- package/dist/provider/hooks/queries/useAccount.d.ts +87 -2
- package/dist/provider/hooks/queries/useAccount.js +106 -7
- package/dist/provider/hooks/queries/useWalletBalance.js +3 -3
- package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +3 -3
- package/dist/provider/providers/AccountLinkProvider.js +5 -4
- package/dist/provider/providers/ExternalWalletProvider.d.ts +0 -2
- package/dist/provider/providers/ExternalWalletProvider.js +15 -25
- package/dist/provider/stores/slices/externalWallets.js +2 -0
- package/dist/provider/stores/types.d.ts +3 -0
- package/package.json +8 -8
package/dist/modal/ParaModal.js
CHANGED
|
@@ -48,7 +48,7 @@ const ParaModal = forwardRef((props, ref) => {
|
|
|
48
48
|
const { setSelectedWallet, updateSelectedWallet } = useWalletState();
|
|
49
49
|
const setAuthStepRoute = useModalStore((state) => state.setAuthStepRoute);
|
|
50
50
|
const { signUpOrLogIn, isCreateGuestWalletsPending } = useAuthActions();
|
|
51
|
-
const {
|
|
51
|
+
const { isLoading: isAccountLoading, isConnected } = useAccount();
|
|
52
52
|
const [isModalMounted, setIsModalMounted] = useState(false);
|
|
53
53
|
const externalWallets = useStore((state) => state.externalWallets);
|
|
54
54
|
const providerProps = useStore((state) => state.providerProps);
|
|
@@ -133,7 +133,7 @@ const ParaModal = forwardRef((props, ref) => {
|
|
|
133
133
|
}, [hasPreviousStep, currentStep]);
|
|
134
134
|
const initModal = (shouldAutoLogin) => __async(void 0, null, function* () {
|
|
135
135
|
var _a2;
|
|
136
|
-
const isAccount =
|
|
136
|
+
const isAccount = isConnected, isGuest = isAccount && para.isGuestMode || isCreateGuestWalletsPending;
|
|
137
137
|
switch (true) {
|
|
138
138
|
case !!currentStepOverride:
|
|
139
139
|
setStep(ModalStep[currentStepOverride.toUpperCase()]);
|
|
@@ -177,7 +177,7 @@ const ParaModal = forwardRef((props, ref) => {
|
|
|
177
177
|
}
|
|
178
178
|
});
|
|
179
179
|
useEffect(() => {
|
|
180
|
-
if (para && isOpen &&
|
|
180
|
+
if (para && isOpen && !isAccountLoading && !isInitialized.current) {
|
|
181
181
|
initModal(isOpen);
|
|
182
182
|
isInitialized.current = true;
|
|
183
183
|
}
|
|
@@ -185,7 +185,7 @@ const ParaModal = forwardRef((props, ref) => {
|
|
|
185
185
|
initModal();
|
|
186
186
|
isInitialized.current = false;
|
|
187
187
|
}
|
|
188
|
-
}, [para, isOpen,
|
|
188
|
+
}, [para, isOpen, isAccountLoading]);
|
|
189
189
|
useEffect(() => {
|
|
190
190
|
let _authLayout = authLayout;
|
|
191
191
|
if (!(externalWallets == null ? void 0 : externalWallets.length) && hasExternalWallet(authLayout)) {
|
|
@@ -210,10 +210,10 @@ const ParaModal = forwardRef((props, ref) => {
|
|
|
210
210
|
updateSelectedWallet();
|
|
211
211
|
}, [para]);
|
|
212
212
|
useEffect(() => {
|
|
213
|
-
if (bareModal &&
|
|
213
|
+
if (bareModal && !isAccountLoading && !isConnected && !["signup", "login"].includes(flow != null ? flow : "") && refs.currentStep.current !== ModalStep.AUTH_MAIN) {
|
|
214
214
|
setStep(ModalStep.AUTH_MAIN);
|
|
215
215
|
}
|
|
216
|
-
}, [bareModal, flow,
|
|
216
|
+
}, [bareModal, flow, isConnected, isAccountLoading]);
|
|
217
217
|
useEffect(() => {
|
|
218
218
|
setAccountLinkOptions(propsSupportedAccountLinks != null ? propsSupportedAccountLinks : para == null ? void 0 : para.supportedAccountLinks);
|
|
219
219
|
}, [propsSupportedAccountLinks, para == null ? void 0 : para.supportedAccountLinks]);
|
|
@@ -28,11 +28,11 @@ const Account = ({ onClose }) => {
|
|
|
28
28
|
});
|
|
29
29
|
const { disconnectExternalWallet } = useExternalWallets();
|
|
30
30
|
const para = useInternalClient();
|
|
31
|
-
const {
|
|
31
|
+
const { embedded } = useAccount();
|
|
32
32
|
const { data: balance, isLoading: isBalanceLoading } = useWalletBalance();
|
|
33
33
|
const { isEnabled } = useAccountLinking();
|
|
34
34
|
const [isDisconnecting, setIsDisconnecting] = useState(false);
|
|
35
|
-
const isGuestMode =
|
|
35
|
+
const isGuestMode = embedded.isConnected && embedded.isGuestMode;
|
|
36
36
|
const cantBuyAndWithdraw = (para.externalWalletConnectionType === "CONNECTION_ONLY" || para.externalWalletConnectionType === "VERIFICATION") && !para.userId;
|
|
37
37
|
const isOnRampLoaded = !!onRampConfig;
|
|
38
38
|
const handleBuyClick = () => {
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { AccountTypeIcon, GradientScroll, StepContainer } from "../common.js";
|
|
8
8
|
import { CpslButton, CpslIcon, CpslIdenticon, CpslText } from "@getpara/react-components";
|
|
9
|
-
import {
|
|
9
|
+
import { useClient } from "../../../provider/index.js";
|
|
10
10
|
import { useLinkedAccounts } from "../../../provider/hooks/index.js";
|
|
11
11
|
import { getWalletDisplayName } from "../../utils/getWalletDisplayName.js";
|
|
12
12
|
import { truncateAddress } from "@getpara/web-sdk";
|
|
@@ -45,15 +45,14 @@ const Entry = ({
|
|
|
45
45
|
] }, address != null ? address : identifier);
|
|
46
46
|
};
|
|
47
47
|
const AccountProfile = () => {
|
|
48
|
-
var _a, _b, _c, _d, _e;
|
|
48
|
+
var _a, _b, _c, _d, _e, _f;
|
|
49
49
|
const para = useClient();
|
|
50
|
-
const { data: account } = useAccount();
|
|
51
50
|
const { data: linkedAccounts } = useLinkedAccounts();
|
|
52
51
|
const { isEnabled, linkAccount, unlinkAccount } = useAccountLinking();
|
|
53
52
|
if (!para) {
|
|
54
53
|
return null;
|
|
55
54
|
}
|
|
56
|
-
const externalWallet =
|
|
55
|
+
const externalWallet = (_a = para.authInfo) == null ? void 0 : _a.externalWallet;
|
|
57
56
|
return /* @__PURE__ */ jsxs(StepContainer, { $wide: true, children: [
|
|
58
57
|
/* @__PURE__ */ jsxs(Section, { children: [
|
|
59
58
|
/* @__PURE__ */ jsx(Title, { variant: "bodyS", color: "secondary", children: "Connected Wallets" }),
|
|
@@ -61,14 +60,14 @@ const AccountProfile = () => {
|
|
|
61
60
|
Entry,
|
|
62
61
|
{
|
|
63
62
|
icon: /* @__PURE__ */ jsx(AccountTypeIcon, { accountType: externalWallet.providerId, size: "24px" }),
|
|
64
|
-
name: (
|
|
65
|
-
address: (
|
|
66
|
-
addressShort: truncateAddress((
|
|
63
|
+
name: (_c = (_b = externalWallet.ensName) != null ? _b : getAccountTypeName(externalWallet.providerId)) != null ? _c : "",
|
|
64
|
+
address: (_d = externalWallet.addressBech32) != null ? _d : externalWallet.address,
|
|
65
|
+
addressShort: truncateAddress((_e = externalWallet.addressBech32) != null ? _e : externalWallet.address, externalWallet.type, {
|
|
67
66
|
prefix: para.cosmosPrefix
|
|
68
67
|
})
|
|
69
68
|
},
|
|
70
69
|
externalWallet.address
|
|
71
|
-
) : (
|
|
70
|
+
) : (_f = para == null ? void 0 : para.availableWallets) == null ? void 0 : _f.map((wallet) => {
|
|
72
71
|
var _a2;
|
|
73
72
|
return /* @__PURE__ */ jsx(
|
|
74
73
|
Entry,
|
|
@@ -22,8 +22,8 @@ const AddFunds = () => {
|
|
|
22
22
|
const setModalStep = useModalStore((state) => state.setStep);
|
|
23
23
|
const setOnRampPurchase = useModalStore((state) => state.setOnRampPurchase);
|
|
24
24
|
const { data: activeWallet } = useWallet();
|
|
25
|
-
const {
|
|
26
|
-
const isGuestMode = (
|
|
25
|
+
const { embedded } = useAccount();
|
|
26
|
+
const isGuestMode = (embedded == null ? void 0 : embedded.isConnected) && embedded.isGuestMode;
|
|
27
27
|
const tabs = TABS.filter(
|
|
28
28
|
([enabledFlow, key]) => !!(onRampConfig == null ? void 0 : onRampConfig[key]) && (!isGuestMode || enabledFlow === EnabledFlow.RECEIVE)
|
|
29
29
|
);
|
|
@@ -22,7 +22,7 @@ const AuthMainStepContent = ({
|
|
|
22
22
|
}) => {
|
|
23
23
|
const { wallets } = useExternalWallets();
|
|
24
24
|
const { createGuestWallets } = useAuthActions();
|
|
25
|
-
const {
|
|
25
|
+
const { embedded } = useAccount();
|
|
26
26
|
const authLayout = useModalStore((state) => state.authLayout);
|
|
27
27
|
const setStep = useModalStore((state) => state.setStep);
|
|
28
28
|
const oAuthLogoVariant = useStore((state) => state.oAuthLogoVariant);
|
|
@@ -30,7 +30,7 @@ const AuthMainStepContent = ({
|
|
|
30
30
|
var _a, _b;
|
|
31
31
|
return ((_b = (_a = state.modalConfig) == null ? void 0 : _a.theme) == null ? void 0 : _b.mode) === "dark";
|
|
32
32
|
});
|
|
33
|
-
const isGuestMode = (
|
|
33
|
+
const isGuestMode = (embedded == null ? void 0 : embedded.isConnected) && embedded.isGuestMode;
|
|
34
34
|
const useBrandedLogos = oAuthLogoVariant === "default";
|
|
35
35
|
const useDarkLogos = useBrandedLogos ? isDark : oAuthLogoVariant !== "dark";
|
|
36
36
|
const handleCondensedAuthClick = () => {
|
|
@@ -14,7 +14,7 @@ const AwaitingWalletCreationStep = ({ isGuestMode = false }) => {
|
|
|
14
14
|
});
|
|
15
15
|
const [showInfoBox, setShowInfoBox] = useState(false);
|
|
16
16
|
const showInfoBoxTimeout = useRef();
|
|
17
|
-
const {
|
|
17
|
+
const { embedded } = useAccount();
|
|
18
18
|
useEffect(() => {
|
|
19
19
|
if (typeof window !== "undefined") {
|
|
20
20
|
showInfoBoxTimeout.current = window.setTimeout(() => {
|
|
@@ -27,7 +27,7 @@ const AwaitingWalletCreationStep = ({ isGuestMode = false }) => {
|
|
|
27
27
|
/* @__PURE__ */ jsx(
|
|
28
28
|
Waiting,
|
|
29
29
|
{
|
|
30
|
-
heading: isGuestMode ? "Creating Guest Account" : (
|
|
30
|
+
heading: isGuestMode ? "Creating Guest Account" : (embedded == null ? void 0 : embedded.isGuestMode) ? hideWallets ? "Linking Guest Account" : "Linking Guest Wallet" : hideWallets ? "Creating Your Account" : "Creating Your Wallet",
|
|
31
31
|
subheading: "This should only take a couple of seconds."
|
|
32
32
|
}
|
|
33
33
|
),
|
|
@@ -18,7 +18,7 @@ const Controls = ({ onClose }) => {
|
|
|
18
18
|
const hasPreviousStep = useModalStore((state) => state.hasPreviousStep());
|
|
19
19
|
const step = useModalStore((state) => state.step);
|
|
20
20
|
const goBack = useGoBack();
|
|
21
|
-
const {
|
|
21
|
+
const { isConnected } = useAccount();
|
|
22
22
|
const shouldShowSelects = [
|
|
23
23
|
ModalStep.ACCOUNT_MAIN,
|
|
24
24
|
ModalStep.CHAIN_SWITCH,
|
|
@@ -41,7 +41,7 @@ const Controls = ({ onClose }) => {
|
|
|
41
41
|
children: /* @__PURE__ */ jsx(CpslIcon, { icon: "arrow" })
|
|
42
42
|
}
|
|
43
43
|
),
|
|
44
|
-
/* @__PURE__ */ jsx(MiddleContainer, { children: shouldShowSelects &&
|
|
44
|
+
/* @__PURE__ */ jsx(MiddleContainer, { children: shouldShowSelects && isConnected && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
45
45
|
/* @__PURE__ */ jsx(ChainSelect, {}),
|
|
46
46
|
/* @__PURE__ */ jsx(AccountSelect, {})
|
|
47
47
|
] }) }),
|
|
@@ -73,8 +73,8 @@ const AccountSelect = () => {
|
|
|
73
73
|
const [isCopied, copy] = useCopyToClipboard();
|
|
74
74
|
const { setSelectedWallet } = useWalletState();
|
|
75
75
|
const { data: activeWallet } = useWallet();
|
|
76
|
-
const {
|
|
77
|
-
const availableWallets =
|
|
76
|
+
const { embedded } = useAccount();
|
|
77
|
+
const availableWallets = embedded == null ? void 0 : embedded.wallets;
|
|
78
78
|
const isGuest = para.isGuestMode && (activeWallet == null ? void 0 : activeWallet.pregenIdentifierType) === "GUEST_ID";
|
|
79
79
|
const handleCopy = () => {
|
|
80
80
|
copy((activeWallet == null ? void 0 : activeWallet.address) ? para.getDisplayAddress(activeWallet.id, { addressType: activeWallet.type }) : "");
|
package/dist/modal/components/ExternalWalletVerificationStep/ExternalWalletVerificationStep.js
CHANGED
|
@@ -9,7 +9,7 @@ import { useExternalWallets } from "../../../provider/providers/ExternalWalletPr
|
|
|
9
9
|
import { useEffect, useRef } from "react";
|
|
10
10
|
const ExternalWalletVerificationStep = () => {
|
|
11
11
|
const effectRan = useRef(false);
|
|
12
|
-
const {
|
|
12
|
+
const { verifyWalletSignature } = useExternalWallets();
|
|
13
13
|
const externalWalletError = useModalStore((state) => state.externalWalletError);
|
|
14
14
|
useEffect(() => {
|
|
15
15
|
const hasRun = effectRan.current;
|
|
@@ -27,7 +27,7 @@ const ExternalWalletVerificationStep = () => {
|
|
|
27
27
|
/* @__PURE__ */ jsx(CpslText, { weight: "semiBold", color: "error", children: externalWalletError == null ? void 0 : externalWalletError[0] })
|
|
28
28
|
] })
|
|
29
29
|
] }),
|
|
30
|
-
/* @__PURE__ */ jsx(InnerStepContainer, { children:
|
|
30
|
+
/* @__PURE__ */ jsx(InnerStepContainer, { children: !externalWalletError || !effectRan.current ? /* @__PURE__ */ jsx(CpslSpinner, {}) : /* @__PURE__ */ jsx(CpslButton, { onClick: verifyWalletSignature, children: "Retry" }) })
|
|
31
31
|
] });
|
|
32
32
|
};
|
|
33
33
|
const InlineText = safeStyled(CpslText)`
|
|
@@ -9,9 +9,9 @@ import { useMemo } from "react";
|
|
|
9
9
|
import { getStepHasFooter } from "../../utils/steps.js";
|
|
10
10
|
import { useAccount } from "../../../provider/index.js";
|
|
11
11
|
const Footer = () => {
|
|
12
|
-
const {
|
|
12
|
+
const { embedded } = useAccount();
|
|
13
13
|
const currentStep = useModalStore((state) => state.step);
|
|
14
|
-
const accountFooter = (
|
|
14
|
+
const accountFooter = (embedded == null ? void 0 : embedded.isConnected) && !embedded.isGuestMode;
|
|
15
15
|
const showFooter = accountFooter || getStepHasFooter(currentStep);
|
|
16
16
|
const Content = useMemo(() => {
|
|
17
17
|
if (accountFooter) {
|
|
@@ -35,7 +35,7 @@ const Footer = () => {
|
|
|
35
35
|
/* @__PURE__ */ jsx(ParaLogo, { icon: "para" })
|
|
36
36
|
] })
|
|
37
37
|
] });
|
|
38
|
-
}, [
|
|
38
|
+
}, [embedded]);
|
|
39
39
|
if (!showFooter) {
|
|
40
40
|
return null;
|
|
41
41
|
}
|
|
@@ -30,7 +30,7 @@ export declare function getNetworkName(str: Network | string): string;
|
|
|
30
30
|
export declare function getNetworkIcon(str: Network | string): IconType;
|
|
31
31
|
export declare function getAssetCode(str: OnRampAsset | string): string;
|
|
32
32
|
export declare function getAssetName(str: OnRampAsset | string): string;
|
|
33
|
-
export declare function getAssetIcon(str: OnRampAsset | string): "key" | "phone" | "farcaster" | "telegram" | "discord" | "x" | "search" | "
|
|
33
|
+
export declare function getAssetIcon(str: OnRampAsset | string): "key" | "phone" | "farcaster" | "telegram" | "discord" | "x" | "search" | "wallet" | "cosmos" | "solana" | "para" | "walletConnect" | "close" | "copy" | "safe" | "alertCircle" | "alertTriangle" | "alignVerticalCenter" | "angelListBrand" | "angelList" | "appleBrand" | "apple" | "arbitrumBrand" | "arrowCircleBrokenDownLeft" | "arrowCircleDownFilled" | "arrowNarrow" | "arrow" | "asterisk" | "backpack" | "backupKit" | "bank" | "baseBrand" | "brush" | "celoBrand" | "checkCircleFilled" | "checkCircle" | "checkSquare" | "check" | "chevronDown" | "chevronRight" | "chevronSelectorVertical" | "chevronUp" | "clock" | "clubhouseBrand" | "clubhouse" | "code" | "coinbase" | "copy07" | "cosmosCircle" | "cosmostation" | "creditCard02" | "creditCard" | "cube03" | "cubeOutline" | "cube" | "currencyDollar" | "decentBrand" | "decent" | "dell" | "discordBrand" | "dot" | "dots" | "downloadCloud" | "download" | "dribbbleBrand" | "dribbble" | "earth" | "edit02" | "emptyCircle" | "ethCircle" | "ethereum" | "eyeOff" | "eye" | "facebookBrand" | "facebook" | "farcasterBrand" | "figmaBrand" | "figma" | "file" | "folder" | "githubBrand" | "github" | "globe" | "glow" | "googleBrand" | "google" | "gridDots" | "haha" | "helpCircle" | "heroAlertCircle" | "heroCheckmarkCapsule" | "heroCheckmark" | "heroEmail" | "heroExternalConnection" | "heroLock" | "heroPasskey" | "heroPhone" | "heroPlusCircleCapsule" | "heroPlusCircle" | "heroWallet" | "home" | "hp" | "image" | "infoCircle" | "instagramBrand" | "instagram" | "keplr" | "laptop" | "leap" | "lenovo" | "lg" | "lightning01" | "lightning" | "linkExternal" | "linkedinBrand" | "linkedin" | "lockKeyholeCircle" | "logOut" | "mail" | "menu" | "metamask" | "monitor" | "moonpayBrand" | "moreLoginOptions" | "motorola" | "nobleBrand" | "okx" | "optimismBrand" | "paraBlackBg" | "paraBrand" | "paraIconBrand" | "paraIconQr" | "paraIcon" | "paraLogo" | "paraRingsDark" | "paraRings" | "passcode" | "phantom" | "pintrestBrand" | "pintrest" | "plusCircle" | "plus" | "polygonBrand" | "polygon" | "puzzlePiece" | "qrCode02" | "qrCode" | "rabby" | "rainbow" | "rampNetworkBrand" | "rampNetwork" | "redditBrand" | "reddit" | "refresh" | "samsung" | "send" | "settings" | "share" | "shield" | "signalBrand" | "signal" | "sliders" | "snapchatBrand" | "snapchat" | "solanaCircle" | "solflare" | "spacingHeight" | "star04Filled" | "star05" | "stars01Filled" | "stars02" | "stars" | "stopSquare" | "stripeBrand" | "telegramBrand" | "tetherBrand" | "tikTokBrand" | "tikTok" | "trash" | "tumblrBrand" | "tumblr" | "twitterBrand" | "twitter" | "usdcBrand" | "userCircle" | "userPlus" | "user" | "valora" | "youtubeBrand" | "youtube" | "zerion" | "AD" | "AE" | "AF" | "AG" | "AI" | "AL" | "AM" | "AO" | "AR" | "AS" | "AT" | "AU" | "AW" | "AX" | "AZ" | "BA" | "BB" | "BD" | "BE" | "BF" | "BG" | "BH" | "BI" | "BJ" | "BL" | "BM" | "BN" | "BO" | "BQ" | "BQ2" | "BQ3" | "BR" | "BS" | "BT" | "BW" | "BY" | "BZ" | "CA" | "CC" | "CD" | "CD2" | "CF" | "CH" | "CK" | "CL" | "CM" | "CN" | "CO" | "CR" | "CU" | "CW" | "CX" | "CY" | "CZ" | "DE" | "DJ" | "DK" | "DM" | "DO" | "DS" | "DZ" | "EC" | "EE" | "EG" | "EH" | "ER" | "ES" | "ET" | "FI" | "FJ" | "FK" | "FM" | "FO" | "FR" | "GA" | "GB2" | "GB" | "GD" | "GE" | "GG" | "GH" | "GI" | "GL" | "GM" | "GN" | "GQ" | "GR" | "GT" | "GU" | "GW" | "GY" | "HK" | "HN" | "HR" | "HT" | "HU" | "ID" | "IE" | "IL" | "IM" | "IN" | "IO" | "IQ" | "IR" | "IS" | "IT" | "JE" | "JM" | "JO" | "JP" | "KE" | "KG" | "KH" | "KI" | "KM" | "KN" | "KP" | "KR" | "KW" | "KY" | "KZ" | "LA" | "LB" | "LC" | "LI" | "LK" | "LR" | "LS" | "LT" | "LU" | "LV" | "LY" | "MA" | "MC" | "MD" | "ME" | "MG" | "MH" | "MK" | "ML" | "MM" | "MN" | "MO" | "MP" | "MQ" | "MR" | "MS" | "MT" | "MU" | "MV" | "MW" | "MX" | "MY" | "MZ" | "NA" | "NE" | "NF" | "NG" | "NI" | "NL" | "NO" | "NP" | "NR" | "NU" | "NZ" | "OM" | "PA" | "PE" | "PF" | "PG" | "PH" | "PK" | "PL" | "PN" | "PR" | "PS" | "PT" | "PW" | "PY" | "QA" | "RO" | "RS" | "RU" | "RW" | "SA" | "SB" | "SC" | "SE" | "SG" | "SI" | "SK" | "SL" | "SM" | "SN" | "SO" | "SR" | "SS" | "ST" | "SV" | "SX" | "SY" | "SZ" | "TC" | "TD" | "TG" | "TH" | "TJ" | "TK" | "TL" | "TM" | "TN" | "TO" | "TR" | "TT" | "TV" | "TW" | "TZ" | "UA" | "UG" | "US" | "UY" | "UZ" | "VC" | "VE" | "VG" | "VI" | "VN" | "VU" | "WS" | "YE" | "ZA" | "ZM" | "ZW";
|
|
34
34
|
export declare const MOBILE_SIZE = 480;
|
|
35
35
|
export declare const NETWORK_NOT_SUPPORTED_ERROR = "network not supported";
|
|
36
36
|
export declare const EMAIL_REGEX: RegExp;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import ParaWeb, {
|
|
2
|
-
type AccountValue =
|
|
1
|
+
import ParaWeb, { PrimaryAuthInfo } from '@getpara/web-sdk';
|
|
2
|
+
type AccountValue = PrimaryAuthInfo & {
|
|
3
3
|
email?: string;
|
|
4
4
|
phone?: `+${number}`;
|
|
5
5
|
farcasterUsername?: string;
|
|
@@ -22,5 +22,5 @@ export type Account = ({
|
|
|
22
22
|
isConnected: true;
|
|
23
23
|
isGuestMode: false;
|
|
24
24
|
} & AccountValue);
|
|
25
|
-
export declare const
|
|
25
|
+
export declare const getEmbeddedAccount: (para?: ParaWeb, _isConnected?: boolean) => Promise<Account>;
|
|
26
26
|
export {};
|
|
@@ -1,29 +1,27 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
-
__async
|
|
4
|
-
__spreadProps,
|
|
5
|
-
__spreadValues
|
|
3
|
+
__async
|
|
6
4
|
} from "../../chunk-MMUBH76A.js";
|
|
7
|
-
const
|
|
8
|
-
if (
|
|
9
|
-
return { isConnected: false };
|
|
10
|
-
}
|
|
11
|
-
if (para.isGuestMode) {
|
|
5
|
+
const getEmbeddedAccount = (para, _isConnected) => __async(void 0, null, function* () {
|
|
6
|
+
if (!!para && para.isGuestMode) {
|
|
12
7
|
return {
|
|
13
8
|
isConnected: true,
|
|
14
9
|
isGuestMode: true,
|
|
15
10
|
wallets: para.availableWallets
|
|
16
11
|
};
|
|
17
12
|
}
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
13
|
+
const isConnected = !!para && (_isConnected != null ? _isConnected : yield para == null ? void 0 : para.isFullyLoggedIn());
|
|
14
|
+
if (isConnected) {
|
|
20
15
|
const authInfo = para.authInfo;
|
|
21
|
-
const value =
|
|
16
|
+
const value = {
|
|
17
|
+
auth: authInfo == null ? void 0 : authInfo.auth,
|
|
18
|
+
authType: authInfo == null ? void 0 : authInfo.authType,
|
|
19
|
+
identifier: authInfo == null ? void 0 : authInfo.identifier,
|
|
22
20
|
userId: para.userId,
|
|
23
21
|
wallets: para.availableWallets,
|
|
24
22
|
isConnected: true,
|
|
25
23
|
isGuestMode: false
|
|
26
|
-
}
|
|
24
|
+
};
|
|
27
25
|
if (authInfo) {
|
|
28
26
|
switch (authInfo.authType) {
|
|
29
27
|
case "email":
|
|
@@ -50,5 +48,5 @@ const getAccount = (para, isConnected) => __async(void 0, null, function* () {
|
|
|
50
48
|
return { isConnected: false };
|
|
51
49
|
});
|
|
52
50
|
export {
|
|
53
|
-
|
|
51
|
+
getEmbeddedAccount
|
|
54
52
|
};
|
|
@@ -3,17 +3,14 @@ import {
|
|
|
3
3
|
__async
|
|
4
4
|
} from "../../chunk-MMUBH76A.js";
|
|
5
5
|
import { CosmosExternalWalletContext } from "./stubs/CosmosExternalWalletContextStub.js";
|
|
6
|
+
import { getParaCosmosLib } from "./getParaCosmosLib.js";
|
|
6
7
|
const getParaCosmosConnector = () => __async(void 0, null, function* () {
|
|
7
|
-
let Provider, context, wallets;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
let Provider = void 0, context = CosmosExternalWalletContext, wallets = [];
|
|
9
|
+
const { lib } = yield getParaCosmosLib();
|
|
10
|
+
if (lib) {
|
|
10
11
|
Provider = lib.ParaCosmosProvider;
|
|
11
12
|
context = lib.CosmosExternalWalletContext;
|
|
12
13
|
wallets = lib.allWallets;
|
|
13
|
-
} catch (e) {
|
|
14
|
-
Provider = void 0;
|
|
15
|
-
context = CosmosExternalWalletContext;
|
|
16
|
-
wallets = [];
|
|
17
14
|
}
|
|
18
15
|
return { Provider, context, wallets };
|
|
19
16
|
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../chunk-MMUBH76A.js";
|
|
5
|
+
const getParaCosmosLib = () => __async(void 0, null, function* () {
|
|
6
|
+
let lib;
|
|
7
|
+
try {
|
|
8
|
+
lib = yield import("@getpara/cosmos-wallet-connectors");
|
|
9
|
+
} catch (e) {
|
|
10
|
+
lib = void 0;
|
|
11
|
+
}
|
|
12
|
+
return { lib };
|
|
13
|
+
});
|
|
14
|
+
export {
|
|
15
|
+
getParaCosmosLib
|
|
16
|
+
};
|
|
@@ -3,17 +3,14 @@ import {
|
|
|
3
3
|
__async
|
|
4
4
|
} from "../../chunk-MMUBH76A.js";
|
|
5
5
|
import { EvmExternalWalletContext } from "./stubs/EvmExternalWalletContextStub.js";
|
|
6
|
+
import { getParaEvmLib } from "./getParaEvmLib.js";
|
|
6
7
|
const getParaEvmConnector = () => __async(void 0, null, function* () {
|
|
7
|
-
let Provider, context, wallets;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
let Provider = void 0, context = EvmExternalWalletContext, wallets = [];
|
|
9
|
+
const { lib } = yield getParaEvmLib();
|
|
10
|
+
if (lib) {
|
|
10
11
|
Provider = lib.ParaEvmProvider;
|
|
11
12
|
context = lib.EvmExternalWalletContext;
|
|
12
13
|
wallets = lib.allWallets;
|
|
13
|
-
} catch (e) {
|
|
14
|
-
Provider = void 0;
|
|
15
|
-
context = EvmExternalWalletContext;
|
|
16
|
-
wallets = [];
|
|
17
14
|
}
|
|
18
15
|
return { Provider, context, wallets };
|
|
19
16
|
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../chunk-MMUBH76A.js";
|
|
5
|
+
const getParaEvmLib = () => __async(void 0, null, function* () {
|
|
6
|
+
let lib;
|
|
7
|
+
try {
|
|
8
|
+
lib = yield import("@getpara/evm-wallet-connectors");
|
|
9
|
+
} catch (e) {
|
|
10
|
+
lib = void 0;
|
|
11
|
+
}
|
|
12
|
+
return { lib };
|
|
13
|
+
});
|
|
14
|
+
export {
|
|
15
|
+
getParaEvmLib
|
|
16
|
+
};
|
|
@@ -3,17 +3,14 @@ import {
|
|
|
3
3
|
__async
|
|
4
4
|
} from "../../chunk-MMUBH76A.js";
|
|
5
5
|
import { SolanaExternalWalletContext } from "./stubs/SolanaExternalWalletContextStub.js";
|
|
6
|
+
import { getParaSolanaLib } from "./getParaSolanaLib.js";
|
|
6
7
|
const getParaSolanaConnector = () => __async(void 0, null, function* () {
|
|
7
|
-
let Provider, context, wallets;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
let Provider = void 0, context = SolanaExternalWalletContext, wallets = [];
|
|
9
|
+
const { lib } = yield getParaSolanaLib();
|
|
10
|
+
if (lib) {
|
|
10
11
|
Provider = lib.ParaSolanaProvider;
|
|
11
12
|
context = lib.SolanaExternalWalletContext;
|
|
12
13
|
wallets = lib.allWallets;
|
|
13
|
-
} catch (e) {
|
|
14
|
-
Provider = void 0;
|
|
15
|
-
context = SolanaExternalWalletContext;
|
|
16
|
-
wallets = [];
|
|
17
14
|
}
|
|
18
15
|
return { Provider, context, wallets };
|
|
19
16
|
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../chunk-MMUBH76A.js";
|
|
5
|
+
const getParaSolanaLib = () => __async(void 0, null, function* () {
|
|
6
|
+
let lib;
|
|
7
|
+
try {
|
|
8
|
+
lib = yield import("@getpara/solana-wallet-connectors");
|
|
9
|
+
} catch (e) {
|
|
10
|
+
lib = void 0;
|
|
11
|
+
}
|
|
12
|
+
return { lib };
|
|
13
|
+
});
|
|
14
|
+
export {
|
|
15
|
+
getParaSolanaLib
|
|
16
|
+
};
|
|
@@ -1,5 +1,90 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { Account } from '../../actions/getEmbeddedAccount.js';
|
|
3
|
+
import type { CosmosExternalWalletContextType, UseAccountParameters as UseCosmosAccountParameters } from '@getpara/cosmos-wallet-connectors';
|
|
4
|
+
import type { EvmExternalWalletContextType } from '@getpara/evm-wallet-connectors';
|
|
5
|
+
import type { Adapter } from '@getpara/solana-wallet-connectors';
|
|
1
6
|
export declare const ACCOUNT_BASE_KEY = "PARA_ACCOUNT";
|
|
7
|
+
type EVMAccountType = ReturnType<ReturnType<typeof useContext<EvmExternalWalletContextType>>['useAccount']>;
|
|
8
|
+
type CosmosAccountType = Omit<ReturnType<ReturnType<typeof useContext<CosmosExternalWalletContextType>>['useAccount']>, 'reconnect'>;
|
|
9
|
+
type SolanaAccountType = Pick<Adapter, 'publicKey' | 'name' | 'icon' | 'readyState' | 'supportedTransactionVersions' | 'url'> & {
|
|
10
|
+
isConnected?: boolean;
|
|
11
|
+
isConnecting?: boolean;
|
|
12
|
+
};
|
|
13
|
+
type ConnectionType = 'embedded' | 'external' | 'both' | 'none';
|
|
14
|
+
type ExternalNetwork = 'evm' | 'cosmos' | 'solana';
|
|
2
15
|
/**
|
|
3
|
-
*
|
|
16
|
+
* The return type for the useAccount hook.
|
|
17
|
+
*
|
|
18
|
+
* @property isConnected - Indicates whether there is a wallet connected (either embedded, external or both).
|
|
19
|
+
* @property isLoading - Indicates whether the account is currently loading.
|
|
20
|
+
* @property connectionType - The type of connection for the account:
|
|
21
|
+
* @property embedded - The embedded account object.
|
|
22
|
+
* @property external - An object containing connected external wallet account data:
|
|
23
|
+
* - `evm`: The connected EVM wallet account (if any).
|
|
24
|
+
* - `cosmos`: The connected Cosmos wallet account (if any), with the `reconnect` property omitted.
|
|
25
|
+
* - `solana`: The connected Solana wallet adapter, with only allowed properties included.
|
|
4
26
|
*/
|
|
5
|
-
export
|
|
27
|
+
export type UseAccountReturn = {
|
|
28
|
+
/**
|
|
29
|
+
* Indicates whether there is a wallet connected (either embedded, external or both).
|
|
30
|
+
*/
|
|
31
|
+
isConnected: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Indicates whether the account is currently loading.
|
|
34
|
+
*/
|
|
35
|
+
isLoading: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* The type of connection for the account.
|
|
38
|
+
* - 'embedded': Only the embedded account is connected.
|
|
39
|
+
* - 'external': Only an external wallet is connected.
|
|
40
|
+
* - 'both': Both embedded and external wallets are connected.
|
|
41
|
+
* - 'none': No wallets are connected.
|
|
42
|
+
*/
|
|
43
|
+
connectionType: ConnectionType;
|
|
44
|
+
/**
|
|
45
|
+
* The embedded account object. Use this instead of the deprecated top-level properties.
|
|
46
|
+
*/
|
|
47
|
+
embedded: Omit<Account, 'isConnected' | 'isGuestMode'> & {
|
|
48
|
+
isConnected: boolean;
|
|
49
|
+
isGuestMode?: boolean;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Connected external wallet account data.
|
|
53
|
+
*/
|
|
54
|
+
external: {
|
|
55
|
+
/**
|
|
56
|
+
* The list of connected external networks, which can include 'evm', 'cosmos', and 'solana'.
|
|
57
|
+
*/
|
|
58
|
+
connectedNetworks: ExternalNetwork[];
|
|
59
|
+
/**
|
|
60
|
+
* The connected EVM wallet (if any), with only allowed properties included.
|
|
61
|
+
*/
|
|
62
|
+
evm: EVMAccountType;
|
|
63
|
+
/**
|
|
64
|
+
* The connected Cosmos wallet (if any), with only allowed properties included.
|
|
65
|
+
*/
|
|
66
|
+
cosmos: CosmosAccountType;
|
|
67
|
+
/**
|
|
68
|
+
* The connected Solana wallet (if any), with only allowed properties included.
|
|
69
|
+
*/
|
|
70
|
+
solana: SolanaAccountType;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
export type UseAccountParameters = {
|
|
74
|
+
cosmos?: UseCosmosAccountParameters;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* React Query hook for retrieving the current embedded account and connected external wallets.
|
|
78
|
+
*
|
|
79
|
+
* @returns {UseAccountReturn}
|
|
80
|
+
* The account data object, or undefined while loading.
|
|
81
|
+
*
|
|
82
|
+
* The returned object contains:
|
|
83
|
+
* - `isConnected`: Indicates whether there is a wallet connected (either embedded, external or both).
|
|
84
|
+
* - `isLoading`: Indicates whether the account is currently loading.
|
|
85
|
+
* - `connectionType`: The type of connection for the account:
|
|
86
|
+
* - `embedded`: The embedded account object.
|
|
87
|
+
* - `external`: Connected external wallet data (EVM, Cosmos, Solana).
|
|
88
|
+
*/
|
|
89
|
+
export declare const useAccount: ({ cosmos }?: UseAccountParameters) => UseAccountReturn;
|
|
90
|
+
export {};
|
|
@@ -1,23 +1,122 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
-
__async
|
|
3
|
+
__async,
|
|
4
|
+
__objRest,
|
|
5
|
+
__spreadProps,
|
|
6
|
+
__spreadValues
|
|
4
7
|
} from "../../../chunk-MMUBH76A.js";
|
|
5
8
|
import { useQuery } from "@tanstack/react-query";
|
|
6
|
-
import { getAccount } from "../../actions/getAccount.js";
|
|
7
9
|
import { useInternalClient } from "../utils/useInternalClient.js";
|
|
8
10
|
import { useIsFullyLoggedIn } from "./useIsFullyLoggedIn.js";
|
|
11
|
+
import { useStore } from "../../stores/useStore.js";
|
|
12
|
+
import { useContext } from "react";
|
|
13
|
+
import { getEmbeddedAccount } from "../../actions/getEmbeddedAccount.js";
|
|
9
14
|
const ACCOUNT_BASE_KEY = "PARA_ACCOUNT";
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
function pickSolanaAdapter(adapter) {
|
|
16
|
+
if (!adapter) return { isConnected: false };
|
|
17
|
+
const { connected, connecting, publicKey, name, icon, readyState, supportedTransactionVersions, url } = adapter;
|
|
18
|
+
return {
|
|
19
|
+
isConnected: connected,
|
|
20
|
+
isConnecting: connecting,
|
|
21
|
+
publicKey,
|
|
22
|
+
name,
|
|
23
|
+
icon,
|
|
24
|
+
readyState,
|
|
25
|
+
supportedTransactionVersions,
|
|
26
|
+
url
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function pickCosmosAccount(account) {
|
|
30
|
+
if (!account) return { isConnected: false };
|
|
31
|
+
const _a = account, { reconnect: _ } = _a, rest = __objRest(_a, ["reconnect"]);
|
|
32
|
+
return rest;
|
|
33
|
+
}
|
|
34
|
+
const useAccount = ({ cosmos } = {}) => {
|
|
35
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
12
36
|
const client = useInternalClient();
|
|
13
37
|
const { data: isFullyLoggedIn, isSuccess } = useIsFullyLoggedIn();
|
|
14
|
-
|
|
38
|
+
const evmContext = useStore((state) => state.evmContext);
|
|
39
|
+
const { useAccount: useEvmAccount } = useContext(evmContext);
|
|
40
|
+
const evmAccount = useEvmAccount();
|
|
41
|
+
const evmQueryKeys = [evmAccount == null ? void 0 : evmAccount.status, evmAccount == null ? void 0 : evmAccount.addresses, evmAccount == null ? void 0 : evmAccount.chainId];
|
|
42
|
+
const cosmosContext = useStore((state) => state.cosmosContext);
|
|
43
|
+
const { useAccount: useCosmosAccount } = useContext(cosmosContext);
|
|
44
|
+
const cosmosAccount = useCosmosAccount(cosmos);
|
|
45
|
+
const cosmosQueryKeys = [cosmosAccount == null ? void 0 : cosmosAccount.status, cosmosAccount == null ? void 0 : cosmosAccount.data];
|
|
46
|
+
const solanaContext = useStore((state) => state.solanaContext);
|
|
47
|
+
const { useWallet: useSolanaWallet } = useContext(solanaContext);
|
|
48
|
+
const solanaWallet = useSolanaWallet();
|
|
49
|
+
const solanaQueryKeys = [
|
|
50
|
+
(_b = (_a = solanaWallet == null ? void 0 : solanaWallet.wallet) == null ? void 0 : _a.adapter) == null ? void 0 : _b.connected,
|
|
51
|
+
(_d = (_c = solanaWallet == null ? void 0 : solanaWallet.wallet) == null ? void 0 : _c.adapter) == null ? void 0 : _d.connecting,
|
|
52
|
+
(_f = (_e = solanaWallet == null ? void 0 : solanaWallet.wallet) == null ? void 0 : _e.adapter) == null ? void 0 : _f.publicKey
|
|
53
|
+
];
|
|
54
|
+
const solanaAdapter = (_g = solanaWallet == null ? void 0 : solanaWallet.wallet) == null ? void 0 : _g.adapter;
|
|
55
|
+
const { data, isLoading } = useQuery({
|
|
15
56
|
enabled: isSuccess && !!client,
|
|
16
|
-
queryKey: [ACCOUNT_BASE_KEY, isFullyLoggedIn != null ? isFullyLoggedIn : null,
|
|
57
|
+
queryKey: [ACCOUNT_BASE_KEY, isFullyLoggedIn != null ? isFullyLoggedIn : null, client == null ? void 0 : client.userId, evmQueryKeys, cosmosQueryKeys, solanaQueryKeys],
|
|
17
58
|
queryFn: () => __async(void 0, null, function* () {
|
|
18
|
-
|
|
59
|
+
const paraAccount = yield getEmbeddedAccount(client);
|
|
60
|
+
let connectionType = "none";
|
|
61
|
+
if (paraAccount.isConnected) {
|
|
62
|
+
connectionType = "embedded";
|
|
63
|
+
if (paraAccount.wallets.some((w) => w.isExternal)) {
|
|
64
|
+
connectionType = "both";
|
|
65
|
+
}
|
|
66
|
+
if (paraAccount.wallets.every((w) => w.isExternal) && (evmAccount.isConnected || cosmosAccount.isConnected || (solanaAdapter == null ? void 0 : solanaAdapter.connected))) {
|
|
67
|
+
connectionType = "external";
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const isEmbeddedConnected = paraAccount.isConnected && (!!paraAccount.userId || paraAccount.isGuestMode);
|
|
71
|
+
const connectedNetworks = [];
|
|
72
|
+
if (evmAccount.isConnected) {
|
|
73
|
+
connectedNetworks.push("evm");
|
|
74
|
+
}
|
|
75
|
+
if (cosmosAccount.isConnected) {
|
|
76
|
+
connectedNetworks.push("cosmos");
|
|
77
|
+
}
|
|
78
|
+
if (solanaAdapter == null ? void 0 : solanaAdapter.connected) {
|
|
79
|
+
connectedNetworks.push("solana");
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
isConnected: paraAccount.isConnected,
|
|
83
|
+
connectionType,
|
|
84
|
+
embedded: __spreadProps(__spreadValues({}, paraAccount), { isConnected: isEmbeddedConnected }),
|
|
85
|
+
external: {
|
|
86
|
+
connectedNetworks,
|
|
87
|
+
evm: evmAccount,
|
|
88
|
+
cosmos: pickCosmosAccount(cosmosAccount),
|
|
89
|
+
solana: pickSolanaAdapter(solanaAdapter)
|
|
90
|
+
}
|
|
91
|
+
};
|
|
19
92
|
})
|
|
20
93
|
});
|
|
94
|
+
const defaultResp = {
|
|
95
|
+
isConnected: false,
|
|
96
|
+
connectionType: "none",
|
|
97
|
+
isLoading,
|
|
98
|
+
embedded: {
|
|
99
|
+
isConnected: false
|
|
100
|
+
},
|
|
101
|
+
external: {
|
|
102
|
+
connectedNetworks: [],
|
|
103
|
+
evm: {
|
|
104
|
+
address: void 0,
|
|
105
|
+
addresses: void 0,
|
|
106
|
+
chain: void 0,
|
|
107
|
+
chainId: void 0,
|
|
108
|
+
connector: void 0,
|
|
109
|
+
isConnected: false,
|
|
110
|
+
isReconnecting: false,
|
|
111
|
+
isConnecting: false,
|
|
112
|
+
isDisconnected: true,
|
|
113
|
+
status: "disconnected"
|
|
114
|
+
},
|
|
115
|
+
cosmos: { isConnected: false },
|
|
116
|
+
solana: { isConnected: false }
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
return __spreadProps(__spreadValues({}, data != null ? data : defaultResp), { isLoading });
|
|
21
120
|
};
|
|
22
121
|
export {
|
|
23
122
|
ACCOUNT_BASE_KEY,
|
|
@@ -16,7 +16,7 @@ const useWalletBalance = (args) => {
|
|
|
16
16
|
const {
|
|
17
17
|
selectedWallet: { type: selectedWalletType }
|
|
18
18
|
} = useWalletState();
|
|
19
|
-
const {
|
|
19
|
+
const { embedded } = useAccount();
|
|
20
20
|
const rpcUrl = useStore((state) => state.rpcUrl);
|
|
21
21
|
const { getWalletBalance: getExternalWalletBalance, chainId } = useExternalWallets();
|
|
22
22
|
const queryFn = useCallback(() => __async(void 0, null, function* () {
|
|
@@ -36,7 +36,7 @@ const useWalletBalance = (args) => {
|
|
|
36
36
|
console.error("Error fetching wallet balance: ", err);
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
39
|
-
}), [
|
|
39
|
+
}), [embedded, selectedWallet, selectedWalletType, rpcUrl, getExternalWalletBalance]);
|
|
40
40
|
return useQuery({
|
|
41
41
|
queryKey: [
|
|
42
42
|
WALLET_BALANCE_BASE_KEY,
|
|
@@ -46,7 +46,7 @@ const useWalletBalance = (args) => {
|
|
|
46
46
|
(selectedWallet == null ? void 0 : selectedWallet.isExternal) ? chainId : ""
|
|
47
47
|
],
|
|
48
48
|
queryFn,
|
|
49
|
-
enabled: !!client && !!selectedWallet && !!rpcUrl && !!(
|
|
49
|
+
enabled: !!client && !!selectedWallet && !!rpcUrl && !!(embedded == null ? void 0 : embedded.isConnected)
|
|
50
50
|
});
|
|
51
51
|
};
|
|
52
52
|
export {
|
|
@@ -9,7 +9,7 @@ const SESSION_CHECK_INTERVAL = 6e4;
|
|
|
9
9
|
const SESSION_REFRESH_THRESHOLD = 3e5;
|
|
10
10
|
const useAutoSessionKeepAlive = ({ disabled }) => {
|
|
11
11
|
const client = useInternalClient();
|
|
12
|
-
const {
|
|
12
|
+
const { embedded } = useAccount();
|
|
13
13
|
const { logoutAsync } = useLogout();
|
|
14
14
|
const { keepSessionAliveAsync } = useKeepSessionAlive();
|
|
15
15
|
const sessionCheckInterval = useRef(null);
|
|
@@ -18,13 +18,13 @@ const useAutoSessionKeepAlive = ({ disabled }) => {
|
|
|
18
18
|
clearSessionMonitoring();
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
if ((
|
|
21
|
+
if ((embedded == null ? void 0 : embedded.isConnected) && !embedded.isGuestMode && client.externalWalletConnectionType !== "CONNECTION_ONLY") {
|
|
22
22
|
setupSessionMonitoring();
|
|
23
23
|
} else {
|
|
24
24
|
clearSessionMonitoring();
|
|
25
25
|
}
|
|
26
26
|
return () => clearSessionMonitoring();
|
|
27
|
-
}, [client,
|
|
27
|
+
}, [client, embedded, disabled]);
|
|
28
28
|
const getSessionExpiry = () => __async(void 0, null, function* () {
|
|
29
29
|
try {
|
|
30
30
|
const sessionCookie = yield client == null ? void 0 : client.retrieveSessionCookie();
|
|
@@ -66,9 +66,10 @@ const useVerifyFarcasterLink = generateInternalMutation("verifyFarcasterLink", a
|
|
|
66
66
|
const useVerifyTelegramLink = generateInternalMutation("verifyTelegramLink", actions.verifyTelegramLink);
|
|
67
67
|
const useVerifyExternalWalletLink = generateInternalMutation("verifyExternalWalletLink", actions.verifyExternalWalletLink);
|
|
68
68
|
const AccountLinkProvider = ({ children }) => {
|
|
69
|
+
var _a;
|
|
69
70
|
const para = useInternalClient();
|
|
70
71
|
const queryClient = useQueryClient();
|
|
71
|
-
const {
|
|
72
|
+
const { embedded } = useAccount();
|
|
72
73
|
const { data: coreAccountLinkInProgress } = useAccountLinkInProgress();
|
|
73
74
|
const {
|
|
74
75
|
wallet: connectedWallet,
|
|
@@ -110,7 +111,7 @@ const AccountLinkProvider = ({ children }) => {
|
|
|
110
111
|
status: statusVerifyExternalWalletLink,
|
|
111
112
|
reset: resetVerifyExternalWalletLink
|
|
112
113
|
} = useVerifyExternalWalletLink();
|
|
113
|
-
const isEnabled = !!(
|
|
114
|
+
const isEnabled = !!(embedded == null ? void 0 : embedded.isConnected) && !(embedded == null ? void 0 : embedded.isGuestMode) && (!((_a = para.authInfo) == null ? void 0 : _a.externalWallet) || includeWalletVerification);
|
|
114
115
|
const [accountLinkInProgress, setAccountLinkInProgress] = useState(
|
|
115
116
|
coreAccountLinkInProgress || void 0
|
|
116
117
|
);
|
|
@@ -246,8 +247,8 @@ const AccountLinkProvider = ({ children }) => {
|
|
|
246
247
|
{
|
|
247
248
|
method,
|
|
248
249
|
isCanceled: () => {
|
|
249
|
-
var
|
|
250
|
-
return !!((
|
|
250
|
+
var _a2;
|
|
251
|
+
return !!((_a2 = refs.popupWindow.current) == null ? void 0 : _a2.closed);
|
|
251
252
|
},
|
|
252
253
|
onOAuthUrl: (oAuthUrl) => {
|
|
253
254
|
refs.popupWindow.current = openPopup({
|
|
@@ -31,7 +31,6 @@ export declare const defaultExternalWallet: {
|
|
|
31
31
|
signMessage: () => Promise<any>;
|
|
32
32
|
isSigningMessage: boolean;
|
|
33
33
|
getWalletBalance: () => Promise<undefined>;
|
|
34
|
-
isExternalWalletVerifying: boolean;
|
|
35
34
|
requestInfo: (_: TExternalWallet) => Promise<ExternalWalletInfo>;
|
|
36
35
|
disconnectBase: (_: TExternalWallet) => Promise<void>;
|
|
37
36
|
};
|
|
@@ -52,7 +51,6 @@ type Value = Omit<ExternalWalletContextType<CosmosSignResult>, 'disconnect' | 's
|
|
|
52
51
|
connectEmbeddedToExternalConnectors: () => Promise<void>;
|
|
53
52
|
isSigningMessage: boolean;
|
|
54
53
|
verifyWalletSignature: () => Promise<VerifyExternalWalletParams | undefined>;
|
|
55
|
-
isExternalWalletVerifying?: boolean;
|
|
56
54
|
requestInfo: (_: TExternalWallet, __: TWalletType) => Promise<ExternalWalletInfo>;
|
|
57
55
|
};
|
|
58
56
|
export declare const ExternalWalletContext: import("react").Context<Value>;
|
|
@@ -48,7 +48,6 @@ const defaultExternalWallet = {
|
|
|
48
48
|
signMessage: () => Promise.resolve({}),
|
|
49
49
|
isSigningMessage: false,
|
|
50
50
|
getWalletBalance: () => Promise.resolve(void 0),
|
|
51
|
-
isExternalWalletVerifying: false,
|
|
52
51
|
requestInfo: (_) => Promise.resolve({}),
|
|
53
52
|
disconnectBase: (_) => Promise.resolve()
|
|
54
53
|
};
|
|
@@ -111,7 +110,6 @@ function ExternalWalletProvider({ children }) {
|
|
|
111
110
|
const { mutateAsync: verifyExternalWallet } = useVerifyExternalWallet();
|
|
112
111
|
const [qrUri, setQrUri] = useState();
|
|
113
112
|
const [chainIdSwitchingTo, setChainIdSwitchingTo] = useState();
|
|
114
|
-
const [isExternalWalletVerifying, setIsExternalWalletVerifying] = useState(false);
|
|
115
113
|
const [isSigningMessage, setIsSigningMessage] = useState(false);
|
|
116
114
|
const wallets = [...evmWallets, ...solanaWallets, ...cosmosWallets].filter((w) => externalWallets.includes(w.id.toUpperCase())).sort(
|
|
117
115
|
(a, b) => externalWallets.indexOf(a.id.toUpperCase()) - externalWallets.indexOf(b.id.toUpperCase())
|
|
@@ -214,7 +212,6 @@ function ExternalWalletProvider({ children }) {
|
|
|
214
212
|
const verifyWalletSignature = useCallback(() => __async(this, null, function* () {
|
|
215
213
|
var _a;
|
|
216
214
|
setExternalWalletError();
|
|
217
|
-
setIsExternalWalletVerifying(true);
|
|
218
215
|
const wallet2 = Object.values(para.externalWallets)[0];
|
|
219
216
|
const walletType = wallet2 == null ? void 0 : wallet2.type;
|
|
220
217
|
let verifyExternalWalletParams;
|
|
@@ -284,28 +281,23 @@ function ExternalWalletProvider({ children }) {
|
|
|
284
281
|
default:
|
|
285
282
|
break;
|
|
286
283
|
}
|
|
287
|
-
if (verifyExternalWalletParams) {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
} catch (e) {
|
|
300
|
-
console.error("Error verifying signature:", e);
|
|
301
|
-
setExternalWalletError(["Signature verification failed."]);
|
|
302
|
-
} finally {
|
|
303
|
-
setIsExternalWalletVerifying(false);
|
|
284
|
+
if (!(verifyExternalWalletParams == null ? void 0 : verifyExternalWalletParams.externalWallet) || !(verifyExternalWalletParams == null ? void 0 : verifyExternalWalletParams.signedMessage)) {
|
|
285
|
+
console.error("No signature or address found on the verifyWalletSignature response.");
|
|
286
|
+
setExternalWalletError(["Signature verification failed."]);
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
try {
|
|
290
|
+
const d = yield verifyExternalWallet(verifyExternalWalletParams);
|
|
291
|
+
if (wallet2 && (externalWalletsWithFullAuth == null ? void 0 : externalWalletsWithFullAuth.includes((_a = wallet2.name) == null ? void 0 : _a.toUpperCase()))) {
|
|
292
|
+
yield onNewAuthState(d);
|
|
293
|
+
} else {
|
|
294
|
+
setStep(ModalStep.LOGIN_DONE);
|
|
304
295
|
}
|
|
305
|
-
|
|
296
|
+
} catch (e) {
|
|
297
|
+
console.error("Error verifying signature:", e);
|
|
298
|
+
setExternalWalletError(["Signature verification failed."]);
|
|
306
299
|
}
|
|
307
|
-
|
|
308
|
-
return void 0;
|
|
300
|
+
return verifyExternalWalletParams;
|
|
309
301
|
}), [cosmosSignVerificationMessage, evmSignVerificationMessage, solanaSignVerificationMessage, wallet]);
|
|
310
302
|
const signMessage = useCallback(
|
|
311
303
|
(_0) => __async(this, [_0], function* ({ message, externalWallet: _externalWallet }) {
|
|
@@ -531,7 +523,6 @@ function ExternalWalletProvider({ children }) {
|
|
|
531
523
|
signMessage,
|
|
532
524
|
isSigningMessage,
|
|
533
525
|
verifyWalletSignature,
|
|
534
|
-
isExternalWalletVerifying,
|
|
535
526
|
getWalletBalance,
|
|
536
527
|
requestInfo,
|
|
537
528
|
disconnectBase
|
|
@@ -554,7 +545,6 @@ function ExternalWalletProvider({ children }) {
|
|
|
554
545
|
signMessage,
|
|
555
546
|
isSigningMessage,
|
|
556
547
|
verifyWalletSignature,
|
|
557
|
-
isExternalWalletVerifying,
|
|
558
548
|
getWalletBalance,
|
|
559
549
|
requestInfo,
|
|
560
550
|
disconnectBase
|
|
@@ -15,6 +15,8 @@ const createExternalWalletsSlice = (set) => ({
|
|
|
15
15
|
setConnectionOnly: (connectionOnly) => set({ connectionOnly }),
|
|
16
16
|
evmContext: EvmExternalWalletContext,
|
|
17
17
|
setEvmContext: (evmContext) => set({ evmContext }),
|
|
18
|
+
evmLib: void 0,
|
|
19
|
+
setEvmLib: (evmLib) => set({ evmLib }),
|
|
18
20
|
EvmProvider: void 0,
|
|
19
21
|
setEvmProvider: (EvmProvider) => set({ EvmProvider }),
|
|
20
22
|
evmWallets: [],
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Context, MutableRefObject } from 'react';
|
|
2
2
|
import ParaWeb, { TWalletType } from '@getpara/web-sdk';
|
|
3
|
+
import * as paraEvmLib from '@getpara/evm-wallet-connectors';
|
|
3
4
|
import { EvmExternalWalletContextType, ParaEvmProvider, WalletList as EvmWalletList } from '@getpara/evm-wallet-connectors';
|
|
4
5
|
import { CosmosExternalWalletContextType, ParaCosmosProvider, WalletList as CosmosWalletList } from '@getpara/cosmos-wallet-connectors';
|
|
5
6
|
import { ParaSolanaProvider, SolanaExternalWalletContextType, WalletList as SolanaWalletList } from '@getpara/solana-wallet-connectors';
|
|
@@ -44,6 +45,8 @@ export interface ExternalWalletsSlice {
|
|
|
44
45
|
setIncludeWalletVerification: (_: boolean) => void;
|
|
45
46
|
externalWalletsWithFullAuth: TExternalWallet[];
|
|
46
47
|
setExternalWalletsWithFullAuth: (_: TExternalWallet[]) => void;
|
|
48
|
+
evmLib: typeof paraEvmLib | undefined;
|
|
49
|
+
setEvmLib: (_: typeof paraEvmLib) => void;
|
|
47
50
|
evmContext: Context<EvmExternalWalletContextType>;
|
|
48
51
|
setEvmContext: (_: Context<EvmExternalWalletContextType>) => void;
|
|
49
52
|
EvmProvider?: typeof ParaEvmProvider;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/react-sdk",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.28",
|
|
4
4
|
"bin": {
|
|
5
5
|
"setup-para": "dist/cli/cli.mjs"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@getpara/react-common": "2.0.0-alpha.
|
|
9
|
-
"@getpara/react-components": "2.0.0-alpha.
|
|
10
|
-
"@getpara/web-sdk": "2.0.0-alpha.
|
|
8
|
+
"@getpara/react-common": "2.0.0-alpha.28",
|
|
9
|
+
"@getpara/react-components": "2.0.0-alpha.28",
|
|
10
|
+
"@getpara/web-sdk": "2.0.0-alpha.28",
|
|
11
11
|
"date-fns": "^3.6.0",
|
|
12
12
|
"framer-motion": "^11.3.31",
|
|
13
13
|
"libphonenumber-js": "^1.11.7",
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"zustand-sync-tabs": "^0.2.2"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@getpara/cosmos-wallet-connectors": "2.0.0-alpha.
|
|
20
|
-
"@getpara/evm-wallet-connectors": "2.0.0-alpha.
|
|
21
|
-
"@getpara/solana-wallet-connectors": "2.0.0-alpha.
|
|
19
|
+
"@getpara/cosmos-wallet-connectors": "2.0.0-alpha.28",
|
|
20
|
+
"@getpara/evm-wallet-connectors": "2.0.0-alpha.28",
|
|
21
|
+
"@getpara/solana-wallet-connectors": "2.0.0-alpha.28",
|
|
22
22
|
"@tanstack/react-query": "^5.74.0",
|
|
23
23
|
"@testing-library/dom": "^10.4.0",
|
|
24
24
|
"@testing-library/react": "^16.3.0",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"package.json",
|
|
39
39
|
"styles.css"
|
|
40
40
|
],
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "1da9f8663f58015a70686f45741fb76ddc671ac7",
|
|
42
42
|
"main": "dist/index.js",
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@getpara/cosmos-wallet-connectors": "^2.0.0-alpha.26",
|