@b3dotfun/sdk 0.1.68 → 0.1.69-alpha.0

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 (263) hide show
  1. package/dist/cjs/anyspend/platform/client.d.ts +35 -0
  2. package/dist/cjs/anyspend/platform/client.js +158 -0
  3. package/dist/cjs/anyspend/platform/errors.d.ts +38 -0
  4. package/dist/cjs/anyspend/platform/errors.js +77 -0
  5. package/dist/cjs/anyspend/platform/index.d.ts +87 -0
  6. package/dist/cjs/anyspend/platform/index.js +85 -0
  7. package/dist/cjs/anyspend/platform/resources/analytics.d.ts +7 -0
  8. package/dist/cjs/anyspend/platform/resources/analytics.js +12 -0
  9. package/dist/cjs/anyspend/platform/resources/checkout-sessions.d.ts +17 -0
  10. package/dist/cjs/anyspend/platform/resources/checkout-sessions.js +27 -0
  11. package/dist/cjs/anyspend/platform/resources/customers.d.ts +19 -0
  12. package/dist/cjs/anyspend/platform/resources/customers.js +34 -0
  13. package/dist/cjs/anyspend/platform/resources/discount-codes.d.ts +29 -0
  14. package/dist/cjs/anyspend/platform/resources/discount-codes.js +31 -0
  15. package/dist/cjs/anyspend/platform/resources/events.d.ts +14 -0
  16. package/dist/cjs/anyspend/platform/resources/events.js +16 -0
  17. package/dist/cjs/anyspend/platform/resources/notifications.d.ts +18 -0
  18. package/dist/cjs/anyspend/platform/resources/notifications.js +27 -0
  19. package/dist/cjs/anyspend/platform/resources/organization.d.ts +17 -0
  20. package/dist/cjs/anyspend/platform/resources/organization.js +15 -0
  21. package/dist/cjs/anyspend/platform/resources/payment-links.d.ts +21 -0
  22. package/dist/cjs/anyspend/platform/resources/payment-links.js +49 -0
  23. package/dist/cjs/anyspend/platform/resources/products.d.ts +27 -0
  24. package/dist/cjs/anyspend/platform/resources/products.js +31 -0
  25. package/dist/cjs/anyspend/platform/resources/transactions.d.ts +11 -0
  26. package/dist/cjs/anyspend/platform/resources/transactions.js +25 -0
  27. package/dist/cjs/anyspend/platform/resources/webhooks.d.ts +14 -0
  28. package/dist/cjs/anyspend/platform/resources/webhooks.js +33 -0
  29. package/dist/cjs/anyspend/platform/resources/widgets.d.ts +38 -0
  30. package/dist/cjs/anyspend/platform/resources/widgets.js +31 -0
  31. package/dist/cjs/anyspend/platform/types.d.ts +478 -0
  32. package/dist/cjs/anyspend/platform/types.js +5 -0
  33. package/dist/cjs/anyspend/platform/utils/idempotency.d.ts +4 -0
  34. package/dist/cjs/anyspend/platform/utils/idempotency.js +17 -0
  35. package/dist/cjs/anyspend/platform/utils/pagination.d.ts +12 -0
  36. package/dist/cjs/anyspend/platform/utils/pagination.js +22 -0
  37. package/dist/cjs/anyspend/react/components/AnySpend.d.ts +5 -1
  38. package/dist/cjs/anyspend/react/components/AnySpend.js +127 -16
  39. package/dist/cjs/anyspend/react/components/AnySpendCustom.js +4 -4
  40. package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +2 -2
  41. package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.d.ts +14 -6
  42. package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.js +55 -8
  43. package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckoutTrigger.d.ts +3 -1
  44. package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckoutTrigger.js +2 -2
  45. package/dist/cjs/anyspend/react/components/checkout/CheckoutPaymentPanel.d.ts +5 -1
  46. package/dist/cjs/anyspend/react/components/checkout/CheckoutPaymentPanel.js +2 -2
  47. package/dist/cjs/anyspend/react/components/checkout/CryptoPayPanel.js +1 -1
  48. package/dist/cjs/anyspend/react/components/checkout/FiatCheckoutPanel.d.ts +5 -1
  49. package/dist/cjs/anyspend/react/components/checkout/FiatCheckoutPanel.js +48 -16
  50. package/dist/cjs/anyspend/react/components/checkout/KycGate.d.ts +11 -0
  51. package/dist/cjs/anyspend/react/components/checkout/KycGate.js +203 -0
  52. package/dist/cjs/anyspend/react/components/checkout/VariablePricingInput.d.ts +17 -0
  53. package/dist/cjs/anyspend/react/components/checkout/VariablePricingInput.js +145 -0
  54. package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +1 -1
  55. package/dist/cjs/anyspend/react/components/common/FeeDetailPanel.js +1 -1
  56. package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.js +2 -2
  57. package/dist/cjs/anyspend/react/components/common/OrderDetails.js +1 -1
  58. package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.js +1 -1
  59. package/dist/cjs/anyspend/react/components/common/RecipientSelection.js +1 -1
  60. package/dist/cjs/anyspend/react/components/index.d.ts +1 -1
  61. package/dist/cjs/anyspend/react/hooks/index.d.ts +1 -0
  62. package/dist/cjs/anyspend/react/hooks/index.js +1 -0
  63. package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +2 -0
  64. package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +14 -0
  65. package/dist/cjs/anyspend/react/hooks/useKycStatus.d.ts +47 -0
  66. package/dist/cjs/anyspend/react/hooks/useKycStatus.js +124 -0
  67. package/dist/cjs/anyspend/services/anyspend.d.ts +4 -1
  68. package/dist/cjs/anyspend/services/anyspend.js +3 -1
  69. package/dist/cjs/global-account/react/components/B3DynamicModal.js +1 -1
  70. package/dist/cjs/global-account/react/components/ManageAccount/BottomNavigation.js +3 -3
  71. package/dist/cjs/global-account/react/components/ManageAccount/HomeActions.js +1 -1
  72. package/dist/cjs/global-account/react/components/ManageAccount/channels/TelegramChannel.js +1 -1
  73. package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +1 -1
  74. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +13 -5
  75. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -1
  76. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -1
  77. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +21 -24
  78. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +1 -1
  79. package/dist/cjs/global-account/react/hooks/useAuth.js +1 -1
  80. package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +3 -1
  81. package/dist/cjs/global-account/react/hooks/useAuthentication.js +94 -24
  82. package/dist/cjs/global-account/react/hooks/useGetAllTWSigners.js +2 -1
  83. package/dist/cjs/global-account/react/stores/useModalStore.d.ts +4 -0
  84. package/dist/cjs/global-account/react/stores/useModalStore.js +2 -0
  85. package/dist/cjs/global-account/react/utils/createWagmiConfig.d.ts +18 -0
  86. package/dist/cjs/global-account/react/utils/createWagmiConfig.js +17 -0
  87. package/dist/esm/anyspend/platform/client.d.ts +35 -0
  88. package/dist/esm/anyspend/platform/client.js +153 -0
  89. package/dist/esm/anyspend/platform/errors.d.ts +38 -0
  90. package/dist/esm/anyspend/platform/errors.js +67 -0
  91. package/dist/esm/anyspend/platform/index.d.ts +87 -0
  92. package/dist/esm/anyspend/platform/index.js +75 -0
  93. package/dist/esm/anyspend/platform/resources/analytics.d.ts +7 -0
  94. package/dist/esm/anyspend/platform/resources/analytics.js +8 -0
  95. package/dist/esm/anyspend/platform/resources/checkout-sessions.d.ts +17 -0
  96. package/dist/esm/anyspend/platform/resources/checkout-sessions.js +23 -0
  97. package/dist/esm/anyspend/platform/resources/customers.d.ts +19 -0
  98. package/dist/esm/anyspend/platform/resources/customers.js +30 -0
  99. package/dist/esm/anyspend/platform/resources/discount-codes.d.ts +29 -0
  100. package/dist/esm/anyspend/platform/resources/discount-codes.js +27 -0
  101. package/dist/esm/anyspend/platform/resources/events.d.ts +14 -0
  102. package/dist/esm/anyspend/platform/resources/events.js +12 -0
  103. package/dist/esm/anyspend/platform/resources/notifications.d.ts +18 -0
  104. package/dist/esm/anyspend/platform/resources/notifications.js +23 -0
  105. package/dist/esm/anyspend/platform/resources/organization.d.ts +17 -0
  106. package/dist/esm/anyspend/platform/resources/organization.js +11 -0
  107. package/dist/esm/anyspend/platform/resources/payment-links.d.ts +21 -0
  108. package/dist/esm/anyspend/platform/resources/payment-links.js +45 -0
  109. package/dist/esm/anyspend/platform/resources/products.d.ts +27 -0
  110. package/dist/esm/anyspend/platform/resources/products.js +27 -0
  111. package/dist/esm/anyspend/platform/resources/transactions.d.ts +11 -0
  112. package/dist/esm/anyspend/platform/resources/transactions.js +21 -0
  113. package/dist/esm/anyspend/platform/resources/webhooks.d.ts +14 -0
  114. package/dist/esm/anyspend/platform/resources/webhooks.js +29 -0
  115. package/dist/esm/anyspend/platform/resources/widgets.d.ts +38 -0
  116. package/dist/esm/anyspend/platform/resources/widgets.js +27 -0
  117. package/dist/esm/anyspend/platform/types.d.ts +478 -0
  118. package/dist/esm/anyspend/platform/types.js +4 -0
  119. package/dist/esm/anyspend/platform/utils/idempotency.d.ts +4 -0
  120. package/dist/esm/anyspend/platform/utils/idempotency.js +14 -0
  121. package/dist/esm/anyspend/platform/utils/pagination.d.ts +12 -0
  122. package/dist/esm/anyspend/platform/utils/pagination.js +19 -0
  123. package/dist/esm/anyspend/react/components/AnySpend.d.ts +5 -1
  124. package/dist/esm/anyspend/react/components/AnySpend.js +128 -17
  125. package/dist/esm/anyspend/react/components/AnySpendCustom.js +4 -4
  126. package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +2 -2
  127. package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.d.ts +14 -6
  128. package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.js +55 -8
  129. package/dist/esm/anyspend/react/components/checkout/AnySpendCheckoutTrigger.d.ts +3 -1
  130. package/dist/esm/anyspend/react/components/checkout/AnySpendCheckoutTrigger.js +2 -2
  131. package/dist/esm/anyspend/react/components/checkout/CheckoutPaymentPanel.d.ts +5 -1
  132. package/dist/esm/anyspend/react/components/checkout/CheckoutPaymentPanel.js +2 -2
  133. package/dist/esm/anyspend/react/components/checkout/CryptoPayPanel.js +1 -1
  134. package/dist/esm/anyspend/react/components/checkout/FiatCheckoutPanel.d.ts +5 -1
  135. package/dist/esm/anyspend/react/components/checkout/FiatCheckoutPanel.js +50 -18
  136. package/dist/esm/anyspend/react/components/checkout/KycGate.d.ts +11 -0
  137. package/dist/esm/anyspend/react/components/checkout/KycGate.js +167 -0
  138. package/dist/esm/anyspend/react/components/checkout/VariablePricingInput.d.ts +17 -0
  139. package/dist/esm/anyspend/react/components/checkout/VariablePricingInput.js +142 -0
  140. package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +1 -1
  141. package/dist/esm/anyspend/react/components/common/FeeDetailPanel.js +1 -1
  142. package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.js +2 -2
  143. package/dist/esm/anyspend/react/components/common/OrderDetails.js +1 -1
  144. package/dist/esm/anyspend/react/components/common/PointsDetailPanel.js +1 -1
  145. package/dist/esm/anyspend/react/components/common/RecipientSelection.js +1 -1
  146. package/dist/esm/anyspend/react/components/index.d.ts +1 -1
  147. package/dist/esm/anyspend/react/hooks/index.d.ts +1 -0
  148. package/dist/esm/anyspend/react/hooks/index.js +1 -0
  149. package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +2 -0
  150. package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +14 -0
  151. package/dist/esm/anyspend/react/hooks/useKycStatus.d.ts +47 -0
  152. package/dist/esm/anyspend/react/hooks/useKycStatus.js +117 -0
  153. package/dist/esm/anyspend/services/anyspend.d.ts +4 -1
  154. package/dist/esm/anyspend/services/anyspend.js +3 -1
  155. package/dist/esm/global-account/react/components/B3DynamicModal.js +1 -1
  156. package/dist/esm/global-account/react/components/ManageAccount/BottomNavigation.js +3 -3
  157. package/dist/esm/global-account/react/components/ManageAccount/HomeActions.js +1 -1
  158. package/dist/esm/global-account/react/components/ManageAccount/channels/TelegramChannel.js +1 -1
  159. package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +1 -1
  160. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +13 -5
  161. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -1
  162. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -1
  163. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +21 -24
  164. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +1 -1
  165. package/dist/esm/global-account/react/hooks/useAuth.js +2 -2
  166. package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +3 -1
  167. package/dist/esm/global-account/react/hooks/useAuthentication.js +94 -24
  168. package/dist/esm/global-account/react/hooks/useGetAllTWSigners.js +2 -1
  169. package/dist/esm/global-account/react/stores/useModalStore.d.ts +4 -0
  170. package/dist/esm/global-account/react/stores/useModalStore.js +2 -0
  171. package/dist/esm/global-account/react/utils/createWagmiConfig.d.ts +18 -0
  172. package/dist/esm/global-account/react/utils/createWagmiConfig.js +16 -0
  173. package/dist/styles/index.css +1 -1
  174. package/dist/types/anyspend/platform/client.d.ts +35 -0
  175. package/dist/types/anyspend/platform/errors.d.ts +38 -0
  176. package/dist/types/anyspend/platform/index.d.ts +87 -0
  177. package/dist/types/anyspend/platform/resources/analytics.d.ts +7 -0
  178. package/dist/types/anyspend/platform/resources/checkout-sessions.d.ts +17 -0
  179. package/dist/types/anyspend/platform/resources/customers.d.ts +19 -0
  180. package/dist/types/anyspend/platform/resources/discount-codes.d.ts +29 -0
  181. package/dist/types/anyspend/platform/resources/events.d.ts +14 -0
  182. package/dist/types/anyspend/platform/resources/notifications.d.ts +18 -0
  183. package/dist/types/anyspend/platform/resources/organization.d.ts +17 -0
  184. package/dist/types/anyspend/platform/resources/payment-links.d.ts +21 -0
  185. package/dist/types/anyspend/platform/resources/products.d.ts +27 -0
  186. package/dist/types/anyspend/platform/resources/transactions.d.ts +11 -0
  187. package/dist/types/anyspend/platform/resources/webhooks.d.ts +14 -0
  188. package/dist/types/anyspend/platform/resources/widgets.d.ts +38 -0
  189. package/dist/types/anyspend/platform/types.d.ts +478 -0
  190. package/dist/types/anyspend/platform/utils/idempotency.d.ts +4 -0
  191. package/dist/types/anyspend/platform/utils/pagination.d.ts +12 -0
  192. package/dist/types/anyspend/react/components/AnySpend.d.ts +5 -1
  193. package/dist/types/anyspend/react/components/checkout/AnySpendCheckout.d.ts +14 -6
  194. package/dist/types/anyspend/react/components/checkout/AnySpendCheckoutTrigger.d.ts +3 -1
  195. package/dist/types/anyspend/react/components/checkout/CheckoutPaymentPanel.d.ts +5 -1
  196. package/dist/types/anyspend/react/components/checkout/FiatCheckoutPanel.d.ts +5 -1
  197. package/dist/types/anyspend/react/components/checkout/KycGate.d.ts +11 -0
  198. package/dist/types/anyspend/react/components/checkout/VariablePricingInput.d.ts +17 -0
  199. package/dist/types/anyspend/react/components/index.d.ts +1 -1
  200. package/dist/types/anyspend/react/hooks/index.d.ts +1 -0
  201. package/dist/types/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +2 -0
  202. package/dist/types/anyspend/react/hooks/useKycStatus.d.ts +47 -0
  203. package/dist/types/anyspend/services/anyspend.d.ts +4 -1
  204. package/dist/types/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -1
  205. package/dist/types/global-account/react/hooks/useAuthentication.d.ts +3 -1
  206. package/dist/types/global-account/react/stores/useModalStore.d.ts +4 -0
  207. package/dist/types/global-account/react/utils/createWagmiConfig.d.ts +18 -0
  208. package/package.json +7 -1
  209. package/src/anyspend/docs/checkout-sessions.md +20 -3
  210. package/src/anyspend/platform/client.ts +198 -0
  211. package/src/anyspend/platform/errors.ts +92 -0
  212. package/src/anyspend/platform/index.ts +129 -0
  213. package/src/anyspend/platform/resources/analytics.ts +10 -0
  214. package/src/anyspend/platform/resources/checkout-sessions.ts +36 -0
  215. package/src/anyspend/platform/resources/customers.ts +54 -0
  216. package/src/anyspend/platform/resources/discount-codes.ts +63 -0
  217. package/src/anyspend/platform/resources/events.ts +22 -0
  218. package/src/anyspend/platform/resources/notifications.ts +37 -0
  219. package/src/anyspend/platform/resources/organization.ts +24 -0
  220. package/src/anyspend/platform/resources/payment-links.ts +74 -0
  221. package/src/anyspend/platform/resources/products.ts +59 -0
  222. package/src/anyspend/platform/resources/transactions.ts +33 -0
  223. package/src/anyspend/platform/resources/webhooks.ts +47 -0
  224. package/src/anyspend/platform/resources/widgets.ts +63 -0
  225. package/src/anyspend/platform/types.ts +532 -0
  226. package/src/anyspend/platform/utils/idempotency.ts +15 -0
  227. package/src/anyspend/platform/utils/pagination.ts +32 -0
  228. package/src/anyspend/react/components/AnySpend.tsx +152 -18
  229. package/src/anyspend/react/components/AnySpendCustom.tsx +4 -4
  230. package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +2 -2
  231. package/src/anyspend/react/components/checkout/AnySpendCheckout.tsx +81 -18
  232. package/src/anyspend/react/components/checkout/AnySpendCheckoutTrigger.tsx +4 -0
  233. package/src/anyspend/react/components/checkout/CheckoutPaymentPanel.tsx +8 -0
  234. package/src/anyspend/react/components/checkout/CryptoPayPanel.tsx +4 -13
  235. package/src/anyspend/react/components/checkout/FiatCheckoutPanel.tsx +86 -17
  236. package/src/anyspend/react/components/checkout/KycGate.tsx +387 -0
  237. package/src/anyspend/react/components/checkout/VariablePricingInput.tsx +247 -0
  238. package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +1 -1
  239. package/src/anyspend/react/components/common/FeeDetailPanel.tsx +1 -1
  240. package/src/anyspend/react/components/common/FiatPaymentMethod.tsx +2 -2
  241. package/src/anyspend/react/components/common/OrderDetails.tsx +1 -1
  242. package/src/anyspend/react/components/common/PointsDetailPanel.tsx +1 -1
  243. package/src/anyspend/react/components/common/RecipientSelection.tsx +1 -1
  244. package/src/anyspend/react/components/index.ts +1 -0
  245. package/src/anyspend/react/hooks/index.ts +1 -0
  246. package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +17 -0
  247. package/src/anyspend/react/hooks/useKycStatus.ts +150 -0
  248. package/src/anyspend/services/anyspend.ts +7 -0
  249. package/src/global-account/react/components/B3DynamicModal.tsx +0 -2
  250. package/src/global-account/react/components/ManageAccount/BottomNavigation.tsx +7 -7
  251. package/src/global-account/react/components/ManageAccount/HomeActions.tsx +2 -2
  252. package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +7 -7
  253. package/src/global-account/react/components/ManageAccount/channels/TelegramChannel.tsx +1 -1
  254. package/src/global-account/react/components/SignInWithB3/SignIn.tsx +1 -1
  255. package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +13 -5
  256. package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +1 -1
  257. package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +35 -25
  258. package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +1 -1
  259. package/src/global-account/react/hooks/useAuth.ts +2 -2
  260. package/src/global-account/react/hooks/useAuthentication.ts +92 -27
  261. package/src/global-account/react/hooks/useGetAllTWSigners.tsx +2 -1
  262. package/src/global-account/react/stores/useModalStore.ts +6 -0
  263. package/src/global-account/react/utils/createWagmiConfig.tsx +18 -0
