@ensofinance/checkout-widget 0.0.13 → 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.
Files changed (143) hide show
  1. package/dist/checkout-widget.es.js +8421 -8103
  2. package/dist/checkout-widget.es.js.map +1 -1
  3. package/dist/checkout-widget.umd.js +31 -31
  4. package/dist/checkout-widget.umd.js.map +1 -1
  5. package/dist/index.d.ts +7 -0
  6. package/orval.config.ts +40 -6
  7. package/package.json +1 -1
  8. package/src/components/BridgeFee.tsx +3 -3
  9. package/src/components/Checkout.tsx +2 -2
  10. package/src/components/ExchangeConfirmSecurity.tsx +16 -3
  11. package/src/components/QuoteParameters.tsx +33 -18
  12. package/src/components/TransactionDetailRow.tsx +6 -5
  13. package/src/components/cards/AssetCard.tsx +2 -2
  14. package/src/components/cards/OptionCard.tsx +2 -0
  15. package/src/components/steps/ExchangeFlow.tsx +254 -96
  16. package/src/components/steps/FlowSelector.tsx +26 -10
  17. package/src/components/steps/WalletFlow/WalletAmountStep.tsx +22 -23
  18. package/src/components/steps/WalletFlow/WalletTokenStep.tsx +5 -3
  19. package/src/components/ui/index.tsx +0 -3
  20. package/src/enso-api/api.ts +144 -3
  21. package/src/enso-api/custom-instance.ts +1 -0
  22. package/src/enso-api/index.ts +29 -118
  23. package/src/enso-api/model/approveActionDto.ts +17 -0
  24. package/src/enso-api/model/approveArgsDto.ts +22 -0
  25. package/src/enso-api/model/approveArgsDtoAmount.ts +16 -0
  26. package/src/enso-api/model/balanceActionDto.ts +17 -0
  27. package/src/enso-api/model/balanceArgsDto.ts +15 -0
  28. package/src/enso-api/model/borrowActionDto.ts +18 -0
  29. package/src/enso-api/model/borrowArgsDto.ts +22 -0
  30. package/src/enso-api/model/borrowArgsDtoAmountOut.ts +16 -0
  31. package/src/enso-api/model/bridgeActionDto.ts +19 -0
  32. package/src/enso-api/model/bridgeArgsDto.ts +29 -0
  33. package/src/enso-api/model/bridgeArgsDtoAmountIn.ts +16 -0
  34. package/src/enso-api/model/bridgeArgsDtoCallbackItem.ts +64 -0
  35. package/src/enso-api/model/bundleControllerBundleShortcutTransactionBodyItem.ts +69 -0
  36. package/src/enso-api/model/callActionDto.ts +18 -0
  37. package/src/enso-api/model/callArgsDto.ts +29 -0
  38. package/src/enso-api/model/callArgsDtoArgsItem.ts +17 -0
  39. package/src/enso-api/model/callArgsDtoArgsItemAnyOf.ts +12 -0
  40. package/src/enso-api/model/callArgsDtoValue.ts +16 -0
  41. package/src/enso-api/model/callOutput.ts +15 -0
  42. package/src/enso-api/model/depositActionDto.ts +18 -0
  43. package/src/enso-api/model/depositArgsDto.ts +28 -0
  44. package/src/enso-api/model/depositArgsDtoAmountIn.ts +20 -0
  45. package/src/enso-api/model/depositArgsDtoAmountInOneOfItem.ts +13 -0
  46. package/src/enso-api/model/depositArgsDtoTokenIn.ts +15 -0
  47. package/src/enso-api/model/depositArgsDtoTokenOut.ts +15 -0
  48. package/src/enso-api/model/depositCLMMActionDto.ts +18 -0
  49. package/src/enso-api/model/depositCLMMArgsDto.ts +30 -0
  50. package/src/enso-api/model/depositCLMMArgsDtoAmountInItem.ts +17 -0
  51. package/src/enso-api/model/depositCLMMArgsDtoAmountInItemAnyOf.ts +12 -0
  52. package/src/enso-api/model/ensoFeeActionDto.ts +17 -0
  53. package/src/enso-api/model/ensoFeeArgsDto.ts +20 -0
  54. package/src/enso-api/model/ensoFeeArgsDtoAmount.ts +16 -0
  55. package/src/enso-api/model/feeActionDto.ts +17 -0
  56. package/src/enso-api/model/feeArgsDto.ts +22 -0
  57. package/src/enso-api/model/feeArgsDtoAmount.ts +16 -0
  58. package/src/enso-api/model/harvestActionDto.ts +19 -0
  59. package/src/enso-api/model/harvestArgsDto.ts +17 -0
  60. package/src/enso-api/model/index.ts +115 -4
  61. package/src/enso-api/model/mergeActionDto.ts +17 -0
  62. package/src/enso-api/model/mergeArgsDto.ts +22 -0
  63. package/src/enso-api/model/mergeArgsDtoAmountInItem.ts +13 -0
  64. package/src/enso-api/model/minAmountOutActionDto.ts +17 -0
  65. package/src/enso-api/model/minAmountOutArgsDto.ts +19 -0
  66. package/src/enso-api/model/minAmountOutArgsDtoAmountOut.ts +16 -0
  67. package/src/enso-api/model/minAmountOutArgsDtoMinAmountOut.ts +16 -0
  68. package/src/enso-api/model/multiDepositActionDto.ts +18 -0
  69. package/src/enso-api/model/multiDepositArgsDto.ts +24 -0
  70. package/src/enso-api/model/multiDepositArgsDtoAmountInItem.ts +17 -0
  71. package/src/enso-api/model/multiDepositArgsDtoAmountInItemAnyOf.ts +12 -0
  72. package/src/enso-api/model/multiOutSingleDepositActionDto.ts +18 -0
  73. package/src/enso-api/model/multiOutSingleDepositArgsDto.ts +24 -0
  74. package/src/enso-api/model/multiOutSingleDepositArgsDtoAmountIn.ts +16 -0
  75. package/src/enso-api/model/multiRedeemActionDto.ts +18 -0
  76. package/src/enso-api/model/multiRedeemArgs2Dto.ts +24 -0
  77. package/src/enso-api/model/multiRedeemArgs2DtoAmountIn.ts +16 -0
  78. package/src/enso-api/model/nontokenizedControllerRouteNontokenizedShorcutTransactionParams.ts +8 -0
  79. package/src/enso-api/model/nontokenizedControllerRouteNontokenizedShorcutTransactionRoutingStrategy.ts +1 -0
  80. package/src/enso-api/model/nontokenizedRouteShortcutTransaction.ts +31 -0
  81. package/src/enso-api/model/paymasterFeeActionDto.ts +17 -0
  82. package/src/enso-api/model/paymasterFeeArgsDto.ts +18 -0
  83. package/src/enso-api/model/paymasterFeeArgsDtoAmount.ts +16 -0
  84. package/src/enso-api/model/permitTransferFromActionDto.ts +18 -0
  85. package/src/enso-api/model/permitTransferFromArgsDto.ts +29 -0
  86. package/src/enso-api/model/permitTransferFromArgsDtoAmount.ts +20 -0
  87. package/src/enso-api/model/permitTransferFromArgsDtoAmountOneOfItem.ts +13 -0
  88. package/src/enso-api/model/permitTransferFromArgsDtoToken.ts +15 -0
  89. package/src/enso-api/model/positionModel.ts +14 -0
  90. package/src/enso-api/model/redeemActionDto.ts +18 -0
  91. package/src/enso-api/model/redeemArgsDto.ts +25 -0
  92. package/src/enso-api/model/redeemArgsDtoAmountIn.ts +16 -0
  93. package/src/enso-api/model/redeemArgsDtoTokenOut.ts +15 -0
  94. package/src/enso-api/model/redeemCLMMActionDto.ts +18 -0
  95. package/src/enso-api/model/redeemCLMMArgsDto.ts +24 -0
  96. package/src/enso-api/model/redeemCLMMArgsDtoLiquidity.ts +16 -0
  97. package/src/enso-api/model/repayActionDto.ts +18 -0
  98. package/src/enso-api/model/repayArgsDto.ts +22 -0
  99. package/src/enso-api/model/repayArgsDtoAmountIn.ts +16 -0
  100. package/src/enso-api/model/routeActionDto.ts +20 -0
  101. package/src/enso-api/model/routeArgsDto.ts +38 -0
  102. package/src/enso-api/model/routeArgsDtoAmountIn.ts +16 -0
  103. package/src/enso-api/model/singleDepositActionDto.ts +18 -0
  104. package/src/enso-api/model/singleDepositArgsDto.ts +24 -0
  105. package/src/enso-api/model/singleDepositArgsDtoAmountIn.ts +16 -0
  106. package/src/enso-api/model/singleRedeemActionDto.ts +18 -0
  107. package/src/enso-api/model/singleRedeemArgs2Dto.ts +24 -0
  108. package/src/enso-api/model/singleRedeemArgs2DtoAmountIn.ts +16 -0
  109. package/src/enso-api/model/slippageActionDto.ts +17 -0
  110. package/src/enso-api/model/slippageArgsDto.ts +18 -0
  111. package/src/enso-api/model/slippageArgsDtoAmountOut.ts +16 -0
  112. package/src/enso-api/model/splitActionDto.ts +17 -0
  113. package/src/enso-api/model/splitArgsDto.ts +22 -0
  114. package/src/enso-api/model/splitArgsDtoAmountIn.ts +16 -0
  115. package/src/enso-api/model/swapActionDto.ts +18 -0
  116. package/src/enso-api/model/swapArgsDto.ts +30 -0
  117. package/src/enso-api/model/swapArgsDtoAmountIn.ts +16 -0
  118. package/src/enso-api/model/tokenizedMultiDepositActionDto.ts +18 -0
  119. package/src/enso-api/model/tokenizedMultiDepositArgsDto.ts +24 -0
  120. package/src/enso-api/model/tokenizedMultiDepositArgsDtoAmountInItem.ts +17 -0
  121. package/src/enso-api/model/tokenizedMultiDepositArgsDtoAmountInItemAnyOf.ts +14 -0
  122. package/src/enso-api/model/tokenizedMultiRedeemActionDto.ts +18 -0
  123. package/src/enso-api/model/tokenizedMultiRedeemArgsDto.ts +24 -0
  124. package/src/enso-api/model/tokenizedMultiRedeemArgsDtoAmountIn.ts +16 -0
  125. package/src/enso-api/model/tokenizedSingleDepositActionDto.ts +18 -0
  126. package/src/enso-api/model/tokenizedSingleDepositArgsDto.ts +24 -0
  127. package/src/enso-api/model/tokenizedSingleDepositArgsDtoAmountIn.ts +16 -0
  128. package/src/enso-api/model/tokenizedSingleRedeemActionDto.ts +18 -0
  129. package/src/enso-api/model/tokenizedSingleRedeemArgsDto.ts +24 -0
  130. package/src/enso-api/model/tokenizedSingleRedeemArgsDtoAmountIn.ts +16 -0
  131. package/src/enso-api/model/tokensControllerTokensLiquidityType.ts +19 -0
  132. package/src/enso-api/model/tokensControllerTokensParams.ts +6 -0
  133. package/src/enso-api/model/transferActionDto.ts +18 -0
  134. package/src/enso-api/model/transferArgsDto.ts +22 -0
  135. package/src/enso-api/model/transferArgsDtoAmount.ts +16 -0
  136. package/src/enso-api/model/transferFromActionDto.ts +18 -0
  137. package/src/enso-api/model/transferFromArgsDto.ts +24 -0
  138. package/src/enso-api/model/transferFromArgsDtoAmount.ts +16 -0
  139. package/src/index.ts +1 -0
  140. package/src/store.ts +12 -5
  141. package/src/types/index.ts +9 -3
  142. package/src/util/common.tsx +2 -0
  143. package/src/util/enso-hooks.tsx +72 -11
