@b3dotfun/sdk 0.0.65-alpha.2 → 0.0.65-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.
@@ -24,7 +24,9 @@ export interface AnySpendCustomExactInProps {
24
24
  }) => void;
25
25
  customUsdInputValues?: string[];
26
26
  preferEoa?: boolean;
27
- customExactInConfig: CustomExactInConfig;
27
+ customExactInConfig?: CustomExactInConfig;
28
+ orderType?: "hype_duel" | "custom_exact_in";
29
+ minDestinationAmount?: number;
28
30
  header?: ({ anyspendPrice, isLoadingAnyspendPrice, }: {
29
31
  anyspendPrice: GetQuoteResponse | undefined;
30
32
  isLoadingAnyspendPrice: boolean;
@@ -8,6 +8,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const utils_1 = require("../../../anyspend/utils");
9
9
  const react_1 = require("../../../global-account/react");
10
10
  const cn_1 = require("../../../shared/utils/cn");
11
+ const number_1 = require("../../../shared/utils/number");
11
12
  const invariant_1 = __importDefault(require("invariant"));
12
13
  const lucide_react_1 = require("lucide-react");
13
14
  const react_2 = require("motion/react");
@@ -30,8 +31,8 @@ function AnySpendCustomExactIn(props) {
30
31
  const fingerprintConfig = (0, AnySpendFingerprintWrapper_1.getFingerprintConfig)();
31
32
  return ((0, jsx_runtime_1.jsx)(AnySpendFingerprintWrapper_1.AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: (0, jsx_runtime_1.jsx)(AnySpendCustomExactInInner, { ...props }) }));
32
33
  }
33
- function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, destinationToken, destinationChainId, onSuccess, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, customExactInConfig, header, }) {
34
- const actionLabel = customExactInConfig.action ?? "Custom Execution";
34
+ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, destinationToken, destinationChainId, onSuccess, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, customExactInConfig, orderType = "custom_exact_in", minDestinationAmount, header, }) {
35
+ const actionLabel = customExactInConfig?.action ?? "Custom Execution";
35
36
  const DESTINATION_TOKEN_DETAILS = {
36
37
  SYMBOL: destinationToken.symbol ?? "TOKEN",
37
38
  LOGO_URI: destinationToken.metadata?.logoURI ?? "",
@@ -48,7 +49,7 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
48
49
  destinationTokenChainId: destinationChainId,
49
50
  slippage: SLIPPAGE_PERCENT,
50
51
  disableUrlParamManagement: true,
51
- orderType: "custom_exact_in",
52
+ orderType,
52
53
  });
53
54
  const { connectedEOAWallet } = (0, react_1.useAccountWallet)();
54
55
  const setActiveWallet = (0, react_4.useSetActiveWallet)();
@@ -64,6 +65,13 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
64
65
  const selectedRecipientOrDefault = selectedRecipientAddress ?? recipientAddress;
65
66
  const expectedDstAmountRaw = anyspendQuote?.data?.currencyOut?.amount ?? "0";
