@dynamic-labs/sdk-react-core 1.4.2 → 1.4.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 +20 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +11 -11
- package/src/index.cjs +13 -13
- package/src/index.d.ts +289 -9
- package/src/lib/components/DynamicFooter/DynamicFooter.cjs +8 -1
- package/src/lib/components/DynamicFooter/DynamicFooter.js +8 -1
- package/src/lib/components/Toolkit/Toolkit.cjs +2 -3
- package/src/lib/components/Toolkit/Toolkit.js +2 -3
- package/src/lib/components/Toolkit/components/index.d.ts +0 -1
- package/src/lib/context/DynamicContext/DynamicContext.cjs +28 -33
- package/src/lib/context/DynamicContext/DynamicContext.js +30 -35
- package/src/lib/context/DynamicContext/handleDisconnectWallet/handleDisconnectWallet.cjs +1 -4
- package/src/lib/context/DynamicContext/handleDisconnectWallet/handleDisconnectWallet.d.ts +1 -7
- package/src/lib/context/DynamicContext/handleDisconnectWallet/handleDisconnectWallet.js +1 -4
- package/src/lib/context/DynamicContext/helpers/helpers.cjs +2 -2
- package/src/lib/context/DynamicContext/helpers/helpers.d.ts +2 -2
- package/src/lib/context/DynamicContext/helpers/helpers.js +2 -2
- package/src/lib/context/DynamicContext/hooks/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/types.d.ts +1 -3
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.cjs +1 -5
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.js +2 -6
- package/src/lib/context/DynamicContext/hooks/useMultiWallet/useMultiWallet.cjs +15 -0
- package/src/lib/context/DynamicContext/hooks/useMultiWallet/useMultiWallet.d.ts +6 -0
- package/src/lib/context/DynamicContext/hooks/useMultiWallet/useMultiWallet.js +11 -0
- package/src/lib/context/DynamicContext/hooks/useSetShowLinkNewWalletModal/useSetShowLinkNewWalletModal.cjs +1 -1
- package/src/lib/context/DynamicContext/hooks/useSetShowLinkNewWalletModal/useSetShowLinkNewWalletModal.js +1 -1
- package/src/lib/context/DynamicContext/types/index.d.ts +9 -3
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.cjs +4 -2
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.js +4 -2
- package/src/lib/context/LoadingContext/LoadingContext.cjs +1 -0
- package/src/lib/context/LoadingContext/LoadingContext.js +1 -0
- package/src/lib/data/api.cjs +3 -0
- package/src/lib/data/api.js +4 -1
- package/src/lib/layout/DynamicAuthLayout/DynamicAuthLayout.cjs +1 -1
- package/src/lib/layout/DynamicAuthLayout/DynamicAuthLayout.js +1 -1
- package/src/lib/main.global.cjs +1 -1
- package/src/lib/main.global.js +1 -1
- package/src/lib/shared/utils/hooks/usePreventPageScroll/usePreventPageScroll.cjs +0 -10
- package/src/lib/shared/utils/hooks/usePreventPageScroll/usePreventPageScroll.js +0 -10
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/constants/index.d.ts +1 -1
- package/src/lib/utils/constants/localStorage.cjs +2 -4
- package/src/lib/utils/constants/localStorage.d.ts +1 -2
- package/src/lib/utils/constants/localStorage.js +2 -3
- package/src/lib/utils/functions/walletListBuilder/utils/getCalculatedOffset/getCalculatedOffset.cjs +9 -4
- package/src/lib/utils/functions/walletListBuilder/utils/getCalculatedOffset/getCalculatedOffset.js +9 -4
- package/src/lib/utils/functions/walletListBuilder/walletListBuilder.cjs +24 -15
- package/src/lib/utils/functions/walletListBuilder/walletListBuilder.d.ts +13 -0
- package/src/lib/utils/functions/walletListBuilder/walletListBuilder.js +24 -16
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs +16 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js +16 -1
- package/src/lib/utils/hooks/index.d.ts +1 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +6 -1
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.d.ts +1 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +6 -1
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +2 -6
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.d.ts +2 -3
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +2 -6
- package/src/lib/utils/hooks/useHandleWalletsToConnect/useHandleWalletsToConnect.cjs +4 -5
- package/src/lib/utils/hooks/useHandleWalletsToConnect/useHandleWalletsToConnect.js +4 -5
- package/src/lib/utils/hooks/useNetworkNotSupported/index.d.ts +1 -0
- package/src/lib/utils/hooks/useNetworkNotSupported/useNetworkNotSupported.cjs +104 -0
- package/src/lib/utils/hooks/useNetworkNotSupported/useNetworkNotSupported.d.ts +3 -0
- package/src/lib/utils/hooks/useNetworkNotSupported/useNetworkNotSupported.js +100 -0
- package/src/lib/utils/hooks/useUserDataForm/useUserDataForm.cjs +5 -0
- package/src/lib/utils/hooks/useUserDataForm/useUserDataForm.js +6 -1
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +9 -31
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +10 -32
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs +8 -31
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js +8 -31
- package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.cjs +11 -1
- package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.js +11 -1
- package/src/lib/components/Toolkit/components/MultiWalletSwitch.cjs +0 -18
- package/src/lib/components/Toolkit/components/MultiWalletSwitch.d.ts +0 -6
- package/src/lib/components/Toolkit/components/MultiWalletSwitch.js +0 -14
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.cjs +0 -39
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.d.ts +0 -9
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.js +0 -35
- /package/src/lib/{utils/hooks/multiWallet → context/DynamicContext/hooks}/useMultiWallet/index.d.ts +0 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { useWalletConnectorNetwork } from '../useWalletConnectorNetwork/useWalletConnectorNetwork.js';
|
|
3
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
4
|
+
import '@dynamic-labs/sdk-api';
|
|
5
|
+
import '../../../shared/logger.js';
|
|
6
|
+
import '@dynamic-labs/iconic';
|
|
7
|
+
import 'react/jsx-runtime';
|
|
8
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
9
|
+
import '@dynamic-labs/wallet-book';
|
|
10
|
+
import '../../constants/colors.js';
|
|
11
|
+
import '../../constants/values.js';
|
|
12
|
+
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
13
|
+
import 'viem';
|
|
14
|
+
import '@dynamic-labs/utils';
|
|
15
|
+
import '../../../shared/consts/index.js';
|
|
16
|
+
import '../../../../../_virtual/_tslib.js';
|
|
17
|
+
import '@dynamic-labs/multi-wallet';
|
|
18
|
+
import { isSupportedNetwork } from '../../functions/isSupportedNetwork/isSupportedNetwork.js';
|
|
19
|
+
import 'viem/chains';
|
|
20
|
+
import { useConnectAndSign } from '../authenticationHooks/useConnectAndSign/useConnectAndSign.js';
|
|
21
|
+
import '../../../context/DynamicContext/DynamicContext.js';
|
|
22
|
+
import '../../../events/dynamicEvents.js';
|
|
23
|
+
import 'react-dom';
|
|
24
|
+
import '../../../config/ApiEndpoint.js';
|
|
25
|
+
import '../../../context/ThemeContext/ThemeContext.js';
|
|
26
|
+
import '@dynamic-labs/types';
|
|
27
|
+
import '../../../context/ErrorContext/ErrorContext.js';
|
|
28
|
+
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
29
|
+
import 'yup';
|
|
30
|
+
import 'react-i18next';
|
|
31
|
+
import '../../../context/MockContext/MockContext.js';
|
|
32
|
+
import '../useUserUpdateRequest/useUpdateUser/useUpdateUser.js';
|
|
33
|
+
import '../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
34
|
+
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
35
|
+
import '@dynamic-labs/rpc-providers';
|
|
36
|
+
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
37
|
+
import '../../../components/Alert/Alert.js';
|
|
38
|
+
import '../../../components/ShadowDOM/ShadowDOM.js';
|
|
39
|
+
import '../../../components/IconButton/IconButton.js';
|
|
40
|
+
import '../../../components/InlineWidget/InlineWidget.js';
|
|
41
|
+
import '../../../components/IsBrowser/IsBrowser.js';
|
|
42
|
+
import '../../../components/MenuList/Dropdown/Dropdown.js';
|
|
43
|
+
import '../../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
44
|
+
import '../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
45
|
+
import '../../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
46
|
+
import '../../../components/Popper/Popper/Popper.js';
|
|
47
|
+
import '../../../components/Popper/PopperContext/PopperContext.js';
|
|
48
|
+
import 'react-focus-lock';
|
|
49
|
+
import 'qrcode';
|
|
50
|
+
import 'formik';
|
|
51
|
+
import 'i18next';
|
|
52
|
+
import '../../../components/OverlayCard/OverlayCard.context.js';
|
|
53
|
+
import '../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
54
|
+
import '../../../context/PasskeyContext/PasskeyContext.js';
|
|
55
|
+
import '../../../views/WalletList/WalletList.js';
|
|
56
|
+
import '../../../context/EmailVerificationContext/EmailVerificationContext.js';
|
|
57
|
+
import '@hcaptcha/react-hcaptcha';
|
|
58
|
+
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
59
|
+
import '../../../context/LoadingContext/LoadingContext.js';
|
|
60
|
+
import '../../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
61
|
+
import '../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
62
|
+
import '../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
63
|
+
import '../../../context/FooterAnimationContext/index.js';
|
|
64
|
+
import '../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
65
|
+
import '../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
66
|
+
import '../../../components/UserProfile/parts/UserProfileField/components/VerifiedEmailIcon/VerifiedEmailIcon.js';
|
|
67
|
+
import '@dynamic-labs/viem-utils';
|
|
68
|
+
import '../../../views/TransactionConfirmationView/helpers/transactionErrorMessage.js';
|
|
69
|
+
import '../useTransactionWithGasPrice/useTransactionWithGasPrice.js';
|
|
70
|
+
import '../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
71
|
+
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
72
|
+
|
|
73
|
+
const useNetworkNotSupported = () => {
|
|
74
|
+
const { selectedWalletConnector: walletConnector, setShowAuthFlow, bridgeChainsToConnect, bridgeOnboardingCompleted, } = useInternalDynamicContext();
|
|
75
|
+
const { network: walletConnectorNetwork } = useWalletConnectorNetwork(walletConnector);
|
|
76
|
+
const finishConnectAndSign = useConnectAndSign({
|
|
77
|
+
shouldCallCallback: false,
|
|
78
|
+
shouldUpdateWallets: Boolean(bridgeChainsToConnect === null || bridgeChainsToConnect === void 0 ? void 0 : bridgeChainsToConnect.length),
|
|
79
|
+
});
|
|
80
|
+
// Finishes auth flow when wallet switches to proper network
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
if (!isSupportedNetwork({ network: walletConnectorNetwork, walletConnector })) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
finishConnectAndSign({
|
|
86
|
+
walletConnector: walletConnector,
|
|
87
|
+
});
|
|
88
|
+
// there are two scenarios here, one in not connected state and the other one in connected state.
|
|
89
|
+
// previously we were calling setShowAuthFlow(false) in useHandleWalletsToConnect.
|
|
90
|
+
// now, we don't call it in network-not-supported view, so we need to handle that scenario and close modal here
|
|
91
|
+
// this should be gone, once we're done with the useConnectAndSign hook refactor.
|
|
92
|
+
// TODO: https://linear.app/dynamic-labs/issue/QNTM-117/break-useconnectandsign-hook-to-small-parts
|
|
93
|
+
if (bridgeOnboardingCompleted) {
|
|
94
|
+
setShowAuthFlow(false);
|
|
95
|
+
}
|
|
96
|
+
}, [walletConnectorNetwork, setShowAuthFlow, bridgeOnboardingCompleted]);
|
|
97
|
+
return { currentNetwork: walletConnectorNetwork };
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export { useNetworkNotSupported };
|
|
@@ -69,6 +69,11 @@ const useUserDataForm = ({ onSubmit, onError, userProfile, shouldEnforcePolicies
|
|
|
69
69
|
if (e instanceof utils.EmailAlreadyExistsError) {
|
|
70
70
|
formikHelper.setErrors({ email: 'Email already exists' });
|
|
71
71
|
}
|
|
72
|
+
else if (e instanceof utils.TooManyEmailVerificationsError) {
|
|
73
|
+
formikHelper.setErrors({
|
|
74
|
+
email: 'Too many email verification attempts.',
|
|
75
|
+
});
|
|
76
|
+
}
|
|
72
77
|
else if (e instanceof utils.UsernameAlreadyExistsError) {
|
|
73
78
|
formikHelper.setErrors({ username: 'Username already exists' });
|
|
74
79
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
2
|
import { useState, useMemo, useCallback } from 'react';
|
|
3
3
|
import { object } from 'yup';
|
|
4
|
-
import { DynamicError, EmailAlreadyExistsError, UsernameAlreadyExistsError } from '@dynamic-labs/utils';
|
|
4
|
+
import { DynamicError, EmailAlreadyExistsError, TooManyEmailVerificationsError, UsernameAlreadyExistsError } from '@dynamic-labs/utils';
|
|
5
5
|
import '@dynamic-labs/sdk-api';
|
|
6
6
|
import { logger } from '../../../shared/logger.js';
|
|
7
7
|
import '@dynamic-labs/iconic';
|
|
@@ -65,6 +65,11 @@ const useUserDataForm = ({ onSubmit, onError, userProfile, shouldEnforcePolicies
|
|
|
65
65
|
if (e instanceof EmailAlreadyExistsError) {
|
|
66
66
|
formikHelper.setErrors({ email: 'Email already exists' });
|
|
67
67
|
}
|
|
68
|
+
else if (e instanceof TooManyEmailVerificationsError) {
|
|
69
|
+
formikHelper.setErrors({
|
|
70
|
+
email: 'Too many email verification attempts.',
|
|
71
|
+
});
|
|
72
|
+
}
|
|
68
73
|
else if (e instanceof UsernameAlreadyExistsError) {
|
|
69
74
|
formikHelper.setErrors({ username: 'Username already exists' });
|
|
70
75
|
}
|
|
@@ -22,15 +22,14 @@ require('../../shared/utils/classes/storage/localStorage.cjs');
|
|
|
22
22
|
require('viem');
|
|
23
23
|
require('../../shared/consts/index.cjs');
|
|
24
24
|
var useInternalDynamicContext = require('../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
25
|
-
|
|
25
|
+
require('../../context/CaptchaContext/CaptchaContext.cjs');
|
|
26
26
|
require('../../context/ErrorContext/ErrorContext.cjs');
|
|
27
|
-
require('../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
28
|
-
require('../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
29
|
-
require('../../config/ApiEndpoint.cjs');
|
|
30
27
|
require('@dynamic-labs/multi-wallet');
|
|
31
28
|
var isSupportedNetwork = require('../../utils/functions/isSupportedNetwork/isSupportedNetwork.cjs');
|
|
32
29
|
require('viem/chains');
|
|
33
|
-
require('../../context/
|
|
30
|
+
require('../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
31
|
+
require('../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
32
|
+
require('../../config/ApiEndpoint.cjs');
|
|
34
33
|
require('../../context/EmailVerificationContext/EmailVerificationContext.cjs');
|
|
35
34
|
require('react-dom');
|
|
36
35
|
require('../../context/ThemeContext/ThemeContext.cjs');
|
|
@@ -66,7 +65,7 @@ require('@dynamic-labs/viem-utils');
|
|
|
66
65
|
require('../TransactionConfirmationView/helpers/transactionErrorMessage.cjs');
|
|
67
66
|
require('../../utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.cjs');
|
|
68
67
|
require('../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
69
|
-
var
|
|
68
|
+
var useNetworkNotSupported = require('../../utils/hooks/useNetworkNotSupported/useNetworkNotSupported.cjs');
|
|
70
69
|
require('../../components/InlineWidget/InlineWidget.cjs');
|
|
71
70
|
require('../../components/IsBrowser/IsBrowser.cjs');
|
|
72
71
|
require('../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
@@ -81,31 +80,10 @@ var SelectNetworkButton = require('../../components/SelectNetworkButton/SelectNe
|
|
|
81
80
|
require('../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
82
81
|
|
|
83
82
|
const NetworkNotSupported = () => {
|
|
84
|
-
const { onboardingImageUrl, selectedWalletConnector: walletConnector
|
|
83
|
+
const { onboardingImageUrl, selectedWalletConnector: walletConnector } = useInternalDynamicContext.useInternalDynamicContext();
|
|
85
84
|
const { t } = reactI18next.useTranslation();
|
|
86
|
-
const {
|
|
87
|
-
const finishConnectAndSign = useConnectAndSign.useConnectAndSign({
|
|
88
|
-
shouldCallCallback: false,
|
|
89
|
-
shouldUpdateWallets: !isFullyConnected ||
|
|
90
|
-
(isFullyConnected && Boolean(bridgeChainsToConnect === null || bridgeChainsToConnect === void 0 ? void 0 : bridgeChainsToConnect.length)),
|
|
91
|
-
});
|
|
85
|
+
const { currentNetwork } = useNetworkNotSupported.useNetworkNotSupported();
|
|
92
86
|
const [isNetworkPickerOpen, setIsNetworkPickerOpen] = React.useState(false);
|
|
93
|
-
// Finishes auth flow when wallet switches to proper network
|
|
94
|
-
React.useEffect(() => {
|
|
95
|
-
if (isSupportedNetwork.isSupportedNetwork({ network: walletConnectorNetwork, walletConnector })) {
|
|
96
|
-
finishConnectAndSign({
|
|
97
|
-
walletConnector: walletConnector,
|
|
98
|
-
});
|
|
99
|
-
// there are two scenarios here, one in not connected state and the other one in connected state.
|
|
100
|
-
// previously we were calling setShowAuthFlow(false) in useHandleWalletsToConnect.
|
|
101
|
-
// now, we don't call it in network-not-supported view, so we need to handle that scenario and close modal here
|
|
102
|
-
// this should be gone, once we're done with the useConnectAndSign hook refactor.
|
|
103
|
-
// TODO: https://linear.app/dynamic-labs/issue/QNTM-117/break-useconnectandsign-hook-to-small-parts
|
|
104
|
-
if (isFullyConnected) {
|
|
105
|
-
setShowAuthFlow(false);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}, [walletConnectorNetwork, setShowAuthFlow, isFullyConnected]);
|
|
109
87
|
if (!walletConnector) {
|
|
110
88
|
return null;
|
|
111
89
|
}
|
|
@@ -121,12 +99,12 @@ const NetworkNotSupported = () => {
|
|
|
121
99
|
});
|
|
122
100
|
const evmNetworks = walletConnector.evmNetworks || [];
|
|
123
101
|
const _isSupportedNetwork = isSupportedNetwork.isSupportedNetwork({
|
|
124
|
-
network:
|
|
102
|
+
network: currentNetwork,
|
|
125
103
|
walletConnector,
|
|
126
104
|
});
|
|
127
105
|
return (jsxRuntime.jsxs("div", { className: 'network-not-supported', "data-testid": 'network-not-supported', children: [onboardingImageUrl && (jsxRuntime.jsx("img", { className: 'network-not-supported__main-img', src: onboardingImageUrl, alt: 'onboarding' })), !_isSupportedNetwork && (jsxRuntime.jsx(ErrorContainer.ErrorContainer, { variant: 'info', withIcon: false, className: 'network-not-supported__error--not-supported', copykey: 'dyn_network_not_supported.warning_message', children: t('dyn_network_not_supported.warning_message') })), jsxRuntime.jsxs("div", { className: classNames.classNames('network-not-supported__content-container', {
|
|
128
106
|
'network-not-supported__content-container--error': !_isSupportedNetwork,
|
|
129
|
-
}), children: [jsxRuntime.jsx("div", { className: 'network-not-supported__img-container', children: jsxRuntime.jsx(walletBook.WalletIcon, { style: { height: 64, width: 64 }, walletKey: walletConnector.key }) }), jsxRuntime.jsx(UserAddress.UserAddress, { walletConnector: walletConnector }), jsxRuntime.jsx("div", { className: 'network-not-supported__network-container', children: evmNetworks.length > 1 && (jsxRuntime.jsx(NetworkPicker.NetworkPicker, { currentNetwork:
|
|
107
|
+
}), children: [jsxRuntime.jsx("div", { className: 'network-not-supported__img-container', children: jsxRuntime.jsx(walletBook.WalletIcon, { style: { height: 64, width: 64 }, walletKey: walletConnector.key }) }), jsxRuntime.jsx(UserAddress.UserAddress, { walletConnector: walletConnector }), jsxRuntime.jsx("div", { className: 'network-not-supported__network-container', children: evmNetworks.length > 1 && (jsxRuntime.jsx(NetworkPicker.NetworkPicker, { currentNetwork: currentNetwork, evmNetworks: evmNetworks, connector: walletConnector, isNetworkPickerOpen: isNetworkPickerOpen, setIsNetworkPickerOpen: setIsNetworkPickerOpen, showNetworkName: true, buttonClassName: 'network-not-supported__network-picker-button', mainClassName: 'network-not-supported__network-picker' })) }), jsxRuntime.jsx("div", { className: 'network-not-supported__welcome-container', children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', copykey: 'dyn_network_not_supported.subtitle', children: t('dyn_network_not_supported.subtitle') }) }), evmNetworks.length === 1 && (jsxRuntime.jsx(SelectNetworkButton.SelectNetworkButton, { onClick: onSelectNetworkButtonClick, networkId: evmNetworks[0].networkId, networkName: evmNetworks[0].vanityName || evmNetworks[0].name, networkIconUrl: evmNetworks[0].iconUrls[0] }))] })] }));
|
|
130
108
|
};
|
|
131
109
|
|
|
132
110
|
exports.NetworkNotSupported = NetworkNotSupported;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { useState
|
|
3
|
+
import { useState } from 'react';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import { WalletIcon } from '@dynamic-labs/wallet-book';
|
|
6
6
|
import { classNames } from '../../utils/functions/classNames/classNames.js';
|
|
@@ -18,15 +18,14 @@ import '../../shared/utils/classes/storage/localStorage.js';
|
|
|
18
18
|
import 'viem';
|
|
19
19
|
import '../../shared/consts/index.js';
|
|
20
20
|
import { useInternalDynamicContext } from '../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
21
|
-
import
|
|
21
|
+
import '../../context/CaptchaContext/CaptchaContext.js';
|
|
22
22
|
import '../../context/ErrorContext/ErrorContext.js';
|
|
23
|
-
import '../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
24
|
-
import '../../context/AccountExistsContext/AccountExistsContext.js';
|
|
25
|
-
import '../../config/ApiEndpoint.js';
|
|
26
23
|
import '@dynamic-labs/multi-wallet';
|
|
27
24
|
import { isSupportedNetwork } from '../../utils/functions/isSupportedNetwork/isSupportedNetwork.js';
|
|
28
25
|
import 'viem/chains';
|
|
29
|
-
import '../../context/
|
|
26
|
+
import '../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
27
|
+
import '../../context/AccountExistsContext/AccountExistsContext.js';
|
|
28
|
+
import '../../config/ApiEndpoint.js';
|
|
30
29
|
import '../../context/EmailVerificationContext/EmailVerificationContext.js';
|
|
31
30
|
import 'react-dom';
|
|
32
31
|
import '../../context/ThemeContext/ThemeContext.js';
|
|
@@ -62,7 +61,7 @@ import '@dynamic-labs/viem-utils';
|
|
|
62
61
|
import '../TransactionConfirmationView/helpers/transactionErrorMessage.js';
|
|
63
62
|
import '../../utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.js';
|
|
64
63
|
import '../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
65
|
-
import {
|
|
64
|
+
import { useNetworkNotSupported } from '../../utils/hooks/useNetworkNotSupported/useNetworkNotSupported.js';
|
|
66
65
|
import '../../components/InlineWidget/InlineWidget.js';
|
|
67
66
|
import '../../components/IsBrowser/IsBrowser.js';
|
|
68
67
|
import '../../components/MenuList/Dropdown/Dropdown.js';
|
|
@@ -77,31 +76,10 @@ import { SelectNetworkButton } from '../../components/SelectNetworkButton/Select
|
|
|
77
76
|
import '../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
78
77
|
|
|
79
78
|
const NetworkNotSupported = () => {
|
|
80
|
-
const { onboardingImageUrl, selectedWalletConnector: walletConnector
|
|
79
|
+
const { onboardingImageUrl, selectedWalletConnector: walletConnector } = useInternalDynamicContext();
|
|
81
80
|
const { t } = useTranslation();
|
|
82
|
-
const {
|
|
83
|
-
const finishConnectAndSign = useConnectAndSign({
|
|
84
|
-
shouldCallCallback: false,
|
|
85
|
-
shouldUpdateWallets: !isFullyConnected ||
|
|
86
|
-
(isFullyConnected && Boolean(bridgeChainsToConnect === null || bridgeChainsToConnect === void 0 ? void 0 : bridgeChainsToConnect.length)),
|
|
87
|
-
});
|
|
81
|
+
const { currentNetwork } = useNetworkNotSupported();
|
|
88
82
|
const [isNetworkPickerOpen, setIsNetworkPickerOpen] = useState(false);
|
|
89
|
-
// Finishes auth flow when wallet switches to proper network
|
|
90
|
-
useEffect(() => {
|
|
91
|
-
if (isSupportedNetwork({ network: walletConnectorNetwork, walletConnector })) {
|
|
92
|
-
finishConnectAndSign({
|
|
93
|
-
walletConnector: walletConnector,
|
|
94
|
-
});
|
|
95
|
-
// there are two scenarios here, one in not connected state and the other one in connected state.
|
|
96
|
-
// previously we were calling setShowAuthFlow(false) in useHandleWalletsToConnect.
|
|
97
|
-
// now, we don't call it in network-not-supported view, so we need to handle that scenario and close modal here
|
|
98
|
-
// this should be gone, once we're done with the useConnectAndSign hook refactor.
|
|
99
|
-
// TODO: https://linear.app/dynamic-labs/issue/QNTM-117/break-useconnectandsign-hook-to-small-parts
|
|
100
|
-
if (isFullyConnected) {
|
|
101
|
-
setShowAuthFlow(false);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}, [walletConnectorNetwork, setShowAuthFlow, isFullyConnected]);
|
|
105
83
|
if (!walletConnector) {
|
|
106
84
|
return null;
|
|
107
85
|
}
|
|
@@ -117,12 +95,12 @@ const NetworkNotSupported = () => {
|
|
|
117
95
|
});
|
|
118
96
|
const evmNetworks = walletConnector.evmNetworks || [];
|
|
119
97
|
const _isSupportedNetwork = isSupportedNetwork({
|
|
120
|
-
network:
|
|
98
|
+
network: currentNetwork,
|
|
121
99
|
walletConnector,
|
|
122
100
|
});
|
|
123
101
|
return (jsxs("div", { className: 'network-not-supported', "data-testid": 'network-not-supported', children: [onboardingImageUrl && (jsx("img", { className: 'network-not-supported__main-img', src: onboardingImageUrl, alt: 'onboarding' })), !_isSupportedNetwork && (jsx(ErrorContainer, { variant: 'info', withIcon: false, className: 'network-not-supported__error--not-supported', copykey: 'dyn_network_not_supported.warning_message', children: t('dyn_network_not_supported.warning_message') })), jsxs("div", { className: classNames('network-not-supported__content-container', {
|
|
124
102
|
'network-not-supported__content-container--error': !_isSupportedNetwork,
|
|
125
|
-
}), children: [jsx("div", { className: 'network-not-supported__img-container', children: jsx(WalletIcon, { style: { height: 64, width: 64 }, walletKey: walletConnector.key }) }), jsx(UserAddress, { walletConnector: walletConnector }), jsx("div", { className: 'network-not-supported__network-container', children: evmNetworks.length > 1 && (jsx(NetworkPicker, { currentNetwork:
|
|
103
|
+
}), children: [jsx("div", { className: 'network-not-supported__img-container', children: jsx(WalletIcon, { style: { height: 64, width: 64 }, walletKey: walletConnector.key }) }), jsx(UserAddress, { walletConnector: walletConnector }), jsx("div", { className: 'network-not-supported__network-container', children: evmNetworks.length > 1 && (jsx(NetworkPicker, { currentNetwork: currentNetwork, evmNetworks: evmNetworks, connector: walletConnector, isNetworkPickerOpen: isNetworkPickerOpen, setIsNetworkPickerOpen: setIsNetworkPickerOpen, showNetworkName: true, buttonClassName: 'network-not-supported__network-picker-button', mainClassName: 'network-not-supported__network-picker' })) }), jsx("div", { className: 'network-not-supported__welcome-container', children: jsx(Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', copykey: 'dyn_network_not_supported.subtitle', children: t('dyn_network_not_supported.subtitle') }) }), evmNetworks.length === 1 && (jsx(SelectNetworkButton, { onClick: onSelectNetworkButtonClick, networkId: evmNetworks[0].networkId, networkName: evmNetworks[0].vanityName || evmNetworks[0].name, networkIconUrl: evmNetworks[0].iconUrls[0] }))] })] }));
|
|
126
104
|
};
|
|
127
105
|
|
|
128
106
|
export { NetworkNotSupported };
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
var React = require('react');
|
|
7
6
|
var reactI18next = require('react-i18next');
|
|
8
7
|
var walletBook = require('@dynamic-labs/wallet-book');
|
|
8
|
+
require('react');
|
|
9
9
|
require('../../events/dynamicEvents.cjs');
|
|
10
10
|
require('../../../../_virtual/_tslib.cjs');
|
|
11
11
|
require('@dynamic-labs/utils');
|
|
@@ -21,17 +21,15 @@ require('../../shared/utils/classes/storage/localStorage.cjs');
|
|
|
21
21
|
require('viem');
|
|
22
22
|
require('../../shared/consts/index.cjs');
|
|
23
23
|
var useInternalDynamicContext = require('../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
24
|
-
|
|
24
|
+
require('../../context/CaptchaContext/CaptchaContext.cjs');
|
|
25
25
|
require('../../context/ErrorContext/ErrorContext.cjs');
|
|
26
|
-
require('../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
27
|
-
require('../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
28
|
-
require('../../config/ApiEndpoint.cjs');
|
|
29
26
|
require('@dynamic-labs/multi-wallet');
|
|
30
27
|
var getWalletConnectorNetworks = require('../../utils/functions/getWalletConnectorNetworks/getWalletConnectorNetworks.cjs');
|
|
31
|
-
var isSupportedNetwork = require('../../utils/functions/isSupportedNetwork/isSupportedNetwork.cjs');
|
|
32
28
|
var pixelToRem = require('../../utils/functions/pixelToRem/pixelToRem.cjs');
|
|
33
29
|
require('viem/chains');
|
|
34
|
-
require('../../context/
|
|
30
|
+
require('../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
31
|
+
require('../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
32
|
+
require('../../config/ApiEndpoint.cjs');
|
|
35
33
|
require('../../context/EmailVerificationContext/EmailVerificationContext.cjs');
|
|
36
34
|
require('react-dom');
|
|
37
35
|
require('../../context/ThemeContext/ThemeContext.cjs');
|
|
@@ -67,7 +65,7 @@ require('@dynamic-labs/viem-utils');
|
|
|
67
65
|
require('../TransactionConfirmationView/helpers/transactionErrorMessage.cjs');
|
|
68
66
|
require('../../utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.cjs');
|
|
69
67
|
require('../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
70
|
-
var
|
|
68
|
+
var useNetworkNotSupported = require('../../utils/hooks/useNetworkNotSupported/useNetworkNotSupported.cjs');
|
|
71
69
|
require('../../components/InlineWidget/InlineWidget.cjs');
|
|
72
70
|
require('../../components/IsBrowser/IsBrowser.cjs');
|
|
73
71
|
require('../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
@@ -82,30 +80,9 @@ require('../../widgets/DynamicBridgeWidget/views/WalletsView/components/Secondar
|
|
|
82
80
|
// as the wallet does not support programmatic network change.
|
|
83
81
|
const NetworkNotSupportedSwitchManual = () => {
|
|
84
82
|
var _a, _b;
|
|
85
|
-
const { user, selectedWalletConnector: walletConnector
|
|
83
|
+
const { user, selectedWalletConnector: walletConnector } = useInternalDynamicContext.useInternalDynamicContext();
|
|
84
|
+
useNetworkNotSupported.useNetworkNotSupported();
|
|
86
85
|
const { t } = reactI18next.useTranslation();
|
|
87
|
-
const { network: walletConnectorNetwork } = useWalletConnectorNetwork.useWalletConnectorNetwork(walletConnector);
|
|
88
|
-
const finishConnectAndSign = useConnectAndSign.useConnectAndSign({
|
|
89
|
-
shouldCallCallback: false,
|
|
90
|
-
shouldUpdateWallets: !isFullyConnected ||
|
|
91
|
-
(isFullyConnected && Boolean(bridgeChainsToConnect === null || bridgeChainsToConnect === void 0 ? void 0 : bridgeChainsToConnect.length)),
|
|
92
|
-
});
|
|
93
|
-
// Finishes auth flow when wallet switches to proper network
|
|
94
|
-
React.useEffect(() => {
|
|
95
|
-
if (isSupportedNetwork.isSupportedNetwork({ network: walletConnectorNetwork, walletConnector })) {
|
|
96
|
-
finishConnectAndSign({
|
|
97
|
-
walletConnector: walletConnector,
|
|
98
|
-
});
|
|
99
|
-
// there are two scenarios here, one in not connected state and the other one in connected state.
|
|
100
|
-
// previously we were calling setShowAuthFlow(false) in useHandleWalletsToConnect.
|
|
101
|
-
// now, we don't call it in network-not-supported view, so we need to handle that scenario and close modal here
|
|
102
|
-
// this should be gone, once we're done with the useConnectAndSign hook refactor.
|
|
103
|
-
// TODO: https://linear.app/dynamic-labs/issue/QNTM-117/break-useconnectandsign-hook-to-small-parts
|
|
104
|
-
if (isFullyConnected) {
|
|
105
|
-
setShowAuthFlow(false);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}, [walletConnectorNetwork, setShowAuthFlow, isFullyConnected]);
|
|
109
86
|
const iconSize = 80;
|
|
110
87
|
const icon = (jsxRuntime.jsx(walletBook.WalletIcon, { walletKey: walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.key, style: {
|
|
111
88
|
height: pixelToRem.pixelToRem(iconSize * IconWithSpinner.iconRatio),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { useEffect } from 'react';
|
|
3
2
|
import { useTranslation } from 'react-i18next';
|
|
4
3
|
import { WalletIcon } from '@dynamic-labs/wallet-book';
|
|
4
|
+
import 'react';
|
|
5
5
|
import '../../events/dynamicEvents.js';
|
|
6
6
|
import '../../../../_virtual/_tslib.js';
|
|
7
7
|
import '@dynamic-labs/utils';
|
|
@@ -17,17 +17,15 @@ import '../../shared/utils/classes/storage/localStorage.js';
|
|
|
17
17
|
import 'viem';
|
|
18
18
|
import '../../shared/consts/index.js';
|
|
19
19
|
import { useInternalDynamicContext } from '../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
20
|
-
import
|
|
20
|
+
import '../../context/CaptchaContext/CaptchaContext.js';
|
|
21
21
|
import '../../context/ErrorContext/ErrorContext.js';
|
|
22
|
-
import '../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
23
|
-
import '../../context/AccountExistsContext/AccountExistsContext.js';
|
|
24
|
-
import '../../config/ApiEndpoint.js';
|
|
25
22
|
import '@dynamic-labs/multi-wallet';
|
|
26
23
|
import { getWalletConnectorNetworks } from '../../utils/functions/getWalletConnectorNetworks/getWalletConnectorNetworks.js';
|
|
27
|
-
import { isSupportedNetwork } from '../../utils/functions/isSupportedNetwork/isSupportedNetwork.js';
|
|
28
24
|
import { pixelToRem } from '../../utils/functions/pixelToRem/pixelToRem.js';
|
|
29
25
|
import 'viem/chains';
|
|
30
|
-
import '../../context/
|
|
26
|
+
import '../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
27
|
+
import '../../context/AccountExistsContext/AccountExistsContext.js';
|
|
28
|
+
import '../../config/ApiEndpoint.js';
|
|
31
29
|
import '../../context/EmailVerificationContext/EmailVerificationContext.js';
|
|
32
30
|
import 'react-dom';
|
|
33
31
|
import '../../context/ThemeContext/ThemeContext.js';
|
|
@@ -63,7 +61,7 @@ import '@dynamic-labs/viem-utils';
|
|
|
63
61
|
import '../TransactionConfirmationView/helpers/transactionErrorMessage.js';
|
|
64
62
|
import '../../utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.js';
|
|
65
63
|
import '../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
66
|
-
import {
|
|
64
|
+
import { useNetworkNotSupported } from '../../utils/hooks/useNetworkNotSupported/useNetworkNotSupported.js';
|
|
67
65
|
import '../../components/InlineWidget/InlineWidget.js';
|
|
68
66
|
import '../../components/IsBrowser/IsBrowser.js';
|
|
69
67
|
import '../../components/MenuList/Dropdown/Dropdown.js';
|
|
@@ -78,30 +76,9 @@ import '../../widgets/DynamicBridgeWidget/views/WalletsView/components/Secondary
|
|
|
78
76
|
// as the wallet does not support programmatic network change.
|
|
79
77
|
const NetworkNotSupportedSwitchManual = () => {
|
|
80
78
|
var _a, _b;
|
|
81
|
-
const { user, selectedWalletConnector: walletConnector
|
|
79
|
+
const { user, selectedWalletConnector: walletConnector } = useInternalDynamicContext();
|
|
80
|
+
useNetworkNotSupported();
|
|
82
81
|
const { t } = useTranslation();
|
|
83
|
-
const { network: walletConnectorNetwork } = useWalletConnectorNetwork(walletConnector);
|
|
84
|
-
const finishConnectAndSign = useConnectAndSign({
|
|
85
|
-
shouldCallCallback: false,
|
|
86
|
-
shouldUpdateWallets: !isFullyConnected ||
|
|
87
|
-
(isFullyConnected && Boolean(bridgeChainsToConnect === null || bridgeChainsToConnect === void 0 ? void 0 : bridgeChainsToConnect.length)),
|
|
88
|
-
});
|
|
89
|
-
// Finishes auth flow when wallet switches to proper network
|
|
90
|
-
useEffect(() => {
|
|
91
|
-
if (isSupportedNetwork({ network: walletConnectorNetwork, walletConnector })) {
|
|
92
|
-
finishConnectAndSign({
|
|
93
|
-
walletConnector: walletConnector,
|
|
94
|
-
});
|
|
95
|
-
// there are two scenarios here, one in not connected state and the other one in connected state.
|
|
96
|
-
// previously we were calling setShowAuthFlow(false) in useHandleWalletsToConnect.
|
|
97
|
-
// now, we don't call it in network-not-supported view, so we need to handle that scenario and close modal here
|
|
98
|
-
// this should be gone, once we're done with the useConnectAndSign hook refactor.
|
|
99
|
-
// TODO: https://linear.app/dynamic-labs/issue/QNTM-117/break-useconnectandsign-hook-to-small-parts
|
|
100
|
-
if (isFullyConnected) {
|
|
101
|
-
setShowAuthFlow(false);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}, [walletConnectorNetwork, setShowAuthFlow, isFullyConnected]);
|
|
105
82
|
const iconSize = 80;
|
|
106
83
|
const icon = (jsx(WalletIcon, { walletKey: walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.key, style: {
|
|
107
84
|
height: pixelToRem(iconSize * iconRatio),
|
package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.cjs
CHANGED
|
@@ -74,7 +74,17 @@ var SocialRedirectContext = require('../../../context/SocialRedirectContext/Soci
|
|
|
74
74
|
|
|
75
75
|
const DynamicEmbeddedAuthFlow = ({ background = 'none', className, style, }) => {
|
|
76
76
|
const hide = useIsLoggedIn.useIsLoggedIn();
|
|
77
|
-
const { projectSettings, isRenderingEmbeddedAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
77
|
+
const { projectSettings, isRenderingEmbeddedAuthFlow, walletConnectorOptions, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
78
|
+
// This is needed to make sure WalletConnect is initialized for users who are using
|
|
79
|
+
// universal links on mobile. This also happens in useShowAuthFlow, but since this
|
|
80
|
+
// is the embedded auth flow, that hook does not get called.
|
|
81
|
+
// Without initializing WalletConnect here, users end up hitting the iOS app store bug
|
|
82
|
+
// and are redirected to the app store, instead of the wallet
|
|
83
|
+
React.useEffect(() => {
|
|
84
|
+
var _a;
|
|
85
|
+
(_a = walletConnectorOptions
|
|
86
|
+
.find((wallet) => wallet.walletConnector.key === 'walletconnect')) === null || _a === void 0 ? void 0 : _a.walletConnector.init();
|
|
87
|
+
}, [walletConnectorOptions]);
|
|
78
88
|
const { goToInitialView: resetAuthView } = ViewContext.useViewContext();
|
|
79
89
|
// Reset view when user logs out
|
|
80
90
|
React.useEffect(() => {
|
package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.js
CHANGED
|
@@ -70,7 +70,17 @@ import { SocialRedirectContextProvider } from '../../../context/SocialRedirectCo
|
|
|
70
70
|
|
|
71
71
|
const DynamicEmbeddedAuthFlow = ({ background = 'none', className, style, }) => {
|
|
72
72
|
const hide = useIsLoggedIn();
|
|
73
|
-
const { projectSettings, isRenderingEmbeddedAuthFlow } = useInternalDynamicContext();
|
|
73
|
+
const { projectSettings, isRenderingEmbeddedAuthFlow, walletConnectorOptions, } = useInternalDynamicContext();
|
|
74
|
+
// This is needed to make sure WalletConnect is initialized for users who are using
|
|
75
|
+
// universal links on mobile. This also happens in useShowAuthFlow, but since this
|
|
76
|
+
// is the embedded auth flow, that hook does not get called.
|
|
77
|
+
// Without initializing WalletConnect here, users end up hitting the iOS app store bug
|
|
78
|
+
// and are redirected to the app store, instead of the wallet
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
var _a;
|
|
81
|
+
(_a = walletConnectorOptions
|
|
82
|
+
.find((wallet) => wallet.walletConnector.key === 'walletconnect')) === null || _a === void 0 ? void 0 : _a.walletConnector.init();
|
|
83
|
+
}, [walletConnectorOptions]);
|
|
74
84
|
const { goToInitialView: resetAuthView } = useViewContext();
|
|
75
85
|
// Reset view when user logs out
|
|
76
86
|
useEffect(() => {
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
var Switch = require('../../Switch/Switch.cjs');
|
|
7
|
-
|
|
8
|
-
const MultiWalletSwitch = ({ multiWallet, setMultiWallet, }) => (jsxRuntime.jsx(Switch.Switch, { firstButton: {
|
|
9
|
-
active: multiWallet,
|
|
10
|
-
handleButtonClick: () => setMultiWallet(true),
|
|
11
|
-
name: 'True',
|
|
12
|
-
}, secondButton: {
|
|
13
|
-
active: !multiWallet,
|
|
14
|
-
handleButtonClick: () => setMultiWallet(false),
|
|
15
|
-
name: 'False',
|
|
16
|
-
} }));
|
|
17
|
-
|
|
18
|
-
exports.MultiWalletSwitch = MultiWalletSwitch;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { Switch } from '../../Switch/Switch.js';
|
|
3
|
-
|
|
4
|
-
const MultiWalletSwitch = ({ multiWallet, setMultiWallet, }) => (jsx(Switch, { firstButton: {
|
|
5
|
-
active: multiWallet,
|
|
6
|
-
handleButtonClick: () => setMultiWallet(true),
|
|
7
|
-
name: 'True',
|
|
8
|
-
}, secondButton: {
|
|
9
|
-
active: !multiWallet,
|
|
10
|
-
handleButtonClick: () => setMultiWallet(false),
|
|
11
|
-
name: 'False',
|
|
12
|
-
} }));
|
|
13
|
-
|
|
14
|
-
export { MultiWalletSwitch };
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var React = require('react');
|
|
6
|
-
require('@dynamic-labs/sdk-api');
|
|
7
|
-
require('../../../../shared/logger.cjs');
|
|
8
|
-
require('@dynamic-labs/iconic');
|
|
9
|
-
require('@dynamic-labs/wallet-connector-core');
|
|
10
|
-
require('react/jsx-runtime');
|
|
11
|
-
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
12
|
-
require('@dynamic-labs/wallet-book');
|
|
13
|
-
var localStorage = require('../../../constants/localStorage.cjs');
|
|
14
|
-
require('../../../constants/colors.cjs');
|
|
15
|
-
require('../../../constants/values.cjs');
|
|
16
|
-
var localStorage$1 = require('../../../../shared/utils/classes/storage/localStorage.cjs');
|
|
17
|
-
require('viem');
|
|
18
|
-
var useLocalStorage = require('../../../../shared/utils/hooks/useLocalStorage/useLocalStorage.cjs');
|
|
19
|
-
require('@dynamic-labs/utils');
|
|
20
|
-
require('../../../../shared/consts/index.cjs');
|
|
21
|
-
|
|
22
|
-
const useMultiWallet = ({ toolkitEnabled, isBridgeFlow, multiWalletSettings, }) => {
|
|
23
|
-
var _a;
|
|
24
|
-
const isMultiWalletEnabled = (_a = (multiWalletSettings || isBridgeFlow)) !== null && _a !== void 0 ? _a : false;
|
|
25
|
-
const [multiWallet, setMultiWallet] = useLocalStorage.useLocalStorage(localStorage.IS_MULTI_WALLET_ENABLED, isMultiWalletEnabled);
|
|
26
|
-
React.useEffect(() => {
|
|
27
|
-
// don't overwrite toolkit stored value after the refresh
|
|
28
|
-
if (toolkitEnabled &&
|
|
29
|
-
localStorage$1.LocalStorage.getFromLS(localStorage.IS_MULTI_WALLET_ENABLED) !== undefined) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
if (multiWalletSettings) {
|
|
33
|
-
setMultiWallet(multiWalletSettings);
|
|
34
|
-
}
|
|
35
|
-
}, [multiWalletSettings]);
|
|
36
|
-
return { multiWallet, setMultiWallet };
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
exports.useMultiWallet = useMultiWallet;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export type UseMultiWalletProps = {
|
|
2
|
-
toolkitEnabled: boolean;
|
|
3
|
-
isBridgeFlow?: boolean;
|
|
4
|
-
multiWalletSettings?: boolean;
|
|
5
|
-
};
|
|
6
|
-
export declare const useMultiWallet: ({ toolkitEnabled, isBridgeFlow, multiWalletSettings, }: UseMultiWalletProps) => {
|
|
7
|
-
multiWallet: boolean;
|
|
8
|
-
setMultiWallet: (value: boolean | ((val: boolean) => boolean)) => void;
|
|
9
|
-
};
|