@ledgerhq/live-common 34.48.0-nightly.1 → 34.48.0-nightly.2
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/bridge/crypto-assets/index.d.ts.map +1 -1
- package/lib/bridge/crypto-assets/index.js +0 -4
- package/lib/bridge/crypto-assets/index.js.map +1 -1
- package/lib/bridge/crypto-assets/index.test.js +0 -36
- package/lib/bridge/crypto-assets/index.test.js.map +1 -1
- package/lib/config/sharedConfig.d.ts.map +1 -1
- package/lib/config/sharedConfig.js +2 -0
- package/lib/config/sharedConfig.js.map +1 -1
- package/lib/e2e/index.d.ts +3 -4
- package/lib/e2e/index.d.ts.map +1 -1
- package/lib/env.react.d.ts +1 -1
- package/lib/env.react.d.ts.map +1 -1
- package/lib/families/canton/bridge/mock-data.d.ts +6 -0
- package/lib/families/canton/bridge/mock-data.d.ts.map +1 -0
- package/lib/families/canton/bridge/mock-data.js +120 -0
- package/lib/families/canton/bridge/mock-data.js.map +1 -0
- package/lib/families/canton/bridge/mock.d.ts +12 -0
- package/lib/families/canton/bridge/mock.d.ts.map +1 -0
- package/lib/families/canton/bridge/mock.js +154 -0
- package/lib/families/canton/bridge/mock.js.map +1 -0
- package/lib/families/canton/config.d.ts.map +1 -1
- package/lib/families/canton/config.js +5 -2
- package/lib/families/canton/config.js.map +1 -1
- package/lib/families/canton/setup.d.ts.map +1 -1
- package/lib/families/canton/setup.js +8 -2
- package/lib/families/canton/setup.js.map +1 -1
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +0 -1
- 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/generated/bridge/mock.d.ts +8 -0
- package/lib/generated/bridge/mock.d.ts.map +1 -1
- package/lib/generated/bridge/mock.js +26 -24
- package/lib/generated/bridge/mock.js.map +1 -1
- package/lib/modularDrawer/hooks/useAssetsData.d.ts +1 -0
- package/lib/modularDrawer/hooks/useAssetsData.d.ts.map +1 -1
- package/lib/modularDrawer/hooks/useAssetsData.js +3 -2
- package/lib/modularDrawer/hooks/useAssetsData.js.map +1 -1
- package/lib/modularDrawer/hooks/useSearch.d.ts +16 -0
- package/lib/modularDrawer/hooks/useSearch.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/useSearch.js +24 -0
- package/lib/modularDrawer/hooks/useSearch.js.map +1 -0
- package/lib/notifications/ServiceStatusProvider/index.d.ts +16 -1
- package/lib/notifications/ServiceStatusProvider/index.d.ts.map +1 -1
- package/lib/notifications/ServiceStatusProvider/index.js +31 -7
- package/lib/notifications/ServiceStatusProvider/index.js.map +1 -1
- package/lib/notifications/ServiceStatusProvider/index.test.d.ts +2 -0
- package/lib/notifications/ServiceStatusProvider/index.test.d.ts.map +1 -0
- package/lib/notifications/ServiceStatusProvider/index.test.js +88 -0
- package/lib/notifications/ServiceStatusProvider/index.test.js.map +1 -0
- package/lib/notifications/ServiceStatusProvider/ledger-components.d.ts +2 -0
- package/lib/notifications/ServiceStatusProvider/ledger-components.d.ts.map +1 -0
- package/lib/notifications/ServiceStatusProvider/ledger-components.js +16 -0
- package/lib/notifications/ServiceStatusProvider/ledger-components.js.map +1 -0
- package/lib/wallet-api/ACRE/server.d.ts +13 -6
- package/lib/wallet-api/ACRE/server.d.ts.map +1 -1
- package/lib/wallet-api/ACRE/server.js +142 -1
- package/lib/wallet-api/ACRE/server.js.map +1 -1
- package/lib/wallet-api/ACRE/server.test.d.ts +2 -0
- package/lib/wallet-api/ACRE/server.test.d.ts.map +1 -0
- package/lib/wallet-api/ACRE/server.test.js +393 -0
- package/lib/wallet-api/ACRE/server.test.js.map +1 -0
- package/lib-es/bridge/crypto-assets/index.d.ts.map +1 -1
- package/lib-es/bridge/crypto-assets/index.js +0 -4
- package/lib-es/bridge/crypto-assets/index.js.map +1 -1
- package/lib-es/bridge/crypto-assets/index.test.js +0 -36
- package/lib-es/bridge/crypto-assets/index.test.js.map +1 -1
- package/lib-es/config/sharedConfig.d.ts.map +1 -1
- package/lib-es/config/sharedConfig.js +2 -0
- package/lib-es/config/sharedConfig.js.map +1 -1
- package/lib-es/e2e/index.d.ts +3 -4
- package/lib-es/e2e/index.d.ts.map +1 -1
- package/lib-es/env.react.d.ts +1 -1
- package/lib-es/env.react.d.ts.map +1 -1
- package/lib-es/families/canton/bridge/mock-data.d.ts +6 -0
- package/lib-es/families/canton/bridge/mock-data.d.ts.map +1 -0
- package/lib-es/families/canton/bridge/mock-data.js +116 -0
- package/lib-es/families/canton/bridge/mock-data.js.map +1 -0
- package/lib-es/families/canton/bridge/mock.d.ts +12 -0
- package/lib-es/families/canton/bridge/mock.d.ts.map +1 -0
- package/lib-es/families/canton/bridge/mock.js +152 -0
- package/lib-es/families/canton/bridge/mock.js.map +1 -0
- package/lib-es/families/canton/config.d.ts.map +1 -1
- package/lib-es/families/canton/config.js +5 -2
- package/lib-es/families/canton/config.js.map +1 -1
- package/lib-es/families/canton/setup.d.ts.map +1 -1
- package/lib-es/families/canton/setup.js +8 -2
- package/lib-es/families/canton/setup.js.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.js +0 -1
- 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/generated/bridge/mock.d.ts +8 -0
- package/lib-es/generated/bridge/mock.d.ts.map +1 -1
- package/lib-es/generated/bridge/mock.js +2 -0
- package/lib-es/generated/bridge/mock.js.map +1 -1
- package/lib-es/modularDrawer/hooks/useAssetsData.d.ts +1 -0
- package/lib-es/modularDrawer/hooks/useAssetsData.d.ts.map +1 -1
- package/lib-es/modularDrawer/hooks/useAssetsData.js +3 -2
- package/lib-es/modularDrawer/hooks/useAssetsData.js.map +1 -1
- package/lib-es/modularDrawer/hooks/useSearch.d.ts +16 -0
- package/lib-es/modularDrawer/hooks/useSearch.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/useSearch.js +20 -0
- package/lib-es/modularDrawer/hooks/useSearch.js.map +1 -0
- package/lib-es/notifications/ServiceStatusProvider/index.d.ts +16 -1
- package/lib-es/notifications/ServiceStatusProvider/index.d.ts.map +1 -1
- package/lib-es/notifications/ServiceStatusProvider/index.js +31 -7
- package/lib-es/notifications/ServiceStatusProvider/index.js.map +1 -1
- package/lib-es/notifications/ServiceStatusProvider/index.test.d.ts +2 -0
- package/lib-es/notifications/ServiceStatusProvider/index.test.d.ts.map +1 -0
- package/lib-es/notifications/ServiceStatusProvider/index.test.js +86 -0
- package/lib-es/notifications/ServiceStatusProvider/index.test.js.map +1 -0
- package/lib-es/notifications/ServiceStatusProvider/ledger-components.d.ts +2 -0
- package/lib-es/notifications/ServiceStatusProvider/ledger-components.d.ts.map +1 -0
- package/lib-es/notifications/ServiceStatusProvider/ledger-components.js +13 -0
- package/lib-es/notifications/ServiceStatusProvider/ledger-components.js.map +1 -0
- package/lib-es/wallet-api/ACRE/server.d.ts +13 -6
- package/lib-es/wallet-api/ACRE/server.d.ts.map +1 -1
- package/lib-es/wallet-api/ACRE/server.js +140 -2
- package/lib-es/wallet-api/ACRE/server.js.map +1 -1
- package/lib-es/wallet-api/ACRE/server.test.d.ts +2 -0
- package/lib-es/wallet-api/ACRE/server.test.d.ts.map +1 -0
- package/lib-es/wallet-api/ACRE/server.test.js +388 -0
- package/lib-es/wallet-api/ACRE/server.test.js.map +1 -0
- package/package.json +48 -48
- package/src/bridge/crypto-assets/index.test.ts +0 -47
- package/src/bridge/crypto-assets/index.ts +0 -5
- package/src/config/sharedConfig.ts +2 -0
- package/src/families/canton/bridge/mock-data.ts +175 -0
- package/src/families/canton/bridge/mock.ts +180 -0
- package/src/families/canton/config.ts +5 -3
- package/src/families/canton/setup.ts +8 -5
- package/src/featureFlags/defaultFeatures.ts +0 -1
- package/src/generated/bridge/mock.ts +2 -0
- package/src/modularDrawer/hooks/useAssetsData.ts +3 -2
- package/src/modularDrawer/hooks/useSearch.ts +52 -0
- package/src/notifications/ServiceStatusProvider/index.test.ts +102 -0
- package/src/notifications/ServiceStatusProvider/index.tsx +37 -12
- package/src/notifications/ServiceStatusProvider/ledger-components.ts +12 -0
- package/src/wallet-api/ACRE/server.test.ts +470 -0
- package/src/wallet-api/ACRE/server.ts +202 -14
- package/lib/bridge/crypto-assets/cal-integration.d.ts +0 -4
- package/lib/bridge/crypto-assets/cal-integration.d.ts.map +0 -1
- package/lib/bridge/crypto-assets/cal-integration.js +0 -26
- package/lib/bridge/crypto-assets/cal-integration.js.map +0 -1
- package/lib/bridge/crypto-assets/cal-integration.test.d.ts +0 -2
- package/lib/bridge/crypto-assets/cal-integration.test.d.ts.map +0 -1
- package/lib/bridge/crypto-assets/cal-integration.test.js +0 -45
- package/lib/bridge/crypto-assets/cal-integration.test.js.map +0 -1
- package/lib/bridge/crypto-assets/cal-store.d.ts +0 -14
- package/lib/bridge/crypto-assets/cal-store.d.ts.map +0 -1
- package/lib/bridge/crypto-assets/cal-store.js +0 -58
- package/lib/bridge/crypto-assets/cal-store.js.map +0 -1
- package/lib/bridge/crypto-assets/cal-store.test.d.ts +0 -2
- package/lib/bridge/crypto-assets/cal-store.test.d.ts.map +0 -1
- package/lib/bridge/crypto-assets/cal-store.test.js +0 -70
- package/lib/bridge/crypto-assets/cal-store.test.js.map +0 -1
- package/lib-es/bridge/crypto-assets/cal-integration.d.ts +0 -4
- package/lib-es/bridge/crypto-assets/cal-integration.d.ts.map +0 -1
- package/lib-es/bridge/crypto-assets/cal-integration.js +0 -21
- package/lib-es/bridge/crypto-assets/cal-integration.js.map +0 -1
- package/lib-es/bridge/crypto-assets/cal-integration.test.d.ts +0 -2
- package/lib-es/bridge/crypto-assets/cal-integration.test.d.ts.map +0 -1
- package/lib-es/bridge/crypto-assets/cal-integration.test.js +0 -43
- package/lib-es/bridge/crypto-assets/cal-integration.test.js.map +0 -1
- package/lib-es/bridge/crypto-assets/cal-store.d.ts +0 -14
- package/lib-es/bridge/crypto-assets/cal-store.d.ts.map +0 -1
- package/lib-es/bridge/crypto-assets/cal-store.js +0 -54
- package/lib-es/bridge/crypto-assets/cal-store.js.map +0 -1
- package/lib-es/bridge/crypto-assets/cal-store.test.d.ts +0 -2
- package/lib-es/bridge/crypto-assets/cal-store.test.d.ts.map +0 -1
- package/lib-es/bridge/crypto-assets/cal-store.test.js +0 -68
- package/lib-es/bridge/crypto-assets/cal-store.test.js.map +0 -1
- package/src/bridge/crypto-assets/cal-integration.test.ts +0 -53
- package/src/bridge/crypto-assets/cal-integration.ts +0 -23
- package/src/bridge/crypto-assets/cal-store.test.ts +0 -93
- package/src/bridge/crypto-assets/cal-store.ts +0 -63
@@ -32,7 +32,7 @@ export function useAssetsData({
|
|
32
32
|
product: "llm" | "lld";
|
33
33
|
version: string;
|
34
34
|
}) {
|
35
|
-
const { data, isLoading, error, fetchNextPage, isSuccess, refetch } =
|
35
|
+
const { data, isLoading, error, fetchNextPage, isSuccess, refetch, isFetching, isError } =
|
36
36
|
useGetAssetsDataInfiniteQuery({
|
37
37
|
search,
|
38
38
|
useCase,
|
@@ -64,10 +64,11 @@ export function useAssetsData({
|
|
64
64
|
|
65
65
|
return {
|
66
66
|
data: joinedPages,
|
67
|
-
isLoading,
|
67
|
+
isLoading: isLoading || isFetching,
|
68
68
|
error,
|
69
69
|
loadNext: hasMore ? fetchNextPage : undefined,
|
70
70
|
isSuccess,
|
71
|
+
isError,
|
71
72
|
refetch,
|
72
73
|
};
|
73
74
|
}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import { ChangeEvent, useCallback, useState } from "react";
|
2
|
+
|
3
|
+
export type UseSearchParams = {
|
4
|
+
/** Initial value to display in the search input */
|
5
|
+
initialValue?: string;
|
6
|
+
/** Persist the search value to the host app state (e.g., Redux) */
|
7
|
+
onPersistSearchValue?: (value: string) => void;
|
8
|
+
/** Track analytics when the debounced value changes and should be emitted */
|
9
|
+
onTrackSearch?: (query: string) => void;
|
10
|
+
};
|
11
|
+
|
12
|
+
export type UseSearchResult = {
|
13
|
+
handleSearch: (queryOrEvent: string | ChangeEvent<HTMLInputElement>) => void;
|
14
|
+
handleDebouncedChange: (current: string, previous: string) => void;
|
15
|
+
displayedValue: string | undefined;
|
16
|
+
};
|
17
|
+
|
18
|
+
const normalize = (value: string) => value.trim();
|
19
|
+
|
20
|
+
export function useSearchCommon({
|
21
|
+
initialValue,
|
22
|
+
onPersistSearchValue,
|
23
|
+
onTrackSearch,
|
24
|
+
}: UseSearchParams): UseSearchResult {
|
25
|
+
const [displayedValue, setDisplayedValue] = useState<string | undefined>(initialValue);
|
26
|
+
|
27
|
+
const handleSearch = useCallback((queryOrEvent: string | ChangeEvent<HTMLInputElement>) => {
|
28
|
+
const nextValue = typeof queryOrEvent === "string" ? queryOrEvent : queryOrEvent.target.value;
|
29
|
+
setDisplayedValue(nextValue);
|
30
|
+
}, []);
|
31
|
+
|
32
|
+
const shouldEmitEvent = useCallback(
|
33
|
+
(currentQuery: string, previousQuery: string) =>
|
34
|
+
currentQuery !== "" && currentQuery !== previousQuery,
|
35
|
+
[],
|
36
|
+
);
|
37
|
+
const handleDebouncedChange = useCallback(
|
38
|
+
(current: string, previous: string) => {
|
39
|
+
const currentQuery = normalize(current);
|
40
|
+
const previousQuery = normalize(previous);
|
41
|
+
|
42
|
+
onPersistSearchValue?.(currentQuery);
|
43
|
+
|
44
|
+
if (!shouldEmitEvent(currentQuery, previousQuery)) return;
|
45
|
+
|
46
|
+
onTrackSearch?.(currentQuery);
|
47
|
+
},
|
48
|
+
[onPersistSearchValue, onTrackSearch, shouldEmitEvent],
|
49
|
+
);
|
50
|
+
|
51
|
+
return { handleSearch, handleDebouncedChange, displayedValue };
|
52
|
+
}
|
@@ -0,0 +1,102 @@
|
|
1
|
+
import { filterServiceStatusIncidents } from "./index";
|
2
|
+
import { LEDGER_COMPONENTS } from "./ledger-components";
|
3
|
+
import type { Incident } from "./types";
|
4
|
+
|
5
|
+
const makeIncident = (overrides: Partial<Incident> = {}): Incident => ({
|
6
|
+
created_at: "2025-01-01T00:00:00Z",
|
7
|
+
id: Math.random().toString(16).slice(2),
|
8
|
+
impact: "minor",
|
9
|
+
incident_updates: [],
|
10
|
+
monitoring_at: null,
|
11
|
+
name: "Test incident",
|
12
|
+
page_id: null,
|
13
|
+
resolved_at: null,
|
14
|
+
shortlink: null,
|
15
|
+
status: "investigating",
|
16
|
+
updated_at: null,
|
17
|
+
...overrides,
|
18
|
+
});
|
19
|
+
|
20
|
+
describe("filterServiceStatusIncidents", () => {
|
21
|
+
it("returns empty when no tickers or no incidents", () => {
|
22
|
+
expect(filterServiceStatusIncidents([], ["BTC"]).length).toBe(0);
|
23
|
+
expect(filterServiceStatusIncidents([makeIncident()], []).length).toBe(0);
|
24
|
+
});
|
25
|
+
|
26
|
+
it("matches incidents with known Ledger components (case-insensitive)", () => {
|
27
|
+
const incidents: Incident[] = [
|
28
|
+
makeIncident({ components: [{ id: "1", name: "Ledger Application Store" }] }),
|
29
|
+
makeIncident({ components: [{ id: "2", name: "ledger appliCAtion store" }] }),
|
30
|
+
makeIncident({ components: [{ id: "3", name: "Unknown Component" }] }),
|
31
|
+
];
|
32
|
+
|
33
|
+
const result = filterServiceStatusIncidents(incidents, ["BTC"]);
|
34
|
+
expect(result.map(i => i.components?.[0].id)).toEqual(["1", "2"]);
|
35
|
+
});
|
36
|
+
|
37
|
+
it("matches incidents if a component contains a tracked ticker as a whole word (case-insensitive)", () => {
|
38
|
+
const incidents: Incident[] = [
|
39
|
+
makeIncident({ components: [{ id: "1", name: "BTC Node" }] }),
|
40
|
+
makeIncident({ components: [{ id: "2", name: "eth Node" }] }),
|
41
|
+
makeIncident({ components: [{ id: "3", name: "TETHER Service" }] }),
|
42
|
+
makeIncident({ components: [{ id: "4", name: "NOTBTCService" }] }),
|
43
|
+
];
|
44
|
+
|
45
|
+
const result = filterServiceStatusIncidents(incidents, ["BTC", "ETH"]);
|
46
|
+
expect(result.map(i => i.components?.[0].id)).toEqual(["1", "2"]);
|
47
|
+
});
|
48
|
+
|
49
|
+
it("includes incidents with no components array or empty array", () => {
|
50
|
+
const incidents: Incident[] = [
|
51
|
+
makeIncident({ components: undefined }),
|
52
|
+
makeIncident({ components: [] }),
|
53
|
+
];
|
54
|
+
|
55
|
+
const result = filterServiceStatusIncidents(incidents, ["BTC"]);
|
56
|
+
expect(result.length).toBe(2);
|
57
|
+
});
|
58
|
+
|
59
|
+
it("escapes tickers so special regex characters do not break matching", () => {
|
60
|
+
const incidents: Incident[] = [
|
61
|
+
makeIncident({ components: [{ id: "1", name: "USDT Node" }] }),
|
62
|
+
makeIncident({ components: [{ id: "2", name: "US.DT Node" }] }),
|
63
|
+
makeIncident({ components: [{ id: "3", name: "(USDT) Node" }] }),
|
64
|
+
makeIncident({ components: [{ id: "4", name: "Ethereum Node" }] }),
|
65
|
+
makeIncident({ components: [{ id: "5", name: "Ethereum (ETH) swap issue" }] }),
|
66
|
+
];
|
67
|
+
|
68
|
+
const result = filterServiceStatusIncidents(incidents, ["USDT", "ETH"]);
|
69
|
+
expect(result.map(i => i.components?.[0].id)).toEqual(["1", "3", "5"]);
|
70
|
+
expect(result.length).toBe(3);
|
71
|
+
});
|
72
|
+
|
73
|
+
it("matches incidents for all known Ledger components", () => {
|
74
|
+
const incidents: Incident[] = LEDGER_COMPONENTS.map((name, index) =>
|
75
|
+
makeIncident({ components: [{ id: `${index + 1}`, name }] }),
|
76
|
+
);
|
77
|
+
|
78
|
+
const result = filterServiceStatusIncidents(incidents, ["BTC"]);
|
79
|
+
expect(result.length).toBe(LEDGER_COMPONENTS.length);
|
80
|
+
});
|
81
|
+
|
82
|
+
it("filters correctly with common tickers", () => {
|
83
|
+
const tickers = ["XRP", "SOL", "ETH", "BTC", "ADA", "USDC", "USDT"];
|
84
|
+
const incidents: Incident[] = [
|
85
|
+
makeIncident({ components: [{ id: "1", name: "BTC Node" }] }),
|
86
|
+
makeIncident({ components: [{ id: "2", name: "eth Node" }] }),
|
87
|
+
makeIncident({ components: [{ id: "3", name: "ADA-Service" }] }),
|
88
|
+
makeIncident({ components: [{ id: "4", name: "usdc gateway" }] }),
|
89
|
+
makeIncident({ components: [{ id: "5", name: "NOTUSDTService" }] }),
|
90
|
+
makeIncident({ components: [{ id: "6", name: "USDT" }] }),
|
91
|
+
makeIncident({ components: [{ id: "7", name: "xrp relayer" }] }),
|
92
|
+
makeIncident({ components: [{ id: "8", name: "SOL Node" }] }),
|
93
|
+
makeIncident({ components: [{ id: "9", name: "SOLANA Node" }] }),
|
94
|
+
makeIncident({ components: [{ id: "10", name: "Random Service" }] }),
|
95
|
+
makeIncident({ components: [] }),
|
96
|
+
];
|
97
|
+
|
98
|
+
const result = filterServiceStatusIncidents(incidents, tickers);
|
99
|
+
expect(result.map(i => i.components?.[0]?.id)).toEqual(["1", "2", "3", "4", "6", "7", "8"]);
|
100
|
+
expect(result.length).toBe(8);
|
101
|
+
});
|
102
|
+
});
|
@@ -4,6 +4,7 @@ import defaultNetworkApi from "./api";
|
|
4
4
|
import { fromPromise } from "xstate";
|
5
5
|
import { useMachine } from "@xstate/react";
|
6
6
|
import { serviceStatusMachine } from "./machine";
|
7
|
+
import { LEDGER_COMPONENTS } from "./ledger-components";
|
7
8
|
type Props = {
|
8
9
|
children: React.ReactNode;
|
9
10
|
autoUpdateDelay: number;
|
@@ -33,27 +34,51 @@ function escapeRegExp(string) {
|
|
33
34
|
return string.replace(/[.*+?^${}()[\]\\]/g, "\\$&"); // $& means the whole matched string
|
34
35
|
}
|
35
36
|
|
37
|
+
function sanitizeName(name: string): string {
|
38
|
+
return name.toLowerCase().trim().replace(/\s+/g, " "); // collapse multiple spaces
|
39
|
+
}
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Filters service status incidents based on related tickers or Ledger components.
|
43
|
+
*
|
44
|
+
* ## Behavior:
|
45
|
+
* - If there are no `tickers` or no `incidents`, returns an empty list.
|
46
|
+
* - For each incident:
|
47
|
+
* 1. ✅ If the incident has no components → keep it (always relevant).
|
48
|
+
* 2. ✅ If at least one component name matches a known **Ledger component** → keep it.
|
49
|
+
* 3. ✅ If at least one component name contains a **currency ticker** → keep it.
|
50
|
+
* 4. ❌ Otherwise, the incident is discarded.
|
51
|
+
*
|
52
|
+
* @param {Incident[]} [incidents=[]] - List of incidents to filter.
|
53
|
+
* @param {string[]} [tickers=[]] - List of currency tickers to match against incident components.
|
54
|
+
* @returns {Incident[]} The list of incidents relevant to the provided tickers or Ledger components.
|
55
|
+
*/
|
56
|
+
|
36
57
|
export function filterServiceStatusIncidents(
|
37
|
-
incidents: Incident[],
|
58
|
+
incidents: Incident[] = [],
|
38
59
|
tickers: string[] = [],
|
39
60
|
): Incident[] {
|
40
|
-
if (!tickers
|
41
|
-
|
42
|
-
}
|
43
|
-
|
44
|
-
const
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
61
|
+
if (!tickers.length || !incidents.length) return [];
|
62
|
+
|
63
|
+
const tickerRegex = new RegExp(`\\b(${tickers.map(escapeRegExp).join("|")})\\b`, "i");
|
64
|
+
|
65
|
+
const ledgerComponentsSet = new Set(LEDGER_COMPONENTS.map(component => sanitizeName(component)));
|
66
|
+
|
67
|
+
return incidents.filter(({ components }) => {
|
68
|
+
if (!components?.length) return true;
|
69
|
+
|
70
|
+
return components.some(({ name }) => {
|
71
|
+
const sanitizedName = sanitizeName(name);
|
72
|
+
return ledgerComponentsSet.has(sanitizedName) || tickerRegex.test(sanitizedName);
|
73
|
+
});
|
74
|
+
});
|
51
75
|
}
|
52
76
|
|
53
77
|
// filter out service status incidents by given currencies or fallback on context currencies
|
54
78
|
export function useFilteredServiceStatus(filters?: ServiceStatusUserSettings): StatusContextType {
|
55
79
|
const stateData = useContext(ServiceStatusContext);
|
56
80
|
const { incidents, context } = stateData;
|
81
|
+
|
57
82
|
const filteredIncidents = useMemo(() => {
|
58
83
|
return filterServiceStatusIncidents(incidents, filters?.tickers || context?.tickers);
|
59
84
|
}, [incidents, context, filters?.tickers]);
|
@@ -0,0 +1,12 @@
|
|
1
|
+
export const LEDGER_COMPONENTS = [
|
2
|
+
"Ledger Application Store",
|
3
|
+
"Ledger Live Security Services",
|
4
|
+
"Swap API",
|
5
|
+
"Buy",
|
6
|
+
"Earn Dashboard",
|
7
|
+
"Crypto Assets Service",
|
8
|
+
"Cloud Sync",
|
9
|
+
"Trustchain",
|
10
|
+
"Loyalty Program",
|
11
|
+
"Card Program",
|
12
|
+
] as const;
|