@b3dotfun/sdk 0.0.40-test.6 → 0.0.41-alpha.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 (264) hide show
  1. package/dist/cjs/anyspend/constants/index.d.ts +0 -1
  2. package/dist/cjs/anyspend/constants/index.js +1 -2
  3. package/dist/cjs/anyspend/react/components/AnySpend.d.ts +11 -1
  4. package/dist/cjs/anyspend/react/components/AnySpend.js +22 -10
  5. package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +0 -1
  6. package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +0 -1
  7. package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +1 -0
  8. package/dist/cjs/anyspend/react/components/AnySpendCustom.js +41 -20
  9. package/dist/cjs/anyspend/react/components/AnySpendNFT.d.ts +2 -1
  10. package/dist/cjs/anyspend/react/components/AnySpendNFT.js +2 -2
  11. package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +0 -1
  12. package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
  13. package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +10 -8
  14. package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.js +1 -2
  15. package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.d.ts +2 -1
  16. package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +7 -4
  17. package/dist/cjs/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
  18. package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +9 -9
  19. package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +80 -10
  20. package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
  21. package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +40 -37
  22. package/dist/cjs/anyspend/react/components/common/OrderDetails.d.ts +2 -0
  23. package/dist/cjs/anyspend/react/components/common/OrderDetails.js +24 -23
  24. package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +9 -8
  25. package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
  26. package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.js +23 -9
  27. package/dist/cjs/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
  28. package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +10 -6
  29. package/dist/cjs/anyspend/react/components/common/PaymentMethodSwitch.d.ts +7 -0
  30. package/dist/cjs/anyspend/react/components/common/PaymentMethodSwitch.js +24 -0
  31. package/dist/cjs/anyspend/react/components/common/PointsBadge.d.ts +7 -0
  32. package/dist/cjs/anyspend/react/components/common/PointsBadge.js +7 -0
  33. package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
  34. package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.js +14 -0
  35. package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.d.ts +2 -0
  36. package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.js +6 -4
  37. package/dist/cjs/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
  38. package/dist/cjs/anyspend/react/contexts/FeatureFlagsContext.js +21 -0
  39. package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
  40. package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +18 -8
  41. package/dist/cjs/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
  42. package/dist/cjs/anyspend/react/providers/AnyspendProvider.js +5 -3
  43. package/dist/cjs/anyspend/react/providers/index.d.ts +1 -0
  44. package/dist/cjs/anyspend/react/providers/index.js +3 -0
  45. package/dist/cjs/anyspend/services/anyspend.d.ts +1 -1
  46. package/dist/cjs/anyspend/services/anyspend.js +2 -0
  47. package/dist/cjs/anyspend/types/api.d.ts +51 -1
  48. package/dist/cjs/anyspend/utils/chain.js +1 -1
  49. package/dist/cjs/anyspend/utils/orderPayload.js +3 -0
  50. package/dist/cjs/bondkit/bondkitToken.d.ts +37 -2
  51. package/dist/cjs/bondkit/bondkitToken.js +268 -2
  52. package/dist/cjs/bondkit/bondkitTokenFactory.d.ts +1 -1
  53. package/dist/cjs/bondkit/bondkitTokenFactory.js +2 -2
  54. package/dist/cjs/bondkit/components/TradingView.js +3 -4
  55. package/dist/cjs/bondkit/config.d.ts +1 -1
  56. package/dist/cjs/bondkit/config.js +5 -2
  57. package/dist/cjs/bondkit/constants.d.ts +4 -0
  58. package/dist/cjs/bondkit/constants.js +6 -1
  59. package/dist/cjs/bondkit/index.d.ts +1 -0
  60. package/dist/cjs/bondkit/index.js +4 -1
  61. package/dist/cjs/bondkit/swapService.d.ts +43 -0
  62. package/dist/cjs/bondkit/swapService.js +376 -0
  63. package/dist/cjs/bondkit/types.d.ts +10 -4
  64. package/dist/cjs/bondkit/types.js +4 -5
  65. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +2 -1
  66. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +27 -28
  67. package/dist/cjs/global-account/react/components/LinkAccount/LinkAccount.js +63 -3
  68. package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +35 -2
  69. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +4 -3
  70. package/dist/cjs/global-account/react/hooks/index.d.ts +1 -0
  71. package/dist/cjs/global-account/react/hooks/index.js +3 -1
  72. package/dist/cjs/global-account/react/hooks/useAccountAssets.js +5 -2
  73. package/dist/cjs/global-account/react/hooks/useAccountWallet.js +0 -12
  74. package/dist/cjs/global-account/react/hooks/useAuthentication.js +2 -3
  75. package/dist/cjs/global-account/react/hooks/useGlobalAccount.d.ts +6 -0
  76. package/dist/cjs/global-account/react/hooks/useGlobalAccount.js +32 -0
  77. package/dist/cjs/global-account/react/hooks/useQueryB3.js +5 -2
  78. package/dist/cjs/global-account/react/hooks/useQueryBSMNT.js +5 -2
  79. package/dist/cjs/global-account/react/hooks/useSimBalance.js +2 -2
  80. package/dist/cjs/global-account/react/hooks/useTokenBalancesByChain.js +7 -1
  81. package/dist/cjs/global-account/react/hooks/useTokenFromUrl.js +2 -2
  82. package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +28 -24
  83. package/dist/cjs/shared/utils/fetchBalances.d.ts +1 -1
  84. package/dist/esm/anyspend/constants/index.d.ts +0 -1
  85. package/dist/esm/anyspend/constants/index.js +0 -1
  86. package/dist/esm/anyspend/react/components/AnySpend.d.ts +11 -1
  87. package/dist/esm/anyspend/react/components/AnySpend.js +23 -11
  88. package/dist/esm/anyspend/react/components/AnySpendBondKit.js +0 -1
  89. package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +0 -1
  90. package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +1 -0
  91. package/dist/esm/anyspend/react/components/AnySpendCustom.js +41 -20
  92. package/dist/esm/anyspend/react/components/AnySpendNFT.d.ts +2 -1
  93. package/dist/esm/anyspend/react/components/AnySpendNFT.js +2 -2
  94. package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +0 -1
  95. package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
  96. package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +11 -9
  97. package/dist/esm/anyspend/react/components/AnyspendSignatureMint.js +1 -2
  98. package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.d.ts +2 -1
  99. package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +8 -5
  100. package/dist/esm/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
  101. package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +9 -9
  102. package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +80 -10
  103. package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
  104. package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +40 -37
  105. package/dist/esm/anyspend/react/components/common/OrderDetails.d.ts +2 -0
  106. package/dist/esm/anyspend/react/components/common/OrderDetails.js +25 -24
  107. package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +10 -9
  108. package/dist/esm/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
  109. package/dist/esm/anyspend/react/components/common/OrderTokenAmount.js +23 -9
  110. package/dist/esm/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
  111. package/dist/esm/anyspend/react/components/common/PanelOnramp.js +10 -6
  112. package/dist/esm/anyspend/react/components/common/PaymentMethodSwitch.d.ts +7 -0
  113. package/dist/esm/anyspend/react/components/common/PaymentMethodSwitch.js +21 -0
  114. package/dist/esm/anyspend/react/components/common/PointsBadge.d.ts +7 -0
  115. package/dist/esm/anyspend/react/components/common/PointsBadge.js +4 -0
  116. package/dist/esm/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
  117. package/dist/esm/anyspend/react/components/common/PointsDetailPanel.js +8 -0
  118. package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.d.ts +2 -0
  119. package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.js +6 -4
  120. package/dist/esm/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
  121. package/dist/esm/anyspend/react/contexts/FeatureFlagsContext.js +17 -0
  122. package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
  123. package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +18 -8
  124. package/dist/esm/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
  125. package/dist/esm/anyspend/react/providers/AnyspendProvider.js +5 -3
  126. package/dist/esm/anyspend/react/providers/index.d.ts +1 -0
  127. package/dist/esm/anyspend/react/providers/index.js +1 -0
  128. package/dist/esm/anyspend/services/anyspend.d.ts +1 -1
  129. package/dist/esm/anyspend/services/anyspend.js +2 -0
  130. package/dist/esm/anyspend/types/api.d.ts +51 -1
  131. package/dist/esm/anyspend/utils/chain.js +1 -1
  132. package/dist/esm/anyspend/utils/orderPayload.js +3 -0
  133. package/dist/esm/bondkit/bondkitToken.d.ts +37 -2
  134. package/dist/esm/bondkit/bondkitToken.js +268 -2
  135. package/dist/esm/bondkit/bondkitTokenFactory.d.ts +1 -1
  136. package/dist/esm/bondkit/bondkitTokenFactory.js +2 -2
  137. package/dist/esm/bondkit/components/TradingView.js +3 -4
  138. package/dist/esm/bondkit/config.d.ts +1 -1
  139. package/dist/esm/bondkit/config.js +5 -2
  140. package/dist/esm/bondkit/constants.d.ts +4 -0
  141. package/dist/esm/bondkit/constants.js +5 -0
  142. package/dist/esm/bondkit/index.d.ts +1 -0
  143. package/dist/esm/bondkit/index.js +2 -0
  144. package/dist/esm/bondkit/swapService.d.ts +43 -0
  145. package/dist/esm/bondkit/swapService.js +372 -0
  146. package/dist/esm/bondkit/types.d.ts +10 -4
  147. package/dist/esm/bondkit/types.js +4 -5
  148. package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +2 -1
  149. package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +27 -28
  150. package/dist/esm/global-account/react/components/LinkAccount/LinkAccount.js +65 -5
  151. package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +35 -2
  152. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +3 -2
  153. package/dist/esm/global-account/react/hooks/index.d.ts +1 -0
  154. package/dist/esm/global-account/react/hooks/index.js +1 -0
  155. package/dist/esm/global-account/react/hooks/useAccountAssets.js +2 -2
  156. package/dist/esm/global-account/react/hooks/useAccountWallet.js +0 -12
  157. package/dist/esm/global-account/react/hooks/useAuthentication.js +2 -3
  158. package/dist/esm/global-account/react/hooks/useGlobalAccount.d.ts +6 -0
  159. package/dist/esm/global-account/react/hooks/useGlobalAccount.js +29 -0
  160. package/dist/esm/global-account/react/hooks/useQueryB3.js +5 -2
  161. package/dist/esm/global-account/react/hooks/useQueryBSMNT.js +5 -2
  162. package/dist/esm/global-account/react/hooks/useSimBalance.js +2 -2
  163. package/dist/esm/global-account/react/hooks/useTokenBalancesByChain.js +4 -1
  164. package/dist/esm/global-account/react/hooks/useTokenFromUrl.js +2 -2
  165. package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +29 -25
  166. package/dist/esm/shared/utils/fetchBalances.d.ts +1 -1
  167. package/dist/styles/index.css +1 -1
  168. package/dist/types/anyspend/constants/index.d.ts +0 -1
  169. package/dist/types/anyspend/react/components/AnySpend.d.ts +11 -1
  170. package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +1 -0
  171. package/dist/types/anyspend/react/components/AnySpendNFT.d.ts +2 -1
  172. package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
  173. package/dist/types/anyspend/react/components/common/ConnectWalletPayment.d.ts +2 -1
  174. package/dist/types/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
  175. package/dist/types/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
  176. package/dist/types/anyspend/react/components/common/OrderDetails.d.ts +2 -0
  177. package/dist/types/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
  178. package/dist/types/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
  179. package/dist/types/anyspend/react/components/common/PaymentMethodSwitch.d.ts +7 -0
  180. package/dist/types/anyspend/react/components/common/PointsBadge.d.ts +7 -0
  181. package/dist/types/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
  182. package/dist/types/anyspend/react/components/common/TransferCryptoDetails.d.ts +2 -0
  183. package/dist/types/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
  184. package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
  185. package/dist/types/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
  186. package/dist/types/anyspend/react/providers/index.d.ts +1 -0
  187. package/dist/types/anyspend/services/anyspend.d.ts +1 -1
  188. package/dist/types/anyspend/types/api.d.ts +51 -1
  189. package/dist/types/bondkit/bondkitToken.d.ts +37 -2
  190. package/dist/types/bondkit/bondkitTokenFactory.d.ts +1 -1
  191. package/dist/types/bondkit/config.d.ts +1 -1
  192. package/dist/types/bondkit/constants.d.ts +4 -0
  193. package/dist/types/bondkit/index.d.ts +1 -0
  194. package/dist/types/bondkit/swapService.d.ts +43 -0
  195. package/dist/types/bondkit/types.d.ts +10 -4
  196. package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +2 -1
  197. package/dist/types/global-account/react/hooks/index.d.ts +1 -0
  198. package/dist/types/global-account/react/hooks/useGlobalAccount.d.ts +6 -0
  199. package/dist/types/shared/utils/fetchBalances.d.ts +1 -1
  200. package/package.json +1 -1
  201. package/src/anyspend/constants/index.ts +0 -2
  202. package/src/anyspend/react/components/AnySpend.tsx +52 -18
  203. package/src/anyspend/react/components/AnySpendBondKit.tsx +0 -1
  204. package/src/anyspend/react/components/AnySpendBuySpin.tsx +0 -1
  205. package/src/anyspend/react/components/AnySpendCustom.tsx +82 -34
  206. package/src/anyspend/react/components/AnySpendNFT.tsx +3 -0
  207. package/src/anyspend/react/components/AnySpendStakeB3.tsx +0 -1
  208. package/src/anyspend/react/components/AnyspendDepositHype.tsx +38 -18
  209. package/src/anyspend/react/components/AnyspendSignatureMint.tsx +1 -2
  210. package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +12 -4
  211. package/src/anyspend/react/components/common/CryptoPaySection.tsx +13 -8
  212. package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +170 -44
  213. package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +61 -45
  214. package/src/anyspend/react/components/common/OrderDetails.tsx +60 -47
  215. package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +62 -41
  216. package/src/anyspend/react/components/common/OrderTokenAmount.tsx +28 -8
  217. package/src/anyspend/react/components/common/PanelOnramp.tsx +28 -15
  218. package/src/anyspend/react/components/common/PaymentMethodSwitch.tsx +38 -0
  219. package/src/anyspend/react/components/common/PointsBadge.tsx +20 -0
  220. package/src/anyspend/react/components/common/PointsDetailPanel.tsx +55 -0
  221. package/src/anyspend/react/components/common/TransferCryptoDetails.tsx +65 -43
  222. package/src/anyspend/react/contexts/FeatureFlagsContext.tsx +34 -0
  223. package/src/anyspend/react/hooks/useAnyspendFlow.ts +18 -8
  224. package/src/anyspend/react/hooks/useAnyspendOrderAndTransactions.ts +1 -1
  225. package/src/anyspend/react/hooks/useCoinbaseOnrampOptions.ts +1 -1
  226. package/src/anyspend/react/providers/AnyspendProvider.tsx +11 -6
  227. package/src/anyspend/react/providers/index.ts +1 -0
  228. package/src/anyspend/services/anyspend.ts +3 -1
  229. package/src/anyspend/types/api.ts +51 -1
  230. package/src/anyspend/types/api_req_res.ts +6 -10
  231. package/src/anyspend/utils/chain.ts +1 -1
  232. package/src/anyspend/utils/orderPayload.ts +3 -0
  233. package/src/bondkit/bondkitToken.ts +323 -3
  234. package/src/bondkit/bondkitTokenFactory.ts +2 -2
  235. package/src/bondkit/components/TradingView.tsx +3 -5
  236. package/src/bondkit/config.ts +5 -2
  237. package/src/bondkit/constants.ts +7 -0
  238. package/src/bondkit/index.ts +3 -0
  239. package/src/bondkit/swapService.ts +464 -0
  240. package/src/bondkit/types.ts +12 -5
  241. package/src/global-account/react/components/B3Provider/B3Provider.tsx +31 -32
  242. package/src/global-account/react/components/LinkAccount/LinkAccount.tsx +106 -32
  243. package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +60 -5
  244. package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +4 -2
  245. package/src/global-account/react/hooks/index.ts +1 -0
  246. package/src/global-account/react/hooks/useAccountAssets.ts +4 -3
  247. package/src/global-account/react/hooks/useAccountWallet.tsx +0 -13
  248. package/src/global-account/react/hooks/useAuthentication.ts +2 -3
  249. package/src/global-account/react/hooks/useGlobalAccount.tsx +36 -0
  250. package/src/global-account/react/hooks/useOneBalance.tsx +1 -1
  251. package/src/global-account/react/hooks/useQueryB3.ts +22 -15
  252. package/src/global-account/react/hooks/useQueryBSMNT.ts +22 -15
  253. package/src/global-account/react/hooks/useSimBalance.ts +2 -2
  254. package/src/global-account/react/hooks/useTokenBalancesByChain.tsx +4 -1
  255. package/src/global-account/react/hooks/useTokenFromUrl.tsx +2 -2
  256. package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +30 -26
  257. package/src/shared/utils/fetchBalances.ts +1 -1
  258. package/dist/cjs/global-account/examples/client-selection-example.d.ts +0 -5
  259. package/dist/cjs/global-account/examples/client-selection-example.js +0 -96
  260. package/dist/esm/global-account/examples/client-selection-example.d.ts +0 -5
  261. package/dist/esm/global-account/examples/client-selection-example.js +0 -93
  262. package/dist/types/global-account/examples/client-selection-example.d.ts +0 -5
  263. package/src/global-account/docs/client-selection.md +0 -292
  264. package/src/global-account/examples/client-selection-example.tsx +0 -197
