@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
@@ -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
  }
@@ -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
  };
@@ -2,20 +2,37 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ActiveSwapsPage = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ /* eslint-disable consistent-return */
6
+ const icons_material_1 = require("@mui/icons-material");
5
7
  const material_1 = require("@mui/material");
8
+ const react_1 = require("react");
9
+ const react_i18next_1 = require("react-i18next");
6
10
  const ActiveSwaps_1 = require("../../components/ActiveSwaps");
11
+ const Dialog_1 = require("../../components/Dialog");
12
+ const Header_1 = require("../../components/Header");
7
13
  const providers_1 = require("../../providers");
8
14
  const stores_1 = require("../../stores");
9
15
  const ActiveSwapsEmpty_1 = require("./ActiveSwapsEmpty");
10
16
  const ActiveSwapsPage = () => {
17
+ const { t } = (0, react_i18next_1.useTranslation)();
11
18
  const { account } = (0, providers_1.useWallet)();
12
19
  const executingRoutes = (0, stores_1.useExecutingRoutesIds)(account.address);
20
+ const deleteRoutes = (0, stores_1.useRouteExecutionStore)((store) => store.deleteRoutes);
21
+ const [open, setOpen] = (0, react_1.useState)(false);
22
+ const toggleDialog = (0, react_1.useCallback)(() => {
23
+ setOpen((open) => !open);
24
+ }, []);
25
+ (0, react_1.useEffect)(() => {
26
+ if (executingRoutes.length) {
27
+ return Header_1.useHeaderActionStore.getState().setAction((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", edge: "end", onClick: toggleDialog }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.DeleteOutline, {}) })));
28
+ }
29
+ }, [executingRoutes.length, toggleDialog]);
13
30
  if (!executingRoutes.length) {
14
31
  return (0, jsx_runtime_1.jsx)(ActiveSwapsEmpty_1.ActiveSwapsEmpty, {});
15
32
  }
16
- return ((0, jsx_runtime_1.jsx)(material_1.Container, Object.assign({ disableGutters: true }, { children: (0, jsx_runtime_1.jsx)(material_1.List, Object.assign({ sx: {
17
- paddingLeft: 1.5,
18
- paddingRight: 1.5,
19
- } }, { children: executingRoutes.map((routeId) => ((0, jsx_runtime_1.jsx)(ActiveSwaps_1.ActiveSwapItem, { routeId: routeId }, routeId))) })) })));
33
+ return ((0, jsx_runtime_1.jsxs)(material_1.Container, Object.assign({ disableGutters: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.List, Object.assign({ sx: {
34
+ paddingLeft: 1.5,
35
+ paddingRight: 1.5,
36
+ } }, { children: executingRoutes.map((routeId) => ((0, jsx_runtime_1.jsx)(ActiveSwaps_1.ActiveSwapItem, { routeId: routeId }, routeId))) })), (0, jsx_runtime_1.jsxs)(Dialog_1.Dialog, Object.assign({ open: open, onClose: toggleDialog }, { children: [(0, jsx_runtime_1.jsx)(material_1.DialogTitle, { children: t('swap.warning.title.deleteActiveSwaps') }), (0, jsx_runtime_1.jsx)(material_1.DialogContent, { children: (0, jsx_runtime_1.jsx)(material_1.DialogContentText, { children: t('swap.warning.message.deleteActiveSwaps') }) }), (0, jsx_runtime_1.jsxs)(material_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ onClick: toggleDialog }, { children: t('button.cancel') })), (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "contained", onClick: () => deleteRoutes('active'), autoFocus: true }, { children: t('button.delete') }))] })] }))] })));
20
37
  };
21
38
  exports.ActiveSwapsPage = ActiveSwapsPage;
@@ -9,11 +9,11 @@ const SelectChainAndToken_1 = require("../../components/SelectChainAndToken");
9
9
  const SendToWallet_1 = require("../../components/SendToWallet");
10
10
  const SwapInput_1 = require("../../components/SwapInput");
11
11
  const SwapRoutes_1 = require("../../components/SwapRoutes");
12
- const providers_1 = require("../../providers");
12
+ const hooks_1 = require("../../hooks");
13
13
  const MainPage_style_1 = require("./MainPage.style");
14
14
  const MainSwapButton_1 = require("./MainSwapButton");
