@lifi/widget 1.18.9 → 1.20.0

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 (167) hide show
  1. package/App.js +3 -3
  2. package/cjs/App.js +3 -3
  3. package/cjs/components/ActiveSwaps/ActiveSwaps.js +1 -1
  4. package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +0 -14
  5. package/cjs/components/ActiveSwaps/ActiveSwaps.style.js +1 -9
  6. package/cjs/components/AppContainer.d.ts +11 -1
  7. package/cjs/components/AppContainer.js +2 -6
  8. package/cjs/components/BottomSheet/BottomSheet.js +9 -31
  9. package/cjs/components/BottomSheet/types.d.ts +2 -2
  10. package/cjs/components/Card/Card.js +1 -1
  11. package/cjs/components/Card/CardHeader.d.ts +1 -1
  12. package/cjs/components/ChainSelect/ChainSelect.js +1 -1
  13. package/cjs/components/ChainSelect/useChainSelect.js +2 -4
  14. package/cjs/components/Dialog.d.ts +22 -1
  15. package/cjs/components/Dialog.js +23 -19
  16. package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.js +19 -22
  17. package/cjs/components/Header/NavigationHeader.js +1 -1
  18. package/cjs/components/Header/WalletHeader.js +2 -2
  19. package/cjs/components/PoweredBy/PoweredBy.js +1 -1
  20. package/cjs/components/ProgressToNextUpdate/ProgressToNextUpdate.js +1 -1
  21. package/cjs/components/ReverseTokensButton/ReverseTokensButton.js +6 -6
  22. package/cjs/components/SelectTokenButton/SelectTokenButton.style.d.ts +1 -1
  23. package/cjs/components/SendToWallet/SendToWallet.d.ts +1 -0
  24. package/cjs/components/SendToWallet/SendToWallet.js +10 -5
  25. package/cjs/components/SendToWallet/SendToWalletButton.js +2 -2
  26. package/cjs/components/Step/StepProcess.js +1 -1
  27. package/cjs/components/SwapButton/SwapButton.js +4 -4
  28. package/cjs/components/SwapButton/types.d.ts +2 -0
  29. package/cjs/components/SwapInput/SwapInput.js +6 -2
  30. package/cjs/components/SwapInput/SwapInputAdornment.js +4 -2
  31. package/cjs/components/SwapInput/SwapInputAdornment.style.js +2 -14
  32. package/cjs/components/SwapRouteCard/SwapRouteCard.js +7 -6
  33. package/cjs/components/SwapRoutes/SwapRoutes.js +4 -4
  34. package/cjs/components/SwapRoutes/SwapRoutesExpanded.d.ts +1 -0
  35. package/cjs/components/SwapRoutes/SwapRoutesExpanded.js +17 -12
  36. package/cjs/components/SwapRoutes/useSetRecommendedRoute.d.ts +2 -0
  37. package/cjs/components/SwapRoutes/useSetRecommendedRoute.js +13 -0
  38. package/cjs/components/TokenList/TokenList.js +9 -6
  39. package/cjs/config/theme.js +22 -8
  40. package/cjs/config/version.d.ts +1 -1
  41. package/cjs/config/version.js +1 -1
  42. package/cjs/hooks/index.d.ts +1 -0
  43. package/cjs/hooks/index.js +1 -0
  44. package/cjs/hooks/useContentHeight.d.ts +2 -0
  45. package/cjs/hooks/useContentHeight.js +18 -1
  46. package/cjs/hooks/useExpandableVariant.d.ts +1 -0
  47. package/cjs/hooks/useExpandableVariant.js +14 -0
  48. package/cjs/hooks/useGasSufficiency.d.ts +3 -2
  49. package/cjs/hooks/useGasSufficiency.js +50 -26
  50. package/cjs/hooks/useSwapRoutes.js +4 -2
  51. package/cjs/hooks/useTokenBalance.js +2 -2
  52. package/cjs/i18n/en/translation.json +15 -7
  53. package/cjs/i18n/index.d.ts +13 -5
  54. package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.js +21 -4
  55. package/cjs/pages/MainPage/MainPage.js +3 -3
  56. package/cjs/pages/SelectWalletPage/SelectWalletPage.js +1 -1
  57. package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +2 -2
  58. package/cjs/pages/SwapHistoryPage/SwapHistoryPage.js +2 -2
  59. package/cjs/pages/SwapPage/StatusBottomSheet.js +4 -4
  60. package/cjs/pages/SwapPage/StatusBottomSheet.style.d.ts +0 -4
  61. package/cjs/pages/SwapPage/StatusBottomSheet.style.js +23 -17
  62. package/cjs/pages/SwapPage/SwapPage.js +38 -17
  63. package/cjs/pages/SwapPage/TokenValueBottomSheet.d.ts +11 -0
  64. package/cjs/pages/SwapPage/TokenValueBottomSheet.js +42 -0
  65. package/cjs/providers/SwapFormProvider/SwapFormProvider.js +3 -2
  66. package/cjs/providers/SwapFormProvider/URLSearchParamsBuilder.d.ts +1 -0
  67. package/cjs/providers/SwapFormProvider/URLSearchParamsBuilder.js +46 -0
  68. package/cjs/providers/SwapFormProvider/types.d.ts +4 -4
  69. package/cjs/providers/SwapFormProvider/types.js +2 -2
  70. package/cjs/providers/WalletProvider/WalletFormUpdate.d.ts +5 -0
  71. package/cjs/providers/WalletProvider/WalletFormUpdate.js +64 -0
  72. package/cjs/providers/WalletProvider/WalletProvider.js +3 -58
  73. package/cjs/providers/WidgetProvider/WidgetProvider.js +12 -5
  74. package/cjs/stores/routes/index.d.ts +1 -1
  75. package/cjs/stores/routes/index.js +1 -1
  76. package/cjs/stores/routes/types.d.ts +5 -5
  77. package/cjs/stores/routes/useRecommendedRouteStore.d.ts +4 -0
  78. package/cjs/stores/routes/{useSelectedRouteStore.js → useRecommendedRouteStore.js} +4 -4
  79. package/cjs/stores/routes/useRouteExecutionStore.js +9 -2
  80. package/cjs/types/widget.d.ts +1 -0
  81. package/components/ActiveSwaps/ActiveSwaps.js +3 -3
  82. package/components/ActiveSwaps/ActiveSwaps.style.d.ts +0 -14
  83. package/components/ActiveSwaps/ActiveSwaps.style.js +1 -9
  84. package/components/AppContainer.d.ts +11 -1
  85. package/components/AppContainer.js +1 -4
  86. package/components/BottomSheet/BottomSheet.js +10 -32
  87. package/components/BottomSheet/types.d.ts +2 -2
  88. package/components/Card/Card.js +1 -1
  89. package/components/Card/CardHeader.d.ts +1 -1
  90. package/components/ChainSelect/ChainSelect.js +1 -1
  91. package/components/ChainSelect/useChainSelect.js +2 -4
  92. package/components/Dialog.d.ts +22 -1
  93. package/components/Dialog.js +23 -19
  94. package/components/GasSufficiencyMessage/GasSufficiencyMessage.js +21 -24
  95. package/components/Header/NavigationHeader.js +2 -2
  96. package/components/Header/WalletHeader.js +2 -2
  97. package/components/PoweredBy/PoweredBy.js +1 -1
  98. package/components/ProgressToNextUpdate/ProgressToNextUpdate.js +1 -1
  99. package/components/ReverseTokensButton/ReverseTokensButton.js +6 -6
  100. package/components/SelectTokenButton/SelectTokenButton.style.d.ts +1 -1
  101. package/components/SendToWallet/SendToWallet.d.ts +1 -0
  102. package/components/SendToWallet/SendToWallet.js +9 -5
  103. package/components/SendToWallet/SendToWalletButton.js +2 -2
  104. package/components/Step/StepProcess.js +1 -1
  105. package/components/SwapButton/SwapButton.js +4 -4
  106. package/components/SwapButton/types.d.ts +2 -0
  107. package/components/SwapInput/SwapInput.js +6 -2
  108. package/components/SwapInput/SwapInputAdornment.js +4 -2
  109. package/components/SwapInput/SwapInputAdornment.style.js +3 -15
  110. package/components/SwapRouteCard/SwapRouteCard.js +8 -7
  111. package/components/SwapRoutes/SwapRoutes.js +4 -4
  112. package/components/SwapRoutes/SwapRoutesExpanded.d.ts +1 -0
  113. package/components/SwapRoutes/SwapRoutesExpanded.js +16 -12
  114. package/components/SwapRoutes/useSetRecommendedRoute.d.ts +2 -0
  115. package/components/SwapRoutes/useSetRecommendedRoute.js +9 -0
  116. package/components/TokenList/TokenList.js +9 -6
  117. package/config/theme.js +22 -8
  118. package/config/version.d.ts +1 -1
  119. package/config/version.js +1 -1
  120. package/hooks/index.d.ts +1 -0
  121. package/hooks/index.js +1 -0
  122. package/hooks/useContentHeight.d.ts +2 -0
  123. package/hooks/useContentHeight.js +16 -0
  124. package/hooks/useExpandableVariant.d.ts +1 -0
  125. package/hooks/useExpandableVariant.js +10 -0
  126. package/hooks/useGasSufficiency.d.ts +3 -2
  127. package/hooks/useGasSufficiency.js +50 -26
  128. package/hooks/useSwapRoutes.js +4 -2
  129. package/hooks/useTokenBalance.js +2 -2
  130. package/i18n/en/translation.json +15 -7
  131. package/i18n/index.d.ts +13 -5
  132. package/package.json +11 -11
  133. package/pages/ActiveSwapsPage/ActiveSwapsPage.js +24 -7
  134. package/pages/MainPage/MainPage.js +3 -3
  135. package/pages/SelectWalletPage/SelectWalletPage.js +1 -1
  136. package/pages/SwapDetailsPage/SwapDetailsPage.js +2 -2
  137. package/pages/SwapHistoryPage/SwapHistoryPage.js +2 -2
  138. package/pages/SwapPage/StatusBottomSheet.js +5 -5
  139. package/pages/SwapPage/StatusBottomSheet.style.d.ts +0 -4
  140. package/pages/SwapPage/StatusBottomSheet.style.js +23 -17
  141. package/pages/SwapPage/SwapPage.js +41 -20
  142. package/pages/SwapPage/TokenValueBottomSheet.d.ts +11 -0
  143. package/pages/SwapPage/TokenValueBottomSheet.js +38 -0
  144. package/providers/SwapFormProvider/SwapFormProvider.js +4 -3
  145. package/providers/SwapFormProvider/URLSearchParamsBuilder.d.ts +1 -0
  146. package/providers/SwapFormProvider/URLSearchParamsBuilder.js +42 -0
  147. package/providers/SwapFormProvider/types.d.ts +4 -4
  148. package/providers/SwapFormProvider/types.js +2 -2
  149. package/providers/WalletProvider/WalletFormUpdate.d.ts +5 -0
  150. package/providers/WalletProvider/WalletFormUpdate.js +60 -0
  151. package/providers/WalletProvider/WalletProvider.js +5 -60
  152. package/providers/WidgetProvider/WidgetProvider.js +12 -5
  153. package/stores/routes/index.d.ts +1 -1
  154. package/stores/routes/index.js +1 -1
  155. package/stores/routes/types.d.ts +5 -5
  156. package/stores/routes/useRecommendedRouteStore.d.ts +4 -0
  157. package/stores/routes/useRecommendedRouteStore.js +9 -0
  158. package/stores/routes/useRouteExecutionStore.js +9 -2
  159. package/tsconfig.cjs.tsbuildinfo +1 -1
  160. package/types/widget.d.ts +1 -0
  161. package/cjs/components/SwapRoutes/useSetSelectedRoute.d.ts +0 -2
  162. package/cjs/components/SwapRoutes/useSetSelectedRoute.js +0 -13
  163. package/cjs/stores/routes/useSelectedRouteStore.d.ts +0 -4
  164. package/components/SwapRoutes/useSetSelectedRoute.d.ts +0 -2
  165. package/components/SwapRoutes/useSetSelectedRoute.js +0 -9
  166. package/stores/routes/useSelectedRouteStore.d.ts +0 -4
  167. package/stores/routes/useSelectedRouteStore.js +0 -9
