@onekeyfe/hd-core 0.3.14 → 0.3.15
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/__tests__/checkBootloaderReleast.test.js +108 -0
- package/dist/api/firmware/bootloaderHelper.d.ts +9 -0
- package/dist/api/firmware/bootloaderHelper.d.ts.map +1 -0
- package/dist/api/firmware/getBinary.d.ts.map +1 -1
- package/dist/api/firmware/updateBootloader.d.ts +1 -1
- package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +21 -6
- package/dist/utils/deviceFeaturesUtils.d.ts +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/jest.config.js +5 -0
- package/package.json +6 -5
- package/src/api/firmware/bootloaderHelper.ts +32 -0
- package/src/api/firmware/getBinary.ts +0 -1
- package/src/api/firmware/updateBootloader.ts +8 -8
- package/src/utils/deviceFeaturesUtils.ts +5 -2
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
|
+
const { shouldUpdateBootloaderForClassicAndMini } = require('../src/api/firmware/bootloaderHelper');
|
|
3
|
+
|
|
4
|
+
const fixtures = [
|
|
5
|
+
{
|
|
6
|
+
description: 'version: 2.10.0 -> 2.11.0, boot 1.9.0 -> boot 2.0.0, No need to upgrade',
|
|
7
|
+
currentVersion: '2.10.0',
|
|
8
|
+
bootloaderVersion: '1.9.0',
|
|
9
|
+
willUpdateFirmware: '2.11.0',
|
|
10
|
+
targetBootloaderVersion: [2, 0, 0],
|
|
11
|
+
bootloaderRelatedFirmwareVersion: [3, 0, 0],
|
|
12
|
+
shouldUpdateBootloader: false,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
description: 'version: 2.10.0 -> 3.0.0, boot 1.9.0 -> boot 2.0.0, Should upgrade bootloader',
|
|
16
|
+
currentVersion: '2.10.0',
|
|
17
|
+
bootloaderVersion: '1.9.0',
|
|
18
|
+
willUpdateFirmware: '3.0.0',
|
|
19
|
+
targetBootloaderVersion: [2, 0, 0],
|
|
20
|
+
bootloaderRelatedFirmwareVersion: [3, 0, 0],
|
|
21
|
+
shouldUpdateBootloader: true,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
description: 'version: 2.10.0 -> 3.0.0, boot 2.0.0 -> boot 2.0.0, No need to upgrade',
|
|
25
|
+
currentVersion: '2.10.0',
|
|
26
|
+
bootloaderVersion: '2.0.0',
|
|
27
|
+
willUpdateFirmware: '3.0.0',
|
|
28
|
+
targetBootloaderVersion: [2, 0, 0],
|
|
29
|
+
bootloaderRelatedFirmwareVersion: [3, 0, 0],
|
|
30
|
+
shouldUpdateBootloader: false,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
description: 'version: 3.0.0 -> 3.0.0, boot 2.0.0 -> boot 2.0.0, No need to upgrade',
|
|
34
|
+
currentVersion: '3.0.0',
|
|
35
|
+
bootloaderVersion: '2.0.0',
|
|
36
|
+
willUpdateFirmware: '3.0.0',
|
|
37
|
+
targetBootloaderVersion: [2, 0, 0],
|
|
38
|
+
bootloaderRelatedFirmwareVersion: [3, 0, 0],
|
|
39
|
+
shouldUpdateBootloader: false,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
description: 'version: 3.0.0 -> 3.1.0, boot 2.0.0 -> boot 2.0.0, No need to upgrade',
|
|
43
|
+
currentVersion: '3.0.0',
|
|
44
|
+
bootloaderVersion: '2.0.0',
|
|
45
|
+
willUpdateFirmware: '3.1.0',
|
|
46
|
+
targetBootloaderVersion: [2, 0, 0],
|
|
47
|
+
bootloaderRelatedFirmwareVersion: [3, 0, 0],
|
|
48
|
+
shouldUpdateBootloader: false,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
description: 'version: 2.11.0 -> 3.1.0, boot 1.9.0 -> boot 2.0.0, Should upgrade bootloader',
|
|
52
|
+
currentVersion: '2.11.0',
|
|
53
|
+
bootloaderVersion: '2.0.0',
|
|
54
|
+
willUpdateFirmware: '3.1.0',
|
|
55
|
+
targetBootloaderVersion: [2, 0, 0],
|
|
56
|
+
bootloaderRelatedFirmwareVersion: [3, 0, 0],
|
|
57
|
+
shouldUpdateBootloader: false,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
description: 'version: 2.11.0 -> 3.1.0, boot 2.0.0 -> boot 2.0.0, No need to upgrade',
|
|
61
|
+
currentVersion: '2.11.0',
|
|
62
|
+
bootloaderVersion: '2.0.0',
|
|
63
|
+
willUpdateFirmware: '3.1.0',
|
|
64
|
+
targetBootloaderVersion: [2, 0, 0],
|
|
65
|
+
bootloaderRelatedFirmwareVersion: [3, 0, 0],
|
|
66
|
+
shouldUpdateBootloader: false,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
description: 'version: 3.1.0 -> 3.2.0, boot 1.9.0 -> boot 2.0.0, Should upgrade bootloader',
|
|
70
|
+
currentVersion: '3.1.0',
|
|
71
|
+
bootloaderVersion: '1.9.0',
|
|
72
|
+
willUpdateFirmware: '3.2.0',
|
|
73
|
+
targetBootloaderVersion: [2, 0, 0],
|
|
74
|
+
bootloaderRelatedFirmwareVersion: [3, 0, 0],
|
|
75
|
+
shouldUpdateBootloader: true,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
description: 'version: 3.1.0 -> 3.3.0, boot 2.0.0 -> boot 2.0.0, No need to upgrade',
|
|
79
|
+
currentVersion: '3.1.0',
|
|
80
|
+
bootloaderVersion: '1.9.0',
|
|
81
|
+
willUpdateFirmware: '3.2.0',
|
|
82
|
+
targetBootloaderVersion: [2, 0, 0],
|
|
83
|
+
bootloaderRelatedFirmwareVersion: [3, 0, 0],
|
|
84
|
+
shouldUpdateBootloader: true,
|
|
85
|
+
},
|
|
86
|
+
];
|
|
87
|
+
|
|
88
|
+
describe('CheckBootloaderReleast', () => {
|
|
89
|
+
fixtures.forEach(data => {
|
|
90
|
+
test(data.description, () => {
|
|
91
|
+
const {
|
|
92
|
+
currentVersion,
|
|
93
|
+
bootloaderVersion,
|
|
94
|
+
willUpdateFirmware,
|
|
95
|
+
targetBootloaderVersion,
|
|
96
|
+
bootloaderRelatedFirmwareVersion,
|
|
97
|
+
} = data;
|
|
98
|
+
const shouldUpdateBootloader = shouldUpdateBootloaderForClassicAndMini({
|
|
99
|
+
currentVersion,
|
|
100
|
+
bootloaderVersion,
|
|
101
|
+
willUpdateFirmware,
|
|
102
|
+
targetBootloaderVersion,
|
|
103
|
+
bootloaderRelatedFirmwareVersion,
|
|
104
|
+
});
|
|
105
|
+
expect(shouldUpdateBootloader).toBe(data.shouldUpdateBootloader);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IVersionArray } from '../../types';
|
|
2
|
+
export declare function shouldUpdateBootloaderForClassicAndMini({ currentVersion, bootloaderVersion, willUpdateFirmware, targetBootloaderVersion, bootloaderRelatedFirmwareVersion, }: {
|
|
3
|
+
currentVersion: string;
|
|
4
|
+
bootloaderVersion: string;
|
|
5
|
+
willUpdateFirmware: string;
|
|
6
|
+
targetBootloaderVersion?: IVersionArray;
|
|
7
|
+
bootloaderRelatedFirmwareVersion: IVersionArray;
|
|
8
|
+
}): boolean;
|
|
9
|
+
//# sourceMappingURL=bootloaderHelper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootloaderHelper.d.ts","sourceRoot":"","sources":["../../../src/api/firmware/bootloaderHelper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,wBAAgB,uCAAuC,CAAC,EACtD,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,gCAAgC,GACjC,EAAE;IACD,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,uBAAuB,CAAC,EAAE,aAAa,CAAC;IACxC,gCAAgC,EAAE,aAAa,CAAC;CACjD,WAgBA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBinary.d.ts","sourceRoot":"","sources":["../../../src/api/firmware/getBinary.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAMvC,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,UAAU,GAAG,KAAK,CAAC;IAC/B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,cAAe,SAAQ,YAAY;IAC3C,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,eAAO,MAAM,SAAS,2DAKnB,cAAc;;;;;;;;;;;;;;;;;;;;EAiChB,CAAC;AAEF,eAAO,MAAM,oBAAoB,QAAe,MAAM;;EAWrD,CAAC;AAEF,eAAO,MAAM,OAAO,4CAA6C,YAAY,
|
|
1
|
+
{"version":3,"file":"getBinary.d.ts","sourceRoot":"","sources":["../../../src/api/firmware/getBinary.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAMvC,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,UAAU,GAAG,KAAK,CAAC;IAC/B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,cAAe,SAAQ,YAAY;IAC3C,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,eAAO,MAAM,SAAS,2DAKnB,cAAc;;;;;;;;;;;;;;;;;;;;EAiChB,CAAC;AAEF,eAAO,MAAM,oBAAoB,QAAe,MAAM;;EAWrD,CAAC;AAEF,eAAO,MAAM,OAAO,4CAA6C,YAAY,2DAgB5E,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Features } from '../../types';
|
|
2
2
|
export declare function checkNeedUpdateBootForTouch(features: Features): boolean;
|
|
3
|
-
export declare function checkNeedUpdateBootForClassicAndMini(features: Features, willUpdateFirmware: string): boolean
|
|
3
|
+
export declare function checkNeedUpdateBootForClassicAndMini(features: Features, willUpdateFirmware: string): boolean;
|
|
4
4
|
export declare function checkBootloaderLength(data: ArrayBuffer): boolean;
|
|
5
5
|
//# sourceMappingURL=updateBootloader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateBootloader.d.ts","sourceRoot":"","sources":["../../../src/api/firmware/updateBootloader.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"updateBootloader.d.ts","sourceRoot":"","sources":["../../../src/api/firmware/updateBootloader.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AASvC,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,QAAQ,WAgB7D;AAED,wBAAgB,oCAAoC,CAClD,QAAQ,EAAE,QAAQ,EAClB,kBAAkB,EAAE,MAAM,WAuB3B;AAGD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,WAAW,WAiBtD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2212,14 +2212,14 @@ declare const getDeviceTypeByDeviceId: (deviceId?: string | undefined) => IDevic
|
|
|
2212
2212
|
declare const getDeviceUUID: (features: Features) => string;
|
|
2213
2213
|
declare const getDeviceLabel: (features: Features) => string;
|
|
2214
2214
|
declare const supportInputPinOnSoftware: (features: Features) => SupportFeatureType;
|
|
2215
|
-
declare const getFirmwareUpdateField: (features: Features, updateType: 'firmware' | 'ble') =>
|
|
2215
|
+
declare const getFirmwareUpdateField: (features: Features, updateType: 'firmware' | 'ble') => 'firmware' | 'ble' | 'firmware-v3' | 'firmware-v2';
|
|
2216
2216
|
|
|
2217
2217
|
declare const getHDPath: (path: string) => Array<number>;
|
|
2218
2218
|
declare const getScriptType: (path: Array<number>) => InputScriptType;
|
|
2219
2219
|
declare const getOutputScriptType: (path?: number[] | undefined) => ChangeOutputScriptType;
|
|
2220
2220
|
|
|
2221
2221
|
declare function checkNeedUpdateBootForTouch(features: Features): boolean;
|
|
2222
|
-
declare function checkNeedUpdateBootForClassicAndMini(features: Features, willUpdateFirmware: string): boolean
|
|
2222
|
+
declare function checkNeedUpdateBootForClassicAndMini(features: Features, willUpdateFirmware: string): boolean;
|
|
2223
2223
|
|
|
2224
2224
|
declare type LogMessage = {
|
|
2225
2225
|
level: string;
|
package/dist/index.js
CHANGED
|
@@ -956,7 +956,7 @@ const getFirmwareUpdateField = (features, updateType) => {
|
|
|
956
956
|
return 'ble';
|
|
957
957
|
}
|
|
958
958
|
if (deviceType === 'classic' || deviceType === 'mini') {
|
|
959
|
-
return 'firmware-
|
|
959
|
+
return 'firmware-v3';
|
|
960
960
|
}
|
|
961
961
|
if (deviceType === 'touch') {
|
|
962
962
|
if (semver__default["default"].lt(deviceFirmwareVersion.join('.'), '3.4.0'))
|
|
@@ -11411,6 +11411,19 @@ const parseConnectSettings = (input = {}) => {
|
|
|
11411
11411
|
return settings;
|
|
11412
11412
|
};
|
|
11413
11413
|
|
|
11414
|
+
function shouldUpdateBootloaderForClassicAndMini({ currentVersion, bootloaderVersion, willUpdateFirmware, targetBootloaderVersion, bootloaderRelatedFirmwareVersion, }) {
|
|
11415
|
+
if (targetBootloaderVersion && semver__default["default"].gte(bootloaderVersion, targetBootloaderVersion.join('.'))) {
|
|
11416
|
+
return false;
|
|
11417
|
+
}
|
|
11418
|
+
if (semver__default["default"].gte(willUpdateFirmware, bootloaderRelatedFirmwareVersion.join('.'))) {
|
|
11419
|
+
return true;
|
|
11420
|
+
}
|
|
11421
|
+
if (semver__default["default"].gte(currentVersion, bootloaderRelatedFirmwareVersion.join('.'))) {
|
|
11422
|
+
return true;
|
|
11423
|
+
}
|
|
11424
|
+
return false;
|
|
11425
|
+
}
|
|
11426
|
+
|
|
11414
11427
|
function checkNeedUpdateBootForTouch(features) {
|
|
11415
11428
|
const deviceType = getDeviceType(features);
|
|
11416
11429
|
if (deviceType !== 'touch')
|
|
@@ -11439,10 +11452,13 @@ function checkNeedUpdateBootForClassicAndMini(features, willUpdateFirmware) {
|
|
|
11439
11452
|
const bootloaderRelatedFirmwareVersion = DataManager.getBootloaderRelatedFirmwareVersion(features);
|
|
11440
11453
|
if (!bootloaderRelatedFirmwareVersion)
|
|
11441
11454
|
return false;
|
|
11442
|
-
return (
|
|
11443
|
-
|
|
11444
|
-
|
|
11445
|
-
|
|
11455
|
+
return shouldUpdateBootloaderForClassicAndMini({
|
|
11456
|
+
currentVersion,
|
|
11457
|
+
bootloaderVersion,
|
|
11458
|
+
willUpdateFirmware,
|
|
11459
|
+
targetBootloaderVersion,
|
|
11460
|
+
bootloaderRelatedFirmwareVersion,
|
|
11461
|
+
});
|
|
11446
11462
|
}
|
|
11447
11463
|
const INIT_DATA_CHUNK_SIZE$1 = 16 * 1024;
|
|
11448
11464
|
function checkBootloaderLength(data) {
|
|
@@ -14073,7 +14089,6 @@ const getInfo = ({ features, updateType, targetVersion }) => {
|
|
|
14073
14089
|
firmwareUpdateField = 'firmware-v3';
|
|
14074
14090
|
}
|
|
14075
14091
|
}
|
|
14076
|
-
console.log('=====>>>getInfo: ', firmwareUpdateField);
|
|
14077
14092
|
const releaseInfo = (_b = (_a = deviceMap === null || deviceMap === void 0 ? void 0 : deviceMap[deviceType]) === null || _a === void 0 ? void 0 : _a[firmwareUpdateField]) !== null && _b !== void 0 ? _b : [];
|
|
14078
14093
|
return findLatestRelease(releaseInfo);
|
|
14079
14094
|
};
|
|
@@ -15,5 +15,5 @@ export declare const supportNewPassphrase: (features?: import("packages/hd-trans
|
|
|
15
15
|
export declare const getPassphraseState: (features: Features, commands: DeviceCommands) => Promise<string | false>;
|
|
16
16
|
export declare const supportBatchPublicKey: (features?: import("packages/hd-transport/dist").Features | undefined) => boolean;
|
|
17
17
|
export declare const supportModifyHomescreen: (features?: import("packages/hd-transport/dist").Features | undefined) => SupportFeatureType;
|
|
18
|
-
export declare const getFirmwareUpdateField: (features: Features, updateType: 'firmware' | 'ble') =>
|
|
18
|
+
export declare const getFirmwareUpdateField: (features: Features, updateType: 'firmware' | 'ble') => 'firmware' | 'ble' | 'firmware-v3' | 'firmware-v2';
|
|
19
19
|
//# sourceMappingURL=deviceFeaturesUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deviceFeaturesUtils.d.ts","sourceRoot":"","sources":["../../src/utils/deviceFeaturesUtils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EACV,QAAQ,EACR,aAAa,EACb,WAAW,EACX,YAAY,EACZ,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,cAAc,4EAA0B,YAcpD,CAAC;AAEF,eAAO,MAAM,aAAa,4EAA0B,WAUnD,CAAC;AAEF,eAAO,MAAM,yBAAyB,4EAA0B,WACvC,CAAC;AAE1B,eAAO,MAAM,sBAAsB,iCAAoB,WAAW,GAAG,IAKpE,CAAC;AAEF,eAAO,MAAM,uBAAuB,qCAAwB,WAQ3D,CAAC;AAEF,eAAO,MAAM,aAAa,aAAc,QAAQ,WAM/C,CAAC;AAEF,eAAO,MAAM,cAAc,aAAc,QAAQ,WAOhD,CAAC;AAKF,eAAO,MAAM,wBAAwB,aAAc,QAAQ,GAAG,SAAS,kBAOtE,CAAC;AAKF,eAAO,MAAM,2BAA2B,aAAc,QAAQ,KAAG,aAAa,GAAG,IAQhF,CAAC;AAEF,eAAO,MAAM,0BAA0B,aAAc,QAAQ,kBAW5D,CAAC;AAEF,eAAO,MAAM,yBAAyB,aAAc,QAAQ,KAAG,kBAU9D,CAAC;AAEF,eAAO,MAAM,oBAAoB,4EAA0B,kBAW1D,CAAC;AAEF,eAAO,MAAM,kBAAkB,aAAoB,QAAQ,YAAY,cAAc,4BAepF,CAAC;AAEF,eAAO,MAAM,qBAAqB,4EAA0B,OAU3D,CAAC;AAEF,eAAO,MAAM,uBAAuB,4EAA0B,kBAU7D,CAAC;AAKF,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"deviceFeaturesUtils.d.ts","sourceRoot":"","sources":["../../src/utils/deviceFeaturesUtils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EACV,QAAQ,EACR,aAAa,EACb,WAAW,EACX,YAAY,EACZ,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,cAAc,4EAA0B,YAcpD,CAAC;AAEF,eAAO,MAAM,aAAa,4EAA0B,WAUnD,CAAC;AAEF,eAAO,MAAM,yBAAyB,4EAA0B,WACvC,CAAC;AAE1B,eAAO,MAAM,sBAAsB,iCAAoB,WAAW,GAAG,IAKpE,CAAC;AAEF,eAAO,MAAM,uBAAuB,qCAAwB,WAQ3D,CAAC;AAEF,eAAO,MAAM,aAAa,aAAc,QAAQ,WAM/C,CAAC;AAEF,eAAO,MAAM,cAAc,aAAc,QAAQ,WAOhD,CAAC;AAKF,eAAO,MAAM,wBAAwB,aAAc,QAAQ,GAAG,SAAS,kBAOtE,CAAC;AAKF,eAAO,MAAM,2BAA2B,aAAc,QAAQ,KAAG,aAAa,GAAG,IAQhF,CAAC;AAEF,eAAO,MAAM,0BAA0B,aAAc,QAAQ,kBAW5D,CAAC;AAEF,eAAO,MAAM,yBAAyB,aAAc,QAAQ,KAAG,kBAU9D,CAAC;AAEF,eAAO,MAAM,oBAAoB,4EAA0B,kBAW1D,CAAC;AAEF,eAAO,MAAM,kBAAkB,aAAoB,QAAQ,YAAY,cAAc,4BAepF,CAAC;AAEF,eAAO,MAAM,qBAAqB,4EAA0B,OAU3D,CAAC;AAEF,eAAO,MAAM,uBAAuB,4EAA0B,kBAU7D,CAAC;AAKF,eAAO,MAAM,sBAAsB,aACvB,QAAQ,cACN,UAAU,GAAG,KAAK,KAC7B,UAAU,GAAG,KAAK,GAAG,aAAa,GAAG,aAgBvC,CAAC"}
|
package/jest.config.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.15",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
@@ -18,14 +18,15 @@
|
|
|
18
18
|
"dev": "rimraf dist && rollup -c ../../build/rollup.config.js -w",
|
|
19
19
|
"build": "rimraf dist && rollup -c ../../build/rollup.config.js",
|
|
20
20
|
"lint": "eslint .",
|
|
21
|
-
"lint:fix": "eslint . --fix"
|
|
21
|
+
"lint:fix": "eslint . --fix",
|
|
22
|
+
"test": "jest"
|
|
22
23
|
},
|
|
23
24
|
"bugs": {
|
|
24
25
|
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
|
|
25
26
|
},
|
|
26
27
|
"dependencies": {
|
|
27
|
-
"@onekeyfe/hd-shared": "^0.3.
|
|
28
|
-
"@onekeyfe/hd-transport": "^0.3.
|
|
28
|
+
"@onekeyfe/hd-shared": "^0.3.15",
|
|
29
|
+
"@onekeyfe/hd-transport": "^0.3.15",
|
|
29
30
|
"axios": "^0.27.2",
|
|
30
31
|
"bignumber.js": "^9.0.2",
|
|
31
32
|
"bytebuffer": "^5.0.1",
|
|
@@ -43,5 +44,5 @@
|
|
|
43
44
|
"@types/semver": "^7.3.9",
|
|
44
45
|
"ripple-keypairs": "^1.1.4"
|
|
45
46
|
},
|
|
46
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "3c2dd011378ec987f6a9ab900d72a83bc6811608"
|
|
47
48
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import semver from 'semver';
|
|
2
|
+
import { IVersionArray } from '../../types';
|
|
3
|
+
|
|
4
|
+
export function shouldUpdateBootloaderForClassicAndMini({
|
|
5
|
+
currentVersion,
|
|
6
|
+
bootloaderVersion,
|
|
7
|
+
willUpdateFirmware,
|
|
8
|
+
targetBootloaderVersion,
|
|
9
|
+
bootloaderRelatedFirmwareVersion,
|
|
10
|
+
}: {
|
|
11
|
+
currentVersion: string;
|
|
12
|
+
bootloaderVersion: string;
|
|
13
|
+
willUpdateFirmware: string;
|
|
14
|
+
targetBootloaderVersion?: IVersionArray;
|
|
15
|
+
bootloaderRelatedFirmwareVersion: IVersionArray;
|
|
16
|
+
}) {
|
|
17
|
+
// If the current bootloader version is greater than or equal to the version that needs to be upgraded, then no upgrade is required
|
|
18
|
+
if (targetBootloaderVersion && semver.gte(bootloaderVersion, targetBootloaderVersion.join('.'))) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (semver.gte(willUpdateFirmware, bootloaderRelatedFirmwareVersion.join('.'))) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// The current version is greater than the relatedVersion and the bootloader version is lower than the target bootloader version
|
|
27
|
+
if (semver.gte(currentVersion, bootloaderRelatedFirmwareVersion.join('.'))) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
@@ -84,7 +84,6 @@ export const getInfo = ({ features, updateType, targetVersion }: GetInfoProps) =
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
console.log('=====>>>getInfo: ', firmwareUpdateField);
|
|
88
87
|
const releaseInfo = deviceMap?.[deviceType]?.[firmwareUpdateField] ?? [];
|
|
89
88
|
return findLatestRelease(releaseInfo);
|
|
90
89
|
};
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
getDeviceFirmwareVersion,
|
|
8
8
|
} from '../../utils/deviceFeaturesUtils';
|
|
9
9
|
import { DataManager } from '../../data-manager';
|
|
10
|
+
import { shouldUpdateBootloaderForClassicAndMini } from './bootloaderHelper';
|
|
10
11
|
|
|
11
12
|
export function checkNeedUpdateBootForTouch(features: Features) {
|
|
12
13
|
const deviceType = getDeviceType(features);
|
|
@@ -44,14 +45,13 @@ export function checkNeedUpdateBootForClassicAndMini(
|
|
|
44
45
|
DataManager.getBootloaderRelatedFirmwareVersion(features);
|
|
45
46
|
if (!bootloaderRelatedFirmwareVersion) return false;
|
|
46
47
|
|
|
47
|
-
return (
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
);
|
|
48
|
+
return shouldUpdateBootloaderForClassicAndMini({
|
|
49
|
+
currentVersion,
|
|
50
|
+
bootloaderVersion,
|
|
51
|
+
willUpdateFirmware,
|
|
52
|
+
targetBootloaderVersion,
|
|
53
|
+
bootloaderRelatedFirmwareVersion,
|
|
54
|
+
});
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
const INIT_DATA_CHUNK_SIZE = 16 * 1024;
|
|
@@ -182,7 +182,10 @@ export const supportModifyHomescreen = (features?: Features): SupportFeatureType
|
|
|
182
182
|
/**
|
|
183
183
|
* Since 3.5.0, Touch uses the firmware-v3 field to get firmware release info
|
|
184
184
|
*/
|
|
185
|
-
export const getFirmwareUpdateField = (
|
|
185
|
+
export const getFirmwareUpdateField = (
|
|
186
|
+
features: Features,
|
|
187
|
+
updateType: 'firmware' | 'ble'
|
|
188
|
+
): 'firmware' | 'ble' | 'firmware-v3' | 'firmware-v2' => {
|
|
186
189
|
const deviceType = getDeviceType(features);
|
|
187
190
|
const deviceFirmwareVersion = getDeviceFirmwareVersion(features);
|
|
188
191
|
if (updateType === 'ble') {
|
|
@@ -190,7 +193,7 @@ export const getFirmwareUpdateField = (features: Features, updateType: 'firmware
|
|
|
190
193
|
}
|
|
191
194
|
|
|
192
195
|
if (deviceType === 'classic' || deviceType === 'mini') {
|
|
193
|
-
return 'firmware-
|
|
196
|
+
return 'firmware-v3';
|
|
194
197
|
}
|
|
195
198
|
|
|
196
199
|
if (deviceType === 'touch') {
|