@b3dotfun/sdk 0.1.70-alpha.2 → 0.1.70-alpha.21

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 (355) hide show
  1. package/README.md +3 -3
  2. package/constants/chains/b3Chain.js +3 -1
  3. package/dist/cjs/anyspend/constants/rpc.d.ts +3 -1
  4. package/dist/cjs/anyspend/constants/rpc.js +6 -2
  5. package/dist/cjs/anyspend/react/components/AnySpend.d.ts +9 -1
  6. package/dist/cjs/anyspend/react/components/AnySpend.js +123 -46
  7. package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +8 -10
  8. package/dist/cjs/anyspend/react/components/AnySpendDeposit.d.ts +15 -3
  9. package/dist/cjs/anyspend/react/components/AnySpendDeposit.js +78 -25
  10. package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +32 -13
  11. package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.js +32 -10
  12. package/dist/cjs/anyspend/react/components/QRDeposit.d.ts +22 -3
  13. package/dist/cjs/anyspend/react/components/QRDeposit.js +25 -16
  14. package/dist/cjs/anyspend/react/components/checkout/CryptoPayPanel.js +18 -11
  15. package/dist/cjs/anyspend/react/components/common/PureTransferView.d.ts +30 -0
  16. package/dist/cjs/anyspend/react/components/common/PureTransferView.js +64 -0
  17. package/dist/cjs/anyspend/react/components/common/TokenBalance.js +4 -5
  18. package/dist/cjs/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +3 -3
  19. package/dist/cjs/anyspend/react/hooks/useSigMint.d.ts +1 -1
  20. package/dist/cjs/anyspend/utils/address.d.ts +2 -1
  21. package/dist/cjs/anyspend/utils/address.js +12 -9
  22. package/dist/cjs/anyspend/utils/chain.d.ts +84 -1
  23. package/dist/cjs/anyspend/utils/chain.js +73 -3
  24. package/dist/cjs/anyspend/utils/token.d.ts +2 -0
  25. package/dist/cjs/anyspend/utils/token.js +15 -1
  26. package/dist/cjs/app.shared.d.ts +9 -1
  27. package/dist/cjs/app.shared.js +19 -0
  28. package/dist/cjs/global-account/app.native.d.ts +1 -1
  29. package/dist/cjs/global-account/better-auth-client.d.ts +3314 -36
  30. package/dist/cjs/global-account/better-auth-client.js +28 -3
  31. package/dist/cjs/global-account/bsmnt.d.ts +2 -2
  32. package/dist/cjs/global-account/bsmnt.native.d.ts +1 -1
  33. package/dist/cjs/global-account/client-manager.d.ts +7 -5
  34. package/dist/cjs/global-account/client-manager.js +51 -4
  35. package/dist/cjs/global-account/react/components/AvatarEditor/AvatarEditor.js +6 -11
  36. package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +11 -0
  37. package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.js +12 -0
  38. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +12 -2
  39. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +25 -3
  40. package/dist/cjs/global-account/react/components/B3Provider/BetterAuthProvider.js +45 -4
  41. package/dist/cjs/global-account/react/components/B3Provider/RelayKitProviderWrapper.d.ts +1 -2
  42. package/dist/cjs/global-account/react/components/B3Provider/RelayKitProviderWrapper.js +11 -5
  43. package/dist/cjs/global-account/react/components/ManageAccount/ContentTokens.js +23 -15
  44. package/dist/cjs/global-account/react/components/ManageAccount/NFTContent.js +2 -2
  45. package/dist/cjs/global-account/react/components/ManageAccount/ProfileSection.js +8 -6
  46. package/dist/cjs/global-account/react/components/ManageAccount/SettingsProfileCard.js +1 -1
  47. package/dist/cjs/global-account/react/components/ManageAccount/TokenContent.js +17 -8
  48. package/dist/cjs/global-account/react/components/Send/Send.js +15 -11
  49. package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthSignIn.js +3 -1
  50. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +1 -5
  51. package/dist/cjs/global-account/react/components/SignInWithB3/components/AuthButton.js +2 -1
  52. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.js +1 -0
  53. package/dist/cjs/global-account/react/components/SignInWithB3/utils/signInUtils.d.ts +3 -2
  54. package/dist/cjs/global-account/react/components/SignInWithB3/utils/signInUtils.js +3 -3
  55. package/dist/cjs/global-account/react/components/index.d.ts +1 -1
  56. package/dist/cjs/global-account/react/components/index.js +3 -3
  57. package/dist/cjs/global-account/react/hooks/index.d.ts +2 -3
  58. package/dist/cjs/global-account/react/hooks/index.js +7 -10
  59. package/dist/cjs/global-account/react/hooks/useAuth.d.ts +5 -4
  60. package/dist/cjs/global-account/react/hooks/useAuth.js +1 -0
  61. package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +3 -2
  62. package/dist/cjs/global-account/react/hooks/useAuthentication.js +2 -1
  63. package/dist/cjs/global-account/react/hooks/useBetterAuth.d.ts +1657 -22
  64. package/dist/cjs/global-account/react/hooks/useBetterAuth.js +7 -7
  65. package/dist/cjs/global-account/react/hooks/useClient.d.ts +3 -3
  66. package/dist/cjs/global-account/react/hooks/useFirstEOA.d.ts +4 -7666
  67. package/dist/cjs/global-account/react/hooks/useFirstEOA.js +1 -0
  68. package/dist/cjs/global-account/react/hooks/useNativeBalance.js +2 -2
  69. package/dist/cjs/global-account/react/hooks/usePortfolioBalance.d.ts +15 -0
  70. package/dist/cjs/global-account/react/hooks/usePortfolioBalance.js +76 -0
  71. package/dist/cjs/global-account/react/hooks/usePortfolioCollectibles.d.ts +12 -0
  72. package/dist/cjs/global-account/react/hooks/usePortfolioCollectibles.js +178 -0
  73. package/dist/cjs/global-account/react/hooks/useSiwe.d.ts +1 -1
  74. package/dist/cjs/global-account/react/hooks/useSiwe.native.d.ts +1 -1
  75. package/dist/cjs/global-account/react/hooks/useTWAuth.d.ts +1 -1
  76. package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.d.ts +1 -0
  77. package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +37 -27
  78. package/dist/cjs/global-account/react/stores/useModalStore.d.ts +14 -2
  79. package/dist/cjs/global-account/types/b3-api.types.d.ts +5 -0
  80. package/dist/cjs/global-account/types/feature-flags.d.ts +5 -5
  81. package/dist/cjs/notifications/services/api.js +1 -0
  82. package/dist/cjs/shared/constants/chains/b3Chain.d.ts +30 -54
  83. package/dist/cjs/shared/constants/chains/b3Chain.js +5 -41
  84. package/dist/cjs/shared/constants/chains/supported.d.ts +1 -49
  85. package/dist/cjs/shared/constants/chains/supported.js +8 -36
  86. package/dist/cjs/shared/constants/index.d.ts +4 -0
  87. package/dist/cjs/shared/utils/chain-transformers.d.ts +4 -4
  88. package/dist/cjs/shared/utils/chain-transformers.js +38 -37
  89. package/dist/cjs/shared/utils/thirdweb-insights.js +2 -2
  90. package/dist/cjs/shared/utils/upload.d.ts +9 -0
  91. package/dist/cjs/shared/utils/upload.js +34 -0
  92. package/dist/cjs/shared/utils/zerionPositions.d.ts +96 -0
  93. package/dist/cjs/shared/utils/zerionPositions.js +188 -0
  94. package/dist/esm/anyspend/constants/rpc.d.ts +3 -1
  95. package/dist/esm/anyspend/constants/rpc.js +5 -1
  96. package/dist/esm/anyspend/react/components/AnySpend.d.ts +9 -1
  97. package/dist/esm/anyspend/react/components/AnySpend.js +124 -47
  98. package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +9 -11
  99. package/dist/esm/anyspend/react/components/AnySpendDeposit.d.ts +15 -3
  100. package/dist/esm/anyspend/react/components/AnySpendDeposit.js +80 -27
  101. package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +33 -14
  102. package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.js +33 -11
  103. package/dist/esm/anyspend/react/components/QRDeposit.d.ts +22 -3
  104. package/dist/esm/anyspend/react/components/QRDeposit.js +27 -18
  105. package/dist/esm/anyspend/react/components/checkout/CryptoPayPanel.js +21 -14
  106. package/dist/esm/anyspend/react/components/common/PureTransferView.d.ts +30 -0
  107. package/dist/esm/anyspend/react/components/common/PureTransferView.js +61 -0
  108. package/dist/esm/anyspend/react/components/common/TokenBalance.js +6 -7
  109. package/dist/esm/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +3 -3
  110. package/dist/esm/anyspend/react/hooks/useSigMint.d.ts +1 -1
  111. package/dist/esm/anyspend/utils/address.d.ts +2 -1
  112. package/dist/esm/anyspend/utils/address.js +9 -6
  113. package/dist/esm/anyspend/utils/chain.d.ts +84 -1
  114. package/dist/esm/anyspend/utils/chain.js +73 -5
  115. package/dist/esm/anyspend/utils/token.d.ts +2 -0
  116. package/dist/esm/anyspend/utils/token.js +13 -0
  117. package/dist/esm/app.shared.d.ts +9 -1
  118. package/dist/esm/app.shared.js +17 -0
  119. package/dist/esm/global-account/app.native.d.ts +1 -1
  120. package/dist/esm/global-account/better-auth-client.d.ts +3314 -36
  121. package/dist/esm/global-account/better-auth-client.js +27 -4
  122. package/dist/esm/global-account/bsmnt.d.ts +2 -2
  123. package/dist/esm/global-account/bsmnt.native.d.ts +1 -1
  124. package/dist/esm/global-account/client-manager.d.ts +7 -5
  125. package/dist/esm/global-account/client-manager.js +51 -5
  126. package/dist/esm/global-account/react/components/AvatarEditor/AvatarEditor.js +6 -11
  127. package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +11 -0
  128. package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.js +11 -0
  129. package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +12 -2
  130. package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +26 -4
  131. package/dist/esm/global-account/react/components/B3Provider/BetterAuthProvider.js +46 -5
  132. package/dist/esm/global-account/react/components/B3Provider/RelayKitProviderWrapper.d.ts +1 -2
  133. package/dist/esm/global-account/react/components/B3Provider/RelayKitProviderWrapper.js +11 -5
  134. package/dist/esm/global-account/react/components/ManageAccount/ContentTokens.js +24 -16
  135. package/dist/esm/global-account/react/components/ManageAccount/NFTContent.js +3 -3
  136. package/dist/esm/global-account/react/components/ManageAccount/ProfileSection.js +9 -7
  137. package/dist/esm/global-account/react/components/ManageAccount/SettingsProfileCard.js +1 -1
  138. package/dist/esm/global-account/react/components/ManageAccount/TokenContent.js +18 -9
  139. package/dist/esm/global-account/react/components/Send/Send.js +16 -12
  140. package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthSignIn.js +3 -1
  141. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +1 -5
  142. package/dist/esm/global-account/react/components/SignInWithB3/components/AuthButton.js +2 -1
  143. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.js +1 -0
  144. package/dist/esm/global-account/react/components/SignInWithB3/utils/signInUtils.d.ts +3 -2
  145. package/dist/esm/global-account/react/components/SignInWithB3/utils/signInUtils.js +3 -3
  146. package/dist/esm/global-account/react/components/index.d.ts +1 -1
  147. package/dist/esm/global-account/react/components/index.js +1 -1
  148. package/dist/esm/global-account/react/hooks/index.d.ts +2 -3
  149. package/dist/esm/global-account/react/hooks/index.js +2 -3
  150. package/dist/esm/global-account/react/hooks/useAuth.d.ts +5 -4
  151. package/dist/esm/global-account/react/hooks/useAuth.js +1 -0
  152. package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +3 -2
  153. package/dist/esm/global-account/react/hooks/useAuthentication.js +2 -1
  154. package/dist/esm/global-account/react/hooks/useBetterAuth.d.ts +1657 -22
  155. package/dist/esm/global-account/react/hooks/useBetterAuth.js +8 -8
  156. package/dist/esm/global-account/react/hooks/useClient.d.ts +3 -3
  157. package/dist/esm/global-account/react/hooks/useFirstEOA.d.ts +4 -7666
  158. package/dist/esm/global-account/react/hooks/useFirstEOA.js +1 -0
  159. package/dist/esm/global-account/react/hooks/useNativeBalance.js +1 -1
  160. package/dist/esm/global-account/react/hooks/usePortfolioBalance.d.ts +15 -0
  161. package/dist/esm/global-account/react/hooks/usePortfolioBalance.js +72 -0
  162. package/dist/esm/global-account/react/hooks/usePortfolioCollectibles.d.ts +12 -0
  163. package/dist/esm/global-account/react/hooks/usePortfolioCollectibles.js +175 -0
  164. package/dist/esm/global-account/react/hooks/useSiwe.d.ts +1 -1
  165. package/dist/esm/global-account/react/hooks/useSiwe.native.d.ts +1 -1
  166. package/dist/esm/global-account/react/hooks/useTWAuth.d.ts +1 -1
  167. package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.d.ts +1 -0
  168. package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +37 -27
  169. package/dist/esm/global-account/react/stores/useModalStore.d.ts +14 -2
  170. package/dist/esm/global-account/types/b3-api.types.d.ts +5 -0
  171. package/dist/esm/global-account/types/feature-flags.d.ts +5 -5
  172. package/dist/esm/notifications/services/api.js +1 -0
  173. package/dist/esm/shared/constants/chains/b3Chain.d.ts +30 -54
  174. package/dist/esm/shared/constants/chains/b3Chain.js +4 -38
  175. package/dist/esm/shared/constants/chains/supported.d.ts +1 -49
  176. package/dist/esm/shared/constants/chains/supported.js +7 -35
  177. package/dist/esm/shared/constants/index.d.ts +4 -0
  178. package/dist/esm/shared/utils/chain-transformers.d.ts +4 -4
  179. package/dist/esm/shared/utils/chain-transformers.js +38 -37
  180. package/dist/esm/shared/utils/thirdweb-insights.js +2 -2
  181. package/dist/esm/shared/utils/upload.d.ts +9 -0
  182. package/dist/esm/shared/utils/upload.js +31 -0
  183. package/dist/esm/shared/utils/zerionPositions.d.ts +96 -0
  184. package/dist/esm/shared/utils/zerionPositions.js +180 -0
  185. package/dist/styles/index.css +1 -1
  186. package/dist/types/anyspend/constants/rpc.d.ts +3 -1
  187. package/dist/types/anyspend/react/components/AnySpend.d.ts +9 -1
  188. package/dist/types/anyspend/react/components/AnySpendDeposit.d.ts +15 -3
  189. package/dist/types/anyspend/react/components/QRDeposit.d.ts +22 -3
  190. package/dist/types/anyspend/react/components/common/PureTransferView.d.ts +30 -0
  191. package/dist/types/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +3 -3
  192. package/dist/types/anyspend/react/hooks/useSigMint.d.ts +1 -1
  193. package/dist/types/anyspend/utils/address.d.ts +2 -1
  194. package/dist/types/anyspend/utils/chain.d.ts +84 -1
  195. package/dist/types/anyspend/utils/token.d.ts +2 -0
  196. package/dist/types/app.shared.d.ts +9 -1
  197. package/dist/types/global-account/app.native.d.ts +1 -1
  198. package/dist/types/global-account/better-auth-client.d.ts +3314 -36
  199. package/dist/types/global-account/bsmnt.d.ts +2 -2
  200. package/dist/types/global-account/bsmnt.native.d.ts +1 -1
  201. package/dist/types/global-account/client-manager.d.ts +7 -5
  202. package/dist/types/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +11 -0
  203. package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +12 -2
  204. package/dist/types/global-account/react/components/B3Provider/RelayKitProviderWrapper.d.ts +1 -2
  205. package/dist/types/global-account/react/components/SignInWithB3/utils/signInUtils.d.ts +3 -2
  206. package/dist/types/global-account/react/components/index.d.ts +1 -1
  207. package/dist/types/global-account/react/hooks/index.d.ts +2 -3
  208. package/dist/types/global-account/react/hooks/useAuth.d.ts +5 -4
  209. package/dist/types/global-account/react/hooks/useAuthentication.d.ts +3 -2
  210. package/dist/types/global-account/react/hooks/useBetterAuth.d.ts +1657 -22
  211. package/dist/types/global-account/react/hooks/useClient.d.ts +3 -3
  212. package/dist/types/global-account/react/hooks/useFirstEOA.d.ts +4 -7666
  213. package/dist/types/global-account/react/hooks/usePortfolioBalance.d.ts +15 -0
  214. package/dist/types/global-account/react/hooks/usePortfolioCollectibles.d.ts +12 -0
  215. package/dist/types/global-account/react/hooks/useSiwe.d.ts +1 -1
  216. package/dist/types/global-account/react/hooks/useSiwe.native.d.ts +1 -1
  217. package/dist/types/global-account/react/hooks/useTWAuth.d.ts +1 -1
  218. package/dist/types/global-account/react/hooks/useUnifiedChainSwitchAndExecute.d.ts +1 -0
  219. package/dist/types/global-account/react/stores/useModalStore.d.ts +14 -2
  220. package/dist/types/global-account/types/b3-api.types.d.ts +5 -0
  221. package/dist/types/global-account/types/feature-flags.d.ts +5 -5
  222. package/dist/types/shared/constants/chains/b3Chain.d.ts +30 -54
  223. package/dist/types/shared/constants/chains/supported.d.ts +1 -49
  224. package/dist/types/shared/constants/index.d.ts +4 -0
  225. package/dist/types/shared/utils/chain-transformers.d.ts +4 -4
  226. package/dist/types/shared/utils/upload.d.ts +9 -0
  227. package/dist/types/shared/utils/zerionPositions.d.ts +96 -0
  228. package/node_modules/@b3/chain-registry/chains.json +1225 -0
  229. package/node_modules/@b3/chain-registry/dist/chains.json +1225 -0
  230. package/node_modules/@b3/chain-registry/dist/index.cjs +1676 -0
  231. package/node_modules/@b3/chain-registry/dist/index.d.cts +195 -0
  232. package/node_modules/@b3/chain-registry/dist/index.d.ts +195 -0
  233. package/node_modules/@b3/chain-registry/dist/index.mjs +1604 -0
  234. package/node_modules/@b3/chain-registry/dist/src/index.d.ts +193 -0
  235. package/node_modules/@b3/chain-registry/dist/src/index.js +408 -0
  236. package/node_modules/@b3/chain-registry/package.json +66 -0
  237. package/node_modules/@b3/chain-registry/src/index.test.ts +432 -0
  238. package/node_modules/@b3/chain-registry/src/index.ts +672 -0
  239. package/package.json +81 -30
  240. package/src/anyspend/README.md +2 -2
  241. package/src/anyspend/constants/rpc.ts +5 -2
  242. package/src/anyspend/docs/components.md +6 -6
  243. package/src/anyspend/docs/contributing.md +1 -1
  244. package/src/anyspend/docs/hooks.md +3 -3
  245. package/src/anyspend/docs/installation.md +2 -2
  246. package/src/anyspend/react/components/AnySpend.tsx +163 -47
  247. package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +10 -11
  248. package/src/anyspend/react/components/AnySpendDeposit.tsx +130 -31
  249. package/src/anyspend/react/components/AnySpendStakeB3.tsx +55 -14
  250. package/src/anyspend/react/components/AnySpendStakeB3ExactIn.tsx +55 -11
  251. package/src/anyspend/react/components/QRDeposit.tsx +101 -22
  252. package/src/anyspend/react/components/__tests__/QRDeposit.test.tsx +331 -0
  253. package/src/anyspend/react/components/checkout/CryptoPayPanel.tsx +38 -16
  254. package/src/anyspend/react/components/common/PureTransferView.tsx +212 -0
  255. package/src/anyspend/react/components/common/TokenBalance.tsx +10 -7
  256. package/src/anyspend/react/hooks/useAnyspendQuote.ts +13 -13
  257. package/src/anyspend/react/hooks/useCreateDepositFirstOrder.ts +4 -4
  258. package/src/anyspend/services/gas.test.ts +95 -18
  259. package/src/anyspend/types/api_req_res.ts +10 -5
  260. package/src/anyspend/utils/__tests__/address.test.ts +39 -0
  261. package/src/anyspend/utils/__tests__/deprecatedChains.test.ts +44 -0
  262. package/src/anyspend/utils/__tests__/toRegistryChainId.test.ts +17 -0
  263. package/src/anyspend/utils/address.ts +8 -6
  264. package/src/anyspend/utils/chain.ts +79 -3
  265. package/src/anyspend/utils/token.ts +14 -0
  266. package/src/app.shared.ts +21 -1
  267. package/src/global-account/app.native.ts +5 -1
  268. package/src/global-account/better-auth-client.ts +30 -4
  269. package/src/global-account/bsmnt.native.ts +5 -1
  270. package/src/global-account/bsmnt.ts +9 -2
  271. package/src/global-account/client-manager.ts +74 -9
  272. package/src/global-account/react/components/AvatarEditor/AvatarEditor.tsx +6 -11
  273. package/src/global-account/react/components/B3Provider/B3ConfigProvider.tsx +12 -0
  274. package/src/global-account/react/components/B3Provider/B3Provider.tsx +40 -4
  275. package/src/global-account/react/components/B3Provider/BetterAuthProvider.tsx +51 -5
  276. package/src/global-account/react/components/B3Provider/RelayKitProviderWrapper.tsx +11 -11
  277. package/src/global-account/react/components/ManageAccount/ContentTokens.tsx +50 -21
  278. package/src/global-account/react/components/ManageAccount/NFTContent.tsx +5 -3
  279. package/src/global-account/react/components/ManageAccount/ProfileSection.tsx +10 -6
  280. package/src/global-account/react/components/ManageAccount/SettingsProfileCard.tsx +1 -1
  281. package/src/global-account/react/components/ManageAccount/TokenContent.tsx +22 -9
  282. package/src/global-account/react/components/Send/Send.tsx +39 -15
  283. package/src/global-account/react/components/SignInWithB3/BetterAuthSignIn.tsx +12 -1
  284. package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +1 -4
  285. package/src/global-account/react/components/SignInWithB3/components/AuthButton.tsx +9 -1
  286. package/src/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.tsx +1 -0
  287. package/src/global-account/react/components/SignInWithB3/utils/signInUtils.ts +4 -4
  288. package/src/global-account/react/components/index.ts +1 -1
  289. package/src/global-account/react/components/ui/button.tsx +1 -2
  290. package/src/global-account/react/hooks/__tests__/useUnifiedChainSwitchAndExecute.test.tsx +156 -0
  291. package/src/global-account/react/hooks/index.ts +2 -3
  292. package/src/global-account/react/hooks/useAuth.ts +5 -4
  293. package/src/global-account/react/hooks/useAuthentication.ts +5 -4
  294. package/src/global-account/react/hooks/useBetterAuth.ts +10 -10
  295. package/src/global-account/react/hooks/useClient.ts +11 -2
  296. package/src/global-account/react/hooks/useFirstEOA.tsx +9 -2
  297. package/src/global-account/react/hooks/useNativeBalance.tsx +1 -1
  298. package/src/global-account/react/hooks/usePortfolioBalance.ts +89 -0
  299. package/src/global-account/react/hooks/usePortfolioCollectibles.ts +212 -0
  300. package/src/global-account/react/hooks/useSiwe.native.tsx +1 -1
  301. package/src/global-account/react/hooks/useSiwe.tsx +1 -1
  302. package/src/global-account/react/hooks/useTWAuth.tsx +1 -1
  303. package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +47 -31
  304. package/src/global-account/react/stores/useModalStore.ts +14 -2
  305. package/src/global-account/types/b3-api.types.ts +5 -1
  306. package/src/notifications/services/api.ts +1 -0
  307. package/src/shared/constants/chains/b3Chain.ts +4 -43
  308. package/src/shared/constants/chains/supported.ts +9 -48
  309. package/src/shared/constants/index.ts +8 -0
  310. package/src/shared/react/hooks/__tests__/useCurrencyConversion.test.ts +54 -43
  311. package/src/shared/utils/__tests__/zerionPositions.test.ts +248 -0
  312. package/src/shared/utils/chain-transformers.ts +41 -39
  313. package/src/shared/utils/thirdweb-insights.ts +2 -2
  314. package/src/shared/utils/upload.ts +48 -0
  315. package/src/shared/utils/zerionPositions.ts +247 -0
  316. package/src/styles/index.css +27 -0
  317. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +0 -10
  318. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +0 -46
  319. package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +0 -11
  320. package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.js +0 -70
  321. package/dist/cjs/global-account/react/hooks/useSimBalance.d.ts +0 -59
  322. package/dist/cjs/global-account/react/hooks/useSimBalance.js +0 -98
  323. package/dist/cjs/global-account/react/hooks/useSimCollectibles.d.ts +0 -45
  324. package/dist/cjs/global-account/react/hooks/useSimCollectibles.js +0 -190
  325. package/dist/cjs/global-account/react/utils/simdune.d.ts +0 -7
  326. package/dist/cjs/global-account/react/utils/simdune.js +0 -21
  327. package/dist/cjs/global-account/types/chain-networks.d.ts +0 -44
  328. package/dist/cjs/global-account/types/chain-networks.js +0 -48
  329. package/dist/cjs/shared/generated/chain-networks.json +0 -684
  330. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +0 -10
  331. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +0 -43
  332. package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +0 -11
  333. package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.js +0 -67
  334. package/dist/esm/global-account/react/hooks/useSimBalance.d.ts +0 -59
  335. package/dist/esm/global-account/react/hooks/useSimBalance.js +0 -93
  336. package/dist/esm/global-account/react/hooks/useSimCollectibles.d.ts +0 -45
  337. package/dist/esm/global-account/react/hooks/useSimCollectibles.js +0 -187
  338. package/dist/esm/global-account/react/utils/simdune.d.ts +0 -7
  339. package/dist/esm/global-account/react/utils/simdune.js +0 -17
  340. package/dist/esm/global-account/types/chain-networks.d.ts +0 -44
  341. package/dist/esm/global-account/types/chain-networks.js +0 -45
  342. package/dist/esm/shared/generated/chain-networks.json +0 -684
  343. package/dist/types/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +0 -10
  344. package/dist/types/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +0 -11
  345. package/dist/types/global-account/react/hooks/useSimBalance.d.ts +0 -59
  346. package/dist/types/global-account/react/hooks/useSimCollectibles.d.ts +0 -45
  347. package/dist/types/global-account/react/utils/simdune.d.ts +0 -7
  348. package/dist/types/global-account/types/chain-networks.d.ts +0 -44
  349. package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +0 -63
  350. package/src/global-account/react/hooks/useHandleConnectWithPrivy.tsx +0 -79
  351. package/src/global-account/react/hooks/useSimBalance.ts +0 -164
  352. package/src/global-account/react/hooks/useSimCollectibles.ts +0 -238
  353. package/src/global-account/react/utils/simdune.ts +0 -20
  354. package/src/global-account/types/chain-networks.ts +0 -54
  355. package/src/shared/generated/chain-networks.json +0 -684
