@getpara/react-sdk 2.0.0-dev.2 → 2.0.0-dev.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/cli/cli.mjs +22 -7
- package/dist/index.d.ts +0 -1
- package/dist/index.js +6 -7058
- package/dist/modal/ParaModal.js +301 -0
- package/dist/modal/components/Account/Account.js +148 -0
- package/dist/modal/components/Account/AccountProfile.d.ts +1 -0
- package/dist/modal/components/Account/AccountProfile.js +168 -0
- package/dist/modal/components/Account/AccountProfileLink.d.ts +1 -0
- package/dist/modal/components/Account/AccountProfileLink.js +206 -0
- package/dist/modal/components/Account/AccountProfileLinkOptions.d.ts +1 -0
- package/dist/modal/components/Account/AccountProfileLinkOptions.js +111 -0
- package/dist/modal/components/Account/AccountProfileUnlink.d.ts +1 -0
- package/dist/modal/components/Account/AccountProfileUnlink.js +47 -0
- package/dist/modal/components/AddFunds/AddFunds.d.ts +0 -2
- package/dist/modal/components/AddFunds/AddFunds.js +69 -0
- package/dist/modal/components/AddFunds/AddFundsAsset.d.ts +1 -0
- package/dist/modal/components/AddFunds/AddFundsAsset.js +125 -0
- package/dist/modal/components/AddFunds/AddFundsAwaiting.js +78 -0
- package/dist/modal/components/AddFunds/AddFundsContext.d.ts +31 -0
- package/dist/modal/components/AddFunds/AddFundsContext.js +160 -0
- package/dist/modal/components/AddFunds/AddFundsDone.js +49 -0
- package/dist/modal/components/AddFunds/AddFundsProvider.d.ts +1 -0
- package/dist/modal/components/AddFunds/AddFundsProvider.js +109 -0
- package/dist/modal/components/AddFunds/AddFundsReceive.d.ts +1 -0
- package/dist/modal/components/AddFunds/AddFundsReceive.js +83 -0
- package/dist/modal/components/AddFunds/AddFundsSettings.d.ts +1 -0
- package/dist/modal/components/AddFunds/AddFundsSettings.js +237 -0
- package/dist/{MoonPayEmbed-Q2HP2BFI.js → modal/components/AddFunds/MoonPayEmbed.js} +1 -3
- package/dist/modal/components/AddFunds/common.d.ts +19 -0
- package/dist/modal/components/AddFunds/common.js +24 -0
- package/dist/modal/components/AddFunds/index.js +4 -0
- package/dist/modal/components/AuthInput/AuthInput.d.ts +17 -3
- package/dist/modal/components/AuthInput/AuthInput.js +277 -0
- package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +33 -0
- package/dist/modal/components/AuthInput/phoneMasks.js +253 -0
- package/dist/modal/components/AuthMainStep/AuthMainStep.d.ts +4 -3
- package/dist/modal/components/AuthMainStep/AuthMainStep.js +50 -0
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.d.ts +4 -3
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +164 -0
- package/dist/modal/components/AuthOptions/AuthOptions.d.ts +4 -3
- package/dist/modal/components/AuthOptions/AuthOptions.js +85 -0
- package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +18 -0
- package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.js +10 -0
- package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +18 -0
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.d.ts +5 -1
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +49 -0
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.d.ts +1 -1
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +62 -0
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.d.ts +1 -1
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +48 -0
- package/dist/modal/components/Body/AnimatedHeightWrapper.js +29 -0
- package/dist/modal/components/Body/Body.d.ts +4 -3
- package/dist/modal/components/Body/Body.js +350 -0
- package/dist/modal/components/ChainSwitch/ChainSwitch.js +95 -0
- package/dist/modal/components/ChainSwitch/config.js +17 -0
- package/dist/modal/components/Controls/Controls.js +78 -0
- package/dist/modal/components/Controls/Selects.js +173 -0
- package/dist/modal/components/ExternalWalletNetworkSelectStep/ExternalWalletNetworkSelectStep.d.ts +1 -0
- package/dist/modal/components/ExternalWalletNetworkSelectStep/ExternalWalletNetworkSelectStep.js +75 -0
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +7 -0
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +175 -0
- package/dist/modal/components/ExternalWalletStep/config.js +17 -0
- package/dist/modal/components/ExternalWalletVerificationStep/ExternalWalletVerificationStep.js +39 -0
- package/dist/modal/components/ExternalWallets/ExternalWallets.js +184 -0
- package/dist/modal/components/Footer/Footer.js +95 -0
- package/dist/modal/components/Header/Header.js +43 -0
- package/dist/modal/components/Header/hooks/useStepTitle.js +61 -0
- package/dist/modal/components/Hero/Hero.js +116 -0
- package/dist/modal/components/IFrameStep/IFrameStep.js +59 -0
- package/dist/modal/components/LoginDoneStep/LoginDoneStep.d.ts +4 -0
- package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +44 -0
- package/dist/modal/components/ModalContent/ModalContent.d.ts +0 -4
- package/dist/modal/components/ModalContent/ModalContent.js +88 -0
- package/dist/modal/components/OAuth/FarcasterOAuthStep.d.ts +1 -0
- package/dist/modal/components/OAuth/FarcasterOAuthStep.js +31 -0
- package/dist/modal/components/OAuth/OAuth.d.ts +2 -2
- package/dist/modal/components/OAuth/OAuth.js +79 -0
- package/dist/modal/components/OAuth/TelegramOAuthStep.d.ts +7 -0
- package/dist/modal/components/OAuth/TelegramOAuthStep.js +74 -0
- package/dist/modal/components/OnRampComponents/AddingFunds.js +23 -0
- package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +77 -0
- package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +107 -0
- package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +132 -0
- package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +27 -0
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.d.ts +12 -1
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +160 -0
- package/dist/modal/components/Waiting/Waiting.js +17 -0
- package/dist/modal/components/WalletCard/PartnerIcon.js +34 -0
- package/dist/modal/components/WalletCard/WalletCard.d.ts +3 -3
- package/dist/modal/components/WalletCard/WalletCard.js +128 -0
- package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +83 -0
- package/dist/modal/components/common.d.ts +49 -13
- package/dist/modal/components/common.js +261 -0
- package/dist/modal/components/index.js +2 -0
- package/dist/modal/constants/constants.d.ts +10 -2
- package/dist/modal/constants/constants.js +142 -0
- package/dist/modal/constants/defaults.js +10 -0
- package/dist/modal/constants/oAuthLogos.d.ts +15 -6
- package/dist/modal/constants/oAuthLogos.js +158 -0
- package/dist/modal/constants/walletTypeConfig.d.ts +6 -0
- package/dist/modal/constants/walletTypeConfig.js +13 -0
- package/dist/modal/hooks/useGoBack.js +43 -0
- package/dist/modal/hooks/useTelegramLogin.d.ts +12 -0
- package/dist/modal/hooks/useTelegramLogin.js +65 -0
- package/dist/modal/index.d.ts +1 -1
- package/dist/modal/index.js +29 -0
- package/dist/modal/stores/index.d.ts +0 -1
- package/dist/modal/stores/index.js +2 -0
- package/dist/modal/stores/modal/actions.js +135 -0
- package/dist/modal/stores/modal/useModalStore.d.ts +17 -16
- package/dist/modal/stores/modal/useModalStore.js +73 -0
- package/dist/modal/types/commonTypes.js +1 -0
- package/dist/modal/types/modalProps.d.ts +15 -2
- package/dist/modal/types/modalProps.js +12 -0
- package/dist/modal/utils/authInputHelpers.d.ts +5 -0
- package/dist/modal/utils/authInputHelpers.js +41 -0
- package/dist/modal/utils/authLayoutHelpers.js +8 -0
- package/dist/modal/utils/countryCodes.js +45 -0
- package/dist/modal/utils/getMailtoLink.js +10 -0
- package/dist/modal/utils/getTileButtonFlex.js +20 -0
- package/dist/modal/utils/getWalletDisplayName.d.ts +5 -0
- package/dist/modal/utils/getWalletDisplayName.js +22 -0
- package/dist/modal/utils/isPasskeySupported.js +15 -0
- package/dist/modal/utils/openPopup.js +60 -0
- package/dist/modal/utils/routeMobileExternalWallet.js +31 -0
- package/dist/modal/utils/steps.d.ts +21 -2
- package/dist/modal/utils/steps.js +273 -0
- package/dist/modal/utils/stringFormatters.d.ts +1 -0
- package/dist/modal/utils/stringFormatters.js +19 -0
- package/dist/modal/utils/validateOnRampConfig.js +32 -0
- package/dist/package.json +6 -0
- package/dist/provider/ParaProvider.js +117 -0
- package/dist/provider/actions/getEmbeddedAccount.d.ts +26 -0
- package/dist/provider/actions/getEmbeddedAccount.js +52 -0
- package/dist/provider/actions/getWallet.d.ts +3 -3
- package/dist/provider/actions/getWallet.js +18 -0
- package/dist/provider/actions/index.d.ts +40 -18
- package/dist/provider/actions/index.js +79 -0
- package/dist/provider/actions/utils.d.ts +4 -3
- package/dist/provider/actions/utils.js +34 -0
- package/dist/provider/components/CosmosWalletWrapper.js +43 -0
- package/dist/provider/components/EvmWalletWrapper.js +43 -0
- package/dist/provider/components/ExternalWalletWrapper.js +140 -0
- package/dist/provider/components/SolanaWalletWrapper.js +44 -0
- package/dist/provider/external/getParaCosmosConnector.js +19 -0
- package/dist/provider/external/getParaCosmosLib.d.ts +4 -0
- package/dist/provider/external/getParaCosmosLib.js +16 -0
- package/dist/provider/external/getParaEvmConnector.js +19 -0
- package/dist/provider/external/getParaEvmLib.d.ts +4 -0
- package/dist/provider/external/getParaEvmLib.js +16 -0
- package/dist/provider/external/getParaSolanaConnector.js +19 -0
- package/dist/provider/external/getParaSolanaLib.d.ts +4 -0
- package/dist/provider/external/getParaSolanaLib.js +16 -0
- package/dist/provider/external/stubs/CosmosExternalWalletContextStub.d.ts +1 -11
- package/dist/provider/external/stubs/CosmosExternalWalletContextStub.js +8 -0
- package/dist/provider/external/stubs/EvmExternalWalletContextStub.d.ts +1 -2
- package/dist/provider/external/stubs/EvmExternalWalletContextStub.js +8 -0
- package/dist/provider/external/stubs/SolanaExternalWalletContextStub.d.ts +1 -7
- package/dist/provider/external/stubs/SolanaExternalWalletContextStub.js +8 -0
- package/dist/provider/hooks/index.js +4 -0
- package/dist/provider/hooks/mutations/core.d.ts +27 -0
- package/dist/provider/hooks/mutations/core.js +66 -0
- package/dist/provider/hooks/mutations/index.d.ts +3 -34
- package/dist/provider/hooks/mutations/index.js +9 -0
- package/dist/provider/hooks/mutations/useLinkAccount.d.ts +9 -0
- package/dist/provider/hooks/mutations/useLinkAccount.js +18 -0
- package/dist/provider/hooks/mutations/utils.d.ts +11 -3
- package/dist/provider/hooks/mutations/utils.js +90 -0
- package/dist/provider/hooks/queries/core.d.ts +4 -0
- package/dist/provider/hooks/queries/core.js +16 -0
- package/dist/provider/hooks/queries/index.d.ts +2 -0
- package/dist/provider/hooks/queries/index.js +11 -0
- package/dist/provider/hooks/queries/useAccount.d.ts +86 -7
- package/dist/provider/hooks/queries/useAccount.js +135 -0
- package/dist/provider/hooks/queries/useIsFullyLoggedIn.d.ts +5 -0
- package/dist/provider/hooks/queries/useIsFullyLoggedIn.js +24 -0
- package/dist/provider/hooks/queries/useWallet.d.ts +1 -1
- package/dist/provider/hooks/queries/useWallet.js +26 -0
- package/dist/provider/hooks/queries/useWalletBalance.d.ts +6 -0
- package/dist/provider/hooks/queries/useWalletBalance.js +55 -0
- package/dist/provider/hooks/queries/utils.d.ts +7 -0
- package/dist/provider/hooks/queries/utils.js +25 -0
- package/dist/provider/hooks/utils/index.js +10 -0
- package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +74 -0
- package/dist/provider/hooks/utils/useClient.d.ts +1 -1
- package/dist/provider/hooks/utils/useClient.js +10 -0
- package/dist/provider/hooks/utils/useEventListeners.d.ts +1 -1
- package/dist/provider/hooks/utils/useEventListeners.js +157 -0
- package/dist/provider/hooks/utils/useFormattedBiometricHints.d.ts +4 -0
- package/dist/provider/hooks/utils/useFormattedBiometricHints.js +27 -0
- package/dist/provider/hooks/utils/useInternalClient.js +10 -0
- package/dist/provider/hooks/utils/useModal.d.ts +4 -1
- package/dist/provider/hooks/utils/useModal.js +27 -0
- package/dist/provider/hooks/utils/useWalletState.d.ts +3 -3
- package/dist/provider/hooks/utils/useWalletState.js +48 -0
- package/dist/provider/index.d.ts +2 -0
- package/dist/provider/index.js +11 -0
- package/dist/provider/providers/AccountLinkProvider.d.ts +47 -0
- package/dist/provider/providers/AccountLinkProvider.js +452 -0
- package/dist/provider/providers/AuthProvider.d.ts +12 -6
- package/dist/provider/providers/AuthProvider.js +523 -0
- package/dist/provider/providers/CosmosExternalWalletProvider.js +66 -0
- package/dist/provider/providers/EvmExternalWalletProvider.js +74 -0
- package/dist/provider/providers/ExternalWalletProvider.d.ts +23 -43
- package/dist/provider/providers/ExternalWalletProvider.js +596 -0
- package/dist/provider/providers/SolanaExternalWalletProvider.js +66 -0
- package/dist/provider/stores/getters.d.ts +1 -1
- package/dist/provider/stores/getters.js +13 -0
- package/dist/provider/stores/setters.js +7 -0
- package/dist/provider/stores/slices/analytics.d.ts +3 -0
- package/dist/provider/stores/slices/analytics.js +9 -0
- package/dist/provider/stores/slices/client.js +9 -0
- package/dist/provider/stores/slices/config.js +9 -0
- package/dist/provider/stores/slices/externalWallets.js +46 -0
- package/dist/provider/stores/slices/index.d.ts +1 -0
- package/dist/provider/stores/slices/index.js +6 -0
- package/dist/provider/stores/slices/modal.js +18 -0
- package/dist/provider/stores/slices/wallet.js +13 -0
- package/dist/provider/stores/types.d.ts +19 -5
- package/dist/provider/stores/types.js +1 -0
- package/dist/provider/stores/useStore.js +34 -0
- package/dist/provider/types/externalWalletProviders.js +1 -0
- package/dist/provider/types/provider.d.ts +23 -4
- package/dist/provider/types/provider.js +1 -0
- package/dist/provider/types/query.js +1 -0
- package/dist/provider/types/utils.d.ts +28 -5
- package/dist/provider/types/utils.js +1 -0
- package/dist/provider/utils/constants.d.ts +5 -0
- package/dist/provider/utils/constants.js +10 -0
- package/dist/provider/utils/paraConfigTypeGuards.js +13 -0
- package/dist/provider/utils/renameMutations.d.ts +2 -2
- package/dist/provider/utils/renameMutations.js +18 -0
- package/package.json +40 -39
- 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/index.js.br +0 -0
- package/dist/index.js.gz +0 -0
- package/dist/modal/components/StripeComponents/StripeComponents.d.ts +0 -16
- package/dist/modal/hooks/useCreateAccount.d.ts +0 -4
- package/dist/modal/stores/userInfo/actions.d.ts +0 -3
- package/dist/modal/stores/userInfo/useUserInfoStore.d.ts +0 -19
- package/dist/provider/actions/checkIfUserExists.d.ts +0 -4
- package/dist/provider/actions/createUser.d.ts +0 -4
- package/dist/provider/actions/getAccount.d.ts +0 -10
- package/dist/provider/actions/initiateLogin.d.ts +0 -4
- package/dist/provider/actions/keepSessionAlive.d.ts +0 -2
- package/dist/provider/actions/logout.d.ts +0 -5
- package/dist/provider/actions/signMessage.d.ts +0 -8
- package/dist/provider/actions/signTransaction.d.ts +0 -8
- package/dist/provider/actions/waitForAccountCreation.d.ts +0 -5
- package/dist/provider/actions/waitForLoginAndSetup.d.ts +0 -6
- package/dist/provider/actions/waitForPasskeyAndCreateWallet.d.ts +0 -2
- package/dist/provider/hooks/mutations/useCheckIfUserExists.d.ts +0 -13
- package/dist/provider/hooks/mutations/useCreateUser.d.ts +0 -13
- package/dist/provider/hooks/mutations/useInitiateLogin.d.ts +0 -14
- package/dist/provider/hooks/mutations/useKeepSessionAlive.d.ts +0 -12
- package/dist/provider/hooks/mutations/useLogout.d.ts +0 -13
- package/dist/provider/hooks/mutations/useSignMessage.d.ts +0 -15
- package/dist/provider/hooks/mutations/useSignTransaction.d.ts +0 -15
- package/dist/provider/hooks/mutations/useWaitForAccountCreation.d.ts +0 -13
- package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.d.ts +0 -14
- package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.d.ts +0 -13
- /package/dist/modal/{components/AuthInput → utils}/countryCodes.d.ts +0 -0
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async,
|
|
4
|
+
__objRest,
|
|
5
|
+
__spreadProps,
|
|
6
|
+
__spreadValues
|
|
7
|
+
} from "../chunk-MMUBH76A.js";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
import { CpslAuthModal, defineCustomElements, generateTheme } from "@getpara/react-components";
|
|
10
|
+
import { ModalContent } from "./components/index.js";
|
|
11
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
12
|
+
import { useModalStore } from "./stores/index.js";
|
|
13
|
+
import { ModalStep, RESET_TO_ACCOUNT_STEPS, RESET_TO_AUTH_STEPS } from "./utils/steps.js";
|
|
14
|
+
import { AuthLayout } from "./types/modalProps.js";
|
|
15
|
+
import { DEFAULTS } from "./constants/defaults.js";
|
|
16
|
+
import { useGoBack } from "./hooks/useGoBack.js";
|
|
17
|
+
import { safeStyled } from "@getpara/react-common";
|
|
18
|
+
import { hasEmbeddedAuth, hasExternalWallet } from "./utils/authLayoutHelpers.js";
|
|
19
|
+
import { useAccount, useModal, useWalletState } from "../provider/index.js";
|
|
20
|
+
import { useInternalClient } from "../provider/hooks/utils/useInternalClient.js";
|
|
21
|
+
import { useExternalWallets } from "../provider/providers/ExternalWalletProvider.js";
|
|
22
|
+
import { useStore } from "../provider/stores/useStore.js";
|
|
23
|
+
import parsePhoneNumberFromString from "libphonenumber-js";
|
|
24
|
+
import { useAuthActions } from "../provider/providers/AuthProvider.js";
|
|
25
|
+
import { validateInput } from "./utils/authInputHelpers.js";
|
|
26
|
+
import { SDK_VERSION } from "./constants/constants.js";
|
|
27
|
+
defineCustomElements();
|
|
28
|
+
const ParaModal = forwardRef((props, ref) => {
|
|
29
|
+
const storedModalConfig = useStore((state) => state.modalConfig);
|
|
30
|
+
const openedToStep = useStore((state) => state.openedToStep);
|
|
31
|
+
const modalContentRef = useRef(null);
|
|
32
|
+
const refs = useModalStore((state) => state.refs);
|
|
33
|
+
const flow = useModalStore((state) => state.flow);
|
|
34
|
+
const currentStep = useModalStore((state) => state.step);
|
|
35
|
+
const setAuthState = useModalStore((state) => state.setAuthState);
|
|
36
|
+
const setOnModalStepChange = useModalStore((state) => state.setOnModalStepChange);
|
|
37
|
+
const setStep = useModalStore((state) => state.setStep);
|
|
38
|
+
const hasPreviousStep = useModalStore((state) => state.hasPreviousStep());
|
|
39
|
+
const setFlow = useModalStore((state) => state.setFlow);
|
|
40
|
+
const goBack = useGoBack();
|
|
41
|
+
const setAuthLayout = useModalStore((state) => state.setAuthLayout);
|
|
42
|
+
const storedAuthLayout = useModalStore((state) => state.authLayout);
|
|
43
|
+
const resetModalState = useModalStore((state) => state.resetState);
|
|
44
|
+
const setRecoveryShare = useModalStore((state) => state.setRecoveryShare);
|
|
45
|
+
const { disconnectExternalWallet } = useExternalWallets();
|
|
46
|
+
const { isOpen: storedIsOpen, closeModal } = useModal();
|
|
47
|
+
const para = useInternalClient();
|
|
48
|
+
const { setSelectedWallet, updateSelectedWallet } = useWalletState();
|
|
49
|
+
const setAuthStepRoute = useModalStore((state) => state.setAuthStepRoute);
|
|
50
|
+
const { signUpOrLogIn, isCreateGuestWalletsPending } = useAuthActions();
|
|
51
|
+
const { isLoading: isAccountLoading, isConnected } = useAccount();
|
|
52
|
+
const [isModalMounted, setIsModalMounted] = useState(false);
|
|
53
|
+
const externalWallets = useStore((state) => state.externalWallets);
|
|
54
|
+
const providerProps = useStore((state) => state.providerProps);
|
|
55
|
+
const setAccountLinkOptions = useModalStore((state) => state.setAccountLinkOptions);
|
|
56
|
+
const isInitialized = useRef(false);
|
|
57
|
+
const _a = __spreadValues(__spreadValues({}, storedModalConfig), props), {
|
|
58
|
+
isOpen: configIsOpen,
|
|
59
|
+
theme,
|
|
60
|
+
disableEmailLogin = false,
|
|
61
|
+
disablePhoneLogin = false,
|
|
62
|
+
isGuestModeEnabled = false,
|
|
63
|
+
oAuthMethods = ["GOOGLE", "TWITTER"],
|
|
64
|
+
bareModal = false,
|
|
65
|
+
className,
|
|
66
|
+
currentStepOverride,
|
|
67
|
+
authLayout = [AuthLayout.AUTH_FULL, AuthLayout.EXTERNAL_FULL],
|
|
68
|
+
embeddedModal,
|
|
69
|
+
onModalStepChange,
|
|
70
|
+
onClose,
|
|
71
|
+
defaultAuthIdentifier,
|
|
72
|
+
supportedAccountLinks: propsSupportedAccountLinks
|
|
73
|
+
} = _a, rest = __objRest(_a, [
|
|
74
|
+
"isOpen",
|
|
75
|
+
"theme",
|
|
76
|
+
"disableEmailLogin",
|
|
77
|
+
"disablePhoneLogin",
|
|
78
|
+
"isGuestModeEnabled",
|
|
79
|
+
"oAuthMethods",
|
|
80
|
+
"bareModal",
|
|
81
|
+
"className",
|
|
82
|
+
"currentStepOverride",
|
|
83
|
+
"authLayout",
|
|
84
|
+
"embeddedModal",
|
|
85
|
+
"onModalStepChange",
|
|
86
|
+
"onClose",
|
|
87
|
+
"defaultAuthIdentifier",
|
|
88
|
+
"supportedAccountLinks"
|
|
89
|
+
]);
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
const trackAnalytics = () => __async(void 0, null, function* () {
|
|
92
|
+
try {
|
|
93
|
+
yield para.ctx.client.trackReactSdkAnalytics({
|
|
94
|
+
props: __spreadValues(__spreadProps(__spreadValues({}, providerProps), {
|
|
95
|
+
theme,
|
|
96
|
+
disableEmailLogin,
|
|
97
|
+
disablePhoneLogin,
|
|
98
|
+
isGuestModeEnabled,
|
|
99
|
+
oAuthMethods,
|
|
100
|
+
bareModal,
|
|
101
|
+
className,
|
|
102
|
+
currentStepOverride,
|
|
103
|
+
authLayout,
|
|
104
|
+
embeddedModal,
|
|
105
|
+
onModalStepChange,
|
|
106
|
+
onClose,
|
|
107
|
+
defaultAuthIdentifier
|
|
108
|
+
}), rest),
|
|
109
|
+
reactSdkVersion: SDK_VERSION
|
|
110
|
+
});
|
|
111
|
+
} catch (_) {
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
trackAnalytics();
|
|
115
|
+
}, []);
|
|
116
|
+
const isOpen = configIsOpen != null ? configIsOpen : storedIsOpen;
|
|
117
|
+
useImperativeHandle(ref, () => {
|
|
118
|
+
return {
|
|
119
|
+
goBack() {
|
|
120
|
+
goBack();
|
|
121
|
+
},
|
|
122
|
+
canGoBack() {
|
|
123
|
+
return hasPreviousStep;
|
|
124
|
+
},
|
|
125
|
+
currentStep() {
|
|
126
|
+
return currentStep;
|
|
127
|
+
},
|
|
128
|
+
handleModalClose() {
|
|
129
|
+
var _a2;
|
|
130
|
+
(_a2 = modalContentRef == null ? void 0 : modalContentRef.current) == null ? void 0 : _a2.handleModalClose();
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}, [hasPreviousStep, currentStep]);
|
|
134
|
+
const initModal = (shouldAutoLogin) => __async(void 0, null, function* () {
|
|
135
|
+
var _a2;
|
|
136
|
+
if (!para.isReady) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const isAccount = isConnected, isGuest = isAccount && para.isGuestMode || isCreateGuestWalletsPending;
|
|
140
|
+
switch (true) {
|
|
141
|
+
case !!currentStepOverride:
|
|
142
|
+
setStep(ModalStep[currentStepOverride.toUpperCase()]);
|
|
143
|
+
break;
|
|
144
|
+
case isGuest:
|
|
145
|
+
setFlow("guest");
|
|
146
|
+
setStep(isCreateGuestWalletsPending ? ModalStep.AWAITING_GUEST_WALLET_CREATION : ModalStep.ACCOUNT_MAIN);
|
|
147
|
+
break;
|
|
148
|
+
case isAccount:
|
|
149
|
+
setFlow("account");
|
|
150
|
+
if (!openedToStep.current) {
|
|
151
|
+
setStep(ModalStep.ACCOUNT_MAIN);
|
|
152
|
+
}
|
|
153
|
+
break;
|
|
154
|
+
default:
|
|
155
|
+
if (currentStep !== ModalStep.AUTH_MAIN && currentStep !== ModalStep.SECRET) {
|
|
156
|
+
setFlow(void 0);
|
|
157
|
+
setStep(para.isTelegram ? ModalStep.TELEGRAM_OAUTH : ModalStep.AUTH_MAIN);
|
|
158
|
+
setAuthState();
|
|
159
|
+
setAuthStepRoute();
|
|
160
|
+
}
|
|
161
|
+
yield disconnectExternalWallet();
|
|
162
|
+
setSelectedWallet({ id: void 0, type: void 0 });
|
|
163
|
+
if (shouldAutoLogin) {
|
|
164
|
+
if (defaultAuthIdentifier && ((_a2 = para.authInfo) == null ? void 0 : _a2.identifier) !== defaultAuthIdentifier) {
|
|
165
|
+
const number = parsePhoneNumberFromString(defaultAuthIdentifier);
|
|
166
|
+
try {
|
|
167
|
+
const auth = validateInput(
|
|
168
|
+
number ? number.nationalNumber : defaultAuthIdentifier,
|
|
169
|
+
(number == null ? void 0 : number.countryCallingCode) ? `+${number == null ? void 0 : number.countryCallingCode}` : void 0,
|
|
170
|
+
number ? "phone" : "email"
|
|
171
|
+
);
|
|
172
|
+
para.setAuth(number ? { phone: defaultAuthIdentifier } : { email: defaultAuthIdentifier });
|
|
173
|
+
signUpOrLogIn(auth);
|
|
174
|
+
} catch (err) {
|
|
175
|
+
console.error("invalid user identifier:", err.message);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
useEffect(() => {
|
|
183
|
+
if ((para == null ? void 0 : para.isReady) && isOpen && !isAccountLoading && !isInitialized.current) {
|
|
184
|
+
initModal(isOpen);
|
|
185
|
+
isInitialized.current = true;
|
|
186
|
+
}
|
|
187
|
+
if ((para == null ? void 0 : para.isReady) && !isOpen && isInitialized.current) {
|
|
188
|
+
initModal();
|
|
189
|
+
isInitialized.current = false;
|
|
190
|
+
}
|
|
191
|
+
}, [para == null ? void 0 : para.isReady, isOpen, isAccountLoading]);
|
|
192
|
+
useEffect(() => {
|
|
193
|
+
let _authLayout = authLayout;
|
|
194
|
+
if (!(externalWallets == null ? void 0 : externalWallets.length) && hasExternalWallet(authLayout)) {
|
|
195
|
+
_authLayout = _authLayout.filter((l) => !l.includes("EXTERNAL"));
|
|
196
|
+
}
|
|
197
|
+
if (disableEmailLogin && disablePhoneLogin && !(oAuthMethods == null ? void 0 : oAuthMethods.length) && hasEmbeddedAuth(authLayout)) {
|
|
198
|
+
_authLayout = _authLayout.filter((l) => !l.includes("AUTH"));
|
|
199
|
+
}
|
|
200
|
+
if (JSON.stringify(storedAuthLayout) !== JSON.stringify(_authLayout)) {
|
|
201
|
+
setAuthLayout(_authLayout);
|
|
202
|
+
}
|
|
203
|
+
}, [disableEmailLogin, disablePhoneLogin, oAuthMethods, externalWallets, authLayout, storedAuthLayout]);
|
|
204
|
+
useEffect(() => {
|
|
205
|
+
if (theme) {
|
|
206
|
+
generateTheme(theme);
|
|
207
|
+
}
|
|
208
|
+
}, [theme]);
|
|
209
|
+
useEffect(() => {
|
|
210
|
+
setOnModalStepChange(onModalStepChange);
|
|
211
|
+
}, [onModalStepChange]);
|
|
212
|
+
useEffect(() => {
|
|
213
|
+
updateSelectedWallet();
|
|
214
|
+
}, [para]);
|
|
215
|
+
useEffect(() => {
|
|
216
|
+
if (bareModal && !isAccountLoading && !isConnected && !["signup", "login"].includes(flow != null ? flow : "") && refs.currentStep.current !== ModalStep.AUTH_MAIN) {
|
|
217
|
+
setStep(ModalStep.AUTH_MAIN);
|
|
218
|
+
}
|
|
219
|
+
}, [bareModal, flow, isConnected, isAccountLoading]);
|
|
220
|
+
useEffect(() => {
|
|
221
|
+
setAccountLinkOptions(propsSupportedAccountLinks != null ? propsSupportedAccountLinks : para == null ? void 0 : para.supportedAccountLinks);
|
|
222
|
+
}, [propsSupportedAccountLinks, para == null ? void 0 : para.supportedAccountLinks]);
|
|
223
|
+
const handleClose = () => {
|
|
224
|
+
closeModal();
|
|
225
|
+
onClose == null ? void 0 : onClose();
|
|
226
|
+
};
|
|
227
|
+
const handleModalEntering = () => {
|
|
228
|
+
setIsModalMounted(true);
|
|
229
|
+
};
|
|
230
|
+
const handleModalExited = () => __async(void 0, null, function* () {
|
|
231
|
+
openedToStep.current = null;
|
|
232
|
+
setIsModalMounted(false);
|
|
233
|
+
if (RESET_TO_AUTH_STEPS.includes(currentStep)) {
|
|
234
|
+
resetModalState();
|
|
235
|
+
setRecoveryShare(null);
|
|
236
|
+
} else if (RESET_TO_ACCOUNT_STEPS.includes(currentStep)) {
|
|
237
|
+
setStep(ModalStep.LOGIN_DONE);
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
if (!para) {
|
|
241
|
+
console.error("A Para instance is required.");
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
if (!(storedAuthLayout == null ? void 0 : storedAuthLayout.length)) {
|
|
245
|
+
const hasExternalWalletError = !(externalWallets == null ? void 0 : externalWallets.length) && hasExternalWallet(authLayout);
|
|
246
|
+
const hasEmbeddedWalletError = disableEmailLogin && disablePhoneLogin && !(oAuthMethods == null ? void 0 : oAuthMethods.length) && hasEmbeddedAuth(authLayout);
|
|
247
|
+
if (hasExternalWalletError || hasEmbeddedWalletError) {
|
|
248
|
+
if (hasExternalWalletError) {
|
|
249
|
+
console.error("At least one external wallet must be provided if external wallet auth is enabled.");
|
|
250
|
+
}
|
|
251
|
+
if (hasEmbeddedWalletError) {
|
|
252
|
+
console.error(
|
|
253
|
+
"At least one login method (email, phone or OAuth) must be provided if embedded wallet auth is enabled."
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
} else {
|
|
257
|
+
console.error("At least one auth layout selection is required.");
|
|
258
|
+
}
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
return /* @__PURE__ */ jsx(
|
|
262
|
+
StyledAuthModal,
|
|
263
|
+
{
|
|
264
|
+
enterTransitionDuration: DEFAULTS.ANIMATION_DURATION,
|
|
265
|
+
exitTransitionDuration: DEFAULTS.ANIMATION_DURATION,
|
|
266
|
+
open: isOpen,
|
|
267
|
+
onCpslModalExited: handleModalExited,
|
|
268
|
+
onCpslModalEntering: handleModalEntering,
|
|
269
|
+
onCpslModalRequestClose: handleClose,
|
|
270
|
+
noOverlay: bareModal,
|
|
271
|
+
className,
|
|
272
|
+
"data-testid": "modal",
|
|
273
|
+
$embeddedModal: !!embeddedModal,
|
|
274
|
+
children: isModalMounted && ((embeddedModal || bareModal) && isInitialized.current || !embeddedModal && !bareModal) && /* @__PURE__ */ jsx(
|
|
275
|
+
ModalContent,
|
|
276
|
+
__spreadValues({
|
|
277
|
+
oAuthMethods,
|
|
278
|
+
disableEmailLogin,
|
|
279
|
+
disablePhoneLogin,
|
|
280
|
+
isGuestModeEnabled,
|
|
281
|
+
onClose: handleClose
|
|
282
|
+
}, rest)
|
|
283
|
+
)
|
|
284
|
+
}
|
|
285
|
+
);
|
|
286
|
+
});
|
|
287
|
+
const StyledAuthModal = safeStyled(CpslAuthModal)`
|
|
288
|
+
${({ $embeddedModal }) => $embeddedModal && `
|
|
289
|
+
&::part(modal-body-card) {
|
|
290
|
+
--card-box-shadow: none;
|
|
291
|
+
--card-border-width: 0px;
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
&::part(modal-footer) {
|
|
295
|
+
--card-box-shadow: none;
|
|
296
|
+
--card-border-width: 0px;
|
|
297
|
+
};`}
|
|
298
|
+
`;
|
|
299
|
+
export {
|
|
300
|
+
ParaModal
|
|
301
|
+
};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { safeStyled } from "@getpara/react-common";
|
|
7
|
+
import { InnerStepContainer, StepContainer, StyledCpslTileButton } from "../common.js";
|
|
8
|
+
import { CpslButton, CpslIcon, CpslSpinner, CpslText } from "@getpara/react-components";
|
|
9
|
+
import { OnRampStep, useModalStore } from "../../stores/index.js";
|
|
10
|
+
import { useEffect, useState } from "react";
|
|
11
|
+
import { ModalStep } from "../../utils/steps.js";
|
|
12
|
+
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
13
|
+
import { useExternalWallets } from "../../../provider/providers/ExternalWalletProvider.js";
|
|
14
|
+
import { useStore } from "../../../provider/stores/useStore.js";
|
|
15
|
+
import { formatBalanceString } from "../../utils/stringFormatters.js";
|
|
16
|
+
import { useAccount, useWalletBalance } from "../../../provider/index.js";
|
|
17
|
+
import { EnabledFlow } from "@getpara/web-sdk";
|
|
18
|
+
import { useAccountLinking } from "../../../provider/providers/AccountLinkProvider.js";
|
|
19
|
+
const Account = ({ onClose }) => {
|
|
20
|
+
const onRampConfig = useModalStore((state) => state.onRampConfig);
|
|
21
|
+
const setStep = useModalStore((state) => state.setStep);
|
|
22
|
+
const setFlow = useModalStore((state) => state.setFlow);
|
|
23
|
+
const setGuestAddFundsTab = useModalStore((state) => state.setGuestAddFundsTab);
|
|
24
|
+
const setOnRampStep = useModalStore((state) => state.setOnRampStep);
|
|
25
|
+
const hideWallets = useStore((state) => {
|
|
26
|
+
var _a;
|
|
27
|
+
return (_a = state.modalConfig) == null ? void 0 : _a.hideWallets;
|
|
28
|
+
});
|
|
29
|
+
const { disconnectExternalWallet } = useExternalWallets();
|
|
30
|
+
const para = useInternalClient();
|
|
31
|
+
const { embedded } = useAccount();
|
|
32
|
+
const { data: balance, isLoading: isBalanceLoading } = useWalletBalance();
|
|
33
|
+
const { isEnabled } = useAccountLinking();
|
|
34
|
+
const [isDisconnecting, setIsDisconnecting] = useState(false);
|
|
35
|
+
const isGuestMode = embedded.isConnected && embedded.isGuestMode;
|
|
36
|
+
const cantBuyAndWithdraw = (para.externalWalletConnectionType === "CONNECTION_ONLY" || para.externalWalletConnectionType === "VERIFICATION") && !para.userId;
|
|
37
|
+
const isOnRampLoaded = !!onRampConfig;
|
|
38
|
+
const handleBuyClick = () => {
|
|
39
|
+
if (isGuestMode) {
|
|
40
|
+
if (onRampConfig == null ? void 0 : onRampConfig.isReceiveEnabled) {
|
|
41
|
+
setStep(ModalStep.ADD_FUNDS_RECEIVE);
|
|
42
|
+
} else {
|
|
43
|
+
setGuestAddFundsTab(EnabledFlow.BUY);
|
|
44
|
+
setStep(ModalStep.AUTH_GUEST_SIGNUP);
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
setOnRampStep(OnRampStep.SETTINGS);
|
|
48
|
+
setStep(ModalStep.ADD_FUNDS_BUY);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const handleSellClick = () => {
|
|
52
|
+
if (isGuestMode) {
|
|
53
|
+
setGuestAddFundsTab(EnabledFlow.WITHDRAW);
|
|
54
|
+
setStep(ModalStep.AUTH_GUEST_SIGNUP);
|
|
55
|
+
} else {
|
|
56
|
+
setOnRampStep(OnRampStep.SETTINGS);
|
|
57
|
+
setStep(ModalStep.ADD_FUNDS_WITHDRAW);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const handleProfileClick = () => {
|
|
61
|
+
setStep(ModalStep.ACCOUNT_PROFILE);
|
|
62
|
+
};
|
|
63
|
+
const handleDisconnectClick = () => __async(void 0, null, function* () {
|
|
64
|
+
setIsDisconnecting(true);
|
|
65
|
+
yield para.logout();
|
|
66
|
+
yield disconnectExternalWallet();
|
|
67
|
+
onClose();
|
|
68
|
+
setStep(ModalStep.AUTH_MAIN);
|
|
69
|
+
setFlow(void 0);
|
|
70
|
+
setIsDisconnecting(false);
|
|
71
|
+
});
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
setGuestAddFundsTab();
|
|
74
|
+
}, []);
|
|
75
|
+
return /* @__PURE__ */ jsx(StepContainer, { $wide: true, children: /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
|
|
76
|
+
isBalanceLoading ? /* @__PURE__ */ jsx(BalanceContainer, { children: /* @__PURE__ */ jsx(CpslSpinner, { size: 39 }) }) : balance !== void 0 && balance !== null && /* @__PURE__ */ jsx(BalanceContainer, { children: /* @__PURE__ */ jsx(CpslText, { variant: "headingS", weight: "medium", children: formatBalanceString(balance) }) }),
|
|
77
|
+
isGuestMode && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
78
|
+
balance && parseFloat(balance) > 0 && /* @__PURE__ */ jsxs(Alert, { children: [
|
|
79
|
+
/* @__PURE__ */ jsx(CpslIcon, { icon: "alertTriangle", size: "24px", style: { color: "var(--cpsl-color-utility-yellow)" } }),
|
|
80
|
+
"You've funded this account - complete account setup to maintain access."
|
|
81
|
+
] }),
|
|
82
|
+
/* @__PURE__ */ jsxs(
|
|
83
|
+
CpslButton,
|
|
84
|
+
{
|
|
85
|
+
fullWidth: true,
|
|
86
|
+
variant: "primary",
|
|
87
|
+
onClick: () => {
|
|
88
|
+
setStep(ModalStep.AUTH_GUEST_SIGNUP);
|
|
89
|
+
},
|
|
90
|
+
children: [
|
|
91
|
+
/* @__PURE__ */ jsx(CpslIcon, { icon: "stars02" }),
|
|
92
|
+
"Complete Account Setup"
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
] }),
|
|
97
|
+
/* @__PURE__ */ jsx(ButtonContainer, { children: isOnRampLoaded ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
98
|
+
onRampConfig.isBuyEnabled && !cantBuyAndWithdraw && /* @__PURE__ */ jsx(OptionButton, { icon: "creditCard", onClick: handleBuyClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Receive" }) }),
|
|
99
|
+
onRampConfig.isWithdrawEnabled && !cantBuyAndWithdraw && /* @__PURE__ */ jsx(OptionButton, { icon: "arrowCircleBrokenDownLeft", onClick: handleSellClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Withdraw" }) }),
|
|
100
|
+
/* @__PURE__ */ jsx(OptionButton, { icon: "user", onClick: handleProfileClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: isEnabled ? "Profile" : "Settings" }) })
|
|
101
|
+
] }) : /* @__PURE__ */ jsx(CpslSpinner, {}) }),
|
|
102
|
+
!isGuestMode && /* @__PURE__ */ jsx(DisconnectButton, { variant: "destructive", fullWidth: true, onClick: handleDisconnectClick, disabled: isDisconnecting, children: isDisconnecting ? /* @__PURE__ */ jsx(CpslSpinner, { size: 16 }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
103
|
+
hideWallets ? "Logout" : "Disconnect Wallet",
|
|
104
|
+
/* @__PURE__ */ jsx(CpslIcon, { icon: "logOut", slot: "end" })
|
|
105
|
+
] }) })
|
|
106
|
+
] }) });
|
|
107
|
+
};
|
|
108
|
+
const ButtonContainer = safeStyled.div`
|
|
109
|
+
display: flex;
|
|
110
|
+
align-items: center;
|
|
111
|
+
justify-content: center;
|
|
112
|
+
gap: 8px;
|
|
113
|
+
width: 100%;
|
|
114
|
+
height: 88px;
|
|
115
|
+
`;
|
|
116
|
+
const OptionButton = safeStyled(StyledCpslTileButton)`
|
|
117
|
+
flex: 1;
|
|
118
|
+
|
|
119
|
+
--button-icon-color: var(--cpsl-color-text-primary);
|
|
120
|
+
`;
|
|
121
|
+
const DisconnectButton = safeStyled(CpslButton)`
|
|
122
|
+
--button-border-width: 0px;
|
|
123
|
+
`;
|
|
124
|
+
const BalanceContainer = safeStyled.div`
|
|
125
|
+
display: flex;
|
|
126
|
+
justify-content: center;
|
|
127
|
+
align-items: center;
|
|
128
|
+
padding-top: 8px;
|
|
129
|
+
padding-bottom: 24px;
|
|
130
|
+
`;
|
|
131
|
+
const Alert = safeStyled.div`
|
|
132
|
+
--icon-color: var(--cpsl-color-utility-yellow);
|
|
133
|
+
--icon-stroke-color: var(--cpsl-color-utility-yellow);
|
|
134
|
+
--icon-fill-color: var(--cpsl-color-utility-yellow);
|
|
135
|
+
|
|
136
|
+
display: flex;
|
|
137
|
+
padding: 8px;
|
|
138
|
+
align-items: flex-start;
|
|
139
|
+
gap: 8px;
|
|
140
|
+
align-self: stretch;
|
|
141
|
+
border-radius: var(--cpsl-border-radius-alert);
|
|
142
|
+
border: 1px solid var(--cpsl-color-utility-yellow);
|
|
143
|
+
background: var(--cpsl-color-utility-yellow-light);
|
|
144
|
+
font-size: 14px;
|
|
145
|
+
`;
|
|
146
|
+
export {
|
|
147
|
+
Account
|
|
148
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const AccountProfile: () => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__spreadProps,
|
|
4
|
+
__spreadValues
|
|
5
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { AccountTypeIcon, GradientScroll, StepContainer } from "../common.js";
|
|
8
|
+
import { CpslButton, CpslIcon, CpslIdenticon, CpslText } from "@getpara/react-components";
|
|
9
|
+
import { useClient } from "../../../provider/index.js";
|
|
10
|
+
import { useLinkedAccounts } from "../../../provider/hooks/index.js";
|
|
11
|
+
import { getWalletDisplayName } from "../../utils/getWalletDisplayName.js";
|
|
12
|
+
import { truncateAddress } from "@getpara/web-sdk";
|
|
13
|
+
import { useAccountLinking } from "../../../provider/providers/AccountLinkProvider.js";
|
|
14
|
+
import { safeStyled, useCopyToClipboard } from "@getpara/react-common";
|
|
15
|
+
import { getAccountTypeName } from "../../constants/oAuthLogos.js";
|
|
16
|
+
const Entry = ({
|
|
17
|
+
identifier,
|
|
18
|
+
icon,
|
|
19
|
+
name,
|
|
20
|
+
address,
|
|
21
|
+
addressShort,
|
|
22
|
+
onUnlink
|
|
23
|
+
}) => {
|
|
24
|
+
const [isCopied, copy] = useCopyToClipboard();
|
|
25
|
+
return /* @__PURE__ */ jsxs(EntryContainer, { children: [
|
|
26
|
+
icon,
|
|
27
|
+
/* @__PURE__ */ jsx(EntryDisplayName, { variant: "bodyM", color: "contrast", children: name }),
|
|
28
|
+
/* @__PURE__ */ jsx(EntryFlex, { children: address ? /* @__PURE__ */ jsxs(EntryAddress, { children: [
|
|
29
|
+
/* @__PURE__ */ jsx(CpslText, { variant: "bodyM", color: "secondary", children: addressShort != null ? addressShort : address }),
|
|
30
|
+
/* @__PURE__ */ jsx(
|
|
31
|
+
CpslButton,
|
|
32
|
+
{
|
|
33
|
+
size: "small",
|
|
34
|
+
variant: "ghost",
|
|
35
|
+
onClick: (e) => {
|
|
36
|
+
e.stopPropagation();
|
|
37
|
+
e.preventDefault();
|
|
38
|
+
copy(address);
|
|
39
|
+
},
|
|
40
|
+
children: /* @__PURE__ */ jsx(CopyIcon, { id: "ignore-click", slot: "start", isCopied, icon: isCopied ? "check" : "copy" })
|
|
41
|
+
}
|
|
42
|
+
)
|
|
43
|
+
] }) : null }),
|
|
44
|
+
onUnlink && /* @__PURE__ */ jsx(EntryUnlink, { href: "#", onClick: onUnlink, children: "Unlink" })
|
|
45
|
+
] }, address != null ? address : identifier);
|
|
46
|
+
};
|
|
47
|
+
const AccountProfile = () => {
|
|
48
|
+
var _a, _b, _c, _d, _e, _f;
|
|
49
|
+
const para = useClient();
|
|
50
|
+
const { data: linkedAccounts } = useLinkedAccounts();
|
|
51
|
+
const { isEnabled, linkAccount, unlinkAccount } = useAccountLinking();
|
|
52
|
+
if (!para) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
const externalWallet = (_a = para.authInfo) == null ? void 0 : _a.externalWallet;
|
|
56
|
+
return /* @__PURE__ */ jsxs(StepContainer, { $wide: true, children: [
|
|
57
|
+
/* @__PURE__ */ jsxs(Section, { children: [
|
|
58
|
+
/* @__PURE__ */ jsx(Title, { variant: "bodyS", color: "secondary", children: "Connected Wallets" }),
|
|
59
|
+
/* @__PURE__ */ jsx(Content, { children: externalWallet ? /* @__PURE__ */ jsx(
|
|
60
|
+
Entry,
|
|
61
|
+
{
|
|
62
|
+
icon: /* @__PURE__ */ jsx(AccountTypeIcon, { accountType: externalWallet.providerId, size: "24px" }),
|
|
63
|
+
name: (_c = (_b = externalWallet.ensName) != null ? _b : getAccountTypeName(externalWallet.providerId)) != null ? _c : "",
|
|
64
|
+
address: (_d = externalWallet.addressBech32) != null ? _d : externalWallet.address,
|
|
65
|
+
addressShort: truncateAddress((_e = externalWallet.addressBech32) != null ? _e : externalWallet.address, externalWallet.type, {
|
|
66
|
+
prefix: para.cosmosPrefix
|
|
67
|
+
})
|
|
68
|
+
},
|
|
69
|
+
externalWallet.address
|
|
70
|
+
) : (_f = para == null ? void 0 : para.availableWallets) == null ? void 0 : _f.map((wallet) => {
|
|
71
|
+
var _a2;
|
|
72
|
+
return /* @__PURE__ */ jsx(
|
|
73
|
+
Entry,
|
|
74
|
+
{
|
|
75
|
+
icon: wallet.isExternal ? /* @__PURE__ */ jsx(AccountTypeIcon, { accountType: (_a2 = wallet.externalProviderId) != null ? _a2 : "EXTERNAL_WALLET", size: "24px" }) : /* @__PURE__ */ jsx(CpslIdenticon, { hash: para.getIdenticonHash(wallet.id, wallet.type), size: "24px", arcWidth: "40%" }),
|
|
76
|
+
name: getWalletDisplayName(para, wallet),
|
|
77
|
+
address: wallet.address,
|
|
78
|
+
addressShort: truncateAddress(wallet.address, wallet.type)
|
|
79
|
+
},
|
|
80
|
+
wallet.address
|
|
81
|
+
);
|
|
82
|
+
}) })
|
|
83
|
+
] }),
|
|
84
|
+
isEnabled && /* @__PURE__ */ jsxs(Section, { children: [
|
|
85
|
+
/* @__PURE__ */ jsx(Title, { variant: "bodyS", color: "secondary", children: "Linked Accounts" }),
|
|
86
|
+
/* @__PURE__ */ jsxs(Content, { children: [
|
|
87
|
+
/* @__PURE__ */ jsx(GradientScroll, { gap: "12px", height: "360px", children: [
|
|
88
|
+
...((linkedAccounts == null ? void 0 : linkedAccounts.primary) || []).map((p) => __spreadProps(__spreadValues({}, p), { isPrimary: true })),
|
|
89
|
+
...(linkedAccounts == null ? void 0 : linkedAccounts.linked) || []
|
|
90
|
+
].map((linkedAccount) => {
|
|
91
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
92
|
+
const { identifier, displayName, type, isPrimary = false, externalWallet: externalWallet2 } = linkedAccount;
|
|
93
|
+
return /* @__PURE__ */ jsx(
|
|
94
|
+
Entry,
|
|
95
|
+
{
|
|
96
|
+
icon: /* @__PURE__ */ jsx(AccountTypeIcon, { accountType: (_a2 = externalWallet2 == null ? void 0 : externalWallet2.providerId) != null ? _a2 : type, size: "24px" }),
|
|
97
|
+
name: externalWallet2 ? (_c2 = (_b2 = externalWallet2.ensName) != null ? _b2 : getAccountTypeName(externalWallet2.providerId)) != null ? _c2 : "" : displayName != null ? displayName : identifier,
|
|
98
|
+
address: (_d2 = externalWallet2 == null ? void 0 : externalWallet2.addressBech32) != null ? _d2 : externalWallet2 == null ? void 0 : externalWallet2.address,
|
|
99
|
+
addressShort: externalWallet2 ? truncateAddress((_e2 = externalWallet2.addressBech32) != null ? _e2 : externalWallet2.address, externalWallet2.type, {
|
|
100
|
+
prefix: para.cosmosPrefix
|
|
101
|
+
}) : void 0,
|
|
102
|
+
onUnlink: isPrimary ? void 0 : (e) => {
|
|
103
|
+
e.preventDefault();
|
|
104
|
+
unlinkAccount(linkedAccount);
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
identifier
|
|
108
|
+
);
|
|
109
|
+
}) }),
|
|
110
|
+
/* @__PURE__ */ jsxs(CpslButton, { fullWidth: true, variant: "tertiary", onClick: () => linkAccount(void 0), children: [
|
|
111
|
+
/* @__PURE__ */ jsx(CpslIcon, { icon: "userPlus", slot: "start" }),
|
|
112
|
+
"Link an account"
|
|
113
|
+
] })
|
|
114
|
+
] })
|
|
115
|
+
] })
|
|
116
|
+
] });
|
|
117
|
+
};
|
|
118
|
+
const Section = safeStyled.div`
|
|
119
|
+
display: flex;
|
|
120
|
+
flex-direction: column;
|
|
121
|
+
align-items: flex-start;
|
|
122
|
+
justify-content: center;
|
|
123
|
+
gap: 16px;
|
|
124
|
+
width: 100%;
|
|
125
|
+
`;
|
|
126
|
+
const Content = safeStyled(Section)``;
|
|
127
|
+
const Title = safeStyled(CpslText)``;
|
|
128
|
+
const EntryContainer = safeStyled.div`
|
|
129
|
+
position: relative;
|
|
130
|
+
width: 100%;
|
|
131
|
+
display: flex;
|
|
132
|
+
gap: 8px;
|
|
133
|
+
align-items: center;
|
|
134
|
+
`;
|
|
135
|
+
const EntryDisplayName = safeStyled(CpslText)``;
|
|
136
|
+
const EntryFlex = safeStyled.div`
|
|
137
|
+
flex: 1;
|
|
138
|
+
`;
|
|
139
|
+
const EntryAddress = safeStyled.div`
|
|
140
|
+
display: flex;
|
|
141
|
+
gap: 8px;
|
|
142
|
+
align-items: center;
|
|
143
|
+
`;
|
|
144
|
+
const CopyIcon = safeStyled(CpslIcon)`
|
|
145
|
+
--width: 16px;
|
|
146
|
+
--height: 16px;
|
|
147
|
+
--icon-color: ${({ isCopied }) => isCopied ? "var(--cpsl-color-utility-green) !important" : "var(--cpsl-color-text-secondary)"};
|
|
148
|
+
|
|
149
|
+
&:hover {
|
|
150
|
+
--icon-color: var(--cpsl-color-text-contrast);
|
|
151
|
+
}
|
|
152
|
+
`;
|
|
153
|
+
const EntryUnlink = safeStyled.a`
|
|
154
|
+
color: var(--cpsl-color-utility-red);
|
|
155
|
+
position: absolute;
|
|
156
|
+
right: 0;
|
|
157
|
+
text-decoration: none;
|
|
158
|
+
font-size: 14px;
|
|
159
|
+
font-weight: 500;
|
|
160
|
+
font-family: var(--cpsl-font-family);
|
|
161
|
+
|
|
162
|
+
&:hover {
|
|
163
|
+
text-decoration: underline;
|
|
164
|
+
}
|
|
165
|
+
`;
|
|
166
|
+
export {
|
|
167
|
+
AccountProfile
|
|
168
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function AccountProfileLink(): import("react/jsx-runtime").JSX.Element;
|