@lifi/widget 2.0.1 → 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 (60) 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/config/version.d.ts +1 -1
  5. package/cjs/config/version.js +1 -1
  6. package/cjs/i18n/en.json +2 -2
  7. package/cjs/i18n/th.json +61 -60
  8. package/cjs/i18n/vi.json +64 -63
  9. package/cjs/pages/ActiveTransactionsPage/ActiveTransactionsPage.js +3 -3
  10. package/cjs/pages/RoutesPage/RoutesPage.js +3 -3
  11. package/cjs/pages/SelectEnabledToolsPage/SelectEnabledToolsPage.js +3 -3
  12. package/cjs/pages/TransactionDetailsPage/ContactSupportButton.d.ts +5 -0
  13. package/cjs/pages/TransactionDetailsPage/ContactSupportButton.js +25 -0
  14. package/cjs/pages/TransactionDetailsPage/TransactionDetailsPage.js +5 -4
  15. package/cjs/pages/TransactionHistoryPage/TransactionHistoryPage.js +3 -3
  16. package/cjs/pages/TransactionPage/TransactionPage.js +3 -3
  17. package/cjs/stores/StoreProvider.js +2 -1
  18. package/cjs/stores/header/index.d.ts +1 -0
  19. package/cjs/stores/header/index.js +17 -0
  20. package/cjs/{components/Header → stores/header}/types.d.ts +4 -2
  21. package/cjs/stores/header/useHeaderStore.d.ts +8 -0
  22. package/cjs/stores/header/useHeaderStore.js +56 -0
  23. package/cjs/stores/index.d.ts +2 -1
  24. package/cjs/stores/index.js +2 -1
  25. package/cjs/types/events.d.ts +6 -1
  26. package/cjs/types/events.js +1 -0
  27. package/components/Header/NavigationHeader.js +2 -2
  28. package/components/Header/index.d.ts +0 -1
  29. package/components/Header/index.js +0 -1
  30. package/config/version.d.ts +1 -1
  31. package/config/version.js +1 -1
  32. package/i18n/en.json +2 -2
  33. package/i18n/th.json +61 -60
  34. package/i18n/vi.json +64 -63
  35. package/package.json +11 -11
  36. package/pages/ActiveTransactionsPage/ActiveTransactionsPage.js +4 -4
  37. package/pages/RoutesPage/RoutesPage.js +4 -4
  38. package/pages/SelectEnabledToolsPage/SelectEnabledToolsPage.js +4 -4
  39. package/pages/TransactionDetailsPage/ContactSupportButton.d.ts +5 -0
  40. package/pages/TransactionDetailsPage/ContactSupportButton.js +21 -0
  41. package/pages/TransactionDetailsPage/TransactionDetailsPage.js +6 -5
  42. package/pages/TransactionHistoryPage/TransactionHistoryPage.js +4 -4
  43. package/pages/TransactionPage/TransactionPage.js +4 -4
  44. package/stores/StoreProvider.js +2 -1
  45. package/stores/header/index.d.ts +1 -0
  46. package/stores/header/index.js +1 -0
  47. package/{components/Header → stores/header}/types.d.ts +4 -2
  48. package/stores/header/useHeaderStore.d.ts +8 -0
  49. package/stores/header/useHeaderStore.js +49 -0
  50. package/stores/index.d.ts +2 -1
  51. package/stores/index.js +2 -1
  52. package/tsconfig.cjs.tsbuildinfo +1 -1
  53. package/types/events.d.ts +6 -1
  54. package/types/events.js +1 -0
  55. package/cjs/components/Header/useHeaderStore.d.ts +0 -2
  56. package/cjs/components/Header/useHeaderStore.js +0 -28
  57. package/components/Header/useHeaderStore.d.ts +0 -2
  58. package/components/Header/useHeaderStore.js +0 -25
  59. /package/cjs/{components/Header → stores/header}/types.js +0 -0
  60. /package/{components/Header → stores/header}/types.js +0 -0