@@ -15,11 +15,26 @@ import { createWagmiConfig } from "../utils/createWagmiConfig.js";
15
15
  import { useTWAuth } from "./useTWAuth.js";
16
16
  import { useUserQuery } from "./useUserQuery.js";
17
17
  const debug = debugB3React("useAuthentication");
18
- export function useAuthentication(partnerId) {
18
+ export function useAuthentication(partnerId, { skipAutoConnect = false } = {}) {
19
19
  const { onConnectCallback, onLogoutCallback } = useContext(LocalSDKContext);
20
20
  const { disconnect } = useDisconnect();
21
21
  const wallets = useConnectedWallets();
22
+ // Keep refs so logout() always disconnects current wallets, not stale closure values.
23
+ // autoConnectCore captures onConnect (and thus logout) from the first render before wallets
24
+ // are populated — without these refs, logout() would capture wallets=[] and disconnect nothing.
25
+ const walletsRef = useRef(wallets);
26
+ useEffect(() => {
27
+ walletsRef.current = wallets;
28
+ }, [wallets]);
22
29
  const activeWallet = useActiveWallet();
30
+ // Track the active wallet by ref so logout() can disconnect the exact reference
31
+ // stored in thirdweb's activeWalletStore. walletsRef.current (from useConnectedWallets)
32
+ // may hold a different object reference than what thirdweb considers "active",
33
+ // causing the identity check in onWalletDisconnect to fail silently.
34
+ const activeWalletRef = useRef(activeWallet);
35
+ useEffect(() => {
36
+ activeWalletRef.current = activeWallet;
37
+ }, [activeWallet]);
23
38
  const isAuthenticated = useAuthStore(state => state.isAuthenticated);
24
39
  const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
25
40
  const setIsConnected = useAuthStore(state => state.setIsConnected);
@@ -126,21 +141,37 @@ export function useAuthentication(partnerId) {
126
141
  }
127
142
  }, [activeWallet, partnerId, authenticate, setIsAuthenticated, setIsAuthenticating, setUser, setHasStartedConnecting]);
