@b3dotfun/sdk 0.1.68-alpha.10 → 0.1.68-alpha.12

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 (39) hide show
  1. package/dist/cjs/anyspend/react/components/AnySpend.js +4 -4
  2. package/dist/cjs/anyspend/react/components/AnySpendCustom.js +4 -4
  3. package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +2 -2
  4. package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +1 -1
  5. package/dist/cjs/anyspend/react/components/common/FeeDetailPanel.js +1 -1
  6. package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.js +2 -2
  7. package/dist/cjs/anyspend/react/components/common/OrderDetails.js +1 -1
  8. package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.js +1 -1
  9. package/dist/cjs/anyspend/react/components/common/RecipientSelection.js +1 -1
  10. package/dist/cjs/global-account/react/components/ManageAccount/HomeActions.js +1 -1
  11. package/dist/cjs/global-account/react/components/ManageAccount/channels/TelegramChannel.js +1 -1
  12. package/dist/cjs/global-account/react/hooks/useAuthentication.js +30 -18
  13. package/dist/esm/anyspend/react/components/AnySpend.js +4 -4
  14. package/dist/esm/anyspend/react/components/AnySpendCustom.js +4 -4
  15. package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +2 -2
  16. package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +1 -1
  17. package/dist/esm/anyspend/react/components/common/FeeDetailPanel.js +1 -1
  18. package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.js +2 -2
  19. package/dist/esm/anyspend/react/components/common/OrderDetails.js +1 -1
  20. package/dist/esm/anyspend/react/components/common/PointsDetailPanel.js +1 -1
  21. package/dist/esm/anyspend/react/components/common/RecipientSelection.js +1 -1
  22. package/dist/esm/global-account/react/components/ManageAccount/HomeActions.js +1 -1
  23. package/dist/esm/global-account/react/components/ManageAccount/channels/TelegramChannel.js +1 -1
  24. package/dist/esm/global-account/react/hooks/useAuthentication.js +30 -18
  25. package/dist/styles/index.css +1 -1
  26. package/package.json +1 -1
  27. package/src/anyspend/react/components/AnySpend.tsx +4 -4
  28. package/src/anyspend/react/components/AnySpendCustom.tsx +4 -4
  29. package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +2 -2
  30. package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +1 -1
  31. package/src/anyspend/react/components/common/FeeDetailPanel.tsx +1 -1
  32. package/src/anyspend/react/components/common/FiatPaymentMethod.tsx +2 -2
  33. package/src/anyspend/react/components/common/OrderDetails.tsx +1 -1
  34. package/src/anyspend/react/components/common/PointsDetailPanel.tsx +1 -1
  35. package/src/anyspend/react/components/common/RecipientSelection.tsx +1 -1
  36. package/src/global-account/react/components/ManageAccount/HomeActions.tsx +2 -2
  37. package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +7 -7
  38. package/src/global-account/react/components/ManageAccount/channels/TelegramChannel.tsx +1 -1
  39. package/src/global-account/react/hooks/useAuthentication.ts +30 -18
@@ -4,7 +4,7 @@ import { BankIcon } from "../../../../global-account/react/components/icons/Bank
4
4
  import { SwapIcon } from "../../../../global-account/react/components/icons/SwapIcon.js";
5
5
  import { cn } from "../../../../shared/utils/index.js";
6
6
  const SendIcon = () => (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: _jsx("path", { d: "M17.9958 1.21467C17.666 1.10449 17.359 1.18417 17.2063 1.22851C17.04 1.27683 16.8417 1.35425 16.6428 1.43191L2.51187 6.94641C2.28951 7.03315 2.07413 7.11717 1.9079 7.19936C1.76427 7.27038 1.45899 7.42845 1.28859 7.75646C1.10067 8.11818 1.10092 8.54881 1.28927 8.9103C1.46006 9.23811 1.76552 9.39582 1.90924 9.46667C2.07556 9.54867 2.29099 9.63241 2.51345 9.71889L6.4468 11.2485C6.74023 11.3626 6.88695 11.4197 7.03291 11.4232C7.16193 11.4263 7.2899 11.3994 7.40674 11.3446C7.53893 11.2826 7.65024 11.1713 7.87287 10.9487L11.9107 6.91083C12.2361 6.58539 12.7638 6.58539 13.0892 6.91083C13.4147 7.23626 13.4147 7.7639 13.0892 8.08934L9.05138 12.1272C8.82875 12.3498 8.71744 12.4611 8.65545 12.5933C8.60065 12.7101 8.57374 12.8381 8.57684 12.9671C8.58035 13.1131 8.6374 13.2598 8.75152 13.5532L10.2811 17.4865C10.3676 17.709 10.4514 17.9245 10.5334 18.0908C10.6042 18.2345 10.7619 18.54 11.0897 18.7108C11.4512 18.8991 11.8819 18.8994 12.2436 18.7115C12.5716 18.541 12.7297 18.2358 12.8007 18.0921C12.8829 17.9259 12.9669 17.7106 13.0536 17.4882L18.5681 3.35726C18.6458 3.15833 18.7232 2.96007 18.7715 2.79371C18.8159 2.64105 18.8955 2.334 18.7854 2.00419C18.6609 1.63157 18.3685 1.33915 17.9958 1.21467Z", fill: "#0C68E9" }) }));
