@b3dotfun/sdk 0.0.83-test.0 → 0.0.83

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.
Files changed (68) hide show
  1. package/dist/cjs/anyspend/react/components/AnySpend.js +0 -3
  2. package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.js +1 -1
  3. package/dist/cjs/anyspend/react/components/AnySpendCustom.js +0 -3
  4. package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +47 -177
  5. package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +0 -3
  6. package/dist/cjs/anyspend/utils/chain.d.ts +38 -0
  7. package/dist/cjs/anyspend/utils/chain.js +22 -1
  8. package/dist/cjs/anyspend/utils/token.d.ts +3 -0
  9. package/dist/cjs/anyspend/utils/token.js +17 -1
  10. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +12 -57
  11. package/dist/cjs/global-account/react/hooks/index.d.ts +0 -1
  12. package/dist/cjs/global-account/react/hooks/index.js +1 -3
  13. package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +2 -2
  14. package/dist/cjs/global-account/react/hooks/useAuthentication.js +63 -72
  15. package/dist/cjs/global-account/react/hooks/useTWAuth.d.ts +0 -3
  16. package/dist/cjs/global-account/react/hooks/useTWAuth.js +0 -8
  17. package/dist/cjs/global-account/react/hooks/useTurnkeyAuth.js +24 -54
  18. package/dist/cjs/global-account/react/hooks/useUserQuery.d.ts +1 -1
  19. package/dist/esm/anyspend/react/components/AnySpend.js +0 -3
  20. package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.js +1 -1
  21. package/dist/esm/anyspend/react/components/AnySpendCustom.js +0 -3
  22. package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +45 -175
  23. package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +0 -3
  24. package/dist/esm/anyspend/utils/chain.d.ts +38 -0
  25. package/dist/esm/anyspend/utils/chain.js +22 -1
  26. package/dist/esm/anyspend/utils/token.d.ts +3 -0
  27. package/dist/esm/anyspend/utils/token.js +15 -1
  28. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +12 -57
  29. package/dist/esm/global-account/react/hooks/index.d.ts +0 -1
  30. package/dist/esm/global-account/react/hooks/index.js +0 -1
  31. package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +2 -2
  32. package/dist/esm/global-account/react/hooks/useAuthentication.js +63 -72
  33. package/dist/esm/global-account/react/hooks/useTWAuth.d.ts +0 -3
  34. package/dist/esm/global-account/react/hooks/useTWAuth.js +0 -8
  35. package/dist/esm/global-account/react/hooks/useTurnkeyAuth.js +24 -54
  36. package/dist/esm/global-account/react/hooks/useUserQuery.d.ts +1 -1
  37. package/dist/styles/index.css +1 -1
  38. package/dist/types/anyspend/utils/chain.d.ts +38 -0
  39. package/dist/types/anyspend/utils/token.d.ts +3 -0
  40. package/dist/types/global-account/react/hooks/index.d.ts +0 -1
  41. package/dist/types/global-account/react/hooks/useAuthentication.d.ts +2 -2
  42. package/dist/types/global-account/react/hooks/useTWAuth.d.ts +0 -3
  43. package/dist/types/global-account/react/hooks/useUserQuery.d.ts +1 -1
  44. package/package.json +1 -1
  45. package/src/anyspend/react/components/AnySpend.tsx +0 -4
  46. package/src/anyspend/react/components/AnySpendCollectorClubPurchase.tsx +1 -1
  47. package/src/anyspend/react/components/AnySpendCustom.tsx +0 -4
  48. package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +22 -253
  49. package/src/anyspend/react/hooks/useAnyspendFlow.ts +0 -4
  50. package/src/anyspend/utils/chain.ts +31 -1
  51. package/src/anyspend/utils/token.ts +17 -1
  52. package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +22 -77
  53. package/src/global-account/react/hooks/index.ts +0 -1
  54. package/src/global-account/react/hooks/useAuthentication.ts +85 -88
  55. package/src/global-account/react/hooks/useTWAuth.tsx +0 -10
  56. package/src/global-account/react/hooks/useTurnkeyAuth.ts +26 -59
  57. package/dist/cjs/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +0 -10
  58. package/dist/cjs/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.js +0 -73
  59. package/dist/cjs/global-account/react/hooks/useAuth.d.ts +0 -76
  60. package/dist/cjs/global-account/react/hooks/useAuth.js +0 -338
  61. package/dist/esm/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +0 -10
  62. package/dist/esm/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.js +0 -70
  63. package/dist/esm/global-account/react/hooks/useAuth.d.ts +0 -76
  64. package/dist/esm/global-account/react/hooks/useAuth.js +0 -332
  65. package/dist/types/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +0 -10
  66. package/dist/types/global-account/react/hooks/useAuth.d.ts +0 -76
  67. package/src/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.ts +0 -80
  68. package/src/global-account/react/hooks/useAuth.ts +0 -380