@@ -1,13 +1,36 @@
1
1
  import { createAuthClient } from "better-auth/client";
2
- import { B3_API_URL } from "../app.shared.js";
3
- export function createB3BetterAuthClient(baseURL = B3_API_URL) {
2
+ import { twoFactorClient } from "better-auth/client/plugins";
3
+ import { getB3ApiUrl } from "../app.shared.js";
4
+ export function createB3BetterAuthClient(baseURL) {
4
5
  return createAuthClient({
5
- baseURL,
6
+ baseURL: baseURL ?? getB3ApiUrl(),
6
7
  basePath: "/auth",
7
8
  fetchOptions: {
8
9
  credentials: "include",
9
10
  },
11
+ plugins: [twoFactorClient()],
10
12
  });
11
13
  }
12
- // Default singleton for standard usage
14
+ // Lazily-initialized singleton. Recreated when the API URL changes via
15
+ // `resetBetterAuthClient()` (called by B3Provider when `apiUrl` changes).
16
+ let _client = null;
17
+ let _clientUrl = null;
18
+ /** Get the shared BetterAuth client, creating it if needed. */
19
+ export function getBetterAuthClient() {
20
+ const url = getB3ApiUrl();
21
+ if (!_client || _clientUrl !== url) {
22
+ _client = createB3BetterAuthClient(url);
23
+ _clientUrl = url;
24
+ }
25
+ return _client;
26
+ }
27
+ /** Force-recreate the client on next access (e.g. after API URL change). */
28
+ export function resetBetterAuthClient() {
29
+ _client = null;
30
+ _clientUrl = null;
31
+ }
32
+ /**
33
+ * @deprecated Use `getBetterAuthClient()` instead. This static singleton
34
+ * does not reflect runtime API URL changes via `B3Provider apiUrl` prop.
35
+ */
13
36
  export const betterAuthClient = createB3BetterAuthClient();
@@ -1,5 +1,5 @@
1
1
  declare const app: import("@b3dotfun/basement-api").ClientApplication;
2
- export declare const authenticate: (accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<import("@feathersjs/authentication").AuthenticationResult | null>;
2
+ export declare const authenticate: (accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<Record<string, any> | null>;
3
3
  export declare const resetSocket: () => void;
4
- export declare const authenticateWithB3JWT: (fullToken: string, params?: Record<string, any>) => Promise<import("@feathersjs/authentication").AuthenticationResult | null>;
4
+ export declare const authenticateWithB3JWT: (fullToken: string, params?: Record<string, any>) => Promise<Record<string, any> | null>;
5
5
  export default app;
@@ -1,5 +1,5 @@
1
1
  import { MMKV } from "react-native-mmkv";
2
2
  export declare const localStoreInstance: MMKV;
3
3
  declare const app: import("@b3dotfun/basement-api").ClientApplication;
4
- export declare const authenticate: (accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<import("@feathersjs/authentication").AuthenticationResult | null>;
4
+ export declare const authenticate: (accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<Record<string, any> | null>;
5
5
  export default app;
@@ -1,5 +1,7 @@
1
1
  import { ClientApplication } from "@b3dotfun/b3-api";
2
2
  export type ClientType = "socket" | "rest";
3
+ /** Reset all cached clients (called when API URL changes). */
4
+ export declare function resetClients(): void;
3
5
  /**
4
6
  * Sets the active client type and creates the appropriate client
5
7
  *
@@ -25,20 +27,20 @@ export declare function resetSocket(): void;
25
27
  /**
26
28
  * Authenticates with the current active client
27
29
  */
28
- export declare const authenticate: (accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<import("@feathersjs/authentication").AuthenticationResult | null>;
30
+ export declare const authenticate: (accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<Record<string, any> | null>;
29
31
  /**
30
32
  * Authenticates with a specific client type
31
33
  */
32
- export declare const authenticateWithClient: (clientType: ClientType, accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<import("@feathersjs/authentication").AuthenticationResult | null>;
34
+ export declare const authenticateWithClient: (clientType: ClientType, accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<Record<string, any> | null>;
33
35
  /**
34
36
  * Authenticates with both clients in parallel (useful for migration scenarios)
35
37
  */
36
38
  export declare const authenticateBoth: (accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<{
37
- socket: import("@feathersjs/authentication").AuthenticationResult | null;
38
- rest: import("@feathersjs/authentication").AuthenticationResult | null;
39
+ socket: Record<string, any> | null;
40
+ rest: Record<string, any> | null;
39
41
  success: boolean;
40
42
  }>;
41
43
  /**
42
44
  * Switches the client type and authenticates
43
45
  */
44
- export declare function switchClientAndAuth(type: ClientType, access: string, id: string, params?: any): Promise<import("@feathersjs/authentication").AuthenticationResult | null>;
46
+ export declare function switchClientAndAuth(type: ClientType, access: string, id: string, params?: any): Promise<Record<string, any> | null>;
@@ -2,22 +2,57 @@ import { createClient } from "@b3dotfun/b3-api";
2
2
  import rest from "@feathersjs/rest-client";
3
3
  import socketio from "@feathersjs/socketio-client";
4
4
  import io from "socket.io-client";
5
- import { authenticate as authenticateB3, B3_API_URL, clientOptions } from "../app.shared.js";
5
+ import { authenticate as authenticateB3, getB3ApiUrl, clientOptions } from "../app.shared.js";
6
6
  // Global state to track which client type is active
7
7
  let currentClientType = "rest";
8
8
  let currentClient = null;
9
9
  // Socket client instance
10
10
  let socketClient = null;
11
11
  let socketInstance = null;
12
+ let socketClientUrl = null;
12
13
  // REST client instance
13
14
  let restClient = null;
15
+ let restClientUrl = null;
16
+ // The pinned @b3dotfun/b3-api client's generated usersMethods predates `setBio`,
17
+ // so `users.setBio(...)` throws "setBio is not a function". Re-register the users
18
+ // service with the full list (mirrors users.shared.ts). Remove once the
19
+ // @b3dotfun/b3-api pin includes setBio.
20
+ const USERS_METHODS = [
21
+ "find",
22
+ "get",
23
+ "create",
24
+ "patch",
25
+ "remove",
26
+ "setReferralCode",
27
+ "syncTwProfiles",
28
+ "setAvatar",
29
+ "setBio",
30
+ "registerUsername",
31
+ "getMe",
32
+ ];
33
+ // Re-register on every client the manager builds — the active transport
34
+ // (REST/socket) switches at runtime.
35
+ function ensureUsersCustomMethods(client) {
36
+ try {
37
+ const connection = client.get("connection");
38
+ if (connection?.service) {
39
+ client.use("users", connection.service("users"), { methods: USERS_METHODS });
40
+ }
41
+ }
42
+ catch {
43
+ // Non-fatal: keep whatever methods the generated client already exposes.
44
+ }
45
+ }
14
46
  /**
15
47
  * Creates a socket client
16
48
  */
17
49
  function createSocketClient() {
18
- if (!socketClient) {
19
- socketInstance = io(B3_API_URL, { transports: ["websocket"] });
50
+ const url = getB3ApiUrl();
51
+ if (!socketClient || socketClientUrl !== url) {
52
+ socketInstance = io(url, { transports: ["websocket"] });
20
53
  socketClient = createClient(socketio(socketInstance), clientOptions);
54
+ ensureUsersCustomMethods(socketClient);
55
+ socketClientUrl = url;
21
56
  }
22
57
  return socketClient;
23
58
  }
@@ -33,12 +68,23 @@ function resolveFetch() {
33
68
  return require("cross-fetch").fetch;
34
69
  }
35
70
  function createRestClient() {
36
- if (!restClient) {
37
- const connection = rest(B3_API_URL).fetch(resolveFetch());
71
+ const url = getB3ApiUrl();
72
+ if (!restClient || restClientUrl !== url) {
73
+ const connection = rest(url).fetch(resolveFetch());
38
74
  restClient = createClient(connection, clientOptions);
75
+ ensureUsersCustomMethods(restClient);
76
+ restClientUrl = url;
39
77
  }
40
78
  return restClient;
41
79
  }
80
+ /** Reset all cached clients (called when API URL changes). */
81
+ export function resetClients() {
82
+ socketClient = null;
83
+ socketClientUrl = null;
84
+ restClient = null;
85
+ restClientUrl = null;
86
+ currentClient = null;
87
+ }
42
88
  /**
43
89
  * Sets the active client type and creates the appropriate client
44
90
  *
@@ -6,13 +6,12 @@ import { validateImageUrl } from "../../../../global-account/react/utils/profile
6
6
  import { cn } from "../../../../shared/utils/cn.js";
7
7
  import { debugB3React } from "../../../../shared/utils/debug.js";
8
8
  import { getIpfsUrl } from "../../../../shared/utils/ipfs.js";
9
- import { client } from "../../../../shared/utils/thirdweb.js";
9
+ import { uploadFile as uploadToB3 } from "../../../../shared/utils/upload.js";
10
10
  import { Loader2, Upload, X } from "lucide-react";
11
11
  import { useCallback, useRef, useState } from "react";
12
12
  import Cropper from "react-easy-crop";
13
13
  import "react-easy-crop/react-easy-crop.css";
14
14
  import { useActiveAccount } from "thirdweb/react";
15
- import { upload } from "thirdweb/storage";
16
15
  import { useModalStore } from "../../stores/index.js";
17
16
  import ModalHeader from "../ModalHeader/ModalHeader.js";
18
17
  const debug = debugB3React("AvatarEditor");
@@ -195,18 +194,14 @@ export function AvatarEditor({ onSetAvatar, className }) {
195
194
  return;
196
195
  }
197
196
  }
198
- // Upload to IPFS if we have a file
197
+ // Upload file if we have one
199
198
  if (fileToUpload) {
200
- debug("Starting upload to IPFS", fileToUpload);
201
- // Upload to IPFS using Thirdweb
202
- const ipfsUrl = await upload({
203
- client,
204
- files: [fileToUpload],
205
- });
206
- debug("Upload successful", ipfsUrl);
199
+ debug("Starting upload", fileToUpload);
200
+ const avatarUrl = await uploadToB3(fileToUpload);
201
+ debug("Upload successful", avatarUrl);
207
202
  // Save avatar URL using profiles service
208
203
  const user = await app.service("users").setAvatar({
209
- avatar: ipfsUrl,
204
+ avatar: avatarUrl,
210
205
  },
211
206
  // @ts-expect-error - our typed client is expecting context even though it's set elsewhere
212
207
  {});
@@ -30,3 +30,14 @@ export declare function B3ConfigProvider({ children, accountOverride, environmen
30
30
  authStrategy?: AuthStrategy;
31
31
  }): import("react/jsx-runtime").JSX.Element;
32
32
  export declare function useB3Config(): B3ConfigContextType;
33
+ /**
34
+ * Overrides ONLY `partnerId` for a subtree, inheriting every other config value from the parent
35
+ * B3ConfigProvider. Lets a single route attribute its AnySpend orders/quotes to a different partner
36
+ * (e.g. `/b3os-deposit` → the b3os partner) without standing up a second B3Provider — the config
37
+ * context is separate from the wallet/modal machinery, so nothing re-initializes. Must be rendered
38
+ * inside an existing B3ConfigProvider.
39
+ */
40
+ export declare function B3ConfigPartnerOverride({ partnerId, children }: {
41
+ partnerId: string;
42
+ children: React.ReactNode;
43
+ }): import("react/jsx-runtime").JSX.Element;
@@ -31,3 +31,14 @@ export function useB3Config() {
31
31
  }
32
32
  return context;
33
33
  }
34
+ /**
35
+ * Overrides ONLY `partnerId` for a subtree, inheriting every other config value from the parent
36
+ * B3ConfigProvider. Lets a single route attribute its AnySpend orders/quotes to a different partner
37
+ * (e.g. `/b3os-deposit` → the b3os partner) without standing up a second B3Provider — the config
38
+ * context is separate from the wallet/modal machinery, so nothing re-initializes. Must be rendered
39
+ * inside an existing B3ConfigProvider.
40
+ */
41
+ export function B3ConfigPartnerOverride({ partnerId, children }) {
42
+ const parent = useB3Config();
43
+ return _jsx(B3ConfigContext.Provider, { value: { ...parent, partnerId }, children: children });
44
+ }
@@ -10,7 +10,7 @@ import { ClientType } from "../../../client-manager";
10
10
  /**
11
11
  * Main B3Provider component
12
12
  */
13
- export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, defaultEoaProvider, simDuneApiKey, toaster: _toaster, clientType, rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors, createClientReferenceId, defaultPermissions, disableBSMNTAuthentication, queryClient, authStrategy, }: {
13
+ export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, defaultEoaProvider, toaster: _toaster, clientType, rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors, createClientReferenceId, defaultPermissions, disableBSMNTAuthentication, queryClient, authStrategy, apiUrl, notificationsApiUrl, }: {
14
14
  theme: "light" | "dark";
15
15
  children: React.ReactNode;
16
16
  accountOverride?: Account;
@@ -18,7 +18,6 @@ export declare function B3Provider({ theme, children, accountOverride, environme
18
18
  automaticallySetFirstEoa?: boolean;
19
19
  /** EIP-1193 provider to auto-connect as the default EOA wallet (e.g., Farcaster frame wallet) */
20
20
  defaultEoaProvider?: EIP1193.EIP1193Provider;
21
- simDuneApiKey?: string;
22
21
  toaster?: {
23
22
  position?: "top-center" | "top-right" | "bottom-center" | "bottom-right";
24
23
  style?: React.CSSProperties;
@@ -39,4 +38,15 @@ export declare function B3Provider({ theme, children, accountOverride, environme
39
38
  queryClient?: QueryClient;
40
39
  /** Auth strategy: "thirdweb" (default, ecosystem wallet) or "better-auth" (email/password via Better Auth) */
41
40
  authStrategy?: AuthStrategy;
41
+ /**
42
+ * Override the B3 API URL. When provided, all SDK requests (auth, Feathers,
43
+ * BetterAuth) will use this URL instead of the `NEXT_PUBLIC_B3_API` env var.
44
+ *
45
+ * Useful for local development: pass `http://localhost:3031` to route
46
+ * OAuth callbacks and session checks through your local B3 API.
47
+ * If omitted, defaults to `NEXT_PUBLIC_B3_API` or `https://api.b3.fun`.
48
+ */
49
+ apiUrl?: string;
50
+ /** Override the notifications worker URL. Defaults to `https://notifications.b3.fun`. */
51
+ notificationsApiUrl?: string;
42
52
  }): import("react/jsx-runtime").JSX.Element;
@@ -5,19 +5,41 @@ import { loadGA4Script } from "../../../../global-account/utils/analytics.js";
5
5
  import { WalletProvider } from "../../../../wallet/react/index.js";
6
6
  import "@relayprotocol/relay-kit-ui/styles.css";
7
7
  import { useEffect, useMemo } from "react";
8
- import { setClientType } from "../../../client-manager.js";
8
+ import { resetClients, setClientType } from "../../../client-manager.js";
9
+ import { setB3ApiUrl } from "../../../../app.shared.js";
10
+ import { setApiUrl as setNotificationsApiUrl } from "../../../../notifications/services/api.js";
11
+ import { resetBetterAuthClient } from "../../../better-auth-client.js";
9
12
  import { StyleRoot } from "../StyleRoot.js";
10
13
  import { setToastContext, ToastProvider, useToastContext } from "../Toast/index.js";
11
14
  import AuthenticationProvider from "./AuthenticationProvider.js";
12
15
  import { B3ConfigProvider } from "./B3ConfigProvider.js";
13
16
  import BetterAuthProvider from "./BetterAuthProvider.js";
14
17
  import { LocalSDKProvider } from "./LocalSDKProvider.js";
18
+ const NOTIFICATIONS_URL_BY_ENV = {
19
+ development: "https://dev-notifications.b3.fun",
20
+ production: "https://notifications.b3.fun",
21
+ };
15
22
  /**
16
23
  * Main B3Provider component
17
24
  */
18
- export function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, defaultEoaProvider, simDuneApiKey,
25
+ export function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, defaultEoaProvider,
19
26
  // deprecated since v0.0.87
20
- toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors = false, createClientReferenceId, defaultPermissions, disableBSMNTAuthentication = false, queryClient, authStrategy = "thirdweb", }) {
27
+ toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors = false, createClientReferenceId, defaultPermissions, disableBSMNTAuthentication = false, queryClient, authStrategy = "thirdweb", apiUrl, notificationsApiUrl, }) {
28
+ // Override the B3 API URL when the `apiUrl` prop is provided.
29
+ // Must run before client initialization and auth providers mount.
30
+ useEffect(() => {
31
+ setB3ApiUrl(apiUrl ?? null);
32
+ if (apiUrl) {
33
+ resetBetterAuthClient();
34
+ resetClients();
35
+ }
36
+ return () => {
37
+ setB3ApiUrl(null);
38
+ };
39
+ }, [apiUrl]);
40
+ useEffect(() => {
41
+ setNotificationsApiUrl(notificationsApiUrl ?? NOTIFICATIONS_URL_BY_ENV[environment ?? "production"]);
42
+ }, [notificationsApiUrl, environment]);
21
43
  // Initialize Google Analytics on mount
22
44
  useEffect(() => {
23
45
  loadGA4Script();
@@ -27,7 +49,7 @@ toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey
27
49
  setClientType(clientType);
28
50
  }, [clientType]);
29
51
  const wagmiConfig = useMemo(() => createWagmiConfig({ partnerId, rpcUrls, connectors, overrideDefaultConnectors }), [partnerId, rpcUrls, connectors, overrideDefaultConnectors]);
30
- return (_jsx(WalletProvider, { wagmiConfig: wagmiConfig, queryClient: queryClient, children: _jsx(TooltipProvider, { children: _jsx(ToastProvider, { children: _jsx(LocalSDKProvider, { onConnectCallback: onConnect, onLogoutCallback: onLogout, disableBSMNTAuthentication: disableBSMNTAuthentication, children: _jsxs(B3ConfigProvider, { accountOverride: accountOverride, environment: environment, automaticallySetFirstEoa: !!automaticallySetFirstEoa, theme: theme, clientType: clientType, partnerId: partnerId, stripePublishableKey: stripePublishableKey, createClientReferenceId: createClientReferenceId, defaultPermissions: defaultPermissions, authStrategy: authStrategy, children: [_jsx(ToastContextConnector, {}), _jsxs(RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, _jsx(StyleRoot, { id: "b3-root" })] }), authStrategy === "better-auth" ? (_jsx(BetterAuthProvider, { partnerId: partnerId })) : (_jsx(AuthenticationProvider, { partnerId: partnerId, automaticallySetFirstEoa: !!automaticallySetFirstEoa, defaultEoaProvider: defaultEoaProvider }))] }) }) }) }) }));
52
+ return (_jsx(WalletProvider, { wagmiConfig: wagmiConfig, queryClient: queryClient, children: _jsx(TooltipProvider, { children: _jsx(ToastProvider, { children: _jsx(LocalSDKProvider, { onConnectCallback: onConnect, onLogoutCallback: onLogout, disableBSMNTAuthentication: disableBSMNTAuthentication, children: _jsxs(B3ConfigProvider, { accountOverride: accountOverride, environment: environment, automaticallySetFirstEoa: !!automaticallySetFirstEoa, theme: theme, clientType: clientType, partnerId: partnerId, stripePublishableKey: stripePublishableKey, createClientReferenceId: createClientReferenceId, defaultPermissions: defaultPermissions, authStrategy: authStrategy, children: [_jsx(ToastContextConnector, {}), _jsxs(RelayKitProviderWrapper, { children: [children, _jsx(StyleRoot, { id: "b3-root" })] }), authStrategy === "better-auth" ? (_jsx(BetterAuthProvider, { partnerId: partnerId })) : (_jsx(AuthenticationProvider, { partnerId: partnerId, automaticallySetFirstEoa: !!automaticallySetFirstEoa, defaultEoaProvider: defaultEoaProvider }))] }) }) }) }) }));
31
53
  }
32
54
  /**
33
55
  * Component to connect the toast context to the global toast API
@@ -4,7 +4,7 @@ import { B3_AUTH_COOKIE_NAME } from "../../../../shared/constants/index.js";
4
4
  import { debugB3React } from "../../../../shared/utils/debug.js";
5
5
  import Cookies from "js-cookie";
6
6
  import { useEffect, useRef } from "react";
7
- import { betterAuthClient } from "../../../better-auth-client.js";
7
+ import { getBetterAuthClient } from "../../../better-auth-client.js";
8
8
  import { useUserQuery } from "../../hooks/useUserQuery.js";
9
9
  const debug = debugB3React("BetterAuthProvider");
10
10
  /**
@@ -40,7 +40,7 @@ const BetterAuthProvider = ({ partnerId }) => {
40
40
  app.logout = async () => {
41
41
  debug("Patched logout: clearing Better Auth session");
42
42
  try {
43
- await betterAuthClient.signOut();
43
+ await getBetterAuthClient().signOut();
44
44
  }
45
45
  catch {
46
46
  debug("Better Auth signOut failed (non-critical)");
@@ -74,9 +74,50 @@ const BetterAuthProvider = ({ partnerId }) => {
74
74
  catch {
75
75
  debug("No existing Feathers JWT");
76
76
  }
77
- // 2. Check for a Better Auth session (e.g. after OAuth redirect sets a cookie)
77
+ // 2. Check for _ba_token in URL (OAuth callback with third-party cookie bypass).
78
+ // When the API and frontend are on different domains, browsers with third-party
79
+ // cookie blocking (Firefox TCP, Safari ITP, Chrome Privacy Sandbox) prevent the
80
+ // better-auth.session_token cookie from being sent on cross-origin requests.
81
+ // The B3 API injects the session token into the redirect URL as _ba_token,
82
+ // allowing direct exchange without relying on cookies.
83
+ const params = new URLSearchParams(window.location.search);
84
+ const baToken = params.get("_ba_token");
85
+ if (baToken) {
86
+ debug("Found _ba_token in URL, exchanging for Feathers JWT");
87
+ // Clean the token from the URL immediately (security)
88
+ params.delete("_ba_token");
89
+ const cleanSearch = params.toString();
90
+ const cleanUrl = window.location.pathname + (cleanSearch ? `?${cleanSearch}` : "") + window.location.hash;
91
+ window.history.replaceState({}, "", cleanUrl);
92
+ try {
93
+ const response = await app.authenticate({
94
+ strategy: "better-auth",
95
+ accessToken: baToken,
96
+ partnerId,
97
+ });
98
+ if (response.accessToken) {
99
+ Cookies.set(B3_AUTH_COOKIE_NAME, response.accessToken, {
100
+ secure: true,
101
+ sameSite: "Lax",
102
+ });
103
+ }
104
+ if (response.user) {
105
+ setUser(response.user);
106
+ setIsAuthenticated(true);
107
+ setIsConnected(true);
108
+ }
109
+ debug("_ba_token exchanged for Feathers JWT", { userId: response.user?.userId });
110
+ setIsAuthenticating(false);
111
+ return;
112
+ }
113
+ catch (err) {
114
+ debug("_ba_token exchange failed", err);
115
+ }
116
+ }
117
+ // 3. Check for a Better Auth session via cookie (works when API and frontend
118
+ // share a domain or when cookies aren't partitioned)
78
119
  try {
79
- const session = await betterAuthClient.getSession();
120
+ const session = await getBetterAuthClient().getSession();
80
121
  if (session.data?.session?.token) {
81
122
  debug("Better Auth session found, exchanging for Feathers JWT", {
82
123
  betterAuthUserId: session.data.user?.id,
@@ -105,7 +146,7 @@ const BetterAuthProvider = ({ partnerId }) => {
105
146
  catch {
106
147
  debug("No Better Auth session to restore");
107
148
  }
108
- // 3. Nothing found — show login UI
149
+ // 4. Nothing found — show login UI
109
150
  setIsAuthenticating(false);
110
151
  };
111
152
  restoreSession();
@@ -1,4 +1,3 @@
1
- export declare function RelayKitProviderWrapper({ children, simDuneApiKey, }: {
1
+ export declare function RelayKitProviderWrapper({ children }: {
2
2
  children: React.ReactNode;
3
- simDuneApiKey?: string;
4
3
  }): import("react/jsx-runtime").JSX.Element;
@@ -2,7 +2,7 @@ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
2
  import { RelayKitProvider } from "@relayprotocol/relay-kit-ui";
3
3
  import { fetchChainConfigs, MAINNET_RELAY_API } from "@relayprotocol/relay-sdk";
4
4
  import { useEffect, useState } from "react";
5
- export function RelayKitProviderWrapper({ children, simDuneApiKey, }) {
5
+ export function RelayKitProviderWrapper({ children }) {
6
6
  const [relayChains, setRelayChains] = useState([]);
7
7
  useEffect(() => {
8
8
  const fetchChains = async () => {
@@ -11,16 +11,22 @@ export function RelayKitProviderWrapper({ children, simDuneApiKey, }) {
11
11
  };
12
12
  fetchChains();
13
13
  }, []);
14
+ // Balances for Relay's token selector come from the b3-zerion-api Zerion proxy, not Relay's own Dune
15
+ // integration. Relay only fires the balance query when duneConfig.apiKey is set, so apiBaseUrl points
16
+ // it at our proxy; the proxy ignores the client-sent key and holds the real Zerion credential itself.
14
17
  return (_jsx(RelayKitProvider, { options: {
15
18
  baseApiUrl: MAINNET_RELAY_API,
16
19
  source: "anyspend",
17
- duneConfig: {
18
- apiKey: simDuneApiKey,
19
- apiBaseUrl: "https://api.sim.dune.com",
20
- },
21
20
  chains: relayChains,
22
21
  privateChainIds: undefined,
23
22
  appName: "AnySpend",
24
23
  useGasFeeEstimations: true,
24
+ duneConfig: {
25
+ // Non-secret placeholder. Relay only fires its balance query when apiKey is defined; the value is sent
26
+ // as X-Sim-Api-Key to our proxy, which ignores it. The real Zerion key stays server-side in b3-zerion-api.
27
+ apiKey: "proxied-via-portfolio-api",
28
+ // Relay appends /v1/evm/balances/{address}. Our b3-zerion-api worker serves that route, backed by Zerion.
29
+ apiBaseUrl: "https://portfolio-api.b3.fun",
30
+ },
25
31
  }, children: _jsx(_Fragment, { children: children }) }));
26
32
  }
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { ALL_CHAINS, getExplorerTxUrl } from "../../../../anyspend/index.js";
3
3
  import { ChainTokenIcon } from "../../../../anyspend/react/components/common/ChainTokenIcon.js";
4
- import { Button, toast, TransitionPanel, useAnalytics, useSimBalance, useUnifiedChainSwitchAndExecute, } from "../../../../global-account/react/index.js";
4
+ import { Button, toast, TransitionPanel, useAnalytics, usePortfolioBalance, useUnifiedChainSwitchAndExecute, } from "../../../../global-account/react/index.js";
5
5
  import { formatDisplayNumber, formatTokenAmount } from "../../../../shared/utils/number.js";
6
6
  import invariant from "invariant";
7
7
  import { ArrowLeft, CircleHelp, Copy, Loader2, Send } from "lucide-react";
@@ -41,7 +41,7 @@ export function ContentTokens({ activeTab }) {
41
41
  const animationDirection = useRef(null);
42
42
  // === DATA FETCHING ===
43
43
  const account = useActiveAccount();
44
- const { data: simBalance, refetch: refetchSimBalance, isLoading: isLoadingBalance } = useSimBalance(account?.address);
44
+ const { data: balances, refetch: refetchBalances, isLoading: isLoadingBalance, isError: isBalanceError, } = usePortfolioBalance(account?.address);
45
45
  // === BLOCKCHAIN INTERACTION ===
46
46
  const { switchChainAndExecute } = useUnifiedChainSwitchAndExecute();
47
47
  // === ANALYTICS ===
@@ -75,13 +75,13 @@ export function ContentTokens({ activeTab }) {
75
75
  // === HELPER FUNCTION ===
76
76
  // Get current version of selected token from fresh balance data
77
77
  // 🔧 FIX: Prevents auto-navigation back to token list when balance refreshes
78
- // The useSimBalance hook refreshes data, creating new token object references
78
+ // The balance hook refreshes data, creating new token object references
79
79
  // This helper ensures we always get the fresh token data instead of stale references
80
80
  const getCurrentSelectedToken = () => {
81
- if (!selectedToken || !simBalance?.balances) {
81
+ if (!selectedToken || !balances) {
82
82
  return null;
83
83
  }
84
- const found = simBalance.balances.find(token => token.chain_id === selectedToken.chain_id && token.address === selectedToken.address);
84
+ const found = balances.find(token => token.chain_id === selectedToken.chain_id && token.address === selectedToken.address);
85
85
  return found || null;
86
86
  };
87
87
  // ==================================================================================
@@ -147,11 +147,13 @@ export function ContentTokens({ activeTab }) {
147
147
  functionName: "transfer",
148
148
  args: [recipientAddress, amountInWei],
149
149
  });
150
- const tx = await switchChainAndExecute(displayToken.chain_id, {
151
- to: displayToken.address === "native" ? recipientAddress : displayToken.address,
152
- data: sendTokenData,
153
- value: displayToken.address === "native" ? amountInWei : BigInt(0),
154
- });
150
+ // A native send carries value and no calldata; an ERC-20 send carries calldata and no
151
+ // value. Branch on the explicit flag, never on the address: the native sentinel is a
152
+ // display detail, and taking the ERC-20 path for a native coin spends gas without moving
153
+ // anything.
154
+ const tx = await switchChainAndExecute(displayToken.chain_id, displayToken.is_native
155
+ ? { to: recipientAddress, value: amountInWei }
156
+ : { to: displayToken.address, data: sendTokenData, value: BigInt(0) });
155
157
  if (tx) {
156
158
  // Track successful send
157
159
  sendAnalyticsEvent("send_token_button_click", {
@@ -177,7 +179,7 @@ export function ContentTokens({ activeTab }) {
177
179
  // Wait 1 second to make sure the tx is indexed on sim api.
178
180
  setTimeout(async () => {
179
181
  // Force refetch to bypass cache and get fresh balance data
180
- await refetchSimBalance();
182
+ await refetchBalances();
181
183
  }, 1000);
182
184
  setIsSending(false);
183
185
  }
@@ -211,21 +213,27 @@ export function ContentTokens({ activeTab }) {
211
213
  if (isLoadingBalance) {
212
214
  return _jsx(LoadingIndicator, {});
213
215
  }
214
- // Show empty state when no account or no balance data
215
- if (!account?.address || !simBalance) {
216
+ // A wallet IS connected here only the read failed. Prompting the user to connect would send
217
+ // them to fix something that is not broken.
218
+ // `isBalanceError` as well as the absent list: after a first success a later refetch failure
219
+ // keeps `data` populated, so `!balances` alone would show stale numbers as if they were fresh.
220
+ if (account?.address && (isBalanceError || !balances)) {
221
+ return (_jsxs("div", { className: "flex flex-col items-center justify-center py-12 text-center", children: [_jsx("div", { className: "bg-b3-line/50 mb-4 rounded-full p-4", children: _jsx(Loader2, { className: "text-b3-foreground-muted h-8 w-8" }) }), _jsx("h3", { className: "text-b3-grey font-neue-montreal-semibold mb-2", children: "Couldn't load your tokens" }), _jsx("button", { onClick: () => refetchBalances(), className: "text-b3-foreground-muted font-neue-montreal-medium text-sm underline", children: "Try again" })] }));
222
+ }
223
+ if (!account?.address) {
216
224
  return (_jsxs("div", { className: "flex flex-col items-center justify-center py-12 text-center", children: [_jsx("div", { className: "bg-b3-line/50 mb-4 rounded-full p-4", children: _jsx(Loader2, { className: "text-b3-foreground-muted h-8 w-8" }) }), _jsx("h3", { className: "text-b3-grey font-neue-montreal-semibold mb-2", children: "No wallet connected" }), _jsx("p", { className: "text-b3-foreground-muted font-neue-montreal-medium text-sm", children: "Connect your wallet to view token balances" })] }));
217
225
  }
218
226
  // === SMART FILTERING LOGIC ===
219
227
  // Filter tokens with value >= $1 to reduce noise from dust tokens
220
- const filteredTokens = simBalance?.balances.filter(token => token.value_usd !== undefined && token.value_usd >= 1) || [];
228
+ const filteredTokens = balances?.filter(token => token.value_usd !== undefined && token.value_usd >= 1) || [];
221
229
  // 🧠 INTELLIGENT DISPLAY LOGIC:
222
230
  // Show all tokens automatically when filtering would be unhelpful:
223
231
  // 1. User explicitly requested to show all, OR
224
232
  // 2. No tokens with value >= $1 (user has only dust), OR
225
233
  // 3. 5 or fewer tokens with value >= $1 (not enough to warrant filtering)
226
234
  const shouldShowAllTokens = showAllTokens || filteredTokens.length === 0 || filteredTokens.length <= 5;
227
- const tokensToShow = shouldShowAllTokens ? simBalance?.balances || [] : filteredTokens;
228
- const hasHiddenTokens = !shouldShowAllTokens && (simBalance?.balances.length || 0) > filteredTokens.length;
235
+ const tokensToShow = shouldShowAllTokens ? balances || [] : filteredTokens;
236
+ const hasHiddenTokens = !shouldShowAllTokens && (balances?.length || 0) > filteredTokens.length;
229
237
  // Handle token selection and navigate to send form
230
238
  const handleTokenClick = (token) => {
231
239
  setSelectedToken(token);
@@ -1,13 +1,13 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useActiveWallet } from "thirdweb/react";
3
3
  import { AccountAssets } from "..";
4
- import { useSimCollectibles } from "../../hooks/index.js";
4
+ import { usePortfolioCollectibles } from "../../hooks/index.js";
5
5
  const NFTContent = () => {
6
6
  // Get active wallet state
7
7
  const activeWallet = useActiveWallet();
8
8
  const activeAccount = activeWallet?.getAccount();
9
9
  const activeAddress = activeAccount?.address;
10
- const { data: nfts, isLoading } = useSimCollectibles(activeAddress, [1, 8453], { filterSpam: true });
11
- return (_jsx("div", { style: { minHeight: "100px" }, children: nfts ? (_jsx(AccountAssets, { nfts: nfts, isLoading: isLoading })) : (_jsx("div", { className: "py-12 text-center text-gray-500", children: "No NFTs found" })) }));
10
+ const { data: nfts, isLoading, isError } = usePortfolioCollectibles(activeAddress, [1, 8453], { filterSpam: true });
11
+ return (_jsx("div", { style: { minHeight: "100px" }, children: isError ? (_jsx("div", { className: "py-12 text-center text-gray-500", children: "Couldn't load your NFTs" })) : nfts ? (_jsx(AccountAssets, { nfts: nfts, isLoading: isLoading })) : (_jsx("div", { className: "py-12 text-center text-gray-500", children: "No NFTs found" })) }));
12
12
  };
13
13
  export default NFTContent;
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useAccountWallet, useB3Config, useModalStore, useProfile, useSimBalance, useUser, } from "../../../../global-account/react/index.js";
2
+ import { useAccountWallet, useB3Config, useModalStore, useProfile, usePortfolioBalance, useUser, } from "../../../../global-account/react/index.js";
3
3
  import { validateImageUrl } from "../../../../global-account/react/utils/profileDisplay.js";
4
4
  import { AVATAR_COLORS } from "../../../../shared/constants/index.js";
5
5
  import { formatUsername } from "../../../../shared/utils/index.js";
@@ -24,14 +24,16 @@ const ProfileSection = () => {
24
24
  const setB3ModalOpen = useModalStore(state => state.setB3ModalOpen);
25
25
  const setB3ModalContentType = useModalStore(state => state.setB3ModalContentType);
26
26
  const navigateBack = useModalStore(state => state.navigateBack);
27
- const { data: simBalance } = useSimBalance(smartWalletAddress);
27
+ const { data: balances, isError: isBalanceError } = usePortfolioBalance(smartWalletAddress);
28
28
  const [imgError, setImgError] = useState(false);
29
29
  const handleImgError = useCallback(() => setImgError(true), []);
30
+ // Null while the holdings are unknown. Summing an absent list to $0.00 would report an empty
31
+ // portfolio to someone whose balances merely failed to load.
30
32
  const totalBalanceUsd = useMemo(() => {
31
- if (!simBalance?.balances)
32
- return 0;
33
- return simBalance.balances.reduce((sum, token) => sum + (token.value_usd || 0), 0);
34
- }, [simBalance]);
33
+ if (isBalanceError || !balances)
34
+ return null;
35
+ return balances.reduce((sum, token) => sum + (token.value_usd || 0), 0);
36
+ }, [balances, isBalanceError]);
35
37
  const handleEditAvatar = () => {
36
38
  setB3ModalOpen(true);
37
39
  setB3ModalContentType({
@@ -48,6 +50,6 @@ const ProfileSection = () => {
48
50
  }, [avatarSrc]);
49
51
  const currentUsername = user?.username || profile?.displayName || formatUsername(profile?.name || "");
50
52
  const avatarSeed = eoaAddress || account?.address || smartWalletAddress || currentUsername || user?.email || "user";
51
- return (_jsx("div", { className: "flex items-center justify-between px-5 py-6", children: _jsxs("div", { className: "global-account-profile flex items-center gap-4", children: [_jsxs("div", { className: "global-account-profile-avatar relative", children: [_jsx("div", { className: "border-b3-line border-1 bg-b3-primary-wash size-14 overflow-hidden rounded-full border", children: avatarSrc && !imgError ? (_jsx(IPFSMediaRenderer, { src: avatarSrc, alt: "Profile Avatar", className: "h-full w-full object-cover", onError: handleImgError })) : (_jsx(Avatar, { name: avatarSeed, variant: "beam", size: 56, colors: AVATAR_COLORS })) }), _jsx("button", { onClick: handleEditAvatar, className: "border-b3-background hover:bg-b3-grey/80 absolute -bottom-1 -right-1 flex size-6 items-center justify-center rounded-full border-4 bg-[#a0a0ab] transition-colors", children: _jsx(Pencil, { size: 10, className: "text-b3-background" }) })] }), _jsxs("div", { className: "global-account-profile-info flex flex-col gap-1", children: [!isBetterAuth && (_jsxs("h2", { className: "text-b3-grey font-neue-montreal-semibold flex h-[38px] items-center gap-1 text-xl", children: [_jsx("div", { className: "text-b3-foreground-muted", children: " $" }), _jsx("div", { className: "text-[30px]", children: formatDisplayNumber(totalBalanceUsd, { fractionDigits: 2 }) })] })), _jsx("div", { className: "b3-modal-username font-neue-montreal-semibold text-base leading-none text-[#0B57C2]", children: currentUsername }), isBetterAuth && user?.email && (_jsx("div", { className: "text-b3-foreground-muted font-neue-montreal-medium text-sm", children: user.email }))] })] }) }));
53
+ return (_jsx("div", { className: "flex items-center justify-between px-5 py-6", children: _jsxs("div", { className: "global-account-profile flex items-center gap-4", children: [_jsxs("div", { className: "global-account-profile-avatar relative", children: [_jsx("div", { className: "border-b3-line border-1 bg-b3-primary-wash size-14 overflow-hidden rounded-full border", children: avatarSrc && !imgError ? (_jsx(IPFSMediaRenderer, { src: avatarSrc, alt: "Profile Avatar", className: "h-full w-full object-cover", onError: handleImgError })) : (_jsx(Avatar, { name: avatarSeed, variant: "beam", size: 56, colors: AVATAR_COLORS })) }), _jsx("button", { onClick: handleEditAvatar, className: "border-b3-background hover:bg-b3-grey/80 absolute -bottom-1 -right-1 flex size-6 items-center justify-center rounded-full border-4 bg-[#a0a0ab] transition-colors", children: _jsx(Pencil, { size: 10, className: "text-b3-background" }) })] }), _jsxs("div", { className: "global-account-profile-info flex flex-col gap-1", children: [!isBetterAuth && (_jsxs("h2", { className: "text-b3-grey font-neue-montreal-semibold flex h-[38px] items-center gap-1 text-xl", children: [_jsx("div", { className: "text-b3-foreground-muted", children: " $" }), _jsx("div", { className: "text-[30px]", children: totalBalanceUsd === null ? "—" : formatDisplayNumber(totalBalanceUsd, { fractionDigits: 2 }) })] })), _jsx("div", { className: "b3-modal-username font-neue-montreal-semibold text-base leading-none text-[#0B57C2]", children: currentUsername }), isBetterAuth && user?.email && (_jsx("div", { className: "text-b3-foreground-muted font-neue-montreal-medium text-sm", children: user.email }))] })] }) }));
52
54
  };
53
55
  export default ProfileSection;