@getpara/react-sdk 1.12.0 → 2.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/cli.mjs +35 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/dist/modal/ParaModal.js +211 -313
- package/dist/modal/components/Account/Account.js +73 -16
- package/dist/modal/components/AddFunds/AddFunds.js +5 -6
- package/dist/modal/components/AddFunds/AddFundsAsset.js +15 -13
- package/dist/modal/components/AddFunds/AddFundsAwaiting.js +16 -10
- package/dist/modal/components/AddFunds/AddFundsContext.d.ts +2 -2
- package/dist/modal/components/AddFunds/AddFundsContext.js +20 -14
- package/dist/modal/components/AddFunds/AddFundsDone.js +10 -4
- package/dist/modal/components/AddFunds/AddFundsProvider.js +11 -7
- package/dist/modal/components/AddFunds/AddFundsReceive.js +17 -13
- package/dist/modal/components/AddFunds/AddFundsSettings.js +10 -6
- package/dist/modal/components/AddFunds/common.d.ts +1 -1
- package/dist/modal/components/AuthInput/AuthInput.d.ts +1 -1
- package/dist/modal/components/AuthInput/AuthInput.js +70 -91
- package/dist/modal/components/AuthInput/hooks/useDropdownPosition.d.ts +4 -4
- package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +4 -4
- package/dist/modal/components/AuthMainStep/AuthMainStep.d.ts +4 -3
- package/dist/modal/components/AuthMainStep/AuthMainStep.js +20 -7
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.d.ts +4 -3
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +54 -10
- package/dist/modal/components/AuthOptions/AuthOptions.d.ts +4 -3
- package/dist/modal/components/AuthOptions/AuthOptions.js +35 -7
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.d.ts +5 -1
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +9 -4
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.d.ts +1 -3
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +25 -17
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.d.ts +1 -1
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +34 -72
- package/dist/modal/components/Body/Body.d.ts +4 -3
- package/dist/modal/components/Body/Body.js +27 -10
- package/dist/modal/components/ChainSwitch/ChainSwitch.d.ts +1 -1
- package/dist/modal/components/ChainSwitch/ChainSwitch.js +5 -4
- package/dist/modal/components/Controls/Controls.js +5 -2
- package/dist/modal/components/Controls/Selects.d.ts +1 -1
- package/dist/modal/components/Controls/Selects.js +30 -25
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +1 -1
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +10 -6
- package/dist/modal/components/ExternalWalletVerificationStep/ExternalWalletVerificationStep.js +7 -69
- package/dist/modal/components/ExternalWallets/ExternalWallets.js +7 -6
- package/dist/modal/components/Footer/Footer.d.ts +1 -1
- package/dist/modal/components/Footer/Footer.js +6 -4
- package/dist/modal/components/Header/hooks/useStepTitle.js +7 -3
- package/dist/modal/components/Hero/Hero.js +5 -5
- package/dist/modal/components/IFrameStep/IFrameStep.js +8 -4
- package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +7 -4
- package/dist/modal/components/ModalContent/ModalContent.js +14 -243
- package/dist/modal/components/OAuth/FarcasterOAuthStep.js +3 -57
- package/dist/modal/components/OAuth/OAuth.d.ts +2 -2
- package/dist/modal/components/OAuth/OAuth.js +11 -85
- package/dist/modal/components/OAuth/TelegramOAuthStep.js +11 -60
- package/dist/modal/components/OnRampComponents/AddingFunds.js +1 -1
- package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +10 -4
- package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +23 -32
- package/dist/modal/components/StripeComponents/StripeComponents.js +1 -1
- package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +5 -2
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +44 -60
- package/dist/modal/components/WalletCard/WalletCard.d.ts +5 -5
- package/dist/modal/components/WalletCard/WalletCard.js +8 -7
- package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +33 -12
- package/dist/modal/components/common.d.ts +5 -5
- package/dist/modal/components/common.js +10 -4
- package/dist/modal/constants/constants.d.ts +1 -1
- package/dist/modal/constants/oAuthLogos.d.ts +3 -3
- package/dist/modal/hooks/useGoBack.js +6 -5
- package/dist/modal/index.d.ts +0 -3
- package/dist/modal/index.js +1 -5
- package/dist/modal/stores/index.d.ts +0 -2
- package/dist/modal/stores/index.js +0 -2
- package/dist/modal/stores/modal/actions.js +69 -16
- package/dist/modal/stores/modal/useModalStore.d.ts +26 -22
- package/dist/modal/stores/modal/useModalStore.js +9 -13
- package/dist/modal/types/commonTypes.d.ts +0 -52
- package/dist/modal/types/modalProps.d.ts +8 -32
- package/dist/modal/utils/authInputHelpers.d.ts +7 -0
- package/dist/modal/utils/authInputHelpers.js +38 -0
- package/dist/modal/utils/authLayoutHelpers.d.ts +2 -2
- package/dist/modal/{components/AuthInput → utils}/countryCodes.js +6 -3
- package/dist/modal/utils/getTileButtonFlex.d.ts +1 -1
- package/dist/modal/utils/isPasskeySupported.d.ts +1 -0
- package/dist/modal/utils/isPasskeySupported.js +15 -0
- package/dist/modal/utils/openPopup.d.ts +2 -2
- package/dist/modal/utils/openPopup.js +2 -2
- package/dist/modal/utils/steps.d.ts +6 -0
- package/dist/modal/utils/steps.js +15 -0
- package/dist/provider/ParaProvider.d.ts +3 -1
- package/dist/provider/ParaProvider.js +69 -8
- package/dist/provider/actions/getAccount.d.ts +26 -8
- package/dist/provider/actions/getAccount.js +42 -14
- package/dist/provider/actions/getWallet.d.ts +3 -3
- package/dist/provider/actions/index.d.ts +27 -0
- package/dist/provider/actions/index.js +59 -0
- package/dist/provider/actions/utils.d.ts +3 -0
- package/dist/provider/actions/utils.js +15 -0
- package/dist/provider/components/CosmosWalletWrapper.d.ts +11 -0
- package/dist/provider/components/CosmosWalletWrapper.js +34 -0
- package/dist/provider/components/EvmWalletWrapper.d.ts +12 -0
- package/dist/provider/components/EvmWalletWrapper.js +34 -0
- package/dist/provider/components/ExternalWalletWrapper.d.ts +8 -0
- package/dist/provider/components/ExternalWalletWrapper.js +139 -0
- package/dist/provider/components/SolanaWalletWrapper.d.ts +9 -0
- package/dist/provider/components/SolanaWalletWrapper.js +36 -0
- package/dist/provider/external/getParaCosmosConnector.d.ts +7 -0
- package/dist/provider/external/getParaCosmosConnector.js +22 -0
- package/dist/provider/external/getParaEvmConnector.d.ts +7 -0
- package/dist/provider/external/getParaEvmConnector.js +22 -0
- package/dist/provider/external/getParaSolanaConnector.d.ts +7 -0
- package/dist/provider/external/getParaSolanaConnector.js +22 -0
- package/dist/provider/external/stubs/CosmosExternalWalletContextStub.d.ts +12 -0
- package/dist/provider/external/stubs/CosmosExternalWalletContextStub.js +18 -0
- package/dist/provider/external/stubs/EvmExternalWalletContextStub.d.ts +3 -0
- package/dist/provider/external/stubs/EvmExternalWalletContextStub.js +21 -0
- package/dist/provider/external/stubs/SolanaExternalWalletContextStub.d.ts +8 -0
- package/dist/provider/external/stubs/SolanaExternalWalletContextStub.js +14 -0
- package/dist/provider/hooks/mutations/index.d.ts +27 -11
- package/dist/provider/hooks/mutations/index.js +54 -17
- package/dist/provider/hooks/mutations/utils.d.ts +5 -0
- package/dist/provider/hooks/mutations/utils.js +59 -0
- package/dist/provider/hooks/queries/useAccount.d.ts +1 -7
- package/dist/provider/hooks/queries/useWallet.d.ts +1 -1
- package/dist/provider/hooks/queries/useWalletBalance.d.ts +1 -2
- package/dist/provider/hooks/queries/useWalletBalance.js +40 -11
- package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +5 -5
- package/dist/provider/hooks/utils/useEventListeners.d.ts +1 -1
- package/dist/provider/hooks/utils/useEventListeners.js +100 -56
- package/dist/provider/hooks/utils/useWalletState.d.ts +5 -4
- package/dist/provider/hooks/utils/useWalletState.js +24 -9
- package/dist/provider/index.d.ts +1 -0
- package/dist/provider/index.js +1 -0
- package/dist/provider/providers/AuthProvider.d.ts +35 -0
- package/dist/provider/providers/AuthProvider.js +498 -0
- package/dist/provider/providers/CosmosExternalWalletProvider.d.ts +7 -0
- package/dist/provider/providers/CosmosExternalWalletProvider.js +66 -0
- package/dist/provider/providers/EvmExternalWalletProvider.d.ts +7 -0
- package/dist/provider/providers/EvmExternalWalletProvider.js +74 -0
- package/dist/provider/providers/ExternalWalletProvider.d.ts +76 -0
- package/dist/{modal/providers/ExternalWalletContext.js → provider/providers/ExternalWalletProvider.js} +146 -112
- package/dist/provider/providers/SolanaExternalWalletProvider.d.ts +7 -0
- package/dist/provider/providers/SolanaExternalWalletProvider.js +66 -0
- package/dist/provider/stores/getters.d.ts +3 -3
- package/dist/provider/stores/setters.d.ts +1 -0
- package/dist/provider/stores/setters.js +7 -0
- package/dist/provider/stores/slices/config.d.ts +3 -0
- package/dist/provider/stores/slices/config.js +9 -0
- package/dist/provider/stores/slices/externalWallets.d.ts +3 -0
- package/dist/provider/stores/slices/externalWallets.js +40 -0
- package/dist/provider/stores/slices/index.d.ts +1 -0
- package/dist/provider/stores/slices/index.js +1 -0
- package/dist/provider/stores/slices/modal.js +11 -4
- package/dist/provider/stores/types.d.ts +50 -4
- package/dist/provider/stores/useStore.js +4 -3
- package/dist/provider/types/externalWalletProviders.d.ts +12 -0
- package/dist/provider/types/externalWalletProviders.js +1 -0
- package/dist/provider/types/provider.d.ts +126 -17
- package/dist/provider/types/utils.d.ts +20 -0
- package/dist/provider/utils/constants.js +3 -4
- package/dist/provider/utils/paraConfigTypeGuards.d.ts +7 -0
- package/dist/provider/utils/paraConfigTypeGuards.js +13 -0
- package/dist/provider/utils/renameMutations.d.ts +3 -0
- package/dist/provider/utils/renameMutations.js +5 -3
- package/package.json +20 -8
- package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.d.ts +0 -8
- package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +0 -124
- package/dist/modal/hooks/useActiveWallet.d.ts +0 -1
- package/dist/modal/hooks/useActiveWallet.js +0 -15
- package/dist/modal/hooks/useCreateAccount.d.ts +0 -6
- package/dist/modal/hooks/useCreateAccount.js +0 -77
- package/dist/modal/hooks/useEmbeddedExternalConnection.d.ts +0 -1
- package/dist/modal/hooks/useEmbeddedExternalConnection.js +0 -54
- package/dist/modal/hooks/useSetLoginURLs.d.ts +0 -8
- package/dist/modal/hooks/useSetLoginURLs.js +0 -49
- package/dist/modal/hooks/useWalletBalance.d.ts +0 -4
- package/dist/modal/hooks/useWalletBalance.js +0 -49
- package/dist/modal/providers/CosmosExternalWalletContextStub.d.ts +0 -42
- package/dist/modal/providers/CosmosExternalWalletContextStub.js +0 -38
- package/dist/modal/providers/EvmExternalWalletContextStub.d.ts +0 -46
- package/dist/modal/providers/EvmExternalWalletContextStub.js +0 -55
- package/dist/modal/providers/ExternalWalletContext.d.ts +0 -92
- package/dist/modal/providers/SolanaExternalWalletContextStub.d.ts +0 -32
- package/dist/modal/providers/SolanaExternalWalletContextStub.js +0 -32
- package/dist/modal/stores/externalWalletProvider/actions.d.ts +0 -3
- package/dist/modal/stores/externalWalletProvider/actions.js +0 -10
- package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.d.ts +0 -22
- package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +0 -21
- package/dist/modal/stores/theme/actions.d.ts +0 -3
- package/dist/modal/stores/theme/actions.js +0 -28
- package/dist/modal/stores/theme/useThemeStore.d.ts +0 -20
- package/dist/modal/stores/theme/useThemeStore.js +0 -21
- package/dist/modal/stores/userInfo/actions.d.ts +0 -3
- package/dist/modal/stores/userInfo/actions.js +0 -30
- package/dist/modal/stores/userInfo/useUserInfoStore.d.ts +0 -19
- package/dist/modal/stores/userInfo/useUserInfoStore.js +0 -17
- package/dist/provider/actions/checkIfUserExists.d.ts +0 -9
- package/dist/provider/actions/checkIfUserExists.js +0 -21
- package/dist/provider/actions/createGuestWallets.d.ts +0 -2
- package/dist/provider/actions/createGuestWallets.js +0 -13
- package/dist/provider/actions/createUser.d.ts +0 -12
- package/dist/provider/actions/createUser.js +0 -26
- package/dist/provider/actions/getWalletBalance.d.ts +0 -2
- package/dist/provider/actions/getWalletBalance.js +0 -14
- package/dist/provider/actions/initiateLogin.d.ts +0 -4
- package/dist/provider/actions/initiateLogin.js +0 -20
- package/dist/provider/actions/keepSessionAlive.d.ts +0 -2
- package/dist/provider/actions/keepSessionAlive.js +0 -20
- package/dist/provider/actions/logout.d.ts +0 -2
- package/dist/provider/actions/logout.js +0 -17
- package/dist/provider/actions/signMessage.d.ts +0 -8
- package/dist/provider/actions/signMessage.js +0 -20
- package/dist/provider/actions/signTransaction.d.ts +0 -8
- package/dist/provider/actions/signTransaction.js +0 -20
- package/dist/provider/actions/waitForAccountCreation.d.ts +0 -2
- package/dist/provider/actions/waitForAccountCreation.js +0 -21
- package/dist/provider/actions/waitForLoginAndSetup.d.ts +0 -6
- package/dist/provider/actions/waitForLoginAndSetup.js +0 -24
- package/dist/provider/actions/waitForPasskeyAndCreateWallet.d.ts +0 -2
- package/dist/provider/actions/waitForPasskeyAndCreateWallet.js +0 -21
- package/dist/provider/hooks/mutations/useCheckIfUserExists.d.ts +0 -13
- package/dist/provider/hooks/mutations/useCheckIfUserExists.js +0 -23
- package/dist/provider/hooks/mutations/useCreateGuestWallets.d.ts +0 -15
- package/dist/provider/hooks/mutations/useCreateGuestWallets.js +0 -23
- package/dist/provider/hooks/mutations/useCreateUser.d.ts +0 -13
- package/dist/provider/hooks/mutations/useCreateUser.js +0 -20
- package/dist/provider/hooks/mutations/useInitiateLogin.d.ts +0 -14
- package/dist/provider/hooks/mutations/useInitiateLogin.js +0 -23
- package/dist/provider/hooks/mutations/useKeepSessionAlive.d.ts +0 -12
- package/dist/provider/hooks/mutations/useKeepSessionAlive.js +0 -20
- package/dist/provider/hooks/mutations/useLogout.d.ts +0 -12
- package/dist/provider/hooks/mutations/useLogout.js +0 -30
- package/dist/provider/hooks/mutations/useSignMessage.d.ts +0 -15
- package/dist/provider/hooks/mutations/useSignMessage.js +0 -39
- package/dist/provider/hooks/mutations/useSignTransaction.d.ts +0 -14
- package/dist/provider/hooks/mutations/useSignTransaction.js +0 -39
- package/dist/provider/hooks/mutations/useWaitForAccountCreation.d.ts +0 -12
- package/dist/provider/hooks/mutations/useWaitForAccountCreation.js +0 -30
- package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.d.ts +0 -14
- package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.js +0 -30
- package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.d.ts +0 -13
- package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.js +0 -30
- /package/dist/modal/{components/AuthInput → utils}/countryCodes.d.ts +0 -0
|
@@ -6,52 +6,94 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
6
6
|
import styled from "styled-components";
|
|
7
7
|
import { InnerStepContainer, StepContainer, StyledCpslTileButton } from "../common.js";
|
|
8
8
|
import { CpslButton, CpslIcon, CpslSpinner, CpslText } from "@getpara/react-components";
|
|
9
|
-
import { OnRampStep, useModalStore
|
|
10
|
-
import {
|
|
11
|
-
import { useState } from "react";
|
|
9
|
+
import { OnRampStep, useModalStore } from "../../stores/index.js";
|
|
10
|
+
import { useEffect, useState } from "react";
|
|
12
11
|
import { ModalStep } from "../../utils/steps.js";
|
|
13
|
-
import { useWalletBalance } from "../../hooks/useWalletBalance.js";
|
|
14
|
-
import { formatBalanceString } from "../../utils/stringFormatters.js";
|
|
15
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";
|
|
16
18
|
const Account = ({ onClose }) => {
|
|
17
19
|
const onRampConfig = useModalStore((state) => state.onRampConfig);
|
|
18
20
|
const setStep = useModalStore((state) => state.setStep);
|
|
19
21
|
const setFlow = useModalStore((state) => state.setFlow);
|
|
22
|
+
const setGuestAddFundsTab = useModalStore((state) => state.setGuestAddFundsTab);
|
|
20
23
|
const setOnRampStep = useModalStore((state) => state.setOnRampStep);
|
|
21
|
-
const hideWallets =
|
|
24
|
+
const hideWallets = useStore((state) => {
|
|
25
|
+
var _a;
|
|
26
|
+
return (_a = state.modalConfig) == null ? void 0 : _a.hideWallets;
|
|
27
|
+
});
|
|
22
28
|
const { disconnectExternalWallet } = useExternalWallets();
|
|
23
|
-
const { balance, isLoading: isBalanceLoading } = useWalletBalance();
|
|
24
29
|
const para = useInternalClient();
|
|
30
|
+
const { data: account } = useAccount();
|
|
31
|
+
const { data: balance, isLoading: isBalanceLoading } = useWalletBalance();
|
|
25
32
|
const [isDisconnecting, setIsDisconnecting] = useState(false);
|
|
33
|
+
const isGuestMode = (account == null ? void 0 : account.isConnected) && account.isGuestMode;
|
|
34
|
+
const cantBuyAndWithdraw = para.externalWalletConnectionType === "CONNECTION_ONLY" && !para.userId;
|
|
26
35
|
const isOnRampLoaded = !!onRampConfig;
|
|
27
|
-
const canBuyAndWithdraw = !!para.userId;
|
|
28
36
|
const handleBuyClick = () => {
|
|
29
|
-
|
|
30
|
-
|
|
37
|
+
if (isGuestMode) {
|
|
38
|
+
setGuestAddFundsTab(EnabledFlow.BUY);
|
|
39
|
+
setStep(ModalStep.AUTH_GUEST_SIGNUP);
|
|
40
|
+
} else {
|
|
41
|
+
setOnRampStep(OnRampStep.SETTINGS);
|
|
42
|
+
setStep(ModalStep.ADD_FUNDS_BUY);
|
|
43
|
+
}
|
|
31
44
|
};
|
|
32
45
|
const handleReceiveClick = () => {
|
|
33
46
|
setStep(ModalStep.ADD_FUNDS_RECEIVE);
|
|
34
47
|
};
|
|
35
48
|
const handleSellClick = () => {
|
|
36
|
-
|
|
37
|
-
|
|
49
|
+
if (isGuestMode) {
|
|
50
|
+
setGuestAddFundsTab(EnabledFlow.WITHDRAW);
|
|
51
|
+
setStep(ModalStep.AUTH_GUEST_SIGNUP);
|
|
52
|
+
} else {
|
|
53
|
+
setOnRampStep(OnRampStep.SETTINGS);
|
|
54
|
+
setStep(ModalStep.ADD_FUNDS_WITHDRAW);
|
|
55
|
+
}
|
|
38
56
|
};
|
|
39
57
|
const handleDisconnectClick = () => __async(void 0, null, function* () {
|
|
40
58
|
setIsDisconnecting(true);
|
|
59
|
+
yield para.logout();
|
|
41
60
|
yield disconnectExternalWallet();
|
|
42
61
|
onClose();
|
|
43
62
|
setStep(ModalStep.AUTH_MAIN);
|
|
44
63
|
setFlow(void 0);
|
|
45
64
|
setIsDisconnecting(false);
|
|
46
65
|
});
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
setGuestAddFundsTab();
|
|
68
|
+
}, []);
|
|
47
69
|
return /* @__PURE__ */ jsx(StepContainer, { $wide: true, children: /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
|
|
48
|
-
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) }) }),
|
|
70
|
+
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) }) }),
|
|
71
|
+
isGuestMode && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
72
|
+
balance && parseFloat(balance) > 0 && /* @__PURE__ */ jsxs(Alert, { children: [
|
|
73
|
+
/* @__PURE__ */ jsx(CpslIcon, { icon: "alertTriangle", size: "24px", style: { color: "var(--cpsl-color-utility-yellow)" } }),
|
|
74
|
+
"You've funded this account - complete account setup to maintain access."
|
|
75
|
+
] }),
|
|
76
|
+
/* @__PURE__ */ jsxs(
|
|
77
|
+
CpslButton,
|
|
78
|
+
{
|
|
79
|
+
fullWidth: true,
|
|
80
|
+
variant: "primary",
|
|
81
|
+
onClick: () => {
|
|
82
|
+
setStep(ModalStep.AUTH_GUEST_SIGNUP);
|
|
83
|
+
},
|
|
84
|
+
children: [
|
|
85
|
+
/* @__PURE__ */ jsx(CpslIcon, { icon: "stars02" }),
|
|
86
|
+
"Complete Account Setup"
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
)
|
|
90
|
+
] }),
|
|
49
91
|
/* @__PURE__ */ jsx(ButtonContainer, { children: isOnRampLoaded ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
50
|
-
|
|
92
|
+
onRampConfig.isBuyEnabled && !cantBuyAndWithdraw && /* @__PURE__ */ jsx(OptionButton, { icon: "creditCard", onClick: handleBuyClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Buy Crypto" }) }),
|
|
51
93
|
onRampConfig.isReceiveEnabled && /* @__PURE__ */ jsx(OptionButton, { icon: "qrCode02", onClick: handleReceiveClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Receive" }) }),
|
|
52
|
-
|
|
94
|
+
onRampConfig.isWithdrawEnabled && !cantBuyAndWithdraw && /* @__PURE__ */ jsx(OptionButton, { icon: "arrowCircleBrokenDownLeft", onClick: handleSellClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Withdraw" }) })
|
|
53
95
|
] }) : /* @__PURE__ */ jsx(CpslSpinner, {}) }),
|
|
54
|
-
/* @__PURE__ */ jsx(DisconnectButton, { variant: "destructive", fullWidth: true, onClick: handleDisconnectClick, disabled: isDisconnecting, children: isDisconnecting ? /* @__PURE__ */ jsx(CpslSpinner, { size: 16 }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
96
|
+
!isGuestMode && /* @__PURE__ */ jsx(DisconnectButton, { variant: "destructive", fullWidth: true, onClick: handleDisconnectClick, disabled: isDisconnecting, children: isDisconnecting ? /* @__PURE__ */ jsx(CpslSpinner, { size: 16 }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
55
97
|
hideWallets ? "Logout" : "Disconnect Wallet",
|
|
56
98
|
/* @__PURE__ */ jsx(CpslIcon, { icon: "logOut", slot: "end" })
|
|
57
99
|
] }) })
|
|
@@ -80,6 +122,21 @@ const BalanceContainer = styled.div`
|
|
|
80
122
|
padding-top: 8px;
|
|
81
123
|
padding-bottom: 24px;
|
|
82
124
|
`;
|
|
125
|
+
const Alert = styled.div`
|
|
126
|
+
--icon-color: var(--cpsl-color-utility-yellow);
|
|
127
|
+
--icon-stroke-color: var(--cpsl-color-utility-yellow);
|
|
128
|
+
--icon-fill-color: var(--cpsl-color-utility-yellow);
|
|
129
|
+
|
|
130
|
+
display: flex;
|
|
131
|
+
padding: 8px;
|
|
132
|
+
align-items: flex-start;
|
|
133
|
+
gap: 8px;
|
|
134
|
+
align-self: stretch;
|
|
135
|
+
border-radius: var(--cpsl-border-radius-alert);
|
|
136
|
+
border: 1px solid var(--cpsl-color-utility-yellow);
|
|
137
|
+
background: var(--cpsl-color-utility-yellow-light);
|
|
138
|
+
font-size: 14px;
|
|
139
|
+
`;
|
|
83
140
|
export {
|
|
84
141
|
Account
|
|
85
142
|
};
|
|
@@ -7,26 +7,25 @@ import { CpslIcon, CpslSpinner, CpslTab, CpslTabs } from "@getpara/react-compone
|
|
|
7
7
|
import { OnRampStep } from "../../stores/index.js";
|
|
8
8
|
import { useModalStore } from "../../stores/modal/useModalStore.js";
|
|
9
9
|
import { useEffect, useMemo } from "react";
|
|
10
|
-
import { useActiveWallet } from "../../hooks/useActiveWallet.js";
|
|
11
10
|
import { getAddFundsStep } from "../../utils/steps.js";
|
|
12
11
|
import styled from "styled-components";
|
|
12
|
+
import { useAccount, useWallet } from "../../../provider/index.js";
|
|
13
13
|
import { AddFundsProvider } from "./AddFundsProvider.js";
|
|
14
14
|
import { AddFundsReceive } from "./AddFundsReceive.js";
|
|
15
15
|
import { AddFundsContextProvider, TABS } from "./AddFundsContext.js";
|
|
16
16
|
import { AnimatePresence } from "framer-motion";
|
|
17
17
|
import { AddFundsSettings } from "./AddFundsSettings.js";
|
|
18
|
-
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
19
18
|
const AddFunds = () => {
|
|
20
19
|
const onRampConfig = useModalStore((state) => state.onRampConfig);
|
|
21
20
|
const onRampStep = useModalStore((state) => state.onRampStep);
|
|
22
21
|
const storedTab = useModalStore((state) => state.accountAddFundTab);
|
|
23
22
|
const setModalStep = useModalStore((state) => state.setStep);
|
|
24
23
|
const setOnRampPurchase = useModalStore((state) => state.setOnRampPurchase);
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
24
|
+
const { data: activeWallet } = useWallet();
|
|
25
|
+
const { data: account } = useAccount();
|
|
26
|
+
const isGuestMode = (account == null ? void 0 : account.isConnected) && account.isGuestMode;
|
|
28
27
|
const tabs = TABS.filter(
|
|
29
|
-
([, key]) => !!(onRampConfig == null ? void 0 : onRampConfig[key]) && (
|
|
28
|
+
([enabledFlow, key]) => !!(onRampConfig == null ? void 0 : onRampConfig[key]) && (!isGuestMode || enabledFlow === EnabledFlow.RECEIVE)
|
|
30
29
|
);
|
|
31
30
|
const tab = storedTab != null ? storedTab : tabs[0][0];
|
|
32
31
|
const isMultiFlow = tabs.length > 1;
|
|
@@ -12,21 +12,21 @@ import { getAssetCode, getAssetName, ON_RAMP_ASSETS } from "../../constants/cons
|
|
|
12
12
|
import { useModalStore } from "../../stores/index.js";
|
|
13
13
|
import { useRef, useState } from "react";
|
|
14
14
|
import { useAddFunds } from "./AddFundsContext.js";
|
|
15
|
-
import {
|
|
15
|
+
import { useWallet } from "../../../provider/hooks/queries/useWallet.js";
|
|
16
16
|
import { AssetIcon } from "../common.js";
|
|
17
17
|
import { AnimatePresence, motion } from "framer-motion";
|
|
18
18
|
import { contentMotionProps } from "./common.js";
|
|
19
19
|
function AddFundsAsset() {
|
|
20
20
|
const onRampConfig = useModalStore((state) => state.onRampConfig);
|
|
21
21
|
const { assets, setAsset, network, setNetwork } = useAddFunds();
|
|
22
|
-
const activeWallet =
|
|
22
|
+
const { data: activeWallet } = useWallet();
|
|
23
23
|
const [isAtBottom, setIsAtBottom] = useState(false);
|
|
24
24
|
const [isAtTop, setIsAtTop] = useState(true);
|
|
25
25
|
const [searchStr, setSearchStr] = useState("");
|
|
26
26
|
const ref = useRef(null);
|
|
27
27
|
const onSelect = (_asset) => __async(this, null, function* () {
|
|
28
28
|
yield setAsset(_asset);
|
|
29
|
-
if (!network) {
|
|
29
|
+
if (!network && !!onRampConfig && !!activeWallet) {
|
|
30
30
|
yield setNetwork(
|
|
31
31
|
getOnRampNetworks(onRampConfig.assetInfo, {
|
|
32
32
|
walletType: activeWallet.type,
|
|
@@ -36,16 +36,18 @@ function AddFundsAsset() {
|
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
const onScroll = () => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
if (ref.current) {
|
|
40
|
+
const { scrollTop, scrollHeight, clientHeight } = ref.current;
|
|
41
|
+
if (scrollTop + clientHeight >= scrollHeight - 30) {
|
|
42
|
+
setIsAtBottom(true);
|
|
43
|
+
} else {
|
|
44
|
+
setIsAtBottom(false);
|
|
45
|
+
}
|
|
46
|
+
if (scrollTop < 30) {
|
|
47
|
+
setIsAtTop(true);
|
|
48
|
+
} else {
|
|
49
|
+
setIsAtTop(false);
|
|
50
|
+
}
|
|
49
51
|
}
|
|
50
52
|
};
|
|
51
53
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
+
__spreadProps,
|
|
3
4
|
__spreadValues
|
|
4
5
|
} from "../../../chunk-MMUBH76A.js";
|
|
5
6
|
import { jsx } from "react/jsx-runtime";
|
|
6
7
|
import { StepContainer } from "../common.js";
|
|
7
8
|
import { OnRampProvider } from "@getpara/web-sdk";
|
|
8
|
-
import { useModalStore
|
|
9
|
+
import { useModalStore } from "../../stores/index.js";
|
|
9
10
|
import { lazy, useEffect, useMemo, useState } from "react";
|
|
10
11
|
import { ModalStep } from "../../utils/steps.js";
|
|
11
12
|
import { RampEmbed, StripeEmbed } from "@getpara/react-common";
|
|
12
13
|
import styled from "styled-components";
|
|
13
14
|
import { useGoBack } from "../../hooks/useGoBack.js";
|
|
14
15
|
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
16
|
+
import { useStore } from "../../../provider/stores/useStore.js";
|
|
15
17
|
const STEPS = {
|
|
16
18
|
CANCELLED: ModalStep.ADD_FUNDS_FAILURE,
|
|
17
19
|
FINISHED: ModalStep.ADD_FUNDS_SUCCESS
|
|
@@ -23,9 +25,9 @@ const AddFundsAwaiting = () => {
|
|
|
23
25
|
const onRampPurchase = useModalStore((state) => state.onRampPurchase);
|
|
24
26
|
const setOnRampPurchase = useModalStore((state) => state.setOnRampPurchase);
|
|
25
27
|
const para = useInternalClient();
|
|
26
|
-
const appName =
|
|
27
|
-
const isDark =
|
|
28
|
-
const [MoonPayEmbed, setMoonPayEmbed] = useState(
|
|
28
|
+
const appName = useStore((state) => state.appName);
|
|
29
|
+
const isDark = useStore((state) => state.isDarkTheme);
|
|
30
|
+
const [MoonPayEmbed, setMoonPayEmbed] = useState();
|
|
29
31
|
const props = {
|
|
30
32
|
para,
|
|
31
33
|
appName,
|
|
@@ -38,26 +40,30 @@ const AddFundsAwaiting = () => {
|
|
|
38
40
|
};
|
|
39
41
|
useEffect(() => {
|
|
40
42
|
const _MoonPayEmbed = lazy(() => import("./MoonPayEmbed.js"));
|
|
41
|
-
|
|
43
|
+
if (_MoonPayEmbed) {
|
|
44
|
+
setMoonPayEmbed(_MoonPayEmbed);
|
|
45
|
+
}
|
|
42
46
|
}, []);
|
|
43
47
|
const onRampEmbed = useMemo(() => {
|
|
44
|
-
|
|
48
|
+
var _a, _b;
|
|
49
|
+
if (!(onRampPurchase == null ? void 0 : onRampPurchase.id) || !props.onRampConfig) {
|
|
45
50
|
return null;
|
|
46
51
|
}
|
|
47
52
|
switch (onRampPurchase == null ? void 0 : onRampPurchase.provider) {
|
|
48
53
|
case OnRampProvider.STRIPE:
|
|
49
|
-
return /* @__PURE__ */ jsx(StripeEmbed, __spreadValues({}, props));
|
|
54
|
+
return /* @__PURE__ */ jsx(StripeEmbed, __spreadProps(__spreadValues({}, props), { onRampConfig: props.onRampConfig }));
|
|
50
55
|
case OnRampProvider.MOONPAY:
|
|
51
|
-
return !MoonPayEmbed || typeof window === "undefined" ? null : /* @__PURE__ */ jsx(MoonPayEmbed, __spreadValues({}, props));
|
|
56
|
+
return !MoonPayEmbed || typeof window === "undefined" ? null : /* @__PURE__ */ jsx(MoonPayEmbed, __spreadProps(__spreadValues({}, props), { onRampConfig: props.onRampConfig }));
|
|
52
57
|
case OnRampProvider.RAMP:
|
|
53
|
-
return /* @__PURE__ */ jsx(RampEmbed, __spreadValues({ apiKey: onRampConfig.rampApiKey
|
|
58
|
+
return /* @__PURE__ */ jsx(RampEmbed, __spreadProps(__spreadValues({}, props), { apiKey: (_b = (_a = props.onRampConfig) == null ? void 0 : _a.rampApiKey) != null ? _b : "", onRampConfig: props.onRampConfig }));
|
|
54
59
|
}
|
|
55
60
|
}, [onRampPurchase == null ? void 0 : onRampPurchase.provider, MoonPayEmbed]);
|
|
56
61
|
useEffect(() => {
|
|
57
62
|
let timeoutId;
|
|
58
63
|
if ((onRampPurchase == null ? void 0 : onRampPurchase.status) && ["CANCELLED", "FINISHED"].includes(onRampPurchase.status)) {
|
|
59
64
|
timeoutId = setTimeout(() => {
|
|
60
|
-
|
|
65
|
+
var _a;
|
|
66
|
+
setStep(STEPS[(_a = onRampPurchase.status) != null ? _a : ""]);
|
|
61
67
|
}, 5e3);
|
|
62
68
|
}
|
|
63
69
|
return () => clearTimeout(timeoutId);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dispatch, PropsWithChildren, ReactNode, SetStateAction } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { useWallet } from '../../../provider/hooks/index.js';
|
|
3
3
|
import { EnabledFlow, Network, OnRampAsset, OnRampConfig, OnRampProvider } from '@getpara/web-sdk';
|
|
4
4
|
import { IconType } from '@getpara/react-components';
|
|
5
5
|
export type Tab = EnabledFlow;
|
|
@@ -20,7 +20,7 @@ type Value = {
|
|
|
20
20
|
assets: OnRampAsset[];
|
|
21
21
|
isProviderAllowed: Partial<Record<OnRampProvider, boolean>>;
|
|
22
22
|
tab: Tab;
|
|
23
|
-
activeWallet: ReturnType<typeof
|
|
23
|
+
activeWallet: ReturnType<typeof useWallet>['data'];
|
|
24
24
|
onRampConfig: OnRampConfig;
|
|
25
25
|
};
|
|
26
26
|
export declare const AddFundsContext: import("react").Context<Value>;
|
|
@@ -12,8 +12,8 @@ import {
|
|
|
12
12
|
useState
|
|
13
13
|
} from "react";
|
|
14
14
|
import { OnRampStep, useModalStore } from "../../stores/index.js";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
15
|
+
import { useWallet } from "../../../provider/hooks/index.js";
|
|
16
|
+
import { useExternalWallets } from "../../../provider/providers/ExternalWalletProvider.js";
|
|
17
17
|
import {
|
|
18
18
|
EnabledFlow,
|
|
19
19
|
getOnRampAssets,
|
|
@@ -43,9 +43,9 @@ const DEFAULT = {
|
|
|
43
43
|
onRampConfig: {},
|
|
44
44
|
activeWallet: {}
|
|
45
45
|
};
|
|
46
|
-
function isValid(
|
|
46
|
+
function isValid(onRampConfig, walletType, network, asset) {
|
|
47
47
|
var _a, _b;
|
|
48
|
-
return !!((_b = (_a = assetInfo[walletType]) == null ? void 0 : _a[network]) == null ? void 0 : _b[asset]);
|
|
48
|
+
return network && asset && walletType ? !!((_b = (_a = onRampConfig == null ? void 0 : onRampConfig.assetInfo[walletType]) == null ? void 0 : _a[network]) == null ? void 0 : _b[asset]) : false;
|
|
49
49
|
}
|
|
50
50
|
const AddFundsContext = createContext(DEFAULT);
|
|
51
51
|
function AddFundsContextProvider({ tab, children }) {
|
|
@@ -54,19 +54,25 @@ function AddFundsContextProvider({ tab, children }) {
|
|
|
54
54
|
const onRampStep = useModalStore((state) => state.onRampStep);
|
|
55
55
|
const setOnRampStep = useModalStore((state) => state.setOnRampStep);
|
|
56
56
|
const { chainId } = useExternalWallets();
|
|
57
|
-
const activeWallet =
|
|
58
|
-
const [fiatQuantity, setFiatQuantity] = useState((_b = (_a = onRampConfig.defaultBuyAmount) == null ? void 0 : _a[0]) != null ? _b : "25.00");
|
|
57
|
+
const { data: activeWallet } = useWallet();
|
|
58
|
+
const [fiatQuantity, setFiatQuantity] = useState((_b = (_a = onRampConfig == null ? void 0 : onRampConfig.defaultBuyAmount) == null ? void 0 : _a[0]) != null ? _b : "25.00");
|
|
59
59
|
const networks = useMemo(() => {
|
|
60
|
+
if (!onRampConfig) {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
60
63
|
const detectedNetwork = getNetworkFromChainId(chainId);
|
|
61
|
-
const isExternal = activeWallet.isExternal && !!detectedNetwork;
|
|
64
|
+
const isExternal = (activeWallet == null ? void 0 : activeWallet.isExternal) && !!detectedNetwork;
|
|
62
65
|
return isExternal ? [getNetworkOrMainNetEquivalent(detectedNetwork, onRampConfig.testMode)] : getOnRampNetworks(onRampConfig.assetInfo, {
|
|
63
|
-
walletType: activeWallet.type,
|
|
66
|
+
walletType: activeWallet == null ? void 0 : activeWallet.type,
|
|
64
67
|
allowed: onRampConfig.allowedAssets ? Object.keys(onRampConfig.allowedAssets) : void 0,
|
|
65
68
|
providers: onRampConfig.providers,
|
|
66
69
|
action: OnRampPurchaseType[tab === EnabledFlow.BUY ? "BUY" : "SELL"]
|
|
67
70
|
});
|
|
68
71
|
}, [chainId, activeWallet, onRampConfig, tab]);
|
|
69
72
|
const assets = useMemo(() => {
|
|
73
|
+
if (!onRampConfig) {
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
70
76
|
return [
|
|
71
77
|
...new Set(
|
|
72
78
|
Object.values(
|
|
@@ -76,7 +82,7 @@ function AddFundsContextProvider({ tab, children }) {
|
|
|
76
82
|
const allowed = configValue === true ? void 0 : configValue;
|
|
77
83
|
return __spreadProps(__spreadValues({}, acc), {
|
|
78
84
|
[network2]: getOnRampAssets(onRampConfig.assetInfo, {
|
|
79
|
-
walletType: activeWallet.type,
|
|
85
|
+
walletType: activeWallet == null ? void 0 : activeWallet.type,
|
|
80
86
|
network: network2,
|
|
81
87
|
allowed,
|
|
82
88
|
providers: onRampConfig.providers,
|
|
@@ -89,13 +95,13 @@ function AddFundsContextProvider({ tab, children }) {
|
|
|
89
95
|
];
|
|
90
96
|
}, [networks, onRampConfig, activeWallet, tab]);
|
|
91
97
|
const [network, setNetwork] = useState(
|
|
92
|
-
!!(onRampConfig == null ? void 0 : onRampConfig.defaultOnRampNetwork) && !!onRampConfig.assetInfo[activeWallet.type][onRampConfig.defaultOnRampNetwork] ? onRampConfig.defaultOnRampNetwork : void 0
|
|
98
|
+
!!(activeWallet == null ? void 0 : activeWallet.type) && !!(onRampConfig == null ? void 0 : onRampConfig.defaultOnRampNetwork) && !!onRampConfig.assetInfo[activeWallet.type][onRampConfig.defaultOnRampNetwork] ? onRampConfig.defaultOnRampNetwork : void 0
|
|
93
99
|
);
|
|
94
100
|
const [asset, setAsset] = useState(
|
|
95
101
|
!!network && !!(onRampConfig == null ? void 0 : onRampConfig.defaultOnRampAsset) && assets.includes(onRampConfig.defaultOnRampAsset) ? onRampConfig.defaultOnRampAsset : void 0
|
|
96
102
|
);
|
|
97
103
|
const isProviderAllowed = useMemo(
|
|
98
|
-
() => onRampConfig.providers.reduce(
|
|
104
|
+
() => onRampConfig && !!(activeWallet == null ? void 0 : activeWallet.type) ? onRampConfig.providers.reduce(
|
|
99
105
|
(acc, id) => {
|
|
100
106
|
var _a2, _b2, _c, _d, _e;
|
|
101
107
|
return __spreadProps(__spreadValues({}, acc), {
|
|
@@ -103,7 +109,7 @@ function AddFundsContextProvider({ tab, children }) {
|
|
|
103
109
|
});
|
|
104
110
|
},
|
|
105
111
|
{}
|
|
106
|
-
),
|
|
112
|
+
) : {},
|
|
107
113
|
[onRampConfig, network, asset, activeWallet, tab]
|
|
108
114
|
);
|
|
109
115
|
const value = useMemo(() => {
|
|
@@ -139,10 +145,10 @@ function AddFundsContextProvider({ tab, children }) {
|
|
|
139
145
|
onRampConfig
|
|
140
146
|
]);
|
|
141
147
|
useEffect(() => {
|
|
142
|
-
if (onRampStep === OnRampStep.PROVIDER && !isValid(onRampConfig, activeWallet.type, network, asset)) {
|
|
148
|
+
if (!!activeWallet && onRampStep === OnRampStep.PROVIDER && !isValid(onRampConfig, activeWallet.type, network, asset)) {
|
|
143
149
|
setOnRampStep(OnRampStep.SETTINGS);
|
|
144
150
|
}
|
|
145
|
-
}, [onRampStep, onRampConfig, activeWallet
|
|
151
|
+
}, [onRampStep, onRampConfig, activeWallet, network, asset, setOnRampStep]);
|
|
146
152
|
return /* @__PURE__ */ jsx(AddFundsContext.Provider, { value, children });
|
|
147
153
|
}
|
|
148
154
|
const useAddFunds = () => useContext(AddFundsContext);
|
|
@@ -2,12 +2,18 @@
|
|
|
2
2
|
import "../../../chunk-MMUBH76A.js";
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { Heading, HeroIcon, InnerStepContainer, StepContainer } from "../common.js";
|
|
5
|
-
import { useModalStore
|
|
5
|
+
import { useModalStore } from "../../stores/index.js";
|
|
6
6
|
import { useMemo } from "react";
|
|
7
7
|
import { CpslButton, CpslText } from "@getpara/react-components";
|
|
8
8
|
import { getAddFundsStep } from "../../utils/steps.js";
|
|
9
|
+
import { useStore } from "../../../provider/stores/useStore.js";
|
|
10
|
+
import { EnabledFlow } from "@getpara/web-sdk";
|
|
9
11
|
const AddFundsDone = ({ isSuccess, onClose }) => {
|
|
10
|
-
|
|
12
|
+
var _a;
|
|
13
|
+
const hideWallets = useStore((state) => {
|
|
14
|
+
var _a2;
|
|
15
|
+
return (_a2 = state.modalConfig) == null ? void 0 : _a2.hideWallets;
|
|
16
|
+
});
|
|
11
17
|
const setStep = useModalStore((state) => state.setStep);
|
|
12
18
|
const onRampPurchase = useModalStore((state) => state.onRampPurchase);
|
|
13
19
|
const accountAddFundTab = useModalStore((state) => state.accountAddFundTab);
|
|
@@ -18,7 +24,7 @@ const AddFundsDone = ({ isSuccess, onClose }) => {
|
|
|
18
24
|
});
|
|
19
25
|
}, [onRampPurchase == null ? void 0 : onRampPurchase.fiat]);
|
|
20
26
|
const heading = isSuccess ? "Transaction Successful" : "Something Went Wrong";
|
|
21
|
-
const text = isSuccess ? `${formatter.format(parseFloat(onRampPurchase == null ? void 0 : onRampPurchase.fiatQuantity))} is now available in your ${hideWallets ? "account" : "wallet"}.` : `No funds were added to your ${hideWallets ? "account" : "wallet"}.`;
|
|
27
|
+
const text = isSuccess ? `${formatter.format(parseFloat((_a = onRampPurchase == null ? void 0 : onRampPurchase.fiatQuantity) != null ? _a : "0"))} is now available in your ${hideWallets ? "account" : "wallet"}.` : `No funds were added to your ${hideWallets ? "account" : "wallet"}.`;
|
|
22
28
|
const buttonText = isSuccess ? "Done" : "Try Again";
|
|
23
29
|
return /* @__PURE__ */ jsxs(StepContainer, { children: [
|
|
24
30
|
/* @__PURE__ */ jsx(HeroIcon, { icon: "checkCircleFilled" }),
|
|
@@ -31,7 +37,7 @@ const AddFundsDone = ({ isSuccess, onClose }) => {
|
|
|
31
37
|
{
|
|
32
38
|
fullWidth: true,
|
|
33
39
|
onClick: () => {
|
|
34
|
-
isSuccess ? onClose() : setStep(getAddFundsStep(accountAddFundTab));
|
|
40
|
+
isSuccess ? onClose() : setStep(getAddFundsStep(accountAddFundTab != null ? accountAddFundTab : EnabledFlow.BUY));
|
|
35
41
|
},
|
|
36
42
|
children: buttonText
|
|
37
43
|
}
|
|
@@ -9,22 +9,26 @@ import styled from "styled-components";
|
|
|
9
9
|
import { Heading, InnerStepContainer } from "../common.js";
|
|
10
10
|
import { CpslText } from "@getpara/react-components";
|
|
11
11
|
import { useAddFunds } from "./AddFundsContext.js";
|
|
12
|
-
import { useModalStore
|
|
12
|
+
import { useModalStore } from "../../stores/index.js";
|
|
13
|
+
import { useStore } from "../../../provider/stores/useStore.js";
|
|
13
14
|
import { motion, AnimatePresence } from "framer-motion";
|
|
14
15
|
import { OnRampProviderButton } from "../OnRampComponents/OnRampProviderButton.js";
|
|
15
|
-
import {
|
|
16
|
+
import { useWallet } from "../../../provider/index.js";
|
|
16
17
|
import { EnabledFlow, OnRampProvider, OnRampPurchaseType } from "@getpara/web-sdk";
|
|
17
18
|
import { ModalStep } from "../../utils/steps.js";
|
|
18
19
|
import { contentMotionProps } from "./common.js";
|
|
19
20
|
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
20
21
|
function AddFundsProvider() {
|
|
21
22
|
const para = useInternalClient();
|
|
22
|
-
const hideWallets =
|
|
23
|
+
const hideWallets = useStore((state) => {
|
|
24
|
+
var _a;
|
|
25
|
+
return (_a = state.modalConfig) == null ? void 0 : _a.hideWallets;
|
|
26
|
+
});
|
|
23
27
|
const onRampConfig = useModalStore((state) => state.onRampConfig);
|
|
24
28
|
const setOnRampPurchase = useModalStore((state) => state.setOnRampPurchase);
|
|
25
29
|
const setModalStep = useModalStore((state) => state.setStep);
|
|
26
30
|
const { asset, network, fiatQuantity, isProviderAllowed, tab } = useAddFunds();
|
|
27
|
-
const activeWallet =
|
|
31
|
+
const { data: activeWallet } = useWallet();
|
|
28
32
|
return /* @__PURE__ */ jsxs(Container, __spreadProps(__spreadValues({}, contentMotionProps), { children: [
|
|
29
33
|
/* @__PURE__ */ jsx(Heading, { variant: "headingS", weight: "bold", children: "Choose Provider" }),
|
|
30
34
|
/* @__PURE__ */ jsxs($InnerStepContainer, { children: [
|
|
@@ -32,7 +36,7 @@ function AddFundsProvider() {
|
|
|
32
36
|
"No providers are available for this ",
|
|
33
37
|
hideWallets ? "account" : "wallet"
|
|
34
38
|
] }),
|
|
35
|
-
/* @__PURE__ */ jsx(AnimatePresence, { children: onRampConfig.providers.map((id, index) => {
|
|
39
|
+
/* @__PURE__ */ jsx(AnimatePresence, { children: onRampConfig ? onRampConfig.providers.map((id, index) => {
|
|
36
40
|
return isProviderAllowed[id] ? /* @__PURE__ */ jsx(
|
|
37
41
|
motion.div,
|
|
38
42
|
{
|
|
@@ -61,7 +65,7 @@ function AddFundsProvider() {
|
|
|
61
65
|
network,
|
|
62
66
|
asset,
|
|
63
67
|
fiatQuantity,
|
|
64
|
-
testMode: onRampConfig.testMode
|
|
68
|
+
testMode: onRampConfig == null ? void 0 : onRampConfig.testMode
|
|
65
69
|
}
|
|
66
70
|
});
|
|
67
71
|
setOnRampPurchase(__spreadProps(__spreadValues({}, newOnRampPurchase), { fiat: "USD" }));
|
|
@@ -73,7 +77,7 @@ function AddFundsProvider() {
|
|
|
73
77
|
},
|
|
74
78
|
id
|
|
75
79
|
) : null;
|
|
76
|
-
}) })
|
|
80
|
+
}) : null })
|
|
77
81
|
] })
|
|
78
82
|
] }));
|
|
79
83
|
}
|
|
@@ -11,27 +11,31 @@ import {
|
|
|
11
11
|
CpslText
|
|
12
12
|
} from "@getpara/react-components";
|
|
13
13
|
import { CenteredText, FilledDisabledInput, InnerStepContainer, QRContainer } from "../common.js";
|
|
14
|
-
import { isMobile
|
|
15
|
-
import { useModalStore
|
|
14
|
+
import { isMobile } from "@getpara/web-sdk";
|
|
15
|
+
import { useModalStore } from "../../stores/index.js";
|
|
16
|
+
import { useStore } from "../../../provider/stores/useStore.js";
|
|
16
17
|
import { useCopyToClipboard } from "@getpara/react-common";
|
|
17
18
|
import { useMemo } from "react";
|
|
18
|
-
import {
|
|
19
|
+
import { useWallet } from "../../../provider/hooks/index.js";
|
|
19
20
|
import { useAddFunds } from "./AddFundsContext.js";
|
|
20
21
|
import { formatNetworkList } from "../../utils/stringFormatters.js";
|
|
21
22
|
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
22
23
|
const GENERIC_WALLET = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
EVM: "Ethereum or EVM-based L2s",
|
|
25
|
+
SOLANA: "Solana",
|
|
26
|
+
COSMOS: "Cosmos"
|
|
26
27
|
};
|
|
27
28
|
function AddFundsReceive() {
|
|
28
29
|
const [isCopied, copy] = useCopyToClipboard();
|
|
29
30
|
const { networks } = useAddFunds();
|
|
30
31
|
const para = useInternalClient();
|
|
31
|
-
const appName =
|
|
32
|
-
const hideWallets =
|
|
32
|
+
const appName = useStore((state) => state.appName);
|
|
33
|
+
const hideWallets = useStore((state) => {
|
|
34
|
+
var _a;
|
|
35
|
+
return (_a = state.modalConfig) == null ? void 0 : _a.hideWallets;
|
|
36
|
+
});
|
|
33
37
|
const onRampConfig = useModalStore((state) => state.onRampConfig);
|
|
34
|
-
const activeWallet =
|
|
38
|
+
const { data: activeWallet } = useWallet();
|
|
35
39
|
const address = useMemo(
|
|
36
40
|
() => activeWallet ? para.getDisplayAddress(activeWallet.id, { addressType: activeWallet.type }) : "",
|
|
37
41
|
[para, activeWallet == null ? void 0 : activeWallet.id, activeWallet == null ? void 0 : activeWallet.type]
|
|
@@ -40,7 +44,7 @@ function AddFundsReceive() {
|
|
|
40
44
|
copy(address);
|
|
41
45
|
};
|
|
42
46
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
43
|
-
/* @__PURE__ */ jsx(InnerStepContainer, { children: /* @__PURE__ */ jsxs(
|
|
47
|
+
activeWallet && /* @__PURE__ */ jsx(InnerStepContainer, { children: /* @__PURE__ */ jsxs(
|
|
44
48
|
FilledDisabledInput,
|
|
45
49
|
{
|
|
46
50
|
noAutoDisable: true,
|
|
@@ -64,13 +68,13 @@ function AddFundsReceive() {
|
|
|
64
68
|
/* @__PURE__ */ jsx(CpslText, { weight: "semiBold", color: "secondary", children: "Scan with your crypto wallet" })
|
|
65
69
|
] })
|
|
66
70
|
] }),
|
|
67
|
-
/* @__PURE__ */ jsxs(InnerStepContainer, { children: [
|
|
71
|
+
(activeWallet == null ? void 0 : activeWallet.type) && /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
|
|
68
72
|
/* @__PURE__ */ jsxs(CenteredText, { weight: "semiBold", children: [
|
|
69
|
-
!!onRampConfig.allowedAssets && networks.length > 0 || hideWallets ? appName != null ? appName : "This App" : "This Wallet",
|
|
73
|
+
!!(onRampConfig == null ? void 0 : onRampConfig.allowedAssets) && networks.length > 0 || hideWallets ? appName != null ? appName : "This App" : "This Wallet",
|
|
70
74
|
" ",
|
|
71
75
|
"Only Supports:"
|
|
72
76
|
] }),
|
|
73
|
-
/* @__PURE__ */ jsx(CenteredText, { weight: "medium", color: "secondary", children: !!onRampConfig.allowedAssets && networks.length > 0 ? formatNetworkList(networks) : GENERIC_WALLET[activeWallet.type] })
|
|
77
|
+
/* @__PURE__ */ jsx(CenteredText, { weight: "medium", color: "secondary", children: !!(onRampConfig == null ? void 0 : onRampConfig.allowedAssets) && networks.length > 0 ? formatNetworkList(networks) : GENERIC_WALLET[activeWallet.type] })
|
|
74
78
|
] })
|
|
75
79
|
] });
|
|
76
80
|
}
|
|
@@ -10,7 +10,8 @@ import { CpslButton, CpslIcon, CpslInput, CpslRow, CpslText } from "@getpara/rea
|
|
|
10
10
|
import { AssetIcon, HeaderSelect, HeaderSelectContainer, HeaderSelectItem, NetworkIcon } from "../common.js";
|
|
11
11
|
import { getAssetCode, getNetworkName } from "../../constants/constants.js";
|
|
12
12
|
import { EnabledFlow, getOnRampNetworks, OnRampPurchaseType } from "@getpara/web-sdk";
|
|
13
|
-
import { OnRampStep, useModalStore
|
|
13
|
+
import { OnRampStep, useModalStore } from "../../stores/index.js";
|
|
14
|
+
import { useStore } from "../../../provider/stores/useStore.js";
|
|
14
15
|
import styled from "styled-components";
|
|
15
16
|
import { contentMotionProps, NoProviders } from "./common.js";
|
|
16
17
|
import { AnimatePresence, motion, useIsPresent } from "framer-motion";
|
|
@@ -40,7 +41,10 @@ function AssetPill({ asset, gap = "4px", slot, fix }) {
|
|
|
40
41
|
const NetworkLabel = /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", style: { margin: "0 8px" }, children: "Network" });
|
|
41
42
|
function AddFundsSettings() {
|
|
42
43
|
const isPresent = useIsPresent();
|
|
43
|
-
const hideWallets =
|
|
44
|
+
const hideWallets = useStore((state) => {
|
|
45
|
+
var _a;
|
|
46
|
+
return (_a = state.modalConfig) == null ? void 0 : _a.hideWallets;
|
|
47
|
+
});
|
|
44
48
|
const setOnRampStep = useModalStore((state) => state.setOnRampStep);
|
|
45
49
|
const {
|
|
46
50
|
assets,
|
|
@@ -56,16 +60,16 @@ function AddFundsSettings() {
|
|
|
56
60
|
isProviderAllowed,
|
|
57
61
|
tab
|
|
58
62
|
} = useAddFunds();
|
|
59
|
-
const [value, setValue] = useState(parseFloat(fiatQuantity
|
|
63
|
+
const [value, setValue] = useState(parseFloat(fiatQuantity || "25.00").toFixed(2));
|
|
60
64
|
const narrowedNetworks = useMemo(() => {
|
|
61
65
|
return !asset ? networks : getOnRampNetworks(onRampConfig.assetInfo, {
|
|
62
|
-
walletType: activeWallet.type,
|
|
66
|
+
walletType: activeWallet == null ? void 0 : activeWallet.type,
|
|
63
67
|
allowed: onRampConfig.allowedAssets ? Object.entries(onRampConfig.allowedAssets).filter(([_, value2]) => value2 === true || value2.includes(asset)).map(([key]) => key) : void 0,
|
|
64
68
|
assets: [asset],
|
|
65
69
|
providers: onRampConfig.providers,
|
|
66
70
|
action: tab === EnabledFlow.BUY ? OnRampPurchaseType.BUY : OnRampPurchaseType.SELL
|
|
67
71
|
});
|
|
68
|
-
}, [networks, network, asset, activeWallet.type, onRampConfig.providers, tab]);
|
|
72
|
+
}, [networks, network, asset, activeWallet == null ? void 0 : activeWallet.type, onRampConfig.providers, tab]);
|
|
69
73
|
const content = useMemo(() => {
|
|
70
74
|
if (!!asset && Object.values(isProviderAllowed).every((v) => !v) || assets.length === 0) {
|
|
71
75
|
return /* @__PURE__ */ jsx(Container, __spreadProps(__spreadValues({}, contentMotionProps), { isPresent, children: /* @__PURE__ */ jsxs(NoProviders, { isHidden: Object.values(isProviderAllowed).some((v) => !!v), variant: "bodyM", children: [
|
|
@@ -161,7 +165,7 @@ function AddFundsSettings() {
|
|
|
161
165
|
fullWidth: true,
|
|
162
166
|
disabled: value === "",
|
|
163
167
|
onClick: () => {
|
|
164
|
-
setFiatQuantity(value);
|
|
168
|
+
setFiatQuantity(value != null ? value : void 0);
|
|
165
169
|
setOnRampStep(OnRampStep.PROVIDER);
|
|
166
170
|
},
|
|
167
171
|
children: [
|
|
@@ -13,7 +13,7 @@ export declare const contentMotionProps: {
|
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
15
|
export declare const NoProviders: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<Omit<Omit<any, "ref"> & import("react").RefAttributes<any>, "ref"> & {
|
|
16
|
-
ref?: import("react").
|
|
16
|
+
ref?: ((instance: any) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<any> | null | undefined;
|
|
17
17
|
}, {
|
|
18
18
|
isHidden?: boolean;
|
|
19
19
|
}>> & string & Omit<import("react").ForwardRefExoticComponent<Omit<any, "ref"> & import("react").RefAttributes<any>>, keyof import("react").Component<any, {}, any>>;
|