@dynamic-labs/sdk-react-core 4.9.0 → 4.9.1-preview.0
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 +8 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +11 -11
- package/src/lib/components/NetworkPicker/components/NetworkDropdown/NetworkDropdown.cjs +2 -11
- package/src/lib/components/NetworkPicker/components/NetworkDropdown/NetworkDropdown.js +2 -11
- package/src/lib/context/DynamicContext/DynamicContext.cjs +3 -1
- package/src/lib/context/DynamicContext/DynamicContext.js +4 -2
- package/src/lib/context/DynamicContext/hooks/useShowAuthFlow/useShowAuthFlow.cjs +1 -1
- package/src/lib/context/DynamicContext/hooks/useShowAuthFlow/useShowAuthFlow.js +1 -1
- package/src/lib/context/DynamicContext/types/IDynamicContext.d.ts +3 -2
- package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.cjs +1 -1
- package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.js +1 -1
- package/src/lib/utils/hooks/useGlobalLoading/useGlobalLoading.cjs +7 -1
- package/src/lib/utils/hooks/useGlobalLoading/useGlobalLoading.js +7 -1
- package/src/lib/utils/hooks/useWalletItemActions/useHandleWalletItem/useHandleWalletItem.cjs +4 -2
- package/src/lib/utils/hooks/useWalletItemActions/useHandleWalletItem/useHandleWalletItem.js +5 -3
- package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.cjs +7 -5
- package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.js +7 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.9.1-preview.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.9.0...v4.9.1-preview.0) (2025-03-07)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* 7702 on sepolia ([#8242](https://github.com/dynamic-labs/dynamic-auth/issues/8242)) ([8e1c63f](https://github.com/dynamic-labs/dynamic-auth/commit/8e1c63f240024f419e12787636dd2ebaacf8da94))
|
|
8
|
+
* embedded widget race condition that would show both embedded and non-embedded widgets at the same time ([8a52778](https://github.com/dynamic-labs/dynamic-auth/commit/8a5277888489e03871532331760c197aa6216495))
|
|
9
|
+
|
|
2
10
|
## [4.9.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.8.6...v4.9.0) (2025-03-07)
|
|
3
11
|
|
|
4
12
|
|
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.9.0",
|
|
3
|
+
"version": "4.9.1-preview.0",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@dynamic-labs/sdk-api-core": "0.0.638",
|
|
6
6
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
"yup": "0.32.11",
|
|
15
15
|
"react-international-phone": "4.2.5",
|
|
16
16
|
"bs58": "5.0.0",
|
|
17
|
-
"@dynamic-labs/assert-package-version": "4.9.0",
|
|
18
|
-
"@dynamic-labs/iconic": "4.9.0",
|
|
19
|
-
"@dynamic-labs/logger": "4.9.0",
|
|
20
|
-
"@dynamic-labs/multi-wallet": "4.9.0",
|
|
21
|
-
"@dynamic-labs/rpc-providers": "4.9.0",
|
|
22
|
-
"@dynamic-labs/store": "4.9.0",
|
|
23
|
-
"@dynamic-labs/types": "4.9.0",
|
|
24
|
-
"@dynamic-labs/utils": "4.9.0",
|
|
25
|
-
"@dynamic-labs/wallet-book": "4.9.0",
|
|
26
|
-
"@dynamic-labs/wallet-connector-core": "4.9.0",
|
|
17
|
+
"@dynamic-labs/assert-package-version": "4.9.1-preview.0",
|
|
18
|
+
"@dynamic-labs/iconic": "4.9.1-preview.0",
|
|
19
|
+
"@dynamic-labs/logger": "4.9.1-preview.0",
|
|
20
|
+
"@dynamic-labs/multi-wallet": "4.9.1-preview.0",
|
|
21
|
+
"@dynamic-labs/rpc-providers": "4.9.1-preview.0",
|
|
22
|
+
"@dynamic-labs/store": "4.9.1-preview.0",
|
|
23
|
+
"@dynamic-labs/types": "4.9.1-preview.0",
|
|
24
|
+
"@dynamic-labs/utils": "4.9.1-preview.0",
|
|
25
|
+
"@dynamic-labs/wallet-book": "4.9.1-preview.0",
|
|
26
|
+
"@dynamic-labs/wallet-connector-core": "4.9.1-preview.0",
|
|
27
27
|
"eventemitter3": "5.0.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
@@ -6,15 +6,14 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
6
6
|
var _tslib = require('../../../../../../_virtual/_tslib.cjs');
|
|
7
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
8
|
var React = require('react');
|
|
9
|
-
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
10
9
|
require('../../../MenuList/Dropdown/Dropdown.cjs');
|
|
11
10
|
var MenuList = require('../../../MenuList/MenuList/MenuList.cjs');
|
|
12
11
|
var NetworkAction = require('../NetworkAction/NetworkAction.cjs');
|
|
13
12
|
var isNetworkUnsupported = require('../../../../utils/functions/isNetworkUnsupported/isNetworkUnsupported.cjs');
|
|
14
|
-
var usePromise = require('../../../../utils/hooks/usePromise/usePromise.cjs');
|
|
15
13
|
require('@dynamic-labs/sdk-api-core');
|
|
16
14
|
var logger = require('../../../../shared/logger.cjs');
|
|
17
15
|
require('@dynamic-labs/iconic');
|
|
16
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
18
17
|
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
19
18
|
require('@dynamic-labs/wallet-book');
|
|
20
19
|
require('@dynamic-labs/utils');
|
|
@@ -24,13 +23,6 @@ require('../../../../shared/consts/index.cjs');
|
|
|
24
23
|
|
|
25
24
|
const NetworkDropdown = ({ anchorRef, connector, customCallbackOnSuccess, setIsNetworkPickerOpen, isNetworkPickerOpen, currentNetwork, className, checkboxClassName, }) => {
|
|
26
25
|
const [newNetworkId, setNewNetworkId] = React.useState(undefined);
|
|
27
|
-
const { data: wcSupportedWalletNetworks } = usePromise.usePromise(() => walletConnectorCore.isWalletConnectConnector(connector)
|
|
28
|
-
? connector === null || connector === void 0 ? void 0 : connector.getSupportedNetworks()
|
|
29
|
-
: Promise.resolve(undefined), {
|
|
30
|
-
deps: [connector, isNetworkPickerOpen],
|
|
31
|
-
enabled: connector.isWalletConnect,
|
|
32
|
-
initialData: undefined,
|
|
33
|
-
});
|
|
34
26
|
if (!connector) {
|
|
35
27
|
return null;
|
|
36
28
|
}
|
|
@@ -60,8 +52,7 @@ const NetworkDropdown = ({ anchorRef, connector, customCallbackOnSuccess, setIsN
|
|
|
60
52
|
return (jsxRuntime.jsx(MenuList.MenuList, { className: className, isOpen: isNetworkPickerOpen, onClickClose: () => setIsNetworkPickerOpen(false), popperProps: {
|
|
61
53
|
anchorOrigin: 'bottom-left',
|
|
62
54
|
anchorRef,
|
|
63
|
-
}, mobileTitle: 'Select network', children: enabledNetworks.map(({ name, networkId, vanityName, iconUrls }) => (jsxRuntime.jsx(NetworkAction.NetworkAction, { iconUrl: iconUrls === null || iconUrls === void 0 ? void 0 : iconUrls[0], networkId: networkId, networkName: vanityName || name, network: currentNetwork, onClick: handleNetworkChange, checkboxClassName: checkboxClassName, newNetworkId: newNetworkId,
|
|
64
|
-
!wcSupportedWalletNetworks.includes(`${networkId}`) }, networkId))) }));
|
|
55
|
+
}, mobileTitle: 'Select network', children: enabledNetworks.map(({ name, networkId, vanityName, iconUrls }) => (jsxRuntime.jsx(NetworkAction.NetworkAction, { iconUrl: iconUrls === null || iconUrls === void 0 ? void 0 : iconUrls[0], networkId: networkId, networkName: vanityName || name, network: currentNetwork, onClick: handleNetworkChange, checkboxClassName: checkboxClassName, newNetworkId: newNetworkId }, networkId))) }));
|
|
65
56
|
};
|
|
66
57
|
|
|
67
58
|
exports.NetworkDropdown = NetworkDropdown;
|
|
@@ -2,15 +2,14 @@
|
|
|
2
2
|
import { __awaiter } from '../../../../../../_virtual/_tslib.js';
|
|
3
3
|
import { jsx } from 'react/jsx-runtime';
|
|
4
4
|
import { useState } from 'react';
|
|
5
|
-
import { isWalletConnectConnector } from '@dynamic-labs/wallet-connector-core';
|
|
6
5
|
import '../../../MenuList/Dropdown/Dropdown.js';
|
|
7
6
|
import { MenuList } from '../../../MenuList/MenuList/MenuList.js';
|
|
8
7
|
import { NetworkAction } from '../NetworkAction/NetworkAction.js';
|
|
9
8
|
import { isNetworkUnsupported } from '../../../../utils/functions/isNetworkUnsupported/isNetworkUnsupported.js';
|
|
10
|
-
import { usePromise } from '../../../../utils/hooks/usePromise/usePromise.js';
|
|
11
9
|
import '@dynamic-labs/sdk-api-core';
|
|
12
10
|
import { logger } from '../../../../shared/logger.js';
|
|
13
11
|
import '@dynamic-labs/iconic';
|
|
12
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
14
13
|
import '../../../../context/ViewContext/ViewContext.js';
|
|
15
14
|
import '@dynamic-labs/wallet-book';
|
|
16
15
|
import '@dynamic-labs/utils';
|
|
@@ -20,13 +19,6 @@ import '../../../../shared/consts/index.js';
|
|
|
20
19
|
|
|
21
20
|
const NetworkDropdown = ({ anchorRef, connector, customCallbackOnSuccess, setIsNetworkPickerOpen, isNetworkPickerOpen, currentNetwork, className, checkboxClassName, }) => {
|
|
22
21
|
const [newNetworkId, setNewNetworkId] = useState(undefined);
|
|
23
|
-
const { data: wcSupportedWalletNetworks } = usePromise(() => isWalletConnectConnector(connector)
|
|
24
|
-
? connector === null || connector === void 0 ? void 0 : connector.getSupportedNetworks()
|
|
25
|
-
: Promise.resolve(undefined), {
|
|
26
|
-
deps: [connector, isNetworkPickerOpen],
|
|
27
|
-
enabled: connector.isWalletConnect,
|
|
28
|
-
initialData: undefined,
|
|
29
|
-
});
|
|
30
22
|
if (!connector) {
|
|
31
23
|
return null;
|
|
32
24
|
}
|
|
@@ -56,8 +48,7 @@ const NetworkDropdown = ({ anchorRef, connector, customCallbackOnSuccess, setIsN
|
|
|
56
48
|
return (jsx(MenuList, { className: className, isOpen: isNetworkPickerOpen, onClickClose: () => setIsNetworkPickerOpen(false), popperProps: {
|
|
57
49
|
anchorOrigin: 'bottom-left',
|
|
58
50
|
anchorRef,
|
|
59
|
-
}, mobileTitle: 'Select network', children: enabledNetworks.map(({ name, networkId, vanityName, iconUrls }) => (jsx(NetworkAction, { iconUrl: iconUrls === null || iconUrls === void 0 ? void 0 : iconUrls[0], networkId: networkId, networkName: vanityName || name, network: currentNetwork, onClick: handleNetworkChange, checkboxClassName: checkboxClassName, newNetworkId: newNetworkId,
|
|
60
|
-
!wcSupportedWalletNetworks.includes(`${networkId}`) }, networkId))) }));
|
|
51
|
+
}, mobileTitle: 'Select network', children: enabledNetworks.map(({ name, networkId, vanityName, iconUrls }) => (jsx(NetworkAction, { iconUrl: iconUrls === null || iconUrls === void 0 ? void 0 : iconUrls[0], networkId: networkId, networkName: vanityName || name, network: currentNetwork, onClick: handleNetworkChange, checkboxClassName: checkboxClassName, newNetworkId: newNetworkId }, networkId))) }));
|
|
61
52
|
};
|
|
62
53
|
|
|
63
54
|
export { NetworkDropdown };
|
|
@@ -291,7 +291,7 @@ const InnerDynamicContextProvider = (props) => {
|
|
|
291
291
|
// which are only available further down and have would have circular dependencies
|
|
292
292
|
const [requiredWalletsConnected, setRequiredWalletsConnected] = React.useState(false);
|
|
293
293
|
const isUserAuthenticated = Boolean(authMode === 'connect-and-sign' ? user$1 : requiredWalletsConnected);
|
|
294
|
-
const isRenderingEmbeddedAuthFlow = React.
|
|
294
|
+
const [isRenderingEmbeddedAuthFlow, setIsRenderingEmbeddedAuthFlow] = React.useState(false);
|
|
295
295
|
const [showAuthFlow, setShowAuthFlow] = useShowAuthFlow.useShowAuthFlow({
|
|
296
296
|
isAuthenticated: isUserAuthenticated,
|
|
297
297
|
isMultiWalletEnabled: multiWallet,
|
|
@@ -560,6 +560,7 @@ const InnerDynamicContextProvider = (props) => {
|
|
|
560
560
|
setBridgeOnboardingCompleted,
|
|
561
561
|
setCallback,
|
|
562
562
|
setDesktopUri,
|
|
563
|
+
setIsRenderingEmbeddedAuthFlow,
|
|
563
564
|
setIsSingleWalletAccount,
|
|
564
565
|
setLegacyIsVerifying,
|
|
565
566
|
setLogInWithEmail,
|
|
@@ -636,6 +637,7 @@ const InnerDynamicContextProvider = (props) => {
|
|
|
636
637
|
handlers,
|
|
637
638
|
i18nSDKInstance,
|
|
638
639
|
isBridgeFlow,
|
|
640
|
+
isRenderingEmbeddedAuthFlow,
|
|
639
641
|
isSingleWalletAccount,
|
|
640
642
|
legacyIsVerifying,
|
|
641
643
|
linkedWallets,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
3
3
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
|
-
import { createContext, useState, useMemo,
|
|
4
|
+
import { createContext, useState, useMemo, useEffect, useCallback } from 'react';
|
|
5
5
|
import { I18nextProvider } from 'react-i18next';
|
|
6
6
|
import { getIconicSpriteUrl } from '@dynamic-labs/iconic';
|
|
7
7
|
import { Logger } from '@dynamic-labs/logger';
|
|
@@ -287,7 +287,7 @@ const InnerDynamicContextProvider = (props) => {
|
|
|
287
287
|
// which are only available further down and have would have circular dependencies
|
|
288
288
|
const [requiredWalletsConnected, setRequiredWalletsConnected] = useState(false);
|
|
289
289
|
const isUserAuthenticated = Boolean(authMode === 'connect-and-sign' ? user : requiredWalletsConnected);
|
|
290
|
-
const isRenderingEmbeddedAuthFlow =
|
|
290
|
+
const [isRenderingEmbeddedAuthFlow, setIsRenderingEmbeddedAuthFlow] = useState(false);
|
|
291
291
|
const [showAuthFlow, setShowAuthFlow] = useShowAuthFlow({
|
|
292
292
|
isAuthenticated: isUserAuthenticated,
|
|
293
293
|
isMultiWalletEnabled: multiWallet,
|
|
@@ -556,6 +556,7 @@ const InnerDynamicContextProvider = (props) => {
|
|
|
556
556
|
setBridgeOnboardingCompleted,
|
|
557
557
|
setCallback,
|
|
558
558
|
setDesktopUri,
|
|
559
|
+
setIsRenderingEmbeddedAuthFlow,
|
|
559
560
|
setIsSingleWalletAccount,
|
|
560
561
|
setLegacyIsVerifying,
|
|
561
562
|
setLogInWithEmail,
|
|
@@ -632,6 +633,7 @@ const InnerDynamicContextProvider = (props) => {
|
|
|
632
633
|
handlers,
|
|
633
634
|
i18nSDKInstance,
|
|
634
635
|
isBridgeFlow,
|
|
636
|
+
isRenderingEmbeddedAuthFlow,
|
|
635
637
|
isSingleWalletAccount,
|
|
636
638
|
legacyIsVerifying,
|
|
637
639
|
linkedWallets,
|
|
@@ -43,7 +43,7 @@ const useShowAuthFlow = ({ isAuthenticated, isRenderingEmbeddedAuthFlow, isMulti
|
|
|
43
43
|
dynamicEvents.dynamicEvents.emit('authFlowClose');
|
|
44
44
|
}
|
|
45
45
|
if (value) {
|
|
46
|
-
if (ignoreIfIsEmbeddedWidget && isRenderingEmbeddedAuthFlow
|
|
46
|
+
if (ignoreIfIsEmbeddedWidget && isRenderingEmbeddedAuthFlow)
|
|
47
47
|
return;
|
|
48
48
|
if (performMultiWalletChecks && isAuthenticated) {
|
|
49
49
|
if (!isMultiWalletEnabled) {
|
|
@@ -39,7 +39,7 @@ const useShowAuthFlow = ({ isAuthenticated, isRenderingEmbeddedAuthFlow, isMulti
|
|
|
39
39
|
dynamicEvents.emit('authFlowClose');
|
|
40
40
|
}
|
|
41
41
|
if (value) {
|
|
42
|
-
if (ignoreIfIsEmbeddedWidget && isRenderingEmbeddedAuthFlow
|
|
42
|
+
if (ignoreIfIsEmbeddedWidget && isRenderingEmbeddedAuthFlow)
|
|
43
43
|
return;
|
|
44
44
|
if (performMultiWalletChecks && isAuthenticated) {
|
|
45
45
|
if (!isMultiWalletEnabled) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Dispatch,
|
|
1
|
+
import { Dispatch, ReactNode, SetStateAction } from 'react';
|
|
2
2
|
import { changeLanguage } from 'i18next';
|
|
3
3
|
import { CountryIso2 } from 'react-international-phone';
|
|
4
4
|
import { NameServiceData, ProjectSettings } from '@dynamic-labs/sdk-api-core';
|
|
@@ -64,7 +64,7 @@ export interface IDynamicContext {
|
|
|
64
64
|
handlers?: DynamicHandlers;
|
|
65
65
|
isBridgeFlow: boolean;
|
|
66
66
|
/** Whether there is an instance of DynamicEmbeddedAuthFlow being rendered */
|
|
67
|
-
isRenderingEmbeddedAuthFlow:
|
|
67
|
+
isRenderingEmbeddedAuthFlow: boolean;
|
|
68
68
|
isSingleWalletAccount: boolean;
|
|
69
69
|
/**
|
|
70
70
|
* Legacy boolean flag used in useVerifyOnAwaitingSignature. Used to be called "isVerifying"
|
|
@@ -80,6 +80,7 @@ export interface IDynamicContext {
|
|
|
80
80
|
loginWithEmail: boolean;
|
|
81
81
|
selectedTabIndex: number;
|
|
82
82
|
selectedTabSettings: WalletListViewTabItem | undefined;
|
|
83
|
+
setIsRenderingEmbeddedAuthFlow: Dispatch<SetStateAction<boolean>>;
|
|
83
84
|
tabsItems: WalletListViewTabItem[] | undefined;
|
|
84
85
|
setSelectedTabIndex: Dispatch<SetStateAction<number>>;
|
|
85
86
|
multiAsset: boolean;
|
|
@@ -112,7 +112,7 @@ const useRedirectSocialHandler = ({ setSocialProvider, }) => {
|
|
|
112
112
|
setSocialProvider(socialSignInProvider);
|
|
113
113
|
clearStackAndPush('social-redirect-view');
|
|
114
114
|
// Only open the auth flow when the embedded widget is not rendered
|
|
115
|
-
if (!isRenderingEmbeddedAuthFlow
|
|
115
|
+
if (!isRenderingEmbeddedAuthFlow) {
|
|
116
116
|
setShowAuthFlow(true);
|
|
117
117
|
}
|
|
118
118
|
}, [
|
|
@@ -108,7 +108,7 @@ const useRedirectSocialHandler = ({ setSocialProvider, }) => {
|
|
|
108
108
|
setSocialProvider(socialSignInProvider);
|
|
109
109
|
clearStackAndPush('social-redirect-view');
|
|
110
110
|
// Only open the auth flow when the embedded widget is not rendered
|
|
111
|
-
if (!isRenderingEmbeddedAuthFlow
|
|
111
|
+
if (!isRenderingEmbeddedAuthFlow) {
|
|
112
112
|
setShowAuthFlow(true);
|
|
113
113
|
}
|
|
114
114
|
}, [
|
|
@@ -9,6 +9,7 @@ var logger = require('../../../shared/logger.cjs');
|
|
|
9
9
|
var index = require('../../../shared/utils/functions/lastAuthenticatedAccount/index.cjs');
|
|
10
10
|
var shouldFetchNonce = require('../../../shared/utils/functions/shouldFetchNonce/shouldFetchNonce.cjs');
|
|
11
11
|
var loadingAndLifecycle = require('../../../store/state/loadingAndLifecycle.cjs');
|
|
12
|
+
var connectorsInitializing = require('../../../store/state/connectorsInitializing/connectorsInitializing.cjs');
|
|
12
13
|
|
|
13
14
|
const useGlobalLoading = ({ authMode, connectedInfo, connectedWallets, projectSettings, primaryWalletId, primaryWallet, user, isUserLoading, walletBook: walletBook$1, enableInstrumentation, appName, environmentId, nonce, }) => {
|
|
14
15
|
var _a;
|
|
@@ -16,6 +17,8 @@ const useGlobalLoading = ({ authMode, connectedInfo, connectedWallets, projectSe
|
|
|
16
17
|
const hasLoaded = React.useRef(false);
|
|
17
18
|
const loadingStart = React.useRef(new Date().getTime());
|
|
18
19
|
const { sessionValidation } = loadingAndLifecycle.useLoadingAndLifecycle();
|
|
20
|
+
const connectorsInitializingState = connectorsInitializing.useConnectorsInitializing();
|
|
21
|
+
const isWaitingForConnectorsInitialization = React.useMemo(() => Object.values(connectorsInitializingState).some(Boolean), [connectorsInitializingState]);
|
|
19
22
|
const isFetchingNonce = React.useMemo(() => shouldFetchNonce.shouldFetchNonce({
|
|
20
23
|
authMode,
|
|
21
24
|
}) && !nonce, [authMode, nonce]);
|
|
@@ -56,12 +59,14 @@ const useGlobalLoading = ({ authMode, connectedInfo, connectedWallets, projectSe
|
|
|
56
59
|
connectedWallets.length === 0;
|
|
57
60
|
const isValidatingSession = !sessionValidation;
|
|
58
61
|
logger.logger.logVerboseTroubleshootingMessage('[useGlobalLoading] SDK loading', {
|
|
62
|
+
connectorsInitializingState,
|
|
59
63
|
isConnectOnlyWalletsLoading,
|
|
60
64
|
isFetchingNonce,
|
|
61
65
|
isPrimaryWalletLoading,
|
|
62
66
|
isProjectSettingsLoading,
|
|
63
67
|
isUserLoading,
|
|
64
68
|
isValidatingSession,
|
|
69
|
+
isWaitingForConnectorsInitialization,
|
|
65
70
|
isWalletBookLoading,
|
|
66
71
|
});
|
|
67
72
|
if (!isWalletBookLoading &&
|
|
@@ -70,7 +75,8 @@ const useGlobalLoading = ({ authMode, connectedInfo, connectedWallets, projectSe
|
|
|
70
75
|
!isPrimaryWalletLoading &&
|
|
71
76
|
!isConnectOnlyWalletsLoading &&
|
|
72
77
|
!isValidatingSession &&
|
|
73
|
-
!isFetchingNonce
|
|
78
|
+
!isFetchingNonce &&
|
|
79
|
+
!isWaitingForConnectorsInitialization) {
|
|
74
80
|
finishLoading();
|
|
75
81
|
}
|
|
76
82
|
return hasLoaded.current;
|
|
@@ -5,6 +5,7 @@ import { logger } from '../../../shared/logger.js';
|
|
|
5
5
|
import { lastAuthenticatedAccount } from '../../../shared/utils/functions/lastAuthenticatedAccount/index.js';
|
|
6
6
|
import { shouldFetchNonce } from '../../../shared/utils/functions/shouldFetchNonce/shouldFetchNonce.js';
|
|
7
7
|
import { useLoadingAndLifecycle } from '../../../store/state/loadingAndLifecycle.js';
|
|
8
|
+
import { useConnectorsInitializing } from '../../../store/state/connectorsInitializing/connectorsInitializing.js';
|
|
8
9
|
|
|
9
10
|
const useGlobalLoading = ({ authMode, connectedInfo, connectedWallets, projectSettings, primaryWalletId, primaryWallet, user, isUserLoading, walletBook, enableInstrumentation, appName, environmentId, nonce, }) => {
|
|
10
11
|
var _a;
|
|
@@ -12,6 +13,8 @@ const useGlobalLoading = ({ authMode, connectedInfo, connectedWallets, projectSe
|
|
|
12
13
|
const hasLoaded = useRef(false);
|
|
13
14
|
const loadingStart = useRef(new Date().getTime());
|
|
14
15
|
const { sessionValidation } = useLoadingAndLifecycle();
|
|
16
|
+
const connectorsInitializingState = useConnectorsInitializing();
|
|
17
|
+
const isWaitingForConnectorsInitialization = useMemo(() => Object.values(connectorsInitializingState).some(Boolean), [connectorsInitializingState]);
|
|
15
18
|
const isFetchingNonce = useMemo(() => shouldFetchNonce({
|
|
16
19
|
authMode,
|
|
17
20
|
}) && !nonce, [authMode, nonce]);
|
|
@@ -52,12 +55,14 @@ const useGlobalLoading = ({ authMode, connectedInfo, connectedWallets, projectSe
|
|
|
52
55
|
connectedWallets.length === 0;
|
|
53
56
|
const isValidatingSession = !sessionValidation;
|
|
54
57
|
logger.logVerboseTroubleshootingMessage('[useGlobalLoading] SDK loading', {
|
|
58
|
+
connectorsInitializingState,
|
|
55
59
|
isConnectOnlyWalletsLoading,
|
|
56
60
|
isFetchingNonce,
|
|
57
61
|
isPrimaryWalletLoading,
|
|
58
62
|
isProjectSettingsLoading,
|
|
59
63
|
isUserLoading,
|
|
60
64
|
isValidatingSession,
|
|
65
|
+
isWaitingForConnectorsInitialization,
|
|
61
66
|
isWalletBookLoading,
|
|
62
67
|
});
|
|
63
68
|
if (!isWalletBookLoading &&
|
|
@@ -66,7 +71,8 @@ const useGlobalLoading = ({ authMode, connectedInfo, connectedWallets, projectSe
|
|
|
66
71
|
!isPrimaryWalletLoading &&
|
|
67
72
|
!isConnectOnlyWalletsLoading &&
|
|
68
73
|
!isValidatingSession &&
|
|
69
|
-
!isFetchingNonce
|
|
74
|
+
!isFetchingNonce &&
|
|
75
|
+
!isWaitingForConnectorsInitialization) {
|
|
70
76
|
finishLoading();
|
|
71
77
|
}
|
|
72
78
|
return hasLoaded.current;
|
package/src/lib/utils/hooks/useWalletItemActions/useHandleWalletItem/useHandleWalletItem.cjs
CHANGED
|
@@ -210,7 +210,8 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
|
|
|
210
210
|
const handleWalletItemClick = (wallet) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
211
211
|
const { walletConnector, isInstalledOnBrowser } = wallet;
|
|
212
212
|
const shouldEndWalletConnectorSession = walletConnector.connectedChain === 'FLOW' ||
|
|
213
|
-
walletConnectorCore.isPhantomRedirectConnector(walletConnector)
|
|
213
|
+
walletConnectorCore.isPhantomRedirectConnector(walletConnector) ||
|
|
214
|
+
walletConnectorCore.isWalletConnectConnector(walletConnector);
|
|
214
215
|
logger.logger.logVerboseTroubleshootingMessage('[handleWalletItemClick]', {
|
|
215
216
|
mockedSDK,
|
|
216
217
|
shouldEndWalletConnectorSession,
|
|
@@ -241,7 +242,8 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
|
|
|
241
242
|
}
|
|
242
243
|
if (!allowAlreadyConnectedWallet &&
|
|
243
244
|
isSelectedWalletAlreadyConnected.isSelectedWalletAlreadyConnected(linkedWallets, walletConnector, user) &&
|
|
244
|
-
walletConnector.connectedChain !== 'FLOW'
|
|
245
|
+
walletConnector.connectedChain !== 'FLOW' &&
|
|
246
|
+
!walletConnector.isWalletConnect) {
|
|
245
247
|
// wallet is already connected
|
|
246
248
|
handleAlreadyConnectedWallet(walletConnector);
|
|
247
249
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../../_virtual/_tslib.js';
|
|
3
3
|
import { StorageService, isMobile, UserRejectedRequestError } from '@dynamic-labs/utils';
|
|
4
|
-
import { isPhantomRedirectConnector } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
+
import { isPhantomRedirectConnector, isWalletConnectConnector } 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';
|
|
@@ -206,7 +206,8 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
|
|
|
206
206
|
const handleWalletItemClick = (wallet) => __awaiter(void 0, void 0, void 0, function* () {
|
|
207
207
|
const { walletConnector, isInstalledOnBrowser } = wallet;
|
|
208
208
|
const shouldEndWalletConnectorSession = walletConnector.connectedChain === 'FLOW' ||
|
|
209
|
-
isPhantomRedirectConnector(walletConnector)
|
|
209
|
+
isPhantomRedirectConnector(walletConnector) ||
|
|
210
|
+
isWalletConnectConnector(walletConnector);
|
|
210
211
|
logger.logVerboseTroubleshootingMessage('[handleWalletItemClick]', {
|
|
211
212
|
mockedSDK,
|
|
212
213
|
shouldEndWalletConnectorSession,
|
|
@@ -237,7 +238,8 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
|
|
|
237
238
|
}
|
|
238
239
|
if (!allowAlreadyConnectedWallet &&
|
|
239
240
|
isSelectedWalletAlreadyConnected(linkedWallets, walletConnector, user) &&
|
|
240
|
-
walletConnector.connectedChain !== 'FLOW'
|
|
241
|
+
walletConnector.connectedChain !== 'FLOW' &&
|
|
242
|
+
!walletConnector.isWalletConnect) {
|
|
241
243
|
// wallet is already connected
|
|
242
244
|
handleAlreadyConnectedWallet(walletConnector);
|
|
243
245
|
}
|
package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.cjs
CHANGED
|
@@ -102,12 +102,14 @@ var SandboxIndicatorWrapper = require('../../../components/SandboxIndicatorWrapp
|
|
|
102
102
|
|
|
103
103
|
const DynamicEmbeddedAuthFlow = ({ background = 'none', className, style, }) => {
|
|
104
104
|
const hide = useIsLoggedIn.useIsLoggedIn();
|
|
105
|
-
const { projectSettings,
|
|
106
|
-
isRenderingEmbeddedAuthFlow.current = !hide;
|
|
105
|
+
const { projectSettings, setIsRenderingEmbeddedAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
107
106
|
// Keep isRenderingEmbeddedAuthFlow up to date
|
|
108
|
-
React.useEffect(() =>
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
React.useEffect(() => {
|
|
108
|
+
setIsRenderingEmbeddedAuthFlow(!hide);
|
|
109
|
+
return () => {
|
|
110
|
+
setIsRenderingEmbeddedAuthFlow(false);
|
|
111
|
+
};
|
|
112
|
+
}, [setIsRenderingEmbeddedAuthFlow, hide]);
|
|
111
113
|
if (hide)
|
|
112
114
|
return null;
|
|
113
115
|
const content = (jsxRuntime.jsx(DynamicAuthLayout.DynamicAuthLayout, { className: className, style: style, projectSettings: projectSettings, children: jsxRuntime.jsx(RenderView.RenderView, {}) }));
|
package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.js
CHANGED
|
@@ -98,12 +98,14 @@ import { SandboxIndicatorWrapper } from '../../../components/SandboxIndicatorWra
|
|
|
98
98
|
|
|
99
99
|
const DynamicEmbeddedAuthFlow = ({ background = 'none', className, style, }) => {
|
|
100
100
|
const hide = useIsLoggedIn();
|
|
101
|
-
const { projectSettings,
|
|
102
|
-
isRenderingEmbeddedAuthFlow.current = !hide;
|
|
101
|
+
const { projectSettings, setIsRenderingEmbeddedAuthFlow } = useInternalDynamicContext();
|
|
103
102
|
// Keep isRenderingEmbeddedAuthFlow up to date
|
|
104
|
-
useEffect(() =>
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
setIsRenderingEmbeddedAuthFlow(!hide);
|
|
105
|
+
return () => {
|
|
106
|
+
setIsRenderingEmbeddedAuthFlow(false);
|
|
107
|
+
};
|
|
108
|
+
}, [setIsRenderingEmbeddedAuthFlow, hide]);
|
|
107
109
|
if (hide)
|
|
108
110
|
return null;
|
|
109
111
|
const content = (jsx(DynamicAuthLayout, { className: className, style: style, projectSettings: projectSettings, children: jsx(RenderView, {}) }));
|