@getpara/react-sdk-lite 2.0.0-dev.6 → 2.0.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/cli/cli.mjs +26 -1
- package/dist/modal/ParaModal.js +16 -11
- package/dist/modal/components/Account/Account.js +42 -4
- package/dist/modal/components/Account/AccountHeader.js +10 -16
- package/dist/modal/components/Account/AccountProfile.d.ts +1 -1
- package/dist/modal/components/Account/AccountProfile.js +82 -210
- package/dist/modal/components/Account/AccountProfileEntry.d.ts +12 -0
- package/dist/modal/components/Account/AccountProfileEntry.js +220 -0
- package/dist/modal/components/Account/AccountProfileLinkOptions.js +15 -4
- package/dist/modal/components/Account/AccountSend/AccountSendAsset.d.ts +1 -0
- package/dist/modal/components/Account/AccountSend/AccountSendAsset.js +94 -0
- package/dist/modal/components/Account/AccountSend/AccountSendForm.d.ts +1 -0
- package/dist/modal/components/Account/AccountSend/AccountSendForm.js +343 -0
- package/dist/modal/components/Account/AccountSend/AccountSendNetwork.d.ts +1 -0
- package/dist/modal/components/Account/AccountSend/AccountSendNetwork.js +53 -0
- package/dist/modal/components/Account/AccountSend/AccountSendNoAssets.d.ts +1 -0
- package/dist/modal/components/Account/AccountSend/AccountSendNoAssets.js +56 -0
- package/dist/modal/components/Account/AccountSend/AssetNetwork.d.ts +5 -0
- package/dist/modal/components/Account/AccountSend/AssetNetwork.js +36 -0
- package/dist/modal/components/Account/AccountSend/context.d.ts +38 -0
- package/dist/modal/components/Account/AccountSend/context.js +418 -0
- package/dist/modal/components/Account/AccountSend/index.d.ts +4 -0
- package/dist/modal/components/Account/AccountSend/index.js +67 -0
- package/dist/modal/components/Account/AccountWallet.d.ts +1 -0
- package/dist/modal/components/Account/AccountWallet.js +133 -0
- package/dist/modal/components/{WalletSelect/WalletSelect.d.ts → Account/AccountWalletSelect.d.ts} +1 -1
- package/dist/modal/components/{WalletSelect/WalletSelect.js → Account/AccountWalletSelect.js} +20 -6
- package/dist/modal/components/AddFunds/AddFunds.js +3 -2
- package/dist/modal/components/AddFunds/AddFundsAsset.js +7 -6
- package/dist/modal/components/AddFunds/AddFundsContext.d.ts +5 -5
- package/dist/modal/components/AddFunds/AddFundsProvider.js +1 -2
- package/dist/modal/components/AddFunds/AddFundsSettings.js +13 -54
- package/dist/modal/components/AddFunds/common.d.ts +0 -14
- package/dist/modal/components/AddFunds/common.js +1 -8
- package/dist/modal/components/AuthInput/AuthInput.js +2 -2
- package/dist/modal/components/AwaitingAccountStep/AwaitingAccountStep.js +10 -1
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +8 -33
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +5 -2
- package/dist/modal/components/Body/Body.js +81 -48
- package/dist/modal/components/ChainSwitch/ChainSwitch.js +8 -5
- package/dist/modal/components/Controls/ChainSelect.js +1 -2
- package/dist/modal/components/Controls/Controls.js +1 -0
- package/dist/modal/components/ExternalWalletNetworkSelectStep/ExternalWalletNetworkSelectStep.d.ts +5 -1
- package/dist/modal/components/ExternalWalletNetworkSelectStep/ExternalWalletNetworkSelectStep.js +48 -19
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +5 -2
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +63 -33
- package/dist/modal/components/ExternalWallets/ExternalWallets.d.ts +3 -1
- package/dist/modal/components/ExternalWallets/ExternalWallets.js +22 -12
- package/dist/modal/components/Footer/Footer.js +4 -5
- package/dist/modal/components/Header/Header.js +1 -2
- package/dist/modal/components/Header/hooks/useStepTitle.js +53 -37
- package/dist/modal/components/Hero/Hero.js +5 -3
- package/dist/modal/components/IFrameStep/IFrameStep.js +13 -12
- package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +4 -1
- package/dist/modal/components/OAuth/FarcasterOAuthStep.js +6 -5
- package/dist/modal/components/OAuth/TelegramOAuthStep.js +34 -18
- package/dist/modal/components/OnRampComponents/AddingFunds.js +1 -1
- package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +1 -2
- package/dist/modal/components/QuantityInput.d.ts +9 -0
- package/dist/modal/components/QuantityInput.js +91 -0
- package/dist/modal/components/SearchableButtonList.d.ts +34 -0
- package/dist/modal/components/SearchableButtonList.js +223 -0
- package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +4 -1
- package/dist/modal/components/SwitchWalletsStep/SwitchWalletsStep.d.ts +1 -0
- package/dist/modal/components/SwitchWalletsStep/SwitchWalletsStep.js +10 -0
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +13 -2
- package/dist/modal/components/Waiting/Waiting.d.ts +1 -1
- package/dist/modal/components/Waiting/Waiting.js +7 -2
- package/dist/modal/components/WalletCard/WalletCard.js +2 -3
- package/dist/modal/components/WalletSelectOld/WalletSelectOld.d.ts +7 -1
- package/dist/modal/components/WalletSelectOld/WalletSelectOld.js +33 -12
- package/dist/modal/components/common.d.ts +8 -10
- package/dist/modal/components/common.js +16 -36
- package/dist/modal/hooks/index.d.ts +4 -0
- package/dist/modal/hooks/index.js +5 -0
- package/dist/modal/hooks/useDebounce.d.ts +4 -0
- package/dist/modal/hooks/useDebounce.js +16 -0
- package/dist/modal/hooks/useFarcasterLogin.js +8 -1
- package/dist/modal/hooks/useTelegramLogin.js +4 -0
- package/dist/modal/index.d.ts +1 -1
- package/dist/modal/index.js +1 -1
- package/dist/modal/stores/modal/actions.js +9 -2
- package/dist/modal/stores/modal/useModalStore.d.ts +9 -1
- package/dist/modal/stores/modal/useModalStore.js +6 -2
- package/dist/modal/types/modalProps.d.ts +5 -1
- package/dist/modal/utils/authInputHelpers.js +1 -1
- package/dist/modal/utils/countryCodes.js +50 -1
- package/dist/modal/utils/getWalletDisplayName.js +1 -1
- package/dist/modal/utils/openPopup.d.ts +1 -1
- package/dist/modal/utils/openPopup.js +6 -2
- package/dist/modal/utils/renderTextWithLinks.d.ts +2 -0
- package/dist/modal/utils/renderTextWithLinks.js +34 -0
- package/dist/modal/utils/steps.d.ts +24 -3
- package/dist/modal/utils/steps.js +51 -5
- package/dist/modal/utils/stringFormatters.d.ts +2 -3
- package/dist/modal/utils/stringFormatters.js +11 -7
- package/dist/modal/utils/validatePortalOrigin.d.ts +2 -0
- package/dist/modal/utils/validatePortalOrigin.js +14 -0
- package/dist/provider/ParaProviderMin.js +13 -5
- package/dist/provider/actions/getEmbeddedAccount.d.ts +3 -2
- package/dist/provider/actions/getEmbeddedAccount.js +13 -4
- package/dist/provider/actions/index.d.ts +11 -9
- package/dist/provider/actions/index.js +4 -0
- package/dist/provider/components/CosmosWalletWrapper.js +3 -3
- package/dist/provider/components/EvmWalletWrapper.js +3 -3
- package/dist/provider/components/ExternalWalletWrapper.js +7 -1
- package/dist/provider/external/stubs/CosmosExternalWalletContextStub.js +3 -1
- package/dist/provider/external/stubs/EvmExternalWalletContextStub.js +3 -1
- package/dist/provider/external/stubs/SolanaExternalWalletContextStub.js +3 -1
- package/dist/provider/hooks/mutations/index.d.ts +2 -0
- package/dist/provider/hooks/mutations/index.js +4 -0
- package/dist/provider/hooks/mutations/useAddAuthMethod.d.ts +42 -0
- package/dist/provider/hooks/mutations/useAddAuthMethod.js +59 -0
- package/dist/provider/hooks/mutations/useClaimPregenWallets.d.ts +2 -2
- package/dist/provider/hooks/mutations/useCreateGuestWallets.d.ts +2 -2
- package/dist/provider/hooks/mutations/useCreatePregenWallet.d.ts +5 -5
- package/dist/provider/hooks/mutations/useCreatePregenWalletPerType.d.ts +2 -2
- package/dist/provider/hooks/mutations/useCreateWallet.d.ts +2 -2
- package/dist/provider/hooks/mutations/useCreateWalletPerType.d.ts +2 -2
- package/dist/provider/hooks/mutations/useEnable2fa.d.ts +2 -2
- package/dist/provider/hooks/mutations/useExportPrivateKey.d.ts +15 -0
- package/dist/provider/hooks/mutations/useExportPrivateKey.js +32 -0
- package/dist/provider/hooks/mutations/useHasPregenWallet.d.ts +2 -2
- package/dist/provider/hooks/mutations/useIssueJwt.d.ts +2 -2
- package/dist/provider/hooks/mutations/useKeepSessionAlive.d.ts +2 -2
- package/dist/provider/hooks/mutations/useLoginExternalWallet.d.ts +8 -2
- package/dist/provider/hooks/mutations/useLogout.d.ts +2 -2
- package/dist/provider/hooks/mutations/useResendVerificationCode.d.ts +2 -2
- package/dist/provider/hooks/mutations/useSetup2fa.d.ts +2 -2
- package/dist/provider/hooks/mutations/useSignMessage.d.ts +2 -2
- package/dist/provider/hooks/mutations/useSignTransaction.d.ts +2 -2
- package/dist/provider/hooks/mutations/useSignUpOrLogIn.d.ts +2 -2
- package/dist/provider/hooks/mutations/useSwitchWallets.d.ts +57 -0
- package/dist/provider/hooks/mutations/useSwitchWallets.js +30 -0
- package/dist/provider/hooks/mutations/useUpdatePregenWalletIdentifier.d.ts +2 -2
- package/dist/provider/hooks/mutations/useVerify2fa.d.ts +2 -2
- package/dist/provider/hooks/mutations/useVerifyExternalWallet.d.ts +18 -27
- package/dist/provider/hooks/mutations/useVerifyFarcaster.d.ts +5 -5
- package/dist/provider/hooks/mutations/useVerifyNewAccount.d.ts +14 -11
- package/dist/provider/hooks/mutations/useVerifyOAuth.d.ts +2 -2
- package/dist/provider/hooks/mutations/useVerifyTelegram.d.ts +5 -5
- package/dist/provider/hooks/mutations/useWaitForLogin.d.ts +2 -2
- package/dist/provider/hooks/mutations/useWaitForSignup.d.ts +2 -2
- package/dist/provider/hooks/mutations/useWaitForWalletCreation.d.ts +2 -2
- package/dist/provider/hooks/queries/index.d.ts +1 -0
- package/dist/provider/hooks/queries/index.js +2 -0
- package/dist/provider/hooks/queries/useAccount.js +58 -24
- package/dist/provider/hooks/queries/useLinkedAccounts.js +4 -2
- package/dist/provider/hooks/queries/useProfileBalance.d.ts +29 -0
- package/dist/provider/hooks/queries/useProfileBalance.js +65 -0
- package/dist/provider/hooks/utils/useAssetInfo.d.ts +3 -0
- package/dist/provider/hooks/utils/useAssetInfo.js +21 -0
- package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +1 -1
- package/dist/provider/hooks/utils/useEventListeners.js +22 -5
- package/dist/provider/hooks/utils/useModal.js +3 -3
- package/dist/provider/hooks/utils/useWalletState.d.ts +2 -1
- package/dist/provider/hooks/utils/useWalletState.js +2 -1
- package/dist/provider/providers/AccountLinkProvider.js +18 -11
- package/dist/provider/providers/AssetsProvider.d.ts +14 -0
- package/dist/provider/providers/AssetsProvider.js +68 -0
- package/dist/provider/providers/AuthProvider.d.ts +6 -1
- package/dist/provider/providers/AuthProvider.js +204 -44
- package/dist/provider/providers/ExternalWalletProvider.d.ts +19 -5
- package/dist/provider/providers/ExternalWalletProvider.js +363 -44
- package/dist/provider/stores/getters.d.ts +2 -2
- package/dist/provider/stores/slices/modal.js +4 -1
- package/dist/provider/stores/types.d.ts +6 -3
- package/package.json +8 -8
- package/dist/modal/constants/constants.d.ts +0 -35
- package/dist/modal/constants/constants.js +0 -148
- package/dist/modal/utils/routeMobileExternalWallet.d.ts +0 -1
- package/dist/modal/utils/routeMobileExternalWallet.js +0 -31
|
@@ -5,7 +5,8 @@ import { TWalletType } from '@getpara/web-sdk';
|
|
|
5
5
|
export declare const useWalletState: () => {
|
|
6
6
|
selectedWallet: {
|
|
7
7
|
id: string | undefined;
|
|
8
|
-
type: "
|
|
8
|
+
type: "SOLANA" | "COSMOS" | "EVM" | undefined;
|
|
9
|
+
address: string | undefined;
|
|
9
10
|
};
|
|
10
11
|
setSelectedWallet: ({ id, type }: {
|
|
11
12
|
id?: string;
|
|
@@ -37,7 +37,8 @@ const useWalletState = () => {
|
|
|
37
37
|
return {
|
|
38
38
|
selectedWallet: {
|
|
39
39
|
id: selectedWalletId,
|
|
40
|
-
type: selectedWalletType
|
|
40
|
+
type: selectedWalletType,
|
|
41
|
+
address: selectedWalletId ? client == null ? void 0 : client.getDisplayAddress(selectedWalletId, { addressType: selectedWalletType }) : void 0
|
|
41
42
|
},
|
|
42
43
|
setSelectedWallet,
|
|
43
44
|
updateSelectedWallet
|
|
@@ -70,10 +70,9 @@ const AccountLinkProvider = ({ children }) => {
|
|
|
70
70
|
var _a, _b, _c;
|
|
71
71
|
const para = useInternalClient();
|
|
72
72
|
const queryClient = useQueryClient();
|
|
73
|
-
const
|
|
73
|
+
const { embedded } = useAccount();
|
|
74
74
|
const { data: coreAccountLinkInProgress } = useAccountLinkInProgress();
|
|
75
75
|
const {
|
|
76
|
-
wallet: connectedWallet,
|
|
77
76
|
wallets,
|
|
78
77
|
signMessage,
|
|
79
78
|
isSigningMessage,
|
|
@@ -113,8 +112,7 @@ const AccountLinkProvider = ({ children }) => {
|
|
|
113
112
|
status: statusVerifyExternalWalletLink,
|
|
114
113
|
reset: resetVerifyExternalWalletLink
|
|
115
114
|
} = useVerifyExternalWalletLink();
|
|
116
|
-
const
|
|
117
|
-
const isEnabled = (embedded == null ? void 0 : embedded.isConnected) || !(embedded == null ? void 0 : embedded.isGuestMode) && (!((_a = para.authInfo) == null ? void 0 : _a.externalWallet) || includeWalletVerification || externalWalletsWithFullAuth.includes((_c = (_b = para.authInfo) == null ? void 0 : _b.externalWallet) == null ? void 0 : _c.providerId));
|
|
115
|
+
const isEnabled = !(embedded == null ? void 0 : embedded.isGuestMode) && (embedded == null ? void 0 : embedded.isConnected) && (!((_a = para.authInfo) == null ? void 0 : _a.externalWallet) || includeWalletVerification || externalWalletsWithFullAuth === "ALL" || externalWalletsWithFullAuth.includes((_c = (_b = para.authInfo) == null ? void 0 : _b.externalWallet) == null ? void 0 : _c.providerId));
|
|
118
116
|
const [accountLinkInProgress, setAccountLinkInProgress] = useState(
|
|
119
117
|
coreAccountLinkInProgress || void 0
|
|
120
118
|
);
|
|
@@ -152,9 +150,6 @@ const AccountLinkProvider = ({ children }) => {
|
|
|
152
150
|
}
|
|
153
151
|
const providerId = supportedWalletId != null ? supportedWalletId : args.externalWallet.provider;
|
|
154
152
|
const type = args.externalWallet.type;
|
|
155
|
-
if (providerId === (connectedWallet == null ? void 0 : connectedWallet.id)) {
|
|
156
|
-
throw new Error(`Cannot link the currently connected external wallet: ${providerId}`);
|
|
157
|
-
}
|
|
158
153
|
setAccountLinkInProgress({
|
|
159
154
|
type: "EXTERNAL_WALLET",
|
|
160
155
|
pendingWalletProvider: providerId,
|
|
@@ -164,7 +159,7 @@ const AccountLinkProvider = ({ children }) => {
|
|
|
164
159
|
if (!linkWallet) {
|
|
165
160
|
throw new Error(`wallet not installed: ${providerId}`);
|
|
166
161
|
}
|
|
167
|
-
openModal({ step: !type ? ModalStep.
|
|
162
|
+
openModal({ step: !type ? ModalStep.LINK_EX_WALLET_NETWORK_SELECT : ModalStep.ACCOUNT_PROFILE_ADD });
|
|
168
163
|
if (!type) {
|
|
169
164
|
return;
|
|
170
165
|
}
|
|
@@ -193,7 +188,7 @@ const AccountLinkProvider = ({ children }) => {
|
|
|
193
188
|
setLinkAccountError(e.message);
|
|
194
189
|
} finally {
|
|
195
190
|
if (linkWallet.type === "EVM" || linkWallet.type === "SOLANA") {
|
|
196
|
-
yield disconnectBase(providerId, linkWallet.type);
|
|
191
|
+
yield disconnectBase(providerId, linkWallet.type, { disconnectType: "ACCOUNT_LINKING" });
|
|
197
192
|
}
|
|
198
193
|
}
|
|
199
194
|
}
|
|
@@ -316,15 +311,27 @@ const AccountLinkProvider = ({ children }) => {
|
|
|
316
311
|
break;
|
|
317
312
|
}
|
|
318
313
|
};
|
|
319
|
-
const onAccountLinkVerified = (updatedAccounts) => {
|
|
314
|
+
const onAccountLinkVerified = (updatedAccounts) => __async(void 0, null, function* () {
|
|
320
315
|
queryClient.invalidateQueries({ queryKey: [LINKED_ACCOUNTS_BASE_KEY] });
|
|
321
316
|
queryClient.setQueryData(["getLinkedAccounts"], () => updatedAccounts);
|
|
317
|
+
if ((accountLinkInProgress == null ? void 0 : accountLinkInProgress.type) === "EXTERNAL_WALLET" && accountLinkInProgress.externalWallet) {
|
|
318
|
+
try {
|
|
319
|
+
yield disconnectBase(
|
|
320
|
+
accountLinkInProgress.externalWallet.providerId,
|
|
321
|
+
accountLinkInProgress.externalWallet.type,
|
|
322
|
+
{ disconnectType: "ACCOUNT_LINKING" }
|
|
323
|
+
);
|
|
324
|
+
} catch (e) {
|
|
325
|
+
}
|
|
326
|
+
}
|
|
322
327
|
setTimeout(() => {
|
|
323
328
|
setStep(ModalStep.ACCOUNT_PROFILE);
|
|
329
|
+
setAccountLinkInProgress(void 0);
|
|
324
330
|
}, 2e3);
|
|
325
|
-
};
|
|
331
|
+
});
|
|
326
332
|
const onAccountLinkError = (e) => {
|
|
327
333
|
setLinkAccountError(e instanceof Error ? e.message : e);
|
|
334
|
+
setAccountLinkInProgress(void 0);
|
|
328
335
|
};
|
|
329
336
|
const unlinkAccount = (linkedAccount) => {
|
|
330
337
|
setUnlinkingAccount(linkedAccount);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { AssetMetadataIndexed, ProfileBalance } from '@getpara/web-sdk';
|
|
3
|
+
type Value = {
|
|
4
|
+
displayCurrency: 'USD';
|
|
5
|
+
profileBalance: ProfileBalance | null;
|
|
6
|
+
profileBalanceIsPending: boolean;
|
|
7
|
+
assetMetadata: AssetMetadataIndexed | null;
|
|
8
|
+
assetMetadataIsPending: boolean;
|
|
9
|
+
totalBalance: string | undefined;
|
|
10
|
+
};
|
|
11
|
+
export declare const AssetsContext: import("react").Context<Value>;
|
|
12
|
+
export declare function AssetsProvider({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare const useAssets: () => Value;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../chunk-MMUBH76A.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { createContext, useContext, useMemo } from "react";
|
|
5
|
+
import { formatCurrency, formatAssetQuantity } from "@getpara/web-sdk";
|
|
6
|
+
import { useAssetInfo } from "../hooks/utils/useAssetInfo.js";
|
|
7
|
+
import { useStore } from "../stores/useStore.js";
|
|
8
|
+
import { useProfileBalance } from "../hooks/queries/index.js";
|
|
9
|
+
const AssetsContext = createContext({
|
|
10
|
+
displayCurrency: "USD",
|
|
11
|
+
profileBalance: null,
|
|
12
|
+
profileBalanceIsPending: true,
|
|
13
|
+
assetMetadata: null,
|
|
14
|
+
assetMetadataIsPending: true,
|
|
15
|
+
totalBalance: void 0
|
|
16
|
+
});
|
|
17
|
+
function AssetsProvider({ children }) {
|
|
18
|
+
const balancesConfig = useStore((state) => {
|
|
19
|
+
var _a;
|
|
20
|
+
return (_a = state.modalConfig) == null ? void 0 : _a.balances;
|
|
21
|
+
});
|
|
22
|
+
const { data: profileBalance, isPending: profileBalanceIsPending } = useProfileBalance();
|
|
23
|
+
const { data: assetMetadata, isPending: assetMetadataIsPending } = useAssetInfo();
|
|
24
|
+
const totalBalance = useMemo(() => {
|
|
25
|
+
switch (true) {
|
|
26
|
+
case !balancesConfig:
|
|
27
|
+
case (balancesConfig == null ? void 0 : balancesConfig.displayType) === "AGGREGATED":
|
|
28
|
+
if (!(profileBalance == null ? void 0 : profileBalance.value)) {
|
|
29
|
+
return void 0;
|
|
30
|
+
}
|
|
31
|
+
return formatCurrency(profileBalance.value);
|
|
32
|
+
default: {
|
|
33
|
+
if (!profileBalance) {
|
|
34
|
+
return void 0;
|
|
35
|
+
}
|
|
36
|
+
const assetQuantity = profileBalance.wallets.reduce((acc, wallet) => {
|
|
37
|
+
const asset = wallet.assets.find((a) => {
|
|
38
|
+
var _a;
|
|
39
|
+
return ((_a = a.metadata) == null ? void 0 : _a.symbol) === balancesConfig.asset.symbol;
|
|
40
|
+
});
|
|
41
|
+
if (!asset) {
|
|
42
|
+
return acc;
|
|
43
|
+
}
|
|
44
|
+
return acc + asset.quantity;
|
|
45
|
+
}, 0);
|
|
46
|
+
return formatAssetQuantity({ quantity: assetQuantity, symbol: balancesConfig.asset.symbol });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}, [balancesConfig, profileBalance]);
|
|
50
|
+
const value = useMemo(
|
|
51
|
+
() => ({
|
|
52
|
+
displayCurrency: "USD",
|
|
53
|
+
profileBalance: profileBalance || null,
|
|
54
|
+
profileBalanceIsPending,
|
|
55
|
+
assetMetadata: assetMetadata || null,
|
|
56
|
+
assetMetadataIsPending,
|
|
57
|
+
totalBalance
|
|
58
|
+
}),
|
|
59
|
+
[profileBalance, totalBalance, profileBalanceIsPending, assetMetadata, assetMetadataIsPending]
|
|
60
|
+
);
|
|
61
|
+
return /* @__PURE__ */ jsx(AssetsContext.Provider, { value, children });
|
|
62
|
+
}
|
|
63
|
+
const useAssets = () => useContext(AssetsContext);
|
|
64
|
+
export {
|
|
65
|
+
AssetsContext,
|
|
66
|
+
AssetsProvider,
|
|
67
|
+
useAssets
|
|
68
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BiometricHints } from '@getpara/react-common';
|
|
2
2
|
import { PropsWithChildren } from 'react';
|
|
3
|
-
import { AuthMethod, CoreMethodParams, AuthState, AuthStateSignup, AuthStateLogin } from '@getpara/web-sdk';
|
|
3
|
+
import { AuthMethod, CoreMethodParams, AuthState, AuthStateSignup, AuthStateLogin, AuthStateVerify } from '@getpara/web-sdk';
|
|
4
4
|
import { ParaModalProps } from '../../modal/types/modalProps.js';
|
|
5
5
|
import { VerifiedAuth, VerifyThirdPartyAuth } from '@getpara/user-management-client';
|
|
6
6
|
import { MutationStatus } from '@tanstack/react-query';
|
|
@@ -18,10 +18,15 @@ type Value = {
|
|
|
18
18
|
onNewAuthState: (_: AuthState) => void;
|
|
19
19
|
presentSignupUi: (_: AuthMethod, __: AuthStateSignup) => void;
|
|
20
20
|
presentLoginUi: (_: AuthMethod, __: AuthStateLogin) => void;
|
|
21
|
+
presentVerifyUi: (_: AuthMethod, __: AuthStateVerify) => void;
|
|
21
22
|
isSetup2faPending: boolean;
|
|
22
23
|
createGuestWallets: () => void;
|
|
23
24
|
isCreateGuestWalletsPending: boolean;
|
|
24
25
|
logout: () => void;
|
|
26
|
+
switchWallets: (authMethod?: string) => void;
|
|
27
|
+
switchWalletsUrl: string | undefined;
|
|
28
|
+
setSwitchWalletsUrl: (_: string) => void;
|
|
29
|
+
isSwitchWalletsPending: boolean;
|
|
25
30
|
biometricHints?: BiometricHints;
|
|
26
31
|
};
|
|
27
32
|
type Props = PropsWithChildren<{
|
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
__spreadValues
|
|
6
6
|
} from "../../chunk-MMUBH76A.js";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
|
-
import { useUserAgent } from "@getpara/react-common";
|
|
9
|
-
import { createContext, useCallback, useContext, useEffect, useMemo } from "react";
|
|
8
|
+
import { openMobileUrl, useUserAgent } from "@getpara/react-common";
|
|
9
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
10
10
|
import { useModalStore } from "../../modal/stores/index.js";
|
|
11
11
|
import { ModalStep } from "../../modal/utils/steps.js";
|
|
12
12
|
import {
|
|
@@ -20,22 +20,24 @@ import {
|
|
|
20
20
|
useVerifyTelegram,
|
|
21
21
|
useSetup2fa,
|
|
22
22
|
useLogout,
|
|
23
|
-
useCreateGuestWallets
|
|
23
|
+
useCreateGuestWallets,
|
|
24
|
+
useWalletState
|
|
24
25
|
} from "../index.js";
|
|
26
|
+
import { useSwitchWallets } from "../hooks/mutations/useSwitchWallets.js";
|
|
25
27
|
import { DEFAULTS } from "../../modal/constants/defaults.js";
|
|
26
28
|
import { openPopup } from "../../modal/utils/openPopup.js";
|
|
27
29
|
import {
|
|
28
30
|
AuthMethod,
|
|
29
31
|
entityToWallet,
|
|
30
|
-
|
|
32
|
+
isMobile
|
|
31
33
|
} from "@getpara/web-sdk";
|
|
32
34
|
import { useInternalClient } from "../../provider/hooks/utils/useInternalClient.js";
|
|
33
35
|
import { useGoBack } from "../../modal/hooks/useGoBack.js";
|
|
34
36
|
import { isExternalWallet } from "@getpara/user-management-client";
|
|
35
|
-
import { routeMobileExternalWallet } from "../../modal/utils/routeMobileExternalWallet.js";
|
|
36
37
|
import { useStore } from "../stores/useStore.js";
|
|
37
38
|
import { useFormattedBiometricHints } from "../hooks/utils/useFormattedBiometricHints.js";
|
|
38
39
|
import { useQueryClient } from "@tanstack/react-query";
|
|
40
|
+
import { validatePortalOrigin } from "../../modal/utils/validatePortalOrigin.js";
|
|
39
41
|
const AuthContext = createContext({
|
|
40
42
|
signUpOrLogIn: () => {
|
|
41
43
|
},
|
|
@@ -59,11 +61,19 @@ const AuthContext = createContext({
|
|
|
59
61
|
},
|
|
60
62
|
presentLoginUi: () => {
|
|
61
63
|
},
|
|
64
|
+
presentVerifyUi: () => {
|
|
65
|
+
},
|
|
62
66
|
createGuestWallets: () => {
|
|
63
67
|
},
|
|
64
68
|
isCreateGuestWalletsPending: false,
|
|
65
69
|
logout: () => {
|
|
66
|
-
}
|
|
70
|
+
},
|
|
71
|
+
switchWallets: () => {
|
|
72
|
+
},
|
|
73
|
+
switchWalletsUrl: void 0,
|
|
74
|
+
setSwitchWalletsUrl: () => {
|
|
75
|
+
},
|
|
76
|
+
isSwitchWalletsPending: false
|
|
67
77
|
});
|
|
68
78
|
function AuthProvider({
|
|
69
79
|
children,
|
|
@@ -109,10 +119,15 @@ function AuthProvider({
|
|
|
109
119
|
const { waitForLogin: mutateWaitForLogin } = useWaitForLogin();
|
|
110
120
|
const { waitForSignup: mutateWaitForSignup } = useWaitForSignup();
|
|
111
121
|
const { waitForWalletCreationAsync: mutateAsyncWaitForWalletCreation } = useWaitForWalletCreation();
|
|
122
|
+
const { switchWallets: mutateSwitchWallets, isPending: mutateIsSwitchWalletsPending } = useSwitchWallets();
|
|
112
123
|
const { setup2fa: mutateSetup2fa, isPending: isSetup2faPending } = useSetup2fa();
|
|
113
124
|
const { createGuestWallets: mutateCreateGuestWallets, isPending: isCreateGuestWalletsPending } = useCreateGuestWallets();
|
|
114
125
|
const { logout: mutateLogout } = useLogout();
|
|
126
|
+
const { updateSelectedWallet } = useWalletState();
|
|
115
127
|
const { data: biometricHints } = useFormattedBiometricHints();
|
|
128
|
+
const [switchWalletsUrl, setSwitchWalletsUrl] = useState(void 0);
|
|
129
|
+
const [isSwitchWalletsPending, setIsSwitchWalletsPending] = useState(mutateIsSwitchWalletsPending);
|
|
130
|
+
const messageHandlerRef = useRef(null);
|
|
116
131
|
const goBackIfPopupClosedOnSteps = (steps) => {
|
|
117
132
|
var _a;
|
|
118
133
|
if (((_a = refs.popupWindow.current) == null ? void 0 : _a.closed) && (!refs.currentStep.current || steps.includes(refs.currentStep.current))) {
|
|
@@ -125,10 +140,12 @@ function AuthProvider({
|
|
|
125
140
|
return !!stepNow && !steps.includes(stepNow);
|
|
126
141
|
};
|
|
127
142
|
const setupListener = () => {
|
|
128
|
-
|
|
143
|
+
if (messageHandlerRef.current) {
|
|
144
|
+
window.removeEventListener("message", messageHandlerRef.current);
|
|
145
|
+
}
|
|
146
|
+
const handleMessage = (event) => {
|
|
129
147
|
var _a;
|
|
130
|
-
|
|
131
|
-
if (!event.origin.startsWith(portalBase)) {
|
|
148
|
+
if (!validatePortalOrigin(event, para.ctx)) {
|
|
132
149
|
return;
|
|
133
150
|
}
|
|
134
151
|
if (((_a = event.data) == null ? void 0 : _a.type) === "CLOSE_WINDOW") {
|
|
@@ -136,11 +153,16 @@ function AuthProvider({
|
|
|
136
153
|
setAuthStepRoute();
|
|
137
154
|
setIFrameUrl();
|
|
138
155
|
setIsIFrameReady(false);
|
|
139
|
-
|
|
156
|
+
if (refs.currentStep.current !== ModalStep.LOGIN_DONE && refs.currentStep.current !== ModalStep.AWAITING_ACCOUNT) {
|
|
157
|
+
setStep(ModalStep.AWAITING_ACCOUNT);
|
|
158
|
+
}
|
|
140
159
|
}
|
|
141
160
|
window.removeEventListener("message", handleMessage);
|
|
161
|
+
messageHandlerRef.current = null;
|
|
142
162
|
}
|
|
143
|
-
}
|
|
163
|
+
};
|
|
164
|
+
messageHandlerRef.current = handleMessage;
|
|
165
|
+
window.addEventListener("message", handleMessage);
|
|
144
166
|
};
|
|
145
167
|
const pollSignup = () => {
|
|
146
168
|
if (typeof window !== "undefined") {
|
|
@@ -167,7 +189,9 @@ function AuthProvider({
|
|
|
167
189
|
onSuccess: () => {
|
|
168
190
|
if (para.isNoWalletConfig) {
|
|
169
191
|
onLoginComplete({
|
|
170
|
-
on2faSetupOrError: () =>
|
|
192
|
+
on2faSetupOrError: () => {
|
|
193
|
+
setStep(ModalStep.LOGIN_DONE);
|
|
194
|
+
},
|
|
171
195
|
on2faNotSetup: () => setStep(ModalStep.SETUP_2FA)
|
|
172
196
|
});
|
|
173
197
|
} else {
|
|
@@ -200,12 +224,14 @@ function AuthProvider({
|
|
|
200
224
|
if (refs.currentStep.current !== ModalStep.AWAITING_BIOMETRIC_CREATION) {
|
|
201
225
|
setStep(ModalStep.AWAITING_BIOMETRIC_CREATION);
|
|
202
226
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
227
|
+
if (typeof window !== "undefined") {
|
|
228
|
+
refs.popupWindow.current = openPopup({
|
|
229
|
+
url: authState.passkeyUrl,
|
|
230
|
+
target: "ParaPasskey",
|
|
231
|
+
type: "CREATE_PASSKEY",
|
|
232
|
+
current: refs.popupWindow.current
|
|
233
|
+
});
|
|
234
|
+
}
|
|
209
235
|
break;
|
|
210
236
|
case AuthMethod.PASSWORD:
|
|
211
237
|
setupListener();
|
|
@@ -234,7 +260,7 @@ function AuthProvider({
|
|
|
234
260
|
const presentVerifyUi = useCallback(
|
|
235
261
|
(method, authState) => {
|
|
236
262
|
switch (method) {
|
|
237
|
-
case AuthMethod.
|
|
263
|
+
case AuthMethod.BASIC_LOGIN:
|
|
238
264
|
setupListener();
|
|
239
265
|
if (isIFrameReady) {
|
|
240
266
|
setStep(ModalStep.OTP);
|
|
@@ -249,13 +275,14 @@ function AuthProvider({
|
|
|
249
275
|
[isIFrameReady]
|
|
250
276
|
);
|
|
251
277
|
const login = (authState) => {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
} else {
|
|
278
|
+
const hasPasskey = !!authState.passkeyUrl;
|
|
279
|
+
if (!hasPasskey) {
|
|
255
280
|
setupListener();
|
|
256
281
|
setIFrameUrl(authState.passwordUrl || authState.pinUrl);
|
|
257
282
|
setIsIFrameReady(false);
|
|
258
283
|
setStep(ModalStep.EMBEDDED_PASSWORD_LOGIN);
|
|
284
|
+
} else {
|
|
285
|
+
setStep(ModalStep.BIOMETRIC_LOGIN);
|
|
259
286
|
}
|
|
260
287
|
pollLogin();
|
|
261
288
|
};
|
|
@@ -272,14 +299,19 @@ function AuthProvider({
|
|
|
272
299
|
ModalStep.AWAITING_BIOMETRIC_LOGIN,
|
|
273
300
|
ModalStep.AWAITING_PASSWORD_LOGIN,
|
|
274
301
|
ModalStep.AWAITING_ACCOUNT,
|
|
275
|
-
ModalStep.OTP
|
|
302
|
+
ModalStep.OTP,
|
|
303
|
+
ModalStep.FARCASTER_OAUTH,
|
|
304
|
+
ModalStep.TELEGRAM_OAUTH,
|
|
305
|
+
ModalStep.AWAITING_OAUTH,
|
|
306
|
+
ModalStep.SWITCH_WALLETS
|
|
276
307
|
]),
|
|
277
308
|
onPoll: () => {
|
|
278
309
|
goBackIfPopupClosedOnSteps([
|
|
279
310
|
ModalStep.AWAITING_BIOMETRIC_LOGIN,
|
|
280
311
|
ModalStep.AWAITING_PASSWORD_LOGIN,
|
|
281
312
|
ModalStep.EMBEDDED_PASSWORD_LOGIN,
|
|
282
|
-
ModalStep.OTP
|
|
313
|
+
ModalStep.OTP,
|
|
314
|
+
ModalStep.SWITCH_WALLETS
|
|
283
315
|
]);
|
|
284
316
|
}
|
|
285
317
|
},
|
|
@@ -321,23 +353,49 @@ function AuthProvider({
|
|
|
321
353
|
loginOverride();
|
|
322
354
|
return;
|
|
323
355
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
356
|
+
if (typeof window !== "undefined") {
|
|
357
|
+
refs.popupWindow.current = openPopup({
|
|
358
|
+
url: isPIN ? authState.pinUrl : isPassword ? authState.passwordUrl : authState.passkeyUrl,
|
|
359
|
+
target: isPIN ? "ParaPIN" : isPassword ? "ParaPassword" : "ParaPasskey",
|
|
360
|
+
type: isPIN ? "LOGIN_PASSWORD" : isPassword ? "LOGIN_PASSWORD" : "LOGIN_PASSKEY",
|
|
361
|
+
current: refs.popupWindow.current
|
|
362
|
+
});
|
|
363
|
+
}
|
|
330
364
|
setStep(isPassword || isPIN ? ModalStep.AWAITING_PASSWORD_LOGIN : ModalStep.AWAITING_BIOMETRIC_LOGIN);
|
|
331
365
|
},
|
|
332
366
|
[loginState, biometricHints]
|
|
333
367
|
);
|
|
334
368
|
const onNewAuthState = (authState) => __async(this, null, function* () {
|
|
335
|
-
|
|
369
|
+
var _a, _b, _c;
|
|
336
370
|
setAuthState(authState);
|
|
337
371
|
switch (authState.stage) {
|
|
338
372
|
case "verify":
|
|
339
|
-
if (isExternalWallet(authState.auth)
|
|
340
|
-
|
|
373
|
+
if (isExternalWallet(authState.auth)) {
|
|
374
|
+
if (authState.loginUrl && ((_a = authState.externalWallet) == null ? void 0 : _a.withFullParaAuth)) {
|
|
375
|
+
let isBasicLogin = false;
|
|
376
|
+
if (authState.nextStage === "login") {
|
|
377
|
+
isBasicLogin = authState.loginAuthMethods.includes(AuthMethod.BASIC_LOGIN);
|
|
378
|
+
} else {
|
|
379
|
+
isBasicLogin = authState.signupAuthMethods.includes(AuthMethod.BASIC_LOGIN);
|
|
380
|
+
}
|
|
381
|
+
if (authState.nextStage === "login") {
|
|
382
|
+
setFlow("login");
|
|
383
|
+
isBasicLogin && pollLogin();
|
|
384
|
+
} else {
|
|
385
|
+
setFlow("signup");
|
|
386
|
+
isBasicLogin && pollSignup();
|
|
387
|
+
}
|
|
388
|
+
if (!isMobile() && refs.popupWindow.current) {
|
|
389
|
+
refs.popupWindow.current.location.href = authState.loginUrl;
|
|
390
|
+
setStep(ModalStep.AWAITING_ACCOUNT);
|
|
391
|
+
} else {
|
|
392
|
+
setIFrameUrl(authState.loginUrl);
|
|
393
|
+
setStep(ModalStep.OTP);
|
|
394
|
+
setupListener();
|
|
395
|
+
}
|
|
396
|
+
} else {
|
|
397
|
+
setStep(ModalStep.EXTERNAL_WALLET_VERIFICATION);
|
|
398
|
+
}
|
|
341
399
|
} else {
|
|
342
400
|
if (authState.nextStage === "login") {
|
|
343
401
|
setFlow("login");
|
|
@@ -349,7 +407,7 @@ function AuthProvider({
|
|
|
349
407
|
if (authState.loginUrl) {
|
|
350
408
|
setIFrameUrl(authState.loginUrl);
|
|
351
409
|
setIsIFrameReady(false);
|
|
352
|
-
presentVerifyUi(AuthMethod.
|
|
410
|
+
presentVerifyUi(AuthMethod.BASIC_LOGIN, authState);
|
|
353
411
|
} else {
|
|
354
412
|
setStep(ModalStep.VERIFICATIONS);
|
|
355
413
|
}
|
|
@@ -378,14 +436,18 @@ function AuthProvider({
|
|
|
378
436
|
}
|
|
379
437
|
break;
|
|
380
438
|
case "done":
|
|
381
|
-
if (authState.
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
439
|
+
if (!((_b = authState.externalWallet) == null ? void 0 : _b.withFullParaAuth) && !((_c = authState.externalWallet) == null ? void 0 : _c.withVerification)) {
|
|
440
|
+
if (authState.isNewUser) {
|
|
441
|
+
pollSignup();
|
|
442
|
+
setFlow("signup");
|
|
443
|
+
} else {
|
|
444
|
+
pollLogin();
|
|
445
|
+
setFlow("login");
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
if (!authState.isWalletSelectionNeeded) {
|
|
449
|
+
setStep(ModalStep.AWAITING_ACCOUNT);
|
|
387
450
|
}
|
|
388
|
-
setStep(ModalStep.AWAITING_ACCOUNT);
|
|
389
451
|
break;
|
|
390
452
|
}
|
|
391
453
|
});
|
|
@@ -431,13 +493,17 @@ function AuthProvider({
|
|
|
431
493
|
);
|
|
432
494
|
});
|
|
433
495
|
const verifyFarcaster = (serverAuthState) => __async(this, null, function* () {
|
|
434
|
-
|
|
496
|
+
if (!serverAuthState) {
|
|
497
|
+
setStep(ModalStep.FARCASTER_OAUTH);
|
|
498
|
+
} else {
|
|
499
|
+
setupListener();
|
|
500
|
+
}
|
|
435
501
|
mutateVerifyFarcaster(
|
|
436
502
|
{
|
|
437
503
|
isCanceled: () => refs.currentStep.current !== ModalStep.FARCASTER_OAUTH,
|
|
438
504
|
onConnectUri: (connectUri) => {
|
|
439
505
|
setFarcasterConnectUri(connectUri);
|
|
440
|
-
|
|
506
|
+
openMobileUrl(connectUri);
|
|
441
507
|
},
|
|
442
508
|
useShortUrls: true,
|
|
443
509
|
serverAuthState
|
|
@@ -453,6 +519,9 @@ function AuthProvider({
|
|
|
453
519
|
);
|
|
454
520
|
});
|
|
455
521
|
const verifyTelegram = (serverAuthState) => __async(this, null, function* () {
|
|
522
|
+
if (serverAuthState) {
|
|
523
|
+
setupListener();
|
|
524
|
+
}
|
|
456
525
|
mutateVerifyTelegram(
|
|
457
526
|
{
|
|
458
527
|
serverAuthState,
|
|
@@ -542,11 +611,81 @@ function AuthProvider({
|
|
|
542
611
|
const logout = () => {
|
|
543
612
|
mutateLogout();
|
|
544
613
|
};
|
|
614
|
+
const switchWallets = () => {
|
|
615
|
+
if (!switchWalletsUrl) {
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
setIsSwitchWalletsPending(true);
|
|
619
|
+
try {
|
|
620
|
+
setStep(ModalStep.SWITCH_WALLETS);
|
|
621
|
+
refs.popupWindow.current = openPopup({
|
|
622
|
+
url: switchWalletsUrl,
|
|
623
|
+
target: "ParaSwitchWallets",
|
|
624
|
+
type: "SWITCH_WALLETS",
|
|
625
|
+
current: refs.popupWindow.current
|
|
626
|
+
});
|
|
627
|
+
pollSwitchWallets();
|
|
628
|
+
} catch (error) {
|
|
629
|
+
console.error("Failed to open wallet switching popup:", error);
|
|
630
|
+
}
|
|
631
|
+
};
|
|
632
|
+
const pollSwitchWallets = () => {
|
|
633
|
+
if (typeof window !== "undefined") {
|
|
634
|
+
refs.poll.current = {
|
|
635
|
+
action: "login",
|
|
636
|
+
timeout: window == null ? void 0 : window.setTimeout(() => __async(this, null, function* () {
|
|
637
|
+
mutateSwitchWallets(
|
|
638
|
+
{
|
|
639
|
+
isCanceled: () => {
|
|
640
|
+
var _a, _b;
|
|
641
|
+
const exitedSteps = cancelIfExitedSteps([ModalStep.SWITCH_WALLETS, ModalStep.SWITCH_WALLETS_IFRAME]);
|
|
642
|
+
const popupClosed = (_b = (_a = refs.popupWindow.current) == null ? void 0 : _a.closed) != null ? _b : false;
|
|
643
|
+
const isCanceled = exitedSteps || popupClosed;
|
|
644
|
+
if (isCanceled) {
|
|
645
|
+
if (popupClosed && (refs.currentStep.current === ModalStep.SWITCH_WALLETS || refs.currentStep.current === ModalStep.SWITCH_WALLETS_IFRAME)) {
|
|
646
|
+
goBack();
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
return isCanceled;
|
|
650
|
+
},
|
|
651
|
+
onPoll: () => {
|
|
652
|
+
if (refs.currentStep.current === ModalStep.SWITCH_WALLETS || refs.currentStep.current === ModalStep.SWITCH_WALLETS_IFRAME) {
|
|
653
|
+
goBackIfPopupClosedOnSteps([ModalStep.SWITCH_WALLETS, ModalStep.SWITCH_WALLETS_IFRAME]);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
},
|
|
657
|
+
{
|
|
658
|
+
onSuccess: () => {
|
|
659
|
+
updateSelectedWallet();
|
|
660
|
+
setTimeout(() => {
|
|
661
|
+
setStep(ModalStep.ACCOUNT_PROFILE);
|
|
662
|
+
refs.popupWindow.current = null;
|
|
663
|
+
}, 500);
|
|
664
|
+
},
|
|
665
|
+
onError: () => {
|
|
666
|
+
if (refs.currentStep.current === ModalStep.SWITCH_WALLETS) {
|
|
667
|
+
goBack();
|
|
668
|
+
}
|
|
669
|
+
},
|
|
670
|
+
onSettled: () => {
|
|
671
|
+
var _a;
|
|
672
|
+
setIsSwitchWalletsPending(false);
|
|
673
|
+
window == null ? void 0 : window.clearTimeout((_a = refs.poll.current) == null ? void 0 : _a.timeout);
|
|
674
|
+
refs.poll.current = null;
|
|
675
|
+
refs.popupWindow.current = null;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
);
|
|
679
|
+
}), DEFAULTS.LOGGIN_POLLING_DELAY_MS)
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
};
|
|
545
683
|
const isPasswordIFrameLoading = !!iFrameUrl && iFrameUrl === (signupState == null ? void 0 : signupState.passwordUrl) && !isIFrameReady;
|
|
546
684
|
const value = useMemo(
|
|
547
685
|
() => ({
|
|
548
686
|
presentSignupUi,
|
|
549
687
|
presentLoginUi,
|
|
688
|
+
presentVerifyUi,
|
|
550
689
|
signUpOrLogIn,
|
|
551
690
|
isSignUpOrLogInPending,
|
|
552
691
|
verifyNewAccount,
|
|
@@ -561,12 +700,17 @@ function AuthProvider({
|
|
|
561
700
|
createGuestWallets,
|
|
562
701
|
isCreateGuestWalletsPending,
|
|
563
702
|
logout,
|
|
703
|
+
switchWallets,
|
|
704
|
+
switchWalletsUrl,
|
|
705
|
+
setSwitchWalletsUrl,
|
|
706
|
+
isSwitchWalletsPending,
|
|
564
707
|
biometricHints: biometricHints || void 0,
|
|
565
708
|
verifyFarcasterStatus
|
|
566
709
|
}),
|
|
567
710
|
[
|
|
568
711
|
presentSignupUi,
|
|
569
712
|
presentLoginUi,
|
|
713
|
+
presentVerifyUi,
|
|
570
714
|
signUpOrLogIn,
|
|
571
715
|
isSignUpOrLogInPending,
|
|
572
716
|
verifyNewAccount,
|
|
@@ -582,16 +726,26 @@ function AuthProvider({
|
|
|
582
726
|
createGuestWallets,
|
|
583
727
|
isCreateGuestWalletsPending,
|
|
584
728
|
logout,
|
|
729
|
+
switchWallets,
|
|
730
|
+
switchWalletsUrl,
|
|
731
|
+
setSwitchWalletsUrl,
|
|
732
|
+
isSwitchWalletsPending,
|
|
585
733
|
biometricHints,
|
|
586
734
|
verifyFarcasterStatus
|
|
587
735
|
]
|
|
588
736
|
);
|
|
589
737
|
useEffect(() => {
|
|
738
|
+
let timerId;
|
|
590
739
|
if (!!authStepRoute && refs.currentStep.current !== authStepRoute) {
|
|
591
|
-
setTimeout(() => {
|
|
740
|
+
timerId = setTimeout(() => {
|
|
592
741
|
setStep(authStepRoute);
|
|
593
742
|
}, 200);
|
|
594
743
|
}
|
|
744
|
+
return () => {
|
|
745
|
+
if (timerId) {
|
|
746
|
+
clearTimeout(timerId);
|
|
747
|
+
}
|
|
748
|
+
};
|
|
595
749
|
}, [authStepRoute]);
|
|
596
750
|
useEffect(() => {
|
|
597
751
|
refs.currentStep.current = currentStep;
|
|
@@ -601,10 +755,16 @@ function AuthProvider({
|
|
|
601
755
|
setStep(ModalStep.ACCOUNT_MAIN);
|
|
602
756
|
}
|
|
603
757
|
}, [isCreateGuestWalletsPending]);
|
|
758
|
+
useEffect(() => {
|
|
759
|
+
setIsSwitchWalletsPending((prev) => !!prev ? mutateIsSwitchWalletsPending : prev);
|
|
760
|
+
}, [mutateIsSwitchWalletsPending]);
|
|
604
761
|
useEffect(() => {
|
|
605
762
|
return () => {
|
|
606
763
|
var _a;
|
|
607
764
|
window == null ? void 0 : window.clearTimeout((_a = refs.poll.current) == null ? void 0 : _a.timeout);
|
|
765
|
+
if (messageHandlerRef.current) {
|
|
766
|
+
window.removeEventListener("message", messageHandlerRef.current);
|
|
767
|
+
}
|
|
608
768
|
};
|
|
609
769
|
}, []);
|
|
610
770
|
return /* @__PURE__ */ jsx(AuthContext.Provider, { value, children });
|