@dynamic-labs/sdk-react-core 4.3.0 → 4.3.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 +9 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +11 -11
- package/src/lib/components/SignMessagePreview/SignMessagePreview.cjs +2 -1
- package/src/lib/components/SignMessagePreview/SignMessagePreview.js +2 -1
- package/src/lib/components/SignMessagePreview/utils/safeJsonParse/index.d.ts +1 -0
- package/src/lib/components/SignMessagePreview/utils/safeJsonParse/safeJsonParse.cjs +21 -0
- package/src/lib/components/SignMessagePreview/utils/safeJsonParse/safeJsonParse.d.ts +1 -0
- package/src/lib/components/SignMessagePreview/utils/safeJsonParse/safeJsonParse.js +17 -0
- package/src/lib/context/UserWalletsContext/UserWalletsContext.cjs +19 -14
- package/src/lib/context/UserWalletsContext/UserWalletsContext.js +20 -15
- package/src/lib/context/ViewContext/types/index.d.ts +1 -1
- package/src/lib/data/api/wallets/wallets.cjs +3 -0
- package/src/lib/data/api/wallets/wallets.js +4 -1
- package/src/lib/locale/en/translation.cjs +4 -0
- package/src/lib/locale/en/translation.d.ts +4 -0
- package/src/lib/locale/en/translation.js +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/getWalletUniqueId/getWalletUniqueId.cjs +13 -0
- package/src/lib/utils/functions/getWalletUniqueId/getWalletUniqueId.d.ts +10 -0
- package/src/lib/utils/functions/getWalletUniqueId/getWalletUniqueId.js +9 -0
- package/src/lib/utils/functions/getWalletUniqueId/index.d.ts +1 -0
- package/src/lib/utils/functions/index.d.ts +1 -0
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +6 -13
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +6 -13
- package/src/lib/utils/hooks/useDynamicLayoutData/useDynamicLayoutData.cjs +4 -0
- package/src/lib/utils/hooks/useDynamicLayoutData/useDynamicLayoutData.js +4 -0
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +5 -0
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +6 -1
- package/src/lib/views/WalletAlreadyExistsView/WalletAlreadyExistsView.cjs +109 -0
- package/src/lib/views/WalletAlreadyExistsView/WalletAlreadyExistsView.d.ts +2 -0
- package/src/lib/views/WalletAlreadyExistsView/WalletAlreadyExistsView.js +105 -0
- package/src/lib/views/WalletAlreadyExistsView/index.d.ts +1 -0
- package/src/lib/views/viewToComponentMap.cjs +2 -0
- package/src/lib/views/viewToComponentMap.d.ts +1 -0
- package/src/lib/views/viewToComponentMap.js +2 -0
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs +8 -6
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js +8 -6
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.js +1 -1
- package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.cjs +10 -4
- package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.d.ts +3 -1
- package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.js +10 -4
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Generates a unique id for a wallet, based on the address,
|
|
8
|
+
* connector key, and chain.
|
|
9
|
+
* This is used to identify a wallet no matter if it's connected only or linked.
|
|
10
|
+
*/
|
|
11
|
+
const getWalletUniqueId = ({ address, connectorKey, chain, }) => `${connectorKey}-${address}-${chain}`;
|
|
12
|
+
|
|
13
|
+
exports.getWalletUniqueId = getWalletUniqueId;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a unique id for a wallet, based on the address,
|
|
3
|
+
* connector key, and chain.
|
|
4
|
+
* This is used to identify a wallet no matter if it's connected only or linked.
|
|
5
|
+
*/
|
|
6
|
+
export declare const getWalletUniqueId: ({ address, connectorKey, chain, }: {
|
|
7
|
+
address: string;
|
|
8
|
+
connectorKey: string;
|
|
9
|
+
chain: string;
|
|
10
|
+
}) => string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
/**
|
|
3
|
+
* Generates a unique id for a wallet, based on the address,
|
|
4
|
+
* connector key, and chain.
|
|
5
|
+
* This is used to identify a wallet no matter if it's connected only or linked.
|
|
6
|
+
*/
|
|
7
|
+
const getWalletUniqueId = ({ address, connectorKey, chain, }) => `${connectorKey}-${address}-${chain}`;
|
|
8
|
+
|
|
9
|
+
export { getWalletUniqueId };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getWalletUniqueId } from './getWalletUniqueId';
|
|
@@ -27,6 +27,7 @@ require('../../../store/state/nonce/nonce.cjs');
|
|
|
27
27
|
var shouldManuallyReconnectOnRefresh = require('../../functions/shouldManuallyReconnectOnRefresh/shouldManuallyReconnectOnRefresh.cjs');
|
|
28
28
|
require('../../../store/state/projectSettings/projectSettings.cjs');
|
|
29
29
|
var updatePrimaryWalletId = require('../../functions/updatePrimaryWalletId/updatePrimaryWalletId.cjs');
|
|
30
|
+
var getWalletUniqueId = require('../../functions/getWalletUniqueId/getWalletUniqueId.cjs');
|
|
30
31
|
require('../../../store/state/user/user.cjs');
|
|
31
32
|
var session = require('../../../data/api/session/session.cjs');
|
|
32
33
|
require('../../../locale/locale.cjs');
|
|
@@ -117,18 +118,6 @@ const useConnectWallet = ({ authMode, enableVisitTrackingOnConnectOnly, environm
|
|
|
117
118
|
updateConnectedWalletsList();
|
|
118
119
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
119
120
|
}, [connectedWalletsInfo, walletConnectorOptions]);
|
|
120
|
-
const getNextIdAvailable = React.useCallback((currentWallets) => {
|
|
121
|
-
const existingIds = currentWallets.map(({ id }) => id);
|
|
122
|
-
const sortedIds = existingIds
|
|
123
|
-
.map((id) => Number(id.replace('connect-wallet-', '')))
|
|
124
|
-
.sort((a, b) => a - b);
|
|
125
|
-
for (let i = 0; i < sortedIds.length; i++) {
|
|
126
|
-
if (sortedIds[i] !== i) {
|
|
127
|
-
return i;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return sortedIds.length;
|
|
131
|
-
}, []);
|
|
132
121
|
const updateConnectedWalletById = React.useCallback((walletId, walletObject) => {
|
|
133
122
|
var _a;
|
|
134
123
|
const clonedConnectedWalletsList = [...connectedWallets];
|
|
@@ -225,7 +214,11 @@ const useConnectWallet = ({ authMode, enableVisitTrackingOnConnectOnly, environm
|
|
|
225
214
|
// https://linear.app/dynamic-labs/issue/QNTM-784/rework-the-way-we-compute-wallet-ids
|
|
226
215
|
if (!isConnectOnly.isConnectOnly(user, authMode))
|
|
227
216
|
return { address: walletAddress, id: '' };
|
|
228
|
-
const walletId =
|
|
217
|
+
const walletId = getWalletUniqueId.getWalletUniqueId({
|
|
218
|
+
address: walletAddress,
|
|
219
|
+
chain: walletConnector.connectedChain,
|
|
220
|
+
connectorKey: walletConnector.key,
|
|
221
|
+
});
|
|
229
222
|
if (!primaryWalletId$1) {
|
|
230
223
|
updatePrimaryWalletId.updatePrimaryWalletId(walletId);
|
|
231
224
|
}
|
|
@@ -23,6 +23,7 @@ import '../../../store/state/nonce/nonce.js';
|
|
|
23
23
|
import { shouldManuallyReconnectOnRefresh } from '../../functions/shouldManuallyReconnectOnRefresh/shouldManuallyReconnectOnRefresh.js';
|
|
24
24
|
import '../../../store/state/projectSettings/projectSettings.js';
|
|
25
25
|
import { updatePrimaryWalletId } from '../../functions/updatePrimaryWalletId/updatePrimaryWalletId.js';
|
|
26
|
+
import { getWalletUniqueId } from '../../functions/getWalletUniqueId/getWalletUniqueId.js';
|
|
26
27
|
import '../../../store/state/user/user.js';
|
|
27
28
|
import { createVisit } from '../../../data/api/session/session.js';
|
|
28
29
|
import '../../../locale/locale.js';
|
|
@@ -113,18 +114,6 @@ const useConnectWallet = ({ authMode, enableVisitTrackingOnConnectOnly, environm
|
|
|
113
114
|
updateConnectedWalletsList();
|
|
114
115
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
115
116
|
}, [connectedWalletsInfo, walletConnectorOptions]);
|
|
116
|
-
const getNextIdAvailable = useCallback((currentWallets) => {
|
|
117
|
-
const existingIds = currentWallets.map(({ id }) => id);
|
|
118
|
-
const sortedIds = existingIds
|
|
119
|
-
.map((id) => Number(id.replace('connect-wallet-', '')))
|
|
120
|
-
.sort((a, b) => a - b);
|
|
121
|
-
for (let i = 0; i < sortedIds.length; i++) {
|
|
122
|
-
if (sortedIds[i] !== i) {
|
|
123
|
-
return i;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return sortedIds.length;
|
|
127
|
-
}, []);
|
|
128
117
|
const updateConnectedWalletById = useCallback((walletId, walletObject) => {
|
|
129
118
|
var _a;
|
|
130
119
|
const clonedConnectedWalletsList = [...connectedWallets];
|
|
@@ -221,7 +210,11 @@ const useConnectWallet = ({ authMode, enableVisitTrackingOnConnectOnly, environm
|
|
|
221
210
|
// https://linear.app/dynamic-labs/issue/QNTM-784/rework-the-way-we-compute-wallet-ids
|
|
222
211
|
if (!isConnectOnly(user, authMode))
|
|
223
212
|
return { address: walletAddress, id: '' };
|
|
224
|
-
const walletId =
|
|
213
|
+
const walletId = getWalletUniqueId({
|
|
214
|
+
address: walletAddress,
|
|
215
|
+
chain: walletConnector.connectedChain,
|
|
216
|
+
connectorKey: walletConnector.key,
|
|
217
|
+
});
|
|
225
218
|
if (!primaryWalletId) {
|
|
226
219
|
updatePrimaryWalletId(walletId);
|
|
227
220
|
}
|
|
@@ -152,6 +152,10 @@ const useDynamicLayoutData = ({ view, authMode, }) => {
|
|
|
152
152
|
copykey: 'dyn_embedded_delete.title',
|
|
153
153
|
heading: t('dyn_embedded_delete.title'),
|
|
154
154
|
},
|
|
155
|
+
'embedded-wallet-exists': {
|
|
156
|
+
copykey: 'dyn_wallet_link.already_exists.title',
|
|
157
|
+
heading: t('dyn_wallet_link.already_exists.title'),
|
|
158
|
+
},
|
|
155
159
|
'external-funding-wallet-list': {
|
|
156
160
|
copykey: 'dyn_receive_external_wallet_funds.wallet_list.title',
|
|
157
161
|
heading: t('dyn_receive_external_wallet_funds.wallet_list.title'),
|
|
@@ -148,6 +148,10 @@ const useDynamicLayoutData = ({ view, authMode, }) => {
|
|
|
148
148
|
copykey: 'dyn_embedded_delete.title',
|
|
149
149
|
heading: t('dyn_embedded_delete.title'),
|
|
150
150
|
},
|
|
151
|
+
'embedded-wallet-exists': {
|
|
152
|
+
copykey: 'dyn_wallet_link.already_exists.title',
|
|
153
|
+
heading: t('dyn_wallet_link.already_exists.title'),
|
|
154
|
+
},
|
|
151
155
|
'external-funding-wallet-list': {
|
|
152
156
|
copykey: 'dyn_receive_external_wallet_funds.wallet_list.title',
|
|
153
157
|
heading: t('dyn_receive_external_wallet_funds.wallet_list.title'),
|
|
@@ -197,6 +197,11 @@ const useVerifyWallet = ({ displaySiweStatement, environmentId, projectSettings,
|
|
|
197
197
|
option: walletConnector.name,
|
|
198
198
|
type: 'wallet',
|
|
199
199
|
}, { error: e });
|
|
200
|
+
if (e instanceof utils.EmbeddedWalletExistsError) {
|
|
201
|
+
setView('embedded-wallet-exists');
|
|
202
|
+
setShowAuthFlow(true);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
200
205
|
if (e instanceof utils.WalletUsedError) {
|
|
201
206
|
handleDisconnectWallet({ endSession: false, walletConnector });
|
|
202
207
|
return handleWalletUsedError(e);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
-
import { DynamicError, StorageService, WalletUsedError, MergeAccountsConfirmationError, ChainalysisError, GateBlockedError, SandboxMaximumThresholdReachedError, NoAccessError, AccountExistsError } from '@dynamic-labs/utils';
|
|
3
|
+
import { DynamicError, StorageService, EmbeddedWalletExistsError, WalletUsedError, MergeAccountsConfirmationError, ChainalysisError, GateBlockedError, SandboxMaximumThresholdReachedError, NoAccessError, AccountExistsError } from '@dynamic-labs/utils';
|
|
4
4
|
import { isSocialWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
5
5
|
import 'react';
|
|
6
6
|
import { dynamicEvents } from '../../../events/dynamicEvents.js';
|
|
@@ -193,6 +193,11 @@ const useVerifyWallet = ({ displaySiweStatement, environmentId, projectSettings,
|
|
|
193
193
|
option: walletConnector.name,
|
|
194
194
|
type: 'wallet',
|
|
195
195
|
}, { error: e });
|
|
196
|
+
if (e instanceof EmbeddedWalletExistsError) {
|
|
197
|
+
setView('embedded-wallet-exists');
|
|
198
|
+
setShowAuthFlow(true);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
196
201
|
if (e instanceof WalletUsedError) {
|
|
197
202
|
handleDisconnectWallet({ endSession: false, walletConnector });
|
|
198
203
|
return handleWalletUsedError(e);
|
|
@@ -0,0 +1,109 @@
|
|
|
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 reactI18next = require('react-i18next');
|
|
9
|
+
var walletBook = require('@dynamic-labs/wallet-book');
|
|
10
|
+
require('@dynamic-labs/utils');
|
|
11
|
+
require('../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
|
|
12
|
+
require('../../components/Alert/Alert.cjs');
|
|
13
|
+
require('react');
|
|
14
|
+
require('../../events/dynamicEvents.cjs');
|
|
15
|
+
require('../../context/DynamicContext/DynamicContext.cjs');
|
|
16
|
+
require('@dynamic-labs/sdk-api-core');
|
|
17
|
+
require('../../shared/logger.cjs');
|
|
18
|
+
require('@dynamic-labs/iconic');
|
|
19
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
20
|
+
require('../../context/ViewContext/ViewContext.cjs');
|
|
21
|
+
var shortenWalletAddress = require('../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.cjs');
|
|
22
|
+
require('../../utils/constants/colors.cjs');
|
|
23
|
+
require('../../utils/constants/values.cjs');
|
|
24
|
+
require('../../store/state/loadingAndLifecycle.cjs');
|
|
25
|
+
require('../../shared/consts/index.cjs');
|
|
26
|
+
var useInternalDynamicContext = require('../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
27
|
+
require('../../context/CaptchaContext/CaptchaContext.cjs');
|
|
28
|
+
require('../../context/ErrorContext/ErrorContext.cjs');
|
|
29
|
+
require('@dynamic-labs/multi-wallet');
|
|
30
|
+
require('react-international-phone');
|
|
31
|
+
require('../../store/state/nonce/nonce.cjs');
|
|
32
|
+
require('../../store/state/projectSettings/projectSettings.cjs');
|
|
33
|
+
require('../../config/ApiEndpoint.cjs');
|
|
34
|
+
require('../../store/state/user/user.cjs');
|
|
35
|
+
require('../../locale/locale.cjs');
|
|
36
|
+
require('../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
37
|
+
require('../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
38
|
+
require('../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
39
|
+
require('../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
40
|
+
require('../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
41
|
+
require('../../context/VerificationContext/VerificationContext.cjs');
|
|
42
|
+
require('react-dom');
|
|
43
|
+
require('../../utils/functions/compareChains/compareChains.cjs');
|
|
44
|
+
require('../../context/ThemeContext/ThemeContext.cjs');
|
|
45
|
+
require('../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
46
|
+
var usePromise = require('../../utils/hooks/usePromise/usePromise.cjs');
|
|
47
|
+
require('@dynamic-labs/types');
|
|
48
|
+
require('../../context/LoadingContext/LoadingContext.cjs');
|
|
49
|
+
require('../../context/WalletContext/WalletContext.cjs');
|
|
50
|
+
require('../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
|
|
51
|
+
require('yup');
|
|
52
|
+
require('../../context/MockContext/MockContext.cjs');
|
|
53
|
+
require('../CollectUserDataView/useFields.cjs');
|
|
54
|
+
require('../../context/FieldsStateContext/FieldsStateContext.cjs');
|
|
55
|
+
require('../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
56
|
+
require('@dynamic-labs/rpc-providers');
|
|
57
|
+
require('../../store/state/walletOptions/walletOptions.cjs');
|
|
58
|
+
var Typography = require('../../components/Typography/Typography.cjs');
|
|
59
|
+
require('../../context/FooterAnimationContext/index.cjs');
|
|
60
|
+
require('../../components/ShadowDOM/ShadowDOM.cjs');
|
|
61
|
+
require('../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
62
|
+
require('../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
63
|
+
require('../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
64
|
+
require('../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.cjs');
|
|
65
|
+
require('../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
66
|
+
require('../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
67
|
+
require('../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
68
|
+
require('react-focus-lock');
|
|
69
|
+
require('../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
|
|
70
|
+
require('../../components/IconButton/IconButton.cjs');
|
|
71
|
+
require('../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
72
|
+
require('formik');
|
|
73
|
+
require('../../utils/hooks/useSubdomainCheck/useSubdomainCheck.cjs');
|
|
74
|
+
require('../../store/state/sendBalances.cjs');
|
|
75
|
+
require('../../components/Input/Input.cjs');
|
|
76
|
+
require('../../components/OverlayCard/OverlayCard.cjs');
|
|
77
|
+
require('../TransactionConfirmationView/TransactionConfirmationView.cjs');
|
|
78
|
+
require('../../context/PasskeyContext/PasskeyContext.cjs');
|
|
79
|
+
require('../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
80
|
+
require('../../widgets/DynamicWidget/views/ReceiveExternalWalletFunds/ReceiveExternalWalletFunds.cjs');
|
|
81
|
+
require('../../../index.cjs');
|
|
82
|
+
require('../../context/IpConfigurationContext/IpConfigurationContext.cjs');
|
|
83
|
+
require('../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
|
|
84
|
+
require('../../context/ConnectWithOtpContext/constants.cjs');
|
|
85
|
+
require('../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
86
|
+
require('@hcaptcha/react-hcaptcha');
|
|
87
|
+
require('../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
|
|
88
|
+
require('../../store/state/tokenBalances.cjs');
|
|
89
|
+
require('../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
90
|
+
require('../../components/InlineWidget/InlineWidget.cjs');
|
|
91
|
+
require('../../components/IsBrowser/IsBrowser.cjs');
|
|
92
|
+
require('../../components/Popper/Popper/Popper.cjs');
|
|
93
|
+
require('../../components/Popper/PopperContext/PopperContext.cjs');
|
|
94
|
+
require('qrcode');
|
|
95
|
+
|
|
96
|
+
const WalletAlreadyExistsView = () => {
|
|
97
|
+
const { selectedWalletConnector: walletConnector } = useInternalDynamicContext.useInternalDynamicContext();
|
|
98
|
+
const { t } = reactI18next.useTranslation();
|
|
99
|
+
const { data: walletAddress } = usePromise.usePromise(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
100
|
+
const accounts = yield (walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.getConnectedAccounts());
|
|
101
|
+
return accounts === null || accounts === void 0 ? void 0 : accounts[0];
|
|
102
|
+
}), {
|
|
103
|
+
deps: [walletConnector],
|
|
104
|
+
});
|
|
105
|
+
const shortenedWalletAddress = shortenWalletAddress.shortenWalletAddress(walletAddress);
|
|
106
|
+
return (jsxRuntime.jsxs("div", { className: 'wallet-already-exists-view__container', children: [jsxRuntime.jsx("div", { className: 'wallet-already-exists-view__icon', children: jsxRuntime.jsx(walletBook.WalletIcon, { icon: walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.metadata.icon, walletKey: walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.key, width: 64, height: 64 }) }), jsxRuntime.jsx(Typography.Typography, { className: 'wallet-already-exists-view__shorten-wallet-address', variant: 'body_normal', weight: 'medium', color: 'primary', children: shortenedWalletAddress }), jsxRuntime.jsx(Typography.Typography, { className: 'wallet-already-exists-view__copy', variant: 'body_normal', color: 'secondary', weight: 'regular', children: t('dyn_wallet_link.already_exists.description') })] }));
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
exports.WalletAlreadyExistsView = WalletAlreadyExistsView;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { WalletIcon } from '@dynamic-labs/wallet-book';
|
|
6
|
+
import '@dynamic-labs/utils';
|
|
7
|
+
import '../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
8
|
+
import '../../components/Alert/Alert.js';
|
|
9
|
+
import 'react';
|
|
10
|
+
import '../../events/dynamicEvents.js';
|
|
11
|
+
import '../../context/DynamicContext/DynamicContext.js';
|
|
12
|
+
import '@dynamic-labs/sdk-api-core';
|
|
13
|
+
import '../../shared/logger.js';
|
|
14
|
+
import '@dynamic-labs/iconic';
|
|
15
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
16
|
+
import '../../context/ViewContext/ViewContext.js';
|
|
17
|
+
import { shortenWalletAddress } from '../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.js';
|
|
18
|
+
import '../../utils/constants/colors.js';
|
|
19
|
+
import '../../utils/constants/values.js';
|
|
20
|
+
import '../../store/state/loadingAndLifecycle.js';
|
|
21
|
+
import '../../shared/consts/index.js';
|
|
22
|
+
import { useInternalDynamicContext } from '../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
23
|
+
import '../../context/CaptchaContext/CaptchaContext.js';
|
|
24
|
+
import '../../context/ErrorContext/ErrorContext.js';
|
|
25
|
+
import '@dynamic-labs/multi-wallet';
|
|
26
|
+
import 'react-international-phone';
|
|
27
|
+
import '../../store/state/nonce/nonce.js';
|
|
28
|
+
import '../../store/state/projectSettings/projectSettings.js';
|
|
29
|
+
import '../../config/ApiEndpoint.js';
|
|
30
|
+
import '../../store/state/user/user.js';
|
|
31
|
+
import '../../locale/locale.js';
|
|
32
|
+
import '../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
33
|
+
import '../../store/state/primaryWalletId/primaryWalletId.js';
|
|
34
|
+
import '../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
35
|
+
import '../../context/AccountExistsContext/AccountExistsContext.js';
|
|
36
|
+
import '../../context/UserWalletsContext/UserWalletsContext.js';
|
|
37
|
+
import '../../context/VerificationContext/VerificationContext.js';
|
|
38
|
+
import 'react-dom';
|
|
39
|
+
import '../../utils/functions/compareChains/compareChains.js';
|
|
40
|
+
import '../../context/ThemeContext/ThemeContext.js';
|
|
41
|
+
import '../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
42
|
+
import { usePromise } from '../../utils/hooks/usePromise/usePromise.js';
|
|
43
|
+
import '@dynamic-labs/types';
|
|
44
|
+
import '../../context/LoadingContext/LoadingContext.js';
|
|
45
|
+
import '../../context/WalletContext/WalletContext.js';
|
|
46
|
+
import '../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
|
|
47
|
+
import 'yup';
|
|
48
|
+
import '../../context/MockContext/MockContext.js';
|
|
49
|
+
import '../CollectUserDataView/useFields.js';
|
|
50
|
+
import '../../context/FieldsStateContext/FieldsStateContext.js';
|
|
51
|
+
import '../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
52
|
+
import '@dynamic-labs/rpc-providers';
|
|
53
|
+
import '../../store/state/walletOptions/walletOptions.js';
|
|
54
|
+
import { Typography } from '../../components/Typography/Typography.js';
|
|
55
|
+
import '../../context/FooterAnimationContext/index.js';
|
|
56
|
+
import '../../components/ShadowDOM/ShadowDOM.js';
|
|
57
|
+
import '../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
58
|
+
import '../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
59
|
+
import '../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
60
|
+
import '../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.js';
|
|
61
|
+
import '../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
62
|
+
import '../../context/WalletGroupContext/WalletGroupContext.js';
|
|
63
|
+
import '../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
64
|
+
import 'react-focus-lock';
|
|
65
|
+
import '../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
66
|
+
import '../../components/IconButton/IconButton.js';
|
|
67
|
+
import '../../components/MenuList/Dropdown/Dropdown.js';
|
|
68
|
+
import 'formik';
|
|
69
|
+
import '../../utils/hooks/useSubdomainCheck/useSubdomainCheck.js';
|
|
70
|
+
import '../../store/state/sendBalances.js';
|
|
71
|
+
import '../../components/Input/Input.js';
|
|
72
|
+
import '../../components/OverlayCard/OverlayCard.js';
|
|
73
|
+
import '../TransactionConfirmationView/TransactionConfirmationView.js';
|
|
74
|
+
import '../../context/PasskeyContext/PasskeyContext.js';
|
|
75
|
+
import '../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
76
|
+
import '../../widgets/DynamicWidget/views/ReceiveExternalWalletFunds/ReceiveExternalWalletFunds.js';
|
|
77
|
+
import '../../../index.js';
|
|
78
|
+
import '../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
79
|
+
import '../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
|
|
80
|
+
import '../../context/ConnectWithOtpContext/constants.js';
|
|
81
|
+
import '../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
82
|
+
import '@hcaptcha/react-hcaptcha';
|
|
83
|
+
import '../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
84
|
+
import '../../store/state/tokenBalances.js';
|
|
85
|
+
import '../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
86
|
+
import '../../components/InlineWidget/InlineWidget.js';
|
|
87
|
+
import '../../components/IsBrowser/IsBrowser.js';
|
|
88
|
+
import '../../components/Popper/Popper/Popper.js';
|
|
89
|
+
import '../../components/Popper/PopperContext/PopperContext.js';
|
|
90
|
+
import 'qrcode';
|
|
91
|
+
|
|
92
|
+
const WalletAlreadyExistsView = () => {
|
|
93
|
+
const { selectedWalletConnector: walletConnector } = useInternalDynamicContext();
|
|
94
|
+
const { t } = useTranslation();
|
|
95
|
+
const { data: walletAddress } = usePromise(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
96
|
+
const accounts = yield (walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.getConnectedAccounts());
|
|
97
|
+
return accounts === null || accounts === void 0 ? void 0 : accounts[0];
|
|
98
|
+
}), {
|
|
99
|
+
deps: [walletConnector],
|
|
100
|
+
});
|
|
101
|
+
const shortenedWalletAddress = shortenWalletAddress(walletAddress);
|
|
102
|
+
return (jsxs("div", { className: 'wallet-already-exists-view__container', children: [jsx("div", { className: 'wallet-already-exists-view__icon', children: jsx(WalletIcon, { icon: walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.metadata.icon, walletKey: walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.key, width: 64, height: 64 }) }), jsx(Typography, { className: 'wallet-already-exists-view__shorten-wallet-address', variant: 'body_normal', weight: 'medium', color: 'primary', children: shortenedWalletAddress }), jsx(Typography, { className: 'wallet-already-exists-view__copy', variant: 'body_normal', color: 'secondary', weight: 'regular', children: t('dyn_wallet_link.already_exists.description') })] }));
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export { WalletAlreadyExistsView };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './WalletAlreadyExistsView';
|
|
@@ -134,6 +134,7 @@ var WalletRedirectView = require('./WalletRedirectView/WalletRedirectView.cjs');
|
|
|
134
134
|
var WalletSignSpinnerView = require('./WalletSignSpinnerView/WalletSignSpinnerView.cjs');
|
|
135
135
|
var WalletUsedView = require('./WalletUsedView/WalletUsedView.cjs');
|
|
136
136
|
var DepositView = require('./DepositView/DepositView.cjs');
|
|
137
|
+
var WalletAlreadyExistsView = require('./WalletAlreadyExistsView/WalletAlreadyExistsView.cjs');
|
|
137
138
|
require('../store/state/tokenBalances.cjs');
|
|
138
139
|
require('../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
139
140
|
require('../components/InlineWidget/InlineWidget.cjs');
|
|
@@ -161,6 +162,7 @@ const viewToComponentMap = {
|
|
|
161
162
|
'embedded-reveal-account-view': EmbeddedRevealView.EmbeddedRevealView,
|
|
162
163
|
'embedded-reveal-view': EmbeddedRevealView.EmbeddedRevealView,
|
|
163
164
|
'embedded-wallet-auth-choice': EmbeddedAuthChoice.EmbeddedAuthChoice,
|
|
165
|
+
'embedded-wallet-exists': WalletAlreadyExistsView.WalletAlreadyExistsView,
|
|
164
166
|
'external-funding-wallet-list': WalletList.WalletList,
|
|
165
167
|
'farcaster-connect-view': FarcasterConnectView.FarcasterConnectView,
|
|
166
168
|
'gate-blocked-wallet': NoAccess.NoAccess,
|
|
@@ -19,6 +19,7 @@ export declare const viewToComponentMap: {
|
|
|
19
19
|
'embedded-reveal-account-view': import("react").FC<import("./EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView").EmbeddedRevealViewProps>;
|
|
20
20
|
'embedded-reveal-view': import("react").FC<import("./EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView").EmbeddedRevealViewProps>;
|
|
21
21
|
'embedded-wallet-auth-choice': import("react").FC<import("./Passkey/EmbeddedAuthChoice/EmbeddedAuthChoice").EmbeddedAuthChoiceProps>;
|
|
22
|
+
'embedded-wallet-exists': () => JSX.Element;
|
|
22
23
|
'external-funding-wallet-list': ({ isWalletConnectList, onSelectWallet, viewWalletsFilter, }: import("./WalletList").WalletListProps) => JSX.Element;
|
|
23
24
|
'farcaster-connect-view': ({ url }: import("./FarcasterConnectView/FarcasterConnectView").FarcasterConnectViewProps) => JSX.Element;
|
|
24
25
|
'gate-blocked-wallet': () => JSX.Element;
|
|
@@ -130,6 +130,7 @@ import { WalletRedirectView } from './WalletRedirectView/WalletRedirectView.js';
|
|
|
130
130
|
import { WalletSignSpinnerView } from './WalletSignSpinnerView/WalletSignSpinnerView.js';
|
|
131
131
|
import { WalletUsedView } from './WalletUsedView/WalletUsedView.js';
|
|
132
132
|
import { DepositView } from './DepositView/DepositView.js';
|
|
133
|
+
import { WalletAlreadyExistsView } from './WalletAlreadyExistsView/WalletAlreadyExistsView.js';
|
|
133
134
|
import '../store/state/tokenBalances.js';
|
|
134
135
|
import '../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
135
136
|
import '../components/InlineWidget/InlineWidget.js';
|
|
@@ -157,6 +158,7 @@ const viewToComponentMap = {
|
|
|
157
158
|
'embedded-reveal-account-view': EmbeddedRevealView,
|
|
158
159
|
'embedded-reveal-view': EmbeddedRevealView,
|
|
159
160
|
'embedded-wallet-auth-choice': EmbeddedAuthChoice,
|
|
161
|
+
'embedded-wallet-exists': WalletAlreadyExistsView,
|
|
160
162
|
'external-funding-wallet-list': WalletList,
|
|
161
163
|
'farcaster-connect-view': FarcasterConnectView,
|
|
162
164
|
'gate-blocked-wallet': NoAccess,
|
|
@@ -99,13 +99,15 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
99
99
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
100
100
|
|
|
101
101
|
const SecondaryWallets = ({ hideUnlinkAction = false }) => {
|
|
102
|
-
const { disconnectWallet,
|
|
103
|
-
const
|
|
104
|
-
const NetworkIcon =
|
|
105
|
-
const networkInfo =
|
|
106
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!
|
|
102
|
+
const { disconnectWallet, bridgeChains, connectedWallets, primaryWalletId } = useInternalDynamicContext.useInternalDynamicContext();
|
|
103
|
+
const secondaryWallet = connectedWallets.find((wallet) => wallet.id !== primaryWalletId);
|
|
104
|
+
const NetworkIcon = secondaryWallet && getChainIcon.getChainIcon(secondaryWallet === null || secondaryWallet === void 0 ? void 0 : secondaryWallet.chain);
|
|
105
|
+
const networkInfo = secondaryWallet && walletConnectorCore.getChainInfoWithOverrides(secondaryWallet === null || secondaryWallet === void 0 ? void 0 : secondaryWallet.chain);
|
|
106
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!secondaryWallet && (jsxRuntime.jsx(DynamicBridgeWidgetEmptyCard.DynamicBridgeWidgetEmptyCard, { chain: bridgeChains === null || bridgeChains === void 0 ? void 0 : bridgeChains[1].chain })), secondaryWallet && NetworkIcon && (jsxRuntime.jsx(DynamicBridgeWalletCard.DynamicBridgeWalletCard, { networkIcon: jsxRuntime.jsx(NetworkIcon, {}), networkName: networkInfo === null || networkInfo === void 0 ? void 0 : networkInfo.displayName, children: jsxRuntime.jsx(DynamicBridgeWalletCardBody.DynamicBridgeWalletCardBody, { walletKey: secondaryWallet.connector.key, walletAddress: secondaryWallet.address, walletBalance:
|
|
107
107
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
108
|
-
jsxRuntime.jsx(Balance.Balance, { wallet:
|
|
108
|
+
jsxRuntime.jsx(Balance.Balance, { wallet: secondaryWallet, network: secondaryWallet.chain }), onDisconnectClick: !hideUnlinkAction
|
|
109
|
+
? () => disconnectWallet(secondaryWallet.id)
|
|
110
|
+
: undefined }, secondaryWallet.id) }))] }));
|
|
109
111
|
};
|
|
110
112
|
const MemoSecondaryWallets = React__default["default"].memo(SecondaryWallets);
|
|
111
113
|
|
|
@@ -91,13 +91,15 @@ import { useInternalDynamicContext } from '../../../../../../context/DynamicCont
|
|
|
91
91
|
import { DynamicBridgeWidgetEmptyCard } from '../../../../components/DynamicBridgeWidgetEmptyCard/DynamicBridgeWidgetEmptyCard.js';
|
|
92
92
|
|
|
93
93
|
const SecondaryWallets = ({ hideUnlinkAction = false }) => {
|
|
94
|
-
const { disconnectWallet,
|
|
95
|
-
const
|
|
96
|
-
const NetworkIcon =
|
|
97
|
-
const networkInfo =
|
|
98
|
-
return (jsxs(Fragment, { children: [!
|
|
94
|
+
const { disconnectWallet, bridgeChains, connectedWallets, primaryWalletId } = useInternalDynamicContext();
|
|
95
|
+
const secondaryWallet = connectedWallets.find((wallet) => wallet.id !== primaryWalletId);
|
|
96
|
+
const NetworkIcon = secondaryWallet && getChainIcon(secondaryWallet === null || secondaryWallet === void 0 ? void 0 : secondaryWallet.chain);
|
|
97
|
+
const networkInfo = secondaryWallet && getChainInfoWithOverrides(secondaryWallet === null || secondaryWallet === void 0 ? void 0 : secondaryWallet.chain);
|
|
98
|
+
return (jsxs(Fragment, { children: [!secondaryWallet && (jsx(DynamicBridgeWidgetEmptyCard, { chain: bridgeChains === null || bridgeChains === void 0 ? void 0 : bridgeChains[1].chain })), secondaryWallet && NetworkIcon && (jsx(DynamicBridgeWalletCard, { networkIcon: jsx(NetworkIcon, {}), networkName: networkInfo === null || networkInfo === void 0 ? void 0 : networkInfo.displayName, children: jsx(DynamicBridgeWalletCardBody, { walletKey: secondaryWallet.connector.key, walletAddress: secondaryWallet.address, walletBalance:
|
|
99
99
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
100
|
-
jsx(Balance, { wallet:
|
|
100
|
+
jsx(Balance, { wallet: secondaryWallet, network: secondaryWallet.chain }), onDisconnectClick: !hideUnlinkAction
|
|
101
|
+
? () => disconnectWallet(secondaryWallet.id)
|
|
102
|
+
: undefined }, secondaryWallet.id) }))] }));
|
|
101
103
|
};
|
|
102
104
|
const MemoSecondaryWallets = React__default.memo(SecondaryWallets);
|
|
103
105
|
|
package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.cjs
CHANGED
|
@@ -119,7 +119,7 @@ const DynamicWidgetWallets = () => {
|
|
|
119
119
|
: t('dyn_widget.empty_wallets_action_connect'),
|
|
120
120
|
}) })) : (jsxRuntime.jsx("div", { className: 'dynamic-widget-wallets__body__wallet-list', children: secondaryWallets.map((wallet, index) => {
|
|
121
121
|
var _a;
|
|
122
|
-
return (jsxRuntime.jsx(Wallet.Wallet, { ens: (_a = getWalletVerifiedCredential.getWalletVerifiedCredential(wallet.address, user === null || user === void 0 ? void 0 : user.verifiedCredentials, wallet.chain)) === null || _a === void 0 ? void 0 : _a.nameService, wallet: wallet }, wallet.id));
|
|
122
|
+
return (jsxRuntime.jsx(Wallet.Wallet, { ens: (_a = getWalletVerifiedCredential.getWalletVerifiedCredential(wallet.address, user === null || user === void 0 ? void 0 : user.verifiedCredentials, wallet.chain)) === null || _a === void 0 ? void 0 : _a.nameService, wallet: wallet, clickable: true }, wallet.id));
|
|
123
123
|
}) })) }) })] }));
|
|
124
124
|
};
|
|
125
125
|
|
package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.js
CHANGED
|
@@ -115,7 +115,7 @@ const DynamicWidgetWallets = () => {
|
|
|
115
115
|
: t('dyn_widget.empty_wallets_action_connect'),
|
|
116
116
|
}) })) : (jsx("div", { className: 'dynamic-widget-wallets__body__wallet-list', children: secondaryWallets.map((wallet, index) => {
|
|
117
117
|
var _a;
|
|
118
|
-
return (jsx(Wallet, { ens: (_a = getWalletVerifiedCredential(wallet.address, user === null || user === void 0 ? void 0 : user.verifiedCredentials, wallet.chain)) === null || _a === void 0 ? void 0 : _a.nameService, wallet: wallet }, wallet.id));
|
|
118
|
+
return (jsx(Wallet, { ens: (_a = getWalletVerifiedCredential(wallet.address, user === null || user === void 0 ? void 0 : user.verifiedCredentials, wallet.chain)) === null || _a === void 0 ? void 0 : _a.nameService, wallet: wallet, clickable: true }, wallet.id));
|
|
119
119
|
}) })) }) })] }));
|
|
120
120
|
};
|
|
121
121
|
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var React = require('react');
|
|
7
8
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
8
|
-
require('react');
|
|
9
9
|
var copy = require('../../../../shared/assets/copy.cjs');
|
|
10
10
|
var key = require('../../../../shared/assets/key.cjs');
|
|
11
11
|
var switchHorizontal = require('../../../../shared/assets/switch-horizontal.cjs');
|
|
@@ -55,6 +55,7 @@ require('../../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs')
|
|
|
55
55
|
require('@dynamic-labs/rpc-providers');
|
|
56
56
|
require('../../../../store/state/walletOptions/walletOptions.cjs');
|
|
57
57
|
require('react-i18next');
|
|
58
|
+
var classNames = require('../../../../utils/functions/classNames/classNames.cjs');
|
|
58
59
|
require('../../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
|
|
59
60
|
require('../../../../components/Alert/Alert.cjs');
|
|
60
61
|
var Typography = require('../../../../components/Typography/Typography.cjs');
|
|
@@ -100,16 +101,19 @@ require('../../../../store/state/tokenBalances.cjs');
|
|
|
100
101
|
require('../../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
101
102
|
var useInternalDynamicContext = require('../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
102
103
|
|
|
103
|
-
const Wallet = ({ wallet, ens }) => {
|
|
104
|
+
const Wallet = ({ wallet, ens, clickable }) => {
|
|
104
105
|
var _a;
|
|
105
106
|
const { connector, address } = wallet;
|
|
106
107
|
const switchWallet = useSwitchWallet.useSwitchWallet();
|
|
107
108
|
const { setSelectedWalletWithAction, projectSettings, authMode } = useInternalDynamicContext.useInternalDynamicContext();
|
|
109
|
+
const handleSwitchWallet = React.useCallback(() => {
|
|
110
|
+
switchWallet(wallet.id);
|
|
111
|
+
}, [switchWallet, wallet.id]);
|
|
108
112
|
const iconSize = 20;
|
|
109
113
|
const options = [
|
|
110
114
|
{
|
|
111
115
|
Icon: jsxRuntime.jsx(switchHorizontal.ReactComponent, {}),
|
|
112
|
-
callback:
|
|
116
|
+
callback: handleSwitchWallet,
|
|
113
117
|
hide: !((_a = wallet.connector) === null || _a === void 0 ? void 0 : _a.isAvailable),
|
|
114
118
|
text: 'Select wallet',
|
|
115
119
|
},
|
|
@@ -142,7 +146,9 @@ const Wallet = ({ wallet, ens }) => {
|
|
|
142
146
|
text: 'Export private keys',
|
|
143
147
|
});
|
|
144
148
|
}
|
|
145
|
-
return (jsxRuntime.jsxs("div", { className: 'wallet__container', "data-testid": 'wallet', children: [jsxRuntime.jsxs("div", { className:
|
|
149
|
+
return (jsxRuntime.jsxs("div", { className: 'wallet__container', "data-testid": 'wallet', children: [jsxRuntime.jsxs("div", { className: classNames.classNames('wallet__row', {
|
|
150
|
+
'wallet__row--clickable': clickable,
|
|
151
|
+
}), onClick: clickable ? handleSwitchWallet : undefined, children: [jsxRuntime.jsx("div", { className: 'wallet__icon-container', children: jsxRuntime.jsx(AuthProviderIcon.AuthProviderIcon, { iconSize: iconSize, wallet: wallet, showNetworkIcon: true }) }), (ens === null || ens === void 0 ? void 0 : ens.name) ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Typography.Typography, { className: 'wallet__ens-name', variant: 'body_small', color: 'primary', truncate: true, children: ens === null || ens === void 0 ? void 0 : ens.name }), jsxRuntime.jsx("div", { className: 'wallet__row__separator' }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_mini', color: 'secondary', children: shortenWalletAddress.shortenWalletAddress(address, 3, 3) })] })) : (jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'primary', children: shortenWalletAddress.shortenWalletAddress(address, 4, 4) }))] }), jsxRuntime.jsx("div", { className: 'wallet__row__separator wallet__row__menu__separator ' }), jsxRuntime.jsx(DotsMenu.DotsMenu, { "data-testid": 'dots-menu', options: options, buttonClassName: 'wallet__menu', direction: 'left' })] }));
|
|
146
152
|
};
|
|
147
153
|
|
|
148
154
|
exports.Wallet = Wallet;
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
import { NameServiceData } from '@dynamic-labs/sdk-api-core';
|
|
3
3
|
import { Wallet as WalletType } from '../../../../shared/types';
|
|
4
4
|
type Props = {
|
|
5
|
+
/** If true, clicking the wallet will set it as the primary wallet */
|
|
6
|
+
clickable?: boolean;
|
|
5
7
|
ens?: NameServiceData;
|
|
6
8
|
expanded?: boolean;
|
|
7
9
|
expandedWallet?: string;
|
|
8
10
|
setExpandedWallet?: (str?: string) => void;
|
|
9
11
|
wallet: WalletType;
|
|
10
12
|
};
|
|
11
|
-
export declare const Wallet: ({ wallet, ens }: Props) => JSX.Element;
|
|
13
|
+
export declare const Wallet: ({ wallet, ens, clickable }: Props) => JSX.Element;
|
|
12
14
|
export {};
|