package/hooks/index.js CHANGED
@@ -2,6 +2,7 @@ export * from './useChain';
2
2
  export * from './useChains';
3
3
  export * from './useContentHeight';
4
4
  export * from './useDebouncedWatch';
5
+ export * from './useExpandableVariant';
5
6
  export * from './useFeaturedTokens';
6
7
  export * from './useGasSufficiency';
7
8
  export * from './useInitializer';
@@ -1 +1,3 @@
1
+ import type { MutableRefObject } from 'react';
1
2
  export declare const useContentHeight: () => number;
3
+ export declare const useSetContentHeight: (ref: MutableRefObject<HTMLElement | undefined>) => void;
@@ -1,5 +1,6 @@
1
1
  import { useLayoutEffect, useState } from 'react';
2
2
  import { ElementId } from '../utils';
3
+ import { getScrollableContainer } from './useScrollableContainer';
3
4
  const getContentHeight = () => {
4
5
  const headerElement = document.getElementById(ElementId.Header);
5
6
  const containerElement = document.getElementById(ElementId.ScrollableContainer);
@@ -21,3 +22,18 @@ export const useContentHeight = () => {
21
22
  }, []);
22
23
  return contentHeight;
23
24
  };
25
+ export const useSetContentHeight = (ref) => {
26
+ useLayoutEffect(() => {
27
+ var _a;
28
+ const scrollableContainer = getScrollableContainer();
29
+ if (!scrollableContainer ||
30
+ !ref.current ||
31
+ ((_a = ref.current) === null || _a === void 0 ? void 0 : _a.clientHeight) <= (scrollableContainer === null || scrollableContainer === void 0 ? void 0 : scrollableContainer.clientHeight)) {
32
+ return;
33
+ }
34
+ scrollableContainer.style.height = `${ref.current.clientHeight}px`;
35
+ return () => {
36
+ scrollableContainer.style.removeProperty('height');
37
+ };
38
+ }, [ref]);
39
+ };
@@ -0,0 +1 @@
1
+ export declare const useExpandableVariant: () => boolean;
@@ -0,0 +1,10 @@
1
+ import { useMediaQuery } from '@mui/material';
2
+ import { useWidgetConfig } from '../providers';
3
+ const defaultExpandableWidth = 852;
4
+ export const useExpandableVariant = () => {
5
+ const { variant } = useWidgetConfig();
6
+ const expandableAllowed = useMediaQuery((theme) => {
7
+ return theme.breakpoints.up(defaultExpandableWidth);
8
+ });
9
+ return variant === 'expandable' && expandableAllowed;
10
+ };
@@ -9,7 +9,8 @@ interface GasSufficiency {
9
9
  chain?: EVMChain;
10
10
  }
