@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
|
@@ -17,37 +17,37 @@ export function OrderHistory({ mode, onBack, onSelectOrder }: OrderHistoryProps)
|
|
|
17
17
|
|
|
18
18
|
return (
|
|
19
19
|
<>
|
|
20
|
-
<div className="mb-
|
|
21
|
-
<Button onClick={onBack} variant="ghost" size="icon">
|
|
22
|
-
<ArrowLeft className="h-
|
|
20
|
+
<div className="mb-8 flex w-full items-center gap-3">
|
|
21
|
+
<Button onClick={onBack} variant="ghost" size="icon" className="hover:bg-as-surface-secondary">
|
|
22
|
+
<ArrowLeft className="h-5 w-5" />
|
|
23
23
|
</Button>
|
|
24
24
|
<div className="flex-1">
|
|
25
|
-
<h3 className="text-
|
|
26
|
-
<p className="text-as-primary/30 text-sm">View your past transactions</p>
|
|
25
|
+
<h3 className="text-as-primary text-2xl font-bold">Order History</h3>
|
|
27
26
|
</div>
|
|
28
27
|
<Button
|
|
29
28
|
variant="ghost"
|
|
30
29
|
size="icon"
|
|
30
|
+
className="hover:bg-as-surface-secondary"
|
|
31
31
|
onClick={() => {
|
|
32
32
|
refetchOrderHistory();
|
|
33
33
|
}}
|
|
34
34
|
>
|
|
35
|
-
<RefreshCcw className="text-as-
|
|
35
|
+
<RefreshCcw className="text-as-secondary hover:text-as-primary h-5 w-5 cursor-pointer transition-all hover:rotate-180" />
|
|
36
36
|
</Button>
|
|
37
37
|
</div>
|
|
38
38
|
|
|
39
39
|
{isLoadingOrderHistory ? (
|
|
40
|
-
<div className="w-full space-y-
|
|
40
|
+
<div className="w-full space-y-3">
|
|
41
41
|
{[1, 2, 3].map(i => (
|
|
42
|
-
<Skeleton key={i} className="h-[
|
|
42
|
+
<Skeleton key={i} className="h-[180px] w-full rounded-2xl" />
|
|
43
43
|
))}
|
|
44
44
|
</div>
|
|
45
45
|
) : !orderHistory?.length ? (
|
|
46
|
-
<div className="bg-as-
|
|
47
|
-
<p className="text-
|
|
46
|
+
<div className="bg-as-surface-secondary w-full rounded-2xl p-12 text-center">
|
|
47
|
+
<p className="text-as-secondary text-sm">No order history found</p>
|
|
48
48
|
</div>
|
|
49
49
|
) : (
|
|
50
|
-
<div className="mb-12 w-full space-y-
|
|
50
|
+
<div className="mb-12 w-full space-y-3">
|
|
51
51
|
{[...orderHistory]
|
|
52
52
|
.sort((a, b) => b.createdAt - a.createdAt)
|
|
53
53
|
.map(order => (
|
|
@@ -2,6 +2,7 @@ import { ALL_CHAINS, getChainName, getStatusDisplay } from "@b3dotfun/sdk/anyspe
|
|
|
2
2
|
import { Badge, Button, useIsMobile } from "@b3dotfun/sdk/global-account/react";
|
|
3
3
|
import { cn } from "@b3dotfun/sdk/shared/utils";
|
|
4
4
|
import { formatTokenAmount } from "@b3dotfun/sdk/shared/utils/number";
|
|
5
|
+
import { getVendorDisplayName } from "@b3dotfun/sdk/shared/utils/payment.utils";
|
|
5
6
|
import { ArrowRight, ChevronDown } from "lucide-react";
|
|
6
7
|
import TimeAgo from "react-timeago";
|
|
7
8
|
import { b3 } from "viem/chains";
|
|
@@ -18,13 +19,7 @@ export function OrderHistoryItem({ order, onSelectOrder, mode }: OrderHistoryIte
|
|
|
18
19
|
const tournament =
|
|
19
20
|
order.type === "join_tournament" || order.type === "fund_tournament" ? order.metadata.tournament : undefined;
|
|
20
21
|
const dstToken = order.metadata.dstToken;
|
|
21
|
-
const actualDstAmount =
|
|
22
|
-
order.type === "mint_nft" ||
|
|
23
|
-
order.type === "join_tournament" ||
|
|
24
|
-
order.type === "fund_tournament" ||
|
|
25
|
-
order.type === "custom"
|
|
26
|
-
? undefined
|
|
27
|
-
: order.payload.actualDstAmount;
|
|
22
|
+
const actualDstAmount = order.settlement?.actualDstAmount;
|
|
28
23
|
const expectedDstAmount =
|
|
29
24
|
order.type === "mint_nft" ||
|
|
30
25
|
order.type === "join_tournament" ||
|
|
@@ -37,153 +32,126 @@ export function OrderHistoryItem({ order, onSelectOrder, mode }: OrderHistoryIte
|
|
|
37
32
|
|
|
38
33
|
const isSmallView = useIsMobile() || mode === "modal";
|
|
39
34
|
|
|
35
|
+
// Check if this is a one-click payment order
|
|
36
|
+
const isOneClickPayment = !!order.oneClickBuyUrl;
|
|
37
|
+
const vendorName = order.onrampMetadata?.vendor ? getVendorDisplayName(order.onrampMetadata.vendor) : null;
|
|
38
|
+
|
|
40
39
|
return (
|
|
41
40
|
<div
|
|
42
41
|
key={`anyspend-${order.id}`}
|
|
43
42
|
className={cn(
|
|
44
|
-
"bg-as-
|
|
45
|
-
onSelectOrder && "
|
|
43
|
+
"bg-as-surface-secondary hover:bg-as-surface-tertiary rounded-xl p-4 transition-all",
|
|
44
|
+
onSelectOrder && "cursor-pointer",
|
|
46
45
|
)}
|
|
47
46
|
onClick={() => onSelectOrder?.(order.id)}
|
|
48
47
|
>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
className={cn(
|
|
52
|
-
"px-3 py-1 text-xs",
|
|
53
|
-
orderDisplayStatus === "processing" && "bg-yellow-500/10 text-yellow-500",
|
|
54
|
-
orderDisplayStatus === "success" && "bg-green-500/10 text-green-500",
|
|
55
|
-
orderDisplayStatus === "failure" && "bg-red-500/10 text-red-500",
|
|
56
|
-
)}
|
|
57
|
-
>
|
|
58
|
-
{orderStatusText}
|
|
59
|
-
</Badge>
|
|
60
|
-
|
|
48
|
+
{/* Header: Status and Time */}
|
|
49
|
+
<div className="mb-3 flex items-center justify-between">
|
|
61
50
|
<div className="flex items-center gap-2">
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
51
|
+
<div
|
|
52
|
+
className={cn(
|
|
53
|
+
"text-xs font-semibold",
|
|
54
|
+
orderDisplayStatus === "processing" && "text-yellow-600",
|
|
55
|
+
orderDisplayStatus === "success" && "text-green-600",
|
|
56
|
+
orderDisplayStatus === "failure" && "text-red-600",
|
|
57
|
+
)}
|
|
58
|
+
>
|
|
59
|
+
{orderStatusText}
|
|
60
|
+
</div>
|
|
61
|
+
{isOneClickPayment && vendorName && (
|
|
62
|
+
<Badge variant="outline" className="text-as-secondary px-2 py-0.5 text-[10px]">
|
|
63
|
+
{vendorName}
|
|
64
|
+
</Badge>
|
|
65
|
+
)}
|
|
66
|
+
</div>
|
|
67
|
+
<div className="text-as-secondary text-[10px] font-medium uppercase tracking-wide">
|
|
68
|
+
<TimeAgo date={new Date(order.createdAt)} />
|
|
65
69
|
</div>
|
|
66
70
|
</div>
|
|
67
71
|
|
|
68
|
-
{
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
{nft ? (
|
|
82
|
-
<img src={nft.imageUrl} alt={nft.name} className="h-6 w-6" />
|
|
83
|
-
) : tournament ? (
|
|
84
|
-
<img src={tournament.imageUrl} alt={tournament.name} className="h-6 w-6" />
|
|
85
|
-
) : (
|
|
86
|
-
<img src={dstToken.metadata.logoURI} alt={dstToken.symbol} className="h-6 w-6" />
|
|
87
|
-
)}
|
|
88
|
-
{nft ? nft.name : tournament ? tournament.name : dstToken.symbol}
|
|
89
|
-
</span>
|
|
90
|
-
|
|
91
|
-
<span className="flex items-center gap-2">
|
|
92
|
-
{` on `}
|
|
93
|
-
<span className="text-as-primary flex items-center gap-2">
|
|
94
|
-
<img src={ALL_CHAINS[order.dstChain]?.logoUrl} alt={getChainName(order.dstChain)} className="h-4" />
|
|
95
|
-
{order.dstChain !== b3.id && getChainName(order.dstChain)}
|
|
96
|
-
</span>
|
|
97
|
-
</span>
|
|
98
|
-
</h3>
|
|
99
|
-
|
|
100
|
-
<p className="label-style text-as-primary/30 mt-1 flex items-center gap-2 text-xs">
|
|
101
|
-
Paying via{" "}
|
|
102
|
-
<img src="https://cdn.b3.fun/coinbase-wordmark-blue.svg" alt="Coinbase" className="-mt-1 h-3" />
|
|
103
|
-
</p>
|
|
104
|
-
</div>
|
|
105
|
-
</div>
|
|
106
|
-
) : (
|
|
107
|
-
<div className={cn("mb-3 mt-4 flex items-center gap-1", isSmallView && "flex-col")}>
|
|
108
|
-
<div className="bg-b3-react-background flex w-full flex-1 flex-col gap-1 overflow-hidden rounded-lg border p-4 px-5">
|
|
109
|
-
<div className="flex items-center gap-2">
|
|
110
|
-
<img
|
|
111
|
-
src={order.metadata.srcToken.metadata.logoURI}
|
|
112
|
-
alt={order.metadata.srcToken.symbol}
|
|
113
|
-
className="h-6 w-6 rounded-full"
|
|
114
|
-
/>
|
|
115
|
-
<div className="text-as-primary flex items-center gap-2 overflow-hidden text-ellipsis whitespace-nowrap text-xl font-semibold">
|
|
116
|
-
{formatTokenAmount(BigInt(order.srcAmount), order.metadata.srcToken.decimals)}{" "}
|
|
117
|
-
{order.metadata.srcToken.symbol}
|
|
118
|
-
</div>
|
|
72
|
+
{/* Main Content: From -> To */}
|
|
73
|
+
<div className="flex items-center gap-4">
|
|
74
|
+
{/* From Section */}
|
|
75
|
+
<div className="flex min-w-0 flex-1 items-center gap-2">
|
|
76
|
+
<img
|
|
77
|
+
src={order.metadata.srcToken.metadata.logoURI}
|
|
78
|
+
alt={order.metadata.srcToken.symbol}
|
|
79
|
+
className="h-8 w-8 shrink-0 rounded-full"
|
|
80
|
+
/>
|
|
81
|
+
<div className="min-w-0 flex-1">
|
|
82
|
+
<div className="text-as-primary truncate text-sm font-bold">
|
|
83
|
+
{formatTokenAmount(BigInt(order.srcAmount), order.metadata.srcToken.decimals)}{" "}
|
|
84
|
+
{order.metadata.srcToken.symbol}
|
|
119
85
|
</div>
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
<img
|
|
124
|
-
src={ALL_CHAINS[order.srcChain]?.logoUrl}
|
|
125
|
-
alt={getChainName(order.srcChain)}
|
|
126
|
-
className={cn("h-4", order.srcChain !== b3.id && "w-4 rounded-full", order.srcChain === b3.id && "h-3")}
|
|
127
|
-
/>
|
|
128
|
-
{getChainName(order.srcChain)}
|
|
86
|
+
<div className="text-as-secondary flex items-center gap-1 text-xs">
|
|
87
|
+
<img src={ALL_CHAINS[order.srcChain]?.logoUrl} alt={getChainName(order.srcChain)} className="h-3 w-3" />
|
|
88
|
+
<span className="truncate">{getChainName(order.srcChain)}</span>
|
|
129
89
|
</div>
|
|
130
90
|
</div>
|
|
91
|
+
</div>
|
|
131
92
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
</div>
|
|
93
|
+
{/* Arrow */}
|
|
94
|
+
<ArrowRight className="text-as-secondary h-5 w-5 shrink-0 opacity-30" />
|
|
135
95
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
<
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
96
|
+
{/* To Section */}
|
|
97
|
+
<div className="flex min-w-0 flex-1 items-center gap-2">
|
|
98
|
+
{nft ? (
|
|
99
|
+
<>
|
|
100
|
+
<img src={nft.imageUrl} alt={nft.name} className="h-8 w-8 shrink-0 rounded-full" />
|
|
101
|
+
<div className="min-w-0 flex-1">
|
|
102
|
+
<div className="text-as-primary truncate text-sm font-bold">{nft.name}</div>
|
|
103
|
+
<div className="text-as-secondary flex items-center gap-1 text-xs">
|
|
104
|
+
<img
|
|
105
|
+
src={ALL_CHAINS[order.dstChain]?.logoUrl}
|
|
106
|
+
alt={getChainName(order.dstChain)}
|
|
107
|
+
className="h-3 w-3"
|
|
108
|
+
/>
|
|
109
|
+
<span className="truncate">{getChainName(order.dstChain)}</span>
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
</>
|
|
113
|
+
) : tournament ? (
|
|
114
|
+
<>
|
|
115
|
+
<img src={tournament.imageUrl} alt={tournament.name} className="h-8 w-8 shrink-0 rounded-full" />
|
|
116
|
+
<div className="min-w-0 flex-1">
|
|
117
|
+
<div className="text-as-primary truncate text-sm font-bold">{tournament.name}</div>
|
|
118
|
+
<div className="text-as-secondary flex items-center gap-1 text-xs">
|
|
119
|
+
<img
|
|
120
|
+
src={ALL_CHAINS[order.dstChain]?.logoUrl}
|
|
121
|
+
alt={getChainName(order.dstChain)}
|
|
122
|
+
className="h-3 w-3"
|
|
123
|
+
/>
|
|
124
|
+
<span className="truncate">{getChainName(order.dstChain)}</span>
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
</>
|
|
128
|
+
) : (
|
|
129
|
+
<>
|
|
130
|
+
<img src={dstToken.metadata.logoURI} alt={dstToken.symbol} className="h-8 w-8 shrink-0 rounded-full" />
|
|
131
|
+
<div className="min-w-0 flex-1">
|
|
132
|
+
<div className="text-as-primary truncate text-sm font-bold">
|
|
133
|
+
{formatTokenAmount(
|
|
134
|
+
actualDstAmount
|
|
135
|
+
? BigInt(actualDstAmount)
|
|
136
|
+
: expectedDstAmount
|
|
137
|
+
? BigInt(expectedDstAmount)
|
|
138
|
+
: BigInt(0),
|
|
139
|
+
dstToken.decimals,
|
|
140
|
+
)}{" "}
|
|
141
|
+
{dstToken.symbol}
|
|
142
|
+
</div>
|
|
143
|
+
<div className="text-as-secondary flex items-center gap-1 text-xs">
|
|
144
|
+
<img
|
|
145
|
+
src={ALL_CHAINS[order.dstChain]?.logoUrl}
|
|
146
|
+
alt={getChainName(order.dstChain)}
|
|
147
|
+
className="h-3 w-3"
|
|
148
|
+
/>
|
|
149
|
+
<span className="truncate">{getChainName(order.dstChain)}</span>
|
|
150
|
+
</div>
|
|
151
|
+
</div>
|
|
152
|
+
</>
|
|
153
|
+
)}
|
|
179
154
|
</div>
|
|
180
|
-
)}
|
|
181
|
-
|
|
182
|
-
<div className="flex items-center justify-end">
|
|
183
|
-
<Button variant="link" size="sm" className="h-auto" onClick={() => onSelectOrder?.(order.id)}>
|
|
184
|
-
{orderDisplayStatus === "processing" ? "Proceed with payment" : "Details"}{" "}
|
|
185
|
-
<ArrowRight className="ml-2 h-3 w-3" />
|
|
186
|
-
</Button>
|
|
187
155
|
</div>
|
|
188
156
|
</div>
|
|
189
157
|
);
|
|
@@ -247,8 +247,8 @@ export function useAnyspendFlow({
|
|
|
247
247
|
// Handle order completion
|
|
248
248
|
useEffect(() => {
|
|
249
249
|
if (oat?.data?.order.status === "executed") {
|
|
250
|
-
// get the actualDstAmount if available from
|
|
251
|
-
const amount =
|
|
250
|
+
// get the actualDstAmount if available from settlement
|
|
251
|
+
const amount = oat.data.order.settlement?.actualDstAmount;
|
|
252
252
|
const formattedActualDstAmount = amount
|
|
253
253
|
? formatTokenAmount(BigInt(amount), oat.data.order.metadata.dstToken.decimals)
|
|
254
254
|
: undefined;
|
|
@@ -256,7 +256,7 @@ export function useAnyspendFlow({
|
|
|
256
256
|
}
|
|
257
257
|
}, [
|
|
258
258
|
oat?.data?.order.status,
|
|
259
|
-
oat?.data?.order.
|
|
259
|
+
oat?.data?.order.settlement?.actualDstAmount,
|
|
260
260
|
onTransactionSuccess,
|
|
261
261
|
oat?.data?.order.metadata.dstToken.decimals,
|
|
262
262
|
]);
|