@b3dotfun/sdk 0.0.62 → 0.0.63-test.0-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 (150) hide show
  1. package/dist/cjs/anyspend/react/components/AnySpend.js +61 -23
  2. package/dist/cjs/anyspend/react/components/AnySpendCustom.js +3 -0
  3. package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.d.ts +34 -0
  4. package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +275 -0
  5. package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +5 -4
  6. package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +9 -0
  7. package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.js +288 -0
  8. package/dist/cjs/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +11 -0
  9. package/dist/cjs/anyspend/react/components/AnySpendStakeUpsideExactIn.js +33 -0
  10. package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +4 -4
  11. package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +4 -6
  12. package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +9 -17
  13. package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.d.ts +6 -1
  14. package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +11 -1
  15. package/dist/cjs/anyspend/react/components/common/OrderDetails.js +66 -147
  16. package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +2 -3
  17. package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.d.ts +2 -1
  18. package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.js +39 -15
  19. package/dist/cjs/anyspend/react/components/common/PaySection.js +1 -1
  20. package/dist/cjs/anyspend/react/components/common/TokenBalance.js +1 -1
  21. package/dist/cjs/anyspend/react/components/index.d.ts +5 -1
  22. package/dist/cjs/anyspend/react/components/index.js +11 -3
  23. package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +25 -3
  24. package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +42 -19
  25. package/dist/cjs/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +116 -0
  26. package/dist/cjs/anyspend/react/hooks/useAnyspendQuote.js +1 -1
  27. package/dist/cjs/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.d.ts +26 -0
  28. package/dist/cjs/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.js +56 -0
  29. package/dist/cjs/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +10 -0
  30. package/dist/cjs/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.js +73 -0
  31. package/dist/cjs/anyspend/react/hooks/useConnectedWalletDisplay.d.ts +14 -0
  32. package/dist/cjs/anyspend/react/hooks/useConnectedWalletDisplay.js +57 -0
  33. package/dist/cjs/anyspend/react/hooks/usePhantomTransfer.d.ts +36 -0
  34. package/dist/cjs/anyspend/react/hooks/usePhantomTransfer.js +211 -0
  35. package/dist/cjs/anyspend/types/api.d.ts +665 -3
  36. package/dist/cjs/anyspend/utils/orderPayload.js +4 -0
  37. package/dist/cjs/global-account/react/components/B3DynamicModal.js +10 -1
  38. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +3 -1
  39. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +2 -2
  40. package/dist/cjs/global-account/react/hooks/index.d.ts +2 -1
  41. package/dist/cjs/global-account/react/hooks/index.js +5 -3
  42. package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +2 -2
  43. package/dist/cjs/global-account/react/hooks/useAuthentication.js +7 -2
  44. package/dist/cjs/global-account/react/hooks/useSimBalance.d.ts +1 -1
  45. package/dist/cjs/global-account/react/hooks/useSimBalance.js +6 -5
  46. package/dist/cjs/global-account/react/hooks/useTokenBalanceDirect.d.ts +12 -0
  47. package/dist/cjs/global-account/react/hooks/useTokenBalanceDirect.js +62 -0
  48. package/dist/cjs/global-account/react/hooks/useTokenFromUrl.js +4 -3
  49. package/dist/cjs/global-account/react/stores/useModalStore.d.ts +31 -1
  50. package/dist/esm/anyspend/react/components/AnySpend.js +62 -24
  51. package/dist/esm/anyspend/react/components/AnySpendCustom.js +3 -0
  52. package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.d.ts +34 -0
  53. package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +269 -0
  54. package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +7 -6
  55. package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +9 -0
  56. package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.js +285 -0
  57. package/dist/esm/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +11 -0
  58. package/dist/esm/anyspend/react/components/AnySpendStakeUpsideExactIn.js +30 -0
  59. package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +4 -4
  60. package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +5 -7
  61. package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +9 -17
  62. package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.d.ts +6 -1
  63. package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +11 -1
  64. package/dist/esm/anyspend/react/components/common/OrderDetails.js +67 -148
  65. package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +2 -3
  66. package/dist/esm/anyspend/react/components/common/OrderTokenAmount.d.ts +2 -1
  67. package/dist/esm/anyspend/react/components/common/OrderTokenAmount.js +40 -16
  68. package/dist/esm/anyspend/react/components/common/PaySection.js +1 -1
  69. package/dist/esm/anyspend/react/components/common/TokenBalance.js +2 -2
  70. package/dist/esm/anyspend/react/components/index.d.ts +5 -1
  71. package/dist/esm/anyspend/react/components/index.js +5 -1
  72. package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +25 -3
  73. package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +42 -19
  74. package/dist/esm/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +116 -0
  75. package/dist/esm/anyspend/react/hooks/useAnyspendQuote.js +1 -1
  76. package/dist/esm/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.d.ts +26 -0
  77. package/dist/esm/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.js +53 -0
  78. package/dist/esm/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +10 -0
  79. package/dist/esm/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.js +70 -0
  80. package/dist/esm/anyspend/react/hooks/useConnectedWalletDisplay.d.ts +14 -0
  81. package/dist/esm/anyspend/react/hooks/useConnectedWalletDisplay.js +54 -0
  82. package/dist/esm/anyspend/react/hooks/usePhantomTransfer.d.ts +36 -0
  83. package/dist/esm/anyspend/react/hooks/usePhantomTransfer.js +208 -0
  84. package/dist/esm/anyspend/types/api.d.ts +665 -3
  85. package/dist/esm/anyspend/utils/orderPayload.js +4 -0
  86. package/dist/esm/global-account/react/components/B3DynamicModal.js +11 -2
  87. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +3 -1
  88. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +2 -2
  89. package/dist/esm/global-account/react/hooks/index.d.ts +2 -1
  90. package/dist/esm/global-account/react/hooks/index.js +2 -1
  91. package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +2 -2
  92. package/dist/esm/global-account/react/hooks/useAuthentication.js +7 -2
  93. package/dist/esm/global-account/react/hooks/useSimBalance.d.ts +1 -1
  94. package/dist/esm/global-account/react/hooks/useSimBalance.js +6 -5
  95. package/dist/esm/global-account/react/hooks/useTokenBalanceDirect.d.ts +12 -0
  96. package/dist/esm/global-account/react/hooks/useTokenBalanceDirect.js +59 -0
  97. package/dist/esm/global-account/react/hooks/useTokenFromUrl.js +4 -3
  98. package/dist/esm/global-account/react/stores/useModalStore.d.ts +31 -1
  99. package/dist/types/anyspend/react/components/AnySpendCustomExactIn.d.ts +34 -0
  100. package/dist/types/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +9 -0
  101. package/dist/types/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +11 -0
  102. package/dist/types/anyspend/react/components/common/CryptoReceiveSection.d.ts +6 -1
  103. package/dist/types/anyspend/react/components/common/OrderTokenAmount.d.ts +2 -1
  104. package/dist/types/anyspend/react/components/index.d.ts +5 -1
  105. package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +25 -3
  106. package/dist/types/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +116 -0
  107. package/dist/types/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.d.ts +26 -0
  108. package/dist/types/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +10 -0
  109. package/dist/types/anyspend/react/hooks/useConnectedWalletDisplay.d.ts +14 -0
  110. package/dist/types/anyspend/react/hooks/usePhantomTransfer.d.ts +36 -0
  111. package/dist/types/anyspend/types/api.d.ts +665 -3
  112. package/dist/types/global-account/react/hooks/index.d.ts +2 -1
  113. package/dist/types/global-account/react/hooks/useAuthentication.d.ts +2 -2
  114. package/dist/types/global-account/react/hooks/useSimBalance.d.ts +1 -1
  115. package/dist/types/global-account/react/hooks/useTokenBalanceDirect.d.ts +12 -0
  116. package/dist/types/global-account/react/stores/useModalStore.d.ts +31 -1
  117. package/package.json +3 -2
  118. package/src/anyspend/react/components/AnySpend.tsx +73 -22
  119. package/src/anyspend/react/components/AnySpendCustom.tsx +4 -0
  120. package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +595 -0
  121. package/src/anyspend/react/components/AnySpendStakeB3.tsx +8 -11
  122. package/src/anyspend/react/components/AnySpendStakeB3ExactIn.tsx +522 -0
  123. package/src/anyspend/react/components/AnySpendStakeUpsideExactIn.tsx +73 -0
  124. package/src/anyspend/react/components/AnyspendDepositHype.tsx +7 -3
  125. package/src/anyspend/react/components/common/CryptoPaySection.tsx +5 -7
  126. package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +9 -18
  127. package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +22 -0
  128. package/src/anyspend/react/components/common/OrderDetails.tsx +76 -190
  129. package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +2 -3
  130. package/src/anyspend/react/components/common/OrderTokenAmount.tsx +48 -17
  131. package/src/anyspend/react/components/common/PaySection.tsx +1 -0
  132. package/src/anyspend/react/components/common/TokenBalance.tsx +2 -2
  133. package/src/anyspend/react/components/index.ts +5 -1
  134. package/src/anyspend/react/hooks/useAnyspendFlow.ts +51 -18
  135. package/src/anyspend/react/hooks/useAnyspendQuote.ts +1 -1
  136. package/src/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.ts +72 -0
  137. package/src/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.ts +80 -0
  138. package/src/anyspend/react/hooks/useConnectedWalletDisplay.ts +69 -0
  139. package/src/anyspend/react/hooks/usePhantomTransfer.ts +301 -0
  140. package/src/anyspend/types/api.ts +669 -1
  141. package/src/anyspend/utils/orderPayload.ts +5 -1
  142. package/src/global-account/react/components/B3DynamicModal.tsx +11 -1
  143. package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +3 -1
  144. package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +2 -2
  145. package/src/global-account/react/hooks/index.ts +2 -1
  146. package/src/global-account/react/hooks/useAuthentication.ts +10 -2
  147. package/src/global-account/react/hooks/useSimBalance.ts +6 -5
  148. package/src/global-account/react/hooks/useTokenBalanceDirect.tsx +84 -0
  149. package/src/global-account/react/hooks/useTokenFromUrl.tsx +6 -5
  150. package/src/global-account/react/stores/useModalStore.ts +34 -0
