@b3dotfun/sdk 0.1.1-test.0 → 0.1.2-test.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (255) hide show
  1. package/dist/cjs/anyspend/react/components/AnySpend.js +2 -2
  2. package/dist/cjs/anyspend/react/components/AnySpendDeposit.d.ts +15 -10
  3. package/dist/cjs/anyspend/react/components/AnySpendDeposit.js +22 -14
  4. package/dist/cjs/anyspend/react/components/QRDeposit.js +31 -5
  5. package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +9 -2
  6. package/dist/cjs/anyspend/react/components/common/OrderDetails.js +1 -1
  7. package/dist/cjs/anyspend/react/components/common/PaymentStripeWeb2.js +1 -1
  8. package/dist/cjs/anyspend/react/components/common/TransferResultScreen.d.ts +22 -0
  9. package/dist/cjs/anyspend/react/components/common/TransferResultScreen.js +25 -0
  10. package/dist/cjs/anyspend/react/hooks/index.d.ts +1 -0
  11. package/dist/cjs/anyspend/react/hooks/index.js +1 -0
  12. package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +1 -1
  13. package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.js +1 -1
  14. package/dist/cjs/anyspend/react/hooks/useCreateDepositFirstOrder.js +1 -1
  15. package/dist/cjs/anyspend/react/hooks/useValidatedClientReferenceId.js +1 -1
  16. package/dist/cjs/anyspend/react/hooks/useWatchTransfer.d.ts +41 -0
  17. package/dist/cjs/anyspend/react/hooks/useWatchTransfer.js +75 -0
  18. package/dist/cjs/anyspend/utils/address.d.ts +5 -0
  19. package/dist/cjs/anyspend/utils/address.js +8 -0
  20. package/dist/cjs/global-account/react/components/AvatarEditor/AvatarEditor.js +1 -1
  21. package/dist/cjs/global-account/react/components/B3DynamicModal.js +5 -1
  22. package/dist/cjs/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +5 -0
  23. package/dist/cjs/global-account/react/components/B3Provider/AuthenticationProvider.js +12 -0
  24. package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +31 -0
  25. package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.js +37 -0
  26. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +3 -18
  27. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +7 -57
  28. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.d.ts +6 -6
  29. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +11 -35
  30. package/dist/cjs/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +3 -1
  31. package/dist/cjs/global-account/react/components/B3Provider/LocalSDKProvider.js +3 -1
  32. package/dist/cjs/global-account/react/components/B3Provider/useB3.d.ts +3 -3
  33. package/dist/cjs/global-account/react/components/B3Provider/useB3.js +4 -10
  34. package/dist/cjs/global-account/react/components/B3Provider/useB3Account.js +5 -2
  35. package/dist/cjs/global-account/react/components/B3Provider/useB3Config.d.ts +1 -9
  36. package/dist/cjs/global-account/react/components/B3Provider/useB3Config.js +2 -20
  37. package/dist/cjs/global-account/react/components/ManageAccount/ProfileSection.js +1 -2
  38. package/dist/cjs/global-account/react/components/ManageAccount/SettingsProfileCard.js +1 -1
  39. package/dist/cjs/global-account/react/components/ManageAccount/channels/DiscordChannel.js +1 -1
  40. package/dist/cjs/global-account/react/components/ManageAccount/channels/EmailChannel.js +1 -1
  41. package/dist/cjs/global-account/react/components/ManageAccount/channels/PhoneChannel.js +1 -1
  42. package/dist/cjs/global-account/react/components/ManageAccount/channels/TelegramChannel.js +1 -1
  43. package/dist/cjs/global-account/react/components/RequestPermissions/RequestPermissions.js +1 -1
  44. package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +1 -1
  45. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
  46. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +4 -2
  47. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -1
  48. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +1 -1
  49. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +1 -1
  50. package/dist/cjs/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.d.ts +64 -0
  51. package/dist/cjs/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.js +163 -0
  52. package/dist/cjs/global-account/react/components/SingleUserSearchSelector/index.d.ts +2 -0
  53. package/dist/cjs/global-account/react/components/SingleUserSearchSelector/index.js +5 -0
  54. package/dist/cjs/global-account/react/components/StyleRoot.js +2 -2
  55. package/dist/cjs/global-account/react/components/WalletImage/WalletImage.d.ts +1 -1
  56. package/dist/cjs/global-account/react/components/custom/ManageAccountButton.js +1 -2
  57. package/dist/cjs/global-account/react/components/index.d.ts +3 -2
  58. package/dist/cjs/global-account/react/components/index.js +6 -6
  59. package/dist/cjs/global-account/react/hooks/index.d.ts +1 -0
  60. package/dist/cjs/global-account/react/hooks/index.js +3 -1
  61. package/dist/cjs/global-account/react/hooks/useAuth.d.ts +2 -2
  62. package/dist/cjs/global-account/react/hooks/useAuth.js +2 -2
  63. package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +2 -2
  64. package/dist/cjs/global-account/react/hooks/useAuthentication.js +6 -3
  65. package/dist/cjs/global-account/react/hooks/useClient.js +1 -1
  66. package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.js +1 -1
  67. package/dist/cjs/global-account/react/hooks/useNotifications.js +1 -1
  68. package/dist/cjs/global-account/react/hooks/useProfile.js +4 -23
  69. package/dist/cjs/global-account/react/hooks/useTokenBalance.js +5 -5
  70. package/dist/cjs/global-account/react/hooks/useTurnkeyAuth.js +1 -1
  71. package/dist/cjs/global-account/react/hooks/useUser.d.ts +60 -0
  72. package/dist/cjs/global-account/react/hooks/useUser.js +20 -0
  73. package/dist/cjs/global-account/react/hooks/useUserQuery.d.ts +6 -7
  74. package/dist/cjs/global-account/react/hooks/useUserQuery.js +64 -39
  75. package/dist/cjs/global-account/react/index.native.d.ts +0 -2
  76. package/dist/cjs/global-account/react/index.native.js +1 -5
  77. package/dist/cjs/global-account/react/stores/useModalStore.d.ts +66 -1
  78. package/dist/cjs/global-account/react/stores/useModalStore.js +3 -0
  79. package/dist/cjs/global-account/react/stores/userStore.d.ts +22 -0
  80. package/dist/cjs/global-account/react/stores/userStore.js +30 -0
  81. package/dist/cjs/global-account/react/utils/profileApi.d.ts +13 -0
  82. package/dist/cjs/global-account/react/utils/profileApi.js +29 -0
  83. package/dist/esm/anyspend/react/components/AnySpend.js +3 -3
  84. package/dist/esm/anyspend/react/components/AnySpendDeposit.d.ts +15 -10
  85. package/dist/esm/anyspend/react/components/AnySpendDeposit.js +23 -15
  86. package/dist/esm/anyspend/react/components/QRDeposit.js +32 -6
  87. package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +10 -3
  88. package/dist/esm/anyspend/react/components/common/OrderDetails.js +2 -2
  89. package/dist/esm/anyspend/react/components/common/PaymentStripeWeb2.js +2 -2
  90. package/dist/esm/anyspend/react/components/common/TransferResultScreen.d.ts +22 -0
  91. package/dist/esm/anyspend/react/components/common/TransferResultScreen.js +22 -0
  92. package/dist/esm/anyspend/react/hooks/index.d.ts +1 -0
  93. package/dist/esm/anyspend/react/hooks/index.js +1 -0
  94. package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +2 -2
  95. package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.js +2 -2
  96. package/dist/esm/anyspend/react/hooks/useCreateDepositFirstOrder.js +2 -2
  97. package/dist/esm/anyspend/react/hooks/useValidatedClientReferenceId.js +2 -2
  98. package/dist/esm/anyspend/react/hooks/useWatchTransfer.d.ts +41 -0
  99. package/dist/esm/anyspend/react/hooks/useWatchTransfer.js +72 -0
  100. package/dist/esm/anyspend/utils/address.d.ts +5 -0
  101. package/dist/esm/anyspend/utils/address.js +7 -0
  102. package/dist/esm/global-account/react/components/AvatarEditor/AvatarEditor.js +2 -2
  103. package/dist/esm/global-account/react/components/B3DynamicModal.js +6 -2
  104. package/dist/esm/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +5 -0
  105. package/dist/esm/global-account/react/components/B3Provider/AuthenticationProvider.js +10 -0
  106. package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +31 -0
  107. package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.js +33 -0
  108. package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +3 -18
  109. package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +6 -58
  110. package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.d.ts +6 -6
  111. package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +10 -37
  112. package/dist/esm/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +3 -1
  113. package/dist/esm/global-account/react/components/B3Provider/LocalSDKProvider.js +3 -1
  114. package/dist/esm/global-account/react/components/B3Provider/useB3.d.ts +3 -3
  115. package/dist/esm/global-account/react/components/B3Provider/useB3.js +4 -10
  116. package/dist/esm/global-account/react/components/B3Provider/useB3Account.js +5 -2
  117. package/dist/esm/global-account/react/components/B3Provider/useB3Config.d.ts +1 -9
  118. package/dist/esm/global-account/react/components/B3Provider/useB3Config.js +1 -19
  119. package/dist/esm/global-account/react/components/ManageAccount/ProfileSection.js +2 -3
  120. package/dist/esm/global-account/react/components/ManageAccount/SettingsProfileCard.js +2 -2
  121. package/dist/esm/global-account/react/components/ManageAccount/channels/DiscordChannel.js +2 -2
  122. package/dist/esm/global-account/react/components/ManageAccount/channels/EmailChannel.js +2 -2
  123. package/dist/esm/global-account/react/components/ManageAccount/channels/PhoneChannel.js +2 -2
  124. package/dist/esm/global-account/react/components/ManageAccount/channels/TelegramChannel.js +2 -2
  125. package/dist/esm/global-account/react/components/RequestPermissions/RequestPermissions.js +2 -2
  126. package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +2 -2
  127. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
  128. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +5 -3
  129. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +2 -2
  130. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +2 -2
  131. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +2 -2
  132. package/dist/esm/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.d.ts +64 -0
  133. package/dist/esm/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.js +160 -0
  134. package/dist/esm/global-account/react/components/SingleUserSearchSelector/index.d.ts +2 -0
  135. package/dist/esm/global-account/react/components/SingleUserSearchSelector/index.js +1 -0
  136. package/dist/esm/global-account/react/components/StyleRoot.js +2 -2
  137. package/dist/esm/global-account/react/components/WalletImage/WalletImage.d.ts +1 -1
  138. package/dist/esm/global-account/react/components/custom/ManageAccountButton.js +2 -3
  139. package/dist/esm/global-account/react/components/index.d.ts +3 -2
  140. package/dist/esm/global-account/react/components/index.js +3 -2
  141. package/dist/esm/global-account/react/hooks/index.d.ts +1 -0
  142. package/dist/esm/global-account/react/hooks/index.js +1 -0
  143. package/dist/esm/global-account/react/hooks/useAuth.d.ts +2 -2
  144. package/dist/esm/global-account/react/hooks/useAuth.js +3 -3
  145. package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +2 -2
  146. package/dist/esm/global-account/react/hooks/useAuthentication.js +6 -3
  147. package/dist/esm/global-account/react/hooks/useClient.js +2 -2
  148. package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.js +2 -2
  149. package/dist/esm/global-account/react/hooks/useNotifications.js +2 -2
  150. package/dist/esm/global-account/react/hooks/useProfile.js +1 -20
  151. package/dist/esm/global-account/react/hooks/useTokenBalance.js +6 -6
  152. package/dist/esm/global-account/react/hooks/useTurnkeyAuth.js +2 -2
  153. package/dist/esm/global-account/react/hooks/useUser.d.ts +60 -0
  154. package/dist/esm/global-account/react/hooks/useUser.js +17 -0
  155. package/dist/esm/global-account/react/hooks/useUserQuery.d.ts +6 -7
  156. package/dist/esm/global-account/react/hooks/useUserQuery.js +63 -37
  157. package/dist/esm/global-account/react/index.native.d.ts +0 -2
  158. package/dist/esm/global-account/react/index.native.js +0 -2
  159. package/dist/esm/global-account/react/stores/useModalStore.d.ts +66 -1
  160. package/dist/esm/global-account/react/stores/useModalStore.js +3 -0
  161. package/dist/esm/global-account/react/stores/userStore.d.ts +22 -0
  162. package/dist/esm/global-account/react/stores/userStore.js +27 -0
  163. package/dist/esm/global-account/react/utils/profileApi.d.ts +13 -0
  164. package/dist/esm/global-account/react/utils/profileApi.js +25 -0
  165. package/dist/styles/index.css +1 -1
  166. package/dist/types/anyspend/react/components/AnySpendDeposit.d.ts +15 -10
  167. package/dist/types/anyspend/react/components/common/TransferResultScreen.d.ts +22 -0
  168. package/dist/types/anyspend/react/hooks/index.d.ts +1 -0
  169. package/dist/types/anyspend/react/hooks/useWatchTransfer.d.ts +41 -0
  170. package/dist/types/anyspend/utils/address.d.ts +5 -0
  171. package/dist/types/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +5 -0
  172. package/dist/types/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +31 -0
  173. package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +3 -18
  174. package/dist/types/global-account/react/components/B3Provider/B3Provider.native.d.ts +6 -6
  175. package/dist/types/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +3 -1
  176. package/dist/types/global-account/react/components/B3Provider/useB3.d.ts +3 -3
  177. package/dist/types/global-account/react/components/B3Provider/useB3Config.d.ts +1 -9
  178. package/dist/types/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
  179. package/dist/types/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.d.ts +64 -0
  180. package/dist/types/global-account/react/components/SingleUserSearchSelector/index.d.ts +2 -0
  181. package/dist/types/global-account/react/components/WalletImage/WalletImage.d.ts +1 -1
  182. package/dist/types/global-account/react/components/index.d.ts +3 -2
  183. package/dist/types/global-account/react/hooks/index.d.ts +1 -0
  184. package/dist/types/global-account/react/hooks/useAuth.d.ts +2 -2
  185. package/dist/types/global-account/react/hooks/useAuthentication.d.ts +2 -2
  186. package/dist/types/global-account/react/hooks/useUser.d.ts +60 -0
  187. package/dist/types/global-account/react/hooks/useUserQuery.d.ts +6 -7
  188. package/dist/types/global-account/react/index.native.d.ts +0 -2
  189. package/dist/types/global-account/react/stores/useModalStore.d.ts +66 -1
  190. package/dist/types/global-account/react/stores/userStore.d.ts +22 -0
  191. package/dist/types/global-account/react/utils/profileApi.d.ts +13 -0
  192. package/package.json +6 -1
  193. package/src/anyspend/react/components/AnySpend.tsx +3 -2
  194. package/src/anyspend/react/components/AnySpendDeposit.tsx +60 -42
  195. package/src/anyspend/react/components/QRDeposit.tsx +57 -5
  196. package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +13 -3
  197. package/src/anyspend/react/components/common/OrderDetails.tsx +2 -2
  198. package/src/anyspend/react/components/common/PaymentStripeWeb2.tsx +2 -2
  199. package/src/anyspend/react/components/common/TransferResultScreen.tsx +107 -0
  200. package/src/anyspend/react/hooks/index.ts +1 -0
  201. package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +2 -2
  202. package/src/anyspend/react/hooks/useAnyspendCreateOrder.ts +2 -2
  203. package/src/anyspend/react/hooks/useCreateDepositFirstOrder.ts +2 -2
  204. package/src/anyspend/react/hooks/useValidatedClientReferenceId.ts +2 -2
  205. package/src/anyspend/react/hooks/useWatchTransfer.ts +114 -0
  206. package/src/anyspend/utils/address.ts +13 -0
  207. package/src/global-account/react/components/AvatarEditor/AvatarEditor.tsx +2 -2
  208. package/src/global-account/react/components/B3DynamicModal.tsx +6 -2
  209. package/src/global-account/react/components/B3Provider/AuthenticationProvider.tsx +19 -0
  210. package/src/global-account/react/components/B3Provider/B3ConfigProvider.tsx +84 -0
  211. package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +26 -45
  212. package/src/global-account/react/components/B3Provider/B3Provider.tsx +15 -103
  213. package/src/global-account/react/components/B3Provider/LocalSDKProvider.tsx +5 -0
  214. package/src/global-account/react/components/B3Provider/useB3.ts +4 -12
  215. package/src/global-account/react/components/B3Provider/useB3Account.ts +6 -2
  216. package/src/global-account/react/components/B3Provider/useB3Config.ts +1 -34
  217. package/src/global-account/react/components/ManageAccount/ProfileSection.tsx +2 -4
  218. package/src/global-account/react/components/ManageAccount/SettingsProfileCard.tsx +2 -2
  219. package/src/global-account/react/components/ManageAccount/channels/DiscordChannel.tsx +2 -2
  220. package/src/global-account/react/components/ManageAccount/channels/EmailChannel.tsx +2 -2
  221. package/src/global-account/react/components/ManageAccount/channels/PhoneChannel.tsx +2 -2
  222. package/src/global-account/react/components/ManageAccount/channels/TelegramChannel.tsx +2 -2
  223. package/src/global-account/react/components/RequestPermissions/RequestPermissions.tsx +2 -2
  224. package/src/global-account/react/components/SignInWithB3/SignIn.tsx +2 -2
  225. package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +7 -3
  226. package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +2 -2
  227. package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +2 -2
  228. package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +2 -2
  229. package/src/global-account/react/components/SingleUserSearchSelector/README.md +266 -0
  230. package/src/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.tsx +330 -0
  231. package/src/global-account/react/components/SingleUserSearchSelector/index.ts +2 -0
  232. package/src/global-account/react/components/StyleRoot.tsx +2 -2
  233. package/src/global-account/react/components/custom/ManageAccountButton.tsx +2 -3
  234. package/src/global-account/react/components/index.ts +8 -2
  235. package/src/global-account/react/hooks/index.ts +1 -0
  236. package/src/global-account/react/hooks/useAuth.ts +3 -3
  237. package/src/global-account/react/hooks/useAuthentication.ts +7 -3
  238. package/src/global-account/react/hooks/useClient.ts +2 -2
  239. package/src/global-account/react/hooks/useHandleConnectWithPrivy.tsx +2 -2
  240. package/src/global-account/react/hooks/useNotifications.ts +2 -2
  241. package/src/global-account/react/hooks/useProfile.ts +1 -32
  242. package/src/global-account/react/hooks/useTokenBalance.tsx +8 -7
  243. package/src/global-account/react/hooks/useTurnkeyAuth.ts +2 -2
  244. package/src/global-account/react/hooks/useUser.ts +20 -0
  245. package/src/global-account/react/hooks/useUserQuery.ts +64 -51
  246. package/src/global-account/react/index.native.ts +0 -2
  247. package/src/global-account/react/stores/useModalStore.ts +70 -1
  248. package/src/global-account/react/stores/userStore.ts +41 -0
  249. package/src/global-account/react/utils/profileApi.ts +38 -0
  250. package/dist/cjs/global-account/react/components/B3Provider/types.d.ts +0 -27
  251. package/dist/cjs/global-account/react/components/B3Provider/types.js +0 -24
  252. package/dist/esm/global-account/react/components/B3Provider/types.d.ts +0 -27
  253. package/dist/esm/global-account/react/components/B3Provider/types.js +0 -21
  254. package/dist/types/global-account/react/components/B3Provider/types.d.ts +0 -27
  255. package/src/global-account/react/components/B3Provider/types.ts +0 -50
