@b3dotfun/sdk 0.0.88-alpha.10 → 0.0.88-alpha.2

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 (281) hide show
  1. package/dist/cjs/anyspend/constants/index.d.ts +0 -2
  2. package/dist/cjs/anyspend/constants/index.js +1 -3
  3. package/dist/cjs/anyspend/index.d.ts +0 -2
  4. package/dist/cjs/anyspend/index.js +0 -3
  5. package/dist/cjs/anyspend/react/components/AnySpend.d.ts +0 -6
  6. package/dist/cjs/anyspend/react/components/AnySpend.js +6 -9
  7. package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +1 -5
  8. package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.js +2 -2
  9. package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +0 -1
  10. package/dist/cjs/anyspend/react/components/AnySpendCustom.js +3 -3
  11. package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.d.ts +0 -6
  12. package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +20 -24
  13. package/dist/cjs/anyspend/react/components/AnySpendDeposit.d.ts +1 -7
  14. package/dist/cjs/anyspend/react/components/AnySpendDeposit.js +3 -3
  15. package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +0 -4
  16. package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +1 -14
  17. package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.d.ts +1 -3
  18. package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +2 -3
  19. package/dist/cjs/anyspend/react/components/common/OrderDetails.d.ts +0 -4
  20. package/dist/cjs/anyspend/react/components/common/OrderDetails.js +6 -34
  21. package/dist/cjs/anyspend/react/components/common/PanelOnramp.d.ts +1 -3
  22. package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +2 -3
  23. package/dist/cjs/anyspend/react/components/common/PaymentStripeWeb2.js +4 -3
  24. package/dist/cjs/anyspend/react/hooks/index.d.ts +0 -1
  25. package/dist/cjs/anyspend/react/hooks/index.js +0 -1
  26. package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +1 -1
  27. package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.js +1 -1
  28. package/dist/cjs/anyspend/react/hooks/useCreateDepositFirstOrder.js +1 -1
  29. package/dist/cjs/anyspend/react/hooks/useValidatedClientReferenceId.js +1 -1
  30. package/dist/cjs/global-account/react/components/B3DynamicModal.js +3 -2
  31. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +18 -2
  32. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +57 -35
  33. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.d.ts +5 -5
  34. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +35 -38
  35. package/dist/cjs/global-account/react/components/B3Provider/RelayKitProviderWrapper.js +1 -3
  36. package/dist/cjs/global-account/react/components/B3Provider/types.d.ts +27 -0
  37. package/dist/cjs/global-account/react/components/B3Provider/types.js +24 -0
  38. package/dist/cjs/global-account/react/components/B3Provider/useB3.d.ts +4 -14
  39. package/dist/cjs/global-account/react/components/B3Provider/useB3.js +11 -4
  40. package/dist/cjs/global-account/react/components/B3Provider/useB3Account.js +2 -5
  41. package/dist/cjs/global-account/react/components/B3Provider/useB3Config.d.ts +2 -10
  42. package/dist/cjs/global-account/react/components/B3Provider/useB3Config.js +17 -18
  43. package/dist/cjs/global-account/react/components/ManageAccount/ProfileSection.js +2 -1
  44. package/dist/cjs/global-account/react/components/ManageAccount/channels/DiscordChannel.js +6 -6
  45. package/dist/cjs/global-account/react/components/ManageAccount/channels/EmailChannel.js +7 -7
  46. package/dist/cjs/global-account/react/components/ManageAccount/channels/PhoneChannel.js +7 -7
  47. package/dist/cjs/global-account/react/components/ManageAccount/channels/TelegramChannel.js +5 -5
  48. package/dist/cjs/global-account/react/components/RequestPermissions/RequestPermissions.js +9 -8
  49. package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +1 -1
  50. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +20 -76
  51. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -1
  52. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +1 -1
  53. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +1 -1
  54. package/dist/cjs/global-account/react/components/StyleRoot.js +3 -3
  55. package/dist/cjs/global-account/react/components/TurnkeyAuthModal.js +1 -3
  56. package/dist/cjs/global-account/react/components/custom/ManageAccountButton.js +2 -1
  57. package/dist/cjs/global-account/react/components/index.d.ts +2 -1
  58. package/dist/cjs/global-account/react/components/index.js +6 -3
  59. package/dist/cjs/global-account/react/hooks/index.d.ts +0 -2
  60. package/dist/cjs/global-account/react/hooks/index.js +1 -5
  61. package/dist/cjs/global-account/react/hooks/useClient.js +1 -1
  62. package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.js +1 -1
  63. package/dist/cjs/global-account/react/hooks/useNotifications.js +14 -14
  64. package/dist/cjs/global-account/react/hooks/useTWAuth.d.ts +0 -3
  65. package/dist/cjs/global-account/react/hooks/useTWAuth.js +0 -8
  66. package/dist/cjs/global-account/react/hooks/useTokenBalance.js +5 -5
  67. package/dist/cjs/global-account/react/hooks/useTokenBalancesByChain.js +2 -4
  68. package/dist/cjs/global-account/react/hooks/useTurnkeyAuth.js +22 -50
  69. package/dist/cjs/global-account/react/hooks/useUserQuery.js +35 -9
  70. package/dist/cjs/global-account/react/index.native.d.ts +2 -0
  71. package/dist/cjs/global-account/react/index.native.js +5 -1
  72. package/dist/cjs/global-account/react/stores/index.d.ts +0 -1
  73. package/dist/cjs/global-account/react/stores/index.js +1 -3
  74. package/dist/cjs/global-account/react/stores/useModalStore.d.ts +0 -10
  75. package/dist/esm/anyspend/constants/index.d.ts +0 -2
  76. package/dist/esm/anyspend/constants/index.js +0 -2
  77. package/dist/esm/anyspend/index.d.ts +0 -2
  78. package/dist/esm/anyspend/index.js +0 -3
  79. package/dist/esm/anyspend/react/components/AnySpend.d.ts +0 -6
  80. package/dist/esm/anyspend/react/components/AnySpend.js +8 -11
  81. package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +1 -5
  82. package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.js +2 -2
  83. package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +0 -1
  84. package/dist/esm/anyspend/react/components/AnySpendCustom.js +3 -3
  85. package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.d.ts +0 -6
  86. package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +4 -8
  87. package/dist/esm/anyspend/react/components/AnySpendDeposit.d.ts +1 -7
  88. package/dist/esm/anyspend/react/components/AnySpendDeposit.js +3 -3
  89. package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +0 -4
  90. package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +1 -14
  91. package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.d.ts +1 -3
  92. package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +2 -3
  93. package/dist/esm/anyspend/react/components/common/OrderDetails.d.ts +0 -4
  94. package/dist/esm/anyspend/react/components/common/OrderDetails.js +8 -36
  95. package/dist/esm/anyspend/react/components/common/PanelOnramp.d.ts +1 -3
  96. package/dist/esm/anyspend/react/components/common/PanelOnramp.js +2 -3
  97. package/dist/esm/anyspend/react/components/common/PaymentStripeWeb2.js +4 -3
  98. package/dist/esm/anyspend/react/hooks/index.d.ts +0 -1
  99. package/dist/esm/anyspend/react/hooks/index.js +0 -1
  100. package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +2 -2
  101. package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.js +2 -2
  102. package/dist/esm/anyspend/react/hooks/useCreateDepositFirstOrder.js +2 -2
  103. package/dist/esm/anyspend/react/hooks/useValidatedClientReferenceId.js +2 -2
  104. package/dist/esm/global-account/react/components/B3DynamicModal.js +4 -3
  105. package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +18 -2
  106. package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +58 -34
  107. package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.d.ts +5 -5
  108. package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +36 -36
  109. package/dist/esm/global-account/react/components/B3Provider/RelayKitProviderWrapper.js +1 -3
  110. package/dist/esm/global-account/react/components/B3Provider/types.d.ts +27 -0
  111. package/dist/esm/global-account/react/components/B3Provider/types.js +21 -0
  112. package/dist/esm/global-account/react/components/B3Provider/useB3.d.ts +4 -14
  113. package/dist/esm/global-account/react/components/B3Provider/useB3.js +11 -4
  114. package/dist/esm/global-account/react/components/B3Provider/useB3Account.js +2 -5
  115. package/dist/esm/global-account/react/components/B3Provider/useB3Config.d.ts +2 -10
  116. package/dist/esm/global-account/react/components/B3Provider/useB3Config.js +17 -18
  117. package/dist/esm/global-account/react/components/ManageAccount/ProfileSection.js +3 -2
  118. package/dist/esm/global-account/react/components/ManageAccount/channels/DiscordChannel.js +2 -2
  119. package/dist/esm/global-account/react/components/ManageAccount/channels/EmailChannel.js +2 -2
  120. package/dist/esm/global-account/react/components/ManageAccount/channels/PhoneChannel.js +2 -2
  121. package/dist/esm/global-account/react/components/ManageAccount/channels/TelegramChannel.js +2 -2
  122. package/dist/esm/global-account/react/components/RequestPermissions/RequestPermissions.js +3 -2
  123. package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +2 -2
  124. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +20 -76
  125. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +2 -2
  126. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +2 -2
  127. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +2 -2
  128. package/dist/esm/global-account/react/components/StyleRoot.js +3 -3
  129. package/dist/esm/global-account/react/components/TurnkeyAuthModal.js +3 -5
  130. package/dist/esm/global-account/react/components/custom/ManageAccountButton.js +3 -2
  131. package/dist/esm/global-account/react/components/index.d.ts +2 -1
  132. package/dist/esm/global-account/react/components/index.js +2 -1
  133. package/dist/esm/global-account/react/hooks/index.d.ts +0 -2
  134. package/dist/esm/global-account/react/hooks/index.js +0 -2
  135. package/dist/esm/global-account/react/hooks/useClient.js +2 -2
  136. package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.js +2 -2
  137. package/dist/esm/global-account/react/hooks/useNotifications.js +2 -2
  138. package/dist/esm/global-account/react/hooks/useTWAuth.d.ts +0 -3
  139. package/dist/esm/global-account/react/hooks/useTWAuth.js +0 -8
  140. package/dist/esm/global-account/react/hooks/useTokenBalance.js +6 -6
  141. package/dist/esm/global-account/react/hooks/useTokenBalancesByChain.js +2 -4
  142. package/dist/esm/global-account/react/hooks/useTurnkeyAuth.js +22 -50
  143. package/dist/esm/global-account/react/hooks/useUserQuery.js +27 -1
  144. package/dist/esm/global-account/react/index.native.d.ts +2 -0
  145. package/dist/esm/global-account/react/index.native.js +2 -0
  146. package/dist/esm/global-account/react/stores/index.d.ts +0 -1
  147. package/dist/esm/global-account/react/stores/index.js +0 -1
  148. package/dist/esm/global-account/react/stores/useModalStore.d.ts +0 -10
  149. package/dist/styles/index.css +1 -1
  150. package/dist/types/anyspend/constants/index.d.ts +0 -2
  151. package/dist/types/anyspend/index.d.ts +0 -2
  152. package/dist/types/anyspend/react/components/AnySpend.d.ts +0 -6
  153. package/dist/types/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +1 -5
  154. package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +0 -1
  155. package/dist/types/anyspend/react/components/AnySpendCustomExactIn.d.ts +0 -6
  156. package/dist/types/anyspend/react/components/AnySpendDeposit.d.ts +1 -7
  157. package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +0 -4
  158. package/dist/types/anyspend/react/components/common/CryptoReceiveSection.d.ts +1 -3
  159. package/dist/types/anyspend/react/components/common/OrderDetails.d.ts +0 -4
  160. package/dist/types/anyspend/react/components/common/PanelOnramp.d.ts +1 -3
  161. package/dist/types/anyspend/react/hooks/index.d.ts +0 -1
  162. package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +18 -2
  163. package/dist/types/global-account/react/components/B3Provider/B3Provider.native.d.ts +5 -5
  164. package/dist/types/global-account/react/components/B3Provider/types.d.ts +27 -0
  165. package/dist/types/global-account/react/components/B3Provider/useB3.d.ts +4 -14
  166. package/dist/types/global-account/react/components/B3Provider/useB3Config.d.ts +2 -10
  167. package/dist/types/global-account/react/components/index.d.ts +2 -1
  168. package/dist/types/global-account/react/hooks/index.d.ts +0 -2
  169. package/dist/types/global-account/react/hooks/useTWAuth.d.ts +0 -3
  170. package/dist/types/global-account/react/index.native.d.ts +2 -0
  171. package/dist/types/global-account/react/stores/index.d.ts +0 -1
  172. package/dist/types/global-account/react/stores/useModalStore.d.ts +0 -10
  173. package/package.json +1 -1
  174. package/src/anyspend/constants/index.ts +0 -3
  175. package/src/anyspend/index.ts +0 -4
  176. package/src/anyspend/react/components/AnySpend.tsx +2 -28
  177. package/src/anyspend/react/components/AnySpendCollectorClubPurchase.tsx +0 -6
  178. package/src/anyspend/react/components/AnySpendCustom.tsx +47 -52
  179. package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +0 -23
  180. package/src/anyspend/react/components/AnySpendDeposit.tsx +1 -18
  181. package/src/anyspend/react/components/AnyspendDepositHype.tsx +0 -4
  182. package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +1 -15
  183. package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +1 -5
  184. package/src/anyspend/react/components/common/OrderDetails.tsx +42 -60
  185. package/src/anyspend/react/components/common/PanelOnramp.tsx +1 -5
  186. package/src/anyspend/react/components/common/PaymentStripeWeb2.tsx +4 -3
  187. package/src/anyspend/react/hooks/index.ts +0 -1
  188. package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +2 -2
  189. package/src/anyspend/react/hooks/useAnyspendCreateOrder.ts +2 -2
  190. package/src/anyspend/react/hooks/useCreateDepositFirstOrder.ts +2 -2
  191. package/src/anyspend/react/hooks/useValidatedClientReferenceId.ts +2 -2
  192. package/src/global-account/react/components/B3DynamicModal.tsx +4 -3
  193. package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +54 -43
  194. package/src/global-account/react/components/B3Provider/B3Provider.tsx +117 -44
  195. package/src/global-account/react/components/B3Provider/RelayKitProviderWrapper.tsx +1 -4
  196. package/src/global-account/react/components/B3Provider/types.ts +50 -0
  197. package/src/global-account/react/components/B3Provider/useB3.ts +13 -4
  198. package/src/global-account/react/components/B3Provider/useB3Account.ts +2 -6
  199. package/src/global-account/react/components/B3Provider/useB3Config.ts +31 -18
  200. package/src/global-account/react/components/ManageAccount/ProfileSection.tsx +4 -2
  201. package/src/global-account/react/components/ManageAccount/channels/DiscordChannel.tsx +2 -2
  202. package/src/global-account/react/components/ManageAccount/channels/EmailChannel.tsx +2 -2
  203. package/src/global-account/react/components/ManageAccount/channels/PhoneChannel.tsx +2 -2
  204. package/src/global-account/react/components/ManageAccount/channels/TelegramChannel.tsx +2 -2
  205. package/src/global-account/react/components/RequestPermissions/RequestPermissions.tsx +4 -4
  206. package/src/global-account/react/components/SignInWithB3/SignIn.tsx +2 -2
  207. package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +100 -168
  208. package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +2 -2
  209. package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +2 -2
  210. package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +2 -2
  211. package/src/global-account/react/components/StyleRoot.tsx +3 -3
  212. package/src/global-account/react/components/TurnkeyAuthModal.tsx +4 -7
  213. package/src/global-account/react/components/custom/ManageAccountButton.tsx +3 -2
  214. package/src/global-account/react/components/index.ts +2 -1
  215. package/src/global-account/react/hooks/index.ts +0 -2
  216. package/src/global-account/react/hooks/useClient.ts +2 -2
  217. package/src/global-account/react/hooks/useHandleConnectWithPrivy.tsx +2 -2
  218. package/src/global-account/react/hooks/useNotifications.ts +2 -2
  219. package/src/global-account/react/hooks/useTWAuth.tsx +0 -10
  220. package/src/global-account/react/hooks/useTokenBalance.tsx +7 -8
  221. package/src/global-account/react/hooks/useTokenBalancesByChain.tsx +2 -4
  222. package/src/global-account/react/hooks/useTurnkeyAuth.ts +23 -54
  223. package/src/global-account/react/hooks/useUserQuery.ts +40 -1
  224. package/src/global-account/react/index.native.ts +2 -0
  225. package/src/global-account/react/stores/index.ts +0 -1
  226. package/src/global-account/react/stores/useModalStore.ts +0 -10
  227. package/dist/cjs/anyspend/react/components/common/GasIndicator.d.ts +0 -6
  228. package/dist/cjs/anyspend/react/components/common/GasIndicator.js +0 -34
  229. package/dist/cjs/anyspend/react/hooks/useGasPrice.d.ts +0 -37
  230. package/dist/cjs/anyspend/react/hooks/useGasPrice.js +0 -43
  231. package/dist/cjs/anyspend/services/gas.d.ts +0 -21
  232. package/dist/cjs/anyspend/services/gas.js +0 -65
  233. package/dist/cjs/anyspend/types/gas.d.ts +0 -61
  234. package/dist/cjs/anyspend/types/gas.js +0 -2
  235. package/dist/cjs/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +0 -5
  236. package/dist/cjs/global-account/react/components/B3Provider/AuthenticationProvider.js +0 -12
  237. package/dist/cjs/global-account/react/hooks/useAuth.d.ts +0 -76
  238. package/dist/cjs/global-account/react/hooks/useAuth.js +0 -337
  239. package/dist/cjs/global-account/react/hooks/useUser.d.ts +0 -60
  240. package/dist/cjs/global-account/react/hooks/useUser.js +0 -20
  241. package/dist/cjs/global-account/react/stores/configStore.d.ts +0 -24
  242. package/dist/cjs/global-account/react/stores/configStore.js +0 -30
  243. package/dist/cjs/global-account/react/stores/userStore.d.ts +0 -22
  244. package/dist/cjs/global-account/react/stores/userStore.js +0 -30
  245. package/dist/esm/anyspend/react/components/common/GasIndicator.d.ts +0 -6
  246. package/dist/esm/anyspend/react/components/common/GasIndicator.js +0 -31
  247. package/dist/esm/anyspend/react/hooks/useGasPrice.d.ts +0 -37
  248. package/dist/esm/anyspend/react/hooks/useGasPrice.js +0 -40
  249. package/dist/esm/anyspend/services/gas.d.ts +0 -21
  250. package/dist/esm/anyspend/services/gas.js +0 -59
  251. package/dist/esm/anyspend/types/gas.d.ts +0 -61
  252. package/dist/esm/anyspend/types/gas.js +0 -1
  253. package/dist/esm/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +0 -5
  254. package/dist/esm/global-account/react/components/B3Provider/AuthenticationProvider.js +0 -10
  255. package/dist/esm/global-account/react/hooks/useAuth.d.ts +0 -76
  256. package/dist/esm/global-account/react/hooks/useAuth.js +0 -331
  257. package/dist/esm/global-account/react/hooks/useUser.d.ts +0 -60
  258. package/dist/esm/global-account/react/hooks/useUser.js +0 -17
  259. package/dist/esm/global-account/react/stores/configStore.d.ts +0 -24
  260. package/dist/esm/global-account/react/stores/configStore.js +0 -27
  261. package/dist/esm/global-account/react/stores/userStore.d.ts +0 -22
  262. package/dist/esm/global-account/react/stores/userStore.js +0 -27
  263. package/dist/types/anyspend/react/components/common/GasIndicator.d.ts +0 -6
  264. package/dist/types/anyspend/react/hooks/useGasPrice.d.ts +0 -37
  265. package/dist/types/anyspend/services/gas.d.ts +0 -21
  266. package/dist/types/anyspend/types/gas.d.ts +0 -61
  267. package/dist/types/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +0 -5
  268. package/dist/types/global-account/react/hooks/useAuth.d.ts +0 -76
  269. package/dist/types/global-account/react/hooks/useUser.d.ts +0 -60
  270. package/dist/types/global-account/react/stores/configStore.d.ts +0 -24
  271. package/dist/types/global-account/react/stores/userStore.d.ts +0 -22
  272. package/src/anyspend/react/components/common/GasIndicator.tsx +0 -59
  273. package/src/anyspend/react/hooks/useGasPrice.ts +0 -70
  274. package/src/anyspend/services/gas.test.ts +0 -31
  275. package/src/anyspend/services/gas.ts +0 -73
  276. package/src/anyspend/types/gas.ts +0 -66
  277. package/src/global-account/react/components/B3Provider/AuthenticationProvider.tsx +0 -19
  278. package/src/global-account/react/hooks/useAuth.ts +0 -379
  279. package/src/global-account/react/hooks/useUser.ts +0 -20
  280. package/src/global-account/react/stores/configStore.ts +0 -51
  281. package/src/global-account/react/stores/userStore.ts +0 -41
