@onekeyfe/hd-core 1.2.0-alpha.0 → 1.2.0-alpha.2

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.
Files changed (68) hide show
  1. package/__tests__/protocol-v2.test.ts +56 -178
  2. package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
  3. package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
  4. package/dist/api/FirmwareUpdateV4.d.ts +2 -2
  5. package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
  6. package/dist/api/GetDeviceInfo.d.ts.map +1 -1
  7. package/dist/api/GetFeatures.d.ts +1 -1
  8. package/dist/api/GetOnekeyFeatures.d.ts.map +1 -1
  9. package/dist/api/device/DeviceUnlock.d.ts +1 -1
  10. package/dist/api/firmware/bootloaderHelper.d.ts.map +1 -1
  11. package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
  12. package/dist/api/tron/TronSignMessage.d.ts +0 -1
  13. package/dist/api/tron/TronSignMessage.d.ts.map +1 -1
  14. package/dist/api/tron/TronSignTransaction.d.ts +0 -1
  15. package/dist/api/tron/TronSignTransaction.d.ts.map +1 -1
  16. package/dist/core/index.d.ts.map +1 -1
  17. package/dist/device/Device.d.ts +10 -15
  18. package/dist/device/Device.d.ts.map +1 -1
  19. package/dist/deviceProfile/buildDeviceFeatures.d.ts +6 -0
  20. package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -0
  21. package/dist/deviceProfile/buildDeviceProfile.d.ts +3 -4
  22. package/dist/deviceProfile/buildDeviceProfile.d.ts.map +1 -1
  23. package/dist/deviceProfile/index.d.ts +1 -1
  24. package/dist/deviceProfile/index.d.ts.map +1 -1
  25. package/dist/index.d.ts +571 -496
  26. package/dist/index.js +502 -571
  27. package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
  28. package/dist/types/api/getDeviceInfo.d.ts +2 -2
  29. package/dist/types/api/getDeviceInfo.d.ts.map +1 -1
  30. package/dist/types/device.d.ts +87 -8
  31. package/dist/types/device.d.ts.map +1 -1
  32. package/dist/utils/capabilitieUtils.d.ts.map +1 -1
  33. package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
  34. package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
  35. package/dist/utils/deviceVersionUtils.d.ts.map +1 -1
  36. package/dist/utils/findDefectiveBatchDevice.d.ts +1 -1
  37. package/dist/utils/patch.d.ts +1 -1
  38. package/package.json +4 -4
  39. package/src/api/FirmwareUpdateV2.ts +9 -2
  40. package/src/api/FirmwareUpdateV3.ts +2 -1
  41. package/src/api/FirmwareUpdateV4.ts +24 -31
  42. package/src/api/GetDeviceInfo.ts +6 -13
  43. package/src/api/GetOnekeyFeatures.ts +3 -14
  44. package/src/api/GetPassphraseState.ts +2 -2
  45. package/src/api/firmware/bootloaderHelper.ts +3 -2
  46. package/src/api/firmware/getBinary.ts +1 -1
  47. package/src/api/firmware/releaseHelper.ts +3 -3
  48. package/src/api/firmware/uploadFirmware.ts +5 -2
  49. package/src/api/tron/TronSignMessage.ts +0 -1
  50. package/src/api/tron/TronSignTransaction.ts +0 -1
  51. package/src/core/index.ts +3 -7
  52. package/src/data-manager/DataManager.ts +4 -4
  53. package/src/device/Device.ts +74 -240
  54. package/src/device/DevicePool.ts +3 -3
  55. package/src/deviceProfile/buildDeviceFeatures.ts +367 -0
  56. package/src/deviceProfile/buildDeviceProfile.ts +102 -155
  57. package/src/deviceProfile/index.ts +4 -1
  58. package/src/protocols/protocol-v2/features.ts +6 -9
  59. package/src/types/api/getDeviceInfo.ts +2 -2
  60. package/src/types/device.ts +97 -34
  61. package/src/utils/capabilitieUtils.ts +1 -2
  62. package/src/utils/deviceFeaturesUtils.ts +11 -17
  63. package/src/utils/deviceInfoUtils.ts +11 -29
  64. package/src/utils/deviceVersionUtils.ts +7 -25
  65. package/src/utils/findDefectiveBatchDevice.ts +6 -6
  66. package/dist/deviceProfile/legacyFeaturesView.d.ts +0 -5
  67. package/dist/deviceProfile/legacyFeaturesView.d.ts.map +0 -1
  68. package/src/deviceProfile/legacyFeaturesView.ts +0 -123
