@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.
Files changed (24) hide show
  1. package/dist/cjs/anyspend/react/components/AnySpend.js +13 -14
  2. package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +14 -15
  3. package/dist/cjs/anyspend/react/components/common/OrderHistory.js +2 -2
  4. package/dist/cjs/anyspend/react/components/common/OrderHistoryItem.js +6 -3
  5. package/dist/cjs/anyspend/types/api.d.ts +176 -0
  6. package/dist/esm/anyspend/react/components/AnySpend.js +14 -15
  7. package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +15 -16
  8. package/dist/esm/anyspend/react/components/common/OrderHistory.js +2 -2
  9. package/dist/esm/anyspend/react/components/common/OrderHistoryItem.js +8 -5
  10. package/dist/esm/anyspend/types/api.d.ts +176 -0
  11. package/dist/styles/index.css +1 -1
  12. package/dist/types/anyspend/types/api.d.ts +176 -0
  13. package/package.json +2 -1
  14. package/src/anyspend/react/components/AnySpend.tsx +21 -19
  15. package/src/anyspend/react/components/AnyspendDepositHype.tsx +21 -21
  16. package/src/anyspend/react/components/common/OrderHistory.tsx +11 -11
  17. package/src/anyspend/react/components/common/OrderHistoryItem.tsx +124 -129
  18. package/src/anyspend/types/api.ts +176 -0
  19. package/dist/cjs/anyspend/react/components/common/ErrorSection.d.ts +0 -6
  20. package/dist/cjs/anyspend/react/components/common/ErrorSection.js +0 -12
  21. package/dist/esm/anyspend/react/components/common/ErrorSection.d.ts +0 -6
  22. package/dist/esm/anyspend/react/components/common/ErrorSection.js +0 -9
  23. package/dist/types/anyspend/react/components/common/ErrorSection.d.ts +0 -6
  24. 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-6 flex w-full items-center gap-4">
21
- <Button onClick={onBack} variant="ghost" size="icon">
22
- <ArrowLeft className="h-4 w-4" />
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-xl font-semibold">Order History</h3>
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-primary/30 hover:text-as-primary h-4 w-4 cursor-pointer transition-all hover:rotate-180" />
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-4">
40
+ <div className="w-full space-y-3">
41
41
  {[1, 2, 3].map(i => (
42
- <Skeleton key={i} className="h-[160px] w-full rounded-lg" />
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-light-brand w-full rounded-lg border p-8 text-center">
47
- <p className="text-b3-react-muted-foreground">No order history found</p>
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-4">
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, Button, useIsMobile } from "@b3dotfun/sdk/global-account/react";
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 { ArrowRight, ChevronDown } from "lucide-react";
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-light-brand/20 rounded-lg border p-4",
39
- onSelectOrder && "hover:bg-as-light-brand/30 hover:border-as-brand cursor-pointer transition-colors",
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
- <div className="flex items-center justify-between">
44
- <Badge
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
- <span className="text-nano label-style text-as-primary/30">
57
- <TimeAgo date={new Date(order.createdAt)} />
58
- </span>
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
- {order.oneClickBuyUrl ? (
63
- <div className="mb-3 mt-4 flex items-center gap-1">
64
- <div className="bg-b3-react-background flex flex-1 flex-col gap-1 rounded-lg border p-4 px-5">
65
- <h3 className="text-as-primary/50 flex items-center gap-2 text-xl font-semibold">
66
- <span>
67
- {"Buy "}
68
- <span className="text-as-primary">
69
- ${formatTokenAmount(BigInt(order.srcAmount), order.metadata.srcToken.decimals)}
70
- </span>
71
- {` of`}
72
- </span>
73
-
74
- <span className="text-as-primary flex items-center gap-2">
75
- {nft ? (
76
- <img src={nft.imageUrl} alt={nft.name} className="h-6 w-6" />
77
- ) : tournament ? (
78
- <img src={tournament.imageUrl} alt={tournament.name} className="h-6 w-6" />
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
- <div className={cn("mb-3 mt-4 flex items-center gap-1", isSmallView && "flex-col")}>
102
- <div className="bg-b3-react-background flex w-full flex-1 flex-col gap-1 overflow-hidden rounded-lg border p-4 px-5">
103
- <div className="flex items-center gap-2">
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={order.metadata.srcToken.metadata.logoURI}
106
- alt={order.metadata.srcToken.symbol}
107
- className="h-6 w-6 rounded-full"
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="text-as-primary flex items-center gap-2 overflow-hidden text-ellipsis whitespace-nowrap text-xl font-semibold">
110
- {formatTokenAmount(BigInt(order.srcAmount), order.metadata.srcToken.decimals)}{" "}
111
- {order.metadata.srcToken.symbol}
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
- </div>
114
-
115
- <div className="label-style text-as-primary/50 flex items-center gap-2 text-sm">
116
- from
119
+ </>
120
+ ) : tournament ? (
121
+ <>
117
122
  <img
118
- src={ALL_CHAINS[order.srcChain]?.logoUrl}
119
- alt={getChainName(order.srcChain)}
120
- className={cn("h-4", order.srcChain !== b3.id && "w-4 rounded-full", order.srcChain === b3.id && "h-3")}
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
- {getChainName(order.srcChain)}
123
- </div>
124
- </div>
125
-
126
- <div className={cn("h-8 w-8 shrink-0 -rotate-90 opacity-30", isSmallView && "rotate-0")}>
127
- <ChevronDown className="h-8 w-8" />
128
- </div>
129
-
130
- <div className="bg-b3-react-background flex w-full flex-1 flex-col gap-1 overflow-hidden rounded-lg border p-4 px-5">
131
- <div className="flex items-center gap-2">
132
- {nft ? (
133
- <>
134
- <img src={nft.imageUrl} alt={nft.name} className="h-6 w-6 rounded-full" />
135
- <div className="text-as-primary overflow-hidden text-ellipsis whitespace-nowrap text-xl font-semibold">
136
- {nft.name}
137
- </div>
138
- </>
139
- ) : tournament ? (
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={ALL_CHAINS[order.dstChain]?.logoUrl}
167
- alt={getChainName(order.dstChain)}
168
- className={cn("h-4", order.dstChain !== b3.id && "w-4 rounded-full", order.dstChain === b3.id && "h-3")}
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
- {getChainName(order.dstChain)}
171
- </div>
172
- </div>
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
  );