66
67
  const buildCustomPayload = (_recipient) => {
68
+ if (!customExactInConfig) {
69
+ // For hype_duel or other simple order types
70
+ return {
71
+ expectedDstAmount: expectedDstAmountRaw,
72
+ };
73
+ }
74
+ // For custom_exact_in with custom config
67
75
  return {
68
76
  amount: expectedDstAmountRaw,
69
77
  expectedDstAmount: expectedDstAmountRaw,
@@ -88,6 +96,24 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
88
96
  return { text: "Select recipient", disable: false, error: false, loading: false };
89
97
  if (!anyspendQuote || !anyspendQuote.success)
90
98
  return { text: "Get quote error", disable: true, error: true, loading: false };
99
+ // Check minimum destination amount if specified
100
+ // Check minimum destination amount if specified
101
+ if (minDestinationAmount &&
102
+ anyspendQuote.data?.currencyOut?.amount &&
103
+ anyspendQuote.data.currencyOut.currency &&
104
+ anyspendQuote.data.currencyOut.currency.decimals != null) {
105
+ const rawAmountInWei = BigInt(anyspendQuote.data.currencyOut.amount);
106
+ const decimals = anyspendQuote.data.currencyOut.currency.decimals;
107
+ const actualAmount = parseFloat((0, number_1.formatUnits)(rawAmountInWei.toString(), decimals));
108
+ if (actualAmount < minDestinationAmount) {
109
+ return {
110
+ text: `Minimum ${minDestinationAmount} ${DESTINATION_TOKEN_DETAILS.SYMBOL} deposit`,
111
+ disable: true,
112
+ error: true,
113
+ loading: false,
114
+ };
115
+ }
116
+ }
91
117
  if (paymentType === "crypto") {
92
118
  if (effectiveCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE) {
93
119
  return { text: "Choose payment method", disable: false, error: false, loading: false };
@@ -97,7 +123,9 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
97
123
  effectiveCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.CONNECT_WALLET) {
98
124
  return { text: "Insufficient balance", disable: true, error: true, loading: false };
99
125
  }
100
- return { text: `Execute ${actionLabel}`, disable: false, error: false, loading: false };
126
+ // Use different text based on order type
127
+ const buttonText = orderType === "hype_duel" ? "Continue to deposit" : `Execute ${actionLabel}`;
128
+ return { text: buttonText, disable: false, error: false, loading: false };
101
129
  }
102
130
  if (paymentType === "fiat") {
103
131
  if (selectedFiatPaymentMethod === FiatPaymentMethod_1.FiatPaymentMethod.NONE) {
@@ -119,6 +147,9 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
119
147
  hasEnoughBalance,
120
148
  isBalanceLoading,
121
149
  actionLabel,
150
+ minDestinationAmount,
151
+ DESTINATION_TOKEN_DETAILS.SYMBOL,
152
+ orderType,
122
153
  ]);
123
154
  const onMainButtonClick = async () => {
124
155
  if (btnInfo.disable)
@@ -155,7 +186,7 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
155
186
  const payload = buildCustomPayload(selectedRecipientOrDefault);
156
187
  createOrder({
157
188
  recipientAddress: selectedRecipientOrDefault,
158
- orderType: "custom_exact_in",
189
+ orderType,
159
190
  srcChain: selectedSrcChainId,
160
191
  dstChain: selectedDstChainId,
161
192
  srcToken: selectedSrcToken,
@@ -203,7 +234,7 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
203
234
  const payload = buildCustomPayload(selectedRecipientOrDefault);
204
235
  createOnrampOrder({
205
236
  recipientAddress: selectedRecipientOrDefault,
206
- orderType: "custom_exact_in",
237
+ orderType,
207
238
  dstChain: selectedDstChainId,
208
239
  dstToken: selectedDstToken,
209
240
  srcFiatAmount: srcAmount,
@@ -22,4 +22,4 @@ export interface AnySpendDepositHypeProps {
22
22
  customUsdInputValues?: string[];
23
23
  preferEoa?: boolean;
24
24
  }
25
- export declare function AnySpendDepositHype(props: AnySpendDepositHypeProps): import("react/jsx-runtime").JSX.Element;
25
+ export declare function AnySpendDepositHype({ loadOrder, mode, recipientAddress, paymentType, sourceTokenAddress, sourceTokenChainId, onSuccess, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, }: AnySpendDepositHypeProps): import("react/jsx-runtime").JSX.Element | null;
@@ -1,264 +1,27 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.HYPE_TOKEN_DETAILS = void 0;
7
4
  exports.AnySpendDepositHype = AnySpendDepositHype;
8
5
  const jsx_runtime_1 = require("react/jsx-runtime");
9
6
  const anyspend_1 = require("../../../anyspend");
10
- const react_1 = require("../../../global-account/react");
11
- const cn_1 = require("../../../shared/utils/cn");
12
- const invariant_1 = __importDefault(require("invariant"));
13
- const react_2 = require("motion/react");
14
- const react_3 = require("react");
15
- const sonner_1 = require("sonner");
16
- const react_4 = require("thirdweb/react");
17
7
  const chains_1 = require("viem/chains");
18
- const useAnyspendFlow_1 = require("../hooks/useAnyspendFlow");
19
- const AnySpendFingerprintWrapper_1 = require("./AnySpendFingerprintWrapper");
20
- const CryptoPaySection_1 = require("./common/CryptoPaySection");
21
- const CryptoPaymentMethod_1 = require("./common/CryptoPaymentMethod");
22
- const CryptoReceiveSection_1 = require("./common/CryptoReceiveSection");
23
- const FeeDetailPanel_1 = require("./common/FeeDetailPanel");
24
- const FiatPaymentMethod_1 = require("./common/FiatPaymentMethod");
25
- const OrderDetails_1 = require("./common/OrderDetails");
26
- const PointsDetailPanel_1 = require("./common/PointsDetailPanel");
27
- const RecipientSelection_1 = require("./common/RecipientSelection");
28
- const lucide_react_1 = require("lucide-react");
29
- const PanelOnramp_1 = require("./common/PanelOnramp");
30
- const SLIPPAGE_PERCENT = 3;
8
+ const AnySpendCustomExactIn_1 = require("./AnySpendCustomExactIn");
31
9
  exports.HYPE_TOKEN_DETAILS = {
32
10
  SYMBOL: "HYPE",
33
11
  LOGO_URI: "https://cdn.hypeduel.com/hypes-coin.svg",
34
12
  };
35
- function AnySpendDepositHype(props) {
36
- const fingerprintConfig = (0, AnySpendFingerprintWrapper_1.getFingerprintConfig)();
37
- return ((0, jsx_runtime_1.jsx)(AnySpendFingerprintWrapper_1.AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: (0, jsx_runtime_1.jsx)(AnySpendDepositHypeInner, { ...props }) }));
38
- }
39
- function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, onSuccess, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, }) {
40
- // Use shared flow hook
41
- const { activePanel, setActivePanel, orderId, setOrderId, oat, selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, dstAmount, isSrcInputDirty, setIsSrcInputDirty, selectedCryptoPaymentMethod, effectiveCryptoPaymentMethod, setSelectedCryptoPaymentMethod, selectedFiatPaymentMethod, setSelectedFiatPaymentMethod, selectedRecipientAddress, setSelectedRecipientAddress, recipientName, globalAddress, anyspendQuote, isLoadingAnyspendQuote, activeInputAmountInWei, geoData, coinbaseAvailablePaymentMethods, stripeWeb2Support, createOrder, isCreatingOrder, createOnrampOrder, isCreatingOnrampOrder, } = (0, useAnyspendFlow_1.useAnyspendFlow)({
42
- paymentType,
43
- recipientAddress,
44
- loadOrder,
45
- isDepositMode: true,
46
- onTransactionSuccess: onSuccess,
47
- sourceTokenAddress,
48
- sourceTokenChainId,
49
- slippage: SLIPPAGE_PERCENT,
50
- disableUrlParamManagement: true,
51
- });
52
- const { connectedEOAWallet: connectedEOAWallet } = (0, react_1.useAccountWallet)();
53
- const setActiveWallet = (0, react_4.useSetActiveWallet)();
54
- const appliedPreferEoa = (0, react_3.useRef)(false);
55
- (0, react_3.useEffect)(() => {
56
- if (preferEoa && !appliedPreferEoa.current) {
57
- if (connectedEOAWallet) {
58
- appliedPreferEoa.current = true;
59
- setActiveWallet(connectedEOAWallet);
60
- }
61
- }
62
- }, [preferEoa, connectedEOAWallet, setActiveWallet]);
63
- // Button state logic
64
- const btnInfo = (0, react_3.useMemo)(() => {
65
- if (activeInputAmountInWei === "0")
66
- return { text: "Enter an amount", disable: true, error: false, loading: false };
67
- if (isLoadingAnyspendQuote)
68
- return { text: "Loading quote...", disable: true, error: false, loading: true };
69
- if (isCreatingOrder || isCreatingOnrampOrder)
70
- return { text: "Creating order...", disable: true, error: false, loading: true };
71
- if (!selectedRecipientAddress)
72
- return { text: "Select recipient", disable: false, error: false, loading: false };
73
- if (!anyspendQuote || !anyspendQuote.success)
74
- return { text: "Get quote error", disable: true, error: true, loading: false };
75
- if (!dstAmount)
76
- return { text: "No quote available", disable: true, error: true, loading: false };
77
- // Check minimum deposit amount (10 HYPE)
78
- // Use the raw amount from the quote instead of the formatted display string
79
- if (anyspendQuote.data?.currencyOut?.amount && anyspendQuote.data.currencyOut.currency?.decimals) {
80
- const rawAmountInWei = anyspendQuote.data.currencyOut.amount;
81
- const decimals = anyspendQuote.data.currencyOut.currency.decimals;
82
- const actualAmount = parseFloat(rawAmountInWei) / Math.pow(10, decimals);
83
- if (actualAmount < 10) {
84
- return { text: "Minimum 10 HYPE deposit", disable: true, error: true, loading: false };
85
- }
86
- }
87
- if (paymentType === "crypto") {
88
- if (effectiveCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE) {
89
- return { text: "Choose payment method", disable: false, error: false, loading: false };
90
- }
91
- return { text: "Continue to deposit", disable: false, error: false, loading: false };
92
- }
93
- if (paymentType === "fiat") {
94
- if (selectedFiatPaymentMethod === FiatPaymentMethod_1.FiatPaymentMethod.NONE) {
95
- return { text: "Select payment method", disable: false, error: false, loading: false };
96
- }
97
- return { text: "Buy", disable: false, error: false, loading: false };
98
- }
99
- return { text: "Continue to deposit", disable: false, error: false, loading: false };
100
- }, [
101
- activeInputAmountInWei,
102
- effectiveCryptoPaymentMethod,
103
- isLoadingAnyspendQuote,
104
- isCreatingOrder,
105
- isCreatingOnrampOrder,
106
- selectedRecipientAddress,
107
- anyspendQuote,
108
- dstAmount,
109
- paymentType,
110
- selectedFiatPaymentMethod,
111
- ]);
112
- const onMainButtonClick = async () => {
113
- if (btnInfo.disable)
114
- return;
115
- if (!selectedRecipientAddress) {
116
- setActivePanel(useAnyspendFlow_1.PanelView.RECIPIENT_SELECTION);
117
- return;
118
- }
119
- if (paymentType === "crypto") {
120
- if (effectiveCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE) {
121
- setActivePanel(useAnyspendFlow_1.PanelView.CRYPTO_PAYMENT_METHOD);
122
- return;
123
- }
124
- await handleCryptoOrder();
125
- }
126
- else if (paymentType === "fiat") {
127
- if (selectedFiatPaymentMethod === FiatPaymentMethod_1.FiatPaymentMethod.NONE) {
128
- setActivePanel(useAnyspendFlow_1.PanelView.FIAT_PAYMENT_METHOD);
129
- return;
130
- }
131
- await handleFiatOrder();
132
- }
133
- };
134
- const mainView = ((0, jsx_runtime_1.jsxs)("div", { className: "mx-auto flex w-[460px] max-w-full flex-col items-center gap-2", children: [(0, jsx_runtime_1.jsx)("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)("h1", { className: "text-as-primary text-xl font-bold", children: paymentType === "crypto" ? "Deposit Crypto" : "Fund with Fiat" }) }) }), (0, jsx_runtime_1.jsx)("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: (0, jsx_runtime_1.jsxs)("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [paymentType === "crypto" ? ((0, jsx_runtime_1.jsx)(CryptoPaySection_1.CryptoPaySection, { selectedSrcChainId: selectedSrcChainId, setSelectedSrcChainId: setSelectedSrcChainId, selectedSrcToken: selectedSrcToken, setSelectedSrcToken: setSelectedSrcToken, srcAmount: srcAmount, setSrcAmount: setSrcAmount, isSrcInputDirty: isSrcInputDirty, setIsSrcInputDirty: setIsSrcInputDirty, selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod, onSelectCryptoPaymentMethod: () => setActivePanel(useAnyspendFlow_1.PanelView.CRYPTO_PAYMENT_METHOD), anyspendQuote: anyspendQuote, onTokenSelect: onTokenSelect })) : ((0, jsx_runtime_1.jsx)(react_2.motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, children: (0, jsx_runtime_1.jsx)(PanelOnramp_1.PanelOnramp, { srcAmountOnRamp: srcAmount, setSrcAmountOnRamp: setSrcAmount, selectedPaymentMethod: selectedFiatPaymentMethod, setActivePanel: setActivePanel, _recipientAddress: recipientAddress, destinationToken: anyspend_1.B3_TOKEN, destinationChainId: chains_1.base.id, dstTokenSymbol: exports.HYPE_TOKEN_DETAILS.SYMBOL, hideDstToken: true, destinationAmount: dstAmount, onDestinationTokenChange: () => { }, onDestinationChainChange: () => { }, fiatPaymentMethodIndex: useAnyspendFlow_1.PanelView.FIAT_PAYMENT_METHOD, recipientSelectionPanelIndex: useAnyspendFlow_1.PanelView.RECIPIENT_SELECTION, anyspendQuote: anyspendQuote, onShowPointsDetail: () => setActivePanel(useAnyspendFlow_1.PanelView.POINTS_DETAIL), onShowFeeDetail: () => setActivePanel(useAnyspendFlow_1.PanelView.FEE_DETAIL), customUsdInputValues: customUsdInputValues }) })), (0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("relative -my-1 flex h-0 items-center justify-center", paymentType === "fiat" && "hidden"), children: (0, jsx_runtime_1.jsx)(react_1.Button, { variant: "ghost", className: (0, cn_1.cn)("swap-direction-button border-as-stroke bg-as-surface-primary z-10 h-10 w-10 cursor-default rounded-xl border-2 sm:h-8 sm:w-8 sm:rounded-xl"), children: (0, jsx_runtime_1.jsx)("div", { className: "relative flex items-center justify-center transition-opacity", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ArrowDown, { className: "text-as-primary/50 h-5 w-5" }) }) }) }), paymentType === "crypto" && ((0, jsx_runtime_1.jsx)(CryptoReceiveSection_1.CryptoReceiveSection, { isDepositMode: false, isBuyMode: true, selectedRecipientAddress: selectedRecipientAddress, recipientName: recipientName || undefined, onSelectRecipient: () => setActivePanel(useAnyspendFlow_1.PanelView.RECIPIENT_SELECTION), setRecipientAddress: setSelectedRecipientAddress, recipientAddressFromProps: recipientAddress, globalAddress: globalAddress, dstAmount: dstAmount, dstToken: anyspend_1.B3_TOKEN, dstTokenSymbol: exports.HYPE_TOKEN_DETAILS.SYMBOL, dstTokenLogoURI: exports.HYPE_TOKEN_DETAILS.LOGO_URI, selectedDstChainId: chains_1.base.id, setSelectedDstChainId: () => { }, setSelectedDstToken: () => { }, isSrcInputDirty: isSrcInputDirty, onChangeDstAmount: value => {
135
- setIsSrcInputDirty(false);
136
- setSrcAmount(value);
137
- }, anyspendQuote: anyspendQuote, onShowPointsDetail: () => setActivePanel(useAnyspendFlow_1.PanelView.POINTS_DETAIL), onShowFeeDetail: () => setActivePanel(useAnyspendFlow_1.PanelView.FEE_DETAIL), selectedCryptoPaymentMethod: selectedCryptoPaymentMethod }))] }) }), (0, jsx_runtime_1.jsx)(react_2.motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: (0, cn_1.cn)("mt-4 flex w-full max-w-[460px] flex-col gap-2"), children: (0, jsx_runtime_1.jsx)(react_1.ShinyButton, { accentColor: "hsl(var(--as-brand))", disabled: btnInfo.disable, onClick: onMainButtonClick, className: (0, cn_1.cn)("as-main-button relative w-full", btnInfo.error ? "!bg-as-red" : btnInfo.disable ? "!bg-as-on-surface-2" : "!bg-as-brand"), textClassName: (0, cn_1.cn)(btnInfo.error ? "text-white" : btnInfo.disable ? "text-as-secondary" : "text-white"), children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-center gap-2", children: [btnInfo.loading && (0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "h-4 w-4 animate-spin" }), btnInfo.text] }) }) }), mainFooter ? mainFooter : null] }));
138
- // Handle crypto order creation
139
- const handleCryptoOrder = async () => {
140
- try {
141
- (0, invariant_1.default)(anyspendQuote, "Relay price is not found");
142
- (0, invariant_1.default)(selectedRecipientAddress, "Recipient address is not found");
143
- const srcAmountBigInt = BigInt(activeInputAmountInWei);
144
- createOrder({
145
- recipientAddress: selectedRecipientAddress,
146
- orderType: "hype_duel",
147
- srcChain: selectedSrcChainId,
148
- dstChain: chains_1.base.id,
149
- srcToken: selectedSrcToken,
150
- dstToken: anyspend_1.B3_TOKEN,
151
- srcAmount: srcAmountBigInt.toString(),
152
- expectedDstAmount: anyspendQuote?.data?.currencyOut?.amount?.toString() || "0",
153
- creatorAddress: globalAddress,
154
- });
155
- }
156
- catch (err) {
157
- console.error(err);
158
- sonner_1.toast.error("Failed to create order: " + err.message);
159
- }
160
- };
161
- // Handle fiat order creation
162
- const handleFiatOrder = async () => {
163
- try {
164
- (0, invariant_1.default)(anyspendQuote, "Relay price is not found");
165
- (0, invariant_1.default)(selectedRecipientAddress, "Recipient address is not found");
166
- if (!srcAmount || parseFloat(srcAmount) <= 0) {
167
- sonner_1.toast.error("Please enter a valid amount");
168
- return;
169
- }
170
- // Determine vendor and payment method string
171
- let vendor;
172
- let paymentMethodString = "";
173
- if (selectedFiatPaymentMethod === FiatPaymentMethod_1.FiatPaymentMethod.COINBASE_PAY) {
174
- if (coinbaseAvailablePaymentMethods.length === 0) {
175
- sonner_1.toast.error("Coinbase Pay not available");
176
- return;
177
- }
178
- vendor = "coinbase";
179
- paymentMethodString = coinbaseAvailablePaymentMethods[0]?.id || "";
180
- }
181
- else if (selectedFiatPaymentMethod === FiatPaymentMethod_1.FiatPaymentMethod.STRIPE) {
182
- if (!stripeWeb2Support || !stripeWeb2Support.isSupport) {
183
- sonner_1.toast.error("Stripe not available");
184
- return;
185
- }
186
- vendor = "stripe-web2";
187
- paymentMethodString = "";
188
- }
189
- else {
190
- sonner_1.toast.error("Please select a payment method");
191
- return;
192
- }
193
- createOnrampOrder({
194
- recipientAddress: selectedRecipientAddress,
195
- orderType: "hype_duel",
196
- dstChain: chains_1.base.id,
197
- dstToken: anyspend_1.B3_TOKEN,
198
- srcFiatAmount: srcAmount,
199
- onramp: {
200
- vendor: vendor,
201
- paymentMethod: paymentMethodString,
202
- country: geoData?.country || "US",
203
- redirectUrl: window.location.origin,
204
- },
205
- expectedDstAmount: anyspendQuote?.data?.currencyOut?.amount?.toString() || "0",
206
- creatorAddress: globalAddress,
207
- });
208
- }
209
- catch (err) {
210
- console.error(err);
211
- sonner_1.toast.error("Failed to create order: " + err.message);
212
- }
13
+ function AnySpendDepositHype({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, onSuccess, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, }) {
14
+ if (!recipientAddress)
15
+ return null;
16
+ const header = () => ((0, jsx_runtime_1.jsx)("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)("h1", { className: "text-as-primary text-xl font-bold", children: paymentType === "crypto" ? "Deposit Crypto" : "Fund with Fiat" }) }) }));
17
+ // Create a modified B3_TOKEN with HYPE branding
18
+ const hypeToken = {
19
+ ...anyspend_1.B3_TOKEN,
20
+ symbol: exports.HYPE_TOKEN_DETAILS.SYMBOL,
21
+ metadata: {
22
+ ...anyspend_1.B3_TOKEN.metadata,
23
+ logoURI: exports.HYPE_TOKEN_DETAILS.LOGO_URI,
24
+ },
213
25
  };
214
- // Order details view
215
- const orderDetailsView = ((0, jsx_runtime_1.jsx)("div", { className: "mx-auto w-[460px] max-w-full", children: (0, jsx_runtime_1.jsx)("div", { className: "relative flex flex-col gap-4", children: oat && ((0, jsx_runtime_1.jsx)(OrderDetails_1.OrderDetails, { mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTxs: oat.data.relayTxs, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, cryptoPaymentMethod: paymentType === "fiat" ? CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE : selectedCryptoPaymentMethod, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod, onPaymentMethodChange: setSelectedCryptoPaymentMethod, onBack: () => {
216
- setOrderId(undefined);
217
- setActivePanel(useAnyspendFlow_1.PanelView.MAIN);
218
- }, disableUrlParamManagement: true, points: oat.data.points || undefined })) }) }));
219
- // Loading view
220
- const loadingView = ((0, jsx_runtime_1.jsx)("div", { className: "mx-auto flex w-full flex-col items-center gap-4 p-5", children: (0, jsx_runtime_1.jsx)("div", { className: "text-as-primary", children: "Loading order details..." }) }));
221
- // Panel views
222
- const recipientSelectionView = ((0, jsx_runtime_1.jsx)(RecipientSelection_1.RecipientSelection, { initialValue: selectedRecipientAddress || "", onBack: () => setActivePanel(useAnyspendFlow_1.PanelView.MAIN), onConfirm: address => {
223
- setSelectedRecipientAddress(address);
224
- setActivePanel(useAnyspendFlow_1.PanelView.MAIN);
225
- } }));
226
- const cryptoPaymentMethodView = ((0, jsx_runtime_1.jsx)(CryptoPaymentMethod_1.CryptoPaymentMethod, { globalAddress: globalAddress, globalWallet: undefined, selectedPaymentMethod: selectedCryptoPaymentMethod, setSelectedPaymentMethod: setSelectedCryptoPaymentMethod, isCreatingOrder: isCreatingOrder, onBack: () => setActivePanel(useAnyspendFlow_1.PanelView.MAIN), onSelectPaymentMethod: (method) => {
227
- setSelectedCryptoPaymentMethod(method);
228
- setActivePanel(useAnyspendFlow_1.PanelView.MAIN);
229
- } }));
230
- const fiatPaymentMethodView = ((0, jsx_runtime_1.jsx)(FiatPaymentMethod_1.FiatPaymentMethodComponent, { selectedPaymentMethod: selectedFiatPaymentMethod, setSelectedPaymentMethod: setSelectedFiatPaymentMethod, onBack: () => setActivePanel(useAnyspendFlow_1.PanelView.MAIN), onSelectPaymentMethod: (method) => {
231
- setSelectedFiatPaymentMethod(method);
232
- setActivePanel(useAnyspendFlow_1.PanelView.MAIN);
233
- }, srcAmountOnRamp: srcAmount }));
234
- const pointsDetailView = ((0, jsx_runtime_1.jsx)(PointsDetailPanel_1.PointsDetailPanel, { pointsAmount: anyspendQuote?.data?.pointsAmount || 0, onBack: () => setActivePanel(useAnyspendFlow_1.PanelView.MAIN) }));
235
- const feeDetailView = anyspendQuote?.data?.fee ? ((0, jsx_runtime_1.jsx)(FeeDetailPanel_1.FeeDetailPanel, { fee: anyspendQuote.data.fee, transactionAmountUsd: paymentType === "fiat"
236
- ? parseFloat(srcAmount)
237
- : anyspendQuote.data.currencyIn?.amountUsd
238
- ? Number(anyspendQuote.data.currencyIn.amountUsd)
239
- : undefined, onBack: () => setActivePanel(useAnyspendFlow_1.PanelView.MAIN) })) : null;
240
- // If showing token selection, render with panel transitions
241
- return ((0, jsx_runtime_1.jsx)(react_1.StyleRoot, { children: (0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("anyspend-container font-inter mx-auto w-full max-w-[460px]", mode === "page" &&
242
- "bg-as-surface-primary border-as-border-secondary overflow-hidden rounded-2xl border shadow-xl"), children: (0, jsx_runtime_1.jsx)(react_1.TransitionPanel, { activeIndex: orderId
243
- ? oat
244
- ? useAnyspendFlow_1.PanelView.ORDER_DETAILS
245
- : useAnyspendFlow_1.PanelView.LOADING
246
- : activePanel === useAnyspendFlow_1.PanelView.ORDER_DETAILS
247
- ? useAnyspendFlow_1.PanelView.MAIN
248
- : activePanel, className: (0, cn_1.cn)("rounded-2xl", {
249
- "mt-0": mode === "modal",
250
- }), variants: {
251
- enter: { x: 300, opacity: 0 },
252
- center: { x: 0, opacity: 1 },
253
- exit: { x: -300, opacity: 0 },
254
- }, transition: { type: "spring", stiffness: 300, damping: 30 }, children: [
255
- (0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: mainView }, "main-view"),
256
- (0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: cryptoPaymentMethodView }, "crypto-payment-method-view"),
257
- (0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: fiatPaymentMethodView }, "fiat-payment-method-view"),
258
- (0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: recipientSelectionView }, "recipient-selection-view"),
259
- (0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: orderDetailsView }, "order-details-view"),
260
- (0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: loadingView }, "loading-view"),
261
- (0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: pointsDetailView }, "points-detail-view"),
262
- (0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: feeDetailView }, "fee-detail-view"),
263
- ] }) }) }));
26
+ return ((0, jsx_runtime_1.jsx)(AnySpendCustomExactIn_1.AnySpendCustomExactIn, { loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, paymentType: paymentType, sourceTokenAddress: sourceTokenAddress, sourceTokenChainId: sourceTokenChainId, destinationToken: hypeToken, destinationChainId: chains_1.base.id, orderType: "hype_duel", minDestinationAmount: 10, header: header, onSuccess: onSuccess, mainFooter: mainFooter, onTokenSelect: onTokenSelect, customUsdInputValues: customUsdInputValues, preferEoa: preferEoa }));
264
27
  }