@@ -1,6 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { HYPERLIQUID_CHAIN_ID } from "../../../anyspend/index.js";
3
- import { Skeleton, useAccountWallet, useSimBalance } from "../../../global-account/react/index.js";
2
+ import { Skeleton, useAccountWallet, useSimBalance, useTokenData } from "../../../global-account/react/index.js";
4
3
  import { cn } from "../../../shared/utils/cn.js";
5
4
  import { NetworkArbitrumOne, NetworkBase, NetworkBinanceSmartChain, NetworkEthereum, NetworkOptimism, NetworkPolygonPos, } from "@web3icons/react";
6
5
  import { ChevronRight } from "lucide-react";
@@ -67,8 +66,8 @@ function ChainIcon({ chainId, className }) {
67
66
  * // Simple deposit with chain selection
68
67
  * <AnySpendDeposit
69
68
  * recipientAddress={userAddress}
70
- * destinationToken={myToken}
71
- * destinationChainId={base.id}
69
+ * destinationTokenAddress="0x..."
70
+ * destinationTokenChainId={base.id}
72
71
  * onSuccess={(amount) => console.log(`Deposited ${amount}`)}
73
72
  * />
74
73
  *
@@ -76,8 +75,8 @@ function ChainIcon({ chainId, className }) {
76
75
  * // Skip chain selection by providing sourceTokenChainId
77
76
  * <AnySpendDeposit
78
77
  * recipientAddress={userAddress}
79
- * destinationToken={myToken}
80
- * destinationChainId={base.id}
78
+ * destinationTokenAddress="0x..."
79
+ * destinationTokenChainId={base.id}
81
80
  * sourceTokenChainId={base.id}
82
81
  * onSuccess={(amount) => console.log(`Deposited ${amount}`)}
83
82
  * />
@@ -86,8 +85,8 @@ function ChainIcon({ chainId, className }) {
86
85
  * // Deposit with custom contract
87
86
  * <AnySpendDeposit
88
87
  * recipientAddress={userAddress}
89
- * destinationToken={myToken}
90
- * destinationChainId={base.id}
88
+ * destinationTokenAddress="0x..."
89
+ * destinationTokenChainId={base.id}
91
90
  * depositContractConfig={{
92
91
  * contractAddress: "0x...",
93
92
  * functionName: "depositFor",
@@ -95,7 +94,7 @@ function ChainIcon({ chainId, className }) {
95
94
  * onSuccess={(amount) => console.log(`Deposited ${amount}`)}
96
95
  * />
97
96
  */
98
- export function AnySpendDeposit({ loadOrder, mode = "modal", recipientAddress, paymentType: initialPaymentType, sourceTokenAddress, sourceTokenChainId: initialSourceChainId, destinationToken, destinationChainId, onSuccess, onOpenCustomModal, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, minDestinationAmount, header, orderType, depositContractConfig, showChainSelection, supportedChains = DEFAULT_SUPPORTED_CHAINS, minPoolSize = DEFAULT_MIN_POOL_SIZE, topChainsCount = 3, onClose, returnToHomeUrl, customRecipientLabel, returnHomeLabel, }) {
97
+ export function AnySpendDeposit({ loadOrder, mode = "modal", recipientAddress, paymentType: initialPaymentType, sourceTokenAddress, sourceTokenChainId: initialSourceChainId, destinationTokenAddress, destinationTokenChainId, onSuccess, onOpenCustomModal, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, minDestinationAmount, header, orderType, depositContractConfig, showChainSelection, supportedChains = DEFAULT_SUPPORTED_CHAINS, minPoolSize = DEFAULT_MIN_POOL_SIZE, topChainsCount = 3, onClose, returnToHomeUrl, customRecipientLabel, returnHomeLabel, isCustomDeposit = false, }) {
99
98
  const { connectedEOAWallet } = useAccountWallet();
100
99
  const eoaAddress = connectedEOAWallet?.getAccount()?.address;
101
100
  // Determine if we should show chain selection
@@ -103,6 +102,17 @@ export function AnySpendDeposit({ loadOrder, mode = "modal", recipientAddress, p
103
102
  const [step, setStep] = useState(shouldShowChainSelection ? "select-chain" : "deposit");
104
103
  const [selectedChainId, setSelectedChainId] = useState(initialSourceChainId);
105
104
  const [paymentType, setPaymentType] = useState(initialPaymentType ?? "crypto");
105
+ // Fetch destination token data
106
+ const { data: destinationTokenData } = useTokenData(destinationTokenChainId, destinationTokenAddress);
107
+ // Construct full destination token object
108
+ const destinationToken = useMemo(() => ({
109
+ address: destinationTokenAddress,
110
+ chainId: destinationTokenChainId,
111
+ symbol: destinationTokenData?.symbol ?? "",
112
+ name: destinationTokenData?.name ?? "",
113
+ decimals: destinationTokenData?.decimals ?? 18,
114
+ metadata: { logoURI: destinationTokenData?.logoURI },
115
+ }), [destinationTokenAddress, destinationTokenChainId, destinationTokenData]);
106
116
  // Fetch balances for EOA wallet
107
117
  const { data: balanceData, isLoading: isBalanceLoading } = useSimBalance(shouldShowChainSelection ? eoaAddress : undefined, supportedChains.map(c => c.id));
108
118
  // Group balances by chain and calculate total USD value per chain
@@ -145,7 +155,7 @@ export function AnySpendDeposit({ loadOrder, mode = "modal", recipientAddress, p
145
155
  }, [chainBalances]);
146
156
  if (!recipientAddress)
147
157
  return null;
148
- const tokenSymbol = destinationToken.symbol ?? "TOKEN";
158
+ const tokenSymbol = destinationToken.symbol || "TOKEN";
149
159
  // Determine order type based on config
150
160
  const effectiveOrderType = orderType ?? (depositContractConfig ? "custom_exact_in" : "swap");
151
161
  // Default header if not provided
@@ -174,14 +184,12 @@ export function AnySpendDeposit({ loadOrder, mode = "modal", recipientAddress, p
174
184
  };
175
185
  // Chain selection view
176
186
  if (step === "select-chain") {
177
- return (_jsxs("div", { className: cn("anyspend-deposit anyspend-deposit-chain-selection font-inter bg-as-surface-primary relative mx-auto w-full max-w-[460px]", mode === "page" && "border-as-border-secondary overflow-hidden rounded-2xl border shadow-xl"), children: [onClose && (_jsx("button", { onClick: onClose, className: "anyspend-deposit-close-button text-as-secondary hover:text-as-primary absolute right-4 top-4 z-10", children: _jsx("svg", { className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }) })), !isBalanceLoading && totalBalance > 0 && (_jsxs("div", { className: "anyspend-deposit-balance border-theme-border-secondary border-b p-5", children: [_jsx("p", { className: "anyspend-deposit-balance-label text-as-secondary text-sm", children: "Your Balance" }), _jsxs("p", { className: "anyspend-deposit-balance-value text-as-primary text-3xl font-semibold", children: [formatDecimal(totalBalance), " ", _jsx("span", { className: "text-sm", children: "USD" })] })] })), _jsxs("div", { className: "anyspend-deposit-options flex flex-col gap-2 p-6", children: [isBalanceLoading && (_jsx("div", { className: "anyspend-deposit-chains-skeleton flex flex-col gap-2", children: [1, 2].map((_, i) => (_jsxs("div", { className: "border-border-primary flex items-center justify-between rounded-xl border p-4", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx(Skeleton, { className: "h-6 w-6 rounded-full" }), _jsxs("div", { className: "flex flex-col gap-1", children: [_jsx(Skeleton, { className: "h-4 w-32" }), _jsx(Skeleton, { className: "h-3 w-20" })] })] }), _jsx(Skeleton, { className: "h-5 w-5" })] }, i))) })), topChainsWithBalance.length > 0 && (_jsx("div", { className: "anyspend-deposit-chains flex flex-col gap-2", children: topChainsWithBalance.map(chain => (_jsxs("button", { onClick: () => handleSelectChain(chain.id), className: "anyspend-deposit-chain-button border-border-primary hover:border-as-brand hover:bg-as-surface-secondary flex w-full items-center justify-between rounded-xl border p-4 text-left shadow-sm transition-all", children: [_jsx("div", { className: "anyspend-deposit-chain-content", children: _jsxs("div", { className: "anyspend-deposit-chain-info", children: [_jsxs("span", { className: "anyspend-deposit-chain-name text-as-primary flex items-center gap-1.5 font-medium", children: ["Deposit from ", chain.name, _jsx(ChainIcon, { chainId: chain.id, className: "h-5 w-5" })] }), _jsxs("p", { className: "anyspend-deposit-chain-balance text-as-secondary text-xs", children: [formatUsd(chain.balance), " available"] })] }) }), _jsx(ChevronRight, { className: "anyspend-deposit-chain-chevron text-as-secondary h-5 w-5" })] }, chain.id))) })), _jsxs("div", { className: "anyspend-deposit-general-options flex flex-col gap-2", children: [_jsxs("button", { onClick: handleSelectCrypto, className: "anyspend-deposit-option-button anyspend-deposit-crypto-button border-border-primary hover:border-as-brand hover:bg-as-surface-secondary flex w-full items-center justify-between rounded-xl border p-4 text-left shadow-sm transition-all", children: [_jsx("div", { className: "anyspend-deposit-option-content", children: _jsxs("div", { className: "anyspend-deposit-option-info", children: [_jsx("span", { className: "anyspend-deposit-option-title text-as-primary font-medium", children: "Deposit Crypto" }), _jsx("p", { className: "anyspend-deposit-option-description text-as-secondary text-xs", children: "Swap from any token on any chain" })] }) }), _jsx(ChevronRight, { className: "anyspend-deposit-option-chevron text-as-secondary h-5 w-5" })] }), _jsxs("div", { className: "anyspend-deposit-divider flex items-center gap-3", children: [_jsx("div", { className: "bg-as-stroke h-px flex-1" }), _jsx("span", { className: "anyspend-deposit-divider-text text-as-secondary text-sm", children: "More options" }), _jsx("div", { className: "bg-as-stroke h-px flex-1" })] }), _jsxs("button", { onClick: handleSelectQrDeposit, className: "anyspend-deposit-option-button anyspend-deposit-qr-button border-border-primary hover:border-as-brand hover:bg-as-surface-secondary flex w-full items-center justify-between rounded-xl border p-4 text-left shadow-sm transition-all", children: [_jsxs("div", { className: "anyspend-deposit-option-content flex items-center gap-3", children: [_jsx(QrCodeIcon, { className: "anyspend-deposit-option-icon h-10 w-10" }), _jsxs("div", { className: "anyspend-deposit-option-info", children: [_jsx("span", { className: "anyspend-deposit-option-title text-as-primary font-medium", children: "Deposit with QR Code" }), _jsx("p", { className: "anyspend-deposit-option-description text-as-secondary text-xs", children: "Send tokens directly to deposit address" })] })] }), _jsx(ChevronRight, { className: "anyspend-deposit-option-chevron text-as-secondary h-5 w-5" })] }), _jsxs("button", { onClick: handleSelectFiat, className: "anyspend-deposit-option-button anyspend-deposit-fiat-button border-border-primary hover:border-as-brand hover:bg-as-surface-secondary flex w-full items-center justify-between rounded-xl border p-4 text-left transition-all", children: [_jsxs("div", { className: "anyspend-deposit-option-content flex items-center gap-3", children: [_jsx(CreditCardIcon, { className: "anyspend-deposit-option-icon h-10 w-10" }), _jsxs("div", { className: "anyspend-deposit-option-info", children: [_jsx("span", { className: "anyspend-deposit-option-title text-as-primary font-medium", children: "Fund with Fiat" }), _jsx("p", { className: "anyspend-deposit-option-description text-as-secondary text-xs", children: "Pay with card or bank transfer" })] })] }), _jsx(ChevronRight, { className: "anyspend-deposit-option-chevron text-as-secondary h-5 w-5" })] })] }), _jsx(ChainWarningText, { chainId: destinationChainId, className: "mt-2" })] })] }));
187
+ return (_jsxs("div", { className: cn("anyspend-deposit anyspend-deposit-chain-selection font-inter bg-as-surface-primary relative mx-auto w-full max-w-[460px]", mode === "page" && "border-as-border-secondary overflow-hidden rounded-2xl border shadow-xl"), children: [onClose && (_jsx("button", { onClick: onClose, className: "anyspend-deposit-close-button text-as-secondary hover:text-as-primary absolute right-4 top-4 z-10", children: _jsx("svg", { className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }) })), !isBalanceLoading && totalBalance > 0 && (_jsxs("div", { className: "anyspend-deposit-balance border-theme-border-secondary border-b p-5", children: [_jsx("p", { className: "anyspend-deposit-balance-label text-as-secondary text-sm", children: "Your Balance" }), _jsxs("p", { className: "anyspend-deposit-balance-value text-as-primary text-3xl font-semibold", children: [formatDecimal(totalBalance), " ", _jsx("span", { className: "text-sm", children: "USD" })] })] })), _jsxs("div", { className: "anyspend-deposit-options flex flex-col gap-2 p-6", children: [isBalanceLoading && (_jsx("div", { className: "anyspend-deposit-chains-skeleton flex flex-col gap-2", children: [1, 2].map((_, i) => (_jsxs("div", { className: "border-border-primary flex items-center justify-between rounded-xl border p-4", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx(Skeleton, { className: "h-6 w-6 rounded-full" }), _jsxs("div", { className: "flex flex-col gap-1", children: [_jsx(Skeleton, { className: "h-4 w-32" }), _jsx(Skeleton, { className: "h-3 w-20" })] })] }), _jsx(Skeleton, { className: "h-5 w-5" })] }, i))) })), topChainsWithBalance.length > 0 && (_jsx("div", { className: "anyspend-deposit-chains flex flex-col gap-2", children: topChainsWithBalance.map(chain => (_jsxs("button", { onClick: () => handleSelectChain(chain.id), className: "anyspend-deposit-chain-button border-border-primary hover:border-as-brand hover:bg-as-surface-secondary flex w-full items-center justify-between rounded-xl border p-4 text-left shadow-sm transition-all", children: [_jsx("div", { className: "anyspend-deposit-chain-content", children: _jsxs("div", { className: "anyspend-deposit-chain-info", children: [_jsxs("span", { className: "anyspend-deposit-chain-name text-as-primary flex items-center gap-1.5 font-medium", children: ["Deposit from ", chain.name, _jsx(ChainIcon, { chainId: chain.id, className: "h-5 w-5" })] }), _jsxs("p", { className: "anyspend-deposit-chain-balance text-as-secondary text-xs", children: [formatUsd(chain.balance), " available"] })] }) }), _jsx(ChevronRight, { className: "anyspend-deposit-chain-chevron text-as-secondary h-5 w-5" })] }, chain.id))) })), _jsxs("div", { className: "anyspend-deposit-general-options flex flex-col gap-2", children: [_jsxs("button", { onClick: handleSelectCrypto, className: "anyspend-deposit-option-button anyspend-deposit-crypto-button border-border-primary hover:border-as-brand hover:bg-as-surface-secondary flex w-full items-center justify-between rounded-xl border p-4 text-left shadow-sm transition-all", children: [_jsx("div", { className: "anyspend-deposit-option-content", children: _jsxs("div", { className: "anyspend-deposit-option-info", children: [_jsx("span", { className: "anyspend-deposit-option-title text-as-primary font-medium", children: "Deposit Crypto" }), _jsx("p", { className: "anyspend-deposit-option-description text-as-secondary text-xs", children: "Swap from any token on any chain" })] }) }), _jsx(ChevronRight, { className: "anyspend-deposit-option-chevron text-as-secondary h-5 w-5" })] }), _jsxs("div", { className: "anyspend-deposit-divider flex items-center gap-3", children: [_jsx("div", { className: "bg-as-stroke h-px flex-1" }), _jsx("span", { className: "anyspend-deposit-divider-text text-as-secondary text-sm", children: "More options" }), _jsx("div", { className: "bg-as-stroke h-px flex-1" })] }), _jsxs("button", { onClick: handleSelectQrDeposit, className: "anyspend-deposit-option-button anyspend-deposit-qr-button border-border-primary hover:border-as-brand hover:bg-as-surface-secondary flex w-full items-center justify-between rounded-xl border p-4 text-left shadow-sm transition-all", children: [_jsxs("div", { className: "anyspend-deposit-option-content flex items-center gap-3", children: [_jsx(QrCodeIcon, { className: "anyspend-deposit-option-icon h-10 w-10" }), _jsxs("div", { className: "anyspend-deposit-option-info", children: [_jsx("span", { className: "anyspend-deposit-option-title text-as-primary font-medium", children: "Deposit with QR Code" }), _jsx("p", { className: "anyspend-deposit-option-description text-as-secondary text-xs", children: "Send tokens directly to deposit address" })] })] }), _jsx(ChevronRight, { className: "anyspend-deposit-option-chevron text-as-secondary h-5 w-5" })] }), _jsxs("button", { onClick: handleSelectFiat, className: "anyspend-deposit-option-button anyspend-deposit-fiat-button border-border-primary hover:border-as-brand hover:bg-as-surface-secondary flex w-full items-center justify-between rounded-xl border p-4 text-left transition-all", children: [_jsxs("div", { className: "anyspend-deposit-option-content flex items-center gap-3", children: [_jsx(CreditCardIcon, { className: "anyspend-deposit-option-icon h-10 w-10" }), _jsxs("div", { className: "anyspend-deposit-option-info", children: [_jsx("span", { className: "anyspend-deposit-option-title text-as-primary font-medium", children: "Fund with Fiat" }), _jsx("p", { className: "anyspend-deposit-option-description text-as-secondary text-xs", children: "Pay with card or bank transfer" })] })] }), _jsx(ChevronRight, { className: "anyspend-deposit-option-chevron text-as-secondary h-5 w-5" })] })] }), _jsx(ChainWarningText, { chainId: destinationTokenChainId, className: "mt-2" })] })] }));
178
188
  }
179
189
  // QR Deposit view
180
190
  if (step === "qr-deposit") {
181
- return (_jsx(QRDeposit, { mode: mode, recipientAddress: recipientAddress, destinationToken: destinationToken, destinationChainId: destinationChainId, depositContractConfig: depositContractConfig, onBack: handleBack, onClose: onClose ?? handleBack }));
191
+ return (_jsx(QRDeposit, { mode: mode, recipientAddress: recipientAddress, destinationToken: destinationToken, destinationChainId: destinationTokenChainId, depositContractConfig: depositContractConfig, onBack: handleBack, onClose: onClose ?? handleBack }));
182
192
  }
183
- // Check if destination is Hyperliquid
184
- const isHyperliquidDeposit = destinationChainId === HYPERLIQUID_CHAIN_ID;
185
193
  // Deposit view
186
- return (_jsxs("div", { className: "anyspend-deposit anyspend-deposit-form relative", children: [shouldShowChainSelection && (_jsxs("button", { onClick: handleBack, className: "anyspend-deposit-back-button text-as-secondary hover:text-as-primary absolute left-4 top-4 z-10 flex items-center gap-1", children: [_jsx("svg", { className: "anyspend-deposit-back-icon h-5 w-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 19l-7-7 7-7" }) }), _jsx("span", { className: "anyspend-deposit-back-text text-sm", children: "Back" })] })), onClose && (_jsx("button", { onClick: onClose, className: "anyspend-deposit-close-button text-as-secondary hover:text-as-primary absolute right-4 top-4 z-10", children: _jsx("svg", { className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }) })), _jsx("div", { className: cn("anyspend-deposit-form-content", shouldShowChainSelection && "pt-8"), children: isHyperliquidDeposit ? (_jsx(AnySpend, { loadOrder: loadOrder, mode: mode, defaultActiveTab: paymentType, recipientAddress: recipientAddress, sourceChainId: selectedChainId, destinationTokenAddress: destinationToken.address, destinationTokenChainId: destinationChainId, onSuccess: txHash => onSuccess?.(txHash ?? ""), onTokenSelect: onTokenSelect, customUsdInputValues: customUsdInputValues, hideHeader: true, hideBottomNavigation: true, disableUrlParamManagement: true, returnToHomeUrl: returnToHomeUrl, customRecipientLabel: customRecipientLabel, returnHomeLabel: returnHomeLabel }, selectedChainId)) : (_jsx(AnySpendCustomExactIn, { loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, paymentType: paymentType, sourceTokenAddress: sourceTokenAddress, sourceTokenChainId: selectedChainId, destinationToken: destinationToken, destinationChainId: destinationChainId, orderType: effectiveOrderType, minDestinationAmount: minDestinationAmount, header: header ?? defaultHeader, onSuccess: onSuccess, onOpenCustomModal: onOpenCustomModal, mainFooter: mainFooter, onTokenSelect: onTokenSelect, customUsdInputValues: customUsdInputValues, preferEoa: preferEoa, customExactInConfig: depositContractConfig, returnToHomeUrl: returnToHomeUrl, customRecipientLabel: customRecipientLabel, returnHomeLabel: returnHomeLabel }, selectedChainId)) }), _jsx(ChainWarningText, { chainId: destinationChainId, className: "px-4 pb-4" })] }));
194
+ return (_jsxs("div", { className: "anyspend-deposit anyspend-deposit-form relative", children: [shouldShowChainSelection && (_jsxs("button", { onClick: handleBack, className: "anyspend-deposit-back-button text-as-secondary hover:text-as-primary absolute left-4 top-4 z-10 flex items-center gap-1", children: [_jsx("svg", { className: "anyspend-deposit-back-icon h-5 w-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 19l-7-7 7-7" }) }), _jsx("span", { className: "anyspend-deposit-back-text text-sm", children: "Back" })] })), onClose && (_jsx("button", { onClick: onClose, className: "anyspend-deposit-close-button text-as-secondary hover:text-as-primary absolute right-4 top-4 z-10", children: _jsx("svg", { className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }) })), _jsx("div", { className: cn("anyspend-deposit-form-content", shouldShowChainSelection && "pt-8"), children: isCustomDeposit ? (_jsx(AnySpendCustomExactIn, { loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, paymentType: paymentType, sourceTokenAddress: sourceTokenAddress, sourceTokenChainId: selectedChainId, destinationToken: destinationToken, destinationChainId: destinationTokenChainId, orderType: effectiveOrderType, minDestinationAmount: minDestinationAmount, header: header ?? defaultHeader, onSuccess: onSuccess, onOpenCustomModal: onOpenCustomModal, mainFooter: mainFooter, onTokenSelect: onTokenSelect, customUsdInputValues: customUsdInputValues, preferEoa: preferEoa, customExactInConfig: depositContractConfig, returnToHomeUrl: returnToHomeUrl, customRecipientLabel: customRecipientLabel, returnHomeLabel: returnHomeLabel }, selectedChainId)) : (_jsx(AnySpend, { loadOrder: loadOrder, mode: mode, defaultActiveTab: paymentType, recipientAddress: recipientAddress, sourceChainId: selectedChainId, destinationTokenAddress: destinationTokenAddress, destinationTokenChainId: destinationTokenChainId, onSuccess: txHash => onSuccess?.(txHash ?? ""), onTokenSelect: onTokenSelect, customUsdInputValues: customUsdInputValues, hideHeader: true, hideBottomNavigation: true, disableUrlParamManagement: true, returnToHomeUrl: returnToHomeUrl, customRecipientLabel: customRecipientLabel, returnHomeLabel: returnHomeLabel }, selectedChainId)) }), _jsx(ChainWarningText, { chainId: destinationTokenChainId, className: "px-4 pb-4" })] }));
187
195
  }
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { ALL_CHAINS, getAvailableChainIds } from "../../../anyspend/index.js";
2
+ import { ALL_CHAINS, getAvailableChainIds, isSameChainAndToken } from "../../../anyspend/index.js";
3
3
  import { Button, toast } from "../../../global-account/react/index.js";
