@ledgerhq/live-common 34.38.2-nightly.0 → 34.39.0-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/bridge/cache.d.ts.map +1 -1
- package/lib/bridge/cache.js +2 -2
- package/lib/bridge/cache.js.map +1 -1
- package/lib/e2e/index.d.ts +0 -3
- 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 +0 -11
- 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/connectAppEventMapper.d.ts.map +1 -1
- package/lib/hw/connectAppEventMapper.js +1 -3
- package/lib/hw/connectAppEventMapper.js.map +1 -1
- package/lib/wallet-api/types.d.ts +1 -1
- package/lib/wallet-api/types.d.ts.map +1 -1
- package/lib/wallet-api/useDappLogic.d.ts.map +1 -1
- package/lib/wallet-api/useDappLogic.js +24 -3
- package/lib/wallet-api/useDappLogic.js.map +1 -1
- 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/e2e/index.d.ts +0 -3
- 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 +0 -11
- 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/connectAppEventMapper.d.ts.map +1 -1
- package/lib-es/hw/connectAppEventMapper.js +1 -3
- package/lib-es/hw/connectAppEventMapper.js.map +1 -1
- package/lib-es/wallet-api/types.d.ts +1 -1
- package/lib-es/wallet-api/types.d.ts.map +1 -1
- package/lib-es/wallet-api/useDappLogic.d.ts.map +1 -1
- package/lib-es/wallet-api/useDappLogic.js +24 -3
- package/lib-es/wallet-api/useDappLogic.js.map +1 -1
- package/package.json +48 -48
- package/src/bridge/cache.ts +2 -5
- package/src/featureFlags/defaultFeatures.ts +0 -11
- package/src/hw/connectAppEventMapper.ts +1 -3
- package/src/wallet-api/types.ts +1 -1
- package/src/wallet-api/useDappLogic.ts +27 -4
- package/lib/bridge/cache.test.d.ts +0 -2
- package/lib/bridge/cache.test.d.ts.map +0 -1
- package/lib/bridge/cache.test.js +0 -63
- package/lib/bridge/cache.test.js.map +0 -1
- package/lib/hooks/useAppVersionBlockCheck.d.ts +0 -11
- package/lib/hooks/useAppVersionBlockCheck.d.ts.map +0 -1
- package/lib/hooks/useAppVersionBlockCheck.js +0 -32
- package/lib/hooks/useAppVersionBlockCheck.js.map +0 -1
- package/lib/hooks/useAppVersionBlockCheck.test.d.ts +0 -2
- package/lib/hooks/useAppVersionBlockCheck.test.d.ts.map +0 -1
- package/lib/hooks/useAppVersionBlockCheck.test.js +0 -133
- package/lib/hooks/useAppVersionBlockCheck.test.js.map +0 -1
- package/lib/modularDrawer/__test__/useModularDrawerVisibility.test.d.ts +0 -2
- package/lib/modularDrawer/__test__/useModularDrawerVisibility.test.d.ts.map +0 -1
- package/lib/modularDrawer/__test__/useModularDrawerVisibility.test.js +0 -107
- package/lib/modularDrawer/__test__/useModularDrawerVisibility.test.js.map +0 -1
- package/lib/modularDrawer/enums.d.ts +0 -8
- package/lib/modularDrawer/enums.d.ts.map +0 -1
- package/lib/modularDrawer/enums.js +0 -12
- package/lib/modularDrawer/enums.js.map +0 -1
- package/lib/modularDrawer/useModularDrawerVisibility.d.ts +0 -9
- package/lib/modularDrawer/useModularDrawerVisibility.d.ts.map +0 -1
- package/lib/modularDrawer/useModularDrawerVisibility.js +0 -18
- package/lib/modularDrawer/useModularDrawerVisibility.js.map +0 -1
- package/lib/wallet-api/utils/txTrackingHelper.d.ts +0 -3
- package/lib/wallet-api/utils/txTrackingHelper.d.ts.map +0 -1
- package/lib/wallet-api/utils/txTrackingHelper.js +0 -16
- package/lib/wallet-api/utils/txTrackingHelper.js.map +0 -1
- package/lib/wallet-api/utils/txTrackingHelper.test.d.ts +0 -2
- package/lib/wallet-api/utils/txTrackingHelper.test.d.ts.map +0 -1
- package/lib/wallet-api/utils/txTrackingHelper.test.js +0 -70
- package/lib/wallet-api/utils/txTrackingHelper.test.js.map +0 -1
- package/lib-es/bridge/cache.test.d.ts +0 -2
- package/lib-es/bridge/cache.test.d.ts.map +0 -1
- package/lib-es/bridge/cache.test.js +0 -38
- package/lib-es/bridge/cache.test.js.map +0 -1
- package/lib-es/hooks/useAppVersionBlockCheck.d.ts +0 -11
- package/lib-es/hooks/useAppVersionBlockCheck.d.ts.map +0 -1
- package/lib-es/hooks/useAppVersionBlockCheck.js +0 -25
- package/lib-es/hooks/useAppVersionBlockCheck.js.map +0 -1
- package/lib-es/hooks/useAppVersionBlockCheck.test.d.ts +0 -2
- package/lib-es/hooks/useAppVersionBlockCheck.test.d.ts.map +0 -1
- package/lib-es/hooks/useAppVersionBlockCheck.test.js +0 -131
- package/lib-es/hooks/useAppVersionBlockCheck.test.js.map +0 -1
- package/lib-es/modularDrawer/__test__/useModularDrawerVisibility.test.d.ts +0 -2
- package/lib-es/modularDrawer/__test__/useModularDrawerVisibility.test.d.ts.map +0 -1
- package/lib-es/modularDrawer/__test__/useModularDrawerVisibility.test.js +0 -105
- package/lib-es/modularDrawer/__test__/useModularDrawerVisibility.test.js.map +0 -1
- package/lib-es/modularDrawer/enums.d.ts +0 -8
- package/lib-es/modularDrawer/enums.d.ts.map +0 -1
- package/lib-es/modularDrawer/enums.js +0 -9
- package/lib-es/modularDrawer/enums.js.map +0 -1
- package/lib-es/modularDrawer/useModularDrawerVisibility.d.ts +0 -9
- package/lib-es/modularDrawer/useModularDrawerVisibility.d.ts.map +0 -1
- package/lib-es/modularDrawer/useModularDrawerVisibility.js +0 -14
- package/lib-es/modularDrawer/useModularDrawerVisibility.js.map +0 -1
- package/lib-es/wallet-api/utils/txTrackingHelper.d.ts +0 -3
- package/lib-es/wallet-api/utils/txTrackingHelper.d.ts.map +0 -1
- package/lib-es/wallet-api/utils/txTrackingHelper.js +0 -12
- package/lib-es/wallet-api/utils/txTrackingHelper.js.map +0 -1
- package/lib-es/wallet-api/utils/txTrackingHelper.test.d.ts +0 -2
- package/lib-es/wallet-api/utils/txTrackingHelper.test.d.ts.map +0 -1
- package/lib-es/wallet-api/utils/txTrackingHelper.test.js +0 -68
- package/lib-es/wallet-api/utils/txTrackingHelper.test.js.map +0 -1
- package/src/bridge/cache.test.ts +0 -46
- package/src/hooks/useAppVersionBlockCheck.test.ts +0 -134
- package/src/hooks/useAppVersionBlockCheck.ts +0 -65
- package/src/modularDrawer/__test__/useModularDrawerVisibility.test.ts +0 -149
- package/src/modularDrawer/enums.ts +0 -7
- package/src/modularDrawer/useModularDrawerVisibility.ts +0 -25
- package/src/wallet-api/utils/txTrackingHelper.test.ts +0 -80
- package/src/wallet-api/utils/txTrackingHelper.ts +0 -14
@@ -1,134 +0,0 @@
|
|
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
|
-
});
|
@@ -1,65 +0,0 @@
|
|
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
|
-
};
|
@@ -1,149 +0,0 @@
|
|
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
|
-
});
|
@@ -1,25 +0,0 @@
|
|
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
|
-
}
|
@@ -1,80 +0,0 @@
|
|
1
|
-
import { getTxType } from "./txTrackingHelper";
|
2
|
-
import { ERC20_CLEAR_SIGNED_SELECTORS, DAPP_SELECTORS } from "@ledgerhq/hw-app-eth";
|
3
|
-
import { Transaction as EvmTransaction } from "@ledgerhq/coin-evm/types/transaction";
|
4
|
-
|
5
|
-
const createMockTransaction = (selector: string): EvmTransaction =>
|
6
|
-
({
|
7
|
-
data: Buffer.from(selector.slice(2) + "0".repeat(128), "hex"),
|
8
|
-
recipient: "0x1234567890123456789012345678901234567890",
|
9
|
-
amount: "0",
|
10
|
-
gasPrice: "0",
|
11
|
-
gasLimit: "21000",
|
12
|
-
nonce: 0,
|
13
|
-
}) as unknown as EvmTransaction;
|
14
|
-
|
15
|
-
describe("getTxType", () => {
|
16
|
-
describe("ERC20 transactions", () => {
|
17
|
-
it("should return 'transfer' for ERC20 transfer selector", () => {
|
18
|
-
const tx = createMockTransaction(ERC20_CLEAR_SIGNED_SELECTORS.TRANSFER);
|
19
|
-
const result = getTxType(tx);
|
20
|
-
expect(result).toBe("transfer");
|
21
|
-
});
|
22
|
-
|
23
|
-
it("should return 'approve' for ERC20 approve selector", () => {
|
24
|
-
const tx = createMockTransaction(ERC20_CLEAR_SIGNED_SELECTORS.APPROVE);
|
25
|
-
const result = getTxType(tx);
|
26
|
-
expect(result).toBe("approve");
|
27
|
-
});
|
28
|
-
});
|
29
|
-
|
30
|
-
describe("DAPP transactions", () => {
|
31
|
-
it("should return the DAPP selector value for known DAPP transactions", () => {
|
32
|
-
const dappSelectors = Object.keys(DAPP_SELECTORS);
|
33
|
-
if (dappSelectors.length > 0) {
|
34
|
-
const firstSelector = dappSelectors[0];
|
35
|
-
const expectedValue = DAPP_SELECTORS[firstSelector];
|
36
|
-
|
37
|
-
const tx = createMockTransaction(firstSelector);
|
38
|
-
const result = getTxType(tx);
|
39
|
-
expect(result).toBe(expectedValue);
|
40
|
-
}
|
41
|
-
});
|
42
|
-
});
|
43
|
-
|
44
|
-
describe("Unknown transactions", () => {
|
45
|
-
it("should return 'transfer' for unknown selectors", () => {
|
46
|
-
const tx = createMockTransaction("0x12345678");
|
47
|
-
const result = getTxType(tx);
|
48
|
-
expect(result).toBe("transfer");
|
49
|
-
});
|
50
|
-
|
51
|
-
it("should return 'transfer' for transactions without data", () => {
|
52
|
-
const tx = {
|
53
|
-
data: undefined,
|
54
|
-
} as EvmTransaction;
|
55
|
-
const result = getTxType(tx);
|
56
|
-
expect(result).toBe("transfer");
|
57
|
-
});
|
58
|
-
|
59
|
-
it("should return 'transfer' for transactions with empty data", () => {
|
60
|
-
const tx = {
|
61
|
-
data: Buffer.alloc(0),
|
62
|
-
} as EvmTransaction;
|
63
|
-
const result = getTxType(tx);
|
64
|
-
expect(result).toBe("transfer");
|
65
|
-
});
|
66
|
-
});
|
67
|
-
|
68
|
-
describe("Selector extract", () => {
|
69
|
-
it("should correctly extract 4-byte selector from transaction data", () => {
|
70
|
-
const transferSelector = ERC20_CLEAR_SIGNED_SELECTORS.TRANSFER;
|
71
|
-
const tx = createMockTransaction(transferSelector);
|
72
|
-
|
73
|
-
const expectedSelector = transferSelector;
|
74
|
-
const txSelector = `0x${tx.data?.toString("hex").substring(0, 8)}`;
|
75
|
-
|
76
|
-
expect(txSelector).toBe(expectedSelector);
|
77
|
-
expect(getTxType(tx)).toBe("transfer");
|
78
|
-
});
|
79
|
-
});
|
80
|
-
});
|
@@ -1,14 +0,0 @@
|
|
1
|
-
import { Transaction as EvmTransaction } from "@ledgerhq/coin-evm/types/transaction";
|
2
|
-
import { DAPP_SELECTORS } from "@ledgerhq/hw-app-eth";
|
3
|
-
|
4
|
-
const fallback = "transfer";
|
5
|
-
|
6
|
-
export const getTxType = (tx: EvmTransaction): string => {
|
7
|
-
if (!tx || !tx.data) return fallback;
|
8
|
-
|
9
|
-
const txSelector = `0x${tx.data.toString("hex").substring(0, 8)}`;
|
10
|
-
const type = DAPP_SELECTORS[txSelector];
|
11
|
-
|
12
|
-
if (!type) return fallback;
|
13
|
-
return type;
|
14
|
-
};
|