@@ -15,7 +15,14 @@ import { validateParams } from './helpers/paramsValidator';
15
15
  import { DevicePool } from '../device/DevicePool';
16
16
  import { getBinary, getInfo, getSysResourceBinary } from './firmware/getBinary';
17
17
  import { updateResources, uploadFirmware } from './firmware/uploadFirmware';
18
- import { LoggerNames, getDeviceFirmwareVersion, getDeviceUUID, getLogger, wait } from '../utils';
18
+ import {
19
+ LoggerNames,
20
+ getDeviceBootloaderVersion,
21
+ getDeviceFirmwareVersion,
22
+ getDeviceUUID,
23
+ getLogger,
24
+ wait,
25
+ } from '../utils';
19
26
  import { FirmwareUpdateTipMessage, createUiMessage } from '../events/ui-request';
20
27
  import { DeviceModelToTypes } from '../types';
21
28
  import { DataManager } from '../data-manager';
@@ -222,7 +229,7 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
222
229
  const isBoot183ClassicUpBle =
223
230
  this.params.updateType === 'firmware' &&
224
231
  deviceType === EDeviceType.Classic &&
225
- features.bootloader_version === '1.8.3';
232
+ getDeviceBootloaderVersion(features).join('.') === '1.8.3';
226
233
  return isMini || isBoot183ClassicUpBle;
227
234
  }
228
235
 
@@ -18,6 +18,7 @@ import { DataManager } from '../data-manager';
18
18
  import { FirmwareUpdateBaseMethod } from './firmware/FirmwareUpdateBaseMethod';
19
19
  import { DevicePool } from '../device/DevicePool';
20
20
  import { DEVICE } from '../events';
21
+ import { buildProtocolV1FeaturesPayload } from '../deviceProfile';
21
22
 
22
23
  import type { FirmwareUpdateV3Params } from '../types/api/firmwareUpdate';
23
24
  import type { Deferred, EFirmwareType } from '@onekeyfe/hd-shared';
@@ -386,7 +387,7 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
386
387
  }),
387
388
  ]);
388
389
  getFeaturesTimeoutCount = 0;
389
- const features = featuresRes.message;
390
+ const features = buildProtocolV1FeaturesPayload(featuresRes.message, this.device.features);
390
391
  const bootloaderVersion = getDeviceBootloaderVersion(features).join('.');
391
392
  const bleVersion = getDeviceBLEFirmwareVersion(features).join('.');
392
393
  const firmwareVersion = getDeviceFirmwareVersion(features).join('.');
