@ledgerhq/live-common 34.48.0-nightly.0 → 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/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +2 -2
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js +1 -1
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
- package/lib/bridge/generic-alpaca/signOperation.js +1 -1
- package/lib/bridge/generic-alpaca/signOperation.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 +4 -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/__test__/useModularDrawerConfiguration.test.d.ts +2 -0
- package/lib/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.js +206 -0
- package/lib/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.js.map +1 -0
- 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/useModularDrawerConfiguration.d.ts +13 -0
- package/lib/modularDrawer/hooks/useModularDrawerConfiguration.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/useModularDrawerConfiguration.js +29 -0
- package/lib/modularDrawer/hooks/useModularDrawerConfiguration.js.map +1 -0
- 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/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +2 -2
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/signOperation.js +1 -1
- package/lib-es/bridge/generic-alpaca/signOperation.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 +4 -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/__test__/useModularDrawerConfiguration.test.d.ts +2 -0
- package/lib-es/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.js +204 -0
- package/lib-es/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.js.map +1 -0
- 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/useModularDrawerConfiguration.d.ts +13 -0
- package/lib-es/modularDrawer/hooks/useModularDrawerConfiguration.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/useModularDrawerConfiguration.js +25 -0
- package/lib-es/modularDrawer/hooks/useModularDrawerConfiguration.js.map +1 -0
- 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/bridge/generic-alpaca/alpaca/network/network-alpaca.ts +4 -3
- package/src/bridge/generic-alpaca/signOperation.ts +1 -1
- 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/__test__/useModularDrawerConfiguration.test.ts +251 -0
- package/src/modularDrawer/hooks/useAssetsData.ts +3 -2
- package/src/modularDrawer/hooks/useModularDrawerConfiguration.ts +33 -0
- 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
@@ -0,0 +1,251 @@
|
|
1
|
+
/**
|
2
|
+
* @jest-environment jsdom
|
3
|
+
*/
|
4
|
+
import { renderHook } from "@testing-library/react";
|
5
|
+
import { useFeature } from "../../../featureFlags";
|
6
|
+
import { EnhancedModularDrawerConfiguration } from "../../../wallet-api/ModularDrawer/types";
|
7
|
+
import { useModularDrawerConfiguration } from "../useModularDrawerConfiguration";
|
8
|
+
|
9
|
+
jest.mock("../../../featureFlags", () => ({ useFeature: jest.fn() }));
|
10
|
+
|
11
|
+
const mockUseFeature = jest.mocked(useFeature);
|
12
|
+
|
13
|
+
describe("useModularDrawerConfiguration", () => {
|
14
|
+
beforeEach(() => {
|
15
|
+
jest.clearAllMocks();
|
16
|
+
});
|
17
|
+
|
18
|
+
describe("when modularization is disabled", () => {
|
19
|
+
beforeEach(() => {
|
20
|
+
mockUseFeature.mockReturnValue({
|
21
|
+
enabled: true,
|
22
|
+
params: {
|
23
|
+
enableModularization: false,
|
24
|
+
},
|
25
|
+
});
|
26
|
+
});
|
27
|
+
|
28
|
+
it("should return disabled configurations when no drawer configuration is provided", () => {
|
29
|
+
const { result } = renderHook(() => useModularDrawerConfiguration("lldModularDrawer"));
|
30
|
+
|
31
|
+
expect(result.current.assetsConfiguration).toEqual({
|
32
|
+
rightElement: "undefined",
|
33
|
+
leftElement: "undefined",
|
34
|
+
filter: "undefined",
|
35
|
+
});
|
36
|
+
expect(result.current.networkConfiguration).toEqual({
|
37
|
+
rightElement: "undefined",
|
38
|
+
leftElement: "undefined",
|
39
|
+
});
|
40
|
+
});
|
41
|
+
|
42
|
+
it("should return disabled configurations even when drawer configuration is provided", () => {
|
43
|
+
const drawerConfiguration: EnhancedModularDrawerConfiguration = {
|
44
|
+
assets: {
|
45
|
+
rightElement: "balance",
|
46
|
+
leftElement: "apy",
|
47
|
+
filter: "topNetworks",
|
48
|
+
},
|
49
|
+
networks: {
|
50
|
+
rightElement: "balance",
|
51
|
+
leftElement: "numberOfAccounts",
|
52
|
+
},
|
53
|
+
};
|
54
|
+
|
55
|
+
const { result } = renderHook(() =>
|
56
|
+
useModularDrawerConfiguration("lldModularDrawer", drawerConfiguration),
|
57
|
+
);
|
58
|
+
|
59
|
+
expect(result.current.assetsConfiguration).toEqual({
|
60
|
+
rightElement: "undefined",
|
61
|
+
leftElement: "undefined",
|
62
|
+
filter: "undefined",
|
63
|
+
});
|
64
|
+
expect(result.current.networkConfiguration).toEqual({
|
65
|
+
rightElement: "undefined",
|
66
|
+
leftElement: "undefined",
|
67
|
+
});
|
68
|
+
});
|
69
|
+
});
|
70
|
+
|
71
|
+
describe("when modularization is enabled", () => {
|
72
|
+
beforeEach(() => {
|
73
|
+
mockUseFeature.mockReturnValue({
|
74
|
+
enabled: true,
|
75
|
+
params: {
|
76
|
+
enableModularization: true,
|
77
|
+
},
|
78
|
+
});
|
79
|
+
});
|
80
|
+
|
81
|
+
it("should return undefined configurations when no drawer configuration is provided", () => {
|
82
|
+
const { result } = renderHook(() => useModularDrawerConfiguration("lldModularDrawer"));
|
83
|
+
|
84
|
+
expect(result.current.assetsConfiguration).toBeUndefined();
|
85
|
+
expect(result.current.networkConfiguration).toBeUndefined();
|
86
|
+
});
|
87
|
+
|
88
|
+
it("should return the provided drawer configuration when modularization is enabled", () => {
|
89
|
+
const drawerConfiguration: EnhancedModularDrawerConfiguration = {
|
90
|
+
assets: {
|
91
|
+
rightElement: "balance",
|
92
|
+
leftElement: "apy",
|
93
|
+
filter: "topNetworks",
|
94
|
+
},
|
95
|
+
networks: {
|
96
|
+
rightElement: "balance",
|
97
|
+
leftElement: "numberOfAccounts",
|
98
|
+
},
|
99
|
+
};
|
100
|
+
|
101
|
+
const { result } = renderHook(() =>
|
102
|
+
useModularDrawerConfiguration("lldModularDrawer", drawerConfiguration),
|
103
|
+
);
|
104
|
+
|
105
|
+
expect(result.current.assetsConfiguration).toEqual(drawerConfiguration.assets);
|
106
|
+
expect(result.current.networkConfiguration).toEqual(drawerConfiguration.networks);
|
107
|
+
});
|
108
|
+
|
109
|
+
it("should handle partial drawer configuration", () => {
|
110
|
+
const drawerConfiguration: EnhancedModularDrawerConfiguration = {
|
111
|
+
assets: {
|
112
|
+
rightElement: "balance",
|
113
|
+
leftElement: "marketTrend",
|
114
|
+
filter: "topNetworks",
|
115
|
+
},
|
116
|
+
};
|
117
|
+
|
118
|
+
const { result } = renderHook(() =>
|
119
|
+
useModularDrawerConfiguration("lldModularDrawer", drawerConfiguration),
|
120
|
+
);
|
121
|
+
|
122
|
+
expect(result.current.assetsConfiguration).toEqual(drawerConfiguration.assets);
|
123
|
+
expect(result.current.networkConfiguration).toBeUndefined();
|
124
|
+
});
|
125
|
+
|
126
|
+
it("should handle configuration with undefined values", () => {
|
127
|
+
const drawerConfiguration: EnhancedModularDrawerConfiguration = {
|
128
|
+
assets: undefined,
|
129
|
+
networks: {
|
130
|
+
rightElement: "balance",
|
131
|
+
leftElement: "numberOfAccountsAndApy",
|
132
|
+
},
|
133
|
+
};
|
134
|
+
|
135
|
+
const { result } = renderHook(() =>
|
136
|
+
useModularDrawerConfiguration("lldModularDrawer", drawerConfiguration),
|
137
|
+
);
|
138
|
+
|
139
|
+
expect(result.current.assetsConfiguration).toBeUndefined();
|
140
|
+
expect(result.current.networkConfiguration).toEqual(drawerConfiguration.networks);
|
141
|
+
});
|
142
|
+
});
|
143
|
+
|
144
|
+
describe("when feature flag is not available", () => {
|
145
|
+
beforeEach(() => {
|
146
|
+
mockUseFeature.mockReturnValue(null);
|
147
|
+
});
|
148
|
+
|
149
|
+
it("should default to disabled configuration when feature flag returns null", () => {
|
150
|
+
const drawerConfiguration: EnhancedModularDrawerConfiguration = {
|
151
|
+
assets: {
|
152
|
+
rightElement: "balance",
|
153
|
+
leftElement: "apy",
|
154
|
+
filter: "topNetworks",
|
155
|
+
},
|
156
|
+
networks: {
|
157
|
+
rightElement: "balance",
|
158
|
+
leftElement: "numberOfAccounts",
|
159
|
+
},
|
160
|
+
};
|
161
|
+
|
162
|
+
const { result } = renderHook(() =>
|
163
|
+
useModularDrawerConfiguration("lldModularDrawer", drawerConfiguration),
|
164
|
+
);
|
165
|
+
|
166
|
+
expect(result.current.assetsConfiguration).toEqual({
|
167
|
+
rightElement: "undefined",
|
168
|
+
leftElement: "undefined",
|
169
|
+
filter: "undefined",
|
170
|
+
});
|
171
|
+
expect(result.current.networkConfiguration).toEqual({
|
172
|
+
rightElement: "undefined",
|
173
|
+
leftElement: "undefined",
|
174
|
+
});
|
175
|
+
});
|
176
|
+
});
|
177
|
+
|
178
|
+
describe("when feature flag params are not available", () => {
|
179
|
+
beforeEach(() => {
|
180
|
+
mockUseFeature.mockReturnValue({
|
181
|
+
enabled: true,
|
182
|
+
params: undefined,
|
183
|
+
});
|
184
|
+
});
|
185
|
+
|
186
|
+
it("should default to disabled configuration when params are undefined", () => {
|
187
|
+
const drawerConfiguration: EnhancedModularDrawerConfiguration = {
|
188
|
+
assets: {
|
189
|
+
rightElement: "balance",
|
190
|
+
leftElement: "apy",
|
191
|
+
filter: "topNetworks",
|
192
|
+
},
|
193
|
+
networks: {
|
194
|
+
rightElement: "balance",
|
195
|
+
leftElement: "numberOfAccounts",
|
196
|
+
},
|
197
|
+
};
|
198
|
+
|
199
|
+
const { result } = renderHook(() =>
|
200
|
+
useModularDrawerConfiguration("lldModularDrawer", drawerConfiguration),
|
201
|
+
);
|
202
|
+
|
203
|
+
expect(result.current.assetsConfiguration).toEqual({
|
204
|
+
rightElement: "undefined",
|
205
|
+
leftElement: "undefined",
|
206
|
+
filter: "undefined",
|
207
|
+
});
|
208
|
+
expect(result.current.networkConfiguration).toEqual({
|
209
|
+
rightElement: "undefined",
|
210
|
+
leftElement: "undefined",
|
211
|
+
});
|
212
|
+
});
|
213
|
+
});
|
214
|
+
|
215
|
+
describe("when enableModularization param is not available", () => {
|
216
|
+
beforeEach(() => {
|
217
|
+
mockUseFeature.mockReturnValue({
|
218
|
+
enabled: true,
|
219
|
+
params: {},
|
220
|
+
});
|
221
|
+
});
|
222
|
+
|
223
|
+
it("should default to disabled configuration when enableModularization is not in params", () => {
|
224
|
+
const drawerConfiguration: EnhancedModularDrawerConfiguration = {
|
225
|
+
assets: {
|
226
|
+
rightElement: "balance",
|
227
|
+
leftElement: "apy",
|
228
|
+
filter: "topNetworks",
|
229
|
+
},
|
230
|
+
networks: {
|
231
|
+
rightElement: "balance",
|
232
|
+
leftElement: "numberOfAccounts",
|
233
|
+
},
|
234
|
+
};
|
235
|
+
|
236
|
+
const { result } = renderHook(() =>
|
237
|
+
useModularDrawerConfiguration("lldModularDrawer", drawerConfiguration),
|
238
|
+
);
|
239
|
+
|
240
|
+
expect(result.current.assetsConfiguration).toEqual({
|
241
|
+
rightElement: "undefined",
|
242
|
+
leftElement: "undefined",
|
243
|
+
filter: "undefined",
|
244
|
+
});
|
245
|
+
expect(result.current.networkConfiguration).toEqual({
|
246
|
+
rightElement: "undefined",
|
247
|
+
leftElement: "undefined",
|
248
|
+
});
|
249
|
+
});
|
250
|
+
});
|
251
|
+
});
|
@@ -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,33 @@
|
|
1
|
+
import { useFeature } from "../../featureFlags";
|
2
|
+
import { EnhancedModularDrawerConfiguration } from "../../wallet-api/ModularDrawer/types";
|
3
|
+
|
4
|
+
const assetConfigurationDisabled: EnhancedModularDrawerConfiguration["assets"] = {
|
5
|
+
rightElement: "undefined",
|
6
|
+
leftElement: "undefined",
|
7
|
+
filter: "undefined",
|
8
|
+
};
|
9
|
+
|
10
|
+
const networkConfigurationDisabled: EnhancedModularDrawerConfiguration["networks"] = {
|
11
|
+
rightElement: "undefined",
|
12
|
+
leftElement: "undefined",
|
13
|
+
};
|
14
|
+
|
15
|
+
export const useModularDrawerConfiguration = (
|
16
|
+
featureFlagKey: "lldModularDrawer" | "llmModularDrawer",
|
17
|
+
drawerConfiguration?: EnhancedModularDrawerConfiguration,
|
18
|
+
) => {
|
19
|
+
const featureModularDrawer = useFeature(featureFlagKey);
|
20
|
+
|
21
|
+
const modularizationEnabled = featureModularDrawer?.params?.enableModularization ?? false;
|
22
|
+
const assetsConfiguration = modularizationEnabled
|
23
|
+
? drawerConfiguration?.assets
|
24
|
+
: assetConfigurationDisabled;
|
25
|
+
const networkConfiguration = modularizationEnabled
|
26
|
+
? drawerConfiguration?.networks
|
27
|
+
: networkConfigurationDisabled;
|
28
|
+
|
29
|
+
return {
|
30
|
+
assetsConfiguration,
|
31
|
+
networkConfiguration,
|
32
|
+
};
|
33
|
+
};
|
@@ -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;
|