@lifi/widget 1.16.0 → 1.17.1

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 (179) hide show
  1. package/AppDrawer.d.ts +3 -3
  2. package/AppProvider.d.ts +0 -4
  3. package/AppProvider.js +2 -10
  4. package/README.md +1 -1
  5. package/cjs/AppDrawer.d.ts +3 -3
  6. package/cjs/AppProvider.d.ts +0 -4
  7. package/cjs/AppProvider.js +3 -12
  8. package/cjs/components/AppContainer.js +2 -2
  9. package/cjs/components/ChainSelect/ChainSelect.style.js +4 -4
  10. package/cjs/components/ChainSelect/useChainSelect.d.ts +2 -2
  11. package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.js +3 -3
  12. package/cjs/components/Header/useHeaderActionStore.d.ts +0 -2
  13. package/cjs/components/Header/useHeaderActionStore.js +1 -5
  14. package/cjs/components/SelectChainAndToken.js +5 -5
  15. package/cjs/components/SwapButton/SwapButton.js +3 -23
  16. package/cjs/components/TokenList/TokenList.js +1 -1
  17. package/cjs/components/TokenList/TokenList.style.js +4 -3
  18. package/cjs/components/TokenList/TokenListItem.js +1 -1
  19. package/cjs/components/TokenList/TokenNotFound.d.ts +2 -1
  20. package/cjs/components/TokenList/TokenNotFound.js +12 -2
  21. package/cjs/components/TokenList/types.d.ts +2 -2
  22. package/cjs/config/version.d.ts +1 -1
  23. package/cjs/config/version.js +1 -1
  24. package/cjs/hooks/useChains.js +23 -10
  25. package/cjs/hooks/useFeaturedTokens.d.ts +1 -1
  26. package/cjs/hooks/useFeaturedTokens.js +6 -3
  27. package/cjs/hooks/useGasSufficiency.d.ts +1 -1
  28. package/cjs/hooks/useGasSufficiency.js +39 -28
  29. package/cjs/hooks/useInitializer.js +6 -0
  30. package/cjs/hooks/useRouteExecution.js +28 -12
  31. package/cjs/hooks/useSwapRoutes.js +10 -11
  32. package/cjs/hooks/useToken.d.ts +0 -1
  33. package/cjs/hooks/useToken.js +1 -2
  34. package/cjs/hooks/useTokenBalances.d.ts +1 -2
  35. package/cjs/hooks/useTokenBalances.js +5 -6
  36. package/cjs/hooks/useTokenSearch.js +3 -2
  37. package/cjs/hooks/useTokens.d.ts +1 -2
  38. package/cjs/hooks/useTokens.js +32 -9
  39. package/cjs/hooks/useTools.js +11 -5
  40. package/cjs/hooks/useWidgetEvents.d.ts +3 -3
  41. package/cjs/hooks/useWidgetEvents.js +2 -2
  42. package/cjs/i18n/en/translation.json +2 -3
  43. package/cjs/i18n/index.d.ts +1 -2
  44. package/cjs/index.d.ts +2 -1
  45. package/cjs/pages/MainPage/MainSwapButton.js +1 -1
  46. package/cjs/pages/SettingsPage/AdvancedPreferences.js +1 -1
  47. package/cjs/pages/SettingsPage/GasPriceSelect.js +1 -1
  48. package/cjs/pages/SettingsPage/RoutePrioritySelect.js +1 -1
  49. package/cjs/pages/SettingsPage/ShowDestinationWallet.js +1 -1
  50. package/cjs/pages/SettingsPage/SlippageInput.js +1 -1
  51. package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +2 -3
  52. package/cjs/pages/SwapHistoryPage/SwapHistoryPage.js +2 -3
  53. package/cjs/pages/SwapPage/SwapPage.js +11 -2
  54. package/cjs/pages/SwapRoutesPage/SwapRoutesPage.js +4 -3
  55. package/cjs/providers/SDKProvider/SDKProvider.d.ts +4 -0
  56. package/cjs/providers/SDKProvider/SDKProvider.js +27 -0
  57. package/cjs/providers/SDKProvider/index.d.ts +1 -0
  58. package/cjs/providers/SDKProvider/index.js +17 -0
  59. package/cjs/providers/SwapFormProvider/SwapFormProvider.js +4 -58
  60. package/cjs/providers/SwapFormProvider/types.d.ts +5 -5
  61. package/cjs/providers/TelemetryProvider/TelemetryProvider.d.ts +4 -0
  62. package/cjs/providers/TelemetryProvider/TelemetryProvider.js +11 -0
  63. package/cjs/providers/TelemetryProvider/index.d.ts +1 -0
  64. package/cjs/providers/TelemetryProvider/index.js +17 -0
  65. package/cjs/providers/WalletProvider/WalletProvider.d.ts +1 -4
  66. package/cjs/providers/WalletProvider/WalletProvider.js +59 -1
  67. package/cjs/providers/WidgetProvider/WidgetProvider.js +1 -12
  68. package/cjs/providers/WidgetProvider/index.d.ts +1 -0
  69. package/cjs/providers/WidgetProvider/index.js +1 -0
  70. package/cjs/providers/WidgetProvider/utils.d.ts +4 -0
  71. package/cjs/providers/WidgetProvider/utils.js +13 -0
  72. package/cjs/providers/index.d.ts +2 -0
  73. package/cjs/providers/index.js +2 -0
  74. package/cjs/stores/chains/index.d.ts +0 -1
  75. package/cjs/stores/chains/index.js +0 -1
  76. package/cjs/stores/chains/types.d.ts +1 -1
  77. package/cjs/stores/chains/useChainOrderStore.js +17 -14
  78. package/cjs/stores/route/utils.d.ts +2 -1
  79. package/cjs/stores/route/utils.js +17 -1
  80. package/cjs/stores/settings/index.d.ts +0 -1
  81. package/cjs/stores/settings/index.js +0 -1
  82. package/cjs/stores/settings/useAppearance.js +3 -1
  83. package/cjs/types/events.d.ts +15 -3
  84. package/cjs/types/events.js +4 -3
  85. package/cjs/types/widget.d.ts +29 -22
  86. package/cjs/utils/colors.d.ts +1 -1
  87. package/components/AppContainer.js +1 -1
  88. package/components/ChainSelect/ChainSelect.style.js +4 -4
  89. package/components/ChainSelect/useChainSelect.d.ts +2 -2
  90. package/components/GasSufficiencyMessage/GasSufficiencyMessage.js +3 -3
  91. package/components/Header/useHeaderActionStore.d.ts +0 -2
  92. package/components/Header/useHeaderActionStore.js +0 -3
  93. package/components/SelectChainAndToken.js +1 -1
  94. package/components/SwapButton/SwapButton.js +5 -25
  95. package/components/TokenList/TokenList.js +1 -1
  96. package/components/TokenList/TokenList.style.js +4 -3
  97. package/components/TokenList/TokenListItem.js +1 -1
  98. package/components/TokenList/TokenNotFound.d.ts +2 -1
  99. package/components/TokenList/TokenNotFound.js +12 -2
  100. package/components/TokenList/types.d.ts +2 -2
  101. package/config/version.d.ts +1 -1
  102. package/config/version.js +1 -1
  103. package/hooks/useChains.js +24 -11
  104. package/hooks/useFeaturedTokens.d.ts +1 -1
  105. package/hooks/useFeaturedTokens.js +6 -3
  106. package/hooks/useGasSufficiency.d.ts +1 -1
  107. package/hooks/useGasSufficiency.js +35 -24
  108. package/hooks/useInitializer.js +6 -0
  109. package/hooks/useRouteExecution.js +28 -12
  110. package/hooks/useSwapRoutes.js +3 -4
  111. package/hooks/useToken.d.ts +0 -1
  112. package/hooks/useToken.js +1 -2
  113. package/hooks/useTokenBalances.d.ts +1 -2
  114. package/hooks/useTokenBalances.js +4 -5
  115. package/hooks/useTokenSearch.js +3 -2
  116. package/hooks/useTokens.d.ts +1 -2
  117. package/hooks/useTokens.js +32 -9
  118. package/hooks/useTools.js +11 -5
  119. package/hooks/useWidgetEvents.d.ts +3 -3
  120. package/hooks/useWidgetEvents.js +2 -2
  121. package/i18n/en/translation.json +2 -3
  122. package/i18n/index.d.ts +1 -2
  123. package/index.d.ts +2 -1
  124. package/package.json +9 -8
  125. package/pages/MainPage/MainSwapButton.js +1 -1
  126. package/pages/SettingsPage/AdvancedPreferences.js +2 -2
  127. package/pages/SettingsPage/GasPriceSelect.js +2 -2
  128. package/pages/SettingsPage/RoutePrioritySelect.js +2 -2
  129. package/pages/SettingsPage/ShowDestinationWallet.js +2 -2
  130. package/pages/SettingsPage/SlippageInput.js +2 -2
  131. package/pages/SwapDetailsPage/SwapDetailsPage.js +3 -4
  132. package/pages/SwapHistoryPage/SwapHistoryPage.js +3 -4
  133. package/pages/SwapPage/SwapPage.js +11 -2
  134. package/pages/SwapRoutesPage/SwapRoutesPage.js +5 -4
  135. package/providers/SDKProvider/SDKProvider.d.ts +4 -0
  136. package/providers/SDKProvider/SDKProvider.js +19 -0
  137. package/providers/SDKProvider/index.d.ts +1 -0
  138. package/providers/SDKProvider/index.js +1 -0
  139. package/providers/SwapFormProvider/SwapFormProvider.js +4 -58
  140. package/providers/SwapFormProvider/types.d.ts +5 -5
  141. package/providers/TelemetryProvider/TelemetryProvider.d.ts +4 -0
  142. package/providers/TelemetryProvider/TelemetryProvider.js +7 -0
  143. package/providers/TelemetryProvider/index.d.ts +1 -0
  144. package/providers/TelemetryProvider/index.js +1 -0
  145. package/providers/WalletProvider/WalletProvider.d.ts +1 -4
  146. package/providers/WalletProvider/WalletProvider.js +59 -1
  147. package/providers/WidgetProvider/WidgetProvider.js +3 -14
  148. package/providers/WidgetProvider/index.d.ts +1 -0
  149. package/providers/WidgetProvider/index.js +1 -0
  150. package/providers/WidgetProvider/utils.d.ts +4 -0
  151. package/providers/WidgetProvider/utils.js +9 -0
  152. package/providers/index.d.ts +2 -0
  153. package/providers/index.js +2 -0
  154. package/stores/chains/index.d.ts +0 -1
  155. package/stores/chains/index.js +0 -1
  156. package/stores/chains/types.d.ts +1 -1
  157. package/stores/chains/useChainOrderStore.js +17 -14
  158. package/stores/route/utils.d.ts +2 -1
  159. package/stores/route/utils.js +12 -0
  160. package/stores/settings/index.d.ts +0 -1
  161. package/stores/settings/index.js +0 -1
  162. package/stores/settings/useAppearance.js +3 -1
  163. package/tsconfig.cjs.tsbuildinfo +1 -1
  164. package/types/events.d.ts +15 -3
  165. package/types/events.js +4 -3
  166. package/types/widget.d.ts +29 -22
  167. package/utils/colors.d.ts +1 -1
  168. package/cjs/config/lifi.d.ts +0 -4
  169. package/cjs/config/lifi.js +0 -14
  170. package/cjs/stores/chains/useInitializeChainOrder.d.ts +0 -1
  171. package/cjs/stores/chains/useInitializeChainOrder.js +0 -12
  172. package/cjs/stores/settings/useSetSettings.d.ts +0 -5
  173. package/cjs/stores/settings/useSetSettings.js +0 -12
  174. package/config/lifi.d.ts +0 -4
  175. package/config/lifi.js +0 -7
  176. package/stores/chains/useInitializeChainOrder.d.ts +0 -1
  177. package/stores/chains/useInitializeChainOrder.js +0 -5
  178. package/stores/settings/useSetSettings.d.ts +0 -5
  179. package/stores/settings/useSetSettings.js +0 -5
