@dynamic-labs/sdk-react-core 4.31.3 → 4.31.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 +7 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +11 -11
- package/src/lib/context/ViewContext/ViewContext.cjs +2 -0
- package/src/lib/context/ViewContext/ViewContext.js +2 -0
- package/src/lib/events/ui.d.ts +4 -0
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +18 -5
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +19 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.31.4](https://github.com/dynamic-labs/dynamic-auth/compare/v4.31.3...v4.31.4) (2025-09-16)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* prevent useUserWallets from returning empty array when cancelling wallet connect connection ([#9500](https://github.com/dynamic-labs/dynamic-auth/issues/9500)) ([850f03c](https://github.com/dynamic-labs/dynamic-auth/commit/850f03cdc954da5a2af5285d873fc02a2f95e09e))
|
|
8
|
+
|
|
2
9
|
### [4.31.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.31.2...v4.31.3) (2025-09-15)
|
|
3
10
|
|
|
4
11
|
|
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": "4.31.
|
|
3
|
+
"version": "4.31.4",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@dynamic-labs/sdk-api-core": "0.0.762",
|
|
6
6
|
"@dynamic-labs-sdk/client": "0.1.0-alpha.3",
|
|
@@ -15,16 +15,16 @@
|
|
|
15
15
|
"yup": "0.32.11",
|
|
16
16
|
"react-international-phone": "4.5.0",
|
|
17
17
|
"bs58": "5.0.0",
|
|
18
|
-
"@dynamic-labs/assert-package-version": "4.31.
|
|
19
|
-
"@dynamic-labs/iconic": "4.31.
|
|
20
|
-
"@dynamic-labs/logger": "4.31.
|
|
21
|
-
"@dynamic-labs/multi-wallet": "4.31.
|
|
22
|
-
"@dynamic-labs/rpc-providers": "4.31.
|
|
23
|
-
"@dynamic-labs/store": "4.31.
|
|
24
|
-
"@dynamic-labs/types": "4.31.
|
|
25
|
-
"@dynamic-labs/utils": "4.31.
|
|
26
|
-
"@dynamic-labs/wallet-book": "4.31.
|
|
27
|
-
"@dynamic-labs/wallet-connector-core": "4.31.
|
|
18
|
+
"@dynamic-labs/assert-package-version": "4.31.4",
|
|
19
|
+
"@dynamic-labs/iconic": "4.31.4",
|
|
20
|
+
"@dynamic-labs/logger": "4.31.4",
|
|
21
|
+
"@dynamic-labs/multi-wallet": "4.31.4",
|
|
22
|
+
"@dynamic-labs/rpc-providers": "4.31.4",
|
|
23
|
+
"@dynamic-labs/store": "4.31.4",
|
|
24
|
+
"@dynamic-labs/types": "4.31.4",
|
|
25
|
+
"@dynamic-labs/utils": "4.31.4",
|
|
26
|
+
"@dynamic-labs/wallet-book": "4.31.4",
|
|
27
|
+
"@dynamic-labs/wallet-connector-core": "4.31.4",
|
|
28
28
|
"eventemitter3": "5.0.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
@@ -7,6 +7,7 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var useDynamicEvents = require('../../utils/hooks/events/useDynamicEvents/useDynamicEvents.cjs');
|
|
9
9
|
var ErrorContext = require('../ErrorContext/ErrorContext.cjs');
|
|
10
|
+
var dynamicEvents = require('../../events/dynamicEvents.cjs');
|
|
10
11
|
|
|
11
12
|
const ViewContext = React.createContext(undefined);
|
|
12
13
|
const ViewContextProvider = ({ children, initialViewType }) => {
|
|
@@ -45,6 +46,7 @@ const ViewContextProvider = ({ children, initialViewType }) => {
|
|
|
45
46
|
return;
|
|
46
47
|
clearError();
|
|
47
48
|
setStack((prev) => prev.slice(0, -1));
|
|
49
|
+
dynamicEvents.dynamicEvents.emit('goBack');
|
|
48
50
|
}, [canGoBack, clearError]);
|
|
49
51
|
const clearStackAndPush = React.useCallback((type, props, events) => {
|
|
50
52
|
clearError();
|
|
@@ -3,6 +3,7 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { createContext, useContext, useState, useMemo, useCallback } from 'react';
|
|
4
4
|
import { useInternalDynamicEvents } from '../../utils/hooks/events/useDynamicEvents/useDynamicEvents.js';
|
|
5
5
|
import { useErrorContext } from '../ErrorContext/ErrorContext.js';
|
|
6
|
+
import { dynamicEvents } from '../../events/dynamicEvents.js';
|
|
6
7
|
|
|
7
8
|
const ViewContext = createContext(undefined);
|
|
8
9
|
const ViewContextProvider = ({ children, initialViewType }) => {
|
|
@@ -41,6 +42,7 @@ const ViewContextProvider = ({ children, initialViewType }) => {
|
|
|
41
42
|
return;
|
|
42
43
|
clearError();
|
|
43
44
|
setStack((prev) => prev.slice(0, -1));
|
|
45
|
+
dynamicEvents.emit('goBack');
|
|
44
46
|
}, [canGoBack, clearError]);
|
|
45
47
|
const clearStackAndPush = useCallback((type, props, events) => {
|
|
46
48
|
clearError();
|
package/src/lib/events/ui.d.ts
CHANGED
|
@@ -163,11 +163,18 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
163
163
|
};
|
|
164
164
|
return (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ walletConnector, getAddressOpts = undefined, }) {
|
|
165
165
|
var _b;
|
|
166
|
+
const connectionCancelPromise = new utils.DeferredPromise();
|
|
167
|
+
const onGoBack = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
168
|
+
loadingAndLifecycle.setIsInitialWalletVerificationInProgress(false);
|
|
169
|
+
connectionCancelPromise.reject(new utils.GetAddressCancelledError());
|
|
170
|
+
});
|
|
166
171
|
try {
|
|
172
|
+
dynamicEvents.dynamicEvents.on('goBack', onGoBack);
|
|
173
|
+
dynamicEvents.dynamicEvents.on('authFlowClose', onGoBack);
|
|
174
|
+
dynamicEvents.dynamicEvents.once('walletAdded', unsetInitialWalletVerificationFlag.unsetInitialWalletVerificationFlag);
|
|
167
175
|
// Lock the variable that indicates that the login wallet verification is in progress
|
|
168
176
|
// Read UserWalletsContext.tsx explanation for more context
|
|
169
177
|
loadingAndLifecycle.setIsInitialWalletVerificationInProgress(true);
|
|
170
|
-
dynamicEvents.dynamicEvents.once('walletAdded', unsetInitialWalletVerificationFlag.unsetInitialWalletVerificationFlag);
|
|
171
178
|
yield showPendingConnectView.showPendingConnectView(walletConnector, pushView);
|
|
172
179
|
if (walletConnectorCore.isEmailWalletConnector(walletConnector)) {
|
|
173
180
|
if (walletConnectorCore.isEmailOTPWalletConnector(walletConnector)) {
|
|
@@ -177,16 +184,20 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
177
184
|
pushView('wait-for-email-confirmation-view');
|
|
178
185
|
}
|
|
179
186
|
}
|
|
180
|
-
|
|
187
|
+
const connectionPromise = connectWallet(walletConnector, getAddressOpts, {
|
|
188
|
+
applyHandleConnectedWallet: shouldCallCallback,
|
|
189
|
+
});
|
|
181
190
|
try {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
191
|
+
yield Promise.race([
|
|
192
|
+
connectionPromise,
|
|
193
|
+
connectionCancelPromise.promise,
|
|
194
|
+
]);
|
|
185
195
|
}
|
|
186
196
|
catch (error) {
|
|
187
197
|
handleWalletConnectionError(error);
|
|
188
198
|
return;
|
|
189
199
|
}
|
|
200
|
+
const connectionResult = yield connectionPromise;
|
|
190
201
|
// Fallback to catch any errors that were missed.
|
|
191
202
|
if (!(connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.address)) {
|
|
192
203
|
handleWalletConnectionError();
|
|
@@ -246,6 +257,8 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
246
257
|
// 3. The SDK will enter a broken state. Try signing a message with wagmi.
|
|
247
258
|
// You can also add a "pause on exception" breakpoint in the debugger and see what happens during verification.
|
|
248
259
|
unsetInitialWalletVerificationFlag.unsetInitialWalletVerificationFlagWithTimeout();
|
|
260
|
+
dynamicEvents.dynamicEvents.removeListener('goBack', onGoBack);
|
|
261
|
+
dynamicEvents.dynamicEvents.removeListener('authFlowClose', onGoBack);
|
|
249
262
|
}
|
|
250
263
|
});
|
|
251
264
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../../_virtual/_tslib.js';
|
|
3
|
-
import { StorageService, CustomError, GetAddressCancelledError } from '@dynamic-labs/utils';
|
|
3
|
+
import { DeferredPromise, StorageService, CustomError, GetAddressCancelledError } from '@dynamic-labs/utils';
|
|
4
4
|
import { isEmailWalletConnector, isEmailOTPWalletConnector, isBloctoConnector } from '@dynamic-labs/wallet-connector-core';
|
|
5
5
|
import { useCaptchaContext } from '../../../../context/CaptchaContext/CaptchaContext.js';
|
|
6
6
|
import 'react';
|
|
@@ -159,11 +159,18 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
159
159
|
};
|
|
160
160
|
return (_a) => __awaiter(void 0, [_a], void 0, function* ({ walletConnector, getAddressOpts = undefined, }) {
|
|
161
161
|
var _b;
|
|
162
|
+
const connectionCancelPromise = new DeferredPromise();
|
|
163
|
+
const onGoBack = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
164
|
+
setIsInitialWalletVerificationInProgress(false);
|
|
165
|
+
connectionCancelPromise.reject(new GetAddressCancelledError());
|
|
166
|
+
});
|
|
162
167
|
try {
|
|
168
|
+
dynamicEvents.on('goBack', onGoBack);
|
|
169
|
+
dynamicEvents.on('authFlowClose', onGoBack);
|
|
170
|
+
dynamicEvents.once('walletAdded', unsetInitialWalletVerificationFlag);
|
|
163
171
|
// Lock the variable that indicates that the login wallet verification is in progress
|
|
164
172
|
// Read UserWalletsContext.tsx explanation for more context
|
|
165
173
|
setIsInitialWalletVerificationInProgress(true);
|
|
166
|
-
dynamicEvents.once('walletAdded', unsetInitialWalletVerificationFlag);
|
|
167
174
|
yield showPendingConnectView(walletConnector, pushView);
|
|
168
175
|
if (isEmailWalletConnector(walletConnector)) {
|
|
169
176
|
if (isEmailOTPWalletConnector(walletConnector)) {
|
|
@@ -173,16 +180,20 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
173
180
|
pushView('wait-for-email-confirmation-view');
|
|
174
181
|
}
|
|
175
182
|
}
|
|
176
|
-
|
|
183
|
+
const connectionPromise = connectWallet(walletConnector, getAddressOpts, {
|
|
184
|
+
applyHandleConnectedWallet: shouldCallCallback,
|
|
185
|
+
});
|
|
177
186
|
try {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
187
|
+
yield Promise.race([
|
|
188
|
+
connectionPromise,
|
|
189
|
+
connectionCancelPromise.promise,
|
|
190
|
+
]);
|
|
181
191
|
}
|
|
182
192
|
catch (error) {
|
|
183
193
|
handleWalletConnectionError(error);
|
|
184
194
|
return;
|
|
185
195
|
}
|
|
196
|
+
const connectionResult = yield connectionPromise;
|
|
186
197
|
// Fallback to catch any errors that were missed.
|
|
187
198
|
if (!(connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.address)) {
|
|
188
199
|
handleWalletConnectionError();
|
|
@@ -242,6 +253,8 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
242
253
|
// 3. The SDK will enter a broken state. Try signing a message with wagmi.
|
|
243
254
|
// You can also add a "pause on exception" breakpoint in the debugger and see what happens during verification.
|
|
244
255
|
unsetInitialWalletVerificationFlagWithTimeout();
|
|
256
|
+
dynamicEvents.removeListener('goBack', onGoBack);
|
|
257
|
+
dynamicEvents.removeListener('authFlowClose', onGoBack);
|
|
245
258
|
}
|
|
246
259
|
});
|
|
247
260
|
};
|