@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
|
@@ -7,9 +7,9 @@ import { OrderHistoryItem } from "./OrderHistoryItem.js";
|
|
|
7
7
|
export function OrderHistory({ mode, onBack, onSelectOrder }) {
|
|
8
8
|
const { address } = useAccountWallet();
|
|
9
9
|
const { orderHistory, isLoadingOrderHistory, refetchOrderHistory } = useAnyspendOrderHistory(address);
|
|
10
|
-
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "mb-
|
|
10
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "mb-8 flex w-full items-center gap-3", children: [_jsx(Button, { onClick: onBack, variant: "ghost", size: "icon", className: "hover:bg-as-surface-secondary", children: _jsx(ArrowLeft, { className: "h-5 w-5" }) }), _jsx("div", { className: "flex-1", children: _jsx("h3", { className: "text-as-primary text-2xl font-bold", children: "Order History" }) }), _jsx(Button, { variant: "ghost", size: "icon", className: "hover:bg-as-surface-secondary", onClick: () => {
|
|
11
11
|
refetchOrderHistory();
|
|
12
|
-
}, children: _jsx(RefreshCcw, { className: "text-as-
|
|
12
|
+
}, children: _jsx(RefreshCcw, { className: "text-as-secondary hover:text-as-primary h-5 w-5 cursor-pointer transition-all hover:rotate-180" }) })] }), isLoadingOrderHistory ? (_jsx("div", { className: "w-full space-y-3", children: [1, 2, 3].map(i => (_jsx(Skeleton, { className: "h-[180px] w-full rounded-2xl" }, i))) })) : !orderHistory?.length ? (_jsx("div", { className: "bg-as-surface-secondary w-full rounded-2xl p-12 text-center", children: _jsx("p", { className: "text-as-secondary text-sm", children: "No order history found" }) })) : (_jsx("div", { className: "mb-12 w-full space-y-3", children: [...orderHistory]
|
|
13
13
|
.sort((a, b) => b.createdAt - a.createdAt)
|
|
14
14
|
.map(order => (_jsx(OrderHistoryItem, { order: order, onSelectOrder: onSelectOrder, mode: mode }, order.id))) }))] }));
|
|
15
15
|
}
|
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { ALL_CHAINS, getChainName, getStatusDisplay } from "../../../../anyspend/index.js";
|
|
3
|
-
import { Badge,
|
|
3
|
+
import { Badge, useIsMobile } from "../../../../global-account/react/index.js";
|
|
4
4
|
import { cn } from "../../../../shared/utils/index.js";
|
|
5
5
|
import { formatTokenAmount } from "../../../../shared/utils/number.js";
|
|
6
|
-
import {
|
|
6
|
+
import { getVendorDisplayName } from "../../../../shared/utils/payment.utils.js";
|
|
7
|
+
import { ArrowRight } from "lucide-react";
|
|
7
8
|
import TimeAgo from "react-timeago";
|
|
8
|
-
import { b3 } from "viem/chains";
|
|
9
9
|
export function OrderHistoryItem({ order, onSelectOrder, mode }) {
|
|
10
10
|
const nft = order.type === "mint_nft" ? order.metadata.nft : undefined;
|
|
11
11
|
const tournament = order.type === "join_tournament" || order.type === "fund_tournament" ? order.metadata.tournament : undefined;
|
|
12
12
|
const dstToken = order.metadata.dstToken;
|
|
13
|
-
const actualDstAmount = order.
|
|
14
|
-
order.type === "join_tournament" ||
|
|
15
|
-
order.type === "fund_tournament" ||
|
|
16
|
-
order.type === "custom"
|
|
17
|
-
? undefined
|
|
18
|
-
: order.payload.actualDstAmount;
|
|
13
|
+
const actualDstAmount = order.settlement?.actualDstAmount;
|
|
19
14
|
const expectedDstAmount = order.type === "mint_nft" ||
|
|
20
15
|
order.type === "join_tournament" ||
|
|
21
16
|
order.type === "fund_tournament" ||
|
|
@@ -24,9 +19,12 @@ export function OrderHistoryItem({ order, onSelectOrder, mode }) {
|
|
|
24
19
|
: order.payload.expectedDstAmount;
|
|
25
20
|
const { text: orderStatusText, status: orderDisplayStatus } = getStatusDisplay(order);
|
|
26
21
|
const isSmallView = useIsMobile() || mode === "modal";
|
|
27
|
-
|
|
22
|
+
// Check if this is a one-click payment order
|
|
23
|
+
const isOneClickPayment = !!order.oneClickBuyUrl;
|
|
24
|
+
const vendorName = order.onrampMetadata?.vendor ? getVendorDisplayName(order.onrampMetadata.vendor) : null;
|
|
25
|
+
return (_jsxs("div", { className: cn("bg-as-surface-secondary hover:bg-as-surface-tertiary rounded-xl p-4 transition-all", onSelectOrder && "cursor-pointer"), onClick: () => onSelectOrder?.(order.id), children: [_jsxs("div", { className: "mb-3 flex items-center justify-between", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("div", { className: cn("text-xs font-semibold", orderDisplayStatus === "processing" && "text-yellow-600", orderDisplayStatus === "success" && "text-green-600", orderDisplayStatus === "failure" && "text-red-600"), children: orderStatusText }), isOneClickPayment && vendorName && (_jsx(Badge, { variant: "outline", className: "text-as-secondary px-2 py-0.5 text-[10px]", children: vendorName }))] }), _jsx("div", { className: "text-as-secondary text-[10px] font-medium uppercase tracking-wide", children: _jsx(TimeAgo, { date: new Date(order.createdAt) }) })] }), _jsxs("div", { className: "flex items-center gap-4", children: [_jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: [_jsx("img", { src: order.metadata.srcToken.metadata.logoURI, alt: order.metadata.srcToken.symbol, className: "h-8 w-8 shrink-0 rounded-full" }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsxs("div", { className: "text-as-primary truncate text-sm font-bold", children: [formatTokenAmount(BigInt(order.srcAmount), order.metadata.srcToken.decimals), " ", order.metadata.srcToken.symbol] }), _jsxs("div", { className: "text-as-secondary flex items-center gap-1 text-xs", children: [_jsx("img", { src: ALL_CHAINS[order.srcChain]?.logoUrl, alt: getChainName(order.srcChain), className: "h-3 w-3" }), _jsx("span", { className: "truncate", children: getChainName(order.srcChain) })] })] })] }), _jsx(ArrowRight, { className: "text-as-secondary h-5 w-5 shrink-0 opacity-30" }), _jsx("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: nft ? (_jsxs(_Fragment, { children: [_jsx("img", { src: nft.imageUrl, alt: nft.name, className: "h-8 w-8 shrink-0 rounded-full" }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("div", { className: "text-as-primary truncate text-sm font-bold", children: nft.name }), _jsxs("div", { className: "text-as-secondary flex items-center gap-1 text-xs", children: [_jsx("img", { src: ALL_CHAINS[order.dstChain]?.logoUrl, alt: getChainName(order.dstChain), className: "h-3 w-3" }), _jsx("span", { className: "truncate", children: getChainName(order.dstChain) })] })] })] })) : tournament ? (_jsxs(_Fragment, { children: [_jsx("img", { src: tournament.imageUrl, alt: tournament.name, className: "h-8 w-8 shrink-0 rounded-full" }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("div", { className: "text-as-primary truncate text-sm font-bold", children: tournament.name }), _jsxs("div", { className: "text-as-secondary flex items-center gap-1 text-xs", children: [_jsx("img", { src: ALL_CHAINS[order.dstChain]?.logoUrl, alt: getChainName(order.dstChain), className: "h-3 w-3" }), _jsx("span", { className: "truncate", children: getChainName(order.dstChain) })] })] })] })) : (_jsxs(_Fragment, { children: [_jsx("img", { src: dstToken.metadata.logoURI, alt: dstToken.symbol, className: "h-8 w-8 shrink-0 rounded-full" }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsxs("div", { className: "text-as-primary truncate text-sm font-bold", children: [formatTokenAmount(actualDstAmount
|
|
28
26
|
? BigInt(actualDstAmount)
|
|
29
27
|
: expectedDstAmount
|
|
30
28
|
? BigInt(expectedDstAmount)
|
|
31
|
-
: BigInt(0), dstToken.decimals), " ", dstToken.symbol] })
|
|
29
|
+
: BigInt(0), dstToken.decimals), " ", dstToken.symbol] }), _jsxs("div", { className: "text-as-secondary flex items-center gap-1 text-xs", children: [_jsx("img", { src: ALL_CHAINS[order.dstChain]?.logoUrl, alt: getChainName(order.dstChain), className: "h-3 w-3" }), _jsx("span", { className: "truncate", children: getChainName(order.dstChain) })] })] })] })) })] })] }, `anyspend-${order.id}`));
|
|
32
30
|
}
|
|
@@ -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;
|
|
@@ -188,8 +188,8 @@ export function useAnyspendFlow({ paymentType = "crypto", recipientAddress, load
|
|
|
188
188
|
// Handle order completion
|
|
189
189
|
useEffect(() => {
|
|
190
190
|
if (oat?.data?.order.status === "executed") {
|
|
191
|
-
// get the actualDstAmount if available from
|
|
192
|
-
const amount = oat.data.order.
|
|
191
|
+
// get the actualDstAmount if available from settlement
|
|
192
|
+
const amount = oat.data.order.settlement?.actualDstAmount;
|
|
193
193
|
const formattedActualDstAmount = amount
|
|
194
194
|
? formatTokenAmount(BigInt(amount), oat.data.order.metadata.dstToken.decimals)
|
|
195
195
|
: undefined;
|
|
@@ -197,7 +197,7 @@ export function useAnyspendFlow({ paymentType = "crypto", recipientAddress, load
|
|
|
197
197
|
}
|
|
198
198
|
}, [
|
|
199
199
|
oat?.data?.order.status,
|
|
200
|
-
oat?.data?.order.
|
|
200
|
+
oat?.data?.order.settlement?.actualDstAmount,
|
|
201
201
|
onTransactionSuccess,
|
|
202
202
|
oat?.data?.order.metadata.dstToken.decimals,
|
|
203
203
|
]);
|
|
@@ -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"];
|