@ledgerhq/live-common 34.39.0-nightly.0 → 34.39.0-nightly.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bridge/cache.d.ts.map +1 -1
- package/lib/bridge/cache.js +2 -2
- package/lib/bridge/cache.js.map +1 -1
- package/lib/bridge/cache.test.d.ts +2 -0
- package/lib/bridge/cache.test.d.ts.map +1 -0
- package/lib/bridge/cache.test.js +63 -0
- package/lib/bridge/cache.test.js.map +1 -0
- package/lib/e2e/index.d.ts +3 -0
- 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/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +11 -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/hooks/useAppVersionBlockCheck.d.ts +11 -0
- package/lib/hooks/useAppVersionBlockCheck.d.ts.map +1 -0
- package/lib/hooks/useAppVersionBlockCheck.js +32 -0
- package/lib/hooks/useAppVersionBlockCheck.js.map +1 -0
- package/lib/hooks/useAppVersionBlockCheck.test.d.ts +2 -0
- package/lib/hooks/useAppVersionBlockCheck.test.d.ts.map +1 -0
- package/lib/hooks/useAppVersionBlockCheck.test.js +133 -0
- package/lib/hooks/useAppVersionBlockCheck.test.js.map +1 -0
- package/lib/hw/connectAppEventMapper.d.ts.map +1 -1
- package/lib/hw/connectAppEventMapper.js +3 -1
- package/lib/hw/connectAppEventMapper.js.map +1 -1
- package/lib/modularDrawer/__test__/useModularDrawerVisibility.test.d.ts +2 -0
- package/lib/modularDrawer/__test__/useModularDrawerVisibility.test.d.ts.map +1 -0
- package/lib/modularDrawer/__test__/useModularDrawerVisibility.test.js +107 -0
- package/lib/modularDrawer/__test__/useModularDrawerVisibility.test.js.map +1 -0
- package/lib/modularDrawer/enums.d.ts +8 -0
- package/lib/modularDrawer/enums.d.ts.map +1 -0
- package/lib/modularDrawer/enums.js +12 -0
- package/lib/modularDrawer/enums.js.map +1 -0
- package/lib/modularDrawer/useModularDrawerVisibility.d.ts +9 -0
- package/lib/modularDrawer/useModularDrawerVisibility.d.ts.map +1 -0
- package/lib/modularDrawer/useModularDrawerVisibility.js +18 -0
- package/lib/modularDrawer/useModularDrawerVisibility.js.map +1 -0
- package/lib-es/bridge/cache.d.ts.map +1 -1
- package/lib-es/bridge/cache.js +2 -2
- package/lib-es/bridge/cache.js.map +1 -1
- package/lib-es/bridge/cache.test.d.ts +2 -0
- package/lib-es/bridge/cache.test.d.ts.map +1 -0
- package/lib-es/bridge/cache.test.js +38 -0
- package/lib-es/bridge/cache.test.js.map +1 -0
- package/lib-es/e2e/index.d.ts +3 -0
- 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/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.js +11 -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/hooks/useAppVersionBlockCheck.d.ts +11 -0
- package/lib-es/hooks/useAppVersionBlockCheck.d.ts.map +1 -0
- package/lib-es/hooks/useAppVersionBlockCheck.js +25 -0
- package/lib-es/hooks/useAppVersionBlockCheck.js.map +1 -0
- package/lib-es/hooks/useAppVersionBlockCheck.test.d.ts +2 -0
- package/lib-es/hooks/useAppVersionBlockCheck.test.d.ts.map +1 -0
- package/lib-es/hooks/useAppVersionBlockCheck.test.js +131 -0
- package/lib-es/hooks/useAppVersionBlockCheck.test.js.map +1 -0
- package/lib-es/hw/connectAppEventMapper.d.ts.map +1 -1
- package/lib-es/hw/connectAppEventMapper.js +3 -1
- package/lib-es/hw/connectAppEventMapper.js.map +1 -1
- package/lib-es/modularDrawer/__test__/useModularDrawerVisibility.test.d.ts +2 -0
- package/lib-es/modularDrawer/__test__/useModularDrawerVisibility.test.d.ts.map +1 -0
- package/lib-es/modularDrawer/__test__/useModularDrawerVisibility.test.js +105 -0
- package/lib-es/modularDrawer/__test__/useModularDrawerVisibility.test.js.map +1 -0
- package/lib-es/modularDrawer/enums.d.ts +8 -0
- package/lib-es/modularDrawer/enums.d.ts.map +1 -0
- package/lib-es/modularDrawer/enums.js +9 -0
- package/lib-es/modularDrawer/enums.js.map +1 -0
- package/lib-es/modularDrawer/useModularDrawerVisibility.d.ts +9 -0
- package/lib-es/modularDrawer/useModularDrawerVisibility.d.ts.map +1 -0
- package/lib-es/modularDrawer/useModularDrawerVisibility.js +14 -0
- package/lib-es/modularDrawer/useModularDrawerVisibility.js.map +1 -0
- package/package.json +46 -46
- package/src/bridge/cache.test.ts +46 -0
- package/src/bridge/cache.ts +5 -2
- package/src/featureFlags/defaultFeatures.ts +11 -0
- package/src/hooks/useAppVersionBlockCheck.test.ts +134 -0
- package/src/hooks/useAppVersionBlockCheck.ts +65 -0
- package/src/hw/connectAppEventMapper.ts +3 -1
- package/src/modularDrawer/__test__/useModularDrawerVisibility.test.ts +149 -0
- package/src/modularDrawer/enums.ts +7 -0
- package/src/modularDrawer/useModularDrawerVisibility.ts +25 -0
@@ -0,0 +1,134 @@
|
|
1
|
+
import { useAppVersionBlockCheck } from "./useAppVersionBlockCheck";
|
2
|
+
|
3
|
+
describe("useAppVersionBlockCheck", () => {
|
4
|
+
describe("LLM", () => {
|
5
|
+
it("should update if current version is not compatible on android", () => {
|
6
|
+
// given
|
7
|
+
const getConfigValue = () => ({
|
8
|
+
llm: {
|
9
|
+
android: [
|
10
|
+
{
|
11
|
+
minOsVersion: "32",
|
12
|
+
version: "2.0.3",
|
13
|
+
},
|
14
|
+
],
|
15
|
+
},
|
16
|
+
});
|
17
|
+
// when
|
18
|
+
const { shouldUpdate } = useAppVersionBlockCheck({
|
19
|
+
appVersion: "2.0.1",
|
20
|
+
osVersion: "32",
|
21
|
+
platform: "android",
|
22
|
+
appKey: "llm",
|
23
|
+
getConfigValue,
|
24
|
+
});
|
25
|
+
//then
|
26
|
+
expect(shouldUpdate).toBe(true);
|
27
|
+
});
|
28
|
+
it("should update if current version is not compatible on ios", () => {
|
29
|
+
const getConfigValue = () => ({
|
30
|
+
llm: {
|
31
|
+
ios: [
|
32
|
+
{
|
33
|
+
minOsVersion: "32",
|
34
|
+
version: "2.0.3",
|
35
|
+
},
|
36
|
+
],
|
37
|
+
},
|
38
|
+
});
|
39
|
+
// when
|
40
|
+
const { shouldUpdate } = useAppVersionBlockCheck({
|
41
|
+
appVersion: "2.0.1",
|
42
|
+
osVersion: "32",
|
43
|
+
platform: "ios",
|
44
|
+
appKey: "llm",
|
45
|
+
getConfigValue,
|
46
|
+
});
|
47
|
+
//then
|
48
|
+
expect(shouldUpdate).toBe(true);
|
49
|
+
});
|
50
|
+
it("should not update the app if current version is not compatible on android with another os version", () => {
|
51
|
+
// given
|
52
|
+
const getConfigValue = () => ({
|
53
|
+
llm: {
|
54
|
+
android: [
|
55
|
+
{
|
56
|
+
minOsVersion: "33",
|
57
|
+
version: "2.0.3",
|
58
|
+
},
|
59
|
+
],
|
60
|
+
},
|
61
|
+
});
|
62
|
+
// when
|
63
|
+
const { shouldUpdate } = useAppVersionBlockCheck({
|
64
|
+
appVersion: "2.0.1",
|
65
|
+
osVersion: "32",
|
66
|
+
platform: "android",
|
67
|
+
appKey: "llm",
|
68
|
+
getConfigValue,
|
69
|
+
});
|
70
|
+
//then
|
71
|
+
expect(shouldUpdate).toBe(false);
|
72
|
+
});
|
73
|
+
it("should not update the app if current version is not compatible on ios with another os version", () => {
|
74
|
+
// given
|
75
|
+
const getConfigValue = () => ({
|
76
|
+
llm: {
|
77
|
+
ios: [
|
78
|
+
{
|
79
|
+
minOsVersion: "33",
|
80
|
+
version: "2.0.3",
|
81
|
+
},
|
82
|
+
],
|
83
|
+
},
|
84
|
+
});
|
85
|
+
// when
|
86
|
+
const { shouldUpdate } = useAppVersionBlockCheck({
|
87
|
+
appVersion: "2.0.1",
|
88
|
+
osVersion: "32",
|
89
|
+
platform: "ios",
|
90
|
+
appKey: "llm",
|
91
|
+
getConfigValue,
|
92
|
+
});
|
93
|
+
//then
|
94
|
+
expect(shouldUpdate).toBe(false);
|
95
|
+
});
|
96
|
+
it.each([
|
97
|
+
["android", "2.1.3"],
|
98
|
+
["ios", "2.1.3"],
|
99
|
+
["android", "2.1.3-rc.2"],
|
100
|
+
["ios", "2.1.3-rc.2"],
|
101
|
+
["android", "2.2.3-next.0"],
|
102
|
+
["ios", "2.2.3-next.0"],
|
103
|
+
["android", "2.0.3-rc2"],
|
104
|
+
["ios", "2.0.3-rc2"],
|
105
|
+
["android", "2.0.3-next.3"],
|
106
|
+
["ios", "2.0.3-next.3"],
|
107
|
+
])(
|
108
|
+
"should not update the app on %s for version %s compatible with 2.0.3",
|
109
|
+
(platform, appVersion) => {
|
110
|
+
// given
|
111
|
+
const getConfigValue = () => ({
|
112
|
+
llm: {
|
113
|
+
[platform]: [
|
114
|
+
{
|
115
|
+
minOsVersion: "32",
|
116
|
+
version: "2.0.3",
|
117
|
+
},
|
118
|
+
],
|
119
|
+
},
|
120
|
+
});
|
121
|
+
// when
|
122
|
+
const { shouldUpdate } = useAppVersionBlockCheck({
|
123
|
+
appVersion,
|
124
|
+
osVersion: "32",
|
125
|
+
platform: platform as "ios" | "android",
|
126
|
+
appKey: "llm",
|
127
|
+
getConfigValue,
|
128
|
+
});
|
129
|
+
// then
|
130
|
+
expect(shouldUpdate).toBe(false);
|
131
|
+
},
|
132
|
+
);
|
133
|
+
});
|
134
|
+
});
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import semver from "semver";
|
2
|
+
import { LiveConfig } from "@ledgerhq/live-config/LiveConfig";
|
3
|
+
|
4
|
+
type LLMMinVersionConfig = {
|
5
|
+
minOsVersion: string;
|
6
|
+
version: string;
|
7
|
+
};
|
8
|
+
|
9
|
+
type LLMinVersionConfig = {
|
10
|
+
lld: {
|
11
|
+
windows: string;
|
12
|
+
macOS: string;
|
13
|
+
linux: string;
|
14
|
+
};
|
15
|
+
llm: {
|
16
|
+
android: LLMMinVersionConfig[];
|
17
|
+
ios: LLMMinVersionConfig[];
|
18
|
+
};
|
19
|
+
};
|
20
|
+
|
21
|
+
const checkLLmVersion = (
|
22
|
+
appVersion: string,
|
23
|
+
osVersion: string,
|
24
|
+
platform: "ios" | "android",
|
25
|
+
llmMinVersionConfig: LLMinVersionConfig["llm"],
|
26
|
+
) => {
|
27
|
+
if (!llmMinVersionConfig[platform]) {
|
28
|
+
return false;
|
29
|
+
}
|
30
|
+
|
31
|
+
return llmMinVersionConfig[platform]
|
32
|
+
.filter(minVersionConfig =>
|
33
|
+
semver.satisfies(semver.coerce(osVersion), `>=${minVersionConfig.minOsVersion}`),
|
34
|
+
)
|
35
|
+
.reduce((acc, curr) => {
|
36
|
+
return acc || semver.satisfies(appVersion, `<${curr.version}`);
|
37
|
+
}, false);
|
38
|
+
};
|
39
|
+
|
40
|
+
export const useAppVersionBlockCheck = ({
|
41
|
+
appVersion: uncoercedAppVersion,
|
42
|
+
appKey,
|
43
|
+
platform,
|
44
|
+
osVersion,
|
45
|
+
getConfigValue = LiveConfig.getValueByKey,
|
46
|
+
}: {
|
47
|
+
appVersion: string;
|
48
|
+
osVersion?: string;
|
49
|
+
appKey: "llm" | "lld";
|
50
|
+
platform: "ios" | "android" | "macOS" | "windows" | "linux";
|
51
|
+
getConfigValue?: typeof LiveConfig.getValueByKey;
|
52
|
+
}) => {
|
53
|
+
const llMinVersionConfig = getConfigValue("config_ll_min_version");
|
54
|
+
const appVersion = semver.coerce(uncoercedAppVersion)?.version || "";
|
55
|
+
let shouldUpdate = false;
|
56
|
+
|
57
|
+
if (!llMinVersionConfig) {
|
58
|
+
return { shouldUpdate };
|
59
|
+
}
|
60
|
+
|
61
|
+
if (appKey === "llm" && (platform === "android" || platform === "ios") && osVersion) {
|
62
|
+
shouldUpdate = checkLLmVersion(appVersion, osVersion, platform, llMinVersionConfig[appKey]);
|
63
|
+
}
|
64
|
+
return { shouldUpdate };
|
65
|
+
};
|
@@ -203,7 +203,9 @@ export class ConnectAppEventMapper {
|
|
203
203
|
type: "install",
|
204
204
|
name: installPlan.installPlan[installPlan.currentIndex]!.versionName,
|
205
205
|
},
|
206
|
-
installQueue: installPlan.installPlan
|
206
|
+
installQueue: installPlan.installPlan
|
207
|
+
.map(app => app.versionName)
|
208
|
+
.slice(installPlan.currentIndex),
|
207
209
|
});
|
208
210
|
this.installPlan = installPlan;
|
209
211
|
}
|
@@ -0,0 +1,149 @@
|
|
1
|
+
/**
|
2
|
+
* @jest-environment jsdom
|
3
|
+
*/
|
4
|
+
import { renderHook } from "@testing-library/react";
|
5
|
+
import { useModularDrawerVisibility } from "../useModularDrawerVisibility";
|
6
|
+
import { ModularDrawerLocation } from "../enums";
|
7
|
+
import {
|
8
|
+
makeMockedFeatureFlagsProviderWrapper,
|
9
|
+
makeMockedContextValue,
|
10
|
+
} from "../../featureFlags/mock";
|
11
|
+
|
12
|
+
describe("useModularDrawerVisibility", () => {
|
13
|
+
describe("lldModularDrawer", () => {
|
14
|
+
it("should return false if the feature flag is not enabled", () => {
|
15
|
+
const mockedFeatures = {
|
16
|
+
lldModularDrawer: {
|
17
|
+
enabled: false,
|
18
|
+
params: { [ModularDrawerLocation.ADD_ACCOUNT]: true },
|
19
|
+
},
|
20
|
+
};
|
21
|
+
|
22
|
+
const { result } = renderHook(
|
23
|
+
() =>
|
24
|
+
useModularDrawerVisibility({
|
25
|
+
modularDrawerFeatureFlagKey: "lldModularDrawer",
|
26
|
+
}),
|
27
|
+
{
|
28
|
+
wrapper: makeMockedFeatureFlagsProviderWrapper(makeMockedContextValue(mockedFeatures)),
|
29
|
+
},
|
30
|
+
);
|
31
|
+
|
32
|
+
expect(result.current.isModularDrawerVisible(ModularDrawerLocation.ADD_ACCOUNT)).toBe(false);
|
33
|
+
});
|
34
|
+
|
35
|
+
it("should return false if the location param is not set", () => {
|
36
|
+
const mockedFeatures = {
|
37
|
+
lldModularDrawer: { enabled: true, params: {} },
|
38
|
+
};
|
39
|
+
|
40
|
+
const { result } = renderHook(
|
41
|
+
() =>
|
42
|
+
useModularDrawerVisibility({
|
43
|
+
modularDrawerFeatureFlagKey: "lldModularDrawer",
|
44
|
+
}),
|
45
|
+
{
|
46
|
+
wrapper: makeMockedFeatureFlagsProviderWrapper(makeMockedContextValue(mockedFeatures)),
|
47
|
+
},
|
48
|
+
);
|
49
|
+
|
50
|
+
expect(result.current.isModularDrawerVisible(ModularDrawerLocation.ADD_ACCOUNT)).toBe(false);
|
51
|
+
});
|
52
|
+
|
53
|
+
it("should return the correct visibility for each location", () => {
|
54
|
+
const mockedFeatures = {
|
55
|
+
lldModularDrawer: {
|
56
|
+
enabled: true,
|
57
|
+
params: {
|
58
|
+
[ModularDrawerLocation.ADD_ACCOUNT]: true,
|
59
|
+
[ModularDrawerLocation.EARN_FLOW]: false,
|
60
|
+
},
|
61
|
+
},
|
62
|
+
};
|
63
|
+
|
64
|
+
const { result } = renderHook(
|
65
|
+
() =>
|
66
|
+
useModularDrawerVisibility({
|
67
|
+
modularDrawerFeatureFlagKey: "lldModularDrawer",
|
68
|
+
}),
|
69
|
+
{
|
70
|
+
wrapper: makeMockedFeatureFlagsProviderWrapper(makeMockedContextValue(mockedFeatures)),
|
71
|
+
},
|
72
|
+
);
|
73
|
+
|
74
|
+
expect(result.current.isModularDrawerVisible(ModularDrawerLocation.ADD_ACCOUNT)).toBe(true);
|
75
|
+
expect(result.current.isModularDrawerVisible(ModularDrawerLocation.EARN_FLOW)).toBe(false);
|
76
|
+
expect(result.current.isModularDrawerVisible(ModularDrawerLocation.LIVE_APP)).toBe(false);
|
77
|
+
});
|
78
|
+
});
|
79
|
+
|
80
|
+
describe("llmModularDrawer", () => {
|
81
|
+
it("should return false if the feature flag is not enabled", () => {
|
82
|
+
const mockedFeatures = {
|
83
|
+
llmModularDrawer: {
|
84
|
+
enabled: false,
|
85
|
+
params: { [ModularDrawerLocation.ADD_ACCOUNT]: true },
|
86
|
+
},
|
87
|
+
};
|
88
|
+
|
89
|
+
const { result } = renderHook(
|
90
|
+
() =>
|
91
|
+
useModularDrawerVisibility({
|
92
|
+
modularDrawerFeatureFlagKey: "llmModularDrawer",
|
93
|
+
}),
|
94
|
+
{
|
95
|
+
wrapper: makeMockedFeatureFlagsProviderWrapper(makeMockedContextValue(mockedFeatures)),
|
96
|
+
},
|
97
|
+
);
|
98
|
+
|
99
|
+
expect(result.current.isModularDrawerVisible(ModularDrawerLocation.ADD_ACCOUNT)).toBe(false);
|
100
|
+
});
|
101
|
+
|
102
|
+
it("should return false if the location param is not set", () => {
|
103
|
+
const mockedFeatures = {
|
104
|
+
llmModularDrawer: { enabled: true, params: {} },
|
105
|
+
};
|
106
|
+
|
107
|
+
const { result } = renderHook(
|
108
|
+
() =>
|
109
|
+
useModularDrawerVisibility({
|
110
|
+
modularDrawerFeatureFlagKey: "llmModularDrawer",
|
111
|
+
}),
|
112
|
+
{
|
113
|
+
wrapper: makeMockedFeatureFlagsProviderWrapper(makeMockedContextValue(mockedFeatures)),
|
114
|
+
},
|
115
|
+
);
|
116
|
+
|
117
|
+
expect(result.current.isModularDrawerVisible(ModularDrawerLocation.ADD_ACCOUNT)).toBe(false);
|
118
|
+
});
|
119
|
+
|
120
|
+
it("should return the correct visibility for each location", () => {
|
121
|
+
const mockedFeatures = {
|
122
|
+
llmModularDrawer: {
|
123
|
+
enabled: true,
|
124
|
+
params: {
|
125
|
+
[ModularDrawerLocation.ADD_ACCOUNT]: false,
|
126
|
+
[ModularDrawerLocation.EARN_FLOW]: true,
|
127
|
+
[ModularDrawerLocation.RECEIVE_FLOW]: true,
|
128
|
+
},
|
129
|
+
},
|
130
|
+
};
|
131
|
+
|
132
|
+
const { result } = renderHook(
|
133
|
+
() =>
|
134
|
+
useModularDrawerVisibility({
|
135
|
+
modularDrawerFeatureFlagKey: "llmModularDrawer",
|
136
|
+
}),
|
137
|
+
{
|
138
|
+
wrapper: makeMockedFeatureFlagsProviderWrapper(makeMockedContextValue(mockedFeatures)),
|
139
|
+
},
|
140
|
+
);
|
141
|
+
|
142
|
+
expect(result.current.isModularDrawerVisible(ModularDrawerLocation.ADD_ACCOUNT)).toBe(false);
|
143
|
+
expect(result.current.isModularDrawerVisible(ModularDrawerLocation.EARN_FLOW)).toBe(true);
|
144
|
+
expect(result.current.isModularDrawerVisible(ModularDrawerLocation.RECEIVE_FLOW)).toBe(true);
|
145
|
+
expect(result.current.isModularDrawerVisible(ModularDrawerLocation.LIVE_APP)).toBe(false);
|
146
|
+
expect(result.current.isModularDrawerVisible(ModularDrawerLocation.SEND_FLOW)).toBe(false);
|
147
|
+
});
|
148
|
+
});
|
149
|
+
});
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { useCallback } from "react";
|
2
|
+
import { useFeature } from "../featureFlags";
|
3
|
+
import { ModularDrawerLocation } from "./enums";
|
4
|
+
|
5
|
+
type ModularDrawerFeatureFlagKey = "lldModularDrawer" | "llmModularDrawer";
|
6
|
+
|
7
|
+
export function useModularDrawerVisibility({
|
8
|
+
modularDrawerFeatureFlagKey,
|
9
|
+
}: {
|
10
|
+
modularDrawerFeatureFlagKey: ModularDrawerFeatureFlagKey;
|
11
|
+
}) {
|
12
|
+
const featureModularDrawer = useFeature(modularDrawerFeatureFlagKey);
|
13
|
+
|
14
|
+
const isModularDrawerVisible = useCallback(
|
15
|
+
(location: ModularDrawerLocation) => {
|
16
|
+
if (!featureModularDrawer?.enabled) return false;
|
17
|
+
return featureModularDrawer.params?.[location] ?? false;
|
18
|
+
},
|
19
|
+
[featureModularDrawer],
|
20
|
+
);
|
21
|
+
|
22
|
+
return {
|
23
|
+
isModularDrawerVisible,
|
24
|
+
};
|
25
|
+
}
|