@onekeyfe/hd-core 1.1.17 → 1.1.18-alpha.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/dist/api/BaseMethod.d.ts +4 -4
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts +1 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/CheckBootloaderRelease.d.ts.map +1 -1
- package/dist/api/CheckFirmwareRelease.d.ts.map +1 -1
- package/dist/api/FirmwareUpdate.d.ts +1 -1
- package/dist/api/FirmwareUpdate.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts +3 -2
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts +2 -2
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts +2 -2
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/device/DeviceFullyUploadResource.d.ts.map +1 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts +6 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
- package/dist/api/firmware/getBinary.d.ts +6 -3
- package/dist/api/firmware/getBinary.d.ts.map +1 -1
- package/dist/api/firmware/releaseHelper.d.ts +7 -2
- package/dist/api/firmware/releaseHelper.d.ts.map +1 -1
- package/dist/api/firmware/updateBootloader.d.ts +7 -2
- package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
- package/dist/api/sui/SuiSignTransaction.d.ts +1 -1
- package/dist/api/sui/SuiSignTransaction.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +16 -9
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/index.d.ts +43 -21
- package/dist/index.js +200 -75
- package/dist/types/api/checkAllFirmwareRelease.d.ts +3 -1
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/checkBootloaderRelease.d.ts +5 -2
- package/dist/types/api/checkBootloaderRelease.d.ts.map +1 -1
- package/dist/types/api/checkFirmwareRelease.d.ts +6 -2
- package/dist/types/api/checkFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/deviceFullyUploadResource.d.ts +6 -1
- package/dist/types/api/deviceFullyUploadResource.d.ts.map +1 -1
- package/dist/types/api/deviceUpdateBootloader.d.ts +6 -3
- package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +3 -1
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/settings.d.ts +3 -0
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +7 -5
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/release.d.ts +1 -1
- package/dist/utils/release.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +17 -7
- package/src/api/CheckAllFirmwareRelease.ts +13 -6
- package/src/api/CheckBootloaderRelease.ts +13 -2
- package/src/api/CheckFirmwareRelease.ts +9 -2
- package/src/api/FirmwareUpdate.ts +7 -5
- package/src/api/FirmwareUpdateV2.ts +26 -14
- package/src/api/FirmwareUpdateV3.ts +29 -18
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +10 -11
- package/src/api/device/DeviceFullyUploadResource.ts +8 -2
- package/src/api/device/DeviceUpdateBootloader.ts +21 -5
- package/src/api/evm/EVMSignTypedData.ts +2 -8
- package/src/api/firmware/getBinary.ts +15 -4
- package/src/api/firmware/releaseHelper.ts +22 -11
- package/src/api/firmware/updateBootloader.ts +17 -9
- package/src/api/sui/SuiSignTransaction.ts +7 -1
- package/src/core/index.ts +3 -1
- package/src/data-manager/DataManager.ts +126 -22
- package/src/types/api/checkAllFirmwareRelease.ts +3 -1
- package/src/types/api/checkBootloaderRelease.ts +7 -3
- package/src/types/api/checkFirmwareRelease.ts +10 -2
- package/src/types/api/deviceFullyUploadResource.ts +7 -1
- package/src/types/api/deviceUpdateBootloader.ts +8 -4
- package/src/types/api/firmwareUpdate.ts +4 -1
- package/src/types/settings.ts +37 -0
- package/src/utils/deviceFeaturesUtils.ts +22 -10
- package/src/utils/release.ts +2 -1
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EDeviceType, ERRORS, HardwareErrorCode, wait } from '@onekeyfe/hd-shared';
|
|
2
2
|
import semver from 'semver';
|
|
3
3
|
import JSZip from 'jszip';
|
|
4
|
-
import { UI_REQUEST, FirmwareUpdateTipMessage } from '../events/ui-request';
|
|
5
|
-
import { validateParams } from './helpers/paramsValidator';
|
|
6
4
|
|
|
5
|
+
import { FirmwareUpdateTipMessage, UI_REQUEST } from '../events/ui-request';
|
|
6
|
+
import { validateParams } from './helpers/paramsValidator';
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
getDeviceBootloaderVersion,
|
|
8
|
+
LoggerNames,
|
|
10
9
|
getDeviceBLEFirmwareVersion,
|
|
10
|
+
getDeviceBootloaderVersion,
|
|
11
11
|
getDeviceFirmwareVersion,
|
|
12
|
-
|
|
12
|
+
getDeviceType,
|
|
13
|
+
getFirmwareType,
|
|
13
14
|
getLogger,
|
|
14
15
|
} from '../utils';
|
|
15
16
|
import { getBinary, getSysResourceBinary } from './firmware/getBinary';
|
|
16
17
|
import { DataManager } from '../data-manager';
|
|
17
|
-
import { FirmwareUpdateV3Params } from '../types/api/firmwareUpdate';
|
|
18
18
|
import { FirmwareUpdateBaseMethod } from './firmware/FirmwareUpdateBaseMethod';
|
|
19
19
|
import { DevicePool } from '../device/DevicePool';
|
|
20
|
-
|
|
20
|
+
|
|
21
|
+
import type { FirmwareUpdateV3Params } from '../types/api/firmwareUpdate';
|
|
22
|
+
import type { Deferred, EFirmwareType } from '@onekeyfe/hd-shared';
|
|
23
|
+
import type { TypedResponseMessage } from '../device/DeviceCommands';
|
|
21
24
|
|
|
22
25
|
const Log = getLogger(LoggerNames.Method);
|
|
23
26
|
|
|
@@ -54,6 +57,7 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
54
57
|
{ name: 'forcedUpdateRes', type: 'boolean' },
|
|
55
58
|
{ name: 'bootloaderVersion', type: 'array' },
|
|
56
59
|
{ name: 'bootloaderBinary', type: 'buffer' },
|
|
60
|
+
{ name: 'firmwareType', type: 'string' },
|
|
57
61
|
{ name: 'platform', type: 'string' },
|
|
58
62
|
]);
|
|
59
63
|
|
|
@@ -66,6 +70,7 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
66
70
|
bootloaderBinary: payload.bootloaderBinary,
|
|
67
71
|
firmwareVersion: payload.firmwareVersion,
|
|
68
72
|
resourceBinary: payload.resourceBinary,
|
|
73
|
+
firmwareType: payload.firmwareType,
|
|
69
74
|
platform: payload.platform,
|
|
70
75
|
};
|
|
71
76
|
}
|
|
@@ -83,14 +88,17 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
83
88
|
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'Device features not available');
|
|
84
89
|
}
|
|
85
90
|
|
|
91
|
+
const deviceFirmwareType = getFirmwareType(features);
|
|
92
|
+
const firmwareType = this.params.firmwareType ?? deviceFirmwareType;
|
|
93
|
+
|
|
86
94
|
let resourceBinary: ArrayBuffer | null = null;
|
|
87
95
|
let fwBinaryMap: { fileName: string; binary: ArrayBuffer }[] = [];
|
|
88
96
|
let bootloaderBinary: ArrayBuffer | null = null;
|
|
89
97
|
try {
|
|
90
98
|
this.postTipMessage(FirmwareUpdateTipMessage.StartDownloadFirmware);
|
|
91
|
-
resourceBinary = await this.prepareResourceBinary();
|
|
92
|
-
fwBinaryMap = await this.prepareFirmwareAndBleBinary();
|
|
93
|
-
bootloaderBinary = await this.prepareBootloaderBinary();
|
|
99
|
+
resourceBinary = await this.prepareResourceBinary(firmwareType);
|
|
100
|
+
fwBinaryMap = await this.prepareFirmwareAndBleBinary(firmwareType);
|
|
101
|
+
bootloaderBinary = await this.prepareBootloaderBinary(firmwareType);
|
|
94
102
|
this.postTipMessage(FirmwareUpdateTipMessage.FinishDownloadFirmware);
|
|
95
103
|
} catch (err) {
|
|
96
104
|
throw ERRORS.TypedError(HardwareErrorCode.FirmwareUpdateDownloadFailed, err.message ?? err);
|
|
@@ -130,16 +138,17 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
130
138
|
}
|
|
131
139
|
}
|
|
132
140
|
|
|
133
|
-
private async prepareResourceBinary() {
|
|
141
|
+
private async prepareResourceBinary(firmwareType: EFirmwareType) {
|
|
134
142
|
if (this.params.resourceBinary) {
|
|
135
143
|
return this.params.resourceBinary;
|
|
136
144
|
}
|
|
137
145
|
const { features } = this.device;
|
|
138
146
|
if (!features) return null;
|
|
139
|
-
const resourceUrl = DataManager.getSysResourcesLatestRelease(
|
|
147
|
+
const resourceUrl = DataManager.getSysResourcesLatestRelease({
|
|
140
148
|
features,
|
|
141
|
-
this.params.forcedUpdateRes
|
|
142
|
-
|
|
149
|
+
forcedUpdateRes: this.params.forcedUpdateRes,
|
|
150
|
+
firmwareType,
|
|
151
|
+
});
|
|
143
152
|
|
|
144
153
|
if (resourceUrl) {
|
|
145
154
|
const resource = (await getSysResourceBinary(resourceUrl)).binary;
|
|
@@ -149,7 +158,7 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
149
158
|
return null;
|
|
150
159
|
}
|
|
151
160
|
|
|
152
|
-
private async prepareBootloaderBinary(): Promise<ArrayBuffer | null> {
|
|
161
|
+
private async prepareBootloaderBinary(firmwareType: EFirmwareType): Promise<ArrayBuffer | null> {
|
|
153
162
|
if (this.params.bootloaderBinary) {
|
|
154
163
|
return this.params.bootloaderBinary;
|
|
155
164
|
}
|
|
@@ -157,7 +166,7 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
157
166
|
if (!features) return null;
|
|
158
167
|
|
|
159
168
|
if (this.params.bootloaderVersion) {
|
|
160
|
-
const bootResourceUrl = DataManager.getBootloaderResource(features);
|
|
169
|
+
const bootResourceUrl = DataManager.getBootloaderResource(features, firmwareType);
|
|
161
170
|
if (bootResourceUrl) {
|
|
162
171
|
const bootBinary = (await getSysResourceBinary(bootResourceUrl)).binary;
|
|
163
172
|
return bootBinary;
|
|
@@ -166,7 +175,7 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
166
175
|
return null;
|
|
167
176
|
}
|
|
168
177
|
|
|
169
|
-
private async prepareFirmwareAndBleBinary() {
|
|
178
|
+
private async prepareFirmwareAndBleBinary(firmwareType: EFirmwareType) {
|
|
170
179
|
const fwBinaryMap: { fileName: string; binary: ArrayBuffer }[] = [];
|
|
171
180
|
if (this.params.firmwareBinary) {
|
|
172
181
|
fwBinaryMap.push({
|
|
@@ -182,6 +191,7 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
182
191
|
version: this.params.firmwareVersion,
|
|
183
192
|
updateType: 'firmware',
|
|
184
193
|
isUpdateBootloader: false,
|
|
194
|
+
firmwareType,
|
|
185
195
|
})
|
|
186
196
|
).binary;
|
|
187
197
|
fwBinaryMap.push({
|
|
@@ -203,6 +213,7 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
203
213
|
features,
|
|
204
214
|
version: this.params.bleVersion,
|
|
205
215
|
updateType: 'ble',
|
|
216
|
+
firmwareType,
|
|
206
217
|
});
|
|
207
218
|
fwBinaryMap.push({
|
|
208
219
|
fileName: 'ble-firmware.bin',
|
|
@@ -9,22 +9,21 @@ import {
|
|
|
9
9
|
import { serializedPath, toHardened } from '../helpers/pathUtils';
|
|
10
10
|
import { BaseMethod } from '../BaseMethod';
|
|
11
11
|
import { validateParams } from '../helpers/paramsValidator';
|
|
12
|
-
import { CoreApi } from '../../types';
|
|
13
|
-
import type {
|
|
14
|
-
AllNetworkAddressParams,
|
|
15
|
-
INetwork,
|
|
16
|
-
AllNetworkAddress,
|
|
17
|
-
CommonResponseParams,
|
|
18
|
-
} from '../../types/api/allNetworkGetAddress';
|
|
19
12
|
import { PROTO } from '../../constants';
|
|
20
|
-
|
|
21
13
|
import { findMethod } from '../utils';
|
|
22
|
-
import {
|
|
14
|
+
import { DEVICE, IFRAME, createUiMessage } from '../../events';
|
|
23
15
|
import { getDeviceFirmwareVersion, getMethodVersionRange } from '../../utils';
|
|
24
|
-
import { Device, DeviceEvents } from '../../device/Device';
|
|
25
16
|
import { UI_REQUEST } from '../../constants/ui-request';
|
|
26
17
|
import { onDeviceButtonHandler } from '../../core';
|
|
27
|
-
|
|
18
|
+
|
|
19
|
+
import type { Device, DeviceEvents } from '../../device/Device';
|
|
20
|
+
import type { CoreApi } from '../../types';
|
|
21
|
+
import type {
|
|
22
|
+
AllNetworkAddress,
|
|
23
|
+
AllNetworkAddressParams,
|
|
24
|
+
CommonResponseParams,
|
|
25
|
+
INetwork,
|
|
26
|
+
} from '../../types/api/allNetworkGetAddress';
|
|
28
27
|
|
|
29
28
|
const Mainnet = 'mainnet';
|
|
30
29
|
|
|
@@ -4,10 +4,11 @@ import { UI_REQUEST } from '../../constants/ui-request';
|
|
|
4
4
|
import { BaseMethod } from '../BaseMethod';
|
|
5
5
|
import { getSysResourceBinary } from '../firmware/getBinary';
|
|
6
6
|
import { updateResources } from '../firmware/uploadFirmware';
|
|
7
|
-
import { getDeviceType, getDeviceFirmwareVersion } from '../../utils';
|
|
7
|
+
import { getDeviceType, getDeviceFirmwareVersion, getFirmwareType } from '../../utils';
|
|
8
8
|
import { createUiMessage } from '../../events/ui-request';
|
|
9
9
|
import type { KnownDevice, Features } from '../../types';
|
|
10
10
|
import { DataManager } from '../../data-manager';
|
|
11
|
+
import type { DeviceFullyUploadResourceParams } from '../../types/api/deviceFullyUploadResource';
|
|
11
12
|
|
|
12
13
|
export default class DeviceFullyUploadResource extends BaseMethod {
|
|
13
14
|
checkPromise: Deferred<any> | null = null;
|
|
@@ -43,13 +44,18 @@ export default class DeviceFullyUploadResource extends BaseMethod {
|
|
|
43
44
|
const { device } = this;
|
|
44
45
|
const { features } = device;
|
|
45
46
|
|
|
47
|
+
const payload = this.payload as DeviceFullyUploadResourceParams;
|
|
48
|
+
|
|
49
|
+
const deviceFirmwareType = getFirmwareType(features);
|
|
50
|
+
const firmwareType = payload.firmwareType ?? deviceFirmwareType;
|
|
51
|
+
|
|
46
52
|
if (!features?.bootloader_mode && features) {
|
|
47
53
|
// check & upgrade firmware resource
|
|
48
54
|
if (features) {
|
|
49
55
|
let { binary } = this.payload;
|
|
50
56
|
if (!binary) {
|
|
51
57
|
this.postTipMessage('CheckLatestUiResource');
|
|
52
|
-
const resourceUrl = DataManager.getSysFullResource(features);
|
|
58
|
+
const resourceUrl = DataManager.getSysFullResource(features, firmwareType);
|
|
53
59
|
if (resourceUrl) {
|
|
54
60
|
this.postTipMessage('DownloadLatestUiResource');
|
|
55
61
|
const resource = await getSysResourceBinary(resourceUrl);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
1
|
+
import { EFirmwareType, ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
2
|
import { RebootType } from '@onekeyfe/hd-transport';
|
|
3
3
|
import { UI_REQUEST } from '../../constants/ui-request';
|
|
4
4
|
import { FirmwareUpdateTipMessage } from '../../events/ui-request';
|
|
@@ -8,10 +8,11 @@ import { updateBootloader } from '../firmware/uploadFirmware';
|
|
|
8
8
|
import { DeviceModelToTypes } from '../../types';
|
|
9
9
|
import { DataManager } from '../../data-manager';
|
|
10
10
|
import { checkBootloaderLength } from '../firmware/updateBootloader';
|
|
11
|
-
import { getDeviceType } from '../../utils';
|
|
11
|
+
import { getDeviceType, getFirmwareType } from '../../utils';
|
|
12
12
|
|
|
13
13
|
import type { Device } from '../../device/Device';
|
|
14
14
|
import type { Features } from '../../types';
|
|
15
|
+
import { DeviceUpdateBootloaderParams } from '../../types/api/deviceUpdateBootloader';
|
|
15
16
|
|
|
16
17
|
export default class DeviceUpdateBootloader extends FirmwareUpdateBaseMethod<any> {
|
|
17
18
|
init() {
|
|
@@ -41,11 +42,21 @@ export default class DeviceUpdateBootloader extends FirmwareUpdateBaseMethod<any
|
|
|
41
42
|
return true;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
async updateTouchBootloader(
|
|
45
|
+
async updateTouchBootloader({
|
|
46
|
+
device,
|
|
47
|
+
features,
|
|
48
|
+
firmwareType,
|
|
49
|
+
}: {
|
|
50
|
+
device: Device;
|
|
51
|
+
features?: Features;
|
|
52
|
+
firmwareType: EFirmwareType;
|
|
53
|
+
}) {
|
|
45
54
|
let { binary } = this.payload;
|
|
46
55
|
if (!binary) {
|
|
47
56
|
this.postTipMessage(FirmwareUpdateTipMessage.CheckLatestUiResource);
|
|
48
|
-
const resourceUrl = features
|
|
57
|
+
const resourceUrl = features
|
|
58
|
+
? DataManager.getBootloaderResource(features, firmwareType)
|
|
59
|
+
: null;
|
|
49
60
|
if (resourceUrl) {
|
|
50
61
|
this.postTipMessage(FirmwareUpdateTipMessage.DownloadLatestBootloaderResource);
|
|
51
62
|
const resource = await getSysResourceBinary(resourceUrl);
|
|
@@ -83,9 +94,14 @@ export default class DeviceUpdateBootloader extends FirmwareUpdateBaseMethod<any
|
|
|
83
94
|
const { device } = this;
|
|
84
95
|
const { features } = device;
|
|
85
96
|
|
|
97
|
+
const payload = this.payload as DeviceUpdateBootloaderParams;
|
|
98
|
+
|
|
86
99
|
const deviceType = getDeviceType(features);
|
|
100
|
+
const deviceFirmwareType = getFirmwareType(features);
|
|
101
|
+
const firmwareType = payload.firmwareType ?? deviceFirmwareType;
|
|
102
|
+
|
|
87
103
|
if (DeviceModelToTypes.model_touch.includes(deviceType)) {
|
|
88
|
-
return this.updateTouchBootloader(device, features);
|
|
104
|
+
return this.updateTouchBootloader({ device, features, firmwareType });
|
|
89
105
|
}
|
|
90
106
|
|
|
91
107
|
return Promise.resolve(true);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import semver from 'semver';
|
|
2
2
|
import { get } from 'lodash';
|
|
3
3
|
import BigNumber from 'bignumber.js';
|
|
4
|
-
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
4
|
+
import { ERRORS, HardwareErrorCode, EDeviceType } from '@onekeyfe/hd-shared';
|
|
5
5
|
import {
|
|
6
6
|
EthereumTypedDataSignature,
|
|
7
7
|
EthereumTypedDataStructAck,
|
|
@@ -337,15 +337,9 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
337
337
|
let biggerLimit = 1024; // 1k
|
|
338
338
|
|
|
339
339
|
const currentVersion = getDeviceFirmwareVersion(this.device.features).join('.');
|
|
340
|
-
const currentDeviceType = getDeviceType(this.device.features);
|
|
341
340
|
const supportBiggerDataVersion = '4.4.0';
|
|
342
341
|
|
|
343
|
-
|
|
344
|
-
DeviceModelToTypes.model_classic1s.includes(currentDeviceType) ||
|
|
345
|
-
(DeviceModelToTypes.model_touch.includes(currentDeviceType) &&
|
|
346
|
-
semver.gte(currentVersion, supportBiggerDataVersion));
|
|
347
|
-
|
|
348
|
-
if (supportBiggerData) {
|
|
342
|
+
if (semver.gte(currentVersion, supportBiggerDataVersion)) {
|
|
349
343
|
biggerLimit = 1536; // 1.5k
|
|
350
344
|
}
|
|
351
345
|
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import semver from 'semver';
|
|
2
2
|
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
import { getDeviceType, httpRequest } from '../../utils';
|
|
5
5
|
import { DataManager } from '../../data-manager';
|
|
6
6
|
import { findLatestRelease } from '../../utils/release';
|
|
7
7
|
import { getFirmwareUpdateField } from '../../utils/deviceFeaturesUtils';
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
import type { Features } from '../../types';
|
|
10
|
+
import type { EFirmwareType } from '@onekeyfe/hd-shared';
|
|
11
|
+
import type { IFirmwareField } from '../../data-manager/DataManager';
|
|
9
12
|
|
|
10
13
|
export interface GetInfoProps {
|
|
11
14
|
features: Features;
|
|
12
15
|
updateType: 'firmware' | 'ble';
|
|
13
16
|
isUpdateBootloader?: boolean;
|
|
14
17
|
targetVersion?: string;
|
|
18
|
+
firmwareType: EFirmwareType;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
interface GetBinaryProps extends GetInfoProps {
|
|
@@ -23,8 +27,14 @@ export const getBinary = async ({
|
|
|
23
27
|
updateType,
|
|
24
28
|
version,
|
|
25
29
|
isUpdateBootloader,
|
|
30
|
+
firmwareType,
|
|
26
31
|
}: GetBinaryProps) => {
|
|
27
|
-
const releaseInfo = getInfo({
|
|
32
|
+
const releaseInfo = getInfo({
|
|
33
|
+
features,
|
|
34
|
+
updateType,
|
|
35
|
+
targetVersion: version?.join('.'),
|
|
36
|
+
firmwareType,
|
|
37
|
+
});
|
|
28
38
|
|
|
29
39
|
if (!releaseInfo) {
|
|
30
40
|
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'no firmware found for this device');
|
|
@@ -71,7 +81,7 @@ export const getSysResourceBinary = async (url: string) => {
|
|
|
71
81
|
};
|
|
72
82
|
};
|
|
73
83
|
|
|
74
|
-
export const getInfo = ({ features, updateType, targetVersion }: GetInfoProps) => {
|
|
84
|
+
export const getInfo = ({ features, updateType, targetVersion, firmwareType }: GetInfoProps) => {
|
|
75
85
|
const deviceType = getDeviceType(features);
|
|
76
86
|
if (deviceType === 'unknown') {
|
|
77
87
|
return null;
|
|
@@ -82,6 +92,7 @@ export const getInfo = ({ features, updateType, targetVersion }: GetInfoProps) =
|
|
|
82
92
|
features,
|
|
83
93
|
updateType,
|
|
84
94
|
targetVersion,
|
|
95
|
+
firmwareType,
|
|
85
96
|
});
|
|
86
97
|
const releaseInfo = deviceMap?.[deviceType]?.[firmwareUpdateField] ?? [];
|
|
87
98
|
return findLatestRelease(releaseInfo);
|
|
@@ -6,10 +6,12 @@ import {
|
|
|
6
6
|
getDeviceType,
|
|
7
7
|
} from '../../utils';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
9
|
+
import type { EFirmwareType } from '@onekeyfe/hd-shared';
|
|
10
|
+
|
|
11
|
+
export const getFirmwareReleaseInfo = (features: Features, firmwareType: EFirmwareType) => {
|
|
12
|
+
const firmwareStatus = DataManager.getFirmwareStatus(features, firmwareType);
|
|
13
|
+
const changelog = DataManager.getFirmwareChangelog(features, firmwareType);
|
|
14
|
+
const release = DataManager.getFirmwareLatestRelease(features, firmwareType);
|
|
13
15
|
const bootloaderMode = !!features.bootloader_mode;
|
|
14
16
|
return {
|
|
15
17
|
status: firmwareStatus,
|
|
@@ -32,11 +34,16 @@ export const getBleFirmwareReleaseInfo = (features: Features) => {
|
|
|
32
34
|
};
|
|
33
35
|
};
|
|
34
36
|
|
|
35
|
-
export const getBootloaderReleaseInfo = (
|
|
36
|
-
features
|
|
37
|
-
willUpdateFirmwareVersion
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
export const getBootloaderReleaseInfo = ({
|
|
38
|
+
features,
|
|
39
|
+
willUpdateFirmwareVersion,
|
|
40
|
+
firmwareType,
|
|
41
|
+
}: {
|
|
42
|
+
features: Features;
|
|
43
|
+
willUpdateFirmwareVersion?: string;
|
|
44
|
+
firmwareType: EFirmwareType;
|
|
45
|
+
}) => {
|
|
46
|
+
const release = DataManager.getFirmwareLatestRelease(features, firmwareType);
|
|
40
47
|
const changelog = [release?.bootloaderChangelog].filter(
|
|
41
48
|
item =>
|
|
42
49
|
item != null &&
|
|
@@ -52,9 +59,13 @@ export const getBootloaderReleaseInfo = (
|
|
|
52
59
|
const deviceType = getDeviceType(features);
|
|
53
60
|
// classic mini classic1s
|
|
54
61
|
if (DeviceModelToTypes.model_mini.includes(deviceType)) {
|
|
55
|
-
shouldUpdate = !!checkNeedUpdateBootForClassicAndMini(
|
|
62
|
+
shouldUpdate = !!checkNeedUpdateBootForClassicAndMini({
|
|
63
|
+
features,
|
|
64
|
+
willUpdateFirmware: willUpdateFirmwareVersion,
|
|
65
|
+
firmwareType,
|
|
66
|
+
});
|
|
56
67
|
} else if (DeviceModelToTypes.model_touch.includes(deviceType)) {
|
|
57
|
-
shouldUpdate = checkNeedUpdateBootForTouch(features);
|
|
68
|
+
shouldUpdate = checkNeedUpdateBootForTouch(features, firmwareType);
|
|
58
69
|
}
|
|
59
70
|
|
|
60
71
|
return {
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import ByteBuffer from 'bytebuffer';
|
|
2
2
|
import semver from 'semver';
|
|
3
|
+
import type { EFirmwareType } from '@onekeyfe/hd-shared';
|
|
3
4
|
import { DeviceModelToTypes, Features } from '../../types';
|
|
4
5
|
import { getDeviceType, getDeviceBootloaderVersion, getDeviceFirmwareVersion } from '../../utils';
|
|
5
6
|
import { DataManager } from '../../data-manager';
|
|
6
7
|
import { shouldUpdateBootloaderForClassicAndMini } from './bootloaderHelper';
|
|
7
8
|
|
|
8
|
-
export function checkNeedUpdateBootForTouch(features: Features) {
|
|
9
|
+
export function checkNeedUpdateBootForTouch(features: Features, firmwareType: EFirmwareType) {
|
|
9
10
|
const deviceType = getDeviceType(features);
|
|
10
11
|
if (!DeviceModelToTypes.model_touch.includes(deviceType)) return false;
|
|
11
12
|
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
12
13
|
const bootloaderVersion = getDeviceBootloaderVersion(features).join('.');
|
|
13
|
-
const targetBootloaderVersion = DataManager.getBootloaderTargetVersion(features);
|
|
14
|
+
const targetBootloaderVersion = DataManager.getBootloaderTargetVersion(features, firmwareType);
|
|
14
15
|
if (!targetBootloaderVersion) return false;
|
|
15
16
|
|
|
16
17
|
return (
|
|
@@ -23,22 +24,29 @@ export function checkNeedUpdateBootForTouch(features: Features) {
|
|
|
23
24
|
);
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
export function checkNeedUpdateBootForClassicAndMini(
|
|
27
|
-
features
|
|
28
|
-
willUpdateFirmware
|
|
29
|
-
|
|
27
|
+
export function checkNeedUpdateBootForClassicAndMini({
|
|
28
|
+
features,
|
|
29
|
+
willUpdateFirmware,
|
|
30
|
+
firmwareType,
|
|
31
|
+
}: {
|
|
32
|
+
features: Features;
|
|
33
|
+
willUpdateFirmware?: string;
|
|
34
|
+
firmwareType: EFirmwareType;
|
|
35
|
+
}) {
|
|
30
36
|
const deviceType = getDeviceType(features);
|
|
31
37
|
if (!DeviceModelToTypes.model_mini.includes(deviceType)) return false;
|
|
32
38
|
if (!willUpdateFirmware) return false;
|
|
33
39
|
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
34
40
|
const bootloaderVersion = getDeviceBootloaderVersion(features).join('.');
|
|
35
|
-
const targetBootloaderVersion = DataManager.getBootloaderTargetVersion(features);
|
|
41
|
+
const targetBootloaderVersion = DataManager.getBootloaderTargetVersion(features, firmwareType);
|
|
36
42
|
if (targetBootloaderVersion && semver.gte(bootloaderVersion, targetBootloaderVersion.join('.'))) {
|
|
37
43
|
return false;
|
|
38
44
|
}
|
|
39
45
|
|
|
40
|
-
const bootloaderRelatedFirmwareVersion =
|
|
41
|
-
|
|
46
|
+
const bootloaderRelatedFirmwareVersion = DataManager.getBootloaderRelatedFirmwareVersion(
|
|
47
|
+
features,
|
|
48
|
+
firmwareType
|
|
49
|
+
);
|
|
42
50
|
if (!bootloaderRelatedFirmwareVersion) return false;
|
|
43
51
|
|
|
44
52
|
return shouldUpdateBootloaderForClassicAndMini({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SuiSignTx as HardwareSuiSignTx, TypedCall, SuiSignedTx } from '@onekeyfe/hd-transport';
|
|
2
1
|
import semver from 'semver';
|
|
3
2
|
import { bytesToHex } from '@noble/hashes/utils';
|
|
3
|
+
|
|
4
4
|
import { UI_REQUEST } from '../../constants/ui-request';
|
|
5
5
|
import { validatePath } from '../helpers/pathUtils';
|
|
6
6
|
import { BaseMethod } from '../BaseMethod';
|
|
@@ -8,6 +8,12 @@ import { validateParams } from '../helpers/paramsValidator';
|
|
|
8
8
|
import { formatAnyHex } from '../helpers/hexUtils';
|
|
9
9
|
import { getDeviceFirmwareVersion, getDeviceType } from '../../utils';
|
|
10
10
|
import { DeviceModelToTypes } from '../../types';
|
|
11
|
+
|
|
12
|
+
import type {
|
|
13
|
+
SuiSignTx as HardwareSuiSignTx,
|
|
14
|
+
SuiSignedTx,
|
|
15
|
+
TypedCall,
|
|
16
|
+
} from '@onekeyfe/hd-transport';
|
|
11
17
|
import type { TypedResponseMessage } from '../../device/DeviceCommands';
|
|
12
18
|
|
|
13
19
|
type SuiSignTx = Omit<HardwareSuiSignTx, 'data_initial_chunk' | 'data_length'> & HardwareSuiSignTx;
|
package/src/core/index.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
setLoggerPostMessage,
|
|
23
23
|
wait,
|
|
24
24
|
getMethodVersionRange,
|
|
25
|
+
getFirmwareType,
|
|
25
26
|
} from '../utils';
|
|
26
27
|
import {
|
|
27
28
|
findDefectiveBatchDevice,
|
|
@@ -282,7 +283,8 @@ const onCallDevice = async (
|
|
|
282
283
|
}
|
|
283
284
|
}
|
|
284
285
|
|
|
285
|
-
const
|
|
286
|
+
const deviceFirmwareType = getFirmwareType(device.features);
|
|
287
|
+
const newVersionStatus = DataManager.getFirmwareStatus(device.features, deviceFirmwareType);
|
|
286
288
|
const bleVersionStatus = DataManager.getBLEFirmwareStatus(device.features);
|
|
287
289
|
|
|
288
290
|
const currentFirmwareVersion = getDeviceFirmwareVersion(device.features).join('.');
|