@@ -3,7 +3,6 @@ export { useAccountAssets } from "./useAccountAssets";
3
3
  export { useAccountWallet } from "./useAccountWallet";
4
4
  export { useAddTWSessionKey } from "./useAddTWSessionKey";
5
5
  export { useAnalytics } from "./useAnalytics";
6
- export { useAuth } from "./useAuth";
7
6
  export { useAuthentication } from "./useAuthentication";
8
7
  export { useB3BalanceFromAddresses } from "./useB3BalanceFromAddresses";
9
8
  export { useB3EnsName } from "./useB3EnsName";
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.useURLParams = exports.useUnifiedChainSwitchAndExecute = exports.useTurnkeyAuth = exports.useTokensFromAddress = exports.useTokenPriceWithFallback = exports.useTokenPrice = exports.useTokenFromUrl = exports.useTokenData = exports.useTokenBalancesByChain = exports.useTokenBalanceDirect = exports.useTokenBalance = exports.useSiwe = exports.useSimSvmBalance = exports.useSimBalance = exports.useSearchParamsSSR = exports.useRouter = exports.useRemoveSessionKey = exports.useQueryBSMNT = exports.useQueryB3 = exports.useProfileSettings = exports.useProfilePreference = exports.useProfile = exports.useDisplayName = exports.useOneBalance = exports.useNotifications = exports.useNativeBalanceFromRPC = exports.useNativeBalance = exports.useMediaQuery = exports.useIsomorphicLayoutEffect = exports.useIsMobile = exports.useHasMounted = exports.useHandleConnectWithPrivy = exports.useGlobalAccount = exports.useGetGeo = exports.useGetAllTWSigners = exports.useFirstEOA = exports.useExchangeRate = exports.useConnect = exports.useClient = exports.useChainSwitchWithAction = exports.useBestTransactionPath = exports.useB3EnsName = exports.useB3BalanceFromAddresses = exports.useAuthentication = exports.useAuth = exports.useAnalytics = exports.useAddTWSessionKey = exports.useAccountWallet = exports.useAccountAssets = exports.createWagmiConfig = void 0;
17
+ exports.useURLParams = exports.useUnifiedChainSwitchAndExecute = exports.useTurnkeyAuth = exports.useTokensFromAddress = exports.useTokenPriceWithFallback = exports.useTokenPrice = exports.useTokenFromUrl = exports.useTokenData = exports.useTokenBalancesByChain = exports.useTokenBalanceDirect = exports.useTokenBalance = exports.useSiwe = exports.useSimSvmBalance = exports.useSimBalance = exports.useSearchParamsSSR = exports.useRouter = exports.useRemoveSessionKey = exports.useQueryBSMNT = exports.useQueryB3 = exports.useProfileSettings = exports.useProfilePreference = exports.useProfile = exports.useDisplayName = exports.useOneBalance = exports.useNotifications = exports.useNativeBalanceFromRPC = exports.useNativeBalance = exports.useMediaQuery = exports.useIsomorphicLayoutEffect = exports.useIsMobile = exports.useHasMounted = exports.useHandleConnectWithPrivy = exports.useGlobalAccount = exports.useGetGeo = exports.useGetAllTWSigners = exports.useFirstEOA = exports.useExchangeRate = exports.useConnect = exports.useClient = exports.useChainSwitchWithAction = exports.useBestTransactionPath = exports.useB3EnsName = exports.useB3BalanceFromAddresses = exports.useAuthentication = exports.useAnalytics = exports.useAddTWSessionKey = exports.useAccountWallet = exports.useAccountAssets = exports.createWagmiConfig = void 0;
18
18
  var createWagmiConfig_1 = require("../utils/createWagmiConfig");
