@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.
- package/dist/cjs/anyspend/react/components/AnySpend.js +61 -23
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +3 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.d.ts +34 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +275 -0
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +5 -4
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +9 -0
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.js +288 -0
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +11 -0
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpsideExactIn.js +33 -0
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +4 -4
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +4 -6
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +9 -17
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.d.ts +6 -1
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +11 -1
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +66 -147
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +2 -3
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.js +39 -15
- package/dist/cjs/anyspend/react/components/common/PaySection.js +1 -1
- package/dist/cjs/anyspend/react/components/common/TokenBalance.js +1 -1
- package/dist/cjs/anyspend/react/components/index.d.ts +5 -1
- package/dist/cjs/anyspend/react/components/index.js +11 -3
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +25 -3
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +42 -19
- package/dist/cjs/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +116 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendQuote.js +1 -1
- package/dist/cjs/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.d.ts +26 -0
- package/dist/cjs/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.js +56 -0
- package/dist/cjs/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +10 -0
- package/dist/cjs/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.js +73 -0
- package/dist/cjs/anyspend/react/hooks/useConnectedWalletDisplay.d.ts +14 -0
- package/dist/cjs/anyspend/react/hooks/useConnectedWalletDisplay.js +57 -0
- package/dist/cjs/anyspend/react/hooks/usePhantomTransfer.d.ts +36 -0
- package/dist/cjs/anyspend/react/hooks/usePhantomTransfer.js +211 -0
- package/dist/cjs/anyspend/types/api.d.ts +665 -3
- package/dist/cjs/anyspend/utils/orderPayload.js +4 -0
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +10 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +3 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +2 -2
- package/dist/cjs/global-account/react/hooks/index.d.ts +2 -1
- package/dist/cjs/global-account/react/hooks/index.js +5 -3
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +2 -2
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +7 -2
- package/dist/cjs/global-account/react/hooks/useSimBalance.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useSimBalance.js +6 -5
- package/dist/cjs/global-account/react/hooks/useTokenBalanceDirect.d.ts +12 -0
- package/dist/cjs/global-account/react/hooks/useTokenBalanceDirect.js +62 -0
- package/dist/cjs/global-account/react/hooks/useTokenFromUrl.js +4 -3
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +31 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +62 -24
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +3 -0
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.d.ts +34 -0
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +269 -0
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +7 -6
- package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +9 -0
- package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.js +285 -0
- package/dist/esm/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +11 -0
- package/dist/esm/anyspend/react/components/AnySpendStakeUpsideExactIn.js +30 -0
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +4 -4
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +5 -7
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +9 -17
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.d.ts +6 -1
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +11 -1
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +67 -148
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +2 -3
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.d.ts +2 -1
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.js +40 -16
- package/dist/esm/anyspend/react/components/common/PaySection.js +1 -1
- package/dist/esm/anyspend/react/components/common/TokenBalance.js +2 -2
- package/dist/esm/anyspend/react/components/index.d.ts +5 -1
- package/dist/esm/anyspend/react/components/index.js +5 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +25 -3
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +42 -19
- package/dist/esm/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +116 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendQuote.js +1 -1
- package/dist/esm/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.d.ts +26 -0
- package/dist/esm/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.js +53 -0
- package/dist/esm/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +10 -0
- package/dist/esm/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.js +70 -0
- package/dist/esm/anyspend/react/hooks/useConnectedWalletDisplay.d.ts +14 -0
- package/dist/esm/anyspend/react/hooks/useConnectedWalletDisplay.js +54 -0
- package/dist/esm/anyspend/react/hooks/usePhantomTransfer.d.ts +36 -0
- package/dist/esm/anyspend/react/hooks/usePhantomTransfer.js +208 -0
- package/dist/esm/anyspend/types/api.d.ts +665 -3
- package/dist/esm/anyspend/utils/orderPayload.js +4 -0
- package/dist/esm/global-account/react/components/B3DynamicModal.js +11 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +3 -1
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +2 -2
- package/dist/esm/global-account/react/hooks/index.d.ts +2 -1
- package/dist/esm/global-account/react/hooks/index.js +2 -1
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +2 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.js +7 -2
- package/dist/esm/global-account/react/hooks/useSimBalance.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useSimBalance.js +6 -5
- package/dist/esm/global-account/react/hooks/useTokenBalanceDirect.d.ts +12 -0
- package/dist/esm/global-account/react/hooks/useTokenBalanceDirect.js +59 -0
- package/dist/esm/global-account/react/hooks/useTokenFromUrl.js +4 -3
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +31 -1
- package/dist/types/anyspend/react/components/AnySpendCustomExactIn.d.ts +34 -0
- package/dist/types/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +9 -0
- package/dist/types/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +11 -0
- package/dist/types/anyspend/react/components/common/CryptoReceiveSection.d.ts +6 -1
- package/dist/types/anyspend/react/components/common/OrderTokenAmount.d.ts +2 -1
- package/dist/types/anyspend/react/components/index.d.ts +5 -1
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +25 -3
- package/dist/types/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +116 -0
- package/dist/types/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.d.ts +26 -0
- package/dist/types/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +10 -0
- package/dist/types/anyspend/react/hooks/useConnectedWalletDisplay.d.ts +14 -0
- package/dist/types/anyspend/react/hooks/usePhantomTransfer.d.ts +36 -0
- package/dist/types/anyspend/types/api.d.ts +665 -3
- package/dist/types/global-account/react/hooks/index.d.ts +2 -1
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +2 -2
- package/dist/types/global-account/react/hooks/useSimBalance.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useTokenBalanceDirect.d.ts +12 -0
- package/dist/types/global-account/react/stores/useModalStore.d.ts +31 -1
- package/package.json +3 -2
- package/src/anyspend/react/components/AnySpend.tsx +73 -22
- package/src/anyspend/react/components/AnySpendCustom.tsx +4 -0
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +595 -0
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +8 -11
- package/src/anyspend/react/components/AnySpendStakeB3ExactIn.tsx +522 -0
- package/src/anyspend/react/components/AnySpendStakeUpsideExactIn.tsx +73 -0
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +7 -3
- package/src/anyspend/react/components/common/CryptoPaySection.tsx +5 -7
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +9 -18
- package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +22 -0
- package/src/anyspend/react/components/common/OrderDetails.tsx +76 -190
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +2 -3
- package/src/anyspend/react/components/common/OrderTokenAmount.tsx +48 -17
- package/src/anyspend/react/components/common/PaySection.tsx +1 -0
- package/src/anyspend/react/components/common/TokenBalance.tsx +2 -2
- package/src/anyspend/react/components/index.ts +5 -1
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +51 -18
- package/src/anyspend/react/hooks/useAnyspendQuote.ts +1 -1
- package/src/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.ts +72 -0
- package/src/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.ts +80 -0
- package/src/anyspend/react/hooks/useConnectedWalletDisplay.ts +69 -0
- package/src/anyspend/react/hooks/usePhantomTransfer.ts +301 -0
- package/src/anyspend/types/api.ts +669 -1
- package/src/anyspend/utils/orderPayload.ts +5 -1
- package/src/global-account/react/components/B3DynamicModal.tsx +11 -1
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +3 -1
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +2 -2
- package/src/global-account/react/hooks/index.ts +2 -1
- package/src/global-account/react/hooks/useAuthentication.ts +10 -2
- package/src/global-account/react/hooks/useSimBalance.ts +6 -5
- package/src/global-account/react/hooks/useTokenBalanceDirect.tsx +84 -0
- package/src/global-account/react/hooks/useTokenFromUrl.tsx +6 -5
- 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: (
|
|
11
|
+
connect: (_walleAutoConnectedWith: Wallet, allConnectedWallets: Wallet[]) => Promise<void>;
|
|
12
12
|
isAuthenticating: boolean;
|
|
13
|
-
onConnect: (
|
|
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.
|
|
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.
|
|
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
|
-
//
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
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
|
);
|