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