@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
@@ -0,0 +1,247 @@
1
+ import { SOLANA_NATIVE_ASSET } from "@b3/chain-registry/runtime";
2
+
3
+ /**
4
+ * Canonical browser-side translation of Zerion wallet positions into B3 balance rows.
5
+ *
6
+ * This lives in the published SDK because every browser consumer needs it — the apps in this repo
7
+ * and the sites that install `@b3dotfun/sdk` from npm — and the in-repo Zerion client is a private
8
+ * workspace package that a published package cannot depend on. Backend services keep their own
9
+ * translation: pulling a browser SDK into a Node service to share one function is a worse trade
10
+ * than the second copy.
11
+ *
12
+ * Only the HTTP layer differs between callers. The rules below — which row counts as the chain's
13
+ * native coin, and which rows have no usable identity — must not be re-derived anywhere else.
14
+ */
15
+
16
+ /** Address B3 uses for a chain's native coin on EVM. Matches NATIVE_TOKEN_ADDRESSES. */
17
+ export const EVM_NATIVE_TOKEN_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
18
+ export const SOLANA_NATIVE_TOKEN_ADDRESS = SOLANA_NATIVE_ASSET.wrapped
19
+ .address as "So11111111111111111111111111111111111111112";
20
+ export const SOLANA_ZERION_SLUG = SOLANA_NATIVE_ASSET.chain as "solana";
21
+ /** What Zerion's `quantity.int` is: a base-10 integer, unbounded in length. */
22
+ const DECIMAL_INTEGER_PATTERN = /^\d+$/;
23
+ /** Solana's chain id as the chain registry defines it — the id every balance row is keyed by. */
24
+ export const SOLANA_CHAIN_ID = SOLANA_NATIVE_ASSET.chainId as 7565164;
25
+
26
+ /**
27
+ * Zerion chain slug → numeric chain id. Slugs are Zerion's own vocabulary and do not always match
28
+ * the chain's common name — Gnosis is `xdai`, Metis is `metis-andromeda` — so an entry invented
29
+ * from the chain name silently drops every position on that chain, because the adapter skips any
30
+ * slug it cannot map. Every entry here is taken from Zerion's `GET /v1/chains/`.
31
+ */
32
+ const ZERION_CHAIN_IDS: Readonly<Record<string, number>> = {
33
+ ethereum: 1,
34
+ optimism: 10,
35
+ "binance-smart-chain": 56,
36
+ xdai: 100,
37
+ unichain: 130,
38
+ polygon: 137,
39
+ sonic: 146,
40
+ fantom: 250,
41
+ "zksync-era": 324,
42
+ world: 480,
43
+ hyperevm: 999,
44
+ "metis-andromeda": 1088,
45
+ "polygon-zkevm": 1101,
46
+ soneium: 1868,
47
+ ronin: 2020,
48
+ abstract: 2741,
49
+ robinhood: 4663,
50
+ mantle: 5000,
51
+ base: 8453,
52
+ mode: 34443,
53
+ arbitrum: 42161,
54
+ celo: 42220,
55
+ avalanche: 43114,
56
+ linea: 59144,
57
+ berachain: 80094,
58
+ blast: 81457,
59
+ taiko: 167000,
60
+ scroll: 534352,
61
+ zora: 7777777,
62
+ degen: 666666666,
63
+ aurora: 1313161554,
64
+ [SOLANA_ZERION_SLUG]: SOLANA_CHAIN_ID,
65
+ };
66
+
67
+ // Maps rather than objects: a slug arrives straight off the wire, and an object lookup resolves an
68
+ // inherited key like `constructor` or `toString` to something truthy instead of reporting the chain
69
+ // as unknown — which would carry a row past the `=== undefined` guard with a function as its id.
70
+ const CHAIN_ID_BY_ZERION_SLUG: ReadonlyMap<string, number> = new Map(Object.entries(ZERION_CHAIN_IDS));
71
+
72
+ const ZERION_SLUG_BY_CHAIN_ID: ReadonlyMap<number, string> = new Map(
73
+ Object.entries(ZERION_CHAIN_IDS).map(([slug, id]) => [id, slug]),
74
+ );
75
+
76
+ export function zerionSlugToChainId(slug: string): number | undefined {
77
+ return CHAIN_ID_BY_ZERION_SLUG.get(slug);
78
+ }
79
+
80
+ export function chainIdToZerionSlug(chainId: number): string | undefined {
81
+ return ZERION_SLUG_BY_CHAIN_ID.get(chainId);
82
+ }
83
+
84
+ export interface ZerionPositionQuantity {
85
+ int?: string;
86
+ decimals?: number;
87
+ }
88
+
89
+ export interface ZerionPositionImplementation {
90
+ chain_id?: string;
91
+ address?: string | null;
92
+ decimals?: number;
93
+ }
94
+
95
+ export interface ZerionPositionFungibleInfo {
96
+ name?: string;
97
+ symbol?: string;
98
+ icon?: { url?: string } | null;
99
+ implementations?: ZerionPositionImplementation[];
100
+ }
101
+
102
+ export interface ZerionPositionLike {
103
+ id?: string;
104
+ attributes?: {
105
+ quantity?: ZerionPositionQuantity;
106
+ value?: number | null;
107
+ price?: number | null;
108
+ fungible_info?: ZerionPositionFungibleInfo;
109
+ flags?: { displayable?: boolean; is_trash?: boolean };
110
+ };
111
+ relationships?: { chain?: { data?: { id?: string } } };
112
+ }
113
+
114
+ /** One spendable holding. `amount` is the raw integer; pair it with `decimals` to display. */
115
+ export interface B3TokenBalance {
116
+ chain: string;
117
+ chain_id: number;
118
+ address: string;
119
+ amount: string;
120
+ symbol: string;
121
+ decimals: number;
122
+ /**
123
+ * Whether `address` is the native-coin sentinel rather than a real contract. Callers deciding
124
+ * between a value-bearing send and an ERC-20 `transfer` MUST branch on this, never on the
125
+ * sentinel string: getting it backwards spends gas and moves nothing.
126
+ */
127
+ is_native: boolean;
128
+ name?: string;
129
+ price_usd?: number;
130
+ value_usd?: number;
131
+ token_metadata?: { logo: string };
132
+ }
133
+
134
+ /**
135
+ * Zerion encodes a position's asset in the first hyphen-delimited segment of its resource `id`
136
+ * (`<assetRef>-<chainSlug>-<positionType>-…`). A chain's native coin uses the literal `base`
137
+ * (`base-polygon-asset-asset`); ERC-20s use the contract address
138
+ * (`0x1dd17…-ethereum-asset-asset`).
139
+ *
140
+ * This is the only reliable native signal. A falsy per-chain `implementation.address` looks
141
+ * equivalent and is not: Zerion reports Polygon's native coin at its `0x…1010` system contract and
142
+ * Celo's at a real ERC-20 address, while Polygon simultaneously carries a non-native fungible with
143
+ * the same `POL` symbol. Keying on the address shape misclassifies both.
144
+ */
145
+ function isNativePosition(id: string | undefined, impl: ZerionPositionImplementation | undefined): boolean {
146
+ if (id?.startsWith("base-") === true) return true;
147
+ // Second signal, for the chains that spell native as an absent address. It requires the
148
+ // implementation to EXIST: a fungible with no entry for this chain tells us nothing about what
149
+ // the row is, and calling that native would hand a value-bearing send an amount we cannot name.
150
+ return impl !== undefined && !impl.address;
151
+ }
152
+
153
+ export function nativeTokenAddressForChain(slug: string): string {
154
+ return slug === SOLANA_ZERION_SLUG ? SOLANA_NATIVE_TOKEN_ADDRESS : EVM_NATIVE_TOKEN_ADDRESS;
155
+ }
156
+
157
+ /**
158
+ * Every spelling of "the chain's own coin" a caller might hold.
159
+ *
160
+ * A token record's address depends on where it came from — a quote provider, a token list, a URL
161
+ * parameter — and each source names the native coin differently. Matching a balance row against any
162
+ * single one of these silently fails for the others.
163
+ */
164
+ const NATIVE_TOKEN_MARKERS: ReadonlySet<string> = new Set([
165
+ "native",
166
+ "0x0000000000000000000000000000000000000000",
167
+ EVM_NATIVE_TOKEN_ADDRESS,
168
+ SOLANA_NATIVE_TOKEN_ADDRESS.toLowerCase(),
169
+ "11111111111111111111111111111111",
170
+ ]);
171
+
172
+ /**
173
+ * Whether `balance` is the token identified by `tokenAddress`.
174
+ *
175
+ * Native coins are matched on the row's `is_native` flag rather than its printed address, because
176
+ * the caller and the adapter rarely spell the native coin the same way.
177
+ */
178
+ export function balanceMatchesToken(balance: B3TokenBalance, tokenAddress: string): boolean {
179
+ const wanted = tokenAddress.toLowerCase();
180
+ if (NATIVE_TOKEN_MARKERS.has(wanted)) return balance.is_native;
181
+ // Case-insensitive only for hex contract addresses. Solana mints are base58, where case is
182
+ // significant — lowercasing them would let two distinct mints compare equal.
183
+ if (balance.chain === SOLANA_ZERION_SLUG) return balance.address === tokenAddress;
184
+ return balance.address.toLowerCase() === wanted;
185
+ }
186
+
187
+ /**
188
+ * Adapt raw Zerion positions into balance rows, dropping any row we cannot describe honestly.
189
+ *
190
+ * A row is dropped when its chain slug is absent or unmapped, or when neither the quantity nor the
191
+ * chain implementation carries decimals — an amount rendered against a guessed scale is a wrong
192
+ * number presented as a real one, which is worse for the reader than a missing row.
193
+ *
194
+ * @param slugToChainId overrides slug resolution; return undefined to skip a chain entirely.
195
+ */
196
+ export function adaptZerionPositions(
197
+ positions: ZerionPositionLike[],
198
+ slugToChainId: (slug: string) => number | undefined = zerionSlugToChainId,
199
+ ): B3TokenBalance[] {
200
+ const out: B3TokenBalance[] = [];
201
+
202
+ for (const position of positions) {
203
+ const attributes = position.attributes ?? {};
204
+ const flags = attributes.flags;
205
+ if (flags && (flags.displayable === false || flags.is_trash === true)) continue;
206
+
207
+ const slug = position.relationships?.chain?.data?.id;
208
+ if (!slug) continue;
209
+
210
+ const chainId = slugToChainId(slug);
211
+ if (chainId === undefined) continue;
212
+
213
+ const fungibleInfo = attributes.fungible_info ?? {};
214
+ const implementation = (fungibleInfo.implementations ?? []).find(entry => entry.chain_id === slug);
215
+
216
+ const decimals = attributes.quantity?.decimals ?? implementation?.decimals;
217
+ if (decimals === undefined) continue;
218
+
219
+ const isNative = isNativePosition(position.id, implementation);
220
+ // A non-native row with no contract address has no on-chain identity — drop it rather than
221
+ // render a holding nothing can name.
222
+ const address = isNative ? nativeTokenAddressForChain(slug) : implementation?.address;
223
+ if (!address) continue;
224
+
225
+ // A quantity we cannot read is not a zero balance. Must be the base-10 integer `quantity.int`
226
+ // is: `null`, `""`, and any other unusable string all format to NaN, which callers coerce back
227
+ // to 0 and show as "holds none". `"0"` matches, so a real zero balance still comes through.
228
+ const amount = attributes.quantity?.int;
229
+ if (amount === undefined || !DECIMAL_INTEGER_PATTERN.test(amount)) continue;
230
+
231
+ out.push({
232
+ chain: slug,
233
+ chain_id: chainId,
234
+ address,
235
+ amount,
236
+ symbol: fungibleInfo.symbol ?? "",
237
+ decimals,
238
+ is_native: isNative,
239
+ name: fungibleInfo.name,
240
+ price_usd: attributes.price ?? undefined,
241
+ value_usd: attributes.value ?? undefined,
242
+ token_metadata: fungibleInfo.icon?.url ? { logo: fungibleInfo.icon.url } : undefined,
243
+ });
244
+ }
245
+
246
+ return out;
247
+ }
@@ -321,6 +321,33 @@ html[data-theme="dark"] .b3-root,
321
321
  padding: 0 !important;
