@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
@@ -7,6 +7,7 @@ export { RelayKitProviderWrapper } from "./B3Provider/RelayKitProviderWrapper";
7
7
  export { useB3 } from "./B3Provider/useB3";
8
8
  export { useB3Account } from "./B3Provider/useB3Account";
9
9
  export { useB3Config } from "./B3Provider/useB3Config";
10
+ export { B3ConfigPartnerOverride } from "./B3Provider/B3ConfigProvider";
10
11
  export { StyleRoot } from "./StyleRoot";
11
12
 
12
13
  // SignInWithB3 Components
@@ -22,7 +23,6 @@ export { PermissionItem } from "./SignInWithB3/components/PermissionItem";
22
23
  export { WalletRow } from "./SignInWithB3/components/WalletRow";
23
24
  export { SignInWithB3 } from "./SignInWithB3/SignInWithB3";
24
25
  export { SignInWithB3Flow } from "./SignInWithB3/SignInWithB3Flow";
25
- export { SignInWithB3Privy } from "./SignInWithB3/SignInWithB3Privy";
26
26
  export { LoginStepContainer } from "./SignInWithB3/steps/LoginStep";
27
27
  export { getConnectOptionsFromStrategy, isWalletType, type AllowedStrategy } from "./SignInWithB3/utils/signInUtils";
28
28
 
@@ -32,8 +32,7 @@ const buttonVariants = cva(
32
32
  );
33
33
 
34
34
  export interface ButtonProps
35
- extends React.ButtonHTMLAttributes<HTMLButtonElement>,
36
- VariantProps<typeof buttonVariants> {
35
+ extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
37
36
  asChild?: boolean;
38
37
  }
39
38
 