11
11
  export declare const useGasSufficiency: (route?: Route) => {
12
- insufficientGas: GasSufficiency[] | undefined;
13
- insufficientFunds: boolean;
12
+ insufficientGas: GasSufficiency[] | null | undefined;
13
+ insufficientFunds: boolean | null | undefined;
14
+ isLoading: boolean;
14
15
  };
15
16
  export {};
@@ -7,23 +7,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
+ import { useQuery } from '@tanstack/react-query';
10
11
  import Big from 'big.js';
11
- import { useCallback, useEffect, useMemo, useState } from 'react';
12
12
  import { useChains } from '.';
13
13
  import { useWallet } from '../providers';
14
+ import { isRouteCompleted } from '../stores';
14
15
  import { useTokenBalance } from './useTokenBalance';
16
+ const refetchInterval = 30000;
15
17
  export const useGasSufficiency = (route) => {
16
18
  const { account } = useWallet();
17
19
  const { getChainById } = useChains();
18
20
  const { token: fromToken, getTokenBalancesWithRetry } = useTokenBalance(route === null || route === void 0 ? void 0 : route.fromToken);
19
- const [insufficientGas, setInsufficientGas] = useState();
20
- const checkInsufficientGas = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
21
+ const { data: insufficientGas, isInitialLoading: insufficientGasLoading } = useQuery(['gas-sufficiency-check', account.address, route === null || route === void 0 ? void 0 : route.id], () => __awaiter(void 0, void 0, void 0, function* () {
21
22
  var _a, _b;
22
23
  if (!account.address || !route) {
23
- setInsufficientGas(undefined);
24
- return;
24
+ return null;
25
25
  }
26
- const gasCosts = route.steps.reduce((groupedGasCosts, step) => {
26
+ const gasCosts = route.steps
27
+ .filter((step) => !step.execution || step.execution.status !== 'DONE')
28
+ .reduce((groupedGasCosts, step) => {
27
29
  if (step.estimate.gasCosts) {
28
30
  const { token } = step.estimate.gasCosts[0];
29
31
  const gasCostAmount = step.estimate.gasCosts
@@ -37,7 +39,6 @@ export const useGasSufficiency = (route) => {
37
39
  gasAmount,
38
40
  tokenAmount: gasAmount,
39
41
  token,
40
- chain: getChainById(token.chainId),
41
42
  };
42
43
  return groupedGasCosts;
43
44
  }
@@ -48,41 +49,64 @@ export const useGasSufficiency = (route) => {
48
49
  }
49
50
  const tokenBalances = yield getTokenBalancesWithRetry(account.address, Object.values(gasCosts).map((item) => item.token));
50
51
  if (!(tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.length)) {
51
- setInsufficientGas(undefined);
52
- return;
52
+ return null;
53
53
  }
54
54
  [route.fromChainId, route.toChainId].forEach((chainId) => {
55
55
  var _a, _b, _c, _d, _e, _f;
56
56
  if (gasCosts[chainId]) {
57
57
  const gasTokenBalance = Big((_b = (_a = tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.find((t) => t.chainId === gasCosts[chainId].token.chainId &&
58
58
  t.address === gasCosts[chainId].token.address)) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0);
59
- const insufficientFromChainGas = gasTokenBalance.lte(0) ||
59
+ const insufficient = gasTokenBalance.lte(0) ||
60
60
  gasTokenBalance.lt((_c = gasCosts[chainId].gasAmount) !== null && _c !== void 0 ? _c : Big(0)) ||
61
61
  gasTokenBalance.lt((_d = gasCosts[chainId].tokenAmount) !== null && _d !== void 0 ? _d : Big(0));
62
- const insufficientFromChainGasAmount = insufficientFromChainGas
62
+ const insufficientAmount = insufficient
63
63
  ? (_f = (_e = gasCosts[chainId].tokenAmount) === null || _e === void 0 ? void 0 : _e.minus(gasTokenBalance)) !== null && _f !== void 0 ? _f : gasCosts[chainId].gasAmount.minus(gasTokenBalance)
64
64
  : undefined;
65
- gasCosts[chainId] = Object.assign(Object.assign({}, gasCosts[chainId]), { insufficient: insufficientFromChainGas, insufficientAmount: insufficientFromChainGasAmount === null || insufficientFromChainGasAmount === void 0 ? void 0 : insufficientFromChainGasAmount.round(5, Big.roundUp) });
65
+ gasCosts[chainId] = Object.assign(Object.assign({}, gasCosts[chainId]), { insufficient, insufficientAmount: insufficientAmount === null || insufficientAmount === void 0 ? void 0 : insufficientAmount.round(5, Big.roundUp), chain: insufficient ? getChainById(chainId) : undefined });
66
66
  }
67
67
  });
68
68
  const gasCostResult = Object.values(gasCosts).filter((gasCost) => gasCost.insufficient);
69
- setInsufficientGas(gasCostResult);
70
- }), [account.address, getChainById, getTokenBalancesWithRetry, route]);
71
- const insufficientFunds = useMemo(() => {
72
- var _a;
73
- if (!account.isActive || !fromToken || !route) {
74
- return false;
69
+ return gasCostResult;
70
+ }), {
71
+ enabled: Boolean(account.address && route),
72
+ refetchIntervalInBackground: true,
73
+ refetchInterval,
74
+ staleTime: refetchInterval,
75
+ cacheTime: refetchInterval,
76
+ });
77
+ const { data: insufficientFunds, isInitialLoading: insufficientFundsLoading, } = useQuery(['funds-sufficiency-check', account.address, route === null || route === void 0 ? void 0 : route.id], () => __awaiter(void 0, void 0, void 0, function* () {
78
+ var _c, _d, _e, _f;
79
+ if (!account.address || !fromToken || !route || isRouteCompleted(route)) {
80
+ return null;
81
+ }
82
+ let currentTokenBalance = Big((_c = fromToken === null || fromToken === void 0 ? void 0 : fromToken.amount) !== null && _c !== void 0 ? _c : 0);
83
+ const currentAction = (_d = route.steps.filter((step) => !step.execution || step.execution.status !== 'DONE')[0]) === null || _d === void 0 ? void 0 : _d.action;
84
+ if (fromToken.chainId === currentAction.fromToken.chainId &&
85
+ fromToken.address === currentAction.fromToken.address &&
86
+ currentTokenBalance.gt(0)) {
87
+ const insufficientFunds = Big(route.fromAmount)
88
+ .div(Math.pow(10, route.fromToken.decimals))
89
+ .gt(currentTokenBalance);
90
+ return insufficientFunds;
75
91
  }
76
- const balance = Big((_a = fromToken === null || fromToken === void 0 ? void 0 : fromToken.amount) !== null && _a !== void 0 ? _a : 0);
77
- return Big(route.fromAmount)
78
- .div(Math.pow(10, route.fromToken.decimals))
79
- .gt(balance);
80
- }, [account.isActive, fromToken, route]);
81
- useEffect(() => {
82
- checkInsufficientGas();
83
- }, [checkInsufficientGas]);
92
+ const tokenBalances = yield getTokenBalancesWithRetry(account.address, [
93
+ currentAction.fromToken,
94
+ ]);
95
+ currentTokenBalance = Big((_f = (_e = tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances[0]) === null || _e === void 0 ? void 0 : _e.amount) !== null && _f !== void 0 ? _f : 0);
96
+ const insufficientFunds = Big(currentAction.fromAmount)
97
+ .div(Math.pow(10, currentAction.fromToken.decimals))
98
+ .gt(currentTokenBalance);
99
+ return insufficientFunds;
100
+ }), {
101
+ enabled: Boolean(account.address && route && fromToken),
102
+ refetchIntervalInBackground: true,
103
+ refetchInterval,
104
+ staleTime: refetchInterval,
105
+ cacheTime: refetchInterval,
106
+ });
84
107
  return {
85
108
  insufficientGas,
86
109
  insufficientFunds,
110
+ isLoading: insufficientGasLoading || insufficientFundsLoading,
87
111
  };
88
112
  };
@@ -74,16 +74,18 @@ export const useSwapRoutes = () => {
74
74
  catch (_d) {
75
75
  toWalletAddress = isAddress(toAddress) ? toAddress : fromAddress;
76
76
  }
77
+ const fromAmount = Big(Number(fromTokenAmount) * Math.pow(10, ((_c = token === null || token === void 0 ? void 0 : token.decimals) !== null && _c !== void 0 ? _c : 0))).toString();
78
+ const formattedSlippage = parseFloat(slippage) / 100;
77
79
  return lifi.getRoutes({
78
80
  fromChainId,
79
- fromAmount: Big(Number(fromTokenAmount) * Math.pow(10, ((_c = token === null || token === void 0 ? void 0 : token.decimals) !== null && _c !== void 0 ? _c : 0))).toString(),
81
+ fromAmount,
80
82
  fromTokenAddress,
81
83
  toChainId,
82
84
  toTokenAddress,
83
85
  fromAddress,
84
86
  toAddress: toWalletAddress,
85
87
  options: {
86
- slippage: slippage / 100,
88
+ slippage: formattedSlippage,
87
89
  bridges: {
88
90
  allow: enabledBridges,
89
91
  },
@@ -21,12 +21,12 @@ export const useTokenBalance = (token, accountAddress) => {
21
21
  try {
22
22
  const tokenBalances = yield lifi.getTokenBalances(accountAddress, tokens);
23
23
  if (!tokenBalances.every((token) => token.blockNumber)) {
24
- if (depth > 5) {
24
+ if (depth > 10) {
25
25
  console.warn('Token balance backoff depth exceeded.');
26
26
  return undefined;
27
27
  }
28
28
  yield new Promise((resolve) => {
29
- setTimeout(resolve, depth * 100);
29
+ setTimeout(resolve, Math.pow(1.5, depth) * 100);
30
30
  });
31
31
  return getTokenBalancesWithRetry(accountAddress, tokens, depth + 1);
32
32
  }
@@ -22,6 +22,7 @@
22
22
  "removeSwap": "Remove swap",
23
23
  "done": "Done",
24
24
  "okay": "Okay",
25
+ "continue": "Continue",
25
26
  "seeDetails": "See details",
26
27
  "tryAgain": "Try again",
27
28
  "light": "Light",
@@ -44,10 +45,6 @@
44
45
  "routes": "You get",
45
46
  "approximateCurrency": "\u2248 {{value, currency(currency: USD)}}",
46
47
  "currency": "{{value, currency(currency: USD)}}",
47
- "sendToRecipient": "Send to recipient",
48
- "addressConfirmation": "I confirm that the address above is correct",
49
- "gas": "gas fee",
50
- "minutes": "minutes",
51
48
  "tokenSearch": "Search your token",
52
49
  "selectChain": "Chain",
53
50
  "selectToken": "Token",
@@ -66,6 +63,10 @@
66
63
  "supportId": "Support ID",
67
64
  "sendToWallet": "Send to a different wallet",
68
65
  "walletAddressOrEns": "Wallet address or ENS name",
66
+ "swapping": "Swapping",
67
+ "gasCost": "Gas cost",
68
+ "receiving": "Receiving",
69
+ "valueLoss": "Value loss",
69
70
  "tags": {
70
71
  "RECOMMENDED": "RECOMMENDED",
71
72
  "FASTEST": "FAST",
@@ -98,12 +99,16 @@
98
99
  "title": {
99
100
  "insufficientGas": "Insufficient gas",
100
101
  "deleteSwap": "Delete this swap?",
101
- "deleteSwapHistory": "Delete swap history?"
102
+ "deleteSwapHistory": "Delete swap history?",
103
+ "deleteActiveSwaps": "Delete all active swaps?",
104
+ "highValueLoss": "High value loss"
102
105
  },
103
106
  "message": {
104
107
  "insufficientFunds": "You don't have enough funds to execute the swap.",
105
108
  "insufficientGas": "You need to add at least:",
106
- "deleteSwap": "Swap history is only stored locally and can't be recovered if you delete it."
109
+ "deleteSwapHistory": "Swap history is only stored locally and can't be recovered if you delete it.",
110
+ "deleteActiveSwaps": "Active swaps are only stored locally and can't be recovered if you delete them.",
111
+ "highValueLoss": "The value of the received tokens is significantly lower than the swapped tokens and transaction cost."
107
112
  }
108
113
  },
109
114
  "error": {
@@ -179,6 +184,9 @@
179
184
  "title": "404",
180
185
  "text": "We couldn't find this page."
181
186
  },
182
- "progressToNextUpdate": "Displayed data will auto-refresh after {{value}} seconds. Click this circle to update manually."
187
+ "progressToNextUpdate": "Displayed data will auto-refresh after {{value}} seconds. Click here to update manually.",
188
+ "numberOfSteps": "A number of swap steps. Each step can contain 1-3 transactions that require a signature.",
189
+ "estimatedTime": "Estimated time in minutes.",
190
+ "estimatedNetworkFee": "Estimated network fee."
183
191
  }
184
192
  }
package/i18n/index.d.ts CHANGED
@@ -25,6 +25,7 @@ export declare const resources: {
25
25
  removeSwap: string;
26
26
  done: string;
27
27
  okay: string;
28
+ continue: string;
28
29
  seeDetails: string;
29
30
  tryAgain: string;
30
31
  light: string;
@@ -47,10 +48,6 @@ export declare const resources: {
47
48
  routes: string;
48
49
  approximateCurrency: string;
49
50
  currency: string;
50
- sendToRecipient: string;
51
- addressConfirmation: string;
52
- gas: string;
53
- minutes: string;
54
51
  tokenSearch: string;
55
52
  selectChain: string;
56
53
  selectToken: string;
@@ -69,6 +66,10 @@ export declare const resources: {
69
66
  supportId: string;
70
67
  sendToWallet: string;
71
68
  walletAddressOrEns: string;
69
+ swapping: string;
70
+ gasCost: string;
71
+ receiving: string;
72
+ valueLoss: string;
72
73
  tags: {
73
74
  RECOMMENDED: string;
74
75
  FASTEST: string;
@@ -102,11 +103,15 @@ export declare const resources: {
102
103
  insufficientGas: string;
103
104
  deleteSwap: string;
104
105
  deleteSwapHistory: string;
106
+ deleteActiveSwaps: string;
107
+ highValueLoss: string;
105
108
  };
106
109
  message: {
107
110
  insufficientFunds: string;
108
111
  insufficientGas: string;
109
- deleteSwap: string;
112
+ deleteSwapHistory: string;
113
+ deleteActiveSwaps: string;
114
+ highValueLoss: string;
110
115
  };
111
116
  };
112
117
  error: {
@@ -183,6 +188,9 @@ export declare const resources: {
183
188
  text: string;
184
189
  };
185
190
  progressToNextUpdate: string;
191
+ numberOfSteps: string;
192
+ estimatedTime: string;
193
+ estimatedNetworkFee: string;
186
194
  };
187
195
  };
188
196
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/widget",
3
- "version": "1.18.9",
3
+ "version": "1.20.0",
4
4
  "description": "LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./index.js",
@@ -45,25 +45,25 @@
45
45
  "@lifi/sdk": "^1.6.0",
46
46
  "@lifi/wallet-management": "^1.1.10",
47
47
  "@mui/icons-material": "^5.10.6",
48
- "@mui/lab": "^5.0.0-alpha.101",
49
- "@mui/material": "^5.10.7",
50
- "@sentry/integrations": "^7.14.0",
51
- "@sentry/react": "^7.14.0",
52
- "@sentry/tracing": "^7.14.0",
53
- "@tanstack/react-query": "^4.8.0",
48
+ "@mui/lab": "^5.0.0-alpha.102",
49
+ "@mui/material": "^5.10.8",
50
+ "@sentry/integrations": "^7.14.2",
51
+ "@sentry/react": "^7.14.2",
52
+ "@sentry/tracing": "^7.14.2",
53
+ "@tanstack/react-query": "^4.10.3",
54
54
  "@tanstack/react-virtual": "^3.0.0-beta.18",
55
55
  "big.js": "^6.2.1",
56
- "i18next": "^21.9.2",
56
+ "i18next": "^21.10.0",
57
57
  "immer": "^9.0.15",
58
58
  "microdiff": "^1.3.1",
59
59
  "mitt": "^3.0.0",
60
60
  "react": "^18.2.0",
61
61
  "react-dom": "^18.2.0",
62
- "react-hook-form": "^7.36.1",
62
+ "react-hook-form": "^7.37.0",
63
63
  "react-i18next": "^11.18.6",
64
- "react-router-dom": "^6.4.1",
64
+ "react-router-dom": "^6.4.2",
65
65
  "react-timer-hook": "^3.0.5",
66
- "zustand": "^4.1.1"
66
+ "zustand": "^4.1.2"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "@types/react": "^18.0.0",
@@ -1,17 +1,34 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Container, List } from '@mui/material';
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /* eslint-disable consistent-return */
3
+ import { DeleteOutline as DeleteIcon } from '@mui/icons-material';
4
+ import { Button, Container, DialogActions, DialogContent, DialogContentText, DialogTitle, IconButton, List, } from '@mui/material';
5
+ import { useCallback, useEffect, useState } from 'react';
6
+ import { useTranslation } from 'react-i18next';
3
7
  import { ActiveSwapItem } from '../../components/ActiveSwaps';
8
+ import { Dialog } from '../../components/Dialog';
9
+ import { useHeaderActionStore } from '../../components/Header';
4
10
  import { useWallet } from '../../providers';
5
- import { useExecutingRoutesIds } from '../../stores';
11
+ import { useExecutingRoutesIds, useRouteExecutionStore } from '../../stores';
6
12
  import { ActiveSwapsEmpty } from './ActiveSwapsEmpty';
7
13
  export const ActiveSwapsPage = () => {
14
+ const { t } = useTranslation();
8
15
  const { account } = useWallet();
9
16
  const executingRoutes = useExecutingRoutesIds(account.address);
17
+ const deleteRoutes = useRouteExecutionStore((store) => store.deleteRoutes);
18
+ const [open, setOpen] = useState(false);
19
+ const toggleDialog = useCallback(() => {
20
+ setOpen((open) => !open);
21
+ }, []);
22
+ useEffect(() => {
23
+ if (executingRoutes.length) {
24
+ return useHeaderActionStore.getState().setAction(_jsx(IconButton, Object.assign({ size: "medium", edge: "end", onClick: toggleDialog }, { children: _jsx(DeleteIcon, {}) })));
25
+ }
26
+ }, [executingRoutes.length, toggleDialog]);
10
27
  if (!executingRoutes.length) {
11
28
  return _jsx(ActiveSwapsEmpty, {});
12
29
  }
13
- return (_jsx(Container, Object.assign({ disableGutters: true }, { children: _jsx(List, Object.assign({ sx: {
14
- paddingLeft: 1.5,
15
- paddingRight: 1.5,
16
- } }, { children: executingRoutes.map((routeId) => (_jsx(ActiveSwapItem, { routeId: routeId }, routeId))) })) })));
30
+ return (_jsxs(Container, Object.assign({ disableGutters: true }, { children: [_jsx(List, Object.assign({ sx: {
31
+ paddingLeft: 1.5,
32
+ paddingRight: 1.5,
33
+ } }, { children: executingRoutes.map((routeId) => (_jsx(ActiveSwapItem, { routeId: routeId }, routeId))) })), _jsxs(Dialog, Object.assign({ open: open, onClose: toggleDialog }, { children: [_jsx(DialogTitle, { children: t('swap.warning.title.deleteActiveSwaps') }), _jsx(DialogContent, { children: _jsx(DialogContentText, { children: t('swap.warning.message.deleteActiveSwaps') }) }), _jsxs(DialogActions, { children: [_jsx(Button, Object.assign({ onClick: toggleDialog }, { children: t('button.cancel') })), _jsx(Button, Object.assign({ variant: "contained", onClick: () => deleteRoutes('active'), autoFocus: true }, { children: t('button.delete') }))] })] }))] })));
17
34
  };
@@ -6,10 +6,10 @@ import { SelectChainAndToken } from '../../components/SelectChainAndToken';
6
6
  import { SendToWallet, SendToWalletButton, } from '../../components/SendToWallet';
7
7
  import { SwapInput } from '../../components/SwapInput';
8
8
  import { SwapRoutes } from '../../components/SwapRoutes';
9
- import { useWidgetConfig } from '../../providers';
9
+ import { useExpandableVariant } from '../../hooks';
10
10
  import { FormContainer } from './MainPage.style';
11
11
  import { MainSwapButton } from './MainSwapButton';
12
12
  export const MainPage = () => {
13
- const { variant } = useWidgetConfig();
14
- return (_jsxs(FormContainer, Object.assign({ disableGutters: true }, { children: [_jsx(ActiveSwaps, { mx: 3, mt: 1, mb: 2 }), _jsx(SelectChainAndToken, { mt: 1, mx: 3, mb: 3 }), _jsx(Box, Object.assign({ mx: 3, mb: 3 }, { children: _jsx(SwapInput, { formType: "from" }) })), variant !== 'expandable' ? _jsx(SwapRoutes, { mx: 3, mb: 3 }) : null, _jsx(GasSufficiencyMessage, { mx: 3, mb: 3 }), _jsxs(Box, Object.assign({ mx: 3, mb: 1 }, { children: [_jsx(SendToWallet, { mb: 3 }), _jsxs(Box, Object.assign({ sx: { display: 'flex' } }, { children: [_jsx(MainSwapButton, {}), _jsx(SendToWalletButton, {})] }))] }))] })));
13
+ const expandable = useExpandableVariant();
14
+ return (_jsxs(FormContainer, Object.assign({ disableGutters: true }, { children: [_jsx(ActiveSwaps, { mx: 3, mt: 1, mb: 2 }), _jsx(SelectChainAndToken, { mt: 1, mx: 3, mb: 3 }), _jsx(Box, Object.assign({ mx: 3, mb: 3 }, { children: _jsx(SwapInput, { formType: "from" }) })), !expandable ? _jsx(SwapRoutes, { mx: 3, mb: 3 }) : null, _jsx(GasSufficiencyMessage, { mx: 3, mb: 3 }), _jsxs(Box, Object.assign({ mx: 3, mb: 1 }, { children: [_jsx(SendToWallet, { mb: 3 }), _jsxs(Box, Object.assign({ sx: { display: 'flex' } }, { children: [_jsx(MainSwapButton, {}), _jsx(SendToWalletButton, {})] }))] }))] })));
15
15
  };
@@ -45,5 +45,5 @@ export const SelectWalletPage = () => {
45
45
  paddingRight: 1.5,
46
46
  } }, { children: supportedWallets.map((wallet) => (_jsxs(ListItemButton, Object.assign({ onClick: () => handleConnect(wallet), disableRipple: true }, { children: [_jsx(ListItemAvatar, { children: _jsx(Avatar, Object.assign({ src: wallet.icon.src || wallet.icon, alt: wallet.name }, { children: wallet.name[0] })) }), _jsx(ListItemText, { primary: wallet.name })] }), wallet.name))) })), _jsxs(Dialog, Object.assign({ open: walletIdentity.show, onClose: closeDialog }, { children: [_jsx(DialogContent, { children: _jsx(DialogContentText, { children: t('wallet.extensionNotFound', {
47
47
  name: (_a = walletIdentity.wallet) === null || _a === void 0 ? void 0 : _a.name,
48
- }) }) }), _jsx(DialogActions, { children: _jsx(Button, Object.assign({ onClick: closeDialog, autoFocus: true }, { children: t('button.ok') })) })] }))] })));
48
+ }) }) }), _jsx(DialogActions, { children: _jsx(Button, Object.assign({ variant: "contained", onClick: closeDialog, autoFocus: true }, { children: t('button.ok') })) })] }))] })));
49
49
  };