@@ -1,4 +1,13 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
13
  };
@@ -8,35 +17,28 @@ const big_js_1 = __importDefault(require("big.js"));
8
17
  const react_1 = require("react");
9
18
  const react_hook_form_1 = require("react-hook-form");
10
19
  const _1 = require(".");
11
- const SwapFormProvider_1 = require("../providers/SwapFormProvider");
12
- const WalletProvider_1 = require("../providers/WalletProvider");
20
+ const providers_1 = require("../providers");
13
21
  const useTokenBalances_1 = require("./useTokenBalances");
14
22
  const useGasSufficiency = (route) => {
15
- const { account } = (0, WalletProvider_1.useWallet)();
23
+ const lifi = (0, providers_1.useLiFi)();
24
+ const { account } = (0, providers_1.useWallet)();
16
25
  const [fromChainId, toChainId, fromToken] = (0, react_hook_form_1.useWatch)({
17
26
  name: [
18
- SwapFormProvider_1.SwapFormKeyHelper.getChainKey('from'),
19
- SwapFormProvider_1.SwapFormKeyHelper.getChainKey('to'),
20
- SwapFormProvider_1.SwapFormKey.FromToken,
27
+ providers_1.SwapFormKeyHelper.getChainKey('from'),
28
+ providers_1.SwapFormKeyHelper.getChainKey('to'),
29
+ providers_1.SwapFormKey.FromToken,
21
30
  ],
22
31
  });
23
- const fromAmount = (0, _1.useDebouncedWatch)(SwapFormProvider_1.SwapFormKey.FromAmount, 250);
32
+ const fromAmount = (0, _1.useDebouncedWatch)(providers_1.SwapFormKey.FromAmount, 250);
24
33
  const { getChainById } = (0, _1.useChains)();
25
34
  const { tokensWithBalance: fromChainTokenBalances } = (0, useTokenBalances_1.useTokenBalances)(fromChainId);
26
- const { tokensWithBalance: toChainTokenBalances } = (0, useTokenBalances_1.useTokenBalances)(toChainId);
27
- const insufficientGas = (0, react_1.useMemo)(() => {
35
+ const [insufficientGas, setInsufficientGas] = (0, react_1.useState)();
36
+ const checkInsufficientGas = (0, react_1.useCallback)(() => __awaiter(void 0, void 0, void 0, function* () {
28
37
  var _a;
29
- if (!account.isActive ||
30
- !route ||
31
- !fromAmount ||
32
- !fromChainTokenBalances ||
33
- !toChainTokenBalances) {
34
- return [];
38
+ if (!account.isActive || !route || !fromAmount) {
39
+ setInsufficientGas(undefined);
40
+ return;
35
41
  }
36
- const tokenBalancesByChain = {
37
- [fromChainId]: fromChainTokenBalances,
38
- [toChainId]: toChainTokenBalances,
39
- };
40
42
  const gasCosts = route.steps.reduce((groupedGasCosts, step) => {
41
43
  if (step.estimate.gasCosts) {
42
44
  const { token } = step.estimate.gasCosts[0];
@@ -61,30 +63,36 @@ const useGasSufficiency = (route) => {
61
63
  route.fromToken.address === gasCosts[fromChainId].token.address) {
62
64
  gasCosts[fromChainId].tokenAmount = (_a = gasCosts[fromChainId]) === null || _a === void 0 ? void 0 : _a.gasAmount.plus((0, big_js_1.default)(fromAmount));
63
65
  }
66
+ const tokenBalances = yield lifi.getTokenBalances(account.address, Object.values(gasCosts).map((item) => item.token));
67
+ if (!(tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.length)) {
68
+ setInsufficientGas(undefined);
69
+ return;
70
+ }
64
71
  [fromChainId, toChainId].forEach((chainId) => {
65
- var _a, _b, _c, _d, _e, _f, _g;
72
+ var _a, _b, _c, _d, _e, _f;
66
73
  if (gasCosts[chainId]) {
67
- const gasTokenBalance = (0, big_js_1.default)((_c = (_b = (_a = tokenBalancesByChain[chainId]) === null || _a === void 0 ? void 0 : _a.find((t) => t.address === gasCosts[chainId].token.address)) === null || _b === void 0 ? void 0 : _b.amount) !== null && _c !== void 0 ? _c : 0);
74
+ const gasTokenBalance = (0, big_js_1.default)((_b = (_a = tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.find((t) => t.chainId === gasCosts[chainId].token.chainId &&
75
+ t.address === gasCosts[chainId].token.address)) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0);
68
76
  const insufficientFromChainGas = gasTokenBalance.lte(0) ||
69
- gasTokenBalance.lt((_d = gasCosts[chainId].gasAmount) !== null && _d !== void 0 ? _d : (0, big_js_1.default)(0)) ||
70
- gasTokenBalance.lt((_e = gasCosts[chainId].tokenAmount) !== null && _e !== void 0 ? _e : (0, big_js_1.default)(0));
77
+ gasTokenBalance.lt((_c = gasCosts[chainId].gasAmount) !== null && _c !== void 0 ? _c : (0, big_js_1.default)(0)) ||
78
+ gasTokenBalance.lt((_d = gasCosts[chainId].tokenAmount) !== null && _d !== void 0 ? _d : (0, big_js_1.default)(0));
71
79
  const insufficientFromChainGasAmount = insufficientFromChainGas
72
- ? (_g = (_f = gasCosts[chainId].tokenAmount) === null || _f === void 0 ? void 0 : _f.minus(gasTokenBalance)) !== null && _g !== void 0 ? _g : gasCosts[chainId].gasAmount.minus(gasTokenBalance)
80
+ ? (_f = (_e = gasCosts[chainId].tokenAmount) === null || _e === void 0 ? void 0 : _e.minus(gasTokenBalance)) !== null && _f !== void 0 ? _f : gasCosts[chainId].gasAmount.minus(gasTokenBalance)
73
81
  : undefined;
74
82
  gasCosts[chainId] = Object.assign(Object.assign({}, gasCosts[chainId]), { insufficient: insufficientFromChainGas, insufficientAmount: insufficientFromChainGasAmount });
75
83
  }
76
84
  });
77
85
  const gasCostResult = Object.values(gasCosts).filter((gasCost) => gasCost.insufficient);
78
- return gasCostResult;
79
- }, [
86
+ setInsufficientGas(gasCostResult);
87
+ }), [
88
+ account.address,
80
89
  account.isActive,
81
90
  fromAmount,
82
91
  fromChainId,
83
- fromChainTokenBalances,
84
92
  getChainById,
93
+ lifi,
85
94
  route,
86
95
  toChainId,
87
- toChainTokenBalances,
88
96
  ]);
89
97
  const insufficientFunds = (0, react_1.useMemo)(() => {
90
98
  var _a, _b;
@@ -97,6 +105,9 @@ const useGasSufficiency = (route) => {
97
105
  const balance = (0, big_js_1.default)((_b = (_a = fromChainTokenBalances === null || fromChainTokenBalances === void 0 ? void 0 : fromChainTokenBalances.find((t) => t.address === fromToken)) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0);
98
106
  return (0, big_js_1.default)(fromAmount).gt(balance);
99
107
  }, [account.isActive, fromAmount, fromChainTokenBalances, fromToken]);
108
+ (0, react_1.useEffect)(() => {
109
+ checkInsufficientGas();
110
+ }, [checkInsufficientGas]);
100
111
  return {
101
112
  insufficientGas,
102
113
  insufficientFunds,
@@ -2,8 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useInitializer = void 0;
4
4
  /* eslint-disable no-underscore-dangle */
5
+ const sdk_1 = require("@lifi/sdk");
6
+ const react_1 = require("react");
7
+ const version_1 = require("../config/version");
5
8
  const useTools_1 = require("./useTools");
6
9
  const useInitializer = () => {
7
10
  (0, useTools_1.useTools)();
11
+ (0, react_1.useEffect)(() => {
12
+ (0, sdk_1.checkPackageUpdates)(version_1.name, version_1.version);
13
+ }, []);
8
14
  };
9
15
  exports.useInitializer = useInitializer;
@@ -16,28 +16,42 @@ exports.useRouteExecution = void 0;
16
16
  const react_query_1 = require("@tanstack/react-query");
17
17
  const react_1 = require("react");
18
18
  const shallow_1 = __importDefault(require("zustand/shallow"));
19
- const lifi_1 = require("../config/lifi");
20
- const WalletProvider_1 = require("../providers/WalletProvider");
19
+ const providers_1 = require("../providers");
21
20
  const stores_1 = require("../stores");
22
21
  const events_1 = require("../types/events");
23
22
  const utils_1 = require("../utils");
24
23
  const useWidgetEvents_1 = require("./useWidgetEvents");
25
24
  const useRouteExecution = (routeId, executeInBackground) => {
26
- const { account, switchChain } = (0, WalletProvider_1.useWallet)();
25
+ const lifi = (0, providers_1.useLiFi)();
26
+ const { account, switchChain } = (0, providers_1.useWallet)();
27
27
  const resumedAfterMount = (0, react_1.useRef)(false);
28
28
  const emitter = (0, useWidgetEvents_1.useWidgetEvents)();
29
29
  const routeExecution = (0, stores_1.useRouteStore)((state) => state.routes[routeId]);
30
30
  const [updateRoute, restartRoute, deleteRoute] = (0, stores_1.useRouteStore)((state) => [state.updateRoute, state.restartRoute, state.deleteRoute], shallow_1.default);
31
31
  const updateCallback = (updatedRoute) => {
32
+ const routeExecution = stores_1.useRouteStore.getState().routes[updatedRoute.id];
33
+ if (!routeExecution) {
34
+ return;
35
+ }
32
36
  const clonedUpdatedRoute = (0, utils_1.deepClone)(updatedRoute);
33
- console.log('Route updated.', clonedUpdatedRoute);
34
37
  updateRoute(clonedUpdatedRoute);
38
+ const process = (0, stores_1.getUpdatedProcess)(routeExecution.route, clonedUpdatedRoute);
39
+ if (process) {
40
+ emitter.emit(events_1.WidgetEvent.RouteExecutionUpdated, {
41
+ route: clonedUpdatedRoute,
42
+ process,
43
+ });
44
+ }
35
45
  if ((0, stores_1.isRouteCompleted)(clonedUpdatedRoute)) {
36
- emitter.emit(events_1.WidgetEvent.SwapCompleted);
46
+ emitter.emit(events_1.WidgetEvent.RouteExecutionCompleted, clonedUpdatedRoute);
37
47
  }
38
- if ((0, stores_1.isRouteFailed)(clonedUpdatedRoute)) {
39
- emitter.emit(events_1.WidgetEvent.SwapFailed);
48
+ if ((0, stores_1.isRouteFailed)(clonedUpdatedRoute) && process) {
49
+ emitter.emit(events_1.WidgetEvent.RouteExecutionFailed, {
50
+ route: clonedUpdatedRoute,
51
+ process,
52
+ });
40
53
  }
54
+ console.log('Route updated.', clonedUpdatedRoute);
41
55
  };
42
56
  const switchChainHook = (requiredChainId) => __awaiter(void 0, void 0, void 0, function* () {
43
57
  if (!account.isActive || !account.signer) {
@@ -59,7 +73,7 @@ const useRouteExecution = (routeId, executeInBackground) => {
59
73
  if (!(routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route)) {
60
74
  throw Error('Execution route not found.');
61
75
  }
62
- return lifi_1.LiFi.executeRoute(account.signer, routeExecution.route, {
76
+ return lifi.executeRoute(account.signer, routeExecution.route, {
63
77
  updateCallback,
64
78
  switchChainHook,
65
79
  infiniteApproval: false,
@@ -68,7 +82,9 @@ const useRouteExecution = (routeId, executeInBackground) => {
68
82
  }, {
69
83
  onMutate: () => {
70
84
  console.log('Execution started.', routeId);
71
- emitter.emit(events_1.WidgetEvent.SwapStarted);
85
+ if (routeExecution) {
86
+ emitter.emit(events_1.WidgetEvent.RouteExecutionStarted, routeExecution.route);
87
+ }
72
88
  },
73
89
  });
74
90
  const resumeRouteMutation = (0, react_query_1.useMutation)((resumedRoute) => {
@@ -78,7 +94,7 @@ const useRouteExecution = (routeId, executeInBackground) => {
78
94
  if (!(routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route)) {
79
95
  throw Error('Execution route not found.');
80
96
  }
81
- return lifi_1.LiFi.resumeRoute(account.signer, resumedRoute !== null && resumedRoute !== void 0 ? resumedRoute : routeExecution.route, {
97
+ return lifi.resumeRoute(account.signer, resumedRoute !== null && resumedRoute !== void 0 ? resumedRoute : routeExecution.route, {
82
98
  updateCallback,
83
99
  switchChainHook,
84
100
  infiniteApproval: false,
@@ -138,11 +154,11 @@ const useRouteExecution = (routeId, executeInBackground) => {
138
154
  if (!route || !(0, stores_1.isRouteActive)(route)) {
139
155
  return;
140
156
  }
141
- lifi_1.LiFi.updateRouteExecution(route, { executeInBackground: true });
157
+ lifi.updateRouteExecution(route, { executeInBackground: true });
142
158
  console.log('Move route execution to background.', routeId);
143
159
  resumedAfterMount.current = false;
144
160
  };
145
- }, [routeId]);
161
+ }, [lifi, routeId]);
146
162
  return {
147
163
  executeRoute,
148
164
  restartRoute: restartRouteMutation,
@@ -18,14 +18,13 @@ const react_query_1 = require("@tanstack/react-query");
18
18
  const big_js_1 = __importDefault(require("big.js"));
19
19
  const react_hook_form_1 = require("react-hook-form");
20
20
  const _1 = require(".");
21
- const lifi_1 = require("../config/lifi");
22
- const SwapFormProvider_1 = require("../providers/SwapFormProvider");
23
- const WalletProvider_1 = require("../providers/WalletProvider");
21
+ const providers_1 = require("../providers");
24
22
  const stores_1 = require("../stores");
25
23
  const refetchTime = 60000;
26
24
  const useSwapRoutes = () => {
27
25
  var _a;
28
- const { account, provider } = (0, WalletProvider_1.useWallet)();
26
+ const lifi = (0, providers_1.useLiFi)();
27
+ const { account, provider } = (0, providers_1.useWallet)();
29
28
  const queryClient = (0, react_query_1.useQueryClient)();
30
29
  const { slippage, enabledBridges, enabledExchanges, routePriority } = (0, stores_1.useSettings)([
31
30
  'slippage',
@@ -35,14 +34,14 @@ const useSwapRoutes = () => {
35
34
  ]);
36
35
  const [fromChainId, fromTokenAddress, toChainId, toTokenAddress, toAddress] = (0, react_hook_form_1.useWatch)({
37
36
  name: [
38
- SwapFormProvider_1.SwapFormKey.FromChain,
39
- SwapFormProvider_1.SwapFormKey.FromToken,
40
- SwapFormProvider_1.SwapFormKey.ToChain,
41
- SwapFormProvider_1.SwapFormKey.ToToken,
42
- SwapFormProvider_1.SwapFormKey.ToAddress,
37
+ providers_1.SwapFormKey.FromChain,
38
+ providers_1.SwapFormKey.FromToken,
39
+ providers_1.SwapFormKey.ToChain,
40
+ providers_1.SwapFormKey.ToToken,
41
+ providers_1.SwapFormKey.ToAddress,
43
42
  ],
44
43
  });
45
- const [fromTokenAmount] = (0, _1.useDebouncedWatch)([SwapFormProvider_1.SwapFormKey.FromAmount], 250);
44
+ const [fromTokenAmount] = (0, _1.useDebouncedWatch)([providers_1.SwapFormKey.FromAmount], 250);
46
45
  const { token } = (0, _1.useToken)(fromChainId, fromTokenAddress);
47
46
  const isEnabled =
48
47
  // Boolean(account.address) &&
@@ -81,7 +80,7 @@ const useSwapRoutes = () => {
81
80
  catch (_d) {
82
81
  toWalletAddress = (0, address_1.isAddress)(toAddress) ? toAddress : fromAddress;
83
82
  }
84
- return lifi_1.LiFi.getRoutes({
83
+ return lifi.getRoutes({
85
84
  fromChainId,
86
85
  fromAmount: (0, big_js_1.default)(Number(fromTokenAmount) * Math.pow(10, ((_c = token === null || token === void 0 ? void 0 : token.decimals) !== null && _c !== void 0 ? _c : 0))).toString(),
87
86
  fromTokenAddress,
@@ -1,5 +1,4 @@
1
1
  export declare const useToken: (chainId: number, tokenAddress: string) => {
2
2
  token: import("..").Token | undefined;
3
3
  isLoading: boolean;
4
- isFetching: boolean;
5
4
  };
@@ -4,7 +4,7 @@ exports.useToken = void 0;
4
4
  const react_1 = require("react");
5
5
  const useTokens_1 = require("./useTokens");
6
6
  const useToken = (chainId, tokenAddress) => {
7
- const { tokens, isLoading, isFetching } = (0, useTokens_1.useTokens)(chainId);
7
+ const { tokens, isLoading } = (0, useTokens_1.useTokens)(chainId);
8
8
  const token = (0, react_1.useMemo)(() => {
9
9
  const token = tokens === null || tokens === void 0 ? void 0 : tokens.find((token) => token.address === tokenAddress && token.chainId === chainId);
10
10
  return token;
@@ -12,7 +12,6 @@ const useToken = (chainId, tokenAddress) => {
12
12
  return {
13
13
  token,
14
14
  isLoading,
15
- isFetching,
16
15
  };
17
16
  };
18
17
  exports.useToken = useToken;
@@ -2,9 +2,8 @@ import type { Token } from '../types';
2
2
  export declare const useTokenBalances: (selectedChainId: number) => {
3
3
  tokens: Token[] | undefined;
4
4
  tokensWithBalance: Token[] | undefined;
5
- featuredTokens: import("@lifi/types").Token[] | undefined;
5
+ featuredTokens: import("@lifi/types").Token[];
6
6
  isLoading: boolean;
7
7
  isBalanceLoading: boolean;
8
- isBalanceFetched: boolean;
9
8
  refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<Token[] | undefined, unknown>>;
10
9
  };
@@ -13,24 +13,24 @@ exports.useTokenBalances = void 0;
13
13
  /* eslint-disable consistent-return */
14
14
  const react_query_1 = require("@tanstack/react-query");
15
15
  const react_1 = require("react");
16
- const lifi_1 = require("../config/lifi");
17
- const WalletProvider_1 = require("../providers/WalletProvider");
16
+ const providers_1 = require("../providers");
18
17
  const utils_1 = require("../utils");
19
18
  const useFeaturedTokens_1 = require("./useFeaturedTokens");
20
19
  const useTokens_1 = require("./useTokens");
21
20
  const defaultRefetchInterval = 60000;
22
21
  const minRefetchInterval = 1000;
23
22
  const useTokenBalances = (selectedChainId) => {
24
- const { account } = (0, WalletProvider_1.useWallet)();
23
+ const lifi = (0, providers_1.useLiFi)();
24
+ const { account } = (0, providers_1.useWallet)();
25
25
  const featuredTokens = (0, useFeaturedTokens_1.useFeaturedTokens)(selectedChainId);
26
26
  const { tokens, isLoading } = (0, useTokens_1.useTokens)(selectedChainId);
27
27
  const [refetchInterval, setRefetchInterval] = (0, react_1.useState)(defaultRefetchInterval);
28
28
  const isBalanceLoadingEnabled = Boolean(account.address) && Boolean(tokens === null || tokens === void 0 ? void 0 : tokens.length);
29
- const { data: tokensWithBalance, isLoading: isBalanceLoading, isFetched: isBalanceFetched, refetch, } = (0, react_query_1.useQuery)(['token-balances', account.address, selectedChainId, tokens === null || tokens === void 0 ? void 0 : tokens.length], ({ queryKey: [, accountAddress] }) => __awaiter(void 0, void 0, void 0, function* () {
29
+ const { data: tokensWithBalance, isLoading: isBalanceLoading, refetch, } = (0, react_query_1.useQuery)(['token-balances', account.address, selectedChainId, tokens === null || tokens === void 0 ? void 0 : tokens.length], ({ queryKey: [, accountAddress] }) => __awaiter(void 0, void 0, void 0, function* () {
30
30
  if (!accountAddress || !tokens) {
31
31
  return;
32
32
  }
33
- const tokenBalances = yield lifi_1.LiFi.getTokenBalances(accountAddress, tokens);
33
+ const tokenBalances = yield lifi.getTokenBalances(accountAddress, tokens);
34
34
  if (!(tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.length)) {
35
35
  // Sometimes RPCs (e.g. Arbitrum) don't return balances on first call
36
36
  // TODO: fix and remove backplane
@@ -73,7 +73,6 @@ const useTokenBalances = (selectedChainId) => {
73
73
  featuredTokens,
74
74
  isLoading,
75
75
  isBalanceLoading: isBalanceLoading && isBalanceLoadingEnabled,
76
- isBalanceFetched,
77
76
  refetch,
78
77
  };
79
78
  };
@@ -11,11 +11,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.useTokenSearch = void 0;
13
13
  const react_query_1 = require("@tanstack/react-query");
14
- const lifi_1 = require("../config/lifi");
14
+ const providers_1 = require("../providers");
15
15
  const useTokenSearch = (token, chainId, enabled) => {
16
+ const lifi = (0, providers_1.useLiFi)();
16
17
  const queryClient = (0, react_query_1.useQueryClient)();
17
18
  const { data, isLoading, isFetching, isFetched } = (0, react_query_1.useQuery)(['token-search', chainId, token], ({ queryKey: [, chainId, token], signal }) => __awaiter(void 0, void 0, void 0, function* () {
18
- const data = yield lifi_1.LiFi.getToken(chainId, token, {
19
+ const data = yield lifi.getToken(chainId, token, {
19
20
  signal,
20
21
  });
21
22
  if (data) {
@@ -1,6 +1,5 @@
1
1
  import type { Token } from '../types';
2
- export declare const useTokens: (selectedChainId: number) => {
2
+ export declare const useTokens: (selectedChainId?: number) => {
3
3
  tokens: Token[] | undefined;
4
4
  isLoading: boolean;
5
- isFetching: boolean;
6
5
  };
@@ -11,26 +11,49 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.useTokens = void 0;
13
13
  const react_query_1 = require("@tanstack/react-query");
14
- const lifi_1 = require("../config/lifi");
14
+ const providers_1 = require("../providers");
15
15
  const useFeaturedTokens_1 = require("./useFeaturedTokens");
16
16
  const useTokens = (selectedChainId) => {
17
+ var _a, _b, _c, _d;
18
+ const lifi = (0, providers_1.useLiFi)();
17
19
  const featuredTokens = (0, useFeaturedTokens_1.useFeaturedTokens)(selectedChainId);
18
- const { data: tokens, isLoading, isFetching, } = (0, react_query_1.useQuery)(['tokens', selectedChainId, featuredTokens === null || featuredTokens === void 0 ? void 0 : featuredTokens.length], () => __awaiter(void 0, void 0, void 0, function* () {
19
- var _a, _b, _c;
20
- const data = yield lifi_1.LiFi.getTokens({ chains: [selectedChainId] });
20
+ const { tokens, chains, disabledChains } = (0, providers_1.useWidgetConfig)();
21
+ const { data, isLoading } = (0, react_query_1.useQuery)([
22
+ 'tokens',
23
+ selectedChainId,
24
+ featuredTokens === null || featuredTokens === void 0 ? void 0 : featuredTokens.length,
25
+ (_a = tokens === null || tokens === void 0 ? void 0 : tokens.allow) === null || _a === void 0 ? void 0 : _a.length,
26
+ (_b = tokens === null || tokens === void 0 ? void 0 : tokens.deny) === null || _b === void 0 ? void 0 : _b.length,
27
+ (_c = chains === null || chains === void 0 ? void 0 : chains.allow) === null || _c === void 0 ? void 0 : _c.length,
28
+ (_d = chains === null || chains === void 0 ? void 0 : chains.deny) === null || _d === void 0 ? void 0 : _d.length,
29
+ ], () => __awaiter(void 0, void 0, void 0, function* () {
30
+ var _e, _f, _g, _h, _j;
31
+ const chainAllowed = selectedChainId &&
32
+ (0, providers_1.isItemAllowed)(selectedChainId, chains, disabledChains);
33
+ if (!chainAllowed) {
34
+ return [];
35
+ }
36
+ let filteredTokens = (_e = tokens === null || tokens === void 0 ? void 0 : tokens.allow) === null || _e === void 0 ? void 0 : _e.filter((token) => token.chainId === selectedChainId);
37
+ if (!(filteredTokens === null || filteredTokens === void 0 ? void 0 : filteredTokens.length)) {
38
+ const data = yield lifi.getTokens({ chains: [selectedChainId] });
39
+ filteredTokens = (_f = data.tokens) === null || _f === void 0 ? void 0 : _f[selectedChainId];
40
+ }
41
+ const deniedTokenAddresses = (_g = tokens === null || tokens === void 0 ? void 0 : tokens.deny) === null || _g === void 0 ? void 0 : _g.filter((token) => token.chainId === selectedChainId).map((token) => token.address);
42
+ if (deniedTokenAddresses === null || deniedTokenAddresses === void 0 ? void 0 : deniedTokenAddresses.length) {
43
+ filteredTokens = filteredTokens === null || filteredTokens === void 0 ? void 0 : filteredTokens.filter((token) => !deniedTokenAddresses.includes(token.address));
44
+ }
21
45
  const featuredTokenAddresses = new Set(featuredTokens === null || featuredTokens === void 0 ? void 0 : featuredTokens.map((token) => token.address));
22
46
  return [
23
- ...((_a = featuredTokens === null || featuredTokens === void 0 ? void 0 : featuredTokens.map((token) => {
47
+ ...((_h = featuredTokens === null || featuredTokens === void 0 ? void 0 : featuredTokens.map((token) => {
24
48
  token.featured = true;
25
49
  return token;
26
- })) !== null && _a !== void 0 ? _a : []),
27
- ...((_c = (_b = data.tokens) === null || _b === void 0 ? void 0 : _b[selectedChainId].filter((token) => !featuredTokenAddresses.has(token.address))) !== null && _c !== void 0 ? _c : []),
50
+ })) !== null && _h !== void 0 ? _h : []),
51
+ ...((_j = filteredTokens === null || filteredTokens === void 0 ? void 0 : filteredTokens.filter((token) => !featuredTokenAddresses.has(token.address))) !== null && _j !== void 0 ? _j : []),
28
52
  ];
29
53
  }));
30
54
  return {
31
- tokens,
55
+ tokens: data,
32
56
  isLoading,
33
- isFetching,
34
57
  };
35
58
  };
36
59
  exports.useTokens = useTokens;
@@ -3,14 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useTools = void 0;
4
4
  const react_query_1 = require("@tanstack/react-query");
5
5
  const react_1 = require("react");
6
- const lifi_1 = require("../config/lifi");
6
+ const providers_1 = require("../providers");
7
7
  const stores_1 = require("../stores");
8
8
  const useTools = () => {
9
- const initializeTools = (0, stores_1.useSettingsStore)((state) => state.initializeTools);
10
- const { data } = (0, react_query_1.useQuery)(['tools'], ({ signal }) => lifi_1.LiFi.getTools(undefined, { signal }), {
9
+ const lifi = (0, providers_1.useLiFi)();
10
+ const { bridges, exchanges } = (0, providers_1.useWidgetConfig)();
11
+ const { data } = (0, react_query_1.useQuery)(['tools'], ({ signal }) => lifi.getTools(undefined, { signal }), {
11
12
  onSuccess(data) {
12
- initializeTools('Bridges', data.bridges.map((bridge) => bridge.key));
13
- initializeTools('Exchanges', data.exchanges.map((exchange) => exchange.key));
13
+ const { initializeTools } = stores_1.useSettingsStore.getState();
14
+ initializeTools('Bridges', data.bridges
15
+ .filter((bridge) => (0, providers_1.isItemAllowed)(bridge.key, bridges))
16
+ .map((bridge) => bridge.key));
17
+ initializeTools('Exchanges', data.exchanges
18
+ .filter((exchange) => (0, providers_1.isItemAllowed)(exchange.key, exchanges))
19
+ .map((exchange) => exchange.key));
14
20
  },
15
21
  });
16
22
  const formattedTools = (0, react_1.useMemo)(() => ({
@@ -1,3 +1,3 @@
1
- /// <reference types="node" />
2
- import { EventEmitter } from 'events';
3
- export declare const useWidgetEvents: () => EventEmitter;
1
+ import type { Emitter } from 'mitt';
2
+ import type { WidgetEvents } from '../types';
3
+ export declare const useWidgetEvents: () => Emitter<WidgetEvents>;
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.useWidgetEvents = void 0;
7
- const events_1 = require("events");
7
+ const mitt_1 = __importDefault(require("mitt"));
8
8
  const zustand_1 = __importDefault(require("zustand"));
9
- const emitterStore = (0, zustand_1.default)()(() => new events_1.EventEmitter());
9
+ const emitterStore = (0, zustand_1.default)()(() => (0, mitt_1.default)());
10
10
  const useWidgetEvents = () => {
11
11
  return emitterStore();
12
12
  };
@@ -15,7 +15,6 @@
15
15
  },
16
16
  "button": {
17
17
  "connectWallet": "Connect wallet",
18
- "switchChain": "Switch chain",
19
18
  "swap": "Swap",
20
19
  "reviewSwap": "Review swap",
21
20
  "startSwap": "Start swap",
@@ -56,7 +55,6 @@
56
55
  "featuredTokens": "Featured tokens",
57
56
  "otherTokens": "Other tokens",
58
57
  "inProgress": "in progress",
59
- "couldntFindTokens": "We couldn't find tokens on this chain or you don't have any.",
60
58
  "stepSwap": "Swap",
61
59
  "stepBridge": "Bridge",
62
60
  "stepSwapAndBridge": "Swap and bridge",
@@ -92,7 +90,8 @@
92
90
  "message": {
93
91
  "routeNotFound": "Try another token combination.",
94
92
  "emptySwapHistory": "Swap history is only stored locally and will be deleted if you clear your browser data.",
95
- "emptyActiveSwaps": "Swaps in progress will appear here. Once completed, find them in swap history."
93
+ "emptyActiveSwaps": "Swaps in progress will appear here. Once completed, find them in swap history.",
94
+ "emptyTokenList": "We couldn't find tokens on {{chainName}} chain or you don't have any. Please try search again or choose another chain."
96
95
  }
97
96
  },
98
97
  "warning": {
@@ -18,7 +18,6 @@ export declare const resources: {
18
18
  };
19
19
  button: {
20
20
  connectWallet: string;
21
- switchChain: string;
22
21
  swap: string;
23
22
  reviewSwap: string;
24
23
  startSwap: string;
@@ -59,7 +58,6 @@ export declare const resources: {
59
58
  featuredTokens: string;
60
59
  otherTokens: string;
61
60
  inProgress: string;
62
- couldntFindTokens: string;
63
61
  stepSwap: string;
64
62
  stepBridge: string;
65
63
  stepSwapAndBridge: string;
@@ -96,6 +94,7 @@ export declare const resources: {
96
94
  routeNotFound: string;
97
95
  emptySwapHistory: string;
98
96
  emptyActiveSwaps: string;
97
+ emptyTokenList: string;
99
98
  };
100
99
  };
101
100
  warning: {
package/cjs/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import './fonts/inter.css';
3
+ export type { WidgetDrawer, WidgetDrawerProps } from './AppDrawer';
3
4
  export { useWidgetEvents } from './hooks';
4
5
  export * from './types';
5
6
  export declare const LiFiWidget: import("react").FC<import("./AppProvider").AppProps>;
6
- export declare const LiFiWidgetDrawer: import("react").ForwardRefExoticComponent<Pick<import("./AppDrawer").AppDrawerProps, "className" | "style" | "classes" | "slot" | "title" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "children" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "sx" | "key" | "transitionDuration" | "variant" | "open" | "anchor" | "elementRef" | "components" | "componentsProps" | "BackdropComponent" | "BackdropProps" | "closeAfterTransition" | "container" | "disableAutoFocus" | "disableEnforceFocus" | "disableEscapeKeyDown" | "disablePortal" | "disableRestoreFocus" | "disableScrollLock" | "hideBackdrop" | "keepMounted" | "onBackdropClick" | "onClose" | "config" | "elevation" | "ModalProps" | "PaperProps" | "SlideProps"> & import("react").RefAttributes<import("./AppDrawer").AppDrawerBase>>;
7
+ export declare const LiFiWidgetDrawer: import("react").ForwardRefExoticComponent<Pick<import("./AppDrawer").WidgetDrawerProps, "className" | "style" | "classes" | "slot" | "title" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "children" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "sx" | "key" | "transitionDuration" | "variant" | "open" | "anchor" | "elementRef" | "components" | "componentsProps" | "BackdropComponent" | "BackdropProps" | "closeAfterTransition" | "container" | "disableAutoFocus" | "disableEnforceFocus" | "disableEscapeKeyDown" | "disablePortal" | "disableRestoreFocus" | "disableScrollLock" | "hideBackdrop" | "keepMounted" | "onBackdropClick" | "onClose" | "config" | "elevation" | "ModalProps" | "PaperProps" | "SlideProps"> & import("react").RefAttributes<import("./AppDrawer").WidgetDrawer>>;
@@ -31,6 +31,6 @@ const MainSwapButton = () => {
31
31
  });
32
32
  }
33
33
  });
34
- return ((0, jsx_runtime_1.jsx)(SwapButton_1.SwapButton, { onClick: handleClick, currentRoute: currentRoute, disable: isLoading || isFetching || !currentRoute || isValidating || !isValid }));
34
+ return ((0, jsx_runtime_1.jsx)(SwapButton_1.SwapButton, { onClick: handleClick, currentRoute: currentRoute, disable: isLoading || isFetching || isValidating || !isValid }));
35
35
  };
36
36
  exports.MainSwapButton = MainSwapButton;
@@ -10,7 +10,7 @@ const EnabledBridgesSelect_1 = require("./EnabledBridgesSelect");
10
10
  const EnabledExchangesSelect_1 = require("./EnabledExchangesSelect");
11
11
  const AdvancedPreferences = () => {
12
12
  const { t } = (0, react_i18next_1.useTranslation)();
13
- const [setValue] = (0, stores_1.useSetSettings)();
13
+ const setValue = (0, stores_1.useSettingsStore)((state) => state.setValue);
14
14
  const { advancedPreferences } = (0, stores_1.useSettings)(['advancedPreferences']);
15
15
  const handleAdvancedPreferences = (_, checked) => {
16
16
  setValue('advancedPreferences', checked);
@@ -10,7 +10,7 @@ const Select_1 = require("../../components/Select");
10
10
  const stores_1 = require("../../stores");
11
11
  const GasPriceSelect = () => {
12
12
  const { t } = (0, react_i18next_1.useTranslation)();
13
- const [setValue] = (0, stores_1.useSetSettings)();
13
+ const setValue = (0, stores_1.useSettingsStore)((state) => state.setValue);
14
14
  const { gasPrice } = (0, stores_1.useSettings)(['gasPrice']);
15
15
  return ((0, jsx_runtime_1.jsxs)(Card_1.Card, Object.assign({ flex: 1 }, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t(`settings.gasPrice.title`) }), (0, jsx_runtime_1.jsx)(material_1.FormControl, Object.assign({ fullWidth: true }, { children: (0, jsx_runtime_1.jsxs)(Select_1.Select, Object.assign({ MenuProps: { elevation: 2 }, value: gasPrice, onChange: (event) => setValue('gasPrice', event.target.value), IconComponent: icons_material_1.KeyboardArrowDown, dense: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.MenuItem, Object.assign({ value: "slow" }, { children: t(`settings.gasPrice.slow`) })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, Object.assign({ value: "normal" }, { children: t(`settings.gasPrice.normal`) })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, Object.assign({ value: "fast" }, { children: t(`settings.gasPrice.fast`) }))] })) }))] })));
16
16
  };
@@ -11,7 +11,7 @@ const Select_1 = require("../../components/Select");
11
11
  const stores_1 = require("../../stores");
12
12
  const RoutePrioritySelect = () => {
13
13
  const { t } = (0, react_i18next_1.useTranslation)();
14
- const [setValue] = (0, stores_1.useSetSettings)();
14
+ const setValue = (0, stores_1.useSettingsStore)((state) => state.setValue);
15
15
  const { routePriority } = (0, stores_1.useSettings)(['routePriority']);
16
16
  return ((0, jsx_runtime_1.jsxs)(Card_1.Card, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t(`settings.routePriority`) }), (0, jsx_runtime_1.jsx)(material_1.FormControl, Object.assign({ fullWidth: true }, { children: (0, jsx_runtime_1.jsx)(Select_1.Select, Object.assign({ MenuProps: { elevation: 2 }, value: routePriority, onChange: (event) => setValue('routePriority', event.target.value), IconComponent: icons_material_1.KeyboardArrowDown, dense: true }, { children: sdk_1.Orders.map((order) => {
17
17
  const tag = t(`swap.tags.${order.toUpperCase()}`);