@ensofinance/checkout-widget 0.1.8 → 0.1.9
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 +24133 -25422
- package/dist/checkout-widget.umd.js +59 -65
- package/dist/index.d.ts +1 -3
- package/package.json +2 -2
- package/src/assets/usdc.webp +0 -0
- package/src/assets/usdt.webp +0 -0
- package/src/components/AmountInput.tsx +25 -41
- package/src/components/ChakraProvider.tsx +13 -36
- package/src/components/Checkout.tsx +0 -3
- package/src/components/CurrencySwapDisplay.tsx +22 -59
- package/src/components/DepositProcessing.tsx +1 -1
- package/src/components/ExchangeConfirmSecurity.tsx +1 -1
- package/src/components/QuoteParameters.tsx +1 -1
- package/src/components/TransactionDetailRow.tsx +2 -2
- package/src/components/cards/ExchangeCard.tsx +1 -1
- package/src/components/cards/OptionCard.tsx +1 -2
- package/src/components/cards/WalletCard.tsx +1 -1
- package/src/components/modal.tsx +3 -3
- package/src/components/steps/ExchangeFlow.tsx +1404 -231
- package/src/components/steps/FlowSelector.tsx +60 -117
- package/src/components/steps/WalletFlow/WalletAmountStep.tsx +2 -2
- package/src/components/steps/WalletFlow/WalletConfirmStep.tsx +51 -92
- package/src/components/steps/WalletFlow/WalletFlow.tsx +16 -17
- package/src/components/steps/WalletFlow/WalletQuoteStep.tsx +2 -2
- package/src/components/steps/WalletFlow/WalletTokenStep.tsx +4 -6
- package/src/components/ui/index.tsx +6 -23
- package/src/components/ui/toaster.tsx +1 -2
- package/src/types/index.ts +0 -97
- package/src/util/constants.tsx +0 -27
- package/src/util/enso-hooks.tsx +61 -75
- package/dist/checkout-widget.es.js.map +0 -1
- package/dist/checkout-widget.umd.js.map +0 -1
- package/src/assets/providers/alchemypay.svg +0 -21
- package/src/assets/providers/banxa.svg +0 -21
- package/src/assets/providers/binanceconnect.svg +0 -14
- package/src/assets/providers/kryptonim.svg +0 -6
- package/src/assets/providers/mercuryo.svg +0 -21
- package/src/assets/providers/moonpay.svg +0 -14
- package/src/assets/providers/stripe.svg +0 -16
- package/src/assets/providers/swapped.svg +0 -1
- package/src/assets/providers/topper.svg +0 -14
- package/src/assets/providers/transak.svg +0 -21
- package/src/assets/providers/unlimit.svg +0 -21
- package/src/components/steps/CardBuyFlow/CardBuyFlow.tsx +0 -412
- package/src/components/steps/CardBuyFlow/ChooseAmountStep.tsx +0 -352
- package/src/components/steps/CardBuyFlow/OpenWidgetStep.tsx +0 -193
- package/src/components/steps/SmartAccountFlow.tsx +0 -372
- package/src/components/steps/shared/ChooseAmountStep.tsx +0 -325
- package/src/components/steps/shared/SignUserOpStep.tsx +0 -117
- package/src/components/steps/shared/TrackUserOpStep.tsx +0 -625
- package/src/components/steps/shared/exchangeIntegration.ts +0 -19
- package/src/components/steps/shared/types.ts +0 -22
- package/src/components/ui/transitions.tsx +0 -16
- package/src/enso-api/model/bridgeTransactionResponse.ts +0 -37
- package/src/enso-api/model/bridgeTransactionResponseStatus.ts +0 -25
- package/src/enso-api/model/ensoEvent.ts +0 -30
- package/src/enso-api/model/ensoMetadata.ts +0 -23
- package/src/enso-api/model/layerZeroControllerCheckBridgeTransactionParams.ts +0 -21
- package/src/enso-api/model/layerZeroMessageStatus.ts +0 -39
- package/src/enso-api/model/refundDetails.ts +0 -21
- package/src/util/meld-hooks.tsx +0 -533
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ComponentType } from 'react';
|
|
|
2
2
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
3
3
|
import { SystemConfig as WidgetTheme } from '@chakra-ui/react';
|
|
4
4
|
|
|
5
|
-
export declare const Checkout: ({ config: { apiKey, tokenOut, chainIdOut, theme, enableExchange,
|
|
5
|
+
export declare const Checkout: ({ config: { apiKey, tokenOut, chainIdOut, theme, enableExchange, cexBridgeChainMapping, recipient, enforceFlow, slippage, }, onClose, wrapper, }: {
|
|
6
6
|
config: CheckoutConfig;
|
|
7
7
|
wrapper?: ComponentType;
|
|
8
8
|
onClose?: () => void;
|
|
@@ -14,8 +14,6 @@ export declare type CheckoutConfig = {
|
|
|
14
14
|
apiKey: string;
|
|
15
15
|
theme?: WidgetTheme;
|
|
16
16
|
enableExchange?: SupportedExchanges[];
|
|
17
|
-
/** Enable card purchases via MELD onramp */
|
|
18
|
-
enableCardBuy?: boolean;
|
|
19
17
|
/** Override the default CEX bridge chain mapping (maps target chains to intermediate chains for withdrawal + bridge) */
|
|
20
18
|
cexBridgeChainMapping?: Record<number, number>;
|
|
21
19
|
/** Override recipient address (defaults to connected wallet's smart account) */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ensofinance/checkout-widget",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"homepage": "https://www.enso.build/",
|
|
6
6
|
"repository": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"generate-api": "orval",
|
|
22
22
|
"publish": "npm publish --access public",
|
|
23
23
|
"dev": "vite build --watch --mode=dev --minify=false --sourcemap=false --emptyOutDir=false",
|
|
24
|
-
"build": "vite build",
|
|
24
|
+
"build": "vite build --sourcemap=false",
|
|
25
25
|
"preview": "vite preview",
|
|
26
26
|
"build:pump:publish": "npm run bump && npm run build && npm run publish"
|
|
27
27
|
},
|
|
Binary file
|
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Box, Icon,
|
|
1
|
+
import { Box, Icon, Text } from "@chakra-ui/react";
|
|
2
2
|
import { ArrowDownUpIcon } from "lucide-react";
|
|
3
3
|
import { Input, IconButton, Tab } from "@/components/ui";
|
|
4
4
|
import { formatNumber, formatUSD } from "@/util";
|
|
@@ -136,8 +136,6 @@ export const AmountInput = ({
|
|
|
136
136
|
});
|
|
137
137
|
};
|
|
138
138
|
|
|
139
|
-
const isLoading = tokenPriceUsd === undefined && !tokenSymbol;
|
|
140
|
-
|
|
141
139
|
const placeholder = value.mode === "usd" ? "$10.00" : "0.00";
|
|
142
140
|
const displayValue =
|
|
143
141
|
value.mode === "usd"
|
|
@@ -172,28 +170,24 @@ export const AmountInput = ({
|
|
|
172
170
|
padding={"25.5px"}
|
|
173
171
|
>
|
|
174
172
|
{/* Main Input */}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
value={displayValue}
|
|
184
|
-
onChange={(event) => handleInputChange(event.target.value)}
|
|
185
|
-
/>
|
|
186
|
-
)}
|
|
173
|
+
<Input
|
|
174
|
+
inputMode="decimal"
|
|
175
|
+
marginY={"8px"}
|
|
176
|
+
variant={"text"}
|
|
177
|
+
placeholder={placeholder}
|
|
178
|
+
value={displayValue}
|
|
179
|
+
onChange={(event) => handleInputChange(event.target.value)}
|
|
180
|
+
/>
|
|
187
181
|
|
|
188
182
|
{/* Toggle Button and Equivalent Display */}
|
|
189
183
|
<Box
|
|
190
184
|
display={"flex"}
|
|
191
185
|
gap={"3"}
|
|
192
186
|
alignItems={"center"}
|
|
193
|
-
onClick={
|
|
194
|
-
_hover={
|
|
195
|
-
cursor={
|
|
196
|
-
borderRadius={"
|
|
187
|
+
onClick={handleToggleMode}
|
|
188
|
+
_hover={{ background: "bg.subtle" }}
|
|
189
|
+
cursor={"pointer"}
|
|
190
|
+
borderRadius={"lg"}
|
|
197
191
|
px={"3"}
|
|
198
192
|
>
|
|
199
193
|
<IconButton
|
|
@@ -204,20 +198,16 @@ export const AmountInput = ({
|
|
|
204
198
|
>
|
|
205
199
|
<Icon
|
|
206
200
|
as={ArrowDownUpIcon}
|
|
207
|
-
color="
|
|
201
|
+
color="gray"
|
|
208
202
|
width={"16px"}
|
|
209
203
|
height={"16px"}
|
|
210
204
|
/>
|
|
211
205
|
</IconButton>
|
|
212
206
|
|
|
213
207
|
{/* Small equivalent value display */}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
<Text fontSize="sm" color="fg.muted">
|
|
218
|
-
{equivalentValue}
|
|
219
|
-
</Text>
|
|
220
|
-
)}
|
|
208
|
+
<Text fontSize="sm" color="fg.muted">
|
|
209
|
+
{equivalentValue}
|
|
210
|
+
</Text>
|
|
221
211
|
</Box>
|
|
222
212
|
</Box>
|
|
223
213
|
|
|
@@ -228,20 +218,14 @@ export const AmountInput = ({
|
|
|
228
218
|
justifyContent={"center"}
|
|
229
219
|
paddingBottom={"35px"}
|
|
230
220
|
>
|
|
231
|
-
{
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
onClick={() => handlePercentSelect(option.value)}
|
|
240
|
-
>
|
|
241
|
-
{option.label}
|
|
242
|
-
</Tab>
|
|
243
|
-
))
|
|
244
|
-
)}
|
|
221
|
+
{percentOptions.map((option) => (
|
|
222
|
+
<Tab
|
|
223
|
+
key={option.label}
|
|
224
|
+
onClick={() => handlePercentSelect(option.value)}
|
|
225
|
+
>
|
|
226
|
+
{option.label}
|
|
227
|
+
</Tab>
|
|
228
|
+
))}
|
|
245
229
|
</Box>
|
|
246
230
|
)}
|
|
247
231
|
</Box>
|
|
@@ -22,7 +22,7 @@ export const buttonRecipe = defineRecipe({
|
|
|
22
22
|
width: "100%",
|
|
23
23
|
justifyContent: "center",
|
|
24
24
|
alignItems: "center",
|
|
25
|
-
borderRadius: "
|
|
25
|
+
borderRadius: "md",
|
|
26
26
|
},
|
|
27
27
|
variants: {
|
|
28
28
|
variant: {
|
|
@@ -61,11 +61,11 @@ export const selectSlotRecipe = defineSlotRecipe({
|
|
|
61
61
|
slots: selectAnatomy.keys(),
|
|
62
62
|
base: {
|
|
63
63
|
trigger: {
|
|
64
|
-
borderRadius: "
|
|
64
|
+
borderRadius: "6px",
|
|
65
65
|
boxShadow: "none",
|
|
66
66
|
},
|
|
67
67
|
content: {
|
|
68
|
-
borderRadius: "
|
|
68
|
+
borderRadius: "6px",
|
|
69
69
|
boxShadow: "none",
|
|
70
70
|
},
|
|
71
71
|
},
|
|
@@ -278,41 +278,18 @@ export const tableSlotRecipe = defineSlotRecipe({
|
|
|
278
278
|
|
|
279
279
|
export const config = defineConfig({
|
|
280
280
|
theme: {
|
|
281
|
-
tokens: {
|
|
282
|
-
radii: {
|
|
283
|
-
container: { value: "16px" },
|
|
284
|
-
card: { value: "8px" },
|
|
285
|
-
control: { value: "6px" },
|
|
286
|
-
},
|
|
287
|
-
},
|
|
288
|
-
keyframes: {
|
|
289
|
-
fadeSlideUp: {
|
|
290
|
-
from: { opacity: "0", transform: "translateY(6px)" },
|
|
291
|
-
to: { opacity: "1", transform: "translateY(0)" },
|
|
292
|
-
},
|
|
293
|
-
fadeIn: {
|
|
294
|
-
from: { opacity: "0" },
|
|
295
|
-
to: { opacity: "1" },
|
|
296
|
-
},
|
|
297
|
-
},
|
|
298
281
|
semanticTokens: {
|
|
299
282
|
colors: {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
"
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
"
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
"border.emphasized": { value: "#1e171f4d" },
|
|
283
|
+
border: {
|
|
284
|
+
value: "#E4E4E7",
|
|
285
|
+
},
|
|
286
|
+
"border.subtle": {
|
|
287
|
+
value: "#F4F4F5",
|
|
288
|
+
},
|
|
289
|
+
"border.emphasized": {
|
|
290
|
+
value: "#1e171f4d",
|
|
291
|
+
},
|
|
310
292
|
primary: { value: "black" },
|
|
311
|
-
"primary.emphasis": { value: "#000000" },
|
|
312
|
-
"primary.muted": { value: "rgba(0,0,0,0.6)" },
|
|
313
|
-
success: { value: "#10B981" },
|
|
314
|
-
error: { value: "#EF4444" },
|
|
315
|
-
warning: { value: "#F59E0B" },
|
|
316
293
|
customBlack: { value: "#1E171F" },
|
|
317
294
|
customWhite: { value: "#FAFAFA" },
|
|
318
295
|
gray: {
|
|
@@ -369,7 +346,7 @@ const ChakraProvider = ({
|
|
|
369
346
|
globalCss: {
|
|
370
347
|
[varRoot]: {
|
|
371
348
|
...defaultConfig.globalCss?.html,
|
|
372
|
-
borderRadius: "
|
|
349
|
+
borderRadius: "xl",
|
|
373
350
|
shadow: "sm",
|
|
374
351
|
border: "none",
|
|
375
352
|
},
|
|
@@ -14,7 +14,6 @@ import posthog from "posthog-js";
|
|
|
14
14
|
type ICheckoutContext = {
|
|
15
15
|
handleClose: () => void;
|
|
16
16
|
enableExchange?: SupportedExchanges[];
|
|
17
|
-
enableCardBuy?: boolean;
|
|
18
17
|
cexBridgeChainMapping?: Record<number, number>;
|
|
19
18
|
enforceFlow?: EnforceFlow;
|
|
20
19
|
};
|
|
@@ -28,7 +27,6 @@ const Checkout = ({
|
|
|
28
27
|
chainIdOut,
|
|
29
28
|
theme,
|
|
30
29
|
enableExchange,
|
|
31
|
-
enableCardBuy,
|
|
32
30
|
cexBridgeChainMapping,
|
|
33
31
|
recipient,
|
|
34
32
|
enforceFlow,
|
|
@@ -91,7 +89,6 @@ const Checkout = ({
|
|
|
91
89
|
value={{
|
|
92
90
|
handleClose,
|
|
93
91
|
enableExchange,
|
|
94
|
-
enableCardBuy,
|
|
95
92
|
cexBridgeChainMapping,
|
|
96
93
|
enforceFlow,
|
|
97
94
|
}}
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Box,
|
|
3
|
-
chakra,
|
|
4
|
-
Flex,
|
|
5
|
-
Skeleton,
|
|
6
|
-
SkeletonCircle,
|
|
7
|
-
Text,
|
|
8
|
-
} from "@chakra-ui/react";
|
|
1
|
+
import { Box, chakra, Flex, Text } from "@chakra-ui/react";
|
|
9
2
|
import { ChevronRightIcon } from "lucide-react";
|
|
10
3
|
import { Token } from "@/util/common";
|
|
11
4
|
import {
|
|
@@ -191,16 +184,6 @@ const DepositItem = ({
|
|
|
191
184
|
);
|
|
192
185
|
};
|
|
193
186
|
|
|
194
|
-
const SwapItemSkeleton = ({ size = 24 }: { size?: number }) => (
|
|
195
|
-
<Flex align="center" gap={2}>
|
|
196
|
-
<SkeletonCircle size={`${size}px`} />
|
|
197
|
-
<Box>
|
|
198
|
-
<Skeleton height="12px" width="48px" mb={1} borderRadius="card" />
|
|
199
|
-
<Skeleton height="12px" width="36px" borderRadius="card" />
|
|
200
|
-
</Box>
|
|
201
|
-
</Flex>
|
|
202
|
-
);
|
|
203
|
-
|
|
204
187
|
const CurrencySwapDisplay = ({
|
|
205
188
|
tokenIn,
|
|
206
189
|
tokenOut,
|
|
@@ -216,50 +199,30 @@ const CurrencySwapDisplay = ({
|
|
|
216
199
|
isNontokenized?: boolean;
|
|
217
200
|
size?: number;
|
|
218
201
|
}) => {
|
|
219
|
-
const isLoading = !tokenIn || !tokenOut;
|
|
220
|
-
|
|
221
202
|
return (
|
|
222
203
|
<SwapWrapper>
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
204
|
+
<SwapItem
|
|
205
|
+
token={tokenIn}
|
|
206
|
+
chainId={chainIdIn}
|
|
207
|
+
title={"You send"}
|
|
208
|
+
subTitle={tokenIn?.symbol}
|
|
209
|
+
size={size}
|
|
210
|
+
/>
|
|
211
|
+
<ChevronRightIcon
|
|
212
|
+
color={"#707070"}
|
|
213
|
+
width={"16px"}
|
|
214
|
+
height={"16px"}
|
|
215
|
+
/>
|
|
216
|
+
{isNontokenized && tokenOut?.protocol ? (
|
|
217
|
+
<DepositItem token={tokenOut} chainId={chainIdOut} size={size} />
|
|
233
218
|
) : (
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
/>
|
|
242
|
-
<ChevronRightIcon
|
|
243
|
-
color={"var(--chakra-colors-fg-muted)"}
|
|
244
|
-
width={"16px"}
|
|
245
|
-
height={"16px"}
|
|
246
|
-
/>
|
|
247
|
-
{isNontokenized && tokenOut?.protocol ? (
|
|
248
|
-
<DepositItem
|
|
249
|
-
token={tokenOut}
|
|
250
|
-
chainId={chainIdOut}
|
|
251
|
-
size={size}
|
|
252
|
-
/>
|
|
253
|
-
) : (
|
|
254
|
-
<SwapItem
|
|
255
|
-
token={tokenOut}
|
|
256
|
-
chainId={chainIdOut}
|
|
257
|
-
title={"You receive"}
|
|
258
|
-
subTitle={tokenOut?.symbol}
|
|
259
|
-
size={size}
|
|
260
|
-
/>
|
|
261
|
-
)}
|
|
262
|
-
</>
|
|
219
|
+
<SwapItem
|
|
220
|
+
token={tokenOut}
|
|
221
|
+
chainId={chainIdOut}
|
|
222
|
+
title={"You receive"}
|
|
223
|
+
subTitle={tokenOut?.symbol}
|
|
224
|
+
size={size}
|
|
225
|
+
/>
|
|
263
226
|
)}
|
|
264
227
|
</SwapWrapper>
|
|
265
228
|
);
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
SupportedChainId,
|
|
26
26
|
} from "@/util/constants";
|
|
27
27
|
import { useMemo } from "react";
|
|
28
|
-
import { EXCHANGE_ICON_BY_TYPE } from "@/components/steps/
|
|
28
|
+
import { EXCHANGE_ICON_BY_TYPE } from "@/components/steps/ExchangeFlow";
|
|
29
29
|
|
|
30
30
|
export const ERROR_MSG =
|
|
31
31
|
"Swap not found for a required underlying of defi route, please make sure your amount is within an acceptable range";
|
|
@@ -12,7 +12,7 @@ export const DetailRowContainer = chakra("div", {
|
|
|
12
12
|
alignItems: "center",
|
|
13
13
|
h: "36px",
|
|
14
14
|
p: "8px 12px",
|
|
15
|
-
borderRadius: "
|
|
15
|
+
borderRadius: "8px",
|
|
16
16
|
bg: "bg",
|
|
17
17
|
w: "100%",
|
|
18
18
|
},
|
|
@@ -57,7 +57,7 @@ export const TransactionDetailRow = () => {
|
|
|
57
57
|
<Box
|
|
58
58
|
width="100%"
|
|
59
59
|
bg="bg.subtle"
|
|
60
|
-
borderRadius="
|
|
60
|
+
borderRadius="md"
|
|
61
61
|
padding="12px"
|
|
62
62
|
transition="all 0.2s"
|
|
63
63
|
>
|
|
@@ -32,7 +32,7 @@ const ExchangeCard: FC<IProps> = ({
|
|
|
32
32
|
),
|
|
33
33
|
low: <Tag>Low Balance</Tag>,
|
|
34
34
|
connected: (
|
|
35
|
-
<Icon as={CheckIcon} color="
|
|
35
|
+
<Icon as={CheckIcon} color="green" width={"16px"} height={"16px"} />
|
|
36
36
|
),
|
|
37
37
|
none: null,
|
|
38
38
|
};
|
|
@@ -39,7 +39,6 @@ const OptionCard = ({
|
|
|
39
39
|
<Image
|
|
40
40
|
w={"32px"}
|
|
41
41
|
h={"32px"}
|
|
42
|
-
objectFit={"contain"}
|
|
43
42
|
borderRadius={"full"}
|
|
44
43
|
position={"relative"}
|
|
45
44
|
zIndex={index}
|
|
@@ -50,7 +49,7 @@ const OptionCard = ({
|
|
|
50
49
|
</Box>
|
|
51
50
|
<Icon
|
|
52
51
|
as={ChevronRight}
|
|
53
|
-
color="
|
|
52
|
+
color="gray"
|
|
54
53
|
width={"16px"}
|
|
55
54
|
height={"16px"}
|
|
56
55
|
/>
|
package/src/components/modal.tsx
CHANGED
|
@@ -35,11 +35,11 @@ export const ModalWrapper = chakra("div", {
|
|
|
35
35
|
maxWidth: "374px",
|
|
36
36
|
justifyContent: "center",
|
|
37
37
|
alignItems: "center",
|
|
38
|
-
borderRadius: "
|
|
38
|
+
borderRadius: "lg",
|
|
39
39
|
border: "1px solid",
|
|
40
|
-
borderColor: "
|
|
40
|
+
borderColor: "gray.300",
|
|
41
41
|
padding: "16px",
|
|
42
|
-
backgroundColor: "
|
|
42
|
+
backgroundColor: "white",
|
|
43
43
|
},
|
|
44
44
|
});
|
|
45
45
|
|