@@ -43,7 +43,7 @@ export const SwapDetailsPage = () => {
43
43
  yield navigator.clipboard.writeText((_c = routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route.id) !== null && _c !== void 0 ? _c : '');
44
44
  });
45
45
  useEffect(() => {
46
- return useHeaderActionStore.getState().setAction(_jsx(IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "end", onClick: toggleDialog }, { children: _jsx(DeleteIcon, {}) })));
46
+ return useHeaderActionStore.getState().setAction(_jsx(IconButton, Object.assign({ size: "medium", edge: "end", onClick: toggleDialog }, { children: _jsx(DeleteIcon, {}) })));
47
47
  }, [toggleDialog]);
48
48
  const startedAt = new Date((_b = (_a = routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route.steps[0].execution) === null || _a === void 0 ? void 0 : _a.process[0].startedAt) !== null && _b !== void 0 ? _b : 0);
49
49
  return (_jsxs(Container, { children: [_jsxs(Box, Object.assign({ sx: {
@@ -58,5 +58,5 @@ export const SwapDetailsPage = () => {
58
58
  }), _jsxs(Card, Object.assign({ mt: 2 }, { children: [_jsxs(Box, Object.assign({ sx: {
59
59
  display: 'flex',
60
60
  flex: 1,
61
- } }, { children: [_jsx(CardTitle, Object.assign({ flex: 1 }, { children: t('swap.supportId') })), _jsx(Box, Object.assign({ mr: 1, mt: 1 }, { children: _jsx(IconButton, Object.assign({ size: "medium", "aria-label": "settings", onClick: copyRouteId }, { children: _jsx(ContentCopyIcon, { fontSize: "small" }) })) }))] })), _jsx(Typography, Object.assign({ variant: "body2", pt: 1, pb: 2, px: 2, sx: { wordBreak: 'break-all' } }, { children: routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route.id }))] })), _jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(Button, Object.assign({ variant: "contained", href: "https://discord.com/channels/849912621360218112/863689862514343946", target: "_blank", rel: "nofollow noreferrer", fullWidth: true }, { children: t('button.contactSupport') })) })), _jsxs(Dialog, Object.assign({ open: open, onClose: toggleDialog }, { children: [_jsx(DialogTitle, { children: t('swap.warning.title.deleteSwap') }), _jsx(DialogContent, { children: _jsx(DialogContentText, { children: t('swap.warning.message.deleteSwap') }) }), _jsxs(DialogActions, { children: [_jsx(Button, Object.assign({ onClick: toggleDialog }, { children: t('button.cancel') })), _jsx(Button, Object.assign({ onClick: handleDeleteRoute, autoFocus: true }, { children: t('button.delete') }))] })] }))] }));
61
+ } }, { children: [_jsx(CardTitle, Object.assign({ flex: 1 }, { children: t('swap.supportId') })), _jsx(Box, Object.assign({ mr: 1, mt: 1 }, { children: _jsx(IconButton, Object.assign({ size: "medium", onClick: copyRouteId }, { children: _jsx(ContentCopyIcon, { fontSize: "small" }) })) }))] })), _jsx(Typography, Object.assign({ variant: "body2", pt: 1, pb: 2, px: 2, sx: { wordBreak: 'break-all' } }, { children: routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route.id }))] })), _jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(Button, Object.assign({ variant: "contained", href: "https://discord.com/channels/849912621360218112/863689862514343946", target: "_blank", rel: "nofollow noreferrer", fullWidth: true }, { children: t('button.contactSupport') })) })), _jsxs(Dialog, Object.assign({ open: open, onClose: toggleDialog }, { children: [_jsx(DialogTitle, { children: t('swap.warning.title.deleteSwap') }), _jsx(DialogContent, { children: _jsx(DialogContentText, { children: t('swap.warning.message.deleteSwapHistory') }) }), _jsxs(DialogActions, { children: [_jsx(Button, Object.assign({ onClick: toggleDialog }, { children: t('button.cancel') })), _jsx(Button, Object.assign({ variant: "contained", onClick: handleDeleteRoute, autoFocus: true }, { children: t('button.delete') }))] })] }))] }));
62
62
  };
