@dynamic-labs/sdk-react-core 4.6.3 → 4.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/CHANGELOG.md +14 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +11 -11
- package/src/lib/Main.cjs +1 -1
- package/src/lib/Main.js +1 -1
- package/src/lib/components/NetworkPicker/components/NetworkSwitchControl/NetworkSwitchControl.cjs +2 -2
- package/src/lib/components/NetworkPicker/components/NetworkSwitchControl/NetworkSwitchControl.js +2 -2
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.cjs +1 -0
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.js +2 -1
- package/src/lib/context/DynamicContext/hooks/useNameService/useNameService.cjs +2 -2
- package/src/lib/context/DynamicContext/hooks/useNameService/useNameService.js +2 -2
- package/src/lib/context/ViewContext/types/index.d.ts +1 -1
- package/src/lib/layout/DynamicAuthLayout/Header/header.cjs +2 -2
- package/src/lib/layout/DynamicAuthLayout/Header/header.js +2 -2
- package/src/lib/locale/en/translation.cjs +10 -0
- package/src/lib/locale/en/translation.d.ts +10 -0
- package/src/lib/locale/en/translation.js +10 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/constants/localStorage.cjs +2 -0
- package/src/lib/utils/constants/localStorage.d.ts +1 -0
- package/src/lib/utils/constants/localStorage.js +2 -1
- package/src/lib/utils/functions/generateMessages/index.cjs +1 -1
- package/src/lib/utils/functions/generateMessages/index.js +1 -1
- package/src/lib/utils/functions/getVerifyArgs/getVerifyArgs.cjs +2 -2
- package/src/lib/utils/functions/getVerifyArgs/getVerifyArgs.js +2 -2
- package/src/lib/utils/functions/index.d.ts +0 -1
- package/src/lib/utils/functions/isSupportedNetwork/isSupportedNetwork.cjs +1 -3
- package/src/lib/utils/functions/isSupportedNetwork/isSupportedNetwork.d.ts +2 -1
- package/src/lib/utils/functions/isSupportedNetwork/isSupportedNetwork.js +1 -3
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js +1 -1
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +4 -1
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.d.ts +1 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +4 -1
- package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.cjs +1 -1
- package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.js +1 -1
- package/src/lib/utils/hooks/useDynamicLayoutData/useDynamicLayoutData.cjs +4 -0
- package/src/lib/utils/hooks/useDynamicLayoutData/useDynamicLayoutData.js +4 -0
- package/src/lib/utils/hooks/useNetworkDataFromWallet/useNetworkDataFromWallet.cjs +4 -96
- package/src/lib/utils/hooks/useNetworkDataFromWallet/useNetworkDataFromWallet.js +4 -96
- package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.cjs +32 -19
- package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.d.ts +2 -2
- package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.js +31 -18
- package/src/lib/utils/hooks/useTransactionSimulation/classes/useSVMTransactionSimulation.cjs +1 -1
- package/src/lib/utils/hooks/useTransactionSimulation/classes/useSVMTransactionSimulation.js +1 -1
- package/src/lib/utils/hooks/useWalletConnectorNetwork/useWalletConnectorNetwork.cjs +2 -2
- package/src/lib/utils/hooks/useWalletConnectorNetwork/useWalletConnectorNetwork.js +2 -2
- package/src/lib/utils/hooks/useWalletConnectors/utils/smartWallet/smartWallet.cjs +12 -16
- package/src/lib/utils/hooks/useWalletConnectors/utils/smartWallet/smartWallet.js +13 -17
- package/src/lib/views/CollectUserDataView/CollectUserDataView.cjs +3 -1
- package/src/lib/views/CollectUserDataView/CollectUserDataView.js +3 -1
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs +2 -2
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js +2 -2
- package/src/lib/views/SendBalanceView/SendBalanceView.cjs +1 -1
- package/src/lib/views/SendBalanceView/SendBalanceView.js +1 -1
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +1 -1
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +1 -1
- package/src/lib/views/UserDeleteAccountView/UserDeleteAccountView.cjs +130 -0
- package/src/lib/views/UserDeleteAccountView/UserDeleteAccountView.d.ts +3 -0
- package/src/lib/views/UserDeleteAccountView/UserDeleteAccountView.js +125 -0
- package/src/lib/views/UserDeleteAccountView/index.d.ts +1 -0
- package/src/lib/views/viewToComponentMap.cjs +2 -0
- package/src/lib/views/viewToComponentMap.d.ts +1 -0
- package/src/lib/views/viewToComponentMap.js +2 -0
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.types.d.ts +1 -1
- package/src/lib/widgets/DynamicWidget/hooks/useFetchChain/useFetchChain.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/hooks/useFetchChain/useFetchChain.js +1 -1
- package/src/lib/widgets/DynamicWidget/hooks/useFetchCurrency/useFetchCurrency.cjs +6 -16
- package/src/lib/widgets/DynamicWidget/hooks/useFetchCurrency/useFetchCurrency.js +6 -16
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/AccountAndSecuritySettingsView.cjs +13 -4
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/AccountAndSecuritySettingsView.js +13 -4
- package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.cjs +18 -6
- package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.js +19 -7
- package/src/lib/utils/functions/getWalletConnectorNetworks/getWalletConnectorNetworks.cjs +0 -13
- package/src/lib/utils/functions/getWalletConnectorNetworks/getWalletConnectorNetworks.d.ts +0 -3
- package/src/lib/utils/functions/getWalletConnectorNetworks/getWalletConnectorNetworks.js +0 -9
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
3
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
|
+
import { useState, useCallback, useMemo } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import '../../events/dynamicEvents.js';
|
|
7
|
+
import '@dynamic-labs/utils';
|
|
8
|
+
import '../../context/DynamicContext/DynamicContext.js';
|
|
9
|
+
import '@dynamic-labs/sdk-api-core';
|
|
10
|
+
import '../../shared/logger.js';
|
|
11
|
+
import '@dynamic-labs/iconic';
|
|
12
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
13
|
+
import { ReactComponent as SvgExclamation } from '../../shared/assets/exclamation.js';
|
|
14
|
+
import '../../context/ViewContext/ViewContext.js';
|
|
15
|
+
import { ReactComponent as SvgWarningRed } from '../../shared/assets/warning-red.js';
|
|
16
|
+
import '@dynamic-labs/wallet-book';
|
|
17
|
+
import '../../utils/constants/colors.js';
|
|
18
|
+
import '../../utils/constants/values.js';
|
|
19
|
+
import '../../shared/consts/index.js';
|
|
20
|
+
import { useInternalDynamicContext } from '../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
21
|
+
import '../../context/CaptchaContext/CaptchaContext.js';
|
|
22
|
+
import '../../context/ErrorContext/ErrorContext.js';
|
|
23
|
+
import '@dynamic-labs/multi-wallet';
|
|
24
|
+
import 'react-international-phone';
|
|
25
|
+
import '../../store/state/nonce/nonce.js';
|
|
26
|
+
import '../../store/state/projectSettings/projectSettings.js';
|
|
27
|
+
import '../../config/ApiEndpoint.js';
|
|
28
|
+
import '../../store/state/user/user.js';
|
|
29
|
+
import '../../locale/locale.js';
|
|
30
|
+
import '../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
31
|
+
import '../../store/state/primaryWalletId/primaryWalletId.js';
|
|
32
|
+
import '../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
33
|
+
import '../../context/AccountExistsContext/AccountExistsContext.js';
|
|
34
|
+
import '../../context/UserWalletsContext/UserWalletsContext.js';
|
|
35
|
+
import '../../context/VerificationContext/VerificationContext.js';
|
|
36
|
+
import 'react-dom';
|
|
37
|
+
import '../../utils/functions/compareChains/compareChains.js';
|
|
38
|
+
import '../../context/ThemeContext/ThemeContext.js';
|
|
39
|
+
import '../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
40
|
+
import 'bs58';
|
|
41
|
+
import '@dynamic-labs/types';
|
|
42
|
+
import '../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
43
|
+
import '../../context/LoadingContext/LoadingContext.js';
|
|
44
|
+
import '../../context/WalletContext/WalletContext.js';
|
|
45
|
+
import '../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
|
|
46
|
+
import 'yup';
|
|
47
|
+
import '../../context/MockContext/MockContext.js';
|
|
48
|
+
import '../CollectUserDataView/useFields.js';
|
|
49
|
+
import '../../context/FieldsStateContext/FieldsStateContext.js';
|
|
50
|
+
import '../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
51
|
+
import '@dynamic-labs/rpc-providers';
|
|
52
|
+
import '../../store/state/loadingAndLifecycle.js';
|
|
53
|
+
import '@dynamic-labs/store';
|
|
54
|
+
import '../../store/state/walletOptions/walletOptions.js';
|
|
55
|
+
import '../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
56
|
+
import '../../components/Alert/Alert.js';
|
|
57
|
+
import { Typography } from '../../components/Typography/Typography.js';
|
|
58
|
+
import '../../components/ShadowDOM/ShadowDOM.js';
|
|
59
|
+
import { TypographyButton } from '../../components/TypographyButton/TypographyButton.js';
|
|
60
|
+
import '../../components/IconButton/IconButton.js';
|
|
61
|
+
import '../../components/InlineWidget/InlineWidget.js';
|
|
62
|
+
import { Input } from '../../components/Input/Input.js';
|
|
63
|
+
import '../../components/IsBrowser/IsBrowser.js';
|
|
64
|
+
import '../../components/MenuList/Dropdown/Dropdown.js';
|
|
65
|
+
import '../../components/OverlayCard/OverlayCard.js';
|
|
66
|
+
import '../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
67
|
+
import '../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
68
|
+
import '../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
69
|
+
import '../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
70
|
+
import '../../components/Popper/Popper/Popper.js';
|
|
71
|
+
import '../../components/Popper/PopperContext/PopperContext.js';
|
|
72
|
+
import 'react-focus-lock';
|
|
73
|
+
import 'qrcode';
|
|
74
|
+
import 'formik';
|
|
75
|
+
import '../../utils/hooks/useSubdomainCheck/useSubdomainCheck.js';
|
|
76
|
+
import '../../context/WalletGroupContext/WalletGroupContext.js';
|
|
77
|
+
import '../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
78
|
+
import '../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
|
|
79
|
+
import '../../context/ConnectWithOtpContext/constants.js';
|
|
80
|
+
import '../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
81
|
+
import '@hcaptcha/react-hcaptcha';
|
|
82
|
+
import '../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
83
|
+
import '../../context/FooterAnimationContext/index.js';
|
|
84
|
+
import '../../context/PasskeyContext/PasskeyContext.js';
|
|
85
|
+
import '../../store/state/sendBalances.js';
|
|
86
|
+
import '../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.js';
|
|
87
|
+
import '../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
88
|
+
import '../TransactionConfirmationView/TransactionConfirmationView.js';
|
|
89
|
+
import '../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
90
|
+
import '../../context/OnrampContext/OnrampContext.js';
|
|
91
|
+
import '../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.js';
|
|
92
|
+
import '../../../index.js';
|
|
93
|
+
import '../../store/state/tokenBalances.js';
|
|
94
|
+
import '../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
95
|
+
import { useDeleteUserAccount } from '../../utils/hooks/useDeleteUserAccount/useDeleteUserAccount.js';
|
|
96
|
+
|
|
97
|
+
const UserDeleteAccountView = () => {
|
|
98
|
+
const { setShowAuthFlow } = useInternalDynamicContext();
|
|
99
|
+
const { t } = useTranslation();
|
|
100
|
+
const { deleteUser, isLoading, error } = useDeleteUserAccount();
|
|
101
|
+
const [isBackupConfirmed, setIsBackupConfirmed] = useState(false);
|
|
102
|
+
const [confirmText, setConfirmText] = useState('');
|
|
103
|
+
const handleConfirmTextChange = useCallback((e) => {
|
|
104
|
+
setConfirmText(e.target.value);
|
|
105
|
+
}, []);
|
|
106
|
+
const handleBackupConfirmChange = useCallback((e) => {
|
|
107
|
+
setIsBackupConfirmed(e.target.checked);
|
|
108
|
+
}, []);
|
|
109
|
+
const handleCancel = useCallback(() => {
|
|
110
|
+
setShowAuthFlow(false);
|
|
111
|
+
}, [setShowAuthFlow]);
|
|
112
|
+
const handleDelete = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
113
|
+
if (!isBackupConfirmed)
|
|
114
|
+
return;
|
|
115
|
+
yield deleteUser();
|
|
116
|
+
}), [deleteUser, isBackupConfirmed]);
|
|
117
|
+
const isDeleteEnabled = useMemo(() => isBackupConfirmed && confirmText === 'DELETE' && !isLoading, [isBackupConfirmed, confirmText, isLoading]);
|
|
118
|
+
return (jsx("div", { className: 'delete-account-view', children: jsxs("div", { className: 'delete-account-view__content', children: [jsx("div", { className: 'warning-section', children: jsxs("div", { className: 'warning-icon-container', children: [jsx(SvgWarningRed, { className: 'warning-icon' }), jsx(SvgExclamation, { className: 'exclamation-icon' })] }) }), jsx("div", { className: 'message-box', children: jsx(Typography, { variant: 'body_normal', children: t('dyn_settings.delete_account.description') }) }), jsxs("div", { className: 'confirmation-section', children: [jsxs("div", { className: 'checkbox-container', children: [jsx("input", { type: 'checkbox', checked: isBackupConfirmed, onChange: handleBackupConfirmChange }), jsx(Typography, { className: 'checkbox-text', variant: 'body_small', children: t('dyn_settings.delete_account.backup_confirmation') })] }), jsxs("div", { className: 'input-section', children: [jsx(Typography, { className: 'input-label', variant: 'body_small', children: t('dyn_settings.delete_account.type_delete') }), jsx(Input, { id: 'delete-confirmation', label: t('dyn_settings.delete_account.type_delete_label'), value: confirmText, onChange: handleConfirmTextChange, placeholder: 'DELETE', variant: 'dense' })] }), error && (jsx(Typography, { variant: 'body_small', color: 'error-1', children: error.message }))] }), jsxs("div", { className: 'button-group', children: [jsx(TypographyButton, { buttonClassName: 'cancel-button', buttonVariant: 'primary', type: 'button', onClick: handleCancel, copykey: 'dyn_settings.delete_account.cancel', children: t('dyn_settings.delete_account.cancel') }), jsx(TypographyButton, { buttonClassName: 'delete-button', buttonVariant: 'primary', type: 'submit', onClick: handleDelete, disabled: !isDeleteEnabled, typographyProps: {
|
|
119
|
+
color: isDeleteEnabled ? 'white' : 'tertiary',
|
|
120
|
+
}, copykey: 'dyn_settings.delete_account.confirm', children: isLoading
|
|
121
|
+
? t('dyn_settings.delete_account.deleting')
|
|
122
|
+
: t('dyn_settings.delete_account.confirm') })] })] }) }));
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export { UserDeleteAccountView, UserDeleteAccountView as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './UserDeleteAccountView';
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var UserDeleteAccountView = require('./UserDeleteAccountView/UserDeleteAccountView.cjs');
|
|
7
8
|
var AccessBlockedView = require('./AccessBlockedView/AccessBlockedView.cjs');
|
|
8
9
|
var AccountExistsView = require('./AccountExistsView/AccountExistsView.cjs');
|
|
9
10
|
var BridgeNextWalletConnectionView = require('./BridgeNextWalletConnectionView/BridgeNextWalletConnectionView.cjs');
|
|
@@ -203,6 +204,7 @@ const viewToComponentMap = {
|
|
|
203
204
|
'select-wallet-in-wallet-group': SelectWalletInWalletGroupView.SelectWalletInWalletGroupView,
|
|
204
205
|
'social-redirect-view': SocialRedirectView.SocialRedirectView,
|
|
205
206
|
'social-wrong-account': SocialWrongAccountView.SocialWrongAccountView,
|
|
207
|
+
'user-delete-account': UserDeleteAccountView.UserDeleteAccountView,
|
|
206
208
|
'verify-email': EmailVerification.EmailVerification,
|
|
207
209
|
'verify-sms': SmsVerification.SmsVerification,
|
|
208
210
|
'wait-for-email-confirmation-view': EmailConfirmationWaitingView.EmailConfirmationWaitingView,
|
|
@@ -78,6 +78,7 @@ export declare const viewToComponentMap: {
|
|
|
78
78
|
}>;
|
|
79
79
|
'social-redirect-view': () => JSX.Element;
|
|
80
80
|
'social-wrong-account': () => JSX.Element | null;
|
|
81
|
+
'user-delete-account': import("react").FC<{}>;
|
|
81
82
|
'verify-email': import("react").FC<import("./EmailVerification/EmailVerification").EmailVerificationProps>;
|
|
82
83
|
'verify-sms': import("react").FC;
|
|
83
84
|
'wait-for-email-confirmation-view': () => JSX.Element;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { UserDeleteAccountView } from './UserDeleteAccountView/UserDeleteAccountView.js';
|
|
3
4
|
import { AccessBlockedView } from './AccessBlockedView/AccessBlockedView.js';
|
|
4
5
|
import { AccountExistsView } from './AccountExistsView/AccountExistsView.js';
|
|
5
6
|
import { BridgeNextWalletConnectionView } from './BridgeNextWalletConnectionView/BridgeNextWalletConnectionView.js';
|
|
@@ -199,6 +200,7 @@ const viewToComponentMap = {
|
|
|
199
200
|
'select-wallet-in-wallet-group': SelectWalletInWalletGroupView,
|
|
200
201
|
'social-redirect-view': SocialRedirectView,
|
|
201
202
|
'social-wrong-account': SocialWrongAccountView,
|
|
203
|
+
'user-delete-account': UserDeleteAccountView,
|
|
202
204
|
'verify-email': EmailVerification,
|
|
203
205
|
'verify-sms': SmsVerification,
|
|
204
206
|
'wait-for-email-confirmation-view': EmailConfirmationWaitingView,
|
|
@@ -11,7 +11,7 @@ export type DynamicPasskeyWidgetViewsType = typeof DynamicPasskeyWidgetViews[num
|
|
|
11
11
|
export type DynamicMfaWidgetViewsType = typeof DynamicMfaWidgetViews[number];
|
|
12
12
|
export declare const DynamicTransactionsWidgetViews: readonly ["send-balance"];
|
|
13
13
|
export type DynamicTransactionsWidgetViewsType = typeof DynamicTransactionsWidgetViews[number];
|
|
14
|
-
export type DynamicWidgetViews = 'wallets' | 'profile' | 'edit-profile' | 'choose-wallet-funding-method' | 'receive-wallet-funds' | DynamicTransactionsWidgetViewsType | DynamicPasskeyWidgetViewsType | DynamicMfaWidgetViewsType | DynamicSettingsType | DynamicGlobalWalletType | 'connected-apps' | 'deposit-view' | 'choose-onramp-provider' | '
|
|
14
|
+
export type DynamicWidgetViews = 'wallets' | 'profile' | 'edit-profile' | 'choose-wallet-funding-method' | 'receive-wallet-funds' | DynamicTransactionsWidgetViewsType | DynamicPasskeyWidgetViewsType | DynamicMfaWidgetViewsType | DynamicSettingsType | DynamicGlobalWalletType | 'connected-apps' | 'deposit-view' | 'choose-onramp-provider' | 'choose-linked-wallet';
|
|
15
15
|
export type DynamicWidgetViewMapConstraint = Record<DynamicWidgetViews, FC<any>>;
|
|
16
16
|
export type DynamicWidgetViewMap = typeof mapViewToComponent;
|
|
17
17
|
export type SetDynamicWidgetView = <T extends DynamicWidgetViews>(view: T, props?: ComponentProps<DynamicWidgetViewMap[T]>) => void;
|
|
@@ -98,7 +98,7 @@ const useFetchChain = (connector) => {
|
|
|
98
98
|
var _a, _b;
|
|
99
99
|
if (!connector)
|
|
100
100
|
return { chainId: undefined, name: '', symbol: undefined };
|
|
101
|
-
const chainId = yield connector.getNetwork();
|
|
101
|
+
const chainId = yield connector.getNetwork(true);
|
|
102
102
|
const { connectedChain } = connector;
|
|
103
103
|
const chainInfo = walletConnectorCore.getChainInfoWithOverrides(connectedChain || '');
|
|
104
104
|
const chainWithIcon = {
|
|
@@ -94,7 +94,7 @@ const useFetchChain = (connector) => {
|
|
|
94
94
|
var _a, _b;
|
|
95
95
|
if (!connector)
|
|
96
96
|
return { chainId: undefined, name: '', symbol: undefined };
|
|
97
|
-
const chainId = yield connector.getNetwork();
|
|
97
|
+
const chainId = yield connector.getNetwork(true);
|
|
98
98
|
const { connectedChain } = connector;
|
|
99
99
|
const chainInfo = getChainInfoWithOverrides(connectedChain || '');
|
|
100
100
|
const chainWithIcon = {
|
|
@@ -95,10 +95,10 @@ require('../../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
|
95
95
|
|
|
96
96
|
const useFetchCurrency = (connector, network) => {
|
|
97
97
|
const fetchChainCurrency = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
98
|
-
var _a, _b, _c, _d, _e
|
|
98
|
+
var _a, _b, _c, _d, _e;
|
|
99
99
|
if (!connector)
|
|
100
100
|
return null;
|
|
101
|
-
const chainId = yield connector.getNetwork();
|
|
101
|
+
const chainId = yield connector.getNetwork(true);
|
|
102
102
|
const chainInfo = walletConnectorCore.getChainInfoWithOverrides((_a = connector.connectedChain) !== null && _a !== void 0 ? _a : '');
|
|
103
103
|
/* istanbul ignore else */
|
|
104
104
|
if (!chainId) {
|
|
@@ -107,21 +107,11 @@ const useFetchCurrency = (connector, network) => {
|
|
|
107
107
|
symbol: chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.symbol,
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
return 'starknetNetworks';
|
|
113
|
-
}
|
|
114
|
-
else if (connector.connectedChain === 'ECLIPSE') {
|
|
115
|
-
return 'eclipseNetworks';
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
return 'evmNetworks';
|
|
119
|
-
}
|
|
120
|
-
})();
|
|
121
|
-
const result = (_b = connector[network]) === null || _b === void 0 ? void 0 : _b.find((element) => element.chainId === chainId);
|
|
110
|
+
const enabledNetworks = connector.getEnabledNetworks();
|
|
111
|
+
const result = enabledNetworks === null || enabledNetworks === void 0 ? void 0 : enabledNetworks.find((network) => network.chainId === chainId);
|
|
122
112
|
return {
|
|
123
|
-
name: (
|
|
124
|
-
symbol: (
|
|
113
|
+
name: (_c = (_b = result === null || result === void 0 ? void 0 : result.nativeCurrency) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.displayName,
|
|
114
|
+
symbol: (_e = (_d = result === null || result === void 0 ? void 0 : result.nativeCurrency) === null || _d === void 0 ? void 0 : _d.symbol) !== null && _e !== void 0 ? _e : chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.symbol,
|
|
125
115
|
};
|
|
126
116
|
});
|
|
127
117
|
const { data: currency, isLoading } = usePromise.usePromise(fetchChainCurrency, {
|
|
@@ -91,10 +91,10 @@ import '../../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
|
91
91
|
|
|
92
92
|
const useFetchCurrency = (connector, network) => {
|
|
93
93
|
const fetchChainCurrency = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
94
|
-
var _a, _b, _c, _d, _e
|
|
94
|
+
var _a, _b, _c, _d, _e;
|
|
95
95
|
if (!connector)
|
|
96
96
|
return null;
|
|
97
|
-
const chainId = yield connector.getNetwork();
|
|
97
|
+
const chainId = yield connector.getNetwork(true);
|
|
98
98
|
const chainInfo = getChainInfoWithOverrides((_a = connector.connectedChain) !== null && _a !== void 0 ? _a : '');
|
|
99
99
|
/* istanbul ignore else */
|
|
100
100
|
if (!chainId) {
|
|
@@ -103,21 +103,11 @@ const useFetchCurrency = (connector, network) => {
|
|
|
103
103
|
symbol: chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.symbol,
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
return 'starknetNetworks';
|
|
109
|
-
}
|
|
110
|
-
else if (connector.connectedChain === 'ECLIPSE') {
|
|
111
|
-
return 'eclipseNetworks';
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
return 'evmNetworks';
|
|
115
|
-
}
|
|
116
|
-
})();
|
|
117
|
-
const result = (_b = connector[network]) === null || _b === void 0 ? void 0 : _b.find((element) => element.chainId === chainId);
|
|
106
|
+
const enabledNetworks = connector.getEnabledNetworks();
|
|
107
|
+
const result = enabledNetworks === null || enabledNetworks === void 0 ? void 0 : enabledNetworks.find((network) => network.chainId === chainId);
|
|
118
108
|
return {
|
|
119
|
-
name: (
|
|
120
|
-
symbol: (
|
|
109
|
+
name: (_c = (_b = result === null || result === void 0 ? void 0 : result.nativeCurrency) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.displayName,
|
|
110
|
+
symbol: (_e = (_d = result === null || result === void 0 ? void 0 : result.nativeCurrency) === null || _d === void 0 ? void 0 : _d.symbol) !== null && _e !== void 0 ? _e : chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.symbol,
|
|
121
111
|
};
|
|
122
112
|
});
|
|
123
113
|
const { data: currency, isLoading } = usePromise(fetchChainCurrency, {
|
|
@@ -23,7 +23,7 @@ var exportRecoveryPhrase = require('../../../../shared/assets/export-recovery-ph
|
|
|
23
23
|
var footerInfoIcon = require('../../../../shared/assets/footer-info-icon.cjs');
|
|
24
24
|
var shield = require('../../../../shared/assets/shield.cjs');
|
|
25
25
|
var signInWithEmail = require('../../../../shared/assets/sign-in-with-email.cjs');
|
|
26
|
-
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
26
|
+
var ViewContext = require('../../../../context/ViewContext/ViewContext.cjs');
|
|
27
27
|
require('@dynamic-labs/wallet-book');
|
|
28
28
|
require('@dynamic-labs/utils');
|
|
29
29
|
require('../../../../utils/constants/colors.cjs');
|
|
@@ -117,7 +117,8 @@ var useInternalDynamicContext = require('../../../../context/DynamicContext/useD
|
|
|
117
117
|
|
|
118
118
|
const AccountAndSecuritySettingsView = () => {
|
|
119
119
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
120
|
-
const {
|
|
120
|
+
const { pushView } = ViewContext.useViewContext();
|
|
121
|
+
const { primaryWallet, user, setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
121
122
|
const projectSettings$1 = projectSettings.useProjectSettings();
|
|
122
123
|
const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
|
|
123
124
|
const { addEmbeddedWalletRecoveryEmail } = useEmbeddedWalletAuthenticator.useEmbeddedWalletAuthenticator();
|
|
@@ -181,6 +182,14 @@ const AccountAndSecuritySettingsView = () => {
|
|
|
181
182
|
const handlePasskeyButtonClick = React.useCallback(() => handlePasskeyClick(), [handlePasskeyClick]);
|
|
182
183
|
const handleExportButtonClick = React.useCallback(() => handleExportClick(), [handleExportClick]);
|
|
183
184
|
const handleExportWithPhraseClick = React.useCallback(() => handleExportClick(true), [handleExportClick]);
|
|
185
|
+
const handleDeleteAccountClick = React.useCallback(() => {
|
|
186
|
+
pushView('user-delete-account', {}, {
|
|
187
|
+
onBackClick: () => {
|
|
188
|
+
setShowAuthFlow(false);
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
setShowAuthFlow(true);
|
|
192
|
+
}, [pushView, setShowAuthFlow]);
|
|
184
193
|
const renderPasskeysButtonEndSlot = () => {
|
|
185
194
|
if (isTurnkeyWalletWithAuthenticator)
|
|
186
195
|
return (jsxRuntime.jsx(checkCircle.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--success' }));
|
|
@@ -206,7 +215,7 @@ const AccountAndSecuritySettingsView = () => {
|
|
|
206
215
|
const identitySectionTitleClasses = React.useMemo(() => classNames.classNames('settings-view__body__section__title', 'settings-view__body__section__title__info-icon'), []);
|
|
207
216
|
const emailButtonClasses = React.useMemo(() => classNames.classNames('settings-view__body__section__button', 'settings-view__body__section__button__badge'), []);
|
|
208
217
|
return (jsxRuntime.jsxs("div", { className: 'account-and-security-settings-view', children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { leading: backButton, children: jsxRuntime.jsx("div", { className: 'send-balance-page-layout__header-content', children: jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', copykey: 'dyn_settings.account_security.title', children: t('dyn_settings.account_security.title') }) }) }), jsxRuntime.jsx("div", { className: 'account-wrap', children: jsxRuntime.jsxs("div", { className: 'settings-view__body', children: [jsxRuntime.jsxs("div", { className: 'settings-view__body__section', children: [shouldShowPasskeyMFA ||
|
|
209
|
-
(isMfaEnabled && (jsxRuntime.jsx("div", { className: securitySectionTitleClasses, children: t('dyn_settings.security_section.title') }))),
|
|
218
|
+
(isMfaEnabled && (jsxRuntime.jsx("div", { className: securitySectionTitleClasses, children: t('dyn_settings.security_section.title') }))), shouldShowPasskeyMFA && (jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'manage-passkeys-button', onClick: handlePasskeyButtonClick, buttonClassName: passkeyButtonClasses, startSlot:
|
|
210
219
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
211
220
|
jsxRuntime.jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsxRuntime.jsx(PasskeyDeviceIcon.PasskeyDeviceIcon, { className: 'settings-view__body__section__button__icon', defaultIcon: jsxRuntime.jsx(androidTouchId.ReactComponent, { "data-testid": 'default-icon' }) }), jsxRuntime.jsx(Typography.Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.security_section.passkey_button', children: t('dyn_settings.security_section.passkey_button') }), !isTurnkeyWalletWithAuthenticator && (jsxRuntime.jsx(Badge.Badge, { text: t('dyn_settings.tags.recommended'), copykey: 'dyn_settings.tags.recommended', variant: 'secondary' }))] }), endSlot: renderPasskeysButtonEndSlot(), disabled: isLoading, showInternalLoading: false })), isMfaEnabled && (jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'manage-mfa-button', onClick: handleMfaClick, buttonClassName: 'settings-view__body__section__button', startSlot:
|
|
212
221
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
@@ -218,7 +227,7 @@ const AccountAndSecuritySettingsView = () => {
|
|
|
218
227
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
219
228
|
jsxRuntime.jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsxRuntime.jsx(exportPrivateKey.ReactComponent, { className: exportIconClasses }), jsxRuntime.jsx(Typography.Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.export_section.private_key_button', children: t('dyn_settings.export_section.private_key_button') })] }), endSlot: jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false }), isTurnkeyHDWallet && (jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'embedded-reveal-button', onClick: handleExportWithPhraseClick, buttonClassName: 'settings-view__body__section__button', startSlot:
|
|
220
229
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
221
|
-
jsxRuntime.jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsxRuntime.jsx(exportRecoveryPhrase.ReactComponent, { className: exportIconClasses }), jsxRuntime.jsx(Typography.Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.export_section.srp_button', children: t('dyn_settings.export_section.srp_button') })] }), endSlot: jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false }))] })] }))] }) })] }));
|
|
230
|
+
jsxRuntime.jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsxRuntime.jsx(exportRecoveryPhrase.ReactComponent, { className: exportIconClasses }), jsxRuntime.jsx(Typography.Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.export_section.srp_button', children: t('dyn_settings.export_section.srp_button') })] }), endSlot: jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false }))] })] }))] }) }), jsxRuntime.jsx("div", { className: 'account-and-security-settings-view__delete-account-container', children: jsxRuntime.jsx(Typography.Typography, { onClick: handleDeleteAccountClick, dataTestId: 'delete-account-button', color: 'error-1', variant: 'body_small', className: 'account-and-security-settings-view__delete-account-container__delete-button', children: t('dyn_settings.delete_account.title') }) })] }));
|
|
222
231
|
};
|
|
223
232
|
|
|
224
233
|
exports.AccountAndSecuritySettingsView = AccountAndSecuritySettingsView;
|
|
@@ -19,7 +19,7 @@ import { ReactComponent as SvgExportRecoveryPhrase } from '../../../../shared/as
|
|
|
19
19
|
import { ReactComponent as SvgFooterInfoIcon } from '../../../../shared/assets/footer-info-icon.js';
|
|
20
20
|
import { ReactComponent as SvgShield } from '../../../../shared/assets/shield.js';
|
|
21
21
|
import { ReactComponent as SvgSignInWithEmail } from '../../../../shared/assets/sign-in-with-email.js';
|
|
22
|
-
import '../../../../context/ViewContext/ViewContext.js';
|
|
22
|
+
import { useViewContext } from '../../../../context/ViewContext/ViewContext.js';
|
|
23
23
|
import '@dynamic-labs/wallet-book';
|
|
24
24
|
import '@dynamic-labs/utils';
|
|
25
25
|
import '../../../../utils/constants/colors.js';
|
|
@@ -113,7 +113,8 @@ import { useInternalDynamicContext } from '../../../../context/DynamicContext/us
|
|
|
113
113
|
|
|
114
114
|
const AccountAndSecuritySettingsView = () => {
|
|
115
115
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
116
|
-
const {
|
|
116
|
+
const { pushView } = useViewContext();
|
|
117
|
+
const { primaryWallet, user, setShowAuthFlow } = useInternalDynamicContext();
|
|
117
118
|
const projectSettings = useProjectSettings();
|
|
118
119
|
const { setDynamicWidgetView } = useWidgetContext();
|
|
119
120
|
const { addEmbeddedWalletRecoveryEmail } = useEmbeddedWalletAuthenticator();
|
|
@@ -177,6 +178,14 @@ const AccountAndSecuritySettingsView = () => {
|
|
|
177
178
|
const handlePasskeyButtonClick = useCallback(() => handlePasskeyClick(), [handlePasskeyClick]);
|
|
178
179
|
const handleExportButtonClick = useCallback(() => handleExportClick(), [handleExportClick]);
|
|
179
180
|
const handleExportWithPhraseClick = useCallback(() => handleExportClick(true), [handleExportClick]);
|
|
181
|
+
const handleDeleteAccountClick = useCallback(() => {
|
|
182
|
+
pushView('user-delete-account', {}, {
|
|
183
|
+
onBackClick: () => {
|
|
184
|
+
setShowAuthFlow(false);
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
setShowAuthFlow(true);
|
|
188
|
+
}, [pushView, setShowAuthFlow]);
|
|
180
189
|
const renderPasskeysButtonEndSlot = () => {
|
|
181
190
|
if (isTurnkeyWalletWithAuthenticator)
|
|
182
191
|
return (jsx(SvgCheckCircle, { className: 'settings-view__body__section__button__icon-secondary--success' }));
|
|
@@ -202,7 +211,7 @@ const AccountAndSecuritySettingsView = () => {
|
|
|
202
211
|
const identitySectionTitleClasses = useMemo(() => classNames('settings-view__body__section__title', 'settings-view__body__section__title__info-icon'), []);
|
|
203
212
|
const emailButtonClasses = useMemo(() => classNames('settings-view__body__section__button', 'settings-view__body__section__button__badge'), []);
|
|
204
213
|
return (jsxs("div", { className: 'account-and-security-settings-view', children: [jsx(ModalHeader, { leading: backButton, children: jsx("div", { className: 'send-balance-page-layout__header-content', children: jsx(Typography, { variant: 'title', color: 'primary', copykey: 'dyn_settings.account_security.title', children: t('dyn_settings.account_security.title') }) }) }), jsx("div", { className: 'account-wrap', children: jsxs("div", { className: 'settings-view__body', children: [jsxs("div", { className: 'settings-view__body__section', children: [shouldShowPasskeyMFA ||
|
|
205
|
-
(isMfaEnabled && (jsx("div", { className: securitySectionTitleClasses, children: t('dyn_settings.security_section.title') }))),
|
|
214
|
+
(isMfaEnabled && (jsx("div", { className: securitySectionTitleClasses, children: t('dyn_settings.security_section.title') }))), shouldShowPasskeyMFA && (jsx(TypographyButton, { dataTestId: 'manage-passkeys-button', onClick: handlePasskeyButtonClick, buttonClassName: passkeyButtonClasses, startSlot:
|
|
206
215
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
207
216
|
jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsx(PasskeyDeviceIcon, { className: 'settings-view__body__section__button__icon', defaultIcon: jsx(SvgAndroidTouchId, { "data-testid": 'default-icon' }) }), jsx(Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.security_section.passkey_button', children: t('dyn_settings.security_section.passkey_button') }), !isTurnkeyWalletWithAuthenticator && (jsx(Badge, { text: t('dyn_settings.tags.recommended'), copykey: 'dyn_settings.tags.recommended', variant: 'secondary' }))] }), endSlot: renderPasskeysButtonEndSlot(), disabled: isLoading, showInternalLoading: false })), isMfaEnabled && (jsx(TypographyButton, { dataTestId: 'manage-mfa-button', onClick: handleMfaClick, buttonClassName: 'settings-view__body__section__button', startSlot:
|
|
208
217
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
@@ -214,7 +223,7 @@ const AccountAndSecuritySettingsView = () => {
|
|
|
214
223
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
215
224
|
jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsx(SvgExportPrivateKey, { className: exportIconClasses }), jsx(Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.export_section.private_key_button', children: t('dyn_settings.export_section.private_key_button') })] }), endSlot: jsx(SvgChevronLeft, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false }), isTurnkeyHDWallet && (jsx(TypographyButton, { dataTestId: 'embedded-reveal-button', onClick: handleExportWithPhraseClick, buttonClassName: 'settings-view__body__section__button', startSlot:
|
|
216
225
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
217
|
-
jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsx(SvgExportRecoveryPhrase, { className: exportIconClasses }), jsx(Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.export_section.srp_button', children: t('dyn_settings.export_section.srp_button') })] }), endSlot: jsx(SvgChevronLeft, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false }))] })] }))] }) })] }));
|
|
226
|
+
jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsx(SvgExportRecoveryPhrase, { className: exportIconClasses }), jsx(Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.export_section.srp_button', children: t('dyn_settings.export_section.srp_button') })] }), endSlot: jsx(SvgChevronLeft, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false }))] })] }))] }) }), jsx("div", { className: 'account-and-security-settings-view__delete-account-container', children: jsx(Typography, { onClick: handleDeleteAccountClick, dataTestId: 'delete-account-button', color: 'error-1', variant: 'body_small', className: 'account-and-security-settings-view__delete-account-container__delete-button', children: t('dyn_settings.delete_account.title') }) })] }));
|
|
218
227
|
};
|
|
219
228
|
|
|
220
229
|
export { AccountAndSecuritySettingsView };
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var React = require('react');
|
|
7
8
|
var reactI18next = require('react-i18next');
|
|
8
9
|
var Typography = require('../../../../components/Typography/Typography.cjs');
|
|
9
10
|
var TypographyButton = require('../../../../components/TypographyButton/TypographyButton.cjs');
|
|
10
|
-
require('react');
|
|
11
11
|
require('../../../../context/DynamicContext/DynamicContext.cjs');
|
|
12
12
|
require('@dynamic-labs/sdk-api-core');
|
|
13
13
|
require('../../../../shared/logger.cjs');
|
|
@@ -16,7 +16,7 @@ require('@dynamic-labs/wallet-connector-core');
|
|
|
16
16
|
var chevronLeft = require('../../../../shared/assets/chevron-left.cjs');
|
|
17
17
|
var connectedApps = require('../../../../shared/assets/connected-apps.cjs');
|
|
18
18
|
var accountAndSecurity = require('../../../../shared/assets/account-and-security.cjs');
|
|
19
|
-
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
19
|
+
var ViewContext = require('../../../../context/ViewContext/ViewContext.cjs');
|
|
20
20
|
require('@dynamic-labs/wallet-book');
|
|
21
21
|
require('@dynamic-labs/utils');
|
|
22
22
|
require('../../../../utils/constants/colors.cjs');
|
|
@@ -102,23 +102,35 @@ var useInternalDynamicContext = require('../../../../context/DynamicContext/useD
|
|
|
102
102
|
|
|
103
103
|
const SettingsView = () => {
|
|
104
104
|
var _a, _b, _c, _d, _e;
|
|
105
|
-
const {
|
|
105
|
+
const { pushView } = ViewContext.useViewContext();
|
|
106
|
+
const { primaryWallet, handleLogOut, setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
106
107
|
const projectSettings$1 = projectSettings.useProjectSettings();
|
|
107
108
|
const { globalWallet } =
|
|
108
109
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
109
110
|
(_a = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector) !== null && _a !== void 0 ? _a : {};
|
|
110
111
|
const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
|
|
111
112
|
const { t } = reactI18next.useTranslation();
|
|
112
|
-
const handleConnectedAppsClick = () => {
|
|
113
|
+
const handleConnectedAppsClick = React.useCallback(() => {
|
|
113
114
|
setDynamicWidgetView('connected-apps');
|
|
114
|
-
};
|
|
115
|
+
}, [setDynamicWidgetView]);
|
|
116
|
+
const handleAccountSecurityClick = React.useCallback(() => {
|
|
117
|
+
setDynamicWidgetView('account-and-security-settings');
|
|
118
|
+
}, [setDynamicWidgetView]);
|
|
119
|
+
const handleDeleteAccountClick = React.useCallback(() => {
|
|
120
|
+
pushView('user-delete-account', {}, {
|
|
121
|
+
onBackClick: () => {
|
|
122
|
+
setShowAuthFlow(false);
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
setShowAuthFlow(true);
|
|
126
|
+
}, [pushView, setShowAuthFlow]);
|
|
115
127
|
const { getEOAWallet } = useSmartWallets.useSmartWallets();
|
|
116
128
|
const eoaWallet = primaryWallet && getEOAWallet(primaryWallet);
|
|
117
129
|
const wallet = eoaWallet !== null && eoaWallet !== void 0 ? eoaWallet : primaryWallet;
|
|
118
130
|
const isMfaEnabled = Boolean((_c = (_b = projectSettings$1 === null || projectSettings$1 === void 0 ? void 0 : projectSettings$1.security) === null || _b === void 0 ? void 0 : _b.mfa) === null || _c === void 0 ? void 0 : _c.enabled);
|
|
119
131
|
const isEmbeddedWallet = Boolean(wallet && ((_e = (_d = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _d === void 0 ? void 0 : _d.key) === null || _e === void 0 ? void 0 : _e.startsWith('turnkey')));
|
|
120
132
|
const shouldShowAccountAndSecuritySettings = isMfaEnabled || isEmbeddedWallet;
|
|
121
|
-
return (jsxRuntime.jsxs("div", { className: 'settings-view', children: [jsxRuntime.
|
|
133
|
+
return (jsxRuntime.jsxs("div", { className: 'settings-view', children: [jsxRuntime.jsx("div", { className: 'settings-view__body', children: shouldShowAccountAndSecuritySettings || globalWallet ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: 'settings-view__body__section', children: [(shouldShowAccountAndSecuritySettings || globalWallet) && (jsxRuntime.jsx("div", { className: 'settings-view__body__section__title', children: t('dyn_settings.general_section.title', 'General') })), shouldShowAccountAndSecuritySettings && (jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'account-and-security-button', buttonClassName: 'settings-view__body__section__button', onClick: handleAccountSecurityClick, startSlot: jsxRuntime.jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsxRuntime.jsx(accountAndSecurity.ReactComponent, { className: 'settings-view__body__section__button__icon' }), jsxRuntime.jsx(Typography.Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.account_security.title', children: t('dyn_settings.account_security.title') })] }), endSlot: jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false }))] }), globalWallet && (jsxRuntime.jsxs("div", { className: 'settings-view__body__section', children: [jsxRuntime.jsx("div", { className: 'settings-view__body__section__title', children: t('dyn_settings.global_connectivity_section.title') }), jsxRuntime.jsx(TypographyButton.TypographyButton, { onClick: handleConnectedAppsClick, dataTestId: 'connected-apps-button', buttonClassName: 'settings-view__body__section__button', startSlot: jsxRuntime.jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsxRuntime.jsx(connectedApps.ReactComponent, { className: 'settings-view__body__section__button__icon' }), jsxRuntime.jsx(Typography.Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.global_connectivity_section.connected_apps_button', children: t('dyn_settings.global_connectivity_section.connected_apps_button') })] }), endSlot: jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false })] }))] })) : (jsxRuntime.jsx(EmptyScreen.EmptyScreen, {})) }), jsxRuntime.jsx("div", { className: 'settings-view__logout-button-container', children: jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonClassName: 'settings-view__logout-button-container__button', onClick: handleLogOut, dataTestId: 'logout-button', copykey: 'dyn_settings.buttonLogout', children: t('dyn_settings.button_logout') }) }), !shouldShowAccountAndSecuritySettings && (jsxRuntime.jsx("div", { className: 'settings-view__delete-account-container', children: jsxRuntime.jsx(Typography.Typography, { onClick: handleDeleteAccountClick, dataTestId: 'delete-account-button', copykey: 'dyn_settings.delete_account.title', color: 'error-1', variant: 'body_small', className: 'settings-view__delete-account-container__delete-button', children: t('dyn_settings.delete_account.title') }) }))] }));
|
|
122
134
|
};
|
|
123
135
|
|
|
124
136
|
exports.SettingsView = SettingsView;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import { useCallback } from 'react';
|
|
3
4
|
import { useTranslation } from 'react-i18next';
|
|
4
5
|
import { Typography } from '../../../../components/Typography/Typography.js';
|
|
5
6
|
import { TypographyButton } from '../../../../components/TypographyButton/TypographyButton.js';
|
|
6
|
-
import 'react';
|
|
7
7
|
import '../../../../context/DynamicContext/DynamicContext.js';
|
|
8
8
|
import '@dynamic-labs/sdk-api-core';
|
|
9
9
|
import '../../../../shared/logger.js';
|
|
@@ -12,7 +12,7 @@ import '@dynamic-labs/wallet-connector-core';
|
|
|
12
12
|
import { ReactComponent as SvgChevronLeft } from '../../../../shared/assets/chevron-left.js';
|
|
13
13
|
import { ReactComponent as SvgConnectedApps } from '../../../../shared/assets/connected-apps.js';
|
|
14
14
|
import { ReactComponent as SvgAccountAndSecurity } from '../../../../shared/assets/account-and-security.js';
|
|
15
|
-
import '../../../../context/ViewContext/ViewContext.js';
|
|
15
|
+
import { useViewContext } from '../../../../context/ViewContext/ViewContext.js';
|
|
16
16
|
import '@dynamic-labs/wallet-book';
|
|
17
17
|
import '@dynamic-labs/utils';
|
|
18
18
|
import '../../../../utils/constants/colors.js';
|
|
@@ -98,23 +98,35 @@ import { useInternalDynamicContext } from '../../../../context/DynamicContext/us
|
|
|
98
98
|
|
|
99
99
|
const SettingsView = () => {
|
|
100
100
|
var _a, _b, _c, _d, _e;
|
|
101
|
-
const {
|
|
101
|
+
const { pushView } = useViewContext();
|
|
102
|
+
const { primaryWallet, handleLogOut, setShowAuthFlow } = useInternalDynamicContext();
|
|
102
103
|
const projectSettings = useProjectSettings();
|
|
103
104
|
const { globalWallet } =
|
|
104
105
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
105
106
|
(_a = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector) !== null && _a !== void 0 ? _a : {};
|
|
106
107
|
const { setDynamicWidgetView } = useWidgetContext();
|
|
107
108
|
const { t } = useTranslation();
|
|
108
|
-
const handleConnectedAppsClick = () => {
|
|
109
|
+
const handleConnectedAppsClick = useCallback(() => {
|
|
109
110
|
setDynamicWidgetView('connected-apps');
|
|
110
|
-
};
|
|
111
|
+
}, [setDynamicWidgetView]);
|
|
112
|
+
const handleAccountSecurityClick = useCallback(() => {
|
|
113
|
+
setDynamicWidgetView('account-and-security-settings');
|
|
114
|
+
}, [setDynamicWidgetView]);
|
|
115
|
+
const handleDeleteAccountClick = useCallback(() => {
|
|
116
|
+
pushView('user-delete-account', {}, {
|
|
117
|
+
onBackClick: () => {
|
|
118
|
+
setShowAuthFlow(false);
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
setShowAuthFlow(true);
|
|
122
|
+
}, [pushView, setShowAuthFlow]);
|
|
111
123
|
const { getEOAWallet } = useSmartWallets();
|
|
112
124
|
const eoaWallet = primaryWallet && getEOAWallet(primaryWallet);
|
|
113
125
|
const wallet = eoaWallet !== null && eoaWallet !== void 0 ? eoaWallet : primaryWallet;
|
|
114
126
|
const isMfaEnabled = Boolean((_c = (_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.security) === null || _b === void 0 ? void 0 : _b.mfa) === null || _c === void 0 ? void 0 : _c.enabled);
|
|
115
127
|
const isEmbeddedWallet = Boolean(wallet && ((_e = (_d = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _d === void 0 ? void 0 : _d.key) === null || _e === void 0 ? void 0 : _e.startsWith('turnkey')));
|
|
116
128
|
const shouldShowAccountAndSecuritySettings = isMfaEnabled || isEmbeddedWallet;
|
|
117
|
-
return (jsxs("div", { className: 'settings-view', children: [
|
|
129
|
+
return (jsxs("div", { className: 'settings-view', children: [jsx("div", { className: 'settings-view__body', children: shouldShowAccountAndSecuritySettings || globalWallet ? (jsxs(Fragment, { children: [jsxs("div", { className: 'settings-view__body__section', children: [(shouldShowAccountAndSecuritySettings || globalWallet) && (jsx("div", { className: 'settings-view__body__section__title', children: t('dyn_settings.general_section.title', 'General') })), shouldShowAccountAndSecuritySettings && (jsx(TypographyButton, { dataTestId: 'account-and-security-button', buttonClassName: 'settings-view__body__section__button', onClick: handleAccountSecurityClick, startSlot: jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsx(SvgAccountAndSecurity, { className: 'settings-view__body__section__button__icon' }), jsx(Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.account_security.title', children: t('dyn_settings.account_security.title') })] }), endSlot: jsx(SvgChevronLeft, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false }))] }), globalWallet && (jsxs("div", { className: 'settings-view__body__section', children: [jsx("div", { className: 'settings-view__body__section__title', children: t('dyn_settings.global_connectivity_section.title') }), jsx(TypographyButton, { onClick: handleConnectedAppsClick, dataTestId: 'connected-apps-button', buttonClassName: 'settings-view__body__section__button', startSlot: jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsx(SvgConnectedApps, { className: 'settings-view__body__section__button__icon' }), jsx(Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.global_connectivity_section.connected_apps_button', children: t('dyn_settings.global_connectivity_section.connected_apps_button') })] }), endSlot: jsx(SvgChevronLeft, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false })] }))] })) : (jsx(EmptyScreen, {})) }), jsx("div", { className: 'settings-view__logout-button-container', children: jsx(TypographyButton, { buttonClassName: 'settings-view__logout-button-container__button', onClick: handleLogOut, dataTestId: 'logout-button', copykey: 'dyn_settings.buttonLogout', children: t('dyn_settings.button_logout') }) }), !shouldShowAccountAndSecuritySettings && (jsx("div", { className: 'settings-view__delete-account-container', children: jsx(Typography, { onClick: handleDeleteAccountClick, dataTestId: 'delete-account-button', copykey: 'dyn_settings.delete_account.title', color: 'error-1', variant: 'body_small', className: 'settings-view__delete-account-container__delete-button', children: t('dyn_settings.delete_account.title') }) }))] }));
|
|
118
130
|
};
|
|
119
131
|
|
|
120
132
|
export { SettingsView };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
const getWalletConnectorNetworks = (walletConnector) => {
|
|
7
|
-
if (!walletConnector)
|
|
8
|
-
return [];
|
|
9
|
-
const _walletConnector = walletConnector;
|
|
10
|
-
return (_walletConnector.evmNetworks || _walletConnector.starknetNetworks || []);
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
exports.getWalletConnectorNetworks = getWalletConnectorNetworks;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
const getWalletConnectorNetworks = (walletConnector) => {
|
|
3
|
-
if (!walletConnector)
|
|
4
|
-
return [];
|
|
5
|
-
const _walletConnector = walletConnector;
|
|
6
|
-
return (_walletConnector.evmNetworks || _walletConnector.starknetNetworks || []);
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export { getWalletConnectorNetworks };
|