15
15
  const MainPage = () => {
16
- const { variant } = (0, providers_1.useWidgetConfig)();
17
- return ((0, jsx_runtime_1.jsxs)(MainPage_style_1.FormContainer, Object.assign({ disableGutters: true }, { children: [(0, jsx_runtime_1.jsx)(ActiveSwaps_1.ActiveSwaps, { mx: 3, mt: 1, mb: 2 }), (0, jsx_runtime_1.jsx)(SelectChainAndToken_1.SelectChainAndToken, { mt: 1, mx: 3, mb: 3 }), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mx: 3, mb: 3 }, { children: (0, jsx_runtime_1.jsx)(SwapInput_1.SwapInput, { formType: "from" }) })), variant !== 'expandable' ? (0, jsx_runtime_1.jsx)(SwapRoutes_1.SwapRoutes, { mx: 3, mb: 3 }) : null, (0, jsx_runtime_1.jsx)(GasSufficiencyMessage_1.GasSufficiencyMessage, { mx: 3, mb: 3 }), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ mx: 3, mb: 1 }, { children: [(0, jsx_runtime_1.jsx)(SendToWallet_1.SendToWallet, { mb: 3 }), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: { display: 'flex' } }, { children: [(0, jsx_runtime_1.jsx)(MainSwapButton_1.MainSwapButton, {}), (0, jsx_runtime_1.jsx)(SendToWallet_1.SendToWalletButton, {})] }))] }))] })));
16
+ const expandable = (0, hooks_1.useExpandableVariant)();
17
+ return ((0, jsx_runtime_1.jsxs)(MainPage_style_1.FormContainer, Object.assign({ disableGutters: true }, { children: [(0, jsx_runtime_1.jsx)(ActiveSwaps_1.ActiveSwaps, { mx: 3, mt: 1, mb: 2 }), (0, jsx_runtime_1.jsx)(SelectChainAndToken_1.SelectChainAndToken, { mt: 1, mx: 3, mb: 3 }), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mx: 3, mb: 3 }, { children: (0, jsx_runtime_1.jsx)(SwapInput_1.SwapInput, { formType: "from" }) })), !expandable ? (0, jsx_runtime_1.jsx)(SwapRoutes_1.SwapRoutes, { mx: 3, mb: 3 }) : null, (0, jsx_runtime_1.jsx)(GasSufficiencyMessage_1.GasSufficiencyMessage, { mx: 3, mb: 3 }), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ mx: 3, mb: 1 }, { children: [(0, jsx_runtime_1.jsx)(SendToWallet_1.SendToWallet, { mb: 3 }), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: { display: 'flex' } }, { children: [(0, jsx_runtime_1.jsx)(MainSwapButton_1.MainSwapButton, {}), (0, jsx_runtime_1.jsx)(SendToWallet_1.SendToWalletButton, {})] }))] }))] })));
18
18
  };
19
19
  exports.MainPage = MainPage;
@@ -48,6 +48,6 @@ const SelectWalletPage = () => {
48
48
  paddingRight: 1.5,
49
49
  } }, { children: wallet_management_1.supportedWallets.map((wallet) => ((0, jsx_runtime_1.jsxs)(SelectWalletPage_style_1.ListItemButton, Object.assign({ onClick: () => handleConnect(wallet), disableRipple: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemAvatar, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, Object.assign({ src: wallet.icon.src || wallet.icon, alt: wallet.name }, { children: wallet.name[0] })) }), (0, jsx_runtime_1.jsx)(SelectWalletPage_style_1.ListItemText, { primary: wallet.name })] }), wallet.name))) })), (0, jsx_runtime_1.jsxs)(Dialog_1.Dialog, Object.assign({ open: walletIdentity.show, onClose: closeDialog }, { children: [(0, jsx_runtime_1.jsx)(material_1.DialogContent, { children: (0, jsx_runtime_1.jsx)(material_1.DialogContentText, { children: t('wallet.extensionNotFound', {
50
50
  name: (_a = walletIdentity.wallet) === null || _a === void 0 ? void 0 : _a.name,
51
- }) }) }), (0, jsx_runtime_1.jsx)(material_1.DialogActions, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ onClick: closeDialog, autoFocus: true }, { children: t('button.ok') })) })] }))] })));
51
+ }) }) }), (0, jsx_runtime_1.jsx)(material_1.DialogActions, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "contained", onClick: closeDialog, autoFocus: true }, { children: t('button.ok') })) })] }))] })));
52
52
  };
53
53
  exports.SelectWalletPage = SelectWalletPage;
@@ -46,7 +46,7 @@ const SwapDetailsPage = () => {
46
46
  yield navigator.clipboard.writeText((_c = routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route.id) !== null && _c !== void 0 ? _c : '');
47
47
  });
48
48
  (0, react_1.useEffect)(() => {
49
- return Header_1.useHeaderActionStore.getState().setAction((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "end", onClick: toggleDialog }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.DeleteOutline, {}) })));
49
+ return Header_1.useHeaderActionStore.getState().setAction((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", edge: "end", onClick: toggleDialog }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.DeleteOutline, {}) })));
50
50
  }, [toggleDialog]);
51
51
  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);
