@getpara/react-sdk 1.1.0 → 1.3.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/MoonPayEmbed-GAWXP6V7.js +2 -0
- package/dist/MoonPayEmbed-GAWXP6V7.js.br +0 -0
- package/dist/MoonPayEmbed-GAWXP6V7.js.gz +0 -0
- package/dist/index.js +675 -5
- package/dist/index.js.br +0 -0
- package/dist/index.js.gz +0 -0
- package/dist/provider/hooks/utils/useEventListeners.d.ts +1 -1
- package/dist/provider/stores/useStore.d.ts +7 -2
- package/dist/provider/types/provider.d.ts +15 -3
- package/package.json +8 -7
- package/dist/modal/ParaModal.js +0 -281
- package/dist/modal/components/Account/Account.js +0 -60
- package/dist/modal/components/AddFunds/AddFunds.js +0 -147
- package/dist/modal/components/AddFunds/AddFundsAwaiting.js +0 -65
- package/dist/modal/components/AddFunds/AddFundsDone.js +0 -26
- package/dist/modal/components/AddFunds/MoonPayEmbed.js +0 -2
- package/dist/modal/components/AddFunds/index.js +0 -3
- package/dist/modal/components/AuthInput/AuthInput.js +0 -221
- package/dist/modal/components/AuthInput/countryCodes.js +0 -40
- package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +0 -23
- package/dist/modal/components/AuthInput/phoneMasks.js +0 -247
- package/dist/modal/components/AuthMainStep/AuthMainStep.js +0 -21
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +0 -89
- package/dist/modal/components/AuthOptions/AuthOptions.js +0 -28
- package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +0 -7
- package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.js +0 -5
- package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +0 -7
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +0 -18
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +0 -17
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +0 -131
- package/dist/modal/components/Body/AnimatedHeightWrapper.js +0 -26
- package/dist/modal/components/Body/Body.js +0 -232
- package/dist/modal/components/ChainSwitch/ChainSwitch.js +0 -77
- package/dist/modal/components/ChainSwitch/config.js +0 -11
- package/dist/modal/components/Controls/Controls.js +0 -54
- package/dist/modal/components/Controls/Selects.js +0 -159
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +0 -116
- package/dist/modal/components/ExternalWalletStep/config.js +0 -11
- package/dist/modal/components/ExternalWallets/ExternalWallets.js +0 -142
- package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +0 -119
- package/dist/modal/components/Footer/Footer.js +0 -71
- package/dist/modal/components/Header/Header.js +0 -24
- package/dist/modal/components/Header/hooks/useStepTitle.js +0 -42
- package/dist/modal/components/Hero/Hero.js +0 -119
- package/dist/modal/components/IFrameStep/IFrameStep.js +0 -41
- package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +0 -19
- package/dist/modal/components/ModalContent/ModalContent.js +0 -280
- package/dist/modal/components/OAuth/FarcasterOAuthStep.js +0 -82
- package/dist/modal/components/OAuth/OAuth.js +0 -125
- package/dist/modal/components/OAuth/TelegramOAuthStep.js +0 -133
- package/dist/modal/components/OnRampComponents/AddingFunds.js +0 -10
- package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +0 -72
- package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +0 -67
- package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +0 -105
- package/dist/modal/components/StripeComponents/StripeComponents.js +0 -78
- package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +0 -8
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +0 -135
- package/dist/modal/components/Waiting/Waiting.js +0 -6
- package/dist/modal/components/WalletCard/PartnerIcon.js +0 -29
- package/dist/modal/components/WalletCard/WalletCard.js +0 -93
- package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +0 -50
- package/dist/modal/components/common.js +0 -67
- package/dist/modal/components/index.js +0 -1
- package/dist/modal/constants/constants.js +0 -93
- package/dist/modal/constants/defaults.js +0 -5
- package/dist/modal/constants/oAuthLogos.js +0 -18
- package/dist/modal/hooks/useActiveWallet.js +0 -11
- package/dist/modal/hooks/useEmbeddedExternalConnection.js +0 -46
- package/dist/modal/hooks/useGoBack.js +0 -34
- package/dist/modal/index.js +0 -9
- package/dist/modal/providers/CosmosExternalWalletContextStub.js +0 -18
- package/dist/modal/providers/EvmExternalWalletContextStub.js +0 -22
- package/dist/modal/providers/ExternalWalletContext.js +0 -253
- package/dist/modal/providers/SolanaExternalWalletContextStub.js +0 -12
- package/dist/modal/stores/externalWalletProvider/actions.js +0 -5
- package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +0 -13
- package/dist/modal/stores/index.js +0 -3
- package/dist/modal/stores/modal/actions.js +0 -64
- package/dist/modal/stores/modal/useModalStore.js +0 -41
- package/dist/modal/stores/para/actions.js +0 -5
- package/dist/modal/stores/para/useParaStore.js +0 -3
- package/dist/modal/stores/theme/actions.js +0 -24
- package/dist/modal/stores/theme/useThemeStore.js +0 -14
- package/dist/modal/stores/userInfo/actions.js +0 -34
- package/dist/modal/stores/userInfo/useUserInfoStore.js +0 -9
- package/dist/modal/types/commonTypes.js +0 -1
- package/dist/modal/types/externalWallets.js +0 -21
- package/dist/modal/types/modalProps.js +0 -7
- package/dist/modal/utils/authLayoutHelpers.js +0 -2
- package/dist/modal/utils/getMailtoLink.js +0 -5
- package/dist/modal/utils/getTileButtonFlex.js +0 -15
- package/dist/modal/utils/isPasskeySupported.js +0 -10
- package/dist/modal/utils/openPopup.js +0 -55
- package/dist/modal/utils/routeMobileExternalWallet.js +0 -35
- package/dist/modal/utils/steps.js +0 -215
- package/dist/modal/utils/stringFormatters.js +0 -12
- package/dist/modal/utils/validateOnRampConfig.js +0 -26
- package/dist/provider/ParaProvider.js +0 -16
- package/dist/provider/actions/checkIfUserExists.js +0 -26
- package/dist/provider/actions/createUser.js +0 -30
- package/dist/provider/actions/getAccount.js +0 -24
- package/dist/provider/actions/getWallet.js +0 -16
- package/dist/provider/actions/initiateLogin.js +0 -23
- package/dist/provider/actions/keepSessionAlive.js +0 -23
- package/dist/provider/actions/logout.js +0 -20
- package/dist/provider/actions/signMessage.js +0 -23
- package/dist/provider/actions/signTransaction.js +0 -23
- package/dist/provider/actions/waitForAccountCreation.js +0 -24
- package/dist/provider/actions/waitForLoginAndSetup.js +0 -27
- package/dist/provider/actions/waitForPasskeyAndCreateWallet.js +0 -24
- package/dist/provider/hooks/index.js +0 -3
- package/dist/provider/hooks/mutations/index.js +0 -10
- package/dist/provider/hooks/mutations/useCheckIfUserExists.js +0 -23
- package/dist/provider/hooks/mutations/useCreateUser.js +0 -23
- package/dist/provider/hooks/mutations/useInitiateLogin.js +0 -23
- package/dist/provider/hooks/mutations/useKeepSessionAlive.js +0 -23
- package/dist/provider/hooks/mutations/useLogout.js +0 -33
- 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 -2
- package/dist/provider/hooks/queries/useAccount.js +0 -23
- package/dist/provider/hooks/queries/useWallet.js +0 -24
- package/dist/provider/hooks/utils/index.js +0 -3
- package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +0 -79
- package/dist/provider/hooks/utils/useClient.js +0 -8
- package/dist/provider/hooks/utils/useEventListeners.js +0 -87
- package/dist/provider/hooks/utils/useInternalClient.js +0 -9
- package/dist/provider/hooks/utils/useModal.js +0 -15
- package/dist/provider/hooks/utils/useWalletState.js +0 -33
- package/dist/provider/index.js +0 -3
- package/dist/provider/stores/getters.js +0 -5
- package/dist/provider/stores/slices/client.js +0 -4
- package/dist/provider/stores/slices/index.js +0 -3
- package/dist/provider/stores/slices/modal.js +0 -4
- package/dist/provider/stores/slices/wallet.js +0 -6
- package/dist/provider/stores/types.js +0 -1
- package/dist/provider/stores/useStore.js +0 -12
- 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 -19
- /package/dist/{modal/css → css}/modal.css +0 -0
- /package/dist/{modal/public → public}/Inter-VariableFont_slnt,wght.ttf +0 -0
package/dist/index.js.br
ADDED
|
Binary file
|
package/dist/index.js.gz
ADDED
|
Binary file
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Callbacks } from '../../types/provider.js';
|
|
2
|
-
export declare const useEventListeners: ({ onLogin, onLogout, onAccountSetup, onAccountCreation, onSignMessage, onSignTransaction, onWalletCreated, onPregenWalletClaimed, onExternalWalletChange, onWalletsChange, }
|
|
2
|
+
export declare const useEventListeners: ({ onLogin, onLogout, onAccountSetup, onAccountCreation, onSignMessage, onSignTransaction, onWalletCreated, onPregenWalletClaimed, onExternalWalletChange, onWalletsChange, }?: Callbacks) => void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { StoreApi } from 'zustand';
|
|
1
2
|
import { Store } from './types.js';
|
|
2
|
-
export declare const
|
|
3
|
+
export declare const vanillaStore: Omit<StoreApi<Store>, "persist"> & {
|
|
3
4
|
persist: {
|
|
4
5
|
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<Store, Pick<Store, "selectedWalletId" | "selectedWalletType">>>) => void;
|
|
5
6
|
clearStorage: () => void;
|
|
@@ -9,4 +10,8 @@ export declare const useStore: import("zustand").UseBoundStore<Omit<import("zust
|
|
|
9
10
|
onFinishHydration: (fn: (state: Store) => void) => () => void;
|
|
10
11
|
getOptions: () => Partial<import("zustand/middleware").PersistOptions<Store, Pick<Store, "selectedWalletId" | "selectedWalletType">>>;
|
|
11
12
|
};
|
|
12
|
-
}
|
|
13
|
+
};
|
|
14
|
+
export declare const useStore: {
|
|
15
|
+
(): Store;
|
|
16
|
+
<T>(selector: (state: Store) => T): T;
|
|
17
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccountCreationEvent, AccountSetupEvent, ConstructorOpts, Environment, ExternalWalletChangeEvent, LoginEvent, LogoutEvent, PregenWalletClaimedEvent, SignMessageEvent, SignTransactionEvent, WalletCreatedEvent, WalletsChangeEvent } from '@getpara/web-sdk';
|
|
1
|
+
import ParaWeb, { AccountCreationEvent, AccountSetupEvent, ConstructorOpts, Environment, ExternalWalletChangeEvent, LoginEvent, LogoutEvent, PregenWalletClaimedEvent, SignMessageEvent, SignTransactionEvent, WalletCreatedEvent, WalletsChangeEvent } from '@getpara/web-sdk';
|
|
2
2
|
import { PropsWithChildren } from 'react';
|
|
3
3
|
export type Callbacks = {
|
|
4
4
|
onLogout?: (event: LogoutEvent) => void;
|
|
@@ -15,8 +15,8 @@ export type Callbacks = {
|
|
|
15
15
|
export type ParaProviderConfig = {
|
|
16
16
|
disableAutoSessionKeepAlive?: boolean;
|
|
17
17
|
};
|
|
18
|
-
|
|
19
|
-
paraClientConfig
|
|
18
|
+
interface ParaProviderPropsBase extends PropsWithChildren {
|
|
19
|
+
paraClientConfig?: {
|
|
20
20
|
env: Environment;
|
|
21
21
|
apiKey: string;
|
|
22
22
|
opts?: ConstructorOpts;
|
|
@@ -24,3 +24,15 @@ export interface ParaProviderProps extends PropsWithChildren {
|
|
|
24
24
|
callbacks?: Callbacks;
|
|
25
25
|
config?: ParaProviderConfig;
|
|
26
26
|
}
|
|
27
|
+
export type ParaProviderProps = ({
|
|
28
|
+
config: ParaProviderConfig & {
|
|
29
|
+
paraClientOverride: ParaWeb;
|
|
30
|
+
};
|
|
31
|
+
paraClientConfig?: never;
|
|
32
|
+
} & ParaProviderPropsBase) | ({
|
|
33
|
+
config?: ParaProviderConfig & {
|
|
34
|
+
paraClientOverride?: never;
|
|
35
|
+
};
|
|
36
|
+
paraClientConfig: ParaProviderPropsBase['paraClientConfig'];
|
|
37
|
+
} & ParaProviderPropsBase);
|
|
38
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/react-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./dist/index.js",
|
|
9
|
-
"./styles.css": "./dist/
|
|
9
|
+
"./styles.css": "./dist/css/modal.css"
|
|
10
10
|
},
|
|
11
11
|
"sideEffects": [
|
|
12
12
|
"*.css"
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@getpara/react-common": "1.
|
|
16
|
-
"@getpara/react-components": "1.
|
|
17
|
-
"@getpara/web-sdk": "1.
|
|
15
|
+
"@getpara/react-common": "1.3.0",
|
|
16
|
+
"@getpara/react-components": "1.3.0",
|
|
17
|
+
"@getpara/web-sdk": "1.3.0",
|
|
18
18
|
"@tanstack/react-query": "^5.0.0",
|
|
19
19
|
"date-fns": "^3.6.0",
|
|
20
20
|
"detect-browser": "^5.3.0",
|
|
@@ -24,8 +24,9 @@
|
|
|
24
24
|
"zustand": "^4.5.2"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "rm -rf dist && tsc && yarn post-build",
|
|
28
27
|
"post-build": "./scripts/post-build.sh",
|
|
28
|
+
"build": "rm -rf dist && yarn typegen && node ./scripts/build.mjs && yarn post-build",
|
|
29
|
+
"typegen": "tsc --emitDeclarationOnly",
|
|
29
30
|
"test": "vitest run --coverage"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
@@ -48,5 +49,5 @@
|
|
|
48
49
|
"resolutions": {
|
|
49
50
|
"styled-components": "^6"
|
|
50
51
|
},
|
|
51
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "2d421556a0a1497abd08e18dca94f08ec3ad640b"
|
|
52
53
|
}
|
package/dist/modal/ParaModal.js
DELETED
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
-
var t = {};
|
|
12
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
-
t[p] = s[p];
|
|
14
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
-
t[p[i]] = s[p[i]];
|
|
18
|
-
}
|
|
19
|
-
return t;
|
|
20
|
-
};
|
|
21
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
|
-
import { CpslAuthModal, defineCustomElements, generateTheme } from '@getpara/react-components';
|
|
23
|
-
import { ModalContent } from './components/index.js';
|
|
24
|
-
import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
25
|
-
import { useModalStore, useUserInfoStore, useThemeStore } from './stores/index.js';
|
|
26
|
-
import { ModalStep, RESET_TO_ACCOUNT_STEPS, RESET_TO_AUTH_STEPS } from './utils/steps.js';
|
|
27
|
-
import { AuthLayout } from './types/modalProps.js';
|
|
28
|
-
import { DEFAULTS } from './constants/defaults.js';
|
|
29
|
-
import { useGoBack } from './hooks/useGoBack.js';
|
|
30
|
-
import { ParaEvent } from '@getpara/web-sdk';
|
|
31
|
-
import { ExternalWalletsWrapper } from './components/ExternalWalletsWrapper/ExternalWalletsWrapper.js';
|
|
32
|
-
import styled from 'styled-components';
|
|
33
|
-
import { useExternalWallets } from './providers/ExternalWalletContext.js';
|
|
34
|
-
import { hasEmbeddedAuth, hasExternalWallet } from './utils/authLayoutHelpers.js';
|
|
35
|
-
import { useModal, useWalletState } from '../provider/index.js';
|
|
36
|
-
import { useStore } from '../provider/stores/useStore.js';
|
|
37
|
-
import { useInternalClient } from '../provider/hooks/utils/useInternalClient.js';
|
|
38
|
-
defineCustomElements();
|
|
39
|
-
export const ParaModal = forwardRef((_a, ref) => {
|
|
40
|
-
var { para, isOpen } = _a, rest = __rest(_a, ["para", "isOpen"]);
|
|
41
|
-
const [isInitialized, setIsInitialized] = useState(false);
|
|
42
|
-
const setClient = useStore(state => state.setClient);
|
|
43
|
-
const client = useStore(state => state.client);
|
|
44
|
-
const { closeModal, openModal } = useModal();
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
if (!client) {
|
|
47
|
-
setClient(para);
|
|
48
|
-
}
|
|
49
|
-
setIsInitialized(true);
|
|
50
|
-
}, []);
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
if (!isOpen) {
|
|
53
|
-
closeModal();
|
|
54
|
-
}
|
|
55
|
-
if (isOpen) {
|
|
56
|
-
openModal();
|
|
57
|
-
}
|
|
58
|
-
}, [isOpen]);
|
|
59
|
-
if (!isInitialized) {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
return _jsx(ParaModalInner, Object.assign({ ref: ref, para: para }, rest));
|
|
63
|
-
});
|
|
64
|
-
const ParaModalInner = forwardRef((_a, ref) => {
|
|
65
|
-
var { theme, appName, logo, disableEmailLogin = false, disablePhoneLogin = false, oAuthMethods, bareModal = false, className, currentStepOverride, externalWallets, authLayout = [AuthLayout.AUTH_FULL, AuthLayout.EXTERNAL_FULL], embeddedModal, onModalStepChange, hideWallets = false, onClose } = _a, rest = __rest(_a, ["theme", "appName", "logo", "disableEmailLogin", "disablePhoneLogin", "oAuthMethods", "bareModal", "className", "currentStepOverride", "externalWallets", "authLayout", "embeddedModal", "onModalStepChange", "hideWallets", "onClose"]);
|
|
66
|
-
const modalContentRef = useRef(null);
|
|
67
|
-
const updateThemeState = useThemeStore(state => state.updateState);
|
|
68
|
-
const setWebAuthURLForLogin = useModalStore(state => state.setWebAuthURLForLogin);
|
|
69
|
-
const setWebAuthURLForCreate = useModalStore(state => state.setWebAuthURLForCreate);
|
|
70
|
-
const setBiometricLocationHints = useModalStore(state => state.setBiometricLocationHints);
|
|
71
|
-
const currentStep = useModalStore(state => state.step);
|
|
72
|
-
const setOnModalStepChange = useModalStore(state => state.setOnModalStepChange);
|
|
73
|
-
const setStep = useModalStore(state => state.setStep);
|
|
74
|
-
const setAuthInfo = useUserInfoStore(state => state.setAuthInfo);
|
|
75
|
-
const hasPreviousStep = useModalStore(state => state.hasPreviousStep());
|
|
76
|
-
const setFlow = useModalStore(state => state.setFlow);
|
|
77
|
-
const setIsFullyLoggedIn = useModalStore(state => state.setIsFullyLoggedIn);
|
|
78
|
-
const goBack = useGoBack();
|
|
79
|
-
const setAuthLayout = useThemeStore(state => state.setAuthLayout);
|
|
80
|
-
const storedAuthLayout = useThemeStore(state => state.authLayout);
|
|
81
|
-
const resetModalState = useModalStore(state => state.resetState);
|
|
82
|
-
const resetUserInfoState = useUserInfoStore(state => state.resetState);
|
|
83
|
-
const setRecoveryShare = useUserInfoStore(state => state.setRecoveryShare);
|
|
84
|
-
const { disconnectExternalWallet } = useExternalWallets();
|
|
85
|
-
const { isOpen, closeModal } = useModal();
|
|
86
|
-
const para = useInternalClient();
|
|
87
|
-
const { selectedWallet, setSelectedWallet } = useWalletState();
|
|
88
|
-
const [isModalMounted, setIsModalMounted] = useState(false);
|
|
89
|
-
const [isInit, setIsInit] = useState(false);
|
|
90
|
-
useImperativeHandle(ref, () => {
|
|
91
|
-
return {
|
|
92
|
-
goBack() {
|
|
93
|
-
goBack();
|
|
94
|
-
},
|
|
95
|
-
canGoBack() {
|
|
96
|
-
return hasPreviousStep;
|
|
97
|
-
},
|
|
98
|
-
currentStep() {
|
|
99
|
-
return currentStep;
|
|
100
|
-
},
|
|
101
|
-
handleModalClose() {
|
|
102
|
-
var _a;
|
|
103
|
-
(_a = modalContentRef === null || modalContentRef === void 0 ? void 0 : modalContentRef.current) === null || _a === void 0 ? void 0 : _a.handleModalClose();
|
|
104
|
-
},
|
|
105
|
-
};
|
|
106
|
-
}, [hasPreviousStep, currentStep]);
|
|
107
|
-
// This will run on mount and on isOpen change but won't cause a rerender unless step or email changes
|
|
108
|
-
const initModal = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
109
|
-
const isAccount = yield para.isFullyLoggedIn();
|
|
110
|
-
if (currentStepOverride) {
|
|
111
|
-
setStep(ModalStep[currentStepOverride.toUpperCase()]);
|
|
112
|
-
}
|
|
113
|
-
else if (isAccount) {
|
|
114
|
-
setFlow('account');
|
|
115
|
-
setStep(ModalStep.ACCOUNT_MAIN);
|
|
116
|
-
setIsFullyLoggedIn(true);
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
if (currentStep !== ModalStep.AUTH_MAIN && currentStep !== ModalStep.SECRET) {
|
|
120
|
-
setStep(ModalStep.AUTH_MAIN);
|
|
121
|
-
setFlow();
|
|
122
|
-
setWebAuthURLForLogin();
|
|
123
|
-
setWebAuthURLForCreate();
|
|
124
|
-
setBiometricLocationHints();
|
|
125
|
-
}
|
|
126
|
-
// Disconnect external wallets if the user is not longer logged in
|
|
127
|
-
yield disconnectExternalWallet();
|
|
128
|
-
setSelectedWallet({ id: undefined, type: undefined });
|
|
129
|
-
setIsFullyLoggedIn(false);
|
|
130
|
-
}
|
|
131
|
-
switch (true) {
|
|
132
|
-
case para.isEmail:
|
|
133
|
-
setAuthInfo({ email: para.getEmail() });
|
|
134
|
-
break;
|
|
135
|
-
case para.isPhone:
|
|
136
|
-
{
|
|
137
|
-
const { phone, countryCode } = para.getPhone();
|
|
138
|
-
setAuthInfo({ phone, countryCode: countryCode });
|
|
139
|
-
}
|
|
140
|
-
break;
|
|
141
|
-
case para.isFarcaster:
|
|
142
|
-
setAuthInfo({ farcasterUsername: para.getFarcasterUsername() });
|
|
143
|
-
break;
|
|
144
|
-
case para.isTelegram:
|
|
145
|
-
setAuthInfo({ telegramUserId: para.telegramUserId });
|
|
146
|
-
if (!isAccount) {
|
|
147
|
-
setStep(ModalStep.TELEGRAM_OAUTH);
|
|
148
|
-
}
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
setIsInit(true);
|
|
152
|
-
});
|
|
153
|
-
useEffect(() => {
|
|
154
|
-
let _authLayout = authLayout;
|
|
155
|
-
// Removing unused auth layouts based on what auth methods are passed in
|
|
156
|
-
if (!(externalWallets === null || externalWallets === void 0 ? void 0 : externalWallets.length) && hasExternalWallet(authLayout)) {
|
|
157
|
-
_authLayout = _authLayout.filter(l => !l.includes('EXTERNAL'));
|
|
158
|
-
}
|
|
159
|
-
if (disableEmailLogin && disablePhoneLogin && !(oAuthMethods === null || oAuthMethods === void 0 ? void 0 : oAuthMethods.length) && hasEmbeddedAuth(authLayout)) {
|
|
160
|
-
_authLayout = _authLayout.filter(l => !l.includes('AUTH'));
|
|
161
|
-
}
|
|
162
|
-
if (JSON.stringify(storedAuthLayout) !== JSON.stringify(_authLayout)) {
|
|
163
|
-
setAuthLayout(_authLayout);
|
|
164
|
-
}
|
|
165
|
-
}, [disableEmailLogin, disablePhoneLogin, oAuthMethods, externalWallets, authLayout]);
|
|
166
|
-
useEffect(() => {
|
|
167
|
-
setOnModalStepChange(onModalStepChange);
|
|
168
|
-
}, [onModalStepChange]);
|
|
169
|
-
useEffect(() => {
|
|
170
|
-
var _a;
|
|
171
|
-
updateThemeState({
|
|
172
|
-
logo,
|
|
173
|
-
appName,
|
|
174
|
-
oAuthLogoVariant: (_a = theme === null || theme === void 0 ? void 0 : theme.oAuthLogoVariant) !== null && _a !== void 0 ? _a : 'default',
|
|
175
|
-
bareModal,
|
|
176
|
-
embeddedModal,
|
|
177
|
-
hideWallets,
|
|
178
|
-
});
|
|
179
|
-
}, [logo, appName, theme === null || theme === void 0 ? void 0 : theme.oAuthLogoVariant, bareModal, embeddedModal, hideWallets]);
|
|
180
|
-
useEffect(() => {
|
|
181
|
-
if (theme) {
|
|
182
|
-
generateTheme(theme);
|
|
183
|
-
updateThemeState({ isDark: theme.mode === 'dark', theme: theme });
|
|
184
|
-
}
|
|
185
|
-
}, [theme]);
|
|
186
|
-
// Set Para instance & init on mount
|
|
187
|
-
useEffect(() => {
|
|
188
|
-
if (para) {
|
|
189
|
-
initModal();
|
|
190
|
-
if (bareModal) {
|
|
191
|
-
setIsModalMounted(true);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
console.error('A Para instance must be provided.');
|
|
196
|
-
}
|
|
197
|
-
}, []);
|
|
198
|
-
// Init modal with proper steps on isOpen change
|
|
199
|
-
useEffect(() => {
|
|
200
|
-
if (isOpen && para) {
|
|
201
|
-
initModal();
|
|
202
|
-
}
|
|
203
|
-
}, [isOpen]);
|
|
204
|
-
const updateActiveWallet = () => {
|
|
205
|
-
if (!(selectedWallet === null || selectedWallet === void 0 ? void 0 : selectedWallet.id) || !para.findWallet(selectedWallet === null || selectedWallet === void 0 ? void 0 : selectedWallet.id)) {
|
|
206
|
-
const defaultWallet = para.findWallet(undefined, undefined, { forbidPregen: true });
|
|
207
|
-
setSelectedWallet({ id: defaultWallet === null || defaultWallet === void 0 ? void 0 : defaultWallet.id, type: defaultWallet === null || defaultWallet === void 0 ? void 0 : defaultWallet.type });
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
useEffect(() => {
|
|
211
|
-
updateActiveWallet();
|
|
212
|
-
}, [para]);
|
|
213
|
-
useEffect(() => {
|
|
214
|
-
// TODO: remove this redundant listener once we force the use of the ParaProvider
|
|
215
|
-
window.addEventListener(ParaEvent.WALLETS_CHANGE_EVENT, updateActiveWallet);
|
|
216
|
-
window.addEventListener(ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, updateActiveWallet);
|
|
217
|
-
return () => {
|
|
218
|
-
window.removeEventListener(ParaEvent.WALLETS_CHANGE_EVENT, updateActiveWallet);
|
|
219
|
-
window.removeEventListener(ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, updateActiveWallet);
|
|
220
|
-
};
|
|
221
|
-
}, []);
|
|
222
|
-
const handleClose = () => {
|
|
223
|
-
closeModal();
|
|
224
|
-
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
225
|
-
};
|
|
226
|
-
const handleModalEntering = () => {
|
|
227
|
-
setIsModalMounted(true);
|
|
228
|
-
};
|
|
229
|
-
const handleModalExited = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
230
|
-
setIsModalMounted(false);
|
|
231
|
-
if (RESET_TO_AUTH_STEPS.includes(currentStep)) {
|
|
232
|
-
resetModalState();
|
|
233
|
-
resetUserInfoState();
|
|
234
|
-
setRecoveryShare(null);
|
|
235
|
-
}
|
|
236
|
-
else if (RESET_TO_ACCOUNT_STEPS.includes(currentStep)) {
|
|
237
|
-
setStep(ModalStep.LOGIN_DONE);
|
|
238
|
-
}
|
|
239
|
-
if (para) {
|
|
240
|
-
yield initModal();
|
|
241
|
-
para.exitLoops();
|
|
242
|
-
}
|
|
243
|
-
setIsInit(false);
|
|
244
|
-
});
|
|
245
|
-
if (!para) {
|
|
246
|
-
console.error('A Para instance is required.');
|
|
247
|
-
return null;
|
|
248
|
-
}
|
|
249
|
-
if (!(storedAuthLayout === null || storedAuthLayout === void 0 ? void 0 : storedAuthLayout.length)) {
|
|
250
|
-
// Checking props here to verify a valid configuration was passed in.
|
|
251
|
-
// Doing this since we auto adjust the auth layouts based on passed in auth method props, if an empty storedAuthLayout was triggered based on invalid props we want to be sure the message reflects that correctly.
|
|
252
|
-
const hasExternalWalletError = !(externalWallets === null || externalWallets === void 0 ? void 0 : externalWallets.length) && hasExternalWallet(authLayout);
|
|
253
|
-
const hasEmbeddedWalletError = disableEmailLogin && disablePhoneLogin && !(oAuthMethods === null || oAuthMethods === void 0 ? void 0 : oAuthMethods.length) && hasEmbeddedAuth(authLayout);
|
|
254
|
-
if (hasExternalWalletError || hasEmbeddedWalletError) {
|
|
255
|
-
if (hasExternalWalletError) {
|
|
256
|
-
console.error('At least one external wallet must be provided if external wallet auth is enabled.');
|
|
257
|
-
}
|
|
258
|
-
if (hasEmbeddedWalletError) {
|
|
259
|
-
console.error('At least one login method (email, phone or OAuth) must be provided if embedded wallet auth is enabled.');
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
else {
|
|
263
|
-
console.error('At least one auth layout selection is required.');
|
|
264
|
-
}
|
|
265
|
-
return null;
|
|
266
|
-
}
|
|
267
|
-
return (_jsx(ExternalWalletsWrapper, { wallets: externalWallets, children: _jsx(StyledAuthModal, { enterTransitionDuration: DEFAULTS.ANIMATION_DURATION, exitTransitionDuration: DEFAULTS.ANIMATION_DURATION, open: isOpen, onCpslModalExited: handleModalExited, onCpslModalEntering: handleModalEntering, onCpslModalRequestClose: handleClose, noOverlay: bareModal, className: className, "data-testid": "modal", "$embeddedModal": embeddedModal, children: isModalMounted && ((isInit && embeddedModal) || !embeddedModal) && (_jsx(ModalContent, Object.assign({ oAuthMethods: oAuthMethods, disableEmailLogin: disableEmailLogin, disablePhoneLogin: disablePhoneLogin, onClose: handleClose }, rest))) }) }));
|
|
268
|
-
});
|
|
269
|
-
const StyledAuthModal = styled(CpslAuthModal) `
|
|
270
|
-
${({ $embeddedModal }) => $embeddedModal &&
|
|
271
|
-
`
|
|
272
|
-
&::part(modal-body-card) {
|
|
273
|
-
--card-box-shadow: none;
|
|
274
|
-
--card-border-width: 0px;
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
&::part(modal-footer) {
|
|
278
|
-
--card-box-shadow: none;
|
|
279
|
-
--card-border-width: 0px;
|
|
280
|
-
};`}
|
|
281
|
-
`;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
-
import styled from 'styled-components';
|
|
12
|
-
import { InnerStepContainer, StepContainer, StyledCpslTileButton } from '../common.js';
|
|
13
|
-
import { CpslButton, CpslIcon, CpslSpinner, CpslText } from '@getpara/react-components';
|
|
14
|
-
import { useModalStore, useThemeStore } from '../../stores/index.js';
|
|
15
|
-
import { useExternalWallets } from '../../providers/ExternalWalletContext.js';
|
|
16
|
-
import { useState } from 'react';
|
|
17
|
-
import { ModalStep } from '../../utils/steps.js';
|
|
18
|
-
import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
|
|
19
|
-
export const Account = ({ onClose }) => {
|
|
20
|
-
const onRampConfig = useModalStore(state => state.onRampConfig);
|
|
21
|
-
const setStep = useModalStore(state => state.setStep);
|
|
22
|
-
const hideWallets = useThemeStore(state => state.hideWallets);
|
|
23
|
-
const { disconnectExternalWallet } = useExternalWallets();
|
|
24
|
-
const para = useInternalClient();
|
|
25
|
-
const [isDisconnecting, setIsDisconnecting] = useState(false);
|
|
26
|
-
const isOnRampLoaded = !!onRampConfig;
|
|
27
|
-
const handleBuyClick = () => {
|
|
28
|
-
setStep(ModalStep.ADD_FUNDS_BUY);
|
|
29
|
-
};
|
|
30
|
-
const handleReceiveClick = () => {
|
|
31
|
-
setStep(ModalStep.ADD_FUNDS_RECEIVE);
|
|
32
|
-
};
|
|
33
|
-
const handleSellClick = () => {
|
|
34
|
-
setStep(ModalStep.ADD_FUNDS_WITHDRAW);
|
|
35
|
-
};
|
|
36
|
-
const handleDisconnectClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
-
setIsDisconnecting(true);
|
|
38
|
-
yield para.logout();
|
|
39
|
-
yield disconnectExternalWallet();
|
|
40
|
-
onClose();
|
|
41
|
-
setIsDisconnecting(false);
|
|
42
|
-
});
|
|
43
|
-
return (_jsx(StepContainer, { "$wide": true, children: _jsxs(InnerStepContainer, { children: [_jsx(ButtonContainer, { children: isOnRampLoaded ? (_jsxs(_Fragment, { children: [onRampConfig.isBuyEnabled && (_jsx(OptionButton, { icon: "creditCard", onClick: handleBuyClick, children: _jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Buy Crypto" }) })), onRampConfig.isReceiveEnabled && (_jsx(OptionButton, { icon: "qrCode02", onClick: handleReceiveClick, children: _jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Receive" }) })), onRampConfig.isWithdrawEnabled && (_jsx(OptionButton, { icon: "arrowCircleBrokenDownLeft", onClick: handleSellClick, children: _jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Withdraw" }) }))] })) : (_jsx(CpslSpinner, {})) }), _jsx(DisconnectButton, { variant: "destructive", fullWidth: true, onClick: handleDisconnectClick, disabled: isDisconnecting, children: isDisconnecting ? (_jsx(CpslSpinner, { size: 16 })) : (_jsxs(_Fragment, { children: [hideWallets ? 'Logout' : 'Disconnect Wallet', _jsx(CpslIcon, { icon: "logOut", slot: "end" })] })) })] }) }));
|
|
44
|
-
};
|
|
45
|
-
const ButtonContainer = styled.div `
|
|
46
|
-
display: flex;
|
|
47
|
-
align-items: center;
|
|
48
|
-
justify-content: center;
|
|
49
|
-
gap: 8px;
|
|
50
|
-
width: 100%;
|
|
51
|
-
height: 88px;
|
|
52
|
-
`;
|
|
53
|
-
const OptionButton = styled(StyledCpslTileButton) `
|
|
54
|
-
flex: 1;
|
|
55
|
-
|
|
56
|
-
--button-icon-color: var(--cpsl-color-text-primary);
|
|
57
|
-
`;
|
|
58
|
-
const DisconnectButton = styled(CpslButton) `
|
|
59
|
-
--button-border-width: 0px;
|
|
60
|
-
`;
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
|
-
import { EnabledFlow, getOnRampAssets, getOnRampNetworks, OnRampProvider, OnRampPurchaseType, toAssetInfoArray, WalletType, } from '@getpara/web-sdk';
|
|
12
|
-
import { CenteredText, FilledDisabledInput, Heading, InnerStepContainer, QRContainer, StepContainer } from '../common.js';
|
|
13
|
-
import { CpslButton, CpslDivider, CpslIcon, CpslIdenticon, CpslQrCode, CpslSpinner, CpslTab, CpslTabs, CpslText, } from '@getpara/react-components';
|
|
14
|
-
import { useModalStore, useThemeStore } from '../../stores/index.js';
|
|
15
|
-
import { useEffect, useMemo } from 'react';
|
|
16
|
-
import { OnRampProviderButton } from '../OnRampComponents/OnRampProviderButton.js';
|
|
17
|
-
import { isMobile } from '@getpara/web-sdk';
|
|
18
|
-
import { useActiveWallet } from '../../hooks/useActiveWallet.js';
|
|
19
|
-
import { getAddFundsStep, ModalStep } from '../../utils/steps.js';
|
|
20
|
-
import { motion, AnimatePresence } from 'framer-motion';
|
|
21
|
-
import { useExternalWallets } from '../../providers/ExternalWalletContext.js';
|
|
22
|
-
import { getNetworkFromChainId, getNetworkOrMainNetEquivalent, useCopyToClipboard } from '@getpara/react-common';
|
|
23
|
-
import { formatNetworkList } from '../../utils/stringFormatters.js';
|
|
24
|
-
import styled from 'styled-components';
|
|
25
|
-
import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
|
|
26
|
-
const TABS = [
|
|
27
|
-
[EnabledFlow.BUY, 'isBuyEnabled', 'creditCard', 'Buy'],
|
|
28
|
-
[EnabledFlow.RECEIVE, 'isReceiveEnabled', 'qrCode', 'Receive'],
|
|
29
|
-
[EnabledFlow.WITHDRAW, 'isWithdrawEnabled', 'arrowCircleBrokenDownLeft', 'Withdraw'],
|
|
30
|
-
];
|
|
31
|
-
const GENERIC_WALLET = {
|
|
32
|
-
[WalletType.EVM]: 'Ethereum or EVM-based L2s',
|
|
33
|
-
[WalletType.SOLANA]: 'Solana',
|
|
34
|
-
[WalletType.COSMOS]: 'Cosmos',
|
|
35
|
-
};
|
|
36
|
-
export const AddFunds = () => {
|
|
37
|
-
const [isCopied, copy] = useCopyToClipboard();
|
|
38
|
-
const para = useInternalClient();
|
|
39
|
-
const appName = useThemeStore(state => state.appName);
|
|
40
|
-
const onRampConfig = useModalStore(state => state.onRampConfig);
|
|
41
|
-
const hideWallets = useThemeStore(state => state.hideWallets);
|
|
42
|
-
const storedTab = useModalStore(state => state.accountAddFundTab);
|
|
43
|
-
const setStep = useModalStore(state => state.setStep);
|
|
44
|
-
const setOnRampPurchase = useModalStore(state => state.setOnRampPurchase);
|
|
45
|
-
const { chainId } = useExternalWallets();
|
|
46
|
-
const activeWallet = useActiveWallet();
|
|
47
|
-
const tabs = TABS.filter(([, key]) => !!onRampConfig[key]);
|
|
48
|
-
const isMultiFlow = tabs.length > 1;
|
|
49
|
-
const tab = storedTab !== null && storedTab !== void 0 ? storedTab : tabs[0][0];
|
|
50
|
-
const address = useMemo(() => (activeWallet ? para.getDisplayAddress(activeWallet.id, { addressType: activeWallet.type }) : ''), [para, activeWallet === null || activeWallet === void 0 ? void 0 : activeWallet.id, activeWallet === null || activeWallet === void 0 ? void 0 : activeWallet.type]);
|
|
51
|
-
const onSetTab = (event) => {
|
|
52
|
-
setStep(getAddFundsStep(event.detail.tab));
|
|
53
|
-
};
|
|
54
|
-
const onCopy = () => {
|
|
55
|
-
copy(address);
|
|
56
|
-
};
|
|
57
|
-
const [allowedNetworks, allowedAssets, isProviderAllowed] = useMemo(() => {
|
|
58
|
-
if (!onRampConfig || !activeWallet) {
|
|
59
|
-
return [[], [], {}];
|
|
60
|
-
}
|
|
61
|
-
const action = tab === EnabledFlow.BUY ? OnRampPurchaseType.BUY : OnRampPurchaseType.SELL;
|
|
62
|
-
const detectedNetwork = getNetworkFromChainId(chainId);
|
|
63
|
-
const isExternal = activeWallet.isExternal && !!detectedNetwork;
|
|
64
|
-
const allowedNetworks = isExternal
|
|
65
|
-
? [getNetworkOrMainNetEquivalent(detectedNetwork, onRampConfig.testMode)]
|
|
66
|
-
: getOnRampNetworks(onRampConfig.assetInfo, {
|
|
67
|
-
walletType: activeWallet.type,
|
|
68
|
-
allowed: onRampConfig.allowedAssets ? Object.keys(onRampConfig.allowedAssets) : undefined,
|
|
69
|
-
});
|
|
70
|
-
const allowedAssetsLookup = allowedNetworks.reduce((acc, network) => {
|
|
71
|
-
var _a;
|
|
72
|
-
const configValue = (_a = onRampConfig.allowedAssets) === null || _a === void 0 ? void 0 : _a[network];
|
|
73
|
-
const allowed = configValue === true ? undefined : configValue;
|
|
74
|
-
return Object.assign(Object.assign({}, acc), { [network]: getOnRampAssets(onRampConfig.assetInfo, { walletType: activeWallet.type, network, allowed }) });
|
|
75
|
-
}, {});
|
|
76
|
-
const isProviderAllowed = onRampConfig.providers.reduce((acc, id) => {
|
|
77
|
-
const hasMatch = toAssetInfoArray(onRampConfig.assetInfo).some(([type, network, asset, validProviders]) => {
|
|
78
|
-
var _a, _b;
|
|
79
|
-
return (type === activeWallet.type &&
|
|
80
|
-
allowedNetworks.includes(network) &&
|
|
81
|
-
(!allowedAssetsLookup[network] || allowedAssetsLookup[network].includes(asset)) &&
|
|
82
|
-
!!((_b = (_a = validProviders[id]) === null || _a === void 0 ? void 0 : _a[1]) === null || _b === void 0 ? void 0 : _b[action]));
|
|
83
|
-
});
|
|
84
|
-
return Object.assign(Object.assign({}, acc), { [id]: hasMatch });
|
|
85
|
-
}, {});
|
|
86
|
-
return [allowedNetworks, [...new Set(Object.values(allowedAssetsLookup).flat())], isProviderAllowed];
|
|
87
|
-
}, [activeWallet === null || activeWallet === void 0 ? void 0 : activeWallet.type, activeWallet === null || activeWallet === void 0 ? void 0 : activeWallet.isExternal, tab, onRampConfig.assetInfo, onRampConfig.allowedAssets, chainId]);
|
|
88
|
-
useEffect(() => {
|
|
89
|
-
setOnRampPurchase(undefined);
|
|
90
|
-
}, []);
|
|
91
|
-
useEffect(() => {
|
|
92
|
-
setOnRampPurchase(undefined);
|
|
93
|
-
}, []);
|
|
94
|
-
if (!onRampConfig || !activeWallet) {
|
|
95
|
-
return (_jsx(SpinnerContainer, { children: _jsx(CpslSpinner, {}) }));
|
|
96
|
-
}
|
|
97
|
-
useEffect(() => {
|
|
98
|
-
setOnRampPurchase(undefined);
|
|
99
|
-
}, []);
|
|
100
|
-
return (_jsxs(StepContainer, { children: [isMultiFlow && (_jsx(InnerStepContainer, { children: _jsx(CpslTabs, { selectedTab: tab, onCpslTabsChanged: onSetTab, children: TABS.map(([tab, _, icon, title]) => (_jsxs(CpslTab, { tab: tab, children: [_jsx(CpslIcon, { slot: "start", icon: icon }), title] }, tab))) }) })), _jsx(_Fragment, { children: [EnabledFlow.BUY, EnabledFlow.WITHDRAW].includes(tab) ? (_jsxs(_Fragment, { children: [_jsx(Heading, { variant: "headingS", weight: "bold", children: "Choose Provider" }), _jsxs($InnerStepContainer, { children: [_jsxs(NoProviders, { isHidden: Object.values(isProviderAllowed).some(v => !!v), variant: "bodyM", children: ["No providers are available for this ", hideWallets ? 'account' : 'wallet'] }), _jsx(AnimatePresence, { children: onRampConfig.providers.map((id, index) => {
|
|
101
|
-
return isProviderAllowed[id] ? (_jsx(motion.div, { style: { width: '100%' }, layout: true, initial: { opacity: 0, transform: 'translateX(25px)' }, animate: { opacity: 1, transform: 'none' }, exit: { opacity: 0, transform: 'translateX(-25px)' }, transition: { duration: 0.2 }, children: _jsx(OnRampProviderButton, { config: onRampConfig, index: index, onClick: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
102
|
-
var _a;
|
|
103
|
-
if (!(activeWallet === null || activeWallet === void 0 ? void 0 : activeWallet.type))
|
|
104
|
-
return;
|
|
105
|
-
const isPopup = id !== OnRampProvider.RAMP;
|
|
106
|
-
const { onRampPurchase: newOnRampPurchase } = yield para.initiateOnRampTransaction({
|
|
107
|
-
walletId: activeWallet.isExternal ? undefined : activeWallet.id,
|
|
108
|
-
externalWalletAddress: activeWallet.isExternal ? activeWallet.id : undefined,
|
|
109
|
-
shouldOpenPopup: isPopup,
|
|
110
|
-
params: {
|
|
111
|
-
type: tab === EnabledFlow.BUY ? OnRampPurchaseType.BUY : OnRampPurchaseType.SELL,
|
|
112
|
-
walletType: activeWallet.type,
|
|
113
|
-
provider: id,
|
|
114
|
-
networks: allowedNetworks,
|
|
115
|
-
assets: allowedAssets,
|
|
116
|
-
defaultNetwork: onRampConfig.defaultOnRampNetwork,
|
|
117
|
-
defaultAsset: onRampConfig.defaultOnRampAsset,
|
|
118
|
-
fiatQuantity: (_a = onRampConfig.defaultBuyAmount) === null || _a === void 0 ? void 0 : _a[0],
|
|
119
|
-
testMode: onRampConfig.testMode,
|
|
120
|
-
},
|
|
121
|
-
});
|
|
122
|
-
setOnRampPurchase(Object.assign(Object.assign({}, newOnRampPurchase), { fiat: 'USD' }));
|
|
123
|
-
!isPopup && setStep(ModalStep.ADD_FUNDS_AWAITING);
|
|
124
|
-
}) }, id) }, id)) : null;
|
|
125
|
-
}) })] })] })) : (_jsxs(_Fragment, { children: [_jsx(InnerStepContainer, { children: _jsxs(FilledDisabledInput, { noAutoDisable: true, readonly: true, placeholder: address, children: [_jsx(CpslIdenticon, { slot: "start", size: "32px", hash: para.getIdenticonHash(activeWallet.id, activeWallet.type) }), _jsx(CpslButton, { slot: "end", variant: "ghost", onClick: onCopy, children: _jsx(CpslIcon, { icon: isCopied ? 'check' : 'copy' }) })] }, address) }), !isMobile() && (_jsxs(_Fragment, { children: [_jsx(CpslDivider, { children: "or" }), _jsxs(InnerStepContainer, { children: [_jsx(QRContainer, { children: !address ? _jsx(CpslSpinner, { size: 100 }) : _jsx(CpslQrCode, { url: address }, address) }), _jsx(CpslText, { weight: "semiBold", color: "secondary", children: "Scan with your crypto wallet" })] })] })), _jsxs(InnerStepContainer, { children: [_jsxs(CenteredText, { weight: "semiBold", children: [(!!onRampConfig.allowedAssets && allowedNetworks.length > 0) || hideWallets
|
|
126
|
-
? (appName !== null && appName !== void 0 ? appName : 'This App')
|
|
127
|
-
: 'This Wallet', ' ', "Only Supports:"] }), _jsx(CenteredText, { weight: "medium", color: "secondary", children: !!onRampConfig.allowedAssets && allowedNetworks.length > 0
|
|
128
|
-
? formatNetworkList(allowedNetworks)
|
|
129
|
-
: GENERIC_WALLET[activeWallet.type] })] })] })) })] }));
|
|
130
|
-
};
|
|
131
|
-
const SpinnerContainer = styled(StepContainer) `
|
|
132
|
-
margin: 50% 0;
|
|
133
|
-
`;
|
|
134
|
-
const $InnerStepContainer = styled(InnerStepContainer) `
|
|
135
|
-
position: relative;
|
|
136
|
-
min-height: 270px;
|
|
137
|
-
`;
|
|
138
|
-
const NoProviders = styled(CpslText) `
|
|
139
|
-
width: 100%;
|
|
140
|
-
text-align: center;
|
|
141
|
-
visibility: ${({ isHidden }) => (isHidden ? 'hidden' : 'visible')};
|
|
142
|
-
position: absolute;
|
|
143
|
-
top: 0;
|
|
144
|
-
left: 0;
|
|
145
|
-
right: 0;
|
|
146
|
-
transition: visibility 0.2s;
|
|
147
|
-
`;
|