package/i18n/vi.json CHANGED
@@ -1,6 +1,15 @@
1
1
  {
2
+ "language": {
3
+ "name": "Tiếng Việt",
4
+ "title": "Ngôn ngữ"
5
+ },
6
+ "format": {
7
+ "currency": "{{value, currency(currency: USD)}}",
8
+ "number": "{{value, number(maximumFractionDigits: 9)}}"
9
+ },
2
10
  "button": {
3
11
  "auto": "Tự động",
12
+ "bridge": "Cầu",
4
13
  "buy": "Mua",
5
14
  "buyNow": "Mua ngay bây giờ",
6
15
  "cancel": "Huỷ bỏ",
@@ -12,94 +21,74 @@
12
21
  "delete": "Xóa",
13
22
  "disconnect": "Ngắt kết nối",
14
23
  "done": "Hoàn thành",
24
+ "exchange": "Hoán đổi",
15
25
  "getGas": "Thiết lập gas",
16
26
  "hide": "Ẩn",
17
27
  "learnMore": "Xem thêm",
18
- "lifiSwap": "LI.FI Swap",
28
+ "lifiCheckout": "LI.FI Checkout",
29
+ "lifiExchange": "LI.FI Exchange",
19
30
  "light": "Sáng",
20
31
  "max": "Tối đa",
21
32
  "ok": "Ok",
22
- "okay": "Okay",
23
- "removeSwap": "Xoá",
33
+ "removeTransaction": "Xoá giao dịch",
24
34
  "reset": "Đặt lại",
25
35
  "resetSettings": "Đặt lại cài đặt",
26
- "restartSwap": "Thiết lập lại",
27
- "reviewGasSwap": "Xem lại gas swap",
36
+ "reviewBridge": "Xem xét cầu",
28
37
  "reviewPurchase": "Đánh giá thanh toán",
29
38
  "reviewSwap": "Xem lại Swap",
30
39
  "seeDetails": "Xem chi tiết",
31
40
  "showAll": "Hiển thị tất cả",
32
- "startGasSwap": "Start gas swap",
33
- "startSwap": "Bắt đầu Swap",
41
+ "startBridging": "Bắt đầu đi cầu",
42
+ "startSwapping": "Bắt đầu Swap",
34
43
  "swap": "Swap",
35
44
  "tryAgain": "Thử lại",
36
45
  "viewCoverage": "Xem phạm vi bảo hiểm",
37
46
  "viewOnExplorer": "Xem tại Explorer"
38
47
  },
39
- "format": {
40
- "currency": "{{value, currency(currency: USD)}}",
41
- "number": "{{value, number(maximumFractionDigits: 9)}}"
42
- },
43
48
  "header": {
44
- "activeSwaps": "Active swaps",
45
- "bridge": "Bridge",
49
+ "activeTransactions": "Các giao dịch hiện tại",
50
+ "bridge": "Cầu",
46
51
  "checkout": "Thanh toán",
52
+ "exchange": "Hoán đổi",
47
53
  "from": "Swap từ",
48
54
  "gas": "Gas",
49
- "gasSwap": "Gas swap",
50
55
  "payWith": "Thanh toán bằng",
51
56
  "purchase": "Thanh toán",
52
57
  "purchaseDetails": "Thông tin chi tiết",
53
- "routes": "Kết quả",
54
58
  "selectChain": "Chọn chain",
55
59
  "selectWallet": "Chọn ví",
56
60
  "settings": "Cài đặt",
57
61
  "swap": "Swap",
58
- "swapDetails": "Thông tin swap",
59
- "swapHistory": "Lịch sử Swap",
60
62
  "to": "Swap từ",
61
- "walletConnected": "Wallet connected"
62
- },
63
- "language": {
64
- "name": "Tiếng Việt",
65
- "title": "Ngôn ngữ"
66
- },
67
- "settings": {
68
- "enabledBridges": "Số lượng cầu khả dụng",
69
- "enabledExchanges": "Số lượng sàn giao dịch khả dụng",
70
- "gasPrice": {
71
- "fast": "Nhanh",
72
- "normal": "Bình thường",
73
- "slow": "Chậm",
74
- "title": "Giá gas"
75
- },
76
- "routePriority": "Tuyền đường ưu tiên",
77
- "showDestinationWallet": "Hiển thị địa chỉ ví nhận",
78
- "slippage": "Trượt giá"
63
+ "transactionDetails": "Chi tiết giao dịch",
64
+ "transactionHistory": "Lịch sử giao dịch",
65
+ "walletConnected": "Wallet connected",
66
+ "youGet": "Bạn nhận"
79
67
  },
80
68
  "info": {
81
69
  "message": {
82
70
  "autoRefuel": "Gas trên {{chainName}} chain của bạn đang thấp. Để tiếp tục, bạn nên có thêm gas để hoàn thành việc swap.",
83
- "emptyActiveSwaps": "Các lệnh swap đang xử lý sẽ được hiện ở đây. Khi nào lệnh hoàn tất, bạn có thể kiểm tra lại tại mục lịch sử swap.",
84
- "emptySwapHistory": "Lịch sử Swap chỉ được lưu trữ cục bộ và sẽ bị xóa nếu bạn xóa dữ liệu trình duyệt của mình.",
71
+ "emptyActiveTransactions": "Các lệnh swap đang xử lý sẽ được hiện ở đây. Khi nào lệnh hoàn tất, bạn có thể kiểm tra lại tại mục lịch sử swap.",
85
72
  "emptyTokenList": "Chúng tôi không thể tìm được Token ở {{chainName}} chain hoặc số dư của bạn không có. Vui lòng thử tìm kiếm lại hoặc chọn một chain khác.",
73
+ "emptyTransactionHistory": "Lịch sử Swap chỉ được lưu trữ cục bộ và sẽ bị xóa nếu bạn xóa dữ liệu trình duyệt của mình.",
86
74
  "routeNotFound": "Vui lòng chọn lại cặp token khác."
87
75
  },
88
76
  "title": {
89
77
  "autoRefuel": "Thiết lập Gas",
90
- "emptyActiveSwaps": "Swap hiện không hoạt động",
91
- "emptySwapHistory": "Khônglệnh Swap gần đây",
78
+ "emptyActiveTransactions": "Không thông tin giao dịch hiện tại",
79
+ "emptyTransactionHistory": "Chưagiao dịch",
92
80
  "routeNotFound": "Không có đường đi"
93
81
  }
94
82
  },
95
83
  "success": {
96
84
  "message": {
97
- "swapPartiallySuccessful": "Chúng tôi đã cố gắng hoàn thành việc hoán đổi, nhưng {{tool}} đã cạn thanh khoản cho token {{tokenSymbol}}.",
98
- "purchaseSuccessful": "Hiện tại bạn đang nắm giữ {{assetName}} tại ví {{walletAddress}} trên chain {{chainName}}.",
99
- "swapSuccessful": "Hiện tại {{amount, number(maximumFractionDigits: 9)}} {{tokenSymbol}} trong ví {{walletAddress}} tại {{chainName}} chain."
85
+ "exchangePartiallySuccessful": "Chúng tôi đã cố gắng hoàn thành việc hoán đổi, nhưng {{tool}} đã cạn thanh khoản cho token {{tokenSymbol}}.",
86
+ "exchangeSuccessful": "Hiện tại {{amount, number(maximumFractionDigits: 9)}} {{tokenSymbol}} trong ví {{walletAddress}} tại {{chainName}} chain.",
87
+ "purchaseSuccessful": "Hiện tại bạn đang nắm giữ {{assetName}} tại ví {{walletAddress}} trên chain {{chainName}}."
100
88
  },
101
89
  "title": {
102
- "gasSwapSuccessful": "Gas Swap thành công",
90
+ "bridgePartiallySuccessful": "Swap thành công một phần",
91
+ "bridgeSuccessful": "Bridge thành công",
103
92
  "purchaseSuccessful": "Mua thành công",
104
93
  "refundIssued": "Đã Refund",
105
94
  "swapPartiallySuccessful": "Swap thành công một phần",
@@ -108,8 +97,8 @@
108
97
  },
109
98
  "warning": {
110
99
  "message": {
111
- "deleteActiveSwaps": "Các giao dịch đang hoạt động chỉ được lưu trữ cục bộ và không thể phục hồi nếu bạn xóa chúng.",
112
- "deleteSwapHistory": "Lịch sử Swap chỉ lưu trữ cục bộ và không thể phục hồi khi bạn xoá chúng.",
100
+ "deleteActiveTransactions": "Các giao dịch đang hoạt động chỉ được lưu trữ cục bộ và không thể phục hồi nếu bạn xóa chúng.",
101
+ "deleteTransactionHistory": "Lịch sử Swap chỉ lưu trữ cục bộ và không thể phục hồi khi bạn xoá chúng.",
113
102
  "highValueLoss": "Giá trị của token nhận được đang thấp hơn rất nhiều so với token được swap và chi phí giao dịch.",
114
103
  "insufficientFunds": "Bạn không có đủ tiền để thực hiện tác vụ này.",
115
104
  "insufficientGas": "Bạn không đủ gas để thực hiện swap. Bạn cần thêm ít nhất:",
@@ -117,9 +106,9 @@
117
106
  "resetSettings": "Thao tác này sẽ đặt lại mức độ ưu tiên của tuyến đường, độ trượt giá, giá gas, bridge và sàn giao dịch."
118
107
  },
119
108
  "title": {
120
- "deleteActiveSwaps": "Xoá tất cả các lệnh swap đang hoạt động?",
121
- "deleteSwap": "Xoá lệnh swap?",
122
- "deleteSwapHistory": "Xoá lịch sử Swap?",
109
+ "deleteActiveTransactions": "Xóa tất cả giao dịch đang thực hiện?",
110
+ "deleteTransaction": "Xóa giao dịch này?",
111
+ "deleteTransactionHistory": "Xoá lịch sử giao dịch?",
123
112
  "highValueLoss": "Tổn thất lớn",
124
113
  "insufficientGas": "Không đủ gas",
125
114
  "rateChanged": "Tỉ giá đã thay đổi",
@@ -140,7 +129,6 @@
140
129
  "allowanceRequired": "Sự cho phép không đủ",
141
130
  "balanceIsTooLow": "Số dư quá thấp",
142
131
  "chainSwitch": "Yêu cầu đổi chain",
143
- "failed": "Việc Swap thất bại",
144
132
  "gasLimitIsTooLow": "Giới hạn gas quá thấp",
145
133
  "insufficientFunds": "Không đủ tài sản",
146
134
  "slippageNotMet": "Điều kiện trượt giá không được đáp ứng",
@@ -155,6 +143,19 @@
155
143
  "walletEnsAddressInvalid": "Địa chỉ ví không hợp lệ hoặc mạng lưới không hỗ trợ ENS."
156
144
  }
157
145
  },
146
+ "tooltip": {
147
+ "additionalProviderFee": "Cầu bổ sung, DEX và phí dịch vụ.",
148
+ "estimatedNetworkFee": "Phí mạng ước tính.",
149
+ "estimatedTime": "Thời gian thực hiện lệnh swap (phút).",
150
+ "notFound": {
151
+ "text": "Chúng tôi không thể tìm thấy trang này.",
152
+ "title": "404"
153
+ },
154
+ "numberOfSteps": "Một số bước swap. Mỗi bước có thể chứa 1-2 giao dịch yêu cầu chữ ký.",
155
+ "progressToNextUpdate": "Thông tin hiển thị sẽ tự động làm mới sau {{value}} giây. Bấm vào đây để cập nhật thủ công.",
156
+ "recommended": "Một tuyến đường giá rẻ cân bằng giữa sự phức tạp và dễ sử dụng.",
157
+ "settingsModified": "Thiết lập (Đã điều chỉnh)"
158
+ },
158
159
  "main": {
159
160
  "crossStepDetails": "Chuyển từ {{from}} đến {{to}} thông qua {{tool}}",
160
161
  "currentAmount": "Số lượng hiện tại",
@@ -211,16 +212,16 @@
211
212
  "selectToken": "Chọn Token",
212
213
  "sendToAddress": "Gửi đến {{address}}",
213
214
  "sendToWallet": "Gửi đến địa chỉ khác",
215
+ "sending": "Đang gửi",
214
216
  "sentToAddress": "Gửi đến {{address}}",
215
- "stepBridge": "Bridge",
217
+ "stepBridge": "Cầu",
216
218
  "stepBridgeAndBuy": "Chuyển và mua",
217
219
  "stepDetails": "{{tool}} thông qua LI.FI",
218
220
  "stepSwap": "Swap",
219
221
  "stepSwapAndBridge": "Swap và Bridge",
220
222
  "stepSwapAndBuy": "Hoán đổi và mua",
221
- "supportId": "Support ID",
223
+ "supportId": " ID yêu cầu hỗ trợ",
222
224
  "swapStepDetails": "Swap tại {{chain}} thông qua {{tool}}",
223
- "swapping": "Đang Swap",
224
225
  "tags": {
225
226
  "cheapest": "Rẻ",
226
227
  "fastest": "Nhanh",
@@ -243,18 +244,18 @@
243
244
  "insured": "Bạn đã bảo hiểm <0>{{amount, number(maximumFractionDigits: 9)}} {{tokenSymbol}}</0> trong quá trình vận chuyển:",
244
245
  "slippageError": "Lỗi trượt giá đối với token nhận được"
245
246
  },
246
- "tooltip": {
247
- "additionalProviderFee": "Cầu bổ sung, DEX và phí dịch vụ.",
248
- "estimatedNetworkFee": "Phí mạng ước tính.",
249
- "estimatedTime": "Thời gian thực hiện lệnh swap (phút).",
250
- "notFound": {
251
- "text": "Chúng tôi không thể tìm thấy trang này.",
252
- "title": "404"
247
+ "settings": {
248
+ "enabledBridges": "Số lượng cầu khả dụng",
249
+ "enabledExchanges": "Số lượng sàn giao dịch khả dụng",
250
+ "gasPrice": {
251
+ "fast": "Nhanh",
252
+ "normal": "Bình thường",
253
+ "slow": "Chậm",
254
+ "title": "Giá gas"
253
255
  },
254
- "numberOfSteps": "Một số bước swap. Mỗi bước có thể chứa 1-2 giao dịch yêu cầu chữ ký.",
255
- "progressToNextUpdate": "Thông tin hiển thị sẽ tự động làm mới sau {{value}} giây. Bấm vào đây để cập nhật thủ công.",
256
- "recommended": "Một tuyến đường giá rẻ cân bằng giữa sự phức tạp và dễ sử dụng.",
257
- "settingsModified": "Thiết lập (Đã điều chỉnh)"
256
+ "routePriority": "Tuyền đường ưu tiên",
257
+ "showDestinationWallet": "Hiển thị địa chỉ nhận",
258
+ "slippage": "Trượt giá"
258
259
  },
259
260
  "wallet": {
260
261
  "extensionNotFound": "Chắc chắn rằng tiện ích trên trình duyệt {{name}} đã được kích hoạt tước khi chọn ví này."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/widget",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "description": "LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./index.js",
@@ -43,24 +43,24 @@
43
43
  "@ethersproject/address": "^5.7.0",
44
44
  "@ethersproject/experimental": "^5.7.0",
45
45
  "@ethersproject/providers": "^5.7.2",
46
- "@lifi/sdk": "^2.0.1",
47
- "@lifi/wallet-management": "^2.0.1",
46
+ "@lifi/sdk": "^2.1.0",
47
+ "@lifi/wallet-management": "^2.1.0",
48
48
  "@mui/icons-material": "^5.11.16",
49
49
  "@mui/lab": "^5.0.0-alpha.134",
50
- "@mui/material": "^5.13.5",
51
- "@tanstack/react-query": "^4.29.14",
50
+ "@mui/material": "^5.13.6",
51
+ "@tanstack/react-query": "^4.29.18",
52
52
  "@tanstack/react-virtual": "^3.0.0-beta.54",
53
53
  "big.js": "^6.2.1",
54
- "i18next": "^23.0.2",
55
- "i18next-browser-languagedetector": "^7.0.2",
54
+ "i18next": "^23.2.3",
55
+ "i18next-browser-languagedetector": "^7.1.0",
56
56
  "microdiff": "^1.3.2",
57
57
  "mitt": "^3.0.0",
58
58
  "react": "^18.2.0",
59
59
  "react-dom": "^18.2.0",
60
- "react-hook-form": "^7.44.3",
61
- "react-i18next": "^13.0.0",
62
- "react-intersection-observer": "^9.4.4",
63
- "react-router-dom": "^6.13.0",
60
+ "react-hook-form": "^7.45.0",
61
+ "react-i18next": "^13.0.1",
62
+ "react-intersection-observer": "^9.5.1",
63
+ "react-router-dom": "^6.14.0",
64
64
  "react-timer-hook": "^3.0.6",
65
65
  "uuid": "^9.0.0",
66
66
  "zustand": "^4.3.8"
@@ -5,24 +5,24 @@ import { useCallback, useEffect, useState } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  import { ActiveTransactionItem } from '../../components/ActiveTransactions';
7
7
  import { Dialog } from '../../components/Dialog';
8
- import { useHeaderStore } from '../../components/Header';
9
8
  import { useWallet } from '../../providers';
10
- import { useExecutingRoutesIds, useRouteExecutionStore } from '../../stores';
9
+ import { useExecutingRoutesIds, useHeaderStoreContext, useRouteExecutionStore, } from '../../stores';
11
10
  import { ActiveTransactionsEmpty } from './ActiveTransactionsEmpty';
12
11
  export const ActiveTransactionsPage = () => {
13
12
  const { t } = useTranslation();
14
13
  const { account } = useWallet();
15
14
  const executingRoutes = useExecutingRoutesIds(account.address);
16
15
  const deleteRoutes = useRouteExecutionStore((store) => store.deleteRoutes);
16
+ const headerStoreContext = useHeaderStoreContext();
17
17
  const [open, setOpen] = useState(false);
18
18
  const toggleDialog = useCallback(() => {
19
19
  setOpen((open) => !open);
20
20
  }, []);
21
21
  useEffect(() => {
22
22
  if (executingRoutes.length) {
23
- return useHeaderStore.getState().setAction(_jsx(IconButton, { size: "medium", edge: "end", onClick: toggleDialog, children: _jsx(DeleteIcon, {}) }));
23
+ return headerStoreContext.getState().setAction(_jsx(IconButton, { size: "medium", edge: "end", onClick: toggleDialog, children: _jsx(DeleteIcon, {}) }));
24
24
  }
25
- }, [executingRoutes.length, toggleDialog]);
25
+ }, [executingRoutes.length, headerStoreContext, toggleDialog]);
26
26
  if (!executingRoutes.length) {
27
27
  return _jsx(ActiveTransactionsEmpty, {});
28
28
  }
@@ -1,16 +1,16 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useEffect } from 'react';
3
- import { useHeaderStore } from '../../components/Header';
4
3
  import { ProgressToNextUpdate } from '../../components/ProgressToNextUpdate';
5
4
  import { RouteCard, RouteCardSkeleton, RouteNotFoundCard, } from '../../components/RouteCard';
6
5
  import { useNavigateBack, useRoutes } from '../../hooks';
7
- import { useSetExecutableRoute } from '../../stores';
6
+ import { useHeaderStoreContext, useSetExecutableRoute } from '../../stores';
8
7
  import { navigationRoutes } from '../../utils';
9
8
  import { Stack } from './RoutesPage.style';
10
9
  export const RoutesPage = () => {
11
10
  const { navigateBack, navigate } = useNavigateBack();
12
11
  const { routes, isLoading, isFetching, dataUpdatedAt, refetchTime, refetch } = useRoutes();
13
12
  const setExecutableRoute = useSetExecutableRoute();
13
+ const headerStoreContext = useHeaderStoreContext();
14
14
  const handleRouteClick = (route) => {
15
15
  setExecutableRoute(route);
16
16
  navigate(navigationRoutes.transactionExecution, {
@@ -25,10 +25,10 @@ export const RoutesPage = () => {
25
25
  // eslint-disable-next-line react-hooks/exhaustive-deps
26
26
  }, []);
27
27
  useEffect(() => {
28
- return useHeaderStore
28
+ return headerStoreContext
29
29
  .getState()
30
30
  .setAction(_jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 }, size: "medium", edge: "end" }));
31
- }, [dataUpdatedAt, isFetching, refetch, refetchTime]);
31
+ }, [dataUpdatedAt, headerStoreContext, isFetching, refetch, refetchTime]);
32
32
  const routeNotFound = !routes?.length && !isLoading && !isFetching;
33
33
  return (_jsx(Stack, { direction: "column", spacing: 2, flex: 1, children: routeNotFound ? (_jsx(RouteNotFoundCard, {})) : isLoading ? (Array.from({ length: 3 }).map((_, index) => (_jsx(RouteCardSkeleton, {}, index)))) : (routes?.map((route, index) => (_jsx(RouteCard, { route: route, onClick: () => handleRouteClick(route), active: index === 0, expanded: routes?.length <= 2 }, route.id)))) }));
34
34
  };
@@ -4,17 +4,17 @@ import CheckBoxOutlineBlankOutlinedIcon from '@mui/icons-material/CheckBoxOutlin
4
4
  import CheckBoxOutlinedIcon from '@mui/icons-material/CheckBoxOutlined';
5
5
  import IndeterminateCheckBoxOutlinedIcon from '@mui/icons-material/IndeterminateCheckBoxOutlined';
6
6
  import { Avatar, Container, IconButton, List, ListItemAvatar, } from '@mui/material';
7
- import { useHeaderStore } from '../../components/Header';
8
7
  import { useEffect } from 'react';
9
8
  import { shallow } from 'zustand/shallow';
10
9
  import { ListItemText } from '../../components/ListItemText';
11
10
  import { useTools } from '../../hooks';
12
- import { useSettingsStore } from '../../stores';
11
+ import { useHeaderStoreContext, useSettingsStore } from '../../stores';
13
12
  import { ListItemButton } from './SelectEnabledToolsPage.style';
14
13
  export const SelectEnabledToolsPage = ({ type }) => {
15
14
  const typeKey = type.toLowerCase();
16
15
  const { tools } = useTools();
17
16
  const [enabledTools, setTools] = useSettingsStore((state) => [state[`enabled${type}`], state.setTools], shallow);
17
+ const headerStoreContext = useHeaderStoreContext();
18
18
  const handleClick = (key) => {
19
19
  if (!tools) {
20
20
  return;
@@ -41,8 +41,8 @@ export const SelectEnabledToolsPage = ({ type }) => {
41
41
  setTools(type, toolKeys, toolKeys);
42
42
  }
43
43
  };
44
- return useHeaderStore.getState().setAction(_jsx(IconButton, { size: "medium", edge: "end", onClick: toggleCheckboxes, children: allToolsSelected ? (_jsx(CheckBoxOutlinedIcon, {})) : enabledTools.length ? (_jsx(IndeterminateCheckBoxOutlinedIcon, {})) : (_jsx(CheckBoxOutlineBlankOutlinedIcon, {})) }));
45
- }, [enabledTools.length, setTools, tools, type, typeKey]);
44
+ return headerStoreContext.getState().setAction(_jsx(IconButton, { size: "medium", edge: "end", onClick: toggleCheckboxes, children: allToolsSelected ? (_jsx(CheckBoxOutlinedIcon, {})) : enabledTools.length ? (_jsx(IndeterminateCheckBoxOutlinedIcon, {})) : (_jsx(CheckBoxOutlineBlankOutlinedIcon, {})) }));
45
+ }, [enabledTools.length, headerStoreContext, setTools, tools, type, typeKey]);
46
46
  return (_jsx(Container, { disableGutters: true, children: _jsx(List, { sx: {
47
47
  paddingLeft: 1.5,
48
48
  paddingRight: 1.5,
@@ -0,0 +1,5 @@
1
+ interface ContactSupportButtonProps {
2
+ supportId?: string;
3
+ }
4
+ export declare const ContactSupportButton: ({ supportId, }: ContactSupportButtonProps) => import("react/jsx-runtime").JSX.Element;
5
+ export {};
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Button } from '@mui/material';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { useWidgetEvents } from '../../hooks/';
5
+ import { WidgetEvent } from '../../types/events';
6
+ export const ContactSupportButton = ({ supportId, }) => {
7
+ const { t } = useTranslation();
8
+ const widgetEvents = useWidgetEvents();
9
+ const handleClick = () => {
10
+ if (!widgetEvents.all.has(WidgetEvent.RouteContactSupport)) {
11
+ const url = 'https://discord.gg/lifi';
12
+ const target = '_blank';
13
+ const rel = 'nofollow noreferrer';
14
+ window.open(url, target, rel);
15
+ }
16
+ else {
17
+ widgetEvents.emit(WidgetEvent.RouteContactSupport, { supportId });
18
+ }
19
+ };
20
+ return (_jsx(Button, { onClick: handleClick, fullWidth: true, children: t('button.contactSupport') }));
21
+ };
@@ -9,13 +9,13 @@ import { shallow } from 'zustand/shallow';
9
9
  import { Card, CardTitle } from '../../components/Card';
10
10
  import { ContractComponent } from '../../components/ContractComponent';
11
11
  import { Dialog } from '../../components/Dialog';
12
- import { useHeaderStore } from '../../components/Header';
13
12
  import { Insurance } from '../../components/Insurance';
14
13
  import { getStepList } from '../../components/Step';
15
14
  import { useNavigateBack } from '../../hooks';
16
15
  import { useWidgetConfig } from '../../providers';
17
- import { useRouteExecutionStore } from '../../stores';
16
+ import { useHeaderStoreContext, useRouteExecutionStore } from '../../stores';
18
17
  import { formatTokenAmount } from '../../utils';
18
+ import { ContactSupportButton } from './ContactSupportButton';
19
19
  import { Container } from './TransactionDetailsPage.style';
20
20
  export const TransactionDetailsPage = () => {
21
21
  const { t, i18n } = useTranslation();
@@ -23,6 +23,7 @@ export const TransactionDetailsPage = () => {
23
23
  const { subvariant, contractComponent, contractSecondaryComponent } = useWidgetConfig();
24
24
  const { state } = useLocation();
25
25
  const [routeExecution, deleteRoute] = useRouteExecutionStore((store) => [store.routes[state?.routeId], store.deleteRoute], shallow);
26
+ const headerStoreContext = useHeaderStoreContext();
26
27
  const [open, setOpen] = useState(false);
27
28
  const toggleDialog = useCallback(() => {
28
29
  setOpen((open) => !open);
@@ -45,8 +46,8 @@ export const TransactionDetailsPage = () => {
45
46
  await navigator.clipboard.writeText(supportId);
46
47
  };
47
48
  useEffect(() => {
48
- return useHeaderStore.getState().setAction(_jsx(IconButton, { size: "medium", edge: "end", onClick: toggleDialog, children: _jsx(DeleteIcon, {}) }));
49
- }, [toggleDialog]);
49
+ return headerStoreContext.getState().setAction(_jsx(IconButton, { size: "medium", edge: "end", onClick: toggleDialog, children: _jsx(DeleteIcon, {}) }));
50
+ }, [headerStoreContext, toggleDialog]);
50
51
  const startedAt = new Date(routeExecution?.route.steps[0].execution?.process[0].startedAt ?? 0);
51
52
  return (_jsxs(Container, { children: [_jsxs(Box, { sx: {
52
53
  display: 'flex',
@@ -57,5 +58,5 @@ export const TransactionDetailsPage = () => {
57
58
  }).format(startedAt) })] }), getStepList(routeExecution?.route, subvariant), subvariant === 'nft' ? (_jsx(ContractComponent, { mt: 2, children: contractSecondaryComponent || contractComponent })) : null, routeExecution?.route?.insurance?.state === 'INSURED' ? (_jsx(Insurance, { mt: 2, status: routeExecution.status, feeAmountUsd: routeExecution.route.insurance.feeAmountUsd, insuredAmount: formatTokenAmount(routeExecution.route.toAmountMin, routeExecution.route.toToken.decimals), insuredTokenSymbol: routeExecution.route.toToken.symbol, insurableRouteId: routeExecution.route.id, insuranceCoverageId: insuranceCoverageId })) : null, _jsxs(Card, { mt: 2, children: [_jsxs(Box, { sx: {
58
59
  display: 'flex',
59
60
  flex: 1,
60
- }, children: [_jsx(CardTitle, { flex: 1, children: t('main.supportId') }), _jsx(Box, { mr: 1, mt: 1, children: _jsx(IconButton, { size: "medium", onClick: copySupportId, children: _jsx(ContentCopyIcon, { fontSize: "small" }) }) })] }), _jsx(Typography, { variant: "body2", pt: 1, pb: 2, px: 2, sx: { wordBreak: 'break-all' }, children: supportId })] }), _jsx(Box, { mt: 2, children: _jsx(Button, { href: "https://discord.gg/lifi", target: "_blank", rel: "nofollow noreferrer", fullWidth: true, children: t('button.contactSupport') }) }), _jsxs(Dialog, { open: open, onClose: toggleDialog, children: [_jsx(DialogTitle, { children: t('warning.title.deleteTransaction') }), _jsx(DialogContent, { children: _jsx(DialogContentText, { children: t('warning.message.deleteTransactionHistory') }) }), _jsxs(DialogActions, { children: [_jsx(Button, { onClick: toggleDialog, children: t('button.cancel') }), _jsx(Button, { variant: "contained", onClick: handleDeleteRoute, autoFocus: true, children: t('button.delete') })] })] })] }));
61
+ }, children: [_jsx(CardTitle, { flex: 1, children: t('main.supportId') }), _jsx(Box, { mr: 1, mt: 1, children: _jsx(IconButton, { size: "medium", onClick: copySupportId, children: _jsx(ContentCopyIcon, { fontSize: "small" }) }) })] }), _jsx(Typography, { variant: "body2", pt: 1, pb: 2, px: 2, sx: { wordBreak: 'break-all' }, children: supportId })] }), _jsx(Box, { mt: 2, children: _jsx(ContactSupportButton, { supportId: supportId }) }), _jsxs(Dialog, { open: open, onClose: toggleDialog, children: [_jsx(DialogTitle, { children: t('warning.title.deleteTransaction') }), _jsx(DialogContent, { children: _jsx(DialogContentText, { children: t('warning.message.deleteTransactionHistory') }) }), _jsxs(DialogActions, { children: [_jsx(Button, { onClick: toggleDialog, children: t('button.cancel') }), _jsx(Button, { variant: "contained", onClick: handleDeleteRoute, autoFocus: true, children: t('button.delete') })] })] })] }));
61
62
  };
