@onekeyfe/hd-core 1.1.18-alpha.0 → 1.1.19-alpha.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/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/events/device.d.ts +2 -2
- package/dist/events/device.d.ts.map +1 -1
- package/dist/index.d.ts +45 -22
- package/dist/index.js +201 -75
- package/dist/types/api/checkAllFirmwareRelease.d.ts +5 -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/api/index.d.ts +128 -128
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/device.d.ts +1 -1
- package/dist/types/device.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 +14 -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/events/device.ts +2 -2
- package/src/types/api/checkAllFirmwareRelease.ts +5 -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/api/index.ts +128 -161
- package/src/types/device.ts +2 -1
- package/src/types/settings.ts +37 -0
- package/src/utils/deviceFeaturesUtils.ts +22 -10
- package/src/utils/release.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.19-alpha.0",
|
|
4
4
|
"description": "Core processes and APIs for communicating with OneKey hardware devices.",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@onekeyfe/hd-shared": "1.1.
|
|
29
|
-
"@onekeyfe/hd-transport": "1.1.
|
|
28
|
+
"@onekeyfe/hd-shared": "1.1.19-alpha.0",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.1.19-alpha.0",
|
|
30
30
|
"axios": "1.12.2",
|
|
31
31
|
"bignumber.js": "^9.0.2",
|
|
32
32
|
"bytebuffer": "^5.0.1",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"@types/web-bluetooth": "^0.0.21",
|
|
47
47
|
"ripple-keypairs": "^1.3.1"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "5726559b1f2f1b919c7ea4626a89df735314107c"
|
|
50
50
|
}
|
package/src/api/BaseMethod.ts
CHANGED
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
import semver from 'semver';
|
|
2
2
|
import {
|
|
3
|
-
createNeedUpgradeFirmwareHardwareError,
|
|
4
3
|
ERRORS,
|
|
5
4
|
HardwareErrorCode,
|
|
5
|
+
createNeedUpgradeFirmwareHardwareError,
|
|
6
6
|
} from '@onekeyfe/hd-shared';
|
|
7
|
+
|
|
7
8
|
import { supportInputPinOnSoftware, supportModifyHomescreen } from '../utils/deviceFeaturesUtils';
|
|
8
9
|
import { createDeviceMessage } from '../events/device';
|
|
9
10
|
import { UI_REQUEST } from '../constants/ui-request';
|
|
10
|
-
import {
|
|
11
|
-
import DeviceConnector from '../device/DeviceConnector';
|
|
12
|
-
import { DeviceFirmwareRange, KnownDevice } from '../types';
|
|
13
|
-
import { CoreMessage, createFirmwareMessage, createUiMessage, DEVICE, FIRMWARE } from '../events';
|
|
11
|
+
import { DEVICE, FIRMWARE, createFirmwareMessage, createUiMessage } from '../events';
|
|
14
12
|
import { getBleFirmwareReleaseInfo, getFirmwareReleaseInfo } from './firmware/releaseHelper';
|
|
15
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
LoggerNames,
|
|
15
|
+
getDeviceFirmwareVersion,
|
|
16
|
+
getFirmwareType,
|
|
17
|
+
getLogger,
|
|
18
|
+
getMethodVersionRange,
|
|
19
|
+
} from '../utils';
|
|
20
|
+
|
|
21
|
+
import type { Device } from '../device/Device';
|
|
22
|
+
import type DeviceConnector from '../device/DeviceConnector';
|
|
23
|
+
import type { DeviceFirmwareRange, KnownDevice } from '../types';
|
|
24
|
+
import type { CoreMessage } from '../events';
|
|
16
25
|
import type { CoreContext } from '../core';
|
|
17
26
|
|
|
18
27
|
const Log = getLogger(LoggerNames.Method);
|
|
@@ -128,7 +137,8 @@ export abstract class BaseMethod<Params = undefined> {
|
|
|
128
137
|
|
|
129
138
|
checkFirmwareRelease() {
|
|
130
139
|
if (!this.device || !this.device.features) return;
|
|
131
|
-
const
|
|
140
|
+
const firmwareType = getFirmwareType(this.device.features);
|
|
141
|
+
const releaseInfo = getFirmwareReleaseInfo(this.device.features, firmwareType);
|
|
132
142
|
this.postMessage(
|
|
133
143
|
createFirmwareMessage(FIRMWARE.RELEASE_INFO, {
|
|
134
144
|
...releaseInfo,
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { BaseMethod } from './BaseMethod';
|
|
2
2
|
import { UI_REQUEST } from '../constants/ui-request';
|
|
3
|
-
|
|
4
3
|
import {
|
|
5
4
|
getBleFirmwareReleaseInfo,
|
|
6
5
|
getBootloaderReleaseInfo,
|
|
7
6
|
getFirmwareReleaseInfo,
|
|
8
7
|
} from './firmware/releaseHelper';
|
|
9
8
|
import { getBridgeReleaseInfo } from '../utils/bridgeUpdate';
|
|
10
|
-
import {
|
|
9
|
+
import { getDeviceFirmwareVersion, getDeviceType, getFirmwareType } from '../utils';
|
|
10
|
+
|
|
11
|
+
import type {
|
|
11
12
|
AllFirmwareRelease,
|
|
12
13
|
CheckAllFirmwareReleaseParams,
|
|
13
14
|
} from '../types/api/checkAllFirmwareRelease';
|
|
14
|
-
import { getDeviceFirmwareVersion, getDeviceType } from '../utils';
|
|
15
15
|
|
|
16
16
|
export default class CheckAllFirmwareRelease extends BaseMethod {
|
|
17
17
|
init() {
|
|
@@ -22,13 +22,16 @@ export default class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
22
22
|
|
|
23
23
|
async run() {
|
|
24
24
|
const { features } = this.device;
|
|
25
|
-
const { checkBridgeRelease } = this
|
|
25
|
+
const { checkBridgeRelease, firmwareType: firmwareTypeParams } = this
|
|
26
|
+
.payload as CheckAllFirmwareReleaseParams;
|
|
26
27
|
|
|
27
28
|
if (!features) {
|
|
28
29
|
return Promise.resolve(null);
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
const
|
|
32
|
+
const deviceFirmwareType = getFirmwareType(features);
|
|
33
|
+
const firmwareType = firmwareTypeParams ?? deviceFirmwareType;
|
|
34
|
+
const firmwareRelease = getFirmwareReleaseInfo(features, firmwareType);
|
|
32
35
|
|
|
33
36
|
const currentFirmwareVersion = getDeviceFirmwareVersion(features).join('.');
|
|
34
37
|
const willUpdateFirmwareVersion = firmwareRelease.release?.version?.join('.');
|
|
@@ -45,7 +48,11 @@ export default class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
45
48
|
willUpdateFirmwareVersion,
|
|
46
49
|
});
|
|
47
50
|
}
|
|
48
|
-
const bootloaderRelease = getBootloaderReleaseInfo(
|
|
51
|
+
const bootloaderRelease = getBootloaderReleaseInfo({
|
|
52
|
+
features,
|
|
53
|
+
willUpdateFirmwareVersion,
|
|
54
|
+
firmwareType,
|
|
55
|
+
});
|
|
49
56
|
const bleFirmwareReleaseInfo = getBleFirmwareReleaseInfo(features);
|
|
50
57
|
|
|
51
58
|
return {
|
|
@@ -60,6 +67,7 @@ export default class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
60
67
|
release: bridgeReleaseInfo.releaseVersion,
|
|
61
68
|
}
|
|
62
69
|
: undefined,
|
|
70
|
+
features,
|
|
63
71
|
} as AllFirmwareRelease;
|
|
64
72
|
}
|
|
65
73
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { BaseMethod } from './BaseMethod';
|
|
2
|
-
|
|
3
2
|
import { UI_REQUEST } from '../constants/ui-request';
|
|
4
3
|
import { getBootloaderReleaseInfo } from './firmware/releaseHelper';
|
|
4
|
+
import { getFirmwareType } from '../utils';
|
|
5
|
+
|
|
6
|
+
import type { CheckBootloaderReleaseParams } from '../types/api/checkBootloaderRelease';
|
|
5
7
|
|
|
6
8
|
export default class CheckBootloaderRelease extends BaseMethod {
|
|
7
9
|
init() {
|
|
@@ -15,7 +17,16 @@ export default class CheckBootloaderRelease extends BaseMethod {
|
|
|
15
17
|
return null;
|
|
16
18
|
}
|
|
17
19
|
const { features } = this.device;
|
|
18
|
-
const
|
|
20
|
+
const payload = this.payload as CheckBootloaderReleaseParams;
|
|
21
|
+
|
|
22
|
+
const deviceFirmwareType = getFirmwareType(features);
|
|
23
|
+
const firmwareType = payload.firmwareType ?? deviceFirmwareType;
|
|
24
|
+
|
|
25
|
+
const releaseInfo = getBootloaderReleaseInfo({
|
|
26
|
+
features,
|
|
27
|
+
willUpdateFirmwareVersion: payload.willUpdateFirmwareVersion,
|
|
28
|
+
firmwareType,
|
|
29
|
+
});
|
|
19
30
|
return Promise.resolve(releaseInfo);
|
|
20
31
|
}
|
|
21
32
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { BaseMethod } from './BaseMethod';
|
|
2
2
|
import { UI_REQUEST } from '../constants/ui-request';
|
|
3
|
-
|
|
4
3
|
import { getFirmwareReleaseInfo } from './firmware/releaseHelper';
|
|
4
|
+
import { getFirmwareType } from '../utils';
|
|
5
|
+
|
|
6
|
+
import type { CheckFirmwareReleaseParams } from '../types/api/checkFirmwareRelease';
|
|
5
7
|
|
|
6
8
|
export default class CheckFirmwareRelease extends BaseMethod {
|
|
7
9
|
init() {
|
|
@@ -15,8 +17,13 @@ export default class CheckFirmwareRelease extends BaseMethod {
|
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
run() {
|
|
20
|
+
const payload = this.payload as CheckFirmwareReleaseParams;
|
|
21
|
+
|
|
18
22
|
if (this.device.features) {
|
|
19
|
-
const
|
|
23
|
+
const deviceFirmwareType = getFirmwareType(this.device.features);
|
|
24
|
+
const firmwareType = payload.firmwareType ?? deviceFirmwareType;
|
|
25
|
+
|
|
26
|
+
const releaseInfo = getFirmwareReleaseInfo(this.device.features, firmwareType);
|
|
20
27
|
return Promise.resolve(releaseInfo);
|
|
21
28
|
}
|
|
22
29
|
return Promise.resolve(null);
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
|
+
EFirmwareType,
|
|
2
3
|
ERRORS,
|
|
3
|
-
HardwareErrorCode,
|
|
4
4
|
HardwareError,
|
|
5
|
+
HardwareErrorCode,
|
|
5
6
|
createDeferred,
|
|
6
|
-
Deferred,
|
|
7
7
|
} from '@onekeyfe/hd-shared';
|
|
8
|
+
|
|
8
9
|
import { UI_REQUEST } from '../constants/ui-request';
|
|
9
10
|
import { BaseMethod } from './BaseMethod';
|
|
10
11
|
import { validateParams } from './helpers/paramsValidator';
|
|
11
12
|
import { getBinary } from './firmware/getBinary';
|
|
12
13
|
import { uploadFirmware } from './firmware/uploadFirmware';
|
|
13
14
|
import { createUiMessage } from '../events';
|
|
14
|
-
import { type KnownDevice
|
|
15
|
-
|
|
15
|
+
import { DeviceModelToTypes, type KnownDevice } from '../types';
|
|
16
16
|
import { isEnteredManuallyBoot } from './firmware/bootloaderHelper';
|
|
17
|
-
|
|
18
17
|
import { LoggerNames, getDeviceType, getDeviceUUID, getLogger, wait } from '../utils';
|
|
19
18
|
import { DataManager } from '../data-manager';
|
|
20
19
|
import { DevicePool } from '../device/DevicePool';
|
|
21
20
|
|
|
21
|
+
import type { Deferred } from '@onekeyfe/hd-shared';
|
|
22
|
+
|
|
22
23
|
type Params = {
|
|
23
24
|
binary?: ArrayBuffer;
|
|
24
25
|
version?: number[];
|
|
@@ -189,6 +190,7 @@ export default class FirmwareUpdate extends BaseMethod<Params> {
|
|
|
189
190
|
features: device.features,
|
|
190
191
|
version: params.version,
|
|
191
192
|
updateType: params.updateType,
|
|
193
|
+
firmwareType: EFirmwareType.Universal,
|
|
192
194
|
});
|
|
193
195
|
binary = firmware.binary;
|
|
194
196
|
this.postTipMessage('DownloadFirmwareSuccess');
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
Deferred,
|
|
2
|
+
type Deferred,
|
|
4
3
|
EDeviceType,
|
|
4
|
+
type EFirmwareType,
|
|
5
5
|
ERRORS,
|
|
6
6
|
HardwareError,
|
|
7
7
|
HardwareErrorCode,
|
|
8
|
+
createDeferred,
|
|
8
9
|
} from '@onekeyfe/hd-shared';
|
|
9
10
|
import semver from 'semver';
|
|
11
|
+
|
|
10
12
|
import { UI_REQUEST } from '../constants/ui-request';
|
|
11
13
|
import { BaseMethod } from './BaseMethod';
|
|
12
14
|
import { validateParams } from './helpers/paramsValidator';
|
|
@@ -14,20 +16,21 @@ import { DevicePool } from '../device/DevicePool';
|
|
|
14
16
|
import { getBinary, getInfo, getSysResourceBinary } from './firmware/getBinary';
|
|
15
17
|
import { updateResources, uploadFirmware } from './firmware/uploadFirmware';
|
|
16
18
|
import {
|
|
19
|
+
LoggerNames,
|
|
20
|
+
getDeviceFirmwareVersion,
|
|
17
21
|
getDeviceType,
|
|
18
22
|
getDeviceUUID,
|
|
19
|
-
|
|
23
|
+
getFirmwareType,
|
|
20
24
|
getLogger,
|
|
21
|
-
|
|
22
|
-
getDeviceFirmwareVersion,
|
|
25
|
+
wait,
|
|
23
26
|
} from '../utils';
|
|
24
|
-
import {
|
|
27
|
+
import { FirmwareUpdateTipMessage, createUiMessage } from '../events/ui-request';
|
|
25
28
|
import { DeviceModelToTypes } from '../types';
|
|
26
29
|
import { DataManager } from '../data-manager';
|
|
30
|
+
import { DEVICE } from '../events';
|
|
27
31
|
|
|
28
|
-
import type {
|
|
32
|
+
import type { Features, KnownDevice } from '../types';
|
|
29
33
|
import type { Device } from '../device/Device';
|
|
30
|
-
import { DEVICE } from '../events';
|
|
31
34
|
|
|
32
35
|
type Params = {
|
|
33
36
|
binary?: ArrayBuffer;
|
|
@@ -35,6 +38,7 @@ type Params = {
|
|
|
35
38
|
updateType: 'firmware' | 'ble';
|
|
36
39
|
forcedUpdateRes?: boolean;
|
|
37
40
|
isUpdateBootloader?: boolean;
|
|
41
|
+
firmwareType?: EFirmwareType;
|
|
38
42
|
};
|
|
39
43
|
|
|
40
44
|
const Log = getLogger(LoggerNames.Method);
|
|
@@ -55,6 +59,7 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
55
59
|
{ name: 'binary', type: 'buffer' },
|
|
56
60
|
{ name: 'forcedUpdateRes', type: 'boolean' },
|
|
57
61
|
{ name: 'platform', type: 'string', required: true },
|
|
62
|
+
{ name: 'firmwareType', type: 'string' },
|
|
58
63
|
]);
|
|
59
64
|
|
|
60
65
|
if (!payload.updateType) {
|
|
@@ -74,6 +79,7 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
74
79
|
this.params = {
|
|
75
80
|
...this.params,
|
|
76
81
|
version: payload.version,
|
|
82
|
+
firmwareType: payload.firmwareType,
|
|
77
83
|
};
|
|
78
84
|
}
|
|
79
85
|
|
|
@@ -246,14 +252,14 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
246
252
|
* Check the version number of Touch to determine if it
|
|
247
253
|
* needs to be upgraded via the desktop
|
|
248
254
|
*/
|
|
249
|
-
checkVersionForCopyTouchResource(features
|
|
255
|
+
checkVersionForCopyTouchResource(features: Features | undefined, firmwareType: EFirmwareType) {
|
|
250
256
|
if (!features) return;
|
|
251
257
|
const deviceType = getDeviceType(features);
|
|
252
258
|
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
253
259
|
const targetVersion = this.params.version?.join('.');
|
|
254
260
|
const { updateType } = this.params;
|
|
255
261
|
|
|
256
|
-
const releaseInfo = getInfo({ features, updateType });
|
|
262
|
+
const releaseInfo = getInfo({ features, updateType, firmwareType });
|
|
257
263
|
if (!releaseInfo) return;
|
|
258
264
|
const { fullResourceRange } = releaseInfo;
|
|
259
265
|
if (!fullResourceRange) return;
|
|
@@ -275,7 +281,10 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
275
281
|
const { features, commands } = device;
|
|
276
282
|
const deviceType = getDeviceType(features);
|
|
277
283
|
|
|
278
|
-
|
|
284
|
+
const deviceFirmwareType = getFirmwareType(device.features);
|
|
285
|
+
const firmwareType = params.firmwareType ?? deviceFirmwareType;
|
|
286
|
+
|
|
287
|
+
this.checkVersionForCopyTouchResource(features, firmwareType);
|
|
279
288
|
|
|
280
289
|
if (!features?.bootloader_mode && features) {
|
|
281
290
|
const uuid = getDeviceUUID(features);
|
|
@@ -287,10 +296,11 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
287
296
|
// check & upgrade firmware resource
|
|
288
297
|
if (features && this.isSupportResourceUpdate(features, params.updateType)) {
|
|
289
298
|
this.postTipMessage('CheckLatestUiResource');
|
|
290
|
-
const resourceUrl = DataManager.getSysResourcesLatestRelease(
|
|
299
|
+
const resourceUrl = DataManager.getSysResourcesLatestRelease({
|
|
291
300
|
features,
|
|
292
|
-
params.forcedUpdateRes
|
|
293
|
-
|
|
301
|
+
forcedUpdateRes: params.forcedUpdateRes,
|
|
302
|
+
firmwareType,
|
|
303
|
+
});
|
|
294
304
|
if (resourceUrl) {
|
|
295
305
|
this.postTipMessage('DownloadLatestUiResource');
|
|
296
306
|
const resource = await getSysResourceBinary(resourceUrl);
|
|
@@ -360,11 +370,13 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
360
370
|
);
|
|
361
371
|
}
|
|
362
372
|
this.postTipMessage('DownloadFirmware');
|
|
373
|
+
|
|
363
374
|
const firmware = await getBinary({
|
|
364
375
|
features: device.features,
|
|
365
376
|
version: params.version,
|
|
366
377
|
updateType: params.updateType,
|
|
367
378
|
isUpdateBootloader: params.isUpdateBootloader,
|
|
379
|
+
firmwareType,
|
|
368
380
|
});
|
|
369
381
|
binary = firmware.binary;
|
|
370
382
|
this.postTipMessage('DownloadFirmwareSuccess');
|
|
@@ -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
|
|