19
19
  Object.defineProperty(exports, "createWagmiConfig", { enumerable: true, get: function () { return createWagmiConfig_1.createWagmiConfig; } });
20
20
  var useAccountAssets_1 = require("./useAccountAssets");
@@ -25,8 +25,6 @@ var useAddTWSessionKey_1 = require("./useAddTWSessionKey");
25
25
  Object.defineProperty(exports, "useAddTWSessionKey", { enumerable: true, get: function () { return useAddTWSessionKey_1.useAddTWSessionKey; } });
26
26
  var useAnalytics_1 = require("./useAnalytics");
27
27
  Object.defineProperty(exports, "useAnalytics", { enumerable: true, get: function () { return useAnalytics_1.useAnalytics; } });
28
- var useAuth_1 = require("./useAuth");
29
- Object.defineProperty(exports, "useAuth", { enumerable: true, get: function () { return useAuth_1.useAuth; } });
30
28
  var useAuthentication_1 = require("./useAuthentication");
31
29
  Object.defineProperty(exports, "useAuthentication", { enumerable: true, get: function () { return useAuthentication_1.useAuthentication; } });
32
30
  var useB3BalanceFromAddresses_1 = require("./useB3BalanceFromAddresses");
@@ -41,8 +41,8 @@ export declare function useAuthentication(partnerId: string): {
41
41
  name?: string | undefined;
42
42
  address?: string | undefined;
43
43
  email?: string | undefined;
44
- phone?: string | undefined;
45
44
  username?: string | undefined;
45
+ phone?: string | undefined;
46
46
  fid?: string | undefined;
47
47
  };
48
48
  }[] | undefined;
@@ -63,6 +63,6 @@ export declare function useAuthentication(partnerId: string): {
63
63
  turnkeyOtpId?: string | undefined;
64
64
  };
65
65
  } | undefined;
66
- refetchUser: () => Promise<import("@feathersjs/authentication").AuthenticationResult>;
66
+ refetchUser: (wallet?: Wallet) => Promise<import("@feathersjs/authentication").AuthenticationResult>;
67
67
  setUser: (newUser?: import("@b3dotfun/b3-api").Users) => void;
68
68
  };
@@ -18,7 +18,7 @@ const in_app_1 = require("thirdweb/wallets/in-app");
18
18
  const wagmi_1 = require("wagmi");
19
19
  const LocalSDKProvider_1 = require("../components/B3Provider/LocalSDKProvider");
20
20
  const createWagmiConfig_1 = require("../utils/createWagmiConfig");
21
- const useAuth_1 = require("./useAuth");
21
+ const useTWAuth_1 = require("./useTWAuth");
22
22
  const useUserQuery_1 = require("./useUserQuery");
23
23
  const debug = (0, debug_1.debugB3React)("useAuthentication");