52
52
  return ((0, jsx_runtime_1.jsxs)(SwapDetailsPage_style_1.Container, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: {
@@ -61,6 +61,6 @@ const SwapDetailsPage = () => {
61
61
  }), (0, jsx_runtime_1.jsxs)(Card_1.Card, Object.assign({ mt: 2 }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: {
62
62
  display: 'flex',
63
63
  flex: 1,
64
- } }, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, Object.assign({ flex: 1 }, { children: t('swap.supportId') })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mr: 1, mt: 1 }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", "aria-label": "settings", onClick: copyRouteId }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.ContentCopy, { fontSize: "small" }) })) }))] })), (0, jsx_runtime_1.jsx)(material_1.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 }))] })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "contained", href: "https://discord.com/channels/849912621360218112/863689862514343946", target: "_blank", rel: "nofollow noreferrer", fullWidth: true }, { children: t('button.contactSupport') })) })), (0, jsx_runtime_1.jsxs)(Dialog_1.Dialog, Object.assign({ open: open, onClose: toggleDialog }, { children: [(0, jsx_runtime_1.jsx)(material_1.DialogTitle, { children: t('swap.warning.title.deleteSwap') }), (0, jsx_runtime_1.jsx)(material_1.DialogContent, { children: (0, jsx_runtime_1.jsx)(material_1.DialogContentText, { children: t('swap.warning.message.deleteSwap') }) }), (0, jsx_runtime_1.jsxs)(material_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ onClick: toggleDialog }, { children: t('button.cancel') })), (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ onClick: handleDeleteRoute, autoFocus: true }, { children: t('button.delete') }))] })] }))] }));
64
+ } }, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, Object.assign({ flex: 1 }, { children: t('swap.supportId') })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mr: 1, mt: 1 }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", onClick: copyRouteId }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.ContentCopy, { fontSize: "small" }) })) }))] })), (0, jsx_runtime_1.jsx)(material_1.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 }))] })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "contained", href: "https://discord.com/channels/849912621360218112/863689862514343946", target: "_blank", rel: "nofollow noreferrer", fullWidth: true }, { children: t('button.contactSupport') })) })), (0, jsx_runtime_1.jsxs)(Dialog_1.Dialog, Object.assign({ open: open, onClose: toggleDialog }, { children: [(0, jsx_runtime_1.jsx)(material_1.DialogTitle, { children: t('swap.warning.title.deleteSwap') }), (0, jsx_runtime_1.jsx)(material_1.DialogContent, { children: (0, jsx_runtime_1.jsx)(material_1.DialogContentText, { children: t('swap.warning.message.deleteSwapHistory') }) }), (0, jsx_runtime_1.jsxs)(material_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ onClick: toggleDialog }, { children: t('button.cancel') })), (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "contained", onClick: handleDeleteRoute, autoFocus: true }, { children: t('button.delete') }))] })] }))] }));
65
65
  };
66
66
  exports.SwapDetailsPage = SwapDetailsPage;
@@ -25,12 +25,12 @@ const SwapHistoryPage = () => {
25
25
  }, []);
26
26
  (0, react_1.useEffect)(() => {
27
27
  if (swaps.length) {
28
- return Header_1.useHeaderActionStore.getState().setAction((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "end", onClick: toggleDialog }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.DeleteOutline, {}) })));
28
+ return Header_1.useHeaderActionStore.getState().setAction((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", edge: "end", onClick: toggleDialog }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.DeleteOutline, {}) })));
29
29
  }
30
30
  }, [swaps.length, toggleDialog]);
31
31
  if (!swaps.length) {
32
32
  return (0, jsx_runtime_1.jsx)(SwapHistoryEmpty_1.SwapHistoryEmpty, {});
33
33
  }
34
- return ((0, jsx_runtime_1.jsxs)(material_1.Container, { children: [(0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ spacing: 2, mt: 1 }, { children: swaps.length ? (swaps.map(({ route }) => ((0, jsx_runtime_1.jsx)(SwapHistoryItem_1.SwapHistoryItem, { route: route }, route.id)))) : ((0, jsx_runtime_1.jsx)(SwapHistoryEmpty_1.SwapHistoryEmpty, {})) })), (0, jsx_runtime_1.jsxs)(Dialog_1.Dialog, Object.assign({ open: open, onClose: toggleDialog }, { children: [(0, jsx_runtime_1.jsx)(material_1.DialogTitle, { children: t('swap.warning.title.deleteSwapHistory') }), (0, jsx_runtime_1.jsx)(material_1.DialogContent, { children: (0, jsx_runtime_1.jsx)(material_1.DialogContentText, { children: t('swap.warning.message.deleteSwap') }) }), (0, jsx_runtime_1.jsxs)(material_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ onClick: toggleDialog }, { children: t('button.cancel') })), (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ onClick: deleteRoutes, autoFocus: true }, { children: t('button.delete') }))] })] }))] }));
34
+ return ((0, jsx_runtime_1.jsxs)(material_1.Container, { children: [(0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ spacing: 2, mt: 1 }, { children: swaps.length ? (swaps.map(({ route }) => ((0, jsx_runtime_1.jsx)(SwapHistoryItem_1.SwapHistoryItem, { route: route }, route.id)))) : ((0, jsx_runtime_1.jsx)(SwapHistoryEmpty_1.SwapHistoryEmpty, {})) })), (0, jsx_runtime_1.jsxs)(Dialog_1.Dialog, Object.assign({ open: open, onClose: toggleDialog }, { children: [(0, jsx_runtime_1.jsx)(material_1.DialogTitle, { children: t('swap.warning.title.deleteSwapHistory') }), (0, jsx_runtime_1.jsx)(material_1.DialogContent, { children: (0, jsx_runtime_1.jsx)(material_1.DialogContentText, { children: t('swap.warning.message.deleteSwapHistory') }) }), (0, jsx_runtime_1.jsxs)(material_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ onClick: toggleDialog }, { children: t('button.cancel') })), (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "contained", onClick: () => deleteRoutes('completed'), autoFocus: true }, { children: t('button.delete') }))] })] }))] }));
35
35
  };