@@ -32,11 +32,12 @@ export { useSearchParamsSSR } from "./useSearchParamsSSR";
32
32
  export { useSimBalance } from "./useSimBalance";
33
33
  export { useSiwe } from "./useSiwe";
34
34
  export { useTokenBalance } from "./useTokenBalance";
35
+ export { useTokenBalanceDirect } from "./useTokenBalanceDirect";
35
36
  export { useTokenBalancesByChain } from "./useTokenBalancesByChain";
36
37
  export { useTokenData } from "./useTokenData";
37
38
  export { useTokenFromUrl } from "./useTokenFromUrl";
38
39
  export { useTokenPrice } from "./useTokenPrice";
39
40
  export { useTokenPriceWithFallback } from "./useTokenPriceWithFallback";
40
41
  export { useTokensFromAddress } from "./useTokensFromAddress";
41
- export { useUnifiedChainSwitchAndExecute } from "./useUnifiedChainSwitchAndExecute";
42
42
  export { useURLParams } from "./useURLParams";
43
+ export { useUnifiedChainSwitchAndExecute } from "./useUnifiedChainSwitchAndExecute";
@@ -8,9 +8,9 @@ export declare function useAuthentication(partnerId: string): {
8
8
  isConnected: boolean;
9
9
  wallet: import("thirdweb/dist/types/wallets/in-app/core/wallet/types").EcosystemWallet;
10
10
  preAuthenticate: typeof preAuthenticate;
11
- connect: (wallet: Wallet) => Promise<void>;
11
+ connect: (_walleAutoConnectedWith: Wallet, allConnectedWallets: Wallet[]) => Promise<void>;
12
12
  isAuthenticating: boolean;
13
- onConnect: (wallet: Wallet) => Promise<void>;
13
+ onConnect: (_walleAutoConnectedWith: Wallet, allConnectedWallets: Wallet[]) => Promise<void>;
14
14
  user: {
15
15
  email?: string | undefined;
16
16
  username?: string | undefined;
@@ -21,4 +21,4 @@ export interface SimBalanceResponse {
21
21
  wallet_address: string;
22
22
  balances: SimBalanceItem[];
23
23
  }
24
- export declare function useSimBalance(address?: string): import("@tanstack/react-query").UseQueryResult<SimBalanceResponse, Error>;
24
+ export declare function useSimBalance(address?: string, chainIdsParam?: number[]): import("@tanstack/react-query").UseQueryResult<SimBalanceResponse, Error>;
@@ -0,0 +1,12 @@
1
+ import { components } from "@b3dotfun/sdk/anyspend/types/api";
2
+ interface UseTokenBalanceProps {
3
+ token: components["schemas"]["Token"];
4
+ address?: string;
5
+ }
6
+ export interface TokenBalanceResult {
7
+ rawBalance: bigint | null;
8
+ formattedBalance: string;
9
+ isLoading: boolean;
10
+ }
11
+ export declare function useTokenBalanceDirect({ token, address }: UseTokenBalanceProps): TokenBalanceResult;
12
+ export {};
@@ -210,6 +210,20 @@ export interface AnySpendStakeB3Props extends BaseModalProps {
210
210
  /** Callback function called when the stake is successful */
211
211
  onSuccess?: () => void;
212
212
  }
213
+ /**
214
+ * Props for the AnySpend Stake B3 (Custom Exact In) modal
215
+ * Handles B3 token staking operations using the custom exact in flow
216
+ */
217
+ export interface AnySpendStakeB3ExactInProps extends BaseModalProps {
218
+ /** Modal type identifier */
219
+ type: "anySpendStakeB3ExactIn";
220
+ /** Recipient address to stake B3 for */
221
+ recipientAddress: string;
222
+ /** Stake amount */
223
+ stakeAmount?: string;
224
+ /** Callback function called when the stake is successful */
225
+ onSuccess?: () => void;
226
+ }
213
227
  /**
214
228
  * Props for the AnySpend Stake Contract modal
215
229
  * Handles token staking operations to a given contract
@@ -230,6 +244,22 @@ export interface AnySpendStakeUpsideProps extends BaseModalProps {
230
244
  /** Callback function called when the stake is successful */
231
245
  onSuccess?: () => void;
232
246
  }
247
+ /**
248
+ * Props for the AnySpend Stake Upside (Exact In) modal
249
+ * Handles token staking operations using the custom exact in flow
250
+ */
251
+ export interface AnySpendStakeUpsideExactInProps extends BaseModalProps {
252
+ /** Modal type identifier */
253
+ type: "anySpendStakeUpsideExactIn";
254
+ /** Recipient address to stake tokens for */
255
+ recipientAddress: string;
256
+ /** Staking contract address */
257
+ stakingContractAddress: string;
258
+ /** Token to stake */
259
+ token: components["schemas"]["Token"];
260
+ /** Callback function called when the stake is successful */
261
+ onSuccess?: () => void;
262
+ }
233
263
  /**
234
264
  * Props for the AnySpend Buy Spin modal
235
265
  * Handles spin wheel entry purchases
@@ -324,7 +354,7 @@ export interface AvatarEditorModalProps extends BaseModalProps {
324
354
  /**
325
355
  * Union type of all possible modal content types
326
356
  */
327
- export type ModalContentType = SignInWithB3ModalProps | RequestPermissionsModalProps | ManageAccountModalProps | AnySpendModalProps | AnyspendOrderDetailsProps | AnySpendNftProps | AnySpendJoinTournamentProps | AnySpendFundTournamentProps | AnySpendOrderHistoryProps | AnySpendStakeB3Props | AnySpendStakeUpsideProps | AnySpendBuySpinProps | AnySpendSignatureMintProps | AnySpendBondKitProps | LinkAccountModalProps | AnySpendDepositHypeProps | AvatarEditorModalProps;
357
+ export type ModalContentType = SignInWithB3ModalProps | RequestPermissionsModalProps | ManageAccountModalProps | AnySpendModalProps | AnyspendOrderDetailsProps | AnySpendNftProps | AnySpendJoinTournamentProps | AnySpendFundTournamentProps | AnySpendOrderHistoryProps | AnySpendStakeB3Props | AnySpendStakeB3ExactInProps | AnySpendStakeUpsideProps | AnySpendStakeUpsideExactInProps | AnySpendBuySpinProps | AnySpendSignatureMintProps | AnySpendBondKitProps | LinkAccountModalProps | AnySpendDepositHypeProps | AvatarEditorModalProps;
328
358
  /**
329
359
  * State interface for the modal store
330
360
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b3dotfun/sdk",
3
- "version": "0.0.62",
3
+ "version": "0.0.63-test.0-alpha.0",
4
4
  "source": "src/index.ts",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "react-native": "./dist/cjs/index.native.js",
@@ -358,6 +358,7 @@
358
358
  "postcss-prefix-selector": "^2.1.1",
359
359
  "tailwindcss": "3.4.1",
360
360
  "tailwindcss-animate": "^1.0.7",
361
+ "thirdweb": "5.112.0",
361
362
  "tsc-alias": "^1.8.16",
362
363
  "tsc-watch": "^7.1.1",
363
364
  "vitest": "^3.2.4"
@@ -380,7 +381,7 @@
380
381
  "react": "^18.0.0 || ^19.0.0",
381
382
  "react-dom": "^18.0.0 || ^19.0.0",
382
383
  "react-native-mmkv": "^3.2.0",
383
- "thirdweb": "5.108.14",
384
+ "thirdweb": "5.112.0",
384
385
  "three": "^0.175.0",
385
386
  "viem": "2.37.9",
386
387
  "wagmi": "2.16.9"
@@ -17,6 +17,7 @@ import {
17
17
  useProfile,
18
18
  useRouter,
19
19
  useSearchParamsSSR,
20
+ useTokenBalanceDirect,
20
21
  useTokenData,
21
22
  useTokenFromUrl,
22
23
  } from "@b3dotfun/sdk/global-account/react";
@@ -30,17 +31,19 @@ import { toast } from "sonner";
30
31
  import { parseUnits } from "viem";
31
32
  import { base, mainnet } from "viem/chains";
32
33
  import { components } from "../../types/api";
34
+ import { useAutoSelectCryptoPaymentMethod } from "../hooks/useAutoSelectCryptoPaymentMethod";
35
+ import { useAutoSetActiveWalletFromWagmi } from "../hooks/useAutoSetActiveWalletFromWagmi";
33
36
  import { AnySpendFingerprintWrapper, getFingerprintConfig } from "./AnySpendFingerprintWrapper";
34
37
  import { CryptoPaymentMethod, CryptoPaymentMethodType } from "./common/CryptoPaymentMethod";
35
38
  import { CryptoPaySection } from "./common/CryptoPaySection";
36
39
  import { CryptoReceiveSection } from "./common/CryptoReceiveSection";
40
+ import { FeeDetailPanel } from "./common/FeeDetailPanel";
37
41
  import { FiatPaymentMethod, FiatPaymentMethodComponent } from "./common/FiatPaymentMethod";
38
42
  import { OrderDetails, OrderDetailsLoadingView } from "./common/OrderDetails";
39
43
  import { OrderHistory } from "./common/OrderHistory";
40
44
  import { PanelOnramp } from "./common/PanelOnramp";
41
45
  import { PanelOnrampPayment } from "./common/PanelOnrampPayment";
42
46
  import { PointsDetailPanel } from "./common/PointsDetailPanel";
43
- import { FeeDetailPanel } from "./common/FeeDetailPanel";
44
47
  import { RecipientSelection } from "./common/RecipientSelection";
45
48
  import { TabSection } from "./common/TabSection";
46
49
 
@@ -437,14 +440,38 @@ function AnySpendInner({
437
440
  // State for recipient selection
438
441
  const [recipientAddress, setRecipientAddress] = useState<string | undefined>();
439
442
 
440
- const { address: globalAddress, wallet: globalWallet } = useAccountWallet();
443
+ const { address: globalAddress, wallet: globalWallet, connectedEOAWallet } = useAccountWallet();
441
444
  const recipientProfile = useProfile({ address: recipientAddress, fresh: true });
442
445
  const recipientName = recipientProfile.data?.name;
443
446
 
444
- // Set default recipient address when wallet changes
445
- useEffect(() => {
446
- setRecipientAddress(recipientAddressFromProps || globalAddress);
447
- }, [recipientAddressFromProps, globalAddress]);
447
+ // Auto-set active wallet from wagmi
448
+ useAutoSetActiveWalletFromWagmi();
449
+
450
+ // Check token balance for crypto payments
451
+ const { rawBalance, isLoading: isBalanceLoading } = useTokenBalanceDirect({
452
+ token: selectedSrcToken,
453
+ address: connectedEOAWallet?.getAccount()?.address,
454
+ });
455
+
456
+ // Check if user has enough balanceuseAutoSetActiveWalletFromWagmi
457
+ const hasEnoughBalance = useMemo(() => {
458
+ if (!rawBalance || isBalanceLoading || activeTab !== "crypto") return false;
459
+ try {
460
+ const requiredAmount = parseUnits(srcAmount.replace(/,/g, ""), selectedSrcToken.decimals);
461
+ return rawBalance >= requiredAmount;
462
+ } catch {
463
+ return false;
464
+ }
465
+ }, [rawBalance, srcAmount, selectedSrcToken.decimals, isBalanceLoading, activeTab]);
466
+
467
+ // Auto-select crypto payment method based on available wallets and balance
468
+ useAutoSelectCryptoPaymentMethod({
469
+ paymentType: activeTab,
470
+ selectedCryptoPaymentMethod,
471
+ setSelectedCryptoPaymentMethod,
472
+ hasEnoughBalance,
473
+ isBalanceLoading,
474
+ });
448
475
 
449
476
  // Get geo-based onramp options for fiat payments
450
477
  const { geoData, coinbaseAvailablePaymentMethods, stripeWeb2Support } = useGeoOnrampOptions(srcAmountOnRamp);
@@ -624,17 +651,34 @@ function AnySpendInner({
624
651
  if (isSameChainSameToken)
625
652
  return { text: "Select a different token or chain", disable: true, error: false, loading: false };
626
653
  if (isLoadingAnyspendQuote) return { text: "Loading quote...", disable: true, error: false, loading: true };
627
- if (!recipientAddress) return { text: "Select recipient", disable: false, error: false, loading: false };
628
654
  if (isCreatingOrder || isCreatingOnrampOrder)
629
655
  return { text: "Creating order...", disable: true, error: false, loading: true };
630
656
  if (!anyspendQuote || !anyspendQuote.success)
631
657
  return { text: "No quote found", disable: true, error: false, loading: false };
632
658
 
659
+ if (activeTab === "fiat") {
660
+ // For fiat: check recipient first, then payment method
661
+ if (!recipientAddress) return { text: "Select recipient", disable: false, error: false, loading: false };
662
+
663
+ // If no fiat payment method selected, show "Select payment method"
664
+ if (selectedFiatPaymentMethod === FiatPaymentMethod.NONE) {
665
+ return { text: "Select payment method", disable: false, error: false, loading: false };
666
+ }
667
+ // If payment method is selected, show "Buy"
668
+ return { text: "Buy", disable: false, error: false, loading: false };
669
+ }
670
+
633
671
  if (activeTab === "crypto") {
672
+ // For crypto: check payment method first, then recipient
673
+
634
674
  // If no payment method selected, show "Choose payment method"
635
675
  if (selectedCryptoPaymentMethod === CryptoPaymentMethodType.NONE) {
636
676
  return { text: "Choose payment method", disable: false, error: false, loading: false };
637
677
  }
678
+
679
+ // Check recipient after payment method
680
+ if (!recipientAddress) return { text: "Select recipient", disable: false, error: false, loading: false };
681
+
638
682
  // If payment method selected, show appropriate action
639
683
  if (
640
684
  selectedCryptoPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET ||
@@ -647,15 +691,6 @@ function AnySpendInner({
647
691
  }
648
692
  }
649
693
 
650
- if (activeTab === "fiat") {
651
- // If no fiat payment method selected, show "Select payment method"
652
- if (selectedFiatPaymentMethod === FiatPaymentMethod.NONE) {
653
- return { text: "Select payment method", disable: false, error: false, loading: false };
654
- }
655
- // If payment method is selected, show "Buy"
656
- return { text: "Buy", disable: false, error: false, loading: false };
657
- }
658
-
659
694
  return { text: "Buy", disable: false, error: false, loading: false };
660
695
  }, [
661
696
  activeInputAmountInWei,
@@ -674,16 +709,18 @@ function AnySpendInner({
674
709
  const onMainButtonClick = async () => {
675
710
  if (btnInfo.disable) return;
676
711
 
677
- if (!recipientAddress) {
678
- navigateToPanel(PanelView.RECIPIENT_SELECTION, "forward");
679
- return;
680
- }
681
-
682
712
  try {
683
713
  invariant(anyspendQuote, "Relay price is not found");
684
- invariant(recipientAddress, "Recipient address is not found");
685
714
 
686
715
  if (activeTab === "fiat") {
716
+ // For fiat: check recipient first
717
+ if (!recipientAddress) {
718
+ navigateToPanel(PanelView.RECIPIENT_SELECTION, "forward");
719
+ return;
720
+ }
721
+
722
+ invariant(recipientAddress, "Recipient address is not found");
723
+
687
724
  // If no fiat payment method selected, show payment method selection
688
725
  if (selectedFiatPaymentMethod === FiatPaymentMethod.NONE) {
689
726
  navigateToPanel(PanelView.FIAT_PAYMENT_METHOD, "forward");
@@ -695,6 +732,8 @@ function AnySpendInner({
695
732
  }
696
733
 
697
734
  if (activeTab === "crypto") {
735
+ // For crypto: check payment method first, then recipient
736
+
698
737
  // If no payment method selected, show payment method selection
699
738
  if (selectedCryptoPaymentMethod === CryptoPaymentMethodType.NONE) {
700
739
  console.log("No payment method selected, showing selection panel");
@@ -702,6 +741,14 @@ function AnySpendInner({
702
741
  return;
703
742
  }
704
743
 
744
+ // Check recipient after payment method
745
+ if (!recipientAddress) {
746
+ navigateToPanel(PanelView.RECIPIENT_SELECTION, "forward");
747
+ return;
748
+ }
749
+
750
+ invariant(recipientAddress, "Recipient address is not found");
751
+
705
752
  // If payment method is selected, create order with payment method info
706
753
  if (
707
754
  selectedCryptoPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET ||
@@ -1057,6 +1104,9 @@ function AnySpendInner({
1057
1104
  selectedRecipientAddress={recipientAddress}
1058
1105
  recipientName={recipientName || undefined}
1059
1106
  onSelectRecipient={() => navigateToPanel(PanelView.RECIPIENT_SELECTION, "forward")}
1107
+ setRecipientAddress={setRecipientAddress}
1108
+ recipientAddressFromProps={recipientAddressFromProps}
1109
+ globalAddress={globalAddress}
1060
1110
  dstAmount={dstAmount}
1061
1111
  dstToken={selectedDstToken}
1062
1112
  selectedDstChainId={selectedDstChainId}
@@ -1070,6 +1120,7 @@ function AnySpendInner({
1070
1120
  anyspendQuote={anyspendQuote}
1071
1121
  onShowPointsDetail={() => navigateToPanel(PanelView.POINTS_DETAIL, "forward")}
1072
1122
  onShowFeeDetail={() => navigateToPanel(PanelView.FEE_DETAIL, "forward")}
1123
+ selectedCryptoPaymentMethod={selectedCryptoPaymentMethod}
1073
1124
  />
1074
1125
  )}
1075
1126
  </div>
@@ -44,6 +44,7 @@ import React, { useCallback, useEffect, useMemo, useState } from "react";
44
44
  import { toast } from "sonner";
45
45
  import { base } from "viem/chains";
46
46
  import { useFeatureFlags } from "../contexts/FeatureFlagsContext";
47
+ import { useAutoSetActiveWalletFromWagmi } from "../hooks/useAutoSetActiveWalletFromWagmi";
47
48
  import { AnySpendFingerprintWrapper, getFingerprintConfig } from "./AnySpendFingerprintWrapper";
48
49
  import { CryptoPaymentMethod, CryptoPaymentMethodType } from "./common/CryptoPaymentMethod";
49
50
  import { FeeBreakDown } from "./common/FeeBreakDown";
@@ -241,6 +242,9 @@ function AnySpendCustomInner({
241
242
  const searchParams = useSearchParamsSSR();
242
243
  const router = useRouter();
243
244
 
245
+ // Auto-set active wallet from wagmi
246
+ useAutoSetActiveWalletFromWagmi();
247
+
244
248
  const [activePanel, setActivePanel] = useState<PanelView>(
245
249
  loadOrder ? PanelView.ORDER_DETAILS : PanelView.CONFIRM_ORDER,
246
250
  );