@@ -3,6 +3,7 @@ export { AnySpendBondKit } from "./AnySpendBondKit";
3
3
  export { AnySpendBuySpin } from "./AnySpendBuySpin";
4
4
  export { AnySpendCustom } from "./AnySpendCustom";
5
5
  export { AnySpendCustomExactIn } from "./AnySpendCustomExactIn";
6
+ export { AnySpendDepositHype, HYPE_TOKEN_DETAILS } from "./AnyspendDepositHype";
6
7
  export * from "./AnySpendFingerprintWrapper";
7
8
  export { AnySpendNFT } from "./AnySpendNFT";
8
9
  export { AnyspendSignatureMint } from "./AnyspendSignatureMint";
@@ -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.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;
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.HYPE_TOKEN_DETAILS = exports.AnySpendDepositHype = 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; } });
@@ -26,6 +26,9 @@ var AnySpendCustom_1 = require("./AnySpendCustom");
26
26
  Object.defineProperty(exports, "AnySpendCustom", { enumerable: true, get: function () { return AnySpendCustom_1.AnySpendCustom; } });
27
27
  var AnySpendCustomExactIn_1 = require("./AnySpendCustomExactIn");
28
28
  Object.defineProperty(exports, "AnySpendCustomExactIn", { enumerable: true, get: function () { return AnySpendCustomExactIn_1.AnySpendCustomExactIn; } });
