@lifi/widget 2.0.0 → 2.1.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 (84) hide show
  1. package/cjs/components/Header/NavigationHeader.js +2 -2
  2. package/cjs/components/Header/index.d.ts +0 -1
  3. package/cjs/components/Header/index.js +0 -1
  4. package/cjs/components/Step/StepList.d.ts +2 -1
  5. package/cjs/components/Step/StepList.js +4 -2
  6. package/cjs/components/StepActions/StepActions.js +12 -3
  7. package/cjs/config/version.d.ts +1 -1
  8. package/cjs/config/version.js +1 -1
  9. package/cjs/hooks/useRoutes.js +2 -4
  10. package/cjs/i18n/en.json +2 -2
  11. package/cjs/i18n/id.json +61 -60
  12. package/cjs/i18n/it.json +61 -60
  13. package/cjs/i18n/pt.json +62 -61
  14. package/cjs/i18n/th.json +61 -60
  15. package/cjs/i18n/uk.json +50 -49
  16. package/cjs/i18n/vi.json +64 -63
  17. package/cjs/pages/ActiveTransactionsPage/ActiveTransactionsPage.js +3 -3
  18. package/cjs/pages/RoutesPage/RoutesPage.js +3 -3
  19. package/cjs/pages/SelectEnabledToolsPage/SelectEnabledToolsPage.js +3 -3
  20. package/cjs/pages/TransactionDetailsPage/ContactSupportButton.d.ts +5 -0
  21. package/cjs/pages/TransactionDetailsPage/ContactSupportButton.js +25 -0
  22. package/cjs/pages/TransactionDetailsPage/TransactionDetailsPage.js +6 -5
  23. package/cjs/pages/TransactionHistoryPage/TransactionHistoryPage.js +3 -3
  24. package/cjs/pages/TransactionPage/ExchangeRateBottomSheet.js +2 -1
  25. package/cjs/pages/TransactionPage/StatusBottomSheet.style.js +5 -1
  26. package/cjs/pages/TransactionPage/TransactionPage.js +8 -4
  27. package/cjs/stores/StoreProvider.js +2 -1
  28. package/cjs/stores/header/index.d.ts +1 -0
  29. package/cjs/stores/header/index.js +17 -0
  30. package/cjs/{components/Header → stores/header}/types.d.ts +4 -2
  31. package/cjs/stores/header/useHeaderStore.d.ts +8 -0
  32. package/cjs/stores/header/useHeaderStore.js +56 -0
  33. package/cjs/stores/index.d.ts +2 -1
  34. package/cjs/stores/index.js +2 -1
  35. package/cjs/stores/routes/utils.d.ts +1 -0
  36. package/cjs/stores/routes/utils.js +5 -1
  37. package/cjs/types/events.d.ts +6 -1
  38. package/cjs/types/events.js +1 -0
  39. package/components/Header/NavigationHeader.js +2 -2
  40. package/components/Header/index.d.ts +0 -1
  41. package/components/Header/index.js +0 -1
  42. package/components/Step/StepList.d.ts +2 -1
  43. package/components/Step/StepList.js +4 -2
  44. package/components/StepActions/StepActions.js +12 -3
  45. package/config/version.d.ts +1 -1
  46. package/config/version.js +1 -1
  47. package/hooks/useRoutes.js +2 -4
  48. package/i18n/en.json +2 -2
  49. package/i18n/id.json +61 -60
  50. package/i18n/it.json +61 -60
  51. package/i18n/pt.json +62 -61
  52. package/i18n/th.json +61 -60
  53. package/i18n/uk.json +50 -49
  54. package/i18n/vi.json +64 -63
  55. package/package.json +15 -29
  56. package/pages/ActiveTransactionsPage/ActiveTransactionsPage.js +4 -4
  57. package/pages/RoutesPage/RoutesPage.js +4 -4
  58. package/pages/SelectEnabledToolsPage/SelectEnabledToolsPage.js +4 -4
  59. package/pages/TransactionDetailsPage/ContactSupportButton.d.ts +5 -0
  60. package/pages/TransactionDetailsPage/ContactSupportButton.js +21 -0
  61. package/pages/TransactionDetailsPage/TransactionDetailsPage.js +7 -6
  62. package/pages/TransactionHistoryPage/TransactionHistoryPage.js +4 -4
  63. package/pages/TransactionPage/ExchangeRateBottomSheet.js +2 -1
  64. package/pages/TransactionPage/StatusBottomSheet.style.js +5 -1
  65. package/pages/TransactionPage/TransactionPage.js +9 -5
  66. package/stores/StoreProvider.js +2 -1
  67. package/stores/header/index.d.ts +1 -0
  68. package/stores/header/index.js +1 -0
  69. package/{components/Header → stores/header}/types.d.ts +4 -2
  70. package/stores/header/useHeaderStore.d.ts +8 -0
  71. package/stores/header/useHeaderStore.js +49 -0
  72. package/stores/index.d.ts +2 -1
  73. package/stores/index.js +2 -1
  74. package/stores/routes/utils.d.ts +1 -0
  75. package/stores/routes/utils.js +3 -0
  76. package/tsconfig.cjs.tsbuildinfo +1 -1
  77. package/types/events.d.ts +6 -1
  78. package/types/events.js +1 -0
  79. package/cjs/components/Header/useHeaderStore.d.ts +0 -2
  80. package/cjs/components/Header/useHeaderStore.js +0 -28
  81. package/components/Header/useHeaderStore.d.ts +0 -2
  82. package/components/Header/useHeaderStore.js +0 -25
  83. /package/cjs/{components/Header → stores/header}/types.js +0 -0
  84. /package/{components/Header → stores/header}/types.js +0 -0