@@ -22,11 +22,11 @@ export const SwapHistoryPage = () => {
22
22
  }, []);
23
23
  useEffect(() => {
24
24
  if (swaps.length) {
25
- return useHeaderActionStore.getState().setAction(_jsx(IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "end", onClick: toggleDialog }, { children: _jsx(DeleteIcon, {}) })));
25
+ return useHeaderActionStore.getState().setAction(_jsx(IconButton, Object.assign({ size: "medium", edge: "end", onClick: toggleDialog }, { children: _jsx(DeleteIcon, {}) })));
26
26
  }
27
27
  }, [swaps.length, toggleDialog]);
28
28
  if (!swaps.length) {
29
29
  return _jsx(SwapHistoryEmpty, {});
30
30
  }
31
- return (_jsxs(Container, { children: [_jsx(Stack, Object.assign({ spacing: 2, mt: 1 }, { children: swaps.length ? (swaps.map(({ route }) => (_jsx(SwapHistoryItem, { route: route }, route.id)))) : (_jsx(SwapHistoryEmpty, {})) })), _jsxs(Dialog, Object.assign({ open: open, onClose: toggleDialog }, { children: [_jsx(DialogTitle, { children: t('swap.warning.title.deleteSwapHistory') }), _jsx(DialogContent, { children: _jsx(DialogContentText, { children: t('swap.warning.message.deleteSwap') }) }), _jsxs(DialogActions, { children: [_jsx(Button, Object.assign({ onClick: toggleDialog }, { children: t('button.cancel') })), _jsx(Button, Object.assign({ onClick: deleteRoutes, autoFocus: true }, { children: t('button.delete') }))] })] }))] }));
31
+ return (_jsxs(Container, { children: [_jsx(Stack, Object.assign({ spacing: 2, mt: 1 }, { children: swaps.length ? (swaps.map(({ route }) => (_jsx(SwapHistoryItem, { route: route }, route.id)))) : (_jsx(SwapHistoryEmpty, {})) })), _jsxs(Dialog, Object.assign({ open: open, onClose: toggleDialog }, { children: [_jsx(DialogTitle, { children: t('swap.warning.title.deleteSwapHistory') }), _jsx(DialogContent, { children: _jsx(DialogContentText, { children: t('swap.warning.message.deleteSwapHistory') }) }), _jsxs(DialogActions, { children: [_jsx(Button, Object.assign({ onClick: toggleDialog }, { children: t('button.cancel') })), _jsx(Button, Object.assign({ variant: "contained", onClick: () => deleteRoutes('completed'), autoFocus: true }, { children: t('button.delete') }))] })] }))] }));
32
32
  };
