@dynamic-labs/sdk-react-core 4.9.3 → 4.9.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.
@@ -7,7 +7,6 @@ var _tslib = require('../../../../../_virtual/_tslib.cjs');
7
7
  var React = require('react');
8
8
  var logger = require('../../../shared/logger.cjs');
9
9
  var loadingAndLifecycle = require('../../../store/state/loadingAndLifecycle.cjs');
10
- var useDynamicEvents = require('../events/useDynamicEvents/useDynamicEvents.cjs');
11
10
  var projectSettings = require('../../../store/state/projectSettings/projectSettings.cjs');
12
11
  var handleStoreAndEnvironmentMismatch = require('./handleStoreAndEnvironmentMismatch/handleStoreAndEnvironmentMismatch.cjs');
13
12
  var handleUserDataOutOfSync = require('./handleUserDataOutOfSync/handleUserDataOutOfSync.cjs');
@@ -42,11 +41,6 @@ const useValidateSession = ({ environmentId, handleLogOut }) => {
42
41
  didRunRef.current = true;
43
42
  validateSession(projectSettings$1);
44
43
  }, [validateSession, projectSettings$1]);
45
- useDynamicEvents.useInternalDynamicEvents('triggerSessionValidation', () => {
46
- if (!projectSettings$1)
47
- return;
48
- validateSession(projectSettings$1);
49
- });
50
44
  };
51
45
 
52
46
  exports.useValidateSession = useValidateSession;
@@ -3,7 +3,6 @@ import { __awaiter } from '../../../../../_virtual/_tslib.js';
3
3
  import { useRef, useCallback, useEffect } from 'react';
4
4
  import { logger } from '../../../shared/logger.js';
5
5
  import { setLoadingAndLifecycle } from '../../../store/state/loadingAndLifecycle.js';
6
- import { useInternalDynamicEvents } from '../events/useDynamicEvents/useDynamicEvents.js';
7
6
  import { useProjectSettings } from '../../../store/state/projectSettings/projectSettings.js';
8
7
  import { handleStoreAndEnvironmentMismatch } from './handleStoreAndEnvironmentMismatch/handleStoreAndEnvironmentMismatch.js';
9
8
  import { handleUserDataOutOfSync } from './handleUserDataOutOfSync/handleUserDataOutOfSync.js';
@@ -38,11 +37,6 @@ const useValidateSession = ({ environmentId, handleLogOut }) => {
38
37
  didRunRef.current = true;
39
38
  validateSession(projectSettings);
40
39
  }, [validateSession, projectSettings]);
41
- useInternalDynamicEvents('triggerSessionValidation', () => {
42
- if (!projectSettings)
43
- return;
44
- validateSession(projectSettings);
45
- });
46
40
  };
47
41
 
48
42
  export { useValidateSession };
@@ -74,6 +74,7 @@ require('react-focus-lock');
74
74
  require('qrcode');
75
75
  require('formik');
76
76
  require('../../../utils/hooks/useSubdomainCheck/useSubdomainCheck.cjs');
77
+ var useWalletList = require('../../../utils/hooks/useWalletList/useWalletList.cjs');
77
78
  require('../../../context/WalletGroupContext/WalletGroupContext.cjs');
78
79
  require('../../../context/IpConfigurationContext/IpConfigurationContext.cjs');
