@b3dotfun/sdk 0.0.88-alpha.3 → 0.0.88-alpha.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.
@@ -32,7 +32,6 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
32
32
  const [refetchCount, setRefetchCount] = (0, react_2.useState)(0);
33
33
  const [refetchError, setRefetchError] = (0, react_2.useState)(null);
34
34
  const [turnkeyAuthCompleted, setTurnkeyAuthCompleted] = (0, react_2.useState)(false);
35
- const justCompletedLoginRef = (0, react_2.useRef)(false);
36
35
  const { data: signers, refetch: refetchSigners, isFetching: isFetchingSigners, } = (0, react_1.useGetAllTWSigners)({
37
36
  chain,
38
37
  accountAddress: account?.address,
@@ -152,12 +151,8 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
152
151
  signersEnabled,
153
152
  });
154
153
  // The useEffect will re-run with updated user data to complete the sign-in process
155
- },
156
- // Zustand setters are stable and don't need to be in dependencies:
157
- // eslint-disable-next-line react-hooks/exhaustive-deps
158
- [
154
+ }, [
159
155
  refetchUser,
160
- setB3ModalContentType,
161
156
  strategies,
162
157
  onLoginSuccess,
163
158
  onSessionKeySuccess,
@@ -168,8 +163,10 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
168
163
  closeAfterLogin,
169
164
  source,
170
165
  signersEnabled,
171
- // Zustand setters are stable and don't need to be in dependencies:
172
- // setIsAuthenticated, setIsConnected, setJustCompletedLogin
166
+ setB3ModalContentType,
167
+ setIsAuthenticated,
168
+ setIsConnected,
169
+ setJustCompletedLogin,
173
170
  ]);
174
171
  // Handle post-login flow after signers are loaded