@@ -10,15 +10,15 @@ import { Token } from '../../components/Token';
10
10
  import { getProcessMessage, useChains, useNavigateBack, useTokenBalance, } from '../../hooks';
11
11
  import { SwapFormKey } from '../../providers';
12
12
  import { navigationRoutes, shortenWalletAddress } from '../../utils';
13
- import { IconCircle, IconContainer, iconStyles, } from './StatusBottomSheet.style';
13
+ import { IconCircle, IconContainer } from './StatusBottomSheet.style';
14
14
  export const StatusBottomSheet = ({ status, route, }) => {
15
15
  var _a, _b, _c, _d, _e, _f, _g;
16
16
  const { t } = useTranslation();
17
17
  const { navigateBack, navigate } = useNavigateBack();
18
18
  const ref = useRef(null);
19
19
  const { getChainById } = useChains();
20
- const { token, refetch, refetchNewBalance, refetchAllBalances } = useTokenBalance(route.toToken, route.toAddress);
21
20
  const { setValue } = useFormContext();
21
+ const { token, refetch, refetchNewBalance, refetchAllBalances } = useTokenBalance(route.toToken, route.toAddress);
22
22
  const clearFromAmount = () => {
23
23
  refetchAllBalances();
24
24
  setValue(SwapFormKey.FromAmount, '');
@@ -30,7 +30,7 @@ export const StatusBottomSheet = ({ status, route, }) => {
30
30
  const handleClose = () => {
31
31
  var _a;
32
32
  clearFromAmount();
33
- (_a = ref.current) === null || _a === void 0 ? void 0 : _a.closeDrawer();
33
+ (_a = ref.current) === null || _a === void 0 ? void 0 : _a.close();
34
34
  };
35
35
  const handleSeeDetails = () => {
36
36
  handleClose();
@@ -73,8 +73,8 @@ export const StatusBottomSheet = ({ status, route, }) => {
73
73
  refetchNewBalance();
74
74
  refetch();
75
75
  }
76
- (_b = ref.current) === null || _b === void 0 ? void 0 : _b.openDrawer();
76
+ (_b = ref.current) === null || _b === void 0 ? void 0 : _b.open();
77
77
  }
78
78
  }, [refetch, refetchNewBalance, status]);
79
- return (_jsx(BottomSheet, Object.assign({ ref: ref }, { children: _jsxs(Box, Object.assign({ p: 3 }, { children: [_jsxs(IconContainer, { children: [_jsxs(IconCircle, Object.assign({ status: status, mb: 1 }, { children: [status === 'idle' ? (_jsx(InfoIcon, { color: "primary", sx: iconStyles })) : null, status === 'success' ? (_jsx(DoneIcon, { color: "success", sx: iconStyles })) : null, status === 'error' ? (_jsx(WarningIcon, { color: "error", sx: iconStyles })) : null] })), _jsx(Typography, Object.assign({ py: 1, fontSize: 18, fontWeight: 700 }, { children: title })), status === 'success' ? (_jsx(Token, { token: Object.assign(Object.assign({}, route.toToken), { amount: (_g = (_e = (_d = (_c = route.steps.at(-1)) === null || _c === void 0 ? void 0 : _c.execution) === null || _d === void 0 ? void 0 : _d.toAmount) !== null && _e !== void 0 ? _e : (_f = route.steps.at(-1)) === null || _f === void 0 ? void 0 : _f.estimate.toAmount) !== null && _g !== void 0 ? _g : route.toAmount }), py: 1 })) : null] }), _jsx(Typography, Object.assign({ pt: 2, pb: 1 }, { children: message })), _jsx(Box, Object.assign({ mt: 2 }, { children: _jsxs(Button, Object.assign({ variant: "contained", fullWidth: true, onClick: status === 'success' ? handleDone : handleClose }, { children: [status === 'idle' ? t('button.okay') : null, status === 'success' ? t('button.done') : null, status === 'error' ? t('button.tryAgain') : null] })) })), status === 'success' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(Button, Object.assign({ variant: "outlined", fullWidth: true, onClick: handleSeeDetails }, { children: t('button.seeDetails') })) }))) : null] })) })));
79
+ return (_jsx(BottomSheet, Object.assign({ ref: ref }, { children: _jsxs(Box, Object.assign({ p: 3 }, { children: [_jsxs(IconContainer, { children: [_jsxs(IconCircle, Object.assign({ status: status, mb: 1 }, { children: [status === 'idle' ? _jsx(InfoIcon, { color: "primary" }) : null, status === 'success' ? _jsx(DoneIcon, { color: "success" }) : null, status === 'error' ? _jsx(WarningIcon, { color: "error" }) : null] })), _jsx(Typography, Object.assign({ py: 1, fontSize: 18, fontWeight: 700 }, { children: title })), status === 'success' ? (_jsx(Token, { token: Object.assign(Object.assign({}, route.toToken), { amount: (_g = (_e = (_d = (_c = route.steps.at(-1)) === null || _c === void 0 ? void 0 : _c.execution) === null || _d === void 0 ? void 0 : _d.toAmount) !== null && _e !== void 0 ? _e : (_f = route.steps.at(-1)) === null || _f === void 0 ? void 0 : _f.estimate.toAmount) !== null && _g !== void 0 ? _g : route.toAmount }), py: 1 })) : null] }), _jsx(Typography, Object.assign({ py: 1 }, { children: message })), _jsx(Box, Object.assign({ mt: 2 }, { children: _jsxs(Button, Object.assign({ variant: "contained", fullWidth: true, onClick: status === 'success' ? handleDone : handleClose }, { children: [status === 'idle' ? t('button.okay') : null, status === 'success' ? t('button.done') : null, status === 'error' ? t('button.seeDetails') : null] })) })), status === 'success' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(Button, Object.assign({ variant: "text", fullWidth: true, onClick: handleSeeDetails }, { children: t('button.seeDetails') })) }))) : null] })) })));
80
80
  };
