@ledgerhq/live-common 34.35.1 → 34.35.2-nightly.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.
- package/lib/apps/support.d.ts +1 -0
- package/lib/apps/support.d.ts.map +1 -1
- package/lib/apps/support.js +10 -1
- package/lib/apps/support.js.map +1 -1
- package/lib/e2e/enum/Account.d.ts +64 -58
- package/lib/e2e/enum/Account.d.ts.map +1 -1
- package/lib/e2e/enum/Account.js +80 -59
- package/lib/e2e/enum/Account.js.map +1 -1
- package/lib/e2e/enum/Device.d.ts +8 -0
- package/lib/e2e/enum/Device.d.ts.map +1 -0
- package/lib/e2e/enum/Device.js +14 -0
- package/lib/e2e/enum/Device.js.map +1 -0
- package/lib/e2e/enum/Swap.d.ts +2 -1
- package/lib/e2e/enum/Swap.d.ts.map +1 -1
- package/lib/e2e/enum/Swap.js +12 -10
- package/lib/e2e/enum/Swap.js.map +1 -1
- package/lib/e2e/families/cardano.d.ts.map +1 -1
- package/lib/e2e/families/cardano.js +55 -26
- package/lib/e2e/families/cardano.js.map +1 -1
- package/lib/e2e/families/evm.d.ts.map +1 -1
- package/lib/e2e/families/evm.js +2 -1
- package/lib/e2e/families/evm.js.map +1 -1
- package/lib/e2e/families/solana.d.ts.map +1 -1
- package/lib/e2e/families/solana.js +5 -2
- package/lib/e2e/families/solana.js.map +1 -1
- package/lib/e2e/index.d.ts +2 -0
- package/lib/e2e/index.d.ts.map +1 -1
- package/lib/e2e/models/BuySell.d.ts +11 -0
- package/lib/e2e/models/BuySell.d.ts.map +1 -0
- package/lib/{index.js → e2e/models/BuySell.js} +1 -1
- package/lib/e2e/models/BuySell.js.map +1 -0
- package/lib/e2e/models/Transaction.d.ts +5 -5
- package/lib/e2e/models/Transaction.d.ts.map +1 -1
- package/lib/e2e/models/Transaction.js.map +1 -1
- package/lib/e2e/speculos.d.ts +6 -1
- package/lib/e2e/speculos.d.ts.map +1 -1
- package/lib/e2e/speculos.js +72 -40
- package/lib/e2e/speculos.js.map +1 -1
- package/lib/e2e/speculosCI.d.ts +5 -0
- package/lib/e2e/speculosCI.d.ts.map +1 -0
- package/lib/e2e/speculosCI.js +129 -0
- package/lib/e2e/speculosCI.js.map +1 -0
- package/lib/families/hedera/logic.d.ts +2 -0
- package/lib/families/hedera/logic.d.ts.map +1 -0
- package/lib/families/hedera/logic.js +19 -0
- package/lib/families/hedera/logic.js.map +1 -0
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +1 -0
- package/lib/featureFlags/defaultFeatures.js.map +1 -1
- package/lib/featureFlags/useFeature.d.ts +1 -1
- package/lib/featureFlags/useFeature.d.ts.map +1 -1
- package/lib/hw/actions/manager.d.ts +1 -1
- package/lib/hw/actions/manager.d.ts.map +1 -1
- package/lib/hw/connectApp.d.ts.map +1 -1
- package/lib/hw/connectApp.js +56 -5
- package/lib/hw/connectApp.js.map +1 -1
- package/lib/hw/connectAppEventMapper.d.ts +29 -0
- package/lib/hw/connectAppEventMapper.d.ts.map +1 -0
- package/lib/hw/connectAppEventMapper.js +300 -0
- package/lib/hw/connectAppEventMapper.js.map +1 -0
- package/lib/hw/connectManager.d.ts +3 -2
- package/lib/hw/connectManager.d.ts.map +1 -1
- package/lib/hw/connectManager.js +34 -3
- package/lib/hw/connectManager.js.map +1 -1
- package/lib/hw/connectManagerEventMapper.d.ts +16 -0
- package/lib/hw/connectManagerEventMapper.d.ts.map +1 -0
- package/lib/hw/connectManagerEventMapper.js +78 -0
- package/lib/hw/connectManagerEventMapper.js.map +1 -0
- package/lib/market/hooks/useLargeMoverChartData.d.ts +18 -0
- package/lib/market/hooks/useLargeMoverChartData.d.ts.map +1 -0
- package/lib/market/hooks/useLargeMoverChartData.js +28 -0
- package/lib/market/hooks/useLargeMoverChartData.js.map +1 -0
- package/lib/market/hooks/useLargeMoverCurrencies.d.ts +13 -0
- package/lib/market/hooks/useLargeMoverCurrencies.d.ts.map +1 -0
- package/lib/market/hooks/useLargeMoverCurrencies.js +29 -0
- package/lib/market/hooks/useLargeMoverCurrencies.js.map +1 -0
- package/lib/notifications/AnnouncementProvider/index.d.ts.map +1 -1
- package/lib/notifications/AnnouncementProvider/index.js +12 -10
- package/lib/notifications/AnnouncementProvider/index.js.map +1 -1
- package/lib/notifications/AnnouncementProvider/machine.d.ts +1 -4
- package/lib/notifications/AnnouncementProvider/machine.d.ts.map +1 -1
- package/lib/notifications/AnnouncementProvider/machine.js +9 -8
- package/lib/notifications/AnnouncementProvider/machine.js.map +1 -1
- package/lib/notifications/ServiceStatusProvider/index.d.ts.map +1 -1
- package/lib/notifications/ServiceStatusProvider/index.js +5 -4
- package/lib/notifications/ServiceStatusProvider/index.js.map +1 -1
- package/lib/notifications/ServiceStatusProvider/machine.d.ts +1 -4
- package/lib/notifications/ServiceStatusProvider/machine.d.ts.map +1 -1
- package/lib/notifications/ServiceStatusProvider/machine.js +4 -4
- package/lib/notifications/ServiceStatusProvider/machine.js.map +1 -1
- package/lib/wallet-api/ModularDrawer/types.d.ts +63 -0
- package/lib/wallet-api/ModularDrawer/types.d.ts.map +1 -0
- package/lib/wallet-api/ModularDrawer/types.js +25 -0
- package/lib/wallet-api/ModularDrawer/types.js.map +1 -0
- package/lib/wallet-api/ModularDrawer/utils.d.ts +5 -0
- package/lib/wallet-api/ModularDrawer/utils.d.ts.map +1 -0
- package/lib/wallet-api/ModularDrawer/utils.js +30 -0
- package/lib/wallet-api/ModularDrawer/utils.js.map +1 -0
- package/lib/wallet-api/react.d.ts +2 -0
- package/lib/wallet-api/react.d.ts.map +1 -1
- package/lib/wallet-api/react.js +2 -1
- package/lib/wallet-api/react.js.map +1 -1
- package/lib-es/apps/support.d.ts +1 -0
- package/lib-es/apps/support.d.ts.map +1 -1
- package/lib-es/apps/support.js +8 -0
- package/lib-es/apps/support.js.map +1 -1
- package/lib-es/e2e/enum/Account.d.ts +64 -58
- package/lib-es/e2e/enum/Account.d.ts.map +1 -1
- package/lib-es/e2e/enum/Account.js +76 -58
- package/lib-es/e2e/enum/Account.js.map +1 -1
- package/lib-es/e2e/enum/Device.d.ts +8 -0
- package/lib-es/e2e/enum/Device.d.ts.map +1 -0
- package/lib-es/e2e/enum/Device.js +10 -0
- package/lib-es/e2e/enum/Device.js.map +1 -0
- package/lib-es/e2e/enum/Swap.d.ts +2 -1
- package/lib-es/e2e/enum/Swap.d.ts.map +1 -1
- package/lib-es/e2e/enum/Swap.js +12 -10
- package/lib-es/e2e/enum/Swap.js.map +1 -1
- package/lib-es/e2e/families/cardano.d.ts.map +1 -1
- package/lib-es/e2e/families/cardano.js +56 -27
- package/lib-es/e2e/families/cardano.js.map +1 -1
- package/lib-es/e2e/families/evm.d.ts.map +1 -1
- package/lib-es/e2e/families/evm.js +2 -1
- package/lib-es/e2e/families/evm.js.map +1 -1
- package/lib-es/e2e/families/solana.d.ts.map +1 -1
- package/lib-es/e2e/families/solana.js +5 -2
- package/lib-es/e2e/families/solana.js.map +1 -1
- package/lib-es/e2e/index.d.ts +2 -0
- package/lib-es/e2e/index.d.ts.map +1 -1
- package/lib-es/e2e/models/BuySell.d.ts +11 -0
- package/lib-es/e2e/models/BuySell.d.ts.map +1 -0
- package/lib-es/e2e/models/BuySell.js +2 -0
- package/lib-es/e2e/models/BuySell.js.map +1 -0
- package/lib-es/e2e/models/Transaction.d.ts +5 -5
- package/lib-es/e2e/models/Transaction.d.ts.map +1 -1
- package/lib-es/e2e/models/Transaction.js.map +1 -1
- package/lib-es/e2e/speculos.d.ts +6 -1
- package/lib-es/e2e/speculos.d.ts.map +1 -1
- package/lib-es/e2e/speculos.js +69 -39
- package/lib-es/e2e/speculos.js.map +1 -1
- package/lib-es/e2e/speculosCI.d.ts +5 -0
- package/lib-es/e2e/speculosCI.d.ts.map +1 -0
- package/lib-es/e2e/speculosCI.js +121 -0
- package/lib-es/e2e/speculosCI.js.map +1 -0
- package/lib-es/families/hedera/logic.d.ts +2 -0
- package/lib-es/families/hedera/logic.d.ts.map +1 -0
- package/lib-es/families/hedera/logic.js +3 -0
- package/lib-es/families/hedera/logic.js.map +1 -0
- package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.js +1 -0
- package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
- package/lib-es/featureFlags/useFeature.d.ts +1 -1
- package/lib-es/featureFlags/useFeature.d.ts.map +1 -1
- package/lib-es/hw/actions/manager.d.ts +1 -1
- package/lib-es/hw/actions/manager.d.ts.map +1 -1
- package/lib-es/hw/connectApp.d.ts.map +1 -1
- package/lib-es/hw/connectApp.js +57 -6
- package/lib-es/hw/connectApp.js.map +1 -1
- package/lib-es/hw/connectAppEventMapper.d.ts +29 -0
- package/lib-es/hw/connectAppEventMapper.d.ts.map +1 -0
- package/lib-es/hw/connectAppEventMapper.js +296 -0
- package/lib-es/hw/connectAppEventMapper.js.map +1 -0
- package/lib-es/hw/connectManager.d.ts +3 -2
- package/lib-es/hw/connectManager.d.ts.map +1 -1
- package/lib-es/hw/connectManager.js +34 -4
- package/lib-es/hw/connectManager.js.map +1 -1
- package/lib-es/hw/connectManagerEventMapper.d.ts +16 -0
- package/lib-es/hw/connectManagerEventMapper.d.ts.map +1 -0
- package/lib-es/hw/connectManagerEventMapper.js +74 -0
- package/lib-es/hw/connectManagerEventMapper.js.map +1 -0
- package/lib-es/market/hooks/useLargeMoverChartData.d.ts +18 -0
- package/lib-es/market/hooks/useLargeMoverChartData.d.ts.map +1 -0
- package/lib-es/market/hooks/useLargeMoverChartData.js +24 -0
- package/lib-es/market/hooks/useLargeMoverChartData.js.map +1 -0
- package/lib-es/market/hooks/useLargeMoverCurrencies.d.ts +13 -0
- package/lib-es/market/hooks/useLargeMoverCurrencies.d.ts.map +1 -0
- package/lib-es/market/hooks/useLargeMoverCurrencies.js +25 -0
- package/lib-es/market/hooks/useLargeMoverCurrencies.js.map +1 -0
- package/lib-es/notifications/AnnouncementProvider/index.d.ts.map +1 -1
- package/lib-es/notifications/AnnouncementProvider/index.js +12 -10
- package/lib-es/notifications/AnnouncementProvider/index.js.map +1 -1
- package/lib-es/notifications/AnnouncementProvider/machine.d.ts +1 -4
- package/lib-es/notifications/AnnouncementProvider/machine.d.ts.map +1 -1
- package/lib-es/notifications/AnnouncementProvider/machine.js +9 -8
- package/lib-es/notifications/AnnouncementProvider/machine.js.map +1 -1
- package/lib-es/notifications/ServiceStatusProvider/index.d.ts.map +1 -1
- package/lib-es/notifications/ServiceStatusProvider/index.js +5 -4
- package/lib-es/notifications/ServiceStatusProvider/index.js.map +1 -1
- package/lib-es/notifications/ServiceStatusProvider/machine.d.ts +1 -4
- package/lib-es/notifications/ServiceStatusProvider/machine.d.ts.map +1 -1
- package/lib-es/notifications/ServiceStatusProvider/machine.js +4 -4
- package/lib-es/notifications/ServiceStatusProvider/machine.js.map +1 -1
- package/lib-es/wallet-api/ModularDrawer/types.d.ts +63 -0
- package/lib-es/wallet-api/ModularDrawer/types.d.ts.map +1 -0
- package/lib-es/wallet-api/ModularDrawer/types.js +22 -0
- package/lib-es/wallet-api/ModularDrawer/types.js.map +1 -0
- package/lib-es/wallet-api/ModularDrawer/utils.d.ts +5 -0
- package/lib-es/wallet-api/ModularDrawer/utils.d.ts.map +1 -0
- package/lib-es/wallet-api/ModularDrawer/utils.js +25 -0
- package/lib-es/wallet-api/ModularDrawer/utils.js.map +1 -0
- package/lib-es/wallet-api/react.d.ts +2 -0
- package/lib-es/wallet-api/react.d.ts.map +1 -1
- package/lib-es/wallet-api/react.js +2 -1
- package/lib-es/wallet-api/react.js.map +1 -1
- package/package.json +50 -49
- package/src/apps/support.ts +11 -0
- package/src/e2e/enum/Account.ts +363 -362
- package/src/e2e/enum/Device.ts +7 -0
- package/src/e2e/enum/Swap.ts +10 -9
- package/src/e2e/families/cardano.ts +63 -28
- package/src/e2e/families/evm.ts +2 -1
- package/src/e2e/families/solana.ts +5 -2
- package/src/e2e/models/BuySell.ts +12 -0
- package/src/e2e/models/Transaction.ts +5 -5
- package/src/e2e/speculos.ts +75 -41
- package/src/e2e/speculosCI.ts +161 -0
- package/src/families/hedera/logic.ts +2 -0
- package/src/featureFlags/defaultFeatures.ts +1 -0
- package/src/hw/actions/manager.ts +1 -1
- package/src/hw/connectApp.ts +245 -178
- package/src/hw/connectAppEventMapper.ts +364 -0
- package/src/hw/connectManager.ts +116 -74
- package/src/hw/connectManagerEventMapper.ts +109 -0
- package/src/market/hooks/useLargeMoverChartData.ts +38 -0
- package/src/market/hooks/useLargeMoverCurrencies.ts +36 -0
- package/src/notifications/AnnouncementProvider/index.tsx +21 -17
- package/src/notifications/AnnouncementProvider/machine.ts +9 -8
- package/src/notifications/ServiceStatusProvider/index.tsx +11 -8
- package/src/notifications/ServiceStatusProvider/machine.ts +4 -4
- package/src/wallet-api/ModularDrawer/types.ts +45 -0
- package/src/wallet-api/ModularDrawer/utils.ts +37 -0
- package/src/wallet-api/react.ts +37 -31
- package/lib/index.d.ts +0 -2
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/market/hooks/useLargeMoverDataProvider.d.ts +0 -17
- package/lib/market/hooks/useLargeMoverDataProvider.d.ts.map +0 -1
- package/lib/market/hooks/useLargeMoverDataProvider.js +0 -48
- package/lib/market/hooks/useLargeMoverDataProvider.js.map +0 -1
- package/lib-es/index.d.ts +0 -1
- package/lib-es/index.d.ts.map +0 -1
- package/lib-es/index.js +0 -2
- package/lib-es/index.js.map +0 -1
- package/lib-es/market/hooks/useLargeMoverDataProvider.d.ts +0 -17
- package/lib-es/market/hooks/useLargeMoverDataProvider.d.ts.map +0 -1
- package/lib-es/market/hooks/useLargeMoverDataProvider.js +0 -44
- package/lib-es/market/hooks/useLargeMoverDataProvider.js.map +0 -1
- package/src/index.ts +0 -0
- package/src/market/hooks/useLargeMoverDataProvider.ts +0 -70
@@ -0,0 +1,38 @@
|
|
1
|
+
import { useQueries } from "@tanstack/react-query";
|
2
|
+
import { fetchCurrencyChartData } from "../api";
|
3
|
+
import { QUERY_KEY } from "../utils/queryKeys";
|
4
|
+
import { REFETCH_TIME_ONE_MINUTE, BASIC_REFETCH } from "../utils/timers";
|
5
|
+
import { MarketCoinDataChart } from "../utils/types";
|
6
|
+
|
7
|
+
type UseLargeMoverChartDataParams = {
|
8
|
+
ids: string[];
|
9
|
+
counterCurrency: string;
|
10
|
+
range: string;
|
11
|
+
};
|
12
|
+
|
13
|
+
export const useLargeMoverChartData = ({
|
14
|
+
ids,
|
15
|
+
counterCurrency,
|
16
|
+
range,
|
17
|
+
}: UseLargeMoverChartDataParams) => {
|
18
|
+
const chartQueries = useQueries({
|
19
|
+
queries: ids.map(id => ({
|
20
|
+
queryKey: [QUERY_KEY.CurrencyChartData, id, counterCurrency, range],
|
21
|
+
queryFn: () => fetchCurrencyChartData({ id, counterCurrency, range }),
|
22
|
+
refetchInterval: REFETCH_TIME_ONE_MINUTE * BASIC_REFETCH,
|
23
|
+
staleTime: REFETCH_TIME_ONE_MINUTE * BASIC_REFETCH,
|
24
|
+
})),
|
25
|
+
});
|
26
|
+
|
27
|
+
const loadingChart = chartQueries.some(query => query.isLoading);
|
28
|
+
const errorChart = chartQueries.every(query => query.isError);
|
29
|
+
|
30
|
+
const chartDataArray = ids.map((id, index) => ({
|
31
|
+
idChartData: id,
|
32
|
+
chartData: chartQueries[index]?.data as MarketCoinDataChart | undefined,
|
33
|
+
isLoading: chartQueries[index]?.isLoading || false,
|
34
|
+
isError: chartQueries[index]?.isError || false,
|
35
|
+
}));
|
36
|
+
|
37
|
+
return { chartDataArray, loadingChart, errorChart };
|
38
|
+
};
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import { useQueries } from "@tanstack/react-query";
|
2
|
+
import { fetchCurrency } from "../api";
|
3
|
+
import { QUERY_KEY } from "../utils/queryKeys";
|
4
|
+
import { REFETCH_TIME_ONE_MINUTE, BASIC_REFETCH } from "../utils/timers";
|
5
|
+
import { MarketItemResponse, CurrencyData } from "../utils/types";
|
6
|
+
import { format } from "../utils/currencyFormatter";
|
7
|
+
import { listCryptoCurrencies } from "@ledgerhq/cryptoassets/currencies";
|
8
|
+
|
9
|
+
const cryptoCurrenciesList = [...listCryptoCurrencies()];
|
10
|
+
|
11
|
+
type UseLargeMoverCurrenciesParams = {
|
12
|
+
ids: string[];
|
13
|
+
counterCurrency: string;
|
14
|
+
};
|
15
|
+
|
16
|
+
export const useLargeMoverCurrencies = ({
|
17
|
+
ids,
|
18
|
+
counterCurrency,
|
19
|
+
}: UseLargeMoverCurrenciesParams) => {
|
20
|
+
const currencyQueries = useQueries({
|
21
|
+
queries: ids.map(id => ({
|
22
|
+
queryKey: [QUERY_KEY.CurrencyDataRaw, id, counterCurrency],
|
23
|
+
queryFn: () => fetchCurrency({ id, counterCurrency }),
|
24
|
+
refetchInterval: REFETCH_TIME_ONE_MINUTE * BASIC_REFETCH,
|
25
|
+
staleTime: REFETCH_TIME_ONE_MINUTE * BASIC_REFETCH,
|
26
|
+
select: (data: MarketItemResponse) => format(data, cryptoCurrenciesList),
|
27
|
+
})),
|
28
|
+
});
|
29
|
+
|
30
|
+
return ids.map((id, index) => ({
|
31
|
+
id,
|
32
|
+
data: currencyQueries[index]?.data as CurrencyData | undefined,
|
33
|
+
isLoading: currencyQueries[index]?.isLoading || false,
|
34
|
+
isError: currencyQueries[index]?.isError || false,
|
35
|
+
}));
|
36
|
+
};
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import React, { createContext, useMemo, useCallback, useContext, ReactElement } from "react";
|
2
2
|
import differenceBy from "lodash/differenceBy";
|
3
|
+
import { fromPromise } from "xstate";
|
3
4
|
import { useMachine } from "@xstate/react";
|
4
5
|
import type { Announcement, AnnouncementsUserSettings, State, AnnouncementsApi } from "./types";
|
5
6
|
import { localizeAnnouncements, filterAnnouncements } from "./logic";
|
@@ -55,7 +56,8 @@ export const AnnouncementProvider = ({
|
|
55
56
|
fetchApi = defaultFetchApi,
|
56
57
|
}: Props): ReactElement => {
|
57
58
|
const fetchData = useCallback(
|
58
|
-
async ({ allIds
|
59
|
+
async (arg0: { input: { allIds: string[]; cache: Record<string, Announcement> } }) => {
|
60
|
+
const { allIds, cache } = arg0.input;
|
59
61
|
const rawAnnouncements = await fetchApi.fetchAnnouncements();
|
60
62
|
const localizedAnnouncements = localizeAnnouncements(rawAnnouncements, context);
|
61
63
|
const announcements = filterAnnouncements(localizedAnnouncements, context);
|
@@ -80,9 +82,9 @@ export const AnnouncementProvider = ({
|
|
80
82
|
[context, onNewAnnouncement, fetchApi],
|
81
83
|
);
|
82
84
|
const emitNewAnnouncement = useCallback(
|
83
|
-
({
|
85
|
+
({ context }) => {
|
84
86
|
if (onAnnouncementRead) {
|
85
|
-
onAnnouncementRead(cache[seenId]);
|
87
|
+
onAnnouncementRead(context.cache[context.seenId]);
|
86
88
|
}
|
87
89
|
},
|
88
90
|
[onAnnouncementRead],
|
@@ -96,7 +98,7 @@ export const AnnouncementProvider = ({
|
|
96
98
|
};
|
97
99
|
}, [handleLoad]);
|
98
100
|
const saveData = useCallback(
|
99
|
-
context => {
|
101
|
+
({ context }) => {
|
100
102
|
const { cache, lastUpdateTime, seenIds, allIds } = context;
|
101
103
|
const announcements = allIds.map((id: string) => cache[id]);
|
102
104
|
handleSave({
|
@@ -107,19 +109,21 @@ export const AnnouncementProvider = ({
|
|
107
109
|
},
|
108
110
|
[handleSave],
|
109
111
|
);
|
110
|
-
const [state, send] = useMachine(
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
112
|
+
const [state, send] = useMachine(
|
113
|
+
announcementMachine.provide({
|
114
|
+
actions: {
|
115
|
+
saveData,
|
116
|
+
emitNewAnnouncement,
|
117
|
+
},
|
118
|
+
actors: {
|
119
|
+
loadData: fromPromise(loadData),
|
120
|
+
fetchData: fromPromise(fetchData),
|
121
|
+
},
|
122
|
+
delays: {
|
123
|
+
AUTO_UPDATE_DELAY: autoUpdateDelay,
|
124
|
+
},
|
125
|
+
}),
|
126
|
+
);
|
123
127
|
const api = useMemo(
|
124
128
|
() => ({
|
125
129
|
updateCache: async () => {
|
@@ -20,8 +20,8 @@ export const announcementMachine = createMachine(
|
|
20
20
|
src: "loadData",
|
21
21
|
onDone: {
|
22
22
|
target: "updating",
|
23
|
-
actions: assign((
|
24
|
-
const { announcements, seenIds, lastUpdateTime } =
|
23
|
+
actions: assign(({ event }) => {
|
24
|
+
const { announcements, seenIds, lastUpdateTime } = event.output;
|
25
25
|
const cache = {};
|
26
26
|
announcements.forEach(announcement => {
|
27
27
|
cache[announcement.uuid] = announcement;
|
@@ -56,11 +56,12 @@ export const announcementMachine = createMachine(
|
|
56
56
|
updating: {
|
57
57
|
invoke: {
|
58
58
|
src: "fetchData",
|
59
|
+
input: ({ context }) => ({ allIds: context.allIds, cache: context.cache }),
|
59
60
|
onDone: {
|
60
61
|
target: "idle",
|
61
62
|
actions: [
|
62
|
-
assign((context
|
63
|
-
const { announcements, updateTime } =
|
63
|
+
assign(({ context, event }) => {
|
64
|
+
const { announcements, updateTime } = event.output;
|
64
65
|
const cache = {};
|
65
66
|
announcements.forEach(announcement => {
|
66
67
|
cache[announcement.uuid] = announcement;
|
@@ -80,8 +81,8 @@ export const announcementMachine = createMachine(
|
|
80
81
|
},
|
81
82
|
onError: {
|
82
83
|
target: "idle",
|
83
|
-
actions: assign((
|
84
|
-
error:
|
84
|
+
actions: assign(({ event }) => ({
|
85
|
+
error: event.error as Error,
|
85
86
|
})),
|
86
87
|
},
|
87
88
|
},
|
@@ -89,14 +90,14 @@ export const announcementMachine = createMachine(
|
|
89
90
|
},
|
90
91
|
on: {
|
91
92
|
SET_AS_SEEN: {
|
92
|
-
|
93
|
+
guard: ({ context, event }) => !context.seenIds.includes(event.seenId),
|
93
94
|
actions: ["setAsSeen", "saveData", "emitNewAnnouncement"],
|
94
95
|
},
|
95
96
|
},
|
96
97
|
},
|
97
98
|
{
|
98
99
|
actions: {
|
99
|
-
setAsSeen: assign((context
|
100
|
+
setAsSeen: assign(({ context, event }) => ({
|
100
101
|
seenIds: [...context.seenIds, event.seenId],
|
101
102
|
})),
|
102
103
|
},
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import React, { createContext, useContext, useMemo, useCallback, ReactElement } from "react";
|
2
2
|
import type { State, ServiceStatusUserSettings, Incident, ServiceStatusApi } from "./types";
|
3
3
|
import defaultNetworkApi from "./api";
|
4
|
+
import { fromPromise } from "xstate";
|
4
5
|
import { useMachine } from "@xstate/react";
|
5
6
|
import { serviceStatusMachine } from "./machine";
|
6
7
|
type Props = {
|
@@ -74,14 +75,16 @@ export const ServiceStatusProvider = ({
|
|
74
75
|
};
|
75
76
|
}, [networkApi]);
|
76
77
|
|
77
|
-
const [state, send] = useMachine(
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
78
|
+
const [state, send] = useMachine(
|
79
|
+
serviceStatusMachine.provide({
|
80
|
+
actors: {
|
81
|
+
fetchData: fromPromise(fetchData),
|
82
|
+
},
|
83
|
+
delays: {
|
84
|
+
AUTO_UPDATE_DELAY: autoUpdateDelay,
|
85
|
+
},
|
86
|
+
}),
|
87
|
+
);
|
85
88
|
const api = useMemo(
|
86
89
|
() => ({
|
87
90
|
updateData: async () => {
|
@@ -33,8 +33,8 @@ export const serviceStatusMachine = createMachine({
|
|
33
33
|
src: "fetchData",
|
34
34
|
onDone: {
|
35
35
|
target: "idle",
|
36
|
-
actions: assign((
|
37
|
-
const { incidents, updateTime } =
|
36
|
+
actions: assign(({ event }) => {
|
37
|
+
const { incidents, updateTime } = event.output;
|
38
38
|
return {
|
39
39
|
incidents,
|
40
40
|
lastUpdateTime: updateTime,
|
@@ -45,8 +45,8 @@ export const serviceStatusMachine = createMachine({
|
|
45
45
|
},
|
46
46
|
onError: {
|
47
47
|
target: "idle",
|
48
|
-
actions: assign((
|
49
|
-
error:
|
48
|
+
actions: assign(({ event }) => ({
|
49
|
+
error: event.error as Error,
|
50
50
|
})),
|
51
51
|
},
|
52
52
|
},
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import { z } from "zod";
|
2
|
+
|
3
|
+
export type ModularDrawerConfiguration = {
|
4
|
+
assets?: {
|
5
|
+
filter?: string;
|
6
|
+
leftElement?: string;
|
7
|
+
rightElement?: string;
|
8
|
+
};
|
9
|
+
networks?: {
|
10
|
+
rightElement?: string;
|
11
|
+
leftElement?: string;
|
12
|
+
};
|
13
|
+
};
|
14
|
+
|
15
|
+
const filterOptions = ["topNetworks"] as const;
|
16
|
+
const assetsLeftElementOptions = ["apy", "priceVariation"] as const;
|
17
|
+
const assetsRightElementOptions = ["balance", "marketTrend"] as const;
|
18
|
+
const networksLeftElementOptions = ["numberOfAccounts", "numberOfAccountsAndApy"] as const;
|
19
|
+
const networksRightElementOptions = ["balance"] as const;
|
20
|
+
|
21
|
+
export const EnhancedModularDrawerConfigurationSchema = z.object({
|
22
|
+
assets: z
|
23
|
+
.object({
|
24
|
+
filter: z.enum(filterOptions).optional(),
|
25
|
+
leftElement: z.enum(assetsLeftElementOptions).optional(),
|
26
|
+
rightElement: z.enum(assetsRightElementOptions).optional(),
|
27
|
+
})
|
28
|
+
.optional(),
|
29
|
+
networks: z
|
30
|
+
.object({
|
31
|
+
leftElement: z.enum(networksLeftElementOptions).optional(),
|
32
|
+
rightElement: z.enum(networksRightElementOptions).optional(),
|
33
|
+
})
|
34
|
+
.optional(),
|
35
|
+
});
|
36
|
+
|
37
|
+
/**
|
38
|
+
* Enhanced configuration for the modular drawer.
|
39
|
+
* Extends the base configuration by allowing customization of `assets` and `networks` properties.
|
40
|
+
*/
|
41
|
+
export type EnhancedModularDrawerConfiguration = Omit<
|
42
|
+
ModularDrawerConfiguration,
|
43
|
+
"assets" | "networks"
|
44
|
+
> &
|
45
|
+
z.infer<typeof EnhancedModularDrawerConfigurationSchema>;
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import {
|
2
|
+
type EnhancedModularDrawerConfiguration,
|
3
|
+
type ModularDrawerConfiguration,
|
4
|
+
EnhancedModularDrawerConfigurationSchema,
|
5
|
+
} from "./types";
|
6
|
+
|
7
|
+
export const defaultDrawerConfiguration: EnhancedModularDrawerConfiguration = {
|
8
|
+
assets: {
|
9
|
+
rightElement: "balance",
|
10
|
+
},
|
11
|
+
networks: {
|
12
|
+
leftElement: "numberOfAccounts",
|
13
|
+
},
|
14
|
+
};
|
15
|
+
|
16
|
+
export function validateAndTransformConfigurationWithZod(
|
17
|
+
config?: ModularDrawerConfiguration | EnhancedModularDrawerConfiguration,
|
18
|
+
): EnhancedModularDrawerConfiguration {
|
19
|
+
const result = EnhancedModularDrawerConfigurationSchema.safeParse(config);
|
20
|
+
|
21
|
+
if (!result.success) {
|
22
|
+
console.warn("Modulare Drawer invalid configuration received:", result.error);
|
23
|
+
return {};
|
24
|
+
}
|
25
|
+
|
26
|
+
return result.data;
|
27
|
+
}
|
28
|
+
|
29
|
+
export function createModularDrawerConfiguration(
|
30
|
+
config?: ModularDrawerConfiguration | EnhancedModularDrawerConfiguration,
|
31
|
+
): EnhancedModularDrawerConfiguration {
|
32
|
+
const validatedConfig = validateAndTransformConfigurationWithZod(config);
|
33
|
+
return {
|
34
|
+
...defaultDrawerConfiguration,
|
35
|
+
...validatedConfig,
|
36
|
+
} satisfies EnhancedModularDrawerConfiguration;
|
37
|
+
}
|
package/src/wallet-api/react.ts
CHANGED
@@ -52,6 +52,7 @@ import {
|
|
52
52
|
import { DiscoverDB } from "./types";
|
53
53
|
import { LiveAppManifest } from "../platform/types";
|
54
54
|
import { WalletState } from "@ledgerhq/live-wallet/store";
|
55
|
+
import { ModularDrawerConfiguration } from "./ModularDrawer/types";
|
55
56
|
|
56
57
|
export function safeGetRefValue<T>(ref: RefObject<T>): NonNullable<T> {
|
57
58
|
if (!ref.current) {
|
@@ -129,6 +130,7 @@ export interface UiHook {
|
|
129
130
|
"account.request": (params: {
|
130
131
|
accounts$?: Observable<WalletAPIAccount[]>;
|
131
132
|
currencies: CryptoOrTokenCurrency[];
|
133
|
+
drawerConfiguration?: ModularDrawerConfiguration;
|
132
134
|
onSuccess: (account: AccountLike, parentAccount: Account | undefined) => void;
|
133
135
|
onCancel: () => void;
|
134
136
|
}) => void;
|
@@ -354,39 +356,43 @@ export function useWalletAPIServer({
|
|
354
356
|
useEffect(() => {
|
355
357
|
if (!uiAccountRequest) return;
|
356
358
|
|
357
|
-
server.setHandler(
|
358
|
-
|
359
|
-
|
359
|
+
server.setHandler(
|
360
|
+
"account.request",
|
361
|
+
async ({ accounts$, currencies$, drawerConfiguration }) => {
|
362
|
+
tracking.requestAccountRequested(manifest);
|
363
|
+
const currencies = await firstValueFrom(currencies$);
|
364
|
+
|
365
|
+
return new Promise((resolve, reject) => {
|
366
|
+
// handle no curencies selected case
|
367
|
+
const currencyList = currencies.reduce<CryptoOrTokenCurrency[]>((prev, { id }) => {
|
368
|
+
const currency = findCryptoCurrencyById(id) || findTokenById(id);
|
369
|
+
if (currency) {
|
370
|
+
prev.push(currency);
|
371
|
+
}
|
372
|
+
return prev;
|
373
|
+
}, []);
|
360
374
|
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
resolve(accountToWalletAPIAccount(walletState, account, parentAccount));
|
380
|
-
},
|
381
|
-
onCancel: () => {
|
382
|
-
if (done) return;
|
383
|
-
done = true;
|
384
|
-
tracking.requestAccountFail(manifest);
|
385
|
-
reject(new Error("Canceled by user"));
|
386
|
-
},
|
375
|
+
let done = false;
|
376
|
+
uiAccountRequest({
|
377
|
+
accounts$,
|
378
|
+
currencies: currencyList,
|
379
|
+
drawerConfiguration,
|
380
|
+
onSuccess: (account: AccountLike, parentAccount: Account | undefined) => {
|
381
|
+
if (done) return;
|
382
|
+
done = true;
|
383
|
+
tracking.requestAccountSuccess(manifest);
|
384
|
+
resolve(accountToWalletAPIAccount(walletState, account, parentAccount));
|
385
|
+
},
|
386
|
+
onCancel: () => {
|
387
|
+
if (done) return;
|
388
|
+
done = true;
|
389
|
+
tracking.requestAccountFail(manifest);
|
390
|
+
reject(new Error("Canceled by user"));
|
391
|
+
},
|
392
|
+
});
|
387
393
|
});
|
388
|
-
}
|
389
|
-
|
394
|
+
},
|
395
|
+
);
|
390
396
|
}, [walletState, manifest, server, tracking, uiAccountRequest]);
|
391
397
|
|
392
398
|
useEffect(() => {
|
package/lib/index.d.ts
DELETED
package/lib/index.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/lib/index.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import { CurrencyData, MarketCoinDataChart } from "../utils/types";
|
2
|
-
type UseLargeMoverDataProviderParams = {
|
3
|
-
ids: string[];
|
4
|
-
counterCurrency: string;
|
5
|
-
range: string;
|
6
|
-
};
|
7
|
-
export declare const useLargeMoverDataProvider: ({ ids, counterCurrency, range, }: UseLargeMoverDataProviderParams) => {
|
8
|
-
currencies: {
|
9
|
-
id: string;
|
10
|
-
data?: CurrencyData;
|
11
|
-
chartData?: MarketCoinDataChart;
|
12
|
-
isLoading: boolean;
|
13
|
-
isError: boolean;
|
14
|
-
}[];
|
15
|
-
};
|
16
|
-
export {};
|
17
|
-
//# sourceMappingURL=useLargeMoverDataProvider.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useLargeMoverDataProvider.d.ts","sourceRoot":"","sources":["../../../src/market/hooks/useLargeMoverDataProvider.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAsB,MAAM,gBAAgB,CAAC;AAMvF,KAAK,+BAA+B,GAAG;IACrC,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAMF,eAAO,MAAM,yBAAyB,qCAInC,+BAA+B;gBACpB;QACV,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,CAAC,EAAE,YAAY,CAAC;QACpB,SAAS,CAAC,EAAE,mBAAmB,CAAC;QAChC,SAAS,EAAE,OAAO,CAAC;QACnB,OAAO,EAAE,OAAO,CAAC;KAClB,EAAE;CAsCJ,CAAC"}
|
@@ -1,48 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.useLargeMoverDataProvider = void 0;
|
4
|
-
const react_query_1 = require("@tanstack/react-query");
|
5
|
-
const api_1 = require("../api");
|
6
|
-
const queryKeys_1 = require("../utils/queryKeys");
|
7
|
-
const timers_1 = require("../utils/timers");
|
8
|
-
const currencyFormatter_1 = require("../utils/currencyFormatter");
|
9
|
-
const currencies_1 = require("@ledgerhq/cryptoassets/currencies");
|
10
|
-
const cryptoCurrenciesList = [...(0, currencies_1.listCryptoCurrencies)()];
|
11
|
-
function mapIdsToQueries(ids, queries) {
|
12
|
-
return Object.fromEntries(ids.map((id, index) => [id, queries[index]]));
|
13
|
-
}
|
14
|
-
const useLargeMoverDataProvider = ({ ids, counterCurrency, range, }) => {
|
15
|
-
const currencyQueries = (0, react_query_1.useQueries)({
|
16
|
-
queries: ids.map(id => ({
|
17
|
-
queryKey: [queryKeys_1.QUERY_KEY.CurrencyDataRaw, id, counterCurrency],
|
18
|
-
queryFn: () => (0, api_1.fetchCurrency)({ id, counterCurrency }),
|
19
|
-
refetchInterval: timers_1.REFETCH_TIME_ONE_MINUTE * timers_1.BASIC_REFETCH,
|
20
|
-
staleTime: timers_1.REFETCH_TIME_ONE_MINUTE * timers_1.BASIC_REFETCH,
|
21
|
-
select: (data) => (0, currencyFormatter_1.format)(data, cryptoCurrenciesList),
|
22
|
-
})),
|
23
|
-
});
|
24
|
-
const chartQueries = (0, react_query_1.useQueries)({
|
25
|
-
queries: ids.map(id => ({
|
26
|
-
queryKey: [queryKeys_1.QUERY_KEY.CurrencyChartData, id, counterCurrency, range],
|
27
|
-
queryFn: () => (0, api_1.fetchCurrencyChartData)({ id, counterCurrency, range }),
|
28
|
-
refetchInterval: timers_1.REFETCH_TIME_ONE_MINUTE * timers_1.BASIC_REFETCH,
|
29
|
-
staleTime: timers_1.REFETCH_TIME_ONE_MINUTE * timers_1.BASIC_REFETCH,
|
30
|
-
})),
|
31
|
-
});
|
32
|
-
const currencyQueryMap = mapIdsToQueries(ids, currencyQueries);
|
33
|
-
const chartQueryMap = mapIdsToQueries(ids, chartQueries);
|
34
|
-
const currencies = ids.map(id => {
|
35
|
-
const currencyQuery = currencyQueryMap[id];
|
36
|
-
const chartQuery = chartQueryMap[id];
|
37
|
-
return {
|
38
|
-
id,
|
39
|
-
data: currencyQuery?.data,
|
40
|
-
chartData: chartQuery?.data,
|
41
|
-
isLoading: currencyQuery?.isLoading || chartQuery?.isLoading || false,
|
42
|
-
isError: currencyQuery?.isError || chartQuery?.isError || false,
|
43
|
-
};
|
44
|
-
});
|
45
|
-
return { currencies };
|
46
|
-
};
|
47
|
-
exports.useLargeMoverDataProvider = useLargeMoverDataProvider;
|
48
|
-
//# sourceMappingURL=useLargeMoverDataProvider.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useLargeMoverDataProvider.js","sourceRoot":"","sources":["../../../src/market/hooks/useLargeMoverDataProvider.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AACnD,gCAA+D;AAC/D,kDAA+C;AAC/C,4CAAyE;AAEzE,kEAAoD;AACpD,kEAAyE;AAEzE,MAAM,oBAAoB,GAAG,CAAC,GAAG,IAAA,iCAAoB,GAAE,CAAC,CAAC;AAQzD,SAAS,eAAe,CAAI,GAAa,EAAE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GAAG,EAAE,eAAe,CAAC,CAAC;IAC/D,MAAM,aAAa,GAAG,eAAe,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IAEzD,MAAM,UAAU,GAAG,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;QAC9B,MAAM,aAAa,GAAG,gBAAgB,CAAC,EAAE,CAAC,CAAC;QAC3C,MAAM,UAAU,GAAG,aAAa,CAAC,EAAE,CAAC,CAAC;QAErC,OAAO;YACL,EAAE;YACF,IAAI,EAAE,aAAa,EAAE,IAAI;YACzB,SAAS,EAAE,UAAU,EAAE,IAAI;YAC3B,SAAS,EAAE,aAAa,EAAE,SAAS,IAAI,UAAU,EAAE,SAAS,IAAI,KAAK;YACrE,OAAO,EAAE,aAAa,EAAE,OAAO,IAAI,UAAU,EAAE,OAAO,IAAI,KAAK;SAChE,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,UAAU,EAAE,CAAC;AACxB,CAAC,CAAC;AAjDW,QAAA,yBAAyB,6BAiDpC"}
|
package/lib-es/index.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
//# sourceMappingURL=index.d.ts.map
|
package/lib-es/index.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/lib-es/index.js
DELETED
package/lib-es/index.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import { CurrencyData, MarketCoinDataChart } from "../utils/types";
|
2
|
-
type UseLargeMoverDataProviderParams = {
|
3
|
-
ids: string[];
|
4
|
-
counterCurrency: string;
|
5
|
-
range: string;
|
6
|
-
};
|
7
|
-
export declare const useLargeMoverDataProvider: ({ ids, counterCurrency, range, }: UseLargeMoverDataProviderParams) => {
|
8
|
-
currencies: {
|
9
|
-
id: string;
|
10
|
-
data?: CurrencyData;
|
11
|
-
chartData?: MarketCoinDataChart;
|
12
|
-
isLoading: boolean;
|
13
|
-
isError: boolean;
|
14
|
-
}[];
|
15
|
-
};
|
16
|
-
export {};
|
17
|
-
//# sourceMappingURL=useLargeMoverDataProvider.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useLargeMoverDataProvider.d.ts","sourceRoot":"","sources":["../../../src/market/hooks/useLargeMoverDataProvider.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAsB,MAAM,gBAAgB,CAAC;AAMvF,KAAK,+BAA+B,GAAG;IACrC,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAMF,eAAO,MAAM,yBAAyB,qCAInC,+BAA+B;gBACpB;QACV,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,CAAC,EAAE,YAAY,CAAC;QACpB,SAAS,CAAC,EAAE,mBAAmB,CAAC;QAChC,SAAS,EAAE,OAAO,CAAC;QACnB,OAAO,EAAE,OAAO,CAAC;KAClB,EAAE;CAsCJ,CAAC"}
|
@@ -1,44 +0,0 @@
|
|
1
|
-
import { useQueries } from "@tanstack/react-query";
|
2
|
-
import { fetchCurrency, fetchCurrencyChartData } from "../api";
|
3
|
-
import { QUERY_KEY } from "../utils/queryKeys";
|
4
|
-
import { REFETCH_TIME_ONE_MINUTE, BASIC_REFETCH } from "../utils/timers";
|
5
|
-
import { format } from "../utils/currencyFormatter";
|
6
|
-
import { listCryptoCurrencies } from "@ledgerhq/cryptoassets/currencies";
|
7
|
-
const cryptoCurrenciesList = [...listCryptoCurrencies()];
|
8
|
-
function mapIdsToQueries(ids, queries) {
|
9
|
-
return Object.fromEntries(ids.map((id, index) => [id, queries[index]]));
|
10
|
-
}
|
11
|
-
export const useLargeMoverDataProvider = ({ ids, counterCurrency, range, }) => {
|
12
|
-
const currencyQueries = useQueries({
|
13
|
-
queries: ids.map(id => ({
|
14
|
-
queryKey: [QUERY_KEY.CurrencyDataRaw, id, counterCurrency],
|
15
|
-
queryFn: () => fetchCurrency({ id, counterCurrency }),
|
16
|
-
refetchInterval: REFETCH_TIME_ONE_MINUTE * BASIC_REFETCH,
|
17
|
-
staleTime: REFETCH_TIME_ONE_MINUTE * BASIC_REFETCH,
|
18
|
-
select: (data) => format(data, cryptoCurrenciesList),
|
19
|
-
})),
|
20
|
-
});
|
21
|
-
const chartQueries = useQueries({
|
22
|
-
queries: ids.map(id => ({
|
23
|
-
queryKey: [QUERY_KEY.CurrencyChartData, id, counterCurrency, range],
|
24
|
-
queryFn: () => fetchCurrencyChartData({ id, counterCurrency, range }),
|
25
|
-
refetchInterval: REFETCH_TIME_ONE_MINUTE * BASIC_REFETCH,
|
26
|
-
staleTime: REFETCH_TIME_ONE_MINUTE * BASIC_REFETCH,
|
27
|
-
})),
|
28
|
-
});
|
29
|
-
const currencyQueryMap = mapIdsToQueries(ids, currencyQueries);
|
30
|
-
const chartQueryMap = mapIdsToQueries(ids, chartQueries);
|
31
|
-
const currencies = ids.map(id => {
|
32
|
-
const currencyQuery = currencyQueryMap[id];
|
33
|
-
const chartQuery = chartQueryMap[id];
|
34
|
-
return {
|
35
|
-
id,
|
36
|
-
data: currencyQuery?.data,
|
37
|
-
chartData: chartQuery?.data,
|
38
|
-
isLoading: currencyQuery?.isLoading || chartQuery?.isLoading || false,
|
39
|
-
isError: currencyQuery?.isError || chartQuery?.isError || false,
|
40
|
-
};
|
41
|
-
});
|
42
|
-
return { currencies };
|
43
|
-
};
|
44
|
-
//# sourceMappingURL=useLargeMoverDataProvider.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useLargeMoverDataProvider.js","sourceRoot":"","sources":["../../../src/market/hooks/useLargeMoverDataProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAA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