@b3dotfun/sdk 0.0.44-alpha.0 → 0.0.44-alpha.2
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 +12 -13
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +13 -14
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +1 -6
- package/dist/cjs/anyspend/react/components/common/OrderHistory.js +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderHistoryItem.js +7 -9
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +1 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +3 -3
- package/dist/cjs/anyspend/react/hooks/useAnyspendOrderAndTransactions.d.ts +2 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +36 -0
- package/dist/cjs/anyspend/types/api.d.ts +189 -10
- package/dist/cjs/anyspend/utils/orderPayload.js +0 -4
- package/dist/esm/anyspend/react/components/AnySpend.js +13 -14
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +14 -15
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +1 -6
- package/dist/esm/anyspend/react/components/common/OrderHistory.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderHistoryItem.js +9 -11
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +1 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +3 -3
- package/dist/esm/anyspend/react/hooks/useAnyspendOrderAndTransactions.d.ts +2 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +36 -0
- package/dist/esm/anyspend/types/api.d.ts +189 -10
- package/dist/esm/anyspend/utils/orderPayload.js +0 -4
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/useAnyspendOrderAndTransactions.d.ts +2 -0
- package/dist/types/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +36 -0
- package/dist/types/anyspend/types/api.d.ts +189 -10
- package/package.json +2 -1
- package/src/anyspend/react/components/AnySpend.tsx +20 -18
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +21 -20
- package/src/anyspend/react/components/common/OrderDetails.tsx +1 -7
- package/src/anyspend/react/components/common/OrderHistory.tsx +11 -11
- package/src/anyspend/react/components/common/OrderHistoryItem.tsx +105 -137
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +3 -3
- package/src/anyspend/types/api.ts +189 -10
- package/src/anyspend/utils/orderPayload.ts +0 -4
- package/dist/cjs/anyspend/react/components/common/ErrorSection.d.ts +0 -6
- package/dist/cjs/anyspend/react/components/common/ErrorSection.js +0 -12
- package/dist/esm/anyspend/react/components/common/ErrorSection.d.ts +0 -6
- package/dist/esm/anyspend/react/components/common/ErrorSection.js +0 -9
- package/dist/types/anyspend/react/components/common/ErrorSection.d.ts +0 -6
- package/src/anyspend/react/components/common/ErrorSection.tsx +0 -21
|
@@ -23,7 +23,6 @@ const AnySpendFingerprintWrapper_1 = require("./AnySpendFingerprintWrapper");
|
|
|
23
23
|
const CryptoPaymentMethod_1 = require("./common/CryptoPaymentMethod");
|
|
24
24
|
const CryptoPaySection_1 = require("./common/CryptoPaySection");
|
|
25
25
|
const CryptoReceiveSection_1 = require("./common/CryptoReceiveSection");
|
|
26
|
-
const ErrorSection_1 = require("./common/ErrorSection");
|
|
27
26
|
const FiatPaymentMethod_1 = require("./common/FiatPaymentMethod");
|
|
28
27
|
const OrderDetails_1 = require("./common/OrderDetails");
|
|
29
28
|
const OrderHistory_1 = require("./common/OrderHistory");
|
|
@@ -469,38 +468,38 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
469
468
|
// Determine button state and text
|
|
470
469
|
const btnInfo = (0, react_4.useMemo)(() => {
|
|
471
470
|
if (activeInputAmountInWei === "0")
|
|
472
|
-
return { text: "Enter an amount", disable: true, error: false };
|
|
471
|
+
return { text: "Enter an amount", disable: true, error: false, loading: false };
|
|
473
472
|
if (isLoadingAnyspendQuote)
|
|
474
|
-
return { text: "Loading...", disable: true, error: false };
|
|
473
|
+
return { text: "Loading quote...", disable: true, error: false, loading: true };
|
|
475
474
|
if (!recipientAddress)
|
|
476
|
-
return { text: "Select recipient", disable: false, error: false };
|
|
475
|
+
return { text: "Select recipient", disable: false, error: false, loading: false };
|
|
477
476
|
if (isCreatingOrder || isCreatingOnrampOrder)
|
|
478
|
-
return { text: "Creating order...", disable: true, error: false };
|
|
477
|
+
return { text: "Creating order...", disable: true, error: false, loading: true };
|
|
479
478
|
if (!anyspendQuote || !anyspendQuote.success)
|
|
480
|
-
return { text: "
|
|
479
|
+
return { text: "No quote found", disable: true, error: false, loading: false };
|
|
481
480
|
if (activeTab === "crypto") {
|
|
482
481
|
// If no payment method selected, show "Choose payment method"
|
|
483
482
|
if (selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE) {
|
|
484
|
-
return { text: "Choose payment method", disable: false, error: false };
|
|
483
|
+
return { text: "Choose payment method", disable: false, error: false, loading: false };
|
|
485
484
|
}
|
|
486
485
|
// If payment method selected, show appropriate action
|
|
487
486
|
if (selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.CONNECT_WALLET ||
|
|
488
487
|
selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.GLOBAL_WALLET) {
|
|
489
|
-
return { text: "Swap", disable: false, error: false };
|
|
488
|
+
return { text: "Swap", disable: false, error: false, loading: false };
|
|
490
489
|
}
|
|
491
490
|
if (selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.TRANSFER_CRYPTO) {
|
|
492
|
-
return { text: "Continue to payment", disable: false, error: false };
|
|
491
|
+
return { text: "Continue to payment", disable: false, error: false, loading: false };
|
|
493
492
|
}
|
|
494
493
|
}
|
|
495
494
|
if (activeTab === "fiat") {
|
|
496
495
|
// If no fiat payment method selected, show "Select payment method"
|
|
497
496
|
if (selectedFiatPaymentMethod === FiatPaymentMethod_1.FiatPaymentMethod.NONE) {
|
|
498
|
-
return { text: "Select payment method", disable: false, error: false };
|
|
497
|
+
return { text: "Select payment method", disable: false, error: false, loading: false };
|
|
499
498
|
}
|
|
500
499
|
// If payment method is selected, show "Buy"
|
|
501
|
-
return { text: "Buy", disable: false, error: false };
|
|
500
|
+
return { text: "Buy", disable: false, error: false, loading: false };
|
|
502
501
|
}
|
|
503
|
-
return { text: "Buy", disable: false, error: false };
|
|
502
|
+
return { text: "Buy", disable: false, error: false, loading: false };
|
|
504
503
|
}, [
|
|
505
504
|
activeInputAmountInWei,
|
|
506
505
|
isLoadingAnyspendQuote,
|
|
@@ -755,7 +754,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
755
754
|
}, 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" }) }) }), activeTab === "crypto" && ((0, jsx_runtime_1.jsx)(CryptoReceiveSection_1.CryptoReceiveSection, { isDepositMode: false, isBuyMode: isBuyMode, selectedRecipientAddress: recipientAddress, recipientName: recipientName || undefined, onSelectRecipient: () => navigateToPanel(PanelView.RECIPIENT_SELECTION, "forward"), dstAmount: dstAmount, dstToken: selectedDstToken, selectedDstChainId: selectedDstChainId, setSelectedDstChainId: setSelectedDstChainId, setSelectedDstToken: setSelectedDstToken, onChangeDstAmount: value => {
|
|
756
755
|
setIsSrcInputDirty(false);
|
|
757
756
|
setDstAmount(value);
|
|
758
|
-
}, anyspendQuote: anyspendQuote, onShowPointsDetail: () => navigateToPanel(PanelView.POINTS_DETAIL, "forward") }))] }), (0, jsx_runtime_1.
|
|
757
|
+
}, anyspendQuote: anyspendQuote, onShowPointsDetail: () => navigateToPanel(PanelView.POINTS_DETAIL, "forward") }))] }), (0, jsx_runtime_1.jsxs)(react_3.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_2.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] }) }), !hideTransactionHistoryButton && (globalAddress || recipientAddress) ? ((0, jsx_runtime_1.jsxs)(react_2.Button, { variant: "link", onClick: onClickHistory, className: "text-as-primary/50 hover:text-as-primary flex items-center gap-1 transition-colors", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.HistoryIcon, { className: "h-4 w-4" }), " ", (0, jsx_runtime_1.jsx)("span", { className: "pr-4", children: "Transaction History" })] })) : null] })] }));
|
|
759
758
|
const onrampPaymentView = ((0, jsx_runtime_1.jsx)(PanelOnrampPayment_1.PanelOnrampPayment, { srcAmountOnRamp: srcAmountOnRamp, recipientName: recipientName || undefined, recipientAddress: recipientAddress, isBuyMode: isBuyMode, destinationTokenChainId: destinationTokenChainId, destinationTokenAddress: destinationTokenAddress, selectedDstChainId: selectedDstChainId, selectedDstToken: selectedDstToken, orderType: "swap", anyspendQuote: anyspendQuote, globalAddress: globalAddress, onOrderCreated: orderId => {
|
|
760
759
|
setOrderId(orderId);
|
|
761
760
|
navigateToPanel(PanelView.ORDER_DETAILS, "forward");
|
|
@@ -19,7 +19,6 @@ const AnySpendFingerprintWrapper_1 = require("./AnySpendFingerprintWrapper");
|
|
|
19
19
|
const CryptoPaySection_1 = require("./common/CryptoPaySection");
|
|
20
20
|
const CryptoPaymentMethod_1 = require("./common/CryptoPaymentMethod");
|
|
21
21
|
const CryptoReceiveSection_1 = require("./common/CryptoReceiveSection");
|
|
22
|
-
const ErrorSection_1 = require("./common/ErrorSection");
|
|
23
22
|
const FiatPaymentMethod_1 = require("./common/FiatPaymentMethod");
|
|
24
23
|
const OrderDetails_1 = require("./common/OrderDetails");
|
|
25
24
|
const PointsDetailPanel_1 = require("./common/PointsDetailPanel");
|
|
@@ -51,17 +50,17 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
51
50
|
// Button state logic
|
|
52
51
|
const btnInfo = (0, react_3.useMemo)(() => {
|
|
53
52
|
if (activeInputAmountInWei === "0")
|
|
54
|
-
return { text: "Enter an amount", disable: true, error: false };
|
|
53
|
+
return { text: "Enter an amount", disable: true, error: false, loading: false };
|
|
55
54
|
if (isLoadingAnyspendQuote)
|
|
56
|
-
return { text: "Loading quote...", disable: true, error: false };
|
|
55
|
+
return { text: "Loading quote...", disable: true, error: false, loading: true };
|
|
57
56
|
if (isCreatingOrder || isCreatingOnrampOrder)
|
|
58
|
-
return { text: "Creating order...", disable: true, error: false };
|
|
57
|
+
return { text: "Creating order...", disable: true, error: false, loading: true };
|
|
59
58
|
if (!selectedRecipientAddress)
|
|
60
|
-
return { text: "Select recipient", disable: false, error: false };
|
|
59
|
+
return { text: "Select recipient", disable: false, error: false, loading: false };
|
|
61
60
|
if (!anyspendQuote || !anyspendQuote.success)
|
|
62
|
-
return { text: "Get quote error", disable: true, error: true };
|
|
61
|
+
return { text: "Get quote error", disable: true, error: true, loading: false };
|
|
63
62
|
if (!dstAmount)
|
|
64
|
-
return { text: "No quote available", disable: true, error: true };
|
|
63
|
+
return { text: "No quote available", disable: true, error: true, loading: false };
|
|
65
64
|
// Check minimum deposit amount (10 HYPE)
|
|
66
65
|
// Use the raw amount from the quote instead of the formatted display string
|
|
67
66
|
if (anyspendQuote.data?.currencyOut?.amount && anyspendQuote.data.currencyOut.currency?.decimals) {
|
|
@@ -69,22 +68,22 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
69
68
|
const decimals = anyspendQuote.data.currencyOut.currency.decimals;
|
|
70
69
|
const actualAmount = parseFloat(rawAmountInWei) / Math.pow(10, decimals);
|
|
71
70
|
if (actualAmount < 10) {
|
|
72
|
-
return { text: "Minimum 10 HYPE deposit", disable: true, error: true };
|
|
71
|
+
return { text: "Minimum 10 HYPE deposit", disable: true, error: true, loading: false };
|
|
73
72
|
}
|
|
74
73
|
}
|
|
75
74
|
if (paymentType === "crypto") {
|
|
76
75
|
if (selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE) {
|
|
77
|
-
return { text: "Choose payment method", disable: false, error: false };
|
|
76
|
+
return { text: "Choose payment method", disable: false, error: false, loading: false };
|
|
78
77
|
}
|
|
79
|
-
return { text: "Continue to deposit", disable: false, error: false };
|
|
78
|
+
return { text: "Continue to deposit", disable: false, error: false, loading: false };
|
|
80
79
|
}
|
|
81
80
|
if (paymentType === "fiat") {
|
|
82
81
|
if (selectedFiatPaymentMethod === FiatPaymentMethod_1.FiatPaymentMethod.NONE) {
|
|
83
|
-
return { text: "Select payment method", disable: false, error: false };
|
|
82
|
+
return { text: "Select payment method", disable: false, error: false, loading: false };
|
|
84
83
|
}
|
|
85
|
-
return { text: "Buy", disable: false, error: false };
|
|
84
|
+
return { text: "Buy", disable: false, error: false, loading: false };
|
|
86
85
|
}
|
|
87
|
-
return { text: "Continue to deposit", disable: false, error: false };
|
|
86
|
+
return { text: "Continue to deposit", disable: false, error: false, loading: false };
|
|
88
87
|
}, [
|
|
89
88
|
activeInputAmountInWei,
|
|
90
89
|
isLoadingAnyspendQuote,
|
|
@@ -122,7 +121,7 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
122
121
|
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, setIsSrcInputDirty: setIsSrcInputDirty, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod, 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), 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: recipientAddress, recipientName: recipientName || undefined, onSelectRecipient: () => setActivePanel(useAnyspendFlow_1.PanelView.RECIPIENT_SELECTION), 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: () => { }, onChangeDstAmount: value => {
|
|
123
122
|
setIsSrcInputDirty(false);
|
|
124
123
|
setSrcAmount(value);
|
|
125
|
-
}, anyspendQuote: anyspendQuote, onShowPointsDetail: () => setActivePanel(useAnyspendFlow_1.PanelView.POINTS_DETAIL) }))] }) }), (0, jsx_runtime_1.jsx)(
|
|
124
|
+
}, anyspendQuote: anyspendQuote, onShowPointsDetail: () => setActivePanel(useAnyspendFlow_1.PanelView.POINTS_DETAIL) }))] }) }), (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] }));
|
|
126
125
|
// Handle crypto order creation
|
|
127
126
|
const handleCryptoOrder = async () => {
|
|
128
127
|
try {
|
|
@@ -280,12 +280,7 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ mode = "modal",
|
|
|
280
280
|
? "0"
|
|
281
281
|
: order.payload.expectedDstAmount.toString();
|
|
282
282
|
const formattedExpectedDstAmount = (0, number_1.formatTokenAmount)(BigInt(expectedDstAmount), dstToken.decimals);
|
|
283
|
-
const actualDstAmount = order.
|
|
284
|
-
order.type === "join_tournament" ||
|
|
285
|
-
order.type === "fund_tournament" ||
|
|
286
|
-
order.type === "custom"
|
|
287
|
-
? undefined
|
|
288
|
-
: order.payload.actualDstAmount;
|
|
283
|
+
const actualDstAmount = order.settlement?.actualDstAmount;
|
|
289
284
|
const formattedActualDstAmount = actualDstAmount
|
|
290
285
|
? (0, number_1.formatTokenAmount)(BigInt(actualDstAmount), dstToken.decimals)
|
|
291
286
|
: undefined;
|
|
@@ -10,9 +10,9 @@ const OrderHistoryItem_1 = require("./OrderHistoryItem");
|
|
|
10
10
|
function OrderHistory({ mode, onBack, onSelectOrder }) {
|
|
11
11
|
const { address } = (0, react_2.useAccountWallet)();
|
|
12
12
|
const { orderHistory, isLoadingOrderHistory, refetchOrderHistory } = (0, react_1.useAnyspendOrderHistory)(address);
|
|
13
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "mb-
|
|
13
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "mb-8 flex w-full items-center gap-3", children: [(0, jsx_runtime_1.jsx)(react_2.Button, { onClick: onBack, variant: "ghost", size: "icon", className: "hover:bg-as-surface-secondary", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ArrowLeft, { className: "h-5 w-5" }) }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1", children: (0, jsx_runtime_1.jsx)("h3", { className: "text-as-primary text-2xl font-bold", children: "Order History" }) }), (0, jsx_runtime_1.jsx)(react_2.Button, { variant: "ghost", size: "icon", className: "hover:bg-as-surface-secondary", onClick: () => {
|
|
14
14
|
refetchOrderHistory();
|
|
15
|
-
}, children: (0, jsx_runtime_1.jsx)(lucide_react_1.RefreshCcw, { className: "text-as-
|
|
15
|
+
}, children: (0, jsx_runtime_1.jsx)(lucide_react_1.RefreshCcw, { className: "text-as-secondary hover:text-as-primary h-5 w-5 cursor-pointer transition-all hover:rotate-180" }) })] }), isLoadingOrderHistory ? ((0, jsx_runtime_1.jsx)("div", { className: "w-full space-y-3", children: [1, 2, 3].map(i => ((0, jsx_runtime_1.jsx)(react_2.Skeleton, { className: "h-[180px] w-full rounded-2xl" }, i))) })) : !orderHistory?.length ? ((0, jsx_runtime_1.jsx)("div", { className: "bg-as-surface-secondary w-full rounded-2xl p-12 text-center", children: (0, jsx_runtime_1.jsx)("p", { className: "text-as-secondary text-sm", children: "No order history found" }) })) : ((0, jsx_runtime_1.jsx)("div", { className: "mb-12 w-full space-y-3", children: [...orderHistory]
|
|
16
16
|
.sort((a, b) => b.createdAt - a.createdAt)
|
|
17
17
|
.map(order => ((0, jsx_runtime_1.jsx)(OrderHistoryItem_1.OrderHistoryItem, { order: order, onSelectOrder: onSelectOrder, mode: mode }, order.id))) }))] }));
|
|
18
18
|
}
|
|
@@ -9,19 +9,14 @@ const anyspend_1 = require("../../../../anyspend");
|
|
|
9
9
|
const react_1 = require("../../../../global-account/react");
|
|
10
10
|
const utils_1 = require("../../../../shared/utils");
|
|
11
11
|
const number_1 = require("../../../../shared/utils/number");
|
|
12
|
+
const payment_utils_1 = require("../../../../shared/utils/payment.utils");
|
|
12
13
|
const lucide_react_1 = require("lucide-react");
|
|
13
14
|
const react_timeago_1 = __importDefault(require("react-timeago"));
|
|
14
|
-
const chains_1 = require("viem/chains");
|
|
15
15
|
function OrderHistoryItem({ order, onSelectOrder, mode }) {
|
|
16
16
|
const nft = order.type === "mint_nft" ? order.metadata.nft : undefined;
|
|
17
17
|
const tournament = order.type === "join_tournament" || order.type === "fund_tournament" ? order.metadata.tournament : undefined;
|
|
18
18
|
const dstToken = order.metadata.dstToken;
|
|
19
|
-
const actualDstAmount = order.
|
|
20
|
-
order.type === "join_tournament" ||
|
|
21
|
-
order.type === "fund_tournament" ||
|
|
22
|
-
order.type === "custom"
|
|
23
|
-
? undefined
|
|
24
|
-
: order.payload.actualDstAmount;
|
|
19
|
+
const actualDstAmount = order.settlement?.actualDstAmount;
|
|
25
20
|
const expectedDstAmount = order.type === "mint_nft" ||
|
|
26
21
|
order.type === "join_tournament" ||
|
|
27
22
|
order.type === "fund_tournament" ||
|
|
@@ -30,9 +25,12 @@ function OrderHistoryItem({ order, onSelectOrder, mode }) {
|
|
|
30
25
|
: order.payload.expectedDstAmount;
|
|
31
26
|
const { text: orderStatusText, status: orderDisplayStatus } = (0, anyspend_1.getStatusDisplay)(order);
|
|
32
27
|
const isSmallView = (0, react_1.useIsMobile)() || mode === "modal";
|
|
33
|
-
|
|
28
|
+
// Check if this is a one-click payment order
|
|
29
|
+
const isOneClickPayment = !!order.oneClickBuyUrl;
|
|
30
|
+
const vendorName = order.onrampMetadata?.vendor ? (0, payment_utils_1.getVendorDisplayName)(order.onrampMetadata.vendor) : null;
|
|
31
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, utils_1.cn)("bg-as-surface-secondary hover:bg-as-surface-tertiary rounded-xl p-4 transition-all", onSelectOrder && "cursor-pointer"), onClick: () => onSelectOrder?.(order.id), children: [(0, jsx_runtime_1.jsxs)("div", { className: "mb-3 flex items-center justify-between", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)("text-xs font-semibold", orderDisplayStatus === "processing" && "text-yellow-600", orderDisplayStatus === "success" && "text-green-600", orderDisplayStatus === "failure" && "text-red-600"), children: orderStatusText }), isOneClickPayment && vendorName && ((0, jsx_runtime_1.jsx)(react_1.Badge, { variant: "outline", className: "text-as-secondary px-2 py-0.5 text-[10px]", children: vendorName }))] }), (0, jsx_runtime_1.jsx)("div", { className: "text-as-secondary text-[10px] font-medium uppercase tracking-wide", children: (0, jsx_runtime_1.jsx)(react_timeago_1.default, { date: new Date(order.createdAt) }) })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: [(0, jsx_runtime_1.jsx)("img", { src: order.metadata.srcToken.metadata.logoURI, alt: order.metadata.srcToken.symbol, className: "h-8 w-8 shrink-0 rounded-full" }), (0, jsx_runtime_1.jsxs)("div", { className: "min-w-0 flex-1", children: [(0, jsx_runtime_1.jsxs)("div", { className: "text-as-primary truncate text-sm font-bold", children: [(0, number_1.formatTokenAmount)(BigInt(order.srcAmount), order.metadata.srcToken.decimals), " ", order.metadata.srcToken.symbol] }), (0, jsx_runtime_1.jsxs)("div", { className: "text-as-secondary flex items-center gap-1 text-xs", children: [(0, jsx_runtime_1.jsx)("img", { src: anyspend_1.ALL_CHAINS[order.srcChain]?.logoUrl, alt: (0, anyspend_1.getChainName)(order.srcChain), className: "h-3 w-3" }), (0, jsx_runtime_1.jsx)("span", { className: "truncate", children: (0, anyspend_1.getChainName)(order.srcChain) })] })] })] }), (0, jsx_runtime_1.jsx)(lucide_react_1.ArrowRight, { className: "text-as-secondary h-5 w-5 shrink-0 opacity-30" }), (0, jsx_runtime_1.jsx)("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: nft ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("img", { src: nft.imageUrl, alt: nft.name, className: "h-8 w-8 shrink-0 rounded-full" }), (0, jsx_runtime_1.jsxs)("div", { className: "min-w-0 flex-1", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary truncate text-sm font-bold", children: nft.name }), (0, jsx_runtime_1.jsxs)("div", { className: "text-as-secondary flex items-center gap-1 text-xs", children: [(0, jsx_runtime_1.jsx)("img", { src: anyspend_1.ALL_CHAINS[order.dstChain]?.logoUrl, alt: (0, anyspend_1.getChainName)(order.dstChain), className: "h-3 w-3" }), (0, jsx_runtime_1.jsx)("span", { className: "truncate", children: (0, anyspend_1.getChainName)(order.dstChain) })] })] })] })) : tournament ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("img", { src: tournament.imageUrl, alt: tournament.name, className: "h-8 w-8 shrink-0 rounded-full" }), (0, jsx_runtime_1.jsxs)("div", { className: "min-w-0 flex-1", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary truncate text-sm font-bold", children: tournament.name }), (0, jsx_runtime_1.jsxs)("div", { className: "text-as-secondary flex items-center gap-1 text-xs", children: [(0, jsx_runtime_1.jsx)("img", { src: anyspend_1.ALL_CHAINS[order.dstChain]?.logoUrl, alt: (0, anyspend_1.getChainName)(order.dstChain), className: "h-3 w-3" }), (0, jsx_runtime_1.jsx)("span", { className: "truncate", children: (0, anyspend_1.getChainName)(order.dstChain) })] })] })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("img", { src: dstToken.metadata.logoURI, alt: dstToken.symbol, className: "h-8 w-8 shrink-0 rounded-full" }), (0, jsx_runtime_1.jsxs)("div", { className: "min-w-0 flex-1", children: [(0, jsx_runtime_1.jsxs)("div", { className: "text-as-primary truncate text-sm font-bold", children: [(0, number_1.formatTokenAmount)(actualDstAmount
|
|
34
32
|
? BigInt(actualDstAmount)
|
|
35
33
|
: expectedDstAmount
|
|
36
34
|
? BigInt(expectedDstAmount)
|
|
37
|
-
: BigInt(0), dstToken.decimals), " ", dstToken.symbol] })
|
|
35
|
+
: BigInt(0), dstToken.decimals), " ", dstToken.symbol] }), (0, jsx_runtime_1.jsxs)("div", { className: "text-as-secondary flex items-center gap-1 text-xs", children: [(0, jsx_runtime_1.jsx)("img", { src: anyspend_1.ALL_CHAINS[order.dstChain]?.logoUrl, alt: (0, anyspend_1.getChainName)(order.dstChain), className: "h-3 w-3" }), (0, jsx_runtime_1.jsx)("span", { className: "truncate", children: (0, anyspend_1.getChainName)(order.dstChain) })] })] })] })) })] })] }, `anyspend-${order.id}`));
|
|
38
36
|
}
|
|
@@ -36,6 +36,7 @@ export declare function useAnyspendFlow({ paymentType, recipientAddress, loadOrd
|
|
|
36
36
|
relayTxs: components["schemas"]["RelayTx"][];
|
|
37
37
|
executeTx: components["schemas"]["ExecuteTx"] | null;
|
|
38
38
|
refundTxs: components["schemas"]["RefundTx"][];
|
|
39
|
+
points: number | null;
|
|
39
40
|
};
|
|
40
41
|
statusCode: number;
|
|
41
42
|
} | undefined;
|
|
@@ -192,8 +192,8 @@ function useAnyspendFlow({ paymentType = "crypto", recipientAddress, loadOrder,
|
|
|
192
192
|
// Handle order completion
|
|
193
193
|
(0, react_3.useEffect)(() => {
|
|
194
194
|
if (oat?.data?.order.status === "executed") {
|
|
195
|
-
// get the actualDstAmount if available from
|
|
196
|
-
const amount = oat.data.order.
|
|
195
|
+
// get the actualDstAmount if available from settlement
|
|
196
|
+
const amount = oat.data.order.settlement?.actualDstAmount;
|
|
197
197
|
const formattedActualDstAmount = amount
|
|
198
198
|
? (0, number_1.formatTokenAmount)(BigInt(amount), oat.data.order.metadata.dstToken.decimals)
|
|
199
199
|
: undefined;
|
|
@@ -201,7 +201,7 @@ function useAnyspendFlow({ paymentType = "crypto", recipientAddress, loadOrder,
|
|
|
201
201
|
}
|
|
202
202
|
}, [
|
|
203
203
|
oat?.data?.order.status,
|
|
204
|
-
oat?.data?.order.
|
|
204
|
+
oat?.data?.order.settlement?.actualDstAmount,
|
|
205
205
|
onTransactionSuccess,
|
|
206
206
|
oat?.data?.order.metadata.dstToken.decimals,
|
|
207
207
|
]);
|
|
@@ -8,6 +8,7 @@ export declare function useAnyspendOrderAndTransactions(orderId: string | undefi
|
|
|
8
8
|
relayTxs: import("../..").components["schemas"]["RelayTx"][];
|
|
9
9
|
executeTx: import("../..").components["schemas"]["ExecuteTx"] | null;
|
|
10
10
|
refundTxs: import("../..").components["schemas"]["RefundTx"][];
|
|
11
|
+
points: number | null;
|
|
11
12
|
};
|
|
12
13
|
statusCode: number;
|
|
13
14
|
} | undefined;
|
|
@@ -22,6 +23,7 @@ export declare function useAnyspendOrderAndTransactions(orderId: string | undefi
|
|
|
22
23
|
relayTxs: import("../..").components["schemas"]["RelayTx"][];
|
|
23
24
|
executeTx: import("../..").components["schemas"]["ExecuteTx"] | null;
|
|
24
25
|
refundTxs: import("../..").components["schemas"]["RefundTx"][];
|
|
26
|
+
points: number | null;
|
|
25
27
|
};
|
|
26
28
|
statusCode: number;
|
|
27
29
|
}, Error>>;
|
|
@@ -18,6 +18,9 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
18
18
|
onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
|
|
19
19
|
oneClickBuyUrl: string | null;
|
|
20
20
|
stripePaymentIntentId: string | null;
|
|
21
|
+
settlement: {
|
|
22
|
+
actualDstAmount: string | null;
|
|
23
|
+
} | null;
|
|
21
24
|
} & {
|
|
22
25
|
type: "swap";
|
|
23
26
|
payload: import("../..").components["schemas"]["SwapPayload"];
|
|
@@ -41,6 +44,9 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
41
44
|
onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
|
|
42
45
|
oneClickBuyUrl: string | null;
|
|
43
46
|
stripePaymentIntentId: string | null;
|
|
47
|
+
settlement: {
|
|
48
|
+
actualDstAmount: string | null;
|
|
49
|
+
} | null;
|
|
44
50
|
} & {
|
|
45
51
|
type: "hype_duel";
|
|
46
52
|
payload: import("../..").components["schemas"]["HypeDuelPayload"];
|
|
@@ -64,6 +70,9 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
64
70
|
onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
|
|
65
71
|
oneClickBuyUrl: string | null;
|
|
66
72
|
stripePaymentIntentId: string | null;
|
|
73
|
+
settlement: {
|
|
74
|
+
actualDstAmount: string | null;
|
|
75
|
+
} | null;
|
|
67
76
|
} & {
|
|
68
77
|
type: "custom";
|
|
69
78
|
payload: import("../..").components["schemas"]["CustomPayload"];
|
|
@@ -87,6 +96,9 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
87
96
|
onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
|
|
88
97
|
oneClickBuyUrl: string | null;
|
|
89
98
|
stripePaymentIntentId: string | null;
|
|
99
|
+
settlement: {
|
|
100
|
+
actualDstAmount: string | null;
|
|
101
|
+
} | null;
|
|
90
102
|
} & {
|
|
91
103
|
type: "mint_nft";
|
|
92
104
|
payload: import("../..").components["schemas"]["MintNftPayload"];
|
|
@@ -110,6 +122,9 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
110
122
|
onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
|
|
111
123
|
oneClickBuyUrl: string | null;
|
|
112
124
|
stripePaymentIntentId: string | null;
|
|
125
|
+
settlement: {
|
|
126
|
+
actualDstAmount: string | null;
|
|
127
|
+
} | null;
|
|
113
128
|
} & {
|
|
114
129
|
type: "join_tournament";
|
|
115
130
|
payload: import("../..").components["schemas"]["JoinTournamentPayload"];
|
|
@@ -133,6 +148,9 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
133
148
|
onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
|
|
134
149
|
oneClickBuyUrl: string | null;
|
|
135
150
|
stripePaymentIntentId: string | null;
|
|
151
|
+
settlement: {
|
|
152
|
+
actualDstAmount: string | null;
|
|
153
|
+
} | null;
|
|
136
154
|
} & {
|
|
137
155
|
type: "fund_tournament";
|
|
138
156
|
payload: import("../..").components["schemas"]["FundTournamentPayload"];
|
|
@@ -159,6 +177,9 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
159
177
|
onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
|
|
160
178
|
oneClickBuyUrl: string | null;
|
|
161
179
|
stripePaymentIntentId: string | null;
|
|
180
|
+
settlement: {
|
|
181
|
+
actualDstAmount: string | null;
|
|
182
|
+
} | null;
|
|
162
183
|
} & {
|
|
163
184
|
type: "swap";
|
|
164
185
|
payload: import("../..").components["schemas"]["SwapPayload"];
|
|
@@ -182,6 +203,9 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
182
203
|
onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
|
|
183
204
|
oneClickBuyUrl: string | null;
|
|
184
205
|
stripePaymentIntentId: string | null;
|
|
206
|
+
settlement: {
|
|
207
|
+
actualDstAmount: string | null;
|
|
208
|
+
} | null;
|
|
185
209
|
} & {
|
|
186
210
|
type: "hype_duel";
|
|
187
211
|
payload: import("../..").components["schemas"]["HypeDuelPayload"];
|
|
@@ -205,6 +229,9 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
205
229
|
onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
|
|
206
230
|
oneClickBuyUrl: string | null;
|
|
207
231
|
stripePaymentIntentId: string | null;
|
|
232
|
+
settlement: {
|
|
233
|
+
actualDstAmount: string | null;
|
|
234
|
+
} | null;
|
|
208
235
|
} & {
|
|
209
236
|
type: "custom";
|
|
210
237
|
payload: import("../..").components["schemas"]["CustomPayload"];
|
|
@@ -228,6 +255,9 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
228
255
|
onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
|
|
229
256
|
oneClickBuyUrl: string | null;
|
|
230
257
|
stripePaymentIntentId: string | null;
|
|
258
|
+
settlement: {
|
|
259
|
+
actualDstAmount: string | null;
|
|
260
|
+
} | null;
|
|
231
261
|
} & {
|
|
232
262
|
type: "mint_nft";
|
|
233
263
|
payload: import("../..").components["schemas"]["MintNftPayload"];
|
|
@@ -251,6 +281,9 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
251
281
|
onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
|
|
252
282
|
oneClickBuyUrl: string | null;
|
|
253
283
|
stripePaymentIntentId: string | null;
|
|
284
|
+
settlement: {
|
|
285
|
+
actualDstAmount: string | null;
|
|
286
|
+
} | null;
|
|
254
287
|
} & {
|
|
255
288
|
type: "join_tournament";
|
|
256
289
|
payload: import("../..").components["schemas"]["JoinTournamentPayload"];
|
|
@@ -274,6 +307,9 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
274
307
|
onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
|
|
275
308
|
oneClickBuyUrl: string | null;
|
|
276
309
|
stripePaymentIntentId: string | null;
|
|
310
|
+
settlement: {
|
|
311
|
+
actualDstAmount: string | null;
|
|
312
|
+
} | null;
|
|
277
313
|
} & {
|
|
278
314
|
type: "fund_tournament";
|
|
279
315
|
payload: import("../..").components["schemas"]["FundTournamentPayload"];
|