79
80
  require('../../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
@@ -103,21 +104,15 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useDyna
103
104
  const NUMBER_OF_WALLETS = 3;
104
105
  const useLoginView = () => {
105
106
  const loginView = useViewSettings.useViewSettings(sdkApiCore.SdkViewType.Login);
106
- const { projectSettings, authorizationViewDisplayOrder, loginWithEmail, walletConnectorOptions, walletsFilter, } = useInternalDynamicContext.useInternalDynamicContext();
107
+ const { projectSettings, authorizationViewDisplayOrder, loginWithEmail, walletsFilter, } = useInternalDynamicContext.useInternalDynamicContext();
107
108
  const { t } = reactI18next.useTranslation();
108
109
  const { enabledSocialProviders } = SocialRedirectContext.useSocialRedirectContext();
110
+ const { numberOfWallets } = useWalletList.useWalletList({
111
+ viewWalletsFilter: walletsFilter,
112
+ });
109
113
  const hasSocialProvidersEnabled = Boolean(enabledSocialProviders === null || enabledSocialProviders === void 0 ? void 0 : enabledSocialProviders.length);
110
114
  const hasEmailProviderEnabled = isEmailProviderEnabled.isEmailProviderEnabled(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers);
111
115
  const hasPhoneProviderEnabled = isPhoneNumberProviderEnabled.isPhoneNumberProviderEnabled(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers);
112
- /** Takes from wallets only those that can be selected in the wallet list by the user.
113
- * Should filter out embedded wallets
114
- * WHY: when we decide whether to show wallets or not, we need to know how many wallets
115
- * will actually be rendered. It would be especially bad to only have for ex "turnkey" in
116
- * wallets and then display an empty wallet list (since turnkey doesn't render)
117
- */
118
- const selectableWallets = (walletsFilter
119
- ? walletsFilter(walletConnectorOptions)
120
- : walletConnectorOptions).filter(({ key }) => key !== 'turnkey');
121
116
  const isWalletOnly = React.useMemo(() => {
122
117
  var _a;
123
118
  if (!projectSettings) {
@@ -158,11 +153,11 @@ const useLoginView = () => {
158
153
  sections.find((section) => section.type === 'wallet')) {
159
154
  logger.logger.error('Failed to render WalletSignInSection - no chains enabled');
160
155
  }
161
- if (selectableWallets === null || selectableWallets === void 0 ? void 0 : selectableWallets.length) {
156
+ if (numberOfWallets > 0) {
162
157
  return sections;
163
158
  }
164
159
  return sections.filter((section) => section.type !== 'wallet');
165
- }, [selectableWallets === null || selectableWallets === void 0 ? void 0 : selectableWallets.length, projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.chains]);
160
+ }, [numberOfWallets, projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.chains]);
166
161
  /**
167
162
  * returns the login view sections to be displayed in order from projectSettings?.sdk?.views
168
163
  * and has backwards compatibility with project settings design.modal props
@@ -185,8 +180,7 @@ const useLoginView = () => {
185
180
  showPhone: hasPhoneProviderEnabled,
186
181
  showSocial: Boolean(enabledSocialProviders === null || enabledSocialProviders === void 0 ? void 0 : enabledSocialProviders.length),
187
182
  // is email only is set in the project settings when the "Email (Web2) only" is toggled on in the dashboard
188
- showWallets: Boolean(selectableWallets === null || selectableWallets === void 0 ? void 0 : selectableWallets.length) &&
189
- !((_f = (_e = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design) === null || _e === void 0 ? void 0 : _e.modal) === null || _f === void 0 ? void 0 : _f.emailOnly),
183
+ showWallets: numberOfWallets > 0 && !((_f = (_e = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design) === null || _e === void 0 ? void 0 : _e.modal) === null || _f === void 0 ? void 0 : _f.emailOnly),
190
184
  socialAboveEmail,
191
185
  splitEmailAndSocial,
192
186
  web3Layout: authorizationViewDisplayOrder === 'web3',
@@ -216,7 +210,7 @@ const useLoginView = () => {
216
210
  hasPhoneProviderEnabled,
217
211
  loginView === null || loginView === void 0 ? void 0 : loginView.sections,
218
212
  projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design.modal,
219
- selectableWallets === null || selectableWallets === void 0 ? void 0 : selectableWallets.length,
213
+ numberOfWallets,
220
214
  t,
221
215
  ]);
222
216
  return {
@@ -70,6 +70,7 @@ import 'react-focus-lock';
70
70
  import 'qrcode';
71
71
  import 'formik';
72
72
  import '../../../utils/hooks/useSubdomainCheck/useSubdomainCheck.js';
73
+ import { useWalletList } from '../../../utils/hooks/useWalletList/useWalletList.js';
73
74
  import '../../../context/WalletGroupContext/WalletGroupContext.js';
74
75
  import '../../../context/IpConfigurationContext/IpConfigurationContext.js';
75
76
  import '../../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
@@ -99,21 +100,15 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDy
99
100
  const NUMBER_OF_WALLETS = 3;
100
101
  const useLoginView = () => {
101
102
  const loginView = useViewSettings(SdkViewType.Login);
102
- const { projectSettings, authorizationViewDisplayOrder, loginWithEmail, walletConnectorOptions, walletsFilter, } = useInternalDynamicContext();
103
+ const { projectSettings, authorizationViewDisplayOrder, loginWithEmail, walletsFilter, } = useInternalDynamicContext();
103
104
  const { t } = useTranslation();
104
105
  const { enabledSocialProviders } = useSocialRedirectContext();
106
+ const { numberOfWallets } = useWalletList({
107
+ viewWalletsFilter: walletsFilter,
108
+ });
105
109
  const hasSocialProvidersEnabled = Boolean(enabledSocialProviders === null || enabledSocialProviders === void 0 ? void 0 : enabledSocialProviders.length);
106
110
  const hasEmailProviderEnabled = isEmailProviderEnabled(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers);
107
111
  const hasPhoneProviderEnabled = isPhoneNumberProviderEnabled(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers);
108
- /** Takes from wallets only those that can be selected in the wallet list by the user.
109
- * Should filter out embedded wallets
110
- * WHY: when we decide whether to show wallets or not, we need to know how many wallets
111
- * will actually be rendered. It would be especially bad to only have for ex "turnkey" in
112
- * wallets and then display an empty wallet list (since turnkey doesn't render)
113
- */
114
- const selectableWallets = (walletsFilter
115
- ? walletsFilter(walletConnectorOptions)
116
- : walletConnectorOptions).filter(({ key }) => key !== 'turnkey');
117
112
  const isWalletOnly = useMemo(() => {
118
113
  var _a;
119
114
  if (!projectSettings) {
@@ -154,11 +149,11 @@ const useLoginView = () => {
154
149
  sections.find((section) => section.type === 'wallet')) {
155
150
  logger.error('Failed to render WalletSignInSection - no chains enabled');
156
151
  }
157
- if (selectableWallets === null || selectableWallets === void 0 ? void 0 : selectableWallets.length) {
152
+ if (numberOfWallets > 0) {
158
153
  return sections;
159
154
  }
160
155
  return sections.filter((section) => section.type !== 'wallet');
161
- }, [selectableWallets === null || selectableWallets === void 0 ? void 0 : selectableWallets.length, projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.chains]);
156
+ }, [numberOfWallets, projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.chains]);
162
157
  /**
163
158
  * returns the login view sections to be displayed in order from projectSettings?.sdk?.views
164
159
  * and has backwards compatibility with project settings design.modal props
@@ -181,8 +176,7 @@ const useLoginView = () => {
181
176
  showPhone: hasPhoneProviderEnabled,
182
177
  showSocial: Boolean(enabledSocialProviders === null || enabledSocialProviders === void 0 ? void 0 : enabledSocialProviders.length),
183
178
  // is email only is set in the project settings when the "Email (Web2) only" is toggled on in the dashboard
184
- showWallets: Boolean(selectableWallets === null || selectableWallets === void 0 ? void 0 : selectableWallets.length) &&
185
- !((_f = (_e = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design) === null || _e === void 0 ? void 0 : _e.modal) === null || _f === void 0 ? void 0 : _f.emailOnly),
179
+ showWallets: numberOfWallets > 0 && !((_f = (_e = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design) === null || _e === void 0 ? void 0 : _e.modal) === null || _f === void 0 ? void 0 : _f.emailOnly),
186
180
  socialAboveEmail,
187
181
  splitEmailAndSocial,
188
182
  web3Layout: authorizationViewDisplayOrder === 'web3',
@@ -212,7 +206,7 @@ const useLoginView = () => {
212
206
  hasPhoneProviderEnabled,
213
207
  loginView === null || loginView === void 0 ? void 0 : loginView.sections,
214
208
  projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design.modal,
215
- selectableWallets === null || selectableWallets === void 0 ? void 0 : selectableWallets.length,
209
+ numberOfWallets,
216
210
  t,
217
211
  ]);
218
212
  return {