24
24
  function useAuthentication(partnerId) {
@@ -36,7 +36,7 @@ function useAuthentication(partnerId) {
36
36
  const setHasStartedConnecting = (0, react_1.useAuthStore)(state => state.setHasStartedConnecting);
37
37
  const setActiveWallet = (0, react_3.useSetActiveWallet)();
38
38
  const hasStartedConnecting = (0, react_1.useAuthStore)(state => state.hasStartedConnecting);
39
- const { reAuthenticate } = (0, useAuth_1.useAuth)();
39
+ const { authenticate } = (0, useTWAuth_1.useTWAuth)();
40
40
  const { user, setUser } = (0, useUserQuery_1.useUserQuery)();
41
41
  const useAutoConnectLoadingPrevious = (0, react_2.useRef)(false);
42
42
  const wagmiConfig = (0, createWagmiConfig_1.createWagmiConfig)({ partnerId });
@@ -96,19 +96,18 @@ function useAuthentication(partnerId) {
96
96
  (0, react_2.useEffect)(() => {
97
97
  syncWagmi();
98
98
  }, [wallets, syncWagmi]);
99
- /**
100
- * Authenticate user using Turnkey
101
- * Note: This no longer requires a wallet for authentication.
102
- * Wallets are still used for signing transactions, but authentication is done via Turnkey email OTP.
103
- *
104
- * For backward compatibility, this function still accepts a wallet parameter,
105
- * but it's not used for authentication anymore.
106
- */
107
- const authenticateUser = (0, react_2.useCallback)(async () => {
99
+ const authenticateUser = (0, react_2.useCallback)(async (wallet) => {
108
100
  setHasStartedConnecting(true);
101
+ if (!wallet) {
102
+ throw new Error("No wallet found during auto-connect");
103
+ }
104
+ const account = wallet ? wallet.getAccount() : activeWallet?.getAccount();
105
+ if (!account) {
106
+ throw new Error("No account found during auto-connect");
107
+ }
109
108
  // Try to re-authenticate first
110
109
  try {
111
- const userAuth = await reAuthenticate();
110
+ const userAuth = await app_1.default.reAuthenticate();
112
111
  setUser(userAuth.user);
113
112
  setIsAuthenticated(true);
114
113
  setIsAuthenticating(false);
@@ -119,50 +118,67 @@ function useAuthentication(partnerId) {
119
118
  return userAuth;
120
119
  }
121
120
  catch (error) {
122
- // If re-authentication fails, user needs to authenticate via Turnkey
123
- // This should be handled by the Turnkey auth modal/flow
124
- debug("Re-authentication failed. User needs to authenticate via Turnkey.", error);
125
- setIsAuthenticated(false);
121
+ // If re-authentication fails, try fresh authentication
122
+ debug("Re-authentication failed, attempting fresh authentication");
123
+ const userAuth = await authenticate(wallet, partnerId);
124
+ setUser(userAuth.user);
125
+ setIsAuthenticated(true);
126
126
  setIsAuthenticating(false);
127
- throw new Error("Authentication required. Please authenticate via Turnkey.");
127
+ debug("Fresh authentication successful", { userAuth });
128
+ // Authenticate on BSMNT with B3 JWT
129
+ const b3Jwt = await (0, bsmnt_1.authenticateWithB3JWT)(userAuth.accessToken);
130
+ debug("@@b3Jwt", b3Jwt);
131
+ return userAuth;
128
132
  }
129
- }, [reAuthenticate, setIsAuthenticated, setIsAuthenticating, setUser, setHasStartedConnecting]);
130
- /**
131
- * Handle wallet connection
132
- * Note: With Turnkey migration, wallet connection is primarily for signing transactions,
133
- * not for authentication. Authentication should be done separately via Turnkey email OTP.
134
- */
133
+ }, [activeWallet, partnerId, authenticate, setIsAuthenticated, setIsAuthenticating, setUser, setHasStartedConnecting]);
134
+ const logout = (0, react_2.useCallback)(async (callback) => {
135
+ if (activeWallet) {
136
+ debug("@@logout:activeWallet", activeWallet);
137
+ disconnect(activeWallet);
138
+ debug("@@logout:activeWallet", activeWallet);
139
+ }
140
+ // Log out of each wallet
141
+ wallets.forEach(wallet => {
142
+ console.log("@@logging out", wallet);
143
+ disconnect(wallet);
144
+ });
145
+ // Delete localStorage thirdweb:connected-wallet-ids
146
+ // https://npc-labs.slack.com/archives/C070E6HNG85/p1750185115273099
147
+ if (typeof localStorage !== "undefined") {
148
+ localStorage.removeItem("thirdweb:connected-wallet-ids");
149
+ localStorage.removeItem("wagmi.store");
150
+ localStorage.removeItem("lastAuthProvider");
151
+ localStorage.removeItem("b3-user");
152
+ }
153
+ app_1.default.logout();
154
+ debug("@@logout:loggedOut");
155
+ setIsAuthenticated(false);
156
+ setIsConnected(false);
157
+ setUser();
158
+ callback?.();
159
+ }, [activeWallet, disconnect, wallets, setIsAuthenticated, setUser, setIsConnected]);
135
160
  const onConnect = (0, react_2.useCallback)(async (_walleAutoConnectedWith, allConnectedWallets) => {
136
161
  debug("@@useAuthentication:onConnect", { _walleAutoConnectedWith, allConnectedWallets });
137
- const wallet = allConnectedWallets.find(wallet => wallet.id.startsWith("ecosystem."));
138
- if (!wallet) {
139
- throw new Error("No smart wallet found during auto-connect");
140
- }
141
- debug("@@useAuthentication:onConnect", { wallet });
142
162
  try {
163
+ const wallet = allConnectedWallets.find(wallet => wallet.id.startsWith("ecosystem."));
164
+ if (!wallet) {
165
+ throw new Error("No smart wallet found during auto-connect");
166
+ }
167
+ debug("@@useAuthentication:onConnect", { wallet });
143
168
  setHasStartedConnecting(true);
144
169
  setIsConnected(true);
145
170
  setIsAuthenticating(true);
146
171
  await setActiveWallet(wallet);
147
- // Try to authenticate user (will use re-authenticate if session exists)
148
- // If no session exists, authentication will need to happen via Turnkey flow
149
- try {
150
- const userAuth = await authenticateUser();
151
- if (userAuth && onConnectCallback) {
152
- await onConnectCallback(wallet, userAuth.accessToken);
153
- }
154
- }
155
- catch (authError) {
156
- // Authentication failed - this is expected if user hasn't authenticated via Turnkey yet
157
- // The Turnkey auth modal should handle this
158
- debug("@@useAuthentication:onConnect:authFailed", { authError });
159
- // Don't set isAuthenticated to false here - let the Turnkey flow handle it
172
+ const userAuth = await authenticateUser(wallet);
173
+ if (userAuth && onConnectCallback) {
174
+ await onConnectCallback(wallet, userAuth.accessToken);
160
175
  }
161
176
  }
162
177
  catch (error) {
163
178
  debug("@@useAuthentication:onConnect:failed", { error });
164
179
  setIsAuthenticated(false);
165
180
  setUser(undefined);
181
+ await logout();
166
182
  }
167
183
  finally {
168
184
  setIsAuthenticating(false);
@@ -173,44 +189,19 @@ function useAuthentication(partnerId) {
173
189
  isConnected,
174
190
  });
175
191
  }, [
176
- onConnectCallback,
177
- authenticateUser,
178
192
  isAuthenticated,
179
193
  isAuthenticating,
180
194
  isConnected,
181
- setActiveWallet,
182
195
  setHasStartedConnecting,
183
- setIsAuthenticated,
184
- setIsAuthenticating,
185
196
  setIsConnected,
197
+ setIsAuthenticating,
198
+ setActiveWallet,
199
+ authenticateUser,
200
+ onConnectCallback,
201
+ setIsAuthenticated,
186
202
  setUser,
203
+ logout,
187
204
  ]);
188
- const logout = (0, react_2.useCallback)(async (callback) => {
189
- if (activeWallet) {
190
- debug("@@logout:activeWallet", activeWallet);
191
- disconnect(activeWallet);
192
- debug("@@logout:activeWallet", activeWallet);
193
- }
194
- // Log out of each wallet
195
- wallets.forEach(wallet => {
196
- console.log("@@logging out", wallet);
197
- disconnect(wallet);
198
- });
199
- // Delete localStorage thirdweb:connected-wallet-ids
200
- // https://npc-labs.slack.com/archives/C070E6HNG85/p1750185115273099
201
- if (typeof localStorage !== "undefined") {
202
- localStorage.removeItem("thirdweb:connected-wallet-ids");
203
- localStorage.removeItem("wagmi.store");
204
- localStorage.removeItem("lastAuthProvider");
205
- localStorage.removeItem("b3-user");
206
- }
207
- app_1.default.logout();
208
- debug("@@logout:loggedOut");
209
- setIsAuthenticated(false);
210
- setIsConnected(false);
211
- setUser();
212
- callback?.();
213
- }, [activeWallet, disconnect, wallets, setIsAuthenticated, setUser, setIsConnected]);
214
205
  const { isLoading: useAutoConnectLoading } = (0, react_3.useAutoConnect)({
215
206
  client: thirdweb_1.client,
216
207
  wallets: [wallet],
@@ -1,7 +1,4 @@
1
1
  import { Wallet } from "thirdweb/wallets";
2
- /**
3
- * @deprecated Use useAuth() with Turnkey authentication instead
4
- */
5
2
  export declare function useTWAuth(): {
6
3
  authenticate: (wallet: Wallet, partnerId: string) => Promise<import("@feathersjs/authentication").AuthenticationResult>;
7
4
  };
@@ -4,19 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.useTWAuth = useTWAuth;
7
- /**
8
- * @deprecated This hook is deprecated. Use useAuth() with Turnkey authentication instead.
9
- * This file is kept for backward compatibility but should not be used in new code.
10
- */
11
7
  const app_1 = __importDefault(require("../../../global-account/app"));
12
8
  const debug_1 = __importDefault(require("../../../shared/utils/debug"));
13
9
  const react_1 = require("react");
14
10
  const useSearchParamsSSR_1 = require("./useSearchParamsSSR");
15
- /**
16
- * @deprecated Use useAuth() with Turnkey authentication instead
17
- */
18
11
  function useTWAuth() {
19
- console.warn("useTWAuth is deprecated. Please migrate to useAuth() with Turnkey authentication. See useTurnkeyAuth.ts for the new implementation.");
20
12
  const referralCode = (0, useSearchParamsSSR_1.useSearchParam)("referralCode");
21
13
  const authenticate = (0, react_1.useCallback)(async (wallet, partnerId) => {
22
14
  if (!wallet || !wallet?.getAuthToken?.())
@@ -4,12 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.useTurnkeyAuth = useTurnkeyAuth;
7
- const debug_1 = require("../../../shared/utils/debug");
8
- const react_1 = require("react");
9
7
  const app_1 = __importDefault(require("../../app"));
10
- const useB3_1 = require("../components/B3Provider/useB3");
11
8
  const stores_1 = require("../stores");
12
- const useAuth_1 = require("./useAuth");
9
+ const react_1 = require("react");
10
+ const useB3_1 = require("../components/B3Provider/useB3");
11
+ const debug_1 = require("../../../shared/utils/debug");
13
12
  const debug = (0, debug_1.debugB3React)("useTurnkeyAuth");
14
13
  /**
15
14
  * Hook for Turnkey email-based OTP authentication
@@ -24,55 +23,29 @@ function useTurnkeyAuth() {
24
23
  const [error, setError] = (0, react_1.useState)(null);
25
24
  const setIsAuthenticating = (0, stores_1.useAuthStore)(state => state.setIsAuthenticating);
26
25
  const setIsAuthenticated = (0, stores_1.useAuthStore)(state => state.setIsAuthenticated);
27
- const { partnerId } = (0, useB3_1.useB3)();
28
- const { authenticate } = (0, useAuth_1.useAuth)();
26
+ const { user } = (0, useB3_1.useB3)();
29
27
  /**
30
28
  * Step 1: Initiate login with email
31
- * - Calls backend turnkey-jwt strategy (init action) to create sub-org (if needed) and send OTP
29
+ * - Calls backend to create sub-org (if needed) and send OTP
32
30
  * - Returns otpId to use in verification step
33
- *
34
- * Note: Uses the turnkey-jwt authentication strategy, not the service directly.
35
- * The turnkey-jwt strategy handles both OTP flow (init/verify) and final authentication.
36
31
  */
37
32
  const initiateLogin = (0, react_1.useCallback)(async (email) => {
38
33
  setIsLoading(true);
39
34
  setError(null);
40
35
  setIsAuthenticating(true);
41
36
  try {
37
+ if (!user?.userId) {
38
+ throw new Error("User ID is required to initiate Turnkey login.");
39
+ }
42
40
  debug(`Initiating login for: ${email}`);
43
- // Use authentication service with turnkey-jwt strategy (init action)
44
- // userId is resolved from authentication context on the backend (params.user.userId)
45
- // Backend will get userId from _params.user?.userId if authenticated, or handle unauthenticated case
46
- // So we only need to send email
47
- debug(`Calling app.authenticate with turnkey-jwt strategy (init action)`, { email });
48
- const response = await app_1.default.authenticate({
49
- strategy: "turnkey-jwt",
50
- action: "init",
51
- email,
52
- });
53
- // The strategy returns the TurnkeyAuthInitResponse directly
54
- const data = response;
41
+ // Call FeathersJS service to initialize OTP
42
+ const data = await app_1.default.service("turnkey-auth").init({ email, userId: user.userId });
55
43
  debug(`OTP initialized successfully. OtpId: ${data.otpId}`);
56
44
  return data;
57
45
  }
58
46
  catch (err) {
59
47
  debug("Error initiating login:", err);
60
- // Provide more detailed error information
61
- let errorMessage = "Failed to send OTP email. Please try again.";
62
- if (err.message) {
63
- errorMessage = err.message;
64
- }
65
- else if (err.name === "TypeError" && err.message?.includes("fetch")) {
66
- errorMessage = "Network error: Unable to reach the server. Please check your connection and try again.";
67
- }
68
- else if (err.code === "ECONNREFUSED" || err.code === "ENOTFOUND") {
69
- errorMessage = "Connection error: Unable to reach the server. Please check your internet connection.";
70
- }
71
- else if (err.response) {
72
- // FeathersJS error response
73
- errorMessage = err.response.message || err.message || errorMessage;
74
- debug("FeathersJS error response:", err.response);
75
- }
48
+ const errorMessage = err.message || "Failed to send OTP email. Please try again.";
76
49
  setError(errorMessage);
77
50
  throw err;
78
51
  }
@@ -80,11 +53,11 @@ function useTurnkeyAuth() {
80
53
  setIsLoading(false);
81
54
  setIsAuthenticating(false);
82
55
  }
83
- }, [setIsAuthenticating]);
56
+ }, [user, setIsAuthenticating]);
84
57
  /**
85
58
  * Step 2: Verify OTP and authenticate
86
- * - Verifies OTP with backend via turnkey-jwt strategy (verify action)
87
- * - Gets Turnkey session JWT from the verify response
59
+ * - Verifies OTP with backend
60
+ * - Gets Turnkey session JWT
88
61
  * - Authenticates with b3-api using "turnkey-jwt" strategy
89
62
  * - JWT automatically stored in cookies by SDK
90
63
  */
@@ -93,22 +66,19 @@ function useTurnkeyAuth() {
93
66
  setError(null);
94
67
  setIsAuthenticating(true);
95
68
  try {
96
- debug(`Verifying OTP...`, { otpId });
97
- // Step 1: Verify OTP with backend using turnkey-jwt strategy (verify action)
98
- // This returns the Turnkey session JWT
99
- const response = await app_1.default.authenticate({
100
- strategy: "turnkey-jwt",
101
- action: "verify",
69
+ debug(`Verifying OTP...`, { userId: user?.userId });
70
+ // Step 1: Verify OTP and get Turnkey session JWT
71
+ const { turnkeySessionJwt } = await app_1.default.service("turnkey-auth").verify({
102
72
  otpId,
103
73
  otpCode,
104
74
  });
105
- // The strategy returns the TurnkeyAuthVerifyResponse directly
106
- const verifyResult = response;
107
- const { turnkeySessionJwt } = verifyResult;
108
- debug(`OTP verified! Got Turnkey session JWT. Authenticating with b3-api...`);
75
+ debug(`OTP verified! Authenticating with b3-api...`);
109
76
  // Step 2: Authenticate with b3-api using Turnkey JWT
110
- // Use the unified useAuth hook for authentication with "turnkey-jwt" strategy
111
- const authResult = await authenticate(turnkeySessionJwt, partnerId || "");
77
+ // The SDK will automatically store the b3-api JWT in cookies
78
+ const authResult = await app_1.default.authenticate({
79
+ strategy: "turnkey-jwt",
80
+ accessToken: turnkeySessionJwt,
81
+ });
112
82
  debug(`Successfully authenticated with b3-api!`, authResult);
113
83
  // Update auth store to reflect authenticated state
114
84
  setIsAuthenticated(true);
@@ -128,7 +98,7 @@ function useTurnkeyAuth() {
128
98
  setIsLoading(false);
129
99
  setIsAuthenticating(false);
130
100
  }
131
- }, [partnerId, setIsAuthenticating, setIsAuthenticated, authenticate]);
101
+ }, [user, setIsAuthenticating, setIsAuthenticated]);
132
102
  const clearError = (0, react_1.useCallback)(() => {
133
103
  setError(null);
134
104
  }, []);
@@ -36,8 +36,8 @@ export declare function useUserQuery(): {
36
36
  name?: string | undefined;
37
37
  address?: string | undefined;
38
38
  email?: string | undefined;
39
- phone?: string | undefined;
40
39
  username?: string | undefined;
40
+ phone?: string | undefined;
41
41
  fid?: string | undefined;
42
42
  };
43
43
  }[] | undefined;
@@ -15,7 +15,6 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
15
15
  import { parseUnits } from "viem";
16
16
  import { base, mainnet } from "viem/chains";
17
17
  import { useAutoSelectCryptoPaymentMethod } from "../hooks/useAutoSelectCryptoPaymentMethod.js";
18
- import { useAutoSetActiveWalletFromWagmi } from "../hooks/useAutoSetActiveWalletFromWagmi.js";
19
18
  import { useConnectedWalletDisplay } from "../hooks/useConnectedWalletDisplay.js";
20
19
  import { useCryptoPaymentMethodState } from "../hooks/useCryptoPaymentMethodState.js";
21
20
  import { useRecipientAddressState } from "../hooks/useRecipientAddressState.js";
@@ -313,8 +312,6 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
313
312
  // );
314
313
  const { address: globalAddress, wallet: globalWallet, connectedEOAWallet } = useAccountWallet();
315
314
  const globalWalletImage = useAccountWalletImage();
316
- // Auto-set active wallet from wagmi
317
- useAutoSetActiveWalletFromWagmi();
318
315
  // Get wallet address based on selected payment method
319
316
  const { walletAddress } = useConnectedWalletDisplay(effectiveCryptoPaymentMethod);
320
317
  // Recipient address state with dual-state system (auto + explicit user selection)
@@ -31,7 +31,7 @@ import { useMemo } from "react";
31
31
  import { encodeFunctionData } from "viem";
32
32
  import { AnySpendCustom } from "./AnySpendCustom.js";
33
33
  // Collector Club Shop contract on Base
34
- const CC_SHOP_ADDRESS = "0x23887D10c81118A9a2E3Af59C423e2f4ee4Cc7Cf";
34
+ const CC_SHOP_ADDRESS = "0x47366E64E4917dd4DdC04Fb9DC507c1dD2b87294";
35
35
  const BASE_CHAIN_ID = 8453;
36
36
  // ABI for buyPacksFor function only
37
37
  const BUY_PACKS_FOR_ABI = {
@@ -13,7 +13,6 @@ import { ChevronRight, ChevronRightCircle, Info, Loader2 } from "lucide-react";
13
13
  import { motion } from "motion/react";
14
14
  import React, { useCallback, useEffect, useMemo, useState } from "react";
15
15
  import { base } from "viem/chains";
16
- import { useAutoSetActiveWalletFromWagmi } from "../hooks/useAutoSetActiveWalletFromWagmi.js";
17
16
  import { useCryptoPaymentMethodState } from "../hooks/useCryptoPaymentMethodState.js";
18
17
  import { useRecipientAddressState } from "../hooks/useRecipientAddressState.js";
19
18
  import { AnySpendFingerprintWrapper, getFingerprintConfig } from "./AnySpendFingerprintWrapper.js";
@@ -111,8 +110,6 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
111
110
  const hasMounted = useHasMounted();
112
111
  const searchParams = useSearchParamsSSR();
113
112
  const router = useRouter();
114
- // Auto-set active wallet from wagmi
115
- useAutoSetActiveWalletFromWagmi();
116
113
  const [activePanel, setActivePanel] = useState(loadOrder ? PanelView.ORDER_DETAILS : PanelView.CONFIRM_ORDER);
117
114
  const [activeTab, setActiveTab] = useState(activeTabProps);
118
115
  // Payment method state with dual-state system (auto + explicit user selection)