@@ -7,7 +7,14 @@ import {
7
7
 
8
8
  import { FirmwareUpdateTipMessage, UI_REQUEST } from '../events/ui-request';
9
9
  import { validateParams } from './helpers/paramsValidator';
10
- import { LoggerNames, getFirmwareType, getLogger } from '../utils';
10
+ import {
11
+ LoggerNames,
12
+ getDeviceBLEFirmwareVersion,
13
+ getDeviceBootloaderVersion,
14
+ getDeviceFirmwareVersion,
15
+ getFirmwareType,
16
+ getLogger,
17
+ } from '../utils';
11
18
  import { getBinary, getSysResourceBinary } from './firmware/getBinary';
12
19
  import { DataManager } from '../data-manager';
13
20
  import { FirmwareUpdateBaseMethod } from './firmware/FirmwareUpdateBaseMethod';
@@ -18,7 +25,6 @@ import {
18
25
  protocolV2FileNameToTargetId,
19
26
  } from '../protocols/protocol-v2';
20
27
  import { requestProtocolV2DeviceInfo } from '../protocols/protocol-v2/features';
21
- import { buildProfileFromProtocolV2 } from '../deviceProfile';
22
28
  import {
23
29
  PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES,
24
30
  getProtocolV2UnknownErrorText,
@@ -164,8 +170,8 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
164
170
  }
165
171
 
166
172
  private async runProtocolV2() {
167
- const legacyFeatures = await this.getProtocolV2LegacyFeatures();
168
- const deviceFirmwareType = getFirmwareType(legacyFeatures);
173
+ const deviceFeatures = await this.getProtocolV2DeviceFeatures();
174
+ const deviceFirmwareType = getFirmwareType(deviceFeatures);
169
175
  const firmwareType = this.params.firmwareType ?? deviceFirmwareType;
170
176
 
171
177
  let resourceBinary: ArrayBuffer | null = null;
@@ -173,9 +179,9 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
173
179
  let bootloaderBinary: ArrayBuffer | null = null;
174
180
  try {
175
181
  this.postTipMessage(FirmwareUpdateTipMessage.StartDownloadFirmware);
176
- resourceBinary = await this.prepareResourceBinary(firmwareType, legacyFeatures);
177
- fwBinaryMap = await this.prepareFirmwareAndBleBinary(firmwareType, legacyFeatures);
178
- bootloaderBinary = await this.prepareBootloaderBinary(firmwareType, legacyFeatures);
182
+ resourceBinary = await this.prepareResourceBinary(firmwareType, deviceFeatures);
183
+ fwBinaryMap = await this.prepareFirmwareAndBleBinary(firmwareType, deviceFeatures);
184
+ bootloaderBinary = await this.prepareBootloaderBinary(firmwareType, deviceFeatures);
179
185
  // 按 DevFirmwareTargetType 拆分的目标二进制(显式 target_id,不走文件名推断)
180
186
  fwBinaryMap.push(...this.collectExplicitTargetBinaries());
181
187
  this.postTipMessage(FirmwareUpdateTipMessage.FinishDownloadFirmware);
@@ -208,9 +214,10 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
208
214
  return versions;
209
215
  }
210
216
 
211
- private async getProtocolV2LegacyFeatures() {
217
+ private async getProtocolV2DeviceFeatures(): Promise<Features> {
212
218
  if (typeof this.device.getFeatures === 'function') {
213
- return this.device.getFeatures();
219
+ const features = await this.device.getFeatures();
220
+ if (features) return features;
214
221
  }
215
222
  if (this.device.features) {
216
223
  return this.device.features;
@@ -258,11 +265,7 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
258
265
  if (typeof this.device.isBootloader === 'function') {
259
266
  return this.device.isBootloader();
260
267
  }
261
- const profile = this.device.profile;
262
- if (profile?.status?.mode === 'bootloader' || profile?.status?.bootloaderMode === true) {
263
- return true;
264
- }
265
- return !!this.device.features?.bootloader_mode;
268
+ return !!this.device.features?.bootloaderMode;
266
269
  }
267
270
 
268
271
  async enterProtocolV2BootloaderMode() {
@@ -314,11 +317,7 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
314
317
  'application_p2.bin',
315
318
  ProtocolV2FirmwareTargetType.TARGET_MAIN_APP
316
319
  );
317
- push(
318
- this.params.coprocessorBinary,
319
- 'coprocessor.bin',
320
- ProtocolV2FirmwareTargetType.TARGET_BT
321
- );
320
+ push(this.params.coprocessorBinary, 'coprocessor.bin', ProtocolV2FirmwareTargetType.TARGET_BT);
322
321
  push(this.params.se01Binary, 'se01.bin', ProtocolV2FirmwareTargetType.TARGET_SE1);
323
322
  push(this.params.se02Binary, 'se02.bin', ProtocolV2FirmwareTargetType.TARGET_SE2);
324
323
  push(this.params.se03Binary, 'se03.bin', ProtocolV2FirmwareTargetType.TARGET_SE3);
@@ -571,14 +570,13 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
571
570
  }
572
571
 
573
572
  private async waitForProtocolV2FinalFeatures() {
574
- const profile = await this.waitForProtocolV2ReconnectAndProfile(
573
+ const features = await this.waitForProtocolV2ReconnectAndFeatures(
575
574
  PROTOCOL_V2_BOOTLOADER_RECONNECT_TIMEOUT
576
575
  );
577
- this.device.updateProfile?.(profile);
578
576
 
579
- const bootloaderVersion = profile.versions.bootloader ?? '0.0.0';
580
- const bleVersion = profile.versions.ble ?? '0.0.0';
581
- const firmwareVersion = profile.versions.firmware ?? '0.0.0';
577
+ const bootloaderVersion = getDeviceBootloaderVersion(features).join('.');
578
+ const bleVersion = getDeviceBLEFirmwareVersion(features).join('.');
579
+ const firmwareVersion = getDeviceFirmwareVersion(features).join('.');
582
580
  if (firmwareVersion === '0.0.0') {
583
581
  Log.warn(
584
582
  'Protocol V2 firmware update finished but app firmware version is still 0.0.0. This is allowed for Pro2 debug BLE-only update flows.'
@@ -592,7 +590,7 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
592
590
  };
593
591
  }
594
592
 
595
- private async waitForProtocolV2ReconnectAndProfile(timeout: number) {
593
+ private async waitForProtocolV2ReconnectAndFeatures(timeout: number) {
596
594
  const startTime = Date.now();
597
595
  let lastError: unknown;
598
596
 
@@ -605,12 +603,7 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
605
603
  // 更新完成判定只需要各 target 版本号;scope 与请求内容保持一致
606
604
  request: PROTOCOL_V2_VERSIONS_DEVICE_INFO_REQUEST,
607
605
  });
608
- return buildProfileFromProtocolV2({
609
- deviceInfo,
610
- sources: ['deviceInfo'],
611
- scope: 'versions',
612
- fallbackSerialNo: this.device.originalDescriptor?.path,
613
- });
606
+ return this.device.updateProtocolV2Features(deviceInfo);
614
607
  } catch (error) {
615
608
  lastError = error;
616
609
  Log.log('Protocol V2 normal mode not ready, polling Ping: ', error);
@@ -57,7 +57,7 @@ function shouldReadOnekeyFeatures(params: GetDeviceInfoParams) {
57
57
  }
58
58
 
59
59
  function supportOnekeyFeatures(features?: Features) {
60
- if (!features || features.bootloader_mode) return false;
60
+ if (!features || features.bootloaderMode) return false;
61
61
 
62
62
  const deviceType = getDeviceType(features);
63
63
  return ![
@@ -109,14 +109,8 @@ export default class GetDeviceInfo extends BaseMethod<GetDeviceInfoParams> {
109
109
  sources,
110
110
  scope: this.params.scope,
111
111
  includeRaw: this.params.includeRaw,
112
- fallbackSerialNo: this.device.originalDescriptor?.path,
113
112
  });
114
- // 缓存走字段级合并:basic 请求不能降级已有的完整 profile;返回值仍按请求 scope 给出
115
- if (typeof this.device.applyProfileUpdate === 'function') {
116
- this.device.applyProfileUpdate(profile, protocolV2DeviceInfo);
117
- } else {
118
- this.device.updateProfile?.(profile);
119
- }
113
+ this.device.updateProtocolV2Features(protocolV2DeviceInfo);
120
114
  return profile;
121
115
  }
122
116
 
@@ -127,26 +121,25 @@ export default class GetDeviceInfo extends BaseMethod<GetDeviceInfoParams> {
127
121
 
128
122
  const sources: DeviceInfoSource[] = ['features'];
129
123
  const { features } = this.device;
130
- let onekeyFeatures: OnekeyFeatures | undefined;
124
+ let protocolV1OneKeyFeatures: OnekeyFeatures | undefined;
131
125
 
132
126
  if (shouldReadOnekeyFeatures(this.params) && supportOnekeyFeatures(features)) {
133
127
  const { message } = await this.device.commands.typedCall(
134
128
  'OnekeyGetFeatures',
135
129
  'OnekeyFeatures'
136
130
  );
137
- onekeyFeatures = normalizeOnekeyFeatures(message);
138
- sources.push('onekeyFeatures');
131
+ protocolV1OneKeyFeatures = normalizeOnekeyFeatures(message);
132
+ sources.push('protocolV1OneKeyFeatures');
139
133
  }
140
134
 
141
135
  const profile = buildProfileFromProtocolV1({
142
136
  protocol: 'V1',
143
137
  features,
144
- onekeyFeatures,
138
+ protocolV1OneKeyFeatures,
145
139
  sources,
146
140
  scope: this.params.scope,
147
141
  includeRaw: this.params.includeRaw,
148
142
  });
149
- this.device.updateProfile?.(profile);
150
143
  return profile;
151
144
  }
152
145
  }
@@ -4,7 +4,6 @@ import { UI_REQUEST } from '../constants/ui-request';
4
4
  import { fixVersion } from '../utils/deviceFeaturesUtils';
5
5
  import { PROTOCOL_V2_DEVICE_INFO_REQUEST } from '../protocols/protocol-v2';
6
6
  import { requestProtocolV2DeviceInfo } from '../protocols/protocol-v2/features';
7
- import { buildProfileFromProtocolV2, buildProtocolV2GetFeaturesPayload } from '../deviceProfile';
8
7
  import { BaseMethod } from './BaseMethod';
9
8
 
10
9
  import type { OnekeyFeatures } from '../types';
@@ -91,23 +90,13 @@ export default class GetOnekeyFeatures extends BaseMethod {
91
90
  async run() {
92
91
  if (this.device.isProtocolV2()) {
93
92
  // V2 没有 OnekeyGetFeatures 消息:
94
- // 取完整 DevGetDeviceInfo(含 SE/hash/build_id)后写入 features 兼容视图。
93
+ // 取完整 DevGetDeviceInfo(含 SE/hash/build_id)后刷新结构化 features 缓存。
95
94
  const deviceInfo = await requestProtocolV2DeviceInfo({
96
95
  commands: this.device.commands,
97
96
  request: PROTOCOL_V2_DEVICE_INFO_REQUEST,
98
97
  });
99
- const profile = this.device.applyProfileUpdate(
100
- buildProfileFromProtocolV2({
101
- deviceInfo,
102
- sources: ['deviceInfo'],
103
- scope: 'verify',
104
- fallbackSerialNo: this.device.originalDescriptor?.path,
105
- }),
106
- deviceInfo
107
- );
108
- return pickOnekeyFeatures(
109
- buildProtocolV2GetFeaturesPayload(profile, deviceInfo) as OnekeyFeatures
110
- );
98
+ const features = this.device.updateProtocolV2Features(deviceInfo);
99
+ return pickOnekeyFeatures(features as OnekeyFeatures);
111
100
  }
112
101
 
113
102
  const { message } = await this.device.commands.typedCall('OnekeyGetFeatures', 'OnekeyFeatures');
@@ -26,8 +26,8 @@ export default class GetPassphraseState extends BaseMethod {
26
26
  // refresh device info
27
27
  return Promise.resolve({
28
28
  passphrase_state: isProSeries || passphraseProtection === true ? passphraseState : undefined,
29
- session_id: newSession ?? features?.session_id ?? undefined,
30
- unlocked_attach_pin: unlockedAttachPin ?? features?.unlocked_attach_pin,
29
+ session_id: newSession ?? features?.sessionId ?? undefined,
30
+ unlocked_attach_pin: unlockedAttachPin ?? features?.unlockedAttachPin,
31
31
  passphrase_protection: passphraseProtection,
32
32
  });
33
33
  }
@@ -1,7 +1,7 @@
1
1
  import semver from 'semver';
2
2
  import { EDeviceType } from '@onekeyfe/hd-shared';
3
3
 
4
- import { getDeviceType } from '../../utils';
4
+ import { getDeviceBootloaderVersion, getDeviceType } from '../../utils';
5
5
 
6
6
  import type { Features, IVersionArray } from '../../types';
7
7
 
@@ -38,9 +38,10 @@ export function shouldUpdateBootloaderForClassicAndMini({
38
38
  export function isEnteredManuallyBoot(features: Features, updateType: string) {
39
39
  const deviceType = getDeviceType(features);
40
40
  const isMini = deviceType === EDeviceType.Mini;
41
+ const bootloaderVersion = getDeviceBootloaderVersion(features).join('.');
41
42
  const isBoot183ClassicUpBle =
42
43
  updateType === 'firmware' &&
43
44
  deviceType === EDeviceType.Classic &&
44
- features.bootloader_version === '1.8.3';
45
+ bootloaderVersion === '1.8.3';
45
46
  return isMini || isBoot183ClassicUpBle;
46
47
  }
@@ -41,7 +41,7 @@ export const getBinary = async ({
41
41
  }
42
42
 
43
43
  if (version && !semver.eq(releaseInfo.version.join('.'), version.join('.'))) {
44
- const touchWithoutVersion = getDeviceType(features) === 'touch' && !features.onekey_version;
44
+ const touchWithoutVersion = getDeviceType(features) === 'touch' && !features.firmwareVersion;
45
45
  if (!touchWithoutVersion) {
46
46
  throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'firmware version mismatch');
47
47
  }
@@ -12,7 +12,7 @@ export const getFirmwareReleaseInfo = (features: Features, firmwareType: EFirmwa
12
12
  const firmwareStatus = DataManager.getFirmwareStatus(features, firmwareType);
13
13
  const changelog = DataManager.getFirmwareChangelog(features, firmwareType);
14
14
  const release = DataManager.getFirmwareLatestRelease(features, firmwareType);
15
- const bootloaderMode = !!features.bootloader_mode;
15
+ const bootloaderMode = !!features.bootloaderMode;
16
16
  return {
17
17
  status: firmwareStatus,
18
18
  changelog,
@@ -25,7 +25,7 @@ export const getBleFirmwareReleaseInfo = (features: Features) => {
25
25
  const firmwareStatus = DataManager.getBLEFirmwareStatus(features);
26
26
  const changelog = DataManager.getBleFirmwareChangelog(features);
27
27
  const release = DataManager.getBleFirmwareLatestRelease(features);
28
- const bootloaderMode = !!features.bootloader_mode;
28
+ const bootloaderMode = !!features.bootloaderMode;
29
29
  return {
30
30
  status: firmwareStatus,
31
31
  changelog,
@@ -52,7 +52,7 @@ export const getBootloaderReleaseInfo = ({
52
52
  Object.prototype.hasOwnProperty.call(item, 'en-US')
53
53
  );
54
54
 
55
- const bootloaderMode = !!features.bootloader_mode;
55
+ const bootloaderMode = !!features.bootloaderMode;
56
56
 
57
57
  let shouldUpdate = false;
58
58
 
@@ -9,6 +9,7 @@ import { DeviceModelToTypes } from '../../types';
9
9
  import { bytesToHex } from '../helpers/hexUtils';
10
10
  import { DataManager } from '../../data-manager';
11
11
  import { DevicePool } from '../../device/DevicePool';
12
+ import { buildProtocolV1FeaturesPayload } from '../../deviceProfile';
12
13
 
13
14
  import type { KnownDevice } from '../../types';
14
15
  import type { TypedCall, TypedResponseMessage } from '../../device/DeviceCommands';
@@ -34,7 +35,7 @@ const isDeviceDisconnectedError = (error: unknown) => {
34
35
 
35
36
  const postConfirmationMessage = (device: Device) => {
36
37
  // only if firmware is already installed. fresh device does not require button confirmation
37
- if (device.features?.firmware_present) {
38
+ if (device.features?.firmwarePresent) {
38
39
  device.emit(DEVICE.BUTTON, device, { code: 'ButtonRequest_FirmwareUpdate' });
39
40
  }
40
41
  };
@@ -109,7 +110,9 @@ export const uploadFirmware = async (
109
110
 
110
111
  if (isFirmware && !isUpdateBootloader) {
111
112
  const newFeatures = await typedCall('GetFeatures', 'Features', {});
112
- const deviceBootloaderVersion = getDeviceBootloaderVersion(newFeatures.message).join('.');
113
+ const deviceBootloaderVersion = getDeviceBootloaderVersion(
114
+ buildProtocolV1FeaturesPayload(newFeatures.message, device.features)
115
+ ).join('.');
113
116
  const supportUpgradeFileHeader = semver.gte(deviceBootloaderVersion, '2.1.0');
114
117
  Log.debug('supportUpgradeFileHeader:', supportUpgradeFileHeader);
115
118
 
@@ -47,7 +47,6 @@ export default class TronSignMessage extends BaseMethod<HardwareTronSignMessage>
47
47
  return {
48
48
  pro2: {
49
49
  min: '0.0.0',
50
- unsupported: true,
51
50
  },
52
51
  model_mini: {
53
52
  min: '2.5.0',
@@ -150,7 +150,6 @@ export default class TronSignTransaction extends BaseMethod<TronSignTx> {
150
150
  return {
151
151
  pro2: {
152
152
  min: '0.0.0',
153
- unsupported: true,
154
153
  },
155
154
  model_mini: {
156
155
  min: '2.5.0',
package/src/core/index.ts CHANGED
@@ -57,16 +57,12 @@ import DeviceConnector from '../device/DeviceConnector';
57
57
  import RequestQueue from './RequestQueue';
58
58
  import { getSynchronize } from '../utils/getSynchronize';
59
59
 
60
- import type { ConnectSettings, KnownDevice } from '../types';
60
+ import type { ConnectSettings, Features, KnownDevice } from '../types';
61
61
  import type { CoreMessage, IFrameCallMessage, UiPromise, UiPromiseResponse } from '../events';
62
62
  import type { DeviceEvents, InitOptions, RunOptions } from '../device/Device';
63
63
  import type { SdkTracingContext } from '../utils/tracing';
64
64
  import type { Deferred } from '@onekeyfe/hd-shared';
65
- import type {
66
- Features,
67
- LowlevelTransportSharedPlugin,
68
- OneKeyDeviceInfo,
69
- } from '@onekeyfe/hd-transport';
65
+ import type { LowlevelTransportSharedPlugin, OneKeyDeviceInfo } from '@onekeyfe/hd-transport';
70
66
  import type { BaseMethod } from '../api/BaseMethod';
71
67
 
72
68
  const Log = getLogger(LoggerNames.Core);
@@ -1115,7 +1111,7 @@ const checkPassphraseEnableState = (method: BaseMethod, features?: Features) =>
1115
1111
 
1116
1112
  const passphraseProtection = method.device
1117
1113
  ? method.device.getCurrentPassphraseProtection()
1118
- : features?.passphrase_protection;
1114
+ : features?.passphraseProtection;
1119
1115
 
1120
1116
  if (passphraseProtection === true) {
1121
1117
  const hasNoPassphraseState =
@@ -114,11 +114,11 @@ export default class DataManager {
114
114
 
115
115
  const deviceFirmwareType = getFirmwareType(features);
116
116
  const deviceFirmwareVersion = getDeviceFirmwareVersion(features);
117
- if (features.firmware_present === false) {
117
+ if (features.firmwarePresent === false) {
118
118
  return 'none';
119
119
  }
120
120
 
121
- if (DeviceModelToTypes.model_mini.includes(deviceType) && features.bootloader_mode) {
121
+ if (DeviceModelToTypes.model_mini.includes(deviceType) && features.bootloaderMode) {
122
122
  return 'unknown';
123
123
  }
124
124
 
@@ -264,8 +264,8 @@ export default class DataManager {
264
264
  const targetDeviceConfigList = this.deviceMap[deviceType]?.[firmwareUpdateField] ?? [];
265
265
 
266
266
  if (
267
- features.firmware_present === false ||
268
- (DeviceModelToTypes.model_classic.includes(deviceType) && features.bootloader_mode)
267
+ features.firmwarePresent === false ||
268
+ (DeviceModelToTypes.model_classic.includes(deviceType) && features.bootloaderMode)
269
269
  ) {
270
270
  // Always return least changelog
271
271
  return getReleaseChangelog(targetDeviceConfigList, '0.0.0');