128
143
  const logout = useCallback(async (callback) => {
129
- if (activeWallet) {
130
- debug("@@logout:activeWallet", activeWallet);
131
- disconnect(activeWallet);
132
- debug("@@logout:activeWallet", activeWallet);
133
- }
134
- // Log out of each wallet
135
- wallets.forEach(wallet => {
136
- console.log("@@logging out", wallet);
137
- disconnect(wallet);
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.
147
+ // Use walletsRef.current (not the stale closure value) so we always get current wallets —
148
+ // autoConnectCore captures logout from the first render when wallets is still [].
149
+ walletsRef.current.forEach(wallet => {
150
+ debug("@@logout:wallet", wallet.id);
151
+ if (wallet.id.startsWith("ecosystem.") || wallet.id === "smart") {
152
+ disconnect(wallet);
153
+ }
138
154
  });
139
- // Delete localStorage thirdweb:connected-wallet-ids
140
- // https://npc-labs.slack.com/archives/C070E6HNG85/p1750185115273099
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.
161
+ // We use the exact reference from activeWalletRef because thirdweb's
162
+ // onWalletDisconnect uses strict identity (===) to decide whether to clear
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.
168
+ if (activeWalletRef.current) {
169
+ debug("@@logout:disconnecting active wallet", activeWalletRef.current.id);
170
+ disconnect(activeWalletRef.current);
171
+ }
172
+ // Clear user-specific storage (auth tokens, cached user data).
173
+ // Thirdweb's wallet connection state is managed separately via disconnect() above.
141
174
  if (typeof localStorage !== "undefined") {
142
- localStorage.removeItem("thirdweb:connected-wallet-ids");
143
- localStorage.removeItem("wagmi.store");
144
175
  localStorage.removeItem("lastAuthProvider");
145
176
  localStorage.removeItem("b3-user");
146
177
  }
@@ -148,33 +179,62 @@ export function useAuthentication(partnerId) {
148
179
  debug("@@logout:loggedOut");
149
180
  setIsAuthenticated(false);
150
181
  setIsConnected(false);
182
+ // Reset isAuthenticating so any in-flight page-load auto-connect that set it true
183
+ // does not keep the login modal spinner stuck after logout() is called.
184
+ setIsAuthenticating(false);
151
185
  setUser();
152
186
  callback?.();
153
187
  if (onLogoutCallback) {
154
188
  await onLogoutCallback();
155
189
  }
156
- }, [activeWallet, disconnect, wallets, setIsAuthenticated, setUser, setIsConnected, onLogoutCallback]);
190
+ },
191
+ // wallets intentionally omitted — we use walletsRef.current so this callback stays stable
192
+ // and always operates on current wallets even when captured in stale closures.
193
+ // eslint-disable-next-line react-hooks/exhaustive-deps
194
+ [disconnect, setIsAuthenticated, setIsAuthenticating, setUser, setIsConnected, onLogoutCallback]);
157
195
  const onConnect = useCallback(async (_walleAutoConnectedWith, allConnectedWallets) => {
158
196
  debug("@@useAuthentication:onConnect", { _walleAutoConnectedWith, allConnectedWallets });
197
+ const connectedEcosystemWallet = allConnectedWallets.find(w => w.id.startsWith("ecosystem."));
159
198
  try {
160
- const wallet = allConnectedWallets.find(wallet => wallet.id.startsWith("ecosystem."));
161
- if (!wallet) {
199
+ if (!connectedEcosystemWallet) {
162
200
  throw new Error("No smart wallet found during auto-connect");
163
201
  }
164
- debug("@@useAuthentication:onConnect", { wallet });
202
+ debug("@@useAuthentication:onConnect", { wallet: connectedEcosystemWallet });
165
203
  setHasStartedConnecting(true);
166
204
  setIsConnected(true);
167
205
  setIsAuthenticating(true);
168
- await setActiveWallet(wallet);
169
- const userAuth = await authenticateUser(wallet);
206
+ await setActiveWallet(connectedEcosystemWallet);
207
+ const userAuth = await authenticateUser(connectedEcosystemWallet);
170
208
  if (userAuth && onConnectCallback) {
171
- await onConnectCallback(wallet, userAuth.accessToken);
209
+ await onConnectCallback(connectedEcosystemWallet, userAuth.accessToken);
172
210
  }
173
211
  }
174
212
  catch (error) {
175
213
  debug("@@useAuthentication:onConnect:failed", { error });
176
214
  setIsAuthenticated(false);
177
215
  setUser(undefined);
216
+ // Directly disconnect the ecosystem wallet we set active above.
217
+ // We can't rely on logout()'s activeWalletRef here because it's updated
218
+ // via useEffect (deferred until after paint), but this callback may run
219
+ // entirely within a single React commit cycle — before the ref updates.
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);
225
+ }
226
+ // Also disconnect the wallet that autoConnectCore set as active.
227
+ // When only a non-ecosystem wallet (e.g. MetaMask) auto-reconnects,
228
+ // connectedEcosystemWallet is undefined, so the block above is skipped.
229
+ // But autoConnectCore already set this wallet as thirdweb's activeWallet,
230
+ // leaving activeAccount set. ConnectEmbed checks show = !activeAccount,
231
+ // so if we don't clear it, the login form renders blank.
232
+ // Uses object identity (===) which is safe because thirdweb returns
233
+ // stable references for connected wallet instances.
234
+ if (_walleAutoConnectedWith && _walleAutoConnectedWith !== connectedEcosystemWallet) {
235
+ debug("@@useAuthentication:onConnect:disconnecting auto-connected wallet", _walleAutoConnectedWith.id);
236
+ disconnect(_walleAutoConnectedWith);
237
+ }
178
238
  await logout();
179
239
  }
180
240
  finally {
@@ -189,6 +249,7 @@ export function useAuthentication(partnerId) {
189
249
  isAuthenticated,
190
250
  isAuthenticating,
191
251
  isConnected,
252
+ disconnect,
192
253
  setHasStartedConnecting,
193
254
  setIsConnected,
194
255
  setIsAuthenticating,
@@ -201,23 +262,32 @@ export function useAuthentication(partnerId) {
201
262
  ]);
202
263
  const { isLoading: useAutoConnectLoading } = useAutoConnect({
203
264
  client,
204
- wallets: [wallet],
265
+ // When skipAutoConnect is true (e.g. LoginStepContent, SignInWithB3Flow), pass an empty
266
+ // wallets array so useAutoConnect completes immediately without firing onConnect.
267
+ // Only AuthenticationProvider (the primary instance) should own auto-connect.
268
+ wallets: skipAutoConnect ? [] : [wallet],
205
269
  onConnect,
206
270
  onTimeout: () => {
271
+ if (skipAutoConnect)
272
+ return;
207
273
  logout().catch(error => {
208
274
  debug("@@useAuthentication:logout on timeout failed", { error });
209
275
  });
210
276
  },
211
277
  });
212
278
  /**
213
- * useAutoConnectLoading starts as false
279
+ * useAutoConnectLoading starts as false.
280
+ * Only the primary (non-skip) instance manages isAuthenticating via this effect
281
+ * to avoid race conditions when multiple useAuthentication instances are mounted.
214
282
  */
215
283
  useEffect(() => {
284
+ if (skipAutoConnect)
285
+ return;
216
286
  if (!useAutoConnectLoading && useAutoConnectLoadingPrevious.current && !hasStartedConnecting) {
217
287
  setIsAuthenticating(false);
218
288
  }
219
289
  useAutoConnectLoadingPrevious.current = useAutoConnectLoading;
220
- }, [useAutoConnectLoading, hasStartedConnecting, setIsAuthenticating]);
290
+ }, [useAutoConnectLoading, hasStartedConnecting, setIsAuthenticating, skipAutoConnect]);
221
291
  const isReady = isAuthenticated && !isAuthenticating;
222
292
  return {
223
293
  logout,
@@ -62,7 +62,8 @@ export function useGetAllTWSigners({ chain, accountAddress, queryOptions }) {
62
62
  });
63
63
  return result;
64
64
  },
