@dynamic-labs/sdk-react-core 4.46.3 → 4.47.1
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 +21 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +12 -12
- package/src/index.cjs +2 -2
- package/src/index.js +1 -1
- package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.cjs +2 -0
- package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.js +2 -0
- package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.cjs +2 -0
- package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.js +2 -0
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +2 -0
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +2 -0
- package/src/lib/layout/DynamicUserProfileLayout/DynamicUserProfileLayout.cjs +2 -0
- package/src/lib/layout/DynamicUserProfileLayout/DynamicUserProfileLayout.js +2 -0
- package/src/lib/shared/assets/backup-waas.cjs +52 -0
- package/src/lib/shared/assets/backup-waas.js +28 -0
- package/src/lib/shared/assets/backupArrow.cjs +54 -0
- package/src/lib/shared/assets/backupArrow.js +30 -0
- package/src/lib/shared/assets/filled-question-mark.cjs +52 -0
- package/src/lib/shared/assets/filled-question-mark.js +28 -0
- package/src/lib/shared/assets/google-drive.cjs +75 -0
- package/src/lib/shared/assets/google-drive.js +51 -0
- package/src/lib/shared/assets/index.d.ts +4 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/functions/clientSessionKeys/getClientSessionKeys.js +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +2 -0
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +2 -0
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs +2 -0
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js +2 -0
- package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.cjs +2 -0
- package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.js +2 -0
- package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.cjs +0 -6
- package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.js +1 -7
- package/src/lib/utils/hooks/useExternalAuth/useExternalAuth.cjs +2 -0
- package/src/lib/utils/hooks/useExternalAuth/useExternalAuth.js +2 -0
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +3 -1
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.d.ts +5 -1
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +3 -1
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +6 -2
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.d.ts +1 -0
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +6 -2
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +2 -0
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +2 -0
- package/src/lib/views/EmailVerification/EmailVerification.cjs +2 -0
- package/src/lib/views/EmailVerification/EmailVerification.js +2 -0
- package/src/lib/views/SendBalanceView/SendBalanceView.cjs +1 -0
- package/src/lib/views/SendBalanceView/SendBalanceView.js +1 -0
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.cjs +2 -0
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.js +2 -0
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.cjs +4 -0
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.d.ts +2 -0
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.js +4 -0
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.types.d.ts +1 -1
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/EmbeddedWalletExportSection/EmbeddedWalletExportSection.cjs +15 -5
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/EmbeddedWalletExportSection/EmbeddedWalletExportSection.js +15 -5
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupInfoView.cjs +36 -0
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupInfoView.d.ts +2 -0
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupInfoView.js +32 -0
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupView.cjs +191 -0
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupView.d.ts +2 -0
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupView.js +187 -0
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/index.d.ts +2 -0
- package/src/lib/widgets/DynamicWidget/views/index.d.ts +2 -0
|
@@ -3,6 +3,7 @@ import { __awaiter } from '../../../../../../../_virtual/_tslib.js';
|
|
|
3
3
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
4
|
import { useCallback, useMemo } from 'react';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import { WaasBackupOptionsEnum } from '@dynamic-labs/sdk-api-core';
|
|
6
7
|
import { isSessionKeyCompatibleWallet } from '@dynamic-labs/wallet-connector-core';
|
|
7
8
|
import { Typography } from '../../../../../components/Typography/Typography.js';
|
|
8
9
|
import { TypographyButton } from '../../../../../components/TypographyButton/TypographyButton.js';
|
|
@@ -13,12 +14,12 @@ import { ReactComponent as SvgChevronLeft } from '../../../../../shared/assets/c
|
|
|
13
14
|
import { ReactComponent as SvgExportPrivateKey } from '../../../../../shared/assets/export-private-key.js';
|
|
14
15
|
import { ReactComponent as SvgExportRecoveryPhrase } from '../../../../../shared/assets/export-recovery-phrase.js';
|
|
15
16
|
import '../../../../../context/ViewContext/ViewContext.js';
|
|
17
|
+
import { ReactComponent as SvgBackupArrow } from '../../../../../shared/assets/backupArrow.js';
|
|
16
18
|
import '../../../../../shared/logger.js';
|
|
17
19
|
import '@dynamic-labs/wallet-book';
|
|
18
20
|
import '@dynamic-labs/utils';
|
|
19
21
|
import '../../../../../utils/constants/colors.js';
|
|
20
22
|
import '../../../../../utils/constants/values.js';
|
|
21
|
-
import '@dynamic-labs/sdk-api-core';
|
|
22
23
|
import '../../../../../shared/consts/index.js';
|
|
23
24
|
import '../../../../../events/dynamicEvents.js';
|
|
24
25
|
import '../../../../../context/CaptchaContext/CaptchaContext.js';
|
|
@@ -83,7 +84,7 @@ import '../../../../../context/IpConfigurationContext/IpConfigurationContext.js'
|
|
|
83
84
|
import '../../../../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
|
|
84
85
|
import '../../../../DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
85
86
|
import '@hcaptcha/react-hcaptcha';
|
|
86
|
-
import '../../../context/DynamicWidgetContext.js';
|
|
87
|
+
import { useWidgetContext } from '../../../context/DynamicWidgetContext.js';
|
|
87
88
|
import '../../../helpers/convertExchangeKeyAndProviderEnum.js';
|
|
88
89
|
import '../../../../../views/ExchangeWhitelistWarning/ExchangeWhitelistWarning.js';
|
|
89
90
|
import '../../../../../context/ErrorContext/hooks/useErrorText/useErrorText.js';
|
|
@@ -107,10 +108,11 @@ import '../../../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
|
107
108
|
import { useInternalDynamicContext } from '../../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
|
|
108
109
|
|
|
109
110
|
const EmbeddedWalletExportSection = () => {
|
|
110
|
-
var _a, _b, _c, _d, _e, _f;
|
|
111
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
111
112
|
const { t } = useTranslation();
|
|
112
113
|
const { theme } = useThemeContext();
|
|
113
|
-
const { primaryWallet, user } = useInternalDynamicContext();
|
|
114
|
+
const { primaryWallet, user, projectSettings } = useInternalDynamicContext();
|
|
115
|
+
const { setDynamicWidgetView } = useWidgetContext();
|
|
114
116
|
const { getEOAWallet } = useSmartWallets();
|
|
115
117
|
const { initPasskeyRecoveryProcess, shouldInitRecovery } = usePasskeyRecovery();
|
|
116
118
|
const { initExportProcess } = useEmbeddedReveal();
|
|
@@ -142,6 +144,12 @@ const EmbeddedWalletExportSection = () => {
|
|
|
142
144
|
const handleExportButtonClick = useCallback(() => handleExportClick(), [handleExportClick]);
|
|
143
145
|
const handleExportWithPhraseClick = useCallback(() => handleExportClick(true), [handleExportClick]);
|
|
144
146
|
const exportIconClasses = useMemo(() => `settings-view__body__section__button__icon${theme.theme.name === 'dark' ? '__stroke' : ''}`, [theme.theme.name]);
|
|
147
|
+
const isV3WaasWallet = Boolean(wallet && ((_h = (_g = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _g === void 0 ? void 0 : _g.key) === null || _h === void 0 ? void 0 : _h.startsWith('dynamicwaas')));
|
|
148
|
+
const isGoogleDriveBackupEnabled = Boolean((_l = (_k = (_j = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _j === void 0 ? void 0 : _j.waas) === null || _k === void 0 ? void 0 : _k.backupOptions) === null || _l === void 0 ? void 0 : _l.includes(WaasBackupOptionsEnum.GoogleDrive));
|
|
149
|
+
const shouldShowBackupOption = isV3WaasWallet && isGoogleDriveBackupEnabled;
|
|
150
|
+
const handleBackupClick = useCallback(() => {
|
|
151
|
+
setDynamicWidgetView('waas-backup');
|
|
152
|
+
}, [setDynamicWidgetView]);
|
|
145
153
|
if (!isEmbeddedWallet) {
|
|
146
154
|
return null;
|
|
147
155
|
}
|
|
@@ -149,7 +157,9 @@ const EmbeddedWalletExportSection = () => {
|
|
|
149
157
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
150
158
|
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:
|
|
151
159
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
152
|
-
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 }))
|
|
160
|
+
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 })), shouldShowBackupOption && (jsx(TypographyButton, { dataTestId: 'backup-button', onClick: handleBackupClick, buttonClassName: 'settings-view__body__section__button', startSlot:
|
|
161
|
+
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
162
|
+
jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsx(SvgBackupArrow, { className: exportIconClasses }), jsx(Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.export_section.backup_button', children: t('dyn_settings.export_section.backup_button') })] }), endSlot: jsx(SvgChevronLeft, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false }))] }));
|
|
153
163
|
};
|
|
154
164
|
|
|
155
165
|
export { EmbeddedWalletExportSection };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var reactI18next = require('react-i18next');
|
|
9
|
+
var Typography = require('../../../../components/Typography/Typography.cjs');
|
|
10
|
+
var TypographyButton = require('../../../../components/TypographyButton/TypographyButton.cjs');
|
|
11
|
+
var IconButton = require('../../../../components/IconButton/IconButton.cjs');
|
|
12
|
+
var ModalHeader = require('../../../../components/ModalHeader/ModalHeader.cjs');
|
|
13
|
+
var Icon = require('../../../../components/Icon/Icon.cjs');
|
|
14
|
+
var Alert = require('../../../../components/Alert/Alert.cjs');
|
|
15
|
+
var close = require('../../../../shared/assets/close.cjs');
|
|
16
|
+
var footerInfoIcon = require('../../../../shared/assets/footer-info-icon.cjs');
|
|
17
|
+
require('@dynamic-labs/iconic');
|
|
18
|
+
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
19
|
+
var filledQuestionMark = require('../../../../shared/assets/filled-question-mark.cjs');
|
|
20
|
+
var DynamicWidgetContext = require('../../context/DynamicWidgetContext.cjs');
|
|
21
|
+
|
|
22
|
+
const WaasBackupInfoView = () => {
|
|
23
|
+
const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
|
|
24
|
+
const { t } = reactI18next.useTranslation();
|
|
25
|
+
const handleBackClick = React.useCallback(() => setDynamicWidgetView('waas-backup'), [setDynamicWidgetView]);
|
|
26
|
+
const handleCloseClick = React.useCallback(() => setDynamicWidgetView('account-and-security-settings'), [setDynamicWidgetView]);
|
|
27
|
+
const closeButton = (jsxRuntime.jsx(IconButton.IconButton, { type: 'button', onClick: handleCloseClick, "data-testid": 'close-button', children: jsxRuntime.jsx(close.ReactComponent, {}) }));
|
|
28
|
+
return (jsxRuntime.jsxs("div", { className: 'waas-backup-view', children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { trailing: closeButton, children: jsxRuntime.jsx("div", { className: 'send-balance-page-layout__header-content', children: jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', copykey: 'dyn_waas.backup_info.title', children: t('dyn_waas.backup_info.title', 'Why backup a share') }) }) }), jsxRuntime.jsx("div", { className: 'account-wrap', children: jsxRuntime.jsx("div", { className: 'settings-view__body', children: jsxRuntime.jsxs("div", { className: 'backup-content', children: [jsxRuntime.jsx("div", { className: 'backup-icon-container', children: jsxRuntime.jsx(Icon.Icon, { color: 'brand-primary', children: jsxRuntime.jsx(filledQuestionMark.ReactComponent, { width: 64, height: 64 }) }) }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_waas.backup_info.description', children: t('dyn_waas.backup_info.description', 'Your account uses strong security behind the scenes. Backing up a share adds additional security to your account by requiring the share to be retrieved if your account is used on another device.') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_waas.backup_info.storage', children: t('dyn_waas.backup_info.storage', 'You can store this backup share in a secure cloud.') }), jsxRuntime.jsx(Alert.Alert, { icon:
|
|
29
|
+
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
30
|
+
jsxRuntime.jsx(Icon.Icon, { size: 'medium', children: jsxRuntime.jsx(footerInfoIcon.ReactComponent, { width: 24, height: 24 }) }), variant: 'warning', copykey: 'dyn_waas.backup_info.warning_alert', children: jsxRuntime.jsxs(Typography.Typography, { variant: 'body_small', color: 'current-color', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', copykey: 'dyn_waas.backup_info.important', style: { color: 'var(--default-alert-1, #DD8500)' }, children: t('dyn_waas.backup_info.important', 'Important') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'secondary', copykey: 'dyn_waas.backup_info.warning', children: t('dyn_waas.backup_info.warning', "Make sure you don't lose access to the backup share or you will not be able to restore this account!") })] }) }), jsxRuntime.jsx("div", { className: 'backup-actions', children: jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'back-button', onClick: handleBackClick, buttonClassName: 'backup-button', typographyProps: {
|
|
31
|
+
color: 'primary',
|
|
32
|
+
weight: 'bold',
|
|
33
|
+
}, copykey: 'dyn_waas.backup_info.back', buttonPadding: 'small', children: t('dyn_waas.backup_info.back', 'Back') }) })] }) }) })] }));
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.WaasBackupInfoView = WaasBackupInfoView;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { Typography } from '../../../../components/Typography/Typography.js';
|
|
6
|
+
import { TypographyButton } from '../../../../components/TypographyButton/TypographyButton.js';
|
|
7
|
+
import { IconButton } from '../../../../components/IconButton/IconButton.js';
|
|
8
|
+
import { ModalHeader } from '../../../../components/ModalHeader/ModalHeader.js';
|
|
9
|
+
import { Icon } from '../../../../components/Icon/Icon.js';
|
|
10
|
+
import { Alert } from '../../../../components/Alert/Alert.js';
|
|
11
|
+
import { ReactComponent as SvgClose } from '../../../../shared/assets/close.js';
|
|
12
|
+
import { ReactComponent as SvgFooterInfoIcon } from '../../../../shared/assets/footer-info-icon.js';
|
|
13
|
+
import '@dynamic-labs/iconic';
|
|
14
|
+
import '../../../../context/ViewContext/ViewContext.js';
|
|
15
|
+
import { ReactComponent as SvgFilledQuestionMark } from '../../../../shared/assets/filled-question-mark.js';
|
|
16
|
+
import { useWidgetContext } from '../../context/DynamicWidgetContext.js';
|
|
17
|
+
|
|
18
|
+
const WaasBackupInfoView = () => {
|
|
19
|
+
const { setDynamicWidgetView } = useWidgetContext();
|
|
20
|
+
const { t } = useTranslation();
|
|
21
|
+
const handleBackClick = useCallback(() => setDynamicWidgetView('waas-backup'), [setDynamicWidgetView]);
|
|
22
|
+
const handleCloseClick = useCallback(() => setDynamicWidgetView('account-and-security-settings'), [setDynamicWidgetView]);
|
|
23
|
+
const closeButton = (jsx(IconButton, { type: 'button', onClick: handleCloseClick, "data-testid": 'close-button', children: jsx(SvgClose, {}) }));
|
|
24
|
+
return (jsxs("div", { className: 'waas-backup-view', children: [jsx(ModalHeader, { trailing: closeButton, children: jsx("div", { className: 'send-balance-page-layout__header-content', children: jsx(Typography, { variant: 'title', color: 'primary', copykey: 'dyn_waas.backup_info.title', children: t('dyn_waas.backup_info.title', 'Why backup a share') }) }) }), jsx("div", { className: 'account-wrap', children: jsx("div", { className: 'settings-view__body', children: jsxs("div", { className: 'backup-content', children: [jsx("div", { className: 'backup-icon-container', children: jsx(Icon, { color: 'brand-primary', children: jsx(SvgFilledQuestionMark, { width: 64, height: 64 }) }) }), jsx(Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_waas.backup_info.description', children: t('dyn_waas.backup_info.description', 'Your account uses strong security behind the scenes. Backing up a share adds additional security to your account by requiring the share to be retrieved if your account is used on another device.') }), jsx(Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_waas.backup_info.storage', children: t('dyn_waas.backup_info.storage', 'You can store this backup share in a secure cloud.') }), jsx(Alert, { icon:
|
|
25
|
+
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
26
|
+
jsx(Icon, { size: 'medium', children: jsx(SvgFooterInfoIcon, { width: 24, height: 24 }) }), variant: 'warning', copykey: 'dyn_waas.backup_info.warning_alert', children: jsxs(Typography, { variant: 'body_small', color: 'current-color', children: [jsx(Typography, { variant: 'body_normal', copykey: 'dyn_waas.backup_info.important', style: { color: 'var(--default-alert-1, #DD8500)' }, children: t('dyn_waas.backup_info.important', 'Important') }), jsx(Typography, { variant: 'body_normal', color: 'secondary', copykey: 'dyn_waas.backup_info.warning', children: t('dyn_waas.backup_info.warning', "Make sure you don't lose access to the backup share or you will not be able to restore this account!") })] }) }), jsx("div", { className: 'backup-actions', children: jsx(TypographyButton, { dataTestId: 'back-button', onClick: handleBackClick, buttonClassName: 'backup-button', typographyProps: {
|
|
27
|
+
color: 'primary',
|
|
28
|
+
weight: 'bold',
|
|
29
|
+
}, copykey: 'dyn_waas.backup_info.back', buttonPadding: 'small', children: t('dyn_waas.backup_info.back', 'Back') }) })] }) }) })] }));
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { WaasBackupInfoView };
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
var React = require('react');
|
|
9
|
+
var reactI18next = require('react-i18next');
|
|
10
|
+
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
11
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
12
|
+
require('@dynamic-labs-sdk/client/core');
|
|
13
|
+
require('../../../../client/client.cjs');
|
|
14
|
+
require('@dynamic-labs-sdk/client');
|
|
15
|
+
require('../../../../config/ApiEndpoint.cjs');
|
|
16
|
+
require('../../../../utils/constants/values.cjs');
|
|
17
|
+
require('@dynamic-labs/utils');
|
|
18
|
+
require('@dynamic-labs/multi-wallet');
|
|
19
|
+
require('react-international-phone');
|
|
20
|
+
require('../../../../utils/constants/colors.cjs');
|
|
21
|
+
require('@dynamic-labs/iconic');
|
|
22
|
+
var check = require('../../../../shared/assets/check.cjs');
|
|
23
|
+
var close = require('../../../../shared/assets/close.cjs');
|
|
24
|
+
var questionMark = require('../../../../shared/assets/question-mark.cjs');
|
|
25
|
+
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
26
|
+
var backupWaas = require('../../../../shared/assets/backup-waas.cjs');
|
|
27
|
+
var googleDrive = require('../../../../shared/assets/google-drive.cjs');
|
|
28
|
+
require('../../../../shared/logger.cjs');
|
|
29
|
+
require('@dynamic-labs/wallet-book');
|
|
30
|
+
require('../../../../shared/consts/index.cjs');
|
|
31
|
+
require('../../../../store/state/nonce/nonce.cjs');
|
|
32
|
+
require('@dynamic-labs/locale');
|
|
33
|
+
require('../../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
34
|
+
require('../../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
35
|
+
require('../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
36
|
+
require('../../../../events/dynamicEvents.cjs');
|
|
37
|
+
var useUser = require('../../../../client/extension/user/useUser/useUser.cjs');
|
|
38
|
+
var ErrorContainer = require('../../../../components/ErrorContainer/ErrorContainer.cjs');
|
|
39
|
+
var Icon = require('../../../../components/Icon/Icon.cjs');
|
|
40
|
+
var IconButton = require('../../../../components/IconButton/IconButton.cjs');
|
|
41
|
+
var ModalHeader = require('../../../../components/ModalHeader/ModalHeader.cjs');
|
|
42
|
+
var Typography = require('../../../../components/Typography/Typography.cjs');
|
|
43
|
+
var TypographyButton = require('../../../../components/TypographyButton/TypographyButton.cjs');
|
|
44
|
+
require('../../../../context/DynamicContext/DynamicContext.cjs');
|
|
45
|
+
require('../../../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
|
|
46
|
+
require('../../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
47
|
+
require('../../../../context/ErrorContext/ErrorContext.cjs');
|
|
48
|
+
require('../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
49
|
+
require('../../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
50
|
+
require('../../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
51
|
+
require('../../../../store/state/authMode/authMode.cjs');
|
|
52
|
+
require('../../../../context/VerificationContext/VerificationContext.cjs');
|
|
53
|
+
require('react-dom');
|
|
54
|
+
require('../../../../utils/functions/compareChains/compareChains.cjs');
|
|
55
|
+
require('../../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
|
|
56
|
+
require('../../../../context/ThemeContext/ThemeContext.cjs');
|
|
57
|
+
require('../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
58
|
+
var utils = require('../../../../utils/hooks/useTransactionSimulation/utils/utils.cjs');
|
|
59
|
+
require('bs58');
|
|
60
|
+
var useSocialAccounts = require('../../../../utils/hooks/useSocialAccounts/useSocialAccounts.cjs');
|
|
61
|
+
require('yup');
|
|
62
|
+
require('../../../../context/MockContext/MockContext.cjs');
|
|
63
|
+
require('../../../../views/CollectUserDataView/useFields.cjs');
|
|
64
|
+
require('../../../../context/FieldsStateContext/FieldsStateContext.cjs');
|
|
65
|
+
require('../../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
66
|
+
require('@dynamic-labs/rpc-providers');
|
|
67
|
+
require('../../../../store/state/walletOptions/walletOptions.cjs');
|
|
68
|
+
require('../../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
|
|
69
|
+
require('../../../../components/Alert/Alert.cjs');
|
|
70
|
+
require('../../../../context/WalletContext/WalletContext.cjs');
|
|
71
|
+
require('../../../../components/ShadowDOM/ShadowDOM.cjs');
|
|
72
|
+
require('../../../../components/InlineWidget/InlineWidget.cjs');
|
|
73
|
+
require('../../../../components/Input/Input.cjs');
|
|
74
|
+
require('../../../../components/IsBrowser/IsBrowser.cjs');
|
|
75
|
+
require('../../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
76
|
+
require('../../../../components/OverlayCard/OverlayCard.cjs');
|
|
77
|
+
require('../../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
78
|
+
require('../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
79
|
+
require('../../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
80
|
+
require('../../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
|
|
81
|
+
require('../../../../components/Popper/Popper/Popper.cjs');
|
|
82
|
+
require('../../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
83
|
+
require('react-focus-lock');
|
|
84
|
+
require('qrcode');
|
|
85
|
+
require('formik');
|
|
86
|
+
require('../../../../utils/hooks/useSubdomainCheck/useSubdomainCheck.cjs');
|
|
87
|
+
require('../../../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
88
|
+
require('../../../../context/IpConfigurationContext/IpConfigurationContext.cjs');
|
|
89
|
+
require('../../../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
90
|
+
require('../../../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
|
|
91
|
+
require('../../../DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
92
|
+
require('@hcaptcha/react-hcaptcha');
|
|
93
|
+
require('../../../../context/LoadingContext/LoadingContext.cjs');
|
|
94
|
+
var DynamicWidgetContext = require('../../context/DynamicWidgetContext.cjs');
|
|
95
|
+
require('../../helpers/convertExchangeKeyAndProviderEnum.cjs');
|
|
96
|
+
require('../../../../views/ExchangeWhitelistWarning/ExchangeWhitelistWarning.cjs');
|
|
97
|
+
require('../../../../context/ErrorContext/hooks/useErrorText/useErrorText.cjs');
|
|
98
|
+
require('../../../../context/FooterAnimationContext/index.cjs');
|
|
99
|
+
require('@dynamic-labs/types');
|
|
100
|
+
require('../../../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
|
|
101
|
+
require('../../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.cjs');
|
|
102
|
+
require('../../../../context/PasskeyContext/PasskeyContext.cjs');
|
|
103
|
+
require('../../../../context/OnrampContext/OnrampContext.cjs');
|
|
104
|
+
var useRefreshUser = require('../../../../utils/hooks/useRefreshUser/useRefreshUser.cjs');
|
|
105
|
+
require('../../../../store/state/sendBalances.cjs');
|
|
106
|
+
require('../../../../store/state/connectorsInitializing/connectorsInitializing.cjs');
|
|
107
|
+
require('../../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.cjs');
|
|
108
|
+
require('../../components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
109
|
+
require('../../../../views/TransactionConfirmationView/TransactionConfirmationView.cjs');
|
|
110
|
+
require('../../components/PasskeyCard/PasskeyCard.cjs');
|
|
111
|
+
require('../CryptoComOnramp/CryptoComOnramp.cjs');
|
|
112
|
+
require('../../../../../index.cjs');
|
|
113
|
+
require('../ReceiveWalletFunds/ReceiveWalletFunds.cjs');
|
|
114
|
+
require('../../../../store/state/tokenBalances.cjs');
|
|
115
|
+
require('../../../../store/state/multichainBalances.cjs');
|
|
116
|
+
require('../../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
117
|
+
var useInternalDynamicContext = require('../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
|
|
118
|
+
|
|
119
|
+
const WaasBackupView = () => {
|
|
120
|
+
const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
|
|
121
|
+
const user = useUser.useUser();
|
|
122
|
+
const { primaryWallet } = useInternalDynamicContext.useInternalDynamicContext();
|
|
123
|
+
const refresh = useRefreshUser.useRefreshUser();
|
|
124
|
+
const { linkSocialAccount, isLinked, isProcessingForProvider } = useSocialAccounts.useSocialAccounts();
|
|
125
|
+
const { t } = reactI18next.useTranslation();
|
|
126
|
+
const [errorMessage, setErrorMessage] = React.useState(null);
|
|
127
|
+
const isGoogleLinked = isLinked(sdkApiCore.ProviderEnum.Google);
|
|
128
|
+
const checkGoogleDriveBackup = React.useCallback(() => {
|
|
129
|
+
var _a, _b;
|
|
130
|
+
if (!user || !primaryWallet)
|
|
131
|
+
return false;
|
|
132
|
+
const walletCredential = (_a = user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find((cred) => cred.walletName === 'dynamicwaas' &&
|
|
133
|
+
cred.address === primaryWallet.address);
|
|
134
|
+
const keyShares = (_b = walletCredential === null || walletCredential === void 0 ? void 0 : walletCredential.walletProperties) === null || _b === void 0 ? void 0 : _b.keyShares;
|
|
135
|
+
if (!keyShares || !Array.isArray(keyShares))
|
|
136
|
+
return false;
|
|
137
|
+
return keyShares.some((keyShare) => keyShare &&
|
|
138
|
+
typeof keyShare === 'object' &&
|
|
139
|
+
'backupLocation' in keyShare &&
|
|
140
|
+
keyShare.backupLocation === 'googleDrive');
|
|
141
|
+
}, [user, primaryWallet]);
|
|
142
|
+
const isBackedUp = React.useMemo(() => checkGoogleDriveBackup(), [checkGoogleDriveBackup]);
|
|
143
|
+
const handleBackClick = React.useCallback(() => setDynamicWidgetView('account-and-security-settings'), [setDynamicWidgetView]);
|
|
144
|
+
const handleInfoClick = React.useCallback(() => {
|
|
145
|
+
setDynamicWidgetView('waas-backup-info');
|
|
146
|
+
}, [setDynamicWidgetView]);
|
|
147
|
+
const handleBackupWalletClick = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
148
|
+
setErrorMessage(null);
|
|
149
|
+
try {
|
|
150
|
+
if (!primaryWallet) {
|
|
151
|
+
throw new Error('No primary wallet found');
|
|
152
|
+
}
|
|
153
|
+
if (!isGoogleLinked) {
|
|
154
|
+
yield linkSocialAccount(sdkApiCore.ProviderEnum.Google, {
|
|
155
|
+
forcePopup: true,
|
|
156
|
+
showWidgetAfterConnection: false,
|
|
157
|
+
});
|
|
158
|
+
yield refresh();
|
|
159
|
+
}
|
|
160
|
+
let waasConnector;
|
|
161
|
+
if (walletConnectorCore.isDynamicWaasConnector(primaryWallet.connector)) {
|
|
162
|
+
waasConnector = primaryWallet.connector;
|
|
163
|
+
}
|
|
164
|
+
else if (utils.isZeroDevConnector(primaryWallet.connector)) {
|
|
165
|
+
const { eoaConnector } = primaryWallet.connector;
|
|
166
|
+
if (!eoaConnector || !walletConnectorCore.isDynamicWaasConnector(eoaConnector)) {
|
|
167
|
+
throw new Error('ZeroDev connector must have a WaaS EOA connector');
|
|
168
|
+
}
|
|
169
|
+
waasConnector = eoaConnector;
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
throw new Error('Not a supported connector type');
|
|
173
|
+
}
|
|
174
|
+
yield waasConnector.backupKeySharesToGoogleDrive({
|
|
175
|
+
accountAddress: primaryWallet.address,
|
|
176
|
+
});
|
|
177
|
+
yield refresh();
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
setErrorMessage(t('dyn_waas.backup.error'));
|
|
181
|
+
}
|
|
182
|
+
}), [primaryWallet, refresh, isGoogleLinked, linkSocialAccount, t]);
|
|
183
|
+
const infoButton = (jsxRuntime.jsx(IconButton.IconButton, { type: 'button', onClick: handleInfoClick, "data-testid": 'info-button', children: jsxRuntime.jsx(questionMark.ReactComponent, {}) }));
|
|
184
|
+
const closeButton = (jsxRuntime.jsx(IconButton.IconButton, { type: 'button', onClick: handleBackClick, "data-testid": 'close-button', children: jsxRuntime.jsx(close.ReactComponent, {}) }));
|
|
185
|
+
return (jsxRuntime.jsxs("div", { className: 'waas-backup-view', children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { leading: infoButton, trailing: closeButton, children: jsxRuntime.jsx("div", { className: 'send-balance-page-layout__header-content', children: jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', copykey: 'dyn_waas.backup.title', children: t('dyn_waas.backup.title') }) }) }), jsxRuntime.jsx("div", { className: 'account-wrap', children: jsxRuntime.jsxs("div", { className: 'settings-view__body', children: [errorMessage && (jsxRuntime.jsx(ErrorContainer.ErrorContainer, { variant: 'error', withIcon: false, children: errorMessage })), jsxRuntime.jsxs("div", { className: 'backup-content', children: [jsxRuntime.jsx("div", { className: 'backup-icon-container', children: jsxRuntime.jsx(Icon.Icon, { color: 'brand-primary', children: jsxRuntime.jsx(backupWaas.ReactComponent, { width: 64, height: 64 }) }) }), jsxRuntime.jsx("div", { className: 'backup-subtitle', children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_waas.backup.subtitle', children: t('dyn_waas.backup.subtitle') }) }), jsxRuntime.jsx("div", { className: 'google-drive-section', children: jsxRuntime.jsxs("div", { className: 'google-drive-container', children: [jsxRuntime.jsxs("div", { className: 'google-drive-header', children: [jsxRuntime.jsx(googleDrive.ReactComponent, { className: 'google-drive-icon' }), jsxRuntime.jsxs("div", { className: 'google-drive-text', children: [jsxRuntime.jsxs("div", { className: 'google-drive-title-row', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', weight: 'bold', copykey: 'dyn_waas.backup.google_drive', children: t('dyn_waas.backup.google_drive') }), isBackedUp && (jsxRuntime.jsx("div", { className: 'backed-up-pill', children: jsxRuntime.jsx(Typography.Typography, { color: 'inherit', weight: 'bold', copykey: 'dyn_waas.backup.backed_up', children: t('dyn_waas.backup.backed_up') }) }))] }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', copykey: 'dyn_waas.backup.google_drive_subtitle', children: t('dyn_waas.backup.google_drive_subtitle') })] }), isBackedUp && (jsxRuntime.jsx(check.ReactComponent, { className: 'google-drive-check-icon' }))] }), !isBackedUp && (jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'backup-wallet-button', onClick: handleBackupWalletClick, buttonClassName: 'backup-button', disabled: isProcessingForProvider(sdkApiCore.ProviderEnum.Google), typographyProps: {
|
|
186
|
+
color: 'primary',
|
|
187
|
+
weight: 'bold',
|
|
188
|
+
}, copykey: 'dyn_waas.backup.back_up', buttonPadding: 'small', children: t('dyn_waas.backup.back_up') }))] }) })] })] }) })] }));
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
exports.WaasBackupView = WaasBackupView;
|
|
@@ -0,0 +1,187 @@
|
|
|
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 { ProviderEnum } from '@dynamic-labs/sdk-api-core';
|
|
7
|
+
import { isDynamicWaasConnector } from '@dynamic-labs/wallet-connector-core';
|
|
8
|
+
import '@dynamic-labs-sdk/client/core';
|
|
9
|
+
import '../../../../client/client.js';
|
|
10
|
+
import '@dynamic-labs-sdk/client';
|
|
11
|
+
import '../../../../config/ApiEndpoint.js';
|
|
12
|
+
import '../../../../utils/constants/values.js';
|
|
13
|
+
import '@dynamic-labs/utils';
|
|
14
|
+
import '@dynamic-labs/multi-wallet';
|
|
15
|
+
import 'react-international-phone';
|
|
16
|
+
import '../../../../utils/constants/colors.js';
|
|
17
|
+
import '@dynamic-labs/iconic';
|
|
18
|
+
import { ReactComponent as SvgCheck } from '../../../../shared/assets/check.js';
|
|
19
|
+
import { ReactComponent as SvgClose } from '../../../../shared/assets/close.js';
|
|
20
|
+
import { ReactComponent as SvgQuestionMark } from '../../../../shared/assets/question-mark.js';
|
|
21
|
+
import '../../../../context/ViewContext/ViewContext.js';
|
|
22
|
+
import { ReactComponent as SvgBackupWaas } from '../../../../shared/assets/backup-waas.js';
|
|
23
|
+
import { ReactComponent as SvgGoogleDrive } from '../../../../shared/assets/google-drive.js';
|
|
24
|
+
import '../../../../shared/logger.js';
|
|
25
|
+
import '@dynamic-labs/wallet-book';
|
|
26
|
+
import '../../../../shared/consts/index.js';
|
|
27
|
+
import '../../../../store/state/nonce/nonce.js';
|
|
28
|
+
import '@dynamic-labs/locale';
|
|
29
|
+
import '../../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
30
|
+
import '../../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
31
|
+
import '../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
32
|
+
import '../../../../events/dynamicEvents.js';
|
|
33
|
+
import { useUser } from '../../../../client/extension/user/useUser/useUser.js';
|
|
34
|
+
import { ErrorContainer } from '../../../../components/ErrorContainer/ErrorContainer.js';
|
|
35
|
+
import { Icon } from '../../../../components/Icon/Icon.js';
|
|
36
|
+
import { IconButton } from '../../../../components/IconButton/IconButton.js';
|
|
37
|
+
import { ModalHeader } from '../../../../components/ModalHeader/ModalHeader.js';
|
|
38
|
+
import { Typography } from '../../../../components/Typography/Typography.js';
|
|
39
|
+
import { TypographyButton } from '../../../../components/TypographyButton/TypographyButton.js';
|
|
40
|
+
import '../../../../context/DynamicContext/DynamicContext.js';
|
|
41
|
+
import '../../../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
|
|
42
|
+
import '../../../../context/CaptchaContext/CaptchaContext.js';
|
|
43
|
+
import '../../../../context/ErrorContext/ErrorContext.js';
|
|
44
|
+
import '../../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
45
|
+
import '../../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
46
|
+
import '../../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
47
|
+
import '../../../../store/state/authMode/authMode.js';
|
|
48
|
+
import '../../../../context/VerificationContext/VerificationContext.js';
|
|
49
|
+
import 'react-dom';
|
|
50
|
+
import '../../../../utils/functions/compareChains/compareChains.js';
|
|
51
|
+
import '../../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
|
|
52
|
+
import '../../../../context/ThemeContext/ThemeContext.js';
|
|
53
|
+
import '../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
54
|
+
import { isZeroDevConnector } from '../../../../utils/hooks/useTransactionSimulation/utils/utils.js';
|
|
55
|
+
import 'bs58';
|
|
56
|
+
import { useSocialAccounts } from '../../../../utils/hooks/useSocialAccounts/useSocialAccounts.js';
|
|
57
|
+
import 'yup';
|
|
58
|
+
import '../../../../context/MockContext/MockContext.js';
|
|
59
|
+
import '../../../../views/CollectUserDataView/useFields.js';
|
|
60
|
+
import '../../../../context/FieldsStateContext/FieldsStateContext.js';
|
|
61
|
+
import '../../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
62
|
+
import '@dynamic-labs/rpc-providers';
|
|
63
|
+
import '../../../../store/state/walletOptions/walletOptions.js';
|
|
64
|
+
import '../../../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
65
|
+
import '../../../../components/Alert/Alert.js';
|
|
66
|
+
import '../../../../context/WalletContext/WalletContext.js';
|
|
67
|
+
import '../../../../components/ShadowDOM/ShadowDOM.js';
|
|
68
|
+
import '../../../../components/InlineWidget/InlineWidget.js';
|
|
69
|
+
import '../../../../components/Input/Input.js';
|
|
70
|
+
import '../../../../components/IsBrowser/IsBrowser.js';
|
|
71
|
+
import '../../../../components/MenuList/Dropdown/Dropdown.js';
|
|
72
|
+
import '../../../../components/OverlayCard/OverlayCard.js';
|
|
73
|
+
import '../../../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
74
|
+
import '../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
75
|
+
import '../../../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
76
|
+
import '../../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
77
|
+
import '../../../../components/Popper/Popper/Popper.js';
|
|
78
|
+
import '../../../../components/Popper/PopperContext/PopperContext.js';
|
|
79
|
+
import 'react-focus-lock';
|
|
80
|
+
import 'qrcode';
|
|
81
|
+
import 'formik';
|
|
82
|
+
import '../../../../utils/hooks/useSubdomainCheck/useSubdomainCheck.js';
|
|
83
|
+
import '../../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
84
|
+
import '../../../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
85
|
+
import '../../../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
86
|
+
import '../../../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
|
|
87
|
+
import '../../../DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
88
|
+
import '@hcaptcha/react-hcaptcha';
|
|
89
|
+
import '../../../../context/LoadingContext/LoadingContext.js';
|
|
90
|
+
import { useWidgetContext } from '../../context/DynamicWidgetContext.js';
|
|
91
|
+
import '../../helpers/convertExchangeKeyAndProviderEnum.js';
|
|
92
|
+
import '../../../../views/ExchangeWhitelistWarning/ExchangeWhitelistWarning.js';
|
|
93
|
+
import '../../../../context/ErrorContext/hooks/useErrorText/useErrorText.js';
|
|
94
|
+
import '../../../../context/FooterAnimationContext/index.js';
|
|
95
|
+
import '@dynamic-labs/types';
|
|
96
|
+
import '../../../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
|
|
97
|
+
import '../../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.js';
|
|
98
|
+
import '../../../../context/PasskeyContext/PasskeyContext.js';
|
|
99
|
+
import '../../../../context/OnrampContext/OnrampContext.js';
|
|
100
|
+
import { useRefreshUser } from '../../../../utils/hooks/useRefreshUser/useRefreshUser.js';
|
|
101
|
+
import '../../../../store/state/sendBalances.js';
|
|
102
|
+
import '../../../../store/state/connectorsInitializing/connectorsInitializing.js';
|
|
103
|
+
import '../../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.js';
|
|
104
|
+
import '../../components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
105
|
+
import '../../../../views/TransactionConfirmationView/TransactionConfirmationView.js';
|
|
106
|
+
import '../../components/PasskeyCard/PasskeyCard.js';
|
|
107
|
+
import '../CryptoComOnramp/CryptoComOnramp.js';
|
|
108
|
+
import '../../../../../index.js';
|
|
109
|
+
import '../ReceiveWalletFunds/ReceiveWalletFunds.js';
|
|
110
|
+
import '../../../../store/state/tokenBalances.js';
|
|
111
|
+
import '../../../../store/state/multichainBalances.js';
|
|
112
|
+
import '../../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
113
|
+
import { useInternalDynamicContext } from '../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
|
|
114
|
+
|
|
115
|
+
const WaasBackupView = () => {
|
|
116
|
+
const { setDynamicWidgetView } = useWidgetContext();
|
|
117
|
+
const user = useUser();
|
|
118
|
+
const { primaryWallet } = useInternalDynamicContext();
|
|
119
|
+
const refresh = useRefreshUser();
|
|
120
|
+
const { linkSocialAccount, isLinked, isProcessingForProvider } = useSocialAccounts();
|
|
121
|
+
const { t } = useTranslation();
|
|
122
|
+
const [errorMessage, setErrorMessage] = useState(null);
|
|
123
|
+
const isGoogleLinked = isLinked(ProviderEnum.Google);
|
|
124
|
+
const checkGoogleDriveBackup = useCallback(() => {
|
|
125
|
+
var _a, _b;
|
|
126
|
+
if (!user || !primaryWallet)
|
|
127
|
+
return false;
|
|
128
|
+
const walletCredential = (_a = user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find((cred) => cred.walletName === 'dynamicwaas' &&
|
|
129
|
+
cred.address === primaryWallet.address);
|
|
130
|
+
const keyShares = (_b = walletCredential === null || walletCredential === void 0 ? void 0 : walletCredential.walletProperties) === null || _b === void 0 ? void 0 : _b.keyShares;
|
|
131
|
+
if (!keyShares || !Array.isArray(keyShares))
|
|
132
|
+
return false;
|
|
133
|
+
return keyShares.some((keyShare) => keyShare &&
|
|
134
|
+
typeof keyShare === 'object' &&
|
|
135
|
+
'backupLocation' in keyShare &&
|
|
136
|
+
keyShare.backupLocation === 'googleDrive');
|
|
137
|
+
}, [user, primaryWallet]);
|
|
138
|
+
const isBackedUp = useMemo(() => checkGoogleDriveBackup(), [checkGoogleDriveBackup]);
|
|
139
|
+
const handleBackClick = useCallback(() => setDynamicWidgetView('account-and-security-settings'), [setDynamicWidgetView]);
|
|
140
|
+
const handleInfoClick = useCallback(() => {
|
|
141
|
+
setDynamicWidgetView('waas-backup-info');
|
|
142
|
+
}, [setDynamicWidgetView]);
|
|
143
|
+
const handleBackupWalletClick = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
144
|
+
setErrorMessage(null);
|
|
145
|
+
try {
|
|
146
|
+
if (!primaryWallet) {
|
|
147
|
+
throw new Error('No primary wallet found');
|
|
148
|
+
}
|
|
149
|
+
if (!isGoogleLinked) {
|
|
150
|
+
yield linkSocialAccount(ProviderEnum.Google, {
|
|
151
|
+
forcePopup: true,
|
|
152
|
+
showWidgetAfterConnection: false,
|
|
153
|
+
});
|
|
154
|
+
yield refresh();
|
|
155
|
+
}
|
|
156
|
+
let waasConnector;
|
|
157
|
+
if (isDynamicWaasConnector(primaryWallet.connector)) {
|
|
158
|
+
waasConnector = primaryWallet.connector;
|
|
159
|
+
}
|
|
160
|
+
else if (isZeroDevConnector(primaryWallet.connector)) {
|
|
161
|
+
const { eoaConnector } = primaryWallet.connector;
|
|
162
|
+
if (!eoaConnector || !isDynamicWaasConnector(eoaConnector)) {
|
|
163
|
+
throw new Error('ZeroDev connector must have a WaaS EOA connector');
|
|
164
|
+
}
|
|
165
|
+
waasConnector = eoaConnector;
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
throw new Error('Not a supported connector type');
|
|
169
|
+
}
|
|
170
|
+
yield waasConnector.backupKeySharesToGoogleDrive({
|
|
171
|
+
accountAddress: primaryWallet.address,
|
|
172
|
+
});
|
|
173
|
+
yield refresh();
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
setErrorMessage(t('dyn_waas.backup.error'));
|
|
177
|
+
}
|
|
178
|
+
}), [primaryWallet, refresh, isGoogleLinked, linkSocialAccount, t]);
|
|
179
|
+
const infoButton = (jsx(IconButton, { type: 'button', onClick: handleInfoClick, "data-testid": 'info-button', children: jsx(SvgQuestionMark, {}) }));
|
|
180
|
+
const closeButton = (jsx(IconButton, { type: 'button', onClick: handleBackClick, "data-testid": 'close-button', children: jsx(SvgClose, {}) }));
|
|
181
|
+
return (jsxs("div", { className: 'waas-backup-view', children: [jsx(ModalHeader, { leading: infoButton, trailing: closeButton, children: jsx("div", { className: 'send-balance-page-layout__header-content', children: jsx(Typography, { variant: 'title', color: 'primary', copykey: 'dyn_waas.backup.title', children: t('dyn_waas.backup.title') }) }) }), jsx("div", { className: 'account-wrap', children: jsxs("div", { className: 'settings-view__body', children: [errorMessage && (jsx(ErrorContainer, { variant: 'error', withIcon: false, children: errorMessage })), jsxs("div", { className: 'backup-content', children: [jsx("div", { className: 'backup-icon-container', children: jsx(Icon, { color: 'brand-primary', children: jsx(SvgBackupWaas, { width: 64, height: 64 }) }) }), jsx("div", { className: 'backup-subtitle', children: jsx(Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_waas.backup.subtitle', children: t('dyn_waas.backup.subtitle') }) }), jsx("div", { className: 'google-drive-section', children: jsxs("div", { className: 'google-drive-container', children: [jsxs("div", { className: 'google-drive-header', children: [jsx(SvgGoogleDrive, { className: 'google-drive-icon' }), jsxs("div", { className: 'google-drive-text', children: [jsxs("div", { className: 'google-drive-title-row', children: [jsx(Typography, { variant: 'body_normal', color: 'primary', weight: 'bold', copykey: 'dyn_waas.backup.google_drive', children: t('dyn_waas.backup.google_drive') }), isBackedUp && (jsx("div", { className: 'backed-up-pill', children: jsx(Typography, { color: 'inherit', weight: 'bold', copykey: 'dyn_waas.backup.backed_up', children: t('dyn_waas.backup.backed_up') }) }))] }), jsx(Typography, { variant: 'body_small', color: 'secondary', copykey: 'dyn_waas.backup.google_drive_subtitle', children: t('dyn_waas.backup.google_drive_subtitle') })] }), isBackedUp && (jsx(SvgCheck, { className: 'google-drive-check-icon' }))] }), !isBackedUp && (jsx(TypographyButton, { dataTestId: 'backup-wallet-button', onClick: handleBackupWalletClick, buttonClassName: 'backup-button', disabled: isProcessingForProvider(ProviderEnum.Google), typographyProps: {
|
|
182
|
+
color: 'primary',
|
|
183
|
+
weight: 'bold',
|
|
184
|
+
}, copykey: 'dyn_waas.backup.back_up', buttonPadding: 'small', children: t('dyn_waas.backup.back_up') }))] }) })] })] }) })] }));
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export { WaasBackupView };
|
|
@@ -7,4 +7,6 @@ export { SettingsView } from './SettingsView';
|
|
|
7
7
|
export { AccountAndSecuritySettingsView } from './AccountAndSecuritySettingsView';
|
|
8
8
|
export { SessionManagementView } from './SessionManagementView';
|
|
9
9
|
export { WalletsDelegatedSettingsView } from './WalletsDelegatedSettingsView';
|
|
10
|
+
export { WaasBackupView } from './WaasBackupView';
|
|
11
|
+
export { WaasBackupInfoView } from './WaasBackupView';
|
|
10
12
|
export { CryptoComOnramp } from './CryptoComOnramp';
|