@dynamic-labs/sdk-react-core 3.1.3 → 3.1.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 +12 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +10 -10
- package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.cjs +11 -1
- package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.js +12 -2
- package/src/lib/modals/SendBalanceModal/SendBalanceModal.cjs +5 -5
- package/src/lib/modals/SendBalanceModal/SendBalanceModal.js +5 -5
- package/src/lib/utils/functions/getWalletConnectorForWallet/getWalletConnectorForWallet.cjs +24 -0
- package/src/lib/utils/functions/getWalletConnectorForWallet/getWalletConnectorForWallet.js +20 -0
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +5 -3
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +5 -3
- package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.cjs +9 -0
- package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.js +10 -1
- package/src/lib/utils/hooks/useWalletConnectors/utils/createLinkedWalletsFromWalletOptions/createLinkedWalletsFromWalletOptions.cjs +9 -2
- package/src/lib/utils/hooks/useWalletConnectors/utils/createLinkedWalletsFromWalletOptions/createLinkedWalletsFromWalletOptions.js +10 -3
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.cjs +0 -14
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.js +0 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
|
|
2
|
+
### [3.1.4](https://github.com/dynamic-labs/DynamicAuth/compare/v3.1.3...v3.1.4) (2024-09-30)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* add popper context to send balance ([#7017](https://github.com/dynamic-labs/DynamicAuth/issues/7017)) ([bedcc5e](https://github.com/dynamic-labs/DynamicAuth/commit/bedcc5ec005267b7fa40a2020bc9fef6e2e09714))
|
|
8
|
+
* add retry to useConnectWithOtp ([#7013](https://github.com/dynamic-labs/DynamicAuth/issues/7013)) ([4d3455a](https://github.com/dynamic-labs/DynamicAuth/commit/4d3455a5ead6585ec309ff32294f392154900d73))
|
|
9
|
+
* don't re-fetch wallet address on network change ([#7023](https://github.com/dynamic-labs/DynamicAuth/issues/7023)) ([d23b716](https://github.com/dynamic-labs/DynamicAuth/commit/d23b71608af8b6b75b015efdfcb8bea34602dc6a))
|
|
10
|
+
* fix sign message with solana wallet standard provider ([#7015](https://github.com/dynamic-labs/DynamicAuth/issues/7015)) ([b575622](https://github.com/dynamic-labs/DynamicAuth/commit/b575622d7ec8b3dc61049acb592b7c7fa458ec61))
|
|
11
|
+
* persist isHardwareWalletEnabled on wallet connector ([#7025](https://github.com/dynamic-labs/DynamicAuth/issues/7025)) ([7ed7832](https://github.com/dynamic-labs/DynamicAuth/commit/7ed7832235ecafe8172a16528d428f7c03485064))
|
|
12
|
+
* update wallet reference when user switches wallet in connect-only ([#7031](https://github.com/dynamic-labs/DynamicAuth/issues/7031)) ([031515f](https://github.com/dynamic-labs/DynamicAuth/commit/031515fc6c785facbbc95d2f65d58551559334e6))
|
|
13
|
+
|
|
2
14
|
### [3.1.3](https://github.com/dynamic-labs/DynamicAuth/compare/v3.1.2...v3.1.3) (2024-09-25)
|
|
3
15
|
|
|
4
16
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
|
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
"react-i18next": "13.5.0",
|
|
18
18
|
"yup": "0.32.11",
|
|
19
19
|
"react-international-phone": "4.2.5",
|
|
20
|
-
"@dynamic-labs/iconic": "3.1.
|
|
21
|
-
"@dynamic-labs/logger": "3.1.
|
|
22
|
-
"@dynamic-labs/multi-wallet": "3.1.
|
|
23
|
-
"@dynamic-labs/rpc-providers": "3.1.
|
|
24
|
-
"@dynamic-labs/store": "3.1.
|
|
25
|
-
"@dynamic-labs/types": "3.1.
|
|
26
|
-
"@dynamic-labs/utils": "3.1.
|
|
27
|
-
"@dynamic-labs/wallet-book": "3.1.
|
|
28
|
-
"@dynamic-labs/wallet-connector-core": "3.1.
|
|
20
|
+
"@dynamic-labs/iconic": "3.1.4",
|
|
21
|
+
"@dynamic-labs/logger": "3.1.4",
|
|
22
|
+
"@dynamic-labs/multi-wallet": "3.1.4",
|
|
23
|
+
"@dynamic-labs/rpc-providers": "3.1.4",
|
|
24
|
+
"@dynamic-labs/store": "3.1.4",
|
|
25
|
+
"@dynamic-labs/types": "3.1.4",
|
|
26
|
+
"@dynamic-labs/utils": "3.1.4",
|
|
27
|
+
"@dynamic-labs/wallet-book": "3.1.4",
|
|
28
|
+
"@dynamic-labs/wallet-connector-core": "3.1.4",
|
|
29
29
|
"eventemitter3": "5.0.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
@@ -27,11 +27,21 @@ require('../../../store/state/projectSettings/projectSettings.cjs');
|
|
|
27
27
|
require('../../../locale/locale.cjs');
|
|
28
28
|
|
|
29
29
|
const createEmailHandler = (environmentId, { shouldRegisterSessionKeysOnSignin, generateSessionKey, }) => (email$1) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
-
const
|
|
30
|
+
const createEmailVerificationResponse = yield email.createEmailVerification({
|
|
31
31
|
email: email$1,
|
|
32
32
|
environmentId,
|
|
33
33
|
});
|
|
34
|
+
let { verificationUUID } = createEmailVerificationResponse;
|
|
34
35
|
return {
|
|
36
|
+
retry: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
const retryEmailVerificationResponse = yield email.retryEmailVerification({
|
|
38
|
+
email: email$1,
|
|
39
|
+
environmentId,
|
|
40
|
+
verificationUUID,
|
|
41
|
+
});
|
|
42
|
+
// eslint-disable-next-line prefer-destructuring
|
|
43
|
+
verificationUUID = retryEmailVerificationResponse.verificationUUID;
|
|
44
|
+
}),
|
|
35
45
|
type: 'email',
|
|
36
46
|
verify: (oneTimePassword) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
37
47
|
let sessionPublicKey = undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
-
import { createEmailVerification, signInWithEmailVerification } from '../../../data/api/email/email.js';
|
|
3
|
+
import { createEmailVerification, retryEmailVerification, signInWithEmailVerification } from '../../../data/api/email/email.js';
|
|
4
4
|
import '@dynamic-labs/sdk-api-core';
|
|
5
5
|
import '@dynamic-labs/utils';
|
|
6
6
|
import '../../../shared/logger.js';
|
|
@@ -23,11 +23,21 @@ import '../../../store/state/projectSettings/projectSettings.js';
|
|
|
23
23
|
import '../../../locale/locale.js';
|
|
24
24
|
|
|
25
25
|
const createEmailHandler = (environmentId, { shouldRegisterSessionKeysOnSignin, generateSessionKey, }) => (email) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
-
const
|
|
26
|
+
const createEmailVerificationResponse = yield createEmailVerification({
|
|
27
27
|
email,
|
|
28
28
|
environmentId,
|
|
29
29
|
});
|
|
30
|
+
let { verificationUUID } = createEmailVerificationResponse;
|
|
30
31
|
return {
|
|
32
|
+
retry: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
+
const retryEmailVerificationResponse = yield retryEmailVerification({
|
|
34
|
+
email,
|
|
35
|
+
environmentId,
|
|
36
|
+
verificationUUID,
|
|
37
|
+
});
|
|
38
|
+
// eslint-disable-next-line prefer-destructuring
|
|
39
|
+
verificationUUID = retryEmailVerificationResponse.verificationUUID;
|
|
40
|
+
}),
|
|
31
41
|
type: 'email',
|
|
32
42
|
verify: (oneTimePassword) => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
43
|
let sessionPublicKey = undefined;
|
|
@@ -79,7 +79,7 @@ require('../../components/IsBrowser/IsBrowser.cjs');
|
|
|
79
79
|
require('../../context/WidgetRegistry/WidgetRegistryContextProvider.cjs');
|
|
80
80
|
require('../../context/FundingContext/FundingContext.cjs');
|
|
81
81
|
require('../../components/Popper/Popper/Popper.cjs');
|
|
82
|
-
require('../../components/Popper/PopperContext/PopperContext.cjs');
|
|
82
|
+
var PopperContext = require('../../components/Popper/PopperContext/PopperContext.cjs');
|
|
83
83
|
require('../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
84
84
|
require('@hcaptcha/react-hcaptcha');
|
|
85
85
|
require('../../context/IpConfigurationContext/IpConfigurationContext.cjs');
|
|
@@ -112,10 +112,10 @@ const SendBalanceModal = ({ initialRecipientAddress, initialValue, onReject, onS
|
|
|
112
112
|
};
|
|
113
113
|
return (jsxRuntime.jsx(Portal.Portal, { handleClose: closeModal, isShown: show, zIndex: index.authModalZIndex, withBackdrop: true, elementId: 'dynamic-send-balance', transitionEvents: {
|
|
114
114
|
onUnmount: handleOnModalUnmount,
|
|
115
|
-
}, children: jsxRuntime.jsx(Modal.Modal, { children: jsxRuntime.jsx(ModalCard.ModalCard, { children: jsxRuntime.jsx(VerticalDrawerTransition.VerticalDrawerTransition, { isShown: true, children: jsxRuntime.jsx(SendBalanceView.SendBalanceView, { initialRecipientAddress: initialRecipientAddress, initialValue: initialValue, onError: (error) => (errorRef.current = error), onClickClose: closeModal, onDone: closeModal, displayPoweredByDynamicFooter: true, onSuccess: (receipt) => {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
115
|
+
}, children: jsxRuntime.jsx(Modal.Modal, { children: jsxRuntime.jsx(ModalCard.ModalCard, { children: jsxRuntime.jsx(VerticalDrawerTransition.VerticalDrawerTransition, { isShown: true, children: jsxRuntime.jsx(PopperContext.PopperProvider, { children: jsxRuntime.jsx(SendBalanceView.SendBalanceView, { initialRecipientAddress: initialRecipientAddress, initialValue: initialValue, onError: (error) => (errorRef.current = error), onClickClose: closeModal, onDone: closeModal, displayPoweredByDynamicFooter: true, onSuccess: (receipt) => {
|
|
116
|
+
errorRef.current = null;
|
|
117
|
+
receiptRef.current = receipt;
|
|
118
|
+
} }) }) }) }) }) }));
|
|
119
119
|
};
|
|
120
120
|
|
|
121
121
|
exports.SendBalanceModal = SendBalanceModal;
|
|
@@ -75,7 +75,7 @@ import '../../components/IsBrowser/IsBrowser.js';
|
|
|
75
75
|
import '../../context/WidgetRegistry/WidgetRegistryContextProvider.js';
|
|
76
76
|
import '../../context/FundingContext/FundingContext.js';
|
|
77
77
|
import '../../components/Popper/Popper/Popper.js';
|
|
78
|
-
import '../../components/Popper/PopperContext/PopperContext.js';
|
|
78
|
+
import { PopperProvider } from '../../components/Popper/PopperContext/PopperContext.js';
|
|
79
79
|
import '../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
80
80
|
import '@hcaptcha/react-hcaptcha';
|
|
81
81
|
import '../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
@@ -108,10 +108,10 @@ const SendBalanceModal = ({ initialRecipientAddress, initialValue, onReject, onS
|
|
|
108
108
|
};
|
|
109
109
|
return (jsx(Portal, { handleClose: closeModal, isShown: show, zIndex: authModalZIndex, withBackdrop: true, elementId: 'dynamic-send-balance', transitionEvents: {
|
|
110
110
|
onUnmount: handleOnModalUnmount,
|
|
111
|
-
}, children: jsx(Modal, { children: jsx(ModalCard, { children: jsx(VerticalDrawerTransition, { isShown: true, children: jsx(SendBalanceView, { initialRecipientAddress: initialRecipientAddress, initialValue: initialValue, onError: (error) => (errorRef.current = error), onClickClose: closeModal, onDone: closeModal, displayPoweredByDynamicFooter: true, onSuccess: (receipt) => {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
}, children: jsx(Modal, { children: jsx(ModalCard, { children: jsx(VerticalDrawerTransition, { isShown: true, children: jsx(PopperProvider, { children: jsx(SendBalanceView, { initialRecipientAddress: initialRecipientAddress, initialValue: initialValue, onError: (error) => (errorRef.current = error), onClickClose: closeModal, onDone: closeModal, displayPoweredByDynamicFooter: true, onSuccess: (receipt) => {
|
|
112
|
+
errorRef.current = null;
|
|
113
|
+
receiptRef.current = receipt;
|
|
114
|
+
} }) }) }) }) }) }));
|
|
115
115
|
};
|
|
116
116
|
|
|
117
117
|
export { SendBalanceModal };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var walletConnectorOptions = require('../../../store/state/walletConnectorOptions.cjs');
|
|
7
|
+
|
|
8
|
+
const getWalletConnectorForWallet = (wallet) => {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
if (!wallet) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
const walletConnectorOptions$1 = walletConnectorOptions.getWalletConnectorOptions();
|
|
14
|
+
const { key: walletKey, chain } = wallet;
|
|
15
|
+
const walletConnector = (_a = walletConnectorOptions$1.find((wallet) => walletKey === wallet.key &&
|
|
16
|
+
wallet.walletConnector.connectedChain === chain)) === null || _a === void 0 ? void 0 : _a.walletConnector;
|
|
17
|
+
if (walletConnector) {
|
|
18
|
+
return walletConnector;
|
|
19
|
+
}
|
|
20
|
+
const fallbackConnector = (_b = walletConnectorOptions$1.find((wallet) => wallet.key === 'fallbackconnector')) === null || _b === void 0 ? void 0 : _b.walletConnector;
|
|
21
|
+
return fallbackConnector;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
exports.getWalletConnectorForWallet = getWalletConnectorForWallet;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { getWalletConnectorOptions } from '../../../store/state/walletConnectorOptions.js';
|
|
3
|
+
|
|
4
|
+
const getWalletConnectorForWallet = (wallet) => {
|
|
5
|
+
var _a, _b;
|
|
6
|
+
if (!wallet) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
const walletConnectorOptions = getWalletConnectorOptions();
|
|
10
|
+
const { key: walletKey, chain } = wallet;
|
|
11
|
+
const walletConnector = (_a = walletConnectorOptions.find((wallet) => walletKey === wallet.key &&
|
|
12
|
+
wallet.walletConnector.connectedChain === chain)) === null || _a === void 0 ? void 0 : _a.walletConnector;
|
|
13
|
+
if (walletConnector) {
|
|
14
|
+
return walletConnector;
|
|
15
|
+
}
|
|
16
|
+
const fallbackConnector = (_b = walletConnectorOptions.find((wallet) => wallet.key === 'fallbackconnector')) === null || _b === void 0 ? void 0 : _b.walletConnector;
|
|
17
|
+
return fallbackConnector;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { getWalletConnectorForWallet };
|
|
@@ -30,6 +30,7 @@ var session = require('../../../data/api/session/session.cjs');
|
|
|
30
30
|
require('../../../locale/locale.cjs');
|
|
31
31
|
var getWalletProvider = require('../../functions/getWalletProvider/getWalletProvider.cjs');
|
|
32
32
|
var isConnectOnly = require('../authenticationHooks/helpers/isConnectOnly.cjs');
|
|
33
|
+
var getWalletConnectorForWallet = require('../../functions/getWalletConnectorForWallet/getWalletConnectorForWallet.cjs');
|
|
33
34
|
var updateUserWalletsFromConnectedWallets = require('./updateUserWalletsFromConnectedWallets/updateUserWalletsFromConnectedWallets.cjs');
|
|
34
35
|
|
|
35
36
|
const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingOnConnectOnly, environmentId, primaryWalletId, setPrimaryWalletId, walletConnectorOptions, handleConnectedWallet, setShowAuthFlow, isBridgeFlow, user, }) => {
|
|
@@ -136,10 +137,11 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
136
137
|
var _a;
|
|
137
138
|
const clonedConnectedWalletsList = [...connectedWallets];
|
|
138
139
|
const connectedWalletIndex = clonedConnectedWalletsList.findIndex((connectedWallet) => connectedWallet.id === walletId);
|
|
139
|
-
if (connectedWalletIndex
|
|
140
|
-
|
|
141
|
-
(_a = walletObject.address) !== null && _a !== void 0 ? _a : clonedConnectedWalletsList[connectedWalletIndex].address;
|
|
140
|
+
if (connectedWalletIndex < 0) {
|
|
141
|
+
return;
|
|
142
142
|
}
|
|
143
|
+
clonedConnectedWalletsList[connectedWalletIndex] =
|
|
144
|
+
clonedConnectedWalletsList[connectedWalletIndex].connector.createWallet(Object.assign(Object.assign({}, clonedConnectedWalletsList[connectedWalletIndex]), { address: (_a = walletObject.address) !== null && _a !== void 0 ? _a : clonedConnectedWalletsList[connectedWalletIndex].address, connector: getWalletConnectorForWallet.getWalletConnectorForWallet(clonedConnectedWalletsList[connectedWalletIndex]) }));
|
|
143
145
|
setConnectedWallets(clonedConnectedWalletsList);
|
|
144
146
|
}, [connectedWallets, setConnectedWallets]);
|
|
145
147
|
// Keeps connected wallet data inside localStorage
|
|
@@ -26,6 +26,7 @@ import { createVisit } from '../../../data/api/session/session.js';
|
|
|
26
26
|
import '../../../locale/locale.js';
|
|
27
27
|
import { getWalletProvider } from '../../functions/getWalletProvider/getWalletProvider.js';
|
|
28
28
|
import { isConnectOnly } from '../authenticationHooks/helpers/isConnectOnly.js';
|
|
29
|
+
import { getWalletConnectorForWallet } from '../../functions/getWalletConnectorForWallet/getWalletConnectorForWallet.js';
|
|
29
30
|
import { updateUserWalletsFromConnectedWallets } from './updateUserWalletsFromConnectedWallets/updateUserWalletsFromConnectedWallets.js';
|
|
30
31
|
|
|
31
32
|
const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingOnConnectOnly, environmentId, primaryWalletId, setPrimaryWalletId, walletConnectorOptions, handleConnectedWallet, setShowAuthFlow, isBridgeFlow, user, }) => {
|
|
@@ -132,10 +133,11 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
132
133
|
var _a;
|
|
133
134
|
const clonedConnectedWalletsList = [...connectedWallets];
|
|
134
135
|
const connectedWalletIndex = clonedConnectedWalletsList.findIndex((connectedWallet) => connectedWallet.id === walletId);
|
|
135
|
-
if (connectedWalletIndex
|
|
136
|
-
|
|
137
|
-
(_a = walletObject.address) !== null && _a !== void 0 ? _a : clonedConnectedWalletsList[connectedWalletIndex].address;
|
|
136
|
+
if (connectedWalletIndex < 0) {
|
|
137
|
+
return;
|
|
138
138
|
}
|
|
139
|
+
clonedConnectedWalletsList[connectedWalletIndex] =
|
|
140
|
+
clonedConnectedWalletsList[connectedWalletIndex].connector.createWallet(Object.assign(Object.assign({}, clonedConnectedWalletsList[connectedWalletIndex]), { address: (_a = walletObject.address) !== null && _a !== void 0 ? _a : clonedConnectedWalletsList[connectedWalletIndex].address, connector: getWalletConnectorForWallet(clonedConnectedWalletsList[connectedWalletIndex]) }));
|
|
139
141
|
setConnectedWallets(clonedConnectedWalletsList);
|
|
140
142
|
}, [connectedWallets, setConnectedWallets]);
|
|
141
143
|
// Keeps connected wallet data inside localStorage
|
|
@@ -19,6 +19,7 @@ require('../../constants/values.cjs');
|
|
|
19
19
|
require('../../../store/state/loadingAndLifecycle.cjs');
|
|
20
20
|
require('../../../shared/consts/index.cjs');
|
|
21
21
|
require('../../../events/dynamicEvents.cjs');
|
|
22
|
+
var useWalletConnectorEvent = require('../events/useWalletConnectorEvent/useWalletConnectorEvent.cjs');
|
|
22
23
|
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
23
24
|
require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
24
25
|
require('@dynamic-labs/multi-wallet');
|
|
@@ -140,6 +141,14 @@ const useConnectedWalletsNetworkValidation = () => {
|
|
|
140
141
|
setShowAuthFlow,
|
|
141
142
|
setView,
|
|
142
143
|
]);
|
|
144
|
+
const uniqueConnectors = React.useMemo(() => {
|
|
145
|
+
const connectors = connectedWallets.map(({ connector }) => connector);
|
|
146
|
+
const allWalletConnectors = new Set([...connectors].filter((connector) => Boolean(connector)));
|
|
147
|
+
return Array.from(allWalletConnectors);
|
|
148
|
+
}, [connectedWallets]);
|
|
149
|
+
useWalletConnectorEvent.useWalletConnectorEvent(uniqueConnectors, 'chainChange', ({ chain }) => {
|
|
150
|
+
validateNetwork();
|
|
151
|
+
});
|
|
143
152
|
React.useEffect(() => {
|
|
144
153
|
/**
|
|
145
154
|
* This check was added to prevent the "wrong network" modal from appearing
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
-
import { useCallback, useEffect } from 'react';
|
|
3
|
+
import { useCallback, useMemo, useEffect } from 'react';
|
|
4
4
|
import '../../../context/DynamicContext/DynamicContext.js';
|
|
5
5
|
import '@dynamic-labs/sdk-api-core';
|
|
6
6
|
import '../../../shared/logger.js';
|
|
@@ -15,6 +15,7 @@ import '../../constants/values.js';
|
|
|
15
15
|
import '../../../store/state/loadingAndLifecycle.js';
|
|
16
16
|
import '../../../shared/consts/index.js';
|
|
17
17
|
import '../../../events/dynamicEvents.js';
|
|
18
|
+
import { useWalletConnectorEvent } from '../events/useWalletConnectorEvent/useWalletConnectorEvent.js';
|
|
18
19
|
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
19
20
|
import '../../../context/ErrorContext/ErrorContext.js';
|
|
20
21
|
import '@dynamic-labs/multi-wallet';
|
|
@@ -136,6 +137,14 @@ const useConnectedWalletsNetworkValidation = () => {
|
|
|
136
137
|
setShowAuthFlow,
|
|
137
138
|
setView,
|
|
138
139
|
]);
|
|
140
|
+
const uniqueConnectors = useMemo(() => {
|
|
141
|
+
const connectors = connectedWallets.map(({ connector }) => connector);
|
|
142
|
+
const allWalletConnectors = new Set([...connectors].filter((connector) => Boolean(connector)));
|
|
143
|
+
return Array.from(allWalletConnectors);
|
|
144
|
+
}, [connectedWallets]);
|
|
145
|
+
useWalletConnectorEvent(uniqueConnectors, 'chainChange', ({ chain }) => {
|
|
146
|
+
validateNetwork();
|
|
147
|
+
});
|
|
139
148
|
useEffect(() => {
|
|
140
149
|
/**
|
|
141
150
|
* This check was added to prevent the "wrong network" modal from appearing
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
7
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
7
8
|
var findWalletOptionFor = require('../../../../functions/findWalletOptionFor/findWalletOptionFor.cjs');
|
|
8
9
|
var shouldManuallyReconnectOnRefresh = require('../../../../functions/shouldManuallyReconnectOnRefresh/shouldManuallyReconnectOnRefresh.cjs');
|
|
9
10
|
var convertLegacyPhantomLedgerConnector = require('../convertLegacyPhantomLedgerConnector/convertLegacyPhantomLedgerConnector.cjs');
|
|
@@ -17,7 +18,7 @@ const createLinkedWalletsFromWalletOptions = ({ user, walletConnectorOptions, pr
|
|
|
17
18
|
return user.verifiedCredentials
|
|
18
19
|
.map(convertLegacyPhantomLedger)
|
|
19
20
|
.map((account) => {
|
|
20
|
-
var _a;
|
|
21
|
+
var _a, _b;
|
|
21
22
|
const wallet = findWalletOptionFor.findWalletOptionFor(account, walletConnectorOptions);
|
|
22
23
|
// this probably shouldn't happen. this would mean that the user has an account linked
|
|
23
24
|
// with wallet W, but the customer has toggled off wallet W or the chain that
|
|
@@ -29,6 +30,12 @@ const createLinkedWalletsFromWalletOptions = ({ user, walletConnectorOptions, pr
|
|
|
29
30
|
shouldManuallyReconnectOnRefresh.shouldManuallyReconnectOnRefresh(wallet.walletConnector)) {
|
|
30
31
|
wallet.walletConnector.connect();
|
|
31
32
|
}
|
|
33
|
+
// only checking for ledger hardware wallets since we only specify ledger as a hardware wallet
|
|
34
|
+
if (((_a = account.walletProperties) === null || _a === void 0 ? void 0 : _a.hardwareWallet) ===
|
|
35
|
+
sdkApiCore.HardwareWalletEnum.Ledger &&
|
|
36
|
+
walletConnectorCore.isHardwareWalletConnector(wallet.walletConnector)) {
|
|
37
|
+
wallet.walletConnector.isHardwareWalletEnabled = true;
|
|
38
|
+
}
|
|
32
39
|
// this account is the owner of a smart wallet, and should not be surfaced
|
|
33
40
|
if (smartWallet.isOwnerOfASmartWallet(account, user.verifiedCredentials)) {
|
|
34
41
|
return null;
|
|
@@ -48,7 +55,7 @@ const createLinkedWalletsFromWalletOptions = ({ user, walletConnectorOptions, pr
|
|
|
48
55
|
connector: wallet.walletConnector,
|
|
49
56
|
id: account.id,
|
|
50
57
|
isAuthenticated: true,
|
|
51
|
-
key: (
|
|
58
|
+
key: (_b = account.walletName) !== null && _b !== void 0 ? _b : wallet.walletConnector.key,
|
|
52
59
|
});
|
|
53
60
|
}
|
|
54
61
|
return null;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';
|
|
2
|
+
import { HardwareWalletEnum, WalletProviderEnum } from '@dynamic-labs/sdk-api-core';
|
|
3
|
+
import { isHardwareWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
3
4
|
import { findWalletOptionFor } from '../../../../functions/findWalletOptionFor/findWalletOptionFor.js';
|
|
4
5
|
import { shouldManuallyReconnectOnRefresh } from '../../../../functions/shouldManuallyReconnectOnRefresh/shouldManuallyReconnectOnRefresh.js';
|
|
5
6
|
import { convertLegacyPhantomLedgerConnector } from '../convertLegacyPhantomLedgerConnector/convertLegacyPhantomLedgerConnector.js';
|
|
@@ -13,7 +14,7 @@ const createLinkedWalletsFromWalletOptions = ({ user, walletConnectorOptions, pr
|
|
|
13
14
|
return user.verifiedCredentials
|
|
14
15
|
.map(convertLegacyPhantomLedger)
|
|
15
16
|
.map((account) => {
|
|
16
|
-
var _a;
|
|
17
|
+
var _a, _b;
|
|
17
18
|
const wallet = findWalletOptionFor(account, walletConnectorOptions);
|
|
18
19
|
// this probably shouldn't happen. this would mean that the user has an account linked
|
|
19
20
|
// with wallet W, but the customer has toggled off wallet W or the chain that
|
|
@@ -25,6 +26,12 @@ const createLinkedWalletsFromWalletOptions = ({ user, walletConnectorOptions, pr
|
|
|
25
26
|
shouldManuallyReconnectOnRefresh(wallet.walletConnector)) {
|
|
26
27
|
wallet.walletConnector.connect();
|
|
27
28
|
}
|
|
29
|
+
// only checking for ledger hardware wallets since we only specify ledger as a hardware wallet
|
|
30
|
+
if (((_a = account.walletProperties) === null || _a === void 0 ? void 0 : _a.hardwareWallet) ===
|
|
31
|
+
HardwareWalletEnum.Ledger &&
|
|
32
|
+
isHardwareWalletConnector(wallet.walletConnector)) {
|
|
33
|
+
wallet.walletConnector.isHardwareWalletEnabled = true;
|
|
34
|
+
}
|
|
28
35
|
// this account is the owner of a smart wallet, and should not be surfaced
|
|
29
36
|
if (isOwnerOfASmartWallet(account, user.verifiedCredentials)) {
|
|
30
37
|
return null;
|
|
@@ -44,7 +51,7 @@ const createLinkedWalletsFromWalletOptions = ({ user, walletConnectorOptions, pr
|
|
|
44
51
|
connector: wallet.walletConnector,
|
|
45
52
|
id: account.id,
|
|
46
53
|
isAuthenticated: true,
|
|
47
|
-
key: (
|
|
54
|
+
key: (_b = account.walletName) !== null && _b !== void 0 ? _b : wallet.walletConnector.key,
|
|
48
55
|
});
|
|
49
56
|
}
|
|
50
57
|
return null;
|
|
@@ -22,13 +22,6 @@ var useWalletConnectorEvent = require('../events/useWalletConnectorEvent/useWall
|
|
|
22
22
|
var dynamicEvents = require('../../../events/dynamicEvents.cjs');
|
|
23
23
|
|
|
24
24
|
const useWalletEventListeners = ({ disconnectWallet, handleLogOut, multiWallet, multiWalletWidgetState, primaryWallet, secondaryWallets, selectedWalletConnector, selectedWalletWithAction, setSelectedWalletConnectorKey, setSelectedWalletWithAction, setMultiWalletWidgetState, user, setPrimaryWalletId, authMode, refreshConnectedWallet, detectNewWalletsForLinking, }) => {
|
|
25
|
-
useWalletConnectorEvent.useWalletConnectorEvent(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, 'chainChange', ({ chain }) => {
|
|
26
|
-
logger.logger.debug('primary wallet chain change', { chain });
|
|
27
|
-
if (!primaryWallet) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
refreshConnectedWallet(primaryWallet.id, primaryWallet.connector);
|
|
31
|
-
});
|
|
32
25
|
const handleAccountChangeWhenAwaitingAccountSwitch = React.useCallback((isPrimaryWallet, newAddress) => {
|
|
33
26
|
logger.logger.debug('handleAccountChangeWhenAwaitingAccountSwitch', {
|
|
34
27
|
isPrimaryWallet,
|
|
@@ -149,13 +142,6 @@ const useWalletEventListeners = ({ disconnectWallet, handleLogOut, multiWallet,
|
|
|
149
142
|
handleAccountChangeWhenAwaitingAccountSwitch(false, (selectedWalletWithAction === null || selectedWalletWithAction === void 0 ? void 0 : selectedWalletWithAction.wallet.address) || '');
|
|
150
143
|
}
|
|
151
144
|
}));
|
|
152
|
-
useWalletConnectorEvent.useWalletConnectorEvent(uniqueNonPrimaryWallets, 'chainChange', (_, changedConnector) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
153
|
-
logger.logger.debug('secondary wallet chain change');
|
|
154
|
-
// Get all wallets with this connector
|
|
155
|
-
const affectedWallets = secondaryWallets.filter(({ connector }) => connector.key === changedConnector.key);
|
|
156
|
-
for (const wallet of affectedWallets)
|
|
157
|
-
refreshConnectedWallet(wallet.id, wallet.connector);
|
|
158
|
-
}));
|
|
159
145
|
useWalletConnectorEvent.useWalletConnectorEvent(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, 'disconnect', () => {
|
|
160
146
|
logger.logger.debug('primary wallet disconnect');
|
|
161
147
|
if (authMode === 'connect-only') {
|
|
@@ -18,13 +18,6 @@ import { useWalletConnectorEvent } from '../events/useWalletConnectorEvent/useWa
|
|
|
18
18
|
import { dynamicEvents } from '../../../events/dynamicEvents.js';
|
|
19
19
|
|
|
20
20
|
const useWalletEventListeners = ({ disconnectWallet, handleLogOut, multiWallet, multiWalletWidgetState, primaryWallet, secondaryWallets, selectedWalletConnector, selectedWalletWithAction, setSelectedWalletConnectorKey, setSelectedWalletWithAction, setMultiWalletWidgetState, user, setPrimaryWalletId, authMode, refreshConnectedWallet, detectNewWalletsForLinking, }) => {
|
|
21
|
-
useWalletConnectorEvent(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, 'chainChange', ({ chain }) => {
|
|
22
|
-
logger.debug('primary wallet chain change', { chain });
|
|
23
|
-
if (!primaryWallet) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
refreshConnectedWallet(primaryWallet.id, primaryWallet.connector);
|
|
27
|
-
});
|
|
28
21
|
const handleAccountChangeWhenAwaitingAccountSwitch = useCallback((isPrimaryWallet, newAddress) => {
|
|
29
22
|
logger.debug('handleAccountChangeWhenAwaitingAccountSwitch', {
|
|
30
23
|
isPrimaryWallet,
|
|
@@ -145,13 +138,6 @@ const useWalletEventListeners = ({ disconnectWallet, handleLogOut, multiWallet,
|
|
|
145
138
|
handleAccountChangeWhenAwaitingAccountSwitch(false, (selectedWalletWithAction === null || selectedWalletWithAction === void 0 ? void 0 : selectedWalletWithAction.wallet.address) || '');
|
|
146
139
|
}
|
|
147
140
|
}));
|
|
148
|
-
useWalletConnectorEvent(uniqueNonPrimaryWallets, 'chainChange', (_, changedConnector) => __awaiter(void 0, void 0, void 0, function* () {
|
|
149
|
-
logger.debug('secondary wallet chain change');
|
|
150
|
-
// Get all wallets with this connector
|
|
151
|
-
const affectedWallets = secondaryWallets.filter(({ connector }) => connector.key === changedConnector.key);
|
|
152
|
-
for (const wallet of affectedWallets)
|
|
153
|
-
refreshConnectedWallet(wallet.id, wallet.connector);
|
|
154
|
-
}));
|
|
155
141
|
useWalletConnectorEvent(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, 'disconnect', () => {
|
|
156
142
|
logger.debug('primary wallet disconnect');
|
|
157
143
|
if (authMode === 'connect-only') {
|