322
322
  }
323
323
 
324
+ /*
325
+ * Relay Kit's "Unverified Token" confirmation dialog (rendered by the Relay
326
+ * TokenSelector inside the AnySpend modal) portals to <body> with its overlay
327
+ * at inline `z-index: 10001` and its content at `z-index: 1000` (inside that
328
+ * overlay). The AnySpend / B3 modal that hosts the TokenSelector — and the
329
+ * TokenSelector's own token-list overlay — get stacked at z-indexes >= 10001
330
+ * by host apps (b3os-web bumps `.b3-modal` to 10001 and the Relay token-list
331
+ * overlay to 10003), so this confirmation dialog ends up *behind* the modal it
332
+ * was launched from and becomes invisible / unclickable.
333
+ *
334
+ * Relay exposes no z-index theming, so force the confirmation overlay (and
335
+ * therefore its content, which lives inside it) above the host stack. The
336
+ * highest known host z-index is 10003 (b3os-web's Relay token-list overlay),
337
+ * so 99999 is comfortably sufficient. The `z-index: 10001` inline value is
338
+ * unique to Relay's UnverifiedTokenModal — its other modals (token list, etc.)
339
+ * default to `z-index: 9999`.
340
+ *
341
+ * NOTE: this selector is intentionally prefixed with `body` so it is NOT
342
+ * scoped under `.b3-root` by postcss-prefix-selector (see postcss.config.js).
343
+ * Relay's modal portals to <body>, OUTSIDE the `.b3-root` subtree, so a
344
+ * `.b3-root`-scoped rule would never match it.
345
+ */
346
+ body .relay-kit-reset[style*="z-index: 10001"],
347
+ body .relay-kit-reset[style*="z-index:10001"] {
348
+ z-index: 99999 !important;
349
+ }
350
+
324
351
  .b3-modal-back-button:hover {
325
352
  @apply border-none !text-black;
326
353
  }
