@getpara/react-sdk 1.8.0 → 2.0.0-alpha.3
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/components/AddFunds/MoonPayEmbed.js → MoonPayEmbed-Q2HP2BFI.js} +3 -1
- package/dist/MoonPayEmbed-Q2HP2BFI.js.br +0 -0
- package/dist/MoonPayEmbed-Q2HP2BFI.js.gz +0 -0
- package/dist/chunk-MMUBH76A.js.br +0 -0
- package/dist/chunk-MMUBH76A.js.gz +0 -0
- package/dist/cli/cli.mjs +40 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6499 -6
- package/dist/index.js.br +0 -0
- package/dist/index.js.gz +0 -0
- package/dist/modal/components/AuthInput/AuthInput.d.ts +1 -1
- package/dist/modal/components/AuthInput/hooks/useDropdownPosition.d.ts +4 -4
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.d.ts +1 -1
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.d.ts +1 -1
- package/dist/modal/components/ChainSwitch/ChainSwitch.d.ts +1 -1
- package/dist/modal/components/Controls/Selects.d.ts +1 -1
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +1 -1
- package/dist/modal/components/Footer/Footer.d.ts +1 -1
- package/dist/modal/components/WalletCard/WalletCard.d.ts +2 -2
- package/dist/modal/components/common.d.ts +7 -7
- package/dist/modal/constants/constants.d.ts +1 -1
- package/dist/modal/index.d.ts +0 -2
- package/dist/modal/stores/index.d.ts +0 -2
- package/dist/modal/stores/modal/useModalStore.d.ts +22 -20
- package/dist/modal/types/commonTypes.d.ts +4 -9
- package/dist/modal/types/externalWallets.d.ts +0 -2
- package/dist/modal/types/modalProps.d.ts +1 -33
- package/dist/modal/utils/authLayoutHelpers.d.ts +2 -2
- package/dist/modal/utils/getTileButtonFlex.d.ts +1 -1
- package/dist/modal/utils/isPasskeySupported.d.ts +1 -0
- package/dist/modal/utils/openPopup.d.ts +2 -2
- package/dist/modal/utils/stringFormatters.d.ts +0 -1
- package/dist/provider/ParaProvider.d.ts +3 -1
- package/dist/provider/actions/getAccount.d.ts +19 -7
- package/dist/provider/actions/getWallet.d.ts +1 -1
- package/dist/provider/actions/index.d.ts +25 -0
- package/dist/provider/actions/utils.d.ts +3 -0
- package/dist/provider/components/CosmosWalletWrapper.d.ts +11 -0
- package/dist/provider/components/EvmWalletWrapper.d.ts +12 -0
- package/dist/provider/components/ExternalWalletWrapper.d.ts +8 -0
- package/dist/provider/components/SolanaWalletWrapper.d.ts +9 -0
- package/dist/provider/external/getParaCosmosConnector.d.ts +7 -0
- package/dist/provider/external/getParaEvmConnector.d.ts +7 -0
- package/dist/provider/external/getParaSolanaConnector.d.ts +7 -0
- package/dist/provider/external/stubs/CosmosExternalWalletContextStub.d.ts +12 -0
- package/dist/provider/external/stubs/EvmExternalWalletContextStub.d.ts +3 -0
- package/dist/provider/external/stubs/SolanaExternalWalletContextStub.d.ts +8 -0
- package/dist/provider/hooks/mutations/index.d.ts +25 -10
- package/dist/provider/hooks/mutations/utils.d.ts +4 -0
- package/dist/provider/hooks/queries/index.d.ts +0 -1
- package/dist/provider/hooks/queries/useAccount.d.ts +1 -6
- package/dist/provider/hooks/queries/useWallet.d.ts +1 -1
- package/dist/provider/hooks/utils/useWalletState.d.ts +3 -2
- package/dist/provider/index.d.ts +1 -0
- package/dist/provider/providers/AuthProvider.d.ts +31 -0
- package/dist/provider/providers/CosmosExternalWalletProvider.d.ts +7 -0
- package/dist/provider/providers/EvmExternalWalletProvider.d.ts +7 -0
- package/dist/provider/providers/ExternalWalletProvider.d.ts +73 -0
- package/dist/provider/providers/SolanaExternalWalletProvider.d.ts +7 -0
- package/dist/provider/stores/getters.d.ts +3 -3
- package/dist/provider/stores/setters.d.ts +1 -0
- package/dist/provider/stores/slices/config.d.ts +3 -0
- package/dist/provider/stores/slices/externalWallets.d.ts +3 -0
- package/dist/provider/stores/slices/index.d.ts +1 -0
- package/dist/provider/stores/types.d.ts +46 -3
- package/dist/provider/types/externalWalletProviders.d.ts +12 -0
- package/dist/provider/types/provider.d.ts +119 -16
- package/dist/provider/types/utils.d.ts +16 -0
- package/dist/provider/utils/paraConfigTypeGuards.d.ts +7 -0
- package/dist/provider/utils/renameMutations.d.ts +3 -0
- package/package.json +19 -7
- package/dist/modal/ParaModal.js +0 -362
- package/dist/modal/components/Account/Account.js +0 -77
- package/dist/modal/components/AddFunds/AddFunds.js +0 -220
- package/dist/modal/components/AddFunds/AddFundsAwaiting.js +0 -72
- package/dist/modal/components/AddFunds/AddFundsDone.js +0 -43
- package/dist/modal/components/AddFunds/index.js +0 -4
- package/dist/modal/components/AuthInput/AuthInput.js +0 -283
- package/dist/modal/components/AuthInput/countryCodes.js +0 -42
- package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +0 -33
- package/dist/modal/components/AuthInput/phoneMasks.js +0 -253
- package/dist/modal/components/AuthMainStep/AuthMainStep.js +0 -37
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +0 -113
- package/dist/modal/components/AuthOptions/AuthOptions.js +0 -33
- package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +0 -18
- package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.js +0 -10
- package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +0 -18
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +0 -44
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +0 -55
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +0 -93
- package/dist/modal/components/Body/AnimatedHeightWrapper.js +0 -29
- package/dist/modal/components/Body/Body.js +0 -308
- package/dist/modal/components/ChainSwitch/ChainSwitch.js +0 -94
- package/dist/modal/components/ChainSwitch/config.js +0 -17
- package/dist/modal/components/Controls/Controls.js +0 -74
- package/dist/modal/components/Controls/Selects.js +0 -234
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +0 -140
- package/dist/modal/components/ExternalWalletStep/config.js +0 -17
- package/dist/modal/components/ExternalWalletVerificationStep/ExternalWalletVerificationStep.js +0 -96
- package/dist/modal/components/ExternalWallets/ExternalWallets.js +0 -172
- package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.d.ts +0 -8
- package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +0 -124
- package/dist/modal/components/Footer/Footer.js +0 -93
- package/dist/modal/components/Header/Header.js +0 -43
- package/dist/modal/components/Header/hooks/useStepTitle.js +0 -50
- package/dist/modal/components/Hero/Hero.js +0 -116
- package/dist/modal/components/IFrameStep/IFrameStep.js +0 -55
- package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +0 -28
- package/dist/modal/components/ModalContent/ModalContent.js +0 -324
- package/dist/modal/components/OAuth/FarcasterOAuthStep.js +0 -81
- package/dist/modal/components/OAuth/OAuth.js +0 -153
- package/dist/modal/components/OAuth/TelegramOAuthStep.js +0 -139
- package/dist/modal/components/OnRampComponents/AddingFunds.js +0 -23
- package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +0 -77
- package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +0 -101
- package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +0 -141
- package/dist/modal/components/StripeComponents/StripeComponents.js +0 -88
- package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +0 -24
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +0 -159
- package/dist/modal/components/Waiting/Waiting.js +0 -17
- package/dist/modal/components/WalletCard/PartnerIcon.js +0 -34
- package/dist/modal/components/WalletCard/WalletCard.js +0 -127
- package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +0 -52
- package/dist/modal/components/common.js +0 -96
- package/dist/modal/components/index.js +0 -2
- package/dist/modal/constants/constants.js +0 -111
- package/dist/modal/constants/defaults.js +0 -10
- package/dist/modal/constants/oAuthLogos.js +0 -24
- 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 -4
- package/dist/modal/hooks/useCreateAccount.js +0 -72
- package/dist/modal/hooks/useEmbeddedExternalConnection.d.ts +0 -1
- package/dist/modal/hooks/useEmbeddedExternalConnection.js +0 -54
- package/dist/modal/hooks/useGoBack.js +0 -42
- 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 -47
- package/dist/modal/index.js +0 -33
- 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/ExternalWalletContext.js +0 -394
- 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/index.js +0 -4
- package/dist/modal/stores/modal/actions.js +0 -70
- package/dist/modal/stores/modal/useModalStore.js +0 -65
- 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/modal/types/commonTypes.js +0 -1
- package/dist/modal/types/externalWallets.js +0 -32
- package/dist/modal/types/modalProps.js +0 -12
- package/dist/modal/utils/authLayoutHelpers.js +0 -8
- package/dist/modal/utils/getMailtoLink.js +0 -10
- package/dist/modal/utils/getTileButtonFlex.js +0 -20
- package/dist/modal/utils/openPopup.js +0 -60
- package/dist/modal/utils/routeMobileExternalWallet.js +0 -31
- package/dist/modal/utils/steps.js +0 -232
- package/dist/modal/utils/stringFormatters.js +0 -19
- package/dist/modal/utils/validateOnRampConfig.js +0 -32
- package/dist/package.json +0 -6
- package/dist/provider/ParaProvider.js +0 -22
- package/dist/provider/actions/checkIfUserExists.d.ts +0 -9
- package/dist/provider/actions/checkIfUserExists.js +0 -21
- package/dist/provider/actions/createUser.d.ts +0 -12
- package/dist/provider/actions/createUser.js +0 -26
- package/dist/provider/actions/getAccount.js +0 -22
- package/dist/provider/actions/getWallet.js +0 -14
- 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/index.js +0 -4
- package/dist/provider/hooks/mutations/index.js +0 -24
- package/dist/provider/hooks/mutations/useCheckIfUserExists.d.ts +0 -13
- package/dist/provider/hooks/mutations/useCheckIfUserExists.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/provider/hooks/queries/index.js +0 -10
- package/dist/provider/hooks/queries/useAccount.js +0 -21
- package/dist/provider/hooks/queries/useWallet.js +0 -22
- package/dist/provider/hooks/queries/useWalletBalance.d.ts +0 -7
- package/dist/provider/hooks/queries/useWalletBalance.js +0 -26
- package/dist/provider/hooks/utils/index.js +0 -10
- package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +0 -74
- package/dist/provider/hooks/utils/useClient.js +0 -10
- package/dist/provider/hooks/utils/useEventListeners.js +0 -105
- package/dist/provider/hooks/utils/useInternalClient.js +0 -10
- package/dist/provider/hooks/utils/useModal.js +0 -17
- package/dist/provider/hooks/utils/useWalletState.js +0 -33
- package/dist/provider/index.js +0 -8
- package/dist/provider/stores/getters.js +0 -13
- package/dist/provider/stores/slices/client.js +0 -9
- package/dist/provider/stores/slices/index.js +0 -4
- package/dist/provider/stores/slices/modal.js +0 -9
- package/dist/provider/stores/slices/wallet.js +0 -13
- package/dist/provider/stores/types.js +0 -1
- package/dist/provider/stores/useStore.js +0 -27
- package/dist/provider/types/provider.js +0 -1
- package/dist/provider/types/query.js +0 -1
- package/dist/provider/types/utils.js +0 -1
- package/dist/provider/utils/constants.d.ts +0 -5
- package/dist/provider/utils/constants.js +0 -11
- package/dist/provider/utils/renameMutations.js +0 -16
package/dist/modal/ParaModal.js
DELETED
|
@@ -1,362 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
__async,
|
|
4
|
-
__objRest,
|
|
5
|
-
__spreadValues
|
|
6
|
-
} from "../chunk-MMUBH76A.js";
|
|
7
|
-
import { jsx } from "react/jsx-runtime";
|
|
8
|
-
import { CpslAuthModal, defineCustomElements, generateTheme } from "@getpara/react-components";
|
|
9
|
-
import { ModalContent } from "./components/index.js";
|
|
10
|
-
import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
11
|
-
import { useModalStore, useUserInfoStore, useThemeStore } from "./stores/index.js";
|
|
12
|
-
import { ModalStep, RESET_TO_ACCOUNT_STEPS, RESET_TO_AUTH_STEPS } from "./utils/steps.js";
|
|
13
|
-
import { AuthLayout } from "./types/modalProps.js";
|
|
14
|
-
import { DEFAULTS } from "./constants/defaults.js";
|
|
15
|
-
import { useGoBack } from "./hooks/useGoBack.js";
|
|
16
|
-
import { isPasskeySupported, ParaEvent } from "@getpara/web-sdk";
|
|
17
|
-
import { ExternalWalletsWrapper } from "./components/ExternalWalletsWrapper/ExternalWalletsWrapper.js";
|
|
18
|
-
import styled from "styled-components";
|
|
19
|
-
import { hasEmbeddedAuth, hasExternalWallet } from "./utils/authLayoutHelpers.js";
|
|
20
|
-
import { useModal, useWalletState } from "../provider/index.js";
|
|
21
|
-
import { useStore } from "../provider/stores/useStore.js";
|
|
22
|
-
import { getExternalWalletDisplayName } from "@getpara/react-common";
|
|
23
|
-
import { useInternalClient } from "../provider/hooks/utils/useInternalClient.js";
|
|
24
|
-
import { useExternalWalletProviderStore } from "./stores/externalWalletProvider/useExternalWalletProviderStore.js";
|
|
25
|
-
defineCustomElements();
|
|
26
|
-
const ParaModal = forwardRef(
|
|
27
|
-
(_a, ref) => {
|
|
28
|
-
var _b = _a, { para, isOpen, externalWalletsWithParaAuth, rpcUrl: rpcUrlFromProps } = _b, rest = __objRest(_b, ["para", "isOpen", "externalWalletsWithParaAuth", "rpcUrl"]);
|
|
29
|
-
const [isInitialized, setIsInitialized] = useState(false);
|
|
30
|
-
const setClient = useStore((state) => state.setClient);
|
|
31
|
-
const client = useStore((state) => state.client);
|
|
32
|
-
const rpcUrl = useStore((state) => state.rpcUrl);
|
|
33
|
-
const setRpcUrl = useStore((state) => state.setRpcUrl);
|
|
34
|
-
const { closeModal, openModal } = useModal();
|
|
35
|
-
const updateExternalWalletProviderState = useExternalWalletProviderStore((state) => state.updateState);
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
updateExternalWalletProviderState({ fullAuthWallets: externalWalletsWithParaAuth });
|
|
38
|
-
}, [externalWalletsWithParaAuth]);
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
if (!client) {
|
|
41
|
-
setClient(para);
|
|
42
|
-
}
|
|
43
|
-
setIsInitialized(true);
|
|
44
|
-
}, []);
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
if (rpcUrl !== rpcUrlFromProps) {
|
|
47
|
-
setRpcUrl(rpcUrlFromProps);
|
|
48
|
-
}
|
|
49
|
-
}, [rpcUrlFromProps]);
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
if (!isOpen) {
|
|
52
|
-
closeModal();
|
|
53
|
-
}
|
|
54
|
-
if (isOpen) {
|
|
55
|
-
openModal();
|
|
56
|
-
}
|
|
57
|
-
}, [isOpen]);
|
|
58
|
-
if (!isInitialized) {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
return /* @__PURE__ */ jsx(ParaModalInner, __spreadValues({ ref, para, externalWalletsWithParaAuth }, rest));
|
|
62
|
-
}
|
|
63
|
-
);
|
|
64
|
-
const ParaModalInner = forwardRef(
|
|
65
|
-
(_c, ref) => {
|
|
66
|
-
var _d = _c, {
|
|
67
|
-
theme,
|
|
68
|
-
appName,
|
|
69
|
-
logo,
|
|
70
|
-
disableEmailLogin = false,
|
|
71
|
-
disablePhoneLogin = false,
|
|
72
|
-
oAuthMethods,
|
|
73
|
-
bareModal = false,
|
|
74
|
-
className,
|
|
75
|
-
currentStepOverride,
|
|
76
|
-
externalWallets,
|
|
77
|
-
authLayout = [AuthLayout.AUTH_FULL, AuthLayout.EXTERNAL_FULL],
|
|
78
|
-
embeddedModal,
|
|
79
|
-
onModalStepChange,
|
|
80
|
-
hideWallets = false,
|
|
81
|
-
onClose,
|
|
82
|
-
externalWalletsWithParaAuth
|
|
83
|
-
} = _d, rest = __objRest(_d, [
|
|
84
|
-
"theme",
|
|
85
|
-
"appName",
|
|
86
|
-
"logo",
|
|
87
|
-
"disableEmailLogin",
|
|
88
|
-
"disablePhoneLogin",
|
|
89
|
-
"oAuthMethods",
|
|
90
|
-
"bareModal",
|
|
91
|
-
"className",
|
|
92
|
-
"currentStepOverride",
|
|
93
|
-
"externalWallets",
|
|
94
|
-
"authLayout",
|
|
95
|
-
"embeddedModal",
|
|
96
|
-
"onModalStepChange",
|
|
97
|
-
"hideWallets",
|
|
98
|
-
"onClose",
|
|
99
|
-
"externalWalletsWithParaAuth"
|
|
100
|
-
]);
|
|
101
|
-
const modalContentRef = useRef(null);
|
|
102
|
-
const updateThemeState = useThemeStore((state) => state.updateState);
|
|
103
|
-
const refs = useModalStore((state) => state.refs);
|
|
104
|
-
const setWebAuthURLForLogin = useModalStore((state) => state.setWebAuthURLForLogin);
|
|
105
|
-
const setWebAuthURLForCreate = useModalStore((state) => state.setWebAuthURLForCreate);
|
|
106
|
-
const setBiometricLocationHints = useModalStore((state) => state.setBiometricLocationHints);
|
|
107
|
-
const currentStep = useModalStore((state) => state.step);
|
|
108
|
-
const setOnModalStepChange = useModalStore((state) => state.setOnModalStepChange);
|
|
109
|
-
const setStep = useModalStore((state) => state.setStep);
|
|
110
|
-
const setAuthInfo = useUserInfoStore((state) => state.setAuthInfo);
|
|
111
|
-
const hasPreviousStep = useModalStore((state) => state.hasPreviousStep());
|
|
112
|
-
const setFlow = useModalStore((state) => state.setFlow);
|
|
113
|
-
const setIsFullyLoggedIn = useModalStore((state) => state.setIsFullyLoggedIn);
|
|
114
|
-
const goBack = useGoBack();
|
|
115
|
-
const setAuthLayout = useThemeStore((state) => state.setAuthLayout);
|
|
116
|
-
const storedAuthLayout = useThemeStore((state) => state.authLayout);
|
|
117
|
-
const resetModalState = useModalStore((state) => state.resetState);
|
|
118
|
-
const resetUserInfoState = useUserInfoStore((state) => state.resetState);
|
|
119
|
-
const setRecoveryShare = useUserInfoStore((state) => state.setRecoveryShare);
|
|
120
|
-
const { isOpen, closeModal } = useModal();
|
|
121
|
-
const para = useInternalClient();
|
|
122
|
-
const { selectedWallet, setSelectedWallet } = useWalletState();
|
|
123
|
-
const setIsPasskeySupported = useModalStore((state) => state.setIsPasskeySupported);
|
|
124
|
-
const [isModalMounted, setIsModalMounted] = useState(false);
|
|
125
|
-
const [isInit, setIsInit] = useState(false);
|
|
126
|
-
const [ready, setIsReady] = useState(false);
|
|
127
|
-
useImperativeHandle(ref, () => {
|
|
128
|
-
return {
|
|
129
|
-
goBack() {
|
|
130
|
-
goBack();
|
|
131
|
-
},
|
|
132
|
-
canGoBack() {
|
|
133
|
-
return hasPreviousStep;
|
|
134
|
-
},
|
|
135
|
-
currentStep() {
|
|
136
|
-
return currentStep;
|
|
137
|
-
},
|
|
138
|
-
handleModalClose() {
|
|
139
|
-
var _a;
|
|
140
|
-
(_a = modalContentRef == null ? void 0 : modalContentRef.current) == null ? void 0 : _a.handleModalClose();
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
}, [hasPreviousStep, currentStep]);
|
|
144
|
-
const initModal = () => __async(void 0, null, function* () {
|
|
145
|
-
const isAccount = yield para.isFullyLoggedIn();
|
|
146
|
-
setIsPasskeySupported(yield isPasskeySupported());
|
|
147
|
-
if (currentStepOverride) {
|
|
148
|
-
setStep(ModalStep[currentStepOverride.toUpperCase()]);
|
|
149
|
-
} else if (isAccount) {
|
|
150
|
-
setFlow("account");
|
|
151
|
-
setStep(ModalStep.ACCOUNT_MAIN);
|
|
152
|
-
setIsFullyLoggedIn(true);
|
|
153
|
-
} else {
|
|
154
|
-
if (currentStep !== ModalStep.AUTH_MAIN && currentStep !== ModalStep.SECRET) {
|
|
155
|
-
setStep(ModalStep.AUTH_MAIN);
|
|
156
|
-
setFlow();
|
|
157
|
-
setWebAuthURLForLogin();
|
|
158
|
-
setWebAuthURLForCreate();
|
|
159
|
-
setBiometricLocationHints();
|
|
160
|
-
}
|
|
161
|
-
setSelectedWallet({ id: void 0, type: void 0 });
|
|
162
|
-
setIsFullyLoggedIn(false);
|
|
163
|
-
}
|
|
164
|
-
switch (true) {
|
|
165
|
-
case para.isEmail:
|
|
166
|
-
setAuthInfo({ email: para.getEmail() });
|
|
167
|
-
break;
|
|
168
|
-
case para.isPhone:
|
|
169
|
-
{
|
|
170
|
-
const { phone, countryCode } = para.getPhone();
|
|
171
|
-
setAuthInfo({ phone, countryCode });
|
|
172
|
-
}
|
|
173
|
-
break;
|
|
174
|
-
case para.isFarcaster:
|
|
175
|
-
setAuthInfo({ farcasterUsername: para.getFarcasterUsername() });
|
|
176
|
-
break;
|
|
177
|
-
case para.isTelegram:
|
|
178
|
-
setAuthInfo({ telegramUserId: para.telegramUserId });
|
|
179
|
-
if (!isAccount) {
|
|
180
|
-
setStep(ModalStep.TELEGRAM_OAUTH);
|
|
181
|
-
}
|
|
182
|
-
break;
|
|
183
|
-
case para.isExternalWalletAuth:
|
|
184
|
-
const externalWallets2 = Object.values(para.externalWallets);
|
|
185
|
-
const externalWalletWithFullAuth = externalWallets2.find((w) => w.isExternalWithParaAuth);
|
|
186
|
-
setAuthInfo({
|
|
187
|
-
displayName: getExternalWalletDisplayName({
|
|
188
|
-
address: externalWalletWithFullAuth.address,
|
|
189
|
-
type: externalWalletWithFullAuth.type
|
|
190
|
-
}),
|
|
191
|
-
externalWalletAddress: externalWalletWithFullAuth.address
|
|
192
|
-
});
|
|
193
|
-
break;
|
|
194
|
-
}
|
|
195
|
-
setIsInit(true);
|
|
196
|
-
});
|
|
197
|
-
useEffect(() => {
|
|
198
|
-
let _authLayout = authLayout;
|
|
199
|
-
if (!(externalWallets == null ? void 0 : externalWallets.length) && hasExternalWallet(authLayout)) {
|
|
200
|
-
_authLayout = _authLayout.filter((l) => !l.includes("EXTERNAL"));
|
|
201
|
-
}
|
|
202
|
-
if (disableEmailLogin && disablePhoneLogin && !(oAuthMethods == null ? void 0 : oAuthMethods.length) && hasEmbeddedAuth(authLayout)) {
|
|
203
|
-
_authLayout = _authLayout.filter((l) => !l.includes("AUTH"));
|
|
204
|
-
}
|
|
205
|
-
if (JSON.stringify(storedAuthLayout) !== JSON.stringify(_authLayout)) {
|
|
206
|
-
setAuthLayout(_authLayout);
|
|
207
|
-
}
|
|
208
|
-
}, [disableEmailLogin, disablePhoneLogin, oAuthMethods, externalWallets, authLayout]);
|
|
209
|
-
useEffect(() => {
|
|
210
|
-
setOnModalStepChange(onModalStepChange);
|
|
211
|
-
}, [onModalStepChange]);
|
|
212
|
-
useEffect(() => {
|
|
213
|
-
var _a;
|
|
214
|
-
updateThemeState({
|
|
215
|
-
logo,
|
|
216
|
-
appName,
|
|
217
|
-
oAuthLogoVariant: (_a = theme == null ? void 0 : theme.oAuthLogoVariant) != null ? _a : "default",
|
|
218
|
-
bareModal,
|
|
219
|
-
embeddedModal,
|
|
220
|
-
hideWallets
|
|
221
|
-
});
|
|
222
|
-
}, [logo, appName, theme == null ? void 0 : theme.oAuthLogoVariant, bareModal, embeddedModal, hideWallets]);
|
|
223
|
-
useEffect(() => {
|
|
224
|
-
if (theme) {
|
|
225
|
-
generateTheme(theme);
|
|
226
|
-
updateThemeState({ isDark: theme.mode === "dark", theme });
|
|
227
|
-
}
|
|
228
|
-
}, [theme]);
|
|
229
|
-
useEffect(() => {
|
|
230
|
-
if (para) {
|
|
231
|
-
initModal();
|
|
232
|
-
if (bareModal) {
|
|
233
|
-
setIsModalMounted(true);
|
|
234
|
-
}
|
|
235
|
-
} else {
|
|
236
|
-
console.error("A Para instance must be provided.");
|
|
237
|
-
}
|
|
238
|
-
}, []);
|
|
239
|
-
useEffect(() => {
|
|
240
|
-
if (isOpen && para) {
|
|
241
|
-
initModal();
|
|
242
|
-
}
|
|
243
|
-
}, [isOpen]);
|
|
244
|
-
const updateActiveWallet = () => {
|
|
245
|
-
if (!(selectedWallet == null ? void 0 : selectedWallet.id) || !para.findWallet(selectedWallet == null ? void 0 : selectedWallet.id)) {
|
|
246
|
-
const defaultWallet = para.findWallet(void 0, void 0, { forbidPregen: true });
|
|
247
|
-
setSelectedWallet({ id: defaultWallet == null ? void 0 : defaultWallet.id, type: defaultWallet == null ? void 0 : defaultWallet.type });
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
|
-
useEffect(() => {
|
|
251
|
-
updateActiveWallet();
|
|
252
|
-
}, [para]);
|
|
253
|
-
useEffect(() => {
|
|
254
|
-
const closePopupWindow = () => {
|
|
255
|
-
var _a;
|
|
256
|
-
(_a = refs.popupWindow.current) == null ? void 0 : _a.close();
|
|
257
|
-
};
|
|
258
|
-
if (typeof window !== "undefined") {
|
|
259
|
-
window.addEventListener(ParaEvent.WALLETS_CHANGE_EVENT, updateActiveWallet);
|
|
260
|
-
window.addEventListener(ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, updateActiveWallet);
|
|
261
|
-
window.addEventListener("beforeunload", closePopupWindow);
|
|
262
|
-
}
|
|
263
|
-
setIsReady(true);
|
|
264
|
-
return () => {
|
|
265
|
-
if (typeof window !== "undefined") {
|
|
266
|
-
window.removeEventListener(ParaEvent.WALLETS_CHANGE_EVENT, updateActiveWallet);
|
|
267
|
-
window.removeEventListener(ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, updateActiveWallet);
|
|
268
|
-
window.removeEventListener("beforeunload", closePopupWindow);
|
|
269
|
-
}
|
|
270
|
-
};
|
|
271
|
-
}, []);
|
|
272
|
-
const handleClose = () => {
|
|
273
|
-
closeModal();
|
|
274
|
-
onClose == null ? void 0 : onClose();
|
|
275
|
-
};
|
|
276
|
-
const handleModalEntering = () => {
|
|
277
|
-
setIsModalMounted(true);
|
|
278
|
-
};
|
|
279
|
-
const handleModalExited = () => __async(void 0, null, function* () {
|
|
280
|
-
if (!bareModal) {
|
|
281
|
-
setIsModalMounted(false);
|
|
282
|
-
}
|
|
283
|
-
if (RESET_TO_AUTH_STEPS.includes(currentStep)) {
|
|
284
|
-
resetModalState();
|
|
285
|
-
resetUserInfoState();
|
|
286
|
-
setRecoveryShare(null);
|
|
287
|
-
} else if (RESET_TO_ACCOUNT_STEPS.includes(currentStep)) {
|
|
288
|
-
setStep(ModalStep.LOGIN_DONE);
|
|
289
|
-
}
|
|
290
|
-
if (para) {
|
|
291
|
-
yield initModal();
|
|
292
|
-
para.exitLoops();
|
|
293
|
-
}
|
|
294
|
-
if (!bareModal) {
|
|
295
|
-
setIsInit(false);
|
|
296
|
-
}
|
|
297
|
-
});
|
|
298
|
-
if (!ready) {
|
|
299
|
-
return null;
|
|
300
|
-
}
|
|
301
|
-
if (!para) {
|
|
302
|
-
console.error("A Para instance is required.");
|
|
303
|
-
return null;
|
|
304
|
-
}
|
|
305
|
-
if (!(storedAuthLayout == null ? void 0 : storedAuthLayout.length)) {
|
|
306
|
-
const hasExternalWalletError = !(externalWallets == null ? void 0 : externalWallets.length) && hasExternalWallet(authLayout);
|
|
307
|
-
const hasEmbeddedWalletError = disableEmailLogin && disablePhoneLogin && !(oAuthMethods == null ? void 0 : oAuthMethods.length) && hasEmbeddedAuth(authLayout);
|
|
308
|
-
if (hasExternalWalletError || hasEmbeddedWalletError) {
|
|
309
|
-
if (hasExternalWalletError) {
|
|
310
|
-
console.error("At least one external wallet must be provided if external wallet auth is enabled.");
|
|
311
|
-
}
|
|
312
|
-
if (hasEmbeddedWalletError) {
|
|
313
|
-
console.error(
|
|
314
|
-
"At least one login method (email, phone or OAuth) must be provided if embedded wallet auth is enabled."
|
|
315
|
-
);
|
|
316
|
-
}
|
|
317
|
-
} else {
|
|
318
|
-
console.error("At least one auth layout selection is required.");
|
|
319
|
-
}
|
|
320
|
-
return null;
|
|
321
|
-
}
|
|
322
|
-
return /* @__PURE__ */ jsx(ExternalWalletsWrapper, { wallets: externalWallets, externalWalletsWithFullAuth: externalWalletsWithParaAuth, children: /* @__PURE__ */ jsx(
|
|
323
|
-
StyledAuthModal,
|
|
324
|
-
{
|
|
325
|
-
enterTransitionDuration: DEFAULTS.ANIMATION_DURATION,
|
|
326
|
-
exitTransitionDuration: DEFAULTS.ANIMATION_DURATION,
|
|
327
|
-
open: isOpen,
|
|
328
|
-
onCpslModalExited: handleModalExited,
|
|
329
|
-
onCpslModalEntering: handleModalEntering,
|
|
330
|
-
onCpslModalRequestClose: handleClose,
|
|
331
|
-
noOverlay: bareModal,
|
|
332
|
-
className,
|
|
333
|
-
"data-testid": "modal",
|
|
334
|
-
$embeddedModal: embeddedModal,
|
|
335
|
-
children: isModalMounted && (isInit && embeddedModal || !embeddedModal) && /* @__PURE__ */ jsx(
|
|
336
|
-
ModalContent,
|
|
337
|
-
__spreadValues({
|
|
338
|
-
oAuthMethods,
|
|
339
|
-
disableEmailLogin,
|
|
340
|
-
disablePhoneLogin,
|
|
341
|
-
onClose: handleClose
|
|
342
|
-
}, rest)
|
|
343
|
-
)
|
|
344
|
-
}
|
|
345
|
-
) });
|
|
346
|
-
}
|
|
347
|
-
);
|
|
348
|
-
const StyledAuthModal = styled(CpslAuthModal)`
|
|
349
|
-
${({ $embeddedModal }) => $embeddedModal && `
|
|
350
|
-
&::part(modal-body-card) {
|
|
351
|
-
--card-box-shadow: none;
|
|
352
|
-
--card-border-width: 0px;
|
|
353
|
-
};
|
|
354
|
-
|
|
355
|
-
&::part(modal-footer) {
|
|
356
|
-
--card-box-shadow: none;
|
|
357
|
-
--card-border-width: 0px;
|
|
358
|
-
};`}
|
|
359
|
-
`;
|
|
360
|
-
export {
|
|
361
|
-
ParaModal
|
|
362
|
-
};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
__async
|
|
4
|
-
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import styled from "styled-components";
|
|
7
|
-
import { InnerStepContainer, StepContainer, StyledCpslTileButton } from "../common.js";
|
|
8
|
-
import { CpslButton, CpslIcon, CpslSpinner, CpslText } from "@getpara/react-components";
|
|
9
|
-
import { useModalStore, useThemeStore } from "../../stores/index.js";
|
|
10
|
-
import { useExternalWallets } from "../../providers/ExternalWalletContext.js";
|
|
11
|
-
import { useState } from "react";
|
|
12
|
-
import { ModalStep } from "../../utils/steps.js";
|
|
13
|
-
import { useWalletBalance } from "../../hooks/useWalletBalance.js";
|
|
14
|
-
import { formatBalanceString } from "../../utils/stringFormatters.js";
|
|
15
|
-
const Account = ({ onClose }) => {
|
|
16
|
-
const onRampConfig = useModalStore((state) => state.onRampConfig);
|
|
17
|
-
const setStep = useModalStore((state) => state.setStep);
|
|
18
|
-
const hideWallets = useThemeStore((state) => state.hideWallets);
|
|
19
|
-
const { disconnectExternalWallet } = useExternalWallets();
|
|
20
|
-
const { balance, isLoading: isBalanceLoading } = useWalletBalance();
|
|
21
|
-
const [isDisconnecting, setIsDisconnecting] = useState(false);
|
|
22
|
-
const isOnRampLoaded = !!onRampConfig;
|
|
23
|
-
const handleBuyClick = () => {
|
|
24
|
-
setStep(ModalStep.ADD_FUNDS_BUY);
|
|
25
|
-
};
|
|
26
|
-
const handleReceiveClick = () => {
|
|
27
|
-
setStep(ModalStep.ADD_FUNDS_RECEIVE);
|
|
28
|
-
};
|
|
29
|
-
const handleSellClick = () => {
|
|
30
|
-
setStep(ModalStep.ADD_FUNDS_WITHDRAW);
|
|
31
|
-
};
|
|
32
|
-
const handleDisconnectClick = () => __async(void 0, null, function* () {
|
|
33
|
-
setIsDisconnecting(true);
|
|
34
|
-
yield disconnectExternalWallet();
|
|
35
|
-
onClose();
|
|
36
|
-
setStep(ModalStep.AUTH_MAIN);
|
|
37
|
-
setIsDisconnecting(false);
|
|
38
|
-
});
|
|
39
|
-
return /* @__PURE__ */ jsx(StepContainer, { $wide: true, children: /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
|
|
40
|
-
isBalanceLoading ? /* @__PURE__ */ jsx(BalanceContainer, { children: /* @__PURE__ */ jsx(CpslSpinner, { size: 39 }) }) : balance !== void 0 && /* @__PURE__ */ jsx(BalanceContainer, { children: /* @__PURE__ */ jsx(CpslText, { variant: "headingS", weight: "medium", children: formatBalanceString(balance) }) }),
|
|
41
|
-
/* @__PURE__ */ jsx(ButtonContainer, { children: isOnRampLoaded ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
42
|
-
onRampConfig.isBuyEnabled && /* @__PURE__ */ jsx(OptionButton, { icon: "creditCard", onClick: handleBuyClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Buy Crypto" }) }),
|
|
43
|
-
onRampConfig.isReceiveEnabled && /* @__PURE__ */ jsx(OptionButton, { icon: "qrCode02", onClick: handleReceiveClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Receive" }) }),
|
|
44
|
-
onRampConfig.isWithdrawEnabled && /* @__PURE__ */ jsx(OptionButton, { icon: "arrowCircleBrokenDownLeft", onClick: handleSellClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Withdraw" }) })
|
|
45
|
-
] }) : /* @__PURE__ */ jsx(CpslSpinner, {}) }),
|
|
46
|
-
/* @__PURE__ */ jsx(DisconnectButton, { variant: "destructive", fullWidth: true, onClick: handleDisconnectClick, disabled: isDisconnecting, children: isDisconnecting ? /* @__PURE__ */ jsx(CpslSpinner, { size: 16 }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
47
|
-
hideWallets ? "Logout" : "Disconnect Wallet",
|
|
48
|
-
/* @__PURE__ */ jsx(CpslIcon, { icon: "logOut", slot: "end" })
|
|
49
|
-
] }) })
|
|
50
|
-
] }) });
|
|
51
|
-
};
|
|
52
|
-
const ButtonContainer = styled.div`
|
|
53
|
-
display: flex;
|
|
54
|
-
align-items: center;
|
|
55
|
-
justify-content: center;
|
|
56
|
-
gap: 8px;
|
|
57
|
-
width: 100%;
|
|
58
|
-
height: 88px;
|
|
59
|
-
`;
|
|
60
|
-
const OptionButton = styled(StyledCpslTileButton)`
|
|
61
|
-
flex: 1;
|
|
62
|
-
|
|
63
|
-
--button-icon-color: var(--cpsl-color-text-primary);
|
|
64
|
-
`;
|
|
65
|
-
const DisconnectButton = styled(CpslButton)`
|
|
66
|
-
--button-border-width: 0px;
|
|
67
|
-
`;
|
|
68
|
-
const BalanceContainer = styled.div`
|
|
69
|
-
display: flex;
|
|
70
|
-
justify-content: center;
|
|
71
|
-
align-items: center;
|
|
72
|
-
padding-top: 8px;
|
|
73
|
-
padding-bottom: 24px;
|
|
74
|
-
`;
|
|
75
|
-
export {
|
|
76
|
-
Account
|
|
77
|
-
};
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
__async,
|
|
4
|
-
__spreadProps,
|
|
5
|
-
__spreadValues
|
|
6
|
-
} from "../../../chunk-MMUBH76A.js";
|
|
7
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
-
import {
|
|
9
|
-
EnabledFlow,
|
|
10
|
-
getOnRampAssets,
|
|
11
|
-
getOnRampNetworks,
|
|
12
|
-
OnRampProvider,
|
|
13
|
-
OnRampPurchaseType,
|
|
14
|
-
toAssetInfoArray,
|
|
15
|
-
WalletType
|
|
16
|
-
} from "@getpara/web-sdk";
|
|
17
|
-
import { CenteredText, FilledDisabledInput, Heading, InnerStepContainer, QRContainer, StepContainer } from "../common.js";
|
|
18
|
-
import {
|
|
19
|
-
CpslButton,
|
|
20
|
-
CpslDivider,
|
|
21
|
-
CpslIcon,
|
|
22
|
-
CpslIdenticon,
|
|
23
|
-
CpslQrCode,
|
|
24
|
-
CpslSpinner,
|
|
25
|
-
CpslTab,
|
|
26
|
-
CpslTabs,
|
|
27
|
-
CpslText
|
|
28
|
-
} from "@getpara/react-components";
|
|
29
|
-
import { useModalStore, useThemeStore } from "../../stores/index.js";
|
|
30
|
-
import { useEffect, useMemo } from "react";
|
|
31
|
-
import { OnRampProviderButton } from "../OnRampComponents/OnRampProviderButton.js";
|
|
32
|
-
import { isMobile } from "@getpara/web-sdk";
|
|
33
|
-
import { useActiveWallet } from "../../hooks/useActiveWallet.js";
|
|
34
|
-
import { getAddFundsStep, ModalStep } from "../../utils/steps.js";
|
|
35
|
-
import { motion, AnimatePresence } from "framer-motion";
|
|
36
|
-
import { useExternalWallets } from "../../providers/ExternalWalletContext.js";
|
|
37
|
-
import { getNetworkFromChainId, getNetworkOrMainNetEquivalent, useCopyToClipboard } from "@getpara/react-common";
|
|
38
|
-
import { formatNetworkList } from "../../utils/stringFormatters.js";
|
|
39
|
-
import styled from "styled-components";
|
|
40
|
-
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
41
|
-
const TABS = [
|
|
42
|
-
[EnabledFlow.BUY, "isBuyEnabled", "creditCard", "Buy"],
|
|
43
|
-
[EnabledFlow.RECEIVE, "isReceiveEnabled", "qrCode", "Receive"],
|
|
44
|
-
[EnabledFlow.WITHDRAW, "isWithdrawEnabled", "arrowCircleBrokenDownLeft", "Withdraw"]
|
|
45
|
-
];
|
|
46
|
-
const GENERIC_WALLET = {
|
|
47
|
-
[WalletType.EVM]: "Ethereum or EVM-based L2s",
|
|
48
|
-
[WalletType.SOLANA]: "Solana",
|
|
49
|
-
[WalletType.COSMOS]: "Cosmos"
|
|
50
|
-
};
|
|
51
|
-
const AddFunds = () => {
|
|
52
|
-
const [isCopied, copy] = useCopyToClipboard();
|
|
53
|
-
const para = useInternalClient();
|
|
54
|
-
const appName = useThemeStore((state) => state.appName);
|
|
55
|
-
const onRampConfig = useModalStore((state) => state.onRampConfig);
|
|
56
|
-
const hideWallets = useThemeStore((state) => state.hideWallets);
|
|
57
|
-
const storedTab = useModalStore((state) => state.accountAddFundTab);
|
|
58
|
-
const setStep = useModalStore((state) => state.setStep);
|
|
59
|
-
const setOnRampPurchase = useModalStore((state) => state.setOnRampPurchase);
|
|
60
|
-
const { chainId } = useExternalWallets();
|
|
61
|
-
const activeWallet = useActiveWallet();
|
|
62
|
-
const tabs = TABS.filter(([, key]) => !!onRampConfig[key]);
|
|
63
|
-
const isMultiFlow = tabs.length > 1;
|
|
64
|
-
const tab = storedTab != null ? storedTab : tabs[0][0];
|
|
65
|
-
const address = useMemo(
|
|
66
|
-
() => activeWallet ? para.getDisplayAddress(activeWallet.id, { addressType: activeWallet.type }) : "",
|
|
67
|
-
[para, activeWallet == null ? void 0 : activeWallet.id, activeWallet == null ? void 0 : activeWallet.type]
|
|
68
|
-
);
|
|
69
|
-
const onSetTab = (event) => {
|
|
70
|
-
setStep(getAddFundsStep(event.detail.tab));
|
|
71
|
-
};
|
|
72
|
-
const onCopy = () => {
|
|
73
|
-
copy(address);
|
|
74
|
-
};
|
|
75
|
-
const [allowedNetworks, allowedAssets, isProviderAllowed] = useMemo(() => {
|
|
76
|
-
if (!onRampConfig || !activeWallet) {
|
|
77
|
-
return [[], [], {}];
|
|
78
|
-
}
|
|
79
|
-
const action = tab === EnabledFlow.BUY ? OnRampPurchaseType.BUY : OnRampPurchaseType.SELL;
|
|
80
|
-
const detectedNetwork = getNetworkFromChainId(chainId);
|
|
81
|
-
const isExternal = activeWallet.isExternal && !!detectedNetwork;
|
|
82
|
-
const allowedNetworks2 = isExternal ? [getNetworkOrMainNetEquivalent(detectedNetwork, onRampConfig.testMode)] : getOnRampNetworks(onRampConfig.assetInfo, {
|
|
83
|
-
walletType: activeWallet.type,
|
|
84
|
-
allowed: onRampConfig.allowedAssets ? Object.keys(onRampConfig.allowedAssets) : void 0
|
|
85
|
-
});
|
|
86
|
-
const allowedAssetsLookup = allowedNetworks2.reduce((acc, network) => {
|
|
87
|
-
var _a;
|
|
88
|
-
const configValue = (_a = onRampConfig.allowedAssets) == null ? void 0 : _a[network];
|
|
89
|
-
const allowed = configValue === true ? void 0 : configValue;
|
|
90
|
-
return __spreadProps(__spreadValues({}, acc), {
|
|
91
|
-
[network]: getOnRampAssets(onRampConfig.assetInfo, { walletType: activeWallet.type, network, allowed })
|
|
92
|
-
});
|
|
93
|
-
}, {});
|
|
94
|
-
const isProviderAllowed2 = onRampConfig.providers.reduce(
|
|
95
|
-
(acc, id) => {
|
|
96
|
-
const hasMatch = toAssetInfoArray(onRampConfig.assetInfo).some(([type, network, asset, validProviders]) => {
|
|
97
|
-
var _a, _b;
|
|
98
|
-
return type === activeWallet.type && allowedNetworks2.includes(network) && (!allowedAssetsLookup[network] || allowedAssetsLookup[network].includes(asset)) && !!((_b = (_a = validProviders[id]) == null ? void 0 : _a[1]) == null ? void 0 : _b[action]);
|
|
99
|
-
});
|
|
100
|
-
return __spreadProps(__spreadValues({}, acc), {
|
|
101
|
-
[id]: hasMatch
|
|
102
|
-
});
|
|
103
|
-
},
|
|
104
|
-
{}
|
|
105
|
-
);
|
|
106
|
-
return [allowedNetworks2, [...new Set(Object.values(allowedAssetsLookup).flat())], isProviderAllowed2];
|
|
107
|
-
}, [activeWallet == null ? void 0 : activeWallet.type, activeWallet == null ? void 0 : activeWallet.isExternal, tab, onRampConfig.assetInfo, onRampConfig.allowedAssets, chainId]);
|
|
108
|
-
useEffect(() => {
|
|
109
|
-
setOnRampPurchase(void 0);
|
|
110
|
-
}, []);
|
|
111
|
-
useEffect(() => {
|
|
112
|
-
setOnRampPurchase(void 0);
|
|
113
|
-
}, []);
|
|
114
|
-
if (!onRampConfig || !activeWallet) {
|
|
115
|
-
return /* @__PURE__ */ jsx(SpinnerContainer, { children: /* @__PURE__ */ jsx(CpslSpinner, {}) });
|
|
116
|
-
}
|
|
117
|
-
useEffect(() => {
|
|
118
|
-
setOnRampPurchase(void 0);
|
|
119
|
-
}, []);
|
|
120
|
-
return /* @__PURE__ */ jsxs(StepContainer, { children: [
|
|
121
|
-
isMultiFlow && /* @__PURE__ */ jsx(InnerStepContainer, { children: /* @__PURE__ */ jsx(CpslTabs, { selectedTab: tab, onCpslTabsChanged: onSetTab, children: TABS.map(([tab2, _, icon, title]) => /* @__PURE__ */ jsxs(CpslTab, { tab: tab2, children: [
|
|
122
|
-
/* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon }),
|
|
123
|
-
title
|
|
124
|
-
] }, tab2)) }) }),
|
|
125
|
-
/* @__PURE__ */ jsx(Fragment, { children: [EnabledFlow.BUY, EnabledFlow.WITHDRAW].includes(tab) ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
126
|
-
/* @__PURE__ */ jsx(Heading, { variant: "headingS", weight: "bold", children: "Choose Provider" }),
|
|
127
|
-
/* @__PURE__ */ jsxs($InnerStepContainer, { children: [
|
|
128
|
-
/* @__PURE__ */ jsxs(NoProviders, { isHidden: Object.values(isProviderAllowed).some((v) => !!v), variant: "bodyM", children: [
|
|
129
|
-
"No providers are available for this ",
|
|
130
|
-
hideWallets ? "account" : "wallet"
|
|
131
|
-
] }),
|
|
132
|
-
/* @__PURE__ */ jsx(AnimatePresence, { children: onRampConfig.providers.map((id, index) => {
|
|
133
|
-
return isProviderAllowed[id] ? /* @__PURE__ */ jsx(
|
|
134
|
-
motion.div,
|
|
135
|
-
{
|
|
136
|
-
style: { width: "100%" },
|
|
137
|
-
layout: true,
|
|
138
|
-
initial: { opacity: 0, transform: "translateX(25px)" },
|
|
139
|
-
animate: { opacity: 1, transform: "none" },
|
|
140
|
-
exit: { opacity: 0, transform: "translateX(-25px)" },
|
|
141
|
-
transition: { duration: 0.2 },
|
|
142
|
-
children: /* @__PURE__ */ jsx(
|
|
143
|
-
OnRampProviderButton,
|
|
144
|
-
{
|
|
145
|
-
config: onRampConfig,
|
|
146
|
-
index,
|
|
147
|
-
onClick: () => __async(void 0, null, function* () {
|
|
148
|
-
var _a;
|
|
149
|
-
if (!(activeWallet == null ? void 0 : activeWallet.type)) return;
|
|
150
|
-
const isPopup = id !== OnRampProvider.RAMP;
|
|
151
|
-
const { onRampPurchase: newOnRampPurchase } = yield para.initiateOnRampTransaction({
|
|
152
|
-
walletId: activeWallet.isExternal ? void 0 : activeWallet.id,
|
|
153
|
-
externalWalletAddress: activeWallet.isExternal ? activeWallet.id : void 0,
|
|
154
|
-
shouldOpenPopup: isPopup,
|
|
155
|
-
params: {
|
|
156
|
-
type: tab === EnabledFlow.BUY ? OnRampPurchaseType.BUY : OnRampPurchaseType.SELL,
|
|
157
|
-
walletType: activeWallet.type,
|
|
158
|
-
provider: id,
|
|
159
|
-
networks: allowedNetworks,
|
|
160
|
-
assets: allowedAssets,
|
|
161
|
-
defaultNetwork: onRampConfig.defaultOnRampNetwork,
|
|
162
|
-
defaultAsset: onRampConfig.defaultOnRampAsset,
|
|
163
|
-
fiatQuantity: (_a = onRampConfig.defaultBuyAmount) == null ? void 0 : _a[0],
|
|
164
|
-
testMode: onRampConfig.testMode
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
setOnRampPurchase(__spreadProps(__spreadValues({}, newOnRampPurchase), { fiat: "USD" }));
|
|
168
|
-
!isPopup && setStep(ModalStep.ADD_FUNDS_AWAITING);
|
|
169
|
-
})
|
|
170
|
-
},
|
|
171
|
-
id
|
|
172
|
-
)
|
|
173
|
-
},
|
|
174
|
-
id
|
|
175
|
-
) : null;
|
|
176
|
-
}) })
|
|
177
|
-
] })
|
|
178
|
-
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
179
|
-
/* @__PURE__ */ jsx(InnerStepContainer, { children: /* @__PURE__ */ jsxs(FilledDisabledInput, { noAutoDisable: true, readonly: true, placeholder: address, children: [
|
|
180
|
-
/* @__PURE__ */ jsx(CpslIdenticon, { slot: "start", size: "32px", hash: para.getIdenticonHash(activeWallet.id, activeWallet.type) }),
|
|
181
|
-
/* @__PURE__ */ jsx(CpslButton, { slot: "end", variant: "ghost", onClick: onCopy, children: /* @__PURE__ */ jsx(CpslIcon, { icon: isCopied ? "check" : "copy" }) })
|
|
182
|
-
] }, address) }),
|
|
183
|
-
!isMobile() && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
184
|
-
/* @__PURE__ */ jsx(CpslDivider, { children: "or" }),
|
|
185
|
-
/* @__PURE__ */ jsxs(InnerStepContainer, { children: [
|
|
186
|
-
/* @__PURE__ */ jsx(QRContainer, { children: !address ? /* @__PURE__ */ jsx(CpslSpinner, { size: 100 }) : /* @__PURE__ */ jsx(CpslQrCode, { url: address }, address) }),
|
|
187
|
-
/* @__PURE__ */ jsx(CpslText, { weight: "semiBold", color: "secondary", children: "Scan with your crypto wallet" })
|
|
188
|
-
] })
|
|
189
|
-
] }),
|
|
190
|
-
/* @__PURE__ */ jsxs(InnerStepContainer, { children: [
|
|
191
|
-
/* @__PURE__ */ jsxs(CenteredText, { weight: "semiBold", children: [
|
|
192
|
-
!!onRampConfig.allowedAssets && allowedNetworks.length > 0 || hideWallets ? appName != null ? appName : "This App" : "This Wallet",
|
|
193
|
-
" ",
|
|
194
|
-
"Only Supports:"
|
|
195
|
-
] }),
|
|
196
|
-
/* @__PURE__ */ jsx(CenteredText, { weight: "medium", color: "secondary", children: !!onRampConfig.allowedAssets && allowedNetworks.length > 0 ? formatNetworkList(allowedNetworks) : GENERIC_WALLET[activeWallet.type] })
|
|
197
|
-
] })
|
|
198
|
-
] }) })
|
|
199
|
-
] });
|
|
200
|
-
};
|
|
201
|
-
const SpinnerContainer = styled(StepContainer)`
|
|
202
|
-
margin: 50% 0;
|
|
203
|
-
`;
|
|
204
|
-
const $InnerStepContainer = styled(InnerStepContainer)`
|
|
205
|
-
position: relative;
|
|
206
|
-
min-height: 270px;
|
|
207
|
-
`;
|
|
208
|
-
const NoProviders = styled(CpslText)`
|
|
209
|
-
width: 100%;
|
|
210
|
-
text-align: center;
|
|
211
|
-
visibility: ${({ isHidden }) => isHidden ? "hidden" : "visible"};
|
|
212
|
-
position: absolute;
|
|
213
|
-
top: 0;
|
|
214
|
-
left: 0;
|
|
215
|
-
right: 0;
|
|
216
|
-
transition: visibility 0.2s;
|
|
217
|
-
`;
|
|
218
|
-
export {
|
|
219
|
-
AddFunds
|
|
220
|
-
};
|