@dynamic-labs/sdk-react-core 4.12.2 → 4.12.3

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 CHANGED
@@ -1,4 +1,12 @@
1
1
 
2
+ ### [4.12.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.12.2...v4.12.3) (2025-04-17)
3
+
4
+
5
+ ### Features
6
+
7
+ * default waas sui connector network based on enabled chains ([#8570](https://github.com/dynamic-labs/dynamic-auth/issues/8570)) ([9a11b01](https://github.com/dynamic-labs/dynamic-auth/commit/9a11b019bc8ed51873de9d24c93bcc3c1ed6406b))
8
+ * dynamic waas can sign smart account transactiosn ([#8551](https://github.com/dynamic-labs/dynamic-auth/issues/8551)) ([f4882eb](https://github.com/dynamic-labs/dynamic-auth/commit/f4882ebc869b5af72c3beb187bd1a98b83c06e04))
9
+
2
10
  ### [4.12.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.12.1...v4.12.2) (2025-04-16)
3
11
 
4
12
 
package/package.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.12.2";
6
+ var version = "4.12.3";
7
7
  var dependencies = {
8
8
  "@dynamic-labs/sdk-api-core": "0.0.658",
9
9
  "@hcaptcha/react-hcaptcha": "1.4.4",
package/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client'
2
- var version = "4.12.2";
2
+ var version = "4.12.3";
3
3
  var dependencies = {
4
4
  "@dynamic-labs/sdk-api-core": "0.0.658",
5
5
  "@hcaptcha/react-hcaptcha": "1.4.4",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/sdk-react-core",
3
- "version": "4.12.2",
3
+ "version": "4.12.3",
4
4
  "dependencies": {
5
5
  "@dynamic-labs/sdk-api-core": "0.0.658",
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.12.2",
18
- "@dynamic-labs/iconic": "4.12.2",
19
- "@dynamic-labs/logger": "4.12.2",
20
- "@dynamic-labs/multi-wallet": "4.12.2",
21
- "@dynamic-labs/rpc-providers": "4.12.2",
22
- "@dynamic-labs/store": "4.12.2",
23
- "@dynamic-labs/types": "4.12.2",
24
- "@dynamic-labs/utils": "4.12.2",
25
- "@dynamic-labs/wallet-book": "4.12.2",
26
- "@dynamic-labs/wallet-connector-core": "4.12.2",
17
+ "@dynamic-labs/assert-package-version": "4.12.3",
18
+ "@dynamic-labs/iconic": "4.12.3",
19
+ "@dynamic-labs/logger": "4.12.3",
20
+ "@dynamic-labs/multi-wallet": "4.12.3",
21
+ "@dynamic-labs/rpc-providers": "4.12.3",
22
+ "@dynamic-labs/store": "4.12.3",
23
+ "@dynamic-labs/types": "4.12.3",
24
+ "@dynamic-labs/utils": "4.12.3",
25
+ "@dynamic-labs/wallet-book": "4.12.3",
26
+ "@dynamic-labs/wallet-connector-core": "4.12.3",
27
27
  "eventemitter3": "5.0.1"
28
28
  },
29
29
  "devDependencies": {
@@ -99,8 +99,19 @@ require('../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
99
99
  var useInternalDynamicContext = require('../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
100
100
 
101
101
  const WalletConnectorEvents = ({ connectorProps, }) => {
102
- const { walletConnectorOptions, primaryWallet } = useInternalDynamicContext.useInternalDynamicContext();
102
+ const { primaryWallet } = useInternalDynamicContext.useInternalDynamicContext();
103
103
  const { handleWalletItemClick } = useWalletItemActions.useWalletItemActions();
104
+ const pendingConstructorRef = React.useRef([]);
105
+ const injectedDebounceTimeoutRef = React.useRef();
106
+ const pendingReadyConnectorsRef = React.useRef([]);
107
+ const readyDebounceTimeoutRef = React.useRef();
108
+ // need to add the timeout to ensure the setConnectorInitializing call is
109
+ // not made in the same tick to avoid a bad setState call error from React
110
+ const waitAndSetState = (func) => {
111
+ setTimeout(() => {
112
+ func();
113
+ }, 0);
114
+ };
104
115
  const walletConnectorConstructorOptions = React.useMemo(() => {
105
116
  var _a, _b;
106
117
  if (!connectorProps.projectSettings ||
@@ -112,44 +123,84 @@ const WalletConnectorEvents = ({ connectorProps, }) => {
112
123
  }, [connectorProps]);
113
124
  // add listener for providerInjected event
114
125
  React.useEffect(() => {
115
- const handleProviderInjected = ({ injectedConnectorConstructor, }) => {
116
- if (!walletConnectorConstructorOptions)
126
+ const processPendingConstructors = () => {
127
+ if (pendingConstructorRef.current.length === 0) {
117
128
  return;
118
- const injectedConnector = new injectedConnectorConstructor(walletConnectorConstructorOptions);
119
- logger.logger.debug('[WalletConnectorEvents] handleProviderInjected', {
120
- injectedConnector,
129
+ }
130
+ logger.logger.debug('[WalletConnectorEvents] processPendingConstructors', {
131
+ pendingConstructors: pendingConstructorRef.current,
121
132
  });
122
- walletConnectorCore.walletConnectorEvents.emit('providerReady', {
123
- connector: injectedConnector,
133
+ pendingConstructorRef.current.forEach((injectedConnectorConstructor) => {
134
+ if (!walletConnectorConstructorOptions)
135
+ return;
136
+ const injectedConnector = new injectedConnectorConstructor(walletConnectorConstructorOptions);
137
+ logger.logger.debug('[WalletConnectorEvents] handleProviderInjected', {
138
+ injectedConnector,
139
+ });
140
+ walletConnectorCore.walletConnectorEvents.emit('providerReady', {
141
+ connector: injectedConnector,
142
+ });
124
143
  });
144
+ pendingConstructorRef.current = [];
145
+ };
146
+ const handleProviderInjected = ({ injectedConnectorConstructor, }) => {
147
+ pendingConstructorRef.current.push(injectedConnectorConstructor);
148
+ if (injectedDebounceTimeoutRef.current) {
149
+ clearTimeout(injectedDebounceTimeoutRef.current);
150
+ }
151
+ injectedDebounceTimeoutRef.current = setTimeout(() => {
152
+ processPendingConstructors();
153
+ }, 100); // 100ms debounce window
125
154
  };
126
155
  walletConnectorCore.walletConnectorEvents.on('providerInjected', handleProviderInjected);
127
156
  return () => {
128
157
  walletConnectorCore.walletConnectorEvents.off('providerInjected', handleProviderInjected);
158
+ if (injectedDebounceTimeoutRef.current) {
159
+ clearTimeout(injectedDebounceTimeoutRef.current);
160
+ }
161
+ // Process any remaining constructors on cleanup
162
+ processPendingConstructors();
129
163
  };
130
164
  }, [walletConnectorConstructorOptions]);
131
165
  // add listener for providerReady event
132
166
  React.useEffect(() => {
133
- const handleProviderReady = ({ connector, }) => {
134
- logger.logger.debug('[WalletConnectorEvents] handleProviderReady', {
135
- connector,
167
+ const processReadyConnectors = () => {
168
+ if (pendingReadyConnectorsRef.current.length === 0) {
169
+ return;
170
+ }
171
+ logger.logger.logVerboseTroubleshootingMessage('[WalletConnectorEvents] processReadyConnectors', {
172
+ connectors: pendingReadyConnectorsRef.current,
136
173
  });
137
- let foundWallet = false;
138
- const updatedConnectors = walletConnectorOptions.map((walletOption) => {
139
- if (walletOption.key === connector.key) {
140
- foundWallet = true;
141
- return Object.assign(Object.assign({}, walletOption), { isInstalledOnBrowser: connector.isInstalledOnBrowser(), walletConnector: connector });
174
+ const walletConnectorOptions = walletOptions.getWalletConnectorOptions();
175
+ const updatedConnectors = [...walletConnectorOptions];
176
+ pendingReadyConnectorsRef.current.forEach((connector) => {
177
+ let foundWallet = false;
178
+ for (let i = 0; i < updatedConnectors.length; i++) {
179
+ if (updatedConnectors[i].key === connector.key) {
180
+ foundWallet = true;
181
+ updatedConnectors[i] = Object.assign(Object.assign({}, updatedConnectors[i]), { isInstalledOnBrowser: connector.isInstalledOnBrowser(), walletConnector: connector });
182
+ break;
183
+ }
184
+ }
185
+ if (!foundWallet) {
186
+ const newWalletOption = createWallet.createWallet(connectorProps.walletBook, connector);
187
+ updatedConnectors.push(newWalletOption);
142
188
  }
143
- return walletOption;
144
189
  });
145
- logger.logger.debug('[WalletConnectorEvents] handleProviderReady', {
146
- foundWallet,
190
+ walletOptions.mergeWalletConnectorOptions(updatedConnectors);
191
+ pendingReadyConnectorsRef.current = [];
192
+ };
193
+ const handleProviderReady = ({ connector, }) => {
194
+ logger.logger.logVerboseTroubleshootingMessage('[WalletConnectorEvents] handleProviderReady', {
195
+ connector,
147
196
  });
148
- if (!foundWallet) {
149
- const newWalletOption = createWallet.createWallet(connectorProps.walletBook, connector);
150
- updatedConnectors.push(newWalletOption);
197
+ pendingReadyConnectorsRef.current.push(connector);
198
+ if (readyDebounceTimeoutRef.current) {
199
+ clearTimeout(readyDebounceTimeoutRef.current);
151
200
  }
152
- walletOptions.mergeWalletConnectorOptions(updatedConnectors);
201
+ readyDebounceTimeoutRef.current = setTimeout(() => {
202
+ processReadyConnectors();
203
+ }, 100); // 100ms debounce window
153
204
  };
154
205
  if (!walletBook.isWalletBookPopulated(connectorProps.walletBook)) {
155
206
  return;
@@ -157,12 +208,18 @@ const WalletConnectorEvents = ({ connectorProps, }) => {
157
208
  walletConnectorCore.walletConnectorEvents.on('providerReady', handleProviderReady);
158
209
  return () => {
159
210
  walletConnectorCore.walletConnectorEvents.off('providerReady', handleProviderReady);
211
+ if (readyDebounceTimeoutRef.current) {
212
+ clearTimeout(readyDebounceTimeoutRef.current);
213
+ }
214
+ // Process any remaining connectors on cleanup
215
+ processReadyConnectors();
160
216
  };
161
- }, [connectorProps.walletBook, walletConnectorOptions]);
217
+ }, [connectorProps.walletBook]);
162
218
  // add listener for autoConnect event
163
219
  React.useEffect(() => {
164
220
  const handleAutoConnect = ({ connector, }) => {
165
221
  logger.logger.debug('[WalletConnectorEvents] handleAutoConnect', { connector });
222
+ const walletConnectorOptions = walletOptions.getWalletConnectorOptions();
166
223
  const walletOption = walletConnectorOptions.find((wallet) => wallet.walletConnector.key === connector.key);
167
224
  logger.logger.debug('[WalletConnectorEvents] handleAutoConnect - found walletOption', Boolean(walletOption));
168
225
  if (!walletOption)
@@ -177,24 +234,20 @@ const WalletConnectorEvents = ({ connectorProps, }) => {
177
234
  return () => {
178
235
  walletConnectorCore.walletConnectorEvents.off('autoConnect', handleAutoConnect);
179
236
  };
180
- }, [handleWalletItemClick, walletConnectorOptions, primaryWallet]);
237
+ }, [handleWalletItemClick, primaryWallet]);
181
238
  // add listener for connectorInitStarted and connectorInitCompleted events
182
239
  React.useEffect(() => {
183
240
  const handleConnectorInitStarted = (key) => {
184
241
  logger.logger.logVerboseTroubleshootingMessage('[WalletConnectorEvents] handleConnectorInitStarted', { key });
185
- // need to add the timeout to ensure the setConnectorInitializing call is not
186
- // made in the same tick to avoid a bad setState call error from React
187
- setTimeout(() => {
242
+ waitAndSetState(() => {
188
243
  connectorsInitializing.setConnectorInitializing(key, true);
189
- }, 0);
244
+ });
190
245
  };
191
246
  const handleConnectorInitCompleted = (key) => {
192
247
  logger.logger.logVerboseTroubleshootingMessage('[WalletConnectorEvents] handleConnectorInitCompleted', { key });
193
- // need to add the timeout to ensure the setConnectorInitializing call is not
194
- // made in the same tick to avoid a bad setState call error from React
195
- setTimeout(() => {
248
+ waitAndSetState(() => {
196
249
  connectorsInitializing.setConnectorInitializing(key, false);
197
- }, 0);
250
+ });
198
251
  };
199
252
  walletConnectorCore.walletConnectorEvents.on('connectorInitStarted', handleConnectorInitStarted);
200
253
  walletConnectorCore.walletConnectorEvents.on('connectorInitCompleted', handleConnectorInitCompleted);
@@ -1,5 +1,5 @@
1
1
  'use client'
2
- import { useMemo, useEffect } from 'react';
2
+ import { useRef, useMemo, useEffect } from 'react';
3
3
  import { walletConnectorEvents } from '@dynamic-labs/wallet-connector-core';
4
4
  import { getWalletConnectorConstructorOptions } from '@dynamic-labs/multi-wallet';
5
5
  import { ChainRpcProviders } from '@dynamic-labs/rpc-providers';
@@ -50,7 +50,7 @@ import '../../context/MockContext/MockContext.js';
50
50
  import '../../views/CollectUserDataView/useFields.js';
51
51
  import '../../context/FieldsStateContext/FieldsStateContext.js';
52
52
  import '../../context/UserFieldEditorContext/UserFieldEditorContext.js';
53
- import { mergeWalletConnectorOptions } from '../../store/state/walletOptions/walletOptions.js';
53
+ import { getWalletConnectorOptions, mergeWalletConnectorOptions } from '../../store/state/walletOptions/walletOptions.js';
54
54
  import 'react-i18next';
55
55
  import '../Accordion/components/AccordionItem/AccordionItem.js';
56
56
  import '../Alert/Alert.js';
@@ -95,8 +95,19 @@ import '../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
95
95
  import { useInternalDynamicContext } from '../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
96
96
 
97
97
  const WalletConnectorEvents = ({ connectorProps, }) => {
98
- const { walletConnectorOptions, primaryWallet } = useInternalDynamicContext();
98
+ const { primaryWallet } = useInternalDynamicContext();
99
99
  const { handleWalletItemClick } = useWalletItemActions();
100
+ const pendingConstructorRef = useRef([]);
101
+ const injectedDebounceTimeoutRef = useRef();
102
+ const pendingReadyConnectorsRef = useRef([]);
103
+ const readyDebounceTimeoutRef = useRef();
104
+ // need to add the timeout to ensure the setConnectorInitializing call is
105
+ // not made in the same tick to avoid a bad setState call error from React
106
+ const waitAndSetState = (func) => {
107
+ setTimeout(() => {
108
+ func();
109
+ }, 0);
110
+ };
100
111
  const walletConnectorConstructorOptions = useMemo(() => {
101
112
  var _a, _b;
102
113
  if (!connectorProps.projectSettings ||
@@ -108,44 +119,84 @@ const WalletConnectorEvents = ({ connectorProps, }) => {
108
119
  }, [connectorProps]);
109
120
  // add listener for providerInjected event
110
121
  useEffect(() => {
111
- const handleProviderInjected = ({ injectedConnectorConstructor, }) => {
112
- if (!walletConnectorConstructorOptions)
122
+ const processPendingConstructors = () => {
123
+ if (pendingConstructorRef.current.length === 0) {
113
124
  return;
114
- const injectedConnector = new injectedConnectorConstructor(walletConnectorConstructorOptions);
115
- logger.debug('[WalletConnectorEvents] handleProviderInjected', {
116
- injectedConnector,
125
+ }
126
+ logger.debug('[WalletConnectorEvents] processPendingConstructors', {
127
+ pendingConstructors: pendingConstructorRef.current,
117
128
  });
118
- walletConnectorEvents.emit('providerReady', {
119
- connector: injectedConnector,
129
+ pendingConstructorRef.current.forEach((injectedConnectorConstructor) => {
130
+ if (!walletConnectorConstructorOptions)
131
+ return;
132
+ const injectedConnector = new injectedConnectorConstructor(walletConnectorConstructorOptions);
133
+ logger.debug('[WalletConnectorEvents] handleProviderInjected', {
134
+ injectedConnector,
135
+ });
136
+ walletConnectorEvents.emit('providerReady', {
137
+ connector: injectedConnector,
138
+ });
120
139
  });
140
+ pendingConstructorRef.current = [];
141
+ };
142
+ const handleProviderInjected = ({ injectedConnectorConstructor, }) => {
143
+ pendingConstructorRef.current.push(injectedConnectorConstructor);
144
+ if (injectedDebounceTimeoutRef.current) {
145
+ clearTimeout(injectedDebounceTimeoutRef.current);
146
+ }
147
+ injectedDebounceTimeoutRef.current = setTimeout(() => {
148
+ processPendingConstructors();
149
+ }, 100); // 100ms debounce window
121
150
  };
122
151
  walletConnectorEvents.on('providerInjected', handleProviderInjected);
123
152
  return () => {
124
153
  walletConnectorEvents.off('providerInjected', handleProviderInjected);
154
+ if (injectedDebounceTimeoutRef.current) {
155
+ clearTimeout(injectedDebounceTimeoutRef.current);
156
+ }
157
+ // Process any remaining constructors on cleanup
158
+ processPendingConstructors();
125
159
  };
126
160
  }, [walletConnectorConstructorOptions]);
127
161
  // add listener for providerReady event
128
162
  useEffect(() => {
129
- const handleProviderReady = ({ connector, }) => {
130
- logger.debug('[WalletConnectorEvents] handleProviderReady', {
131
- connector,
163
+ const processReadyConnectors = () => {
164
+ if (pendingReadyConnectorsRef.current.length === 0) {
165
+ return;
166
+ }
167
+ logger.logVerboseTroubleshootingMessage('[WalletConnectorEvents] processReadyConnectors', {
168
+ connectors: pendingReadyConnectorsRef.current,
132
169
  });
133
- let foundWallet = false;
134
- const updatedConnectors = walletConnectorOptions.map((walletOption) => {
135
- if (walletOption.key === connector.key) {
136
- foundWallet = true;
137
- return Object.assign(Object.assign({}, walletOption), { isInstalledOnBrowser: connector.isInstalledOnBrowser(), walletConnector: connector });
170
+ const walletConnectorOptions = getWalletConnectorOptions();
171
+ const updatedConnectors = [...walletConnectorOptions];
172
+ pendingReadyConnectorsRef.current.forEach((connector) => {
173
+ let foundWallet = false;
174
+ for (let i = 0; i < updatedConnectors.length; i++) {
175
+ if (updatedConnectors[i].key === connector.key) {
176
+ foundWallet = true;
177
+ updatedConnectors[i] = Object.assign(Object.assign({}, updatedConnectors[i]), { isInstalledOnBrowser: connector.isInstalledOnBrowser(), walletConnector: connector });
178
+ break;
179
+ }
180
+ }
181
+ if (!foundWallet) {
182
+ const newWalletOption = createWallet(connectorProps.walletBook, connector);
183
+ updatedConnectors.push(newWalletOption);
138
184
  }
139
- return walletOption;
140
185
  });
141
- logger.debug('[WalletConnectorEvents] handleProviderReady', {
142
- foundWallet,
186
+ mergeWalletConnectorOptions(updatedConnectors);
187
+ pendingReadyConnectorsRef.current = [];
188
+ };
189
+ const handleProviderReady = ({ connector, }) => {
190
+ logger.logVerboseTroubleshootingMessage('[WalletConnectorEvents] handleProviderReady', {
191
+ connector,
143
192
  });
144
- if (!foundWallet) {
145
- const newWalletOption = createWallet(connectorProps.walletBook, connector);
146
- updatedConnectors.push(newWalletOption);
193
+ pendingReadyConnectorsRef.current.push(connector);
194
+ if (readyDebounceTimeoutRef.current) {
195
+ clearTimeout(readyDebounceTimeoutRef.current);
147
196
  }
148
- mergeWalletConnectorOptions(updatedConnectors);
197
+ readyDebounceTimeoutRef.current = setTimeout(() => {
198
+ processReadyConnectors();
199
+ }, 100); // 100ms debounce window
149
200
  };
150
201
  if (!isWalletBookPopulated(connectorProps.walletBook)) {
151
202
  return;
@@ -153,12 +204,18 @@ const WalletConnectorEvents = ({ connectorProps, }) => {
153
204
  walletConnectorEvents.on('providerReady', handleProviderReady);
154
205
  return () => {
155
206
  walletConnectorEvents.off('providerReady', handleProviderReady);
207
+ if (readyDebounceTimeoutRef.current) {
208
+ clearTimeout(readyDebounceTimeoutRef.current);
209
+ }
210
+ // Process any remaining connectors on cleanup
211
+ processReadyConnectors();
156
212
  };
157
- }, [connectorProps.walletBook, walletConnectorOptions]);
213
+ }, [connectorProps.walletBook]);
158
214
  // add listener for autoConnect event
159
215
  useEffect(() => {
160
216
  const handleAutoConnect = ({ connector, }) => {
161
217
  logger.debug('[WalletConnectorEvents] handleAutoConnect', { connector });
218
+ const walletConnectorOptions = getWalletConnectorOptions();
162
219
  const walletOption = walletConnectorOptions.find((wallet) => wallet.walletConnector.key === connector.key);
163
220
  logger.debug('[WalletConnectorEvents] handleAutoConnect - found walletOption', Boolean(walletOption));
164
221
  if (!walletOption)
@@ -173,24 +230,20 @@ const WalletConnectorEvents = ({ connectorProps, }) => {
173
230
  return () => {
174
231
  walletConnectorEvents.off('autoConnect', handleAutoConnect);
175
232
  };
176
- }, [handleWalletItemClick, walletConnectorOptions, primaryWallet]);
233
+ }, [handleWalletItemClick, primaryWallet]);
177
234
  // add listener for connectorInitStarted and connectorInitCompleted events
178
235
  useEffect(() => {
179
236
  const handleConnectorInitStarted = (key) => {
180
237
  logger.logVerboseTroubleshootingMessage('[WalletConnectorEvents] handleConnectorInitStarted', { key });
181
- // need to add the timeout to ensure the setConnectorInitializing call is not
182
- // made in the same tick to avoid a bad setState call error from React
183
- setTimeout(() => {
238
+ waitAndSetState(() => {
184
239
  setConnectorInitializing(key, true);
185
- }, 0);
240
+ });
186
241
  };
187
242
  const handleConnectorInitCompleted = (key) => {
188
243
  logger.logVerboseTroubleshootingMessage('[WalletConnectorEvents] handleConnectorInitCompleted', { key });
189
- // need to add the timeout to ensure the setConnectorInitializing call is not
190
- // made in the same tick to avoid a bad setState call error from React
191
- setTimeout(() => {
244
+ waitAndSetState(() => {
192
245
  setConnectorInitializing(key, false);
193
- }, 0);
246
+ });
194
247
  };
195
248
  walletConnectorEvents.on('connectorInitStarted', handleConnectorInitStarted);
196
249
  walletConnectorEvents.on('connectorInitCompleted', handleConnectorInitCompleted);
@@ -40,9 +40,10 @@ require('../../../locale/locale.cjs');
40
40
  require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
41
41
  require('../../../context/VerificationContext/VerificationContext.cjs');
42
42
  require('react-dom');
43
- require('../../functions/compareChains/compareChains.cjs');
43
+ var smartWallet = require('../useWalletConnectors/utils/smartWallet/smartWallet.cjs');
44
44
  require('../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
45
45
  require('../../../context/ThemeContext/ThemeContext.cjs');
46
+ require('../../functions/compareChains/compareChains.cjs');
46
47
  require('../useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
47
48
  require('bs58');
48
49
  require('@dynamic-labs/types');
@@ -169,14 +170,18 @@ const useDynamicWaas = () => {
169
170
  })));
170
171
  const primaryWalletAccount = createdWalletAccounts === null || createdWalletAccounts === void 0 ? void 0 : createdWalletAccounts.find((wallet) => (wallet === null || wallet === void 0 ? void 0 : wallet.chainName) === (primaryChain === null || primaryChain === void 0 ? void 0 : primaryChain.name));
171
172
  const refreshedUser = yield refresh();
172
- const createdPrimaryWallet = refreshedUser === null || refreshedUser === void 0 ? void 0 : refreshedUser.verifiedCredentials.find((wallet) => {
173
- var _a, _b, _c;
174
- return ((_a = wallet.walletName) === null || _a === void 0 ? void 0 : _a.includes(dynamicWaasKey)) &&
175
- ((_b = wallet.address) === null || _b === void 0 ? void 0 : _b.toLowerCase()) ===
176
- ((_c = primaryWalletAccount === null || primaryWalletAccount === void 0 ? void 0 : primaryWalletAccount.accountAddress) === null || _c === void 0 ? void 0 : _c.toLowerCase());
177
- });
178
- if (createdPrimaryWallet) {
179
- updatePrimaryWalletId.updatePrimaryWalletId(createdPrimaryWallet.id);
173
+ if (refreshedUser && primaryWalletAccount) {
174
+ const createdPrimaryWallet = refreshedUser.verifiedCredentials.find((wallet) => {
175
+ var _a, _b, _c;
176
+ return ((_a = wallet.walletName) === null || _a === void 0 ? void 0 : _a.includes(dynamicWaasKey)) &&
177
+ ((_b = wallet.address) === null || _b === void 0 ? void 0 : _b.toLowerCase()) ===
178
+ ((_c = primaryWalletAccount.accountAddress) === null || _c === void 0 ? void 0 : _c.toLowerCase());
179
+ });
180
+ if (createdPrimaryWallet) {
181
+ const smartWalletAccount = smartWallet.findSmartWallet(createdPrimaryWallet, refreshedUser.verifiedCredentials);
182
+ const walletIdToUse = (smartWalletAccount === null || smartWalletAccount === void 0 ? void 0 : smartWalletAccount.id) || createdPrimaryWallet.id;
183
+ updatePrimaryWalletId.updatePrimaryWalletId(walletIdToUse);
184
+ }
180
185
  }
181
186
  setShowAuthFlow(false, { performMultiWalletChecks: false }); // close email otp pin modal
182
187
  return createdWalletAccounts;
@@ -36,9 +36,10 @@ import '../../../locale/locale.js';
36
36
  import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
37
37
  import '../../../context/VerificationContext/VerificationContext.js';
38
38
  import 'react-dom';
39
- import '../../functions/compareChains/compareChains.js';
39
+ import { findSmartWallet } from '../useWalletConnectors/utils/smartWallet/smartWallet.js';
40
40
  import '../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
41
41
  import '../../../context/ThemeContext/ThemeContext.js';
42
+ import '../../functions/compareChains/compareChains.js';
42
43
  import '../useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
43
44
  import 'bs58';
44
45
  import '@dynamic-labs/types';
@@ -165,14 +166,18 @@ const useDynamicWaas = () => {
165
166
  })));
166
167
  const primaryWalletAccount = createdWalletAccounts === null || createdWalletAccounts === void 0 ? void 0 : createdWalletAccounts.find((wallet) => (wallet === null || wallet === void 0 ? void 0 : wallet.chainName) === (primaryChain === null || primaryChain === void 0 ? void 0 : primaryChain.name));
167
168
  const refreshedUser = yield refresh();
168
- const createdPrimaryWallet = refreshedUser === null || refreshedUser === void 0 ? void 0 : refreshedUser.verifiedCredentials.find((wallet) => {
169
- var _a, _b, _c;
170
- return ((_a = wallet.walletName) === null || _a === void 0 ? void 0 : _a.includes(dynamicWaasKey)) &&
171
- ((_b = wallet.address) === null || _b === void 0 ? void 0 : _b.toLowerCase()) ===
172
- ((_c = primaryWalletAccount === null || primaryWalletAccount === void 0 ? void 0 : primaryWalletAccount.accountAddress) === null || _c === void 0 ? void 0 : _c.toLowerCase());
173
- });
174
- if (createdPrimaryWallet) {
175
- updatePrimaryWalletId(createdPrimaryWallet.id);
169
+ if (refreshedUser && primaryWalletAccount) {
170
+ const createdPrimaryWallet = refreshedUser.verifiedCredentials.find((wallet) => {
171
+ var _a, _b, _c;
172
+ return ((_a = wallet.walletName) === null || _a === void 0 ? void 0 : _a.includes(dynamicWaasKey)) &&
173
+ ((_b = wallet.address) === null || _b === void 0 ? void 0 : _b.toLowerCase()) ===
174
+ ((_c = primaryWalletAccount.accountAddress) === null || _c === void 0 ? void 0 : _c.toLowerCase());
175
+ });
176
+ if (createdPrimaryWallet) {
177
+ const smartWalletAccount = findSmartWallet(createdPrimaryWallet, refreshedUser.verifiedCredentials);
178
+ const walletIdToUse = (smartWalletAccount === null || smartWalletAccount === void 0 ? void 0 : smartWalletAccount.id) || createdPrimaryWallet.id;
179
+ updatePrimaryWalletId(walletIdToUse);
180
+ }
176
181
  }
177
182
  setShowAuthFlow(false, { performMultiWalletChecks: false }); // close email otp pin modal
178
183
  return createdWalletAccounts;
@@ -100,10 +100,12 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useDyna
100
100
  const useIsLoadingEmbeddedWallet = () => {
101
101
  const { user } = useInternalDynamicContext.useInternalDynamicContext();
102
102
  const projectSettings$1 = projectSettings.getProjectSettings();
103
+ // we only want to show the loading state if the user has no wallets at all, and is creating a waas wallet
104
+ // for example if they sign up with phantom wallet, we don't want to show the loading state
103
105
  const isLoadingEmbeddedWallet = React.useMemo(() => {
104
106
  var _a;
105
107
  return usingV3Wallets.usingV3Wallets(projectSettings$1) &&
106
- !((_a = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find(({ walletProvider }) => walletProvider === 'embeddedWallet'));
108
+ !((_a = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find(({ format }) => format === 'blockchain'));
107
109
  }, [projectSettings$1, user]);
108
110
  return { isLoadingEmbeddedWallet };
109
111
  };
@@ -96,10 +96,12 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDy
96
96
  const useIsLoadingEmbeddedWallet = () => {
97
97
  const { user } = useInternalDynamicContext();
98
98
  const projectSettings = getProjectSettings();
99
+ // we only want to show the loading state if the user has no wallets at all, and is creating a waas wallet
100
+ // for example if they sign up with phantom wallet, we don't want to show the loading state
99
101
  const isLoadingEmbeddedWallet = useMemo(() => {
100
102
  var _a;
101
103
  return usingV3Wallets(projectSettings) &&
102
- !((_a = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find(({ walletProvider }) => walletProvider === 'embeddedWallet'));
104
+ !((_a = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find(({ format }) => format === 'blockchain'));
103
105
  }, [projectSettings, user]);
104
106
  return { isLoadingEmbeddedWallet };
105
107
  };
@@ -41,6 +41,7 @@ require('../../functions/compareChains/compareChains.cjs');
41
41
  require('../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
42
42
  require('../../../context/ThemeContext/ThemeContext.cjs');
43
43
  var useSmartWallets = require('../useSmartWallets/useSmartWallets.cjs');
44
+ var usingV3Wallets = require('../../functions/usingV3Wallets/usingV3Wallets.cjs');
44
45
  require('../useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
45
46
  require('bs58');
46
47
  require('@dynamic-labs/types');
@@ -111,7 +112,8 @@ const useIsLoggedIn = () => {
111
112
  const isLoggedIn = Boolean(user) || (authMode === 'connect-only' && Boolean(primaryWallet));
112
113
  const userWalletsCredentials = (_a = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.filter(({ walletProvider }) => walletProvider);
113
114
  const hasEmbeddedWalletVerifiedCredential = Boolean(userWalletsCredentials === null || userWalletsCredentials === void 0 ? void 0 : userWalletsCredentials.find(({ walletProvider }) => walletProvider === 'embeddedWallet'));
114
- const isTurnkeyPregen = isTurnkeyProviderEnabled &&
115
+ const isTurnkeyPregen = !usingV3Wallets.usingV3Wallets(projectSettings) &&
116
+ isTurnkeyProviderEnabled &&
115
117
  ((_c = (_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _b === void 0 ? void 0 : _b.embeddedWallets) === null || _c === void 0 ? void 0 : _c.automaticEmbeddedWalletCreation) &&
116
118
  (!(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets.forceAuthenticatorAtSignup) ||
117
119
  isSessionKeyCompatible);
@@ -37,6 +37,7 @@ import '../../functions/compareChains/compareChains.js';
37
37
  import '../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
38
38
  import '../../../context/ThemeContext/ThemeContext.js';
39
39
  import { useSmartWallets } from '../useSmartWallets/useSmartWallets.js';
40
+ import { usingV3Wallets } from '../../functions/usingV3Wallets/usingV3Wallets.js';
40
41
  import '../useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
41
42
  import 'bs58';
42
43
  import '@dynamic-labs/types';
@@ -107,7 +108,8 @@ const useIsLoggedIn = () => {
107
108
  const isLoggedIn = Boolean(user) || (authMode === 'connect-only' && Boolean(primaryWallet));
108
109
  const userWalletsCredentials = (_a = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.filter(({ walletProvider }) => walletProvider);
109
110
  const hasEmbeddedWalletVerifiedCredential = Boolean(userWalletsCredentials === null || userWalletsCredentials === void 0 ? void 0 : userWalletsCredentials.find(({ walletProvider }) => walletProvider === 'embeddedWallet'));
110
- const isTurnkeyPregen = isTurnkeyProviderEnabled &&
111
+ const isTurnkeyPregen = !usingV3Wallets(projectSettings) &&
112
+ isTurnkeyProviderEnabled &&
111
113
  ((_c = (_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _b === void 0 ? void 0 : _b.embeddedWallets) === null || _c === void 0 ? void 0 : _c.automaticEmbeddedWalletCreation) &&
112
114
  (!(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets.forceAuthenticatorAtSignup) ||
113
115
  isSessionKeyCompatible);