36
36
  exports.SwapHistoryPage = SwapHistoryPage;
@@ -20,8 +20,8 @@ const StatusBottomSheet = ({ status, route, }) => {
20
20
  const { navigateBack, navigate } = (0, hooks_1.useNavigateBack)();
21
21
  const ref = (0, react_1.useRef)(null);
22
22
  const { getChainById } = (0, hooks_1.useChains)();
23
- const { token, refetch, refetchNewBalance, refetchAllBalances } = (0, hooks_1.useTokenBalance)(route.toToken, route.toAddress);
24
23
  const { setValue } = (0, react_hook_form_1.useFormContext)();
24
+ const { token, refetch, refetchNewBalance, refetchAllBalances } = (0, hooks_1.useTokenBalance)(route.toToken, route.toAddress);
25
25
  const clearFromAmount = () => {
26
26
  refetchAllBalances();
27
27
  setValue(providers_1.SwapFormKey.FromAmount, '');
@@ -33,7 +33,7 @@ const StatusBottomSheet = ({ status, route, }) => {
33
33
  const handleClose = () => {
34
34
  var _a;
35
35
  clearFromAmount();
36
- (_a = ref.current) === null || _a === void 0 ? void 0 : _a.closeDrawer();
36
+ (_a = ref.current) === null || _a === void 0 ? void 0 : _a.close();
37
37
  };
38
38
  const handleSeeDetails = () => {
39
39
  handleClose();
@@ -76,9 +76,9 @@ const StatusBottomSheet = ({ status, route, }) => {
76
76
  refetchNewBalance();
77
77
  refetch();
78
78
  }
79
- (_b = ref.current) === null || _b === void 0 ? void 0 : _b.openDrawer();
79
+ (_b = ref.current) === null || _b === void 0 ? void 0 : _b.open();
80
80
  }
81
81
  }, [refetch, refetchNewBalance, status]);
82
- return ((0, jsx_runtime_1.jsx)(BottomSheet_1.BottomSheet, Object.assign({ ref: ref }, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ p: 3 }, { children: [(0, jsx_runtime_1.jsxs)(StatusBottomSheet_style_1.IconContainer, { children: [(0, jsx_runtime_1.jsxs)(StatusBottomSheet_style_1.IconCircle, Object.assign({ status: status, mb: 1 }, { children: [status === 'idle' ? ((0, jsx_runtime_1.jsx)(icons_material_1.Info, { color: "primary", sx: StatusBottomSheet_style_1.iconStyles })) : null, status === 'success' ? ((0, jsx_runtime_1.jsx)(icons_material_1.Done, { color: "success", sx: StatusBottomSheet_style_1.iconStyles })) : null, status === 'error' ? ((0, jsx_runtime_1.jsx)(icons_material_1.Warning, { color: "error", sx: StatusBottomSheet_style_1.iconStyles })) : null] })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ py: 1, fontSize: 18, fontWeight: 700 }, { children: title })), status === 'success' ? ((0, jsx_runtime_1.jsx)(Token_1.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] }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ pt: 2, pb: 1 }, { children: message })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsxs)(material_1.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' ? ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "outlined", fullWidth: true, onClick: handleSeeDetails }, { children: t('button.seeDetails') })) }))) : null] })) })));
82
+ return ((0, jsx_runtime_1.jsx)(BottomSheet_1.BottomSheet, Object.assign({ ref: ref }, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ p: 3 }, { children: [(0, jsx_runtime_1.jsxs)(StatusBottomSheet_style_1.IconContainer, { children: [(0, jsx_runtime_1.jsxs)(StatusBottomSheet_style_1.IconCircle, Object.assign({ status: status, mb: 1 }, { children: [status === 'idle' ? (0, jsx_runtime_1.jsx)(icons_material_1.Info, { color: "primary" }) : null, status === 'success' ? (0, jsx_runtime_1.jsx)(icons_material_1.Done, { color: "success" }) : null, status === 'error' ? (0, jsx_runtime_1.jsx)(icons_material_1.Warning, { color: "error" }) : null] })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ py: 1, fontSize: 18, fontWeight: 700 }, { children: title })), status === 'success' ? ((0, jsx_runtime_1.jsx)(Token_1.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] }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ py: 1 }, { children: message })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsxs)(material_1.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' ? ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "text", fullWidth: true, onClick: handleSeeDetails }, { children: t('button.seeDetails') })) }))) : null] })) })));
83
83
  };
84
84
  exports.StatusBottomSheet = StatusBottomSheet;
@@ -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,16 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.iconStyles = exports.IconCircle = exports.IconContainer = void 0;
3
+ exports.IconCircle = exports.IconContainer = void 0;
4
4
  const material_1 = require("@mui/material");
5
5
  const styles_1 = require("@mui/material/styles");
6
6
  const getStatusColor = (status, theme) => {
7
7
  switch (status) {
8
8
  case 'success':
9
- return theme.palette.success.main;
9
+ return { color: theme.palette.success.main, alpha: 0.15, darken: 0 };
10
10
  case 'error':
11
- return theme.palette.error.main;
11
+ return { color: theme.palette.error.main, alpha: 0.2, darken: 0 };
12
+ case 'warning':
13
+ return { color: theme.palette.warning.main, alpha: 0.7, darken: 0.4 };
12
14
  default:
13
- return theme.palette.primary.main;
15
+ return { color: theme.palette.primary.main, alpha: 0.15, darken: 0 };
14
16
  }
15
17
  };
16
18
  exports.IconContainer = (0, styles_1.styled)(material_1.Box)(({ theme }) => ({
@@ -20,16 +22,20 @@ exports.IconContainer = (0, styles_1.styled)(material_1.Box)(({ theme }) => ({
20
22
  }));
21
23
  exports.IconCircle = (0, styles_1.styled)(material_1.Box, {
22
24
  shouldForwardProp: (prop) => prop !== 'status',
23
- })(({ theme, status }) => ({
24
- border: `3px solid ${getStatusColor(status, theme)}`,
25
- borderRadius: '50%',
26
- width: 64,
27
- height: 64,
28
- display: 'grid',
29
- position: 'relative',
30
- placeItems: 'center',
31
- }));
32
- exports.iconStyles = {
33
- position: 'absolute',
34
- fontSize: '2.5rem',
35
- };
25
+ })(({ theme, status }) => {
26
+ const { color, alpha: alphaValue, darken: darkenValue, } = getStatusColor(status, theme);
27
+ return {
28
+ backgroundColor: (0, styles_1.alpha)(color, alphaValue),
29
+ borderRadius: '50%',
30
+ width: 64,
31
+ height: 64,
32
+ display: 'grid',
33
+ position: 'relative',
34
+ placeItems: 'center',
35
+ '& > svg': {
36
+ color: (0, styles_1.darken)(color, darkenValue),
37
+ width: 32,
38
+ height: 32,
39
+ },
40
+ };
41
+ });
@@ -25,32 +25,51 @@ const hooks_1 = require("../../hooks");
25
25
  const providers_1 = require("../../providers");
26
26
  const StatusBottomSheet_1 = require("./StatusBottomSheet");
27
27
  const SwapPage_style_1 = require("./SwapPage.style");
28
+ const TokenValueBottomSheet_1 = require("./TokenValueBottomSheet");
28
29
  const SwapPage = () => {
29
30
  const { t } = (0, react_i18next_1.useTranslation)();
30
31
  const { state } = (0, react_router_dom_1.useLocation)();
31
32
  const { navigateBack } = (0, hooks_1.useNavigateBack)();
32
- const { setValue, formState: { isValid, isValidating }, } = (0, react_hook_form_1.useFormContext)();
33
+ const tokenValueBottomSheetRef = (0, react_1.useRef)(null);
34
+ const { setValue,
35
+ // formState: { isValid, isValidating },
36
+ } = (0, react_hook_form_1.useFormContext)();
33
37
  const { route, status, executeRoute, restartRoute, deleteRoute } = (0, hooks_1.useRouteExecution)(state === null || state === void 0 ? void 0 : state.routeId);
34
- const handleRemoveRoute = () => {
35
- navigateBack();
36
- deleteRoute();
37
- };
38
+ const handleExecuteRoute = (0, react_1.useCallback)(() => {
39
+ var _a, _b;
40
+ if ((_a = tokenValueBottomSheetRef.current) === null || _a === void 0 ? void 0 : _a.isOpen()) {
41
+ (_b = tokenValueBottomSheetRef.current) === null || _b === void 0 ? void 0 : _b.close();
42
+ }
43
+ executeRoute();
44
+ setValue(providers_1.SwapFormKey.FromAmount, '');
45
+ }, [executeRoute, setValue]);
38
46
  const handleSwapClick = () => __awaiter(void 0, void 0, void 0, function* () {
47
+ var _a;
39
48
  if (status === 'idle') {
40
- executeRoute();
41
- setValue(providers_1.SwapFormKey.FromAmount, '');
49
+ const thresholdExceeded = (0, TokenValueBottomSheet_1.getTokenValueLossThreshold)(route);
50
+ if (thresholdExceeded) {
51
+ (_a = tokenValueBottomSheetRef.current) === null || _a === void 0 ? void 0 : _a.open();
52
+ }
53
+ else {
54
+ handleExecuteRoute();
55
+ }
42
56
  }
43
57
  if (status === 'error') {
44
58
  restartRoute();
45
59
  }
46
60
  });
47
- // eslint-disable-next-line consistent-return
61
+ const handleRemoveRoute = () => {
62
+ navigateBack();
63
+ deleteRoute();
64
+ };
48
65
  const getSwapButtonText = () => {
49
- if (status === 'idle') {
50
- return t('button.startSwap');
51
- }
52
- if (status === 'error') {
53
- return t('button.restartSwap');
66
+ switch (status) {
67
+ case 'idle':
68
+ return t('button.startSwap');
69
+ case 'error':
70
+ return t('button.restartSwap');
71
+ default:
72
+ return '';
54
73
  }
55
74
  };
56
75
  return ((0, jsx_runtime_1.jsxs)(SwapPage_style_1.Container, { children: [route === null || route === void 0 ? void 0 : route.steps.map((step, index, steps) => {
@@ -58,9 +77,11 @@ const SwapPage = () => {
58
77
  return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Step_1.Step, { step: step, fromToken: index === 0
59
78
  ? Object.assign(Object.assign({}, step.action.fromToken), { amount: step.action.fromAmount }) : undefined, toToken: index === steps.length - 1
60
79
  ? Object.assign(Object.assign({}, step.action.toToken), { amount: (_b = (_a = step.execution) === null || _a === void 0 ? void 0 : _a.toAmount) !== null && _b !== void 0 ? _b : step.estimate.toAmount }) : undefined }), steps.length > 1 && index !== steps.length - 1 ? ((0, jsx_runtime_1.jsx)(StepDivider_1.StepDivider, {})) : null] }, step.id));
61
- }), status === 'idle' ? ((0, jsx_runtime_1.jsx)(GasSufficiencyMessage_1.GasSufficiencyMessage, { route: route, mt: 2 })) : null, status === 'idle' || status === 'error' ? ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ mt: 2, display: "flex" }, { children: [(0, jsx_runtime_1.jsx)(SwapButton_1.SwapButton, { text: getSwapButtonText(), onClick: handleSwapClick, currentRoute: route, disable: status === 'idle' && (isValidating || !isValid) }), status === 'error' ? ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ onClick: handleRemoveRoute, sx: {
62
- minWidth: 48,
63
- marginLeft: 1,
64
- } }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.Delete, {}) }))) : null] }))) : null, route && status ? ((0, jsx_runtime_1.jsx)(StatusBottomSheet_1.StatusBottomSheet, { status: status, route: route })) : null] }));
80
+ }), status === 'idle' || status === 'error' ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(GasSufficiencyMessage_1.GasSufficiencyMessage, { route: route, mt: 2 }), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ mt: 2, display: "flex" }, { children: [(0, jsx_runtime_1.jsx)(SwapButton_1.SwapButton, { text: getSwapButtonText(), onClick: handleSwapClick, currentRoute: route,
81
+ // disable={status === 'idle' && (isValidating || !isValid)}
82
+ enableLoading: true }), status === 'error' ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: t('button.removeSwap'), placement: "bottom-end", enterDelay: 400, arrow: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ onClick: handleRemoveRoute, sx: {
83
+ minWidth: 48,
84
+ marginLeft: 1,
85
+ } }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.Delete, {}) })) }))) : null] }))] })) : null, route && status ? ((0, jsx_runtime_1.jsx)(StatusBottomSheet_1.StatusBottomSheet, { status: status, route: route })) : null, route ? ((0, jsx_runtime_1.jsx)(TokenValueBottomSheet_1.TokenValueBottomSheet, { route: route, ref: tokenValueBottomSheetRef, onContinue: handleExecuteRoute })) : null] }));
65
86
  };