@@ -7,7 +7,6 @@ const material_1 = require("@mui/material");
7
7
  const react_1 = require("react");
8
8
  const react_i18next_1 = require("react-i18next");
9
9
  const Dialog_1 = require("../../components/Dialog");
10
- const Header_1 = require("../../components/Header");
11
10
  const providers_1 = require("../../providers");
12
11
  const stores_1 = require("../../stores");
13
12
  const routes_1 = require("../../stores/routes");
@@ -17,6 +16,7 @@ const TransactionHistoryPage = () => {
17
16
  const { t } = (0, react_i18next_1.useTranslation)();
18
17
  const { account } = (0, providers_1.useWallet)();
19
18
  const transactions = (0, routes_1.useTransactionHistory)(account.address);
19
+ const headerStoreContext = (0, stores_1.useHeaderStoreContext)();
20
20
  const deleteRoutes = (0, stores_1.useRouteExecutionStore)((store) => store.deleteRoutes);
21
21
  const [open, setOpen] = (0, react_1.useState)(false);
22
22
  const toggleDialog = (0, react_1.useCallback)(() => {
@@ -24,9 +24,9 @@ const TransactionHistoryPage = () => {
24
24
  }, []);
25
25
  (0, react_1.useEffect)(() => {
26
26
  if (transactions.length) {
27
- return Header_1.useHeaderStore.getState().setAction((0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "medium", edge: "end", onClick: toggleDialog, children: (0, jsx_runtime_1.jsx)(DeleteOutline_1.default, {}) }));
27
+ return headerStoreContext.getState().setAction((0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "medium", edge: "end", onClick: toggleDialog, children: (0, jsx_runtime_1.jsx)(DeleteOutline_1.default, {}) }));
28
28
  }
29
- }, [transactions.length, toggleDialog]);
29
+ }, [transactions.length, toggleDialog, headerStoreContext]);
30
30
  if (!transactions.length) {
31
31
  return (0, jsx_runtime_1.jsx)(TransactionHistoryEmpty_1.TransactionHistoryEmpty, {});
32
32
  }