@@ -0,0 +1,156 @@
1
+ import { act, renderHook } from "@testing-library/react";
2
+ import { beforeEach, describe, expect, it, vi } from "vitest";
3
+ import { useUnifiedChainSwitchAndExecute } from "../useUnifiedChainSwitchAndExecute";
4
+
5
+ const mocks = vi.hoisted(() => ({
6
+ eoaGetAccount: vi.fn(),
7
+ globalAccountGetAccount: vi.fn(),
8
+ intentCreate: vi.fn(),
9
+ prepareTransaction: vi.fn(),
10
+ sendTransaction: vi.fn(),
11
+ toastError: vi.fn(),
12
+ toastInfo: vi.fn(),
13
+ toastSuccess: vi.fn(),
14
+ useAccountWallet: vi.fn(),
15
+ }));
16
+
17
+ vi.mock("@b3dotfun/sdk/anyspend", () => ({
18
+ getChainName: (chainId: number) => `Chain ${chainId}`,
19
+ getNativeToken: () => ({ name: "Ether", symbol: "ETH", decimals: 18 }),
20
+ }));
21
+
22
+ vi.mock("@b3dotfun/sdk/global-account/app", () => ({
23
+ default: {
24
+ service: () => ({ create: mocks.intentCreate }),
25
+ },
26
+ }));
27
+
28
+ vi.mock("@b3dotfun/sdk/global-account/react", () => ({
29
+ toast: {
30
+ dismiss: vi.fn(),
31
+ error: mocks.toastError,
32
+ info: mocks.toastInfo,
33
+ success: mocks.toastSuccess,
34
+ },
35
+ }));
36
+
37
+ vi.mock("@b3dotfun/sdk/shared/constants/chains/supported", () => ({
38
+ getThirdwebChain: (chainId: number) => ({ id: chainId }),
39
+ supportedChains: [],
40
+ }));
41
+
42
+ vi.mock("@b3dotfun/sdk/shared/utils/thirdweb", () => ({ client: {} }));
43
+
44
+ vi.mock("thirdweb", () => ({
45
+ prepareTransaction: mocks.prepareTransaction,
46
+ sendTransaction: mocks.sendTransaction,
47
+ }));
48
+
49
+ vi.mock("viem", () => ({ isAddress: () => true }));
50
+
51
+ vi.mock("wagmi", () => ({
52
+ useSwitchChain: () => ({ switchChainAsync: vi.fn() }),
53
+ }));
54
+
55
+ vi.mock("../../components/B3Provider/B3ConfigProvider", () => ({
56
+ useB3Config: () => ({ partnerId: "test-partner" }),
57
+ }));
58
+
59
+ vi.mock("../useAccountWallet", () => ({
60
+ useAccountWallet: mocks.useAccountWallet,
61
+ }));
62
+
63
+ const GLOBAL_ACCOUNT_ADDRESS = "0x1111111111111111111111111111111111111111";
64
+ const OTHER_GLOBAL_ACCOUNT_ADDRESS = "0x2222222222222222222222222222222222222222";
65
+ const EOA_ADDRESS = "0x3333333333333333333333333333333333333333";
66
+ const TRANSACTION_HASH = `0x${"a".repeat(64)}`;
67
+
68
+ const globalAccount = { address: GLOBAL_ACCOUNT_ADDRESS };
69
+ const preparedTransaction = { prepared: true };
70
+ const transactionParams = {
71
+ to: "0x4444444444444444444444444444444444444444",
72
+ data: "0x1234",
73
+ value: BigInt(0),
74
+ };
75
+
76
+ describe("useUnifiedChainSwitchAndExecute", () => {
77
+ beforeEach(() => {
78
+ vi.clearAllMocks();
79
+
80
+ mocks.globalAccountGetAccount.mockReturnValue(globalAccount);
81
+ mocks.eoaGetAccount.mockReturnValue({ address: EOA_ADDRESS });
82
+ mocks.intentCreate.mockResolvedValue({});
83
+ mocks.prepareTransaction.mockReturnValue(preparedTransaction);
84
+ mocks.sendTransaction.mockResolvedValue({ transactionHash: TRANSACTION_HASH });
85
+ mocks.useAccountWallet.mockReturnValue({
86
+ connectedSmartWallet: { getAccount: mocks.globalAccountGetAccount },
87
+ connectedEOAWallet: { getAccount: mocks.eoaGetAccount },
88
+ isActiveSmartWallet: false,
89
+ isActiveEOAWallet: true,
90
+ });
91
+ });
92
+
93
+ it("uses the connected Global Account even when the EOA wallet is active", async () => {
94
+ const { result } = renderHook(() => useUnifiedChainSwitchAndExecute());
95
+
96
+ let transactionHash: string | undefined;
97
+ await act(async () => {
98
+ transactionHash = await result.current.switchChainAndExecuteWithGlobalAccount(
99
+ 8453,
100
+ transactionParams,
101
+ GLOBAL_ACCOUNT_ADDRESS,
102
+ );
103
+ });
104
+
105
+ expect(transactionHash).toBe(TRANSACTION_HASH);
106
+ expect(mocks.globalAccountGetAccount).toHaveBeenCalledOnce();
107
+ expect(mocks.eoaGetAccount).not.toHaveBeenCalled();
108
+ expect(mocks.sendTransaction).toHaveBeenCalledWith({
109
+ account: globalAccount,
110
+ transaction: preparedTransaction,
111
+ });
112
+ });
113
+
114
+ it("rejects a signer that does not match the authenticated Global Account", async () => {
115
+ const { result } = renderHook(() => useUnifiedChainSwitchAndExecute());
116
+
117
+ let transactionHash: string | undefined;
118
+ await act(async () => {
119
+ transactionHash = await result.current.switchChainAndExecuteWithGlobalAccount(
120
+ 8453,
121
+ transactionParams,
122
+ OTHER_GLOBAL_ACCOUNT_ADDRESS,
123
+ );
124
+ });
125
+
126
+ expect(transactionHash).toBeUndefined();
127
+ expect(mocks.toastError).toHaveBeenCalledWith("Connected Global Account does not match the authenticated account");
128
+ expect(mocks.prepareTransaction).not.toHaveBeenCalled();
129
+ expect(mocks.sendTransaction).not.toHaveBeenCalled();
130
+ expect(mocks.eoaGetAccount).not.toHaveBeenCalled();
131
+ });
132
+
133
+ it("fails closed when no Global Account signer is connected", async () => {
134
+ mocks.useAccountWallet.mockReturnValue({
135
+ connectedSmartWallet: undefined,
136
+ connectedEOAWallet: { getAccount: mocks.eoaGetAccount },
137
+ isActiveSmartWallet: false,
138
+ isActiveEOAWallet: true,
139
+ });
140
+ const { result } = renderHook(() => useUnifiedChainSwitchAndExecute());
141
+
142
+ let transactionHash: string | undefined;
143
+ await act(async () => {
144
+ transactionHash = await result.current.switchChainAndExecuteWithGlobalAccount(
145
+ 8453,
146
+ transactionParams,
147
+ GLOBAL_ACCOUNT_ADDRESS,
148
+ );
149
+ });
150
+
151
+ expect(transactionHash).toBeUndefined();
152
+ expect(mocks.toastError).toHaveBeenCalledWith("Global Account not connected");
153
+ expect(mocks.sendTransaction).not.toHaveBeenCalled();
154
+ expect(mocks.eoaGetAccount).not.toHaveBeenCalled();
155
+ });
156
+ });
@@ -17,7 +17,6 @@ export { useFirstEOA } from "./useFirstEOA";
17
17
  export { useGetAllTWSigners, type TWSignerWithMetadata } from "./useGetAllTWSigners";
