@ensofinance/checkout-widget 0.1.8 → 1.0.1
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/checkout-widget.es.js +7287 -7299
- package/dist/checkout-widget.es.js.map +1 -1
- package/dist/checkout-widget.umd.js +48 -48
- package/dist/checkout-widget.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/steps/CardBuyFlow/CardBuyFlow.tsx +11 -3
- package/src/components/steps/CardBuyFlow/ChooseAmountStep.tsx +170 -179
- package/src/components/steps/CardBuyFlow/OpenWidgetStep.tsx +1 -5
- package/src/components/steps/ExchangeFlow.tsx +6 -6
- package/src/components/steps/FlowSelector.tsx +1 -1
- package/src/components/steps/WalletFlow/WalletConfirmStep.tsx +1 -1
- package/src/components/steps/shared/TrackUserOpStep.tsx +40 -15
- package/src/enso-api/custom-instance.ts +5 -1
- package/src/util/meld-hooks.tsx +0 -39
|
@@ -45,15 +45,15 @@ const PhaseIndicator = ({
|
|
|
45
45
|
borderRadius="full"
|
|
46
46
|
bg={
|
|
47
47
|
index < currentPhase
|
|
48
|
-
? "
|
|
48
|
+
? "success"
|
|
49
49
|
: index === currentPhase
|
|
50
|
-
? "
|
|
51
|
-
: "
|
|
50
|
+
? "primary"
|
|
51
|
+
: "border"
|
|
52
52
|
}
|
|
53
53
|
display="flex"
|
|
54
54
|
alignItems="center"
|
|
55
55
|
justifyContent="center"
|
|
56
|
-
color="
|
|
56
|
+
color="bg"
|
|
57
57
|
fontSize="xs"
|
|
58
58
|
fontWeight="bold"
|
|
59
59
|
>
|
|
@@ -83,6 +83,7 @@ const TrackUserOpStep = ({
|
|
|
83
83
|
}: Props) => {
|
|
84
84
|
const { chainIdIn, chainIdOut, tokenInData } = useAppDetails();
|
|
85
85
|
const amountIn = useAppStore((s) => s.amountIn);
|
|
86
|
+
const ensoApiToken = useAppStore((s) => s.ensoApiToken);
|
|
86
87
|
|
|
87
88
|
const isCrosschain = useMemo(
|
|
88
89
|
() => !!chainIdIn && !!chainIdOut && chainIdIn !== chainIdOut,
|
|
@@ -128,6 +129,7 @@ const TrackUserOpStep = ({
|
|
|
128
129
|
method: "POST",
|
|
129
130
|
headers: {
|
|
130
131
|
"Content-Type": "application/json",
|
|
132
|
+
Authorization: `Bearer ${ensoApiToken}`,
|
|
131
133
|
},
|
|
132
134
|
body: JSON.stringify({
|
|
133
135
|
userOperationData: {
|
|
@@ -137,10 +139,12 @@ const TrackUserOpStep = ({
|
|
|
137
139
|
factoryData: userOp.factoryData,
|
|
138
140
|
callData: userOp.callData,
|
|
139
141
|
callGasLimit: userOp.callGasLimit,
|
|
140
|
-
verificationGasLimit:
|
|
142
|
+
verificationGasLimit:
|
|
143
|
+
userOp.verificationGasLimit,
|
|
141
144
|
preVerificationGas: userOp.preVerificationGas,
|
|
142
145
|
maxFeePerGas: userOp.maxFeePerGas,
|
|
143
|
-
maxPriorityFeePerGas:
|
|
146
|
+
maxPriorityFeePerGas:
|
|
147
|
+
userOp.maxPriorityFeePerGas,
|
|
144
148
|
paymaster: userOp.paymaster,
|
|
145
149
|
paymasterData: userOp.paymasterData,
|
|
146
150
|
paymasterVerificationGasLimit:
|
|
@@ -182,7 +186,16 @@ const TrackUserOpStep = ({
|
|
|
182
186
|
};
|
|
183
187
|
|
|
184
188
|
sendUserOpToTracker();
|
|
185
|
-
}, [
|
|
189
|
+
}, [
|
|
190
|
+
amountIn,
|
|
191
|
+
ensoApiToken,
|
|
192
|
+
chainIdIn,
|
|
193
|
+
isCrosschain,
|
|
194
|
+
pendingMessage,
|
|
195
|
+
status,
|
|
196
|
+
tokenInData,
|
|
197
|
+
userOp,
|
|
198
|
+
]);
|
|
186
199
|
|
|
187
200
|
// Track operation status
|
|
188
201
|
useEffect(() => {
|
|
@@ -218,7 +231,9 @@ const TrackUserOpStep = ({
|
|
|
218
231
|
setPhase("completed");
|
|
219
232
|
}
|
|
220
233
|
} else if (
|
|
221
|
-
["failed", "failed_permanent"].includes(
|
|
234
|
+
["failed", "failed_permanent"].includes(
|
|
235
|
+
data.operation?.status,
|
|
236
|
+
)
|
|
222
237
|
) {
|
|
223
238
|
setStatus("failed");
|
|
224
239
|
setMessage(
|
|
@@ -248,7 +263,12 @@ const TrackUserOpStep = ({
|
|
|
248
263
|
}
|
|
249
264
|
|
|
250
265
|
// When LayerZero shows DELIVERED, verify destination execution with Enso API
|
|
251
|
-
if (
|
|
266
|
+
if (
|
|
267
|
+
lzStatus.isComplete &&
|
|
268
|
+
!destinationVerified &&
|
|
269
|
+
txHash &&
|
|
270
|
+
chainIdIn
|
|
271
|
+
) {
|
|
252
272
|
const verifyDestination = async () => {
|
|
253
273
|
try {
|
|
254
274
|
const res = await fetch(
|
|
@@ -445,15 +465,20 @@ const TrackUserOpStep = ({
|
|
|
445
465
|
color="fg.muted"
|
|
446
466
|
maxWidth="280px"
|
|
447
467
|
>
|
|
448
|
-
Your operation is being processed – no
|
|
449
|
-
required from you.
|
|
468
|
+
Your operation is being processed – no
|
|
469
|
+
action is required from you.
|
|
450
470
|
</Text>
|
|
451
471
|
)}
|
|
452
472
|
</Box>
|
|
453
473
|
</Box>
|
|
454
474
|
|
|
455
475
|
{/* Status Table */}
|
|
456
|
-
<Table.Root
|
|
476
|
+
<Table.Root
|
|
477
|
+
key="status"
|
|
478
|
+
size="sm"
|
|
479
|
+
variant="outline"
|
|
480
|
+
width="100%"
|
|
481
|
+
>
|
|
457
482
|
<Table.Body>
|
|
458
483
|
<Table.Row>
|
|
459
484
|
<Table.Cell>Status</Table.Cell>
|
|
@@ -537,7 +562,7 @@ const TrackUserOpStep = ({
|
|
|
537
562
|
>
|
|
538
563
|
<Text
|
|
539
564
|
fontSize="sm"
|
|
540
|
-
color="
|
|
565
|
+
color="primary"
|
|
541
566
|
cursor="pointer"
|
|
542
567
|
onClick={() =>
|
|
543
568
|
window.open(
|
|
@@ -561,7 +586,7 @@ const TrackUserOpStep = ({
|
|
|
561
586
|
>
|
|
562
587
|
<Text
|
|
563
588
|
fontSize="sm"
|
|
564
|
-
color="
|
|
589
|
+
color="primary"
|
|
565
590
|
cursor="pointer"
|
|
566
591
|
onClick={() => {
|
|
567
592
|
const explorer =
|
|
@@ -599,7 +624,7 @@ const TrackUserOpStep = ({
|
|
|
599
624
|
textAlign="end"
|
|
600
625
|
justifyContent="end"
|
|
601
626
|
>
|
|
602
|
-
<Text fontSize="sm" color="
|
|
627
|
+
<Text fontSize="sm" color="warning">
|
|
603
628
|
Funds refunded to smart account
|
|
604
629
|
</Text>
|
|
605
630
|
</Table.Cell>
|
|
@@ -21,7 +21,11 @@ export const useCustomClient = <T>(): CustomClient<T> => {
|
|
|
21
21
|
// const response = await fetch(url.replace("https://api.enso.build", "http://localhost:3000") + "?" + new URLSearchParams(params), {
|
|
22
22
|
const response = await fetch(url + "?" + new URLSearchParams(params), {
|
|
23
23
|
method,
|
|
24
|
-
headers: {
|
|
24
|
+
headers: {
|
|
25
|
+
...data?.headers,
|
|
26
|
+
Authorization: `Bearer ${token}`,
|
|
27
|
+
"x-enso-widget": "checkout",
|
|
28
|
+
},
|
|
25
29
|
...(data ? { body: JSON.stringify(data) } : {}),
|
|
26
30
|
});
|
|
27
31
|
|
package/src/util/meld-hooks.tsx
CHANGED
|
@@ -267,45 +267,6 @@ const TERMINAL_MELD_STATUSES = new Set<MeldTransactionStatus>([
|
|
|
267
267
|
"AUTHORIZATION_EXPIRED",
|
|
268
268
|
]);
|
|
269
269
|
|
|
270
|
-
/**
|
|
271
|
-
* Hook to track a MELD transaction
|
|
272
|
-
*/
|
|
273
|
-
export function useMeldTransaction(sessionId: string | null) {
|
|
274
|
-
return useQuery({
|
|
275
|
-
queryKey: ["meld-transaction", sessionId],
|
|
276
|
-
queryFn: async (): Promise<MeldTransaction | null> => {
|
|
277
|
-
if (!sessionId) return null;
|
|
278
|
-
|
|
279
|
-
const res = await fetch(`${MELD_BFF_URL}/transaction/${sessionId}`);
|
|
280
|
-
|
|
281
|
-
if (!res.ok) {
|
|
282
|
-
if (res.status === 404) {
|
|
283
|
-
return null; // Transaction not found yet
|
|
284
|
-
}
|
|
285
|
-
const error = await res
|
|
286
|
-
.json()
|
|
287
|
-
.catch(() => ({ error: "Failed to fetch transaction" }));
|
|
288
|
-
throw new Error(
|
|
289
|
-
error.error ||
|
|
290
|
-
error.message ||
|
|
291
|
-
"Failed to fetch transaction",
|
|
292
|
-
);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
return res.json();
|
|
296
|
-
},
|
|
297
|
-
enabled: !!sessionId,
|
|
298
|
-
refetchInterval: (query) => {
|
|
299
|
-
const data = query.state.data;
|
|
300
|
-
if (data?.status && TERMINAL_MELD_STATUSES.has(data.status)) {
|
|
301
|
-
return false;
|
|
302
|
-
}
|
|
303
|
-
return 3000; // Poll every 3 seconds
|
|
304
|
-
},
|
|
305
|
-
staleTime: 0, // Always refetch
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
|
|
309
270
|
/**
|
|
310
271
|
* Terminal status check
|
|
311
272
|
*/
|