@dynamic-labs/sdk-react-core 3.0.0-alpha.10 → 3.0.0-alpha.12
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 +19 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +10 -10
- package/src/index.cjs +1 -1
- package/src/index.js +1 -1
- package/src/lib/components/AuthProviderIcon/AuthProviderIcon.cjs +4 -2
- package/src/lib/components/AuthProviderIcon/AuthProviderIcon.js +4 -2
- package/src/lib/context/DynamicContext/DynamicContext.cjs +1 -0
- package/src/lib/context/DynamicContext/DynamicContext.js +1 -0
- package/src/lib/context/PasskeyContext/PasskeyContext.cjs +5 -6
- package/src/lib/context/PasskeyContext/PasskeyContext.js +5 -6
- package/src/lib/locale/en/translation.cjs +2 -2
- package/src/lib/locale/en/translation.d.ts +1 -1
- package/src/lib/locale/en/translation.js +2 -2
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/functions/getPlatformForConnector/getPlatformForConnector.cjs +10 -0
- package/src/lib/utils/functions/getPlatformForConnector/getPlatformForConnector.d.ts +3 -0
- package/src/lib/utils/functions/getPlatformForConnector/getPlatformForConnector.js +6 -0
- package/src/lib/utils/functions/getPlatformForConnector/index.d.ts +1 -0
- package/src/lib/utils/functions/index.d.ts +1 -0
- package/src/lib/utils/functions/walletListBuilder/utils/applyMultiWalletFilters/applyMultiWalletFilters.cjs +2 -2
- package/src/lib/utils/functions/walletListBuilder/utils/applyMultiWalletFilters/applyMultiWalletFilters.d.ts +3 -1
- package/src/lib/utils/functions/walletListBuilder/utils/applyMultiWalletFilters/applyMultiWalletFilters.js +2 -2
- package/src/lib/utils/functions/walletListBuilder/utils/staticLinkedWalletFilter/staticLinkedWalletFilter.cjs +5 -12
- package/src/lib/utils/functions/walletListBuilder/utils/staticLinkedWalletFilter/staticLinkedWalletFilter.d.ts +2 -1
- package/src/lib/utils/functions/walletListBuilder/utils/staticLinkedWalletFilter/staticLinkedWalletFilter.js +5 -12
- package/src/lib/utils/functions/walletListBuilder/walletListBuilder.cjs +1 -0
- package/src/lib/utils/functions/walletListBuilder/walletListBuilder.js +1 -0
- package/src/lib/utils/hooks/useIsTurnkeyWallet/useIsTurnkeyWallet.cjs +4 -1
- package/src/lib/utils/hooks/useIsTurnkeyWallet/useIsTurnkeyWallet.d.ts +1 -0
- package/src/lib/utils/hooks/useIsTurnkeyWallet/useIsTurnkeyWallet.js +4 -1
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.cjs +2 -2
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.d.ts +3 -1
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.js +2 -2
- package/src/lib/utils/hooks/useWalletsConnectionState/useWalletsConnectionState.cjs +14 -7
- package/src/lib/utils/hooks/useWalletsConnectionState/useWalletsConnectionState.d.ts +3 -2
- package/src/lib/utils/hooks/useWalletsConnectionState/useWalletsConnectionState.js +14 -7
- package/src/lib/views/SelectHardwareWalletView/SelectHardwareWalletView.cjs +1 -5
- package/src/lib/views/SelectHardwareWalletView/SelectHardwareWalletView.js +2 -6
- package/src/lib/views/WalletGroupView/WalletGroupView.cjs +1 -6
- package/src/lib/views/WalletGroupView/WalletGroupView.js +2 -7
- package/src/lib/widgets/DynamicWidget/prompts/DetectedNewWalletModal/DetectedNewWalletModal.cjs +8 -5
- package/src/lib/widgets/DynamicWidget/prompts/DetectedNewWalletModal/DetectedNewWalletModal.js +8 -5
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/PendingAccountSwitchModal.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/PendingAccountSwitchModal.js +1 -1
- package/src/lib/shared/assets/prompt-account-switch.cjs +0 -64
- package/src/lib/shared/assets/prompt-account-switch.js +0 -40
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var utils = require('@dynamic-labs/utils');
|
|
7
|
+
|
|
8
|
+
const getPlatformForConnector = (connector) => utils.isMobile() || connector.isWalletConnect ? 'mobile' : 'browserExtension';
|
|
9
|
+
|
|
10
|
+
exports.getPlatformForConnector = getPlatformForConnector;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getPlatformForConnector';
|
|
@@ -7,7 +7,7 @@ var filterConnectedWallets = require('../filterConnectedWallets/filterConnectedW
|
|
|
7
7
|
var staticLinkedWalletFilter = require('../staticLinkedWalletFilter/staticLinkedWalletFilter.cjs');
|
|
8
8
|
var filterWalletConnectWallets = require('../filterWalletConnectWallets/filterWalletConnectWallets.cjs');
|
|
9
9
|
|
|
10
|
-
const applyMultiWalletFilters = ({ authMode, userWallets, walletOptions, }) => {
|
|
10
|
+
const applyMultiWalletFilters = ({ authMode, userWallets, walletOptions, walletBook, }) => {
|
|
11
11
|
const walletList = filterWalletConnectWallets.filterWalletConnectWallets({
|
|
12
12
|
userWallets,
|
|
13
13
|
walletOptions,
|
|
@@ -18,7 +18,7 @@ const applyMultiWalletFilters = ({ authMode, userWallets, walletOptions, }) => {
|
|
|
18
18
|
walletOptions: walletList,
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
return staticLinkedWalletFilter.staticWalletFilter(userWallets, walletList);
|
|
21
|
+
return staticLinkedWalletFilter.staticWalletFilter(userWallets, walletList, walletBook);
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
exports.applyMultiWalletFilters = applyMultiWalletFilters;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { WalletBookSchema } from '@dynamic-labs/wallet-book';
|
|
1
2
|
import { AuthModeType, Wallet, WalletOption } from '../../../../../shared';
|
|
2
|
-
export declare const applyMultiWalletFilters: ({ authMode, userWallets, walletOptions, }: {
|
|
3
|
+
export declare const applyMultiWalletFilters: ({ authMode, userWallets, walletOptions, walletBook, }: {
|
|
3
4
|
authMode: AuthModeType;
|
|
4
5
|
userWallets: Wallet[];
|
|
5
6
|
walletOptions: WalletOption[];
|
|
7
|
+
walletBook: WalletBookSchema;
|
|
6
8
|
}) => WalletOption[];
|
|
@@ -3,7 +3,7 @@ import { filterConnectedWallets } from '../filterConnectedWallets/filterConnecte
|
|
|
3
3
|
import { staticWalletFilter } from '../staticLinkedWalletFilter/staticLinkedWalletFilter.js';
|
|
4
4
|
import { filterWalletConnectWallets } from '../filterWalletConnectWallets/filterWalletConnectWallets.js';
|
|
5
5
|
|
|
6
|
-
const applyMultiWalletFilters = ({ authMode, userWallets, walletOptions, }) => {
|
|
6
|
+
const applyMultiWalletFilters = ({ authMode, userWallets, walletOptions, walletBook, }) => {
|
|
7
7
|
const walletList = filterWalletConnectWallets({
|
|
8
8
|
userWallets,
|
|
9
9
|
walletOptions,
|
|
@@ -14,7 +14,7 @@ const applyMultiWalletFilters = ({ authMode, userWallets, walletOptions, }) => {
|
|
|
14
14
|
walletOptions: walletList,
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
|
-
return staticWalletFilter(userWallets, walletList);
|
|
17
|
+
return staticWalletFilter(userWallets, walletList, walletBook);
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
export { applyMultiWalletFilters };
|
|
@@ -3,22 +3,15 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*/
|
|
10
|
-
const staticListToFilter = [
|
|
11
|
-
'xverse',
|
|
12
|
-
'magiceden',
|
|
13
|
-
'magicedenbtc',
|
|
14
|
-
'magicedensol',
|
|
15
|
-
];
|
|
6
|
+
var walletBook = require('@dynamic-labs/wallet-book');
|
|
7
|
+
var getPlatformForConnector = require('../../../getPlatformForConnector/getPlatformForConnector.cjs');
|
|
8
|
+
|
|
16
9
|
/**
|
|
17
10
|
* This function is a helper to filter out wallets that should not appear in the wallet list
|
|
18
11
|
* if they are already linked to the user profile.
|
|
19
12
|
*/
|
|
20
|
-
const staticWalletFilter = (linkedWallets, walletOptions) => walletOptions.filter((walletOption) => {
|
|
21
|
-
if (
|
|
13
|
+
const staticWalletFilter = (linkedWallets, walletOptions, walletBook$1) => walletOptions.filter((walletOption) => {
|
|
14
|
+
if (walletBook.isWalletEventSupported(walletBook.findWalletBookWallet(walletBook$1, walletOption.key), 'accountChanged', getPlatformForConnector.getPlatformForConnector(walletOption.walletConnector))) {
|
|
22
15
|
return true;
|
|
23
16
|
}
|
|
24
17
|
if (linkedWallets.some((wallet) => wallet.connector.key === walletOption.key)) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { WalletBookSchema } from '@dynamic-labs/wallet-book';
|
|
1
2
|
import { Wallet, WalletOption } from '../../../../../shared';
|
|
2
3
|
/**
|
|
3
4
|
* This function is a helper to filter out wallets that should not appear in the wallet list
|
|
4
5
|
* if they are already linked to the user profile.
|
|
5
6
|
*/
|
|
6
|
-
export declare const staticWalletFilter: (linkedWallets: Wallet[], walletOptions: WalletOption[]) => WalletOption[];
|
|
7
|
+
export declare const staticWalletFilter: (linkedWallets: Wallet[], walletOptions: WalletOption[], walletBook: WalletBookSchema) => WalletOption[];
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
const staticListToFilter = [
|
|
7
|
-
'xverse',
|
|
8
|
-
'magiceden',
|
|
9
|
-
'magicedenbtc',
|
|
10
|
-
'magicedensol',
|
|
11
|
-
];
|
|
2
|
+
import { isWalletEventSupported, findWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
3
|
+
import { getPlatformForConnector } from '../../../getPlatformForConnector/getPlatformForConnector.js';
|
|
4
|
+
|
|
12
5
|
/**
|
|
13
6
|
* This function is a helper to filter out wallets that should not appear in the wallet list
|
|
14
7
|
* if they are already linked to the user profile.
|
|
15
8
|
*/
|
|
16
|
-
const staticWalletFilter = (linkedWallets, walletOptions) => walletOptions.filter((walletOption) => {
|
|
17
|
-
if (
|
|
9
|
+
const staticWalletFilter = (linkedWallets, walletOptions, walletBook) => walletOptions.filter((walletOption) => {
|
|
10
|
+
if (isWalletEventSupported(findWalletBookWallet(walletBook, walletOption.key), 'accountChanged', getPlatformForConnector(walletOption.walletConnector))) {
|
|
18
11
|
return true;
|
|
19
12
|
}
|
|
20
13
|
if (linkedWallets.some((wallet) => wallet.connector.key === walletOption.key)) {
|
|
@@ -80,7 +80,7 @@ require('../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCa
|
|
|
80
80
|
var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
81
81
|
|
|
82
82
|
const useIsTurnkeyWallet = () => {
|
|
83
|
-
var _a;
|
|
83
|
+
var _a, _b;
|
|
84
84
|
const { primaryWallet, user } = useInternalDynamicContext.useInternalDynamicContext();
|
|
85
85
|
const wallet = getEOAWallet.getEOAWallet(primaryWallet, (user === null || user === void 0 ? void 0 : user.verifiedCredentials) || []);
|
|
86
86
|
const getTurnkeyVerifiedCredential = () => {
|
|
@@ -119,9 +119,12 @@ const useIsTurnkeyWallet = () => {
|
|
|
119
119
|
isUnclaimedTurnkeyTheSignerOfScw;
|
|
120
120
|
const hasRecoveryEmail = isTurnkeyWallet &&
|
|
121
121
|
Boolean(getUserVerifiedCredentialType.getUserVerifiedCredentialType(user, sdkApiCore.JwtVerifiedCredentialFormatEnum.Email));
|
|
122
|
+
const isSessionKeyCompatible = isTurnkeyWallet &&
|
|
123
|
+
Boolean((_b = turnkeyVerifiedCredential === null || turnkeyVerifiedCredential === void 0 ? void 0 : turnkeyVerifiedCredential.walletProperties) === null || _b === void 0 ? void 0 : _b.isSessionKeyCompatible);
|
|
122
124
|
return {
|
|
123
125
|
hasRecoveryEmail,
|
|
124
126
|
hasTurnkeyVerifiedCredentialAuthenticator,
|
|
127
|
+
isSessionKeyCompatible,
|
|
125
128
|
isTurnkeyWallet,
|
|
126
129
|
isTurnkeyWalletWithoutAuthenticator,
|
|
127
130
|
turnkeyVerifiedCredential,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const useIsTurnkeyWallet: () => {
|
|
2
2
|
hasRecoveryEmail: boolean;
|
|
3
3
|
hasTurnkeyVerifiedCredentialAuthenticator: boolean;
|
|
4
|
+
isSessionKeyCompatible: boolean;
|
|
4
5
|
isTurnkeyWallet: boolean;
|
|
5
6
|
isTurnkeyWalletWithoutAuthenticator: boolean;
|
|
6
7
|
turnkeyVerifiedCredential: import("@dynamic-labs/sdk-api-core").JwtVerifiedCredential | undefined;
|
|
@@ -76,7 +76,7 @@ import '../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCar
|
|
|
76
76
|
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
77
77
|
|
|
78
78
|
const useIsTurnkeyWallet = () => {
|
|
79
|
-
var _a;
|
|
79
|
+
var _a, _b;
|
|
80
80
|
const { primaryWallet, user } = useInternalDynamicContext();
|
|
81
81
|
const wallet = getEOAWallet(primaryWallet, (user === null || user === void 0 ? void 0 : user.verifiedCredentials) || []);
|
|
82
82
|
const getTurnkeyVerifiedCredential = () => {
|
|
@@ -115,9 +115,12 @@ const useIsTurnkeyWallet = () => {
|
|
|
115
115
|
isUnclaimedTurnkeyTheSignerOfScw;
|
|
116
116
|
const hasRecoveryEmail = isTurnkeyWallet &&
|
|
117
117
|
Boolean(getUserVerifiedCredentialType(user, JwtVerifiedCredentialFormatEnum.Email));
|
|
118
|
+
const isSessionKeyCompatible = isTurnkeyWallet &&
|
|
119
|
+
Boolean((_b = turnkeyVerifiedCredential === null || turnkeyVerifiedCredential === void 0 ? void 0 : turnkeyVerifiedCredential.walletProperties) === null || _b === void 0 ? void 0 : _b.isSessionKeyCompatible);
|
|
118
120
|
return {
|
|
119
121
|
hasRecoveryEmail,
|
|
120
122
|
hasTurnkeyVerifiedCredentialAuthenticator,
|
|
123
|
+
isSessionKeyCompatible,
|
|
121
124
|
isTurnkeyWallet,
|
|
122
125
|
isTurnkeyWalletWithoutAuthenticator,
|
|
123
126
|
turnkeyVerifiedCredential,
|
|
@@ -82,7 +82,7 @@ require('../../../views/TransactionConfirmationView/helpers/transactionErrorMess
|
|
|
82
82
|
require('../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
83
83
|
var logVerboseTroubleshootingMessage = require('../../functions/logVerboseTroubleshootingMessage/logVerboseTroubleshootingMessage.cjs');
|
|
84
84
|
|
|
85
|
-
const useWalletConnectors = ({ authMode, connectedWallets, walletConnectorOptions, multiWalletWidgetState, setDesktopUri, setMultiWalletWidgetState, setQrcodeUri, primaryWalletId, setPrimaryWalletId, user, canHaveMultipleWalletsConnected, }) => {
|
|
85
|
+
const useWalletConnectors = ({ authMode, connectedWallets, walletConnectorOptions, multiWalletWidgetState, setDesktopUri, setMultiWalletWidgetState, setQrcodeUri, primaryWalletId, setPrimaryWalletId, user, canHaveMultipleWalletsConnected, walletBook, }) => {
|
|
86
86
|
const [showQrcodeModal, setShowQrcodeModal] = React.useState(false);
|
|
87
87
|
const linkedWallets = React.useMemo(() => {
|
|
88
88
|
if (!user) {
|
|
@@ -125,7 +125,7 @@ const useWalletConnectors = ({ authMode, connectedWallets, walletConnectorOption
|
|
|
125
125
|
React.useEffect(() => walletsBasedOnAuthMode.forEach((wallet) => {
|
|
126
126
|
wallet.connector.initEventListener();
|
|
127
127
|
}), [walletsBasedOnAuthMode]);
|
|
128
|
-
const { connectedWalletsMap, didConnectedStateLoad } = useWalletsConnectionState.useWalletsConnectionState(walletsBasedOnAuthMode);
|
|
128
|
+
const { connectedWalletsMap, didConnectedStateLoad } = useWalletsConnectionState.useWalletsConnectionState(walletsBasedOnAuthMode, walletBook, primaryWalletId, authMode);
|
|
129
129
|
const wallets = React.useMemo(() => walletsBasedOnAuthMode.map((wallet) => (Object.assign(Object.assign({}, wallet), { connected: Boolean(connectedWalletsMap[getWalletIdentifier.getWalletIdentifier(wallet)]) }))), [connectedWalletsMap, walletsBasedOnAuthMode]);
|
|
130
130
|
logVerboseTroubleshootingMessage.logVerboseTroubleshootingMessage('wallets', wallets);
|
|
131
131
|
logVerboseTroubleshootingMessage.logVerboseTroubleshootingMessage('didConnectedStateLoad', didConnectedStateLoad);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Dispatch, SetStateAction } from 'react';
|
|
2
2
|
import { UserProfile } from '@dynamic-labs/types';
|
|
3
|
+
import { WalletBookSchema } from '@dynamic-labs/wallet-book';
|
|
3
4
|
import { AuthModeType, MultiWalletWidgetState, Wallet, WalletOption } from '../../../shared';
|
|
4
5
|
import { MultiWalletWidgetStateSetter } from '../multiWallet';
|
|
5
6
|
type Props = {
|
|
@@ -14,6 +15,7 @@ type Props = {
|
|
|
14
15
|
primaryWalletId: string | undefined;
|
|
15
16
|
user?: UserProfile;
|
|
16
17
|
canHaveMultipleWalletsConnected?: boolean;
|
|
18
|
+
walletBook: WalletBookSchema;
|
|
17
19
|
};
|
|
18
20
|
export interface UseWalletConnectors {
|
|
19
21
|
didConnectedStateLoad: boolean;
|
|
@@ -24,5 +26,5 @@ export interface UseWalletConnectors {
|
|
|
24
26
|
showQrcodeModal: boolean;
|
|
25
27
|
wallets: Wallet[];
|
|
26
28
|
}
|
|
27
|
-
export declare const useWalletConnectors: ({ authMode, connectedWallets, walletConnectorOptions, multiWalletWidgetState, setDesktopUri, setMultiWalletWidgetState, setQrcodeUri, primaryWalletId, setPrimaryWalletId, user, canHaveMultipleWalletsConnected, }: Props) => UseWalletConnectors;
|
|
29
|
+
export declare const useWalletConnectors: ({ authMode, connectedWallets, walletConnectorOptions, multiWalletWidgetState, setDesktopUri, setMultiWalletWidgetState, setQrcodeUri, primaryWalletId, setPrimaryWalletId, user, canHaveMultipleWalletsConnected, walletBook, }: Props) => UseWalletConnectors;
|
|
28
30
|
export {};
|
|
@@ -78,7 +78,7 @@ import '../../../views/TransactionConfirmationView/helpers/transactionErrorMessa
|
|
|
78
78
|
import '../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
79
79
|
import { logVerboseTroubleshootingMessage } from '../../functions/logVerboseTroubleshootingMessage/logVerboseTroubleshootingMessage.js';
|
|
80
80
|
|
|
81
|
-
const useWalletConnectors = ({ authMode, connectedWallets, walletConnectorOptions, multiWalletWidgetState, setDesktopUri, setMultiWalletWidgetState, setQrcodeUri, primaryWalletId, setPrimaryWalletId, user, canHaveMultipleWalletsConnected, }) => {
|
|
81
|
+
const useWalletConnectors = ({ authMode, connectedWallets, walletConnectorOptions, multiWalletWidgetState, setDesktopUri, setMultiWalletWidgetState, setQrcodeUri, primaryWalletId, setPrimaryWalletId, user, canHaveMultipleWalletsConnected, walletBook, }) => {
|
|
82
82
|
const [showQrcodeModal, setShowQrcodeModal] = useState(false);
|
|
83
83
|
const linkedWallets = useMemo(() => {
|
|
84
84
|
if (!user) {
|
|
@@ -121,7 +121,7 @@ const useWalletConnectors = ({ authMode, connectedWallets, walletConnectorOption
|
|
|
121
121
|
useEffect(() => walletsBasedOnAuthMode.forEach((wallet) => {
|
|
122
122
|
wallet.connector.initEventListener();
|
|
123
123
|
}), [walletsBasedOnAuthMode]);
|
|
124
|
-
const { connectedWalletsMap, didConnectedStateLoad } = useWalletsConnectionState(walletsBasedOnAuthMode);
|
|
124
|
+
const { connectedWalletsMap, didConnectedStateLoad } = useWalletsConnectionState(walletsBasedOnAuthMode, walletBook, primaryWalletId, authMode);
|
|
125
125
|
const wallets = useMemo(() => walletsBasedOnAuthMode.map((wallet) => (Object.assign(Object.assign({}, wallet), { connected: Boolean(connectedWalletsMap[getWalletIdentifier(wallet)]) }))), [connectedWalletsMap, walletsBasedOnAuthMode]);
|
|
126
126
|
logVerboseTroubleshootingMessage('wallets', wallets);
|
|
127
127
|
logVerboseTroubleshootingMessage('didConnectedStateLoad', didConnectedStateLoad);
|
|
@@ -6,12 +6,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
6
6
|
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
9
|
+
var walletBook = require('@dynamic-labs/wallet-book');
|
|
9
10
|
require('@dynamic-labs/sdk-api-core');
|
|
10
11
|
require('../../../shared/logger.cjs');
|
|
11
12
|
require('@dynamic-labs/iconic');
|
|
12
13
|
require('react/jsx-runtime');
|
|
13
14
|
require('../../../context/ViewContext/ViewContext.cjs');
|
|
14
|
-
require('@dynamic-labs/wallet-book');
|
|
15
15
|
require('../../constants/colors.cjs');
|
|
16
16
|
require('../../constants/values.cjs');
|
|
17
17
|
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
@@ -73,6 +73,7 @@ require('../../../widgets/DynamicBridgeWidget/views/WalletsView/components/Secon
|
|
|
73
73
|
require('@hcaptcha/react-hcaptcha');
|
|
74
74
|
require('../../../context/FooterAnimationContext/index.cjs');
|
|
75
75
|
require('../../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
76
|
+
var getPlatformForConnector = require('../../functions/getPlatformForConnector/getPlatformForConnector.cjs');
|
|
76
77
|
require('../../../context/MfaSettingsContext/MfaSettingsContext.cjs');
|
|
77
78
|
require('../../../context/IpConfigurationContext/IpConfigurationContext.cjs');
|
|
78
79
|
require('../../../context/PasskeyContext/PasskeyContext.cjs');
|
|
@@ -85,14 +86,17 @@ require('../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCa
|
|
|
85
86
|
* For the given wallet array, this returns an object mapping from each wallet's
|
|
86
87
|
* identifier to whether its connector recognizes it as currently connected or not.
|
|
87
88
|
*/
|
|
88
|
-
const getConnectedWalletsMap = (wallets) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
89
|
+
const getConnectedWalletsMap = (wallets, walletBook$1, primaryWalletId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
89
90
|
const newMap = {};
|
|
90
|
-
yield Promise.all(wallets
|
|
91
|
+
yield Promise.all(wallets
|
|
92
|
+
.filter((wallet) => wallet.id === primaryWalletId ||
|
|
93
|
+
walletBook.isWalletMethodSupported(walletBook.findWalletBookWallet(walletBook$1, wallet.key), 'getConnectedAccounts', getPlatformForConnector.getPlatformForConnector(wallet.connector)))
|
|
94
|
+
.map((wallet) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
91
95
|
newMap[getWalletIdentifier.getWalletIdentifier(wallet)] = yield isWalletConnected.isWalletConnected(wallet);
|
|
92
96
|
})));
|
|
93
97
|
return newMap;
|
|
94
98
|
});
|
|
95
|
-
const useWalletsConnectionState = (wallets) => {
|
|
99
|
+
const useWalletsConnectionState = (wallets, walletBook, primaryWalletId, authMode) => {
|
|
96
100
|
const [connectedWalletsMap, setConnectedWalletsMap] = React.useState({});
|
|
97
101
|
/**
|
|
98
102
|
* Whether the connection map has been loaded off of the current wallet array.
|
|
@@ -109,7 +113,7 @@ const useWalletsConnectionState = (wallets) => {
|
|
|
109
113
|
const incomingWalletSwitchAddress = React.useRef(undefined);
|
|
110
114
|
const computeConnectedStateForWallets = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
111
115
|
didConnectedStateLoad.current = false;
|
|
112
|
-
const newMap = yield getConnectedWalletsMap(wallets);
|
|
116
|
+
const newMap = yield getConnectedWalletsMap(wallets, walletBook, primaryWalletId);
|
|
113
117
|
if (Object.values(newMap).length === 0) {
|
|
114
118
|
setConnectedWalletsMap({});
|
|
115
119
|
return;
|
|
@@ -125,7 +129,7 @@ const useWalletsConnectionState = (wallets) => {
|
|
|
125
129
|
return;
|
|
126
130
|
}
|
|
127
131
|
setConnectedWalletsMap(newMap);
|
|
128
|
-
}), [wallets]);
|
|
132
|
+
}), [primaryWalletId, walletBook, wallets]);
|
|
129
133
|
/** A string that is unique for each possible value of the wallets prop */
|
|
130
134
|
const walletsHash = wallets.map(getWalletIdentifier.getWalletIdentifier).join('-');
|
|
131
135
|
const connectors = wallets.map(({ connector }) => connector);
|
|
@@ -142,6 +146,9 @@ const useWalletsConnectionState = (wallets) => {
|
|
|
142
146
|
useWalletConnectorEvent.useWalletConnectorEvent(connectors, 'accountChange', onAccountChange);
|
|
143
147
|
useWalletConnectorEvent.useWalletConnectorEvent(connectors, 'disconnect', handleEvent);
|
|
144
148
|
useWalletConnectorEvent.useWalletConnectorEvent(connectors, 'chainChange', handleEvent);
|
|
149
|
+
const computeConnectedStateKey = authMode === 'connect-and-sign'
|
|
150
|
+
? `${primaryWalletId}-${walletsHash}`
|
|
151
|
+
: walletsHash;
|
|
145
152
|
React.useEffect(() => {
|
|
146
153
|
computeConnectedStateForWallets();
|
|
147
154
|
},
|
|
@@ -150,7 +157,7 @@ const useWalletsConnectionState = (wallets) => {
|
|
|
150
157
|
* wallets change.
|
|
151
158
|
*/
|
|
152
159
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
153
|
-
[
|
|
160
|
+
[computeConnectedStateKey]);
|
|
154
161
|
/**
|
|
155
162
|
* This is a workaround to detect when the user switches to another tab/extension
|
|
156
163
|
* and then comes back to the dapp.
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { MutableRefObject } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { WalletBookSchema } from '@dynamic-labs/wallet-book';
|
|
3
|
+
import { AuthModeType, Wallet } from '../../../shared';
|
|
3
4
|
type ConnectedWalletsMap = {
|
|
4
5
|
[address: string]: boolean;
|
|
5
6
|
};
|
|
6
|
-
type WalletsConnectionStateHook = (wallets: Wallet[]) => {
|
|
7
|
+
type WalletsConnectionStateHook = (wallets: Wallet[], walletBook: WalletBookSchema, primaryWalletId: string | undefined, authMode: AuthModeType) => {
|
|
7
8
|
connectedWalletsMap: ConnectedWalletsMap;
|
|
8
9
|
didConnectedStateLoad: MutableRefObject<boolean>;
|
|
9
10
|
};
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
3
|
import { useState, useRef, useCallback, useEffect } from 'react';
|
|
4
4
|
import { isSameAddress } from '@dynamic-labs/wallet-connector-core';
|
|
5
|
+
import { isWalletMethodSupported, findWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
5
6
|
import '@dynamic-labs/sdk-api-core';
|
|
6
7
|
import '../../../shared/logger.js';
|
|
7
8
|
import '@dynamic-labs/iconic';
|
|
8
9
|
import 'react/jsx-runtime';
|
|
9
10
|
import '../../../context/ViewContext/ViewContext.js';
|
|
10
|
-
import '@dynamic-labs/wallet-book';
|
|
11
11
|
import '../../constants/colors.js';
|
|
12
12
|
import '../../constants/values.js';
|
|
13
13
|
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
@@ -69,6 +69,7 @@ import '../../../widgets/DynamicBridgeWidget/views/WalletsView/components/Second
|
|
|
69
69
|
import '@hcaptcha/react-hcaptcha';
|
|
70
70
|
import '../../../context/FooterAnimationContext/index.js';
|
|
71
71
|
import '../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
72
|
+
import { getPlatformForConnector } from '../../functions/getPlatformForConnector/getPlatformForConnector.js';
|
|
72
73
|
import '../../../context/MfaSettingsContext/MfaSettingsContext.js';
|
|
73
74
|
import '../../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
74
75
|
import '../../../context/PasskeyContext/PasskeyContext.js';
|
|
@@ -81,14 +82,17 @@ import '../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCar
|
|
|
81
82
|
* For the given wallet array, this returns an object mapping from each wallet's
|
|
82
83
|
* identifier to whether its connector recognizes it as currently connected or not.
|
|
83
84
|
*/
|
|
84
|
-
const getConnectedWalletsMap = (wallets) => __awaiter(void 0, void 0, void 0, function* () {
|
|
85
|
+
const getConnectedWalletsMap = (wallets, walletBook, primaryWalletId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
85
86
|
const newMap = {};
|
|
86
|
-
yield Promise.all(wallets
|
|
87
|
+
yield Promise.all(wallets
|
|
88
|
+
.filter((wallet) => wallet.id === primaryWalletId ||
|
|
89
|
+
isWalletMethodSupported(findWalletBookWallet(walletBook, wallet.key), 'getConnectedAccounts', getPlatformForConnector(wallet.connector)))
|
|
90
|
+
.map((wallet) => __awaiter(void 0, void 0, void 0, function* () {
|
|
87
91
|
newMap[getWalletIdentifier(wallet)] = yield isWalletConnected(wallet);
|
|
88
92
|
})));
|
|
89
93
|
return newMap;
|
|
90
94
|
});
|
|
91
|
-
const useWalletsConnectionState = (wallets) => {
|
|
95
|
+
const useWalletsConnectionState = (wallets, walletBook, primaryWalletId, authMode) => {
|
|
92
96
|
const [connectedWalletsMap, setConnectedWalletsMap] = useState({});
|
|
93
97
|
/**
|
|
94
98
|
* Whether the connection map has been loaded off of the current wallet array.
|
|
@@ -105,7 +109,7 @@ const useWalletsConnectionState = (wallets) => {
|
|
|
105
109
|
const incomingWalletSwitchAddress = useRef(undefined);
|
|
106
110
|
const computeConnectedStateForWallets = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
107
111
|
didConnectedStateLoad.current = false;
|
|
108
|
-
const newMap = yield getConnectedWalletsMap(wallets);
|
|
112
|
+
const newMap = yield getConnectedWalletsMap(wallets, walletBook, primaryWalletId);
|
|
109
113
|
if (Object.values(newMap).length === 0) {
|
|
110
114
|
setConnectedWalletsMap({});
|
|
111
115
|
return;
|
|
@@ -121,7 +125,7 @@ const useWalletsConnectionState = (wallets) => {
|
|
|
121
125
|
return;
|
|
122
126
|
}
|
|
123
127
|
setConnectedWalletsMap(newMap);
|
|
124
|
-
}), [wallets]);
|
|
128
|
+
}), [primaryWalletId, walletBook, wallets]);
|
|
125
129
|
/** A string that is unique for each possible value of the wallets prop */
|
|
126
130
|
const walletsHash = wallets.map(getWalletIdentifier).join('-');
|
|
127
131
|
const connectors = wallets.map(({ connector }) => connector);
|
|
@@ -138,6 +142,9 @@ const useWalletsConnectionState = (wallets) => {
|
|
|
138
142
|
useWalletConnectorEvent(connectors, 'accountChange', onAccountChange);
|
|
139
143
|
useWalletConnectorEvent(connectors, 'disconnect', handleEvent);
|
|
140
144
|
useWalletConnectorEvent(connectors, 'chainChange', handleEvent);
|
|
145
|
+
const computeConnectedStateKey = authMode === 'connect-and-sign'
|
|
146
|
+
? `${primaryWalletId}-${walletsHash}`
|
|
147
|
+
: walletsHash;
|
|
141
148
|
useEffect(() => {
|
|
142
149
|
computeConnectedStateForWallets();
|
|
143
150
|
},
|
|
@@ -146,7 +153,7 @@ const useWalletsConnectionState = (wallets) => {
|
|
|
146
153
|
* wallets change.
|
|
147
154
|
*/
|
|
148
155
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
149
|
-
[
|
|
156
|
+
[computeConnectedStateKey]);
|
|
150
157
|
/**
|
|
151
158
|
* This is a workaround to detect when the user switches to another tab/extension
|
|
152
159
|
* and then comes back to the dapp.
|
|
@@ -82,12 +82,8 @@ require('../../context/IpConfigurationContext/IpConfigurationContext.cjs');
|
|
|
82
82
|
var HardwareWalletToggle = require('../../components/HardwareWalletToggle/HardwareWalletToggle.cjs');
|
|
83
83
|
|
|
84
84
|
const SelectHardwareWalletView = ({ wallet, onSelectWallet, }) => {
|
|
85
|
-
var _a;
|
|
86
85
|
const { t } = reactI18next.useTranslation();
|
|
87
|
-
|
|
88
|
-
return (jsxRuntime.jsx("div", { className: 'select-hardware-wallet-view', children: jsxRuntime.jsxs("div", { className: 'select-hardware-wallet-view__container', children: [jsxRuntime.jsx(Icon.Icon, { className: 'select-hardware-wallet-view__icon', children: jsxRuntime.jsx(walletBook.WalletIcon, { walletKey: wallet.key }) }), jsxRuntime.jsx(Typography.Typography, { className: 'select-hardware-wallet-view__text', as: 'p', color: 'secondary', variant: 'body_normal', copykey: 'dyn_select_hardware_wallet.description', children: t('dyn_select_hardware_wallet.description') }), walletConnectorCore.isHardwareWalletConnector(wallet.walletConnector) && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(HardwareWalletToggle.HardwareWalletToggle, { connectors: [wallet.walletConnector], copykey: 'dyn_select_chain.using_hardware_wallet_toggle_label', label: t('dyn_select_chain.using_hardware_wallet_toggle_label', {
|
|
89
|
-
chainName,
|
|
90
|
-
}) }), jsxRuntime.jsx(Divider.Divider, {})] })), jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonVariant: 'primary', onClick: () => onSelectWallet === null || onSelectWallet === void 0 ? void 0 : onSelectWallet(wallet), copykey: 'dyn_select_hardware_wallet.button', dataTestId: 'select-hardware-wallet-connect-button', children: t('dyn_select_hardware_wallet.button') })] }) }));
|
|
86
|
+
return (jsxRuntime.jsx("div", { className: 'select-hardware-wallet-view', children: jsxRuntime.jsxs("div", { className: 'select-hardware-wallet-view__container', children: [jsxRuntime.jsx(Icon.Icon, { className: 'select-hardware-wallet-view__icon', children: jsxRuntime.jsx(walletBook.WalletIcon, { walletKey: wallet.key }) }), jsxRuntime.jsx(Typography.Typography, { className: 'select-hardware-wallet-view__text', as: 'p', color: 'secondary', variant: 'body_normal', copykey: 'dyn_select_hardware_wallet.description', children: t('dyn_select_hardware_wallet.description') }), walletConnectorCore.isHardwareWalletConnector(wallet.walletConnector) && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(HardwareWalletToggle.HardwareWalletToggle, { connectors: [wallet.walletConnector], copykey: 'dyn_select_chain.using_hardware_wallet_toggle_label', label: t('dyn_select_chain.using_hardware_wallet_toggle_label') }), jsxRuntime.jsx(Divider.Divider, {})] })), jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonVariant: 'primary', onClick: () => onSelectWallet === null || onSelectWallet === void 0 ? void 0 : onSelectWallet(wallet), copykey: 'dyn_select_hardware_wallet.button', dataTestId: 'select-hardware-wallet-connect-button', children: t('dyn_select_hardware_wallet.button') })] }) }));
|
|
91
87
|
};
|
|
92
88
|
|
|
93
89
|
exports.SelectHardwareWalletView = SelectHardwareWalletView;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import { WalletIcon } from '@dynamic-labs/wallet-book';
|
|
5
|
-
import {
|
|
5
|
+
import { isHardwareWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
6
6
|
import '../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
7
7
|
import '../../components/Alert/Alert.js';
|
|
8
8
|
import 'react';
|
|
@@ -78,12 +78,8 @@ import '../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
|
78
78
|
import { HardwareWalletToggle } from '../../components/HardwareWalletToggle/HardwareWalletToggle.js';
|
|
79
79
|
|
|
80
80
|
const SelectHardwareWalletView = ({ wallet, onSelectWallet, }) => {
|
|
81
|
-
var _a;
|
|
82
81
|
const { t } = useTranslation();
|
|
83
|
-
|
|
84
|
-
return (jsx("div", { className: 'select-hardware-wallet-view', children: jsxs("div", { className: 'select-hardware-wallet-view__container', children: [jsx(Icon, { className: 'select-hardware-wallet-view__icon', children: jsx(WalletIcon, { walletKey: wallet.key }) }), jsx(Typography, { className: 'select-hardware-wallet-view__text', as: 'p', color: 'secondary', variant: 'body_normal', copykey: 'dyn_select_hardware_wallet.description', children: t('dyn_select_hardware_wallet.description') }), isHardwareWalletConnector(wallet.walletConnector) && (jsxs(Fragment, { children: [jsx(HardwareWalletToggle, { connectors: [wallet.walletConnector], copykey: 'dyn_select_chain.using_hardware_wallet_toggle_label', label: t('dyn_select_chain.using_hardware_wallet_toggle_label', {
|
|
85
|
-
chainName,
|
|
86
|
-
}) }), jsx(Divider, {})] })), jsx(TypographyButton, { buttonVariant: 'primary', onClick: () => onSelectWallet === null || onSelectWallet === void 0 ? void 0 : onSelectWallet(wallet), copykey: 'dyn_select_hardware_wallet.button', dataTestId: 'select-hardware-wallet-connect-button', children: t('dyn_select_hardware_wallet.button') })] }) }));
|
|
82
|
+
return (jsx("div", { className: 'select-hardware-wallet-view', children: jsxs("div", { className: 'select-hardware-wallet-view__container', children: [jsx(Icon, { className: 'select-hardware-wallet-view__icon', children: jsx(WalletIcon, { walletKey: wallet.key }) }), jsx(Typography, { className: 'select-hardware-wallet-view__text', as: 'p', color: 'secondary', variant: 'body_normal', copykey: 'dyn_select_hardware_wallet.description', children: t('dyn_select_hardware_wallet.description') }), isHardwareWalletConnector(wallet.walletConnector) && (jsxs(Fragment, { children: [jsx(HardwareWalletToggle, { connectors: [wallet.walletConnector], copykey: 'dyn_select_chain.using_hardware_wallet_toggle_label', label: t('dyn_select_chain.using_hardware_wallet_toggle_label') }), jsx(Divider, {})] })), jsx(TypographyButton, { buttonVariant: 'primary', onClick: () => onSelectWallet === null || onSelectWallet === void 0 ? void 0 : onSelectWallet(wallet), copykey: 'dyn_select_hardware_wallet.button', dataTestId: 'select-hardware-wallet-connect-button', children: t('dyn_select_hardware_wallet.button') })] }) }));
|
|
87
83
|
};
|
|
88
84
|
|
|
89
85
|
export { SelectHardwareWalletView };
|
|
@@ -82,7 +82,6 @@ require('../TransactionConfirmationView/helpers/transactionErrorMessage.cjs');
|
|
|
82
82
|
require('../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
83
83
|
|
|
84
84
|
const WalletGroupView = () => {
|
|
85
|
-
var _a, _b;
|
|
86
85
|
const { selectedWalletGroup } = WalletGroupContext.useWalletGroupContext();
|
|
87
86
|
const { walletBook: walletBook$1 } = walletBook.useWalletBookContext();
|
|
88
87
|
const { handleWalletItemClick } = useWalletItemActions.useWalletItemActions();
|
|
@@ -94,11 +93,7 @@ const WalletGroupView = () => {
|
|
|
94
93
|
.map(({ walletConnector }) => walletConnector)
|
|
95
94
|
.filter(walletConnectorCore.isHardwareWalletConnector)
|
|
96
95
|
.filter((connector) => connector.canConnectWithHardwareWallet());
|
|
97
|
-
|
|
98
|
-
const chainName = hardwareConnectedChain && ((_b = walletConnectorCore.getChainInfo(hardwareConnectedChain)) === null || _b === void 0 ? void 0 : _b.displayName);
|
|
99
|
-
return (jsxRuntime.jsx(WalletGroupViewLayout.WalletGroupViewLayout, { icon: jsxRuntime.jsx(walletBook.WalletIcon, { walletKey: walletBookData.key }), title: t('dyn_select_chain.description'), titleCopyKey: 'dyn_select_chain.description', children: jsxRuntime.jsxs("div", { className: 'wallet-group__list', children: [Boolean(hardwareWalletConnectors.length) && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(HardwareWalletToggle.HardwareWalletToggle, { connectors: hardwareWalletConnectors, copykey: 'dyn_select_chain.using_hardware_wallet_toggle_label', label: t('dyn_select_chain.using_hardware_wallet_toggle_label', {
|
|
100
|
-
chainName,
|
|
101
|
-
}) }), jsxRuntime.jsx(Divider.Divider, {})] })), jsxRuntime.jsx("div", { className: 'wallet-group-view-layout__list', children: selectedWalletGroup.groupedWallets.map((wallet, index) => (jsxRuntime.jsx(WalletGroupItem.WalletGroupItem, { wallet: wallet, onClick: () => handleWalletItemClick(wallet) }, `${wallet.key}_${index}`))) })] }) }));
|
|
96
|
+
return (jsxRuntime.jsx(WalletGroupViewLayout.WalletGroupViewLayout, { icon: jsxRuntime.jsx(walletBook.WalletIcon, { walletKey: walletBookData.key }), title: t('dyn_select_chain.description'), titleCopyKey: 'dyn_select_chain.description', children: jsxRuntime.jsxs("div", { className: 'wallet-group__list', children: [Boolean(hardwareWalletConnectors.length) && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(HardwareWalletToggle.HardwareWalletToggle, { connectors: hardwareWalletConnectors, copykey: 'dyn_select_chain.using_hardware_wallet_toggle_label', label: t('dyn_select_chain.using_hardware_wallet_toggle_label') }), jsxRuntime.jsx(Divider.Divider, {})] })), jsxRuntime.jsx("div", { className: 'wallet-group-view-layout__list', children: selectedWalletGroup.groupedWallets.map((wallet, index) => (jsxRuntime.jsx(WalletGroupItem.WalletGroupItem, { wallet: wallet, onClick: () => handleWalletItemClick(wallet) }, `${wallet.key}_${index}`))) })] }) }));
|
|
102
97
|
};
|
|
103
98
|
|
|
104
99
|
exports.WalletGroupView = WalletGroupView;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import { useWalletBookContext, getWalletGroup, WalletIcon } from '@dynamic-labs/wallet-book';
|
|
5
|
-
import { isHardwareWalletConnector
|
|
5
|
+
import { isHardwareWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
6
6
|
import { useWalletGroupContext } from '../../context/WalletGroupContext/WalletGroupContext.js';
|
|
7
7
|
import 'react';
|
|
8
8
|
import '../../events/dynamicEvents.js';
|
|
@@ -78,7 +78,6 @@ import '../TransactionConfirmationView/helpers/transactionErrorMessage.js';
|
|
|
78
78
|
import '../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
79
79
|
|
|
80
80
|
const WalletGroupView = () => {
|
|
81
|
-
var _a, _b;
|
|
82
81
|
const { selectedWalletGroup } = useWalletGroupContext();
|
|
83
82
|
const { walletBook } = useWalletBookContext();
|
|
84
83
|
const { handleWalletItemClick } = useWalletItemActions();
|
|
@@ -90,11 +89,7 @@ const WalletGroupView = () => {
|
|
|
90
89
|
.map(({ walletConnector }) => walletConnector)
|
|
91
90
|
.filter(isHardwareWalletConnector)
|
|
92
91
|
.filter((connector) => connector.canConnectWithHardwareWallet());
|
|
93
|
-
|
|
94
|
-
const chainName = hardwareConnectedChain && ((_b = getChainInfo(hardwareConnectedChain)) === null || _b === void 0 ? void 0 : _b.displayName);
|
|
95
|
-
return (jsx(WalletGroupViewLayout, { icon: jsx(WalletIcon, { walletKey: walletBookData.key }), title: t('dyn_select_chain.description'), titleCopyKey: 'dyn_select_chain.description', children: jsxs("div", { className: 'wallet-group__list', children: [Boolean(hardwareWalletConnectors.length) && (jsxs(Fragment, { children: [jsx(HardwareWalletToggle, { connectors: hardwareWalletConnectors, copykey: 'dyn_select_chain.using_hardware_wallet_toggle_label', label: t('dyn_select_chain.using_hardware_wallet_toggle_label', {
|
|
96
|
-
chainName,
|
|
97
|
-
}) }), jsx(Divider, {})] })), jsx("div", { className: 'wallet-group-view-layout__list', children: selectedWalletGroup.groupedWallets.map((wallet, index) => (jsx(WalletGroupItem, { wallet: wallet, onClick: () => handleWalletItemClick(wallet) }, `${wallet.key}_${index}`))) })] }) }));
|
|
92
|
+
return (jsx(WalletGroupViewLayout, { icon: jsx(WalletIcon, { walletKey: walletBookData.key }), title: t('dyn_select_chain.description'), titleCopyKey: 'dyn_select_chain.description', children: jsxs("div", { className: 'wallet-group__list', children: [Boolean(hardwareWalletConnectors.length) && (jsxs(Fragment, { children: [jsx(HardwareWalletToggle, { connectors: hardwareWalletConnectors, copykey: 'dyn_select_chain.using_hardware_wallet_toggle_label', label: t('dyn_select_chain.using_hardware_wallet_toggle_label') }), jsx(Divider, {})] })), jsx("div", { className: 'wallet-group-view-layout__list', children: selectedWalletGroup.groupedWallets.map((wallet, index) => (jsx(WalletGroupItem, { wallet: wallet, onClick: () => handleWalletItemClick(wallet) }, `${wallet.key}_${index}`))) })] }) }));
|
|
98
93
|
};
|
|
99
94
|
|
|
100
95
|
export { WalletGroupView };
|