7
- const BuyIcon = () => (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: [_jsx("path", { d: "M9.99998 8.75C9.30962 8.75 8.74998 9.30964 8.74998 10C8.74998 10.6904 9.30962 11.25 9.99998 11.25C10.6903 11.25 11.25 10.6904 11.25 10C11.25 9.30964 10.6903 8.75 9.99998 8.75Z", fill: "#0C68E9" }), _jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M14.1666 2.5C12.3642 2.5 10.8013 2.95205 9.44241 3.37018L9.18862 3.44844C7.90485 3.84476 6.86213 4.16667 5.83332 4.16667C5.09512 4.16667 4.43564 4.08819 3.88041 3.98151L3.85421 3.97647C3.44746 3.89831 3.10585 3.83267 2.84038 3.79758C2.60748 3.76679 2.26236 3.7302 1.94675 3.84126C1.78134 3.89947 1.60242 3.98249 1.43327 4.12224C1.26411 4.26199 1.14882 4.42202 1.06045 4.57348C0.898119 4.85168 0.864329 5.167 0.849347 5.3925C0.833297 5.63407 0.833306 5.94132 0.833317 6.29588L0.833315 15.2922C0.833263 15.4565 0.833201 15.6516 0.932434 15.9263C0.981719 16.0628 1.06288 16.1945 1.10974 16.2664C1.15659 16.3383 1.24436 16.4657 1.34932 16.5659C1.41718 16.6306 1.49456 16.6992 1.58722 16.76C1.67809 16.8196 1.76087 16.8559 1.79699 16.8717L1.80356 16.8746C2.48669 17.1759 3.71203 17.5 5.83332 17.5C7.63579 17.5 9.19862 17.0479 10.5576 16.6298L10.8113 16.5516C12.0951 16.1552 13.1378 15.8333 14.1666 15.8333C14.9048 15.8333 15.5643 15.9118 16.1196 16.0185L16.1458 16.0235C16.5525 16.1017 16.8941 16.1673 17.1596 16.2024C17.3925 16.2332 17.7376 16.2698 18.0532 16.1587C18.2186 16.1005 18.3975 16.0175 18.5667 15.8778C18.7359 15.738 18.8511 15.578 18.9395 15.4265C19.1018 15.1483 19.1356 14.833 19.1506 14.6075C19.1667 14.3659 19.1667 14.0587 19.1666 13.7041L19.1667 4.70776C19.1667 4.54347 19.1668 4.34839 19.0675 4.07365C19.0182 3.9372 18.9371 3.80547 18.8902 3.73359C18.8434 3.6617 18.7556 3.53428 18.6507 3.43412C18.5828 3.36935 18.5054 3.30084 18.4127 3.24003C18.3219 3.1804 18.2391 3.14413 18.203 3.1283L18.1964 3.12542C17.5133 2.82409 16.2879 2.5 14.1666 2.5ZM15.8333 7.5C15.8333 7.03976 15.4602 6.66667 15 6.66667C14.5397 6.66667 14.1666 7.03976 14.1666 7.5V10.8333C14.1666 11.2936 14.5397 11.6667 15 11.6667C15.4602 11.6667 15.8333 11.2936 15.8333 10.8333V7.5ZM7.08331 10C7.08331 8.38917 8.38915 7.08333 9.99998 7.08333C11.6108 7.08333 12.9166 8.38917 12.9166 10C12.9166 11.6108 11.6108 12.9167 9.99998 12.9167C8.38915 12.9167 7.08331 11.6108 7.08331 10ZM4.99998 8.33333C5.46022 8.33333 5.83331 8.70643 5.83331 9.16667V12.5C5.83331 12.9602 5.46022 13.3333 4.99998 13.3333C4.53974 13.3333 4.16665 12.9602 4.16665 12.5V9.16667C4.16665 8.70643 4.53974 8.33333 4.99998 8.33333Z", fill: "#0C68E9" })] }));
7
+ const BuyIcon = () => (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: [_jsx("path", { d: "M9.99998 8.75C9.30962 8.75 8.74998 9.30964 8.74998 10C8.74998 10.6904 9.30962 11.25 9.99998 11.25C10.6903 11.25 11.25 10.6904 11.25 10C11.25 9.30964 10.6903 8.75 9.99998 8.75Z", fill: "#0C68E9" }), _jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M14.1666 2.5C12.3642 2.5 10.8013 2.95205 9.44241 3.37018L9.18862 3.44844C7.90485 3.84476 6.86213 4.16667 5.83332 4.16667C5.09512 4.16667 4.43564 4.08819 3.88041 3.98151L3.85421 3.97647C3.44746 3.89831 3.10585 3.83267 2.84038 3.79758C2.60748 3.76679 2.26236 3.7302 1.94675 3.84126C1.78134 3.89947 1.60242 3.98249 1.43327 4.12224C1.26411 4.26199 1.14882 4.42202 1.06045 4.57348C0.898119 4.85168 0.864329 5.167 0.849347 5.3925C0.833297 5.63407 0.833306 5.94132 0.833317 6.29588L0.833315 15.2922C0.833263 15.4565 0.833201 15.6516 0.932434 15.9263C0.981719 16.0628 1.06288 16.1945 1.10974 16.2664C1.15659 16.3383 1.24436 16.4657 1.34932 16.5659C1.41718 16.6306 1.49456 16.6992 1.58722 16.76C1.67809 16.8196 1.76087 16.8559 1.79699 16.8717L1.80356 16.8746C2.48669 17.1759 3.71203 17.5 5.83332 17.5C7.63579 17.5 9.19862 17.0479 10.5576 16.6298L10.8113 16.5516C12.0951 16.1552 13.1378 15.8333 14.1666 15.8333C14.9048 15.8333 15.5643 15.9118 16.1196 16.0185L16.1458 16.0235C16.5525 16.1017 16.8941 16.1673 17.1596 16.2024C17.3925 16.2332 17.7376 16.2698 18.0532 16.1587C18.2186 16.1005 18.3975 16.0175 18.5667 15.8778C18.7359 15.738 18.8511 15.578 18.9395 15.4265C19.1018 15.1483 19.1356 14.833 19.1506 14.6075C19.1667 14.3659 19.1667 14.0587 19.1666 13.7041L19.1667 4.70776C19.1667 4.54347 19.1668 4.34839 19.0675 4.07365C19.0182 3.9372 18.9371 3.80547 18.8902 3.73359C18.8434 3.6617 18.7556 3.53428 18.6507 3.43412C18.5828 3.36935 18.5054 3.30084 18.4127 3.24003C18.3219 3.1804 18.2391 3.14413 18.203 3.1283L18.1964 3.12542C17.5133 2.82409 16.2879 2.5 14.1666 2.5ZM15.8333 7.5C15.8333 7.03976 15.4602 6.66667 15 6.66667C14.5397 6.66667 14.1666 7.03976 14.1666 7.5V10.8333C14.1666 11.2936 14.5397 11.6667 15 11.6667C15.4602 11.6667 15.8333 11.2936 15.8333 10.8333V7.5ZM7.08331 10C7.08331 8.38917 8.38915 7.08333 9.99998 7.08333C11.6108 7.08333 12.9166 8.38917 12.9166 10C12.9166 11.6108 11.6108 12.9167 9.99998 12.9167C8.38915 12.9167 7.08331 11.6108 7.08331 10ZM4.99998 8.33333C5.46022 8.33333 5.83331 8.70643 5.83331 9.16667V12.5C5.83331 12.9602 5.46022 13.3333 4.99998 13.3333C4.53974 13.3333 4.16665 12.9602 4.16665 12.5V9.16667C4.16665 8.70643 4.53974 8.33333 4.99998 8.33333Z", fill: "#0C68E9" })] }));
8
8
  const HomeActionButton = ({ customClass, icon, label, onClick, }) => {
9
9
  return (_jsxs(Button, { className: cn("border-b3-line hover:border-b3-primary-blue flex h-[84px] w-full flex-col items-center justify-center gap-2 rounded-2xl border-[1.5px] bg-[#FAFAFA] shadow-[0_0_0_1px_rgba(10,13,18,0.18)_inset,0_-2px_0_0_rgba(10,13,18,0.05)_inset,0_1px_2px_0_rgba(10,13,18,0.05)] hover:bg-[#FAFAFA]", customClass), onClick: onClick, children: [icon, _jsx("div", { className: "text-b3-grey font-neue-montreal-semibold", children: label })] }));
10
10
  };
@@ -69,7 +69,7 @@ export const TelegramChannel = ({ userId, jwtToken, telegramChannel, isConnected
69
69
  handleConnect();
70
70
  }
71
71
  };
72
- const icon = (_jsx("svg", { width: "1000px", height: "1000px", viewBox: "0 0 1000 1000", version: "1.1", xmlns: "http://www.w3.org/2000/svg", children: _jsx("g", { id: "Telegram", stroke: "none", "stroke-width": "1", fill: "none", "fill-rule": "evenodd", children: _jsx("path", { d: "M226.328419,494.722069 C372.088573,431.216685 469.284839,389.350049 517.917216,369.122161 C656.772535,311.36743 685.625481,301.334815 704.431427,301.003532 C708.567621,300.93067 717.815839,301.955743 723.806446,306.816707 C728.864797,310.92121 730.256552,316.46581 730.922551,320.357329 C731.588551,324.248848 732.417879,333.113828 731.758626,340.040666 C724.234007,419.102486 691.675104,610.964674 675.110982,699.515267 C668.10208,736.984342 654.301336,749.547532 640.940618,750.777006 C611.904684,753.448938 589.856115,731.588035 561.733393,713.153237 C517.726886,684.306416 492.866009,666.349181 450.150074,638.200013 C400.78442,605.66878 432.786119,587.789048 460.919462,558.568563 C468.282091,550.921423 596.21508,434.556479 598.691227,424.000355 C599.00091,422.680135 599.288312,417.758981 596.36474,415.160431 C593.441168,412.561881 589.126229,413.450484 586.012448,414.157198 C581.598758,415.158943 511.297793,461.625274 375.109553,553.556189 C355.154858,567.258623 337.080515,573.934908 320.886524,573.585046 C303.033948,573.199351 268.692754,563.490928 243.163606,555.192408 C211.851067,545.013936 186.964484,539.632504 189.131547,522.346309 C190.260287,513.342589 202.659244,504.134509 226.328419,494.722069 Z", id: "Path-3", fill: "#FFFFFF" }) }) }));
72
+ const icon = (_jsx("svg", { width: "1000px", height: "1000px", viewBox: "0 0 1000 1000", version: "1.1", xmlns: "http://www.w3.org/2000/svg", children: _jsx("g", { id: "Telegram", stroke: "none", strokeWidth: "1", fill: "none", fillRule: "evenodd", children: _jsx("path", { d: "M226.328419,494.722069 C372.088573,431.216685 469.284839,389.350049 517.917216,369.122161 C656.772535,311.36743 685.625481,301.334815 704.431427,301.003532 C708.567621,300.93067 717.815839,301.955743 723.806446,306.816707 C728.864797,310.92121 730.256552,316.46581 730.922551,320.357329 C731.588551,324.248848 732.417879,333.113828 731.758626,340.040666 C724.234007,419.102486 691.675104,610.964674 675.110982,699.515267 C668.10208,736.984342 654.301336,749.547532 640.940618,750.777006 C611.904684,753.448938 589.856115,731.588035 561.733393,713.153237 C517.726886,684.306416 492.866009,666.349181 450.150074,638.200013 C400.78442,605.66878 432.786119,587.789048 460.919462,558.568563 C468.282091,550.921423 596.21508,434.556479 598.691227,424.000355 C599.00091,422.680135 599.288312,417.758981 596.36474,415.160431 C593.441168,412.561881 589.126229,413.450484 586.012448,414.157198 C581.598758,415.158943 511.297793,461.625274 375.109553,553.556189 C355.154858,567.258623 337.080515,573.934908 320.886524,573.585046 C303.033948,573.199351 268.692754,563.490928 243.163606,555.192408 C211.851067,545.013936 186.964484,539.632504 189.131547,522.346309 C190.260287,513.342589 202.659244,504.134509 226.328419,494.722069 Z", id: "Path-3", fill: "#FFFFFF" }) }) }));
73
73
  const inputSection = status === "pending" ? (_jsxs("div", { className: "mt-1", children: [_jsx("p", { className: "font-['PP_Neue_Montreal','PP_Neue_Montreal_Fallback',sans-serif] text-[14px] leading-[20px] text-yellow-700 dark:text-white", children: "Waiting for connection..." }), _jsx("p", { className: "font-['PP_Neue_Montreal','PP_Neue_Montreal_Fallback',sans-serif] text-[12px] text-yellow-600 dark:text-white", children: "Send /start to @b3_notifications_bot" })] })) : (_jsxs("button", { onClick: handleConnect, disabled: isConnecting, className: "mt-1 flex items-center gap-1 disabled:opacity-50", children: [_jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", children: _jsx("path", { d: "M8 3.33333V12.6667M3.33333 8H12.6667", stroke: "#0c68e9", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }), _jsx("span", { className: "font-['Inter',sans-serif] text-[11px] font-semibold leading-[16px] text-[#0b57c2]", children: isConnecting ? "Opening..." : "Add Telegram" })] }));
74
74
  return (_jsx(NotificationChannel, { icon: icon, iconClassName: "bg-[#24A1DE] rounded-xl", title: "Telegram", isConnected: isOptimisticallyConnected || status === "connected", isConnecting: isConnecting, isDisconnecting: isDisconnecting, connectedInfo: telegramChannel?.channel_identifier || "Connected", inputSection: inputSection, onToggle: handleToggle }));
75
75
  };
@@ -141,8 +141,9 @@ export function useAuthentication(partnerId, { skipAutoConnect = false } = {}) {
141
141
  }
142
142
  }, [activeWallet, partnerId, authenticate, setIsAuthenticated, setIsAuthenticating, setUser, setHasStartedConnecting]);
143
143
  const logout = useCallback(async (callback) => {
144
- // Only disconnect ecosystem/smart wallets, preserve EOA wallets (e.g. MetaMask)
145
- // so they remain available after re-login.
144
+ // Disconnect ecosystem/smart wallets from the connected wallets list.
145
+ // EOA wallets (MetaMask, Coinbase Wallet) are left in the list so they can
146
+ // auto-reconnect on next login without requiring a new approval popup.
146
147
  // Use walletsRef.current (not the stale closure value) so we always get current wallets —
147
148
  // autoConnectCore captures logout from the first render when wallets is still [].
148
149
  walletsRef.current.forEach(wallet => {
@@ -151,18 +152,25 @@ export function useAuthentication(partnerId, { skipAutoConnect = false } = {}) {
151
152
  disconnect(wallet);
152
153
  }
153
154
  });
154
- // Always disconnect the active wallet to clear thirdweb's activeAccountStore.
155
- // Without this, any auto-reconnected wallet (e.g. Coinbase Wallet, MetaMask)
156
- // keeps activeAccount set, and ConnectEmbed renders show=false (blank modal).
155
+ // Unconditionally disconnect the active wallet to clear thirdweb's activeAccountStore.
156
+ // This is separate from the loop above: even if the active wallet is an EOA (e.g.
157
+ // Coinbase Wallet), we must disconnect it so activeAccount becomes undefined.
158
+ // Without this, ConnectEmbed renders show=false (blank modal) because it checks
159
+ // show = !activeAccount. Note: thirdweb's disconnect() is idempotent — calling it
160
+ // on an already-disconnected wallet (from the loop above) is a no-op.
157
161
  // We use the exact reference from activeWalletRef because thirdweb's
158
162
  // onWalletDisconnect uses strict identity (===) to decide whether to clear
159
163
  // activeAccountStore.
164
+ // Tradeoff: EOA wallets (MetaMask, Coinbase Wallet) will be removed from
165
+ // connectedWallets and require a new approval popup on next login.
166
+ // This is acceptable because a working login form is more critical than
167
+ // skipping one wallet approval step.
160
168
  if (activeWalletRef.current) {
161
169
  debug("@@logout:disconnecting active wallet", activeWalletRef.current.id);
162
170
  disconnect(activeWalletRef.current);
163
171
  }
164
- // Clear user-specific storage but preserve wallet connection state
165
- // so EOA wallets (e.g. MetaMask) can auto-reconnect on next login
172
+ // Clear user-specific storage (auth tokens, cached user data).
173
+ // Thirdweb's wallet connection state is managed separately via disconnect() above.
166
174
  if (typeof localStorage !== "undefined") {
167
175
  localStorage.removeItem("lastAuthProvider");
168
176
  localStorage.removeItem("b3-user");
@@ -186,19 +194,19 @@ export function useAuthentication(partnerId, { skipAutoConnect = false } = {}) {
186
194
  [disconnect, setIsAuthenticated, setIsAuthenticating, setUser, setIsConnected, onLogoutCallback]);
187
195
  const onConnect = useCallback(async (_walleAutoConnectedWith, allConnectedWallets) => {
188
196
  debug("@@useAuthentication:onConnect", { _walleAutoConnectedWith, allConnectedWallets });
189
- const ecosystemWalletToDisconnect = allConnectedWallets.find(w => w.id.startsWith("ecosystem."));
197
+ const connectedEcosystemWallet = allConnectedWallets.find(w => w.id.startsWith("ecosystem."));
190
198
  try {
191
- if (!ecosystemWalletToDisconnect) {
199
+ if (!connectedEcosystemWallet) {
192
200
  throw new Error("No smart wallet found during auto-connect");
193
201
  }
194
- debug("@@useAuthentication:onConnect", { wallet: ecosystemWalletToDisconnect });
202
+ debug("@@useAuthentication:onConnect", { wallet: connectedEcosystemWallet });
195
203
  setHasStartedConnecting(true);
196
204
  setIsConnected(true);
197
205
  setIsAuthenticating(true);
198
- await setActiveWallet(ecosystemWalletToDisconnect);
199
- const userAuth = await authenticateUser(ecosystemWalletToDisconnect);
206
+ await setActiveWallet(connectedEcosystemWallet);
207
+ const userAuth = await authenticateUser(connectedEcosystemWallet);
200
208
  if (userAuth && onConnectCallback) {
201
- await onConnectCallback(ecosystemWalletToDisconnect, userAuth.accessToken);
209
+ await onConnectCallback(connectedEcosystemWallet, userAuth.accessToken);
202
210
  }
203
211
  }
204
212
  catch (error) {
@@ -209,17 +217,21 @@ export function useAuthentication(partnerId, { skipAutoConnect = false } = {}) {
209
217
  // We can't rely on logout()'s activeWalletRef here because it's updated
210
218
  // via useEffect (deferred until after paint), but this callback may run
211
219
  // entirely within a single React commit cycle — before the ref updates.
212
- if (ecosystemWalletToDisconnect) {
213
- debug("@@useAuthentication:onConnect:disconnecting ecosystem wallet", ecosystemWalletToDisconnect.id);
214
- disconnect(ecosystemWalletToDisconnect);
220
+ // Note: logout() below may also call disconnect() on the same wallet via
221
+ // activeWalletRef — thirdweb's disconnect() is idempotent so this is safe.
222
+ if (connectedEcosystemWallet) {
223
+ debug("@@useAuthentication:onConnect:disconnecting ecosystem wallet", connectedEcosystemWallet.id);
224
+ disconnect(connectedEcosystemWallet);
215
225
  }
216
226
  // Also disconnect the wallet that autoConnectCore set as active.
217
227
  // When only a non-ecosystem wallet (e.g. MetaMask) auto-reconnects,
218
- // ecosystemWalletToDisconnect is undefined, so the block above is skipped.
228
+ // connectedEcosystemWallet is undefined, so the block above is skipped.
219
229
  // But autoConnectCore already set this wallet as thirdweb's activeWallet,
220
230
  // leaving activeAccount set. ConnectEmbed checks show = !activeAccount,
221
231
  // so if we don't clear it, the login form renders blank.
222
- if (_walleAutoConnectedWith && _walleAutoConnectedWith !== ecosystemWalletToDisconnect) {
232
+ // Uses object identity (===) which is safe because thirdweb returns
233
+ // stable references for connected wallet instances.
234
+ if (_walleAutoConnectedWith && _walleAutoConnectedWith !== connectedEcosystemWallet) {
223
235
  debug("@@useAuthentication:onConnect:disconnecting auto-connected wallet", _walleAutoConnectedWith.id);
224
236
  disconnect(_walleAutoConnectedWith);
225
237
  }