29
+ var AnyspendDepositHype_1 = require("./AnyspendDepositHype");
30
+ Object.defineProperty(exports, "AnySpendDepositHype", { enumerable: true, get: function () { return AnyspendDepositHype_1.AnySpendDepositHype; } });
31
+ Object.defineProperty(exports, "HYPE_TOKEN_DETAILS", { enumerable: true, get: function () { return AnyspendDepositHype_1.HYPE_TOKEN_DETAILS; } });
29
32
  __exportStar(require("./AnySpendFingerprintWrapper"), exports);
30
33
  var AnySpendNFT_1 = require("./AnySpendNFT");
31
34
  Object.defineProperty(exports, "AnySpendNFT", { enumerable: true, get: function () { return AnySpendNFT_1.AnySpendNFT; } });
@@ -24,7 +24,9 @@ export interface AnySpendCustomExactInProps {
24
24
  }) => void;
25
25
  customUsdInputValues?: string[];
26
26
  preferEoa?: boolean;
27
- customExactInConfig: CustomExactInConfig;
27
+ customExactInConfig?: CustomExactInConfig;
28
+ orderType?: "hype_duel" | "custom_exact_in";
29
+ minDestinationAmount?: number;
28
30
  header?: ({ anyspendPrice, isLoadingAnyspendPrice, }: {
29
31
  anyspendPrice: GetQuoteResponse | undefined;
30
32
  isLoadingAnyspendPrice: boolean;
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { normalizeAddress } from "../../../anyspend/utils/index.js";
3
3
  import { Button, ShinyButton, StyleRoot, TransitionPanel, useAccountWallet } from "../../../global-account/react/index.js";
4
4
  import { cn } from "../../../shared/utils/cn.js";
5
+ import { formatUnits } from "../../../shared/utils/number.js";
5
6
  import invariant from "invariant";
6
7
  import { ArrowDown, Loader2 } from "lucide-react";
7
8
  import { motion } from "motion/react";
@@ -24,8 +25,8 @@ export function AnySpendCustomExactIn(props) {
24
25
  const fingerprintConfig = getFingerprintConfig();
25
26
  return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: _jsx(AnySpendCustomExactInInner, { ...props }) }));