@@ -1,10 +0,0 @@
1
- import type { Chain } from "thirdweb";
2
- import { Account } from "thirdweb/wallets";
3
- interface SignInWithB3PrivyProps {
4
- onError?: (error: Error) => Promise<void>;
5
- onSuccess: (account: Account) => Promise<void>;
6
- accessToken?: string;
7
- chain: Chain;
8
- }
9
- export declare function SignInWithB3Privy({ onSuccess, onError, chain }: SignInWithB3PrivyProps): import("react/jsx-runtime").JSX.Element;
10
- export {};
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SignInWithB3Privy = SignInWithB3Privy;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("../../../../global-account/react");
6
- const debug_1 = require("../../../../shared/utils/debug");
7
- const react_2 = require("react");
8
- const debug = (0, debug_1.debugB3React)("SignInWithB3Privy");
9
- function SignInWithB3Privy({ onSuccess, onError, chain }) {
10
- const { partnerId } = (0, react_1.useB3Config)();
11
- const { isLoading, connectTw, fullToken } = (0, react_1.useHandleConnectWithPrivy)(chain, onSuccess);
12
- const setIsAuthenticating = (0, react_1.useAuthStore)(state => state.setIsAuthenticating);
13
- const setIsAuthenticated = (0, react_1.useAuthStore)(state => state.setIsAuthenticated);
14
- const { logout } = (0, react_1.useAuthentication)(partnerId, { skipAutoConnect: true });
15
- debug("@@SignInWithB3Privy", {
16
- isLoading,
17
- fullToken,
18
- });
19
- (0, react_2.useEffect)(() => {
20
- async function autoConnect() {
21
- try {
22
- const connectResult = await connectTw();
23
- const account = connectResult?.getAccount();
24
- if (!account) {
25
- setIsAuthenticated(false);
26
- return;
27
- }
28
- await onSuccess(account);
29
- setIsAuthenticated(true);
30
- }
31
- catch (error) {
32
- console.error("Failed to connect:", error);
33
- await onError?.(error);
34
- await logout();
35
- setIsAuthenticated(false);
36
- }
37
- finally {
38
- debug("setIsAuthenticating:false:7");
39
- setIsAuthenticating(false);
40
- }
41
- }
42
- autoConnect();
43
- }, [connectTw, onSuccess, onError, setIsAuthenticated, logout, setIsAuthenticating]);
44
- // Currently we auto login, so we can show loading immediately and the onSuccess will proceed to the next modal
45
- return ((0, jsx_runtime_1.jsx)("div", { className: "flex aspect-square items-center justify-center p-6", children: (0, jsx_runtime_1.jsx)(react_1.Loading, { variant: "white", size: "lg" }) }));
46
- }
@@ -1,11 +0,0 @@
1
- import { Chain } from "thirdweb";
2
- import { Account } from "thirdweb/wallets";
3
- /**
4
- * This essentially wraps our useConnect hook to handle the Privy auth flow.
5
- * Currently, this is for the basement-privy strategy
6
- */
7
- export declare function useHandleConnectWithPrivy(chain?: Chain, onSuccess?: (account: Account) => void): {
8
- connectTw: () => Promise<import("thirdweb/wallets").Wallet | null | undefined>;
9
- isLoading: boolean;
10
- fullToken: string | null;
11
- };
@@ -1,70 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useHandleConnectWithPrivy = useHandleConnectWithPrivy;
4
- const react_1 = require("../../../global-account/react");
5
- const debug_1 = require("../../../shared/utils/debug");
6
- const react_auth_1 = require("@privy-io/react-auth");
7
- const react_2 = require("react");
8
- const debug = (0, debug_1.debugB3React)("@@b3:useHandleConnectWithPrivy");
9
- /**
10
- * This essentially wraps our useConnect hook to handle the Privy auth flow.
11
- * Currently, this is for the basement-privy strategy
12
- */
13
- function useHandleConnectWithPrivy(chain, onSuccess) {
14
- const { partnerId } = (0, react_1.useB3Config)();
15
- if (!chain) {
16
- throw new Error("Chain is required");
17
- }
18
- const { connect } = (0, react_1.useConnect)(partnerId, chain);
19
- const [isLoading, setIsLoading] = (0, react_2.useState)(true);
20
- const isConnecting = (0, react_2.useRef)(false);
21
- const { identityToken } = (0, react_auth_1.useIdentityToken)();
22
- const { getAccessToken } = (0, react_auth_1.usePrivy)();
23
- const [fullToken, setFullToken] = (0, react_2.useState)(null);
24
- const connectTw = (0, react_2.useCallback)(async () => {
25
- if (isConnecting.current) {
26
- debug("@@connectTw:skipping:isConnecting", isConnecting.current);
27
- return;
28
- }
29
- setIsLoading(true);
30
- isConnecting.current = true;
31
- // Form token
32
- const accessToken = await getAccessToken();
33
- const fullToken = `${accessToken}+${identityToken}`;
34
- setFullToken(fullToken);
35
- debug("@@connectTw:fullToken", fullToken);
36
- if (!fullToken)
37
- throw new Error("Token is not set");
38
- // Connect to TW via privy
39
- const wallet = await connect({
40
- strategy: "auth_endpoint",
41
- payload: JSON.stringify({
42
- strategy: "basement",
43
- accessToken: fullToken,
44
- }),
45
- });
46
- debug("@@useHandleConnectWithPrivy:connect:return", wallet);
47
- setIsLoading(false);
48
- // Handle onsuccess & more
49
- try {
50
- debug("@@autoLogin:starting", fullToken);
51
- const account = wallet?.getAccount();
52
- if (!account) {
53
- throw new Error("Failed to connect");
54
- }
55
- onSuccess?.(account);
56
- if (!account) {
57
- throw new Error("Failed to connect");
58
- }
59
- }
60
- catch (error) {
61
- console.error("@@Error signing in with Privy", error);
62
- }
63
- finally {
64
- isConnecting.current = false;
65
- setIsLoading(false);
66
- }
67
- return wallet;
68
- }, [connect, getAccessToken, identityToken, onSuccess]);
69
- return { connectTw, isLoading, fullToken };
70
- }
@@ -1,59 +0,0 @@
1
- export interface SimTokenMetadata {
2
- logo?: string;
3
- }
4
- export interface SimBalanceItem {
5
- chain: string;
6
- chain_id: number;
7
- address: string;
8
- amount: string;
9
- symbol: string;
10
- decimals: number;
11
- price_usd?: number;
12
- value_usd?: number;
13
- name?: string;
14
- token_metadata?: SimTokenMetadata;
15
- pool_size?: number;
16
- low_liquidity?: boolean;
17
- }
18
- export interface SimBalanceResponse {
19
- request_time: string;
20
- response_time: string;
21
- wallet_address: string;
22
- balances: SimBalanceItem[];
23
- }
24
- export interface SvmBalanceItem {
25
- chain: string;
26
- address: string;
27
- amount: string;
28
- balance: string;
29
- raw_balance: string;
30
- value_usd?: number;
31
- program_id: string | null;
32
- decimals: number;
33
- total_supply: string;
34
- metadata_address?: string;
35
- name?: string;
36
- symbol: string;
37
- uri?: string | null;
38
- price_usd?: number;
39
- liquidity_usd?: number;
40
- pool_type?: string | null;
41
- pool_address?: string | null;
42
- mint_authority?: string | null;
43
- }
44
- export interface SvmBalanceResponse {
45
- processing_time_ms?: number;
46
- wallet_address: string;
47
- next_offset?: string;
48
- balances_count?: number;
49
- balances: SvmBalanceItem[];
50
- }
51
- export declare function useSimBalance(address?: string, chainIdsParam?: number[]): import("@tanstack/react-query").UseQueryResult<SimBalanceResponse, Error>;
52
- export declare function useSimSvmBalance(address?: string, chains?: ("solana" | "eclipse")[], limit?: number): import("@tanstack/react-query").UseQueryResult<SvmBalanceResponse, Error>;
53
- /**
54
- * Hook to fetch a single token balance for a wallet.
55
- * @param walletAddress - The wallet address to fetch balance for
56
- * @param tokenAddress - The token contract address, or "native" for native token (ETH, etc.)
57
- * @param chainId - Chain ID to query (defaults to 1 for Ethereum mainnet)
58
- */
59
- export declare function useSimTokenBalance(walletAddress?: string, tokenAddress?: string, chainId?: number): import("@tanstack/react-query").UseQueryResult<SimBalanceResponse, Error>;
@@ -1,98 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useSimBalance = useSimBalance;
4
- exports.useSimSvmBalance = useSimSvmBalance;
5
- exports.useSimTokenBalance = useSimTokenBalance;
6
- const react_query_1 = require("@tanstack/react-query");
7
- const simdune_1 = require("../utils/simdune");
8
- async function fetchSimBalance(address, chainIdsParam) {
9
- if (!address)
10
- throw new Error("Address is required");
11
- const chainIds = chainIdsParam.length === 0 ? "mainnet" : chainIdsParam.join(",");
12
- const queryParams = new URLSearchParams();
13
- queryParams.append("metadata", "logo");
14
- queryParams.append("chain_ids", chainIds);
15
- queryParams.append("exclude_spam_tokens", "true");
16
- const url = (0, simdune_1.buildSimduneUrl)(`/v1/evm/balances/${address}`, queryParams);
17
- const response = await fetch(url);
18
- if (!response.ok) {
19
- throw new Error(`Failed to fetch balance: ${response.statusText}`);
20
- }
21
- const balanceData = await response.json();
22
- return balanceData;
23
- }
24
- async function fetchSimTokenBalance(walletAddress, tokenAddress, chainId) {
25
- if (!walletAddress)
26
- throw new Error("Wallet address is required");
27
- if (!tokenAddress)
28
- throw new Error("Token address is required");
29
- if (!chainId)
30
- throw new Error("Chain ID is required");
31
- const queryParams = new URLSearchParams();
32
- queryParams.append("chain_ids", chainId.toString());
33
- const url = (0, simdune_1.buildSimduneUrl)(`/v1/evm/balances/${walletAddress}/token/${tokenAddress}`, queryParams);
34
- const response = await fetch(url);
35
- if (!response.ok) {
36
- throw new Error(`Failed to fetch token balance: ${response.statusText}`);
37
- }
38
- const balanceData = await response.json();
39
- return balanceData;
40
- }
41
- async function fetchSimSvmBalance(address, chains, limit) {
42
- if (!address)
43
- throw new Error("Address is required");
44
- const queryParams = new URLSearchParams();
45
- if (chains && chains.length > 0) {
46
- queryParams.append("chains", chains.join(","));
47
- }
48
- if (limit) {
49
- queryParams.append("limit", limit.toString());
50
- }
51
- const url = (0, simdune_1.buildSimduneUrl)(`/beta/svm/balances/${address}`, queryParams.toString() ? queryParams : undefined);
52
- const response = await fetch(url);
53
- if (!response.ok) {
54
- throw new Error(`Failed to fetch SVM balance: ${response.statusText}`);
55
- }
56
- const balanceData = await response.json();
57
- return balanceData;
58
- }
59
- function useSimBalance(address, chainIdsParam) {
60
- return (0, react_query_1.useQuery)({
61
- queryKey: ["simBalance", address, chainIdsParam],
62
- queryFn: () => {
63
- if (!address)
64
- throw new Error("Address is required");
65
- return fetchSimBalance(address, chainIdsParam || []);
66
- },
67
- enabled: Boolean(address),
68
- });
69
- }
70
- function useSimSvmBalance(address, chains, limit) {
71
- return (0, react_query_1.useQuery)({
72
- queryKey: ["svmBalance", address, chains, limit],
73
- queryFn: () => {
74
- if (!address)
75
- throw new Error("Address is required");
76
- return fetchSimSvmBalance(address, chains, limit);
77
- },
78
- enabled: Boolean(address),
79
- });
80
- }
81
- /**
82
- * Hook to fetch a single token balance for a wallet.
83
- * @param walletAddress - The wallet address to fetch balance for
84
- * @param tokenAddress - The token contract address, or "native" for native token (ETH, etc.)
85
- * @param chainId - Chain ID to query (defaults to 1 for Ethereum mainnet)
86
- */
87
- function useSimTokenBalance(walletAddress, tokenAddress, chainId) {
88
- return (0, react_query_1.useQuery)({
89
- queryKey: ["simTokenBalance", walletAddress, tokenAddress, chainId],
90
- queryFn: () => {
91
- if (!walletAddress || !tokenAddress || !chainId) {
92
- throw new Error("Missing required parameters");
93
- }
94
- return fetchSimTokenBalance(walletAddress, tokenAddress, chainId);
95
- },
96
- enabled: Boolean(walletAddress) && Boolean(tokenAddress),
97
- });
98
- }
@@ -1,45 +0,0 @@
1
- import type { SimpleHashNFTResponse } from "../../../global-account/types/simplehash.types";
2
- export interface SimCollectibleMetadata {
3
- uri: string;
4
- attributes?: Array<{
5
- trait_type: string;
6
- value: string;
7
- display_type?: string | null;
8
- }>;
9
- }
10
- export interface SimCollectibleEntry {
11
- contract_address: string;
12
- token_standard: "ERC721" | "ERC1155";
13
- token_id: string;
14
- chain: string;
15
- chain_id: number;
16
- name?: string;
17
- description?: string;
18
- symbol?: string;
19
- image_url?: string;
20
- last_sale_price?: string;
21
- metadata?: SimCollectibleMetadata;
22
- is_spam?: boolean;
23
- spam_score?: number;
24
- explanations?: string[];
25
- balance?: string;
26
- last_acquired?: string;
27
- }
28
- export interface SimCollectiblesResponse {
29
- address: string;
30
- entries: SimCollectibleEntry[];
31
- next_offset?: string;
32
- request_time: string;
33
- response_time: string;
34
- }
35
- /**
36
- * Hook to fetch NFT collectibles from Simdune API.
37
- * Returns data in SimpleHash format for compatibility with AccountAssets component.
38
- * @param address - Wallet address to fetch collectibles for
39
- * @param chainIdsParam - Optional array of chain IDs to filter by
40
- * @param options - Optional parameters (limit, filterSpam)
41
- */
42
- export declare function useSimCollectibles(address?: string, chainIdsParam?: number[], options?: {
43
- limit?: number;
44
- filterSpam?: boolean;
45
- }): import("@tanstack/react-query").UseQueryResult<SimpleHashNFTResponse, Error>;