@b3dotfun/sdk 0.0.44-alpha.1 → 0.0.44-alpha.3
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 +13 -14
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +14 -15
- package/dist/cjs/anyspend/react/components/common/OrderHistory.js +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderHistoryItem.js +6 -3
- package/dist/cjs/anyspend/types/api.d.ts +176 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +14 -15
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +15 -16
- package/dist/esm/anyspend/react/components/common/OrderHistory.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderHistoryItem.js +8 -5
- package/dist/esm/anyspend/types/api.d.ts +176 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/types/api.d.ts +176 -0
- package/package.json +2 -1
- package/src/anyspend/react/components/AnySpend.tsx +21 -19
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +21 -21
- package/src/anyspend/react/components/common/OrderHistory.tsx +11 -11
- package/src/anyspend/react/components/common/OrderHistoryItem.tsx +124 -129
- package/src/anyspend/types/api.ts +176 -0
- 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 => (
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ALL_CHAINS, getChainName, getStatusDisplay } from "@b3dotfun/sdk/anyspend";
|
|
2
|
-
import { Badge,
|
|
2
|
+
import { Badge, 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 {
|
|
5
|
+
import { getVendorDisplayName } from "@b3dotfun/sdk/shared/utils/payment.utils";
|
|
6
|
+
import { ArrowRight } from "lucide-react";
|
|
6
7
|
import TimeAgo from "react-timeago";
|
|
7
|
-
import { b3 } from "viem/chains";
|
|
8
8
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
9
9
|
|
|
10
10
|
interface OrderHistoryItemProps {
|
|
@@ -31,153 +31,148 @@ export function OrderHistoryItem({ order, onSelectOrder, mode }: OrderHistoryIte
|
|
|
31
31
|
|
|
32
32
|
const isSmallView = useIsMobile() || mode === "modal";
|
|
33
33
|
|
|
34
|
+
// Check if this is a one-click payment order
|
|
35
|
+
const isOneClickPayment = !!order.oneClickBuyUrl;
|
|
36
|
+
const vendorName = order.onrampMetadata?.vendor ? getVendorDisplayName(order.onrampMetadata.vendor) : null;
|
|
37
|
+
|
|
34
38
|
return (
|
|
35
39
|
<div
|
|
36
40
|
key={`anyspend-${order.id}`}
|
|
37
41
|
className={cn(
|
|
38
|
-
"bg-as-
|
|
39
|
-
onSelectOrder && "
|
|
42
|
+
"bg-as-surface-secondary hover:bg-as-surface-tertiary rounded-xl p-4 transition-all",
|
|
43
|
+
onSelectOrder && "cursor-pointer",
|
|
40
44
|
)}
|
|
41
45
|
onClick={() => onSelectOrder?.(order.id)}
|
|
42
46
|
>
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
className={cn(
|
|
46
|
-
"px-3 py-1 text-xs",
|
|
47
|
-
orderDisplayStatus === "processing" && "bg-yellow-500/10 text-yellow-500",
|
|
48
|
-
orderDisplayStatus === "success" && "bg-green-500/10 text-green-500",
|
|
49
|
-
orderDisplayStatus === "failure" && "bg-red-500/10 text-red-500",
|
|
50
|
-
)}
|
|
51
|
-
>
|
|
52
|
-
{orderStatusText}
|
|
53
|
-
</Badge>
|
|
54
|
-
|
|
47
|
+
{/* Header: Status and Time */}
|
|
48
|
+
<div className="mb-3 flex items-center justify-between">
|
|
55
49
|
<div className="flex items-center gap-2">
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
<div
|
|
51
|
+
className={cn(
|
|
52
|
+
"text-xs font-semibold",
|
|
53
|
+
orderDisplayStatus === "processing" && "text-yellow-600",
|
|
54
|
+
orderDisplayStatus === "success" && "text-green-600",
|
|
55
|
+
orderDisplayStatus === "failure" && "text-red-600",
|
|
56
|
+
)}
|
|
57
|
+
>
|
|
58
|
+
{orderStatusText}
|
|
59
|
+
</div>
|
|
60
|
+
{isOneClickPayment && vendorName && (
|
|
61
|
+
<Badge variant="outline" className="text-as-secondary px-2 py-0.5 text-[10px]">
|
|
62
|
+
{vendorName}
|
|
63
|
+
</Badge>
|
|
64
|
+
)}
|
|
65
|
+
</div>
|
|
66
|
+
<div className="text-as-secondary text-[10px] font-medium uppercase tracking-wide">
|
|
67
|
+
<TimeAgo date={new Date(order.createdAt)} />
|
|
59
68
|
</div>
|
|
60
69
|
</div>
|
|
61
70
|
|
|
62
|
-
{
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
<img src={dstToken.metadata.logoURI} alt={dstToken.symbol} className="h-6 w-6" />
|
|
81
|
-
)}
|
|
82
|
-
{nft ? nft.name : tournament ? tournament.name : dstToken.symbol}
|
|
83
|
-
</span>
|
|
84
|
-
|
|
85
|
-
<span className="flex items-center gap-2">
|
|
86
|
-
{` on `}
|
|
87
|
-
<span className="text-as-primary flex items-center gap-2">
|
|
88
|
-
<img src={ALL_CHAINS[order.dstChain]?.logoUrl} alt={getChainName(order.dstChain)} className="h-4" />
|
|
89
|
-
{order.dstChain !== b3.id && getChainName(order.dstChain)}
|
|
90
|
-
</span>
|
|
91
|
-
</span>
|
|
92
|
-
</h3>
|
|
93
|
-
|
|
94
|
-
<p className="label-style text-as-primary/30 mt-1 flex items-center gap-2 text-xs">
|
|
95
|
-
Paying via{" "}
|
|
96
|
-
<img src="https://cdn.b3.fun/coinbase-wordmark-blue.svg" alt="Coinbase" className="-mt-1 h-3" />
|
|
97
|
-
</p>
|
|
71
|
+
{/* Main Content: From -> To */}
|
|
72
|
+
<div className={cn("flex items-center", isSmallView ? "gap-2" : "gap-4")}>
|
|
73
|
+
{/* From Section */}
|
|
74
|
+
<div className={cn("flex min-w-0 flex-1 items-center", isSmallView ? "gap-1.5" : "gap-2")}>
|
|
75
|
+
<img
|
|
76
|
+
src={order.metadata.srcToken.metadata.logoURI}
|
|
77
|
+
alt={order.metadata.srcToken.symbol}
|
|
78
|
+
className={cn("shrink-0 rounded-full", isSmallView ? "h-7 w-7" : "h-8 w-8")}
|
|
79
|
+
/>
|
|
80
|
+
<div className="min-w-0 flex-1">
|
|
81
|
+
<div className={cn("text-as-primary truncate font-bold", isSmallView ? "text-xs" : "text-sm")}>
|
|
82
|
+
{formatTokenAmount(BigInt(order.srcAmount), order.metadata.srcToken.decimals)}{" "}
|
|
83
|
+
{order.metadata.srcToken.symbol}
|
|
84
|
+
</div>
|
|
85
|
+
<div className={cn("text-as-secondary flex items-center gap-1", isSmallView ? "text-[10px]" : "text-xs")}>
|
|
86
|
+
<img src={ALL_CHAINS[order.srcChain]?.logoUrl} alt={getChainName(order.srcChain)} className="h-3 w-3" />
|
|
87
|
+
<span className="truncate">{getChainName(order.srcChain)}</span>
|
|
88
|
+
</div>
|
|
98
89
|
</div>
|
|
99
90
|
</div>
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
91
|
+
|
|
92
|
+
{/* Arrow */}
|
|
93
|
+
<ArrowRight className={cn("text-as-secondary shrink-0 opacity-30", isSmallView ? "h-4 w-4" : "h-5 w-5")} />
|
|
94
|
+
|
|
95
|
+
{/* To Section */}
|
|
96
|
+
<div className={cn("flex min-w-0 flex-1 items-center", isSmallView ? "gap-1.5" : "gap-2")}>
|
|
97
|
+
{nft ? (
|
|
98
|
+
<>
|
|
104
99
|
<img
|
|
105
|
-
src={
|
|
106
|
-
alt={
|
|
107
|
-
className="h-
|
|
100
|
+
src={nft.imageUrl}
|
|
101
|
+
alt={nft.name}
|
|
102
|
+
className={cn("shrink-0 rounded-full", isSmallView ? "h-7 w-7" : "h-8 w-8")}
|
|
108
103
|
/>
|
|
109
|
-
<div className="
|
|
110
|
-
{
|
|
111
|
-
|
|
104
|
+
<div className="min-w-0 flex-1">
|
|
105
|
+
<div className={cn("text-as-primary truncate font-bold", isSmallView ? "text-xs" : "text-sm")}>
|
|
106
|
+
{nft.name}
|
|
107
|
+
</div>
|
|
108
|
+
<div
|
|
109
|
+
className={cn("text-as-secondary flex items-center gap-1", isSmallView ? "text-[10px]" : "text-xs")}
|
|
110
|
+
>
|
|
111
|
+
<img
|
|
112
|
+
src={ALL_CHAINS[order.dstChain]?.logoUrl}
|
|
113
|
+
alt={getChainName(order.dstChain)}
|
|
114
|
+
className="h-3 w-3"
|
|
115
|
+
/>
|
|
116
|
+
<span className="truncate">{getChainName(order.dstChain)}</span>
|
|
117
|
+
</div>
|
|
112
118
|
</div>
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
from
|
|
119
|
+
</>
|
|
120
|
+
) : tournament ? (
|
|
121
|
+
<>
|
|
117
122
|
<img
|
|
118
|
-
src={
|
|
119
|
-
alt={
|
|
120
|
-
className={cn("
|
|
123
|
+
src={tournament.imageUrl}
|
|
124
|
+
alt={tournament.name}
|
|
125
|
+
className={cn("shrink-0 rounded-full", isSmallView ? "h-7 w-7" : "h-8 w-8")}
|
|
121
126
|
/>
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
<
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
<>
|
|
141
|
-
<img src={tournament.imageUrl} alt={tournament.name} className="h-6 w-6 rounded-full" />
|
|
142
|
-
<div className="text-as-primary overflow-hidden text-ellipsis whitespace-nowrap text-xl font-semibold">
|
|
143
|
-
{tournament.name}
|
|
144
|
-
</div>
|
|
145
|
-
</>
|
|
146
|
-
) : (
|
|
147
|
-
<>
|
|
148
|
-
<img src={dstToken.metadata.logoURI} alt={dstToken.symbol} className="h-6 w-6 rounded-full" />
|
|
149
|
-
<div className="text-as-primary overflow-hidden text-ellipsis whitespace-nowrap text-xl font-semibold">
|
|
150
|
-
{formatTokenAmount(
|
|
151
|
-
actualDstAmount
|
|
152
|
-
? BigInt(actualDstAmount)
|
|
153
|
-
: expectedDstAmount
|
|
154
|
-
? BigInt(expectedDstAmount)
|
|
155
|
-
: BigInt(0),
|
|
156
|
-
dstToken.decimals,
|
|
157
|
-
)}{" "}
|
|
158
|
-
{dstToken.symbol}
|
|
159
|
-
</div>
|
|
160
|
-
</>
|
|
161
|
-
)}
|
|
162
|
-
</div>
|
|
163
|
-
<div className="label-style text-as-primary/50 flex items-center gap-2 text-sm">
|
|
164
|
-
to
|
|
127
|
+
<div className="min-w-0 flex-1">
|
|
128
|
+
<div className={cn("text-as-primary truncate font-bold", isSmallView ? "text-xs" : "text-sm")}>
|
|
129
|
+
{tournament.name}
|
|
130
|
+
</div>
|
|
131
|
+
<div
|
|
132
|
+
className={cn("text-as-secondary flex items-center gap-1", isSmallView ? "text-[10px]" : "text-xs")}
|
|
133
|
+
>
|
|
134
|
+
<img
|
|
135
|
+
src={ALL_CHAINS[order.dstChain]?.logoUrl}
|
|
136
|
+
alt={getChainName(order.dstChain)}
|
|
137
|
+
className="h-3 w-3"
|
|
138
|
+
/>
|
|
139
|
+
<span className="truncate">{getChainName(order.dstChain)}</span>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
</>
|
|
143
|
+
) : (
|
|
144
|
+
<>
|
|
165
145
|
<img
|
|
166
|
-
src={
|
|
167
|
-
alt={
|
|
168
|
-
className={cn("
|
|
146
|
+
src={dstToken.metadata.logoURI}
|
|
147
|
+
alt={dstToken.symbol}
|
|
148
|
+
className={cn("shrink-0 rounded-full", isSmallView ? "h-7 w-7" : "h-8 w-8")}
|
|
169
149
|
/>
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
150
|
+
<div className="min-w-0 flex-1">
|
|
151
|
+
<div className={cn("text-as-primary truncate font-bold", isSmallView ? "text-xs" : "text-sm")}>
|
|
152
|
+
{formatTokenAmount(
|
|
153
|
+
actualDstAmount
|
|
154
|
+
? BigInt(actualDstAmount)
|
|
155
|
+
: expectedDstAmount
|
|
156
|
+
? BigInt(expectedDstAmount)
|
|
157
|
+
: BigInt(0),
|
|
158
|
+
dstToken.decimals,
|
|
159
|
+
)}{" "}
|
|
160
|
+
{dstToken.symbol}
|
|
161
|
+
</div>
|
|
162
|
+
<div
|
|
163
|
+
className={cn("text-as-secondary flex items-center gap-1", isSmallView ? "text-[10px]" : "text-xs")}
|
|
164
|
+
>
|
|
165
|
+
<img
|
|
166
|
+
src={ALL_CHAINS[order.dstChain]?.logoUrl}
|
|
167
|
+
alt={getChainName(order.dstChain)}
|
|
168
|
+
className="h-3 w-3"
|
|
169
|
+
/>
|
|
170
|
+
<span className="truncate">{getChainName(order.dstChain)}</span>
|
|
171
|
+
</div>
|
|
172
|
+
</div>
|
|
173
|
+
</>
|
|
174
|
+
)}
|
|
173
175
|
</div>
|
|
174
|
-
)}
|
|
175
|
-
|
|
176
|
-
<div className="flex items-center justify-end">
|
|
177
|
-
<Button variant="link" size="sm" className="h-auto" onClick={() => onSelectOrder?.(order.id)}>
|
|
178
|
-
{orderDisplayStatus === "processing" ? "Proceed with payment" : "Details"}{" "}
|
|
179
|
-
<ArrowRight className="ml-2 h-3 w-3" />
|
|
180
|
-
</Button>
|
|
181
176
|
</div>
|
|
182
177
|
</div>
|
|
183
178
|
);
|