package/dist/index.d.ts CHANGED
@@ -16,6 +16,13 @@ export declare const CheckoutModal: ({ config, setIsActive, isActive, onClose, }
16
16
 
17
17
  export { CheckoutModalProps }
18
18
 
19
+ export declare enum SupportedExchanges {
20
+ Binance = "binance",
21
+ Kraken = "kraken",
22
+ Coinbase = "coinbase",
23
+ Bybit = "bybit"
24
+ }
25
+
19
26
  export { WidgetTheme }
20
27
 
21
28
  export { }
package/orval.config.ts CHANGED
@@ -8,11 +8,9 @@ export default {
8
8
  schemas: "src/enso-api/model",
9
9
  client: "react-query",
10
10
  override: {
11
- query: {
12
- options: {
13
- refetchInterval: 30_000,
14
- retry: 2,
15
- },
11
+ queryOptions: {
12
+ refetchInterval: 30_000,
13
+ retry: 2,
16
14
  },
17
15
  mutator: {
18
16
  path: "./src/enso-api/custom-instance.ts",
@@ -20,6 +18,42 @@ export default {
20
18
  },
21
19
  },
22
20
  },
23
- input: "https://api.enso.finance/api-yaml",
21
+ input: {
22
+ target: "https://api.enso.finance/api-yaml",
23
+ override: {
24
+ transformer: (spec: any) => {
25
+ // Fix all malformed array schemas that have items: { type: 'array' } without proper definition
26
+ const fixArraySchema = (obj: any) => {
27
+ if (!obj || typeof obj !== 'object') return;
28
+
29
+ // Fix array items that are themselves arrays without proper items definition
30
+ if (obj.type === 'array' && obj.items?.type === 'array' && !obj.items.items) {
31
+ obj.items = {
32
+ anyOf: [
33
+ { type: 'string' },
34
+ { type: 'number' },
35
+ { type: 'boolean' },
36
+ { type: 'object' },
37
+ ]
38
+ };
39
+ }
40
+
41
+ // Recursively fix nested objects
42
+ for (const key in obj) {
43
+ if (obj.hasOwnProperty(key)) {
44
+ fixArraySchema(obj[key]);
45
+ }
46
+ }
47
+ };
48
+
49
+ // Apply fix to all schemas
50
+ if (spec.components?.schemas) {
51
+ fixArraySchema(spec.components.schemas);
52
+ }
53
+
54
+ return spec;
55
+ }
56
+ }
57
+ },
24
58
  },
25
59
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ensofinance/checkout-widget",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "type": "module",
5
5
  "homepage": "https://www.enso.build/",
6
6
  "repository": {
@@ -13,7 +13,7 @@ import { Fuel } from "lucide-react";
13
13
  import { Tooltip } from "./ui/tooltip";
14
14
 
15
15
  const BridgingFee = () => {
16
- const { routerData } = useRouteData();
16
+ const { routeData } = useRouteData();
17
17
  const { tokenIn, chainIdIn, amountIn } = useAppDetails();
18
18
  const { data: nativeTokenPriceData } = useEnsoPrice(chainIdIn, ETH_ADDRESS);
19
19
  const {
@@ -21,14 +21,14 @@ const BridgingFee = () => {
21
21
  } = useEnsoToken(ETH_ADDRESS, chainIdIn);
22
22
 
23
23
  const gasValue = useMemo(() => {
24
- let txCost = +(routerData?.tx?.value ?? 0);
24
+ let txCost = +(routeData?.tx?.value ?? 0);
25
25
 
26
26
  if (compareCaseInsensitive(tokenIn, ETH_ADDRESS)) {
27
27
  txCost -= +amountIn;
28
28
  }
29
29
 
30
30
  return normalizeValue(Math.max(0, txCost).toString(), 18);
31
- }, [routerData?.tx?.value, tokenIn, amountIn]);
31
+ }, [routeData?.tx?.value, tokenIn, amountIn]);
32
32
 
33
33
  const gasCostUSD = +gasValue * +(nativeTokenPriceData ?? 0);
34
34
 
@@ -9,7 +9,7 @@ import { type CheckoutConfig, type SupportedExchanges } from "@/types";
9
9
  type ICheckoutContext = {
10
10
  handleClose: () => void;
11
11
 
12
- enableExchanges?: SupportedExchanges[];
12
+ enableExchange?: SupportedExchanges[];
13
13
  };
14
14
 
15
15
  const CheckoutContext = createContext<ICheckoutContext>({} as ICheckoutContext);
@@ -64,7 +64,7 @@ const Checkout = ({
64
64
  <CheckoutContext.Provider
65
65
  value={{
66
66
  handleClose,
67
- enableExchanges: enableExchange,
67
+ enableExchange,
68
68
  }}
69
69
  >
70
70
  <ChakraProvider themeConfig={theme}>
@@ -45,11 +45,24 @@ const SecurityFeature = ({
45
45
  </Box>
46
46
  );
47
47
 
48
- const ConfirmExchangeStep = ({ onConfirm }: { onConfirm: () => void }) => {
48
+ const ConfirmExchangeStep = ({
49
+ onConfirm,
50
+ exchangeName = "your exchange",
51
+ exchangeIcon,
52
+ }: {
53
+ onConfirm: () => void;
54
+ exchangeName?: string;
55
+ exchangeIcon?: string;
56
+ }) => {
49
57
  return (
50
58
  <BodyWrapper>
51
59
  <Box display="flex" justifyContent="center" width="100%">
52
- <Image w={"48px"} src={BinanceIcon} />
60
+ <Image
61
+ w={"48px"}
62
+ h={"48px"}
63
+ borderRadius={"full"}
64
+ src={exchangeIcon || BinanceIcon}
65
+ />
53
66
  </Box>
54
67
 
55
68
  <Box
@@ -59,7 +72,7 @@ const ConfirmExchangeStep = ({ onConfirm }: { onConfirm: () => void }) => {
59
72
  color="fg"
60
73
  textAlign="center"
61
74
  >
62
- Enso Checkout uses a 3rd party to connect your Binance account.
75
+ Enso Checkout uses a 3rd party to connect your {exchangeName} account.
63
76
  </Box>
64
77
 
65
78
  <Box display="flex" flexDirection="column" gap="12px" width="100%">
@@ -24,11 +24,8 @@ import {
24
24
  STARGATE_CHAIN_NAMES,
25
25
  SupportedChainId,
26
26
  } from "@/util/constants";
27
- import { useAppStore } from "@/store";
28
- // @ts-ignore
29
- import BinanceBadge from "../assets/BinanceBadge.svg";
30
27
  import { useMemo } from "react";
31
- import { ExchangeNames, ExchangeType } from "@/components/steps/ExchangeFlow";
28
+ import { EXCHANGE_ICON_BY_TYPE } from "@/components/steps/ExchangeFlow";
32
29
 
33
30
  export const ERROR_MSG =
34
31
  "Swap not found for a required underlying of defi route, please make sure your amount is within an acceptable range";
@@ -101,11 +98,16 @@ const TokenIcon = ({
101
98
  const QuoteParameters = () => {
102
99
  const { address } = useAccount();
103
100
  const { walletIcon, walletDisplayName } = useWalletIcon();
104
- const { chainIdOut, tokenOutData, tokenInData, amountIn, chainIdIn } =
105
- useAppDetails();
101
+ const {
102
+ chainIdOut,
103
+ effectiveTokenOutData,
104
+ tokenInData,
105
+ amountIn,
106
+ chainIdIn,
107
+ selectedIntegration,
108
+ } = useAppDetails();
106
109
  const { routeLoading, routeData, routeFetched, routerError } =
107
110
  useRouteData();
108
- const { activeExchange } = useAppStore();
109
111
  const showRouteLoading = routeLoading || (!routeFetched && !routerError);
110
112
 
111
113
  const routeErrorMessage: string | null =
@@ -126,16 +128,23 @@ const QuoteParameters = () => {
126
128
  });
127
129
 
128
130
  const sourceInfo = useMemo(() => {
129
- if (activeExchange === ExchangeType.binance)
131
+ if (selectedIntegration?.type) {
132
+ const icon = EXCHANGE_ICON_BY_TYPE[selectedIntegration.type];
133
+ const name = selectedIntegration.name || selectedIntegration.type;
130
134
  return (
131
135
  <>
132
- <Image src={BinanceBadge} width={"16px"} height={"16px"} />
133
- <Text>Binance</Text>
136
+ {icon && (
137
+ <Image
138
+ src={icon}
139
+ width={"16px"}
140
+ height={"16px"}
141
+ borderRadius={"full"}
142
+ />
143
+ )}
144
+ <Text>{name}</Text>
134
145
  </>
135
146
  );
136
-
137
- if (activeExchange === ExchangeType.delayed)
138
- return <Text>{ExchangeNames[ExchangeType.delayed]}</Text>;
147
+ }
139
148
 
140
149
  return (
141
150
  <>
@@ -164,7 +173,13 @@ const QuoteParameters = () => {
164
173
  )}
165
174
  </>
166
175
  );
167
- }, [activeExchange]);
176
+ }, [
177
+ selectedIntegration,
178
+ walletIcon,
179
+ walletDisplayName,
180
+ address,
181
+ inWalletUrl,
182
+ ]);
168
183
 
169
184
  return (
170
185
  <>
@@ -247,7 +262,7 @@ const QuoteParameters = () => {
247
262
  width={showRouteLoading ? "80px" : "auto"}
248
263
  >
249
264
  <Text>
250
- {activeExchange === "binance"
265
+ {selectedIntegration?.type
251
266
  ? `~2min`
252
267
  : chainIdIn !== chainIdOut
253
268
  ? `~1 min`
@@ -321,13 +336,13 @@ const QuoteParameters = () => {
321
336
  {formatNumber(
322
337
  normalizeValue(
323
338
  routeData?.amountOut,
324
- tokenOutData?.decimals,
339
+ effectiveTokenOutData?.decimals,
325
340
  ),
326
341
  )}{" "}
327
- {tokenOutData?.symbol}
342
+ {effectiveTokenOutData?.symbol}
328
343
  </Text>
329
344
  <TokenIcon
330
- token={tokenOutData}
345
+ token={effectiveTokenOutData}
331
346
  chainId={chainIdOut}
332
347
  size={24}
333
348
  />
@@ -19,13 +19,14 @@ export const DetailRowContainer = chakra("div", {
19
19
  });
20
20
 
21
21
  export const TransactionDetailRow = () => {
22
- const { routerData } = useRouteData();
23
- const { chainIdIn, chainIdOut, isCheckout } = useAppDetails();
22
+ const { routeData } = useRouteData();
23
+ const { chainIdIn, chainIdOut, selectedIntegration } = useAppDetails();
24
+
24
25
  const slippage = useAppStore((state) => state.slippage);
25
26
  const [isExpanded, setIsExpanded] = useState(false);
26
27
 
27
- const formattedPriceImpact = routerData?.priceImpact
28
- ? (-routerData?.priceImpact / 100).toFixed(2)
28
+ const formattedPriceImpact = routeData?.priceImpact
29
+ ? (-routeData?.priceImpact / 100).toFixed(2)
29
30
  : "0.00";
30
31
 
31
32
  const detailItems = [
@@ -38,7 +39,7 @@ export const TransactionDetailRow = () => {
38
39
  label: "Max. slippage",
39
40
  },
40
41
  {
41
- detail: isCheckout
42
+ detail: selectedIntegration?.type
42
43
  ? `~2min`
43
44
  : chainIdIn !== chainIdOut
44
45
  ? `~1 min`
@@ -80,13 +80,13 @@ const AssetCard = ({
80
80
  }: {
81
81
  icon?: ReactElement | string;
82
82
  title: string;
83
- balance: string | number;
83
+ balance?: string | number;
84
84
  usdBalance: string;
85
85
  tag: string;
86
86
  loading: boolean;
87
87
  selected: boolean;
88
88
  onClick: () => void;
89
- chainId: number;
89
+ chainId?: number;
90
90
  }) => {
91
91
  return (
92
92
  <Card
@@ -38,6 +38,8 @@ const OptionCard = ({
38
38
  {icons.map((icon, index) => (
39
39
  <Image
40
40
  w={"32px"}
41
+ h={"32px"}
42
+ borderRadius={"full"}
41
43
  position={"relative"}
42
44
  zIndex={index}
43
45
  right={`${0 - (icons.length - 1 - index) * 10}px`}