@ensofinance/checkout-widget 0.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.
Files changed (128) hide show
  1. package/dist/checkout-widget.es.js +52889 -0
  2. package/dist/checkout-widget.es.js.map +1 -0
  3. package/dist/checkout-widget.umd.js +203 -0
  4. package/dist/checkout-widget.umd.js.map +1 -0
  5. package/dist/index.d.ts +23 -0
  6. package/enso-api.yaml +1982 -0
  7. package/orval.config.ts +25 -0
  8. package/package.json +79 -0
  9. package/src/assets/BinanceBadge.svg +4 -0
  10. package/src/assets/CoinbaseIcon.svg +4 -0
  11. package/src/assets/USD Coin (USDC).svg +5 -0
  12. package/src/assets/avecIcon.svg +5 -0
  13. package/src/assets/base.webp +0 -0
  14. package/src/assets/depositIcon.svg +6 -0
  15. package/src/assets/eth.webp +0 -0
  16. package/src/assets/ethMainnetIcon.svg +10 -0
  17. package/src/assets/fail.svg +5 -0
  18. package/src/assets/kraken.png +0 -0
  19. package/src/assets/logo.svg +10 -0
  20. package/src/assets/mastercard.png +0 -0
  21. package/src/assets/metamask.png +0 -0
  22. package/src/assets/rabby.png +0 -0
  23. package/src/assets/success.svg +4 -0
  24. package/src/assets/usdc.webp +0 -0
  25. package/src/assets/usdt.webp +0 -0
  26. package/src/assets/visa.png +0 -0
  27. package/src/assets/visa.webp +0 -0
  28. package/src/components/BridgeFee.tsx +58 -0
  29. package/src/components/ChakraProvider.tsx +372 -0
  30. package/src/components/Checkout.tsx +127 -0
  31. package/src/components/CheckoutModal.tsx +22 -0
  32. package/src/components/CircleTimer.tsx +66 -0
  33. package/src/components/CurrencySwapDisplay.tsx +153 -0
  34. package/src/components/DepositProcessing.tsx +116 -0
  35. package/src/components/ExchangeConfirmSecurity.tsx +110 -0
  36. package/src/components/QuoteParameters.tsx +341 -0
  37. package/src/components/TransactionDetailRow.tsx +124 -0
  38. package/src/components/cards/AssetCard.tsx +167 -0
  39. package/src/components/cards/ExchangeCard.tsx +53 -0
  40. package/src/components/cards/OptionCard.tsx +59 -0
  41. package/src/components/cards/WalletCard.tsx +99 -0
  42. package/src/components/cards/index.ts +6 -0
  43. package/src/components/modal.tsx +83 -0
  44. package/src/components/steps/ExchangeFlow.tsx +1402 -0
  45. package/src/components/steps/InitialStep.tsx +169 -0
  46. package/src/components/steps/QuoteStep.tsx +121 -0
  47. package/src/components/steps/WalletAmountStep.tsx +258 -0
  48. package/src/components/steps/WalletConfirmStep.tsx +404 -0
  49. package/src/components/steps/WalletTokenStep.tsx +128 -0
  50. package/src/components/ui/index.tsx +394 -0
  51. package/src/components/ui/styled.tsx +85 -0
  52. package/src/components/ui/toaster.tsx +43 -0
  53. package/src/components/ui/tooltip.tsx +46 -0
  54. package/src/enso-api/api.ts +173 -0
  55. package/src/enso-api/custom-instance.ts +35 -0
  56. package/src/enso-api/index.ts +5119 -0
  57. package/src/enso-api/model/action.ts +17 -0
  58. package/src/enso-api/model/actionAction.ts +52 -0
  59. package/src/enso-api/model/actionInputs.ts +12 -0
  60. package/src/enso-api/model/actionToBundle.ts +19 -0
  61. package/src/enso-api/model/actionToBundleAction.ts +53 -0
  62. package/src/enso-api/model/actionToBundleArgs.ts +12 -0
  63. package/src/enso-api/model/bundleControllerBundleShortcutTransactionParams.ts +53 -0
  64. package/src/enso-api/model/bundleControllerBundleShortcutTransactionRoutingStrategy.ts +23 -0
  65. package/src/enso-api/model/bundleShortcutTransaction.ts +35 -0
  66. package/src/enso-api/model/bundleShortcutTransactionAmountsOut.ts +15 -0
  67. package/src/enso-api/model/bundleShortcutTransactionFeeAmount.ts +12 -0
  68. package/src/enso-api/model/connectedNetwork.ts +16 -0
  69. package/src/enso-api/model/hop.ts +24 -0
  70. package/src/enso-api/model/hopArgs.ts +12 -0
  71. package/src/enso-api/model/index.ts +70 -0
  72. package/src/enso-api/model/iporControllerIporShortcutTransactionParams.ts +21 -0
  73. package/src/enso-api/model/iporShortcutInput.ts +33 -0
  74. package/src/enso-api/model/iporShortcutTransaction.ts +22 -0
  75. package/src/enso-api/model/lZDestinationTokenData.ts +19 -0
  76. package/src/enso-api/model/lZPoolLookupResponse.ts +26 -0
  77. package/src/enso-api/model/layerZeroControllerGetPoolAddressParams.ts +29 -0
  78. package/src/enso-api/model/network.ts +15 -0
  79. package/src/enso-api/model/networksControllerNetworksParams.ts +21 -0
  80. package/src/enso-api/model/nonTokenizedControllerTokens200.ts +15 -0
  81. package/src/enso-api/model/nonTokenizedControllerTokens200AllOf.ts +16 -0
  82. package/src/enso-api/model/nonTokenizedControllerTokensParams.ts +41 -0
  83. package/src/enso-api/model/nonTokenizedModel.ts +27 -0
  84. package/src/enso-api/model/nontokenizedControllerRouteNontokenizedShorcutTransactionParams.ts +64 -0
  85. package/src/enso-api/model/nontokenizedControllerRouteNontokenizedShorcutTransactionRoutingStrategy.ts +22 -0
  86. package/src/enso-api/model/paginatedResult.ts +16 -0
  87. package/src/enso-api/model/paginationMeta.ts +27 -0
  88. package/src/enso-api/model/positionModel.ts +77 -0
  89. package/src/enso-api/model/price.ts +20 -0
  90. package/src/enso-api/model/pricesControllerGetPricesParams.ts +17 -0
  91. package/src/enso-api/model/project.ts +15 -0
  92. package/src/enso-api/model/protocol.ts +15 -0
  93. package/src/enso-api/model/protocolModel.ts +26 -0
  94. package/src/enso-api/model/protocolsControllerFindAllParams.ts +21 -0
  95. package/src/enso-api/model/routeShortcutTransaction.ts +33 -0
  96. package/src/enso-api/model/routeShortcutVariableInputs.ts +68 -0
  97. package/src/enso-api/model/routeShortcutVariableInputsRoutingStrategy.ts +27 -0
  98. package/src/enso-api/model/routeShortcutVariableInputsVariableEstimates.ts +14 -0
  99. package/src/enso-api/model/routerControllerRouteShortcutTransactionParams.ts +91 -0
  100. package/src/enso-api/model/routerControllerRouteShortcutTransactionRoutingStrategy.ts +23 -0
  101. package/src/enso-api/model/standard.ts +18 -0
  102. package/src/enso-api/model/standardAction.ts +20 -0
  103. package/src/enso-api/model/standardActionAction.ts +53 -0
  104. package/src/enso-api/model/tokenModel.ts +36 -0
  105. package/src/enso-api/model/tokensControllerTokens200.ts +15 -0
  106. package/src/enso-api/model/tokensControllerTokens200AllOf.ts +16 -0
  107. package/src/enso-api/model/tokensControllerTokensParams.ts +91 -0
  108. package/src/enso-api/model/tokensControllerTokensType.ts +19 -0
  109. package/src/enso-api/model/transaction.ts +17 -0
  110. package/src/enso-api/model/userOperation.ts +28 -0
  111. package/src/enso-api/model/walletApproveTransaction.ts +24 -0
  112. package/src/enso-api/model/walletApproveTransactionTx.ts +15 -0
  113. package/src/enso-api/model/walletBalance.ts +29 -0
  114. package/src/enso-api/model/walletControllerCreateApproveTransactionParams.ts +35 -0
  115. package/src/enso-api/model/walletControllerCreateApproveTransactionRoutingStrategy.ts +23 -0
  116. package/src/enso-api/model/walletControllerWalletBalancesParams.ts +25 -0
  117. package/src/index.ts +17 -0
  118. package/src/store.ts +68 -0
  119. package/src/types/assets.d.ts +29 -0
  120. package/src/types/index.ts +21 -0
  121. package/src/util/common.tsx +324 -0
  122. package/src/util/constants.tsx +213 -0
  123. package/src/util/enso-hooks.tsx +203 -0
  124. package/src/util/index.tsx +68 -0
  125. package/src/util/tx-tracker.tsx +301 -0
  126. package/src/util/wallet.tsx +258 -0
  127. package/tsconfig.json +13 -0
  128. package/vite.config.ts +51 -0