4
4
  import { cn } from "../../../shared/utils/cn.js";
5
5
  import { TokenSelector } from "@relayprotocol/relay-kit-ui";
@@ -8,8 +8,10 @@ import { QRCodeSVG } from "qrcode.react";
8
8
  import { useEffect, useRef, useState } from "react";
9
9
  import { useAnyspendOrderAndTransactions } from "../hooks/useAnyspendOrderAndTransactions.js";
10
10
  import { useCreateDepositFirstOrder } from "../hooks/useCreateDepositFirstOrder.js";
11
+ import { useWatchTransfer } from "../hooks/useWatchTransfer.js";
11
12
  import { ChainTokenIcon } from "./common/ChainTokenIcon.js";
12
13
  import { OrderDetails } from "./common/OrderDetails.js";
14
+ import { TransferResultScreen } from "./common/TransferResultScreen.js";
13
15
  import { ChainWarningText, WarningText } from "./common/WarningText.js";
14
16
  // Default source token: ETH on Base
15
17
  const DEFAULT_ETH_ON_BASE = {
@@ -42,9 +44,24 @@ export function QRDeposit({ mode = "modal", recipientAddress, sourceToken: sourc
42
44
  const [globalAddress, setGlobalAddress] = useState();
43
45
  const orderCreatedRef = useRef(false);
44
46
  const onSuccessCalled = useRef(false);
47
+ const [transferResult, setTransferResult] = useState(null);
45
48
  // Source token/chain as state (can be changed by user)
46
49
  const [sourceChainId, setSourceChainId] = useState(sourceChainIdProp ?? 8453);
47
50
  const [sourceToken, setSourceToken] = useState(sourceTokenProp ?? DEFAULT_ETH_ON_BASE);
51
+ // Check if this is a pure transfer (same chain and token)
52
+ const isPureTransfer = isSameChainAndToken(sourceChainId, sourceToken.address, destinationChainId, destinationToken.address);
53
+ // Watch for pure transfers (same chain and token)
54
+ const { isWatching: isWatchingTransfer } = useWatchTransfer({
55
+ address: recipientAddress,
56
+ chainId: sourceChainId,
57
+ tokenAddress: sourceToken.address,
58
+ tokenDecimals: sourceToken.decimals,
59
+ enabled: isPureTransfer && !transferResult,
60
+ onTransferDetected: result => {
61
+ setTransferResult(result);
62
+ onSuccess?.();
63
+ },
64
+ });
48
65
  // Handle token selection from TokenSelector
49
66
  const handleTokenSelect = (newToken) => {
50
67
  const token = {
@@ -59,6 +76,7 @@ export function QRDeposit({ mode = "modal", recipientAddress, sourceToken: sourc
59
76
  setOrderId(undefined);
60
77
  setGlobalAddress(undefined);
61
78
  orderCreatedRef.current = false;
79
+ setTransferResult(null);
62
80
  // Update token and chain
63
81
  setSourceChainId(newToken.chainId);
64
82
  setSourceToken(token);
@@ -79,10 +97,12 @@ export function QRDeposit({ mode = "modal", recipientAddress, sourceToken: sourc
79
97
  });
80
98
  // Fetch order status
81
99
  const { orderAndTransactions: oat } = useAnyspendOrderAndTransactions(orderId);
82
- // Create order on mount
100
+ // Create order on mount (skip for pure transfers)
83
101
  useEffect(() => {
84
102
  if (orderCreatedRef.current)
85
103
  return;
104
+ if (isPureTransfer)
105
+ return; // Skip order creation for pure transfers
86
106
  orderCreatedRef.current = true;
87
107
  createOrder({
88
108
  recipientAddress,
@@ -102,6 +122,7 @@ export function QRDeposit({ mode = "modal", recipientAddress, sourceToken: sourc
102
122
  creatorAddress,
103
123
  depositContractConfig,
104
124
  createOrder,
125
+ isPureTransfer,
105
126
  ]);
106
127
  // Call onSuccess when order is executed
107
128
  useEffect(() => {
@@ -115,7 +136,8 @@ export function QRDeposit({ mode = "modal", recipientAddress, sourceToken: sourc
115
136
  useEffect(() => {
116
137
  onSuccessCalled.current = false;
117
138
  }, [orderId]);
118
- const displayAddress = globalAddress || recipientAddress;
139
+ // For pure transfers, always use recipient address; for orders, use global address
140
+ const displayAddress = isPureTransfer ? recipientAddress : globalAddress || recipientAddress;
119
141
  const handleCopyAddress = async () => {
120
142
  if (displayAddress) {
121
143
  await navigator.clipboard.writeText(displayAddress);
@@ -131,13 +153,17 @@ export function QRDeposit({ mode = "modal", recipientAddress, sourceToken: sourc
131
153
  setCopied(false);
132
154
  onClose?.();
133
155
  };
156
+ // Show transfer result screen for completed pure transfers
157
+ if (isPureTransfer && transferResult) {
158
+ return (_jsx(TransferResultScreen, { mode: mode, transferResult: transferResult, token: sourceToken, chainId: sourceChainId, recipientAddress: recipientAddress, onBack: onBack, onClose: onClose }));
159
+ }
134
160
  // Show order details if order has deposits or is being processed
135
161
  if (oat?.data && oat.data.depositTxs && oat.data.depositTxs.length > 0) {
136
162
  return (_jsx("div", { className: cn("anyspend-container anyspend-qr-order-details font-inter bg-as-surface-primary mx-auto w-full max-w-[460px] p-6", mode === "page" && "border-as-border-secondary overflow-hidden rounded-2xl border shadow-xl"), children: _jsx("div", { className: "anyspend-qr-order-details-content relative flex flex-col gap-4", children: _jsx(OrderDetails, { mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTxs: oat.data.relayTxs, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, onBack: handleBack }) }) }));
137
163
  }
138
- // Show loading state while creating order (but not if we already have an orderId)
139
- if (isCreatingOrder && !orderId) {
164
+ // Show loading state while creating order (but not if we already have an orderId or for pure transfers)
165
+ if (isCreatingOrder && !orderId && !isPureTransfer) {
140
166
  return (_jsx("div", { className: cn("anyspend-container anyspend-qr-loading font-inter bg-as-surface-primary mx-auto w-full max-w-[460px] p-6", mode === "page" && "border-as-border-secondary overflow-hidden rounded-2xl border shadow-xl"), children: _jsxs("div", { className: "anyspend-qr-loading-content flex flex-col items-center justify-center gap-4 py-12", children: [_jsx(Loader2, { className: "anyspend-qr-loading-spinner text-as-brand h-8 w-8 animate-spin" }), _jsx("p", { className: "anyspend-qr-loading-text text-as-secondary text-sm", children: "Creating deposit order..." })] }) }));
141
167
  }
142
- return (_jsx("div", { className: cn("anyspend-container anyspend-qr-deposit font-inter bg-as-surface-primary mx-auto w-full max-w-[460px] p-6", mode === "page" && "border-as-border-secondary overflow-hidden rounded-2xl border shadow-xl"), children: _jsxs("div", { className: "anyspend-qr-deposit-content flex flex-col gap-4", children: [_jsxs("div", { className: "anyspend-qr-header flex items-center justify-between", children: [_jsx("button", { onClick: handleBack, className: "anyspend-qr-back-button text-as-secondary hover:text-as-primary", children: _jsx("svg", { className: "h-5 w-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 19l-7-7 7-7" }) }) }), _jsx("h2", { className: "anyspend-qr-title text-as-primary text-base font-semibold", children: "Deposit" }), onClose ? (_jsx("button", { onClick: handleClose, className: "anyspend-qr-close-button text-as-secondary hover:text-as-primary", children: _jsx("svg", { className: "h-5 w-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }) })) : (_jsx("div", { className: "w-5" }))] }), _jsxs("div", { className: "anyspend-qr-token-selector flex flex-col gap-1.5", children: [_jsx("label", { className: "anyspend-qr-token-label text-as-secondary text-sm", children: "Send" }), _jsx(TokenSelector, { chainIdsFilter: getAvailableChainIds("from"), context: "from", fromChainWalletVMSupported: true, isValidAddress: true, lockedChainIds: getAvailableChainIds("from"), multiWalletSupportEnabled: true, onAnalyticEvent: undefined, setToken: handleTokenSelect, supportedWalletVMs: ["evm"], token: undefined, trigger: _jsxs(Button, { variant: "outline", role: "combobox", className: "anyspend-qr-token-trigger border-as-stroke bg-as-surface-secondary flex h-auto w-full items-center justify-between gap-2 rounded-xl border px-3 py-2.5", children: [_jsxs("div", { className: "flex items-center gap-2", children: [sourceToken.metadata?.logoURI ? (_jsx(ChainTokenIcon, { chainUrl: ALL_CHAINS[sourceChainId]?.logoUrl, tokenUrl: sourceToken.metadata.logoURI, className: "h-8 min-h-8 w-8 min-w-8" })) : (_jsx("div", { className: "h-8 w-8 rounded-full bg-gray-700" })), _jsxs("div", { className: "flex flex-col items-start gap-0", children: [_jsx("div", { className: "text-as-primary font-semibold", children: sourceToken.symbol }), _jsx("div", { className: "text-as-primary/70 text-xs", children: ALL_CHAINS[sourceChainId]?.name ?? "Unknown" })] })] }), _jsx(ChevronsUpDown, { className: "h-4 w-4 shrink-0 opacity-70" })] }) })] }), _jsxs("div", { className: "anyspend-qr-content border-as-stroke flex items-start gap-4 rounded-xl border p-4", children: [_jsxs("div", { className: "anyspend-qr-code-container flex flex-col items-center gap-2", children: [_jsx("div", { className: "anyspend-qr-code rounded-lg bg-white p-2", children: _jsx(QRCodeSVG, { value: displayAddress, size: 120, level: "M", marginSize: 0 }) }), _jsxs("span", { className: "anyspend-qr-scan-hint text-as-secondary text-xs", children: ["SCAN WITH ", _jsx("span", { className: "inline-block", children: "\uD83E\uDD8A" })] })] }), _jsxs("div", { className: "anyspend-qr-address-container flex flex-1 flex-col gap-1", children: [_jsx("span", { className: "anyspend-qr-address-label text-as-secondary text-sm", children: "Deposit address:" }), _jsxs("div", { className: "anyspend-qr-address-row flex items-start gap-1", children: [_jsx("span", { className: "anyspend-qr-address text-as-primary break-all font-mono text-sm leading-relaxed", children: displayAddress }), _jsx("button", { onClick: handleCopyAddress, className: "anyspend-qr-copy-icon text-as-secondary hover:text-as-primary mt-0.5 shrink-0", children: copied ? _jsx(Check, { className: "h-4 w-4" }) : _jsx(Copy, { className: "h-4 w-4" }) })] })] })] }), _jsx(ChainWarningText, { chainId: destinationChainId }), _jsxs(WarningText, { children: ["Only send ", sourceToken.symbol, " on ", ALL_CHAINS[sourceChainId]?.name ?? "the specified chain", ". Other tokens will not be converted."] }), _jsx("button", { onClick: handleCopyAddress, className: "anyspend-qr-copy-button flex w-full items-center justify-center gap-2 rounded-xl bg-blue-500 py-3.5 font-medium text-white transition-all hover:bg-blue-600", children: "Copy deposit address" })] }) }));
168
+ return (_jsx("div", { className: cn("anyspend-container anyspend-qr-deposit font-inter bg-as-surface-primary mx-auto w-full max-w-[460px] p-6", mode === "page" && "border-as-border-secondary overflow-hidden rounded-2xl border shadow-xl"), children: _jsxs("div", { className: "anyspend-qr-deposit-content flex flex-col gap-4", children: [_jsxs("div", { className: "anyspend-qr-header flex items-center justify-between", children: [_jsx("button", { onClick: handleBack, className: "anyspend-qr-back-button text-as-secondary hover:text-as-primary", children: _jsx("svg", { className: "h-5 w-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 19l-7-7 7-7" }) }) }), _jsx("h2", { className: "anyspend-qr-title text-as-primary text-base font-semibold", children: "Deposit" }), onClose ? (_jsx("button", { onClick: handleClose, className: "anyspend-qr-close-button text-as-secondary hover:text-as-primary", children: _jsx("svg", { className: "h-5 w-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }) })) : (_jsx("div", { className: "w-5" }))] }), _jsxs("div", { className: "anyspend-qr-token-selector flex flex-col gap-1.5", children: [_jsx("label", { className: "anyspend-qr-token-label text-as-secondary text-sm", children: "Send" }), _jsx(TokenSelector, { chainIdsFilter: getAvailableChainIds("from"), context: "from", fromChainWalletVMSupported: true, isValidAddress: true, lockedChainIds: getAvailableChainIds("from"), multiWalletSupportEnabled: true, onAnalyticEvent: undefined, setToken: handleTokenSelect, supportedWalletVMs: ["evm"], token: undefined, trigger: _jsxs(Button, { variant: "outline", role: "combobox", className: "anyspend-qr-token-trigger border-as-stroke bg-as-surface-secondary flex h-auto w-full items-center justify-between gap-2 rounded-xl border px-3 py-2.5", children: [_jsxs("div", { className: "flex items-center gap-2", children: [sourceToken.metadata?.logoURI ? (_jsx(ChainTokenIcon, { chainUrl: ALL_CHAINS[sourceChainId]?.logoUrl, tokenUrl: sourceToken.metadata.logoURI, className: "h-8 min-h-8 w-8 min-w-8" })) : (_jsx("div", { className: "h-8 w-8 rounded-full bg-gray-700" })), _jsxs("div", { className: "flex flex-col items-start gap-0", children: [_jsx("div", { className: "text-as-primary font-semibold", children: sourceToken.symbol }), _jsx("div", { className: "text-as-primary/70 text-xs", children: ALL_CHAINS[sourceChainId]?.name ?? "Unknown" })] })] }), _jsx(ChevronsUpDown, { className: "h-4 w-4 shrink-0 opacity-70" })] }) })] }), _jsxs("div", { className: "anyspend-qr-content border-as-stroke flex items-start gap-4 rounded-xl border p-4", children: [_jsxs("div", { className: "anyspend-qr-code-container flex flex-col items-center gap-2", children: [_jsx("div", { className: "anyspend-qr-code rounded-lg bg-white p-2", children: _jsx(QRCodeSVG, { value: displayAddress, size: 120, level: "M", marginSize: 0 }) }), _jsxs("span", { className: "anyspend-qr-scan-hint text-as-secondary text-xs", children: ["SCAN WITH ", _jsx("span", { className: "inline-block", children: "\uD83E\uDD8A" })] })] }), _jsxs("div", { className: "anyspend-qr-address-container flex flex-1 flex-col gap-1", children: [_jsx("span", { className: "anyspend-qr-address-label text-as-secondary text-sm", children: "Deposit address:" }), _jsxs("div", { className: "anyspend-qr-address-row flex items-start gap-1", children: [_jsx("span", { className: "anyspend-qr-address text-as-primary break-all font-mono text-sm leading-relaxed", children: displayAddress }), _jsx("button", { onClick: handleCopyAddress, className: "anyspend-qr-copy-icon text-as-secondary hover:text-as-primary mt-0.5 shrink-0", children: copied ? _jsx(Check, { className: "h-4 w-4" }) : _jsx(Copy, { className: "h-4 w-4" }) })] })] })] }), _jsx(ChainWarningText, { chainId: destinationChainId }), _jsxs(WarningText, { children: ["Only send ", sourceToken.symbol, " on ", ALL_CHAINS[sourceChainId]?.name ?? "the specified chain", ". Other tokens will not be converted."] }), isPureTransfer && isWatchingTransfer && (_jsxs("div", { className: "anyspend-qr-watching flex items-center justify-center gap-2 rounded-lg bg-blue-500/10 p-3", children: [_jsx(Loader2, { className: "h-4 w-4 animate-spin text-blue-500" }), _jsx("span", { className: "text-sm text-blue-500", children: "Watching for incoming transfer..." })] })), _jsx("button", { onClick: handleCopyAddress, className: "anyspend-qr-copy-button flex w-full items-center justify-center gap-2 rounded-xl bg-blue-500 py-3.5 font-medium text-white transition-all hover:bg-blue-600", children: "Copy deposit address" })] }) }));
143
169
  }
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { toast, useAccountWallet, WalletImage } from "../../../../global-account/react/index.js";
3
+ import { toast, useAccountWallet, useModalStore, WalletImage } from "../../../../global-account/react/index.js";
4
4
  import { cn } from "../../../../shared/utils/cn.js";
5
5
  import { shortenAddress } from "../../../../shared/utils/formatAddress.js";
6
6
  import { client } from "../../../../shared/utils/thirdweb.js";
@@ -29,12 +29,16 @@ export function CryptoPaymentMethod({ selectedPaymentMethod, setSelectedPaymentM
29
29
  const globalAddress = connectedSmartWallet?.getAccount()?.address;
30
30
  // Use custom hook to determine wallet display logic
31
31
  const { shouldShowConnectedEOA } = useConnectedWalletDisplay(selectedPaymentMethod);
32
+ // Get modal store to block parent modal closing while connect modal is open
33
+ const setClosable = useModalStore(state => state.setClosable);
32
34
  // Handle wallet connection using thirdweb modal
33
35
  const handleConnectWallet = async () => {
36
+ // Block parent B3 modal from closing while thirdweb connect modal is open
37
+ setClosable(false);
34
38
  try {
35
39
  // Disconnect current wallet before connecting a new one
36
40
  if (connectedEOAWallet) {
37
- await disconnect(connectedEOAWallet);
41
+ disconnect(connectedEOAWallet);
38
42
  }
39
43
  const wallet = await openConnectModal({
40
44
  client,
@@ -44,7 +48,6 @@ export function CryptoPaymentMethod({ selectedPaymentMethod, setSelectedPaymentM
44
48
  wallets: recommendWallets,
45
49
  });
46
50
  if (wallet) {
47
- // setActiveWallet(wallet);
48
51
  setSelectedPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
49
52
  onSelectPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
50
53
  toast.success("Wallet connected");
@@ -64,6 +67,10 @@ export function CryptoPaymentMethod({ selectedPaymentMethod, setSelectedPaymentM
64
67
  }
65
68
  }
66
69
  }
70
+ finally {
71
+ // Always re-enable parent modal closing when connect modal closes
72
+ setClosable(true);
73
+ }
67
74
  };
68
75
  return (_jsx("div", { className: "crypto-payment-method mx-auto h-fit w-[460px] max-w-full px-5 pb-5 pt-5 sm:px-0 sm:pt-5", children: _jsxs("div", { className: cn("relative flex flex-col gap-10"), children: [_jsx("button", { onClick: onBack, className: "text-as-quaternary hover:text-as-primary absolute flex h-8 w-8 items-center justify-center rounded-lg transition-colors", children: _jsx(ChevronLeft, { className: "h-6 w-6" }) }), _jsx("div", { className: "flex items-center justify-around gap-4", children: _jsx("div", { className: "flex-1 text-center", children: _jsx("h2", { className: "text-as-primary text-lg font-semibold", children: "Select a payment method" }) }) }), process.env.NODE_ENV === "development" && (_jsxs("div", { className: "rounded-lg border border-yellow-500/50 bg-yellow-50 p-3 dark:bg-yellow-950/20", children: [_jsx("p", { className: "mb-2 text-xs font-semibold text-yellow-800 dark:text-yellow-300", children: "\uD83E\uDDEA Toast Test (Dev Only)" }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsx("button", { onClick: () => toast.success("Success! Transaction completed"), className: "rounded bg-green-600 px-2 py-1 text-xs font-medium text-white hover:bg-green-700", children: "Success" }), _jsx("button", { onClick: () => toast.error("Error! Transaction failed"), className: "rounded bg-red-600 px-2 py-1 text-xs font-medium text-white hover:bg-red-700", children: "Error" }), _jsx("button", { onClick: () => toast.info("Info: Processing your request..."), className: "rounded bg-blue-600 px-2 py-1 text-xs font-medium text-white hover:bg-blue-700", children: "Info" }), _jsx("button", { onClick: () => toast.warning("Warning: Low balance detected"), className: "rounded bg-yellow-600 px-2 py-1 text-xs font-medium text-white hover:bg-yellow-700", children: "Warning" }), _jsx("button", { onClick: () => {
69
76
  toast.success("Multiple test 1");
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { ALL_CHAINS, getChainName, getErrorDisplay, getExplorerTxUrl, getPaymentUrl, getStatusDisplay, isNativeToken, RELAY_SOLANA_MAINNET_CHAIN_ID, ZERO_ADDRESS, } from "../../../../anyspend/index.js";
4
- import { Badge, Button, CopyToClipboard, ShinyButton, Skeleton, TextLoop, TextShimmer, useAccountWallet, useB3, useModalStore, useProfile, useUnifiedChainSwitchAndExecute, } from "../../../../global-account/react/index.js";
4
+ import { Badge, Button, CopyToClipboard, ShinyButton, Skeleton, TextLoop, TextShimmer, useAccountWallet, useB3Config, useModalStore, useProfile, useUnifiedChainSwitchAndExecute, } from "../../../../global-account/react/index.js";
5
5
  import { useRouter, useSearchParams } from "../../../../shared/react/hooks/index.js";
6
6
  import { cn } from "../../../../shared/utils/index.js";
7
7
  import centerTruncate from "../../../../shared/utils/centerTruncate.js";
@@ -135,7 +135,7 @@ export const OrderDetails = memo(function OrderDetails({ mode = "modal", order,
135
135
  const router = useRouter();
136
136
  const searchParams = useSearchParams();
137
137
  // Get theme from B3Provider context
138
- const { theme } = useB3();
138
+ const { theme } = useB3Config();
139
139
  const colorMode = theme || "light";
140
140
  // Read crypto payment method from URL parameters
141
141
  const cryptoPaymentMethodFromUrl = searchParams.get("cryptoPaymentMethod");
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { OrderDetailsCollapsible, useStripeClientSecret } from "../../../../anyspend/react/index.js";
3
- import { ShinyButton, useB3, useModalStore, useProfile } from "../../../../global-account/react/index.js";
3
+ import { ShinyButton, useB3Config, useModalStore, useProfile } from "../../../../global-account/react/index.js";
4
4
  import { formatTokenAmount } from "../../../../shared/utils/number.js";
5
5
  import { formatStripeAmount, getStripePromise } from "../../../../shared/utils/payment.utils.js";
6
6
  import { AddressElement, Elements, PaymentElement, useElements, useStripe } from "@stripe/react-stripe-js";
@@ -10,7 +10,7 @@ import { AnySpendFingerprintWrapper, getFingerprintConfig } from "../AnySpendFin
10
10
  import HowItWorks from "./HowItWorks.js";
11
11
  import PaymentMethodIcons from "./PaymentMethodIcons.js";
12
12
  export default function PaymentStripeWeb2({ order, stripePaymentIntentId, onPaymentSuccess }) {
13
- const { theme, stripePublishableKey } = useB3();
13
+ const { theme, stripePublishableKey } = useB3Config();
14
14
  const fingerprintConfig = getFingerprintConfig();
15
15
  const { clientSecret, isLoadingStripeClientSecret, stripeClientSecretError } = useStripeClientSecret(stripePaymentIntentId);
16
16
  if (isLoadingStripeClientSecret) {
@@ -0,0 +1,22 @@
1
+ import { components } from "../../../../anyspend/types/api";
2
+ import { TransferResult } from "../../hooks/useWatchTransfer";
3
+ export interface TransferResultScreenProps {
4
+ mode?: "modal" | "page";
5
+ /** The transfer result containing amount info */
6
+ transferResult: TransferResult;
7
+ /** The token that was transferred */
8
+ token: components["schemas"]["Token"];
9
+ /** The chain ID where the transfer happened */
10
+ chainId: number;
11
+ /** The recipient address */
12
+ recipientAddress: string;
13
+ /** Callback when back/close button is clicked */
14
+ onBack?: () => void;
15
+ /** Callback when close button is clicked */
16
+ onClose?: () => void;
17
+ }
18
+ /**
19
+ * A component for displaying the result of a pure transfer (same chain, same token).
20
+ * Shows the transferred amount with success styling.
21
+ */
22
+ export declare function TransferResultScreen({ mode, transferResult, token, chainId, recipientAddress, onBack, onClose, }: TransferResultScreenProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { ALL_CHAINS } from "../../../../anyspend/index.js";
4
+ import { cn } from "../../../../shared/utils/cn.js";
5
+ import { CheckCircle2, Home } from "lucide-react";
6
+ import { ChainTokenIcon } from "./ChainTokenIcon.js";
7
+ /**
8
+ * A component for displaying the result of a pure transfer (same chain, same token).
9
+ * Shows the transferred amount with success styling.
10
+ */
11
+ export function TransferResultScreen({ mode = "modal", transferResult, token, chainId, recipientAddress, onBack, onClose, }) {
12
+ const chain = ALL_CHAINS[chainId];
13
+ const handleClose = () => {
14
+ if (onClose) {
15
+ onClose();
16
+ }
17
+ else if (onBack) {
18
+ onBack();
19
+ }
20
+ };
21
+ return (_jsx("div", { className: cn("anyspend-container anyspend-transfer-result font-inter bg-as-surface-primary mx-auto w-full max-w-[460px] p-6", mode === "page" && "border-as-border-secondary overflow-hidden rounded-2xl border shadow-xl"), children: _jsxs("div", { className: "anyspend-transfer-result-content flex flex-col items-center gap-6", children: [_jsx("div", { className: "anyspend-transfer-success-icon bg-as-success-secondary flex h-16 w-16 items-center justify-center rounded-full", children: _jsx(CheckCircle2, { className: "text-as-content-icon-success h-10 w-10" }) }), _jsxs("div", { className: "anyspend-transfer-success-message flex flex-col items-center gap-2", children: [_jsx("h2", { className: "text-as-primary text-xl font-semibold", children: "Transfer Received!" }), _jsx("p", { className: "text-as-secondary text-center text-sm", children: "Your transfer has been successfully received." })] }), _jsx("div", { className: "anyspend-transfer-amount border-as-border-secondary bg-as-surface-secondary flex w-full flex-col items-center gap-3 rounded-xl border p-4", children: _jsxs("div", { className: "flex items-center gap-3", children: [_jsx(ChainTokenIcon, { chainUrl: chain?.logoUrl, tokenUrl: token.metadata?.logoURI, className: "h-10 min-h-10 w-10 min-w-10" }), _jsxs("div", { className: "flex flex-col", children: [_jsxs("span", { className: "text-as-primary text-2xl font-bold", children: [transferResult.formattedAmount, " ", token.symbol] }), _jsxs("span", { className: "text-as-secondary text-sm", children: ["on ", chain?.name ?? "Unknown Chain"] })] })] }) }), _jsxs("div", { className: "anyspend-transfer-recipient flex w-full flex-col gap-1", children: [_jsx("span", { className: "text-as-secondary text-xs", children: "Received at" }), _jsx("span", { className: "text-as-primary break-all font-mono text-sm", children: recipientAddress })] }), _jsx("button", { onClick: handleClose, className: "anyspend-transfer-close-button bg-as-brand flex w-full items-center justify-center gap-2 rounded-xl py-3.5 font-medium text-white transition-all hover:opacity-90", children: mode === "page" ? (_jsxs(_Fragment, { children: ["Return to Home ", _jsx(Home, { className: "ml-2 h-4 w-4" })] })) : ("Close") })] }) }));
22
+ }
@@ -15,3 +15,4 @@ export * from "./useRecipientAddressState";
15
15
  export * from "./useSigMint";
16
16
  export * from "./useStripeClientSecret";
17
17
  export * from "./useStripeSupport";
18
+ export * from "./useWatchTransfer";
@@ -15,3 +15,4 @@ export * from "./useRecipientAddressState.js";
15
15
  export * from "./useSigMint.js";
16
16
  export * from "./useStripeClientSecret.js";
17
17
  export * from "./useStripeSupport.js";
18
+ export * from "./useWatchTransfer.js";
@@ -1,7 +1,7 @@
1
1
  import { USDC_BASE } from "../../../anyspend/constants/index.js";
2
2
  import { anyspendService } from "../../../anyspend/services/anyspend.js";
3
3
  import { buildMetadata, buildPayload, normalizeAddress } from "../../../anyspend/utils/index.js";
4
- import { useB3 } from "../../../global-account/react/index.js";
4
+ import { useB3Config } from "../../../global-account/react/index.js";
5
5
  import { useVisitorData } from "@fingerprintjs/fingerprintjs-pro-react";
6
6
  import { useMutation } from "@tanstack/react-query";
7
7
  import { useMemo } from "react";
@@ -14,7 +14,7 @@ import { useValidatedClientReferenceId } from "./useValidatedClientReferenceId.j
14
14
  */
15
15
  export function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
16
16
  // Get B3 context values
17
- const { partnerId } = useB3();
17
+ const { partnerId } = useB3Config();
18
18
  // Get validated client reference ID from B3 context
19
19
  const createValidatedClientReferenceId = useValidatedClientReferenceId();
20
20
  // Get fingerprint data
@@ -1,6 +1,6 @@
1
1
  import { anyspendService } from "../../../anyspend/services/anyspend.js";
2
2
  import { buildMetadata, buildPayload, normalizeAddress } from "../../../anyspend/utils/index.js";
3
- import { useB3 } from "../../../global-account/react/index.js";
3
+ import { useB3Config } from "../../../global-account/react/index.js";
4
4
  import { useVisitorData } from "@fingerprintjs/fingerprintjs-pro-react";
5
5
  import { useMutation } from "@tanstack/react-query";
6
6
  import { useMemo } from "react";
@@ -12,7 +12,7 @@ import { useValidatedClientReferenceId } from "./useValidatedClientReferenceId.j
12
12
  */
13
13
  export function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
14
14
  // Get B3 context values
15
- const { partnerId } = useB3();
15
+ const { partnerId } = useB3Config();
16
16
  // Get validated client reference ID from B3 context
17
17
  const createValidatedClientReferenceId = useValidatedClientReferenceId();
18
18
  // Get fingerprint data
@@ -1,6 +1,6 @@
1
1
  import { anyspendService } from "../../../anyspend/services/anyspend.js";
2
2
  import { normalizeAddress } from "../../../anyspend/utils/index.js";
3
- import { useB3 } from "../../../global-account/react/index.js";
3
+ import { useB3Config } from "../../../global-account/react/index.js";
4
4
  import { useVisitorData } from "@fingerprintjs/fingerprintjs-pro-react";
5
5
  import { useMutation } from "@tanstack/react-query";
6
6
  import { useMemo } from "react";
@@ -9,7 +9,7 @@ import { useMemo } from "react";
9
9
  * This order type doesn't require srcAmount - the user deposits tokens after the order is created.
10
10
  */
11
11
  export function useCreateDepositFirstOrder({ onSuccess, onError } = {}) {
12
- const { partnerId } = useB3();
12
+ const { partnerId } = useB3Config();
13
13
  const { data: fpData } = useVisitorData({ extendedResult: true }, { immediate: true });
14
14
  const visitorData = fpData && {
15
15
  requestId: fpData.requestId,
@@ -1,12 +1,12 @@
1
1
  import { Validators } from "../../../anyspend/utils/validation.js";
2
- import { useB3 } from "../../../global-account/react/index.js";
2
+ import { useB3Config } from "../../../global-account/react/index.js";
3
3
  import { useCallback } from "react";
4
4
  /**
5
5
  * Hook that provides a validated client reference ID
6
6
  * Gets the createClientReferenceId function from B3 context and validates the result
7
7
  */
8
8
  export function useValidatedClientReferenceId() {
9
- const { createClientReferenceId } = useB3();
9
+ const { createClientReferenceId } = useB3Config();
10
10
  const createValidatedClientReferenceId = useCallback(async (params) => {
11
11
  // If no function provided, return undefined
12
12
  if (!createClientReferenceId) {
@@ -0,0 +1,41 @@
1
+ export interface TransferResult {
2
+ amount: string;
3
+ formattedAmount: string;
4
+ txHash?: string;
5
+ timestamp: number;
6
+ }
7
+ export interface UseWatchTransferProps {
8
+ /** Address to watch for incoming transfers */
9
+ address: string;
10
+ /** Chain ID to watch on */
11
+ chainId: number;
12
+ /** Token address (use zero address for native token) */
13
+ tokenAddress: string;
14
+ /** Token decimals */
15
+ tokenDecimals: number;
16
+ /** Whether watching is enabled */
17
+ enabled?: boolean;
18
+ /** Callback when a transfer is detected */
19
+ onTransferDetected?: (result: TransferResult) => void;
20
+ }
21
+ /**
22
+ * Hook to watch for incoming transfers to an address by monitoring balance changes.
23
+ * When a transfer is detected (balance increases), it captures the amount and notifies.
24
+ */
25
+ export declare function useWatchTransfer({ address, chainId, tokenAddress, tokenDecimals, enabled, onTransferDetected, }: UseWatchTransferProps): {
26
+ /** Whether currently watching for transfers */
27
+ isWatching: boolean;
28
+ /** The detected transfer result, if any */
29
+ transferResult: TransferResult | null;
30
+ /** Whether a transfer has been detected */
31
+ hasTransfer: boolean;
32
+ /** Reset and start watching again */
33
+ reset: () => void;
34
+ /** Manually refetch balance */
35
+ refetchBalance: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<{
36
+ decimals: number;
37
+ formatted: string;
38
+ symbol: string;
39
+ value: bigint;
40
+ }, import("viem").GetBalanceErrorType>>;
41
+ };
@@ -0,0 +1,72 @@
1
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
2
+ import { formatUnits } from "viem";
3
+ import { useBalance } from "wagmi";
4
+ import { isNativeToken } from "../../utils/index.js";
5
+ /**
6
+ * Hook to watch for incoming transfers to an address by monitoring balance changes.
7
+ * When a transfer is detected (balance increases), it captures the amount and notifies.
8
+ */
9
+ export function useWatchTransfer({ address, chainId, tokenAddress, tokenDecimals, enabled = true, onTransferDetected, }) {
10
+ const [transferResult, setTransferResult] = useState(null);
11
+ const [isWatching, setIsWatching] = useState(false);
12
+ const initialBalanceRef = useRef(null);
13
+ const transferDetectedRef = useRef(false);
14
+ const isNative = isNativeToken(tokenAddress);
15
+ // Get current balance
16
+ const { data: balanceData, refetch: refetchBalance } = useBalance({
17
+ address: address,
18
+ chainId,
19
+ token: isNative ? undefined : tokenAddress,
20
+ query: {
21
+ enabled: enabled && !!address,
22
+ refetchInterval: 3000,
23
+ },
24
+ });
25
+ // Initialize or update the initial balance
26
+ useEffect(() => {
27
+ if (balanceData && initialBalanceRef.current === null && enabled) {
28
+ initialBalanceRef.current = balanceData.value;
29
+ setIsWatching(true);
30
+ }
31
+ }, [balanceData, enabled]);
32
+ // Check for balance increase (transfer detected)
33
+ useEffect(() => {
34
+ if (!enabled || transferDetectedRef.current || initialBalanceRef.current === null || !balanceData) {
35
+ return;
36
+ }
37
+ const currentBalance = balanceData.value;
38
+ const initialBalance = initialBalanceRef.current;
39
+ if (currentBalance > initialBalance) {
40
+ const transferAmount = currentBalance - initialBalance;
41
+ const formattedAmount = formatUnits(transferAmount, tokenDecimals);
42
+ const result = {
43
+ amount: transferAmount.toString(),
44
+ formattedAmount,
45
+ timestamp: Date.now(),
46
+ };
47
+ transferDetectedRef.current = true;
48
+ setTransferResult(result);
49
+ setIsWatching(false);
50
+ onTransferDetected?.(result);
51
+ }
52
+ }, [balanceData, enabled, tokenDecimals, onTransferDetected]);
53
+ // Reset function to start watching again
54
+ const reset = useCallback(() => {
55
+ transferDetectedRef.current = false;
56
+ initialBalanceRef.current = null;
57
+ setTransferResult(null);
58
+ setIsWatching(false);
59
+ }, []);
60
+ return useMemo(() => ({
61
+ /** Whether currently watching for transfers */
62
+ isWatching,
63
+ /** The detected transfer result, if any */
64
+ transferResult,
65
+ /** Whether a transfer has been detected */
66
+ hasTransfer: transferResult !== null,
67
+ /** Reset and start watching again */
68
+ reset,
69
+ /** Manually refetch balance */
70
+ refetchBalance,
71
+ }), [isWatching, transferResult, reset, refetchBalance]);
72
+ }
@@ -13,3 +13,8 @@ export declare function isEvmOrSolanaAddress(address: string): boolean;
13
13
  export declare function isHyperliquidUSDC(chainId: number, address: string): boolean;
14
14
  export declare function normalizeAddress(address: string): string;
15
15
  export declare function eqci(a: string | null | undefined, b: string | null | undefined): boolean;
16
+ /**
17
+ * Check if source and destination represent the same token on the same chain.
18
+ * When true, this is a pure transfer (no swap/bridge needed).
19
+ */
20
+ export declare function isSameChainAndToken(sourceChainId: number, sourceTokenAddress: string, destinationChainId: number, destinationTokenAddress: string): boolean;
@@ -35,3 +35,10 @@ export function eqci(a, b) {
35
35
  return false;
36
36
  return a.toLowerCase() === b.toLowerCase();
37
37
  }
38
+ /**
39
+ * Check if source and destination represent the same token on the same chain.
40
+ * When true, this is a pure transfer (no swap/bridge needed).
41
+ */
42
+ export function isSameChainAndToken(sourceChainId, sourceTokenAddress, destinationChainId, destinationTokenAddress) {
43
+ return sourceChainId === destinationChainId && eqci(sourceTokenAddress, destinationTokenAddress);
44
+ }