@@ -19,7 +19,3 @@ export declare const IconCircle: import("@emotion/styled").StyledComponent<impor
19
19
  }, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "ref" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "component"> & import("@mui/system").MUIStyledCommonProps<Theme> & {
20
20
  status: RouteExecutionStatus;
21
21
  }, {}, {}>;
22
- export declare const iconStyles: {
23
- position: string;
24
- fontSize: string;
25
- };
@@ -1,13 +1,15 @@
1
1
  import { Box } from '@mui/material';
2
- import { styled } from '@mui/material/styles';
2
+ import { alpha, darken, styled } from '@mui/material/styles';
3
3
  const getStatusColor = (status, theme) => {
4
4
  switch (status) {
5
5
  case 'success':
6
- return theme.palette.success.main;
6
+ return { color: theme.palette.success.main, alpha: 0.15, darken: 0 };
7
7
  case 'error':
8
- return theme.palette.error.main;
8
+ return { color: theme.palette.error.main, alpha: 0.2, darken: 0 };
9
+ case 'warning':
10
+ return { color: theme.palette.warning.main, alpha: 0.7, darken: 0.4 };
9
11
  default:
10
- return theme.palette.primary.main;
12
+ return { color: theme.palette.primary.main, alpha: 0.15, darken: 0 };
11
13
  }
12
14
  };