175
172
  (0, react_2.useEffect)(() => {
@@ -184,9 +181,7 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
184
181
  if (isConnected && isAuthenticated && user) {
185
182
  // Mark that login just completed BEFORE opening manage account or closing modal
186
183
  // This allows Turnkey modal to show (if enableTurnkey is true)
187
- // Use ref to prevent setting this multiple times and causing infinite loops
188
- if (closeAfterLogin && !justCompletedLoginRef.current) {
189
- justCompletedLoginRef.current = true;
184
+ if (closeAfterLogin) {
190
185
  setJustCompletedLogin(true);
191
186
  }
192
187
  // Check if we should show Turnkey login form as SECONDARY option (after wallet connection)
@@ -230,7 +225,6 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
230
225
  handlePostTurnkeyFlow();
231
226
  }
232
227
  },
233
- // handlePostTurnkeyFlow changes when its dependencies change, causing infinite loops
234
228
  // eslint-disable-next-line react-hooks/exhaustive-deps
235
229
  [
236
230
  signers,
@@ -251,9 +245,9 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
251
245
  user,
252
246
  enableTurnkey,
253
247
  turnkeyAuthCompleted,
254
- handleTurnkeySuccess,
248
+ // handleTurnkeySuccess, // This is causing infinite loops
255
249
  contentType,
256
- // handlePostTurnkeyFlow - removed because it changes when signers/partnerId/etc change, triggering infinite loops
250
+ handlePostTurnkeyFlow,
257
251
  ]);
258
252
  debug("render", {
259
253
  step,
@@ -268,7 +262,9 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
268
262
  if (closeAfterLogin && sessionKeyAdded) {
269
263
  setB3ModalOpen(false);
270
264
  }
271
- }, [closeAfterLogin, sessionKeyAdded, setB3ModalOpen]);
265
+ // setB3ModalOpen is stable
266
+ // eslint-disable-next-line react-hooks/exhaustive-deps
267
+ }, [closeAfterLogin, sessionKeyAdded]);
272
268
  const onSessionKeySuccessEnhanced = (0, react_2.useCallback)(() => {
273
269
  onSessionKeySuccess?.();
274
270
  setB3ModalContentType({
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Loading, useAuthentication, useAuthStore, useB3Config, useGetAllTWSigners, useModalStore, } from "../../../../global-account/react/index.js";
3
3
  import { debugB3React } from "../../../../shared/utils/debug.js";
4
- import { useCallback, useEffect, useRef, useState } from "react";
4
+ import { useCallback, useEffect, useState } from "react";
5
5
  import { useActiveAccount } from "thirdweb/react";
6
6
  import { TurnkeyAuthModal } from "../TurnkeyAuthModal.js";
7
7
  import { SignInWithB3Privy } from "./SignInWithB3Privy.js";
@@ -29,7 +29,6 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
29
29
  const [refetchCount, setRefetchCount] = useState(0);
30
30
  const [refetchError, setRefetchError] = useState(null);
31
31
  const [turnkeyAuthCompleted, setTurnkeyAuthCompleted] = useState(false);
32
- const justCompletedLoginRef = useRef(false);
33
32
  const { data: signers, refetch: refetchSigners, isFetching: isFetchingSigners, } = useGetAllTWSigners({
34
33
  chain,
35
34
  accountAddress: account?.address,
@@ -149,12 +148,8 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
149
148
  signersEnabled,
150
149
  });
151
150
  // The useEffect will re-run with updated user data to complete the sign-in process
152
- },
153
- // Zustand setters are stable and don't need to be in dependencies:
154
- // eslint-disable-next-line react-hooks/exhaustive-deps
155
- [
151
+ }, [
156
152
  refetchUser,
157
- setB3ModalContentType,
158
153
  strategies,
159
154
  onLoginSuccess,
160
155
  onSessionKeySuccess,
@@ -165,8 +160,10 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
165
160
  closeAfterLogin,
166
161
  source,
167
162
  signersEnabled,
168
- // Zustand setters are stable and don't need to be in dependencies:
169
- // setIsAuthenticated, setIsConnected, setJustCompletedLogin
163
+ setB3ModalContentType,
164
+ setIsAuthenticated,
165
+ setIsConnected,
166
+ setJustCompletedLogin,
170
167
  ]);
171
168
  // Handle post-login flow after signers are loaded
172
169
  useEffect(() => {
@@ -181,9 +178,7 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
181
178
  if (isConnected && isAuthenticated && user) {
182
179
  // Mark that login just completed BEFORE opening manage account or closing modal
183
180
  // This allows Turnkey modal to show (if enableTurnkey is true)
184
- // Use ref to prevent setting this multiple times and causing infinite loops
185
- if (closeAfterLogin && !justCompletedLoginRef.current) {
186
- justCompletedLoginRef.current = true;
181
+ if (closeAfterLogin) {
187
182
  setJustCompletedLogin(true);
188
183
  }
189
184
  // Check if we should show Turnkey login form as SECONDARY option (after wallet connection)
@@ -227,7 +222,6 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
227
222
  handlePostTurnkeyFlow();
228
223
  }
229
224
  },
230
- // handlePostTurnkeyFlow changes when its dependencies change, causing infinite loops
231
225
  // eslint-disable-next-line react-hooks/exhaustive-deps
232
226
  [
233
227
  signers,
@@ -248,9 +242,9 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
248
242
  user,
249
243
  enableTurnkey,
250
244
  turnkeyAuthCompleted,
251
- handleTurnkeySuccess,
245
+ // handleTurnkeySuccess, // This is causing infinite loops
252
246
  contentType,
253
- // handlePostTurnkeyFlow - removed because it changes when signers/partnerId/etc change, triggering infinite loops
247
+ handlePostTurnkeyFlow,
254
248
  ]);
255
249
  debug("render", {
256
250
  step,
@@ -265,7 +259,9 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
265
259
  if (closeAfterLogin && sessionKeyAdded) {
266
260
  setB3ModalOpen(false);
267
261
  }
268
- }, [closeAfterLogin, sessionKeyAdded, setB3ModalOpen]);
262
+ // setB3ModalOpen is stable
263
+ // eslint-disable-next-line react-hooks/exhaustive-deps
264
+ }, [closeAfterLogin, sessionKeyAdded]);
269
265
  const onSessionKeySuccessEnhanced = useCallback(() => {
270
266
  onSessionKeySuccess?.();
271
267
  setB3ModalContentType({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b3dotfun/sdk",
3
- "version": "0.0.88-alpha.3",
3
+ "version": "0.0.88-alpha.4",
4
4
  "source": "src/index.ts",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "react-native": "./dist/cjs/index.native.js",
@@ -8,7 +8,7 @@ import {
8
8
  useModalStore,
9
9
  } from "@b3dotfun/sdk/global-account/react";
10
10
  import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
11
- import { useCallback, useEffect, useRef, useState } from "react";
11
+ import { useCallback, useEffect, useState } from "react";
12
12
  import { useActiveAccount } from "thirdweb/react";
13
13
  import { Account } from "thirdweb/wallets";
14
14
  import { TurnkeyAuthModal } from "../TurnkeyAuthModal";
@@ -51,7 +51,6 @@ export function SignInWithB3Flow({
51
51
  const [refetchCount, setRefetchCount] = useState(0);
52
52
  const [refetchError, setRefetchError] = useState<string | null>(null);
53
53
  const [turnkeyAuthCompleted, setTurnkeyAuthCompleted] = useState(false);
54
- const justCompletedLoginRef = useRef(false);
55
54
  const {
56
55
  data: signers,
57
56
  refetch: refetchSigners,
@@ -185,11 +184,8 @@ export function SignInWithB3Flow({
185
184
  });
186
185
  // The useEffect will re-run with updated user data to complete the sign-in process
187
186
  },
188
- // Zustand setters are stable and don't need to be in dependencies:
189
- // eslint-disable-next-line react-hooks/exhaustive-deps
190
187
  [
191
188
  refetchUser,
192
- setB3ModalContentType,
193
189
  strategies,
194
190
  onLoginSuccess,
195
191
  onSessionKeySuccess,
@@ -200,8 +196,10 @@ export function SignInWithB3Flow({
200
196
  closeAfterLogin,
201
197
  source,
202
198
  signersEnabled,
203
- // Zustand setters are stable and don't need to be in dependencies:
204
- // setIsAuthenticated, setIsConnected, setJustCompletedLogin
199
+ setB3ModalContentType,
200
+ setIsAuthenticated,
201
+ setIsConnected,
202
+ setJustCompletedLogin,
205
203
  ],
206
204
  );
207
205
 
@@ -220,9 +218,7 @@ export function SignInWithB3Flow({
220
218
  if (isConnected && isAuthenticated && user) {
221
219
  // Mark that login just completed BEFORE opening manage account or closing modal
222
220
  // This allows Turnkey modal to show (if enableTurnkey is true)
223
- // Use ref to prevent setting this multiple times and causing infinite loops
224
- if (closeAfterLogin && !justCompletedLoginRef.current) {
225
- justCompletedLoginRef.current = true;
221
+ if (closeAfterLogin) {
226
222
  setJustCompletedLogin(true);
227
223
  }
228
224
 
@@ -271,7 +267,6 @@ export function SignInWithB3Flow({
271
267
  handlePostTurnkeyFlow();
272
268
  }
273
269
  },
274
- // handlePostTurnkeyFlow changes when its dependencies change, causing infinite loops
275
270
  // eslint-disable-next-line react-hooks/exhaustive-deps
276
271
  [
277
272
  signers,
@@ -292,9 +287,9 @@ export function SignInWithB3Flow({
292
287
  user,
293
288
  enableTurnkey,
294
289
  turnkeyAuthCompleted,
295
- handleTurnkeySuccess,
290
+ // handleTurnkeySuccess, // This is causing infinite loops
296
291
  contentType,
297
- // handlePostTurnkeyFlow - removed because it changes when signers/partnerId/etc change, triggering infinite loops
292
+ handlePostTurnkeyFlow,
298
293
  ],
299
294
  );
300
295
 
@@ -312,7 +307,9 @@ export function SignInWithB3Flow({
312
307
  if (closeAfterLogin && sessionKeyAdded) {
313
308
  setB3ModalOpen(false);
314
309
  }
315
- }, [closeAfterLogin, sessionKeyAdded, setB3ModalOpen]);
310
+ // setB3ModalOpen is stable
311
+ // eslint-disable-next-line react-hooks/exhaustive-deps
312
+ }, [closeAfterLogin, sessionKeyAdded]);
316
313
 
317
314
  const onSessionKeySuccessEnhanced = useCallback(() => {
318
315
  onSessionKeySuccess?.();