66
87
  exports.SwapPage = SwapPage;
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import type { Route } from '@lifi/sdk';
3
+ import type { BottomSheetBase } from '../../components/BottomSheet';
4
+ interface TokenValueBottomSheetProps {
5
+ route: Route;
6
+ onContinue(): void;
7
+ onCancel?(): void;
8
+ }
9
+ export declare const TokenValueBottomSheet: import("react").ForwardRefExoticComponent<TokenValueBottomSheetProps & import("react").RefAttributes<BottomSheetBase>>;
10
+ export declare const getTokenValueLossThreshold: (route?: Route) => boolean;
11
+ export {};
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTokenValueLossThreshold = exports.TokenValueBottomSheet = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const icons_material_1 = require("@mui/icons-material");
6
+ const material_1 = require("@mui/material");
7
+ const big_js_1 = require("big.js");
8
+ const react_1 = require("react");
9
+ const react_i18next_1 = require("react-i18next");
10
+ const BottomSheet_1 = require("../../components/BottomSheet");
11
+ const hooks_1 = require("../../hooks");
12
+ const StatusBottomSheet_style_1 = require("./StatusBottomSheet.style");
13
+ exports.TokenValueBottomSheet = (0, react_1.forwardRef)(({ route, onContinue, onCancel }, ref) => {
14
+ const handleCancel = () => {
15
+ var _a;
16
+ (_a = ref.current) === null || _a === void 0 ? void 0 : _a.close();
17
+ onCancel === null || onCancel === void 0 ? void 0 : onCancel();
18
+ };
19
+ return ((0, jsx_runtime_1.jsx)(BottomSheet_1.BottomSheet, Object.assign({ ref: ref }, { children: (0, jsx_runtime_1.jsx)(TokenValueBottomSheetContent, { route: route, onContinue: onContinue, onCancel: handleCancel }) })));
20
+ });
21
+ const TokenValueBottomSheetContent = ({ route, onCancel, onContinue, }) => {
22
+ const { t } = (0, react_i18next_1.useTranslation)();
23
+ const ref = (0, react_1.useRef)();
24
+ (0, hooks_1.useSetContentHeight)(ref);
25
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ p: 3, ref: ref }, { children: [(0, jsx_runtime_1.jsxs)(StatusBottomSheet_style_1.IconContainer, { children: [(0, jsx_runtime_1.jsx)(StatusBottomSheet_style_1.IconCircle, Object.assign({ status: "warning", mb: 1 }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.Warning, { color: "warning" }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ py: 1, fontSize: 18, fontWeight: 700 }, { children: t('swap.warning.title.highValueLoss') }))] }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ py: 1 }, { children: t('swap.warning.message.highValueLoss') })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ display: "flex", justifyContent: "space-between", mt: 1 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { children: t('swap.swapping') }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontWeight: 600 }, { children: t('swap.currency', { value: route.fromAmountUSD }) }))] })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ display: "flex", justifyContent: "space-between", mt: 0.25 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { children: t('swap.gasCost') }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontWeight: 600 }, { children: t('swap.currency', { value: route.gasCostUSD }) }))] })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ display: "flex", justifyContent: "space-between", mt: 0.25 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { children: t('swap.receiving') }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontWeight: 600 }, { children: t('swap.currency', { value: route.toAmountUSD }) }))] })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ display: "flex", justifyContent: "space-between", mt: 0.25 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { children: t('swap.valueLoss') }), (0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ fontWeight: 600 }, { children: [(0, big_js_1.default)(route.toAmountUSD || 0)
26
+ .div((0, big_js_1.default)(route.fromAmountUSD || 0).plus((0, big_js_1.default)(route.gasCostUSD || 0)))
27
+ .mul(-100)
28
+ .toFixed(1), "%"] }))] })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ display: "flex", mt: 3 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "text", onClick: onCancel, fullWidth: true }, { children: t('button.cancel') })), (0, jsx_runtime_1.jsx)(material_1.Box, { display: "flex", p: 1 }), (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "contained", onClick: onContinue, fullWidth: true }, { children: t('button.continue') }))] }))] })));
29
+ };
30
+ const getTokenValueLossThreshold = (route) => {
31
+ if (!route) {
32
+ return false;
33
+ }
34
+ const fromAmountUSD = (0, big_js_1.default)((route === null || route === void 0 ? void 0 : route.fromAmountUSD) || 0);
35
+ const toAmountUSD = (0, big_js_1.default)((route === null || route === void 0 ? void 0 : route.toAmountUSD) || 0);
36
+ const gasCostUSD = (0, big_js_1.default)((route === null || route === void 0 ? void 0 : route.gasCostUSD) || 0);
37
+ if (fromAmountUSD.eq(0) && toAmountUSD.eq(0)) {
38
+ return false;
39
+ }
40
+ return toAmountUSD.div(fromAmountUSD.plus(gasCostUSD)).lt(0.9);
41
+ };
42
+ exports.getTokenValueLossThreshold = getTokenValueLossThreshold;
@@ -5,13 +5,14 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_hook_form_1 = require("react-hook-form");
6
6
  const WidgetProvider_1 = require("../WidgetProvider");