@@ -0,0 +1,59 @@
1
+ import { Card } from "../ui";
2
+ import { Box, Icon, Image } from "@chakra-ui/react";
3
+ import { ChevronRight } from "lucide-react";
4
+
5
+ const OptionCard = ({
6
+ title,
7
+ limit,
8
+ delay,
9
+ icons,
10
+ onClick,
11
+ }: {
12
+ title: string;
13
+ limit: string;
14
+ delay: string;
15
+ icons: Array<string>;
16
+ onClick: () => void;
17
+ }) => {
18
+ return (
19
+ <Card onClick={onClick}>
20
+ <Box display="flex" alignItems="center" gap="1" minWidth="320px">
21
+ <Box
22
+ display="flex"
23
+ alignItems="center"
24
+ gap="1"
25
+ marginRight="auto"
26
+ >
27
+ <Box>
28
+ <Card.Title>{title}</Card.Title>
29
+ {limit && (
30
+ <Card.Description>
31
+ {limit}
32
+ {delay ? ` - ${delay}` : ""}
33
+ </Card.Description>
34
+ )}
35
+ </Box>
36
+ </Box>
37
+ <Box display={"flex"} position={"relative"}>
38
+ {icons.map((icon, index) => (
39
+ <Image
40
+ w={"32px"}
41
+ position={"relative"}
42
+ zIndex={index}
43
+ right={`${0 - (icons.length - 1 - index) * 10}px`}
44
+ src={icon}
45
+ />
46
+ ))}
47
+ </Box>
48
+ <Icon
49
+ as={ChevronRight}
50
+ color="gray"
51
+ width={"16px"}
52
+ height={"16px"}
53
+ />
54
+ </Box>
55
+ </Card>
56
+ );
57
+ };
58
+
59
+ export default OptionCard;
@@ -0,0 +1,99 @@
1
+ import { FC, PropsWithChildren, ReactElement } from "react";
2
+ import { Card, Tag } from "../ui";
3
+ import {
4
+ Box,
5
+ Icon,
6
+ Image,
7
+ SkeletonCircle,
8
+ SkeletonText,
9
+ } from "@chakra-ui/react";
10
+ import { CheckIcon } from "lucide-react";
11
+
12
+ export enum WalletStatus {
13
+ LOADING = "loading",
14
+ CONNECTED = "connected",
15
+ NONE = "none",
16
+ }
17
+
18
+ const WalletCardSkeleton: FC<PropsWithChildren<{ isLoading: boolean }>> = ({
19
+ children,
20
+ isLoading,
21
+ }) => {
22
+ if (isLoading) {
23
+ return (
24
+ <Box display="flex" alignItems="center" gap="1" minWidth="320px">
25
+ <SkeletonCircle size="8" />
26
+ <Box display="flex" flexDirection="column" gap="1">
27
+ <SkeletonText noOfLines={1} width="80px" />
28
+ <Card.Description>Loading wallet...</Card.Description>
29
+ </Box>
30
+ </Box>
31
+ );
32
+ }
33
+
34
+ return children;
35
+ };
36
+
37
+ const WalletCard = ({
38
+ icon,
39
+ walletHash,
40
+ balance,
41
+ delay,
42
+ status,
43
+ badge,
44
+ onClick,
45
+ }: {
46
+ icon?: ReactElement | string;
47
+ walletHash: string;
48
+ balance: string | number;
49
+ delay: string;
50
+ status: WalletStatus;
51
+ badge?: string;
52
+ onClick?: () => void;
53
+ }) => {
54
+ return (
55
+ <Card onClick={onClick}>
56
+ <WalletCardSkeleton isLoading={status === WalletStatus.LOADING}>
57
+ <Box
58
+ display="flex"
59
+ alignItems="center"
60
+ gap="1"
61
+ minWidth="320px"
62
+ >
63
+ <Box
64
+ display="flex"
65
+ alignItems="center"
66
+ gap="1"
67
+ marginRight="auto"
68
+ >
69
+ {icon &&
70
+ (typeof icon === "string" ? (
71
+ <Image src={icon as string} />
72
+ ) : (
73
+ icon
74
+ ))}
75
+ <Box>
76
+ <Card.Title>{walletHash}</Card.Title>
77
+ {balance && delay && (
78
+ <Card.Description>
79
+ {balance} - {delay}
80
+ </Card.Description>
81
+ )}
82
+ </Box>
83
+ </Box>
84
+ {badge && <Tag>{badge}</Tag>}
85
+ {status === WalletStatus.CONNECTED && (
86
+ <Icon
87
+ as={CheckIcon}
88
+ color="green"
89
+ width={"16px"}
90
+ height={"16px"}
91
+ />
92
+ )}
93
+ </Box>
94
+ </WalletCardSkeleton>
95
+ </Card>
96
+ );
97
+ };
98
+
99
+ export default WalletCard;
@@ -0,0 +1,6 @@
1
+ import AssetCard from "./AssetCard";
2
+ import WalletCard from "./WalletCard";
3
+ import OptionCard from "./OptionCard";
4
+ import ExchangeCard from "./ExchangeCard";
5
+
6
+ export { WalletCard, AssetCard, OptionCard, ExchangeCard };
@@ -0,0 +1,83 @@
1
+ import { FC, PropsWithChildren, ReactElement } from "react";
2
+ import { chakra } from "@chakra-ui/react";
3
+
4
+ export const ModalLayout = chakra("div", {
5
+ base: {
6
+ position: "sticky",
7
+ top: "0px",
8
+ display: "flex",
9
+ flexDirection: "column",
10
+ width: "100vw",
11
+ height: "100vh",
12
+ justifyContent: "center",
13
+ alignItems: "center",
14
+ },
15
+ });
16
+
17
+ export const ModalOverlay = chakra("div", {
18
+ base: {
19
+ zIndex: 1,
20
+ position: "absolute",
21
+ top: "0px",
22
+ left: "0px",
23
+ width: "100vw",
24
+ height: "100vh",
25
+ backgroundColor: "rgba(0, 0, 0, 0.58)",
26
+ },
27
+ });
28
+
29
+ export const ModalWrapper = chakra("div", {
30
+ base: {
31
+ zIndex: 2,
32
+ display: "flex",
33
+ flexDirection: "column",
34
+ width: "100%",
35
+ maxWidth: "374px",
36
+ justifyContent: "center",
37
+ alignItems: "center",
38
+ borderRadius: "lg",
39
+ border: "1px solid",
40
+ borderColor: "gray.300",
41
+ padding: "16px",
42
+ backgroundColor: "white",
43
+ },
44
+ });
45
+
46
+ export const ModalHeaderWrapper = chakra("div", {
47
+ base: {
48
+ display: "flex",
49
+ width: "100%",
50
+ justifyContent: "center",
51
+ alignItems: "center",
52
+ },
53
+ });
54
+
55
+ export const ModalBodyWrapper = chakra("div", {
56
+ base: {
57
+ display: "flex",
58
+ width: "100%",
59
+ justifyContent: "center",
60
+ alignItems: "center",
61
+ },
62
+ });
63
+
64
+ const Modal = ({ children }: { children: ReactElement }) => {
65
+ return (
66
+ <ModalLayout>
67
+ <ModalWrapper>{children}</ModalWrapper>
68
+ <ModalOverlay />
69
+ </ModalLayout>
70
+ );
71
+ };
72
+
73
+ const ModalHeader: FC<PropsWithChildren<{}>> = ({ children }) => {
74
+ return <ModalHeaderWrapper>{children}</ModalHeaderWrapper>;
75
+ };
76
+ Modal.Header = ModalHeader;
77
+
78
+ const ModalBody: FC<PropsWithChildren<{}>> = ({ children }) => {
79
+ return <ModalBodyWrapper>{children}</ModalBodyWrapper>;
80
+ };
81
+ Modal.Body = ModalBody;
82
+
83
+ export default Modal;