@dynamic-labs/sdk-react-core 3.0.0-alpha.7 → 3.0.0-alpha.9
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 +23 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +10 -10
- package/src/index.cjs +4 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +2 -0
- package/src/lib/Main.cjs +1 -0
- package/src/lib/Main.js +1 -0
- package/src/lib/components/TransactionOriginDestination/TransactionOriginDestination.d.ts +0 -11
- package/src/lib/context/DynamicContext/DynamicContext.cjs +2 -1
- package/src/lib/context/DynamicContext/DynamicContext.js +3 -2
- package/src/lib/context/ReinitializeContext/ReinitializeContextProvider.cjs +113 -0
- package/src/lib/context/ReinitializeContext/ReinitializeContextProvider.d.ts +22 -0
- package/src/lib/context/ReinitializeContext/ReinitializeContextProvider.js +107 -0
- package/src/lib/context/ReinitializeContext/index.d.ts +1 -0
- package/src/lib/context/WalletContext/WalletContext.cjs +1 -1
- package/src/lib/context/WalletContext/WalletContext.js +1 -1
- package/src/lib/data/api/externalAuth/externalAuth.cjs +44 -0
- package/src/lib/data/api/externalAuth/externalAuth.js +40 -0
- package/src/lib/events/multiWallet.d.ts +1 -0
- package/src/lib/store/index.d.ts +1 -1
- package/src/lib/store/store.cjs +6 -0
- package/src/lib/store/store.d.ts +1 -0
- package/src/lib/store/store.js +6 -1
- package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.d.ts +1 -1
- package/src/lib/utils/hooks/multiWallet/useVerifyOnAwaitingSignature/useVerifyOnAwaitingSignature.cjs +39 -13
- package/src/lib/utils/hooks/multiWallet/useVerifyOnAwaitingSignature/useVerifyOnAwaitingSignature.js +40 -14
- package/src/lib/utils/hooks/useExternalAuth/useExternalAuth.cjs +115 -0
- package/src/lib/utils/hooks/useExternalAuth/useExternalAuth.js +111 -0
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.cjs +76 -0
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.js +76 -0
- package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.cjs +20 -1
- package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.js +20 -1
|
@@ -16,6 +16,64 @@ import '@dynamic-labs/utils';
|
|
|
16
16
|
import '../../../shared/consts/index.js';
|
|
17
17
|
import { useInternalDynamicEvents } from '../events/useDynamicEvents/useDynamicEvents.js';
|
|
18
18
|
import { useWalletConnectorEvent } from '../events/useWalletConnectorEvent/useWalletConnectorEvent.js';
|
|
19
|
+
import '@dynamic-labs/multi-wallet';
|
|
20
|
+
import 'react-international-phone';
|
|
21
|
+
import '../../../config/ApiEndpoint.js';
|
|
22
|
+
import '@dynamic-labs/store';
|
|
23
|
+
import '../../../locale/locale.js';
|
|
24
|
+
import '../../../context/DynamicContext/DynamicContext.js';
|
|
25
|
+
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
26
|
+
import '../../../context/ErrorContext/ErrorContext.js';
|
|
27
|
+
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
28
|
+
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
29
|
+
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
30
|
+
import { dynamicEvents } from '../../../events/dynamicEvents.js';
|
|
31
|
+
import '../../../context/VerificationContext/VerificationContext.js';
|
|
32
|
+
import 'react-dom';
|
|
33
|
+
import '../../../context/WalletContext/WalletContext.js';
|
|
34
|
+
import '../../../context/ThemeContext/ThemeContext.js';
|
|
35
|
+
import '../useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
36
|
+
import '@dynamic-labs/types';
|
|
37
|
+
import '../../../context/LoadingContext/LoadingContext.js';
|
|
38
|
+
import 'yup';
|
|
39
|
+
import '../../../context/MockContext/MockContext.js';
|
|
40
|
+
import '../../../views/CollectUserDataView/useFields.js';
|
|
41
|
+
import '../../../context/FieldsStateContext/FieldsStateContext.js';
|
|
42
|
+
import '../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
43
|
+
import '@dynamic-labs/rpc-providers';
|
|
44
|
+
import 'react-i18next';
|
|
45
|
+
import '../../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
46
|
+
import '../../../components/Alert/Alert.js';
|
|
47
|
+
import '../../../components/ShadowDOM/ShadowDOM.js';
|
|
48
|
+
import '../../../components/IconButton/IconButton.js';
|
|
49
|
+
import '../../../components/InlineWidget/InlineWidget.js';
|
|
50
|
+
import '../../../components/Input/Input.js';
|
|
51
|
+
import '../../../components/IsBrowser/IsBrowser.js';
|
|
52
|
+
import '../../../components/MenuList/Dropdown/Dropdown.js';
|
|
53
|
+
import '../../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
54
|
+
import '../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
55
|
+
import '../../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
56
|
+
import '../../../components/OverlayCard/OverlayCardTarget/OverlayCardTarget.js';
|
|
57
|
+
import '../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
58
|
+
import '../../../components/Popper/Popper/Popper.js';
|
|
59
|
+
import '../../../components/Popper/PopperContext/PopperContext.js';
|
|
60
|
+
import 'react-focus-lock';
|
|
61
|
+
import 'qrcode';
|
|
62
|
+
import 'formik';
|
|
63
|
+
import '../../../views/WalletList/WalletList.js';
|
|
64
|
+
import '../../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
65
|
+
import '../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
66
|
+
import '@hcaptcha/react-hcaptcha';
|
|
67
|
+
import '../../../context/FooterAnimationContext/index.js';
|
|
68
|
+
import '../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
69
|
+
import '../../../context/MfaSettingsContext/MfaSettingsContext.js';
|
|
70
|
+
import '../../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
71
|
+
import '../../../context/PasskeyContext/PasskeyContext.js';
|
|
72
|
+
import '../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
73
|
+
import '../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
74
|
+
import '../../../views/TransactionConfirmationView/helpers/transactionErrorMessage.js';
|
|
75
|
+
import '../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
76
|
+
import { logVerboseTroubleshootingMessage } from '../../functions/logVerboseTroubleshootingMessage/logVerboseTroubleshootingMessage.js';
|
|
19
77
|
|
|
20
78
|
const useWalletEventListeners = ({ disconnectWallet, handleLogOut, multiWallet, multiWalletWidgetState, primaryWallet, secondaryWallets, selectedWalletConnector, selectedWalletWithAction, setSelectedWalletConnectorKey, setSelectedWalletWithAction, setMultiWalletWidgetState, user, setPrimaryWalletId, authMode, refreshConnectedWallet, }) => {
|
|
21
79
|
useWalletConnectorEvent(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, 'disconnect', () => {
|
|
@@ -30,7 +88,12 @@ const useWalletEventListeners = ({ disconnectWallet, handleLogOut, multiWallet,
|
|
|
30
88
|
refreshConnectedWallet(primaryWallet.id, primaryWallet.connector);
|
|
31
89
|
});
|
|
32
90
|
const handleAccountChangeWhenAwaitingAccountSwitch = useCallback((isPrimaryWallet, newAddress) => {
|
|
91
|
+
logger.debug('handleAccountChangeWhenAwaitingAccountSwitch', {
|
|
92
|
+
isPrimaryWallet,
|
|
93
|
+
newAddress,
|
|
94
|
+
});
|
|
33
95
|
const linkedSecondaryWallet = secondaryWallets.find((wallet) => isSameAddress(wallet.address, newAddress, wallet.chain));
|
|
96
|
+
logVerboseTroubleshootingMessage('[handleAccountChangeWhenAwaitingAccountSwitch]', { linkedSecondaryWallet });
|
|
34
97
|
// this means the user is linking a new account, so we need proof of ownership...
|
|
35
98
|
if (!linkedSecondaryWallet) {
|
|
36
99
|
setMultiWalletWidgetState('awaiting_signature', undefined, 'linking_new_wallet');
|
|
@@ -39,6 +102,12 @@ const useWalletEventListeners = ({ disconnectWallet, handleLogOut, multiWallet,
|
|
|
39
102
|
}
|
|
40
103
|
return;
|
|
41
104
|
}
|
|
105
|
+
const isTryingToUpdateUnkownWallet = linkedSecondaryWallet.connector.key === 'unknown';
|
|
106
|
+
if (isTryingToUpdateUnkownWallet) {
|
|
107
|
+
//prompt the user to connect and sign with the wallet
|
|
108
|
+
dynamicEvents.emit('triggerConnectAndSign');
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
42
111
|
// ...otherwise, the user is switching primary accounts betweeen the same wallet
|
|
43
112
|
setSelectedWalletWithAction(null);
|
|
44
113
|
setPrimaryWalletId(linkedSecondaryWallet.id);
|
|
@@ -52,6 +121,13 @@ const useWalletEventListeners = ({ disconnectWallet, handleLogOut, multiWallet,
|
|
|
52
121
|
setPrimaryWalletId,
|
|
53
122
|
]);
|
|
54
123
|
const calculatePrimaryWalletMultiWalletStateFromAccounts = useCallback(({ accounts }) => {
|
|
124
|
+
logger.debug('calculatePrimaryWalletMultiWalletStateFromAccounts', {
|
|
125
|
+
accounts,
|
|
126
|
+
authMode,
|
|
127
|
+
multiWallet,
|
|
128
|
+
multiWalletWidgetState,
|
|
129
|
+
primaryWallet,
|
|
130
|
+
});
|
|
55
131
|
// change the api here
|
|
56
132
|
if (!primaryWallet)
|
|
57
133
|
return;
|
|
@@ -9,7 +9,7 @@ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
|
9
9
|
require('react');
|
|
10
10
|
require('../../../context/DynamicContext/DynamicContext.cjs');
|
|
11
11
|
require('@dynamic-labs/sdk-api-core');
|
|
12
|
-
require('../../../shared/logger.cjs');
|
|
12
|
+
var logger = require('../../../shared/logger.cjs');
|
|
13
13
|
require('@dynamic-labs/iconic');
|
|
14
14
|
require('react/jsx-runtime');
|
|
15
15
|
var ViewContext = require('../../../context/ViewContext/ViewContext.cjs');
|
|
@@ -31,6 +31,7 @@ require('@dynamic-labs/multi-wallet');
|
|
|
31
31
|
require('react-international-phone');
|
|
32
32
|
var requiresTwoStepAuthentication = require('../../functions/requiresTwoStepAuthentication/requiresTwoStepAuthentication.cjs');
|
|
33
33
|
require('@dynamic-labs/store');
|
|
34
|
+
var logVerboseTroubleshootingMessage = require('../../functions/logVerboseTroubleshootingMessage/logVerboseTroubleshootingMessage.cjs');
|
|
34
35
|
require('../../../locale/locale.cjs');
|
|
35
36
|
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
36
37
|
var useConnectAndSignSplitSteps = require('../authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs');
|
|
@@ -90,7 +91,11 @@ const useWalletItemActions = () => {
|
|
|
90
91
|
const { onlyConnectUser } = useConnectAndSignSplitSteps.useConnectAndSignSplitSteps();
|
|
91
92
|
const connectAndSignWallet = useConnectAndSign.useConnectAndSign();
|
|
92
93
|
const handleCustodialWalletClick = (walletConnector) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
94
|
+
logger.logger.debug('handleCustodialWalletClick', walletConnector);
|
|
93
95
|
const twoStepAuthentication = requiresTwoStepAuthentication.requiresTwoStepAuthentication(walletConnector);
|
|
96
|
+
logVerboseTroubleshootingMessage.logVerboseTroubleshootingMessage('[handleCustodialWalletClick]', {
|
|
97
|
+
twoStepAuthentication,
|
|
98
|
+
});
|
|
94
99
|
if (twoStepAuthentication) {
|
|
95
100
|
setSelectedWalletConnectorKey(walletConnector.key);
|
|
96
101
|
yield onlyConnectUser({
|
|
@@ -105,6 +110,7 @@ const useWalletItemActions = () => {
|
|
|
105
110
|
});
|
|
106
111
|
const handleMobileWalletClick = (walletConnector) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
107
112
|
var _a;
|
|
113
|
+
logger.logger.debug('handleMobileWalletClick', walletConnector);
|
|
108
114
|
setSelectedWalletConnectorKey(walletConnector.key);
|
|
109
115
|
// We need to set to LS when about to verify phantom wallet on mobile
|
|
110
116
|
// because the deeplink interrupts this code execution and then redirects back on a new tab.
|
|
@@ -124,10 +130,12 @@ const useWalletItemActions = () => {
|
|
|
124
130
|
onlyConnectUser({ walletConnector });
|
|
125
131
|
});
|
|
126
132
|
const handleInstalledExtensionClick = (walletConnector) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
133
|
+
logger.logger.debug('handleInstalledExtensionClick', walletConnector);
|
|
127
134
|
setSelectedWalletConnectorKey(walletConnector.key);
|
|
128
135
|
setMultiWalletWidgetState('awaiting_signature', undefined, 'linking_new_wallet');
|
|
129
136
|
});
|
|
130
137
|
const handleUninstalledClick = (walletConnector) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
138
|
+
logger.logger.debug('handleUninstalledClick', walletConnector);
|
|
131
139
|
setSelectedWalletConnectorKey(walletConnector.key);
|
|
132
140
|
if (!walletConnector.canConnectViaQrCode) {
|
|
133
141
|
setView('no-qr-not-installed');
|
|
@@ -149,8 +157,14 @@ const useWalletItemActions = () => {
|
|
|
149
157
|
setError(undefined);
|
|
150
158
|
});
|
|
151
159
|
const handleAlreadyConnectedWallet = (walletConnector) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
160
|
+
logger.logger.debug('handleAlreadyConnectedWallet', walletConnector);
|
|
152
161
|
const connectedAccounts = yield walletConnector.getConnectedAccounts();
|
|
153
162
|
const activeAccountAlreadyLinked = linkedWallets.find((wallet) => { var _a; return wallet.address.toLowerCase() === ((_a = connectedAccounts[0]) === null || _a === void 0 ? void 0 : _a.toLowerCase()); });
|
|
163
|
+
logVerboseTroubleshootingMessage.logVerboseTroubleshootingMessage('[handleAlreadyConnectedWallet]', {
|
|
164
|
+
activeAccountAlreadyLinked,
|
|
165
|
+
connectedAccounts,
|
|
166
|
+
linkedWallets,
|
|
167
|
+
});
|
|
154
168
|
if (activeAccountAlreadyLinked) {
|
|
155
169
|
setMultiWalletWidgetState('awaiting_account_switch', 'linking_new_wallet');
|
|
156
170
|
}
|
|
@@ -180,6 +194,11 @@ const useWalletItemActions = () => {
|
|
|
180
194
|
const { walletConnector, isInstalledOnBrowser } = wallet;
|
|
181
195
|
const shouldEndWalletConnectorSession = walletConnector.connectedChain === 'FLOW' ||
|
|
182
196
|
walletConnectorCore.isPhantomRedirectConnector(walletConnector);
|
|
197
|
+
logVerboseTroubleshootingMessage.logVerboseTroubleshootingMessage('[handleWalletItemClick]', {
|
|
198
|
+
mockedSDK,
|
|
199
|
+
shouldEndWalletConnectorSession,
|
|
200
|
+
wallet,
|
|
201
|
+
});
|
|
183
202
|
if (mockedSDK)
|
|
184
203
|
return;
|
|
185
204
|
if (shouldEndWalletConnectorSession) {
|
|
@@ -5,7 +5,7 @@ import { isPhantomRedirectConnector } from '@dynamic-labs/wallet-connector-core'
|
|
|
5
5
|
import 'react';
|
|
6
6
|
import '../../../context/DynamicContext/DynamicContext.js';
|
|
7
7
|
import '@dynamic-labs/sdk-api-core';
|
|
8
|
-
import '../../../shared/logger.js';
|
|
8
|
+
import { logger } from '../../../shared/logger.js';
|
|
9
9
|
import '@dynamic-labs/iconic';
|
|
10
10
|
import 'react/jsx-runtime';
|
|
11
11
|
import { useViewContext } from '../../../context/ViewContext/ViewContext.js';
|
|
@@ -27,6 +27,7 @@ import '@dynamic-labs/multi-wallet';
|
|
|
27
27
|
import 'react-international-phone';
|
|
28
28
|
import { requiresTwoStepAuthentication } from '../../functions/requiresTwoStepAuthentication/requiresTwoStepAuthentication.js';
|
|
29
29
|
import '@dynamic-labs/store';
|
|
30
|
+
import { logVerboseTroubleshootingMessage } from '../../functions/logVerboseTroubleshootingMessage/logVerboseTroubleshootingMessage.js';
|
|
30
31
|
import '../../../locale/locale.js';
|
|
31
32
|
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
32
33
|
import { useConnectAndSignSplitSteps } from '../authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js';
|
|
@@ -86,7 +87,11 @@ const useWalletItemActions = () => {
|
|
|
86
87
|
const { onlyConnectUser } = useConnectAndSignSplitSteps();
|
|
87
88
|
const connectAndSignWallet = useConnectAndSign();
|
|
88
89
|
const handleCustodialWalletClick = (walletConnector) => __awaiter(void 0, void 0, void 0, function* () {
|
|
90
|
+
logger.debug('handleCustodialWalletClick', walletConnector);
|
|
89
91
|
const twoStepAuthentication = requiresTwoStepAuthentication(walletConnector);
|
|
92
|
+
logVerboseTroubleshootingMessage('[handleCustodialWalletClick]', {
|
|
93
|
+
twoStepAuthentication,
|
|
94
|
+
});
|
|
90
95
|
if (twoStepAuthentication) {
|
|
91
96
|
setSelectedWalletConnectorKey(walletConnector.key);
|
|
92
97
|
yield onlyConnectUser({
|
|
@@ -101,6 +106,7 @@ const useWalletItemActions = () => {
|
|
|
101
106
|
});
|
|
102
107
|
const handleMobileWalletClick = (walletConnector) => __awaiter(void 0, void 0, void 0, function* () {
|
|
103
108
|
var _a;
|
|
109
|
+
logger.debug('handleMobileWalletClick', walletConnector);
|
|
104
110
|
setSelectedWalletConnectorKey(walletConnector.key);
|
|
105
111
|
// We need to set to LS when about to verify phantom wallet on mobile
|
|
106
112
|
// because the deeplink interrupts this code execution and then redirects back on a new tab.
|
|
@@ -120,10 +126,12 @@ const useWalletItemActions = () => {
|
|
|
120
126
|
onlyConnectUser({ walletConnector });
|
|
121
127
|
});
|
|
122
128
|
const handleInstalledExtensionClick = (walletConnector) => __awaiter(void 0, void 0, void 0, function* () {
|
|
129
|
+
logger.debug('handleInstalledExtensionClick', walletConnector);
|
|
123
130
|
setSelectedWalletConnectorKey(walletConnector.key);
|
|
124
131
|
setMultiWalletWidgetState('awaiting_signature', undefined, 'linking_new_wallet');
|
|
125
132
|
});
|
|
126
133
|
const handleUninstalledClick = (walletConnector) => __awaiter(void 0, void 0, void 0, function* () {
|
|
134
|
+
logger.debug('handleUninstalledClick', walletConnector);
|
|
127
135
|
setSelectedWalletConnectorKey(walletConnector.key);
|
|
128
136
|
if (!walletConnector.canConnectViaQrCode) {
|
|
129
137
|
setView('no-qr-not-installed');
|
|
@@ -145,8 +153,14 @@ const useWalletItemActions = () => {
|
|
|
145
153
|
setError(undefined);
|
|
146
154
|
});
|
|
147
155
|
const handleAlreadyConnectedWallet = (walletConnector) => __awaiter(void 0, void 0, void 0, function* () {
|
|
156
|
+
logger.debug('handleAlreadyConnectedWallet', walletConnector);
|
|
148
157
|
const connectedAccounts = yield walletConnector.getConnectedAccounts();
|
|
149
158
|
const activeAccountAlreadyLinked = linkedWallets.find((wallet) => { var _a; return wallet.address.toLowerCase() === ((_a = connectedAccounts[0]) === null || _a === void 0 ? void 0 : _a.toLowerCase()); });
|
|
159
|
+
logVerboseTroubleshootingMessage('[handleAlreadyConnectedWallet]', {
|
|
160
|
+
activeAccountAlreadyLinked,
|
|
161
|
+
connectedAccounts,
|
|
162
|
+
linkedWallets,
|
|
163
|
+
});
|
|
150
164
|
if (activeAccountAlreadyLinked) {
|
|
151
165
|
setMultiWalletWidgetState('awaiting_account_switch', 'linking_new_wallet');
|
|
152
166
|
}
|
|
@@ -176,6 +190,11 @@ const useWalletItemActions = () => {
|
|
|
176
190
|
const { walletConnector, isInstalledOnBrowser } = wallet;
|
|
177
191
|
const shouldEndWalletConnectorSession = walletConnector.connectedChain === 'FLOW' ||
|
|
178
192
|
isPhantomRedirectConnector(walletConnector);
|
|
193
|
+
logVerboseTroubleshootingMessage('[handleWalletItemClick]', {
|
|
194
|
+
mockedSDK,
|
|
195
|
+
shouldEndWalletConnectorSession,
|
|
196
|
+
wallet,
|
|
197
|
+
});
|
|
179
198
|
if (mockedSDK)
|
|
180
199
|
return;
|
|
181
200
|
if (shouldEndWalletConnectorSession) {
|