@b3dotfun/sdk 0.0.62-alpha.3 → 0.0.62-alpha.4

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 (57) hide show
  1. package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.d.ts +34 -0
  2. package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +276 -0
  3. package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +7 -0
  4. package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.js +288 -0
  5. package/dist/cjs/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +9 -0
  6. package/dist/cjs/anyspend/react/components/AnySpendStakeUpsideExactIn.js +33 -0
  7. package/dist/cjs/anyspend/react/components/common/OrderDetails.js +10 -2
  8. package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +2 -3
  9. package/dist/cjs/anyspend/react/components/index.d.ts +5 -1
  10. package/dist/cjs/anyspend/react/components/index.js +11 -3
  11. package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +24 -2
  12. package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +29 -7
  13. package/dist/cjs/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +116 -0
  14. package/dist/cjs/anyspend/react/hooks/useAnyspendQuote.js +1 -1
  15. package/dist/cjs/anyspend/types/api.d.ts +665 -3
  16. package/dist/cjs/anyspend/utils/orderPayload.js +4 -0
  17. package/dist/cjs/global-account/react/components/B3DynamicModal.js +10 -1
  18. package/dist/cjs/global-account/react/stores/useModalStore.d.ts +31 -1
  19. package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.d.ts +34 -0
  20. package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +270 -0
  21. package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +7 -0
  22. package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.js +285 -0
  23. package/dist/esm/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +9 -0
  24. package/dist/esm/anyspend/react/components/AnySpendStakeUpsideExactIn.js +30 -0
  25. package/dist/esm/anyspend/react/components/common/OrderDetails.js +10 -2
  26. package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +2 -3
  27. package/dist/esm/anyspend/react/components/index.d.ts +5 -1
  28. package/dist/esm/anyspend/react/components/index.js +5 -1
  29. package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +24 -2
  30. package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +29 -7
  31. package/dist/esm/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +116 -0
  32. package/dist/esm/anyspend/react/hooks/useAnyspendQuote.js +1 -1
  33. package/dist/esm/anyspend/types/api.d.ts +665 -3
  34. package/dist/esm/anyspend/utils/orderPayload.js +4 -0
  35. package/dist/esm/global-account/react/components/B3DynamicModal.js +11 -2
  36. package/dist/esm/global-account/react/stores/useModalStore.d.ts +31 -1
  37. package/dist/types/anyspend/react/components/AnySpendCustomExactIn.d.ts +34 -0
  38. package/dist/types/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +7 -0
  39. package/dist/types/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +9 -0
  40. package/dist/types/anyspend/react/components/index.d.ts +5 -1
  41. package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +24 -2
  42. package/dist/types/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +116 -0
  43. package/dist/types/anyspend/types/api.d.ts +665 -3
  44. package/dist/types/global-account/react/stores/useModalStore.d.ts +31 -1
  45. package/package.json +1 -1
  46. package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +596 -0
  47. package/src/anyspend/react/components/AnySpendStakeB3ExactIn.tsx +516 -0
  48. package/src/anyspend/react/components/AnySpendStakeUpsideExactIn.tsx +67 -0
  49. package/src/anyspend/react/components/common/OrderDetails.tsx +10 -2
  50. package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +2 -3
  51. package/src/anyspend/react/components/index.ts +5 -1
  52. package/src/anyspend/react/hooks/useAnyspendFlow.ts +36 -6
  53. package/src/anyspend/react/hooks/useAnyspendQuote.ts +1 -1
  54. package/src/anyspend/types/api.ts +669 -1
  55. package/src/anyspend/utils/orderPayload.ts +5 -1
  56. package/src/global-account/react/components/B3DynamicModal.tsx +11 -1
  57. package/src/global-account/react/stores/useModalStore.ts +34 -0
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AnySpendStakeUpsideExactIn = AnySpendStakeUpsideExactIn;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const utils_1 = require("../../../anyspend/utils");
6
+ const chains_1 = require("viem/chains");
7
+ const AnySpendCustomExactIn_1 = require("./AnySpendCustomExactIn");
8
+ const STAKE_FOR_FUNCTION_ABI = JSON.stringify([
9
+ {
10
+ name: "stakeFor",
11
+ type: "function",
12
+ stateMutability: "nonpayable",
13
+ inputs: [
14
+ { name: "user", type: "address" },
15
+ { name: "amount", type: "uint256" },
16
+ ],
17
+ outputs: [],
18
+ },
19
+ ]);
20
+ function AnySpendStakeUpsideExactIn({ loadOrder, mode = "modal", recipientAddress, stakingContractAddress, token, onSuccess, }) {
21
+ if (!recipientAddress)
22
+ return null;
23
+ const header = () => ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)("div", { className: "from-b3-react-background to-as-on-surface-1 w-full rounded-t-lg bg-gradient-to-t", children: (0, jsx_runtime_1.jsx)("div", { className: "mb-1 flex w-full flex-col items-center gap-2", children: (0, jsx_runtime_1.jsxs)("span", { className: "font-sf-rounded text-2xl font-semibold", children: ["Swap & Stake ", token.symbol, " (Exact In)"] }) }) }) }));
24
+ const customExactInConfig = {
25
+ functionAbi: STAKE_FOR_FUNCTION_ABI,
26
+ functionName: "stakeFor",
27
+ functionArgs: [(0, utils_1.normalizeAddress)(recipientAddress), "{{amount_out}}"],
28
+ to: stakingContractAddress,
29
+ spenderAddress: stakingContractAddress,
30
+ action: `stake ${token.symbol}`,
31
+ };
32
+ return ((0, jsx_runtime_1.jsx)(AnySpendCustomExactIn_1.AnySpendCustomExactIn, { loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, destinationToken: token, destinationChainId: chains_1.base.id, customExactInConfig: customExactInConfig, header: header, onSuccess: onSuccess }));
33
+ }
@@ -54,6 +54,12 @@ function getOrderSuccessText({ order, tournament, formattedActualDstAmount, form
54
54
  case "custom":
55
55
  actionText = order.metadata.action || `executed contract`;
56
56
  return `Successfully ${actionText}`;
57
+ case "x402_swap":
58
+ actionText = `sent ${formattedActualDstAmount || "--"} ${dstToken.symbol}`;
59
+ return `Successfully ${actionText} to ${recipient}`;
60
+ case "custom_exact_in":
61
+ actionText = `executed contract`;
62
+ return `Successfully ${actionText}`;
57
63
  default:
58
64
  throw new Error("Invalid order type");
59
65
  }
@@ -366,7 +372,7 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ mode = "modal",
366
372
  ? depositTxs.map(dTxs => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.onrampMetadata?.vendor === "stripe-web2"
367
373
  ? `Received payment`
368
374
  : `Received ${(0, number_1.formatTokenAmount)(BigInt(dTxs.amount), srcToken.decimals)} ${srcToken.symbol}`, chainId: order.srcChain, tx: dTxs, isProcessing: false }, dTxs.txHash)))