13
15
  export const IconContainer = styled(Box)(({ theme }) => ({
@@ -17,16 +19,20 @@ export const IconContainer = styled(Box)(({ theme }) => ({
17
19
  }));
18
20
  export const IconCircle = styled(Box, {
19
21
  shouldForwardProp: (prop) => prop !== 'status',
20
- })(({ theme, status }) => ({
21
- border: `3px solid ${getStatusColor(status, theme)}`,
22
- borderRadius: '50%',
23
- width: 64,
24
- height: 64,
25
- display: 'grid',
26
- position: 'relative',
27
- placeItems: 'center',
28
- }));
29
- export const iconStyles = {
30
- position: 'absolute',
31
- fontSize: '2.5rem',
32
- };
22
+ })(({ theme, status }) => {
23
+ const { color, alpha: alphaValue, darken: darkenValue, } = getStatusColor(status, theme);
24
+ return {
25
+ backgroundColor: alpha(color, alphaValue),
26
+ borderRadius: '50%',
27
+ width: 64,
28
+ height: 64,
29
+ display: 'grid',
30
+ position: 'relative',
31
+ placeItems: 'center',
32
+ '& > svg': {
33
+ color: darken(color, darkenValue),
34
+ width: 32,
35
+ height: 32,
36
+ },
37
+ };
38
+ });