@dynamic-labs/sdk-react-core 4.46.3 → 4.47.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 +7 -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/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/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 +3 -2
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.d.ts +1 -0
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +3 -2
- 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
|
@@ -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';
|