@ensofinance/checkout-widget 0.1.5 → 0.1.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ensofinance/checkout-widget",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "type": "module",
5
5
  "homepage": "https://www.enso.build/",
6
6
  "repository": {
@@ -159,18 +159,18 @@ export enum WithdrawalStep {
159
159
  InitiateWithdrawal,
160
160
  TrackUserOp,
161
161
  }
162
- const withdrawalSteps = [
163
- WithdrawalStep.ChooseExchange,
164
- WithdrawalStep.ChooseExchangeAsset,
165
- WithdrawalStep.ChooseAmount,
166
- WithdrawalStep.SignUserOp,
167
- WithdrawalStep.InitiateWithdrawal,
168
- ];
169
- const balanceSteps = [
170
- WithdrawalStep.ChooseBalanceAsset,
171
- WithdrawalStep.ChooseAmount,
172
- WithdrawalStep.SignUserOp,
173
- ];
162
+ const withdrawalPreviousStep: Partial<Record<WithdrawalStep, WithdrawalStep>> =
163
+ {
164
+ [WithdrawalStep.CheckSessionKey]: WithdrawalStep.ChooseExchange,
165
+ [WithdrawalStep.ChooseExchangeAsset]: WithdrawalStep.ChooseExchange,
166
+ [WithdrawalStep.ChooseAmount]: WithdrawalStep.ChooseExchangeAsset,
167
+ [WithdrawalStep.SignUserOp]: WithdrawalStep.ChooseAmount,
168
+ [WithdrawalStep.InitiateWithdrawal]: WithdrawalStep.SignUserOp,
169
+ };
170
+ const balancePreviousStep: Partial<Record<WithdrawalStep, WithdrawalStep>> = {
171
+ [WithdrawalStep.ChooseAmount]: WithdrawalStep.ChooseBalanceAsset,
172
+ [WithdrawalStep.SignUserOp]: WithdrawalStep.ChooseAmount,
173
+ };
174
174
  // Integration details are fetched dynamically from Mesh API.
175
175
 
176
176
  // Mesh network IDs for EVM chains (from Mesh networks API)
@@ -901,7 +901,9 @@ const ChooseAmountStep = ({
901
901
  }
902
902
 
903
903
  try {
904
- setAmountIn(denormalizeValue(normalizedAmount, tokenInData.decimals));
904
+ setAmountIn(
905
+ denormalizeValue(normalizedAmount, tokenInData.decimals),
906
+ );
905
907
  } catch (error) {
906
908
  setAmountIn("0");
907
909
  }
@@ -918,7 +920,7 @@ const ChooseAmountStep = ({
918
920
 
919
921
  // Limits validation logic - only for CEX withdrawals
920
922
  const currentUsdValue = hasUsdValue
921
- ? getPositiveDecimalValue(usdValue) ?? 0
923
+ ? (getPositiveDecimalValue(usdValue) ?? 0)
922
924
  : 0;
923
925
  const minValueForToken =
924
926
  isWithdrawal && selectedToken
@@ -992,9 +994,7 @@ const ChooseAmountStep = ({
992
994
  fontSize="xs"
993
995
  h={3}
994
996
  m={-1}
995
- visibility={
996
- isAmountInvalid ? "visible" : "hidden"
997
- }
997
+ visibility={isAmountInvalid ? "visible" : "hidden"}
998
998
  >
999
999
  {!hasPositiveAmount
1000
1000
  ? "Please enter an amount"
@@ -1270,7 +1270,14 @@ const InitiateWithdrawalStep = ({
1270
1270
  if (error) {
1271
1271
  return (
1272
1272
  <BodyWrapper>
1273
- <Flex direction="column" align="center" justify="center" flex={1} p={6} gap={4}>
1273
+ <Flex
1274
+ direction="column"
1275
+ align="center"
1276
+ justify="center"
1277
+ flex={1}
1278
+ p={6}
1279
+ gap={4}
1280
+ >
1274
1281
  <Flex
1275
1282
  align="center"
1276
1283
  justify="center"
@@ -1279,7 +1286,11 @@ const InitiateWithdrawalStep = ({
1279
1286
  borderRadius="full"
1280
1287
  bg="orange.100"
1281
1288
  >
1282
- <Icon as={TriangleAlert} boxSize={6} color="orange.500" />
1289
+ <Icon
1290
+ as={TriangleAlert}
1291
+ boxSize={6}
1292
+ color="orange.500"
1293
+ />
1283
1294
  </Flex>
1284
1295
  <Text fontSize="md" textAlign="center" color="gray.700">
1285
1296
  {error}
@@ -2035,15 +2046,15 @@ const ExchangeFlow = ({
2035
2046
  minHeight={"16px"}
2036
2047
  maxWidth={"16px"}
2037
2048
  onClick={() => {
2038
- const index =
2039
- (selectedIntegration?.type === "delayed"
2040
- ? balanceSteps
2041
- : withdrawalSteps
2042
- ).findIndex(
2043
- (step) => step === currentStep,
2044
- ) - 1;
2045
- if (index >= 0) {
2046
- setCurrentStep(withdrawalSteps[index]);
2049
+ const previousStep = (
2050
+ isDelayedBalanceUsed(
2051
+ selectedIntegration?.type,
2052
+ )
2053
+ ? balancePreviousStep
2054
+ : withdrawalPreviousStep
2055
+ )[currentStep];
2056
+ if (previousStep !== undefined) {
2057
+ setCurrentStep(previousStep);
2047
2058
  } else {
2048
2059
  setFlow("");
2049
2060
  }
@@ -15,8 +15,16 @@ const WalletAssetStep = ({ setStep }: { setStep: (step: string) => void }) => {
15
15
  const tokenIn = useAppStore((state) => state.tokenIn);
16
16
  const setChainIdIn = useAppStore((state) => state.setChainIdIn);
17
17
  const chainIdIn = useAppStore((state) => state.chainIdIn);
18
+ const tokenOut = useAppStore((state) => state.tokenOut);
19
+ const chainIdOut = useAppStore((state) => state.chainIdOut);
18
20
  const { holdingsList, isLoading } = useWalletBalance();
19
21
 
22
+ const filteredHoldings = holdingsList?.filter(
23
+ (asset) =>
24
+ !(asset.token.toLowerCase() === tokenOut.toLowerCase() &&
25
+ asset.chainId === chainIdOut),
26
+ );
27
+
20
28
  useEffect(() => {
21
29
  setSelectedIntegration(null);
22
30
  }, []);
@@ -33,7 +41,7 @@ const WalletAssetStep = ({ setStep }: { setStep: (step: string) => void }) => {
33
41
  width="300px"
34
42
  />
35
43
  ))
36
- : holdingsList?.map((asset) => (
44
+ : filteredHoldings?.map((asset) => (
37
45
  <AssetCard
38
46
  key={`${asset.token}-${asset.chainId}`}
39
47
  chainId={asset.chainId}
@@ -1,37 +0,0 @@
1
- /**
2
- * Generated by orval v7.11.1 🍺
3
- * Do not edit manually.
4
- * #### Enso API
5
- - Find detailed documentation on [docs.enso.finance](https://docs.enso.finance).
6
- - To use the API, **you must include your API Key in the Authorization header** (Bearer format).
7
- - For testing, Swagger pre-authorizes you using the key: `1e02632d-6feb-4a75-a157-documentation` (1rps).
8
- - Get your own API Key at [enso.finance/developers](https://developers.enso.build/).
9
- * OpenAPI spec version: 1.0
10
- */
11
- import type { BridgeTransactionResponseStatus } from "./bridgeTransactionResponseStatus";
12
- import type { LayerZeroMessageStatus } from "./layerZeroMessageStatus";
13
- import type { EnsoEvent } from "./ensoEvent";
14
- import type { EnsoMetadata } from "./ensoMetadata";
15
-
16
- export interface BridgeTransactionResponse {
17
- /** Source chain ID */
18
- sourceChainId: number;
19
- /** Source transaction hash */
20
- sourceTxHash: string;
21
- /** Destination chain ID (if known) */
22
- destinationChainId?: number;
23
- /** Destination transaction hash (if completed) */
24
- destinationTxHash?: string;
25
- /** Overall bridge status */
26
- status: BridgeTransactionResponseStatus;
27
- /** LayerZero message information */
28
- layerZeroMessage?: LayerZeroMessageStatus;
29
- /** Enso shortcut event from source chain (ShortcutExecuted + execution result) */
30
- ensoSourceEvent?: EnsoEvent;
31
- /** Enso shortcut event from destination chain (ShortcutExecuted + execution result) */
32
- ensoDestinationEvent?: EnsoEvent;
33
- /** Enso transaction metadata */
34
- ensoMetadata?: EnsoMetadata;
35
- /** Error message if something went wrong */
36
- error?: string;
37
- }
@@ -1,25 +0,0 @@
1
- /**
2
- * Generated by orval v7.11.1 🍺
3
- * Do not edit manually.
4
- * #### Enso API
5
- - Find detailed documentation on [docs.enso.finance](https://docs.enso.finance).
6
- - To use the API, **you must include your API Key in the Authorization header** (Bearer format).
7
- - For testing, Swagger pre-authorizes you using the key: `1e02632d-6feb-4a75-a157-documentation` (1rps).
8
- - Get your own API Key at [enso.finance/developers](https://developers.enso.build/).
9
- * OpenAPI spec version: 1.0
10
- */
11
-
12
- /**
13
- * Overall bridge status
14
- */
15
- export type BridgeTransactionResponseStatus =
16
- (typeof BridgeTransactionResponseStatus)[keyof typeof BridgeTransactionResponseStatus];
17
-
18
- // eslint-disable-next-line @typescript-eslint/no-redeclare
19
- export const BridgeTransactionResponseStatus = {
20
- pending: "pending",
21
- inflight: "inflight",
22
- delivered: "delivered",
23
- failed: "failed",
24
- unknown: "unknown",
25
- } as const;
@@ -1,30 +0,0 @@
1
- /**
2
- * Generated by orval v7.11.1 🍺
3
- * Do not edit manually.
4
- * #### Enso API
5
- - Find detailed documentation on [docs.enso.finance](https://docs.enso.finance).
6
- - To use the API, **you must include your API Key in the Authorization header** (Bearer format).
7
- - For testing, Swagger pre-authorizes you using the key: `1e02632d-6feb-4a75-a157-documentation` (1rps).
8
- - Get your own API Key at [enso.finance/developers](https://developers.enso.build/).
9
- * OpenAPI spec version: 1.0
10
- */
11
- import type { RefundDetails } from "./refundDetails";
12
-
13
- export interface EnsoEvent {
14
- /** Account ID from ShortcutExecuted event */
15
- accountId?: string;
16
- /** Request ID from ShortcutExecuted event */
17
- requestId?: string;
18
- /** Block number where the event was emitted */
19
- blockNumber: number;
20
- /** Transaction hash */
21
- transactionHash: string;
22
- /** Chain ID where the event was emitted */
23
- chainId: number;
24
- /** Whether the shortcut execution was successful */
25
- success: boolean;
26
- /** Error data if execution failed */
27
- error?: string;
28
- /** Refund details if execution failed and funds were returned */
29
- refundDetails?: RefundDetails;
30
- }
@@ -1,23 +0,0 @@
1
- /**
2
- * Generated by orval v7.11.1 🍺
3
- * Do not edit manually.
4
- * #### Enso API
5
- - Find detailed documentation on [docs.enso.finance](https://docs.enso.finance).
6
- - To use the API, **you must include your API Key in the Authorization header** (Bearer format).
7
- - For testing, Swagger pre-authorizes you using the key: `1e02632d-6feb-4a75-a157-documentation` (1rps).
8
- - Get your own API Key at [enso.finance/developers](https://developers.enso.build/).
9
- * OpenAPI spec version: 1.0
10
- */
11
-
12
- export interface EnsoMetadata {
13
- /** Token in address */
14
- tokenIn?: string;
15
- /** Token out address */
16
- tokenOut?: string;
17
- /** Amount in */
18
- amountIn?: string;
19
- /** Chain ID from the request */
20
- chainId?: number;
21
- /** Timestamp of the request */
22
- timestamp?: number;
23
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * Generated by orval v7.11.1 🍺
3
- * Do not edit manually.
4
- * #### Enso API
5
- - Find detailed documentation on [docs.enso.finance](https://docs.enso.finance).
6
- - To use the API, **you must include your API Key in the Authorization header** (Bearer format).
7
- - For testing, Swagger pre-authorizes you using the key: `1e02632d-6feb-4a75-a157-documentation` (1rps).
8
- - Get your own API Key at [enso.finance/developers](https://developers.enso.build/).
9
- * OpenAPI spec version: 1.0
10
- */
11
-
12
- export type LayerZeroControllerCheckBridgeTransactionParams = {
13
- /**
14
- * Chain ID of the source transaction
15
- */
16
- chainId: number;
17
- /**
18
- * Transaction hash
19
- */
20
- txHash: string;
21
- };
@@ -1,39 +0,0 @@
1
- /**
2
- * Generated by orval v7.11.1 🍺
3
- * Do not edit manually.
4
- * #### Enso API
5
- - Find detailed documentation on [docs.enso.finance](https://docs.enso.finance).
6
- - To use the API, **you must include your API Key in the Authorization header** (Bearer format).
7
- - For testing, Swagger pre-authorizes you using the key: `1e02632d-6feb-4a75-a157-documentation` (1rps).
8
- - Get your own API Key at [enso.finance/developers](https://developers.enso.build/).
9
- * OpenAPI spec version: 1.0
10
- */
11
-
12
- export interface LayerZeroMessageStatus {
13
- /** Source chain endpoint ID */
14
- srcEid: number;
15
- /** Destination chain endpoint ID */
16
- dstEid: number;
17
- /** Source chain ID (EVM) */
18
- srcChainId?: number;
19
- /** Destination chain ID (EVM) */
20
- dstChainId?: number;
21
- /** Message status from LayerZero */
22
- status: string;
23
- /** Source transaction hash */
24
- srcTxHash?: string;
25
- /** Destination transaction hash (if delivered) */
26
- dstTxHash?: string;
27
- /** Source block number */
28
- srcBlockNumber?: number;
29
- /** Destination block number (if delivered) */
30
- dstBlockNumber?: number;
31
- /** Source timestamp */
32
- srcTimestamp?: string;
33
- /** Destination timestamp (if delivered) */
34
- dstTimestamp?: string;
35
- /** Sender address */
36
- sender?: string;
37
- /** Receiver address */
38
- receiver?: string;
39
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * Generated by orval v7.11.1 🍺
3
- * Do not edit manually.
4
- * #### Enso API
5
- - Find detailed documentation on [docs.enso.finance](https://docs.enso.finance).
6
- - To use the API, **you must include your API Key in the Authorization header** (Bearer format).
7
- - For testing, Swagger pre-authorizes you using the key: `1e02632d-6feb-4a75-a157-documentation` (1rps).
8
- - Get your own API Key at [enso.finance/developers](https://developers.enso.build/).
9
- * OpenAPI spec version: 1.0
10
- */
11
-
12
- export interface RefundDetails {
13
- /** Token address (0xeee... for native token) */
14
- token: string;
15
- /** Amount refunded */
16
- amount: string;
17
- /** Recipient address */
18
- recipient: string;
19
- /** Whether the refund is in native token */
20
- isNative: boolean;
21
- }