@@ -47,12 +47,13 @@ const ExchangeRateBottomSheetContent = ({ data, onCancel, onContinue }) => {
47
47
  const { t } = (0, react_i18next_1.useTranslation)();
48
48
  const ref = (0, react_1.useRef)();
49
49
  (0, hooks_1.useSetContentHeight)(ref);
50
+ const oldAmount = (0, big_js_1.default)(data?.oldToAmount || 1);
50
51
  return ((0, jsx_runtime_1.jsxs)(material_1.Box, { p: 3, ref: ref, children: [(0, jsx_runtime_1.jsxs)(StatusBottomSheet_style_1.CenterContainer, { children: [(0, jsx_runtime_1.jsx)(StatusBottomSheet_style_1.IconCircle, { status: "warning", mb: 1, children: (0, jsx_runtime_1.jsx)(WarningRounded_1.default, { color: "warning" }) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { py: 1, fontSize: 18, fontWeight: 700, children: t('warning.title.rateChanged') })] }), (0, jsx_runtime_1.jsx)(material_1.Typography, { py: 1, children: t('warning.message.rateChanged') }), (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", justifyContent: "space-between", mt: 1, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { children: t('main.quotedAmount') }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { fontWeight: 600, children: [t('format.number', {
51
52
  value: (0, utils_1.formatTokenAmount)(data?.oldToAmount, data?.toToken.decimals, 5),
52
53
  }), ' ', data?.toToken.symbol] })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", justifyContent: "space-between", mt: 0.25, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { children: t('main.currentAmount') }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { fontWeight: 600, children: [t('format.number', {
53
54
  value: (0, utils_1.formatTokenAmount)(data?.newToAmount, data?.toToken.decimals, 5),
54
55
  }), ' ', data?.toToken.symbol] })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", justifyContent: "space-between", mt: 0.25, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { children: t('main.rateChange') }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { fontWeight: 600, children: [(0, big_js_1.default)(data?.newToAmount || 0)
55
- .div((0, big_js_1.default)(data?.oldToAmount || 0))
56
+ .div(oldAmount.eq(0) ? (0, big_js_1.default)(1) : oldAmount)
56
57
  .minus(1)
57
58
  .mul(100)
58
59
  .round(2, big_js_1.default.roundUp)
@@ -13,7 +13,11 @@ const getStatusColor = (status, theme) => {
13
13
  case stores_1.RouteExecutionStatus.Done | stores_1.RouteExecutionStatus.Partial:
14
14
  case stores_1.RouteExecutionStatus.Done | stores_1.RouteExecutionStatus.Refunded:
15
15
  case 'warning':
16
- return { color: theme.palette.warning.main, alpha: 0.48, darken: 0.32 };
16
+ return {
17
+ color: theme.palette.warning.main,
18
+ alpha: 0.48,
19
+ darken: theme.palette.mode === 'light' ? 0.32 : 0,
20
+ };
17
21
  default:
18
22
  return { color: theme.palette.primary.main, alpha: 0.12, darken: 0 };
19
23
  }
@@ -10,7 +10,6 @@ const react_i18next_1 = require("react-i18next");
10
10
  const react_router_dom_1 = require("react-router-dom");
11
11
  const ContractComponent_1 = require("../../components/ContractComponent");
12
12
  const GasMessage_1 = require("../../components/GasMessage");
13
- const Header_1 = require("../../components/Header");
14
13
  const Insurance_1 = require("../../components/Insurance");
15
14
  const Step_1 = require("../../components/Step");
16
15
  const hooks_1 = require("../../hooks");
@@ -31,6 +30,7 @@ const TransactionPage = () => {
31
30
  const { navigateBack } = (0, hooks_1.useNavigateBack)();
32
31
  const { subvariant, insurance, contractComponent, contractSecondaryComponent, } = (0, providers_1.useWidgetConfig)();
33
32
  const { state } = (0, react_router_dom_1.useLocation)();
33
+ const headerStoreContext = (0, stores_1.useHeaderStoreContext)();
34
34
  const stateRouteId = state?.routeId;
35
35
  const [routeId, setRouteId] = (0, react_1.useState)(stateRouteId);
36
36
  const tokenValueBottomSheetRef = (0, react_1.useRef)(null);
@@ -45,13 +45,13 @@ const TransactionPage = () => {
45
45
  (0, react_1.useEffect)(() => {
46
46
  if (route && subvariant !== 'nft') {
47
47
  const transactionType = route.fromChainId === route.toChainId ? 'Swap' : 'Bridge';
48
- return Header_1.useHeaderStore
48
+ return headerStoreContext
49
49
  .getState()
50
50
  .setTitle(status === stores_1.RouteExecutionStatus.Idle
51
51
  ? t(`button.review${transactionType}`)
52
52
  : t(`header.${transactionType.toLowerCase()}`));
53
53
  }
54
- }, [route, status, subvariant, t]);
54
+ }, [headerStoreContext, route, status, subvariant, t]);
55
55
  if (!route) {
56
56
  return null;
57
57
  }