7
7
  const types_1 = require("./types");
8
+ const URLSearchParamsBuilder_1 = require("./URLSearchParamsBuilder");
8
9
  exports.formDefaultValues = {
9
10
  [types_1.SwapFormKey.FromAmount]: '',
10
11
  [types_1.SwapFormKey.ToAddress]: '',
11
12
  [types_1.SwapFormKey.TokenSearchFilter]: '',
12
13
  };
13
14
  const SwapFormProvider = ({ children, }) => {
14
- const { fromChain, fromToken, fromAmount, toChain, toToken, toAddress } = (0, WidgetProvider_1.useWidgetConfig)();
15
+ const { fromChain, fromToken, fromAmount, toChain, toToken, toAddress, buildSwapUrl, } = (0, WidgetProvider_1.useWidgetConfig)();
15
16
  const methods = (0, react_hook_form_1.useForm)({
16
17
  defaultValues: Object.assign(Object.assign({}, exports.formDefaultValues), { fromChain,
17
18
  fromToken, fromAmount: (typeof fromAmount === 'number'
@@ -20,6 +21,6 @@ const SwapFormProvider = ({ children, }) => {
20
21
  toToken,
21
22
  toAddress }),
22
23
  });
23
- return (0, jsx_runtime_1.jsx)(react_hook_form_1.FormProvider, Object.assign({}, methods, { children: children }));
24
+ return ((0, jsx_runtime_1.jsxs)(react_hook_form_1.FormProvider, Object.assign({}, methods, { children: [buildSwapUrl ? (0, jsx_runtime_1.jsx)(URLSearchParamsBuilder_1.URLSearchParamsBuilder, {}) : null, children] })));
24
25
  };
25
26
  exports.SwapFormProvider = SwapFormProvider;
@@ -0,0 +1 @@
1
+ export declare const URLSearchParamsBuilder: () => null;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.URLSearchParamsBuilder = void 0;
15
+ const react_1 = require("react");
16
+ const react_hook_form_1 = require("react-hook-form");
17
+ const react_router_dom_1 = require("react-router-dom");
18
+ const types_1 = require("./types");
19
+ const formValueKeys = [
20
+ types_1.SwapFormKey.FromAmount,
21
+ types_1.SwapFormKey.FromChain,
22
+ types_1.SwapFormKey.FromToken,
23
+ types_1.SwapFormKey.ToAddress,
24
+ types_1.SwapFormKey.ToChain,
25
+ types_1.SwapFormKey.ToToken,
26
+ ];
27
+ const URLSearchParamsBuilder = () => {
28
+ const { pathname } = (0, react_router_dom_1.useLocation)();
29
+ const touchedFields = __rest((0, react_hook_form_1.useFormState)().touchedFields, []);
30
+ const values = (0, react_hook_form_1.useWatch)({ name: formValueKeys });
31
+ (0, react_1.useEffect)(() => {
32
+ const url = new URL(window.location);
33
+ formValueKeys.forEach((key, index) => {
34
+ if (touchedFields[key] && values[index]) {
35
+ url.searchParams.set(key, values[index]);
36
+ }
37
+ else if (url.searchParams.has(key) && !values[index]) {
38
+ url.searchParams.delete(key);
39
+ }
40
+ });
41
+ url.searchParams.sort();
42
+ window.history.replaceState(window.history.state, '', url);
43
+ }, [pathname, touchedFields, values]);
44
+ return null;
45
+ };
46
+ exports.URLSearchParamsBuilder = URLSearchParamsBuilder;
@@ -2,19 +2,19 @@ export declare enum SwapFormKey {
2
2
  FromAmount = "fromAmount",
3
3
  FromChain = "fromChain",
4
4
  FromToken = "fromToken",
5
- TokenSearchFilter = "tokenSearchFilter",
5
+ ToAddress = "toAddress",
6
6
  ToChain = "toChain",
7
7
  ToToken = "toToken",
8
- ToAddress = "toAddress"
8
+ TokenSearchFilter = "tokenSearchFilter"
9
9
  }
10
10
  export declare type SwapFormValues = {
11
11
  [SwapFormKey.FromAmount]: string;
12
12
  [SwapFormKey.FromChain]: number;
13
13
  [SwapFormKey.FromToken]: string;
14
- [SwapFormKey.TokenSearchFilter]: string;
14
+ [SwapFormKey.ToAddress]: string;
15
15
  [SwapFormKey.ToChain]: number;
16
16
  [SwapFormKey.ToToken]: string;
17
- [SwapFormKey.ToAddress]: string;
17
+ [SwapFormKey.TokenSearchFilter]: string;
18
18
  };
19
19
  export declare type SwapFormType = 'from' | 'to';
20
20
  export declare const SwapFormKeyHelper: {
@@ -6,10 +6,10 @@ var SwapFormKey;
6
6
  SwapFormKey["FromAmount"] = "fromAmount";
7
7
  SwapFormKey["FromChain"] = "fromChain";
8
8
  SwapFormKey["FromToken"] = "fromToken";
9
- SwapFormKey["TokenSearchFilter"] = "tokenSearchFilter";
9
+ SwapFormKey["ToAddress"] = "toAddress";
10
10
  SwapFormKey["ToChain"] = "toChain";
11
11
  SwapFormKey["ToToken"] = "toToken";
12
- SwapFormKey["ToAddress"] = "toAddress";
12
+ SwapFormKey["TokenSearchFilter"] = "tokenSearchFilter";
13
13
  })(SwapFormKey = exports.SwapFormKey || (exports.SwapFormKey = {}));
14
14
  exports.SwapFormKeyHelper = {
15
15
  getChainKey: (formType) => `${formType}Chain`,
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import type { WalletAccount } from './types';
3
+ export declare const WalletFormUpdate: React.FC<{
4
+ account: WalletAccount;
5
+ }>;