@dynamic-labs/sdk-react-core 2.1.0-alpha.2 → 2.1.0-alpha.4
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 +26 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +13 -14
- package/src/index.cjs +0 -2
- package/src/index.d.ts +1 -1
- package/src/index.js +0 -1
- package/src/lib/Main.cjs +5 -0
- package/src/lib/Main.js +5 -0
- package/src/lib/components/Alert/Alert.cjs +2 -2
- package/src/lib/components/Alert/Alert.js +2 -2
- package/src/lib/components/Alert/Alert.types.d.ts +1 -0
- package/src/lib/components/EmailForm/EmailForm.cjs +1 -1
- package/src/lib/components/EmailForm/EmailForm.js +1 -1
- package/src/lib/components/PhoneNumberField/PhoneNumberField.cjs +1 -1
- package/src/lib/components/PhoneNumberField/PhoneNumberField.js +1 -1
- package/src/lib/components/RadioButton/RadioButton.cjs +14 -0
- package/src/lib/components/RadioButton/RadioButton.d.ts +5 -0
- package/src/lib/components/RadioButton/RadioButton.js +10 -0
- package/src/lib/components/RadioButton/index.d.ts +1 -0
- package/src/lib/components/UserProfile/parts/UserProfileField/UserProfileField.cjs +1 -1
- package/src/lib/components/UserProfile/parts/UserProfileField/UserProfileField.d.ts +2 -1
- package/src/lib/components/UserProfile/parts/UserProfileField/UserProfileField.js +1 -1
- package/src/lib/components/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +1 -0
- package/src/lib/context/DynamicContext/DynamicContext.js +1 -0
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.cjs +2 -2
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.js +2 -2
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.cjs +5 -2
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.js +5 -2
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.cjs +2 -1
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.d.ts +1 -1
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.js +2 -1
- package/src/lib/context/ViewContext/ViewContext.cjs +2 -2
- package/src/lib/context/ViewContext/ViewContext.js +2 -2
- package/src/lib/context/ViewContext/types/index.d.ts +7 -2
- package/src/lib/data/api/user/user.cjs +16 -0
- package/src/lib/data/api/user/user.js +16 -1
- package/src/lib/events/dynamicEvents.d.ts +1 -1
- package/src/lib/layout/DynamicAuthLayout/Header/header.cjs +6 -0
- package/src/lib/layout/DynamicAuthLayout/Header/header.js +6 -0
- package/src/lib/locale/en/translation.cjs +44 -3
- package/src/lib/locale/en/translation.d.ts +43 -2
- package/src/lib/locale/en/translation.js +44 -3
- package/src/lib/shared/types/dynamicEventsCallbacks.d.ts +2 -1
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/constants/errors.cjs +0 -2
- package/src/lib/utils/constants/errors.js +1 -2
- package/src/lib/utils/functions/findTurnkeyWallet/findTurnkeyWallet.cjs +11 -9
- package/src/lib/utils/functions/findTurnkeyWallet/findTurnkeyWallet.d.ts +6 -2
- package/src/lib/utils/functions/findTurnkeyWallet/findTurnkeyWallet.js +12 -10
- package/src/lib/utils/functions/findTurnkeyWallet/index.d.ts +1 -1
- package/src/lib/utils/functions/index.d.ts +1 -0
- package/src/lib/utils/functions/serializeWalletConnectors/index.d.ts +1 -0
- package/src/lib/utils/functions/serializeWalletConnectors/serializeWalletConnectors.cjs +32 -0
- package/src/lib/utils/functions/serializeWalletConnectors/serializeWalletConnectors.d.ts +2 -0
- package/src/lib/utils/functions/serializeWalletConnectors/serializeWalletConnectors.js +28 -0
- package/src/lib/utils/hooks/index.d.ts +1 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +4 -1
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +4 -1
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.cjs +1 -1
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.js +1 -1
- package/src/lib/utils/hooks/useDynamicLayoutData/useDynamicLayoutData.cjs +8 -0
- package/src/lib/utils/hooks/useDynamicLayoutData/useDynamicLayoutData.js +8 -0
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +7 -8
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.d.ts +10 -1
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +7 -8
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.cjs +1 -1
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.js +1 -1
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useMPCEmbeddedWallet.cjs +1 -1
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useMPCEmbeddedWallet.js +1 -1
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.cjs +137 -25
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.d.ts +17 -7
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.js +140 -28
- package/src/lib/utils/hooks/useMergeUserAccounts/index.d.ts +1 -0
- package/src/lib/utils/hooks/useMergeUserAccounts/useMergeUserAccounts.cjs +99 -0
- package/src/lib/utils/hooks/useMergeUserAccounts/useMergeUserAccounts.d.ts +4 -0
- package/src/lib/utils/hooks/useMergeUserAccounts/useMergeUserAccounts.js +95 -0
- package/src/lib/utils/hooks/useSendDynamicProps/useSendDynamicProps.cjs +6 -13
- package/src/lib/utils/hooks/useSendDynamicProps/useSendDynamicProps.d.ts +1 -3
- package/src/lib/utils/hooks/useSendDynamicProps/useSendDynamicProps.js +6 -12
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +5 -0
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +6 -1
- package/src/lib/utils/hooks/useWalletConnectorOptions/useWalletConnectorOptions.cjs +25 -2
- package/src/lib/utils/hooks/useWalletConnectorOptions/useWalletConnectorOptions.js +25 -2
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.cjs +2 -4
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.d.ts +2 -1
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.js +2 -4
- package/src/lib/views/CollectUserDataView/UserDataFields/UserField/UserField.cjs +3 -3
- package/src/lib/views/CollectUserDataView/UserDataFields/UserField/UserField.js +3 -3
- package/src/lib/views/CollectUserDataView/useFields.cjs +1 -0
- package/src/lib/views/CollectUserDataView/useFields.d.ts +2 -0
- package/src/lib/views/CollectUserDataView/useFields.js +1 -0
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.cjs +2 -2
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.js +2 -2
- package/src/lib/views/MergeUserAccountsConflictsView/MergeUserAccountsConflictsView.cjs +126 -0
- package/src/lib/views/MergeUserAccountsConflictsView/MergeUserAccountsConflictsView.d.ts +6 -0
- package/src/lib/views/MergeUserAccountsConflictsView/MergeUserAccountsConflictsView.js +122 -0
- package/src/lib/views/MergeUserAccountsConflictsView/index.d.ts +1 -0
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +123 -0
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.d.ts +4 -0
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +119 -0
- package/src/lib/views/MergeUserAccountsView/index.d.ts +1 -0
- package/src/lib/views/Passkey/utils/createEmbeddedWalletWithPasskey/createEmbeddedWalletWithPasskey.cjs +1 -1
- package/src/lib/views/Passkey/utils/createEmbeddedWalletWithPasskey/createEmbeddedWalletWithPasskey.js +1 -1
- package/src/lib/views/Passkey/utils/createPregeneratedWallet/createPregeneratedWallet.cjs +1 -1
- package/src/lib/views/Passkey/utils/createPregeneratedWallet/createPregeneratedWallet.js +1 -1
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.cjs +7 -7
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.js +7 -7
- package/src/lib/views/viewToComponentMap.cjs +4 -0
- package/src/lib/views/viewToComponentMap.d.ts +2 -0
- package/src/lib/views/viewToComponentMap.js +4 -0
|
@@ -0,0 +1,126 @@
|
|
|
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
|
+
require('../../events/dynamicEvents.cjs');
|
|
12
|
+
require('@dynamic-labs/utils');
|
|
13
|
+
require('../../context/DynamicContext/DynamicContext.cjs');
|
|
14
|
+
var logger = require('../../shared/logger.cjs');
|
|
15
|
+
require('@dynamic-labs/iconic');
|
|
16
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
17
|
+
require('../../context/ViewContext/ViewContext.cjs');
|
|
18
|
+
require('@dynamic-labs/wallet-book');
|
|
19
|
+
require('../../utils/constants/colors.cjs');
|
|
20
|
+
require('../../utils/constants/values.cjs');
|
|
21
|
+
require('../../shared/utils/classes/storage/localStorage.cjs');
|
|
22
|
+
var capitalize = require('../../shared/utils/functions/capitalize/capitalize.cjs');
|
|
23
|
+
require('../../shared/consts/index.cjs');
|
|
24
|
+
require('../../context/CaptchaContext/CaptchaContext.cjs');
|
|
25
|
+
require('../../context/ErrorContext/ErrorContext.cjs');
|
|
26
|
+
require('@dynamic-labs/multi-wallet');
|
|
27
|
+
require('react-international-phone');
|
|
28
|
+
require('viem');
|
|
29
|
+
require('viem/chains');
|
|
30
|
+
require('../../config/ApiEndpoint.cjs');
|
|
31
|
+
require('../../locale/locale.cjs');
|
|
32
|
+
require('../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
33
|
+
require('../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
34
|
+
require('../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
35
|
+
require('../../context/VerificationContext/VerificationContext.cjs');
|
|
36
|
+
require('react-dom');
|
|
37
|
+
require('../../context/WalletContext/WalletContext.cjs');
|
|
38
|
+
require('../../context/ThemeContext/ThemeContext.cjs');
|
|
39
|
+
require('@dynamic-labs/types');
|
|
40
|
+
require('yup');
|
|
41
|
+
require('../../context/MockContext/MockContext.cjs');
|
|
42
|
+
require('../../context/FieldsStateContext/FieldsStateContext.cjs');
|
|
43
|
+
require('../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs');
|
|
44
|
+
require('../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
45
|
+
require('@dynamic-labs/rpc-providers');
|
|
46
|
+
var Typography = require('../../components/Typography/Typography.cjs');
|
|
47
|
+
require('../../context/FooterAnimationContext/index.cjs');
|
|
48
|
+
require('../../components/ShadowDOM/ShadowDOM.cjs');
|
|
49
|
+
require('../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
50
|
+
require('../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
51
|
+
require('../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
52
|
+
require('../../components/OverlayCard/OverlayCardTarget/OverlayCardTarget.cjs');
|
|
53
|
+
require('../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
54
|
+
require('../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
55
|
+
require('../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
56
|
+
require('react-focus-lock');
|
|
57
|
+
require('../../context/LoadingContext/LoadingContext.cjs');
|
|
58
|
+
require('../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
|
|
59
|
+
require('../../components/IconButton/IconButton.cjs');
|
|
60
|
+
require('../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
61
|
+
require('formik');
|
|
62
|
+
var TypographyButton = require('../../components/TypographyButton/TypographyButton.cjs');
|
|
63
|
+
require('../TransactionConfirmationView/helpers/transactionErrorMessage.cjs');
|
|
64
|
+
var Alert = require('../../components/Alert/Alert.cjs');
|
|
65
|
+
require('../../components/Input/Input.cjs');
|
|
66
|
+
require('../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
|
|
67
|
+
require('../../context/PasskeyContext/PasskeyContext.cjs');
|
|
68
|
+
require('../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
69
|
+
var useMergeUserAccounts = require('../../utils/hooks/useMergeUserAccounts/useMergeUserAccounts.cjs');
|
|
70
|
+
require('../../components/InlineWidget/InlineWidget.cjs');
|
|
71
|
+
require('../../components/IsBrowser/IsBrowser.cjs');
|
|
72
|
+
require('../../components/Popper/Popper/Popper.cjs');
|
|
73
|
+
require('../../components/Popper/PopperContext/PopperContext.cjs');
|
|
74
|
+
require('qrcode');
|
|
75
|
+
var RadioButton = require('../../components/RadioButton/RadioButton.cjs');
|
|
76
|
+
require('../WalletList/WalletList.cjs');
|
|
77
|
+
require('../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
78
|
+
require('@hcaptcha/react-hcaptcha');
|
|
79
|
+
require('../LoginView/sections/PhoneNumberSignInSection/PhoneNumberSignInSection.cjs');
|
|
80
|
+
|
|
81
|
+
const MergeUserAccountsConflictsView = ({ mergeConflicts }) => {
|
|
82
|
+
const { mergeUserAccounts } = useMergeUserAccounts.useMergeUserAccounts();
|
|
83
|
+
const { t } = reactI18next.useTranslation();
|
|
84
|
+
const [error, setError] = React.useState('');
|
|
85
|
+
const mergeResolutions = React.useRef(
|
|
86
|
+
// defaults to current user field values
|
|
87
|
+
Object.fromEntries(mergeConflicts.map(({ field, currentUser }) => [
|
|
88
|
+
`${field.name}_${field.type}`,
|
|
89
|
+
{
|
|
90
|
+
fieldKey: field.name,
|
|
91
|
+
type: field.type || sdkApiCore.KycFieldType.Standard,
|
|
92
|
+
userId: currentUser.userId,
|
|
93
|
+
},
|
|
94
|
+
])));
|
|
95
|
+
const handleMergeConfirm = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
96
|
+
const parsedMergeResolutions = Object.values(mergeResolutions.current).map(({ fieldKey, type, userId }) => ({
|
|
97
|
+
fieldKey,
|
|
98
|
+
type,
|
|
99
|
+
userId,
|
|
100
|
+
}));
|
|
101
|
+
try {
|
|
102
|
+
yield mergeUserAccounts(parsedMergeResolutions);
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
logger.logger.error('Error merging user accounts', error);
|
|
106
|
+
setError(t('dyn_merge_user_accounts_conflicts.errors.merge_error'));
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
if (!(mergeConflicts === null || mergeConflicts === void 0 ? void 0 : mergeConflicts.length)) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
const handleOptionChange = (fieldKey, fieldType, userId, isSelected) => {
|
|
113
|
+
setError('');
|
|
114
|
+
if (!isSelected) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
mergeResolutions.current[`${fieldKey}_${fieldType}`] = {
|
|
118
|
+
fieldKey,
|
|
119
|
+
type: fieldType || sdkApiCore.KycFieldType.Standard,
|
|
120
|
+
userId,
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
return (jsxRuntime.jsxs("div", { className: 'merge-user-accounts-conflicts__container', children: [error && (jsxRuntime.jsx(Alert.Alert, { icon: 'error', variant: 'error', className: 'merge-user-accounts-conflicts__error', children: error })), jsxRuntime.jsx("div", { className: 'merge-user-accounts-conflicts__fields', children: mergeConflicts.map(({ field, currentUser, fromUser }) => (jsxRuntime.jsxs("div", { className: 'merge-user-accounts-conflicts__fields__item', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'merge-user-accounts-conflicts__fields__item__name', children: capitalize.capitalize(field.name) }), jsxRuntime.jsx(RadioButton.RadioButton, { name: field.name, value: currentUser.value, checked: true, className: 'merge-user-accounts-conflicts__fields__item__button', onChange: (e) => handleOptionChange(field.name, field.type, currentUser.userId, e.target.checked), children: currentUser.value }), jsxRuntime.jsx(RadioButton.RadioButton, { name: field.name, value: fromUser.value, className: 'merge-user-accounts-conflicts__fields__item__button', onChange: (e) => handleOptionChange(field.name, field.type, fromUser.userId, e.target.checked), children: fromUser.value })] }, field.name))) }), jsxRuntime.jsx("div", { className: 'merge-user-accounts-conflicts__buttons', children: jsxRuntime.jsx(TypographyButton.TypographyButton, { className: 'merge-user-accounts-conflicts__buttons__button', onClick: handleMergeConfirm, buttonVariant: 'primary', buttonPadding: 'large', expanded: true, copykey: 'dyn_merge_user_accounts_conflicts.confirm_button', children: t('dyn_merge_user_accounts_conflicts.confirm_button') }) })] }));
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
exports.MergeUserAccountsConflictsView = MergeUserAccountsConflictsView;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { MergeUserConflict } from '@dynamic-labs/sdk-api-core';
|
|
3
|
+
export type MergeUserAccountsConflictsViewProps = {
|
|
4
|
+
mergeConflicts: MergeUserConflict[];
|
|
5
|
+
};
|
|
6
|
+
export declare const MergeUserAccountsConflictsView: FC<MergeUserAccountsConflictsViewProps>;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
+
import { useState, useRef } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import { KycFieldType } from '@dynamic-labs/sdk-api-core';
|
|
7
|
+
import '../../events/dynamicEvents.js';
|
|
8
|
+
import '@dynamic-labs/utils';
|
|
9
|
+
import '../../context/DynamicContext/DynamicContext.js';
|
|
10
|
+
import { logger } from '../../shared/logger.js';
|
|
11
|
+
import '@dynamic-labs/iconic';
|
|
12
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
13
|
+
import '../../context/ViewContext/ViewContext.js';
|
|
14
|
+
import '@dynamic-labs/wallet-book';
|
|
15
|
+
import '../../utils/constants/colors.js';
|
|
16
|
+
import '../../utils/constants/values.js';
|
|
17
|
+
import '../../shared/utils/classes/storage/localStorage.js';
|
|
18
|
+
import { capitalize } from '../../shared/utils/functions/capitalize/capitalize.js';
|
|
19
|
+
import '../../shared/consts/index.js';
|
|
20
|
+
import '../../context/CaptchaContext/CaptchaContext.js';
|
|
21
|
+
import '../../context/ErrorContext/ErrorContext.js';
|
|
22
|
+
import '@dynamic-labs/multi-wallet';
|
|
23
|
+
import 'react-international-phone';
|
|
24
|
+
import 'viem';
|
|
25
|
+
import 'viem/chains';
|
|
26
|
+
import '../../config/ApiEndpoint.js';
|
|
27
|
+
import '../../locale/locale.js';
|
|
28
|
+
import '../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
29
|
+
import '../../context/AccountExistsContext/AccountExistsContext.js';
|
|
30
|
+
import '../../context/UserWalletsContext/UserWalletsContext.js';
|
|
31
|
+
import '../../context/VerificationContext/VerificationContext.js';
|
|
32
|
+
import 'react-dom';
|
|
33
|
+
import '../../context/WalletContext/WalletContext.js';
|
|
34
|
+
import '../../context/ThemeContext/ThemeContext.js';
|
|
35
|
+
import '@dynamic-labs/types';
|
|
36
|
+
import 'yup';
|
|
37
|
+
import '../../context/MockContext/MockContext.js';
|
|
38
|
+
import '../../context/FieldsStateContext/FieldsStateContext.js';
|
|
39
|
+
import '../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js';
|
|
40
|
+
import '../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
41
|
+
import '@dynamic-labs/rpc-providers';
|
|
42
|
+
import { Typography } from '../../components/Typography/Typography.js';
|
|
43
|
+
import '../../context/FooterAnimationContext/index.js';
|
|
44
|
+
import '../../components/ShadowDOM/ShadowDOM.js';
|
|
45
|
+
import '../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
46
|
+
import '../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
47
|
+
import '../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
48
|
+
import '../../components/OverlayCard/OverlayCardTarget/OverlayCardTarget.js';
|
|
49
|
+
import '../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
50
|
+
import '../../context/WalletGroupContext/WalletGroupContext.js';
|
|
51
|
+
import '../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
52
|
+
import 'react-focus-lock';
|
|
53
|
+
import '../../context/LoadingContext/LoadingContext.js';
|
|
54
|
+
import '../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
55
|
+
import '../../components/IconButton/IconButton.js';
|
|
56
|
+
import '../../components/MenuList/Dropdown/Dropdown.js';
|
|
57
|
+
import 'formik';
|
|
58
|
+
import { TypographyButton } from '../../components/TypographyButton/TypographyButton.js';
|
|
59
|
+
import '../TransactionConfirmationView/helpers/transactionErrorMessage.js';
|
|
60
|
+
import { Alert } from '../../components/Alert/Alert.js';
|
|
61
|
+
import '../../components/Input/Input.js';
|
|
62
|
+
import '../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
63
|
+
import '../../context/PasskeyContext/PasskeyContext.js';
|
|
64
|
+
import '../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
65
|
+
import { useMergeUserAccounts } from '../../utils/hooks/useMergeUserAccounts/useMergeUserAccounts.js';
|
|
66
|
+
import '../../components/InlineWidget/InlineWidget.js';
|
|
67
|
+
import '../../components/IsBrowser/IsBrowser.js';
|
|
68
|
+
import '../../components/Popper/Popper/Popper.js';
|
|
69
|
+
import '../../components/Popper/PopperContext/PopperContext.js';
|
|
70
|
+
import 'qrcode';
|
|
71
|
+
import { RadioButton } from '../../components/RadioButton/RadioButton.js';
|
|
72
|
+
import '../WalletList/WalletList.js';
|
|
73
|
+
import '../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
74
|
+
import '@hcaptcha/react-hcaptcha';
|
|
75
|
+
import '../LoginView/sections/PhoneNumberSignInSection/PhoneNumberSignInSection.js';
|
|
76
|
+
|
|
77
|
+
const MergeUserAccountsConflictsView = ({ mergeConflicts }) => {
|
|
78
|
+
const { mergeUserAccounts } = useMergeUserAccounts();
|
|
79
|
+
const { t } = useTranslation();
|
|
80
|
+
const [error, setError] = useState('');
|
|
81
|
+
const mergeResolutions = useRef(
|
|
82
|
+
// defaults to current user field values
|
|
83
|
+
Object.fromEntries(mergeConflicts.map(({ field, currentUser }) => [
|
|
84
|
+
`${field.name}_${field.type}`,
|
|
85
|
+
{
|
|
86
|
+
fieldKey: field.name,
|
|
87
|
+
type: field.type || KycFieldType.Standard,
|
|
88
|
+
userId: currentUser.userId,
|
|
89
|
+
},
|
|
90
|
+
])));
|
|
91
|
+
const handleMergeConfirm = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
92
|
+
const parsedMergeResolutions = Object.values(mergeResolutions.current).map(({ fieldKey, type, userId }) => ({
|
|
93
|
+
fieldKey,
|
|
94
|
+
type,
|
|
95
|
+
userId,
|
|
96
|
+
}));
|
|
97
|
+
try {
|
|
98
|
+
yield mergeUserAccounts(parsedMergeResolutions);
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
logger.error('Error merging user accounts', error);
|
|
102
|
+
setError(t('dyn_merge_user_accounts_conflicts.errors.merge_error'));
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
if (!(mergeConflicts === null || mergeConflicts === void 0 ? void 0 : mergeConflicts.length)) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
const handleOptionChange = (fieldKey, fieldType, userId, isSelected) => {
|
|
109
|
+
setError('');
|
|
110
|
+
if (!isSelected) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
mergeResolutions.current[`${fieldKey}_${fieldType}`] = {
|
|
114
|
+
fieldKey,
|
|
115
|
+
type: fieldType || KycFieldType.Standard,
|
|
116
|
+
userId,
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
return (jsxs("div", { className: 'merge-user-accounts-conflicts__container', children: [error && (jsx(Alert, { icon: 'error', variant: 'error', className: 'merge-user-accounts-conflicts__error', children: error })), jsx("div", { className: 'merge-user-accounts-conflicts__fields', children: mergeConflicts.map(({ field, currentUser, fromUser }) => (jsxs("div", { className: 'merge-user-accounts-conflicts__fields__item', children: [jsx(Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'merge-user-accounts-conflicts__fields__item__name', children: capitalize(field.name) }), jsx(RadioButton, { name: field.name, value: currentUser.value, checked: true, className: 'merge-user-accounts-conflicts__fields__item__button', onChange: (e) => handleOptionChange(field.name, field.type, currentUser.userId, e.target.checked), children: currentUser.value }), jsx(RadioButton, { name: field.name, value: fromUser.value, className: 'merge-user-accounts-conflicts__fields__item__button', onChange: (e) => handleOptionChange(field.name, field.type, fromUser.userId, e.target.checked), children: fromUser.value })] }, field.name))) }), jsx("div", { className: 'merge-user-accounts-conflicts__buttons', children: jsx(TypographyButton, { className: 'merge-user-accounts-conflicts__buttons__button', onClick: handleMergeConfirm, buttonVariant: 'primary', buttonPadding: 'large', expanded: true, copykey: 'dyn_merge_user_accounts_conflicts.confirm_button', children: t('dyn_merge_user_accounts_conflicts.confirm_button') }) })] }));
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export { MergeUserAccountsConflictsView };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MergeUserAccountsConflictsView } from './MergeUserAccountsConflictsView';
|
|
@@ -0,0 +1,123 @@
|
|
|
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 walletBook = require('@dynamic-labs/wallet-book');
|
|
11
|
+
var iconic = require('@dynamic-labs/iconic');
|
|
12
|
+
require('../../events/dynamicEvents.cjs');
|
|
13
|
+
require('@dynamic-labs/utils');
|
|
14
|
+
require('../../context/DynamicContext/DynamicContext.cjs');
|
|
15
|
+
require('@dynamic-labs/sdk-api-core');
|
|
16
|
+
var logger = require('../../shared/logger.cjs');
|
|
17
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
18
|
+
var ViewContext = require('../../context/ViewContext/ViewContext.cjs');
|
|
19
|
+
var user = require('../../shared/assets/user.cjs');
|
|
20
|
+
var shortenWalletAddress = require('../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.cjs');
|
|
21
|
+
require('../../utils/constants/colors.cjs');
|
|
22
|
+
require('../../utils/constants/values.cjs');
|
|
23
|
+
require('../../shared/utils/classes/storage/localStorage.cjs');
|
|
24
|
+
require('../../shared/consts/index.cjs');
|
|
25
|
+
var useInternalDynamicContext = require('../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
26
|
+
require('../../context/CaptchaContext/CaptchaContext.cjs');
|
|
27
|
+
require('../../context/ErrorContext/ErrorContext.cjs');
|
|
28
|
+
require('@dynamic-labs/multi-wallet');
|
|
29
|
+
require('react-international-phone');
|
|
30
|
+
require('viem');
|
|
31
|
+
require('viem/chains');
|
|
32
|
+
require('../../config/ApiEndpoint.cjs');
|
|
33
|
+
require('../../locale/locale.cjs');
|
|
34
|
+
require('../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
35
|
+
require('../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
36
|
+
require('../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
37
|
+
require('../../context/VerificationContext/VerificationContext.cjs');
|
|
38
|
+
require('react-dom');
|
|
39
|
+
require('../../context/WalletContext/WalletContext.cjs');
|
|
40
|
+
require('../../context/ThemeContext/ThemeContext.cjs');
|
|
41
|
+
require('@dynamic-labs/types');
|
|
42
|
+
require('yup');
|
|
43
|
+
require('../../context/MockContext/MockContext.cjs');
|
|
44
|
+
require('../../context/FieldsStateContext/FieldsStateContext.cjs');
|
|
45
|
+
require('../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs');
|
|
46
|
+
require('../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
47
|
+
require('@dynamic-labs/rpc-providers');
|
|
48
|
+
var Alert = require('../../components/Alert/Alert.cjs');
|
|
49
|
+
var Typography = require('../../components/Typography/Typography.cjs');
|
|
50
|
+
var TypographyButton = require('../../components/TypographyButton/TypographyButton.cjs');
|
|
51
|
+
require('../../components/ShadowDOM/ShadowDOM.cjs');
|
|
52
|
+
require('../../components/IconButton/IconButton.cjs');
|
|
53
|
+
require('../../components/InlineWidget/InlineWidget.cjs');
|
|
54
|
+
require('../../components/Input/Input.cjs');
|
|
55
|
+
require('../../components/IsBrowser/IsBrowser.cjs');
|
|
56
|
+
require('../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
57
|
+
require('../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
58
|
+
require('../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
59
|
+
require('../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
60
|
+
require('../../components/OverlayCard/OverlayCardTarget/OverlayCardTarget.cjs');
|
|
61
|
+
require('../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
|
|
62
|
+
require('../../components/Popper/Popper/Popper.cjs');
|
|
63
|
+
require('../../components/Popper/PopperContext/PopperContext.cjs');
|
|
64
|
+
require('react-focus-lock');
|
|
65
|
+
require('qrcode');
|
|
66
|
+
require('formik');
|
|
67
|
+
require('../WalletList/WalletList.cjs');
|
|
68
|
+
require('../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
69
|
+
require('../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
70
|
+
require('@hcaptcha/react-hcaptcha');
|
|
71
|
+
require('../../context/LoadingContext/LoadingContext.cjs');
|
|
72
|
+
require('../../context/FooterAnimationContext/index.cjs');
|
|
73
|
+
require('../LoginView/sections/PhoneNumberSignInSection/PhoneNumberSignInSection.cjs');
|
|
74
|
+
require('../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
75
|
+
require('../../context/PasskeyContext/PasskeyContext.cjs');
|
|
76
|
+
require('../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
77
|
+
require('../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
|
|
78
|
+
require('../TransactionConfirmationView/helpers/transactionErrorMessage.cjs');
|
|
79
|
+
require('../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
80
|
+
var useMergeUserAccounts = require('../../utils/hooks/useMergeUserAccounts/useMergeUserAccounts.cjs');
|
|
81
|
+
|
|
82
|
+
const MergeUserAccountsView = (props) => {
|
|
83
|
+
const { selectedWalletConnector } = useInternalDynamicContext.useInternalDynamicContext();
|
|
84
|
+
const { setView } = ViewContext.useViewContext();
|
|
85
|
+
const { mergeUserAccounts } = useMergeUserAccounts.useMergeUserAccounts();
|
|
86
|
+
const { t } = reactI18next.useTranslation();
|
|
87
|
+
const [error, setError] = React.useState('');
|
|
88
|
+
const { mergeConflicts, walletAddress } = props;
|
|
89
|
+
const goToConflictsResolutionView = () => {
|
|
90
|
+
// back button on conflicts resolution view should go back to this view
|
|
91
|
+
const onConflictsResolutionBackClick = () => {
|
|
92
|
+
setView('merge-user-accounts', props);
|
|
93
|
+
};
|
|
94
|
+
setView('merge-user-accounts-conflicts', { mergeConflicts: (mergeConflicts === null || mergeConflicts === void 0 ? void 0 : mergeConflicts.conflicts) || [] }, {
|
|
95
|
+
onBackClick: onConflictsResolutionBackClick,
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
const handleMergeConfirm = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
99
|
+
// if there are conflicts, show the conflicts resolution view, otherwise merge
|
|
100
|
+
if (mergeConflicts === null || mergeConflicts === void 0 ? void 0 : mergeConflicts.conflicts.length) {
|
|
101
|
+
goToConflictsResolutionView();
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
yield mergeUserAccounts([]);
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
logger.logger.error('Error merging user accounts', error);
|
|
109
|
+
setError(t('dyn_merge_user_accounts.errors.merge_error'));
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
const renderDuplicatedInfo = () => {
|
|
113
|
+
if (walletAddress) {
|
|
114
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(walletBook.WalletIcon, { walletKey: selectedWalletConnector === null || selectedWalletConnector === void 0 ? void 0 : selectedWalletConnector.key, className: 'merge-user-accounts__accounts__item__icon' }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', weight: 'medium', color: 'secondary', className: 'merge-user-accounts__accounts__item__text', children: shortenWalletAddress.shortenWalletAddress(walletAddress, 3, 3) })] }));
|
|
115
|
+
}
|
|
116
|
+
return (jsxRuntime.jsx(iconic.UserProfileIcon, { className: 'merge-user-accounts__accounts__item__icon' }));
|
|
117
|
+
};
|
|
118
|
+
return (jsxRuntime.jsxs("div", { className: 'merge-user-accounts', children: [error && (jsxRuntime.jsx(Alert.Alert, { icon: 'error', variant: 'error', className: 'merge-user-accounts__error', children: error })), jsxRuntime.jsxs("div", { className: 'merge-user-accounts__container', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'merge-user-accounts__title', copykey: 'dyn_merge_user_accounts.same_wallet.content', children: t('dyn_merge_user_accounts.same_wallet.content') }), jsxRuntime.jsx("div", { className: 'merge-user-accounts__accounts', children: jsxRuntime.jsx("div", { className: 'merge-user-accounts__accounts__item', children: renderDuplicatedInfo() }) }), jsxRuntime.jsx(TypographyButton.TypographyButton, { onClick: handleMergeConfirm, buttonClassName: 'merge-user-accounts__button', buttonVariant: 'brand-primary', buttonPadding: 'large', typographyProps: {
|
|
119
|
+
color: 'inherit',
|
|
120
|
+
}, startSlot: jsxRuntime.jsx(user.ReactComponent, {}), expanded: true, copykey: 'dyn_merge_user_accounts.confirm_button', children: t('dyn_merge_user_accounts.confirm_button') })] })] }));
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
exports.MergeUserAccountsView = MergeUserAccountsView;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { MergeAccountsConfirmationErrorProps } from '@dynamic-labs/utils';
|
|
3
|
+
export type MergeUserAccountsViewProps = Pick<MergeAccountsConfirmationErrorProps, 'mergeConflicts' | 'walletAddress'>;
|
|
4
|
+
export declare const MergeUserAccountsView: FC<MergeUserAccountsViewProps>;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
3
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import { WalletIcon } from '@dynamic-labs/wallet-book';
|
|
7
|
+
import { UserProfileIcon } from '@dynamic-labs/iconic';
|
|
8
|
+
import '../../events/dynamicEvents.js';
|
|
9
|
+
import '@dynamic-labs/utils';
|
|
10
|
+
import '../../context/DynamicContext/DynamicContext.js';
|
|
11
|
+
import '@dynamic-labs/sdk-api-core';
|
|
12
|
+
import { logger } from '../../shared/logger.js';
|
|
13
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
14
|
+
import { useViewContext } from '../../context/ViewContext/ViewContext.js';
|
|
15
|
+
import { ReactComponent as SvgUser } from '../../shared/assets/user.js';
|
|
16
|
+
import { shortenWalletAddress } from '../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.js';
|
|
17
|
+
import '../../utils/constants/colors.js';
|
|
18
|
+
import '../../utils/constants/values.js';
|
|
19
|
+
import '../../shared/utils/classes/storage/localStorage.js';
|
|
20
|
+
import '../../shared/consts/index.js';
|
|
21
|
+
import { useInternalDynamicContext } from '../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
22
|
+
import '../../context/CaptchaContext/CaptchaContext.js';
|
|
23
|
+
import '../../context/ErrorContext/ErrorContext.js';
|
|
24
|
+
import '@dynamic-labs/multi-wallet';
|
|
25
|
+
import 'react-international-phone';
|
|
26
|
+
import 'viem';
|
|
27
|
+
import 'viem/chains';
|
|
28
|
+
import '../../config/ApiEndpoint.js';
|
|
29
|
+
import '../../locale/locale.js';
|
|
30
|
+
import '../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
31
|
+
import '../../context/AccountExistsContext/AccountExistsContext.js';
|
|
32
|
+
import '../../context/UserWalletsContext/UserWalletsContext.js';
|
|
33
|
+
import '../../context/VerificationContext/VerificationContext.js';
|
|
34
|
+
import 'react-dom';
|
|
35
|
+
import '../../context/WalletContext/WalletContext.js';
|
|
36
|
+
import '../../context/ThemeContext/ThemeContext.js';
|
|
37
|
+
import '@dynamic-labs/types';
|
|
38
|
+
import 'yup';
|
|
39
|
+
import '../../context/MockContext/MockContext.js';
|
|
40
|
+
import '../../context/FieldsStateContext/FieldsStateContext.js';
|
|
41
|
+
import '../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js';
|
|
42
|
+
import '../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
43
|
+
import '@dynamic-labs/rpc-providers';
|
|
44
|
+
import { Alert } from '../../components/Alert/Alert.js';
|
|
45
|
+
import { Typography } from '../../components/Typography/Typography.js';
|
|
46
|
+
import { TypographyButton } from '../../components/TypographyButton/TypographyButton.js';
|
|
47
|
+
import '../../components/ShadowDOM/ShadowDOM.js';
|
|
48
|
+
import '../../components/IconButton/IconButton.js';
|
|
49
|
+
import '../../components/InlineWidget/InlineWidget.js';
|
|
50
|
+
import '../../components/Input/Input.js';
|
|
51
|
+
import '../../components/IsBrowser/IsBrowser.js';
|
|
52
|
+
import '../../components/MenuList/Dropdown/Dropdown.js';
|
|
53
|
+
import '../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
54
|
+
import '../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
55
|
+
import '../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
56
|
+
import '../../components/OverlayCard/OverlayCardTarget/OverlayCardTarget.js';
|
|
57
|
+
import '../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
58
|
+
import '../../components/Popper/Popper/Popper.js';
|
|
59
|
+
import '../../components/Popper/PopperContext/PopperContext.js';
|
|
60
|
+
import 'react-focus-lock';
|
|
61
|
+
import 'qrcode';
|
|
62
|
+
import 'formik';
|
|
63
|
+
import '../WalletList/WalletList.js';
|
|
64
|
+
import '../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
65
|
+
import '../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
66
|
+
import '@hcaptcha/react-hcaptcha';
|
|
67
|
+
import '../../context/LoadingContext/LoadingContext.js';
|
|
68
|
+
import '../../context/FooterAnimationContext/index.js';
|
|
69
|
+
import '../LoginView/sections/PhoneNumberSignInSection/PhoneNumberSignInSection.js';
|
|
70
|
+
import '../../context/WalletGroupContext/WalletGroupContext.js';
|
|
71
|
+
import '../../context/PasskeyContext/PasskeyContext.js';
|
|
72
|
+
import '../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
73
|
+
import '../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
74
|
+
import '../TransactionConfirmationView/helpers/transactionErrorMessage.js';
|
|
75
|
+
import '../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
76
|
+
import { useMergeUserAccounts } from '../../utils/hooks/useMergeUserAccounts/useMergeUserAccounts.js';
|
|
77
|
+
|
|
78
|
+
const MergeUserAccountsView = (props) => {
|
|
79
|
+
const { selectedWalletConnector } = useInternalDynamicContext();
|
|
80
|
+
const { setView } = useViewContext();
|
|
81
|
+
const { mergeUserAccounts } = useMergeUserAccounts();
|
|
82
|
+
const { t } = useTranslation();
|
|
83
|
+
const [error, setError] = useState('');
|
|
84
|
+
const { mergeConflicts, walletAddress } = props;
|
|
85
|
+
const goToConflictsResolutionView = () => {
|
|
86
|
+
// back button on conflicts resolution view should go back to this view
|
|
87
|
+
const onConflictsResolutionBackClick = () => {
|
|
88
|
+
setView('merge-user-accounts', props);
|
|
89
|
+
};
|
|
90
|
+
setView('merge-user-accounts-conflicts', { mergeConflicts: (mergeConflicts === null || mergeConflicts === void 0 ? void 0 : mergeConflicts.conflicts) || [] }, {
|
|
91
|
+
onBackClick: onConflictsResolutionBackClick,
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
const handleMergeConfirm = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
95
|
+
// if there are conflicts, show the conflicts resolution view, otherwise merge
|
|
96
|
+
if (mergeConflicts === null || mergeConflicts === void 0 ? void 0 : mergeConflicts.conflicts.length) {
|
|
97
|
+
goToConflictsResolutionView();
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
yield mergeUserAccounts([]);
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
logger.error('Error merging user accounts', error);
|
|
105
|
+
setError(t('dyn_merge_user_accounts.errors.merge_error'));
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
const renderDuplicatedInfo = () => {
|
|
109
|
+
if (walletAddress) {
|
|
110
|
+
return (jsxs(Fragment, { children: [jsx(WalletIcon, { walletKey: selectedWalletConnector === null || selectedWalletConnector === void 0 ? void 0 : selectedWalletConnector.key, className: 'merge-user-accounts__accounts__item__icon' }), jsx(Typography, { variant: 'body_small', weight: 'medium', color: 'secondary', className: 'merge-user-accounts__accounts__item__text', children: shortenWalletAddress(walletAddress, 3, 3) })] }));
|
|
111
|
+
}
|
|
112
|
+
return (jsx(UserProfileIcon, { className: 'merge-user-accounts__accounts__item__icon' }));
|
|
113
|
+
};
|
|
114
|
+
return (jsxs("div", { className: 'merge-user-accounts', children: [error && (jsx(Alert, { icon: 'error', variant: 'error', className: 'merge-user-accounts__error', children: error })), jsxs("div", { className: 'merge-user-accounts__container', children: [jsx(Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'merge-user-accounts__title', copykey: 'dyn_merge_user_accounts.same_wallet.content', children: t('dyn_merge_user_accounts.same_wallet.content') }), jsx("div", { className: 'merge-user-accounts__accounts', children: jsx("div", { className: 'merge-user-accounts__accounts__item', children: renderDuplicatedInfo() }) }), jsx(TypographyButton, { onClick: handleMergeConfirm, buttonClassName: 'merge-user-accounts__button', buttonVariant: 'brand-primary', buttonPadding: 'large', typographyProps: {
|
|
115
|
+
color: 'inherit',
|
|
116
|
+
}, startSlot: jsx(SvgUser, {}), expanded: true, copykey: 'dyn_merge_user_accounts.confirm_button', children: t('dyn_merge_user_accounts.confirm_button') })] })] }));
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export { MergeUserAccountsView };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MergeUserAccountsView } from './MergeUserAccountsView';
|
|
@@ -33,7 +33,7 @@ const createEmbeddedWalletWithPasskey = (_a) => _tslib.__awaiter(void 0, [_a], v
|
|
|
33
33
|
throw new utils.DynamicError('Auth token is not defined');
|
|
34
34
|
}
|
|
35
35
|
if (!walletConnector) {
|
|
36
|
-
throw new utils.DynamicError('
|
|
36
|
+
throw new utils.DynamicError('Connector is missing. Please make sure you added EthereumWalletConnectors and/or SolanaWalletConnectors to DynamicProvider settings');
|
|
37
37
|
}
|
|
38
38
|
if (!user) {
|
|
39
39
|
throw new utils.DynamicError('User is not defined');
|
|
@@ -29,7 +29,7 @@ const createEmbeddedWalletWithPasskey = (_a) => __awaiter(void 0, [_a], void 0,
|
|
|
29
29
|
throw new DynamicError('Auth token is not defined');
|
|
30
30
|
}
|
|
31
31
|
if (!walletConnector) {
|
|
32
|
-
throw new DynamicError('
|
|
32
|
+
throw new DynamicError('Connector is missing. Please make sure you added EthereumWalletConnectors and/or SolanaWalletConnectors to DynamicProvider settings');
|
|
33
33
|
}
|
|
34
34
|
if (!user) {
|
|
35
35
|
throw new DynamicError('User is not defined');
|
|
@@ -32,7 +32,7 @@ const createPregeneratedWallet = (_a) => _tslib.__awaiter(void 0, [_a], void 0,
|
|
|
32
32
|
throw new utils.DynamicError('Auth token is not defined');
|
|
33
33
|
}
|
|
34
34
|
if (!walletConnector) {
|
|
35
|
-
throw new utils.DynamicError('
|
|
35
|
+
throw new utils.DynamicError('Connector is missing. Please make sure you added EthereumWalletConnectors and/or SolanaWalletConnectors to DynamicProvider settings');
|
|
36
36
|
}
|
|
37
37
|
if (!user) {
|
|
38
38
|
throw new utils.DynamicError('User is not defined');
|
|
@@ -28,7 +28,7 @@ const createPregeneratedWallet = (_a) => __awaiter(void 0, [_a], void 0, functio
|
|
|
28
28
|
throw new DynamicError('Auth token is not defined');
|
|
29
29
|
}
|
|
30
30
|
if (!walletConnector) {
|
|
31
|
-
throw new DynamicError('
|
|
31
|
+
throw new DynamicError('Connector is missing. Please make sure you added EthereumWalletConnectors and/or SolanaWalletConnectors to DynamicProvider settings');
|
|
32
32
|
}
|
|
33
33
|
if (!user) {
|
|
34
34
|
throw new DynamicError('User is not defined');
|
|
@@ -39,7 +39,7 @@ const initEmbeddedWalletSession = (_a) => _tslib.__awaiter(void 0, [_a], void 0,
|
|
|
39
39
|
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.connector) ||
|
|
40
40
|
!(wallet === null || wallet === void 0 ? void 0 : wallet.id) ||
|
|
41
41
|
!walletConnectorCore.isPasskeyWalletConnector(wallet === null || wallet === void 0 ? void 0 : wallet.connector)) {
|
|
42
|
-
throw new utils.DynamicError('
|
|
42
|
+
throw new utils.DynamicError('Connector is missing. Please make sure you added EthereumWalletConnectors and/or SolanaWalletConnectors to DynamicProvider settings');
|
|
43
43
|
}
|
|
44
44
|
const turnkeyRecoveryHandler = (_b = wallet.connector) === null || _b === void 0 ? void 0 : _b.getAuthenticatorHandler();
|
|
45
45
|
if (authenticatorType === 'passkey' &&
|
|
@@ -76,7 +76,7 @@ const passkeyRecoveryBundleValidation = (_c) => _tslib.__awaiter(void 0, [_c], v
|
|
|
76
76
|
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.connector) ||
|
|
77
77
|
!(wallet === null || wallet === void 0 ? void 0 : wallet.id) ||
|
|
78
78
|
!walletConnectorCore.isPasskeyWalletConnector(wallet === null || wallet === void 0 ? void 0 : wallet.connector)) {
|
|
79
|
-
throw new utils.DynamicError('
|
|
79
|
+
throw new utils.DynamicError('Connector is missing. Please make sure you added EthereumWalletConnectors and/or SolanaWalletConnectors to DynamicProvider settings');
|
|
80
80
|
}
|
|
81
81
|
const decodedJwt = decodeJwt.decodeJwt(authToken);
|
|
82
82
|
if (!decodedJwt) {
|
|
@@ -100,7 +100,7 @@ const resentRecoveryEmail = (_h) => _tslib.__awaiter(void 0, [_h], void 0, funct
|
|
|
100
100
|
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.connector) ||
|
|
101
101
|
!(wallet === null || wallet === void 0 ? void 0 : wallet.id) ||
|
|
102
102
|
!walletConnectorCore.isPasskeyWalletConnector(wallet === null || wallet === void 0 ? void 0 : wallet.connector)) {
|
|
103
|
-
throw new utils.DynamicError('
|
|
103
|
+
throw new utils.DynamicError('Connector is missing. Please make sure you added EthereumWalletConnectors and/or SolanaWalletConnectors to DynamicProvider settings');
|
|
104
104
|
}
|
|
105
105
|
const publicKey = (_j = wallet.connector) === null || _j === void 0 ? void 0 : _j.getAuthenticatorHandler().publicKey;
|
|
106
106
|
if (!publicKey) {
|
|
@@ -126,7 +126,7 @@ const completePasskeyRecovery = (_k) => _tslib.__awaiter(void 0, [_k], void 0, f
|
|
|
126
126
|
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.connector) ||
|
|
127
127
|
!(wallet === null || wallet === void 0 ? void 0 : wallet.id) ||
|
|
128
128
|
!walletConnectorCore.isPasskeyWalletConnector(wallet === null || wallet === void 0 ? void 0 : wallet.connector)) {
|
|
129
|
-
throw new utils.DynamicError('
|
|
129
|
+
throw new utils.DynamicError('Connector is missing. Please make sure you added EthereumWalletConnectors and/or SolanaWalletConnectors to DynamicProvider settings');
|
|
130
130
|
}
|
|
131
131
|
const connector = wallet.connector;
|
|
132
132
|
connector.setEmail(userEmail);
|
|
@@ -182,7 +182,7 @@ const addNewPasskeyAuthenticator = (_p) => _tslib.__awaiter(void 0, [_p], void 0
|
|
|
182
182
|
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.connector) ||
|
|
183
183
|
!(wallet === null || wallet === void 0 ? void 0 : wallet.id) ||
|
|
184
184
|
!walletConnectorCore.isPasskeyWalletConnector(wallet === null || wallet === void 0 ? void 0 : wallet.connector)) {
|
|
185
|
-
throw new utils.DynamicError('
|
|
185
|
+
throw new utils.DynamicError('Connector is missing. Please make sure you added EthereumWalletConnectors and/or SolanaWalletConnectors to DynamicProvider settings');
|
|
186
186
|
}
|
|
187
187
|
const connector = wallet.connector;
|
|
188
188
|
connector.setEmail(userEmail);
|
|
@@ -252,7 +252,7 @@ const restoreEmbeddedWalletSession = (_t) => _tslib.__awaiter(void 0, [_t], void
|
|
|
252
252
|
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.connector) ||
|
|
253
253
|
!(wallet === null || wallet === void 0 ? void 0 : wallet.id) ||
|
|
254
254
|
!walletConnectorCore.isPasskeyWalletConnector(wallet === null || wallet === void 0 ? void 0 : wallet.connector)) {
|
|
255
|
-
throw new utils.DynamicError('
|
|
255
|
+
throw new utils.DynamicError('Connector is missing. Please make sure you added EthereumWalletConnectors and/or SolanaWalletConnectors to DynamicProvider settings');
|
|
256
256
|
}
|
|
257
257
|
const sessionSettings = localStorage.LocalStorage.getFromLS(localStorage$1.EMBEDDED_WALLET_SESSION_SETTINGS);
|
|
258
258
|
const turnkeyRecoveryHandler = (_u = wallet.connector) === null || _u === void 0 ? void 0 : _u.getAuthenticatorHandler();
|
|
@@ -281,7 +281,7 @@ const addEmailRecovery = (_y) => _tslib.__awaiter(void 0, [_y], void 0, function
|
|
|
281
281
|
!(wallet === null || wallet === void 0 ? void 0 : wallet.id) ||
|
|
282
282
|
!walletConnectorCore.isPasskeyWalletConnector(wallet === null || wallet === void 0 ? void 0 : wallet.connector) ||
|
|
283
283
|
!walletConnectorCore.isEmailWalletConnector(wallet === null || wallet === void 0 ? void 0 : wallet.connector)) {
|
|
284
|
-
throw new utils.DynamicError('
|
|
284
|
+
throw new utils.DynamicError('Connector is missing. Please make sure you added EthereumWalletConnectors and/or SolanaWalletConnectors to DynamicProvider settings');
|
|
285
285
|
}
|
|
286
286
|
const { turnkeySubOrganizationId, turnkeyUserId } = (_0 = (_z = decodedJwt.verifiedCredentials) === null || _z === void 0 ? void 0 : _z.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'))) === null || _0 === void 0 ? void 0 : _0.walletProperties;
|
|
287
287
|
if (!turnkeySubOrganizationId || !turnkeyUserId) {
|