@getpara/react-sdk 1.12.0 → 2.0.0-alpha.11
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 +35 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/dist/modal/ParaModal.js +211 -313
- package/dist/modal/components/Account/Account.js +73 -16
- package/dist/modal/components/AddFunds/AddFunds.js +5 -6
- package/dist/modal/components/AddFunds/AddFundsAsset.js +15 -13
- package/dist/modal/components/AddFunds/AddFundsAwaiting.js +16 -10
- package/dist/modal/components/AddFunds/AddFundsContext.d.ts +2 -2
- package/dist/modal/components/AddFunds/AddFundsContext.js +20 -14
- package/dist/modal/components/AddFunds/AddFundsDone.js +10 -4
- package/dist/modal/components/AddFunds/AddFundsProvider.js +11 -7
- package/dist/modal/components/AddFunds/AddFundsReceive.js +17 -13
- package/dist/modal/components/AddFunds/AddFundsSettings.js +10 -6
- package/dist/modal/components/AddFunds/common.d.ts +1 -1
- package/dist/modal/components/AuthInput/AuthInput.d.ts +1 -1
- package/dist/modal/components/AuthInput/AuthInput.js +70 -91
- package/dist/modal/components/AuthInput/hooks/useDropdownPosition.d.ts +4 -4
- package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +4 -4
- package/dist/modal/components/AuthMainStep/AuthMainStep.d.ts +4 -3
- package/dist/modal/components/AuthMainStep/AuthMainStep.js +20 -7
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.d.ts +4 -3
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +54 -10
- package/dist/modal/components/AuthOptions/AuthOptions.d.ts +4 -3
- package/dist/modal/components/AuthOptions/AuthOptions.js +35 -7
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.d.ts +5 -1
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +9 -4
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.d.ts +1 -3
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +25 -17
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.d.ts +1 -1
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +34 -72
- package/dist/modal/components/Body/Body.d.ts +4 -3
- package/dist/modal/components/Body/Body.js +27 -10
- package/dist/modal/components/ChainSwitch/ChainSwitch.d.ts +1 -1
- package/dist/modal/components/ChainSwitch/ChainSwitch.js +5 -4
- package/dist/modal/components/Controls/Controls.js +5 -2
- package/dist/modal/components/Controls/Selects.d.ts +1 -1
- package/dist/modal/components/Controls/Selects.js +30 -25
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +1 -1
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +10 -6
- package/dist/modal/components/ExternalWalletVerificationStep/ExternalWalletVerificationStep.js +7 -69
- package/dist/modal/components/ExternalWallets/ExternalWallets.js +7 -6
- package/dist/modal/components/Footer/Footer.d.ts +1 -1
- package/dist/modal/components/Footer/Footer.js +6 -4
- package/dist/modal/components/Header/hooks/useStepTitle.js +7 -3
- package/dist/modal/components/Hero/Hero.js +5 -5
- package/dist/modal/components/IFrameStep/IFrameStep.js +8 -4
- package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +7 -4
- package/dist/modal/components/ModalContent/ModalContent.js +14 -243
- package/dist/modal/components/OAuth/FarcasterOAuthStep.js +3 -57
- package/dist/modal/components/OAuth/OAuth.d.ts +2 -2
- package/dist/modal/components/OAuth/OAuth.js +11 -85
- package/dist/modal/components/OAuth/TelegramOAuthStep.js +11 -60
- package/dist/modal/components/OnRampComponents/AddingFunds.js +1 -1
- package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +10 -4
- package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +23 -32
- package/dist/modal/components/StripeComponents/StripeComponents.js +1 -1
- package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +5 -2
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +44 -60
- package/dist/modal/components/WalletCard/WalletCard.d.ts +5 -5
- package/dist/modal/components/WalletCard/WalletCard.js +8 -7
- package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +33 -12
- package/dist/modal/components/common.d.ts +5 -5
- package/dist/modal/components/common.js +10 -4
- package/dist/modal/constants/constants.d.ts +1 -1
- package/dist/modal/constants/oAuthLogos.d.ts +3 -3
- package/dist/modal/hooks/useGoBack.js +6 -5
- package/dist/modal/index.d.ts +0 -3
- package/dist/modal/index.js +1 -5
- package/dist/modal/stores/index.d.ts +0 -2
- package/dist/modal/stores/index.js +0 -2
- package/dist/modal/stores/modal/actions.js +69 -16
- package/dist/modal/stores/modal/useModalStore.d.ts +26 -22
- package/dist/modal/stores/modal/useModalStore.js +9 -13
- package/dist/modal/types/commonTypes.d.ts +0 -52
- package/dist/modal/types/modalProps.d.ts +8 -32
- package/dist/modal/utils/authInputHelpers.d.ts +7 -0
- package/dist/modal/utils/authInputHelpers.js +38 -0
- package/dist/modal/utils/authLayoutHelpers.d.ts +2 -2
- package/dist/modal/{components/AuthInput → utils}/countryCodes.js +6 -3
- package/dist/modal/utils/getTileButtonFlex.d.ts +1 -1
- package/dist/modal/utils/isPasskeySupported.d.ts +1 -0
- package/dist/modal/utils/isPasskeySupported.js +15 -0
- package/dist/modal/utils/openPopup.d.ts +2 -2
- package/dist/modal/utils/openPopup.js +2 -2
- package/dist/modal/utils/steps.d.ts +6 -0
- package/dist/modal/utils/steps.js +15 -0
- package/dist/provider/ParaProvider.d.ts +3 -1
- package/dist/provider/ParaProvider.js +69 -8
- package/dist/provider/actions/getAccount.d.ts +26 -8
- package/dist/provider/actions/getAccount.js +42 -14
- package/dist/provider/actions/getWallet.d.ts +3 -3
- package/dist/provider/actions/index.d.ts +27 -0
- package/dist/provider/actions/index.js +59 -0
- package/dist/provider/actions/utils.d.ts +3 -0
- package/dist/provider/actions/utils.js +15 -0
- package/dist/provider/components/CosmosWalletWrapper.d.ts +11 -0
- package/dist/provider/components/CosmosWalletWrapper.js +34 -0
- package/dist/provider/components/EvmWalletWrapper.d.ts +12 -0
- package/dist/provider/components/EvmWalletWrapper.js +34 -0
- package/dist/provider/components/ExternalWalletWrapper.d.ts +8 -0
- package/dist/provider/components/ExternalWalletWrapper.js +139 -0
- package/dist/provider/components/SolanaWalletWrapper.d.ts +9 -0
- package/dist/provider/components/SolanaWalletWrapper.js +36 -0
- package/dist/provider/external/getParaCosmosConnector.d.ts +7 -0
- package/dist/provider/external/getParaCosmosConnector.js +22 -0
- package/dist/provider/external/getParaEvmConnector.d.ts +7 -0
- package/dist/provider/external/getParaEvmConnector.js +22 -0
- package/dist/provider/external/getParaSolanaConnector.d.ts +7 -0
- package/dist/provider/external/getParaSolanaConnector.js +22 -0
- package/dist/provider/external/stubs/CosmosExternalWalletContextStub.d.ts +12 -0
- package/dist/provider/external/stubs/CosmosExternalWalletContextStub.js +18 -0
- package/dist/provider/external/stubs/EvmExternalWalletContextStub.d.ts +3 -0
- package/dist/provider/external/stubs/EvmExternalWalletContextStub.js +21 -0
- package/dist/provider/external/stubs/SolanaExternalWalletContextStub.d.ts +8 -0
- package/dist/provider/external/stubs/SolanaExternalWalletContextStub.js +14 -0
- package/dist/provider/hooks/mutations/index.d.ts +27 -11
- package/dist/provider/hooks/mutations/index.js +54 -17
- package/dist/provider/hooks/mutations/utils.d.ts +5 -0
- package/dist/provider/hooks/mutations/utils.js +59 -0
- package/dist/provider/hooks/queries/useAccount.d.ts +1 -7
- package/dist/provider/hooks/queries/useWallet.d.ts +1 -1
- package/dist/provider/hooks/queries/useWalletBalance.d.ts +1 -2
- package/dist/provider/hooks/queries/useWalletBalance.js +40 -11
- package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +5 -5
- package/dist/provider/hooks/utils/useEventListeners.d.ts +1 -1
- package/dist/provider/hooks/utils/useEventListeners.js +100 -56
- package/dist/provider/hooks/utils/useWalletState.d.ts +5 -4
- package/dist/provider/hooks/utils/useWalletState.js +24 -9
- package/dist/provider/index.d.ts +1 -0
- package/dist/provider/index.js +1 -0
- package/dist/provider/providers/AuthProvider.d.ts +35 -0
- package/dist/provider/providers/AuthProvider.js +498 -0
- package/dist/provider/providers/CosmosExternalWalletProvider.d.ts +7 -0
- package/dist/provider/providers/CosmosExternalWalletProvider.js +66 -0
- package/dist/provider/providers/EvmExternalWalletProvider.d.ts +7 -0
- package/dist/provider/providers/EvmExternalWalletProvider.js +74 -0
- package/dist/provider/providers/ExternalWalletProvider.d.ts +76 -0
- package/dist/{modal/providers/ExternalWalletContext.js → provider/providers/ExternalWalletProvider.js} +146 -112
- package/dist/provider/providers/SolanaExternalWalletProvider.d.ts +7 -0
- package/dist/provider/providers/SolanaExternalWalletProvider.js +66 -0
- package/dist/provider/stores/getters.d.ts +3 -3
- package/dist/provider/stores/setters.d.ts +1 -0
- package/dist/provider/stores/setters.js +7 -0
- package/dist/provider/stores/slices/config.d.ts +3 -0
- package/dist/provider/stores/slices/config.js +9 -0
- package/dist/provider/stores/slices/externalWallets.d.ts +3 -0
- package/dist/provider/stores/slices/externalWallets.js +40 -0
- package/dist/provider/stores/slices/index.d.ts +1 -0
- package/dist/provider/stores/slices/index.js +1 -0
- package/dist/provider/stores/slices/modal.js +11 -4
- package/dist/provider/stores/types.d.ts +50 -4
- package/dist/provider/stores/useStore.js +4 -3
- package/dist/provider/types/externalWalletProviders.d.ts +12 -0
- package/dist/provider/types/externalWalletProviders.js +1 -0
- package/dist/provider/types/provider.d.ts +126 -17
- package/dist/provider/types/utils.d.ts +20 -0
- package/dist/provider/utils/constants.js +3 -4
- package/dist/provider/utils/paraConfigTypeGuards.d.ts +7 -0
- package/dist/provider/utils/paraConfigTypeGuards.js +13 -0
- package/dist/provider/utils/renameMutations.d.ts +3 -0
- package/dist/provider/utils/renameMutations.js +5 -3
- package/package.json +20 -8
- package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.d.ts +0 -8
- package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +0 -124
- package/dist/modal/hooks/useActiveWallet.d.ts +0 -1
- package/dist/modal/hooks/useActiveWallet.js +0 -15
- package/dist/modal/hooks/useCreateAccount.d.ts +0 -6
- package/dist/modal/hooks/useCreateAccount.js +0 -77
- package/dist/modal/hooks/useEmbeddedExternalConnection.d.ts +0 -1
- package/dist/modal/hooks/useEmbeddedExternalConnection.js +0 -54
- package/dist/modal/hooks/useSetLoginURLs.d.ts +0 -8
- package/dist/modal/hooks/useSetLoginURLs.js +0 -49
- package/dist/modal/hooks/useWalletBalance.d.ts +0 -4
- package/dist/modal/hooks/useWalletBalance.js +0 -49
- package/dist/modal/providers/CosmosExternalWalletContextStub.d.ts +0 -42
- package/dist/modal/providers/CosmosExternalWalletContextStub.js +0 -38
- package/dist/modal/providers/EvmExternalWalletContextStub.d.ts +0 -46
- package/dist/modal/providers/EvmExternalWalletContextStub.js +0 -55
- package/dist/modal/providers/ExternalWalletContext.d.ts +0 -92
- package/dist/modal/providers/SolanaExternalWalletContextStub.d.ts +0 -32
- package/dist/modal/providers/SolanaExternalWalletContextStub.js +0 -32
- package/dist/modal/stores/externalWalletProvider/actions.d.ts +0 -3
- package/dist/modal/stores/externalWalletProvider/actions.js +0 -10
- package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.d.ts +0 -22
- package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +0 -21
- package/dist/modal/stores/theme/actions.d.ts +0 -3
- package/dist/modal/stores/theme/actions.js +0 -28
- package/dist/modal/stores/theme/useThemeStore.d.ts +0 -20
- package/dist/modal/stores/theme/useThemeStore.js +0 -21
- package/dist/modal/stores/userInfo/actions.d.ts +0 -3
- package/dist/modal/stores/userInfo/actions.js +0 -30
- package/dist/modal/stores/userInfo/useUserInfoStore.d.ts +0 -19
- package/dist/modal/stores/userInfo/useUserInfoStore.js +0 -17
- package/dist/provider/actions/checkIfUserExists.d.ts +0 -9
- package/dist/provider/actions/checkIfUserExists.js +0 -21
- package/dist/provider/actions/createGuestWallets.d.ts +0 -2
- package/dist/provider/actions/createGuestWallets.js +0 -13
- package/dist/provider/actions/createUser.d.ts +0 -12
- package/dist/provider/actions/createUser.js +0 -26
- package/dist/provider/actions/getWalletBalance.d.ts +0 -2
- package/dist/provider/actions/getWalletBalance.js +0 -14
- package/dist/provider/actions/initiateLogin.d.ts +0 -4
- package/dist/provider/actions/initiateLogin.js +0 -20
- package/dist/provider/actions/keepSessionAlive.d.ts +0 -2
- package/dist/provider/actions/keepSessionAlive.js +0 -20
- package/dist/provider/actions/logout.d.ts +0 -2
- package/dist/provider/actions/logout.js +0 -17
- package/dist/provider/actions/signMessage.d.ts +0 -8
- package/dist/provider/actions/signMessage.js +0 -20
- package/dist/provider/actions/signTransaction.d.ts +0 -8
- package/dist/provider/actions/signTransaction.js +0 -20
- package/dist/provider/actions/waitForAccountCreation.d.ts +0 -2
- package/dist/provider/actions/waitForAccountCreation.js +0 -21
- package/dist/provider/actions/waitForLoginAndSetup.d.ts +0 -6
- package/dist/provider/actions/waitForLoginAndSetup.js +0 -24
- package/dist/provider/actions/waitForPasskeyAndCreateWallet.d.ts +0 -2
- package/dist/provider/actions/waitForPasskeyAndCreateWallet.js +0 -21
- package/dist/provider/hooks/mutations/useCheckIfUserExists.d.ts +0 -13
- package/dist/provider/hooks/mutations/useCheckIfUserExists.js +0 -23
- package/dist/provider/hooks/mutations/useCreateGuestWallets.d.ts +0 -15
- package/dist/provider/hooks/mutations/useCreateGuestWallets.js +0 -23
- package/dist/provider/hooks/mutations/useCreateUser.d.ts +0 -13
- package/dist/provider/hooks/mutations/useCreateUser.js +0 -20
- package/dist/provider/hooks/mutations/useInitiateLogin.d.ts +0 -14
- package/dist/provider/hooks/mutations/useInitiateLogin.js +0 -23
- package/dist/provider/hooks/mutations/useKeepSessionAlive.d.ts +0 -12
- package/dist/provider/hooks/mutations/useKeepSessionAlive.js +0 -20
- package/dist/provider/hooks/mutations/useLogout.d.ts +0 -12
- package/dist/provider/hooks/mutations/useLogout.js +0 -30
- package/dist/provider/hooks/mutations/useSignMessage.d.ts +0 -15
- package/dist/provider/hooks/mutations/useSignMessage.js +0 -39
- package/dist/provider/hooks/mutations/useSignTransaction.d.ts +0 -14
- package/dist/provider/hooks/mutations/useSignTransaction.js +0 -39
- package/dist/provider/hooks/mutations/useWaitForAccountCreation.d.ts +0 -12
- package/dist/provider/hooks/mutations/useWaitForAccountCreation.js +0 -30
- package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.d.ts +0 -14
- package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.js +0 -30
- package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.d.ts +0 -13
- package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.js +0 -30
- /package/dist/modal/{components/AuthInput → utils}/countryCodes.d.ts +0 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const ExternalWalletCard: ({ address, showAddFunds }: Pick<SharedWalletCardProps, "address" | "showAddFunds">) => import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
import { TWalletType } from '@getpara/web-sdk';
|
|
2
|
+
export declare const ExternalWalletCard: ({ address, showAddFunds }: Pick<SharedWalletCardProps, "address" | "showAddFunds">) => import("react/jsx-runtime").JSX.Element | null;
|
|
3
3
|
interface WalletCardProps {
|
|
4
4
|
id: string;
|
|
5
|
-
type:
|
|
5
|
+
type: TWalletType;
|
|
6
6
|
showAddFunds?: boolean;
|
|
7
7
|
}
|
|
8
|
-
export declare const WalletCard: ({ id, type, showAddFunds }: WalletCardProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare const WalletCard: ({ id, type, showAddFunds }: WalletCardProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
9
9
|
interface SharedWalletCardProps {
|
|
10
10
|
address: string;
|
|
11
11
|
id?: string;
|
|
12
|
-
type?:
|
|
12
|
+
type?: TWalletType;
|
|
13
13
|
name?: string;
|
|
14
14
|
identiconHash: string;
|
|
15
15
|
showAddFunds?: boolean;
|
|
@@ -2,32 +2,33 @@
|
|
|
2
2
|
import "../../../chunk-MMUBH76A.js";
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import styled from "styled-components";
|
|
5
|
-
import { useModalStore
|
|
5
|
+
import { useModalStore } from "../../stores/index.js";
|
|
6
6
|
import { CpslButton, CpslIdenticon, CpslText } from "@getpara/react-components";
|
|
7
7
|
import { truncateAddress } from "@getpara/web-sdk";
|
|
8
8
|
import { ModalStep } from "../../utils/steps.js";
|
|
9
9
|
import { useWalletState } from "../../../provider/index.js";
|
|
10
10
|
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
11
|
+
import { useStore } from "../../../provider/stores/useStore.js";
|
|
11
12
|
const ExternalWalletCard = ({ address, showAddFunds }) => {
|
|
12
|
-
var _a;
|
|
13
|
+
var _a, _b;
|
|
13
14
|
const para = useInternalClient();
|
|
14
15
|
const wallet = para.externalWallets[address];
|
|
15
|
-
if (!wallet) {
|
|
16
|
+
if (!(wallet == null ? void 0 : wallet.address) || !(wallet == null ? void 0 : wallet.type)) {
|
|
16
17
|
return null;
|
|
17
18
|
}
|
|
18
19
|
return /* @__PURE__ */ jsx(
|
|
19
20
|
SharedWalletCard,
|
|
20
21
|
{
|
|
21
22
|
address: (_a = wallet.ensName) != null ? _a : truncateAddress(wallet.address, wallet.type),
|
|
22
|
-
identiconHash: para.getIdenticonHash(wallet.id, wallet.type),
|
|
23
|
+
identiconHash: (_b = para.getIdenticonHash(wallet.id, wallet.type)) != null ? _b : "",
|
|
23
24
|
showAddFunds
|
|
24
25
|
}
|
|
25
26
|
);
|
|
26
27
|
};
|
|
27
28
|
const WalletCard = ({ id, type, showAddFunds }) => {
|
|
28
|
-
var _a, _b;
|
|
29
|
+
var _a, _b, _c;
|
|
29
30
|
const para = useInternalClient();
|
|
30
|
-
const appName =
|
|
31
|
+
const appName = useStore((state) => state.appName);
|
|
31
32
|
const wallet = para.findWallet(id, type);
|
|
32
33
|
if (!wallet) {
|
|
33
34
|
return null;
|
|
@@ -40,7 +41,7 @@ const WalletCard = ({ id, type, showAddFunds }) => {
|
|
|
40
41
|
type: wallet.type,
|
|
41
42
|
address: (_a = wallet.ensName) != null ? _a : truncateAddress(address, type, { prefix: para.cosmosPrefix }),
|
|
42
43
|
name: (_b = wallet.name) != null ? _b : `${appName ? `${appName} ` : ""}Wallet`,
|
|
43
|
-
identiconHash: para.getIdenticonHash(wallet.id, type),
|
|
44
|
+
identiconHash: (_c = para.getIdenticonHash(wallet.id, type)) != null ? _c : "",
|
|
44
45
|
showAddFunds
|
|
45
46
|
}
|
|
46
47
|
);
|
|
@@ -5,34 +5,55 @@ import {
|
|
|
5
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { CpslButton, CpslText } from "@getpara/react-components";
|
|
7
7
|
import { StepContainer, InnerStepContainer, HeroIcon } from "../common.js";
|
|
8
|
-
import { useModalStore
|
|
8
|
+
import { useModalStore } from "../../stores/index.js";
|
|
9
9
|
import { ModalStep } from "../../utils/steps.js";
|
|
10
10
|
import { WalletCard, WalletCards } from "../WalletCard/WalletCard.js";
|
|
11
11
|
import styled from "styled-components";
|
|
12
12
|
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
13
|
+
import { useStore } from "../../../provider/stores/useStore.js";
|
|
14
|
+
import { useAuthActions } from "../../../provider/providers/AuthProvider.js";
|
|
15
|
+
import { useEffect, useState } from "react";
|
|
13
16
|
const WalletCreationDoneStep = ({ twoFactorAuthEnabled, onClose }) => {
|
|
14
|
-
const
|
|
17
|
+
const { isSetup2faPending } = useAuthActions();
|
|
18
|
+
const hideWallets = useStore((state) => {
|
|
19
|
+
var _a;
|
|
20
|
+
return (_a = state.modalConfig) == null ? void 0 : _a.hideWallets;
|
|
21
|
+
});
|
|
15
22
|
const setStep = useModalStore((state) => state.setStep);
|
|
16
23
|
const isLogin = useModalStore((state) => state.isLogin());
|
|
24
|
+
const twoFactorStatus = useModalStore((state) => state.twoFactorStatus);
|
|
17
25
|
const onRampConfig = useModalStore((state) => state.onRampConfig);
|
|
18
26
|
const para = useInternalClient();
|
|
27
|
+
const [isWaiting, setIsWaiting] = useState(false);
|
|
19
28
|
const isOnRampConfigured = (onRampConfig == null ? void 0 : onRampConfig.isBuyEnabled) || (onRampConfig == null ? void 0 : onRampConfig.isReceiveEnabled) || (onRampConfig == null ? void 0 : onRampConfig.isWithdrawEnabled);
|
|
20
|
-
const
|
|
29
|
+
const onBypass2fa = () => {
|
|
21
30
|
if (isLogin) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
31
|
+
setStep(ModalStep.LOGIN_DONE);
|
|
32
|
+
} else {
|
|
33
|
+
onClose();
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const handleNext = () => __async(void 0, null, function* () {
|
|
37
|
+
if (!twoFactorAuthEnabled) {
|
|
38
|
+
onBypass2fa();
|
|
39
|
+
}
|
|
40
|
+
if (!twoFactorStatus) {
|
|
41
|
+
if (isSetup2faPending) {
|
|
42
|
+
setIsWaiting(true);
|
|
25
43
|
}
|
|
26
|
-
const { isSetup: is2faComplete } = yield para.check2FAStatus();
|
|
27
|
-
setStep(is2faComplete ? ModalStep.LOGIN_DONE : ModalStep.SETUP_2FA);
|
|
28
44
|
} else {
|
|
29
|
-
if (
|
|
30
|
-
|
|
45
|
+
if (twoFactorStatus.isSetup) {
|
|
46
|
+
onBypass2fa();
|
|
31
47
|
} else {
|
|
32
|
-
|
|
48
|
+
setStep(ModalStep.SETUP_2FA);
|
|
33
49
|
}
|
|
34
50
|
}
|
|
35
51
|
});
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (isWaiting && !!twoFactorStatus) {
|
|
54
|
+
setStep(ModalStep.SETUP_2FA);
|
|
55
|
+
}
|
|
56
|
+
}, [isWaiting, twoFactorStatus]);
|
|
36
57
|
return /* @__PURE__ */ jsxs(StepContainer, { $wide: true, children: [
|
|
37
58
|
/* @__PURE__ */ jsx(CardContainer, { children: hideWallets ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
38
59
|
/* @__PURE__ */ jsx(HeroIcon, { icon: "checkCircleFilled" }),
|
|
@@ -40,7 +61,7 @@ const WalletCreationDoneStep = ({ twoFactorAuthEnabled, onClose }) => {
|
|
|
40
61
|
] }) : /* @__PURE__ */ jsx(WalletCards, { children: para.currentWalletIdsArray.map(([id, type]) => {
|
|
41
62
|
return /* @__PURE__ */ jsx(WalletCard, { id, type, showAddFunds: isOnRampConfigured }, id);
|
|
42
63
|
}) }) }),
|
|
43
|
-
/* @__PURE__ */ jsx(InnerStepContainer, { children: /* @__PURE__ */ jsx(CpslButton, { fullWidth: true, onClick: handleNext, children: twoFactorAuthEnabled ? "Continue" : "Done" }) })
|
|
64
|
+
/* @__PURE__ */ jsx(InnerStepContainer, { children: /* @__PURE__ */ jsx(CpslButton, { fullWidth: true, onClick: handleNext, disabled: isWaiting, children: twoFactorAuthEnabled ? "Continue" : "Done" }) })
|
|
44
65
|
] });
|
|
45
66
|
};
|
|
46
67
|
const CardContainer = styled(InnerStepContainer)`
|
|
@@ -9,23 +9,23 @@ export declare const FullWidthFilledDisabledInput: typeof CpslInput;
|
|
|
9
9
|
export declare const CenteredText: typeof CpslText;
|
|
10
10
|
export declare const InnerStepContainer: import("styled-components/dist/types.js").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
11
11
|
export declare const StepContainer: import("styled-components/dist/types.js").IStyledComponentBase<"web", import("styled-components/dist/types.js").Substitute<Omit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>, "ref"> & {
|
|
12
|
-
ref?: import("react").
|
|
12
|
+
ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
13
13
|
}, {
|
|
14
14
|
$wide?: boolean;
|
|
15
15
|
}>> & string;
|
|
16
16
|
export declare const Heading: typeof CpslText;
|
|
17
17
|
export declare const StyledCpslTileButton: typeof CpslTileButton;
|
|
18
18
|
export declare const HeroIcon: import("styled-components/dist/types.js").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<Omit<any, "ref"> & import("react").RefAttributes<any>, "ref"> & {
|
|
19
|
-
ref?: import("react").
|
|
19
|
+
ref?: ((instance: any) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<any> | null | undefined;
|
|
20
20
|
}, never>> & string & Omit<import("react").ForwardRefExoticComponent<Omit<any, "ref"> & import("react").RefAttributes<any>>, keyof import("react").Component<any, {}, any>>;
|
|
21
21
|
export declare const HeaderSelect: import("styled-components/dist/types.js").IStyledComponentBase<"web", import("styled-components/dist/types.js").Substitute<Omit<Omit<any, "ref"> & import("react").RefAttributes<any>, "ref"> & {
|
|
22
|
-
ref?: import("react").
|
|
22
|
+
ref?: ((instance: any) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<any> | null | undefined;
|
|
23
23
|
}, {
|
|
24
24
|
$width: number;
|
|
25
25
|
$top?: number;
|
|
26
26
|
}>> & string & Omit<import("react").ForwardRefExoticComponent<Omit<any, "ref"> & import("react").RefAttributes<any>>, keyof import("react").Component<any, {}, any>>;
|
|
27
27
|
export declare const HeaderSelectItem: import("styled-components/dist/types.js").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<Omit<any, "ref"> & import("react").RefAttributes<any>, "ref"> & {
|
|
28
|
-
ref?: import("react").
|
|
28
|
+
ref?: ((instance: any) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<any> | null | undefined;
|
|
29
29
|
}, never>> & string & Omit<import("react").ForwardRefExoticComponent<Omit<any, "ref"> & import("react").RefAttributes<any>>, keyof import("react").Component<any, {}, any>>;
|
|
30
30
|
export declare const HeaderSelectContainer: import("styled-components/dist/types.js").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
31
31
|
export declare function AssetIcon({ asset, size }: {
|
|
@@ -38,5 +38,5 @@ export declare function NetworkIcon({ network, size }: {
|
|
|
38
38
|
}): import("react/jsx-runtime").JSX.Element;
|
|
39
39
|
export declare const ErrorContainer: import("styled-components/dist/types.js").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
40
40
|
export declare const ErrorIcon: import("styled-components/dist/types.js").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<Omit<any, "ref"> & import("react").RefAttributes<any>, "ref"> & {
|
|
41
|
-
ref?: import("react").
|
|
41
|
+
ref?: ((instance: any) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<any> | null | undefined;
|
|
42
42
|
}, never>> & string & Omit<import("react").ForwardRefExoticComponent<Omit<any, "ref"> & import("react").RefAttributes<any>>, keyof import("react").Component<any, {}, any>>;
|
|
@@ -4,7 +4,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
4
4
|
import { CpslIcon, CpslInput, CpslSelect, CpslSelectItem, CpslText, CpslTileButton } from "@getpara/react-components";
|
|
5
5
|
import { styled } from "styled-components";
|
|
6
6
|
import { MOBILE_SIZE, NETWORKS, ON_RAMP_ASSETS } from "../constants/constants.js";
|
|
7
|
-
import {
|
|
7
|
+
import { useStore } from "../../provider/stores/useStore.js";
|
|
8
8
|
const SpinnerContainer = styled.div`
|
|
9
9
|
display: flex;
|
|
10
10
|
align-items: center;
|
|
@@ -71,7 +71,7 @@ const HeroIcon = styled(CpslIcon)`
|
|
|
71
71
|
--icon-color: var(--cpsl-color-text-primary);
|
|
72
72
|
`;
|
|
73
73
|
const HeaderSelect = styled(CpslSelect)`
|
|
74
|
-
--container-height:
|
|
74
|
+
--container-height: 26px;
|
|
75
75
|
--container-border-width: 0px;
|
|
76
76
|
--container-padding-end: 0px;
|
|
77
77
|
--container-padding-start: 0px;
|
|
@@ -126,12 +126,18 @@ const StyledIcon = styled(CpslIcon)`
|
|
|
126
126
|
border-radius: 100%;
|
|
127
127
|
`;
|
|
128
128
|
function AssetIcon({ asset, size }) {
|
|
129
|
-
const isDark =
|
|
129
|
+
const isDark = useStore((state) => {
|
|
130
|
+
var _a, _b;
|
|
131
|
+
return ((_b = (_a = state.modalConfig) == null ? void 0 : _a.theme) == null ? void 0 : _b.mode) === "dark";
|
|
132
|
+
});
|
|
130
133
|
const data = ON_RAMP_ASSETS[asset];
|
|
131
134
|
return /* @__PURE__ */ jsx(StyledIcon, { size, icon: data.icon, inset: data.isCircular ? void 0 : "15%", invert: isDark && data.isDark });
|
|
132
135
|
}
|
|
133
136
|
function NetworkIcon({ network, size }) {
|
|
134
|
-
const isDark =
|
|
137
|
+
const isDark = useStore((state) => {
|
|
138
|
+
var _a, _b;
|
|
139
|
+
return ((_b = (_a = state.modalConfig) == null ? void 0 : _a.theme) == null ? void 0 : _b.mode) === "dark";
|
|
140
|
+
});
|
|
135
141
|
const data = NETWORKS[network];
|
|
136
142
|
return /* @__PURE__ */ jsx(StyledIcon, { size, icon: data.icon, inset: data.isCircular ? void 0 : "15%", invert: isDark && data.isDark });
|
|
137
143
|
}
|
|
@@ -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): "alertCircle" | "alertTriangle" | "alignVerticalCenter" | "angelListBrand" | "angelList" | "appleBrand" | "apple" | "arbitrumBrand" | "arrowCircleBrokenDownLeft" | "arrowCircleDownFilled" | "arrowNarrow" | "arrow" | "asterisk" | "backupKit" | "bank" | "baseBrand" | "brush" | "celoBrand" | "checkCircleFilled" | "checkCircle" | "checkSquare" | "check" | "chevronDown" | "chevronRight" | "chevronSelectorVertical" | "chevronUp" | "clock" | "
|
|
33
|
+
export declare function getAssetIcon(str: OnRampAsset | string): "key" | "phone" | "farcaster" | "telegram" | "discord" | "x" | "search" | "para" | "wallet" | "close" | "copy" | "cosmos" | "code" | "menu" | "alertCircle" | "alertTriangle" | "alignVerticalCenter" | "angelListBrand" | "angelList" | "appleBrand" | "apple" | "arbitrumBrand" | "arrowCircleBrokenDownLeft" | "arrowCircleDownFilled" | "arrowNarrow" | "arrow" | "asterisk" | "backupKit" | "bank" | "baseBrand" | "brush" | "celoBrand" | "checkCircleFilled" | "checkCircle" | "checkSquare" | "check" | "chevronDown" | "chevronRight" | "chevronSelectorVertical" | "chevronUp" | "clock" | "clubhouseBrand" | "clubhouse" | "copy07" | "creditCard02" | "creditCard" | "cube03" | "cubeOutline" | "cube" | "currencyDollar" | "decentBrand" | "decent" | "dell" | "discordBrand" | "dot" | "dots" | "downloadCloud" | "download" | "dribbbleBrand" | "dribbble" | "earth" | "edit02" | "emptyCircle" | "ethereum" | "eyeOff" | "eye" | "facebookBrand" | "facebook" | "farcasterBrand" | "figmaBrand" | "figma" | "file" | "folder" | "githubBrand" | "github" | "globe" | "googleBrand" | "google" | "gridDots" | "helpCircle" | "heroAlertCircle" | "heroCheckmarkCapsule" | "heroCheckmark" | "heroEmail" | "heroExternalConnection" | "heroLock" | "heroPasskey" | "heroPhone" | "heroPlusCircleCapsule" | "heroPlusCircle" | "heroWallet" | "home" | "hp" | "image" | "infoCircle" | "instagramBrand" | "instagram" | "laptop" | "lenovo" | "lg" | "lightning01" | "lightning" | "linkExternal" | "linkedinBrand" | "linkedin" | "lockKeyholeCircle" | "logOut" | "mail" | "monitor" | "moonpayBrand" | "moreLoginOptions" | "motorola" | "nobleBrand" | "optimismBrand" | "paraBlackBg" | "paraBrand" | "paraIconBrand" | "paraIconQr" | "paraIcon" | "paraLogo" | "paraRingsDark" | "paraRings" | "passcode" | "pintrestBrand" | "pintrest" | "plusCircle" | "plus" | "polygonBrand" | "polygon" | "puzzlePiece" | "qrCode02" | "qrCode" | "rampNetworkBrand" | "rampNetwork" | "redditBrand" | "reddit" | "refresh" | "samsung" | "send" | "settings" | "share" | "shield" | "signalBrand" | "signal" | "sliders" | "snapchatBrand" | "snapchat" | "solana" | "spacingHeight" | "star04Filled" | "stars01Filled" | "stars02" | "stars" | "stopSquare" | "stripeBrand" | "telegramBrand" | "tetherBrand" | "tikTokBrand" | "tikTok" | "trash" | "tumblrBrand" | "tumblr" | "twitterBrand" | "twitter" | "usdcBrand" | "userCircle" | "user" | "youtubeBrand" | "youtube" | "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,8 +1,8 @@
|
|
|
1
1
|
import { IconType } from '@getpara/react-components';
|
|
2
|
-
import {
|
|
2
|
+
import { TOAuthMethod } from '@getpara/web-sdk';
|
|
3
3
|
export declare const brandedOAuthLogos: {
|
|
4
|
-
[key in
|
|
4
|
+
[key in TOAuthMethod]: IconType;
|
|
5
5
|
};
|
|
6
6
|
export declare const oAuthLogos: {
|
|
7
|
-
[key in
|
|
7
|
+
[key in TOAuthMethod]: IconType;
|
|
8
8
|
};
|
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../../chunk-MMUBH76A.js";
|
|
3
3
|
import { useInternalClient } from "../../provider/hooks/utils/useInternalClient.js";
|
|
4
|
-
import { useExternalWallets } from "
|
|
4
|
+
import { useExternalWallets } from "../../provider/providers/ExternalWalletProvider.js";
|
|
5
5
|
import { useModalStore } from "../stores/index.js";
|
|
6
6
|
import { getAddFundsStep, ModalStep } from "../utils/steps.js";
|
|
7
7
|
const useGoBack = () => {
|
|
8
8
|
const currentStep = useModalStore((state) => state.step);
|
|
9
|
+
const refs = useModalStore((state) => state.refs);
|
|
9
10
|
const setStep = useModalStore((state) => state.setStep);
|
|
10
11
|
const accountAddFundTab = useModalStore((state) => state.accountAddFundTab);
|
|
11
12
|
const decrementStep = useModalStore((state) => state.decrementStep);
|
|
12
13
|
const resetState = useModalStore((state) => state.resetState);
|
|
13
14
|
const { setChainIdSwitchingTo, disconnectExternalWallet } = useExternalWallets();
|
|
14
|
-
const
|
|
15
|
+
const para = useInternalClient();
|
|
15
16
|
const goBack = () => {
|
|
16
|
-
if (currentStep === ModalStep.ADD_FUNDS_AWAITING) {
|
|
17
|
+
if (accountAddFundTab && currentStep === ModalStep.ADD_FUNDS_AWAITING) {
|
|
17
18
|
setStep(getAddFundsStep(accountAddFundTab));
|
|
18
19
|
} else {
|
|
19
20
|
decrementStep();
|
|
20
21
|
}
|
|
21
|
-
switch (currentStep) {
|
|
22
|
+
switch (refs.currentStep.current) {
|
|
22
23
|
case ModalStep.AUTH_MAIN:
|
|
23
24
|
case ModalStep.AUTH_MORE:
|
|
24
25
|
case ModalStep.EX_WALLET_SELECTED:
|
|
25
26
|
case ModalStep.EXTERNAL_WALLET_VERIFICATION: {
|
|
26
27
|
resetState();
|
|
27
|
-
if (
|
|
28
|
+
if (para.isExternalWalletAuth) {
|
|
28
29
|
disconnectExternalWallet();
|
|
29
30
|
}
|
|
30
31
|
break;
|
package/dist/modal/index.d.ts
CHANGED
|
@@ -6,6 +6,3 @@ export * from './utils/openPopup.js';
|
|
|
6
6
|
export { ON_RAMP_PROVIDERS, ON_RAMP_ASSETS, NETWORKS, getAssetIcon, getAssetCode, getNetworkIcon, getNetworkName, } from './constants/constants.js';
|
|
7
7
|
export { SaveRecoverySecret } from './components/RecoverySecretStep/RecoverySecretStep.js';
|
|
8
8
|
export * from './utils/validateOnRampConfig.js';
|
|
9
|
-
export * from './types/externalWallets.js';
|
|
10
|
-
export { useExternalWalletProviderStore } from './stores/externalWalletProvider/useExternalWalletProviderStore.js';
|
|
11
|
-
export * from './types/commonTypes.js';
|
package/dist/modal/index.js
CHANGED
|
@@ -15,9 +15,6 @@ import {
|
|
|
15
15
|
} from "./constants/constants.js";
|
|
16
16
|
import { SaveRecoverySecret } from "./components/RecoverySecretStep/RecoverySecretStep.js";
|
|
17
17
|
export * from "./utils/validateOnRampConfig.js";
|
|
18
|
-
export * from "./types/externalWallets.js";
|
|
19
|
-
import { useExternalWalletProviderStore } from "./stores/externalWalletProvider/useExternalWalletProviderStore.js";
|
|
20
|
-
export * from "./types/commonTypes.js";
|
|
21
18
|
export {
|
|
22
19
|
AuthLayout,
|
|
23
20
|
ModalStep,
|
|
@@ -28,6 +25,5 @@ export {
|
|
|
28
25
|
getAssetCode,
|
|
29
26
|
getAssetIcon,
|
|
30
27
|
getNetworkIcon,
|
|
31
|
-
getNetworkName
|
|
32
|
-
useExternalWalletProviderStore
|
|
28
|
+
getNetworkName
|
|
33
29
|
};
|
|
@@ -3,10 +3,20 @@ import {
|
|
|
3
3
|
__spreadValues
|
|
4
4
|
} from "../../../chunk-MMUBH76A.js";
|
|
5
5
|
import { DEFAULT_MODAL_STATE } from "./useModalStore.js";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
AccountPreviousStep,
|
|
8
|
+
GuestPreviousStep,
|
|
9
|
+
LoginPreviousStep,
|
|
10
|
+
ModalStep,
|
|
11
|
+
SignUpPreviousStep
|
|
12
|
+
} from "../../utils/steps.js";
|
|
13
|
+
function getPreviousStep(flow, step) {
|
|
14
|
+
return flow === "account" ? AccountPreviousStep[step] : flow === "login" ? LoginPreviousStep[step] : flow === "guest" ? GuestPreviousStep[step] : SignUpPreviousStep[step];
|
|
15
|
+
}
|
|
7
16
|
const getActions = (set, get) => ({
|
|
8
17
|
resetState: () => set(DEFAULT_MODAL_STATE),
|
|
9
18
|
setOnModalStepChange: (onModalStepChange) => set({ onModalStepChange }),
|
|
19
|
+
setRecoveryShare: (recoveryShare) => set({ recoveryShare }),
|
|
10
20
|
setStep: (step) => {
|
|
11
21
|
const onModalStepChange = get().onModalStepChange;
|
|
12
22
|
const previousStep = get().step;
|
|
@@ -17,61 +27,104 @@ const getActions = (set, get) => ({
|
|
|
17
27
|
var _a;
|
|
18
28
|
const currentStep = get().step;
|
|
19
29
|
const onRampStep = get().onRampStep;
|
|
30
|
+
const flow = get().flow;
|
|
20
31
|
if ([ModalStep.ADD_FUNDS_BUY, ModalStep.ADD_FUNDS_WITHDRAW].includes(currentStep) && onRampStep > 0) {
|
|
21
32
|
set({ onRampStep: onRampStep - 1 });
|
|
22
33
|
return;
|
|
23
34
|
}
|
|
35
|
+
if (!flow) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
24
38
|
const onModalStepChange = get().onModalStepChange;
|
|
25
|
-
const
|
|
26
|
-
const isAccount = get().flow === "account";
|
|
27
|
-
const webAuthURLForCreate = get().webAuthURLForCreate;
|
|
39
|
+
const signupState = get().getSignupState();
|
|
28
40
|
const iFrameUrl = get().iFrameUrl;
|
|
29
41
|
const refs = get().refs;
|
|
30
|
-
let prevStep = (
|
|
31
|
-
if (currentStep === ModalStep.PASSWORD_CREATION && iFrameUrl && !
|
|
42
|
+
let prevStep = getPreviousStep(flow, currentStep);
|
|
43
|
+
if (currentStep === ModalStep.PASSWORD_CREATION && iFrameUrl && !(signupState == null ? void 0 : signupState.passkeyUrl)) {
|
|
32
44
|
prevStep = ModalStep.AUTH_MAIN;
|
|
33
45
|
}
|
|
34
46
|
if (currentStep === ModalStep.EX_WALLET_SELECTED) {
|
|
35
47
|
set({ selectedExternalWalletId: void 0, isExternalWalletConnecting: false, externalWalletError: void 0 });
|
|
36
48
|
}
|
|
37
49
|
if (prevStep) {
|
|
38
|
-
set({
|
|
50
|
+
set(__spreadValues({
|
|
51
|
+
authStepRoute: void 0,
|
|
52
|
+
step: prevStep,
|
|
53
|
+
stepDirection: -1
|
|
54
|
+
}, prevStep === ModalStep.AUTH_MAIN && { flow: void 0 }));
|
|
39
55
|
onModalStepChange == null ? void 0 : onModalStepChange({ previousStep: currentStep, currentStep: prevStep, canGoBack: get().hasPreviousStep() });
|
|
40
56
|
}
|
|
41
57
|
(_a = refs.popupWindow.current) == null ? void 0 : _a.close();
|
|
42
|
-
refs.popupWindow.current =
|
|
58
|
+
refs.popupWindow.current = null;
|
|
43
59
|
},
|
|
44
60
|
hasPreviousStep: () => {
|
|
45
|
-
const
|
|
46
|
-
const isAccount = get().flow === "account";
|
|
61
|
+
const flow = get().flow;
|
|
47
62
|
const currentStep = get().step;
|
|
48
63
|
const onRampStep = get().onRampStep;
|
|
49
64
|
if ([ModalStep.ADD_FUNDS_BUY, ModalStep.ADD_FUNDS_WITHDRAW].includes(currentStep) && onRampStep > 0) {
|
|
50
65
|
return true;
|
|
51
66
|
}
|
|
52
|
-
return !!
|
|
67
|
+
return !!flow && !!getPreviousStep(flow, currentStep);
|
|
53
68
|
},
|
|
54
69
|
setFlow: (flow) => set({ flow }),
|
|
55
70
|
isLogin: () => get().flow === "login",
|
|
56
71
|
isAccount: () => get().flow === "account",
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
72
|
+
setAuthState: (authState) => {
|
|
73
|
+
let flow = get().flow, newFlow;
|
|
74
|
+
switch (authState == null ? void 0 : authState.stage) {
|
|
75
|
+
case "login":
|
|
76
|
+
newFlow = "login";
|
|
77
|
+
break;
|
|
78
|
+
case "signup":
|
|
79
|
+
case "verify":
|
|
80
|
+
newFlow = flow === "guest" ? "guest" : "signup";
|
|
81
|
+
break;
|
|
82
|
+
default:
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
set(__spreadValues({ authState }, newFlow ? { flow: newFlow } : {}));
|
|
86
|
+
},
|
|
87
|
+
getVerifyState: () => {
|
|
88
|
+
const authState = get().authState;
|
|
89
|
+
return (authState == null ? void 0 : authState.stage) === "verify" ? authState : void 0;
|
|
90
|
+
},
|
|
91
|
+
getLoginState: () => {
|
|
92
|
+
const authState = get().authState;
|
|
93
|
+
return (authState == null ? void 0 : authState.stage) === "login" ? authState : void 0;
|
|
94
|
+
},
|
|
95
|
+
getSignupState: () => {
|
|
96
|
+
const authState = get().authState;
|
|
97
|
+
return (authState == null ? void 0 : authState.stage) === "signup" ? authState : void 0;
|
|
98
|
+
},
|
|
61
99
|
setOnRampPurchase: (onRampPurchase) => set((state) => ({ onRampPurchase: __spreadValues(__spreadValues({}, state.onRampPurchase || {}), onRampPurchase) })),
|
|
62
100
|
setOnRampConfig: (onRampConfig) => set({ onRampConfig }),
|
|
63
101
|
setOnRampStep: (onRampStep) => set({ onRampStep }),
|
|
64
102
|
setIsFullyLoggedIn: (isFullyLoggedIn) => set({ isFullyLoggedIn }),
|
|
65
103
|
setAccountAddFundTab: (accountAddFundTab) => set({ accountAddFundTab }),
|
|
104
|
+
setGuestAddFundsTab: (guestAddFundsTab) => set({ guestAddFundsTab }),
|
|
66
105
|
setSelectedExternalWalletId: (selectedExternalWalletId) => set({ selectedExternalWalletId }),
|
|
67
106
|
setIsExternalWalletConnecting: (isExternalWalletConnecting) => set({ isExternalWalletConnecting }),
|
|
68
107
|
setExternalWalletError: (externalWalletError) => set({ externalWalletError }),
|
|
69
108
|
setIsUsingMobileConnector: (isUsingMobileConnector) => set({ isUsingMobileConnector }),
|
|
70
109
|
setStepDirection: (stepDirection) => set({ stepDirection }),
|
|
71
110
|
setFarcasterConnectUri: (farcasterConnectUri) => set({ farcasterConnectUri }),
|
|
72
|
-
|
|
111
|
+
setTwoFactorStatus: (twoFactorStatus) => set({ twoFactorStatus }),
|
|
73
112
|
setIFrameUrl: (iFrameUrl) => set({ iFrameUrl }),
|
|
74
113
|
setIsIFrameReady: (isIFrameReady) => set({ isIFrameReady }),
|
|
114
|
+
setAuthLayout: (authLayout) => {
|
|
115
|
+
const types = [];
|
|
116
|
+
const uniqueLayouts = [];
|
|
117
|
+
authLayout.map((layout) => {
|
|
118
|
+
const type = layout.split(":")[0];
|
|
119
|
+
if (!types.includes(type)) {
|
|
120
|
+
uniqueLayouts.push(layout);
|
|
121
|
+
types.push(type);
|
|
122
|
+
} else {
|
|
123
|
+
console.warn(`${layout} is a duplicate ${type} layout type. Please remove the duplicate type from your config.`);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
set({ authLayout: uniqueLayouts });
|
|
127
|
+
},
|
|
75
128
|
setAuthStepRoute: (authStepRoute) => set({ authStepRoute }),
|
|
76
129
|
setIsPasskeySupported: (isPasskeySupported) => set({ isPasskeySupported })
|
|
77
130
|
});
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { ModalStep } from '../../utils/steps.js';
|
|
2
|
-
import { OnRampConfig as OnRampConfigBase, OnRampPurchase,
|
|
2
|
+
import { OnRampConfig as OnRampConfigBase, OnRampPurchase, TWalletType } from '@getpara/web-sdk';
|
|
3
3
|
import { Tab as AddFundsTabType } from '../../components/AddFunds/AddFundsContext.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { AuthStateLogin, AuthStateSignup, AuthState, AuthStateVerify } from '@getpara/core-sdk';
|
|
5
|
+
import { TAuthLayout } from '../../types/modalProps.js';
|
|
6
6
|
import { MutableRefObject } from 'react';
|
|
7
|
-
|
|
8
|
-
type
|
|
7
|
+
import { Setup2faResponse } from '@getpara/user-management-client';
|
|
8
|
+
export type Flow = AuthStateSignup['stage'] | AuthStateLogin['stage'] | 'account' | 'guest';
|
|
9
|
+
type ActiveWallet = [string | undefined, TWalletType | undefined];
|
|
9
10
|
export declare enum OnRampStep {
|
|
10
11
|
SETTINGS = 0,
|
|
11
12
|
PROVIDER = 1
|
|
@@ -19,66 +20,69 @@ export interface OnModalStepChangeValue {
|
|
|
19
20
|
canGoBack: boolean;
|
|
20
21
|
}
|
|
21
22
|
interface ModalState {
|
|
23
|
+
recoveryShare: string | null;
|
|
22
24
|
step: ModalStep;
|
|
23
25
|
stepDirection: 1 | -1;
|
|
24
26
|
flow: Flow | undefined;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
passwordUrlForLogin: string | undefined;
|
|
28
|
-
supportedAuthMethods: Set<AuthMethod>;
|
|
29
|
-
onModalStepChange: (value: OnModalStepChangeValue) => void | undefined;
|
|
27
|
+
authState: AuthState | undefined;
|
|
28
|
+
onModalStepChange?: (value: OnModalStepChangeValue) => void | undefined;
|
|
30
29
|
onRampConfig: OnRampConfig | undefined;
|
|
31
30
|
onRampPurchase: Partial<OnRampPurchase> | undefined;
|
|
32
31
|
onRampStep: OnRampStep;
|
|
33
32
|
isFullyLoggedIn: boolean;
|
|
34
33
|
accountAddFundTab?: AddFundsTabType;
|
|
34
|
+
guestAddFundsTab?: AddFundsTabType;
|
|
35
35
|
selectedExternalWalletId?: string;
|
|
36
36
|
isUsingMobileConnector?: boolean;
|
|
37
37
|
isExternalWalletConnecting?: boolean;
|
|
38
38
|
externalWalletError?: string[];
|
|
39
39
|
activeWallet: ActiveWallet | undefined;
|
|
40
40
|
farcasterConnectUri: string | undefined;
|
|
41
|
-
|
|
41
|
+
twoFactorStatus: Setup2faResponse | undefined;
|
|
42
42
|
iFrameUrl: string | undefined;
|
|
43
43
|
isIFrameReady: boolean | undefined;
|
|
44
|
+
authLayout?: TAuthLayout[];
|
|
44
45
|
authStepRoute: ModalStep | undefined;
|
|
45
46
|
refs: {
|
|
46
|
-
popupWindow: MutableRefObject<Window>;
|
|
47
|
+
popupWindow: MutableRefObject<Window | null>;
|
|
47
48
|
poll: MutableRefObject<{
|
|
48
|
-
action: 'login' | '
|
|
49
|
+
action: 'login' | 'signup';
|
|
49
50
|
timeout: number;
|
|
50
|
-
}>;
|
|
51
|
-
currentStep: MutableRefObject<ModalStep>;
|
|
51
|
+
} | null>;
|
|
52
|
+
currentStep: MutableRefObject<ModalStep | null>;
|
|
52
53
|
};
|
|
53
54
|
isPasskeySupported: boolean;
|
|
54
55
|
}
|
|
55
56
|
export interface ModalActions {
|
|
56
57
|
resetState: () => void;
|
|
58
|
+
setRecoveryShare: (recoveryShare: string | null) => void;
|
|
57
59
|
setStep: (step: ModalStep) => void;
|
|
60
|
+
setGuestAddFundsTab: (tab?: AddFundsTabType | undefined) => void;
|
|
58
61
|
decrementStep: () => void;
|
|
59
62
|
hasPreviousStep: () => boolean;
|
|
60
63
|
setFlow: (flow?: Flow) => void;
|
|
64
|
+
setAuthState: (authState?: AuthState | undefined) => void;
|
|
65
|
+
getVerifyState: () => AuthStateVerify | undefined;
|
|
66
|
+
getSignupState: () => AuthStateSignup | undefined;
|
|
67
|
+
getLoginState: () => AuthStateLogin | undefined;
|
|
61
68
|
isLogin: () => boolean;
|
|
62
69
|
isAccount: () => boolean;
|
|
63
|
-
|
|
64
|
-
setWebAuthURLForLogin: (url?: string) => void;
|
|
65
|
-
setWebAuthURLForCreate: (url?: string) => void;
|
|
66
|
-
setPasswordUrlForLogin: (url?: string) => void;
|
|
67
|
-
setOnModalStepChange: (fn: (value: OnModalStepChangeValue) => void) => void;
|
|
70
|
+
setOnModalStepChange: (fn?: (value: OnModalStepChangeValue) => void) => void;
|
|
68
71
|
setOnRampConfig: (_: OnRampConfig | undefined) => void;
|
|
69
72
|
setOnRampPurchase: (_: Partial<OnRampPurchase> | undefined) => void;
|
|
70
73
|
setOnRampStep: (_: OnRampStep) => void;
|
|
71
74
|
setIsFullyLoggedIn: (isFullyLoggedIn: boolean) => void;
|
|
72
|
-
setAccountAddFundTab: (accountAddFundTab
|
|
75
|
+
setAccountAddFundTab: (accountAddFundTab?: AddFundsTabType) => void;
|
|
73
76
|
setSelectedExternalWalletId: (id?: string) => void;
|
|
74
77
|
setIsUsingMobileConnector: (isUsingMobileConnector?: boolean) => void;
|
|
75
78
|
setIsExternalWalletConnecting: (isExternalWalletConnecting: boolean) => void;
|
|
76
79
|
setExternalWalletError: (externalWalletError?: string[]) => void;
|
|
77
80
|
setStepDirection: (stepDirection: 1 | -1) => void;
|
|
78
81
|
setFarcasterConnectUri: (_: string | undefined) => void;
|
|
79
|
-
|
|
82
|
+
setTwoFactorStatus: (twoFactorStatus?: Setup2faResponse) => void;
|
|
80
83
|
setIFrameUrl: (_?: string) => void;
|
|
81
84
|
setIsIFrameReady: (_?: boolean) => void;
|
|
85
|
+
setAuthLayout: (authLayout: TAuthLayout[]) => void;
|
|
82
86
|
setAuthStepRoute: (_?: ModalStep) => void;
|
|
83
87
|
setIsPasskeySupported: (_: boolean) => void;
|
|
84
88
|
}
|