@getpara/react-sdk 1.6.1-dev.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{modal/components/AddFunds/MoonPayEmbed.js → MoonPayEmbed-Q2HP2BFI.js} +3 -1
- package/dist/MoonPayEmbed-Q2HP2BFI.js.br +0 -0
- package/dist/MoonPayEmbed-Q2HP2BFI.js.gz +0 -0
- package/dist/chunk-MMUBH76A.js.br +0 -0
- package/dist/chunk-MMUBH76A.js.gz +0 -0
- package/dist/index.js +6657 -6
- package/dist/index.js.br +0 -0
- package/dist/index.js.gz +0 -0
- package/dist/modal/components/ExternalWalletVerificationStep/ExternalWalletVerificationStep.d.ts +1 -0
- package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.d.ts +2 -1
- package/dist/modal/components/common.d.ts +4 -0
- package/dist/modal/index.d.ts +1 -0
- package/dist/modal/providers/CosmosExternalWalletContextStub.d.ts +13 -0
- package/dist/modal/providers/EvmExternalWalletContextStub.d.ts +11 -0
- package/dist/modal/providers/ExternalWalletContext.d.ts +15 -1
- package/dist/modal/providers/SolanaExternalWalletContextStub.d.ts +11 -0
- package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.d.ts +2 -0
- package/dist/modal/types/commonTypes.d.ts +12 -2
- package/dist/modal/types/externalWallets.d.ts +2 -0
- package/dist/modal/types/modalProps.d.ts +6 -0
- package/dist/modal/utils/steps.d.ts +2 -0
- package/dist/provider/utils/constants.d.ts +5 -0
- package/package.json +5 -5
- package/dist/modal/ParaModal.js +0 -337
- package/dist/modal/components/Account/Account.js +0 -69
- package/dist/modal/components/AddFunds/AddFunds.js +0 -220
- package/dist/modal/components/AddFunds/AddFundsAwaiting.js +0 -72
- package/dist/modal/components/AddFunds/AddFundsDone.js +0 -43
- package/dist/modal/components/AddFunds/index.js +0 -4
- package/dist/modal/components/AuthInput/AuthInput.js +0 -283
- package/dist/modal/components/AuthInput/countryCodes.js +0 -42
- package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +0 -33
- package/dist/modal/components/AuthInput/phoneMasks.js +0 -253
- package/dist/modal/components/AuthMainStep/AuthMainStep.js +0 -37
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +0 -113
- package/dist/modal/components/AuthOptions/AuthOptions.js +0 -33
- package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +0 -18
- package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.js +0 -10
- package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +0 -18
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +0 -44
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +0 -52
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +0 -93
- package/dist/modal/components/Body/AnimatedHeightWrapper.js +0 -29
- package/dist/modal/components/Body/Body.js +0 -304
- package/dist/modal/components/ChainSwitch/ChainSwitch.js +0 -94
- package/dist/modal/components/ChainSwitch/config.js +0 -17
- package/dist/modal/components/Controls/Controls.js +0 -74
- package/dist/modal/components/Controls/Selects.js +0 -213
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +0 -151
- package/dist/modal/components/ExternalWalletStep/config.js +0 -17
- package/dist/modal/components/ExternalWallets/ExternalWallets.js +0 -172
- package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +0 -123
- package/dist/modal/components/Footer/Footer.js +0 -93
- package/dist/modal/components/Header/Header.js +0 -43
- package/dist/modal/components/Header/hooks/useStepTitle.js +0 -50
- package/dist/modal/components/Hero/Hero.js +0 -122
- package/dist/modal/components/IFrameStep/IFrameStep.js +0 -55
- package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +0 -28
- package/dist/modal/components/ModalContent/ModalContent.js +0 -310
- package/dist/modal/components/OAuth/FarcasterOAuthStep.js +0 -81
- package/dist/modal/components/OAuth/OAuth.js +0 -153
- package/dist/modal/components/OAuth/TelegramOAuthStep.js +0 -139
- package/dist/modal/components/OnRampComponents/AddingFunds.js +0 -23
- package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +0 -77
- package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +0 -101
- package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +0 -141
- package/dist/modal/components/StripeComponents/StripeComponents.js +0 -88
- package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +0 -24
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +0 -159
- package/dist/modal/components/Waiting/Waiting.js +0 -17
- package/dist/modal/components/WalletCard/PartnerIcon.js +0 -34
- package/dist/modal/components/WalletCard/WalletCard.js +0 -127
- package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +0 -52
- package/dist/modal/components/common.js +0 -83
- package/dist/modal/components/index.js +0 -2
- package/dist/modal/constants/constants.js +0 -111
- package/dist/modal/constants/defaults.js +0 -10
- package/dist/modal/constants/oAuthLogos.js +0 -24
- package/dist/modal/hooks/useActiveWallet.js +0 -15
- package/dist/modal/hooks/useCreateAccount.js +0 -72
- package/dist/modal/hooks/useEmbeddedExternalConnection.js +0 -39
- package/dist/modal/hooks/useGoBack.js +0 -35
- package/dist/modal/hooks/useSetLoginURLs.js +0 -45
- package/dist/modal/index.js +0 -32
- package/dist/modal/providers/CosmosExternalWalletContextStub.js +0 -34
- package/dist/modal/providers/EvmExternalWalletContextStub.js +0 -38
- package/dist/modal/providers/ExternalWalletContext.js +0 -275
- package/dist/modal/providers/SolanaExternalWalletContextStub.js +0 -19
- package/dist/modal/stores/externalWalletProvider/actions.js +0 -10
- package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +0 -20
- package/dist/modal/stores/index.js +0 -4
- package/dist/modal/stores/modal/actions.js +0 -70
- package/dist/modal/stores/modal/useModalStore.js +0 -65
- package/dist/modal/stores/theme/actions.js +0 -28
- package/dist/modal/stores/theme/useThemeStore.js +0 -21
- package/dist/modal/stores/userInfo/actions.js +0 -30
- package/dist/modal/stores/userInfo/useUserInfoStore.js +0 -17
- package/dist/modal/types/commonTypes.js +0 -1
- package/dist/modal/types/externalWallets.js +0 -31
- package/dist/modal/types/modalProps.js +0 -12
- package/dist/modal/utils/authLayoutHelpers.js +0 -8
- package/dist/modal/utils/getMailtoLink.js +0 -10
- package/dist/modal/utils/getTileButtonFlex.js +0 -20
- package/dist/modal/utils/openPopup.js +0 -60
- package/dist/modal/utils/routeMobileExternalWallet.js +0 -31
- package/dist/modal/utils/steps.js +0 -228
- package/dist/modal/utils/stringFormatters.js +0 -14
- package/dist/modal/utils/validateOnRampConfig.js +0 -32
- package/dist/provider/ParaProvider.js +0 -22
- package/dist/provider/actions/checkIfUserExists.js +0 -21
- package/dist/provider/actions/createUser.js +0 -26
- package/dist/provider/actions/getAccount.js +0 -22
- package/dist/provider/actions/getWallet.js +0 -14
- package/dist/provider/actions/initiateLogin.js +0 -20
- package/dist/provider/actions/keepSessionAlive.js +0 -20
- package/dist/provider/actions/logout.js +0 -17
- package/dist/provider/actions/signMessage.js +0 -20
- package/dist/provider/actions/signTransaction.js +0 -20
- package/dist/provider/actions/waitForAccountCreation.js +0 -21
- package/dist/provider/actions/waitForLoginAndSetup.js +0 -24
- package/dist/provider/actions/waitForPasskeyAndCreateWallet.js +0 -21
- package/dist/provider/hooks/index.js +0 -4
- package/dist/provider/hooks/mutations/index.js +0 -24
- package/dist/provider/hooks/mutations/useCheckIfUserExists.js +0 -23
- package/dist/provider/hooks/mutations/useCreateUser.js +0 -20
- package/dist/provider/hooks/mutations/useInitiateLogin.js +0 -23
- package/dist/provider/hooks/mutations/useKeepSessionAlive.js +0 -20
- package/dist/provider/hooks/mutations/useLogout.js +0 -30
- package/dist/provider/hooks/mutations/useSignMessage.js +0 -33
- package/dist/provider/hooks/mutations/useSignTransaction.js +0 -33
- package/dist/provider/hooks/mutations/useWaitForAccountCreation.js +0 -30
- package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.js +0 -30
- package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.js +0 -30
- package/dist/provider/hooks/queries/index.js +0 -8
- package/dist/provider/hooks/queries/useAccount.js +0 -21
- package/dist/provider/hooks/queries/useWallet.js +0 -22
- package/dist/provider/hooks/utils/index.js +0 -10
- package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +0 -74
- package/dist/provider/hooks/utils/useClient.js +0 -10
- package/dist/provider/hooks/utils/useEventListeners.js +0 -105
- package/dist/provider/hooks/utils/useInternalClient.js +0 -10
- package/dist/provider/hooks/utils/useModal.js +0 -17
- package/dist/provider/hooks/utils/useWalletState.js +0 -33
- package/dist/provider/index.js +0 -8
- package/dist/provider/stores/getters.js +0 -13
- package/dist/provider/stores/slices/client.js +0 -9
- package/dist/provider/stores/slices/index.js +0 -4
- package/dist/provider/stores/slices/modal.js +0 -9
- package/dist/provider/stores/slices/wallet.js +0 -11
- package/dist/provider/stores/types.js +0 -1
- package/dist/provider/stores/useStore.js +0 -27
- package/dist/provider/types/provider.js +0 -1
- package/dist/provider/types/query.js +0 -1
- package/dist/provider/types/utils.js +0 -1
- package/dist/provider/utils/renameMutations.js +0 -16
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
__async
|
|
4
|
-
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import styled from "styled-components";
|
|
7
|
-
import { InnerStepContainer, StepContainer, StyledCpslTileButton } from "../common.js";
|
|
8
|
-
import { CpslButton, CpslIcon, CpslSpinner, CpslText } from "@getpara/react-components";
|
|
9
|
-
import { useModalStore, useThemeStore } from "../../stores/index.js";
|
|
10
|
-
import { useExternalWallets } from "../../providers/ExternalWalletContext.js";
|
|
11
|
-
import { useState } from "react";
|
|
12
|
-
import { ModalStep } from "../../utils/steps.js";
|
|
13
|
-
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
14
|
-
const Account = ({ onClose }) => {
|
|
15
|
-
const onRampConfig = useModalStore((state) => state.onRampConfig);
|
|
16
|
-
const setStep = useModalStore((state) => state.setStep);
|
|
17
|
-
const hideWallets = useThemeStore((state) => state.hideWallets);
|
|
18
|
-
const { disconnectExternalWallet } = useExternalWallets();
|
|
19
|
-
const para = useInternalClient();
|
|
20
|
-
const [isDisconnecting, setIsDisconnecting] = useState(false);
|
|
21
|
-
const isOnRampLoaded = !!onRampConfig;
|
|
22
|
-
const handleBuyClick = () => {
|
|
23
|
-
setStep(ModalStep.ADD_FUNDS_BUY);
|
|
24
|
-
};
|
|
25
|
-
const handleReceiveClick = () => {
|
|
26
|
-
setStep(ModalStep.ADD_FUNDS_RECEIVE);
|
|
27
|
-
};
|
|
28
|
-
const handleSellClick = () => {
|
|
29
|
-
setStep(ModalStep.ADD_FUNDS_WITHDRAW);
|
|
30
|
-
};
|
|
31
|
-
const handleDisconnectClick = () => __async(void 0, null, function* () {
|
|
32
|
-
setIsDisconnecting(true);
|
|
33
|
-
yield para.logout();
|
|
34
|
-
yield disconnectExternalWallet();
|
|
35
|
-
onClose();
|
|
36
|
-
setStep(ModalStep.AUTH_MAIN);
|
|
37
|
-
setIsDisconnecting(false);
|
|
38
|
-
});
|
|
39
|
-
return /* @__PURE__ */ jsx(StepContainer, { $wide: true, children: /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
|
|
40
|
-
/* @__PURE__ */ jsx(ButtonContainer, { children: isOnRampLoaded ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
41
|
-
onRampConfig.isBuyEnabled && /* @__PURE__ */ jsx(OptionButton, { icon: "creditCard", onClick: handleBuyClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Buy Crypto" }) }),
|
|
42
|
-
onRampConfig.isReceiveEnabled && /* @__PURE__ */ jsx(OptionButton, { icon: "qrCode02", onClick: handleReceiveClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Receive" }) }),
|
|
43
|
-
onRampConfig.isWithdrawEnabled && /* @__PURE__ */ jsx(OptionButton, { icon: "arrowCircleBrokenDownLeft", onClick: handleSellClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Withdraw" }) })
|
|
44
|
-
] }) : /* @__PURE__ */ jsx(CpslSpinner, {}) }),
|
|
45
|
-
/* @__PURE__ */ jsx(DisconnectButton, { variant: "destructive", fullWidth: true, onClick: handleDisconnectClick, disabled: isDisconnecting, children: isDisconnecting ? /* @__PURE__ */ jsx(CpslSpinner, { size: 16 }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
46
|
-
hideWallets ? "Logout" : "Disconnect Wallet",
|
|
47
|
-
/* @__PURE__ */ jsx(CpslIcon, { icon: "logOut", slot: "end" })
|
|
48
|
-
] }) })
|
|
49
|
-
] }) });
|
|
50
|
-
};
|
|
51
|
-
const ButtonContainer = styled.div`
|
|
52
|
-
display: flex;
|
|
53
|
-
align-items: center;
|
|
54
|
-
justify-content: center;
|
|
55
|
-
gap: 8px;
|
|
56
|
-
width: 100%;
|
|
57
|
-
height: 88px;
|
|
58
|
-
`;
|
|
59
|
-
const OptionButton = styled(StyledCpslTileButton)`
|
|
60
|
-
flex: 1;
|
|
61
|
-
|
|
62
|
-
--button-icon-color: var(--cpsl-color-text-primary);
|
|
63
|
-
`;
|
|
64
|
-
const DisconnectButton = styled(CpslButton)`
|
|
65
|
-
--button-border-width: 0px;
|
|
66
|
-
`;
|
|
67
|
-
export {
|
|
68
|
-
Account
|
|
69
|
-
};
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
__async,
|
|
4
|
-
__spreadProps,
|
|
5
|
-
__spreadValues
|
|
6
|
-
} from "../../../chunk-MMUBH76A.js";
|
|
7
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
-
import {
|
|
9
|
-
EnabledFlow,
|
|
10
|
-
getOnRampAssets,
|
|
11
|
-
getOnRampNetworks,
|
|
12
|
-
OnRampProvider,
|
|
13
|
-
OnRampPurchaseType,
|
|
14
|
-
toAssetInfoArray,
|
|
15
|
-
WalletType
|
|
16
|
-
} from "@getpara/web-sdk";
|
|
17
|
-
import { CenteredText, FilledDisabledInput, Heading, InnerStepContainer, QRContainer, StepContainer } from "../common.js";
|
|
18
|
-
import {
|
|
19
|
-
CpslButton,
|
|
20
|
-
CpslDivider,
|
|
21
|
-
CpslIcon,
|
|
22
|
-
CpslIdenticon,
|
|
23
|
-
CpslQrCode,
|
|
24
|
-
CpslSpinner,
|
|
25
|
-
CpslTab,
|
|
26
|
-
CpslTabs,
|
|
27
|
-
CpslText
|
|
28
|
-
} from "@getpara/react-components";
|
|
29
|
-
import { useModalStore, useThemeStore } from "../../stores/index.js";
|
|
30
|
-
import { useEffect, useMemo } from "react";
|
|
31
|
-
import { OnRampProviderButton } from "../OnRampComponents/OnRampProviderButton.js";
|
|
32
|
-
import { isMobile } from "@getpara/web-sdk";
|
|
33
|
-
import { useActiveWallet } from "../../hooks/useActiveWallet.js";
|
|
34
|
-
import { getAddFundsStep, ModalStep } from "../../utils/steps.js";
|
|
35
|
-
import { motion, AnimatePresence } from "framer-motion";
|
|
36
|
-
import { useExternalWallets } from "../../providers/ExternalWalletContext.js";
|
|
37
|
-
import { getNetworkFromChainId, getNetworkOrMainNetEquivalent, useCopyToClipboard } from "@getpara/react-common";
|
|
38
|
-
import { formatNetworkList } from "../../utils/stringFormatters.js";
|
|
39
|
-
import styled from "styled-components";
|
|
40
|
-
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
41
|
-
const TABS = [
|
|
42
|
-
[EnabledFlow.BUY, "isBuyEnabled", "creditCard", "Buy"],
|
|
43
|
-
[EnabledFlow.RECEIVE, "isReceiveEnabled", "qrCode", "Receive"],
|
|
44
|
-
[EnabledFlow.WITHDRAW, "isWithdrawEnabled", "arrowCircleBrokenDownLeft", "Withdraw"]
|
|
45
|
-
];
|
|
46
|
-
const GENERIC_WALLET = {
|
|
47
|
-
[WalletType.EVM]: "Ethereum or EVM-based L2s",
|
|
48
|
-
[WalletType.SOLANA]: "Solana",
|
|
49
|
-
[WalletType.COSMOS]: "Cosmos"
|
|
50
|
-
};
|
|
51
|
-
const AddFunds = () => {
|
|
52
|
-
const [isCopied, copy] = useCopyToClipboard();
|
|
53
|
-
const para = useInternalClient();
|
|
54
|
-
const appName = useThemeStore((state) => state.appName);
|
|
55
|
-
const onRampConfig = useModalStore((state) => state.onRampConfig);
|
|
56
|
-
const hideWallets = useThemeStore((state) => state.hideWallets);
|
|
57
|
-
const storedTab = useModalStore((state) => state.accountAddFundTab);
|
|
58
|
-
const setStep = useModalStore((state) => state.setStep);
|
|
59
|
-
const setOnRampPurchase = useModalStore((state) => state.setOnRampPurchase);
|
|
60
|
-
const { chainId } = useExternalWallets();
|
|
61
|
-
const activeWallet = useActiveWallet();
|
|
62
|
-
const tabs = TABS.filter(([, key]) => !!onRampConfig[key]);
|
|
63
|
-
const isMultiFlow = tabs.length > 1;
|
|
64
|
-
const tab = storedTab != null ? storedTab : tabs[0][0];
|
|
65
|
-
const address = useMemo(
|
|
66
|
-
() => activeWallet ? para.getDisplayAddress(activeWallet.id, { addressType: activeWallet.type }) : "",
|
|
67
|
-
[para, activeWallet == null ? void 0 : activeWallet.id, activeWallet == null ? void 0 : activeWallet.type]
|
|
68
|
-
);
|
|
69
|
-
const onSetTab = (event) => {
|
|
70
|
-
setStep(getAddFundsStep(event.detail.tab));
|
|
71
|
-
};
|
|
72
|
-
const onCopy = () => {
|
|
73
|
-
copy(address);
|
|
74
|
-
};
|
|
75
|
-
const [allowedNetworks, allowedAssets, isProviderAllowed] = useMemo(() => {
|
|
76
|
-
if (!onRampConfig || !activeWallet) {
|
|
77
|
-
return [[], [], {}];
|
|
78
|
-
}
|
|
79
|
-
const action = tab === EnabledFlow.BUY ? OnRampPurchaseType.BUY : OnRampPurchaseType.SELL;
|
|
80
|
-
const detectedNetwork = getNetworkFromChainId(chainId);
|
|
81
|
-
const isExternal = activeWallet.isExternal && !!detectedNetwork;
|
|
82
|
-
const allowedNetworks2 = isExternal ? [getNetworkOrMainNetEquivalent(detectedNetwork, onRampConfig.testMode)] : getOnRampNetworks(onRampConfig.assetInfo, {
|
|
83
|
-
walletType: activeWallet.type,
|
|
84
|
-
allowed: onRampConfig.allowedAssets ? Object.keys(onRampConfig.allowedAssets) : void 0
|
|
85
|
-
});
|
|
86
|
-
const allowedAssetsLookup = allowedNetworks2.reduce((acc, network) => {
|
|
87
|
-
var _a;
|
|
88
|
-
const configValue = (_a = onRampConfig.allowedAssets) == null ? void 0 : _a[network];
|
|
89
|
-
const allowed = configValue === true ? void 0 : configValue;
|
|
90
|
-
return __spreadProps(__spreadValues({}, acc), {
|
|
91
|
-
[network]: getOnRampAssets(onRampConfig.assetInfo, { walletType: activeWallet.type, network, allowed })
|
|
92
|
-
});
|
|
93
|
-
}, {});
|
|
94
|
-
const isProviderAllowed2 = onRampConfig.providers.reduce(
|
|
95
|
-
(acc, id) => {
|
|
96
|
-
const hasMatch = toAssetInfoArray(onRampConfig.assetInfo).some(([type, network, asset, validProviders]) => {
|
|
97
|
-
var _a, _b;
|
|
98
|
-
return type === activeWallet.type && allowedNetworks2.includes(network) && (!allowedAssetsLookup[network] || allowedAssetsLookup[network].includes(asset)) && !!((_b = (_a = validProviders[id]) == null ? void 0 : _a[1]) == null ? void 0 : _b[action]);
|
|
99
|
-
});
|
|
100
|
-
return __spreadProps(__spreadValues({}, acc), {
|
|
101
|
-
[id]: hasMatch
|
|
102
|
-
});
|
|
103
|
-
},
|
|
104
|
-
{}
|
|
105
|
-
);
|
|
106
|
-
return [allowedNetworks2, [...new Set(Object.values(allowedAssetsLookup).flat())], isProviderAllowed2];
|
|
107
|
-
}, [activeWallet == null ? void 0 : activeWallet.type, activeWallet == null ? void 0 : activeWallet.isExternal, tab, onRampConfig.assetInfo, onRampConfig.allowedAssets, chainId]);
|
|
108
|
-
useEffect(() => {
|
|
109
|
-
setOnRampPurchase(void 0);
|
|
110
|
-
}, []);
|
|
111
|
-
useEffect(() => {
|
|
112
|
-
setOnRampPurchase(void 0);
|
|
113
|
-
}, []);
|
|
114
|
-
if (!onRampConfig || !activeWallet) {
|
|
115
|
-
return /* @__PURE__ */ jsx(SpinnerContainer, { children: /* @__PURE__ */ jsx(CpslSpinner, {}) });
|
|
116
|
-
}
|
|
117
|
-
useEffect(() => {
|
|
118
|
-
setOnRampPurchase(void 0);
|
|
119
|
-
}, []);
|
|
120
|
-
return /* @__PURE__ */ jsxs(StepContainer, { children: [
|
|
121
|
-
isMultiFlow && /* @__PURE__ */ jsx(InnerStepContainer, { children: /* @__PURE__ */ jsx(CpslTabs, { selectedTab: tab, onCpslTabsChanged: onSetTab, children: TABS.map(([tab2, _, icon, title]) => /* @__PURE__ */ jsxs(CpslTab, { tab: tab2, children: [
|
|
122
|
-
/* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon }),
|
|
123
|
-
title
|
|
124
|
-
] }, tab2)) }) }),
|
|
125
|
-
/* @__PURE__ */ jsx(Fragment, { children: [EnabledFlow.BUY, EnabledFlow.WITHDRAW].includes(tab) ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
126
|
-
/* @__PURE__ */ jsx(Heading, { variant: "headingS", weight: "bold", children: "Choose Provider" }),
|
|
127
|
-
/* @__PURE__ */ jsxs($InnerStepContainer, { children: [
|
|
128
|
-
/* @__PURE__ */ jsxs(NoProviders, { isHidden: Object.values(isProviderAllowed).some((v) => !!v), variant: "bodyM", children: [
|
|
129
|
-
"No providers are available for this ",
|
|
130
|
-
hideWallets ? "account" : "wallet"
|
|
131
|
-
] }),
|
|
132
|
-
/* @__PURE__ */ jsx(AnimatePresence, { children: onRampConfig.providers.map((id, index) => {
|
|
133
|
-
return isProviderAllowed[id] ? /* @__PURE__ */ jsx(
|
|
134
|
-
motion.div,
|
|
135
|
-
{
|
|
136
|
-
style: { width: "100%" },
|
|
137
|
-
layout: true,
|
|
138
|
-
initial: { opacity: 0, transform: "translateX(25px)" },
|
|
139
|
-
animate: { opacity: 1, transform: "none" },
|
|
140
|
-
exit: { opacity: 0, transform: "translateX(-25px)" },
|
|
141
|
-
transition: { duration: 0.2 },
|
|
142
|
-
children: /* @__PURE__ */ jsx(
|
|
143
|
-
OnRampProviderButton,
|
|
144
|
-
{
|
|
145
|
-
config: onRampConfig,
|
|
146
|
-
index,
|
|
147
|
-
onClick: () => __async(void 0, null, function* () {
|
|
148
|
-
var _a;
|
|
149
|
-
if (!(activeWallet == null ? void 0 : activeWallet.type)) return;
|
|
150
|
-
const isPopup = id !== OnRampProvider.RAMP;
|
|
151
|
-
const { onRampPurchase: newOnRampPurchase } = yield para.initiateOnRampTransaction({
|
|
152
|
-
walletId: activeWallet.isExternal ? void 0 : activeWallet.id,
|
|
153
|
-
externalWalletAddress: activeWallet.isExternal ? activeWallet.id : void 0,
|
|
154
|
-
shouldOpenPopup: isPopup,
|
|
155
|
-
params: {
|
|
156
|
-
type: tab === EnabledFlow.BUY ? OnRampPurchaseType.BUY : OnRampPurchaseType.SELL,
|
|
157
|
-
walletType: activeWallet.type,
|
|
158
|
-
provider: id,
|
|
159
|
-
networks: allowedNetworks,
|
|
160
|
-
assets: allowedAssets,
|
|
161
|
-
defaultNetwork: onRampConfig.defaultOnRampNetwork,
|
|
162
|
-
defaultAsset: onRampConfig.defaultOnRampAsset,
|
|
163
|
-
fiatQuantity: (_a = onRampConfig.defaultBuyAmount) == null ? void 0 : _a[0],
|
|
164
|
-
testMode: onRampConfig.testMode
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
setOnRampPurchase(__spreadProps(__spreadValues({}, newOnRampPurchase), { fiat: "USD" }));
|
|
168
|
-
!isPopup && setStep(ModalStep.ADD_FUNDS_AWAITING);
|
|
169
|
-
})
|
|
170
|
-
},
|
|
171
|
-
id
|
|
172
|
-
)
|
|
173
|
-
},
|
|
174
|
-
id
|
|
175
|
-
) : null;
|
|
176
|
-
}) })
|
|
177
|
-
] })
|
|
178
|
-
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
179
|
-
/* @__PURE__ */ jsx(InnerStepContainer, { children: /* @__PURE__ */ jsxs(FilledDisabledInput, { noAutoDisable: true, readonly: true, placeholder: address, children: [
|
|
180
|
-
/* @__PURE__ */ jsx(CpslIdenticon, { slot: "start", size: "32px", hash: para.getIdenticonHash(activeWallet.id, activeWallet.type) }),
|
|
181
|
-
/* @__PURE__ */ jsx(CpslButton, { slot: "end", variant: "ghost", onClick: onCopy, children: /* @__PURE__ */ jsx(CpslIcon, { icon: isCopied ? "check" : "copy" }) })
|
|
182
|
-
] }, address) }),
|
|
183
|
-
!isMobile() && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
184
|
-
/* @__PURE__ */ jsx(CpslDivider, { children: "or" }),
|
|
185
|
-
/* @__PURE__ */ jsxs(InnerStepContainer, { children: [
|
|
186
|
-
/* @__PURE__ */ jsx(QRContainer, { children: !address ? /* @__PURE__ */ jsx(CpslSpinner, { size: 100 }) : /* @__PURE__ */ jsx(CpslQrCode, { url: address }, address) }),
|
|
187
|
-
/* @__PURE__ */ jsx(CpslText, { weight: "semiBold", color: "secondary", children: "Scan with your crypto wallet" })
|
|
188
|
-
] })
|
|
189
|
-
] }),
|
|
190
|
-
/* @__PURE__ */ jsxs(InnerStepContainer, { children: [
|
|
191
|
-
/* @__PURE__ */ jsxs(CenteredText, { weight: "semiBold", children: [
|
|
192
|
-
!!onRampConfig.allowedAssets && allowedNetworks.length > 0 || hideWallets ? appName != null ? appName : "This App" : "This Wallet",
|
|
193
|
-
" ",
|
|
194
|
-
"Only Supports:"
|
|
195
|
-
] }),
|
|
196
|
-
/* @__PURE__ */ jsx(CenteredText, { weight: "medium", color: "secondary", children: !!onRampConfig.allowedAssets && allowedNetworks.length > 0 ? formatNetworkList(allowedNetworks) : GENERIC_WALLET[activeWallet.type] })
|
|
197
|
-
] })
|
|
198
|
-
] }) })
|
|
199
|
-
] });
|
|
200
|
-
};
|
|
201
|
-
const SpinnerContainer = styled(StepContainer)`
|
|
202
|
-
margin: 50% 0;
|
|
203
|
-
`;
|
|
204
|
-
const $InnerStepContainer = styled(InnerStepContainer)`
|
|
205
|
-
position: relative;
|
|
206
|
-
min-height: 270px;
|
|
207
|
-
`;
|
|
208
|
-
const NoProviders = styled(CpslText)`
|
|
209
|
-
width: 100%;
|
|
210
|
-
text-align: center;
|
|
211
|
-
visibility: ${({ isHidden }) => isHidden ? "hidden" : "visible"};
|
|
212
|
-
position: absolute;
|
|
213
|
-
top: 0;
|
|
214
|
-
left: 0;
|
|
215
|
-
right: 0;
|
|
216
|
-
transition: visibility 0.2s;
|
|
217
|
-
`;
|
|
218
|
-
export {
|
|
219
|
-
AddFunds
|
|
220
|
-
};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
__spreadValues
|
|
4
|
-
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
-
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
import { StepContainer } from "../common.js";
|
|
7
|
-
import { OnRampProvider } from "@getpara/web-sdk";
|
|
8
|
-
import { useModalStore, useThemeStore } from "../../stores/index.js";
|
|
9
|
-
import { lazy, useEffect, useMemo, useState } from "react";
|
|
10
|
-
import { ModalStep } from "../../utils/steps.js";
|
|
11
|
-
import { RampEmbed, StripeEmbed } from "@getpara/react-common";
|
|
12
|
-
import styled from "styled-components";
|
|
13
|
-
import { useGoBack } from "../../hooks/useGoBack.js";
|
|
14
|
-
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
15
|
-
const STEPS = {
|
|
16
|
-
CANCELLED: ModalStep.ADD_FUNDS_FAILURE,
|
|
17
|
-
FINISHED: ModalStep.ADD_FUNDS_SUCCESS
|
|
18
|
-
};
|
|
19
|
-
const AddFundsAwaiting = () => {
|
|
20
|
-
const setStep = useModalStore((state) => state.setStep);
|
|
21
|
-
const goBack = useGoBack();
|
|
22
|
-
const onRampConfig = useModalStore((state) => state.onRampConfig);
|
|
23
|
-
const onRampPurchase = useModalStore((state) => state.onRampPurchase);
|
|
24
|
-
const setOnRampPurchase = useModalStore((state) => state.setOnRampPurchase);
|
|
25
|
-
const para = useInternalClient();
|
|
26
|
-
const appName = useThemeStore((state) => state.appName);
|
|
27
|
-
const isDark = useThemeStore((state) => state.isDark);
|
|
28
|
-
const [MoonPayEmbed, setMoonPayEmbed] = useState(null);
|
|
29
|
-
const props = {
|
|
30
|
-
para,
|
|
31
|
-
appName,
|
|
32
|
-
onRampConfig,
|
|
33
|
-
onRampPurchase,
|
|
34
|
-
isDark,
|
|
35
|
-
isEmbedded: true,
|
|
36
|
-
setOnRampPurchase,
|
|
37
|
-
onClose: goBack
|
|
38
|
-
};
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
const _MoonPayEmbed = lazy(() => import("./MoonPayEmbed.js"));
|
|
41
|
-
setMoonPayEmbed(_MoonPayEmbed);
|
|
42
|
-
}, []);
|
|
43
|
-
const onRampEmbed = useMemo(() => {
|
|
44
|
-
if (!onRampPurchase.id) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
switch (onRampPurchase == null ? void 0 : onRampPurchase.provider) {
|
|
48
|
-
case OnRampProvider.STRIPE:
|
|
49
|
-
return /* @__PURE__ */ jsx(StripeEmbed, __spreadValues({}, props));
|
|
50
|
-
case OnRampProvider.MOONPAY:
|
|
51
|
-
return !MoonPayEmbed || typeof window === "undefined" ? null : /* @__PURE__ */ jsx(MoonPayEmbed, __spreadValues({}, props));
|
|
52
|
-
case OnRampProvider.RAMP:
|
|
53
|
-
return /* @__PURE__ */ jsx(RampEmbed, __spreadValues({ apiKey: onRampConfig.rampApiKey }, props));
|
|
54
|
-
}
|
|
55
|
-
}, [onRampPurchase == null ? void 0 : onRampPurchase.provider, MoonPayEmbed]);
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
let timeoutId;
|
|
58
|
-
if ((onRampPurchase == null ? void 0 : onRampPurchase.status) && ["CANCELLED", "FINISHED"].includes(onRampPurchase.status)) {
|
|
59
|
-
timeoutId = setTimeout(() => {
|
|
60
|
-
setStep(STEPS[onRampPurchase.status]);
|
|
61
|
-
}, 5e3);
|
|
62
|
-
}
|
|
63
|
-
return () => clearTimeout(timeoutId);
|
|
64
|
-
}, [onRampPurchase == null ? void 0 : onRampPurchase.status]);
|
|
65
|
-
return /* @__PURE__ */ jsx(Container, { $wide: true, children: onRampEmbed });
|
|
66
|
-
};
|
|
67
|
-
const Container = styled(StepContainer)`
|
|
68
|
-
flex: 1;
|
|
69
|
-
`;
|
|
70
|
-
export {
|
|
71
|
-
AddFundsAwaiting
|
|
72
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import "../../../chunk-MMUBH76A.js";
|
|
3
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
-
import { Heading, HeroIcon, InnerStepContainer, StepContainer } from "../common.js";
|
|
5
|
-
import { useModalStore, useThemeStore } from "../../stores/index.js";
|
|
6
|
-
import { useMemo } from "react";
|
|
7
|
-
import { CpslButton, CpslText } from "@getpara/react-components";
|
|
8
|
-
import { getAddFundsStep } from "../../utils/steps.js";
|
|
9
|
-
const AddFundsDone = ({ isSuccess, onClose }) => {
|
|
10
|
-
const hideWallets = useThemeStore((state) => state.hideWallets);
|
|
11
|
-
const setStep = useModalStore((state) => state.setStep);
|
|
12
|
-
const onRampPurchase = useModalStore((state) => state.onRampPurchase);
|
|
13
|
-
const accountAddFundTab = useModalStore((state) => state.accountAddFundTab);
|
|
14
|
-
const formatter = useMemo(() => {
|
|
15
|
-
return new Intl.NumberFormat("en-US", {
|
|
16
|
-
style: "currency",
|
|
17
|
-
currency: (onRampPurchase == null ? void 0 : onRampPurchase.fiat) || "USD"
|
|
18
|
-
});
|
|
19
|
-
}, [onRampPurchase == null ? void 0 : onRampPurchase.fiat]);
|
|
20
|
-
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"}.`;
|
|
22
|
-
const buttonText = isSuccess ? "Done" : "Try Again";
|
|
23
|
-
return /* @__PURE__ */ jsxs(StepContainer, { children: [
|
|
24
|
-
/* @__PURE__ */ jsx(HeroIcon, { icon: "checkCircleFilled" }),
|
|
25
|
-
/* @__PURE__ */ jsxs(InnerStepContainer, { children: [
|
|
26
|
-
/* @__PURE__ */ jsx(Heading, { variant: "headingS", weight: "bold", children: heading }),
|
|
27
|
-
/* @__PURE__ */ jsx(CpslText, { variant: "bodyS", color: "secondary", children: text })
|
|
28
|
-
] }),
|
|
29
|
-
/* @__PURE__ */ jsx(
|
|
30
|
-
CpslButton,
|
|
31
|
-
{
|
|
32
|
-
fullWidth: true,
|
|
33
|
-
onClick: () => {
|
|
34
|
-
isSuccess ? onClose() : setStep(getAddFundsStep(accountAddFundTab));
|
|
35
|
-
},
|
|
36
|
-
children: buttonText
|
|
37
|
-
}
|
|
38
|
-
)
|
|
39
|
-
] });
|
|
40
|
-
};
|
|
41
|
-
export {
|
|
42
|
-
AddFundsDone
|
|
43
|
-
};
|