@@ -4,9 +4,8 @@ import { Button, Container, DialogActions, DialogContent, DialogContentText, Dia
4
4
  import { useCallback, useEffect, useState } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  import { Dialog } from '../../components/Dialog';
7
- import { useHeaderStore } from '../../components/Header';
8
7
  import { useWallet } from '../../providers';
9
- import { useRouteExecutionStore } from '../../stores';
8
+ import { useHeaderStoreContext, useRouteExecutionStore } from '../../stores';
10
9
  import { useTransactionHistory } from '../../stores/routes';
11
10
  import { TransactionHistoryEmpty } from './TransactionHistoryEmpty';
12
11
  import { TransactionHistoryItem } from './TransactionHistoryItem';
@@ -14,6 +13,7 @@ export const TransactionHistoryPage = () => {
14
13
  const { t } = useTranslation();
15
14
  const { account } = useWallet();
16
15
  const transactions = useTransactionHistory(account.address);
16
+ const headerStoreContext = useHeaderStoreContext();
17
17
  const deleteRoutes = useRouteExecutionStore((store) => store.deleteRoutes);
18
18
  const [open, setOpen] = useState(false);
19
19
  const toggleDialog = useCallback(() => {
@@ -21,9 +21,9 @@ export const TransactionHistoryPage = () => {
21
21
  }, []);
22
22
  useEffect(() => {
23
23
  if (transactions.length) {
24
- return useHeaderStore.getState().setAction(_jsx(IconButton, { size: "medium", edge: "end", onClick: toggleDialog, children: _jsx(DeleteIcon, {}) }));
24
+ return headerStoreContext.getState().setAction(_jsx(IconButton, { size: "medium", edge: "end", onClick: toggleDialog, children: _jsx(DeleteIcon, {}) }));
25
25
  }
26
- }, [transactions.length, toggleDialog]);
26
+ }, [transactions.length, toggleDialog, headerStoreContext]);
27
27
  if (!transactions.length) {
28
28
  return _jsx(TransactionHistoryEmpty, {});
29
29
  }
@@ -7,12 +7,11 @@ import { useTranslation } from 'react-i18next';
7
7
  import { useLocation } from 'react-router-dom';
8
8
  import { ContractComponent } from '../../components/ContractComponent';
9
9
  import { GasMessage } from '../../components/GasMessage';
10
- import { useHeaderStore } from '../../components/Header';
11
10
  import { Insurance } from '../../components/Insurance';
12
11
  import { getStepList } from '../../components/Step';
13
12
  import { useNavigateBack, useRouteExecution, useWidgetEvents, } from '../../hooks';
14
13
  import { FormKey, useWidgetConfig } from '../../providers';
15
- import { RouteExecutionStatus } from '../../stores';
14
+ import { RouteExecutionStatus, useHeaderStoreContext } from '../../stores';
16
15
  import { WidgetEvent } from '../../types/events';
17
16
  import { formatTokenAmount } from '../../utils';
18
17
  import { ExchangeRateBottomSheet } from './ExchangeRateBottomSheet';
@@ -28,6 +27,7 @@ export const TransactionPage = () => {
28
27
  const { navigateBack } = useNavigateBack();
29
28
  const { subvariant, insurance, contractComponent, contractSecondaryComponent, } = useWidgetConfig();
30
29
  const { state } = useLocation();
30
+ const headerStoreContext = useHeaderStoreContext();
31
31
  const stateRouteId = state?.routeId;
32
32
  const [routeId, setRouteId] = useState(stateRouteId);
33
33
  const tokenValueBottomSheetRef = useRef(null);
@@ -42,13 +42,13 @@ export const TransactionPage = () => {
42
42
  useEffect(() => {
43
43
  if (route && subvariant !== 'nft') {
44
44
  const transactionType = route.fromChainId === route.toChainId ? 'Swap' : 'Bridge';
45
- return useHeaderStore
45
+ return headerStoreContext
46
46
  .getState()
47
47
  .setTitle(status === RouteExecutionStatus.Idle
48
48
  ? t(`button.review${transactionType}`)
49
49
  : t(`header.${transactionType.toLowerCase()}`));
50
50
  }
51
- }, [route, status, subvariant, t]);
51
+ }, [headerStoreContext, route, status, subvariant, t]);
52
52
  if (!route) {
53
53
  return null;
54
54
  }
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { HeaderStoreProvider } from './header';
2
3
  import { RouteExecutionStoreProvider } from './routes';
3
4
  import { SplitSubvariantStoreProvider } from './settings';
4
5
  export const StoreProvider = ({ children, config, }) => {
5
- return (_jsx(SplitSubvariantStoreProvider, { state: config.subvariant === 'split' ? 'swap' : undefined, children: _jsx(RouteExecutionStoreProvider, { namePrefix: config?.localStorageKeyPrefix, children: children }) }));
6
+ return (_jsx(SplitSubvariantStoreProvider, { state: config.subvariant === 'split' ? 'swap' : undefined, children: _jsx(HeaderStoreProvider, { namePrefix: config?.localStorageKeyPrefix, children: _jsx(RouteExecutionStoreProvider, { namePrefix: config?.localStorageKeyPrefix, children: children }) }) }));
6
7
  };
@@ -0,0 +1 @@
1
+ export * from './useHeaderStore';
@@ -0,0 +1 @@
1
+ export * from './useHeaderStore';
@@ -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,49 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, useRef } from 'react';
3
+ import { create } from 'zustand';
4
+ export const HeaderStoreContext = createContext(null);
5
+ export function HeaderStoreProvider({ children, ...props }) {
6
+ const storeRef = useRef();
7
+ if (!storeRef.current) {
8
+ storeRef.current = createHeaderStore(props);
9
+ }
10
+ return (_jsx(HeaderStoreContext.Provider, { value: storeRef.current, children: children }));
11
+ }
12
+ export function useHeaderStore(selector, equalityFn) {
13
+ const useStore = useContext(HeaderStoreContext);
14
+ if (!useStore) {
15
+ throw new Error(`You forgot to wrap your component in <${HeaderStoreProvider.name}>.`);
16
+ }
17
+ return useStore(selector, equalityFn);
18
+ }
19
+ export function useHeaderStoreContext() {
20
+ const useStore = useContext(HeaderStoreContext);
21
+ if (!useStore) {
22
+ throw new Error(`You forgot to wrap your component in <${HeaderStoreProvider.name}>.`);
23
+ }
24
+ return useStore;
25
+ }
26
+ export const createHeaderStore = ({ namePrefix }) => create((set, get) => ({
27
+ setAction: (element) => {
28
+ set(() => ({
29
+ element,
30
+ }));
31
+ return get().removeAction;
32
+ },
33
+ setTitle: (title) => {
34
+ set(() => ({
35
+ title,
36
+ }));
37
+ return get().removeTitle;
38
+ },
39
+ removeAction: () => {
40
+ set(() => ({
41
+ element: null,
42
+ }));
43
+ },
44
+ removeTitle: () => {
45
+ set(() => ({
46
+ title: undefined,
47
+ }));
48
+ },
49
+ }));
package/stores/index.d.ts CHANGED
@@ -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';
package/stores/index.js CHANGED
@@ -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';