@@ -1,337 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.useAuth = useAuth;
7
- const app_1 = __importDefault(require("../../../global-account/app"));
8
- const bsmnt_1 = require("../../../global-account/bsmnt");
9
- const react_1 = require("../../../global-account/react");
10
- const constants_1 = require("../../../shared/constants");
11
- const debug_1 = require("../../../shared/utils/debug");
12
- const thirdweb_1 = require("../../../shared/utils/thirdweb");
13
- const core_1 = require("@wagmi/core");
14
- const react_2 = require("react");
15
- const react_3 = require("thirdweb/react");
16
- const wallets_1 = require("thirdweb/wallets");
17
- const in_app_1 = require("thirdweb/wallets/in-app");
18
- const wagmi_1 = require("wagmi");
19
- const LocalSDKProvider_1 = require("../components/B3Provider/LocalSDKProvider");
20
- const createWagmiConfig_1 = require("../utils/createWagmiConfig");
21
- const useSearchParamsSSR_1 = require("./useSearchParamsSSR");
22
- const useUserQuery_1 = require("./useUserQuery");
23
- const debug = (0, debug_1.debugB3React)("useAuth");
24
- /**
25
- * Unified authentication hook that uses Turnkey for authentication
26
- * This replaces the previous Thirdweb-based authentication
27
- *
28
- * This hook provides 1:1 feature parity with useAuthentication.ts
29
- */
30
- function useAuth() {
31
- const { onConnectCallback } = (0, react_2.useContext)(LocalSDKProvider_1.LocalSDKContext);
32
- const { disconnect } = (0, react_3.useDisconnect)();
33
- const wallets = (0, react_3.useConnectedWallets)();
34
- const activeWallet = (0, react_3.useActiveWallet)();
35
- const isAuthenticated = (0, react_1.useAuthStore)(state => state.isAuthenticated);
36
- const setIsAuthenticated = (0, react_1.useAuthStore)(state => state.setIsAuthenticated);
37
- const setIsConnected = (0, react_1.useAuthStore)(state => state.setIsConnected);
38
- const isConnecting = (0, react_1.useAuthStore)(state => state.isConnecting);
39
- const isConnected = (0, react_1.useAuthStore)(state => state.isConnected);
40
- const isAuthenticating = (0, react_1.useAuthStore)(state => state.isAuthenticating);
41
- const setIsAuthenticating = (0, react_1.useAuthStore)(state => state.setIsAuthenticating);
42
- const setHasStartedConnecting = (0, react_1.useAuthStore)(state => state.setHasStartedConnecting);
43
- const setActiveWallet = (0, react_3.useSetActiveWallet)();
44
- const hasStartedConnecting = (0, react_1.useAuthStore)(state => state.hasStartedConnecting);
45
- const useAutoConnectLoadingPrevious = (0, react_2.useRef)(false);
46
- const referralCode = (0, useSearchParamsSSR_1.useSearchParam)("referralCode");
47
- const { partnerId } = (0, react_1.useB3Config)();
48
- const wagmiConfig = (0, createWagmiConfig_1.createWagmiConfig)({ partnerId });
49
- const { connect } = (0, wagmi_1.useConnect)();
50
- const activeWagmiAccount = (0, wagmi_1.useAccount)();
51
- const { switchAccount } = (0, wagmi_1.useSwitchAccount)();
52
- const { user, setUser } = (0, useUserQuery_1.useUserQuery)();
53
- debug("@@activeWagmiAccount", activeWagmiAccount);
54
- const wallet = (0, wallets_1.ecosystemWallet)(constants_1.ecosystemWalletId, {
55
- partnerId: partnerId,
56
- });
57
- /**
58
- * Re-authenticate using existing session
59
- * Also updates user state and authenticates with BSMNT
60
- */
61
- const reAuthenticate = (0, react_2.useCallback)(async () => {
62
- debug("Re-authenticating...");
63
- try {
64
- const response = await app_1.default.reAuthenticate();
65
- debug("Re-authentication successful", response);
66
- // Update user state if user data exists
67
- if (response.user) {
68
- setUser(response.user);
69
- debug("User state updated", response.user);
70
- }
71
- // Authenticate with BSMNT
72
- try {
73
- const b3Jwt = await (0, bsmnt_1.authenticateWithB3JWT)(response.accessToken);
74
- debug("BSMNT re-authentication successful", b3Jwt);
75
- }
76
- catch (bsmntError) {
77
- // BSMNT authentication failure shouldn't block the main auth flow
78
- debug("BSMNT re-authentication failed (non-critical)", bsmntError);
79
- }
80
- return response;
81
- }
82
- catch (err) {
83
- debug("Re-authentication failed", err);
84
- throw err;
85
- }
86
- }, [setUser]);
87
- const syncWagmi = (0, react_2.useCallback)(async () => {
88
- function syncWagmiFunc() {
89
- const connectors = (0, core_1.getConnectors)(wagmiConfig);
90
- debug("@@syncWagmi", {
91
- connectors,
92
- wallets,
93
- });
94
- // For each that matchs a TW wallet on wallets, connect to the wagmi connector
95
- // or, since ecosystem wallets is separate, connect those via in-app-wallet from wagmi
96
- connectors.forEach(async (connector) => {
97
- const twWallet = wallets.find(wallet => wallet.id === connector.id || connector.id === "in-app-wallet");
98
- // If no TW wallet, do not prompt the user to connect
99
- if (!twWallet) {
100
- return;
101
- }
102
- // Metamask will prompt to connect, we can just switch accounts here.
103
- if (connector.id === "io.metamask") {
104
- return switchAccount({ connector });
105
- }
106
- if (
107
- // If it's not an in-app wallet or it is the ecosystem wallet, connect
108
- connector.id !== "in-app-wallet" ||
109
- (connector.id === "in-app-wallet" && twWallet.id === constants_1.ecosystemWalletId)) {
110
- try {
111
- const options = {
112
- wallet: twWallet, // the connected wallet
113
- };
114
- debug("@@syncWagmi:connecting", { twWallet, connector });
115
- connect({
116
- connector,
117
- ...options,
118
- });
119
- }
120
- catch (error) {
121
- console.error("@@syncWagmi:error", error);
122
- }
123
- }
124
- else {
125
- debug("@@syncWagmi:not-connecting", connector);
126
- }
127
- });
128
- }
129
- syncWagmiFunc();
130
- // wagmi config shouldn't change
131
- // eslint-disable-next-line react-hooks/exhaustive-deps
132
- }, [partnerId, wallets]);
133
- (0, react_2.useEffect)(() => {
134
- syncWagmi();
135
- }, [wallets, syncWagmi]);
136
- /**
137
- * Authenticate user using Turnkey
138
- * Note: This no longer requires a wallet for authentication.
139
- * Wallets are still used for signing transactions, but authentication is done via Turnkey email OTP.
140
- *
141
- * For backward compatibility, this function still accepts a wallet parameter,
142
- * but it's not used for authentication anymore.
143
- */
144
- const authenticateUser = (0, react_2.useCallback)(async () => {
145
- setHasStartedConnecting(true);
146
- // Try to re-authenticate first
147
- try {
148
- const userAuth = await reAuthenticate();
149
- setUser(userAuth.user);
150
- setIsAuthenticated(true);
151
- setIsAuthenticating(false);
152
- debug("Re-authenticated successfully", { userAuth });
153
- // Authenticate on BSMNT with B3 JWT
154
- const b3Jwt = await (0, bsmnt_1.authenticateWithB3JWT)(userAuth.accessToken);
155
- debug("@@b3Jwt", b3Jwt);
156
- return userAuth;
157
- }
158
- catch (error) {
159
- // If re-authentication fails, user needs to authenticate via Turnkey
160
- // This should be handled by the Turnkey auth modal/flow
161
- debug("Re-authentication failed. User needs to authenticate via Turnkey.", error);
162
- setIsAuthenticated(false);
163
- setIsAuthenticating(false);
164
- throw new Error("Authentication required. Please authenticate via Turnkey.");
165
- }
166
- }, [reAuthenticate, setIsAuthenticated, setIsAuthenticating, setUser, setHasStartedConnecting]);
167
- /**
168
- * Authenticate with Turnkey using email OTP
169
- * This is the primary authentication method, replacing Thirdweb wallet-based auth
170
- *
171
- * This function:
172
- * 1. Authenticates with FeathersJS (persists session via cookies)
173
- * 2. Sets user state in the user store (persists to localStorage)
174
- * 3. Authenticates with BSMNT for basement integration
175
- */
176
- const authenticate = (0, react_2.useCallback)(async (turnkeySessionJwt, partnerId) => {
177
- if (!turnkeySessionJwt) {
178
- throw new Error("Turnkey session JWT is required");
179
- }
180
- debug("Authenticating with Turnkey JWT", { referralCode, partnerId });
181
- try {
182
- // Step 1: Authenticate with FeathersJS (session persisted via cookies)
183
- const response = await app_1.default.authenticate({
184
- strategy: "turnkey-jwt",
185
- accessToken: turnkeySessionJwt,
186
- referralCode,
187
- partnerId: partnerId,
188
- });
189
- debug("Authentication successful", response);
190
- // Step 2: Set user state (persists to localStorage via Zustand)
191
- if (response.user) {
192
- setUser(response.user);
193
- debug("User state updated", response.user);
194
- }
195
- // Step 3: Authenticate with BSMNT for basement integration
196
- try {
197
- const b3Jwt = await (0, bsmnt_1.authenticateWithB3JWT)(response.accessToken);
198
- debug("BSMNT authentication successful", b3Jwt);
199
- }
200
- catch (bsmntError) {
201
- // BSMNT authentication failure shouldn't block the main auth flow
202
- debug("BSMNT authentication failed (non-critical)", bsmntError);
203
- }
204
- return response;
205
- }
206
- catch (err) {
207
- debug("Authentication failed", err);
208
- throw err;
209
- }
210
- }, [referralCode, setUser]);
211
- /**
212
- * Handle wallet connection
213
- * Note: With Turnkey migration, wallet connection is primarily for signing transactions,
214
- * not for authentication. Authentication should be done separately via Turnkey email OTP.
215
- */
216
- /**
217
- * Handle wallet connection
218
- * Note: With Turnkey migration, wallet connection is primarily for signing transactions,
219
- * not for authentication. Authentication should be done separately via Turnkey email OTP.
220
- */
221
- const onConnect = (0, react_2.useCallback)(async (_walleAutoConnectedWith, allConnectedWallets) => {
222
- debug("@@useAuth:onConnect", { _walleAutoConnectedWith, allConnectedWallets });
223
- const wallet = allConnectedWallets.find(wallet => wallet.id.startsWith("ecosystem."));
224
- if (!wallet) {
225
- throw new Error("No smart wallet found during auto-connect");
226
- }
227
- debug("@@useAuth:onConnect", { wallet });
228
- try {
229
- setHasStartedConnecting(true);
230
- setIsConnected(true);
231
- setIsAuthenticating(true);
232
- await setActiveWallet(wallet);
233
- // Try to authenticate user (will use re-authenticate if session exists)
234
- // If no session exists, authentication will need to happen via Turnkey flow
235
- try {
236
- const userAuth = await authenticateUser();
237
- if (userAuth && onConnectCallback) {
238
- await onConnectCallback(wallet, userAuth.accessToken);
239
- }
240
- }
241
- catch (authError) {
242
- // Authentication failed - this is expected if user hasn't authenticated via Turnkey yet
243
- // The Turnkey auth modal should handle this
244
- debug("@@useAuth:onConnect:authFailed", { authError });
245
- // Don't set isAuthenticated to false here - let the Turnkey flow handle it
246
- }
247
- }
248
- catch (error) {
249
- debug("@@useAuth:onConnect:failed", { error });
250
- setIsAuthenticated(false);
251
- setUser(undefined);
252
- }
253
- finally {
254
- setIsAuthenticating(false);
255
- }
256
- debug({
257
- isAuthenticated,
258
- isAuthenticating,
259
- isConnected,
260
- });
261
- }, [
262
- onConnectCallback,
263
- authenticateUser,
264
- isAuthenticated,
265
- isAuthenticating,
266
- isConnected,
267
- setActiveWallet,
268
- setHasStartedConnecting,
269
- setIsAuthenticated,
270
- setIsAuthenticating,
271
- setIsConnected,
272
- setUser,
273
- ]);
274
- const logout = (0, react_2.useCallback)(async (callback) => {
275
- if (activeWallet) {
276
- debug("@@logout:activeWallet", activeWallet);
277
- disconnect(activeWallet);
278
- debug("@@logout:activeWallet", activeWallet);
279
- }
280
- // Log out of each wallet
281
- wallets.forEach(wallet => {
282
- console.log("@@logging out", wallet);
283
- disconnect(wallet);
284
- });
285
- // Delete localStorage thirdweb:connected-wallet-ids
286
- // https://npc-labs.slack.com/archives/C070E6HNG85/p1750185115273099
287
- if (typeof localStorage !== "undefined") {
288
- localStorage.removeItem("thirdweb:connected-wallet-ids");
289
- localStorage.removeItem("wagmi.store");
290
- localStorage.removeItem("lastAuthProvider");
291
- localStorage.removeItem("b3-user");
292
- }
293
- app_1.default.logout();
294
- debug("@@logout:loggedOut");
295
- setIsAuthenticated(false);
296
- setIsConnected(false);
297
- setUser();
298
- callback?.();
299
- }, [activeWallet, disconnect, wallets, setIsAuthenticated, setUser, setIsConnected]);
300
- const { isLoading: useAutoConnectLoading } = (0, react_3.useAutoConnect)({
301
- client: thirdweb_1.client,
302
- wallets: [wallet],
303
- onConnect,
304
- onTimeout: () => {
305
- logout().catch(error => {
306
- debug("@@useAuth:logout on timeout failed", { error });
307
- });
308
- },
309
- });
310
- /**
311
- * useAutoConnectLoading starts as false
312
- */
313
- (0, react_2.useEffect)(() => {
314
- if (!useAutoConnectLoading && useAutoConnectLoadingPrevious.current && !hasStartedConnecting) {
315
- setIsAuthenticating(false);
316
- }
317
- useAutoConnectLoadingPrevious.current = useAutoConnectLoading;
318
- }, [useAutoConnectLoading, hasStartedConnecting, setIsAuthenticating]);
319
- const isReady = isAuthenticated && !isAuthenticating;
320
- return {
321
- authenticate,
322
- reAuthenticate,
323
- logout,
324
- isAuthenticated,
325
- isReady,
326
- isConnecting,
327
- isConnected,
328
- wallet,
329
- preAuthenticate: in_app_1.preAuthenticate,
330
- connect: onConnect,
331
- isAuthenticating,
332
- onConnect,
333
- user,
334
- refetchUser: authenticateUser,
335
- setUser,
336
- };
337
- }
@@ -1,60 +0,0 @@
1
- /**
2
- * Preferred Hook to get the user data
3
- */
4
- export declare function useUser(): {
5
- user: {
6
- email?: string | undefined;
7
- username?: string | undefined;
8
- telNumber?: string | undefined;
9
- ens?: string | undefined;
10
- avatar?: string | undefined;
11
- preferences?: {} | undefined;
12
- referredBy?: string | {} | undefined;
13
- sourceApp?: string | undefined;
14
- referralCode?: string | undefined;
15
- userGroups?: number[] | undefined;
16
- isMigratedFromBSMNT?: boolean | undefined;
17
- privyLinkedAccounts?: {
18
- name?: string | undefined;
19
- address?: string | undefined;
20
- email?: string | undefined;
21
- chain_type?: string | undefined;
22
- lv?: number | undefined;
23
- wallet_client_type?: string | undefined;
24
- smart_wallet_type?: string | undefined;
25
- subject?: string | undefined;
26
- type: string;
27
- }[] | undefined;
28
- twProfiles?: {
29
- type: string;
30
- details: {
31
- id?: string | undefined;
32
- name?: string | undefined;
33
- address?: string | undefined;
34
- email?: string | undefined;
35
- username?: string | undefined;
36
- phone?: string | undefined;
37
- fid?: string | undefined;
38
- };
39
- }[] | undefined;
40
- turnkeySubOrgs?: {
41
- hasDelegatedUser?: boolean | undefined;
42
- subOrgId: string;
43
- accounts: Record<string, any>[];
44
- }[] | undefined;
45
- _id: string | {};
46
- userId: string;
47
- smartAccountAddress: string;
48
- createdAt: number;
49
- updatedAt: number;
50
- partnerIds: {
51
- privyId?: string | undefined;
52
- thirdwebId?: string | undefined;
53
- turnkeyId?: string | undefined;
54
- turnkeyOtpId?: string | undefined;
55
- };
56
- } | null;
57
- isConnecting: boolean;
58
- isConnected: boolean;
59
- isAuthenticating: boolean;
60
- };
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useUser = useUser;
4
- const react_1 = require("../../../global-account/react");
5
- const userStore_1 = require("../stores/userStore");
6
- /**
7
- * Preferred Hook to get the user data
8
- */
9
- function useUser() {
10
- const user = (0, userStore_1.useUserStore)(state => state.user);
11
- const isConnecting = (0, react_1.useAuthStore)(state => state.isConnecting);
12
- const isConnected = (0, react_1.useAuthStore)(state => state.isConnected);
13
- const isAuthenticating = (0, react_1.useAuthStore)(state => state.isAuthenticating);
14
- return {
15
- user,
16
- isConnecting,
17
- isConnected,
18
- isAuthenticating,
19
- };
20
- }
@@ -1,24 +0,0 @@
1
- import { CreateOnrampOrderParams } from "../../../anyspend/react/hooks/useAnyspendCreateOnrampOrder";
2
- import { CreateOrderParams } from "../../../anyspend/react/hooks/useAnyspendCreateOrder";
3
- import { PermissionsConfig } from "../../../global-account/types/permissions";
4
- import { Account } from "thirdweb/wallets";
5
- import { ClientType } from "../../client-manager";
6
- interface ConfigStore {
7
- accountOverride?: Account;
8
- automaticallySetFirstEoa: boolean;
9
- environment: "development" | "production";
10
- defaultPermissions: PermissionsConfig;
11
- theme: "light" | "dark";
12
- clientType: ClientType;
13
- partnerId: string;
14
- stripePublishableKey?: string;
15
- createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
16
- enableTurnkey: boolean;
17
- setConfig: (config: Partial<Omit<ConfigStore, "setConfig">>) => void;
18
- }
19
- /**
20
- * Zustand store for B3 configuration
21
- * NOT persisted - these are developer-set configuration values
22
- */
23
- export declare const useB3ConfigStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ConfigStore>>;
24
- export {};
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useB3ConfigStore = void 0;
4
- const zustand_1 = require("zustand");
5
- /**
6
- * Default permissions configuration for B3 provider
7
- */
8
- const DEFAULT_PERMISSIONS = {
9
- approvedTargets: ["0xa8e42121e318e3D3BeD7f5969AF6D360045317DD"],
10
- nativeTokenLimitPerTransaction: 0.1,
11
- startDate: new Date(),
12
- endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
13
- };
14
- /**
15
- * Zustand store for B3 configuration
16
- * NOT persisted - these are developer-set configuration values
17
- */
18
- exports.useB3ConfigStore = (0, zustand_1.create)(set => ({
19
- accountOverride: undefined,
20
- automaticallySetFirstEoa: false,
21
- environment: "development",
22
- defaultPermissions: DEFAULT_PERMISSIONS,
23
- theme: "light",
24
- clientType: "rest",
25
- partnerId: "",
26
- stripePublishableKey: undefined,
27
- createClientReferenceId: undefined,
28
- enableTurnkey: false,
29
- setConfig: config => set(state => ({ ...state, ...config })),
30
- }));
@@ -1,22 +0,0 @@
1
- import { Users } from "@b3dotfun/b3-api";
2
- interface UserStore {
3
- user: Users | null;
4
- setUser: (user: Users | undefined) => void;
5
- clearUser: () => void;
6
- }
7
- /**
8
- * Zustand store for managing user state
9
- * Persists user data to localStorage
10
- */
11
- export declare const useUserStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<UserStore>, "persist"> & {
12
- persist: {
13
- setOptions: (options: Partial<import("zustand/middleware").PersistOptions<UserStore, UserStore>>) => void;
14
- clearStorage: () => void;
15
- rehydrate: () => Promise<void> | void;
16
- hasHydrated: () => boolean;
17
- onHydrate: (fn: (state: UserStore) => void) => () => void;
18
- onFinishHydration: (fn: (state: UserStore) => void) => () => void;
19
- getOptions: () => Partial<import("zustand/middleware").PersistOptions<UserStore, UserStore>>;
20
- };
21
- }>;
22
- export {};
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useUserStore = void 0;
4
- const debug_1 = require("../../../shared/utils/debug");
5
- const zustand_1 = require("zustand");
6
- const middleware_1 = require("zustand/middleware");
7
- const debug = (0, debug_1.debugB3React)("useUserQuery");
8
- /**
9
- * Zustand store for managing user state
10
- * Persists user data to localStorage
11
- */
12
- exports.useUserStore = (0, zustand_1.create)()((0, middleware_1.persist)(set => ({
13
- user: null,
14
- setUser: (newUser) => {
15
- const userToSave = newUser ?? null;
16
- set({ user: userToSave });
17
- debug("User updated", userToSave);
18
- },
19
- clearUser: () => {
20
- set({ user: null });
21
- debug("User cleared");
22
- },
23
- }), {
24
- name: "b3-user",
25
- onRehydrateStorage: () => (_, error) => {
26
- if (error) {
27
- console.warn("Failed to rehydrate user store:", error);
28
- }
29
- },
30
- }));
@@ -1,6 +0,0 @@
1
- import type { GasPriceData } from "../../../types/gas";
2
- export interface GasIndicatorProps {
3
- gasPrice: GasPriceData;
4
- className?: string;
5
- }
6
- export declare function GasIndicator({ gasPrice, className }: GasIndicatorProps): import("react/jsx-runtime").JSX.Element;
@@ -1,31 +0,0 @@
1
- "use client";
2
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
3
- import { cn } from "../../../../shared/utils/cn.js";
4
- import { motion } from "motion/react";
5
- const LEVEL_LABELS = {
6
- low: "Low",
7
- normal: "Normal",
8
- elevated: "Elevated",
9
- high: "High",
10
- spike: "Spike",
11
- };
12
- const LEVEL_STYLES = {
13
- low: "bg-green-500/20 text-green-500",
14
- normal: "bg-as-surface-tertiary text-as-secondary",
15
- elevated: "bg-yellow-500/20 text-yellow-600",
16
- high: "bg-orange-500/20 text-orange-500",
17
- spike: "bg-red-500/20 text-red-500",
18
- };
19
- function formatGasPrice(gweiString) {
20
- const gwei = parseFloat(gweiString);
21
- if (gwei < 0.001)
22
- return "<0.001";
23
- if (gwei < 1)
24
- return gwei.toFixed(3);
25
- if (gwei < 10)
26
- return gwei.toFixed(2);
27
- return gwei.toFixed(1);
28
- }
29
- export function GasIndicator({ gasPrice, className }) {
30
- return (_jsxs(motion.div, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.2 }, className: cn("flex items-center justify-between rounded-lg px-3 py-2", gasPrice.isSpike ? "bg-yellow-500/10" : "bg-as-surface-secondary", className), children: [_jsx("div", { className: "flex items-center gap-2", children: _jsxs("span", { className: "text-as-secondary text-xs", children: ["Gas on ", gasPrice.chainName] }) }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: cn("rounded px-1.5 py-0.5 text-xs font-medium", LEVEL_STYLES[gasPrice.level]), children: LEVEL_LABELS[gasPrice.level] }), _jsxs("span", { className: "text-as-primary text-xs font-medium", children: [formatGasPrice(gasPrice.gasPriceGwei), " Gwei"] })] })] }));
31
- }
@@ -1,37 +0,0 @@
1
- import type { GasPriceData } from "../../types/gas";
2
- export interface UseGasPriceOptions {
3
- /** Refetch interval in ms (default: 10000 = 10s) */
4
- refetchInterval?: number;
5
- /** Whether to enable the query (default: true if chainId is supported) */
6
- enabled?: boolean;
7
- }
8
- export interface UseGasPriceResult {
9
- /** Gas price data */
10
- gasPrice: GasPriceData | undefined;
11
- /** Whether the query is loading */
12
- isLoading: boolean;
13
- /** Whether there's an error */
14
- isError: boolean;
15
- /** Error object if any */
16
- error: Error | null;
17
- /** Whether gas is currently spiking */
18
- isSpike: boolean;
19
- /** Refetch function */
20
- refetch: () => void;
21
- }
22
- /**
23
- * React hook to fetch current gas price for a chain.
24
- *
25
- * @param chainId - The chain ID to fetch gas price for
26
- * @param options - Optional configuration
27
- *
28
- * @example
29
- * ```tsx
30
- * const { gasPrice, isSpike, isLoading } = useGasPrice(8453); // Base
31
- *
32
- * if (isSpike) {
33
- * return <Warning>Gas prices are high: {gasPrice?.recommendation}</Warning>;
34
- * }
35
- * ```
36
- */
37
- export declare function useGasPrice(chainId: number | undefined, options?: UseGasPriceOptions): UseGasPriceResult;
@@ -1,40 +0,0 @@
1
- import { useQuery } from "@tanstack/react-query";
2
- import { useMemo } from "react";
3
- import { gasService, isGasOracleSupported } from "../../services/gas.js";
4
- /**
5
- * React hook to fetch current gas price for a chain.
6
- *
7
- * @param chainId - The chain ID to fetch gas price for
8
- * @param options - Optional configuration
9
- *
10
- * @example
11
- * ```tsx
12
- * const { gasPrice, isSpike, isLoading } = useGasPrice(8453); // Base
13
- *
14
- * if (isSpike) {
15
- * return <Warning>Gas prices are high: {gasPrice?.recommendation}</Warning>;
16
- * }
17
- * ```
18
- */
19
- export function useGasPrice(chainId, options = {}) {
20
- const { refetchInterval = 10000, enabled } = options;
21
- const isSupported = chainId !== undefined && isGasOracleSupported(chainId);
22
- const queryEnabled = enabled ?? isSupported;
23
- const { data, isLoading, isError, error, refetch } = useQuery({
24
- queryKey: ["gasPrice", chainId],
25
- queryFn: () => gasService.fetch(chainId),
26
- enabled: queryEnabled && chainId !== undefined,
27
- refetchInterval,
28
- staleTime: 5000, // Consider data fresh for 5s
29
- retry: 2,
30
- refetchOnWindowFocus: true,
31
- });
32
- return useMemo(() => ({
33
- gasPrice: data,
34
- isLoading,
35
- isError,
36
- error: error,
37
- isSpike: data?.isSpike ?? false,
38
- refetch,
39
- }), [data, isLoading, isError, error, refetch]);
40
- }
@@ -1,21 +0,0 @@
1
- import type { GasOracleResponse, GasPriceData } from "../types/gas";
2
- /** Supported chain IDs for gas oracle */
3
- export declare const GAS_ORACLE_SUPPORTED_CHAINS: readonly [1, 137, 42161, 8453, 56, 10, 43114, 8333, 2741, 4689, 3338, 1329];
4
- export type GasOracleSupportedChainId = (typeof GAS_ORACLE_SUPPORTED_CHAINS)[number];
5
- /** Check if a chain is supported by the gas oracle */
6
- export declare function isGasOracleSupported(chainId: number): chainId is GasOracleSupportedChainId;
7
- /** Fetch gas price data from the gas oracle */
8
- export declare function fetchGasPrice(chainId: number): Promise<GasOracleResponse>;
9
- /** Transform raw oracle response to simplified UI data */
10
- export declare function toGasPriceData(response: GasOracleResponse): GasPriceData;
11
- /** Gas service for fetching and transforming gas data */
12
- export declare const gasService: {
13
- /** Fetch raw gas oracle response */
14
- fetchRaw: typeof fetchGasPrice;
15
- /** Fetch and transform to UI-friendly format */
16
- fetch: (chainId: number) => Promise<GasPriceData>;
17
- /** Check if chain is supported */
18
- isSupported: typeof isGasOracleSupported;
19
- /** List of supported chain IDs */
20
- supportedChains: readonly [1, 137, 42161, 8453, 56, 10, 43114, 8333, 2741, 4689, 3338, 1329];
21
- };