18
18
  export { useGetGeo } from "./useGetGeo";
19
19
  export { useGlobalAccount } from "./useGlobalAccount";
20
- export { useHandleConnectWithPrivy } from "./useHandleConnectWithPrivy";
21
20
  export { useHasMounted } from "./useHasMounted";
22
21
  export { useIsMobile } from "./useIsMobile";
23
22
  export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect";
@@ -40,8 +39,8 @@ export { useQueryBSMNT } from "./useQueryBSMNT";
40
39
  export { useRemoveSessionKey } from "./useRemoveSessionKey";
41
40
  export { useRouter } from "./useRouter";
42
41
  export { useSearchParamsSSR } from "./useSearchParamsSSR";
43
- export { useSimBalance, useSimSvmBalance, useSimTokenBalance } from "./useSimBalance";
44
- export { useSimCollectibles } from "./useSimCollectibles";
42
+ export { usePortfolioBalance, usePortfolioTokenBalance } from "./usePortfolioBalance";
43
+ export { usePortfolioCollectibles } from "./usePortfolioCollectibles";
45
44
  export { useSiwe } from "./useSiwe";
46
45
  export { useTokenBalance } from "./useTokenBalance";
47
46
  export { useTokenBalanceDirect } from "./useTokenBalanceDirect";
@@ -1,7 +1,7 @@
1
1
  import app from "@b3dotfun/sdk/global-account/app";
2
2
  import { authenticateWithB3JWT } from "@b3dotfun/sdk/global-account/bsmnt";
3
3
  import { useAuthStore, useB3Config } from "@b3dotfun/sdk/global-account/react";
4
- import { ecosystemWalletId } from "@b3dotfun/sdk/shared/constants";
4
+ import { ecosystemWalletId, type EcosystemWallet } from "@b3dotfun/sdk/shared/constants";
5
5
  import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
6
6
  import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
7
7
  import { ConnectionOptions } from "@thirdweb-dev/wagmi-adapter";
