@lifi/widget 1.15.0 → 1.16.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.
- package/App.js +21 -0
- package/AppProvider.d.ts +0 -4
- package/AppProvider.js +2 -10
- package/cjs/App.js +21 -0
- package/cjs/AppProvider.d.ts +0 -4
- package/cjs/AppProvider.js +3 -12
- package/cjs/components/ActiveSwaps/ActiveSwapItem.d.ts +5 -0
- package/cjs/components/ActiveSwaps/ActiveSwapItem.js +45 -0
- package/cjs/components/{SwapsInProgress/SwapsInProgress.d.ts → ActiveSwaps/ActiveSwaps.d.ts} +1 -1
- package/cjs/components/ActiveSwaps/ActiveSwaps.js +30 -0
- package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +78 -0
- package/cjs/components/ActiveSwaps/ActiveSwaps.style.js +40 -0
- package/cjs/components/ActiveSwaps/index.d.ts +2 -0
- package/cjs/components/ActiveSwaps/index.js +18 -0
- package/cjs/components/AppContainer.js +2 -2
- package/cjs/components/Card/Card.d.ts +7 -4
- package/cjs/components/Card/Card.js +38 -28
- package/cjs/{pages/SelectTokenPage → components/ChainSelect}/ChainSelect.d.ts +0 -0
- package/cjs/components/ChainSelect/ChainSelect.js +35 -0
- package/cjs/components/{SwapsInProgress/SwapsInProgress.style.d.ts → ChainSelect/ChainSelect.style.d.ts} +10 -19
- package/cjs/components/ChainSelect/ChainSelect.style.js +19 -0
- package/cjs/components/ChainSelect/index.d.ts +2 -0
- package/cjs/components/ChainSelect/index.js +18 -0
- package/cjs/components/ChainSelect/useChainSelect.d.ts +8 -0
- package/cjs/components/ChainSelect/useChainSelect.js +33 -0
- package/cjs/components/Header/Header.js +1 -9
- package/cjs/components/Header/NavigationHeader.js +6 -11
- package/cjs/components/PoweredBy/PoweredBy.style.d.ts +1 -1
- package/cjs/components/PoweredBy/PoweredBy.style.js +1 -0
- package/cjs/components/SelectChainAndToken.js +5 -5
- package/cjs/components/SendToWallet/SendToWallet.js +6 -6
- package/cjs/components/Step/CircularProgress.js +1 -1
- package/cjs/components/Step/CircularProgress.style.js +1 -1
- package/cjs/components/Step/StepProcess.js +1 -5
- package/cjs/components/Step/StepProcess.style.d.ts +1 -1
- package/cjs/components/Step/StepTimer.d.ts +1 -0
- package/cjs/components/Step/StepTimer.js +6 -6
- package/cjs/components/SwapButton/SwapButton.js +5 -12
- package/cjs/components/SwapButton/types.d.ts +2 -2
- package/cjs/components/SwapRouteCard/SwapRouteCard.js +1 -1
- package/cjs/components/TokenAvatar/TokenAvatar.style.js +0 -3
- package/cjs/components/TokenList/TokenList.js +6 -2
- package/cjs/config/theme.js +24 -23
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/index.d.ts +2 -0
- package/cjs/hooks/index.js +2 -0
- package/cjs/hooks/useChains.d.ts +1 -97
- package/cjs/hooks/useChains.js +12 -19
- package/cjs/hooks/useFeaturedTokens.js +2 -2
- package/cjs/hooks/useGasSufficiency.js +6 -7
- package/cjs/hooks/useInitializer.js +6 -0
- package/cjs/{components/Step/utils.d.ts → hooks/useProcessMessage.d.ts} +4 -0
- package/cjs/{components/Step/utils.js → hooks/useProcessMessage.js} +16 -10
- package/cjs/hooks/useRouteExecution.d.ts +1 -1
- package/cjs/hooks/useRouteExecution.js +26 -35
- package/cjs/hooks/useSwapRoutes.js +10 -11
- package/cjs/hooks/useTokenBalances.js +4 -4
- package/cjs/hooks/useTokenSearch.js +3 -2
- package/cjs/hooks/useTokens.js +3 -2
- package/cjs/hooks/useTools.js +3 -2
- package/cjs/hooks/useWidgetEvents.d.ts +3 -0
- package/cjs/hooks/useWidgetEvents.js +13 -0
- package/cjs/i18n/en/translation.json +13 -8
- package/cjs/i18n/index.d.ts +10 -5
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +3 -1
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsEmpty.d.ts +2 -0
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +18 -0
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +2 -0
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.js +21 -0
- package/cjs/pages/ActiveSwapsPage/index.d.ts +1 -0
- package/cjs/{components/SwapsInProgress → pages/ActiveSwapsPage}/index.js +1 -1
- package/cjs/pages/MainPage/MainPage.js +2 -3
- package/cjs/pages/MainPage/MainSwapButton.js +3 -1
- package/cjs/pages/MainPage/SwapRoutes.js +4 -1
- package/cjs/pages/SelectChainPage/SelectChainPage.d.ts +3 -0
- package/cjs/pages/SelectChainPage/SelectChainPage.js +33 -0
- package/cjs/pages/SelectChainPage/SelectChainPage.style.d.ts +21 -0
- package/cjs/pages/SelectChainPage/SelectChainPage.style.js +20 -0
- package/cjs/pages/SelectChainPage/index.d.ts +1 -0
- package/cjs/pages/SelectChainPage/index.js +17 -0
- package/cjs/pages/SelectTokenPage/SelectTokenPage.d.ts +2 -4
- package/cjs/pages/SelectTokenPage/SelectTokenPage.js +2 -2
- package/cjs/pages/SelectWalletPage/SelectWalletPage.js +4 -4
- package/cjs/pages/SelectWalletPage/SelectWalletPage.style.d.ts +2 -27
- package/cjs/pages/SelectWalletPage/SelectWalletPage.style.js +4 -14
- package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
- package/cjs/pages/SettingsPage/EnabledBridgesSelect.js +3 -6
- package/cjs/pages/SettingsPage/EnabledExchangesSelect.js +3 -5
- package/cjs/pages/SettingsPage/RoutePrioritySelect.js +5 -1
- package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +1 -1
- package/cjs/pages/SwapPage/StatusBottomSheet.js +25 -36
- package/cjs/pages/SwapPage/SwapPage.js +5 -1
- package/cjs/providers/SDKProvider/SDKProvider.d.ts +4 -0
- package/cjs/providers/SDKProvider/SDKProvider.js +27 -0
- package/cjs/providers/SDKProvider/index.d.ts +1 -0
- package/cjs/providers/SDKProvider/index.js +17 -0
- package/cjs/providers/SwapFormProvider/SwapFormProvider.js +39 -11
- package/cjs/providers/TelemetryProvider/TelemetryProvider.d.ts +4 -0
- package/cjs/providers/TelemetryProvider/TelemetryProvider.js +11 -0
- package/cjs/providers/TelemetryProvider/index.d.ts +1 -0
- package/cjs/providers/TelemetryProvider/index.js +17 -0
- package/cjs/providers/WalletProvider/WalletProvider.d.ts +1 -4
- package/cjs/providers/WalletProvider/WalletProvider.js +10 -3
- package/cjs/providers/WidgetProvider/WidgetProvider.js +1 -16
- package/cjs/providers/index.d.ts +2 -0
- package/cjs/providers/index.js +2 -0
- package/cjs/stores/chains/index.d.ts +4 -0
- package/cjs/stores/chains/index.js +20 -0
- package/cjs/stores/chains/types.d.ts +8 -0
- package/cjs/stores/chains/types.js +2 -0
- package/cjs/stores/chains/useChainOrder.d.ts +1 -0
- package/cjs/stores/chains/useChainOrder.js +12 -0
- package/cjs/stores/chains/useChainOrderStore.d.ts +19 -0
- package/cjs/stores/chains/useChainOrderStore.js +42 -0
- package/cjs/stores/chains/useInitializeChainOrder.d.ts +1 -0
- package/cjs/stores/chains/useInitializeChainOrder.js +12 -0
- package/cjs/stores/route/index.d.ts +2 -1
- package/cjs/stores/route/index.js +2 -1
- package/cjs/stores/route/useExecutingRoutesIds.d.ts +1 -0
- package/cjs/stores/route/useExecutingRoutesIds.js +20 -0
- package/cjs/stores/route/useRouteStore.js +5 -4
- package/cjs/stores/route/utils.d.ts +4 -0
- package/cjs/stores/route/utils.js +21 -0
- package/cjs/stores/settings/useSettingsStore.js +5 -2
- package/cjs/types/events.d.ts +5 -0
- package/cjs/types/events.js +9 -0
- package/cjs/types/index.d.ts +1 -0
- package/cjs/types/index.js +1 -0
- package/cjs/types/widget.d.ts +2 -1
- package/cjs/utils/colors.d.ts +1 -1
- package/cjs/utils/navigationRoutes.d.ts +5 -0
- package/cjs/utils/navigationRoutes.js +31 -4
- package/components/ActiveSwaps/ActiveSwapItem.d.ts +5 -0
- package/components/ActiveSwaps/ActiveSwapItem.js +41 -0
- package/components/{SwapsInProgress/SwapsInProgress.d.ts → ActiveSwaps/ActiveSwaps.d.ts} +1 -1
- package/components/ActiveSwaps/ActiveSwaps.js +26 -0
- package/components/ActiveSwaps/ActiveSwaps.style.d.ts +78 -0
- package/components/ActiveSwaps/ActiveSwaps.style.js +37 -0
- package/components/ActiveSwaps/index.d.ts +2 -0
- package/components/ActiveSwaps/index.js +2 -0
- package/components/AppContainer.js +1 -1
- package/components/Card/Card.d.ts +7 -4
- package/components/Card/Card.js +39 -29
- package/{pages/SelectTokenPage → components/ChainSelect}/ChainSelect.d.ts +0 -0
- package/components/ChainSelect/ChainSelect.js +31 -0
- package/components/{SwapsInProgress/SwapsInProgress.style.d.ts → ChainSelect/ChainSelect.style.d.ts} +10 -19
- package/components/ChainSelect/ChainSelect.style.js +16 -0
- package/components/ChainSelect/index.d.ts +2 -0
- package/components/ChainSelect/index.js +2 -0
- package/components/ChainSelect/useChainSelect.d.ts +8 -0
- package/components/ChainSelect/useChainSelect.js +29 -0
- package/components/Header/Header.js +1 -9
- package/components/Header/NavigationHeader.js +6 -11
- package/components/PoweredBy/PoweredBy.style.d.ts +1 -1
- package/components/PoweredBy/PoweredBy.style.js +1 -0
- package/components/SelectChainAndToken.js +1 -1
- package/components/SendToWallet/SendToWallet.js +6 -6
- package/components/Step/CircularProgress.js +3 -3
- package/components/Step/CircularProgress.style.js +1 -1
- package/components/Step/StepProcess.js +2 -6
- package/components/Step/StepProcess.style.d.ts +1 -1
- package/components/Step/StepTimer.d.ts +1 -0
- package/components/Step/StepTimer.js +6 -6
- package/components/SwapButton/SwapButton.js +6 -13
- package/components/SwapButton/types.d.ts +2 -2
- package/components/SwapRouteCard/SwapRouteCard.js +1 -1
- package/components/TokenAvatar/TokenAvatar.style.js +0 -3
- package/components/TokenList/TokenList.js +6 -2
- package/config/theme.js +24 -23
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/index.d.ts +2 -0
- package/hooks/index.js +2 -0
- package/hooks/useChains.d.ts +1 -97
- package/hooks/useChains.js +11 -18
- package/hooks/useFeaturedTokens.js +1 -1
- package/hooks/useGasSufficiency.js +1 -2
- package/hooks/useInitializer.js +6 -0
- package/{components/Step/utils.d.ts → hooks/useProcessMessage.d.ts} +4 -0
- package/{pages/SwapPage/utils.js → hooks/useProcessMessage.js} +15 -10
- package/hooks/useRouteExecution.d.ts +1 -1
- package/hooks/useRouteExecution.js +26 -35
- package/hooks/useSwapRoutes.js +3 -4
- package/hooks/useTokenBalances.js +3 -3
- package/hooks/useTokenSearch.js +3 -2
- package/hooks/useTokens.js +3 -2
- package/hooks/useTools.js +3 -2
- package/hooks/useWidgetEvents.d.ts +3 -0
- package/hooks/useWidgetEvents.js +6 -0
- package/i18n/en/translation.json +13 -8
- package/i18n/index.d.ts +10 -5
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +14 -13
- package/pages/ActiveSwapsPage/ActiveSwapsEmpty.d.ts +2 -0
- package/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +14 -0
- package/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +2 -0
- package/pages/ActiveSwapsPage/ActiveSwapsPage.js +17 -0
- package/pages/ActiveSwapsPage/index.d.ts +1 -0
- package/pages/ActiveSwapsPage/index.js +1 -0
- package/pages/MainPage/MainPage.js +2 -3
- package/pages/MainPage/MainSwapButton.js +3 -1
- package/pages/MainPage/SwapRoutes.js +4 -1
- package/pages/SelectChainPage/SelectChainPage.d.ts +3 -0
- package/pages/SelectChainPage/SelectChainPage.js +29 -0
- package/pages/SelectChainPage/SelectChainPage.style.d.ts +21 -0
- package/pages/SelectChainPage/SelectChainPage.style.js +17 -0
- package/pages/SelectChainPage/index.d.ts +1 -0
- package/pages/SelectChainPage/index.js +1 -0
- package/pages/SelectTokenPage/SelectTokenPage.d.ts +2 -4
- package/pages/SelectTokenPage/SelectTokenPage.js +2 -2
- package/pages/SelectWalletPage/SelectWalletPage.js +5 -5
- package/pages/SelectWalletPage/SelectWalletPage.style.d.ts +2 -27
- package/pages/SelectWalletPage/SelectWalletPage.style.js +4 -14
- package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
- package/pages/SettingsPage/EnabledBridgesSelect.js +4 -7
- package/pages/SettingsPage/EnabledExchangesSelect.js +4 -6
- package/pages/SettingsPage/RoutePrioritySelect.js +5 -1
- package/pages/SwapDetailsPage/SwapDetailsPage.js +1 -1
- package/pages/SwapPage/StatusBottomSheet.js +27 -38
- package/pages/SwapPage/SwapPage.js +5 -1
- package/providers/SDKProvider/SDKProvider.d.ts +4 -0
- package/providers/SDKProvider/SDKProvider.js +19 -0
- package/providers/SDKProvider/index.d.ts +1 -0
- package/providers/SDKProvider/index.js +1 -0
- package/providers/SwapFormProvider/SwapFormProvider.js +39 -11
- package/providers/TelemetryProvider/TelemetryProvider.d.ts +4 -0
- package/providers/TelemetryProvider/TelemetryProvider.js +7 -0
- package/providers/TelemetryProvider/index.d.ts +1 -0
- package/providers/TelemetryProvider/index.js +1 -0
- package/providers/WalletProvider/WalletProvider.d.ts +1 -4
- package/providers/WalletProvider/WalletProvider.js +10 -3
- package/providers/WidgetProvider/WidgetProvider.js +3 -18
- package/providers/index.d.ts +2 -0
- package/providers/index.js +2 -0
- package/stores/chains/index.d.ts +4 -0
- package/stores/chains/index.js +4 -0
- package/stores/chains/types.d.ts +8 -0
- package/stores/chains/types.js +1 -0
- package/stores/chains/useChainOrder.d.ts +1 -0
- package/stores/chains/useChainOrder.js +5 -0
- package/stores/chains/useChainOrderStore.d.ts +19 -0
- package/stores/chains/useChainOrderStore.js +36 -0
- package/stores/chains/useInitializeChainOrder.d.ts +1 -0
- package/stores/chains/useInitializeChainOrder.js +5 -0
- package/stores/route/index.d.ts +2 -1
- package/stores/route/index.js +2 -1
- package/stores/route/useExecutingRoutesIds.d.ts +1 -0
- package/stores/route/useExecutingRoutesIds.js +13 -0
- package/stores/route/useRouteStore.js +5 -4
- package/stores/route/utils.d.ts +4 -0
- package/stores/route/utils.js +15 -0
- package/stores/settings/useSettingsStore.js +5 -2
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/events.d.ts +5 -0
- package/types/events.js +6 -0
- package/types/index.d.ts +1 -0
- package/types/index.js +1 -0
- package/types/widget.d.ts +2 -1
- package/utils/colors.d.ts +1 -1
- package/utils/navigationRoutes.d.ts +5 -0
- package/utils/navigationRoutes.js +30 -3
- package/cjs/components/SwapButton/SwapButton.style.d.ts +0 -65
- package/cjs/components/SwapButton/SwapButton.style.js +0 -15
- package/cjs/components/SwapsInProgress/SwapsInProgress.js +0 -29
- package/cjs/components/SwapsInProgress/SwapsInProgress.style.js +0 -17
- package/cjs/components/SwapsInProgress/index.d.ts +0 -1
- package/cjs/config/lifi.d.ts +0 -4
- package/cjs/config/lifi.js +0 -14
- package/cjs/pages/SelectTokenPage/ChainSelect.js +0 -31
- package/cjs/pages/SwapPage/utils.d.ts +0 -6
- package/cjs/pages/SwapPage/utils.js +0 -93
- package/cjs/stores/route/useExecutingRoutes.d.ts +0 -2
- package/cjs/stores/route/useExecutingRoutes.js +0 -13
- package/components/Step/utils.js +0 -89
- package/components/SwapButton/SwapButton.style.d.ts +0 -65
- package/components/SwapButton/SwapButton.style.js +0 -12
- package/components/SwapsInProgress/SwapsInProgress.js +0 -25
- package/components/SwapsInProgress/SwapsInProgress.style.js +0 -14
- package/components/SwapsInProgress/index.d.ts +0 -1
- package/components/SwapsInProgress/index.js +0 -1
- package/config/lifi.d.ts +0 -4
- package/config/lifi.js +0 -7
- package/pages/SelectTokenPage/ChainSelect.js +0 -27
- package/pages/SwapPage/utils.d.ts +0 -6
- package/stores/route/useExecutingRoutes.d.ts +0 -2
- package/stores/route/useExecutingRoutes.js +0 -6
package/cjs/hooks/useChains.d.ts
CHANGED
|
@@ -1,101 +1,5 @@
|
|
|
1
1
|
export declare const useChains: () => {
|
|
2
|
-
error: unknown;
|
|
3
|
-
isError: true;
|
|
4
|
-
isLoading: false;
|
|
5
|
-
isLoadingError: false;
|
|
6
|
-
isRefetchError: true;
|
|
7
|
-
isSuccess: false;
|
|
8
|
-
status: "error";
|
|
9
|
-
dataUpdatedAt: number;
|
|
10
|
-
errorUpdatedAt: number;
|
|
11
|
-
failureCount: number;
|
|
12
|
-
errorUpdateCount: number;
|
|
13
|
-
isFetched: boolean;
|
|
14
|
-
isFetchedAfterMount: boolean;
|
|
15
|
-
isFetching: boolean;
|
|
16
|
-
isPaused: boolean;
|
|
17
|
-
isPlaceholderData: boolean;
|
|
18
|
-
isPreviousData: boolean;
|
|
19
|
-
isRefetching: boolean;
|
|
20
|
-
isStale: boolean;
|
|
21
|
-
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@lifi/types").EVMChain[], unknown>>;
|
|
22
|
-
remove: () => void;
|
|
23
|
-
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
24
|
-
chains: import("@lifi/types").EVMChain[] | undefined;
|
|
25
|
-
getChainById: (chainId: number) => import("@lifi/types").EVMChain | undefined;
|
|
26
|
-
} | {
|
|
27
|
-
error: null;
|
|
28
|
-
isError: false;
|
|
29
|
-
isLoading: false;
|
|
30
|
-
isLoadingError: false;
|
|
31
|
-
isRefetchError: false;
|
|
32
|
-
isSuccess: true;
|
|
33
|
-
status: "success";
|
|
34
|
-
dataUpdatedAt: number;
|
|
35
|
-
errorUpdatedAt: number;
|
|
36
|
-
failureCount: number;
|
|
37
|
-
errorUpdateCount: number;
|
|
38
|
-
isFetched: boolean;
|
|
39
|
-
isFetchedAfterMount: boolean;
|
|
40
|
-
isFetching: boolean;
|
|
41
|
-
isPaused: boolean;
|
|
42
|
-
isPlaceholderData: boolean;
|
|
43
|
-
isPreviousData: boolean;
|
|
44
|
-
isRefetching: boolean;
|
|
45
|
-
isStale: boolean;
|
|
46
|
-
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@lifi/types").EVMChain[], unknown>>;
|
|
47
|
-
remove: () => void;
|
|
48
|
-
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
49
|
-
chains: import("@lifi/types").EVMChain[] | undefined;
|
|
50
|
-
getChainById: (chainId: number) => import("@lifi/types").EVMChain | undefined;
|
|
51
|
-
} | {
|
|
52
|
-
error: unknown;
|
|
53
|
-
isError: true;
|
|
54
|
-
isLoading: false;
|
|
55
|
-
isLoadingError: true;
|
|
56
|
-
isRefetchError: false;
|
|
57
|
-
isSuccess: false;
|
|
58
|
-
status: "error";
|
|
59
|
-
dataUpdatedAt: number;
|
|
60
|
-
errorUpdatedAt: number;
|
|
61
|
-
failureCount: number;
|
|
62
|
-
errorUpdateCount: number;
|
|
63
|
-
isFetched: boolean;
|
|
64
|
-
isFetchedAfterMount: boolean;
|
|
65
|
-
isFetching: boolean;
|
|
66
|
-
isPaused: boolean;
|
|
67
|
-
isPlaceholderData: boolean;
|
|
68
|
-
isPreviousData: boolean;
|
|
69
|
-
isRefetching: boolean;
|
|
70
|
-
isStale: boolean;
|
|
71
|
-
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@lifi/types").EVMChain[], unknown>>;
|
|
72
|
-
remove: () => void;
|
|
73
|
-
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
74
|
-
chains: import("@lifi/types").EVMChain[] | undefined;
|
|
75
|
-
getChainById: (chainId: number) => import("@lifi/types").EVMChain | undefined;
|
|
76
|
-
} | {
|
|
77
|
-
error: null;
|
|
78
|
-
isError: false;
|
|
79
|
-
isLoading: true;
|
|
80
|
-
isLoadingError: false;
|
|
81
|
-
isRefetchError: false;
|
|
82
|
-
isSuccess: false;
|
|
83
|
-
status: "loading";
|
|
84
|
-
dataUpdatedAt: number;
|
|
85
|
-
errorUpdatedAt: number;
|
|
86
|
-
failureCount: number;
|
|
87
|
-
errorUpdateCount: number;
|
|
88
|
-
isFetched: boolean;
|
|
89
|
-
isFetchedAfterMount: boolean;
|
|
90
|
-
isFetching: boolean;
|
|
91
|
-
isPaused: boolean;
|
|
92
|
-
isPlaceholderData: boolean;
|
|
93
|
-
isPreviousData: boolean;
|
|
94
|
-
isRefetching: boolean;
|
|
95
|
-
isStale: boolean;
|
|
96
|
-
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@lifi/types").EVMChain[], unknown>>;
|
|
97
|
-
remove: () => void;
|
|
98
|
-
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
99
2
|
chains: import("@lifi/types").EVMChain[] | undefined;
|
|
100
3
|
getChainById: (chainId: number) => import("@lifi/types").EVMChain | undefined;
|
|
4
|
+
isLoading: boolean;
|
|
101
5
|
};
|
package/cjs/hooks/useChains.js
CHANGED
|
@@ -8,29 +8,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
-
var t = {};
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
12
|
exports.useChains = void 0;
|
|
24
13
|
const react_query_1 = require("@tanstack/react-query");
|
|
25
14
|
const react_1 = require("react");
|
|
26
|
-
const
|
|
27
|
-
const
|
|
15
|
+
const providers_1 = require("../providers");
|
|
16
|
+
const chains_1 = require("../stores/chains");
|
|
28
17
|
const useChains = () => {
|
|
29
|
-
const { disabledChains } = (0,
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
18
|
+
const { disabledChains } = (0, providers_1.useWidgetConfig)();
|
|
19
|
+
const lifi = (0, providers_1.useLiFi)();
|
|
20
|
+
const [, initializeChains] = (0, chains_1.useSetChainOrder)();
|
|
21
|
+
const { data, isLoading } = (0, react_query_1.useQuery)(['chains'], () => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
const chains = yield lifi.getChains();
|
|
23
|
+
const filteredChains = chains.filter((chain) => !(disabledChains === null || disabledChains === void 0 ? void 0 : disabledChains.includes(chain.id)));
|
|
24
|
+
initializeChains(filteredChains.map((chain) => chain.id));
|
|
25
|
+
return filteredChains;
|
|
26
|
+
}));
|
|
34
27
|
const getChainById = (0, react_1.useCallback)((chainId) => {
|
|
35
28
|
const chain = data === null || data === void 0 ? void 0 : data.find((chain) => chain.id === chainId);
|
|
36
29
|
// if (!chain) {
|
|
@@ -38,6 +31,6 @@ const useChains = () => {
|
|
|
38
31
|
// }
|
|
39
32
|
return chain;
|
|
40
33
|
}, [data]);
|
|
41
|
-
return
|
|
34
|
+
return { chains: data, getChainById, isLoading };
|
|
42
35
|
};
|
|
43
36
|
exports.useChains = useChains;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useFeaturedTokens = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
const
|
|
5
|
+
const providers_1 = require("../providers");
|
|
6
6
|
const useFeaturedTokens = (selectedChainId) => {
|
|
7
|
-
const { featuredTokens } = (0,
|
|
7
|
+
const { featuredTokens } = (0, providers_1.useWidgetConfig)();
|
|
8
8
|
return (0, react_1.useMemo)(() => featuredTokens === null || featuredTokens === void 0 ? void 0 : featuredTokens.filter((token) => token.chainId === selectedChainId), [featuredTokens, selectedChainId]);
|
|
9
9
|
};
|
|
10
10
|
exports.useFeaturedTokens = useFeaturedTokens;
|
|
@@ -8,19 +8,18 @@ const big_js_1 = __importDefault(require("big.js"));
|
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const react_hook_form_1 = require("react-hook-form");
|
|
10
10
|
const _1 = require(".");
|
|
11
|
-
const
|
|
12
|
-
const WalletProvider_1 = require("../providers/WalletProvider");
|
|
11
|
+
const providers_1 = require("../providers");
|
|
13
12
|
const useTokenBalances_1 = require("./useTokenBalances");
|
|
14
13
|
const useGasSufficiency = (route) => {
|
|
15
|
-
const { account } = (0,
|
|
14
|
+
const { account } = (0, providers_1.useWallet)();
|
|
16
15
|
const [fromChainId, toChainId, fromToken] = (0, react_hook_form_1.useWatch)({
|
|
17
16
|
name: [
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
providers_1.SwapFormKeyHelper.getChainKey('from'),
|
|
18
|
+
providers_1.SwapFormKeyHelper.getChainKey('to'),
|
|
19
|
+
providers_1.SwapFormKey.FromToken,
|
|
21
20
|
],
|
|
22
21
|
});
|
|
23
|
-
const fromAmount = (0, _1.useDebouncedWatch)(
|
|
22
|
+
const fromAmount = (0, _1.useDebouncedWatch)(providers_1.SwapFormKey.FromAmount, 250);
|
|
24
23
|
const { getChainById } = (0, _1.useChains)();
|
|
25
24
|
const { tokensWithBalance: fromChainTokenBalances } = (0, useTokenBalances_1.useTokenBalances)(fromChainId);
|
|
26
25
|
const { tokensWithBalance: toChainTokenBalances } = (0, useTokenBalances_1.useTokenBalances)(toChainId);
|
|
@@ -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;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { EVMChain, Process, Step } from '@lifi/sdk';
|
|
2
2
|
import type { TFunction } from 'react-i18next';
|
|
3
|
+
export declare const useProcessMessage: (step?: Step, process?: Process) => {
|
|
4
|
+
title?: string | undefined;
|
|
5
|
+
message?: string | undefined;
|
|
6
|
+
};
|
|
3
7
|
export declare function getProcessMessage(t: TFunction<'translation', undefined>, getChainById: (chainId: number) => EVMChain | undefined, step: Step, process: Process): {
|
|
4
8
|
title?: string;
|
|
5
9
|
message?: string;
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getProcessMessage = void 0;
|
|
3
|
+
exports.getProcessMessage = exports.useProcessMessage = void 0;
|
|
4
4
|
const sdk_1 = require("@lifi/sdk");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
},
|
|
5
|
+
const react_i18next_1 = require("react-i18next");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const useChains_1 = require("./useChains");
|
|
8
|
+
const useProcessMessage = (step, process) => {
|
|
9
|
+
const { t } = (0, react_i18next_1.useTranslation)();
|
|
10
|
+
const { getChainById } = (0, useChains_1.useChains)();
|
|
11
|
+
if (!step || !process) {
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
return getProcessMessage(t, getChainById, step, process);
|
|
10
15
|
};
|
|
16
|
+
exports.useProcessMessage = useProcessMessage;
|
|
11
17
|
const processMessages = {
|
|
12
18
|
TOKEN_ALLOWANCE: {
|
|
13
19
|
STARTED: (t) => t(`swap.process.tokenAllowance.started`),
|
|
@@ -15,7 +21,7 @@ const processMessages = {
|
|
|
15
21
|
DONE: (t) => t(`swap.process.tokenAllowance.done`),
|
|
16
22
|
},
|
|
17
23
|
SWITCH_CHAIN: {
|
|
18
|
-
|
|
24
|
+
ACTION_REQUIRED: (t) => t(`swap.process.switchChain.actionRequired`),
|
|
19
25
|
DONE: (t) => t(`swap.process.switchChain.done`),
|
|
20
26
|
},
|
|
21
27
|
SWAP: {
|
|
@@ -70,9 +76,9 @@ function getProcessMessage(t, getChainById, step, process) {
|
|
|
70
76
|
title = t(`swap.error.title.slippageTooLarge`);
|
|
71
77
|
message = t(`swap.error.message.slippageTooLarge`);
|
|
72
78
|
break;
|
|
73
|
-
case sdk_1.
|
|
74
|
-
title = t(`swap.error.title.
|
|
75
|
-
message = t(`swap.error.message.
|
|
79
|
+
case sdk_1.LifiErrorCode.TransactionRejected:
|
|
80
|
+
title = t(`swap.error.title.transactionRejected`);
|
|
81
|
+
message = t(`swap.error.message.transactionRejected`, {
|
|
76
82
|
amount: (0, utils_1.formatTokenAmount)(step.action.fromAmount, step.action.fromToken.decimals),
|
|
77
83
|
tokenSymbol: step.action.fromToken.symbol,
|
|
78
84
|
chainName: (_b = (_a = getChainById(step.action.fromChainId)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Route } from '@lifi/sdk';
|
|
2
|
-
export declare const useRouteExecution: (routeId: string) => {
|
|
2
|
+
export declare const useRouteExecution: (routeId: string, executeInBackground?: boolean) => {
|
|
3
3
|
executeRoute: () => void;
|
|
4
4
|
restartRoute: () => void;
|
|
5
5
|
deleteRoute: () => void;
|
|
@@ -16,19 +16,28 @@ 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
|
|
20
|
-
const WalletProvider_1 = require("../providers/WalletProvider");
|
|
19
|
+
const providers_1 = require("../providers");
|
|
21
20
|
const stores_1 = require("../stores");
|
|
21
|
+
const events_1 = require("../types/events");
|
|
22
22
|
const utils_1 = require("../utils");
|
|
23
|
-
const
|
|
24
|
-
|
|
23
|
+
const useWidgetEvents_1 = require("./useWidgetEvents");
|
|
24
|
+
const useRouteExecution = (routeId, executeInBackground) => {
|
|
25
|
+
const lifi = (0, providers_1.useLiFi)();
|
|
26
|
+
const { account, switchChain } = (0, providers_1.useWallet)();
|
|
25
27
|
const resumedAfterMount = (0, react_1.useRef)(false);
|
|
28
|
+
const emitter = (0, useWidgetEvents_1.useWidgetEvents)();
|
|
26
29
|
const routeExecution = (0, stores_1.useRouteStore)((state) => state.routes[routeId]);
|
|
27
30
|
const [updateRoute, restartRoute, deleteRoute] = (0, stores_1.useRouteStore)((state) => [state.updateRoute, state.restartRoute, state.deleteRoute], shallow_1.default);
|
|
28
31
|
const updateCallback = (updatedRoute) => {
|
|
29
32
|
const clonedUpdatedRoute = (0, utils_1.deepClone)(updatedRoute);
|
|
30
33
|
console.log('Route updated.', clonedUpdatedRoute);
|
|
31
34
|
updateRoute(clonedUpdatedRoute);
|
|
35
|
+
if ((0, stores_1.isRouteCompleted)(clonedUpdatedRoute)) {
|
|
36
|
+
emitter.emit(events_1.WidgetEvent.SwapCompleted);
|
|
37
|
+
}
|
|
38
|
+
if ((0, stores_1.isRouteFailed)(clonedUpdatedRoute)) {
|
|
39
|
+
emitter.emit(events_1.WidgetEvent.SwapFailed);
|
|
40
|
+
}
|
|
32
41
|
};
|
|
33
42
|
const switchChainHook = (requiredChainId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
43
|
if (!account.isActive || !account.signer) {
|
|
@@ -50,20 +59,16 @@ const useRouteExecution = (routeId) => {
|
|
|
50
59
|
if (!(routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route)) {
|
|
51
60
|
throw Error('Execution route not found.');
|
|
52
61
|
}
|
|
53
|
-
return
|
|
62
|
+
return lifi.executeRoute(account.signer, routeExecution.route, {
|
|
54
63
|
updateCallback,
|
|
55
64
|
switchChainHook,
|
|
56
65
|
infiniteApproval: false,
|
|
66
|
+
executeInBackground,
|
|
57
67
|
});
|
|
58
68
|
}, {
|
|
59
69
|
onMutate: () => {
|
|
60
70
|
console.log('Execution started.', routeId);
|
|
61
|
-
|
|
62
|
-
onError: () => {
|
|
63
|
-
console.warn('Execution failed.', routeId);
|
|
64
|
-
},
|
|
65
|
-
onSuccess: (route) => {
|
|
66
|
-
console.log('Executed successfully.', routeId);
|
|
71
|
+
emitter.emit(events_1.WidgetEvent.SwapStarted);
|
|
67
72
|
},
|
|
68
73
|
});
|
|
69
74
|
const resumeRouteMutation = (0, react_query_1.useMutation)((resumedRoute) => {
|
|
@@ -73,30 +78,25 @@ const useRouteExecution = (routeId) => {
|
|
|
73
78
|
if (!(routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route)) {
|
|
74
79
|
throw Error('Execution route not found.');
|
|
75
80
|
}
|
|
76
|
-
return
|
|
81
|
+
return lifi.resumeRoute(account.signer, resumedRoute !== null && resumedRoute !== void 0 ? resumedRoute : routeExecution.route, {
|
|
77
82
|
updateCallback,
|
|
78
83
|
switchChainHook,
|
|
79
84
|
infiniteApproval: false,
|
|
85
|
+
executeInBackground,
|
|
80
86
|
});
|
|
81
87
|
}, {
|
|
82
88
|
onMutate: () => {
|
|
83
89
|
console.log('Resumed to execution.', routeId);
|
|
84
90
|
},
|
|
85
|
-
onError: () => {
|
|
86
|
-
console.warn('Resumed execution failed.', routeId);
|
|
87
|
-
},
|
|
88
|
-
onSuccess: (route) => {
|
|
89
|
-
console.log('Resumed execution successful.', route);
|
|
90
|
-
},
|
|
91
91
|
});
|
|
92
92
|
const executeRoute = (0, react_1.useCallback)(() => {
|
|
93
93
|
executeRouteMutation.mutateAsync(undefined, {
|
|
94
94
|
onError: () => {
|
|
95
|
-
console.warn('
|
|
95
|
+
console.warn('Execution failed!', routeId);
|
|
96
96
|
// Notification.showNotification(NotificationType.SwapExecution_ERROR);
|
|
97
97
|
},
|
|
98
98
|
onSuccess: (route) => {
|
|
99
|
-
console.log('
|
|
99
|
+
console.log('Executed successfully!', route);
|
|
100
100
|
// Notification.showNotification(NotificationType.TRANSACTION_SUCCESSFULL);
|
|
101
101
|
},
|
|
102
102
|
});
|
|
@@ -104,10 +104,10 @@ const useRouteExecution = (routeId) => {
|
|
|
104
104
|
const resumeRoute = (0, react_1.useCallback)((route) => {
|
|
105
105
|
resumeRouteMutation.mutateAsync(route, {
|
|
106
106
|
onError: () => {
|
|
107
|
-
console.warn('
|
|
107
|
+
console.warn('Resumed execution failed.', routeId);
|
|
108
108
|
},
|
|
109
109
|
onSuccess: (route) => {
|
|
110
|
-
console.log('
|
|
110
|
+
console.log('Resumed execution successful.', route);
|
|
111
111
|
},
|
|
112
112
|
});
|
|
113
113
|
}, [resumeRouteMutation, routeId]);
|
|
@@ -123,7 +123,7 @@ const useRouteExecution = (routeId) => {
|
|
|
123
123
|
// Resume route execution after page reload
|
|
124
124
|
(0, react_1.useEffect)(() => {
|
|
125
125
|
// Check if route is eligible for automatic resuming
|
|
126
|
-
if (
|
|
126
|
+
if ((0, stores_1.isRouteActive)(routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route) &&
|
|
127
127
|
account.isActive &&
|
|
128
128
|
!resumedAfterMount.current) {
|
|
129
129
|
resumedAfterMount.current = true;
|
|
@@ -135,14 +135,14 @@ const useRouteExecution = (routeId) => {
|
|
|
135
135
|
return () => {
|
|
136
136
|
var _a;
|
|
137
137
|
const route = (_a = stores_1.useRouteStore.getState().routes[routeId]) === null || _a === void 0 ? void 0 : _a.route;
|
|
138
|
-
if (!route || !
|
|
138
|
+
if (!route || !(0, stores_1.isRouteActive)(route)) {
|
|
139
139
|
return;
|
|
140
140
|
}
|
|
141
|
-
|
|
141
|
+
lifi.updateRouteExecution(route, { executeInBackground: true });
|
|
142
142
|
console.log('Move route execution to background.', routeId);
|
|
143
143
|
resumedAfterMount.current = false;
|
|
144
144
|
};
|
|
145
|
-
}, [routeId]);
|
|
145
|
+
}, [lifi, routeId]);
|
|
146
146
|
return {
|
|
147
147
|
executeRoute,
|
|
148
148
|
restartRoute: restartRouteMutation,
|
|
@@ -152,12 +152,3 @@ const useRouteExecution = (routeId) => {
|
|
|
152
152
|
};
|
|
153
153
|
};
|
|
154
154
|
exports.useRouteExecution = useRouteExecution;
|
|
155
|
-
const isActiveRoute = (route) => {
|
|
156
|
-
if (!route) {
|
|
157
|
-
return false;
|
|
158
|
-
}
|
|
159
|
-
const allDone = route.steps.every((step) => { var _a; return ((_a = step.execution) === null || _a === void 0 ? void 0 : _a.status) === 'DONE'; });
|
|
160
|
-
const isFailed = route.steps.some((step) => { var _a; return ((_a = step.execution) === null || _a === void 0 ? void 0 : _a.status) === 'FAILED'; });
|
|
161
|
-
const alreadyStarted = route.steps.some((step) => step.execution);
|
|
162
|
-
return !allDone && !isFailed && alreadyStarted;
|
|
163
|
-
};
|
|
@@ -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
|
|
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
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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)([
|
|
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
|
|
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,
|
|
@@ -13,15 +13,15 @@ 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
|
|
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
|
|
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);
|
|
@@ -30,7 +30,7 @@ const useTokenBalances = (selectedChainId) => {
|
|
|
30
30
|
if (!accountAddress || !tokens) {
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
const tokenBalances = yield
|
|
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
|
|
@@ -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
|
|
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
|
|
19
|
+
const data = yield lifi.getToken(chainId, token, {
|
|
19
20
|
signal,
|
|
20
21
|
});
|
|
21
22
|
if (data) {
|
package/cjs/hooks/useTokens.js
CHANGED
|
@@ -11,13 +11,14 @@ 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
|
|
14
|
+
const providers_1 = require("../providers");
|
|
15
15
|
const useFeaturedTokens_1 = require("./useFeaturedTokens");
|
|
16
16
|
const useTokens = (selectedChainId) => {
|
|
17
|
+
const lifi = (0, providers_1.useLiFi)();
|
|
17
18
|
const featuredTokens = (0, useFeaturedTokens_1.useFeaturedTokens)(selectedChainId);
|
|
18
19
|
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
20
|
var _a, _b, _c;
|
|
20
|
-
const data = yield
|
|
21
|
+
const data = yield lifi.getTokens({ chains: [selectedChainId] });
|
|
21
22
|
const featuredTokenAddresses = new Set(featuredTokens === null || featuredTokens === void 0 ? void 0 : featuredTokens.map((token) => token.address));
|
|
22
23
|
return [
|
|
23
24
|
...((_a = featuredTokens === null || featuredTokens === void 0 ? void 0 : featuredTokens.map((token) => {
|
package/cjs/hooks/useTools.js
CHANGED
|
@@ -3,11 +3,12 @@ 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
|
|
6
|
+
const providers_1 = require("../providers");
|
|
7
7
|
const stores_1 = require("../stores");
|
|
8
8
|
const useTools = () => {
|
|
9
|
+
const lifi = (0, providers_1.useLiFi)();
|
|
9
10
|
const initializeTools = (0, stores_1.useSettingsStore)((state) => state.initializeTools);
|
|
10
|
-
const { data } = (0, react_query_1.useQuery)(['tools'], ({ signal }) =>
|
|
11
|
+
const { data } = (0, react_query_1.useQuery)(['tools'], ({ signal }) => lifi.getTools(undefined, { signal }), {
|
|
11
12
|
onSuccess(data) {
|
|
12
13
|
initializeTools('Bridges', data.bridges.map((bridge) => bridge.key));
|
|
13
14
|
initializeTools('Exchanges', data.exchanges.map((exchange) => exchange.key));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useWidgetEvents = void 0;
|
|
7
|
+
const events_1 = require("events");
|
|
8
|
+
const zustand_1 = __importDefault(require("zustand"));
|
|
9
|
+
const emitterStore = (0, zustand_1.default)()(() => new events_1.EventEmitter());
|
|
10
|
+
const useWidgetEvents = () => {
|
|
11
|
+
return emitterStore();
|
|
12
|
+
};
|
|
13
|
+
exports.useWidgetEvents = useWidgetEvents;
|