65
- enabled: Boolean(chain && accountAddress),
65
+ // Respect queryOptions.enabled if explicitly set (e.g. signersEnabled=false from SignInWithB3Flow)
66
+ enabled: queryOptions?.enabled !== false && Boolean(chain && accountAddress),
66
67
  refetchOnMount: true,
67
68
  refetchOnWindowFocus: true,
68
69
  refetchOnReconnect: true,
@@ -657,6 +657,10 @@ interface ModalState {
657
657
  setLinkingState: (isLinking: boolean, method?: string | null) => void;
658
658
  /** Function to update closable property of current content without adding to history */
659
659
  setClosable: (closable: boolean) => void;
660
+ /** Whether a third-party iframe (e.g. Persona KYC) is currently active over the modal */
661
+ personaActive: boolean;
662
+ /** Function to mark a third-party iframe as active/inactive */
663
+ setPersonaActive: (active: boolean) => void;
660
664
  }
661
665
  /**
662
666
  * Zustand store for managing modal state
@@ -36,4 +36,6 @@ export const useModalStore = create(set => ({
36
36
  setClosable: (closable) => set(state => ({
37
37
  contentType: state.contentType ? { ...state.contentType, closable } : null,
38
38
  })),
39
+ personaActive: false,
40
+ setPersonaActive: (active) => set({ personaActive: active }),
39
41
  }));
@@ -25,3 +25,21 @@ export declare function createWagmiConfig(options: CreateWagmiConfigOptions): im
25
25
  }, {
26
26
  "thirdweb:lastChainId": number;
27
27
  }>)[]>;
28
+ /**
29
+ * Returns a cached wagmi config for the given partnerId.
30
+ * Use this instead of calling createWagmiConfig() directly inside React components or hooks
31
+ * to avoid registering duplicate EventEmitter listeners on every render.
32
+ */
33
+ export declare function getCachedWagmiConfig(options: CreateWagmiConfigOptions): import("wagmi").Config<readonly [import("viem").Chain, ...import("viem").Chain[]], {
34
+ [k: string]: import("viem").HttpTransport<undefined, false>;
35
+ }, (CreateConnectorFn | CreateConnectorFn<import("thirdweb/dist/types/adapters/eip1193").EIP1193Provider | undefined, {
36
+ connect<withCapabilities extends boolean = false>(parameters?: import("@thirdweb-dev/wagmi-adapter").ConnectionOptions<withCapabilities> | undefined): Promise<{
37
+ accounts: withCapabilities extends true ? readonly {
38
+ address: `0x${string}`;
39
+ capabilities: Record<string, unknown>;
40
+ }[] : readonly `0x${string}`[];
41
+ chainId: number;
42
+ }>;
43
+ }, {
44
+ "thirdweb:lastChainId": number;
45
+ }>)[]>;
@@ -27,3 +27,19 @@ export function createWagmiConfig(options) {
27
27
  connectors: finalConnectors,
28
28
  });
29
29
  }
30
+ /** Module-level cache — wagmi configs must not be recreated on every render. */
31
+ const wagmiConfigCache = new Map();
32
+ /**
33
+ * Returns a cached wagmi config for the given partnerId.
34
+ * Use this instead of calling createWagmiConfig() directly inside React components or hooks
35
+ * to avoid registering duplicate EventEmitter listeners on every render.
36
+ */
37
+ export function getCachedWagmiConfig(options) {
38
+ const key = options.partnerId;
39
+ let config = wagmiConfigCache.get(key);
40
+ if (!config) {
41
+ config = createWagmiConfig(options);
42
+ wagmiConfigCache.set(key, config);
43
+ }
44
+ return config;
45
+ }