26
27
  }
27
- function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, destinationToken, destinationChainId, onSuccess, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, customExactInConfig, header, }) {
28
- const actionLabel = customExactInConfig.action ?? "Custom Execution";
28
+ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, destinationToken, destinationChainId, onSuccess, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, customExactInConfig, orderType = "custom_exact_in", minDestinationAmount, header, }) {
29
+ const actionLabel = customExactInConfig?.action ?? "Custom Execution";
29
30
  const DESTINATION_TOKEN_DETAILS = {
30
31
  SYMBOL: destinationToken.symbol ?? "TOKEN",
31
32
  LOGO_URI: destinationToken.metadata?.logoURI ?? "",
@@ -42,7 +43,7 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
42
43
  destinationTokenChainId: destinationChainId,
43
44
  slippage: SLIPPAGE_PERCENT,
44
45
  disableUrlParamManagement: true,
45
- orderType: "custom_exact_in",
46
+ orderType,
46
47
  });
47
48
  const { connectedEOAWallet } = useAccountWallet();
48
49
  const setActiveWallet = useSetActiveWallet();
@@ -58,6 +59,13 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
58
59
  const selectedRecipientOrDefault = selectedRecipientAddress ?? recipientAddress;
59
60
  const expectedDstAmountRaw = anyspendQuote?.data?.currencyOut?.amount ?? "0";
