@getpara/react-sdk 2.0.0-alpha.3 → 2.0.0-alpha.6
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 +1 -6
- package/dist/index.js +11 -6499
- package/dist/modal/ParaModal.js +262 -0
- package/dist/modal/components/Account/Account.js +139 -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.js +262 -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 +157 -0
- package/dist/modal/components/AuthOptions/AuthOptions.d.ts +4 -3
- package/dist/modal/components/AuthOptions/AuthOptions.js +67 -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.js +63 -0
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +55 -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 +327 -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 +77 -0
- package/dist/modal/components/Controls/Selects.js +189 -0
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +144 -0
- package/dist/modal/components/ExternalWalletStep/config.js +17 -0
- package/dist/modal/components/ExternalWalletVerificationStep/ExternalWalletVerificationStep.js +34 -0
- package/dist/modal/components/ExternalWallets/ExternalWallets.js +173 -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 +54 -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.js +31 -0
- package/dist/modal/components/ModalContent/ModalContent.js +95 -0
- package/dist/modal/components/OAuth/FarcasterOAuthStep.js +27 -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.js +90 -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/StripeComponents/StripeComponents.js +88 -0
- package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +27 -0
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +143 -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 +73 -0
- package/dist/modal/components/common.d.ts +32 -13
- package/dist/modal/components/common.js +175 -0
- package/dist/modal/components/index.js +2 -0
- package/dist/modal/constants/constants.d.ts +9 -2
- package/dist/modal/constants/constants.js +138 -0
- package/dist/modal/constants/defaults.js +10 -0
- package/dist/modal/constants/oAuthLogos.d.ts +3 -3
- package/dist/modal/constants/oAuthLogos.js +24 -0
- package/dist/modal/hooks/useGoBack.js +43 -0
- package/dist/modal/index.d.ts +1 -2
- package/dist/modal/index.js +29 -0
- package/dist/modal/stores/index.js +2 -0
- package/dist/modal/stores/modal/actions.js +133 -0
- package/dist/modal/stores/modal/useModalStore.d.ts +12 -4
- package/dist/modal/stores/modal/useModalStore.js +68 -0
- package/dist/modal/types/commonTypes.d.ts +0 -47
- package/dist/modal/types/commonTypes.js +1 -0
- package/dist/modal/types/externalWallets.d.ts +2 -0
- package/dist/modal/types/externalWallets.js +32 -0
- package/dist/modal/types/modalProps.d.ts +10 -2
- package/dist/modal/types/modalProps.js +12 -0
- package/dist/modal/utils/authInputHelpers.d.ts +7 -0
- package/dist/modal/utils/authInputHelpers.js +38 -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/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 +6 -0
- package/dist/modal/utils/steps.js +247 -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 +83 -0
- package/dist/provider/actions/getAccount.d.ts +8 -1
- package/dist/provider/actions/getAccount.js +51 -0
- package/dist/provider/actions/getWallet.d.ts +2 -2
- package/dist/provider/actions/getWallet.js +14 -0
- package/dist/provider/actions/index.d.ts +2 -0
- package/dist/provider/actions/index.js +59 -0
- package/dist/provider/actions/utils.js +15 -0
- package/dist/provider/components/CosmosWalletWrapper.js +34 -0
- package/dist/provider/components/EvmWalletWrapper.js +34 -0
- package/dist/provider/components/ExternalWalletWrapper.js +139 -0
- package/dist/provider/components/SolanaWalletWrapper.js +36 -0
- package/dist/provider/external/getParaCosmosConnector.js +22 -0
- package/dist/provider/external/getParaEvmConnector.js +22 -0
- package/dist/provider/external/getParaSolanaConnector.js +22 -0
- package/dist/provider/external/stubs/CosmosExternalWalletContextStub.js +18 -0
- package/dist/provider/external/stubs/EvmExternalWalletContextStub.js +21 -0
- package/dist/provider/external/stubs/SolanaExternalWalletContextStub.js +14 -0
- package/dist/provider/hooks/index.js +4 -0
- package/dist/provider/hooks/mutations/index.d.ts +1 -0
- package/dist/provider/hooks/mutations/index.js +61 -0
- package/dist/provider/hooks/mutations/utils.js +22 -0
- package/dist/provider/hooks/queries/index.d.ts +1 -0
- package/dist/provider/hooks/queries/index.js +10 -0
- package/dist/provider/hooks/queries/useAccount.js +21 -0
- package/dist/provider/hooks/queries/useWallet.js +22 -0
- package/dist/provider/hooks/queries/useWalletBalance.d.ts +6 -0
- package/dist/provider/hooks/queries/useWalletBalance.js +55 -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.js +10 -0
- package/dist/provider/hooks/utils/useEventListeners.d.ts +1 -1
- package/dist/provider/hooks/utils/useEventListeners.js +147 -0
- package/dist/provider/hooks/utils/useInternalClient.js +10 -0
- package/dist/provider/hooks/utils/useModal.js +17 -0
- package/dist/provider/hooks/utils/useWalletState.d.ts +3 -3
- package/dist/provider/hooks/utils/useWalletState.js +48 -0
- package/dist/provider/index.js +9 -0
- package/dist/provider/providers/AuthProvider.d.ts +10 -6
- package/dist/provider/providers/AuthProvider.js +498 -0
- package/dist/provider/providers/CosmosExternalWalletProvider.js +66 -0
- package/dist/provider/providers/EvmExternalWalletProvider.js +74 -0
- package/dist/provider/providers/ExternalWalletProvider.d.ts +5 -2
- package/dist/provider/providers/ExternalWalletProvider.js +428 -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/client.js +9 -0
- package/dist/provider/stores/slices/config.js +9 -0
- package/dist/provider/stores/slices/externalWallets.js +40 -0
- package/dist/provider/stores/slices/index.js +5 -0
- package/dist/provider/stores/slices/modal.js +16 -0
- package/dist/provider/stores/slices/wallet.js +13 -0
- package/dist/provider/stores/types.d.ts +7 -4
- package/dist/provider/stores/types.js +1 -0
- package/dist/provider/stores/useStore.js +28 -0
- package/dist/provider/types/externalWalletProviders.d.ts +2 -2
- package/dist/provider/types/externalWalletProviders.js +1 -0
- package/dist/provider/types/provider.d.ts +9 -3
- package/dist/provider/types/provider.js +1 -0
- package/dist/provider/types/query.js +1 -0
- 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.js +18 -0
- package/package.json +18 -16
- 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/AuthInput → utils}/countryCodes.d.ts +0 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async,
|
|
4
|
+
__objRest,
|
|
5
|
+
__spreadValues
|
|
6
|
+
} from "../chunk-MMUBH76A.js";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
import { CpslAuthModal, defineCustomElements, generateTheme } from "@getpara/react-components";
|
|
9
|
+
import { ModalContent } from "./components/index.js";
|
|
10
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
11
|
+
import { useModalStore } from "./stores/index.js";
|
|
12
|
+
import { ModalStep, RESET_TO_ACCOUNT_STEPS, RESET_TO_AUTH_STEPS } from "./utils/steps.js";
|
|
13
|
+
import { AuthLayout } from "./types/modalProps.js";
|
|
14
|
+
import { DEFAULTS } from "./constants/defaults.js";
|
|
15
|
+
import { useGoBack } from "./hooks/useGoBack.js";
|
|
16
|
+
import styled from "styled-components";
|
|
17
|
+
import { hasEmbeddedAuth, hasExternalWallet } from "./utils/authLayoutHelpers.js";
|
|
18
|
+
import { useModal, useWalletState } from "../provider/index.js";
|
|
19
|
+
import { useInternalClient } from "../provider/hooks/utils/useInternalClient.js";
|
|
20
|
+
import { useExternalWallets } from "../provider/providers/ExternalWalletProvider.js";
|
|
21
|
+
import { useStore } from "../provider/stores/useStore.js";
|
|
22
|
+
import parsePhoneNumberFromString from "libphonenumber-js";
|
|
23
|
+
import { useAuthActions } from "../provider/providers/AuthProvider.js";
|
|
24
|
+
import { validateAuth } from "./utils/authInputHelpers.js";
|
|
25
|
+
defineCustomElements();
|
|
26
|
+
const ParaModal = forwardRef((props, ref) => {
|
|
27
|
+
const storedModalConfig = useStore((state) => state.modalConfig);
|
|
28
|
+
const modalContentRef = useRef(null);
|
|
29
|
+
const currentStep = useModalStore((state) => state.step);
|
|
30
|
+
const setAuthState = useModalStore((state) => state.setAuthState);
|
|
31
|
+
const setOnModalStepChange = useModalStore((state) => state.setOnModalStepChange);
|
|
32
|
+
const setStep = useModalStore((state) => state.setStep);
|
|
33
|
+
const hasPreviousStep = useModalStore((state) => state.hasPreviousStep());
|
|
34
|
+
const setFlow = useModalStore((state) => state.setFlow);
|
|
35
|
+
const setIsFullyLoggedIn = useModalStore((state) => state.setIsFullyLoggedIn);
|
|
36
|
+
const goBack = useGoBack();
|
|
37
|
+
const setAuthLayout = useModalStore((state) => state.setAuthLayout);
|
|
38
|
+
const storedAuthLayout = useModalStore((state) => state.authLayout);
|
|
39
|
+
const resetModalState = useModalStore((state) => state.resetState);
|
|
40
|
+
const setRecoveryShare = useModalStore((state) => state.setRecoveryShare);
|
|
41
|
+
const { disconnectExternalWallet } = useExternalWallets();
|
|
42
|
+
const { isOpen: storedIsOpen, closeModal } = useModal();
|
|
43
|
+
const para = useInternalClient();
|
|
44
|
+
const { setSelectedWallet, updateSelectedWallet } = useWalletState();
|
|
45
|
+
const setAuthStepRoute = useModalStore((state) => state.setAuthStepRoute);
|
|
46
|
+
const { signUpOrLogIn, isCreateGuestWalletsPending } = useAuthActions();
|
|
47
|
+
const [isModalMounted, setIsModalMounted] = useState(false);
|
|
48
|
+
const [isInit, setIsInit] = useState(false);
|
|
49
|
+
const externalWallets = useStore((state) => state.externalWallets);
|
|
50
|
+
const _a = __spreadValues(__spreadValues({}, storedModalConfig), props), {
|
|
51
|
+
isOpen: configIsOpen,
|
|
52
|
+
theme,
|
|
53
|
+
disableEmailLogin = false,
|
|
54
|
+
disablePhoneLogin = false,
|
|
55
|
+
isGuestModeEnabled = false,
|
|
56
|
+
oAuthMethods = ["GOOGLE", "TWITTER"],
|
|
57
|
+
bareModal = false,
|
|
58
|
+
className,
|
|
59
|
+
currentStepOverride,
|
|
60
|
+
authLayout = [AuthLayout.AUTH_FULL, AuthLayout.EXTERNAL_FULL],
|
|
61
|
+
embeddedModal,
|
|
62
|
+
onModalStepChange,
|
|
63
|
+
onClose,
|
|
64
|
+
defaultAuthIdentifier
|
|
65
|
+
} = _a, rest = __objRest(_a, [
|
|
66
|
+
"isOpen",
|
|
67
|
+
"theme",
|
|
68
|
+
"disableEmailLogin",
|
|
69
|
+
"disablePhoneLogin",
|
|
70
|
+
"isGuestModeEnabled",
|
|
71
|
+
"oAuthMethods",
|
|
72
|
+
"bareModal",
|
|
73
|
+
"className",
|
|
74
|
+
"currentStepOverride",
|
|
75
|
+
"authLayout",
|
|
76
|
+
"embeddedModal",
|
|
77
|
+
"onModalStepChange",
|
|
78
|
+
"onClose",
|
|
79
|
+
"defaultAuthIdentifier"
|
|
80
|
+
]);
|
|
81
|
+
const isOpen = configIsOpen != null ? configIsOpen : storedIsOpen;
|
|
82
|
+
useImperativeHandle(ref, () => {
|
|
83
|
+
return {
|
|
84
|
+
goBack() {
|
|
85
|
+
goBack();
|
|
86
|
+
},
|
|
87
|
+
canGoBack() {
|
|
88
|
+
return hasPreviousStep;
|
|
89
|
+
},
|
|
90
|
+
currentStep() {
|
|
91
|
+
return currentStep;
|
|
92
|
+
},
|
|
93
|
+
handleModalClose() {
|
|
94
|
+
var _a2;
|
|
95
|
+
(_a2 = modalContentRef == null ? void 0 : modalContentRef.current) == null ? void 0 : _a2.handleModalClose();
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}, [hasPreviousStep, currentStep]);
|
|
99
|
+
const initModal = (shouldAutoLogin) => __async(void 0, null, function* () {
|
|
100
|
+
var _a2;
|
|
101
|
+
const isAccount = yield para.isFullyLoggedIn(), isGuest = isAccount && para.isGuestMode || isCreateGuestWalletsPending;
|
|
102
|
+
switch (true) {
|
|
103
|
+
case !!currentStepOverride:
|
|
104
|
+
setStep(ModalStep[currentStepOverride.toUpperCase()]);
|
|
105
|
+
break;
|
|
106
|
+
case isGuest:
|
|
107
|
+
setFlow("guest");
|
|
108
|
+
setStep(isCreateGuestWalletsPending ? ModalStep.AWAITING_GUEST_WALLET_CREATION : ModalStep.ACCOUNT_MAIN);
|
|
109
|
+
setIsFullyLoggedIn(true);
|
|
110
|
+
break;
|
|
111
|
+
case isAccount:
|
|
112
|
+
setFlow("account");
|
|
113
|
+
setStep(ModalStep.ACCOUNT_MAIN);
|
|
114
|
+
setIsFullyLoggedIn(true);
|
|
115
|
+
break;
|
|
116
|
+
default:
|
|
117
|
+
if (currentStep !== ModalStep.AUTH_MAIN && currentStep !== ModalStep.SECRET) {
|
|
118
|
+
setFlow(void 0);
|
|
119
|
+
setStep(para.isTelegram ? ModalStep.TELEGRAM_OAUTH : ModalStep.AUTH_MAIN);
|
|
120
|
+
setAuthState();
|
|
121
|
+
setAuthStepRoute();
|
|
122
|
+
}
|
|
123
|
+
yield disconnectExternalWallet();
|
|
124
|
+
setSelectedWallet({ id: void 0, type: void 0 });
|
|
125
|
+
setIsFullyLoggedIn(false);
|
|
126
|
+
if (shouldAutoLogin) {
|
|
127
|
+
if (defaultAuthIdentifier && ((_a2 = para.authInfo) == null ? void 0 : _a2.identifier) !== defaultAuthIdentifier) {
|
|
128
|
+
const number = parsePhoneNumberFromString(defaultAuthIdentifier);
|
|
129
|
+
try {
|
|
130
|
+
const auth = validateAuth(
|
|
131
|
+
number ? number.nationalNumber : defaultAuthIdentifier,
|
|
132
|
+
(number == null ? void 0 : number.countryCallingCode) ? `+${number == null ? void 0 : number.countryCallingCode}` : void 0,
|
|
133
|
+
number ? "phone" : "email"
|
|
134
|
+
);
|
|
135
|
+
para.setAuth(number ? { phone: defaultAuthIdentifier } : { email: defaultAuthIdentifier });
|
|
136
|
+
signUpOrLogIn(auth);
|
|
137
|
+
} catch (err) {
|
|
138
|
+
console.error("invalid user identifier:", err.message);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
setIsInit(true);
|
|
145
|
+
});
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
let _authLayout = authLayout;
|
|
148
|
+
if (!(externalWallets == null ? void 0 : externalWallets.length) && hasExternalWallet(authLayout)) {
|
|
149
|
+
_authLayout = _authLayout.filter((l) => !l.includes("EXTERNAL"));
|
|
150
|
+
}
|
|
151
|
+
if (disableEmailLogin && disablePhoneLogin && !(oAuthMethods == null ? void 0 : oAuthMethods.length) && hasEmbeddedAuth(authLayout)) {
|
|
152
|
+
_authLayout = _authLayout.filter((l) => !l.includes("AUTH"));
|
|
153
|
+
}
|
|
154
|
+
if (JSON.stringify(storedAuthLayout) !== JSON.stringify(_authLayout)) {
|
|
155
|
+
setAuthLayout(_authLayout);
|
|
156
|
+
}
|
|
157
|
+
}, [disableEmailLogin, disablePhoneLogin, oAuthMethods, externalWallets, authLayout, storedAuthLayout]);
|
|
158
|
+
useEffect(() => {
|
|
159
|
+
if (theme) {
|
|
160
|
+
generateTheme(theme);
|
|
161
|
+
}
|
|
162
|
+
}, [theme]);
|
|
163
|
+
useEffect(() => {
|
|
164
|
+
setOnModalStepChange(onModalStepChange);
|
|
165
|
+
}, [onModalStepChange]);
|
|
166
|
+
useEffect(() => {
|
|
167
|
+
if (para) {
|
|
168
|
+
initModal();
|
|
169
|
+
} else {
|
|
170
|
+
console.error("A Para instance must be provided.");
|
|
171
|
+
}
|
|
172
|
+
}, []);
|
|
173
|
+
useEffect(() => {
|
|
174
|
+
if (isOpen && para) {
|
|
175
|
+
initModal(true);
|
|
176
|
+
}
|
|
177
|
+
}, [isOpen]);
|
|
178
|
+
useEffect(() => {
|
|
179
|
+
updateSelectedWallet();
|
|
180
|
+
}, [para]);
|
|
181
|
+
const handleClose = () => {
|
|
182
|
+
closeModal();
|
|
183
|
+
onClose == null ? void 0 : onClose();
|
|
184
|
+
};
|
|
185
|
+
const handleModalEntering = () => {
|
|
186
|
+
setIsModalMounted(true);
|
|
187
|
+
};
|
|
188
|
+
const handleModalExited = () => __async(void 0, null, function* () {
|
|
189
|
+
setIsModalMounted(false);
|
|
190
|
+
if (RESET_TO_AUTH_STEPS.includes(currentStep)) {
|
|
191
|
+
resetModalState();
|
|
192
|
+
setRecoveryShare(null);
|
|
193
|
+
} else if (RESET_TO_ACCOUNT_STEPS.includes(currentStep)) {
|
|
194
|
+
setStep(ModalStep.LOGIN_DONE);
|
|
195
|
+
}
|
|
196
|
+
if (para) {
|
|
197
|
+
yield initModal();
|
|
198
|
+
}
|
|
199
|
+
setIsInit(false);
|
|
200
|
+
});
|
|
201
|
+
if (!para) {
|
|
202
|
+
console.error("A Para instance is required.");
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
if (!(storedAuthLayout == null ? void 0 : storedAuthLayout.length)) {
|
|
206
|
+
const hasExternalWalletError = !(externalWallets == null ? void 0 : externalWallets.length) && hasExternalWallet(authLayout);
|
|
207
|
+
const hasEmbeddedWalletError = disableEmailLogin && disablePhoneLogin && !(oAuthMethods == null ? void 0 : oAuthMethods.length) && hasEmbeddedAuth(authLayout);
|
|
208
|
+
if (hasExternalWalletError || hasEmbeddedWalletError) {
|
|
209
|
+
if (hasExternalWalletError) {
|
|
210
|
+
console.error("At least one external wallet must be provided if external wallet auth is enabled.");
|
|
211
|
+
}
|
|
212
|
+
if (hasEmbeddedWalletError) {
|
|
213
|
+
console.error(
|
|
214
|
+
"At least one login method (email, phone or OAuth) must be provided if embedded wallet auth is enabled."
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
} else {
|
|
218
|
+
console.error("At least one auth layout selection is required.");
|
|
219
|
+
}
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
return /* @__PURE__ */ jsx(
|
|
223
|
+
StyledAuthModal,
|
|
224
|
+
{
|
|
225
|
+
enterTransitionDuration: DEFAULTS.ANIMATION_DURATION,
|
|
226
|
+
exitTransitionDuration: DEFAULTS.ANIMATION_DURATION,
|
|
227
|
+
open: isOpen,
|
|
228
|
+
onCpslModalExited: handleModalExited,
|
|
229
|
+
onCpslModalEntering: handleModalEntering,
|
|
230
|
+
onCpslModalRequestClose: handleClose,
|
|
231
|
+
noOverlay: bareModal,
|
|
232
|
+
className,
|
|
233
|
+
"data-testid": "modal",
|
|
234
|
+
$embeddedModal: !!embeddedModal,
|
|
235
|
+
children: isModalMounted && ((embeddedModal || bareModal) && isInit || !embeddedModal && !bareModal) && /* @__PURE__ */ jsx(
|
|
236
|
+
ModalContent,
|
|
237
|
+
__spreadValues({
|
|
238
|
+
oAuthMethods,
|
|
239
|
+
disableEmailLogin,
|
|
240
|
+
disablePhoneLogin,
|
|
241
|
+
isGuestModeEnabled,
|
|
242
|
+
onClose: handleClose
|
|
243
|
+
}, rest)
|
|
244
|
+
)
|
|
245
|
+
}
|
|
246
|
+
);
|
|
247
|
+
});
|
|
248
|
+
const StyledAuthModal = styled(CpslAuthModal)`
|
|
249
|
+
${({ $embeddedModal }) => $embeddedModal && `
|
|
250
|
+
&::part(modal-body-card) {
|
|
251
|
+
--card-box-shadow: none;
|
|
252
|
+
--card-border-width: 0px;
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
&::part(modal-footer) {
|
|
256
|
+
--card-box-shadow: none;
|
|
257
|
+
--card-border-width: 0px;
|
|
258
|
+
};`}
|
|
259
|
+
`;
|
|
260
|
+
export {
|
|
261
|
+
ParaModal
|
|
262
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
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 { OnRampStep, useModalStore } from "../../stores/index.js";
|
|
10
|
+
import { 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
|
+
const Account = ({ onClose }) => {
|
|
19
|
+
const onRampConfig = useModalStore((state) => state.onRampConfig);
|
|
20
|
+
const setStep = useModalStore((state) => state.setStep);
|
|
21
|
+
const setFlow = useModalStore((state) => state.setFlow);
|
|
22
|
+
const setGuestAddFundsTab = useModalStore((state) => state.setGuestAddFundsTab);
|
|
23
|
+
const setOnRampStep = useModalStore((state) => state.setOnRampStep);
|
|
24
|
+
const hideWallets = useStore((state) => {
|
|
25
|
+
var _a;
|
|
26
|
+
return (_a = state.modalConfig) == null ? void 0 : _a.hideWallets;
|
|
27
|
+
});
|
|
28
|
+
const { disconnectExternalWallet } = useExternalWallets();
|
|
29
|
+
const para = useInternalClient();
|
|
30
|
+
const { data: account } = useAccount();
|
|
31
|
+
const { data: balance, isLoading: isBalanceLoading } = useWalletBalance();
|
|
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;
|
|
35
|
+
const isOnRampLoaded = !!onRampConfig;
|
|
36
|
+
const handleBuyClick = () => {
|
|
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
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const handleReceiveClick = () => {
|
|
46
|
+
setStep(ModalStep.ADD_FUNDS_RECEIVE);
|
|
47
|
+
};
|
|
48
|
+
const handleSellClick = () => {
|
|
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
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const handleDisconnectClick = () => __async(void 0, null, function* () {
|
|
58
|
+
setIsDisconnecting(true);
|
|
59
|
+
yield para.logout();
|
|
60
|
+
yield disconnectExternalWallet();
|
|
61
|
+
onClose();
|
|
62
|
+
setStep(ModalStep.AUTH_MAIN);
|
|
63
|
+
setFlow(void 0);
|
|
64
|
+
setIsDisconnecting(false);
|
|
65
|
+
});
|
|
66
|
+
return /* @__PURE__ */ jsx(StepContainer, { $wide: true, children: /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
|
|
67
|
+
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) }) }),
|
|
68
|
+
isGuestMode && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
69
|
+
balance && parseFloat(balance) > 0 && /* @__PURE__ */ jsxs(Alert, { children: [
|
|
70
|
+
/* @__PURE__ */ jsx(CpslIcon, { icon: "alertTriangle", size: "24px", style: { color: "var(--cpsl-color-utility-yellow)" } }),
|
|
71
|
+
"You've funded this account - complete account setup to maintain access."
|
|
72
|
+
] }),
|
|
73
|
+
/* @__PURE__ */ jsxs(
|
|
74
|
+
CpslButton,
|
|
75
|
+
{
|
|
76
|
+
fullWidth: true,
|
|
77
|
+
variant: "primary",
|
|
78
|
+
onClick: () => {
|
|
79
|
+
setStep(ModalStep.AUTH_GUEST_SIGNUP);
|
|
80
|
+
},
|
|
81
|
+
children: [
|
|
82
|
+
/* @__PURE__ */ jsx(CpslIcon, { icon: "stars02" }),
|
|
83
|
+
"Complete Account Setup"
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
)
|
|
87
|
+
] }),
|
|
88
|
+
/* @__PURE__ */ jsx(ButtonContainer, { children: isOnRampLoaded ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
89
|
+
onRampConfig.isBuyEnabled && !cantBuyAndWithdraw && /* @__PURE__ */ jsx(OptionButton, { icon: "creditCard", onClick: handleBuyClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Buy Crypto" }) }),
|
|
90
|
+
onRampConfig.isReceiveEnabled && /* @__PURE__ */ jsx(OptionButton, { icon: "qrCode02", onClick: handleReceiveClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Receive" }) }),
|
|
91
|
+
onRampConfig.isWithdrawEnabled && !cantBuyAndWithdraw && /* @__PURE__ */ jsx(OptionButton, { icon: "arrowCircleBrokenDownLeft", onClick: handleSellClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Withdraw" }) })
|
|
92
|
+
] }) : /* @__PURE__ */ jsx(CpslSpinner, {}) }),
|
|
93
|
+
!isGuestMode && /* @__PURE__ */ jsx(DisconnectButton, { variant: "destructive", fullWidth: true, onClick: handleDisconnectClick, disabled: isDisconnecting, children: isDisconnecting ? /* @__PURE__ */ jsx(CpslSpinner, { size: 16 }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
94
|
+
hideWallets ? "Logout" : "Disconnect Wallet",
|
|
95
|
+
/* @__PURE__ */ jsx(CpslIcon, { icon: "logOut", slot: "end" })
|
|
96
|
+
] }) })
|
|
97
|
+
] }) });
|
|
98
|
+
};
|
|
99
|
+
const ButtonContainer = styled.div`
|
|
100
|
+
display: flex;
|
|
101
|
+
align-items: center;
|
|
102
|
+
justify-content: center;
|
|
103
|
+
gap: 8px;
|
|
104
|
+
width: 100%;
|
|
105
|
+
height: 88px;
|
|
106
|
+
`;
|
|
107
|
+
const OptionButton = styled(StyledCpslTileButton)`
|
|
108
|
+
flex: 1;
|
|
109
|
+
|
|
110
|
+
--button-icon-color: var(--cpsl-color-text-primary);
|
|
111
|
+
`;
|
|
112
|
+
const DisconnectButton = styled(CpslButton)`
|
|
113
|
+
--button-border-width: 0px;
|
|
114
|
+
`;
|
|
115
|
+
const BalanceContainer = styled.div`
|
|
116
|
+
display: flex;
|
|
117
|
+
justify-content: center;
|
|
118
|
+
align-items: center;
|
|
119
|
+
padding-top: 8px;
|
|
120
|
+
padding-bottom: 24px;
|
|
121
|
+
`;
|
|
122
|
+
const Alert = styled.div`
|
|
123
|
+
--icon-color: var(--cpsl-color-utility-yellow);
|
|
124
|
+
--icon-stroke-color: var(--cpsl-color-utility-yellow);
|
|
125
|
+
--icon-fill-color: var(--cpsl-color-utility-yellow);
|
|
126
|
+
|
|
127
|
+
display: flex;
|
|
128
|
+
padding: 8px;
|
|
129
|
+
align-items: flex-start;
|
|
130
|
+
gap: 8px;
|
|
131
|
+
align-self: stretch;
|
|
132
|
+
border-radius: var(--cpsl-border-radius-alert);
|
|
133
|
+
border: 1px solid var(--cpsl-color-utility-yellow);
|
|
134
|
+
background: var(--cpsl-color-utility-yellow-light);
|
|
135
|
+
font-size: 14px;
|
|
136
|
+
`;
|
|
137
|
+
export {
|
|
138
|
+
Account
|
|
139
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../../chunk-MMUBH76A.js";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { EnabledFlow } from "@getpara/web-sdk";
|
|
5
|
+
import { InnerStepContainer, StepContainer } from "../common.js";
|
|
6
|
+
import { CpslIcon, CpslSpinner, CpslTab, CpslTabs } from "@getpara/react-components";
|
|
7
|
+
import { OnRampStep } from "../../stores/index.js";
|
|
8
|
+
import { useModalStore } from "../../stores/modal/useModalStore.js";
|
|
9
|
+
import { useEffect, useMemo } from "react";
|
|
10
|
+
import { getAddFundsStep } from "../../utils/steps.js";
|
|
11
|
+
import styled from "styled-components";
|
|
12
|
+
import { useAccount, useWallet } from "../../../provider/index.js";
|
|
13
|
+
import { AddFundsProvider } from "./AddFundsProvider.js";
|
|
14
|
+
import { AddFundsReceive } from "./AddFundsReceive.js";
|
|
15
|
+
import { AddFundsContextProvider, TABS } from "./AddFundsContext.js";
|
|
16
|
+
import { AnimatePresence } from "framer-motion";
|
|
17
|
+
import { AddFundsSettings } from "./AddFundsSettings.js";
|
|
18
|
+
const AddFunds = () => {
|
|
19
|
+
const onRampConfig = useModalStore((state) => state.onRampConfig);
|
|
20
|
+
const onRampStep = useModalStore((state) => state.onRampStep);
|
|
21
|
+
const storedTab = useModalStore((state) => state.accountAddFundTab);
|
|
22
|
+
const setModalStep = useModalStore((state) => state.setStep);
|
|
23
|
+
const setOnRampPurchase = useModalStore((state) => state.setOnRampPurchase);
|
|
24
|
+
const { data: activeWallet } = useWallet();
|
|
25
|
+
const { data: account } = useAccount();
|
|
26
|
+
const isGuestMode = (account == null ? void 0 : account.isConnected) && account.isGuestMode;
|
|
27
|
+
const tabs = TABS.filter(
|
|
28
|
+
([enabledFlow, key]) => !!(onRampConfig == null ? void 0 : onRampConfig[key]) && (!isGuestMode || enabledFlow === EnabledFlow.RECEIVE)
|
|
29
|
+
);
|
|
30
|
+
const tab = storedTab != null ? storedTab : tabs[0][0];
|
|
31
|
+
const isMultiFlow = tabs.length > 1;
|
|
32
|
+
const onSetTab = (event) => {
|
|
33
|
+
setModalStep(getAddFundsStep(event.detail.tab));
|
|
34
|
+
};
|
|
35
|
+
const Content = useMemo(() => {
|
|
36
|
+
switch (tab) {
|
|
37
|
+
case EnabledFlow.BUY:
|
|
38
|
+
case EnabledFlow.WITHDRAW: {
|
|
39
|
+
switch (onRampStep) {
|
|
40
|
+
case OnRampStep.SETTINGS:
|
|
41
|
+
return /* @__PURE__ */ jsx(AddFundsSettings, {});
|
|
42
|
+
case OnRampStep.PROVIDER:
|
|
43
|
+
return /* @__PURE__ */ jsx(AddFundsProvider, {});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
default:
|
|
47
|
+
return /* @__PURE__ */ jsx(AddFundsReceive, {});
|
|
48
|
+
}
|
|
49
|
+
}, [onRampStep, tab]);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
setOnRampPurchase(void 0);
|
|
52
|
+
}, []);
|
|
53
|
+
if (!onRampConfig || !activeWallet) {
|
|
54
|
+
return /* @__PURE__ */ jsx(SpinnerContainer, { children: /* @__PURE__ */ jsx(CpslSpinner, {}) });
|
|
55
|
+
}
|
|
56
|
+
return /* @__PURE__ */ jsxs(StepContainer, { children: [
|
|
57
|
+
isMultiFlow && /* @__PURE__ */ jsx(InnerStepContainer, { children: /* @__PURE__ */ jsx(CpslTabs, { selectedTab: tab, onCpslTabsChanged: onSetTab, children: TABS.map(([tab2, _, icon, title]) => /* @__PURE__ */ jsxs(CpslTab, { tab: tab2, children: [
|
|
58
|
+
/* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon }),
|
|
59
|
+
title
|
|
60
|
+
] }, tab2)) }) }),
|
|
61
|
+
/* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", children: /* @__PURE__ */ jsx(AddFundsContextProvider, { "data-testid": "add-funds", tab, children: Content }) })
|
|
62
|
+
] });
|
|
63
|
+
};
|
|
64
|
+
const SpinnerContainer = styled(StepContainer)`
|
|
65
|
+
margin: 50% 0;
|
|
66
|
+
`;
|
|
67
|
+
export {
|
|
68
|
+
AddFunds
|
|
69
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function AddFundsAsset(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,125 @@
|
|
|
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 * as comp from "@getpara/react-components";
|
|
9
|
+
import { getOnRampNetworks } from "@getpara/web-sdk";
|
|
10
|
+
import styled from "styled-components";
|
|
11
|
+
import { getAssetCode, getAssetName, ON_RAMP_ASSETS } from "../../constants/constants.js";
|
|
12
|
+
import { useModalStore } from "../../stores/index.js";
|
|
13
|
+
import { useRef, useState } from "react";
|
|
14
|
+
import { useAddFunds } from "./AddFundsContext.js";
|
|
15
|
+
import { useWallet } from "../../../provider/hooks/queries/useWallet.js";
|
|
16
|
+
import { AssetIcon } from "../common.js";
|
|
17
|
+
import { AnimatePresence, motion } from "framer-motion";
|
|
18
|
+
import { contentMotionProps } from "./common.js";
|
|
19
|
+
function AddFundsAsset() {
|
|
20
|
+
const onRampConfig = useModalStore((state) => state.onRampConfig);
|
|
21
|
+
const { assets, setAsset, network, setNetwork } = useAddFunds();
|
|
22
|
+
const { data: activeWallet } = useWallet();
|
|
23
|
+
const [isAtBottom, setIsAtBottom] = useState(false);
|
|
24
|
+
const [isAtTop, setIsAtTop] = useState(true);
|
|
25
|
+
const [searchStr, setSearchStr] = useState("");
|
|
26
|
+
const ref = useRef(null);
|
|
27
|
+
const onSelect = (_asset) => __async(this, null, function* () {
|
|
28
|
+
yield setAsset(_asset);
|
|
29
|
+
if (!network && !!onRampConfig && !!activeWallet) {
|
|
30
|
+
yield setNetwork(
|
|
31
|
+
getOnRampNetworks(onRampConfig.assetInfo, {
|
|
32
|
+
walletType: activeWallet.type,
|
|
33
|
+
assets: [_asset]
|
|
34
|
+
})[0]
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const onScroll = () => {
|
|
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
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
54
|
+
/* @__PURE__ */ jsx(AnimatePresence, { mode: "sync", children: assets.length >= 4 && /* @__PURE__ */ jsx(motion.div, __spreadProps(__spreadValues({}, contentMotionProps), { children: /* @__PURE__ */ jsx(
|
|
55
|
+
SearchInput,
|
|
56
|
+
{
|
|
57
|
+
placeholder: "Search for an asset",
|
|
58
|
+
value: searchStr,
|
|
59
|
+
onCpslInput: (e) => {
|
|
60
|
+
setSearchStr(e.detail.value);
|
|
61
|
+
},
|
|
62
|
+
children: /* @__PURE__ */ jsx(comp.CpslIcon, { icon: "search", slot: "start" })
|
|
63
|
+
}
|
|
64
|
+
) })) }),
|
|
65
|
+
/* @__PURE__ */ jsx(ScrollContainer, { isAtBottom, isAtTop, ref, onScroll, children: /* @__PURE__ */ jsx(AssetList, { children: /* @__PURE__ */ jsx(AnimatePresence, { mode: "sync", children: assets.filter((asset) => {
|
|
66
|
+
return searchStr === "" || getAssetCode(asset).toLowerCase().startsWith(searchStr.toLowerCase()) || getAssetName(asset).toLowerCase().startsWith(searchStr.toLowerCase());
|
|
67
|
+
}).map((asset) => /* @__PURE__ */ jsx(
|
|
68
|
+
motion.li,
|
|
69
|
+
{
|
|
70
|
+
style: { width: "100%" },
|
|
71
|
+
initial: { opacity: 0 },
|
|
72
|
+
animate: { opacity: 1 },
|
|
73
|
+
exit: { opacity: 0 },
|
|
74
|
+
transition: { duration: 0.2 },
|
|
75
|
+
children: /* @__PURE__ */ jsxs(AssetButton, { fullWidth: true, variant: "secondary", onClick: () => onSelect(asset), children: [
|
|
76
|
+
/* @__PURE__ */ jsx(AssetIcon, { asset, size: "48px" }),
|
|
77
|
+
/* @__PURE__ */ jsxs(Info, { children: [
|
|
78
|
+
/* @__PURE__ */ jsx(Code, { variant: "bodyL", children: ON_RAMP_ASSETS[asset].code }),
|
|
79
|
+
/* @__PURE__ */ jsx(Name, { variant: "bodyS", children: ON_RAMP_ASSETS[asset].name })
|
|
80
|
+
] })
|
|
81
|
+
] }, asset)
|
|
82
|
+
},
|
|
83
|
+
asset
|
|
84
|
+
)) }) }) })
|
|
85
|
+
] });
|
|
86
|
+
}
|
|
87
|
+
const ScrollContainer = styled.div`
|
|
88
|
+
height: calc(100% - 56px);
|
|
89
|
+
width: 100%;
|
|
90
|
+
display: flex;
|
|
91
|
+
flex-direction: column;
|
|
92
|
+
gap: 8px;
|
|
93
|
+
overflow-y: auto;
|
|
94
|
+
mask-image: ${({ isAtBottom, isAtTop }) => !isAtBottom && !isAtTop ? "linear-gradient(to bottom, transparent 0%, black 24px, black calc(100% - 24px), transparent 100%)" : !isAtBottom ? "linear-gradient(to bottom, black calc(100% - 24px), transparent 100%)" : !isAtTop ? "linear-gradient(to top, black calc(100% - 24px), transparent 100%)" : "none"};
|
|
95
|
+
`;
|
|
96
|
+
const AssetList = styled.ul`
|
|
97
|
+
display: flex;
|
|
98
|
+
flex-direction: column;
|
|
99
|
+
width: 100%;
|
|
100
|
+
gap: 8px;
|
|
101
|
+
list-style: none;
|
|
102
|
+
padding-inline-start: 0;
|
|
103
|
+
margin: 0;
|
|
104
|
+
padding: 0px;
|
|
105
|
+
`;
|
|
106
|
+
const AssetButton = styled(comp.CpslButton)`
|
|
107
|
+
display: flex;
|
|
108
|
+
justify-content: center;
|
|
109
|
+
align-items: center;
|
|
110
|
+
gap: 8px;
|
|
111
|
+
--button-secondary-background-color: var(--cpsl-color-background-8);
|
|
112
|
+
--button-secondary-border-color: var(--cpsl-color-background-8);
|
|
113
|
+
--button-secondary-hover-background-color: var(--cpsl-color-background-16);
|
|
114
|
+
--button-secondary-hover-border-color: var(--cpsl-color-background-16);
|
|
115
|
+
`;
|
|
116
|
+
const Info = styled(comp.CpslCol)`
|
|
117
|
+
text-align: left;
|
|
118
|
+
`, Code = comp.CpslText, Name = comp.CpslText;
|
|
119
|
+
const SearchInput = styled(comp.CpslInput)`
|
|
120
|
+
--container-background-color: var(--cpsl-color-background-8);
|
|
121
|
+
--input-background-color: transparent;
|
|
122
|
+
`;
|
|
123
|
+
export {
|
|
124
|
+
AddFundsAsset
|
|
125
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__spreadProps,
|
|
4
|
+
__spreadValues
|
|
5
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { StepContainer } from "../common.js";
|
|
8
|
+
import { OnRampProvider } from "@getpara/web-sdk";
|
|
9
|
+
import { useModalStore } from "../../stores/index.js";
|
|
10
|
+
import { lazy, useEffect, useMemo, useState } from "react";
|
|
11
|
+
import { ModalStep } from "../../utils/steps.js";
|
|
12
|
+
import { RampEmbed, StripeEmbed } from "@getpara/react-common";
|
|
13
|
+
import styled from "styled-components";
|
|
14
|
+
import { useGoBack } from "../../hooks/useGoBack.js";
|
|
15
|
+
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
16
|
+
import { useStore } from "../../../provider/stores/useStore.js";
|
|
17
|
+
const STEPS = {
|
|
18
|
+
CANCELLED: ModalStep.ADD_FUNDS_FAILURE,
|
|
19
|
+
FINISHED: ModalStep.ADD_FUNDS_SUCCESS
|
|
20
|
+
};
|
|
21
|
+
const AddFundsAwaiting = () => {
|
|
22
|
+
const setStep = useModalStore((state) => state.setStep);
|
|
23
|
+
const goBack = useGoBack();
|
|
24
|
+
const onRampConfig = useModalStore((state) => state.onRampConfig);
|
|
25
|
+
const onRampPurchase = useModalStore((state) => state.onRampPurchase);
|
|
26
|
+
const setOnRampPurchase = useModalStore((state) => state.setOnRampPurchase);
|
|
27
|
+
const para = useInternalClient();
|
|
28
|
+
const appName = useStore((state) => state.appName);
|
|
29
|
+
const isDark = useStore((state) => state.isDarkTheme);
|
|
30
|
+
const [MoonPayEmbed, setMoonPayEmbed] = useState();
|
|
31
|
+
const props = {
|
|
32
|
+
para,
|
|
33
|
+
appName,
|
|
34
|
+
onRampConfig,
|
|
35
|
+
onRampPurchase,
|
|
36
|
+
isDark,
|
|
37
|
+
isEmbedded: true,
|
|
38
|
+
setOnRampPurchase,
|
|
39
|
+
onClose: goBack
|
|
40
|
+
};
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
const _MoonPayEmbed = lazy(() => import("./MoonPayEmbed.js"));
|
|
43
|
+
if (_MoonPayEmbed) {
|
|
44
|
+
setMoonPayEmbed(_MoonPayEmbed);
|
|
45
|
+
}
|
|
46
|
+
}, []);
|
|
47
|
+
const onRampEmbed = useMemo(() => {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
if (!(onRampPurchase == null ? void 0 : onRampPurchase.id) || !props.onRampConfig) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
switch (onRampPurchase == null ? void 0 : onRampPurchase.provider) {
|
|
53
|
+
case OnRampProvider.STRIPE:
|
|
54
|
+
return /* @__PURE__ */ jsx(StripeEmbed, __spreadProps(__spreadValues({}, props), { onRampConfig: props.onRampConfig }));
|
|
55
|
+
case OnRampProvider.MOONPAY:
|
|
56
|
+
return !MoonPayEmbed || typeof window === "undefined" ? null : /* @__PURE__ */ jsx(MoonPayEmbed, __spreadProps(__spreadValues({}, props), { onRampConfig: props.onRampConfig }));
|
|
57
|
+
case OnRampProvider.RAMP:
|
|
58
|
+
return /* @__PURE__ */ jsx(RampEmbed, __spreadProps(__spreadValues({}, props), { apiKey: (_b = (_a = props.onRampConfig) == null ? void 0 : _a.rampApiKey) != null ? _b : "", onRampConfig: props.onRampConfig }));
|
|
59
|
+
}
|
|
60
|
+
}, [onRampPurchase == null ? void 0 : onRampPurchase.provider, MoonPayEmbed]);
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
let timeoutId;
|
|
63
|
+
if ((onRampPurchase == null ? void 0 : onRampPurchase.status) && ["CANCELLED", "FINISHED"].includes(onRampPurchase.status)) {
|
|
64
|
+
timeoutId = setTimeout(() => {
|
|
65
|
+
var _a;
|
|
66
|
+
setStep(STEPS[(_a = onRampPurchase.status) != null ? _a : ""]);
|
|
67
|
+
}, 5e3);
|
|
68
|
+
}
|
|
69
|
+
return () => clearTimeout(timeoutId);
|
|
70
|
+
}, [onRampPurchase == null ? void 0 : onRampPurchase.status]);
|
|
71
|
+
return /* @__PURE__ */ jsx(Container, { $wide: true, children: onRampEmbed });
|
|
72
|
+
};
|
|
73
|
+
const Container = styled(StepContainer)`
|
|
74
|
+
flex: 1;
|
|
75
|
+
`;
|
|
76
|
+
export {
|
|
77
|
+
AddFundsAwaiting
|
|
78
|
+
};
|