@@ -6,10 +6,11 @@ import invariant from "invariant";
6
6
  import { useCallback, useState } from "react";
7
7
  import { toast } from "sonner";
8
8
  import { prepareTransaction, sendTransaction as twSendTransaction } from "thirdweb";
9
- import { useSwitchChain, useWalletClient } from "wagmi";
9
+ import { useActiveWallet } from "thirdweb/react";
10
+ import { isAddress } from "viem";
11
+ import { useSwitchChain } from "wagmi";
10
12
  import { useB3 } from "../components";
11
13
  import { useAccountWallet } from "./useAccountWallet";
12
- import { isAddress } from "viem";
13
14
 
14
15
  export interface UnifiedTransactionParams {
15
16
  to: string;
@@ -26,49 +27,55 @@ const partnerId = String(
26
27
  invariant(partnerId, "Partner ID is required");
27
28
 
28
29
  export function useUnifiedChainSwitchAndExecute() {
29
- const { data: walletClient } = useWalletClient();
30
30
  const { switchChainAsync } = useSwitchChain();
31
31
  const [isSwitchingOrExecuting, setIsSwitchingOrExecuting] = useState(false);
32
+ const activeWallet = useActiveWallet();
32
33
 
33
- const { isActiveSmartWallet, isActiveEOAWallet } = useAccountWallet();
34
+ const { isActiveSmartWallet, isActiveEOAWallet, connectedEOAWallet } = useAccountWallet();
34
35
  const { account: aaAccount } = useB3();
35
36
 
36
37
  // Handle EOA wallet chain switch and execute transaction
37
38
  const handleEOASwitchChainAndSendTransaction = useCallback(
38
39
  async (targetChainId: number, params: UnifiedTransactionParams): Promise<string | undefined> => {
39
- if (!walletClient) {
40
+ if (!connectedEOAWallet) {
40
41
  toast.error("Please connect your wallet");
41
42
  return;
42
43
  }
43
44
 
44
- const providerId = walletClient.chain.id;
45
- const onCorrectChain = providerId === targetChainId;
45
+ // Get target chain configuration once
46
+ const targetChain = supportedChains.find(chain => chain.id === targetChainId);
47
+ if (!targetChain) {
48
+ toast.error(`Chain ${targetChainId} is not supported`);
49
+ return;
50
+ }
51
+
52
+ const currentChainId = activeWallet?.getChain()?.id;
53
+ const onCorrectChain = currentChainId === targetChainId;
46
54
 
47
55
  // Helper function to execute the transaction
48
56
  const executeTransaction = async (): Promise<string> => {
49
- const signer = walletClient.account;
57
+ const signer = activeWallet?.getAccount();
50
58
  if (!signer) {
51
59
  throw new Error("No account connected");
52
60
  }
53
61
 
54
- // Get the target chain configuration instead of using potentially stale walletClient.chain
55
- const targetChain = supportedChains.find(chain => chain.id === targetChainId);
56
- if (!targetChain) {
57
- throw new Error(`Chain ${targetChainId} is not supported`);
62
+ // Coinbase Smart Wallet specific chain switching (different behavior from other wallets)
63
+ const walletChain = connectedEOAWallet.getChain();
64
+ if (walletChain?.id !== targetChainId) {
65
+ activeWallet?.switchChain(getThirdwebChain(targetChainId));
58
66
  }
59
67
 
60
68
  invariant(isAddress(params.to), "params.to is not a valid address");
61
69
 
62
- const hash = await walletClient.sendTransaction({
63
- account: signer,
64
- chain: targetChain,
70
+ const result = await signer.sendTransaction({
71
+ chainId: targetChainId,
65
72
  to: params.to,
66
73
  data: params.data as `0x${string}`,
67
74
  value: params.value,
68
75
  });
69
76
 
70
- toast.success(`Transaction sent: ${hash.slice(0, 10)}...`);
71
- return hash;
77
+ toast.success(`Transaction sent: ${result.transactionHash.slice(0, 10)}...`);
78
+ return result.transactionHash;
72
79
  };
73
80
 
74
81
  try {
@@ -80,12 +87,6 @@ export function useUnifiedChainSwitchAndExecute() {
80
87
 
81
88
  const switchingToastId = toast.info(`Switching to ${getChainName(targetChainId)}…`);
82
89
 
83
- const targetChain = supportedChains.find(chain => chain.id === targetChainId);
84
- if (!targetChain) {
85
- toast.error(`Chain ${targetChainId} is not supported`);
86
- return;
87
- }
88
-
89
90
  const blockExplorerUrl = targetChain.blockExplorers?.default.url;
90
91
  invariant(blockExplorerUrl, "Block explorer URL is required");
91
92
  const nativeCurrency = getNativeToken(targetChainId);
@@ -120,7 +121,7 @@ export function useUnifiedChainSwitchAndExecute() {
120
121
  setIsSwitchingOrExecuting(false);
121
122
  }
122
123
  },
123
- [walletClient, switchChainAsync],
124
+ [connectedEOAWallet, activeWallet, switchChainAsync],
124
125
  );
125
126
 
126
127
  // Handle AA wallet transaction (no chain switch needed for AA)
@@ -154,19 +155,22 @@ export function useUnifiedChainSwitchAndExecute() {
154
155
  value: params.value.toString(),
155
156
  });
156
157
  } catch (err: any) {
157
- console.error(err);
158
+ console.error("Create global-accounts-intents error", err);
158
159
  }
159
160
 
160
161
  toast.info("Sending transaction…");
162
+ const start = performance.now();
161
163
  const sendTxResponse = await twSendTransaction({
162
164
  account: aaAccount,
163
165
  transaction,
164
166
  });
167
+ const end = performance.now();
168
+ console.log("Time taken to send transaction", end - start);
165
169
 
166
170
  toast.success("Transaction sent successfully");
167
171
  return sendTxResponse.transactionHash;
168
172
  } catch (err: any) {
169
- console.error(err);
173
+ console.error("Send transaction error", err);
170
174
  toast.error(err?.message ?? "Transaction failed");
171
175
  return undefined;
172
176
  } finally {
@@ -19,7 +19,7 @@ export interface AssetBalance {
19
19
  chainBalances: ChainBalance[];
20
20
  }
21
21
 
22
- export const fetchBalances = async (address: string, testnet?: boolean): Promise<AssetBalance[]> => {
22
+ export const fetchBalances = async (address: string | undefined, testnet?: boolean): Promise<AssetBalance[]> => {
23
23
  if (!address) return [];
24
24
 
25
25
  const assetsResponse = await fetch(`${getSprinterBaseUrl(testnet)}/assets/fungible`);
@@ -1,5 +0,0 @@
1
- /**
2
- * Example app showing different client configurations
3
- */
4
- export declare function ClientSelectionApp(): import("react/jsx-runtime").JSX.Element;
5
- export default ClientSelectionApp;
@@ -1,96 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ClientSelectionApp = ClientSelectionApp;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("../../global-account/react");
6
- const react_2 = require("react");
7
- /**
8
- * Example component showing how to use the client selection system
9
- */
10
- function ClientSelectionExample() {
11
- const { clientType, switchClientType, getCurrentClient, authenticateWithType } = (0, react_1.useClient)();
12
- const { user } = (0, react_1.useB3)();
13
- const [data, setData] = (0, react_2.useState)(null);
14
- const [loading, setLoading] = (0, react_2.useState)(false);
15
- const handleSwitchClient = (type) => {
16
- switchClientType(type);
17
- };
18
- const handleFetchData = async () => {
19
- setLoading(true);
20
- try {
21
- const client = getCurrentClient();
22
- const result = await client.service("users").find();
23
- setData(result);
24
- }
25
- catch (error) {
26
- console.error("Failed to fetch data:", error);
27
- }
28
- finally {
29
- setLoading(false);
30
- }
31
- };
32
- const handleAuthenticateWithType = async (type) => {
33
- try {
34
- const result = await authenticateWithType(type, "your-access-token", "your-identity-token");
35
- console.log(`Authenticated with ${type}:`, result);
36
- }
37
- catch (error) {
38
- console.error(`Authentication failed with ${type}:`, error);
39
- }
40
- };
41
- return ((0, jsx_runtime_1.jsxs)("div", { style: { padding: "20px", fontFamily: "Arial, sans-serif" }, children: [(0, jsx_runtime_1.jsx)("h2", { children: "Client Selection Example" }), (0, jsx_runtime_1.jsxs)("div", { style: { marginBottom: "20px" }, children: [(0, jsx_runtime_1.jsxs)("h3", { children: ["Current Client Type: ", clientType] }), (0, jsx_runtime_1.jsxs)("div", { style: { display: "flex", gap: "10px", marginBottom: "10px" }, children: [(0, jsx_runtime_1.jsx)("button", { onClick: () => handleSwitchClient("socket"), style: {
42
- padding: "8px 16px",
43
- backgroundColor: clientType === "socket" ? "#007bff" : "#f8f9fa",
44
- color: clientType === "socket" ? "white" : "black",
45
- border: "1px solid #007bff",
46
- borderRadius: "4px",
47
- cursor: "pointer"
48
- }, children: "Switch to Socket" }), (0, jsx_runtime_1.jsx)("button", { onClick: () => handleSwitchClient("rest"), style: {
49
- padding: "8px 16px",
50
- backgroundColor: clientType === "rest" ? "#007bff" : "#f8f9fa",
51
- color: clientType === "rest" ? "white" : "black",
52
- border: "1px solid #007bff",
53
- borderRadius: "4px",
54
- cursor: "pointer"
55
- }, children: "Switch to REST" })] })] }), (0, jsx_runtime_1.jsxs)("div", { style: { marginBottom: "20px" }, children: [(0, jsx_runtime_1.jsx)("h3", { children: "Test API Calls" }), (0, jsx_runtime_1.jsx)("button", { onClick: handleFetchData, disabled: loading, style: {
56
- padding: "8px 16px",
57
- backgroundColor: "#28a745",
58
- color: "white",
59
- border: "none",
60
- borderRadius: "4px",
61
- cursor: loading ? "not-allowed" : "pointer"
62
- }, children: loading ? "Loading..." : "Fetch Data" }), data && ((0, jsx_runtime_1.jsx)("pre", { style: {
63
- marginTop: "10px",
64
- padding: "10px",
65
- backgroundColor: "#f8f9fa",
66
- borderRadius: "4px",
67
- overflow: "auto"
68
- }, children: JSON.stringify(data, null, 2) }))] }), (0, jsx_runtime_1.jsxs)("div", { style: { marginBottom: "20px" }, children: [(0, jsx_runtime_1.jsx)("h3", { children: "Authentication Tests" }), (0, jsx_runtime_1.jsxs)("div", { style: { display: "flex", gap: "10px" }, children: [(0, jsx_runtime_1.jsx)("button", { onClick: () => handleAuthenticateWithType("socket"), style: {
69
- padding: "8px 16px",
70
- backgroundColor: "#17a2b8",
71
- color: "white",
72
- border: "none",
73
- borderRadius: "4px",
74
- cursor: "pointer"
75
- }, children: "Auth with Socket" }), (0, jsx_runtime_1.jsx)("button", { onClick: () => handleAuthenticateWithType("rest"), style: {
76
- padding: "8px 16px",
77
- backgroundColor: "#17a2b8",
78
- color: "white",
79
- border: "none",
80
- borderRadius: "4px",
81
- cursor: "pointer"
82
- }, children: "Auth with REST" })] })] }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h3", { children: "User Status" }), (0, jsx_runtime_1.jsxs)("p", { children: ["Authenticated: ", user ? "Yes" : "No"] }), user && ((0, jsx_runtime_1.jsx)("pre", { style: {
83
- padding: "10px",
84
- backgroundColor: "#f8f9fa",
85
- borderRadius: "4px",
86
- overflow: "auto"
87
- }, children: JSON.stringify(user, null, 2) }))] })] }));
88
- }
89
- /**
90
- * Example app showing different client configurations
91
- */
92
- function ClientSelectionApp() {
93
- const [clientType, setClientType] = (0, react_2.useState)("socket");
94
- return ((0, jsx_runtime_1.jsx)(react_1.B3Provider, { environment: "development", clientType: clientType, automaticallySetFirstEoa: true, theme: "light", children: (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h1", { children: "B3 SDK Client Selection Demo" }), (0, jsx_runtime_1.jsx)("div", { style: { marginBottom: "20px" }, children: (0, jsx_runtime_1.jsxs)("label", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Provider Client Type:" }), (0, jsx_runtime_1.jsxs)("select", { value: clientType, onChange: (e) => setClientType(e.target.value), style: { marginLeft: "10px", padding: "4px 8px" }, children: [(0, jsx_runtime_1.jsx)("option", { value: "socket", children: "Socket (Default)" }), (0, jsx_runtime_1.jsx)("option", { value: "rest", children: "REST" })] })] }) }), (0, jsx_runtime_1.jsx)(ClientSelectionExample, {})] }) }));
95
- }
96
- exports.default = ClientSelectionApp;
@@ -1,5 +0,0 @@
1
- /**
2
- * Example app showing different client configurations
3
- */
4
- export declare function ClientSelectionApp(): import("react/jsx-runtime").JSX.Element;
5
- export default ClientSelectionApp;
@@ -1,93 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { B3Provider, useB3, useClient } from "../../global-account/react/index.js";
3
- import { useState } from "react";
4
- /**
5
- * Example component showing how to use the client selection system
6
- */
7
- function ClientSelectionExample() {
8
- const { clientType, switchClientType, getCurrentClient, authenticateWithType } = useClient();
9
- const { user } = useB3();
10
- const [data, setData] = useState(null);
11
- const [loading, setLoading] = useState(false);
12
- const handleSwitchClient = (type) => {
13
- switchClientType(type);
14
- };
15
- const handleFetchData = async () => {
16
- setLoading(true);
17
- try {
18
- const client = getCurrentClient();
19
- const result = await client.service("users").find();
20
- setData(result);
21
- }
22
- catch (error) {
23
- console.error("Failed to fetch data:", error);
24
- }
25
- finally {
26
- setLoading(false);
27
- }
28
- };
29
- const handleAuthenticateWithType = async (type) => {
30
- try {
31
- const result = await authenticateWithType(type, "your-access-token", "your-identity-token");
32
- console.log(`Authenticated with ${type}:`, result);
33
- }
34
- catch (error) {
35
- console.error(`Authentication failed with ${type}:`, error);
36
- }
37
- };
38
- return (_jsxs("div", { style: { padding: "20px", fontFamily: "Arial, sans-serif" }, children: [_jsx("h2", { children: "Client Selection Example" }), _jsxs("div", { style: { marginBottom: "20px" }, children: [_jsxs("h3", { children: ["Current Client Type: ", clientType] }), _jsxs("div", { style: { display: "flex", gap: "10px", marginBottom: "10px" }, children: [_jsx("button", { onClick: () => handleSwitchClient("socket"), style: {
39
- padding: "8px 16px",
40
- backgroundColor: clientType === "socket" ? "#007bff" : "#f8f9fa",
41
- color: clientType === "socket" ? "white" : "black",
42
- border: "1px solid #007bff",
43
- borderRadius: "4px",
44
- cursor: "pointer"
45
- }, children: "Switch to Socket" }), _jsx("button", { onClick: () => handleSwitchClient("rest"), style: {
46
- padding: "8px 16px",
47
- backgroundColor: clientType === "rest" ? "#007bff" : "#f8f9fa",
48
- color: clientType === "rest" ? "white" : "black",
49
- border: "1px solid #007bff",
50
- borderRadius: "4px",
51
- cursor: "pointer"
52
- }, children: "Switch to REST" })] })] }), _jsxs("div", { style: { marginBottom: "20px" }, children: [_jsx("h3", { children: "Test API Calls" }), _jsx("button", { onClick: handleFetchData, disabled: loading, style: {
53
- padding: "8px 16px",
54
- backgroundColor: "#28a745",
55
- color: "white",
56
- border: "none",
57
- borderRadius: "4px",
58
- cursor: loading ? "not-allowed" : "pointer"
59
- }, children: loading ? "Loading..." : "Fetch Data" }), data && (_jsx("pre", { style: {
60
- marginTop: "10px",
61
- padding: "10px",
62
- backgroundColor: "#f8f9fa",
63
- borderRadius: "4px",
64
- overflow: "auto"
65
- }, children: JSON.stringify(data, null, 2) }))] }), _jsxs("div", { style: { marginBottom: "20px" }, children: [_jsx("h3", { children: "Authentication Tests" }), _jsxs("div", { style: { display: "flex", gap: "10px" }, children: [_jsx("button", { onClick: () => handleAuthenticateWithType("socket"), style: {
66
- padding: "8px 16px",
67
- backgroundColor: "#17a2b8",
68
- color: "white",
69
- border: "none",
70
- borderRadius: "4px",
71
- cursor: "pointer"
72
- }, children: "Auth with Socket" }), _jsx("button", { onClick: () => handleAuthenticateWithType("rest"), style: {
73
- padding: "8px 16px",
74
- backgroundColor: "#17a2b8",
75
- color: "white",
76
- border: "none",
77
- borderRadius: "4px",
78
- cursor: "pointer"
79
- }, children: "Auth with REST" })] })] }), _jsxs("div", { children: [_jsx("h3", { children: "User Status" }), _jsxs("p", { children: ["Authenticated: ", user ? "Yes" : "No"] }), user && (_jsx("pre", { style: {
80
- padding: "10px",
81
- backgroundColor: "#f8f9fa",
82
- borderRadius: "4px",
83
- overflow: "auto"
84
- }, children: JSON.stringify(user, null, 2) }))] })] }));
85
- }
86
- /**
87
- * Example app showing different client configurations
88
- */
89
- export function ClientSelectionApp() {
90
- const [clientType, setClientType] = useState("socket");
91
- return (_jsx(B3Provider, { environment: "development", clientType: clientType, automaticallySetFirstEoa: true, theme: "light", children: _jsxs("div", { children: [_jsx("h1", { children: "B3 SDK Client Selection Demo" }), _jsx("div", { style: { marginBottom: "20px" }, children: _jsxs("label", { children: [_jsx("strong", { children: "Provider Client Type:" }), _jsxs("select", { value: clientType, onChange: (e) => setClientType(e.target.value), style: { marginLeft: "10px", padding: "4px 8px" }, children: [_jsx("option", { value: "socket", children: "Socket (Default)" }), _jsx("option", { value: "rest", children: "REST" })] })] }) }), _jsx(ClientSelectionExample, {})] }) }));
92
- }
93
- export default ClientSelectionApp;
@@ -1,5 +0,0 @@
1
- /**
2
- * Example app showing different client configurations
3
- */
4
- export declare function ClientSelectionApp(): import("react/jsx-runtime").JSX.Element;
5
- export default ClientSelectionApp;
@@ -1,292 +0,0 @@
1
- # FeathersJS Client Selection
2
-
3
- The B3 SDK now supports both Socket.IO and REST clients for communicating with the B3 API. This document explains how to choose and configure the appropriate client type for your application.
4
-
5
- ## Client Types
6
-
7
- ### Socket Client (Default)
8
- - **Real-time communication** via WebSocket
9
- - **Lower latency** for frequent updates
10
- - **Automatic reconnection** on connection loss
11
- - **Best for**: Interactive applications, real-time features, frequent API calls
12
-
13
- ### REST Client
14
- - **HTTP-based communication** via REST API
15
- - **Better for server-side rendering** and static generation
16
- - **Simpler debugging** and network inspection
17
- - **Best for**: Static sites, server-side rendering, simple integrations
18
-
19
- ## Configuration
20
-
21
- ### 1. Provider-Level Configuration (Recommended)
22
-
23
- Configure the client type at the provider level for your entire application:
24
-
25
- ```tsx
26
- import { B3Provider } from "@b3dotfun/sdk/global-account/react";
27
-
28
- function App() {
29
- return (
30
- <B3Provider
31
- environment="production"
32
- clientType="rest" // or "socket"
33
- // ... other props
34
- >
35
- <YourApp />
36
- </B3Provider>
37
- );
38
- }
39
- ```
40
-
41
- ### 2. Programmatic Configuration
42
-
43
- Change the client type at runtime:
44
-
45
- ```tsx
46
- import { useClient } from "@b3dotfun/sdk/global-account/react";
47
-
48
- function MyComponent() {
49
- const { switchClientType, clientType } = useClient();
50
-
51
- const handleSwitchToRest = () => {
52
- switchClientType("rest");
53
- };
54
-
55
- return (
56
- <div>
57
- <p>Current client: {clientType}</p>
58
- <button onClick={handleSwitchToRest}>Switch to REST</button>
59
- </div>
60
- );
61
- }
62
- ```
63
-
64
- ### 3. Direct Client Access
65
-
66
- Access specific client types directly:
67
-
68
- ```tsx
69
- import { useClient } from "@b3dotfun/sdk/global-account/react";
70
-
71
- function MyComponent() {
72
- const { getCurrentClient, getClientByType } = useClient();
73
-
74
- // Get the currently active client
75
- const currentClient = getCurrentClient();
76
-
77
- // Get a specific client type
78
- const restClient = getClientByType("rest");
79
- const socketClient = getClientByType("socket");
80
-
81
- // Use the clients directly
82
- const data = await currentClient.service("users").find();
83
- }
84
- ```
85
-
86
- ## Authentication
87
-
88
- ### Single Client Authentication
89
-
90
- Authenticate with the currently active client:
91
-
92
- ```tsx
93
- import { useClient } from "@b3dotfun/sdk/global-account/react";
94
-
95
- function LoginComponent() {
96
- const { getCurrentClient } = useClient();
97
-
98
- const handleLogin = async () => {
99
- const client = getCurrentClient();
100
- await client.authenticate({
101
- strategy: "jwt",
102
- accessToken: "your-token"
103
- });
104
- };
105
- }
106
- ```
107
-
108
- ### Multi-Client Authentication
109
-
110
- Authenticate with both clients simultaneously (useful for migration scenarios):
111
-
112
- ```tsx
113
- import { useClient } from "@b3dotfun/sdk/global-account/react";
114
-
115
- function LoginComponent() {
116
- const { authenticateWithBoth } = useClient();
117
-
118
- const handleLogin = async () => {
119
- const result = await authenticateWithBoth("access-token", "identity-token");
120
-
121
- if (result.success) {
122
- console.log("Socket auth:", result.socket);
123
- console.log("REST auth:", result.rest);
124
- }
125
- };
126
- }
127
- ```
128
-
129
- ### Type-Specific Authentication
130
-
131
- Authenticate with a specific client type:
132
-
133
- ```tsx
134
- import { useClient } from "@b3dotfun/sdk/global-account/react";
135
-
136
- function LoginComponent() {
137
- const { authenticateWithType } = useClient();
138
-
139
- const handleRestLogin = async () => {
140
- await authenticateWithType("rest", "access-token", "identity-token");
141
- };
142
-
143
- const handleSocketLogin = async () => {
144
- await authenticateWithType("socket", "access-token", "identity-token");
145
- };
146
- }
147
- ```
148
-
149
- ## Migration Guide
150
-
151
- ### From Socket-Only to Client Selection
152
-
153
- **Before:**
154
- ```tsx
155
- import app from "@b3dotfun/sdk/global-account/app";
156
-
157
- // Always used socket client
158
- const data = await app.service("users").find();
159
- ```
160
-
161
- **After (Backwards Compatible):**
162
- ```tsx
163
- import app from "@b3dotfun/sdk/global-account/app";
164
-
165
- // Still works - defaults to socket client
166
- const data = await app.service("users").find();
167
- ```
168
-
169
- **After (Explicit Client Selection):**
170
- ```tsx
171
- import { B3Provider } from "@b3dotfun/sdk/global-account/react";
172
-
173
- // Configure at provider level
174
- <B3Provider clientType="rest">
175
- <App />
176
- </B3Provider>
177
- ```
178
-
179
- ### From Direct REST Import
180
-
181
- **Before:**
182
- ```tsx
183
- import app from "@b3dotfun/sdk/global-account/app.rest";
184
-
185
- // Always used REST client
186
- const data = await app.service("users").find();
187
- ```
188
-
189
- **After:**
190
- ```tsx
191
- import { B3Provider } from "@b3dotfun/sdk/global-account/react";
192
-
193
- // Configure at provider level
194
- <B3Provider clientType="rest">
195
- <App />
196
- </B3Provider>
197
- ```
198
-
199
- ## Best Practices
200
-
201
- ### 1. Choose the Right Client Type
202
-
203
- - **Use Socket** for: Real-time apps, frequent updates, interactive features
204
- - **Use REST** for: Static sites, SSR, simple integrations, debugging
205
-
206
- ### 2. Consistent Client Usage
207
-
208
- - Set the client type once at the provider level
209
- - Avoid mixing client types within the same app unless necessary
210
- - Use the `useClient` hook for runtime client access
211
-
212
- ### 3. Error Handling
213
-
214
- ```tsx
215
- import { useClient } from "@b3dotfun/sdk/global-account/react";
216
-
217
- function MyComponent() {
218
- const { getCurrentClient } = useClient();
219
-
220
- const fetchData = async () => {
221
- try {
222
- const client = getCurrentClient();
223
- const data = await client.service("users").find();
224
- return data;
225
- } catch (error) {
226
- console.error("API call failed:", error);
227
- // Handle error appropriately
228
- }
229
- };
230
- }
231
- ```
232
-
233
- ### 4. Performance Considerations
234
-
235
- - Socket clients maintain persistent connections
236
- - REST clients make individual HTTP requests
237
- - Consider your app's communication patterns when choosing
238
-
239
- ## Troubleshooting
240
-
241
- ### Common Issues
242
-
243
- 1. **Client Type Not Switching**
244
- - Ensure you're calling `switchClientType` after the provider is mounted
245
- - Check that the provider has the correct `clientType` prop
246
-
247
- 2. **Authentication Failures**
248
- - Verify the client type matches your authentication strategy
249
- - Check that tokens are valid for the selected client type
250
-
251
- 3. **Connection Issues**
252
- - For socket clients: Check WebSocket connectivity
253
- - For REST clients: Verify HTTP endpoints are accessible
254
-
255
- ### Debug Information
256
-
257
- ```tsx
258
- import { useClient } from "@b3dotfun/sdk/global-account/react";
259
-
260
- function DebugComponent() {
261
- const { clientType, getCurrentClient } = useClient();
262
-
263
- console.log("Current client type:", clientType);
264
- console.log("Current client:", getCurrentClient());
265
- }
266
- ```
267
-
268
- ## API Reference
269
-
270
- ### B3Provider Props
271
-
272
- ```tsx
273
- interface B3ProviderProps {
274
- clientType?: "socket" | "rest"; // Default: "socket"
275
- // ... other props
276
- }
277
- ```
278
-
279
- ### useClient Hook
280
-
281
- ```tsx
282
- interface UseClientReturn {
283
- clientType: "socket" | "rest";
284
- getCurrentClient: () => ClientApplication;
285
- getClientByType: (type: ClientType) => ClientApplication;
286
- switchClientType: (type: ClientType) => void;
287
- authenticateWithType: (type: ClientType, accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<any>;
288
- authenticateWithBoth: (accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<{socket: any, rest: any, success: boolean}>;
289
- }
290
- ```
291
-
292
-