60
61
  const buildCustomPayload = (_recipient) => {
62
+ if (!customExactInConfig) {
63
+ // For hype_duel or other simple order types
64
+ return {
65
+ expectedDstAmount: expectedDstAmountRaw,
66
+ };
67
+ }
68
+ // For custom_exact_in with custom config
61
69
  return {
62
70
  amount: expectedDstAmountRaw,
63
71
  expectedDstAmount: expectedDstAmountRaw,
@@ -82,6 +90,24 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
82
90
  return { text: "Select recipient", disable: false, error: false, loading: false };
83
91
  if (!anyspendQuote || !anyspendQuote.success)
84
92
  return { text: "Get quote error", disable: true, error: true, loading: false };
93
+ // Check minimum destination amount if specified
94
+ // Check minimum destination amount if specified
95
+ if (minDestinationAmount &&
96
+ anyspendQuote.data?.currencyOut?.amount &&
97
+ anyspendQuote.data.currencyOut.currency &&
98
+ anyspendQuote.data.currencyOut.currency.decimals != null) {
99
+ const rawAmountInWei = BigInt(anyspendQuote.data.currencyOut.amount);
100
+ const decimals = anyspendQuote.data.currencyOut.currency.decimals;
101
+ const actualAmount = parseFloat(formatUnits(rawAmountInWei.toString(), decimals));
102
+ if (actualAmount < minDestinationAmount) {
103
+ return {
104
+ text: `Minimum ${minDestinationAmount} ${DESTINATION_TOKEN_DETAILS.SYMBOL} deposit`,
105
+ disable: true,
106
+ error: true,
107
+ loading: false,
108
+ };
109
+ }
110
+ }
85
111
  if (paymentType === "crypto") {
86
112
  if (effectiveCryptoPaymentMethod === CryptoPaymentMethodType.NONE) {
87
113
  return { text: "Choose payment method", disable: false, error: false, loading: false };
@@ -91,7 +117,9 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
91
117
  effectiveCryptoPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET) {
92
118
  return { text: "Insufficient balance", disable: true, error: true, loading: false };
93
119
  }
94
- return { text: `Execute ${actionLabel}`, disable: false, error: false, loading: false };
120
+ // Use different text based on order type
121
+ const buttonText = orderType === "hype_duel" ? "Continue to deposit" : `Execute ${actionLabel}`;
122
+ return { text: buttonText, disable: false, error: false, loading: false };
95
123
  }
96
124
  if (paymentType === "fiat") {
97
125
  if (selectedFiatPaymentMethod === FiatPaymentMethod.NONE) {
@@ -113,6 +141,9 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
113
141
  hasEnoughBalance,
114
142
  isBalanceLoading,
115
143
  actionLabel,
144
+ minDestinationAmount,
145
+ DESTINATION_TOKEN_DETAILS.SYMBOL,
146
+ orderType,
116
147
  ]);
117
148
  const onMainButtonClick = async () => {
118
149
  if (btnInfo.disable)
@@ -149,7 +180,7 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
149
180
  const payload = buildCustomPayload(selectedRecipientOrDefault);
150
181
  createOrder({
151
182
  recipientAddress: selectedRecipientOrDefault,
152
- orderType: "custom_exact_in",
183
+ orderType,
153
184
  srcChain: selectedSrcChainId,
154
185
  dstChain: selectedDstChainId,
155
186
  srcToken: selectedSrcToken,
@@ -197,7 +228,7 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
197
228
  const payload = buildCustomPayload(selectedRecipientOrDefault);
198
229
  createOnrampOrder({
199
230
  recipientAddress: selectedRecipientOrDefault,
200
- orderType: "custom_exact_in",
231
+ orderType,
201
232
  dstChain: selectedDstChainId,
202
233
  dstToken: selectedDstToken,
203
234
  srcFiatAmount: srcAmount,
@@ -22,4 +22,4 @@ export interface AnySpendDepositHypeProps {
22
22
  customUsdInputValues?: string[];
23
23
  preferEoa?: boolean;
24
24
  }
25
- export declare function AnySpendDepositHype(props: AnySpendDepositHypeProps): import("react/jsx-runtime").JSX.Element;
25
+ export declare function AnySpendDepositHype({ loadOrder, mode, recipientAddress, paymentType, sourceTokenAddress, sourceTokenChainId, onSuccess, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, }: AnySpendDepositHypeProps): import("react/jsx-runtime").JSX.Element | null;