@@ -68,6 +68,10 @@ const TransactionPage = () => {
68
68
  tokenValueBottomSheetRef.current?.close();
69
69
  executeRoute();
70
70
  setValue(providers_1.FormKey.FromAmount, '');
71
+ if (subvariant === 'nft') {
72
+ setValue(providers_1.FormKey.FromToken, '');
73
+ setValue(providers_1.FormKey.ToToken, '');
74
+ }
71
75
  };
72
76
  const handleStartClick = async () => {
73
77
  if (status === stores_1.RouteExecutionStatus.Idle) {
@@ -116,7 +120,7 @@ const TransactionPage = () => {
116
120
  const getInsuranceCoverageId = () => route.steps[0].execution?.process
117
121
  .filter((process) => process.type !== 'TOKEN_ALLOWANCE')
118
122
  .find((process) => process.txHash)?.txHash ?? route.fromAddress;
119
- return ((0, jsx_runtime_1.jsxs)(TransactionPage_style_1.Container, { children: [(0, Step_1.getStepList)(route), subvariant === 'nft' ? ((0, jsx_runtime_1.jsx)(ContractComponent_1.ContractComponent, { mt: 2, children: contractSecondaryComponent || contractComponent })) : null, insuranceAvailable ? ((0, jsx_runtime_1.jsx)(Insurance_1.Insurance, { mt: 2, status: status, insurableRouteId: stateRouteId, feeAmountUsd: route.insurance.feeAmountUsd, insuredAmount: (0, utils_1.formatTokenAmount)(route.toAmountMin, route.toToken.decimals), insuredTokenSymbol: route.toToken.symbol, insuranceCoverageId: getInsuranceCoverageId(), onChange: setRouteId })) : null, status === stores_1.RouteExecutionStatus.Idle ||
123
+ return ((0, jsx_runtime_1.jsxs)(TransactionPage_style_1.Container, { children: [(0, Step_1.getStepList)(route, subvariant), subvariant === 'nft' ? ((0, jsx_runtime_1.jsx)(ContractComponent_1.ContractComponent, { mt: 2, children: contractSecondaryComponent || contractComponent })) : null, insuranceAvailable ? ((0, jsx_runtime_1.jsx)(Insurance_1.Insurance, { mt: 2, status: status, insurableRouteId: stateRouteId, feeAmountUsd: route.insurance.feeAmountUsd, insuredAmount: (0, utils_1.formatTokenAmount)(route.toAmountMin, route.toToken.decimals), insuredTokenSymbol: route.toToken.symbol, insuranceCoverageId: getInsuranceCoverageId(), onChange: setRouteId })) : null, status === stores_1.RouteExecutionStatus.Idle ||
120
124
  status === stores_1.RouteExecutionStatus.Failed ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(GasMessage_1.GasMessage, { mt: 2, route: route }), (0, jsx_runtime_1.jsxs)(material_1.Box, { mt: 2, display: "flex", children: [(0, jsx_runtime_1.jsx)(StartButton, { text: getButtonText(), onClick: handleStartClick, route: route, insurableRouteId: stateRouteId }), status === stores_1.RouteExecutionStatus.Failed ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: t('button.removeTransaction'), placement: "bottom-end", enterDelay: 400, arrow: true, children: (0, jsx_runtime_1.jsx)(material_1.Button, { onClick: handleRemoveRoute, sx: {
121
125
  minWidth: 48,
122
126
  marginLeft: 1,
@@ -2,9 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StoreProvider = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const header_1 = require("./header");
5
6
  const routes_1 = require("./routes");
6
7
  const settings_1 = require("./settings");
7
8
  const StoreProvider = ({ children, config, }) => {
8
- return ((0, jsx_runtime_1.jsx)(settings_1.SplitSubvariantStoreProvider, { state: config.subvariant === 'split' ? 'swap' : undefined, children: (0, jsx_runtime_1.jsx)(routes_1.RouteExecutionStoreProvider, { namePrefix: config?.localStorageKeyPrefix, children: children }) }));
9
+ return ((0, jsx_runtime_1.jsx)(settings_1.SplitSubvariantStoreProvider, { state: config.subvariant === 'split' ? 'swap' : undefined, children: (0, jsx_runtime_1.jsx)(header_1.HeaderStoreProvider, { namePrefix: config?.localStorageKeyPrefix, children: (0, jsx_runtime_1.jsx)(routes_1.RouteExecutionStoreProvider, { namePrefix: config?.localStorageKeyPrefix, children: children }) }) }));
9
10
  };
10
11
  exports.StoreProvider = StoreProvider;
@@ -0,0 +1 @@
1
+ export * from './useHeaderStore';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./useHeaderStore"), exports);
@@ -1,9 +1,11 @@
1
1
  /// <reference types="react" />
2
- export interface HeaderState {
2
+ import type { StoreApi, UseBoundStore } from 'zustand';
3
+ export type HeaderStore = UseBoundStore<StoreApi<HeaderState>>;
4
+ export interface HeaderStateBase {
3
5
  element?: React.ReactNode | null;
4
6
  title?: string;
5
7
  }
6
- export interface HeaderStore extends HeaderState {
8
+ export interface HeaderState extends HeaderStateBase {
7
9
  setAction(element?: React.ReactNode | null): () => void;
8
10
  setTitle(title?: string): () => void;
9
11
  removeAction(): void;
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import type { PersistStoreProps, PersistStoreProviderProps } from '../types';
3
+ import type { HeaderState, HeaderStore } from './types';
4
+ export declare const HeaderStoreContext: import("react").Context<HeaderStore | null>;
5
+ export declare function HeaderStoreProvider({ children, ...props }: PersistStoreProviderProps): import("react/jsx-runtime").JSX.Element;
6
+ export declare function useHeaderStore<T>(selector: (state: HeaderState) => T, equalityFn?: (left: T, right: T) => boolean): T;
7
+ export declare function useHeaderStoreContext(): HeaderStore;
8
+ export declare const createHeaderStore: ({ namePrefix }: PersistStoreProps) => import("zustand").UseBoundStore<import("zustand").StoreApi<HeaderState>>;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createHeaderStore = exports.useHeaderStoreContext = exports.useHeaderStore = exports.HeaderStoreProvider = exports.HeaderStoreContext = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const zustand_1 = require("zustand");
7
+ exports.HeaderStoreContext = (0, react_1.createContext)(null);
8
+ function HeaderStoreProvider({ children, ...props }) {
9
+ const storeRef = (0, react_1.useRef)();
10
+ if (!storeRef.current) {
11
+ storeRef.current = (0, exports.createHeaderStore)(props);
12
+ }
13
+ return ((0, jsx_runtime_1.jsx)(exports.HeaderStoreContext.Provider, { value: storeRef.current, children: children }));
14
+ }
15
+ exports.HeaderStoreProvider = HeaderStoreProvider;
16
+ function useHeaderStore(selector, equalityFn) {
17
+ const useStore = (0, react_1.useContext)(exports.HeaderStoreContext);
18
+ if (!useStore) {
19
+ throw new Error(`You forgot to wrap your component in <${HeaderStoreProvider.name}>.`);
20
+ }
21
+ return useStore(selector, equalityFn);
22
+ }
23
+ exports.useHeaderStore = useHeaderStore;
24
+ function useHeaderStoreContext() {
25
+ const useStore = (0, react_1.useContext)(exports.HeaderStoreContext);
26
+ if (!useStore) {
27
+ throw new Error(`You forgot to wrap your component in <${HeaderStoreProvider.name}>.`);
28
+ }
29
+ return useStore;
30
+ }
31
+ exports.useHeaderStoreContext = useHeaderStoreContext;
32
+ const createHeaderStore = ({ namePrefix }) => (0, zustand_1.create)((set, get) => ({
33
+ setAction: (element) => {
34
+ set(() => ({
35
+ element,
36
+ }));
37
+ return get().removeAction;
38
+ },
39
+ setTitle: (title) => {
40
+ set(() => ({
41
+ title,
42
+ }));
43
+ return get().removeTitle;
44
+ },
45
+ removeAction: () => {
46
+ set(() => ({
47
+ element: null,
48
+ }));
49
+ },
50
+ removeTitle: () => {
51
+ set(() => ({
52
+ title: undefined,
53
+ }));
54
+ },
55
+ }));
56
+ exports.createHeaderStore = createHeaderStore;
@@ -1,4 +1,5 @@
1
+ export * from './StoreProvider';
1
2
  export * from './chains';
3
+ export * from './header';
2
4
  export * from './routes';
3
5
  export * from './settings';
4
- export * from './StoreProvider';
@@ -14,7 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./StoreProvider"), exports);
17
18
  __exportStar(require("./chains"), exports);
19
+ __exportStar(require("./header"), exports);
18
20
  __exportStar(require("./routes"), exports);
19
21
  __exportStar(require("./settings"), exports);
20
- __exportStar(require("./StoreProvider"), exports);
@@ -4,4 +4,5 @@ export declare const isRoutePartiallyDone: (route: Route) => boolean;
4
4
  export declare const isRouteRefunded: (route: Route) => boolean;
5
5
  export declare const isRouteFailed: (route: Route) => boolean;
6
6
  export declare const isRouteActive: (route?: Route) => boolean;
7
+ export declare const doesRouteHaveCustomTool: (route: Route) => boolean;
7
8
  export declare const getUpdatedProcess: (currentRoute: Route, updatedRoute: Route) => Process | undefined;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getUpdatedProcess = exports.isRouteActive = exports.isRouteFailed = exports.isRouteRefunded = exports.isRoutePartiallyDone = exports.isRouteDone = void 0;
3
+ exports.getUpdatedProcess = exports.doesRouteHaveCustomTool = exports.isRouteActive = exports.isRouteFailed = exports.isRouteRefunded = exports.isRoutePartiallyDone = exports.isRouteDone = void 0;
4
4
  const microdiff_1 = require("microdiff");
5
5
  const isRouteDone = (route) => {
6
6
  return route.steps.every((step) => step.execution?.status === 'DONE');
@@ -28,6 +28,10 @@ const isRouteActive = (route) => {
28
28
  return !isDone && !isFailed && alreadyStarted;
29
29
  };
30
30
  exports.isRouteActive = isRouteActive;
31
+ const doesRouteHaveCustomTool = (route) => {
32
+ return route.steps.some((step) => step.tool === 'custom' || step.toolDetails.key === 'custom');
33
+ };
34
+ exports.doesRouteHaveCustomTool = doesRouteHaveCustomTool;
31
35
  const getUpdatedProcess = (currentRoute, updatedRoute) => {
32
36
  const processDiff = (0, microdiff_1.default)(currentRoute, updatedRoute).find((diff) => diff.path.includes('process'));
33
37
  if (!processDiff) {
@@ -4,7 +4,8 @@ export declare enum WidgetEvent {
4
4
  RouteExecutionUpdated = "routeExecutionUpdated",
5
5
  RouteExecutionCompleted = "routeExecutionCompleted",
6
6
  RouteExecutionFailed = "routeExecutionFailed",
7
- RouteHighValueLoss = "routeHighValueLoss"
7
+ RouteHighValueLoss = "routeHighValueLoss",
8
+ RouteContactSupport = "routeContactSupport"
8
9
  }
9
10
  export type WidgetEvents = {
10
11
  routeExecutionStarted: Route;
@@ -12,7 +13,11 @@ export type WidgetEvents = {
12
13
  routeExecutionCompleted: Route;
13
14
  routeExecutionFailed: RouteExecutionUpdate;
14
15
  routeHighValueLoss: RouteHighValueLossUpdate;
16
+ routeContactSupport: RouteContactSupport;
15
17
  };
18
+ export interface RouteContactSupport {
19
+ supportId?: string;
20
+ }
16
21
  export interface RouteHighValueLossUpdate {
17
22
  fromAmountUsd: string;
18
23
  gasCostUSD?: string;
@@ -8,4 +8,5 @@ var WidgetEvent;
8
8
  WidgetEvent["RouteExecutionCompleted"] = "routeExecutionCompleted";
9
9
  WidgetEvent["RouteExecutionFailed"] = "routeExecutionFailed";
10
10
  WidgetEvent["RouteHighValueLoss"] = "routeHighValueLoss";
11
+ WidgetEvent["RouteContactSupport"] = "routeContactSupport";
11
12
  })(WidgetEvent || (exports.WidgetEvent = WidgetEvent = {}));
@@ -7,18 +7,18 @@ import { useTranslation } from 'react-i18next';
7
7
  import { Route, Routes, useLocation } from 'react-router-dom';
8
8
  import { useNavigateBack } from '../../hooks';
9
9
  import { useWallet, useWidgetConfig } from '../../providers';
10
+ import { useHeaderStore } from '../../stores';
10
11
  import { HiddenUI } from '../../types';
11
12
  import { backButtonRoutes, navigationRoutes, navigationRoutesValues, } from '../../utils';
12
13
  import { HeaderAppBar } from './Header.style';
13
14
  import { NavigationTabs } from './NavigationTabs';
14
15
  import { WalletMenuButton } from './WalletHeader';
15
- import { useHeaderStore } from './useHeaderStore';
16
16
  export const NavigationHeader = () => {
17
17
  const { t } = useTranslation();
18
18
  const { subvariant, hiddenUI } = useWidgetConfig();
19
19
  const { navigate, navigateBack } = useNavigateBack();
20
20
  const { account } = useWallet();
21
- const { element, title } = useHeaderStore();
21
+ const { element, title } = useHeaderStore((state) => state);
22
22
  const { pathname } = useLocation();
23
23
  const cleanedPathname = pathname.endsWith('/')
24
24
  ? pathname.slice(0, -1)
@@ -1,2 +1 @@
1
1
  export * from './Header';
2
- export * from './useHeaderStore';
@@ -1,2 +1 @@
1
1
  export * from './Header';
2
- export * from './useHeaderStore';
@@ -1,2 +1,3 @@
1
1
  import type { Route } from '@lifi/sdk';
2
- export declare const getStepList: (route?: Route) => import("react/jsx-runtime").JSX.Element[] | undefined;
2
+ import type { WidgetSubvariant } from '../../types';
3
+ export declare const getStepList: (route?: Route, subvariant?: WidgetSubvariant) => import("react/jsx-runtime").JSX.Element[] | undefined;
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Fragment } from 'react';
3
3
  import { StepDivider } from '../../components/StepDivider';
4
4
  import { Step } from './Step';
5
- export const getStepList = (route) => route?.steps.map((step, index, steps) => {
5
+ export const getStepList = (route, subvariant) => route?.steps.map((step, index, steps) => {
6
6
  const lastIndex = steps.length - 1;
7
7
  const fromToken = index === 0
8
8
  ? { ...step.action.fromToken, amount: step.action.fromAmount }
@@ -10,7 +10,9 @@ export const getStepList = (route) => route?.steps.map((step, index, steps) => {
10
10
  const toToken = index === lastIndex
11
11
  ? {
12
12
  ...(step.execution?.toToken ?? step.action?.toToken),
13
- amount: step.execution?.toAmount ?? step.estimate.toAmount,
13
+ amount: step.execution?.toAmount ?? subvariant === 'nft'
14
+ ? route.toAmount
15
+ : step.estimate.toAmount,
14
16
  }
15
17
  : undefined;
16
18
  const toAddress = index === lastIndex && route.fromAddress !== route.toAddress
@@ -22,8 +22,12 @@ export const StepActions = ({ step, dense, ...other }) => {
22
22
  setCardExpanded((expanded) => !expanded);
23
23
  };
24
24
  const hasCollapsedSteps = dense && step.includedSteps?.length > 1;
25
- return (_jsxs(Box, { ...other, children: [_jsxs(Box, { display: "flex", alignItems: "center", children: [_jsx(Badge, { overlap: "circular", anchorOrigin: { vertical: 'bottom', horizontal: 'right' }, badgeContent: _jsx(SmallAvatar, { children: _jsx(LiFiToolLogo, {}) }), children: _jsx(StepAvatar, { variant: "circular", src: step.toolDetails.logoURI, alt: step.toolDetails.name, children: step.toolDetails.name[0] }) }), _jsx(Typography, { ml: 2, fontSize: 18, fontWeight: "500", flex: 1, children: t(`main.stepDetails`, {
26
- tool: step.toolDetails.name,
25
+ // FIXME: step transaction request overrides step tool details, but not included step tool details
26
+ const toolDetails = subvariant === 'nft'
27
+ ? step.includedSteps.find((step) => step.tool === 'custom' && step.toolDetails.key !== 'custom')?.toolDetails || step.toolDetails
28
+ : step.toolDetails;
29
+ return (_jsxs(Box, { ...other, children: [_jsxs(Box, { display: "flex", alignItems: "center", children: [_jsx(Badge, { overlap: "circular", anchorOrigin: { vertical: 'bottom', horizontal: 'right' }, badgeContent: _jsx(SmallAvatar, { children: _jsx(LiFiToolLogo, {}) }), children: _jsx(StepAvatar, { variant: "circular", src: toolDetails.logoURI, alt: toolDetails.name, children: toolDetails.name[0] }) }), _jsx(Typography, { ml: 2, fontSize: 18, fontWeight: "500", flex: 1, children: t(`main.stepDetails`, {
30
+ tool: toolDetails.name,
27
31
  }) }), hasCollapsedSteps ? (_jsx(CardIconButton, { onClick: handleExpand, size: "small", children: cardExpanded ? _jsx(ExpandLessIcon, {}) : _jsx(ExpandMoreIcon, {}) })) : null] }), hasCollapsedSteps ? (_jsx(Collapse, { timeout: 225, in: cardExpanded, mountOnEnter: true, unmountOnExit: true, children: _jsx(IncludedSteps, { step: step, subvariant: subvariant }) })) : (_jsx(IncludedSteps, { step: step, subvariant: subvariant }))] }));
28
32
  };
29
33
  export const IncludedSteps = ({ step, subvariant }) => {
@@ -72,8 +76,13 @@ export const CustomStepDetailsLabel = ({ step, subvariant, }) => {
72
76
  if (!subvariant) {
73
77
  return null;
74
78
  }
79
+ // FIXME: step transaction request overrides step tool details, but not included step tool details
80
+ const toolDetails = subvariant === 'nft' &&
81
+ step.includedSteps?.length > 0
82
+ ? step.includedSteps.find((step) => step.tool === 'custom' && step.toolDetails.key !== 'custom')?.toolDetails || step.toolDetails
83
+ : step.toolDetails;
75
84
  return (_jsx(Typography, { fontSize: 12, fontWeight: "500", color: "text.secondary", children: t(`main.${subvariant}StepDetails`, {
76
- tool: step.toolDetails.name,
85
+ tool: toolDetails.name,
77
86
  }) }));
78
87
  };
79
88
  export const CrossStepDetailsLabel = ({ step }) => {
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/widget";
2
- export declare const version = "2.0.0";
2
+ export declare const version = "2.1.0";
package/config/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/widget';
2
- export const version = '2.0.0';
2
+ export const version = '2.1.0';
@@ -114,8 +114,6 @@ export const useRoutes = ({ insurableRoute } = {}) => {
114
114
  toFallbackAddress: toWalletAddress,
115
115
  slippage: formattedSlippage,
116
116
  }, { signal });
117
- contractCallQuote.estimate.toAmount = toTokenAmount;
118
- contractCallQuote.estimate.toAmountMin = toTokenAmount;
119
117
  contractCallQuote.action.toToken = toToken;
120
118
  const customStep = subvariant === 'nft'
121
119
  ? contractCallQuote.includedSteps?.find((step) => step.type === 'custom')
@@ -138,8 +136,8 @@ export const useRoutes = ({ insurableRoute } = {}) => {
138
136
  fromAddress: contractCallQuote.action.fromAddress,
139
137
  toChainId: contractCallQuote.action.toChainId,
140
138
  toAmountUSD: contractCallQuote.estimate.toAmountUSD || '',
141
- toAmount: contractCallQuote.estimate.toAmount || toTokenAmount,
142
- toAmountMin: contractCallQuote.estimate.toAmountMin || toTokenAmount,
139
+ toAmount: toTokenAmount,
140
+ toAmountMin: toTokenAmount,
143
141
  toToken: toToken,
144
142
  toAddress: toWalletAddress,
145
143
  gasCostUSD: contractCallQuote.estimate.gasCosts?.[0].amountUSD,
package/i18n/en.json CHANGED
@@ -69,9 +69,9 @@
69
69
  "message": {
70
70
  "autoRefuel": "You're low on {{chainName}} gas. By continuing, you'll get enough gas to complete the transaction.",
71
71
  "emptyActiveTransactions": "Transactions in progress will appear here. Once completed, find them in transaction history.",
72
- "emptyTokenList": "We couldn't find tokens on {{chainName}} chain or you don't have any. Please try search again or choose another chain.",
72
+ "emptyTokenList": "We couldn't find tokens on {{chainName}} chain or you don't have any. Please search by contract address if your token doesn't appear or choose another chain.",
73
73
  "emptyTransactionHistory": "Transaction history is only stored locally and will be deleted if you clear your browser data.",
74
- "routeNotFound": "Try another token combination."
74
+ "routeNotFound": "Reasons for that could be: low liquidity, amount selected is too low, gas costs are too high or there are no routes for the selected combination."
75
75
  },
76
76
  "title": {
77
77
  "autoRefuel": "Get gas",