@onekeyfe/hd-core 1.1.27-alpha.30 → 1.1.27-alpha.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/evmSignTransaction.test.ts +1 -1
- package/__tests__/evmSignTypedData.test.ts +1 -1
- package/__tests__/protocol-v2.test.ts +189 -33
- package/dist/api/GetPassphraseState.d.ts +6 -1
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignTransaction.d.ts.map +1 -1
- package/dist/api/dynex/DnxGetAddress.d.ts.map +1 -1
- package/dist/api/dynex/DnxSignTransaction.d.ts.map +1 -1
- package/dist/api/helpers/batchGetPublickeys.d.ts.map +1 -1
- package/dist/api/index.d.ts +5 -5
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceReboot.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceReboot.d.ts.map +1 -0
- package/dist/api/protocol-v2/helpers.d.ts +19 -19
- package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +4 -3
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/MessagesConfig.d.ts +2 -2
- package/dist/data-manager/MessagesConfig.d.ts.map +1 -1
- package/dist/data-manager/TransportManager.d.ts +3 -3
- package/dist/data-manager/TransportManager.d.ts.map +1 -1
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/index.d.ts +34 -27
- package/dist/index.js +231 -184
- package/dist/protocols/protocol-v2/features.d.ts +1 -0
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/firmware.d.ts +7 -7
- package/dist/types/api/getPassphraseState.d.ts +7 -1
- package/dist/types/api/getPassphraseState.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +7 -6
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +16 -16
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +3 -3
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/FirmwareUpdateV4.ts +13 -13
- package/src/api/GetPassphraseState.ts +14 -2
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +15 -0
- package/src/api/conflux/ConfluxSignTransaction.ts +5 -2
- package/src/api/device/DeviceRebootToBoardloader.ts +4 -4
- package/src/api/device/DeviceRebootToBootloader.ts +4 -4
- package/src/api/dynex/DnxGetAddress.ts +7 -0
- package/src/api/dynex/DnxSignTransaction.ts +7 -0
- package/src/api/evm/EVMGetAddress.ts +1 -1
- package/src/api/evm/EVMGetPublicKey.ts +1 -1
- package/src/api/evm/EVMSignMessage.ts +1 -1
- package/src/api/evm/EVMSignTransaction.ts +1 -1
- package/src/api/evm/EVMSignTypedData.ts +6 -6
- package/src/api/evm/EVMVerifyMessage.ts +1 -1
- package/src/api/helpers/batchGetPublickeys.ts +4 -2
- package/src/api/index.ts +5 -5
- package/src/api/protocol-v2/{DevFirmwareUpdate.ts → DeviceFirmwareUpdate.ts} +3 -3
- package/src/api/protocol-v2/{DevGetDeviceInfo.ts → DeviceGetDeviceInfo.ts} +3 -3
- package/src/api/protocol-v2/{DevGetFirmwareUpdateStatus.ts → DeviceGetFirmwareUpdateStatus.ts} +3 -3
- package/src/api/protocol-v2/{DevGetOnboardingStatus.ts → DeviceGetOnboardingStatus.ts} +3 -3
- package/src/api/protocol-v2/{DevReboot.ts → DeviceReboot.ts} +3 -3
- package/src/api/protocol-v2/helpers.ts +38 -38
- package/src/api/tron/TronSignMessage.ts +1 -1
- package/src/api/xrp/XrpSignTransaction.ts +1 -1
- package/src/core/index.ts +5 -1
- package/src/data/messages/messages-pro2.json +67 -63
- package/src/data-manager/DataManager.ts +7 -6
- package/src/data-manager/MessagesConfig.ts +14 -14
- package/src/data-manager/TransportManager.ts +12 -12
- package/src/device/Device.ts +7 -3
- package/src/inject.ts +9 -9
- package/src/protocols/protocol-v2/features.ts +7 -6
- package/src/protocols/protocol-v2/firmware.ts +16 -16
- package/src/types/api/getPassphraseState.ts +10 -1
- package/src/types/api/index.ts +11 -10
- package/src/types/api/protocolV2.ts +27 -27
- package/src/utils/deviceFeaturesUtils.ts +33 -15
- package/dist/api/protocol-v2/DevFirmwareUpdate.d.ts +0 -7
- package/dist/api/protocol-v2/DevFirmwareUpdate.d.ts.map +0 -1
- package/dist/api/protocol-v2/DevGetDeviceInfo.d.ts +0 -7
- package/dist/api/protocol-v2/DevGetDeviceInfo.d.ts.map +0 -1
- package/dist/api/protocol-v2/DevGetFirmwareUpdateStatus.d.ts +0 -6
- package/dist/api/protocol-v2/DevGetFirmwareUpdateStatus.d.ts.map +0 -1
- package/dist/api/protocol-v2/DevGetOnboardingStatus.d.ts +0 -6
- package/dist/api/protocol-v2/DevGetOnboardingStatus.d.ts.map +0 -1
- package/dist/api/protocol-v2/DevReboot.d.ts +0 -7
- package/dist/api/protocol-v2/DevReboot.d.ts.map +0 -1
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { createDeviceNotSupportMethodError } from '@onekeyfe/hd-shared';
|
|
2
|
+
|
|
1
3
|
import { UI_REQUEST } from '../../constants/ui-request';
|
|
2
4
|
import { serializedPath, validatePath } from '../helpers/pathUtils';
|
|
3
5
|
import { BaseMethod } from '../BaseMethod';
|
|
4
6
|
import { validateParams } from '../helpers/paramsValidator';
|
|
5
7
|
import { stripHexPrefix } from '../helpers/hexUtils';
|
|
8
|
+
import { getFirmwareType } from '../../utils';
|
|
6
9
|
|
|
7
10
|
import type { TypedResponseMessage } from '../../device/DeviceCommands';
|
|
8
11
|
import type { DnxSignature } from '../../types';
|
|
@@ -115,6 +118,10 @@ export default class DnxSignTransaction extends BaseMethod<DnxSignTx> {
|
|
|
115
118
|
}
|
|
116
119
|
|
|
117
120
|
async run() {
|
|
121
|
+
if (this.device.originalDescriptor?.protocolType === 'V2') {
|
|
122
|
+
throw createDeviceNotSupportMethodError(this.name, getFirmwareType(this.device.features));
|
|
123
|
+
}
|
|
124
|
+
|
|
118
125
|
const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
|
|
119
126
|
|
|
120
127
|
const res = await this.device.commands.typedCall('DnxSignTx', 'DnxInputRequest', {
|
|
@@ -44,7 +44,7 @@ export default class EvmGetAddress extends BaseMethod<EthereumGetAddressOneKey[]
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
async getEvmAddress(param: EthereumGetAddressOneKey) {
|
|
47
|
-
if (TransportManager.
|
|
47
|
+
if (TransportManager.getProtocolV1MessageSchema() === 'protocolV1Legacy') {
|
|
48
48
|
return getAddressLegacyV1({
|
|
49
49
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
50
50
|
param,
|
|
@@ -57,7 +57,7 @@ export default class EVMGetPublicKey extends BaseMethod<EthereumGetPublicKeyOneK
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
getEvmPublicKey(param: EthereumGetPublicKey) {
|
|
60
|
-
if (TransportManager.
|
|
60
|
+
if (TransportManager.getProtocolV1MessageSchema() === 'protocolV1Legacy') {
|
|
61
61
|
return getPublicKeyLegacyV1({
|
|
62
62
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
63
63
|
param,
|
|
@@ -34,7 +34,7 @@ export default class EVMSignMessage extends BaseMethod<EthereumSignMessageOneKey
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
async run() {
|
|
37
|
-
if (TransportManager.
|
|
37
|
+
if (TransportManager.getProtocolV1MessageSchema() === 'protocolV1Legacy') {
|
|
38
38
|
return signMessageLegacyV1({
|
|
39
39
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
40
40
|
params: this.params,
|
|
@@ -120,7 +120,7 @@ export default class EVMSignTransaction extends BaseMethod {
|
|
|
120
120
|
|
|
121
121
|
if (formattedTx == null) throw ERRORS.TypedError('Runtime', 'formattedTx is not set');
|
|
122
122
|
|
|
123
|
-
if (TransportManager.
|
|
123
|
+
if (TransportManager.getProtocolV1MessageSchema() === 'protocolV1Legacy') {
|
|
124
124
|
return signTransactionLegacyV1({
|
|
125
125
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
126
126
|
addressN,
|
|
@@ -260,8 +260,8 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
260
260
|
|
|
261
261
|
let supportTrezor = false;
|
|
262
262
|
let response: MessageResponse<MessageKey>;
|
|
263
|
-
switch (TransportManager.
|
|
264
|
-
case '
|
|
263
|
+
switch (TransportManager.getProtocolV1MessageSchema()) {
|
|
264
|
+
case 'protocolV1Legacy':
|
|
265
265
|
supportTrezor = true;
|
|
266
266
|
response = await signTypedDataLegacyV1({
|
|
267
267
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
@@ -272,7 +272,7 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
272
272
|
});
|
|
273
273
|
break;
|
|
274
274
|
|
|
275
|
-
case '
|
|
275
|
+
case 'protocolV1Current':
|
|
276
276
|
default:
|
|
277
277
|
supportTrezor = false;
|
|
278
278
|
response = await signTypedData({
|
|
@@ -308,8 +308,8 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
308
308
|
}) {
|
|
309
309
|
if (!domainHash) throw ERRORS.TypedError('Runtime', 'domainHash is required');
|
|
310
310
|
|
|
311
|
-
switch (TransportManager.
|
|
312
|
-
case '
|
|
311
|
+
switch (TransportManager.getProtocolV1MessageSchema()) {
|
|
312
|
+
case 'protocolV1Legacy':
|
|
313
313
|
return signTypedHashLegacyV1({
|
|
314
314
|
typedCall,
|
|
315
315
|
addressN,
|
|
@@ -319,7 +319,7 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
319
319
|
device: this.device,
|
|
320
320
|
});
|
|
321
321
|
|
|
322
|
-
case '
|
|
322
|
+
case 'protocolV1Current':
|
|
323
323
|
default:
|
|
324
324
|
return signTypedHash({
|
|
325
325
|
typedCall,
|
|
@@ -31,7 +31,7 @@ export default class EVMSignMessage extends BaseMethod<EthereumVerifyMessageOneK
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
async run() {
|
|
34
|
-
if (TransportManager.
|
|
34
|
+
if (TransportManager.getProtocolV1MessageSchema() === 'protocolV1Legacy') {
|
|
35
35
|
return verifyMessageLegacyV1({
|
|
36
36
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
37
37
|
params: this.params,
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import { supportBatchPublicKey } from '../../utils/deviceFeaturesUtils';
|
|
8
8
|
import { isEqualBip44CoinType } from './pathUtils';
|
|
9
9
|
import { splitArray } from '../../utils/arrayUtils';
|
|
10
|
-
import { getDeviceType, getFirmwareType } from '../../utils';
|
|
10
|
+
import { getDeviceType, getFirmwareType, shouldSkipMethodSupportCheck } from '../../utils';
|
|
11
11
|
import { DeviceModelToTypes } from '../../types';
|
|
12
12
|
|
|
13
13
|
import type { EcdsaPublicKeys, Path } from '@onekeyfe/hd-transport';
|
|
@@ -28,7 +28,9 @@ export async function batchGetPublickeys(
|
|
|
28
28
|
throw TypedError(HardwareErrorCode.ForbiddenKeyPath, 'Path length must be greater than 3');
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
const supportsBatchPublicKey =
|
|
31
|
+
const supportsBatchPublicKey =
|
|
32
|
+
shouldSkipMethodSupportCheck(device.features, device.originalDescriptor?.protocolType) ||
|
|
33
|
+
supportBatchPublicKey(device.features, options);
|
|
32
34
|
if (!supportsBatchPublicKey) {
|
|
33
35
|
throw createDeviceNotSupportMethodError('BatchGetPublickeys', getFirmwareType(device.features));
|
|
34
36
|
}
|
package/src/api/index.ts
CHANGED
|
@@ -43,11 +43,11 @@ export { default as promptWebDeviceAccess } from './PromptWebDeviceAccess';
|
|
|
43
43
|
// File system & device control API (Protocol V2 only)
|
|
44
44
|
export { default as getProtoVersion } from './protocol-v2/GetProtoVersion';
|
|
45
45
|
export { default as ping } from './protocol-v2/Ping';
|
|
46
|
-
export { default as
|
|
47
|
-
export { default as
|
|
48
|
-
export { default as
|
|
49
|
-
export { default as
|
|
50
|
-
export { default as
|
|
46
|
+
export { default as deviceReboot } from './protocol-v2/DeviceReboot';
|
|
47
|
+
export { default as deviceGetDeviceInfo } from './protocol-v2/DeviceGetDeviceInfo';
|
|
48
|
+
export { default as deviceGetOnboardingStatus } from './protocol-v2/DeviceGetOnboardingStatus';
|
|
49
|
+
export { default as deviceFirmwareUpdate } from './protocol-v2/DeviceFirmwareUpdate';
|
|
50
|
+
export { default as deviceGetFirmwareUpdateStatus } from './protocol-v2/DeviceGetFirmwareUpdateStatus';
|
|
51
51
|
export { default as factoryDeviceInfoSettings } from './protocol-v2/FactoryDeviceInfoSettings';
|
|
52
52
|
export { default as factoryGetDeviceInfo } from './protocol-v2/FactoryGetDeviceInfo';
|
|
53
53
|
export { default as filesystemFixPermission } from './protocol-v2/FilesystemFixPermission';
|
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
normalizeFirmwareTargets,
|
|
6
6
|
} from './helpers';
|
|
7
7
|
|
|
8
|
-
import type {
|
|
8
|
+
import type { DeviceFirmwareUpdateParams } from './helpers';
|
|
9
9
|
|
|
10
|
-
export default class
|
|
10
|
+
export default class DeviceFirmwareUpdate extends BaseMethod<DeviceFirmwareUpdateParams> {
|
|
11
11
|
init() {
|
|
12
12
|
this.skipForceUpdateCheck = true;
|
|
13
13
|
this.useDevicePassphraseState = false;
|
|
@@ -21,7 +21,7 @@ export default class DevFirmwareUpdate extends BaseMethod<DevFirmwareUpdateParam
|
|
|
21
21
|
|
|
22
22
|
async run() {
|
|
23
23
|
const res = await this.device.commands.typedCall(
|
|
24
|
-
'
|
|
24
|
+
'DeviceFirmwareUpdate',
|
|
25
25
|
PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES,
|
|
26
26
|
{
|
|
27
27
|
targets: normalizeFirmwareTargets(this.params),
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseMethod } from '../BaseMethod';
|
|
2
2
|
import { buildTargets, buildTypes } from './helpers';
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type { DeviceGetDeviceInfoParams } from './helpers';
|
|
5
5
|
|
|
6
|
-
export default class
|
|
6
|
+
export default class DeviceGetDeviceInfo extends BaseMethod<DeviceGetDeviceInfoParams> {
|
|
7
7
|
init() {
|
|
8
8
|
this.skipForceUpdateCheck = true;
|
|
9
9
|
this.useDevicePassphraseState = false;
|
|
@@ -26,7 +26,7 @@ export default class DevGetDeviceInfo extends BaseMethod<DevGetDeviceInfoParams>
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
async run() {
|
|
29
|
-
const res = await this.device.commands.typedCall('
|
|
29
|
+
const res = await this.device.commands.typedCall('DeviceGetDeviceInfo', 'DeviceInfo', {
|
|
30
30
|
targets: buildTargets(this.params),
|
|
31
31
|
types: buildTypes(this.params),
|
|
32
32
|
});
|
package/src/api/protocol-v2/{DevGetFirmwareUpdateStatus.ts → DeviceGetFirmwareUpdateStatus.ts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseMethod } from '../BaseMethod';
|
|
2
2
|
|
|
3
|
-
export default class
|
|
3
|
+
export default class DeviceGetFirmwareUpdateStatus extends BaseMethod {
|
|
4
4
|
init() {
|
|
5
5
|
this.skipForceUpdateCheck = true;
|
|
6
6
|
this.useDevicePassphraseState = false;
|
|
@@ -9,8 +9,8 @@ export default class DevGetFirmwareUpdateStatus extends BaseMethod {
|
|
|
9
9
|
|
|
10
10
|
async run() {
|
|
11
11
|
const res = await this.device.commands.typedCall(
|
|
12
|
-
'
|
|
13
|
-
'
|
|
12
|
+
'DeviceGetFirmwareUpdateStatus',
|
|
13
|
+
'DeviceFirmwareUpdateStatus',
|
|
14
14
|
{}
|
|
15
15
|
);
|
|
16
16
|
return Promise.resolve(res.message);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseMethod } from '../BaseMethod';
|
|
2
2
|
|
|
3
|
-
export default class
|
|
3
|
+
export default class DeviceGetOnboardingStatus extends BaseMethod {
|
|
4
4
|
init() {
|
|
5
5
|
this.skipForceUpdateCheck = true;
|
|
6
6
|
this.useDevicePassphraseState = false;
|
|
@@ -9,8 +9,8 @@ export default class DevGetOnboardingStatus extends BaseMethod {
|
|
|
9
9
|
|
|
10
10
|
async run() {
|
|
11
11
|
const res = await this.device.commands.typedCall(
|
|
12
|
-
'
|
|
13
|
-
'
|
|
12
|
+
'DeviceGetOnboardingStatus',
|
|
13
|
+
'DeviceOnboardingStatus',
|
|
14
14
|
{}
|
|
15
15
|
);
|
|
16
16
|
return Promise.resolve(res.message);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseMethod } from '../BaseMethod';
|
|
2
2
|
import { normalizeRebootType } from './helpers';
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type { DeviceRebootParams } from './helpers';
|
|
5
5
|
|
|
6
|
-
export default class
|
|
6
|
+
export default class DeviceReboot extends BaseMethod<DeviceRebootParams> {
|
|
7
7
|
init() {
|
|
8
8
|
this.skipForceUpdateCheck = true;
|
|
9
9
|
this.useDevicePassphraseState = false;
|
|
@@ -14,7 +14,7 @@ export default class DevReboot extends BaseMethod<DevRebootParams> {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
async run() {
|
|
17
|
-
const res = await this.device.commands.typedCall('
|
|
17
|
+
const res = await this.device.commands.typedCall('DeviceReboot', 'Success', {
|
|
18
18
|
reboot_type: normalizeRebootType(this.params.reboot_type ?? this.params.rebootType),
|
|
19
19
|
});
|
|
20
20
|
return Promise.resolve(res.message);
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DeviceRebootType } from '@onekeyfe/hd-transport';
|
|
2
2
|
|
|
3
3
|
import type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
DeviceFirmwareTarget,
|
|
5
|
+
DeviceFirmwareTargetType,
|
|
6
|
+
DeviceInfoTargets,
|
|
7
|
+
DeviceInfoTypes,
|
|
8
8
|
TransportCallOptions,
|
|
9
9
|
} from '@onekeyfe/hd-transport';
|
|
10
10
|
|
|
11
|
-
export type RebootTypeInput =
|
|
11
|
+
export type RebootTypeInput = DeviceRebootType | keyof typeof DeviceRebootType | string | number;
|
|
12
12
|
|
|
13
|
-
export type
|
|
13
|
+
export type DeviceRebootParams = {
|
|
14
14
|
rebootType?: RebootTypeInput;
|
|
15
15
|
reboot_type?: RebootTypeInput;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
export type
|
|
19
|
-
targets?:
|
|
20
|
-
types?:
|
|
18
|
+
export type DeviceGetDeviceInfoParams = {
|
|
19
|
+
targets?: DeviceInfoTargets;
|
|
20
|
+
types?: DeviceInfoTypes;
|
|
21
21
|
targetHw?: boolean;
|
|
22
22
|
targetFw?: boolean;
|
|
23
23
|
targetBt?: boolean;
|
|
@@ -32,18 +32,18 @@ export type DevGetDeviceInfoParams = {
|
|
|
32
32
|
includeSpecific?: boolean;
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
export type
|
|
36
|
-
|
|
|
35
|
+
export type DeviceFirmwareTargetInput =
|
|
36
|
+
| DeviceFirmwareTarget
|
|
37
37
|
| {
|
|
38
|
-
targetId?:
|
|
39
|
-
target_id?:
|
|
38
|
+
targetId?: DeviceFirmwareTargetType | string | number;
|
|
39
|
+
target_id?: DeviceFirmwareTargetType | string | number;
|
|
40
40
|
path: string;
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
export type
|
|
44
|
-
targets?:
|
|
45
|
-
targetId?:
|
|
46
|
-
target_id?:
|
|
43
|
+
export type DeviceFirmwareUpdateParams = {
|
|
44
|
+
targets?: DeviceFirmwareTargetInput[];
|
|
45
|
+
targetId?: DeviceFirmwareTargetType | string | number;
|
|
46
|
+
target_id?: DeviceFirmwareTargetType | string | number;
|
|
47
47
|
path?: string;
|
|
48
48
|
};
|
|
49
49
|
|
|
@@ -56,42 +56,42 @@ export type FactoryDeviceInfoSettingsParams = {
|
|
|
56
56
|
preFirmware?: string;
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
-
const
|
|
60
|
-
Normal:
|
|
61
|
-
normal:
|
|
62
|
-
Boardloader:
|
|
63
|
-
boardloader:
|
|
64
|
-
Bootloader:
|
|
65
|
-
bootloader:
|
|
59
|
+
const DEVICE_REBOOT_TYPES: Record<string, DeviceRebootType> = {
|
|
60
|
+
Normal: DeviceRebootType.Normal,
|
|
61
|
+
normal: DeviceRebootType.Normal,
|
|
62
|
+
Boardloader: DeviceRebootType.Boardloader,
|
|
63
|
+
boardloader: DeviceRebootType.Boardloader,
|
|
64
|
+
Bootloader: DeviceRebootType.Bootloader,
|
|
65
|
+
bootloader: DeviceRebootType.Bootloader,
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
export const PROTOCOL_V2_FIRMWARE_UPDATE_OPTIONS: TransportCallOptions = {
|
|
69
|
-
intermediateTypes: ['
|
|
69
|
+
intermediateTypes: ['DeviceFirmwareInstallProgress'],
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
-
export const PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES: ('Success' | '
|
|
73
|
-
['Success', '
|
|
72
|
+
export const PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES: ('Success' | 'DeviceFirmwareUpdateStatus')[] =
|
|
73
|
+
['Success', 'DeviceFirmwareUpdateStatus'];
|
|
74
74
|
|
|
75
|
-
export function normalizeRebootType(value: RebootTypeInput | undefined):
|
|
75
|
+
export function normalizeRebootType(value: RebootTypeInput | undefined): DeviceRebootType {
|
|
76
76
|
if (typeof value === 'number') return value;
|
|
77
77
|
if (typeof value === 'string') {
|
|
78
78
|
const numeric = Number(value);
|
|
79
79
|
if (Number.isFinite(numeric)) return numeric;
|
|
80
|
-
if (value in
|
|
80
|
+
if (value in DEVICE_REBOOT_TYPES) return DEVICE_REBOOT_TYPES[value];
|
|
81
81
|
}
|
|
82
|
-
return
|
|
82
|
+
return DeviceRebootType.Normal;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
function normalizeTargetId(
|
|
86
|
-
value:
|
|
87
|
-
):
|
|
86
|
+
value: DeviceFirmwareTargetType | string | number | undefined
|
|
87
|
+
): DeviceFirmwareTargetType {
|
|
88
88
|
if (typeof value === 'number') return value;
|
|
89
89
|
const numeric = Number(value);
|
|
90
90
|
if (Number.isFinite(numeric)) return numeric;
|
|
91
91
|
return 0;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
export function normalizeFirmwareTargets(params:
|
|
94
|
+
export function normalizeFirmwareTargets(params: DeviceFirmwareUpdateParams): DeviceFirmwareTarget[] {
|
|
95
95
|
const targets =
|
|
96
96
|
params.targets ??
|
|
97
97
|
(params.path
|
|
@@ -109,10 +109,10 @@ export function normalizeFirmwareTargets(params: DevFirmwareUpdateParams): DevFi
|
|
|
109
109
|
}));
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
export function buildTargets(params:
|
|
112
|
+
export function buildTargets(params: DeviceGetDeviceInfoParams): DeviceInfoTargets | undefined {
|
|
113
113
|
if (params.targets) return params.targets;
|
|
114
114
|
|
|
115
|
-
const targets:
|
|
115
|
+
const targets: DeviceInfoTargets = {
|
|
116
116
|
hw: params.targetHw,
|
|
117
117
|
fw: params.targetFw,
|
|
118
118
|
bt: params.targetBt,
|
|
@@ -125,10 +125,10 @@ export function buildTargets(params: DevGetDeviceInfoParams): DevInfoTargets | u
|
|
|
125
125
|
return Object.values(targets).some(value => value !== undefined) ? targets : undefined;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
export function buildTypes(params:
|
|
128
|
+
export function buildTypes(params: DeviceGetDeviceInfoParams): DeviceInfoTypes | undefined {
|
|
129
129
|
if (params.types) return params.types;
|
|
130
130
|
|
|
131
|
-
const types:
|
|
131
|
+
const types: DeviceInfoTypes = {
|
|
132
132
|
version: params.includeVersion,
|
|
133
133
|
build_id: params.includeBuildId,
|
|
134
134
|
hash: params.includeHash,
|
|
@@ -28,7 +28,7 @@ export default class TronSignMessage extends BaseMethod<HardwareTronSignMessage>
|
|
|
28
28
|
if (this.payload.messageType === 'V1' || this.payload.messageType == null) {
|
|
29
29
|
throw createDeviceNotSupportMethodError(
|
|
30
30
|
'TronSignMessage',
|
|
31
|
-
getFirmwareType(this.device
|
|
31
|
+
getFirmwareType(this.device?.features)
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -29,7 +29,7 @@ export default class XrpGetAddress extends BaseMethod<XrpSignTransactionParams>
|
|
|
29
29
|
{ name: 'payment', type: 'object' },
|
|
30
30
|
]);
|
|
31
31
|
validateParams(transaction.payment, [
|
|
32
|
-
{ name: 'amount', type: '
|
|
32
|
+
{ name: 'amount', type: 'uint', required: true },
|
|
33
33
|
{ name: 'destination', type: 'string', required: true },
|
|
34
34
|
{ name: 'destinationTag', type: 'number' },
|
|
35
35
|
]);
|
package/src/core/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import semver from 'semver';
|
|
2
2
|
import EventEmitter from 'events';
|
|
3
3
|
import {
|
|
4
|
+
EDeviceType,
|
|
4
5
|
ERRORS,
|
|
5
6
|
ERROR_CODES_REQUIRE_RELEASE,
|
|
6
7
|
HardwareError,
|
|
@@ -19,6 +20,7 @@ import {
|
|
|
19
20
|
enableLog,
|
|
20
21
|
getDeviceBLEFirmwareVersion,
|
|
21
22
|
getDeviceFirmwareVersion,
|
|
23
|
+
getDeviceType,
|
|
22
24
|
getFirmwareType,
|
|
23
25
|
getLogger,
|
|
24
26
|
getMethodVersionRange,
|
|
@@ -992,6 +994,8 @@ export const cancel = (context: CoreContext, connectId?: string) => {
|
|
|
992
994
|
const checkPassphraseEnableState = (method: BaseMethod, features?: Features) => {
|
|
993
995
|
if (!method.useDevicePassphraseState) return;
|
|
994
996
|
|
|
997
|
+
const isPro2 = getDeviceType(features) === EDeviceType.Pro2;
|
|
998
|
+
|
|
995
999
|
if (features?.passphrase_protection === true) {
|
|
996
1000
|
const hasNoPassphraseState =
|
|
997
1001
|
method.payload.passphraseState == null || method.payload.passphraseState === '';
|
|
@@ -1004,7 +1008,7 @@ const checkPassphraseEnableState = (method: BaseMethod, features?: Features) =>
|
|
|
1004
1008
|
}
|
|
1005
1009
|
}
|
|
1006
1010
|
|
|
1007
|
-
if (features?.passphrase_protection === false && method.payload.passphraseState) {
|
|
1011
|
+
if (features?.passphrase_protection === false && method.payload.passphraseState && !isPro2) {
|
|
1008
1012
|
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
1009
1013
|
throw ERRORS.TypedError(HardwareErrorCode.DeviceNotOpenedPassphrase);
|
|
1010
1014
|
}
|