@ensofinance/checkout-widget 0.0.12 → 0.0.14
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 +14486 -13826
- package/dist/checkout-widget.es.js.map +1 -1
- package/dist/checkout-widget.umd.js +44 -43
- package/dist/checkout-widget.umd.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/orval.config.ts +40 -6
- package/package.json +1 -1
- package/src/components/BridgeFee.tsx +3 -3
- package/src/components/Checkout.tsx +5 -53
- package/src/components/ExchangeConfirmSecurity.tsx +16 -3
- package/src/components/QuoteParameters.tsx +84 -65
- package/src/components/TransactionDetailRow.tsx +6 -5
- package/src/components/cards/AssetCard.tsx +2 -2
- package/src/components/cards/OptionCard.tsx +2 -0
- package/src/components/steps/ExchangeFlow.tsx +414 -135
- package/src/components/steps/{InitialStep.tsx → FlowSelector.tsx} +76 -33
- package/src/components/steps/WalletFlow/WalletAmountStep.tsx +214 -0
- package/src/components/steps/{WalletConfirmStep.tsx → WalletFlow/WalletConfirmStep.tsx} +107 -156
- package/src/components/steps/WalletFlow/WalletFlow.tsx +116 -0
- package/src/components/steps/{QuoteStep.tsx → WalletFlow/WalletQuoteStep.tsx} +9 -58
- package/src/components/steps/WalletFlow/WalletTokenStep.tsx +75 -0
- package/src/components/ui/index.tsx +0 -3
- package/src/enso-api/api.ts +192 -3
- package/src/enso-api/custom-instance.ts +1 -0
- package/src/enso-api/index.ts +29 -118
- package/src/enso-api/model/approveActionDto.ts +17 -0
- package/src/enso-api/model/approveArgsDto.ts +22 -0
- package/src/enso-api/model/approveArgsDtoAmount.ts +16 -0
- package/src/enso-api/model/balanceActionDto.ts +17 -0
- package/src/enso-api/model/balanceArgsDto.ts +15 -0
- package/src/enso-api/model/borrowActionDto.ts +18 -0
- package/src/enso-api/model/borrowArgsDto.ts +22 -0
- package/src/enso-api/model/borrowArgsDtoAmountOut.ts +16 -0
- package/src/enso-api/model/bridgeActionDto.ts +19 -0
- package/src/enso-api/model/bridgeArgsDto.ts +29 -0
- package/src/enso-api/model/bridgeArgsDtoAmountIn.ts +16 -0
- package/src/enso-api/model/bridgeArgsDtoCallbackItem.ts +64 -0
- package/src/enso-api/model/bundleControllerBundleShortcutTransactionBodyItem.ts +69 -0
- package/src/enso-api/model/callActionDto.ts +18 -0
- package/src/enso-api/model/callArgsDto.ts +29 -0
- package/src/enso-api/model/callArgsDtoArgsItem.ts +17 -0
- package/src/enso-api/model/callArgsDtoArgsItemAnyOf.ts +12 -0
- package/src/enso-api/model/callArgsDtoValue.ts +16 -0
- package/src/enso-api/model/callOutput.ts +15 -0
- package/src/enso-api/model/depositActionDto.ts +18 -0
- package/src/enso-api/model/depositArgsDto.ts +28 -0
- package/src/enso-api/model/depositArgsDtoAmountIn.ts +20 -0
- package/src/enso-api/model/depositArgsDtoAmountInOneOfItem.ts +13 -0
- package/src/enso-api/model/depositArgsDtoTokenIn.ts +15 -0
- package/src/enso-api/model/depositArgsDtoTokenOut.ts +15 -0
- package/src/enso-api/model/depositCLMMActionDto.ts +18 -0
- package/src/enso-api/model/depositCLMMArgsDto.ts +30 -0
- package/src/enso-api/model/depositCLMMArgsDtoAmountInItem.ts +17 -0
- package/src/enso-api/model/depositCLMMArgsDtoAmountInItemAnyOf.ts +12 -0
- package/src/enso-api/model/ensoFeeActionDto.ts +17 -0
- package/src/enso-api/model/ensoFeeArgsDto.ts +20 -0
- package/src/enso-api/model/ensoFeeArgsDtoAmount.ts +16 -0
- package/src/enso-api/model/feeActionDto.ts +17 -0
- package/src/enso-api/model/feeArgsDto.ts +22 -0
- package/src/enso-api/model/feeArgsDtoAmount.ts +16 -0
- package/src/enso-api/model/harvestActionDto.ts +19 -0
- package/src/enso-api/model/harvestArgsDto.ts +17 -0
- package/src/enso-api/model/index.ts +115 -4
- package/src/enso-api/model/mergeActionDto.ts +17 -0
- package/src/enso-api/model/mergeArgsDto.ts +22 -0
- package/src/enso-api/model/mergeArgsDtoAmountInItem.ts +13 -0
- package/src/enso-api/model/minAmountOutActionDto.ts +17 -0
- package/src/enso-api/model/minAmountOutArgsDto.ts +19 -0
- package/src/enso-api/model/minAmountOutArgsDtoAmountOut.ts +16 -0
- package/src/enso-api/model/minAmountOutArgsDtoMinAmountOut.ts +16 -0
- package/src/enso-api/model/multiDepositActionDto.ts +18 -0
- package/src/enso-api/model/multiDepositArgsDto.ts +24 -0
- package/src/enso-api/model/multiDepositArgsDtoAmountInItem.ts +17 -0
- package/src/enso-api/model/multiDepositArgsDtoAmountInItemAnyOf.ts +12 -0
- package/src/enso-api/model/multiOutSingleDepositActionDto.ts +18 -0
- package/src/enso-api/model/multiOutSingleDepositArgsDto.ts +24 -0
- package/src/enso-api/model/multiOutSingleDepositArgsDtoAmountIn.ts +16 -0
- package/src/enso-api/model/multiRedeemActionDto.ts +18 -0
- package/src/enso-api/model/multiRedeemArgs2Dto.ts +24 -0
- package/src/enso-api/model/multiRedeemArgs2DtoAmountIn.ts +16 -0
- package/src/enso-api/model/nontokenizedControllerRouteNontokenizedShorcutTransactionParams.ts +8 -0
- package/src/enso-api/model/nontokenizedControllerRouteNontokenizedShorcutTransactionRoutingStrategy.ts +1 -0
- package/src/enso-api/model/nontokenizedRouteShortcutTransaction.ts +31 -0
- package/src/enso-api/model/paymasterFeeActionDto.ts +17 -0
- package/src/enso-api/model/paymasterFeeArgsDto.ts +18 -0
- package/src/enso-api/model/paymasterFeeArgsDtoAmount.ts +16 -0
- package/src/enso-api/model/permitTransferFromActionDto.ts +18 -0
- package/src/enso-api/model/permitTransferFromArgsDto.ts +29 -0
- package/src/enso-api/model/permitTransferFromArgsDtoAmount.ts +20 -0
- package/src/enso-api/model/permitTransferFromArgsDtoAmountOneOfItem.ts +13 -0
- package/src/enso-api/model/permitTransferFromArgsDtoToken.ts +15 -0
- package/src/enso-api/model/positionModel.ts +14 -0
- package/src/enso-api/model/redeemActionDto.ts +18 -0
- package/src/enso-api/model/redeemArgsDto.ts +25 -0
- package/src/enso-api/model/redeemArgsDtoAmountIn.ts +16 -0
- package/src/enso-api/model/redeemArgsDtoTokenOut.ts +15 -0
- package/src/enso-api/model/redeemCLMMActionDto.ts +18 -0
- package/src/enso-api/model/redeemCLMMArgsDto.ts +24 -0
- package/src/enso-api/model/redeemCLMMArgsDtoLiquidity.ts +16 -0
- package/src/enso-api/model/repayActionDto.ts +18 -0
- package/src/enso-api/model/repayArgsDto.ts +22 -0
- package/src/enso-api/model/repayArgsDtoAmountIn.ts +16 -0
- package/src/enso-api/model/routeActionDto.ts +20 -0
- package/src/enso-api/model/routeArgsDto.ts +38 -0
- package/src/enso-api/model/routeArgsDtoAmountIn.ts +16 -0
- package/src/enso-api/model/singleDepositActionDto.ts +18 -0
- package/src/enso-api/model/singleDepositArgsDto.ts +24 -0
- package/src/enso-api/model/singleDepositArgsDtoAmountIn.ts +16 -0
- package/src/enso-api/model/singleRedeemActionDto.ts +18 -0
- package/src/enso-api/model/singleRedeemArgs2Dto.ts +24 -0
- package/src/enso-api/model/singleRedeemArgs2DtoAmountIn.ts +16 -0
- package/src/enso-api/model/slippageActionDto.ts +17 -0
- package/src/enso-api/model/slippageArgsDto.ts +18 -0
- package/src/enso-api/model/slippageArgsDtoAmountOut.ts +16 -0
- package/src/enso-api/model/splitActionDto.ts +17 -0
- package/src/enso-api/model/splitArgsDto.ts +22 -0
- package/src/enso-api/model/splitArgsDtoAmountIn.ts +16 -0
- package/src/enso-api/model/swapActionDto.ts +18 -0
- package/src/enso-api/model/swapArgsDto.ts +30 -0
- package/src/enso-api/model/swapArgsDtoAmountIn.ts +16 -0
- package/src/enso-api/model/tokenizedMultiDepositActionDto.ts +18 -0
- package/src/enso-api/model/tokenizedMultiDepositArgsDto.ts +24 -0
- package/src/enso-api/model/tokenizedMultiDepositArgsDtoAmountInItem.ts +17 -0
- package/src/enso-api/model/tokenizedMultiDepositArgsDtoAmountInItemAnyOf.ts +14 -0
- package/src/enso-api/model/tokenizedMultiRedeemActionDto.ts +18 -0
- package/src/enso-api/model/tokenizedMultiRedeemArgsDto.ts +24 -0
- package/src/enso-api/model/tokenizedMultiRedeemArgsDtoAmountIn.ts +16 -0
- package/src/enso-api/model/tokenizedSingleDepositActionDto.ts +18 -0
- package/src/enso-api/model/tokenizedSingleDepositArgsDto.ts +24 -0
- package/src/enso-api/model/tokenizedSingleDepositArgsDtoAmountIn.ts +16 -0
- package/src/enso-api/model/tokenizedSingleRedeemActionDto.ts +18 -0
- package/src/enso-api/model/tokenizedSingleRedeemArgsDto.ts +24 -0
- package/src/enso-api/model/tokenizedSingleRedeemArgsDtoAmountIn.ts +16 -0
- package/src/enso-api/model/tokensControllerTokensLiquidityType.ts +19 -0
- package/src/enso-api/model/tokensControllerTokensParams.ts +6 -0
- package/src/enso-api/model/transferActionDto.ts +18 -0
- package/src/enso-api/model/transferArgsDto.ts +22 -0
- package/src/enso-api/model/transferArgsDtoAmount.ts +16 -0
- package/src/enso-api/model/transferFromActionDto.ts +18 -0
- package/src/enso-api/model/transferFromArgsDto.ts +24 -0
- package/src/enso-api/model/transferFromArgsDtoAmount.ts +16 -0
- package/src/index.ts +1 -0
- package/src/store.ts +13 -5
- package/src/types/index.ts +9 -3
- package/src/util/common.tsx +4 -1
- package/src/util/enso-hooks.tsx +137 -14
- package/src/util/wallet.tsx +2 -69
- package/src/components/steps/WalletAmountStep.tsx +0 -267
- package/src/components/steps/WalletTokenStep.tsx +0 -128
|
@@ -1,25 +1,23 @@
|
|
|
1
|
-
import { Box,
|
|
2
|
-
import {
|
|
3
|
-
import { ChevronLeft, X } from "lucide-react";
|
|
4
|
-
import { useContext, useEffect, useState, useMemo, useCallback } from "react";
|
|
1
|
+
import { Box, Table, Text, Image } from "@chakra-ui/react";
|
|
2
|
+
import { useEffect, useState, useMemo, useCallback } from "react";
|
|
5
3
|
import { useAccount } from "wagmi";
|
|
6
4
|
import { Address } from "viem";
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import DepositProcessing from "../DepositProcessing";
|
|
5
|
+
import { BodyWrapper } from "@/components/ui/styled";
|
|
6
|
+
import { Button } from "@/components/ui";
|
|
7
|
+
import { CircleTimer } from "@/components/CircleTimer";
|
|
8
|
+
import { TransactionDetailRow } from "@/components/TransactionDetailRow";
|
|
9
|
+
import DepositProcessing from "@/components/DepositProcessing";
|
|
13
10
|
import { useSendTxns, useRouteData, useAppDetails } from "@/util/enso-hooks";
|
|
14
|
-
import { getChainIcon } from "@/util";
|
|
11
|
+
import { compareCaseInsensitive, getChainIcon } from "@/util";
|
|
15
12
|
import { getChainEtherscanUrl } from "@/util/common";
|
|
16
13
|
import { useTrackTx, useTxByHash } from "@/util/tx-tracker";
|
|
17
|
-
import QuoteParameters from "
|
|
14
|
+
import QuoteParameters from "@/components/QuoteParameters";
|
|
18
15
|
import { useApproveData } from "@/enso-api/api";
|
|
19
16
|
import { useIsApproveNeeded } from "@/util/wallet";
|
|
17
|
+
import { ETH_ADDRESS } from "@/util/constants";
|
|
20
18
|
|
|
21
|
-
import SuccessIcon from "
|
|
22
|
-
import FailIcon from "
|
|
19
|
+
import SuccessIcon from "@/assets/success.svg";
|
|
20
|
+
import FailIcon from "@/assets/fail.svg";
|
|
23
21
|
|
|
24
22
|
type TransferStatus = "processing" | "success" | "failed" | "idle";
|
|
25
23
|
|
|
@@ -42,7 +40,13 @@ const useOperationsCalls = () => {
|
|
|
42
40
|
);
|
|
43
41
|
|
|
44
42
|
const calls = useMemo(() => {
|
|
45
|
-
if (
|
|
43
|
+
if (
|
|
44
|
+
(!compareCaseInsensitive(tokenIn, ETH_ADDRESS) &&
|
|
45
|
+
!allowanceFetched) ||
|
|
46
|
+
!routeFetched ||
|
|
47
|
+
!approveFetched
|
|
48
|
+
)
|
|
49
|
+
return [];
|
|
46
50
|
|
|
47
51
|
if (approveNeeded) {
|
|
48
52
|
return [approveData?.tx, routeData?.tx];
|
|
@@ -63,8 +67,11 @@ const useOperationsCalls = () => {
|
|
|
63
67
|
};
|
|
64
68
|
};
|
|
65
69
|
|
|
66
|
-
const WalletConfirmStep = (
|
|
67
|
-
|
|
70
|
+
const WalletConfirmStep = ({
|
|
71
|
+
setStep,
|
|
72
|
+
}: {
|
|
73
|
+
setStep: (step: string) => void;
|
|
74
|
+
}) => {
|
|
68
75
|
const [status, setStatus] = useState<TransferStatus>("idle");
|
|
69
76
|
const [isTimerFinished, setIsTimerFinished] = useState(false);
|
|
70
77
|
const { address } = useAccount();
|
|
@@ -113,6 +120,7 @@ const WalletConfirmStep = () => {
|
|
|
113
120
|
|
|
114
121
|
// Initiate the transaction when wallet is ready
|
|
115
122
|
useEffect(() => {
|
|
123
|
+
console.log(called, ready);
|
|
116
124
|
if (!called && ready) {
|
|
117
125
|
sendTxns(onTxSend, onFail);
|
|
118
126
|
setCalled(true);
|
|
@@ -125,7 +133,6 @@ const WalletConfirmStep = () => {
|
|
|
125
133
|
|
|
126
134
|
const handleNewDeposit = () => {
|
|
127
135
|
// Reset to initial step or handle new deposit logic
|
|
128
|
-
setFlow("mainFlow");
|
|
129
136
|
setStep("selectToken");
|
|
130
137
|
};
|
|
131
138
|
|
|
@@ -133,7 +140,6 @@ const WalletConfirmStep = () => {
|
|
|
133
140
|
// Reset to previous step to retry the transfer
|
|
134
141
|
// setStatus("processing");
|
|
135
142
|
// setIsTimerFinished(false);
|
|
136
|
-
setFlow("mainFlow");
|
|
137
143
|
setStep("quote");
|
|
138
144
|
};
|
|
139
145
|
|
|
@@ -258,146 +264,91 @@ const WalletConfirmStep = () => {
|
|
|
258
264
|
};
|
|
259
265
|
|
|
260
266
|
return (
|
|
261
|
-
|
|
262
|
-
<
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
<
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
<IconButton
|
|
287
|
-
onClick={handleClose}
|
|
288
|
-
width={"40px"}
|
|
289
|
-
marginLeft={"auto"}
|
|
267
|
+
<BodyWrapper>
|
|
268
|
+
<Box
|
|
269
|
+
display={"flex"}
|
|
270
|
+
flexDirection={"column"}
|
|
271
|
+
paddingBottom={"16px"}
|
|
272
|
+
alignItems={"center"}
|
|
273
|
+
width={"100%"}
|
|
274
|
+
>
|
|
275
|
+
{renderStatusIcon()}
|
|
276
|
+
{renderProcessingText()}
|
|
277
|
+
</Box>
|
|
278
|
+
|
|
279
|
+
<Table.Root
|
|
280
|
+
key={"status"}
|
|
281
|
+
size="sm"
|
|
282
|
+
variant={"outline"}
|
|
283
|
+
width={"100%"}
|
|
284
|
+
>
|
|
285
|
+
<Table.Body>
|
|
286
|
+
<Table.Row>
|
|
287
|
+
<Table.Cell>Status</Table.Cell>
|
|
288
|
+
<Table.Cell
|
|
289
|
+
display="flex"
|
|
290
|
+
textAlign="end"
|
|
291
|
+
justifyContent="end"
|
|
290
292
|
>
|
|
291
|
-
<
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
<Box
|
|
304
|
-
display={"flex"}
|
|
305
|
-
flexDirection={"column"}
|
|
306
|
-
paddingBottom={"16px"}
|
|
307
|
-
alignItems={"center"}
|
|
308
|
-
width={"100%"}
|
|
309
|
-
>
|
|
310
|
-
{renderStatusIcon()}
|
|
311
|
-
{renderProcessingText()}
|
|
312
|
-
</Box>
|
|
313
|
-
|
|
314
|
-
<Table.Root
|
|
315
|
-
key={"status"}
|
|
316
|
-
size="sm"
|
|
317
|
-
variant={"outline"}
|
|
318
|
-
width={"100%"}
|
|
319
|
-
>
|
|
320
|
-
<Table.Body>
|
|
321
|
-
<Table.Row>
|
|
322
|
-
<Table.Cell>Status</Table.Cell>
|
|
323
|
-
<Table.Cell
|
|
324
|
-
display="flex"
|
|
325
|
-
textAlign="end"
|
|
326
|
-
justifyContent="end"
|
|
327
|
-
>
|
|
328
|
-
<Text color={getStatusColor()}>
|
|
329
|
-
{getStatusText()}
|
|
330
|
-
</Text>
|
|
331
|
-
</Table.Cell>
|
|
332
|
-
</Table.Row>
|
|
333
|
-
{["success", "processing"].includes(status) && (
|
|
334
|
-
<Table.Row>
|
|
335
|
-
<Table.Cell>Transaction</Table.Cell>
|
|
336
|
-
<Table.Cell
|
|
337
|
-
display="flex"
|
|
338
|
-
textAlign="end"
|
|
339
|
-
justifyContent="end"
|
|
340
|
-
>
|
|
341
|
-
{explorerUrl ? (
|
|
342
|
-
<a
|
|
343
|
-
href={explorerUrl}
|
|
344
|
-
target="_blank"
|
|
345
|
-
rel="noreferrer"
|
|
346
|
-
>
|
|
347
|
-
<Text color="blue.500">
|
|
348
|
-
View on{" "}
|
|
349
|
-
{isCrosschain
|
|
350
|
-
? "LayerZero"
|
|
351
|
-
: "Etherscan"}
|
|
352
|
-
</Text>
|
|
353
|
-
</a>
|
|
354
|
-
) : (
|
|
355
|
-
<Text>-</Text>
|
|
356
|
-
)}
|
|
357
|
-
</Table.Cell>
|
|
358
|
-
</Table.Row>
|
|
359
|
-
)}
|
|
360
|
-
</Table.Body>
|
|
361
|
-
</Table.Root>
|
|
362
|
-
|
|
363
|
-
<QuoteParameters />
|
|
364
|
-
|
|
365
|
-
{status === "processing" ? (
|
|
366
|
-
<DepositProcessing
|
|
367
|
-
currencyIcon={getChainIcon(chainIdOut)}
|
|
368
|
-
/>
|
|
369
|
-
) : (
|
|
370
|
-
<TransactionDetailRow />
|
|
371
|
-
)}
|
|
372
|
-
|
|
373
|
-
{status === "success" && (
|
|
374
|
-
<Box display="flex" gap={"12px"} width="100%">
|
|
375
|
-
<Button visual={"lightGray"} onClick={handleClose}>
|
|
376
|
-
Close
|
|
377
|
-
</Button>
|
|
378
|
-
<Button visual={"solid"} onClick={handleNewDeposit}>
|
|
379
|
-
New Deposit
|
|
380
|
-
</Button>
|
|
381
|
-
</Box>
|
|
382
|
-
)}
|
|
383
|
-
|
|
384
|
-
{status === "failed" && (
|
|
385
|
-
<Box display="flex" gap={"12px"} width="100%">
|
|
386
|
-
<Button
|
|
387
|
-
// variant={"surface"}
|
|
388
|
-
visual={"lightGray"}
|
|
389
|
-
onClick={handleClose}
|
|
293
|
+
<Text color={getStatusColor()}>
|
|
294
|
+
{getStatusText()}
|
|
295
|
+
</Text>
|
|
296
|
+
</Table.Cell>
|
|
297
|
+
</Table.Row>
|
|
298
|
+
{["success", "processing"].includes(status) && (
|
|
299
|
+
<Table.Row>
|
|
300
|
+
<Table.Cell>Transaction</Table.Cell>
|
|
301
|
+
<Table.Cell
|
|
302
|
+
display="flex"
|
|
303
|
+
textAlign="end"
|
|
304
|
+
justifyContent="end"
|
|
390
305
|
>
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
306
|
+
{explorerUrl ? (
|
|
307
|
+
<a
|
|
308
|
+
href={explorerUrl}
|
|
309
|
+
target="_blank"
|
|
310
|
+
rel="noreferrer"
|
|
311
|
+
>
|
|
312
|
+
<Text color="blue.500">
|
|
313
|
+
View on{" "}
|
|
314
|
+
{isCrosschain
|
|
315
|
+
? "LayerZero"
|
|
316
|
+
: "Etherscan"}
|
|
317
|
+
</Text>
|
|
318
|
+
</a>
|
|
319
|
+
) : (
|
|
320
|
+
<Text>-</Text>
|
|
321
|
+
)}
|
|
322
|
+
</Table.Cell>
|
|
323
|
+
</Table.Row>
|
|
397
324
|
)}
|
|
398
|
-
</
|
|
399
|
-
</
|
|
400
|
-
|
|
325
|
+
</Table.Body>
|
|
326
|
+
</Table.Root>
|
|
327
|
+
|
|
328
|
+
<QuoteParameters />
|
|
329
|
+
|
|
330
|
+
{status === "processing" ? (
|
|
331
|
+
<DepositProcessing currencyIcon={getChainIcon(chainIdOut)} />
|
|
332
|
+
) : (
|
|
333
|
+
<TransactionDetailRow />
|
|
334
|
+
)}
|
|
335
|
+
|
|
336
|
+
{status === "success" && (
|
|
337
|
+
<Button
|
|
338
|
+
visual={"solid"}
|
|
339
|
+
onClick={handleNewDeposit}
|
|
340
|
+
width="100%"
|
|
341
|
+
>
|
|
342
|
+
New Deposit
|
|
343
|
+
</Button>
|
|
344
|
+
)}
|
|
345
|
+
|
|
346
|
+
{status === "failed" && (
|
|
347
|
+
<Button visual={"solid"} onClick={handleRetry} width="100%">
|
|
348
|
+
Retry Deposit
|
|
349
|
+
</Button>
|
|
350
|
+
)}
|
|
351
|
+
</BodyWrapper>
|
|
401
352
|
);
|
|
402
353
|
};
|
|
403
354
|
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { useState, useContext } from "react";
|
|
2
|
+
import { Box, Icon } from "@chakra-ui/react";
|
|
3
|
+
import { ChevronLeft, X } from "lucide-react";
|
|
4
|
+
import WalletTokenStep from "./WalletTokenStep";
|
|
5
|
+
import WalletAmountStep from "./WalletAmountStep";
|
|
6
|
+
import WalletQuoteStep from "./WalletQuoteStep";
|
|
7
|
+
import WalletConfirmStep from "./WalletConfirmStep";
|
|
8
|
+
import { CheckoutContext } from "@/components/Checkout";
|
|
9
|
+
import Modal from "@/components/modal";
|
|
10
|
+
import { IconButton } from "@/components/ui";
|
|
11
|
+
import { HeaderWrapper, HeaderTitle } from "@/components/ui/styled";
|
|
12
|
+
|
|
13
|
+
export enum WalletFlowStep {
|
|
14
|
+
SelectToken = "selectToken",
|
|
15
|
+
SelectAmount = "selectAmount",
|
|
16
|
+
Quote = "quote",
|
|
17
|
+
ConfirmTransfer = "confirmTransfer",
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const walletSteps = [
|
|
21
|
+
WalletFlowStep.SelectToken,
|
|
22
|
+
WalletFlowStep.SelectAmount,
|
|
23
|
+
WalletFlowStep.Quote,
|
|
24
|
+
WalletFlowStep.ConfirmTransfer,
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
const WalletFlow = ({
|
|
28
|
+
initialStep = WalletFlowStep.SelectToken,
|
|
29
|
+
setFlow,
|
|
30
|
+
}: {
|
|
31
|
+
initialStep?: WalletFlowStep;
|
|
32
|
+
setFlow?: (step: string) => void;
|
|
33
|
+
}) => {
|
|
34
|
+
const [currentStep, setCurrentStep] = useState<WalletFlowStep>(initialStep);
|
|
35
|
+
const { handleClose } = useContext(CheckoutContext);
|
|
36
|
+
|
|
37
|
+
const handleSetStep = (step: WalletFlowStep | string) => {
|
|
38
|
+
setCurrentStep(step as WalletFlowStep);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const handleBackClick = () => {
|
|
42
|
+
const index = walletSteps.findIndex((step) => step === currentStep) - 1;
|
|
43
|
+
if (index >= 0) {
|
|
44
|
+
setCurrentStep(walletSteps[index]);
|
|
45
|
+
} else if (setFlow) {
|
|
46
|
+
setFlow("");
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const currentStepComponent = (() => {
|
|
51
|
+
switch (currentStep) {
|
|
52
|
+
case WalletFlowStep.SelectToken:
|
|
53
|
+
return <WalletTokenStep setStep={handleSetStep} />;
|
|
54
|
+
case WalletFlowStep.SelectAmount:
|
|
55
|
+
return <WalletAmountStep setStep={handleSetStep} />;
|
|
56
|
+
case WalletFlowStep.Quote:
|
|
57
|
+
return <WalletQuoteStep setStep={handleSetStep} />;
|
|
58
|
+
case WalletFlowStep.ConfirmTransfer:
|
|
59
|
+
return <WalletConfirmStep setStep={handleSetStep} />;
|
|
60
|
+
default:
|
|
61
|
+
return <WalletTokenStep setStep={handleSetStep} />;
|
|
62
|
+
}
|
|
63
|
+
})();
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<>
|
|
67
|
+
<Modal.Header>
|
|
68
|
+
<HeaderWrapper>
|
|
69
|
+
<IconButton
|
|
70
|
+
minWidth={"16px"}
|
|
71
|
+
minHeight={"16px"}
|
|
72
|
+
maxWidth={"16px"}
|
|
73
|
+
onClick={handleBackClick}
|
|
74
|
+
>
|
|
75
|
+
<Icon
|
|
76
|
+
as={ChevronLeft}
|
|
77
|
+
color="gray"
|
|
78
|
+
width={"16px"}
|
|
79
|
+
height={"16px"}
|
|
80
|
+
/>
|
|
81
|
+
</IconButton>
|
|
82
|
+
|
|
83
|
+
<Box
|
|
84
|
+
display="flex"
|
|
85
|
+
flexDirection="column"
|
|
86
|
+
gap={"4px"}
|
|
87
|
+
alignItems={"center"}
|
|
88
|
+
width="100%"
|
|
89
|
+
>
|
|
90
|
+
<HeaderTitle>Wallet Deposit</HeaderTitle>
|
|
91
|
+
</Box>
|
|
92
|
+
|
|
93
|
+
{handleClose && (
|
|
94
|
+
<IconButton
|
|
95
|
+
onClick={handleClose}
|
|
96
|
+
minWidth={"16px"}
|
|
97
|
+
minHeight={"16px"}
|
|
98
|
+
maxWidth={"16px"}
|
|
99
|
+
marginLeft={"auto"}
|
|
100
|
+
>
|
|
101
|
+
<Icon
|
|
102
|
+
as={X}
|
|
103
|
+
color="gray"
|
|
104
|
+
width={"16px"}
|
|
105
|
+
height={"16px"}
|
|
106
|
+
/>
|
|
107
|
+
</IconButton>
|
|
108
|
+
)}
|
|
109
|
+
</HeaderWrapper>
|
|
110
|
+
</Modal.Header>
|
|
111
|
+
<Modal.Body>{currentStepComponent}</Modal.Body>
|
|
112
|
+
</>
|
|
113
|
+
);
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export default WalletFlow;
|
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Box, Icon, Skeleton, Flex } from "@chakra-ui/react";
|
|
3
|
-
import { ChevronLeft, X } from "lucide-react";
|
|
1
|
+
import { Skeleton, Flex } from "@chakra-ui/react";
|
|
4
2
|
import { useChainId, useSwitchChain } from "wagmi";
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { HeaderWrapper, HeaderTitle, BodyWrapper } from "../ui/styled";
|
|
9
|
-
import { TransactionDetailRow } from "../TransactionDetailRow";
|
|
3
|
+
import { Button, Input } from "@/components/ui";
|
|
4
|
+
import { BodyWrapper } from "@/components/ui/styled";
|
|
5
|
+
import { TransactionDetailRow } from "@/components/TransactionDetailRow";
|
|
10
6
|
import { useAppDetails, useRouteData } from "@/util/enso-hooks";
|
|
11
7
|
import { useChainName } from "@/util/common";
|
|
12
|
-
import QuoteParameters from "
|
|
13
|
-
|
|
14
|
-
const QuoteStep = () => {
|
|
15
|
-
const { handleClose, setStep } = useContext(CheckoutContext);
|
|
8
|
+
import QuoteParameters from "@/components/QuoteParameters";
|
|
16
9
|
|
|
10
|
+
const WalletQuoteStep = ({ setStep }: { setStep: (step: string) => void }) => {
|
|
17
11
|
const { chainIdIn } = useAppDetails();
|
|
18
12
|
|
|
19
13
|
const { routeLoading, usdAmountIn, routeData } = useRouteData();
|
|
@@ -24,48 +18,7 @@ const QuoteStep = () => {
|
|
|
24
18
|
const wrongChain = walletChainId !== chainIdIn;
|
|
25
19
|
|
|
26
20
|
return (
|
|
27
|
-
|
|
28
|
-
<Modal.Header>
|
|
29
|
-
<HeaderWrapper>
|
|
30
|
-
<IconButton
|
|
31
|
-
minWidth={"16px"}
|
|
32
|
-
minHeight={"16px"}
|
|
33
|
-
maxWidth={"16px"}
|
|
34
|
-
onClick={() => {
|
|
35
|
-
setStep("selectAmount");
|
|
36
|
-
}}
|
|
37
|
-
>
|
|
38
|
-
<Icon
|
|
39
|
-
as={ChevronLeft}
|
|
40
|
-
color="gray"
|
|
41
|
-
width={"16px"}
|
|
42
|
-
height={"16px"}
|
|
43
|
-
/>
|
|
44
|
-
</IconButton>
|
|
45
|
-
|
|
46
|
-
<Box display="flex" flexDirection="column" gap={"4px"}>
|
|
47
|
-
<HeaderTitle>Deposit</HeaderTitle>
|
|
48
|
-
</Box>
|
|
49
|
-
|
|
50
|
-
{handleClose && (
|
|
51
|
-
<IconButton
|
|
52
|
-
onClick={handleClose}
|
|
53
|
-
width={"40px"}
|
|
54
|
-
marginLeft={"auto"}
|
|
55
|
-
>
|
|
56
|
-
<Icon
|
|
57
|
-
as={X}
|
|
58
|
-
color="gray"
|
|
59
|
-
width={"16px"}
|
|
60
|
-
height={"16px"}
|
|
61
|
-
/>
|
|
62
|
-
</IconButton>
|
|
63
|
-
)}
|
|
64
|
-
</HeaderWrapper>
|
|
65
|
-
</Modal.Header>
|
|
66
|
-
|
|
67
|
-
<Modal.Body>
|
|
68
|
-
<BodyWrapper>
|
|
21
|
+
<BodyWrapper>
|
|
69
22
|
<Flex
|
|
70
23
|
flexDirection={"column"}
|
|
71
24
|
gap={"16px"}
|
|
@@ -113,10 +66,8 @@ const QuoteStep = () => {
|
|
|
113
66
|
{routeLoading ? "Loading quote" : "Continue"}
|
|
114
67
|
</Button>
|
|
115
68
|
)}
|
|
116
|
-
|
|
117
|
-
</Modal.Body>
|
|
118
|
-
</>
|
|
69
|
+
</BodyWrapper>
|
|
119
70
|
);
|
|
120
71
|
};
|
|
121
72
|
|
|
122
|
-
export default
|
|
73
|
+
export default WalletQuoteStep;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Box, Skeleton } from "@chakra-ui/react";
|
|
2
|
+
import { ListWrapper, BodyWrapper } from "@/components/ui/styled";
|
|
3
|
+
import { useEffect } from "react";
|
|
4
|
+
import { Button } from "@/components/ui";
|
|
5
|
+
import { AssetCard } from "@/components/cards";
|
|
6
|
+
import { useAppStore } from "@/store";
|
|
7
|
+
import { useWalletBalance } from "@/enso-api/api";
|
|
8
|
+
import { formatNumber, formatUSD, normalizeValue } from "@/util";
|
|
9
|
+
|
|
10
|
+
const WalletAssetStep = ({ setStep }: { setStep: (step: string) => void }) => {
|
|
11
|
+
const setSelectedIntegration = useAppStore(
|
|
12
|
+
(state) => state.setSelectedIntegration,
|
|
13
|
+
);
|
|
14
|
+
const setTokenIn = useAppStore((state) => state.setTokenIn);
|
|
15
|
+
const tokenIn = useAppStore((state) => state.tokenIn);
|
|
16
|
+
const setChainIdIn = useAppStore((state) => state.setChainIdIn);
|
|
17
|
+
const chainIdIn = useAppStore((state) => state.chainIdIn);
|
|
18
|
+
const { holdingsList, isLoading } = useWalletBalance();
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
setSelectedIntegration(null);
|
|
22
|
+
}, []);
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<BodyWrapper>
|
|
26
|
+
<Box overflowY={"scroll"} maxH={"400px"}>
|
|
27
|
+
<ListWrapper>
|
|
28
|
+
{isLoading
|
|
29
|
+
? Array.from({ length: 10 }).map((_, index) => (
|
|
30
|
+
<Skeleton
|
|
31
|
+
key={index}
|
|
32
|
+
height="40px"
|
|
33
|
+
width="300px"
|
|
34
|
+
/>
|
|
35
|
+
))
|
|
36
|
+
: holdingsList?.map((asset) => (
|
|
37
|
+
<AssetCard
|
|
38
|
+
key={`${asset.token}-${asset.chainId}`}
|
|
39
|
+
chainId={asset.chainId}
|
|
40
|
+
icon={asset.logoUri}
|
|
41
|
+
title={asset.name}
|
|
42
|
+
balance={`${formatNumber(
|
|
43
|
+
normalizeValue(
|
|
44
|
+
asset.amount,
|
|
45
|
+
asset.decimals,
|
|
46
|
+
),
|
|
47
|
+
)} ${asset.symbol}`}
|
|
48
|
+
usdBalance={formatUSD(asset.total)}
|
|
49
|
+
tag={""}
|
|
50
|
+
loading={false}
|
|
51
|
+
selected={
|
|
52
|
+
asset.token === tokenIn &&
|
|
53
|
+
asset.chainId === chainIdIn
|
|
54
|
+
}
|
|
55
|
+
onClick={() => {
|
|
56
|
+
setTokenIn(asset.token);
|
|
57
|
+
setChainIdIn(asset.chainId);
|
|
58
|
+
}}
|
|
59
|
+
/>
|
|
60
|
+
))}
|
|
61
|
+
</ListWrapper>
|
|
62
|
+
</Box>
|
|
63
|
+
<Button
|
|
64
|
+
onClick={() => {
|
|
65
|
+
setStep("selectAmount");
|
|
66
|
+
}}
|
|
67
|
+
disabled={!tokenIn}
|
|
68
|
+
>
|
|
69
|
+
Continue
|
|
70
|
+
</Button>
|
|
71
|
+
</BodyWrapper>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default WalletAssetStep;
|