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

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 (232) 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 +123 -12
  39. package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.d.ts +14 -6
  40. package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.js +55 -8
  41. package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckoutTrigger.d.ts +3 -1
  42. package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckoutTrigger.js +2 -2
  43. package/dist/cjs/anyspend/react/components/checkout/CheckoutPaymentPanel.d.ts +5 -1
  44. package/dist/cjs/anyspend/react/components/checkout/CheckoutPaymentPanel.js +2 -2
  45. package/dist/cjs/anyspend/react/components/checkout/CryptoPayPanel.js +1 -1
  46. package/dist/cjs/anyspend/react/components/checkout/FiatCheckoutPanel.d.ts +5 -1
  47. package/dist/cjs/anyspend/react/components/checkout/FiatCheckoutPanel.js +48 -16
  48. package/dist/cjs/anyspend/react/components/checkout/KycGate.d.ts +11 -0
  49. package/dist/cjs/anyspend/react/components/checkout/KycGate.js +203 -0
  50. package/dist/cjs/anyspend/react/components/checkout/VariablePricingInput.d.ts +17 -0
  51. package/dist/cjs/anyspend/react/components/checkout/VariablePricingInput.js +145 -0
  52. package/dist/cjs/anyspend/react/components/index.d.ts +1 -1
  53. package/dist/cjs/anyspend/react/hooks/index.d.ts +1 -0
  54. package/dist/cjs/anyspend/react/hooks/index.js +1 -0
  55. package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +2 -0
  56. package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +14 -0
  57. package/dist/cjs/anyspend/react/hooks/useKycStatus.d.ts +47 -0
  58. package/dist/cjs/anyspend/react/hooks/useKycStatus.js +124 -0
  59. package/dist/cjs/anyspend/services/anyspend.d.ts +4 -1
  60. package/dist/cjs/anyspend/services/anyspend.js +3 -1
  61. package/dist/cjs/global-account/react/components/B3DynamicModal.js +1 -1
  62. package/dist/cjs/global-account/react/components/ManageAccount/BottomNavigation.js +3 -3
  63. package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +1 -1
  64. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +13 -5
  65. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -1
  66. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -1
  67. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +21 -24
  68. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +1 -1
  69. package/dist/cjs/global-account/react/hooks/useAuth.js +1 -1
  70. package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +3 -1
  71. package/dist/cjs/global-account/react/hooks/useAuthentication.js +82 -24
  72. package/dist/cjs/global-account/react/hooks/useGetAllTWSigners.js +2 -1
  73. package/dist/cjs/global-account/react/stores/useModalStore.d.ts +4 -0
  74. package/dist/cjs/global-account/react/stores/useModalStore.js +2 -0
  75. package/dist/cjs/global-account/react/utils/createWagmiConfig.d.ts +18 -0
  76. package/dist/cjs/global-account/react/utils/createWagmiConfig.js +17 -0
  77. package/dist/esm/anyspend/platform/client.d.ts +35 -0
  78. package/dist/esm/anyspend/platform/client.js +153 -0
  79. package/dist/esm/anyspend/platform/errors.d.ts +38 -0
  80. package/dist/esm/anyspend/platform/errors.js +67 -0
  81. package/dist/esm/anyspend/platform/index.d.ts +87 -0
  82. package/dist/esm/anyspend/platform/index.js +75 -0
  83. package/dist/esm/anyspend/platform/resources/analytics.d.ts +7 -0
  84. package/dist/esm/anyspend/platform/resources/analytics.js +8 -0
  85. package/dist/esm/anyspend/platform/resources/checkout-sessions.d.ts +17 -0
  86. package/dist/esm/anyspend/platform/resources/checkout-sessions.js +23 -0
  87. package/dist/esm/anyspend/platform/resources/customers.d.ts +19 -0
  88. package/dist/esm/anyspend/platform/resources/customers.js +30 -0
  89. package/dist/esm/anyspend/platform/resources/discount-codes.d.ts +29 -0
  90. package/dist/esm/anyspend/platform/resources/discount-codes.js +27 -0
  91. package/dist/esm/anyspend/platform/resources/events.d.ts +14 -0
  92. package/dist/esm/anyspend/platform/resources/events.js +12 -0
  93. package/dist/esm/anyspend/platform/resources/notifications.d.ts +18 -0
  94. package/dist/esm/anyspend/platform/resources/notifications.js +23 -0
  95. package/dist/esm/anyspend/platform/resources/organization.d.ts +17 -0
  96. package/dist/esm/anyspend/platform/resources/organization.js +11 -0
  97. package/dist/esm/anyspend/platform/resources/payment-links.d.ts +21 -0
  98. package/dist/esm/anyspend/platform/resources/payment-links.js +45 -0
  99. package/dist/esm/anyspend/platform/resources/products.d.ts +27 -0
  100. package/dist/esm/anyspend/platform/resources/products.js +27 -0
  101. package/dist/esm/anyspend/platform/resources/transactions.d.ts +11 -0
  102. package/dist/esm/anyspend/platform/resources/transactions.js +21 -0
  103. package/dist/esm/anyspend/platform/resources/webhooks.d.ts +14 -0
  104. package/dist/esm/anyspend/platform/resources/webhooks.js +29 -0
  105. package/dist/esm/anyspend/platform/resources/widgets.d.ts +38 -0
  106. package/dist/esm/anyspend/platform/resources/widgets.js +27 -0
  107. package/dist/esm/anyspend/platform/types.d.ts +478 -0
  108. package/dist/esm/anyspend/platform/types.js +4 -0
  109. package/dist/esm/anyspend/platform/utils/idempotency.d.ts +4 -0
  110. package/dist/esm/anyspend/platform/utils/idempotency.js +14 -0
  111. package/dist/esm/anyspend/platform/utils/pagination.d.ts +12 -0
  112. package/dist/esm/anyspend/platform/utils/pagination.js +19 -0
  113. package/dist/esm/anyspend/react/components/AnySpend.d.ts +5 -1
  114. package/dist/esm/anyspend/react/components/AnySpend.js +124 -13
  115. package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.d.ts +14 -6
  116. package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.js +55 -8
  117. package/dist/esm/anyspend/react/components/checkout/AnySpendCheckoutTrigger.d.ts +3 -1
  118. package/dist/esm/anyspend/react/components/checkout/AnySpendCheckoutTrigger.js +2 -2
  119. package/dist/esm/anyspend/react/components/checkout/CheckoutPaymentPanel.d.ts +5 -1
  120. package/dist/esm/anyspend/react/components/checkout/CheckoutPaymentPanel.js +2 -2
  121. package/dist/esm/anyspend/react/components/checkout/CryptoPayPanel.js +1 -1
  122. package/dist/esm/anyspend/react/components/checkout/FiatCheckoutPanel.d.ts +5 -1
  123. package/dist/esm/anyspend/react/components/checkout/FiatCheckoutPanel.js +50 -18
  124. package/dist/esm/anyspend/react/components/checkout/KycGate.d.ts +11 -0
  125. package/dist/esm/anyspend/react/components/checkout/KycGate.js +167 -0
  126. package/dist/esm/anyspend/react/components/checkout/VariablePricingInput.d.ts +17 -0
  127. package/dist/esm/anyspend/react/components/checkout/VariablePricingInput.js +142 -0
  128. package/dist/esm/anyspend/react/components/index.d.ts +1 -1
  129. package/dist/esm/anyspend/react/hooks/index.d.ts +1 -0
  130. package/dist/esm/anyspend/react/hooks/index.js +1 -0
  131. package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +2 -0
  132. package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +14 -0
  133. package/dist/esm/anyspend/react/hooks/useKycStatus.d.ts +47 -0
  134. package/dist/esm/anyspend/react/hooks/useKycStatus.js +117 -0
  135. package/dist/esm/anyspend/services/anyspend.d.ts +4 -1
  136. package/dist/esm/anyspend/services/anyspend.js +3 -1
  137. package/dist/esm/global-account/react/components/B3DynamicModal.js +1 -1
  138. package/dist/esm/global-account/react/components/ManageAccount/BottomNavigation.js +3 -3
  139. package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +1 -1
  140. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +13 -5
  141. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -1
  142. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -1
  143. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +21 -24
  144. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +1 -1
  145. package/dist/esm/global-account/react/hooks/useAuth.js +2 -2
  146. package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +3 -1
  147. package/dist/esm/global-account/react/hooks/useAuthentication.js +82 -24
  148. package/dist/esm/global-account/react/hooks/useGetAllTWSigners.js +2 -1
  149. package/dist/esm/global-account/react/stores/useModalStore.d.ts +4 -0
  150. package/dist/esm/global-account/react/stores/useModalStore.js +2 -0
  151. package/dist/esm/global-account/react/utils/createWagmiConfig.d.ts +18 -0
  152. package/dist/esm/global-account/react/utils/createWagmiConfig.js +16 -0
  153. package/dist/styles/index.css +1 -1
  154. package/dist/types/anyspend/platform/client.d.ts +35 -0
  155. package/dist/types/anyspend/platform/errors.d.ts +38 -0
  156. package/dist/types/anyspend/platform/index.d.ts +87 -0
  157. package/dist/types/anyspend/platform/resources/analytics.d.ts +7 -0
  158. package/dist/types/anyspend/platform/resources/checkout-sessions.d.ts +17 -0
  159. package/dist/types/anyspend/platform/resources/customers.d.ts +19 -0
  160. package/dist/types/anyspend/platform/resources/discount-codes.d.ts +29 -0
  161. package/dist/types/anyspend/platform/resources/events.d.ts +14 -0
  162. package/dist/types/anyspend/platform/resources/notifications.d.ts +18 -0
  163. package/dist/types/anyspend/platform/resources/organization.d.ts +17 -0
  164. package/dist/types/anyspend/platform/resources/payment-links.d.ts +21 -0
  165. package/dist/types/anyspend/platform/resources/products.d.ts +27 -0
  166. package/dist/types/anyspend/platform/resources/transactions.d.ts +11 -0
  167. package/dist/types/anyspend/platform/resources/webhooks.d.ts +14 -0
  168. package/dist/types/anyspend/platform/resources/widgets.d.ts +38 -0
  169. package/dist/types/anyspend/platform/types.d.ts +478 -0
  170. package/dist/types/anyspend/platform/utils/idempotency.d.ts +4 -0
  171. package/dist/types/anyspend/platform/utils/pagination.d.ts +12 -0
  172. package/dist/types/anyspend/react/components/AnySpend.d.ts +5 -1
  173. package/dist/types/anyspend/react/components/checkout/AnySpendCheckout.d.ts +14 -6
  174. package/dist/types/anyspend/react/components/checkout/AnySpendCheckoutTrigger.d.ts +3 -1
  175. package/dist/types/anyspend/react/components/checkout/CheckoutPaymentPanel.d.ts +5 -1
  176. package/dist/types/anyspend/react/components/checkout/FiatCheckoutPanel.d.ts +5 -1
  177. package/dist/types/anyspend/react/components/checkout/KycGate.d.ts +11 -0
  178. package/dist/types/anyspend/react/components/checkout/VariablePricingInput.d.ts +17 -0
  179. package/dist/types/anyspend/react/components/index.d.ts +1 -1
  180. package/dist/types/anyspend/react/hooks/index.d.ts +1 -0
  181. package/dist/types/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +2 -0
  182. package/dist/types/anyspend/react/hooks/useKycStatus.d.ts +47 -0
  183. package/dist/types/anyspend/services/anyspend.d.ts +4 -1
  184. package/dist/types/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -1
  185. package/dist/types/global-account/react/hooks/useAuthentication.d.ts +3 -1
  186. package/dist/types/global-account/react/stores/useModalStore.d.ts +4 -0
  187. package/dist/types/global-account/react/utils/createWagmiConfig.d.ts +18 -0
  188. package/package.json +7 -1
  189. package/src/anyspend/docs/checkout-sessions.md +20 -3
  190. package/src/anyspend/platform/client.ts +198 -0
  191. package/src/anyspend/platform/errors.ts +92 -0
  192. package/src/anyspend/platform/index.ts +129 -0
  193. package/src/anyspend/platform/resources/analytics.ts +10 -0
  194. package/src/anyspend/platform/resources/checkout-sessions.ts +36 -0
  195. package/src/anyspend/platform/resources/customers.ts +54 -0
  196. package/src/anyspend/platform/resources/discount-codes.ts +63 -0
  197. package/src/anyspend/platform/resources/events.ts +22 -0
  198. package/src/anyspend/platform/resources/notifications.ts +37 -0
  199. package/src/anyspend/platform/resources/organization.ts +24 -0
  200. package/src/anyspend/platform/resources/payment-links.ts +74 -0
  201. package/src/anyspend/platform/resources/products.ts +59 -0
  202. package/src/anyspend/platform/resources/transactions.ts +33 -0
  203. package/src/anyspend/platform/resources/webhooks.ts +47 -0
  204. package/src/anyspend/platform/resources/widgets.ts +63 -0
  205. package/src/anyspend/platform/types.ts +532 -0
  206. package/src/anyspend/platform/utils/idempotency.ts +15 -0
  207. package/src/anyspend/platform/utils/pagination.ts +32 -0
  208. package/src/anyspend/react/components/AnySpend.tsx +148 -14
  209. package/src/anyspend/react/components/checkout/AnySpendCheckout.tsx +81 -18
  210. package/src/anyspend/react/components/checkout/AnySpendCheckoutTrigger.tsx +4 -0
  211. package/src/anyspend/react/components/checkout/CheckoutPaymentPanel.tsx +8 -0
  212. package/src/anyspend/react/components/checkout/CryptoPayPanel.tsx +4 -13
  213. package/src/anyspend/react/components/checkout/FiatCheckoutPanel.tsx +86 -17
  214. package/src/anyspend/react/components/checkout/KycGate.tsx +387 -0
  215. package/src/anyspend/react/components/checkout/VariablePricingInput.tsx +247 -0
  216. package/src/anyspend/react/components/index.ts +1 -0
  217. package/src/anyspend/react/hooks/index.ts +1 -0
  218. package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +17 -0
  219. package/src/anyspend/react/hooks/useKycStatus.ts +150 -0
  220. package/src/anyspend/services/anyspend.ts +7 -0
  221. package/src/global-account/react/components/B3DynamicModal.tsx +0 -2
  222. package/src/global-account/react/components/ManageAccount/BottomNavigation.tsx +7 -7
  223. package/src/global-account/react/components/SignInWithB3/SignIn.tsx +1 -1
  224. package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +13 -5
  225. package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +1 -1
  226. package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +35 -25
  227. package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +1 -1
  228. package/src/global-account/react/hooks/useAuth.ts +2 -2
  229. package/src/global-account/react/hooks/useAuthentication.ts +80 -27
  230. package/src/global-account/react/hooks/useGetAllTWSigners.tsx +2 -1
  231. package/src/global-account/react/stores/useModalStore.ts +6 -0
  232. package/src/global-account/react/utils/createWagmiConfig.tsx +18 -0
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ "use client";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.getCachedWalletHeaders = getCachedWalletHeaders;
5
+ exports.useWalletAuthHeaders = useWalletAuthHeaders;
6
+ exports.useKycStatus = useKycStatus;
7
+ exports.useCreateKycInquiry = useCreateKycInquiry;
8
+ exports.useVerifyKyc = useVerifyKyc;
9
+ const constants_1 = require("../../../anyspend/constants");
10
+ const react_query_1 = require("@tanstack/react-query");
11
+ const react_1 = require("react");
12
+ const wagmi_1 = require("wagmi");
13
+ function buildWalletAuthMessage(walletAddress, timestamp) {
14
+ return `AnySpend wants to verify your identity for card payments.\n\nThis signature does not trigger a blockchain transaction or cost any gas.\n\nWallet: ${walletAddress.toLowerCase()}\nNonce: ${timestamp}`;
15
+ }
16
+ /** Module-level signature cache to avoid repeated wallet prompts within the 5-minute window. */
17
+ const headerCache = new Map();
18
+ /**
19
+ * Returns cached wallet auth headers without triggering a wallet signature prompt.
20
+ * Returns undefined if no valid cache exists for the given address.
21
+ */
22
+ function getCachedWalletHeaders(address) {
23
+ const cached = headerCache.get(address.toLowerCase());
24
+ if (cached && Date.now() < cached.expiresAt)
25
+ return cached.headers;
26
+ return undefined;
27
+ }
28
+ /**
29
+ * Returns a function that builds the wallet-signature auth headers.
30
+ * Caches signatures for 4 minutes (server allows 5-minute window).
31
+ */
32
+ function useWalletAuthHeaders() {
33
+ const { address } = (0, wagmi_1.useAccount)();
34
+ const { signMessageAsync } = (0, wagmi_1.useSignMessage)();
35
+ const getHeaders = (0, react_1.useCallback)(async () => {
36
+ if (!address)
37
+ throw new Error("No wallet connected");
38
+ const walletAddress = address.toLowerCase();
39
+ const cached = headerCache.get(walletAddress);
40
+ if (cached && Date.now() < cached.expiresAt)
41
+ return cached.headers;
42
+ const timestamp = Math.floor(Date.now() / 1000);
43
+ const message = buildWalletAuthMessage(walletAddress, timestamp);
44
+ const signature = await signMessageAsync({ message });
45
+ const headers = {
46
+ "X-Wallet-Address": walletAddress,
47
+ "X-Wallet-Signature": signature,
48
+ "X-Wallet-Timestamp": String(timestamp),
49
+ };
50
+ // Cache for 4 minutes so repeated fetches don't re-prompt the user
51
+ headerCache.set(walletAddress, { headers, expiresAt: Date.now() + 4 * 60 * 1000 });
52
+ return headers;
53
+ }, [address, signMessageAsync]);
54
+ return { address, getHeaders };
55
+ }
56
+ function useKycStatus(enabled = true) {
57
+ const { address, getHeaders } = useWalletAuthHeaders();
58
+ const { data, isLoading, error, refetch } = (0, react_query_1.useQuery)({
59
+ queryKey: ["kyc-status", address],
60
+ queryFn: async () => {
61
+ const headers = await getHeaders();
62
+ const response = await fetch(`${constants_1.ANYSPEND_MAINNET_BASE_URL}/kyc/status`, { headers });
63
+ const json = await response.json();
64
+ if (!response.ok)
65
+ throw new Error(json.message || "Failed to fetch KYC status");
66
+ return json.data;
67
+ },
68
+ enabled: enabled && !!address,
69
+ staleTime: 30000,
70
+ retry: 0,
71
+ refetchOnWindowFocus: false,
72
+ });
73
+ return {
74
+ kycStatus: data || null,
75
+ isLoadingKycStatus: isLoading,
76
+ kycStatusError: error,
77
+ refetchKycStatus: refetch,
78
+ };
79
+ }
80
+ function useCreateKycInquiry() {
81
+ const { address, getHeaders } = useWalletAuthHeaders();
82
+ const { mutateAsync, isPending } = (0, react_query_1.useMutation)({
83
+ mutationFn: async () => {
84
+ if (!address)
85
+ throw new Error("No wallet connected");
86
+ const headers = await getHeaders();
87
+ const response = await fetch(`${constants_1.ANYSPEND_MAINNET_BASE_URL}/kyc/inquiry`, {
88
+ method: "POST",
89
+ headers: { "Content-Type": "application/json", ...headers },
90
+ });
91
+ const json = await response.json();
92
+ if (!response.ok)
93
+ throw new Error(json.message || "Failed to create KYC inquiry");
94
+ return json.data;
95
+ },
96
+ });
97
+ return {
98
+ createInquiry: mutateAsync,
99
+ isCreatingInquiry: isPending,
100
+ };
101
+ }
102
+ function useVerifyKyc() {
103
+ const { address, getHeaders } = useWalletAuthHeaders();
104
+ const { mutateAsync, isPending } = (0, react_query_1.useMutation)({
105
+ mutationFn: async (inquiryId) => {
106
+ if (!address)
107
+ throw new Error("No wallet connected");
108
+ const headers = await getHeaders();
109
+ const response = await fetch(`${constants_1.ANYSPEND_MAINNET_BASE_URL}/kyc/verify`, {
110
+ method: "POST",
111
+ headers: { "Content-Type": "application/json", ...headers },
112
+ body: JSON.stringify({ inquiryId }),
113
+ });
114
+ const json = await response.json();
115
+ if (!response.ok)
116
+ throw new Error(json.message || "Failed to verify KYC");
117
+ return json.data;
118
+ },
119
+ });
120
+ return {
121
+ verifyKyc: mutateAsync,
122
+ isVerifying: isPending,
123
+ };
124
+ }
@@ -6,7 +6,7 @@ export declare const anyspendService: {
6
6
  getTokenList: (chainId: number, query: string) => Promise<components["schemas"]["Token"][]>;
7
7
  getToken: (chainId: number, tokenAddress: string) => Promise<components["schemas"]["Token"]>;
8
8
  getQuote: (req: GetQuoteRequest, partnerId?: string) => Promise<GetQuoteResponse>;
9
- createOrder: ({ recipientAddress, type, srcChain, dstChain, srcTokenAddress, dstTokenAddress, srcAmount, payload, onramp, metadata, creatorAddress, partnerId, clientReferenceId, visitorData, callbackMetadata, }: {
9
+ createOrder: ({ recipientAddress, type, srcChain, dstChain, srcTokenAddress, dstTokenAddress, srcAmount, payload, onramp, metadata, creatorAddress, partnerId, clientReferenceId, visitorData, callbackMetadata, feeOnTop, kycWalletHeaders, }: {
10
10
  recipientAddress: string;
11
11
  type: string;
12
12
  srcChain: number;
@@ -22,6 +22,9 @@ export declare const anyspendService: {
22
22
  clientReferenceId?: string;
23
23
  visitorData?: VisitorData;
24
24
  callbackMetadata?: Record<string, unknown>;
25
+ feeOnTop?: boolean;
26
+ /** Wallet signature auth headers for KYC lookup (stripe-web2 orders only). */
27
+ kycWalletHeaders?: Record<string, string>;
25
28
  }) => Promise<{
26
29
  success: boolean;
27
30
  message: string;
@@ -43,7 +43,7 @@ exports.anyspendService = {
43
43
  return data;
44
44
  },
45
45
  // Order related
46
- createOrder: async ({ recipientAddress, type, srcChain, dstChain, srcTokenAddress, dstTokenAddress, srcAmount, payload, onramp, metadata, creatorAddress, partnerId, clientReferenceId, visitorData, callbackMetadata, }) => {
46
+ createOrder: async ({ recipientAddress, type, srcChain, dstChain, srcTokenAddress, dstTokenAddress, srcAmount, payload, onramp, metadata, creatorAddress, partnerId, clientReferenceId, visitorData, callbackMetadata, feeOnTop, kycWalletHeaders, }) => {
47
47
  const accessToken = await app_1.default.authentication.getAccessToken();
48
48
  const response = await fetch(`${constants_1.ANYSPEND_MAINNET_BASE_URL}/orders`, {
49
49
  method: "POST",
@@ -52,6 +52,7 @@ exports.anyspendService = {
52
52
  ...(visitorData?.requestId && { "X-Fingerprint-Request-Id": visitorData.requestId }),
53
53
  ...(visitorData?.visitorId && { "X-Fingerprint-Visitor-Id": visitorData.visitorId }),
54
54
  ...(accessToken && { Authorization: `Bearer ${accessToken}` }),
55
+ ...kycWalletHeaders,
55
56
  },
56
57
  body: JSON.stringify({
57
58
  recipientAddress,
@@ -68,6 +69,7 @@ exports.anyspendService = {
68
69
  partnerId,
69
70
  ...(clientReferenceId && { clientReferenceId }),
70
71
  ...(callbackMetadata && { callbackMetadata }),
72
+ ...(feeOnTop != null && { feeOnTop }),
71
73
  }),
72
74
  });
73
75
  const data = await response.json();
@@ -168,7 +168,7 @@ function B3DynamicModal() {
168
168
  contentType?.type === "send" ||
169
169
  contentType?.type === "avatarEditor" ||
170
170
  contentType?.type === "notifications") &&
171
- "p-0", "mx-auto w-full max-w-md sm:max-w-lg"), hideCloseButton: hideCloseButton, hideGABranding: isAnySpendType, onEscapeKeyDown: !isClosable ? e => e.preventDefault() : undefined, onPointerDownOutside: !isClosable ? e => e.preventDefault() : undefined, onInteractOutside: !isClosable ? e => e.preventDefault() : undefined, children: [(0, jsx_runtime_1.jsx)(ModalTitle, { className: "sr-only hidden", children: contentType?.type || "Modal" }), (0, jsx_runtime_1.jsx)(ModalDescription, { className: "sr-only hidden", children: contentType?.type || "Modal Body" }), (0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("b3-modal-content no-scrollbar dark:bg-b3-background flex max-h-[90dvh] flex-col overflow-auto sm:max-h-[80dvh]"), children: [!hideCloseButton && ((0, jsx_runtime_1.jsxs)("button", { onClick: navigateBack, className: "flex items-center gap-2 px-6 py-4 text-gray-600 transition-colors hover:text-gray-900 dark:text-gray-400 dark:hover:text-white", children: [(0, jsx_runtime_1.jsxs)("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [(0, jsx_runtime_1.jsx)("path", { d: "M15.8337 10H4.16699", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }), (0, jsx_runtime_1.jsx)("path", { d: "M10.0003 15.8334L4.16699 10L10.0003 4.16669", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })] }), (0, jsx_runtime_1.jsx)("span", { className: "font-inter text-sm font-semibold", children: "Back" })] })), (0, jsx_runtime_1.jsx)("div", { className: "flex-1", children: renderContent() }), (0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { children: toasts.length > 0 && ((0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { initial: { height: 0 }, animate: { height: "auto" }, exit: { height: 0 }, transition: { duration: 0.3, ease: "easeInOut" }, className: "toast-section relative z-10 overflow-hidden bg-white dark:border-neutral-800 dark:bg-neutral-900", children: (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { initial: { opacity: 0, y: -10 }, animate: { opacity: 1, y: 0 }, exit: { opacity: 0, y: -10 }, transition: { duration: 0.2, delay: 0.1 }, className: "p-4 pt-0", children: (0, jsx_runtime_1.jsx)(index_1.ToastContainer, { toasts: toasts, onDismiss: removeToast, theme: theme }) }) })) })] })] }), isOpen && !isAnySpendType && ((0, jsx_runtime_1.jsx)("style", { children: `
171
+ "p-0", "mx-auto w-full max-w-md sm:max-w-lg"), hideCloseButton: hideCloseButton, hideGABranding: isAnySpendType, onEscapeKeyDown: !isClosable ? e => e.preventDefault() : undefined, children: [(0, jsx_runtime_1.jsx)(ModalTitle, { className: "sr-only hidden", children: contentType?.type || "Modal" }), (0, jsx_runtime_1.jsx)(ModalDescription, { className: "sr-only hidden", children: contentType?.type || "Modal Body" }), (0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("b3-modal-content no-scrollbar dark:bg-b3-background flex max-h-[90dvh] flex-col overflow-auto sm:max-h-[80dvh]"), children: [!hideCloseButton && ((0, jsx_runtime_1.jsxs)("button", { onClick: navigateBack, className: "flex items-center gap-2 px-6 py-4 text-gray-600 transition-colors hover:text-gray-900 dark:text-gray-400 dark:hover:text-white", children: [(0, jsx_runtime_1.jsxs)("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [(0, jsx_runtime_1.jsx)("path", { d: "M15.8337 10H4.16699", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }), (0, jsx_runtime_1.jsx)("path", { d: "M10.0003 15.8334L4.16699 10L10.0003 4.16669", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })] }), (0, jsx_runtime_1.jsx)("span", { className: "font-inter text-sm font-semibold", children: "Back" })] })), (0, jsx_runtime_1.jsx)("div", { className: "flex-1", children: renderContent() }), (0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { children: toasts.length > 0 && ((0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { initial: { height: 0 }, animate: { height: "auto" }, exit: { height: 0 }, transition: { duration: 0.3, ease: "easeInOut" }, className: "toast-section relative z-10 overflow-hidden bg-white dark:border-neutral-800 dark:bg-neutral-900", children: (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { initial: { opacity: 0, y: -10 }, animate: { opacity: 1, y: 0 }, exit: { opacity: 0, y: -10 }, transition: { duration: 0.2, delay: 0.1 }, className: "p-4 pt-0", children: (0, jsx_runtime_1.jsx)(index_1.ToastContainer, { toasts: toasts, onDismiss: removeToast, theme: theme }) }) })) })] })] }), isOpen && !isAnySpendType && ((0, jsx_runtime_1.jsx)("style", { children: `
172
172
  .modal-inner-content {
173
173
  transition: margin-bottom 0.3s ease-in-out;
174
174
  margin-bottom: ${toasts.length > 0 ? "0px" : "23px"} !important;
@@ -3,13 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const jsx_runtime_1 = require("react/jsx-runtime");
4
4
  const react_1 = require("../../../../global-account/react");
5
5
  const HomeIcon = () => {
6
- return ((0, jsx_runtime_1.jsx)("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M12.5227 1.33636C12.1804 1.24368 11.8196 1.24368 11.4773 1.33636C11.08 1.44395 10.7454 1.7066 10.4784 1.91623L10.4038 1.97465L3.54376 7.31012C3.16713 7.6024 2.83532 7.85991 2.58806 8.19421C2.37107 8.48759 2.20942 8.8181 2.11106 9.1695C1.99898 9.56992 1.99943 9.98993 1.99995 10.4667L2.00002 17.8385C2 18.3657 1.99998 18.8204 2.03059 19.195C2.06289 19.5904 2.1342 19.9836 2.327 20.362C2.61462 20.9264 3.07356 21.3854 3.63805 21.673C4.01643 21.8658 4.40964 21.9371 4.80499 21.9694C5.17956 22 5.63431 22 6.16145 22H17.8386C18.3657 22 18.8205 22 19.195 21.9694C19.5904 21.9371 19.9836 21.8658 20.362 21.673C20.9265 21.3854 21.3854 20.9264 21.673 20.362C21.8658 19.9836 21.9371 19.5904 21.9694 19.195C22.0001 18.8204 22 18.3657 22 17.8386L22.0001 10.4667C22.0006 9.98993 22.0011 9.56992 21.889 9.1695C21.7906 8.8181 21.629 8.48759 21.412 8.19421C21.1647 7.8599 20.8329 7.6024 20.4563 7.31011L13.5963 1.97465L13.5216 1.91623C13.2546 1.7066 12.9201 1.44395 12.5227 1.33636ZM8.00003 16C7.44775 16 7.00003 16.4477 7.00003 17C7.00003 17.5523 7.44775 18 8.00003 18H16C16.5523 18 17 17.5523 17 17C17 16.4477 16.5523 16 16 16H8.00003Z", fill: "currentColor" }) }));
6
+ return ((0, jsx_runtime_1.jsx)("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M12.5227 1.33636C12.1804 1.24368 11.8196 1.24368 11.4773 1.33636C11.08 1.44395 10.7454 1.7066 10.4784 1.91623L10.4038 1.97465L3.54376 7.31012C3.16713 7.6024 2.83532 7.85991 2.58806 8.19421C2.37107 8.48759 2.20942 8.8181 2.11106 9.1695C1.99898 9.56992 1.99943 9.98993 1.99995 10.4667L2.00002 17.8385C2 18.3657 1.99998 18.8204 2.03059 19.195C2.06289 19.5904 2.1342 19.9836 2.327 20.362C2.61462 20.9264 3.07356 21.3854 3.63805 21.673C4.01643 21.8658 4.40964 21.9371 4.80499 21.9694C5.17956 22 5.63431 22 6.16145 22H17.8386C18.3657 22 18.8205 22 19.195 21.9694C19.5904 21.9371 19.9836 21.8658 20.362 21.673C20.9265 21.3854 21.3854 20.9264 21.673 20.362C21.8658 19.9836 21.9371 19.5904 21.9694 19.195C22.0001 18.8204 22 18.3657 22 17.8386L22.0001 10.4667C22.0006 9.98993 22.0011 9.56992 21.889 9.1695C21.7906 8.8181 21.629 8.48759 21.412 8.19421C21.1647 7.8599 20.8329 7.6024 20.4563 7.31011L13.5963 1.97465L13.5216 1.91623C13.2546 1.7066 12.9201 1.44395 12.5227 1.33636ZM8.00003 16C7.44775 16 7.00003 16.4477 7.00003 17C7.00003 17.5523 7.44775 18 8.00003 18H16C16.5523 18 17 17.5523 17 17C17 16.4477 16.5523 16 16 16H8.00003Z", fill: "currentColor" }) }));
7
7
  };
8
8
  const SwapIcon = () => {
9
- return ((0, jsx_runtime_1.jsx)("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { d: "M20.4533 12.893C20.1755 15.5029 18.6968 17.9487 16.2498 19.3614C12.1843 21.7086 6.98576 20.3157 4.63855 16.2502L4.38855 15.8172M3.5465 11.107C3.8243 8.49711 5.30309 6.05138 7.75007 4.63862C11.8156 2.29141 17.0141 3.68434 19.3613 7.74983L19.6113 8.18285M3.49353 18.0661L4.22558 15.334L6.95763 16.0661M17.0428 7.93401L19.7748 8.66606L20.5069 5.93401", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }) }));
9
+ return ((0, jsx_runtime_1.jsx)("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { d: "M20.4533 12.893C20.1755 15.5029 18.6968 17.9487 16.2498 19.3614C12.1843 21.7086 6.98576 20.3157 4.63855 16.2502L4.38855 15.8172M3.5465 11.107C3.8243 8.49711 5.30309 6.05138 7.75007 4.63862C11.8156 2.29141 17.0141 3.68434 19.3613 7.74983L19.6113 8.18285M3.49353 18.0661L4.22558 15.334L6.95763 16.0661M17.0428 7.93401L19.7748 8.66606L20.5069 5.93401", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }));
10
10
  };
11
11
  const SettingsIcon = () => {
12
- return ((0, jsx_runtime_1.jsx)("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M19.286 15.9606C19.2272 15.6362 19.2669 15.3016 19.4 15C19.5268 14.7042 19.7372 14.452 20.0055 14.2743C20.2738 14.0966 20.5882 14.0013 20.91 14H21C21.5304 14 22.0391 13.7893 22.4142 13.4142C22.7893 13.0391 23 12.5304 23 12C23 11.4696 22.7893 10.9609 22.4142 10.5858C22.0391 10.2107 21.5304 10 21 10H20.83C20.5082 9.99872 20.1938 9.90337 19.9255 9.72569C19.6572 9.54802 19.4468 9.29577 19.32 9V8.92C19.1869 8.61838 19.1472 8.28381 19.206 7.95941C19.2648 7.63502 19.4195 7.33568 19.65 7.1L19.71 7.04C19.896 6.85425 20.0435 6.63368 20.1441 6.39088C20.2448 6.14808 20.2966 5.88783 20.2966 5.625C20.2966 5.36217 20.2448 5.10192 20.1441 4.85912C20.0435 4.61632 19.896 4.39575 19.71 4.21C19.5243 4.02405 19.3037 3.87653 19.0609 3.77588C18.8181 3.67523 18.5578 3.62343 18.295 3.62343C18.0322 3.62343 17.7719 3.67523 17.5291 3.77588C17.2863 3.87653 17.0657 4.02405 16.88 4.21L16.82 4.27C16.5843 4.50054 16.285 4.65519 15.9606 4.714C15.6362 4.77282 15.3016 4.73312 15 4.6C14.7042 4.47324 14.452 4.26276 14.2743 3.99447C14.0966 3.72618 14.0013 3.41179 14 3.09V3C14 2.46957 13.7893 1.96086 13.4142 1.58579C13.0391 1.21071 12.5304 1 12 1C11.4696 1 10.9609 1.21071 10.5858 1.58579C10.2107 1.96086 10 2.46957 10 3V3.17C9.99872 3.49179 9.90337 3.80618 9.72569 4.07447C9.54802 4.34276 9.29577 4.55324 9 4.68H8.92C8.61838 4.81312 8.28381 4.85282 7.95941 4.794C7.63502 4.73519 7.33568 4.58054 7.1 4.35L7.04 4.29C6.85425 4.10405 6.63368 3.95653 6.39088 3.85588C6.14808 3.75523 5.88783 3.70343 5.625 3.70343C5.36217 3.70343 5.10192 3.75523 4.85912 3.85588C4.61632 3.95653 4.39575 4.10405 4.21 4.29C4.02405 4.47575 3.87653 4.69632 3.77588 4.93912C3.67523 5.18192 3.62343 5.44217 3.62343 5.705C3.62343 5.96783 3.67523 6.22808 3.77588 6.47088C3.87653 6.71368 4.02405 6.93425 4.21 7.12L4.27 7.18C4.50054 7.41568 4.65519 7.71502 4.714 8.03941C4.77282 8.36381 4.73312 8.69838 4.6 9C4.48572 9.31074 4.28059 9.5799 4.0113 9.77251C3.742 9.96512 3.42099 10.0723 3.09 10.08H3C2.46957 10.08 1.96086 10.2907 1.58579 10.6658C1.21071 11.0409 1 11.5496 1 12.08C1 12.6104 1.21071 13.1191 1.58579 13.4942C1.96086 13.8693 2.46957 14.08 3 14.08H3.17C3.49179 14.0813 3.80618 14.1766 4.07447 14.3543C4.34276 14.532 4.55324 14.7842 4.68 15.08C4.81312 15.3816 4.85282 15.7162 4.794 16.0406C4.73519 16.365 4.58054 16.6643 4.35 16.9L4.29 16.96C4.10405 17.1457 3.95653 17.3663 3.85588 17.6091C3.75523 17.8519 3.70343 18.1122 3.70343 18.375C3.70343 18.6378 3.75523 18.8981 3.85588 19.1409C3.95653 19.3837 4.10405 19.6043 4.29 19.79C4.47575 19.976 4.69632 20.1235 4.93912 20.2241C5.18192 20.3248 5.44217 20.3766 5.705 20.3766C5.96783 20.3766 6.22808 20.3248 6.47088 20.2241C6.71368 20.1235 6.93425 19.976 7.12 19.79L7.18 19.73C7.41568 19.4995 7.71502 19.3448 8.03941 19.286C8.36381 19.2272 8.69838 19.2669 9 19.4C9.31074 19.5143 9.5799 19.7194 9.77251 19.9887C9.96512 20.258 10.0723 20.579 10.08 20.91V21C10.08 21.5304 10.2907 22.0391 10.6658 22.4142C11.0409 22.7893 11.5496 23 12.08 23C12.6104 23 13.1191 22.7893 13.4942 22.4142C13.8693 22.0391 14.08 21.5304 14.08 21V20.83C14.0813 20.5082 14.1766 20.1938 14.3543 19.9255C14.532 19.6572 14.7842 19.4468 15.08 19.32C15.3816 19.1869 15.7162 19.1472 16.0406 19.206C16.365 19.2648 16.6643 19.4195 16.9 19.65L16.96 19.71C17.1457 19.896 17.3663 20.0435 17.6091 20.1441C17.8519 20.2448 18.1122 20.2966 18.375 20.2966C18.6378 20.2966 18.8981 20.2448 19.1409 20.1441C19.3837 20.0435 19.6043 19.896 19.79 19.71C19.976 19.5243 20.1235 19.3037 20.2241 19.0609C20.3248 18.8181 20.3766 18.5578 20.3766 18.295C20.3766 18.0322 20.3248 17.7719 20.2241 17.5291C20.1235 17.2863 19.976 17.0657 19.79 16.88L19.73 16.82C19.4995 16.5843 19.3448 16.285 19.286 15.9606ZM15 12C15 13.6569 13.6569 15 12 15C10.3431 15 9 13.6569 9 12C9 10.3431 10.3431 9 12 9C13.6569 9 15 10.3431 15 12Z", fill: "currentColor" }) }));
12
+ return ((0, jsx_runtime_1.jsx)("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M19.286 15.9606C19.2272 15.6362 19.2669 15.3016 19.4 15C19.5268 14.7042 19.7372 14.452 20.0055 14.2743C20.2738 14.0966 20.5882 14.0013 20.91 14H21C21.5304 14 22.0391 13.7893 22.4142 13.4142C22.7893 13.0391 23 12.5304 23 12C23 11.4696 22.7893 10.9609 22.4142 10.5858C22.0391 10.2107 21.5304 10 21 10H20.83C20.5082 9.99872 20.1938 9.90337 19.9255 9.72569C19.6572 9.54802 19.4468 9.29577 19.32 9V8.92C19.1869 8.61838 19.1472 8.28381 19.206 7.95941C19.2648 7.63502 19.4195 7.33568 19.65 7.1L19.71 7.04C19.896 6.85425 20.0435 6.63368 20.1441 6.39088C20.2448 6.14808 20.2966 5.88783 20.2966 5.625C20.2966 5.36217 20.2448 5.10192 20.1441 4.85912C20.0435 4.61632 19.896 4.39575 19.71 4.21C19.5243 4.02405 19.3037 3.87653 19.0609 3.77588C18.8181 3.67523 18.5578 3.62343 18.295 3.62343C18.0322 3.62343 17.7719 3.67523 17.5291 3.77588C17.2863 3.87653 17.0657 4.02405 16.88 4.21L16.82 4.27C16.5843 4.50054 16.285 4.65519 15.9606 4.714C15.6362 4.77282 15.3016 4.73312 15 4.6C14.7042 4.47324 14.452 4.26276 14.2743 3.99447C14.0966 3.72618 14.0013 3.41179 14 3.09V3C14 2.46957 13.7893 1.96086 13.4142 1.58579C13.0391 1.21071 12.5304 1 12 1C11.4696 1 10.9609 1.21071 10.5858 1.58579C10.2107 1.96086 10 2.46957 10 3V3.17C9.99872 3.49179 9.90337 3.80618 9.72569 4.07447C9.54802 4.34276 9.29577 4.55324 9 4.68H8.92C8.61838 4.81312 8.28381 4.85282 7.95941 4.794C7.63502 4.73519 7.33568 4.58054 7.1 4.35L7.04 4.29C6.85425 4.10405 6.63368 3.95653 6.39088 3.85588C6.14808 3.75523 5.88783 3.70343 5.625 3.70343C5.36217 3.70343 5.10192 3.75523 4.85912 3.85588C4.61632 3.95653 4.39575 4.10405 4.21 4.29C4.02405 4.47575 3.87653 4.69632 3.77588 4.93912C3.67523 5.18192 3.62343 5.44217 3.62343 5.705C3.62343 5.96783 3.67523 6.22808 3.77588 6.47088C3.87653 6.71368 4.02405 6.93425 4.21 7.12L4.27 7.18C4.50054 7.41568 4.65519 7.71502 4.714 8.03941C4.77282 8.36381 4.73312 8.69838 4.6 9C4.48572 9.31074 4.28059 9.5799 4.0113 9.77251C3.742 9.96512 3.42099 10.0723 3.09 10.08H3C2.46957 10.08 1.96086 10.2907 1.58579 10.6658C1.21071 11.0409 1 11.5496 1 12.08C1 12.6104 1.21071 13.1191 1.58579 13.4942C1.96086 13.8693 2.46957 14.08 3 14.08H3.17C3.49179 14.0813 3.80618 14.1766 4.07447 14.3543C4.34276 14.532 4.55324 14.7842 4.68 15.08C4.81312 15.3816 4.85282 15.7162 4.794 16.0406C4.73519 16.365 4.58054 16.6643 4.35 16.9L4.29 16.96C4.10405 17.1457 3.95653 17.3663 3.85588 17.6091C3.75523 17.8519 3.70343 18.1122 3.70343 18.375C3.70343 18.6378 3.75523 18.8981 3.85588 19.1409C3.95653 19.3837 4.10405 19.6043 4.29 19.79C4.47575 19.976 4.69632 20.1235 4.93912 20.2241C5.18192 20.3248 5.44217 20.3766 5.705 20.3766C5.96783 20.3766 6.22808 20.3248 6.47088 20.2241C6.71368 20.1235 6.93425 19.976 7.12 19.79L7.18 19.73C7.41568 19.4995 7.71502 19.3448 8.03941 19.286C8.36381 19.2272 8.69838 19.2669 9 19.4C9.31074 19.5143 9.5799 19.7194 9.77251 19.9887C9.96512 20.258 10.0723 20.579 10.08 20.91V21C10.08 21.5304 10.2907 22.0391 10.6658 22.4142C11.0409 22.7893 11.5496 23 12.08 23C12.6104 23 13.1191 22.7893 13.4942 22.4142C13.8693 22.0391 14.08 21.5304 14.08 21V20.83C14.0813 20.5082 14.1766 20.1938 14.3543 19.9255C14.532 19.6572 14.7842 19.4468 15.08 19.32C15.3816 19.1869 15.7162 19.1472 16.0406 19.206C16.365 19.2648 16.6643 19.4195 16.9 19.65L16.96 19.71C17.1457 19.896 17.3663 20.0435 17.6091 20.1441C17.8519 20.2448 18.1122 20.2966 18.375 20.2966C18.6378 20.2966 18.8981 20.2448 19.1409 20.1441C19.3837 20.0435 19.6043 19.896 19.79 19.71C19.976 19.5243 20.1235 19.3037 20.2241 19.0609C20.3248 18.8181 20.3766 18.5578 20.3766 18.295C20.3766 18.0322 20.3248 17.7719 20.2241 17.5291C20.1235 17.2863 19.976 17.0657 19.79 16.88L19.73 16.82C19.4995 16.5843 19.3448 16.285 19.286 15.9606ZM15 12C15 13.6569 13.6569 15 12 15C10.3431 15 9 13.6569 9 12C9 10.3431 10.3431 9 12 9C13.6569 9 15 10.3431 15 12Z", fill: "currentColor" }) }));
13
13
  };
14
14
  const BottomNavigation = () => {
15
15
  const setB3ModalContentType = (0, react_1.useModalStore)(state => state.setB3ModalContentType);
@@ -19,7 +19,7 @@ function SignIn(props) {
19
19
  const { address: globalAddress, ensName, connectedSmartWallet, connectedEOAWallet, isActiveSmartWallet, isActiveEOAWallet, smartWalletIcon, } = (0, react_1.useAccountWallet)();
20
20
  const { data: walletImage } = (0, react_4.useWalletImage)(connectedEOAWallet?.id);
21
21
  const isMobile = (0, react_1.useIsMobile)();
22
- const { logout } = (0, react_1.useAuthentication)(partnerId);
22
+ const { logout } = (0, react_1.useAuthentication)(partnerId, { skipAutoConnect: true });
23
23
  const onDisconnect = async () => {
24
24
  await logout();
25
25
  };
@@ -17,16 +17,23 @@ const MAX_REFETCH_ATTEMPTS = 20;
17
17
  */
18
18
  function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin = false, source = "signInWithB3Button", signersEnabled = false, }) {
19
19
  const { automaticallySetFirstEoa } = (0, react_1.useB3Config)();
20
- const { user, logout } = (0, react_1.useAuthentication)(partnerId);
21
- // FIXME Logout before login to ensure a clean state
20
+ // skipAutoConnect: this component intentionally logs out on mount to show a fresh login screen.
21
+ // AuthenticationProvider is the sole owner of useAutoConnect to avoid competing auth cycles.
22
+ const { user, logout } = (0, react_1.useAuthentication)(partnerId, { skipAutoConnect: true });
23
+ // Tracks whether the pre-login logout has finished.
24
+ // We must not render ConnectEmbed until logout (wallet disconnect) completes,
25
+ // otherwise the wallet state disrupts ConnectEmbed causing a blank modal.
26
+ const [readyToShowLogin, setReadyToShowLogin] = (0, react_2.useState)(source === "requestPermissions");
22
27
  const hasLoggedOutRef = (0, react_2.useRef)(false);
23
28
  (0, react_2.useEffect)(() => {
24
29
  if (hasLoggedOutRef.current)
25
30
  return;
26
31
  if (source !== "requestPermissions") {
27
32
  debug("Logging out before login");
28
- logout();
29
33
  hasLoggedOutRef.current = true;
34
+ logout().finally(() => {
35
+ setReadyToShowLogin(true);
36
+ });
30
37
  }
31
38
  }, [source, logout]);
32
39
  const [step, setStep] = (0, react_2.useState)(source === "requestPermissions" ? null : "login");
@@ -231,8 +238,9 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
231
238
  content = ((0, jsx_runtime_1.jsx)(LoginStep_1.LoginStepContainer, { partnerId: partnerId, children: (0, jsx_runtime_1.jsx)("div", { className: "p-4 text-center text-red-500", children: refetchError }) }));
232
239
  }
233
240
  else if (step === "login") {
234
- // Show loading spinner
235
- if (isAuthenticating || (isFetchingSigners && step === "login") || source === "requestPermissions") {
241
+ // Show loading spinner while: authenticating, waiting for pre-login logout to finish,
242
+ // or fetching signers.
243
+ if (!readyToShowLogin || isAuthenticating || isFetchingSigners) {
236
244
  content = ((0, jsx_runtime_1.jsx)(LoginStep_1.LoginStepContainer, { partnerId: partnerId, children: (0, jsx_runtime_1.jsx)("div", { className: "my-8 flex min-h-[350px] items-center justify-center", children: (0, jsx_runtime_1.jsx)(react_1.Loading, { variant: "white", size: "lg" }) }) }));
237
245
  }
238
246
  else {
@@ -11,7 +11,7 @@ function SignInWithB3Privy({ onSuccess, onError, chain }) {
11
11
  const { isLoading, connectTw, fullToken } = (0, react_1.useHandleConnectWithPrivy)(chain, onSuccess);
12
12
  const setIsAuthenticating = (0, react_1.useAuthStore)(state => state.setIsAuthenticating);
13
13
  const setIsAuthenticated = (0, react_1.useAuthStore)(state => state.setIsAuthenticated);
14
- const { logout } = (0, react_1.useAuthentication)(partnerId);
14
+ const { logout } = (0, react_1.useAuthentication)(partnerId, { skipAutoConnect: true });
15
15
  debug("@@SignInWithB3Privy", {
16
16
  isLoading,
17
17
  fullToken,
@@ -19,5 +19,5 @@ interface LoginStepContainerProps {
19
19
  partnerId?: string;
20
20
  }
21
21
  export declare function LoginStepContainer({ children, partnerId }: LoginStepContainerProps): import("react/jsx-runtime").JSX.Element;
22
- export declare function LoginStep({ onSuccess, chain }: LoginStepProps): import("react/jsx-runtime").JSX.Element;
22
+ export declare function LoginStep({ onSuccess, chain }: LoginStepProps): import("react/jsx-runtime").JSX.Element | null;
23
23
  export {};
@@ -7,6 +7,7 @@ const react_1 = require("../../../../../global-account/react");
7
7
  const constants_1 = require("../../../../../shared/constants");
8
8
  const thirdweb_1 = require("../../../../../shared/utils/thirdweb");
9
9
  const react_2 = require("thirdweb/react");
10
+ const react_3 = require("react");
10
11
  const wallets_1 = require("thirdweb/wallets");
11
12
  function LoginStepContainer({ children, partnerId }) {
12
13
  const { data: partner } = (0, react_1.useQueryB3)("global-accounts-partners", "find", {
@@ -18,30 +19,17 @@ function LoginStepContainer({ children, partnerId }) {
18
19
  const partnerLogo = partner?.data?.[0]?.loginCustomization?.logoUrl;
19
20
  return ((0, jsx_runtime_1.jsxs)("div", { className: "bg-b3-react-background flex flex-col items-center justify-center pt-6", children: [partnerLogo && ((0, jsx_runtime_1.jsx)("img", { src: partnerLogo, alt: "Partner Logo", className: "partner-logo mb-6 h-12 w-auto object-contain" })), children] }));
20
21
  }
21
- function LoginStep({ onSuccess, chain }) {
22
- const { partnerId, theme } = (0, react_1.useB3Config)();
23
- const wallet = (0, wallets_1.ecosystemWallet)(constants_1.ecosystemWalletId, {
24
- partnerId: partnerId,
25
- });
26
- const { onConnect } = (0, react_1.useAuthentication)(partnerId);
27
- return ((0, jsx_runtime_1.jsx)(LoginStepContainer, { partnerId: partnerId, children: (0, jsx_runtime_1.jsx)(react_2.ConnectEmbed, { showThirdwebBranding: false, client: thirdweb_1.client, chain: chain, wallets: [wallet], theme: theme === "light"
28
- ? (0, react_2.lightTheme)({
29
- colors: {
30
- modalBg: "hsl(var(--b3-react-background))",
31
- },
32
- })
33
- : (0, react_2.darkTheme)({
34
- colors: {
35
- modalBg: "hsl(var(--b3-react-background))",
36
- },
37
- }), style: {
38
- width: "100%",
39
- height: "100%",
40
- border: 0,
41
- }, header: {
42
- title: "Sign in with B3",
43
- titleIcon: "https://cdn.b3.fun/b3_logo.svg",
44
- }, className: "b3-login-step", onConnect: async (wallet, allConnectedWallets) => {
22
+ /** Inner component that only mounts when partnerId is a non-empty string.
23
+ * Keeps all hooks unconditional without calling useAuthentication(""). */
24
+ function LoginStepContent({ onSuccess, chain, partnerId, theme, }) {
25
+ const wallet = (0, react_3.useMemo)(() => (0, wallets_1.ecosystemWallet)(constants_1.ecosystemWalletId, { partnerId }), [partnerId]);
26
+ // skipAutoConnect: AuthenticationProvider already owns the auto-connect instance.
27
+ // Creating another here would cause a second authentication cycle (another 401 attempt)
28
+ // that makes the modal flash between spinner and blank before finally showing the login form.
29
+ const { onConnect } = (0, react_1.useAuthentication)(partnerId, { skipAutoConnect: true });
30
+ return ((0, jsx_runtime_1.jsx)(LoginStepContainer, { partnerId: partnerId, children: (0, jsx_runtime_1.jsx)(react_2.ConnectEmbed, { showThirdwebBranding: false, autoConnect: false, client: thirdweb_1.client, chain: chain, wallets: [wallet], theme: theme === "light"
31
+ ? (0, react_2.lightTheme)({ colors: { modalBg: "hsl(var(--b3-react-background))" } })
32
+ : (0, react_2.darkTheme)({ colors: { modalBg: "hsl(var(--b3-react-background))" } }), style: { width: "100%", height: "100%", border: 0 }, header: { title: "Sign in with B3", titleIcon: "https://cdn.b3.fun/b3_logo.svg" }, className: "b3-login-step", onConnect: async (wallet, allConnectedWallets) => {
45
33
  await onConnect(wallet, allConnectedWallets);
46
34
  const account = wallet.getAccount();
47
35
  if (!account)
@@ -49,3 +37,12 @@ function LoginStep({ onSuccess, chain }) {
49
37
  await onSuccess(account);
50
38
  } }) }));
51
39
  }
40
+ function LoginStep({ onSuccess, chain }) {
41
+ const { partnerId, theme } = (0, react_1.useB3Config)();
42
+ // partnerId may be undefined during the brief B3Provider hydration window.
43
+ // Return null rather than rendering ConnectEmbed with an invalid ecosystem
44
+ // wallet config (which causes a blank screen).
45
+ if (!partnerId)
46
+ return null;
47
+ return (0, jsx_runtime_1.jsx)(LoginStepContent, { onSuccess: onSuccess, chain: chain, partnerId: partnerId, theme: theme });
48
+ }
@@ -16,7 +16,7 @@ function LoginStepCustom({ onSuccess, onError, chain, strategies, maxInitialWall
16
16
  const { connect } = (0, react_1.useConnect)(partnerId, chain);
17
17
  const setIsAuthenticating = (0, react_1.useAuthStore)(state => state.setIsAuthenticating);
18
18
  const setIsAuthenticated = (0, react_1.useAuthStore)(state => state.setIsAuthenticated);
19
- const { logout } = (0, react_1.useAuthentication)(partnerId);
19
+ const { logout } = (0, react_1.useAuthentication)(partnerId, { skipAutoConnect: true });
20
20
  const { connect: connectTW } = (0, react_3.useConnect)();
21
21
  // Split strategies into auth and wallet types
22
22
  const authStrategies = strategies.filter(s => !(0, react_1.isWalletType)(s));
@@ -44,7 +44,7 @@ function useAuth() {
44
44
  const useAutoConnectLoadingPrevious = (0, react_2.useRef)(false);
45
45
  const referralCode = (0, useSearchParamsSSR_1.useSearchParam)("referralCode");
46
46
  const { partnerId } = (0, react_1.useB3Config)();
47
- const wagmiConfig = (0, createWagmiConfig_1.createWagmiConfig)({ partnerId });
47
+ const wagmiConfig = (0, createWagmiConfig_1.getCachedWagmiConfig)({ partnerId });
48
48
  const { connect } = (0, wagmi_1.useConnect)();
49
49
  const activeWagmiAccount = (0, wagmi_1.useAccount)();
50
50
  const { switchAccount } = (0, wagmi_1.useSwitchAccount)();
@@ -1,6 +1,8 @@
1
1
  import { Wallet } from "thirdweb/wallets";
2
2
  import { preAuthenticate } from "thirdweb/wallets/in-app";
3
- export declare function useAuthentication(partnerId: string): {
3
+ export declare function useAuthentication(partnerId: string, { skipAutoConnect }?: {
4
+ skipAutoConnect?: boolean;
5
+ }): {
4
6
  logout: (callback?: () => void) => Promise<void>;
5
7
  isAuthenticated: boolean;
6
8
  isReady: boolean;
@@ -21,11 +21,26 @@ const createWagmiConfig_1 = require("../utils/createWagmiConfig");
21
21
  const useTWAuth_1 = require("./useTWAuth");
22
22
  const useUserQuery_1 = require("./useUserQuery");
23
23
  const debug = (0, debug_1.debugB3React)("useAuthentication");
24
- function useAuthentication(partnerId) {
24
+ function useAuthentication(partnerId, { skipAutoConnect = false } = {}) {
25
25
  const { onConnectCallback, onLogoutCallback } = (0, react_2.useContext)(LocalSDKProvider_1.LocalSDKContext);
26
26
  const { disconnect } = (0, react_3.useDisconnect)();
27
27
  const wallets = (0, react_3.useConnectedWallets)();
28
+ // Keep refs so logout() always disconnects current wallets, not stale closure values.
29
+ // autoConnectCore captures onConnect (and thus logout) from the first render before wallets
30
+ // are populated — without these refs, logout() would capture wallets=[] and disconnect nothing.
31
+ const walletsRef = (0, react_2.useRef)(wallets);
32
+ (0, react_2.useEffect)(() => {
33
+ walletsRef.current = wallets;
34
+ }, [wallets]);
28
35
  const activeWallet = (0, react_3.useActiveWallet)();
36
+ // Track the active wallet by ref so logout() can disconnect the exact reference
37
+ // stored in thirdweb's activeWalletStore. walletsRef.current (from useConnectedWallets)
38
+ // may hold a different object reference than what thirdweb considers "active",
39
+ // causing the identity check in onWalletDisconnect to fail silently.
40
+ const activeWalletRef = (0, react_2.useRef)(activeWallet);
41
+ (0, react_2.useEffect)(() => {
42
+ activeWalletRef.current = activeWallet;
43
+ }, [activeWallet]);
29
44
  const isAuthenticated = (0, react_1.useAuthStore)(state => state.isAuthenticated);
30
45
  const setIsAuthenticated = (0, react_1.useAuthStore)(state => state.setIsAuthenticated);
31
46
  const setIsConnected = (0, react_1.useAuthStore)(state => state.setIsConnected);
@@ -132,21 +147,29 @@ function useAuthentication(partnerId) {
132
147
  }
133
148
  }, [activeWallet, partnerId, authenticate, setIsAuthenticated, setIsAuthenticating, setUser, setHasStartedConnecting]);
134
149
  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);
150
+ // Only disconnect ecosystem/smart wallets, preserve EOA wallets (e.g. MetaMask)
151
+ // so they remain available after re-login.
152
+ // Use walletsRef.current (not the stale closure value) so we always get current wallets —
153
+ // autoConnectCore captures logout from the first render when wallets is still [].
154
+ walletsRef.current.forEach(wallet => {
155
+ debug("@@logout:wallet", wallet.id);
156
+ if (wallet.id.startsWith("ecosystem.") || wallet.id === "smart") {
157
+ disconnect(wallet);
158
+ }
144
159
  });
145
- // Delete localStorage thirdweb:connected-wallet-ids
146
- // https://npc-labs.slack.com/archives/C070E6HNG85/p1750185115273099
160
+ // Always disconnect the active wallet to clear thirdweb's activeAccountStore.
161
+ // Without this, any auto-reconnected wallet (e.g. Coinbase Wallet, MetaMask)
162
+ // keeps activeAccount set, and ConnectEmbed renders show=false (blank modal).
163
+ // We use the exact reference from activeWalletRef because thirdweb's
164
+ // onWalletDisconnect uses strict identity (===) to decide whether to clear
165
+ // activeAccountStore.
166
+ if (activeWalletRef.current) {
167
+ debug("@@logout:disconnecting active wallet", activeWalletRef.current.id);
168
+ disconnect(activeWalletRef.current);
169
+ }
170
+ // Clear user-specific storage but preserve wallet connection state
171
+ // so EOA wallets (e.g. MetaMask) can auto-reconnect on next login
147
172
  if (typeof localStorage !== "undefined") {
148
- localStorage.removeItem("thirdweb:connected-wallet-ids");
149
- localStorage.removeItem("wagmi.store");
150
173
  localStorage.removeItem("lastAuthProvider");
151
174
  localStorage.removeItem("b3-user");
152
175
  }
@@ -154,33 +177,58 @@ function useAuthentication(partnerId) {
154
177
  debug("@@logout:loggedOut");
155
178
  setIsAuthenticated(false);
156
179
  setIsConnected(false);
180
+ // Reset isAuthenticating so any in-flight page-load auto-connect that set it true
181
+ // does not keep the login modal spinner stuck after logout() is called.
182
+ setIsAuthenticating(false);
157
183
  setUser();
158
184
  callback?.();
159
185
  if (onLogoutCallback) {
160
186
  await onLogoutCallback();
161
187
  }
162
- }, [activeWallet, disconnect, wallets, setIsAuthenticated, setUser, setIsConnected, onLogoutCallback]);
188
+ },
189
+ // wallets intentionally omitted — we use walletsRef.current so this callback stays stable
190
+ // and always operates on current wallets even when captured in stale closures.
191
+ // eslint-disable-next-line react-hooks/exhaustive-deps
192
+ [disconnect, setIsAuthenticated, setIsAuthenticating, setUser, setIsConnected, onLogoutCallback]);
163
193
  const onConnect = (0, react_2.useCallback)(async (_walleAutoConnectedWith, allConnectedWallets) => {
164
194
  debug("@@useAuthentication:onConnect", { _walleAutoConnectedWith, allConnectedWallets });
195
+ const ecosystemWalletToDisconnect = allConnectedWallets.find(w => w.id.startsWith("ecosystem."));
165
196
  try {
166
- const wallet = allConnectedWallets.find(wallet => wallet.id.startsWith("ecosystem."));
167
- if (!wallet) {
197
+ if (!ecosystemWalletToDisconnect) {
168
198
  throw new Error("No smart wallet found during auto-connect");
169
199
  }
170
- debug("@@useAuthentication:onConnect", { wallet });
200
+ debug("@@useAuthentication:onConnect", { wallet: ecosystemWalletToDisconnect });
171
201
  setHasStartedConnecting(true);
172
202
  setIsConnected(true);
173
203
  setIsAuthenticating(true);
174
- await setActiveWallet(wallet);
175
- const userAuth = await authenticateUser(wallet);
204
+ await setActiveWallet(ecosystemWalletToDisconnect);
205
+ const userAuth = await authenticateUser(ecosystemWalletToDisconnect);
176
206
  if (userAuth && onConnectCallback) {
177
- await onConnectCallback(wallet, userAuth.accessToken);
207
+ await onConnectCallback(ecosystemWalletToDisconnect, userAuth.accessToken);
178
208
  }
179
209
  }
180
210
  catch (error) {
181
211
  debug("@@useAuthentication:onConnect:failed", { error });
182
212
  setIsAuthenticated(false);
183
213
  setUser(undefined);
214
+ // Directly disconnect the ecosystem wallet we set active above.
215
+ // We can't rely on logout()'s activeWalletRef here because it's updated
216
+ // via useEffect (deferred until after paint), but this callback may run
217
+ // entirely within a single React commit cycle — before the ref updates.
218
+ if (ecosystemWalletToDisconnect) {
219
+ debug("@@useAuthentication:onConnect:disconnecting ecosystem wallet", ecosystemWalletToDisconnect.id);
220
+ disconnect(ecosystemWalletToDisconnect);
221
+ }
222
+ // Also disconnect the wallet that autoConnectCore set as active.
223
+ // When only a non-ecosystem wallet (e.g. MetaMask) auto-reconnects,
224
+ // ecosystemWalletToDisconnect is undefined, so the block above is skipped.
225
+ // But autoConnectCore already set this wallet as thirdweb's activeWallet,
226
+ // leaving activeAccount set. ConnectEmbed checks show = !activeAccount,
227
+ // so if we don't clear it, the login form renders blank.
228
+ if (_walleAutoConnectedWith && _walleAutoConnectedWith !== ecosystemWalletToDisconnect) {
229
+ debug("@@useAuthentication:onConnect:disconnecting auto-connected wallet", _walleAutoConnectedWith.id);
230
+ disconnect(_walleAutoConnectedWith);
231
+ }
184
232
  await logout();
185
233
  }
186
234
  finally {
@@ -195,6 +243,7 @@ function useAuthentication(partnerId) {
195
243
  isAuthenticated,
196
244
  isAuthenticating,
197
245
  isConnected,
246
+ disconnect,
198
247
  setHasStartedConnecting,
199
248
  setIsConnected,
200
249
  setIsAuthenticating,
@@ -207,23 +256,32 @@ function useAuthentication(partnerId) {
207
256
  ]);
208
257
  const { isLoading: useAutoConnectLoading } = (0, react_3.useAutoConnect)({
209
258
  client: thirdweb_1.client,
210
- wallets: [wallet],
259
+ // When skipAutoConnect is true (e.g. LoginStepContent, SignInWithB3Flow), pass an empty
260
+ // wallets array so useAutoConnect completes immediately without firing onConnect.
261
+ // Only AuthenticationProvider (the primary instance) should own auto-connect.
262
+ wallets: skipAutoConnect ? [] : [wallet],
211
263
  onConnect,
212
264
  onTimeout: () => {
265
+ if (skipAutoConnect)
266
+ return;
213
267
  logout().catch(error => {
214
268
  debug("@@useAuthentication:logout on timeout failed", { error });
215
269
  });
216
270
  },
217
271
  });
218
272
  /**
219
- * useAutoConnectLoading starts as false
273
+ * useAutoConnectLoading starts as false.
274
+ * Only the primary (non-skip) instance manages isAuthenticating via this effect
275
+ * to avoid race conditions when multiple useAuthentication instances are mounted.
220
276
  */
221
277
  (0, react_2.useEffect)(() => {
278
+ if (skipAutoConnect)
279
+ return;
222
280
  if (!useAutoConnectLoading && useAutoConnectLoadingPrevious.current && !hasStartedConnecting) {
223
281
  setIsAuthenticating(false);
224
282
  }
225
283
  useAutoConnectLoadingPrevious.current = useAutoConnectLoading;
226
- }, [useAutoConnectLoading, hasStartedConnecting, setIsAuthenticating]);
284
+ }, [useAutoConnectLoading, hasStartedConnecting, setIsAuthenticating, skipAutoConnect]);
227
285
  const isReady = isAuthenticated && !isAuthenticating;
228
286
  return {
229
287
  logout,
@@ -68,7 +68,8 @@ function useGetAllTWSigners({ chain, accountAddress, queryOptions }) {
68
68
  });
69
69
  return result;
70
70
  },
71
- enabled: Boolean(chain && accountAddress),
71
+ // Respect queryOptions.enabled if explicitly set (e.g. signersEnabled=false from SignInWithB3Flow)
72
+ enabled: queryOptions?.enabled !== false && Boolean(chain && accountAddress),
72
73
  refetchOnMount: true,
73
74
  refetchOnWindowFocus: true,
74
75
  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
@@ -39,4 +39,6 @@ exports.useModalStore = (0, zustand_1.create)(set => ({
39
39
  setClosable: (closable) => set(state => ({
40
40
  contentType: state.contentType ? { ...state.contentType, closable } : null,
41
41
  })),
42
+ personaActive: false,
43
+ setPersonaActive: (active) => set({ personaActive: active }),
42
44
  }));