@@ -54,7 +54,8 @@ export function useAuth() {
54
54
  const { user, setUser } = useUserQuery();
55
55
  debug("@@activeWagmiAccount", activeWagmiAccount);
56
56
 
57
- const wallet = ecosystemWallet(ecosystemWalletId, {
57
+ // Explicit annotation keeps the hook's declaration portable (TS2742).
58
+ const wallet: EcosystemWallet = ecosystemWallet(ecosystemWalletId, {
58
59
  partnerId: partnerId,
59
60
  });
60
61
 
@@ -62,7 +63,7 @@ export function useAuth() {
62
63
  * Re-authenticate using existing session
63
64
  * Also updates user state and authenticates with BSMNT
64
65
  */
65
- const reAuthenticate = useCallback(async () => {
66
+ const reAuthenticate = useCallback(async (): Promise<Record<string, any>> => {
66
67
  debug("Re-authenticating...");
67
68
  try {
68
69
  const response = await app.reAuthenticate();
@@ -191,7 +192,7 @@ export function useAuth() {
191
192
  * 3. Authenticates with BSMNT for basement integration
192
193
  */
193
194
  const authenticate = useCallback(
194
- async (accessToken: string, partnerId: string, strategy = "thirdweb-jwt") => {
195
+ async (accessToken: string, partnerId: string, strategy = "thirdweb-jwt"): Promise<Record<string, any>> => {
195
196
  if (!accessToken) {
196
197
  throw new Error("Access token is required");
197
198
  }
@@ -1,7 +1,7 @@
1
1
  import app from "@b3dotfun/sdk/global-account/app";
2
2
  import { authenticateWithB3JWT } from "@b3dotfun/sdk/global-account/bsmnt";
3
3
  import { useAuthStore } from "@b3dotfun/sdk/global-account/react";
4
- import { ecosystemWalletId } from "@b3dotfun/sdk/shared/constants";
4
+ import { ecosystemWalletId, type EcosystemWallet } from "@b3dotfun/sdk/shared/constants";
5
5
  import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
6
6
  import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
7
7
  import { ConnectionOptions } from "@thirdweb-dev/wagmi-adapter";
@@ -63,7 +63,8 @@ export function useAuthentication(partnerId: string, { skipAutoConnect = false }
63
63
  const { switchAccount } = useSwitchAccount();
64
64
  debug("@@activeWagmiAccount", activeWagmiAccount);
65
65
 
66
- const wallet = ecosystemWallet(ecosystemWalletId, {
66
+ // Explicit annotation keeps the hook's declaration portable (TS2742).
67
+ const wallet: EcosystemWallet = ecosystemWallet(ecosystemWalletId, {
67
68
  partnerId: partnerId,
68
69
  });
69
70
 
@@ -120,7 +121,7 @@ export function useAuthentication(partnerId: string, { skipAutoConnect = false }
120
121
  }, [wallets, syncWagmi]);
121
122
 
122
123
  const authenticateUser = useCallback(
123
- async (wallet?: Wallet) => {
124
+ async (wallet?: Wallet): Promise<Record<string, any>> => {
124
125
  setHasStartedConnecting(true);
125
126
 
126
127
  if (!wallet) {
@@ -216,7 +217,7 @@ export function useAuthentication(partnerId: string, { skipAutoConnect = false }
216
217
  localStorage.removeItem("b3-user");
217
218
  }
218
219
 
219
- app.logout();
220
+ await app.logout();
220
221
  debug("@@logout:loggedOut");
221
222
 
222
223
  setIsAuthenticated(false);
@@ -2,12 +2,12 @@ import app from "@b3dotfun/sdk/global-account/app";
2
2
  import { useAuthStore, useB3Config } from "@b3dotfun/sdk/global-account/react";
3
3
  import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
4
4
  import { useCallback } from "react";
5
- import { betterAuthClient } from "../../better-auth-client";
5
+ import { getBetterAuthClient } from "../../better-auth-client";
6
6
  import { useUserQuery } from "./useUserQuery";
7
7
 
8
8
  const debug = debugB3React("useBetterAuth");
9
9
 
10
- export type BetterAuthSocialProvider = "google" | "discord" | "apple" | "github" | "slack" | "microsoft";
10
+ export type BetterAuthSocialProvider = "google" | "discord" | "apple" | "github" | "slack" | "microsoft" | "twitter";
11
11
 
12
12
  /** Thrown when email verification is required before the user can sign in. */
13
13
  export class EmailVerificationRequiredError extends Error {
@@ -34,7 +34,7 @@ export function useBetterAuth() {
34
34
  const setHasStartedConnecting = useAuthStore(state => state.setHasStartedConnecting);
35
35
 
36
36
  const exchangeForFeathersJWT = useCallback(
37
- async (sessionToken: string) => {
37
+ async (sessionToken: string): Promise<Record<string, any>> => {
38
38
  debug("Exchanging Better Auth token for Feathers JWT");
39
39
 
40
40
  const response = await app.authenticate({
@@ -65,7 +65,7 @@ export function useBetterAuth() {
65
65
  setIsAuthenticating(true);
66
66
 
67
67
  try {
68
- const result = await betterAuthClient.signIn.email({ email, password });
68
+ const result = await getBetterAuthClient().signIn.email({ email, password });
69
69
 
70
70
  if (result.error) {
71
71
  throw new Error(result.error.message || "Sign in failed");
@@ -93,7 +93,7 @@ export function useBetterAuth() {
93
93
  setIsAuthenticating(true);
94
94
 
95
95
  try {
96
- const result = await betterAuthClient.signUp.email({ email, password, name });
96
+ const result = await getBetterAuthClient().signUp.email({ email, password, name });
97
97
 
98
98
  if (result.error) {
99
99
  throw new Error(result.error.message || "Sign up failed");
@@ -104,7 +104,7 @@ export function useBetterAuth() {
104
104
  // requireEmailVerification is enabled — send verification email with
105
105
  // a callbackURL Better Auth redirects to after server-side verify.
106
106
  // Pass verifyCallbackURL to land on a dedicated confirmation page.
107
- await betterAuthClient.sendVerificationEmail({
107
+ await getBetterAuthClient().sendVerificationEmail({
108
108
  email,
109
109
  callbackURL: verifyCallbackURL || `${window.location.origin}?authStrategy=better-auth`,
110
110
  });
@@ -128,7 +128,7 @@ export function useBetterAuth() {
128
128
  setIsAuthenticating(true);
129
129
 
130
130
  try {
131
- const result = await betterAuthClient.signIn.social({
131
+ const result = await getBetterAuthClient().signIn.social({
132
132
  provider,
133
133
  callbackURL: window.location.href,
134
134
  });
@@ -151,7 +151,7 @@ export function useBetterAuth() {
151
151
  const requestPasswordReset = useCallback(async (email: string, redirectTo?: string) => {
152
152
  debug("Requesting password reset", { email });
153
153
 
154
- const result = await betterAuthClient.requestPasswordReset({
154
+ const result = await getBetterAuthClient().requestPasswordReset({
155
155
  email,
156
156
  redirectTo,
157
157
  });
@@ -167,7 +167,7 @@ export function useBetterAuth() {
167
167
  const resetPassword = useCallback(async (newPassword: string, token: string) => {
168
168
  debug("Resetting password");
169
169
 
170
- const result = await betterAuthClient.resetPassword({
170
+ const result = await getBetterAuthClient().resetPassword({
171
171
  newPassword,
172
172
  token,
173
173
  });
@@ -187,6 +187,6 @@ export function useBetterAuth() {
187
187
  requestPasswordReset,
188
188
  resetPassword,
189
189
  exchangeForFeathersJWT,
190
- betterAuthClient,
190
+ betterAuthClient: getBetterAuthClient(),
191
191
  };
192
192
  }
@@ -28,14 +28,23 @@ export function useClient() {
28
28
  }, []);
29
29
 
30
30
  const authenticateWithType = useCallback(
31
- async (type: ClientType, accessToken: string, identityToken: string, params?: Record<string, any>) => {
31
+ async (
32
+ type: ClientType,
33
+ accessToken: string,
34
+ identityToken: string,
35
+ params?: Record<string, any>,
36
+ ): Promise<Record<string, any> | null> => {
32
37
  return authenticateWithClient(type, accessToken, identityToken, params);
33
38
  },
34
39
  [],
35
40
  );
36
41
 
37
42
  const authenticateWithBoth = useCallback(
38
- async (accessToken: string, identityToken: string, params?: Record<string, any>) => {
43
+ async (
44
+ accessToken: string,
45
+ identityToken: string,
46
+ params?: Record<string, any>,
47
+ ): Promise<{ socket: Record<string, any> | null; rest: Record<string, any> | null; success: boolean }> => {
39
48
  return authenticateBoth(accessToken, identityToken, params);
40
49
  },
41
50
  [],
@@ -5,10 +5,17 @@ import { useEffect, useMemo, useState } from "react";
5
5
  import { viemAdapter } from "thirdweb/adapters/viem";
6
6
  import { useConnectedWallets, useWalletInfo } from "thirdweb/react";
7
7
  import { Wallet } from "thirdweb/wallets";
8
+ import type { WalletClient } from "viem";
8
9
 
9
10
  const debug = debugB3React("useFirstEOA");
10
11
 
11
- export function useFirstEOA(chain?: { id: number; name: string; rpc: string }) {
12
+ // Explicit return annotation keeps the hook's declaration portable (TS2742).
13
+ export function useFirstEOA(chain?: { id: number; name: string; rpc: string }): {
14
+ account: Wallet | undefined;
15
+ address: string | undefined;
16
+ info: ReturnType<typeof useWalletInfo>;
17
+ walletClient: WalletClient | undefined;
18
+ } {
12
19
  const wallets = useConnectedWallets();
13
20
  const isConnected = useAuthStore(state => state.isConnected);
14
21
  const [firstEOA, setFirstEOA] = useState<Wallet | undefined>(undefined);
@@ -41,7 +48,7 @@ export function useFirstEOA(chain?: { id: number; name: string; rpc: string }) {
41
48
  autoSelectFirstEOAWallet();
42
49
  }, [isConnected, wallets]);
43
50
 
44
- const walletClient = useMemo(() => {
51
+ const walletClient = useMemo<WalletClient | undefined>(() => {
45
52
  if (!firstEOA) return undefined;
46
53
  if (!chain) return undefined;
47
54
  try {
@@ -1,6 +1,6 @@
1
1
  import { toast } from "@b3dotfun/sdk/global-account/react";
2
2
  import { PUBLIC_BASE_RPC_URL } from "@b3dotfun/sdk/shared/constants";
3
- import { b3Mainnet, b3Testnet } from "@b3dotfun/sdk/shared/constants/chains/supported";
3
+ import { b3Mainnet, b3Testnet } from "@b3dotfun/sdk/shared/constants/chains/b3Chain";
4
4
  import { formatNumber } from "@b3dotfun/sdk/shared/utils/formatNumber";
5
5
  import { useQuery } from "@tanstack/react-query";
6
6
 
@@ -0,0 +1,89 @@
1
+ import { useQuery } from "@tanstack/react-query";
2
+ import {
3
+ adaptZerionPositions,
4
+ balanceMatchesToken,
5
+ type B3TokenBalance,
6
+ type ZerionPositionLike,
7
+ } from "@b3dotfun/sdk/shared/utils/zerionPositions";
8
+
9
+ /**
10
+ * Wallet holdings, read through the b3 portfolio proxy.
11
+ *
12
+ * The proxy holds the upstream API key server-side and authorizes browsers by Origin allowlist, so
13
+ * nothing secret ships to the client and no key is accepted from it. A consumer served from an
14
+ * origin the proxy does not know will be refused — adding an origin is a proxy config change, not
15
+ * an SDK change.
16
+ */
17
+ const PORTFOLIO_API_BASE_URL = "https://portfolio-api.b3.fun";
18
+
19
+ interface ZerionPositionsResponse {
20
+ data?: ZerionPositionLike[];
21
+ }
22
+
23
+ /**
24
+ * Fetch every spendable holding for a wallet in one request.
25
+ *
26
+ * Deliberately unpaginated and unfiltered by chain. The positions endpoint returns a wallet's full
27
+ * simple-position list in a single response, and passing a chain filter is actively harmful: the
28
+ * upstream rejects a handful of otherwise-valid chain slugs and fails the WHOLE request when one
29
+ * appears, so a caller asking for five chains can lose all five. Callers narrow the result instead.
30
+ */
31
+ async function fetchWalletPositions(address: string): Promise<B3TokenBalance[]> {
32
+ const url = `${PORTFOLIO_API_BASE_URL}/v1/wallets/${encodeURIComponent(address)}/positions/?filter[positions]=only_simple`;
33
+ const response = await fetch(url, { headers: { Accept: "application/json" } });
34
+
35
+ if (!response.ok) {
36
+ throw new Error(`Failed to fetch wallet balances: ${response.status} ${response.statusText}`);
37
+ }
38
+
39
+ const body = (await response.json()) as ZerionPositionsResponse;
40
+ return adaptZerionPositions(body.data ?? []);
41
+ }
42
+
43
+ /**
44
+ * Keyed by wallet alone so every consumer of the same wallet shares one fetch and one cache entry.
45
+ * Keying by the requested chain subset instead would refetch per caller and share nothing.
46
+ */
47
+ function walletPositionsQueryKey(address?: string) {
48
+ return ["walletPositions", address] as const;
49
+ }
50
+
51
+ /**
52
+ * Holdings for a wallet, optionally narrowed to specific chains.
53
+ *
54
+ * Read `isError` before reading `data`: a failed read and an empty wallet are different facts, and
55
+ * rendering the first as the second tells the user they hold nothing when nobody knows.
56
+ */
57
+ export function usePortfolioBalance(address?: string, chainIds?: number[]) {
58
+ const wantedChainIds = chainIds && chainIds.length > 0 ? chainIds : undefined;
59
+
60
+ return useQuery({
61
+ queryKey: walletPositionsQueryKey(address),
62
+ queryFn: () => {
63
+ if (!address) throw new Error("Address is required");
64
+ return fetchWalletPositions(address);
65
+ },
66
+ enabled: Boolean(address),
67
+ select: (balances: B3TokenBalance[]) =>
68
+ wantedChainIds ? balances.filter(balance => wantedChainIds.includes(balance.chain_id)) : balances,
69
+ });
70
+ }
71
+
72
+ /**
73
+ * One token's balance for a wallet, served from the same per-wallet fetch as {@link usePortfolioBalance}.
74
+ *
75
+ * `tokenAddress` may be a contract address or the chain's native sentinel; matching is
76
+ * case-insensitive because callers pass addresses in whatever casing their source used.
77
+ */
78
+ export function usePortfolioTokenBalance(walletAddress?: string, tokenAddress?: string, chainId?: number) {
79
+ return useQuery({
80
+ queryKey: walletPositionsQueryKey(walletAddress),
81
+ queryFn: () => {
82
+ if (!walletAddress) throw new Error("Address is required");
83
+ return fetchWalletPositions(walletAddress);
84
+ },
85
+ enabled: Boolean(walletAddress) && Boolean(tokenAddress) && Boolean(chainId),
86
+ select: (balances: B3TokenBalance[]) =>
87
+ balances.find(balance => balance.chain_id === chainId && balanceMatchesToken(balance, tokenAddress ?? "")),
88
+ });
89
+ }