369
- : null, relayTxs.map(relayTx => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: "Processed Transaction", chainId: relayTx.chain, isProcessing: false, tx: relayTx, delay: 0.5 }))), order.status === "executing" && ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.type === "swap"
375
+ : null, relayTxs.map(relayTx => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: "Processed Transaction", chainId: relayTx.chain, isProcessing: false, tx: relayTx, delay: 0.5 }))), order.status === "executing" && ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.type === "swap" || order.type === "x402_swap"
370
376
  ? "Processing Swap"
371
377
  : order.type === "mint_nft"
372
378
  ? "Minting NFT"
@@ -376,7 +382,9 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ mode = "modal",
376
382
  ? "Funding Tournament"
377
383
  : order.type === "hype_duel"
378
384
  ? "Depositing Hype Duel"
379
- : "Processing Bridge", chainId: order.dstChain, isProcessing: true, tx: null, delay: 1 }))] }) })] }) }), order.type === "join_tournament" && order.status === "executed" && ((0, jsx_runtime_1.jsxs)(react_1.ShinyButton, { accentColor: "hsl(var(--as-brand))", textColor: "text-white", className: "flex w-full items-center gap-2", disabled: txLoading || isSwitchingOrExecuting, onClick: handleCloseModal, children: [(0, jsx_runtime_1.jsx)("span", { className: "pl-4", children: "Continue to Tournament" }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })), order.status === "executed" && ((0, jsx_runtime_1.jsx)("button", { className: "order-close-button order-details-close-btn bg-as-brand flex w-full items-center justify-center gap-2 rounded-lg p-2 font-semibold text-white", onClick: mode === "page" ? handleBack : handleCloseModal, children: mode === "page" ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Return to Home ", (0, jsx_runtime_1.jsx)(lucide_react_1.Home, { className: "ml-2 h-4 w-4" })] })) : ("Close") }))] }));
385
+ : order.type === "custom" || order.type === "custom_exact_in"
386
+ ? "Executing Contract"
387
+ : "Processing Bridge", chainId: order.dstChain, isProcessing: true, tx: null, delay: 1 }))] }) })] }) }), order.type === "join_tournament" && order.status === "executed" && ((0, jsx_runtime_1.jsxs)(react_1.ShinyButton, { accentColor: "hsl(var(--as-brand))", textColor: "text-white", className: "flex w-full items-center gap-2", disabled: txLoading || isSwitchingOrExecuting, onClick: handleCloseModal, children: [(0, jsx_runtime_1.jsx)("span", { className: "pl-4", children: "Continue to Tournament" }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })), order.status === "executed" && ((0, jsx_runtime_1.jsx)("button", { className: "order-close-button order-details-close-btn bg-as-brand flex w-full items-center justify-center gap-2 rounded-lg p-2 font-semibold text-white", onClick: mode === "page" ? handleBack : handleCloseModal, children: mode === "page" ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Return to Home ", (0, jsx_runtime_1.jsx)(lucide_react_1.Home, { className: "ml-2 h-4 w-4" })] })) : ("Close") }))] }));
380
388
  }
381
389
  // This boolean indicates that user finish payment, and waiting for the deposit to be confirmed. We get this from query params (waitingForDeposit=true)
382
390
  const waitingForDeposit = new URLSearchParams(window.location.search).get("waitingForDeposit") === "true";
@@ -23,8 +23,7 @@ exports.OrderDetailsCollapsible = (0, react_3.memo)(function OrderDetailsCollaps
23
23
  const expectedDstAmount = order.type === "mint_nft" ||
24
24
  order.type === "join_tournament" ||
25
25
  order.type === "fund_tournament" ||
26
- order.type === "custom" ||
27
- order.type === "hype_duel"
26
+ order.type === "custom"
28
27
  ? "0"
29
28
  : order.payload.expectedDstAmount.toString();
30
29
  const finalFormattedExpectedDstAmount = formattedExpectedDstAmount || (0, number_1.formatTokenAmount)(BigInt(expectedDstAmount), dstToken.decimals);
@@ -36,7 +35,7 @@ exports.OrderDetailsCollapsible = (0, react_3.memo)(function OrderDetailsCollaps
36
35
  ? "Join tournament"
37
36
  : order.type === "fund_tournament"
38
37
  ? "Fund tournament"
39
- : order.type === "custom"
38
+ : order.type === "custom" || order.type === "custom_exact_in"
40
39
  ? order.metadata.action
41
40
  ? (0, anyspend_1.capitalizeFirstLetter)(order.metadata.action)
42
41
  : "Contract execution"
@@ -2,11 +2,15 @@ export { AnySpend } from "./AnySpend";
2
2
  export { AnySpendBondKit } from "./AnySpendBondKit";
3
3
  export { AnySpendBuySpin } from "./AnySpendBuySpin";
4
4
  export { AnySpendCustom } from "./AnySpendCustom";
5
+ export { AnySpendCustomExactIn } from "./AnySpendCustomExactIn";
5
6
  export * from "./AnySpendFingerprintWrapper";
6
7
  export { AnySpendNFT } from "./AnySpendNFT";
8
+ export { AnyspendSignatureMint } from "./AnyspendSignatureMint";
7
9
  export { AnySpendStakeB3 } from "./AnySpendStakeB3";
10
+ export { AnySpendStakeB3ExactIn } from "./AnySpendStakeB3ExactIn";
11
+ export { AnySpendStakeUpside } from "./AnySpendStakeUpside";
12
+ export { AnySpendStakeUpsideExactIn } from "./AnySpendStakeUpsideExactIn";
8
13
  export { AnySpendTournament } from "./AnySpendTournament";
9
- export { AnyspendSignatureMint } from "./AnyspendSignatureMint";
10
14
  export { AnySpendNFTButton } from "./common/AnySpendNFTButton";
11
15
  export { ChainTokenIcon } from "./common/ChainTokenIcon";
12
16
  export { CryptoPaySection } from "./common/CryptoPaySection";
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.WebviewOnrampPayment = exports.WebviewOnrampOrderStatus = exports.TransferCryptoDetails = exports.TokenBalance = exports.StepProgress = exports.RecipientSelection = exports.OrderTokenAmount = exports.OrderToken = exports.OrderStatus = exports.OrderHistoryItem = exports.OrderHistory = exports.OrderDetailsCollapsible = exports.OrderDetails = exports.CryptoReceiveSection = exports.CryptoPaySection = exports.ChainTokenIcon = exports.AnySpendNFTButton = exports.AnyspendSignatureMint = exports.AnySpendTournament = exports.AnySpendStakeB3 = exports.AnySpendNFT = exports.AnySpendCustom = exports.AnySpendBuySpin = exports.AnySpendBondKit = exports.AnySpend = void 0;
17
+ exports.WebviewOnrampPayment = exports.WebviewOnrampOrderStatus = exports.TransferCryptoDetails = exports.TokenBalance = exports.StepProgress = exports.RecipientSelection = exports.OrderTokenAmount = exports.OrderToken = exports.OrderStatus = exports.OrderHistoryItem = exports.OrderHistory = exports.OrderDetailsCollapsible = exports.OrderDetails = exports.CryptoReceiveSection = exports.CryptoPaySection = exports.ChainTokenIcon = exports.AnySpendNFTButton = exports.AnySpendTournament = exports.AnySpendStakeUpsideExactIn = exports.AnySpendStakeUpside = exports.AnySpendStakeB3ExactIn = exports.AnySpendStakeB3 = exports.AnyspendSignatureMint = exports.AnySpendNFT = exports.AnySpendCustomExactIn = exports.AnySpendCustom = exports.AnySpendBuySpin = exports.AnySpendBondKit = exports.AnySpend = void 0;
18
18
  // Components
19
19
  var AnySpend_1 = require("./AnySpend");
20
20
  Object.defineProperty(exports, "AnySpend", { enumerable: true, get: function () { return AnySpend_1.AnySpend; } });
@@ -24,15 +24,23 @@ var AnySpendBuySpin_1 = require("./AnySpendBuySpin");
24
24
  Object.defineProperty(exports, "AnySpendBuySpin", { enumerable: true, get: function () { return AnySpendBuySpin_1.AnySpendBuySpin; } });
25
25
  var AnySpendCustom_1 = require("./AnySpendCustom");
26
26
  Object.defineProperty(exports, "AnySpendCustom", { enumerable: true, get: function () { return AnySpendCustom_1.AnySpendCustom; } });
27
+ var AnySpendCustomExactIn_1 = require("./AnySpendCustomExactIn");
28
+ Object.defineProperty(exports, "AnySpendCustomExactIn", { enumerable: true, get: function () { return AnySpendCustomExactIn_1.AnySpendCustomExactIn; } });
27
29
  __exportStar(require("./AnySpendFingerprintWrapper"), exports);
28
30
  var AnySpendNFT_1 = require("./AnySpendNFT");
29
31
  Object.defineProperty(exports, "AnySpendNFT", { enumerable: true, get: function () { return AnySpendNFT_1.AnySpendNFT; } });
32
+ var AnyspendSignatureMint_1 = require("./AnyspendSignatureMint");
33
+ Object.defineProperty(exports, "AnyspendSignatureMint", { enumerable: true, get: function () { return AnyspendSignatureMint_1.AnyspendSignatureMint; } });
30
34
  var AnySpendStakeB3_1 = require("./AnySpendStakeB3");
31
35
  Object.defineProperty(exports, "AnySpendStakeB3", { enumerable: true, get: function () { return AnySpendStakeB3_1.AnySpendStakeB3; } });
36
+ var AnySpendStakeB3ExactIn_1 = require("./AnySpendStakeB3ExactIn");
37
+ Object.defineProperty(exports, "AnySpendStakeB3ExactIn", { enumerable: true, get: function () { return AnySpendStakeB3ExactIn_1.AnySpendStakeB3ExactIn; } });
38
+ var AnySpendStakeUpside_1 = require("./AnySpendStakeUpside");
39
+ Object.defineProperty(exports, "AnySpendStakeUpside", { enumerable: true, get: function () { return AnySpendStakeUpside_1.AnySpendStakeUpside; } });
40
+ var AnySpendStakeUpsideExactIn_1 = require("./AnySpendStakeUpsideExactIn");
41
+ Object.defineProperty(exports, "AnySpendStakeUpsideExactIn", { enumerable: true, get: function () { return AnySpendStakeUpsideExactIn_1.AnySpendStakeUpsideExactIn; } });
32
42
  var AnySpendTournament_1 = require("./AnySpendTournament");
33
43
  Object.defineProperty(exports, "AnySpendTournament", { enumerable: true, get: function () { return AnySpendTournament_1.AnySpendTournament; } });
34
- var AnyspendSignatureMint_1 = require("./AnyspendSignatureMint");
35
- Object.defineProperty(exports, "AnyspendSignatureMint", { enumerable: true, get: function () { return AnyspendSignatureMint_1.AnyspendSignatureMint; } });
36
44
  var AnySpendNFTButton_1 = require("./common/AnySpendNFTButton");
37
45
  Object.defineProperty(exports, "AnySpendNFTButton", { enumerable: true, get: function () { return AnySpendNFTButton_1.AnySpendNFTButton; } });
38
46
  // Common Components
@@ -20,10 +20,13 @@ interface UseAnyspendFlowProps {
20
20
  onTransactionSuccess?: (amount?: string) => void;
21
21
  sourceTokenAddress?: string;
22
22
  sourceTokenChainId?: number;
23
+ destinationTokenAddress?: string;
24
+ destinationTokenChainId?: number;
23
25
  slippage?: number;
24
26
  disableUrlParamManagement?: boolean;
27
+ orderType?: "hype_duel" | "custom_exact_in";
25
28
  }
26
- export declare function useAnyspendFlow({ paymentType, recipientAddress, loadOrder, isDepositMode, onOrderSuccess, onTransactionSuccess, sourceTokenAddress, sourceTokenChainId, slippage, disableUrlParamManagement, }: UseAnyspendFlowProps): {
29
+ export declare function useAnyspendFlow({ paymentType, recipientAddress, loadOrder, isDepositMode, onOrderSuccess, onTransactionSuccess, sourceTokenAddress, sourceTokenChainId, destinationTokenAddress, destinationTokenChainId, slippage, disableUrlParamManagement, orderType, }: UseAnyspendFlowProps): {
27
30
  activePanel: PanelView;
28
31
  setActivePanel: import("react").Dispatch<import("react").SetStateAction<PanelView>>;
29
32
  orderId: string | undefined;
@@ -44,7 +47,6 @@ export declare function useAnyspendFlow({ paymentType, recipientAddress, loadOrd
44
47
  selectedSrcChainId: number;
45
48
  setSelectedSrcChainId: import("react").Dispatch<import("react").SetStateAction<number>>;
46
49
  selectedDstChainId: number;
47
- setSelectedDstChainId: import("react").Dispatch<import("react").SetStateAction<number>>;
48
50
  selectedSrcToken: {
49
51
  chainId: number;
50
52
  address: string;
@@ -65,6 +67,26 @@ export declare function useAnyspendFlow({ paymentType, recipientAddress, loadOrd
65
67
  logoURI?: string;
66
68
  };
67
69
  }>>;
70
+ selectedDstToken: {
71
+ chainId: number;
72
+ address: string;
73
+ symbol: string;
74
+ name: string;
75
+ decimals: number;
76
+ metadata: {
77
+ logoURI?: string;
78
+ };
79
+ };
80
+ setSelectedDstToken: import("react").Dispatch<import("react").SetStateAction<{
81
+ chainId: number;
82
+ address: string;
83
+ symbol: string;
84
+ name: string;
85
+ decimals: number;
86
+ metadata: {
87
+ logoURI?: string;
88
+ };
89
+ }>>;
68
90
  srcAmount: string;
69
91
  setSrcAmount: import("react").Dispatch<import("react").SetStateAction<string>>;
70
92
  dstAmount: string;
@@ -27,21 +27,25 @@ var PanelView;
27
27
  PanelView[PanelView["POINTS_DETAIL"] = 6] = "POINTS_DETAIL";
28
28
  PanelView[PanelView["FEE_DETAIL"] = 7] = "FEE_DETAIL";
29
29
  })(PanelView || (exports.PanelView = PanelView = {}));
30
- function useAnyspendFlow({ paymentType = "crypto", recipientAddress, loadOrder, isDepositMode = false, onOrderSuccess, onTransactionSuccess, sourceTokenAddress, sourceTokenChainId, slippage = 0, disableUrlParamManagement = false, }) {
30
+ // This hook serves for order hype_duel and custom_exact_in
31
+ function useAnyspendFlow({ paymentType = "crypto", recipientAddress, loadOrder, isDepositMode = false, onOrderSuccess, onTransactionSuccess, sourceTokenAddress, sourceTokenChainId, destinationTokenAddress, destinationTokenChainId, slippage = 0, disableUrlParamManagement = false, orderType = "hype_duel", }) {
31
32
  const searchParams = (0, react_2.useSearchParamsSSR)();
32
33
  const router = (0, react_2.useRouter)();
33
34
  // Panel and order state
34
35
  const [activePanel, setActivePanel] = (0, react_3.useState)(loadOrder ? PanelView.ORDER_DETAILS : PanelView.MAIN);
35
36
  const [orderId, setOrderId] = (0, react_3.useState)(loadOrder);
36
37
  const { orderAndTransactions: oat } = (0, react_1.useAnyspendOrderAndTransactions)(orderId);
37
- // Token selection state - use provided sourceTokenChainId if available
38
+ // Token selection state - use provided sourceTokenChainId and destinationTokenChainId if available
38
39
  const [selectedSrcChainId, setSelectedSrcChainId] = (0, react_3.useState)(sourceTokenChainId || (paymentType === "fiat" ? chains_1.base.id : chains_1.mainnet.id));
39
- const [selectedDstChainId, setSelectedDstChainId] = (0, react_3.useState)(chains_1.base.id); // Default to Base for cross-chain swaps
40
40
  const defaultSrcToken = paymentType === "fiat" ? anyspend_1.USDC_BASE : (0, anyspend_1.getDefaultToken)(selectedSrcChainId);
41
+ const defaultDstToken = anyspend_1.B3_TOKEN; // Default destination token
41
42
  const [selectedSrcToken, setSelectedSrcToken] = (0, react_3.useState)(defaultSrcToken);
43
+ const [selectedDstToken, setSelectedDstToken] = (0, react_3.useState)(defaultDstToken);
42
44
  const [srcAmount, setSrcAmount] = (0, react_3.useState)(paymentType === "fiat" ? "5" : "0.1");
43
45
  const [dstAmount, setDstAmount] = (0, react_3.useState)("");
44
46
  const [isSrcInputDirty, setIsSrcInputDirty] = (0, react_3.useState)(true);
47
+ // Derive destination chain ID from token or prop (cannot change)
48
+ const selectedDstChainId = destinationTokenChainId || selectedDstToken.chainId;
45
49
  // Payment method state
46
50
  const [selectedCryptoPaymentMethod, setSelectedCryptoPaymentMethod] = (0, react_3.useState)(CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE);
47
51
  const [selectedFiatPaymentMethod, setSelectedFiatPaymentMethod] = (0, react_3.useState)(FiatPaymentMethod_1.FiatPaymentMethod.NONE);
@@ -101,6 +105,23 @@ function useAnyspendFlow({ paymentType = "crypto", recipientAddress, loadOrder,
101
105
  };
102
106
  fetchSourceToken();
103
107
  }, [sourceTokenAddress, sourceTokenChainId]);
108
+ // Fetch specific token when destinationTokenAddress and destinationTokenChainId are provided
109
+ (0, react_3.useEffect)(() => {
110
+ const fetchDestinationToken = async () => {
111
+ if (destinationTokenAddress && destinationTokenChainId) {
112
+ try {
113
+ const token = await anyspend_2.anyspendService.getToken(destinationTokenChainId, destinationTokenAddress);
114
+ setSelectedDstToken(token);
115
+ }
116
+ catch (error) {
117
+ console.error("Failed to fetch destination token:", error);
118
+ sonner_1.toast.error(`Failed to load token ${destinationTokenAddress} on chain ${destinationTokenChainId}`);
119
+ // Keep the default token on error
120
+ }
121
+ }
122
+ };
123
+ fetchDestinationToken();
124
+ }, [destinationTokenAddress, destinationTokenChainId]);
104
125
  // Helper function for onramp vendor mapping
105
126
  const getOnrampVendor = (paymentMethod) => {
106
127
  switch (paymentMethod) {
@@ -120,8 +141,8 @@ function useAnyspendFlow({ paymentType = "crypto", recipientAddress, loadOrder,
120
141
  srcChain: paymentType === "fiat" ? chains_1.base.id : selectedSrcChainId,
121
142
  dstChain: isDepositMode ? chains_1.base.id : selectedDstChainId, // For deposits, always Base; for swaps, use selected destination
122
143
  srcTokenAddress: paymentType === "fiat" ? anyspend_1.USDC_BASE.address : selectedSrcToken.address,
123
- dstTokenAddress: isDepositMode ? anyspend_1.B3_TOKEN.address : selectedSrcToken.address, // For deposits, always B3
124
- type: "hype_duel",
144
+ dstTokenAddress: selectedDstToken.address,
145
+ type: orderType,
125
146
  amount: activeInputAmountInWei,
126
147
  recipientAddress: selectedRecipientAddress,
127
148
  onrampVendor: paymentType === "fiat" ? getOnrampVendor(selectedFiatPaymentMethod) : undefined,
@@ -217,10 +238,11 @@ function useAnyspendFlow({ paymentType = "crypto", recipientAddress, loadOrder,
217
238
  // Token state
218
239
  selectedSrcChainId,
219
240
  setSelectedSrcChainId,
220
- selectedDstChainId,
221
- setSelectedDstChainId,
241
+ selectedDstChainId, // Derived, not stateful
222
242
  selectedSrcToken,
223
243
  setSelectedSrcToken,
244
+ selectedDstToken,
245
+ setSelectedDstToken,
224
246
  srcAmount,
225
247
  setSrcAmount,
226
248
  dstAmount,
@@ -53,6 +53,35 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
53
53
  relay?: Record<string, never>;
54
54
  } | null;
55
55
  fee?: Omit<import("../..").components["schemas"]["Fee"], "type"> | null;
56
+ } & {
57
+ type: "x402_swap";
58
+ payload: import("../..").components["schemas"]["X402SwapPayload"];
59
+ metadata: import("../..").components["schemas"]["X402SwapMetadata"];
60
+ }) | ({
61
+ id: string;
62
+ recipientAddress: string;
63
+ globalAddress: string;
64
+ srcChain: number;
65
+ dstChain: number;
66
+ srcTokenAddress: string;
67
+ dstTokenAddress: string;
68
+ srcAmount: string;
69
+ status: "scanning_deposit_transaction" | "waiting_stripe_payment" | "expired" | "sending_token_from_vault" | "relay" | "executing" | "executed" | "refunding" | "refunded" | "failure";
70
+ errorDetails: string | null;
71
+ createdAt: number;
72
+ expiredAt: number;
73
+ filledAt: number | null;
74
+ receivedDepositAt: number | null;
75
+ creatorAddress: string | null;
76
+ partnerId: string | null;
77
+ onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
78
+ oneClickBuyUrl: string | null;
79
+ stripePaymentIntentId: string | null;
80
+ settlement: {
81
+ actualDstAmount?: string;
82
+ relay?: Record<string, never>;
83
+ } | null;
84
+ fee?: Omit<import("../..").components["schemas"]["Fee"], "type"> | null;
56
85
  } & {
57
86
  type: "hype_duel";
58
87
  payload: import("../..").components["schemas"]["HypeDuelPayload"];
@@ -111,6 +140,35 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
111
140
  relay?: Record<string, never>;
112
141
  } | null;
113
142
  fee?: Omit<import("../..").components["schemas"]["Fee"], "type"> | null;
143
+ } & {
144
+ type: "custom_exact_in";
145
+ payload: import("../..").components["schemas"]["CustomExactInPayload"];
146
+ metadata: import("../..").components["schemas"]["CustomMetadata"];
147
+ }) | ({
148
+ id: string;
149
+ recipientAddress: string;
150
+ globalAddress: string;
151
+ srcChain: number;
152
+ dstChain: number;
153
+ srcTokenAddress: string;
154
+ dstTokenAddress: string;
155
+ srcAmount: string;
156
+ status: "scanning_deposit_transaction" | "waiting_stripe_payment" | "expired" | "sending_token_from_vault" | "relay" | "executing" | "executed" | "refunding" | "refunded" | "failure";
157
+ errorDetails: string | null;
158
+ createdAt: number;
159
+ expiredAt: number;
160
+ filledAt: number | null;
161
+ receivedDepositAt: number | null;
162
+ creatorAddress: string | null;
163
+ partnerId: string | null;
164
+ onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
165
+ oneClickBuyUrl: string | null;
166
+ stripePaymentIntentId: string | null;
167
+ settlement: {
168
+ actualDstAmount?: string;
169
+ relay?: Record<string, never>;
170
+ } | null;
171
+ fee?: Omit<import("../..").components["schemas"]["Fee"], "type"> | null;
114
172
  } & {
115
173
  type: "mint_nft";
116
174
  payload: import("../..").components["schemas"]["MintNftPayload"];
@@ -230,6 +288,35 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
230
288
  relay?: Record<string, never>;
231
289
  } | null;
232
290
  fee?: Omit<import("../..").components["schemas"]["Fee"], "type"> | null;
291
+ } & {
292
+ type: "x402_swap";
293
+ payload: import("../..").components["schemas"]["X402SwapPayload"];
294
+ metadata: import("../..").components["schemas"]["X402SwapMetadata"];
295
+ }) | ({
296
+ id: string;
297
+ recipientAddress: string;
298
+ globalAddress: string;
299
+ srcChain: number;
300
+ dstChain: number;
301
+ srcTokenAddress: string;
302
+ dstTokenAddress: string;
303
+ srcAmount: string;
304
+ status: "scanning_deposit_transaction" | "waiting_stripe_payment" | "expired" | "sending_token_from_vault" | "relay" | "executing" | "executed" | "refunding" | "refunded" | "failure";
305
+ errorDetails: string | null;
306
+ createdAt: number;
307
+ expiredAt: number;
308
+ filledAt: number | null;
309
+ receivedDepositAt: number | null;
310
+ creatorAddress: string | null;
311
+ partnerId: string | null;
312
+ onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
313
+ oneClickBuyUrl: string | null;
314
+ stripePaymentIntentId: string | null;
315
+ settlement: {
316
+ actualDstAmount?: string;
317
+ relay?: Record<string, never>;
318
+ } | null;
319
+ fee?: Omit<import("../..").components["schemas"]["Fee"], "type"> | null;
233
320
  } & {
234
321
  type: "hype_duel";
235
322
  payload: import("../..").components["schemas"]["HypeDuelPayload"];
@@ -288,6 +375,35 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
288
375
  relay?: Record<string, never>;
289
376
  } | null;
290
377
  fee?: Omit<import("../..").components["schemas"]["Fee"], "type"> | null;
378
+ } & {
379
+ type: "custom_exact_in";
380
+ payload: import("../..").components["schemas"]["CustomExactInPayload"];
381
+ metadata: import("../..").components["schemas"]["CustomMetadata"];
382
+ }) | ({
383
+ id: string;
384
+ recipientAddress: string;
385
+ globalAddress: string;
386
+ srcChain: number;
387
+ dstChain: number;
388
+ srcTokenAddress: string;
389
+ dstTokenAddress: string;
390
+ srcAmount: string;
391
+ status: "scanning_deposit_transaction" | "waiting_stripe_payment" | "expired" | "sending_token_from_vault" | "relay" | "executing" | "executed" | "refunding" | "refunded" | "failure";
392
+ errorDetails: string | null;
393
+ createdAt: number;
394
+ expiredAt: number;
395
+ filledAt: number | null;
396
+ receivedDepositAt: number | null;
397
+ creatorAddress: string | null;
398
+ partnerId: string | null;
399
+ onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
400
+ oneClickBuyUrl: string | null;
401
+ stripePaymentIntentId: string | null;
402
+ settlement: {
403
+ actualDstAmount?: string;
404
+ relay?: Record<string, never>;
405
+ } | null;
406
+ fee?: Omit<import("../..").components["schemas"]["Fee"], "type"> | null;
291
407
  } & {
292
408
  type: "mint_nft";
293
409
  payload: import("../..").components["schemas"]["MintNftPayload"];
@@ -14,7 +14,7 @@ function useAnyspendQuote(req) {
14
14
  req.dstChain &&
15
15
  req.srcTokenAddress &&
16
16
  req.dstTokenAddress &&
17
- BigInt(req.type === "swap" || req.type === "hype_duel"
17
+ BigInt(req.type === "swap" || req.type === "hype_duel" || req.type === "x402_swap" || req.type === "custom_exact_in"
18
18
  ? req.amount
19
19
  : req.type === "mint_nft"
20
20
  ? req.price