@onekeyfe/hd-core 1.2.0-alpha.34 → 1.2.0-alpha.35
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__/DeviceCommands.test.ts +84 -0
- package/__tests__/device-settings.test.ts +3 -0
- package/__tests__/device-wallet-session-store.test.ts +80 -7
- package/__tests__/evmSignTransaction.test.ts +69 -0
- package/__tests__/get-device-state.test.ts +78 -30
- package/__tests__/open-wallet-session.test.ts +186 -51
- package/__tests__/protocol-v2.test.ts +490 -112
- package/dist/api/FirmwareUpdateV4.d.ts +1 -0
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/OpenWalletSession.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
- package/dist/api/evm/protocol.d.ts +3 -0
- package/dist/api/evm/protocol.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +1 -1
- package/dist/device/Device.d.ts +3 -2
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DeviceWalletSessionStore.d.ts +0 -1
- package/dist/device/DeviceWalletSessionStore.d.ts.map +1 -1
- package/dist/index.d.ts +8 -6
- package/dist/index.js +606 -641
- package/dist/protocols/protocol-v2/features.d.ts +17 -6
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/index.d.ts +2 -2
- package/dist/protocols/protocol-v2/index.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/settingsUnlockPolicy.d.ts +1 -0
- package/dist/protocols/protocol-v2/settingsUnlockPolicy.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/walletSession.d.ts +1 -0
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
- package/dist/types/api/openWalletSession.d.ts +1 -1
- package/dist/types/api/openWalletSession.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +2 -2
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/types/device.d.ts +2 -1
- package/dist/types/device.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 +26 -8
- package/src/api/GetPassphraseState.ts +11 -0
- package/src/api/OpenWalletSession.ts +15 -7
- package/src/api/evm/EVMGetAddress.ts +2 -2
- package/src/api/evm/EVMGetPublicKey.ts +2 -2
- package/src/api/evm/EVMSignMessage.ts +2 -2
- package/src/api/evm/EVMSignTransaction.ts +2 -2
- package/src/api/evm/EVMSignTypedData.ts +35 -45
- package/src/api/evm/EVMVerifyMessage.ts +2 -2
- package/src/api/evm/protocol.ts +6 -0
- package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +2 -2
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +1 -1
- package/src/data/messages/messages-protocol-v2.json +393 -485
- package/src/device/Device.ts +63 -37
- package/src/device/DeviceCommands.ts +12 -2
- package/src/device/DeviceWalletSessionStore.ts +0 -14
- package/src/deviceProfile/buildDeviceFeatures.ts +1 -1
- package/src/protocols/protocol-v2/features.ts +58 -16
- package/src/protocols/protocol-v2/index.ts +5 -0
- package/src/protocols/protocol-v2/settingsUnlockPolicy.ts +8 -3
- package/src/protocols/protocol-v2/unlockRetry.ts +18 -7
- package/src/protocols/protocol-v2/walletSession.ts +35 -35
- package/src/types/api/openWalletSession.ts +1 -1
- package/src/types/api/protocolV2.ts +2 -2
- package/src/types/device.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.35",
|
|
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.2.0-alpha.
|
|
29
|
-
"@onekeyfe/hd-transport": "1.2.0-alpha.
|
|
28
|
+
"@onekeyfe/hd-shared": "1.2.0-alpha.35",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.2.0-alpha.35",
|
|
30
30
|
"axios": "1.15.2",
|
|
31
31
|
"bignumber.js": "^9.0.2",
|
|
32
32
|
"bytebuffer": "^5.0.1",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"@types/w3c-web-usb": "^1.0.10",
|
|
45
45
|
"@types/web-bluetooth": "^0.0.21"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "638bd33030686c4a3321e4feb4924c3f9f5c81a8"
|
|
48
48
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ERRORS, HardwareError, HardwareErrorCode, wait } from '@onekeyfe/hd-shared';
|
|
1
|
+
import { EDeviceType, ERRORS, HardwareError, HardwareErrorCode, wait } from '@onekeyfe/hd-shared';
|
|
2
2
|
import {
|
|
3
3
|
DeviceRebootType,
|
|
4
4
|
PROTOCOL_V2_BLE_FILE_CHUNK_SIZE,
|
|
@@ -994,14 +994,31 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
994
994
|
if (typeof this.device.isBootloader === 'function') {
|
|
995
995
|
return this.device.isBootloader();
|
|
996
996
|
}
|
|
997
|
-
return
|
|
997
|
+
return (
|
|
998
|
+
this.device.features?.mode === 'bootloader' ||
|
|
999
|
+
(this.device.features?.mode == null && !!this.device.features?.bootloaderMode)
|
|
1000
|
+
);
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
private isProtocolV2RomloaderMode() {
|
|
1004
|
+
if (!this.device.isProtocolV2() || this.device.getCurrentDeviceType() !== EDeviceType.Pro2) {
|
|
1005
|
+
return false;
|
|
1006
|
+
}
|
|
1007
|
+
if (typeof this.device.isRomloader === 'function') {
|
|
1008
|
+
return this.device.isRomloader();
|
|
1009
|
+
}
|
|
1010
|
+
return this.device.features?.mode === 'romloader';
|
|
998
1011
|
}
|
|
999
1012
|
|
|
1000
1013
|
async enterProtocolV2BootloaderMode() {
|
|
1001
1014
|
// romloader is the first update environment and forwards targets to bootloader.
|
|
1002
1015
|
// It rejects DeviceRebootType.Bootloader, so reuse the current connection.
|
|
1003
|
-
if (this.
|
|
1004
|
-
Log.debug('Protocol V2 device is
|
|
1016
|
+
if (this.isProtocolV2RomloaderMode()) {
|
|
1017
|
+
Log.debug('Protocol V2 device is in romloader mode; start firmware update directly');
|
|
1018
|
+
return false;
|
|
1019
|
+
}
|
|
1020
|
+
if (this.isProtocolV2BootloaderMode()) {
|
|
1021
|
+
Log.debug('Protocol V2 device is already in bootloader mode, skip reboot');
|
|
1005
1022
|
return false;
|
|
1006
1023
|
}
|
|
1007
1024
|
|
|
@@ -1036,10 +1053,11 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
1036
1053
|
timeoutMs: PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT,
|
|
1037
1054
|
});
|
|
1038
1055
|
this.assertProtocolV2DeviceInfoIdentity(deviceInfo);
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1056
|
+
const features = await this.device.probeProtocolV2RuntimeState(
|
|
1057
|
+
deviceInfo,
|
|
1058
|
+
PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT
|
|
1059
|
+
);
|
|
1060
|
+
if (features?.mode === 'bootloader') {
|
|
1043
1061
|
return features;
|
|
1044
1062
|
}
|
|
1045
1063
|
lastError = new Error('Protocol V2 device is reachable but is not in bootloader mode');
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
2
|
|
|
3
3
|
import { UI_REQUEST } from '../constants/ui-request';
|
|
4
|
+
import { refreshProtocolV2DeviceStatus } from '../protocols/protocol-v2/walletSession';
|
|
4
5
|
import { getPassphraseStateWithRefreshDeviceInfo } from '../utils/deviceFeaturesUtils';
|
|
5
6
|
import { BaseMethod } from './BaseMethod';
|
|
6
7
|
|
|
@@ -20,6 +21,12 @@ export default class GetPassphraseState extends BaseMethod {
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
const isProtocolV2 = this.device.isProtocolV2();
|
|
24
|
+
if (isProtocolV2 && this.payload.useEmptyPassphrase !== true) {
|
|
25
|
+
const features = await refreshProtocolV2DeviceStatus(this.device);
|
|
26
|
+
if (features.unlocked === false) {
|
|
27
|
+
await this.device.unlockDevice();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
23
30
|
const { passphraseState } = await getPassphraseStateWithRefreshDeviceInfo(
|
|
24
31
|
this.device,
|
|
25
32
|
isProtocolV2
|
|
@@ -30,6 +37,10 @@ export default class GetPassphraseState extends BaseMethod {
|
|
|
30
37
|
: undefined
|
|
31
38
|
);
|
|
32
39
|
|
|
40
|
+
if (!isProtocolV2 && this.device.getCurrentPassphraseProtection() !== true) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
|
|
33
44
|
return passphraseState;
|
|
34
45
|
}
|
|
35
46
|
}
|
|
@@ -103,6 +103,11 @@ export default class OpenWalletSession extends BaseMethod<OpenWalletSessionParam
|
|
|
103
103
|
currentDeviceId = refreshedState.identity.deviceId;
|
|
104
104
|
return requireDeviceId();
|
|
105
105
|
};
|
|
106
|
+
const unlockProtocolV2IfLocked = async () => {
|
|
107
|
+
if (isProtocolV2 && state.status.unlocked === false) {
|
|
108
|
+
await this.device.unlockDevice();
|
|
109
|
+
}
|
|
110
|
+
};
|
|
106
111
|
|
|
107
112
|
const protocol = isProtocolV2 ? 'V2' : 'V1';
|
|
108
113
|
|
|
@@ -128,16 +133,14 @@ export default class OpenWalletSession extends BaseMethod<OpenWalletSessionParam
|
|
|
128
133
|
protocol,
|
|
129
134
|
walletType: 'standard',
|
|
130
135
|
deviceId,
|
|
131
|
-
passphraseState:
|
|
136
|
+
passphraseState: null,
|
|
132
137
|
resumed: wasResumed(session),
|
|
133
138
|
};
|
|
134
139
|
}
|
|
135
140
|
|
|
136
141
|
if (this.params.mode === OpenWalletSessionMode.ResumeHidden) {
|
|
137
142
|
if (isProtocolV2) {
|
|
138
|
-
|
|
139
|
-
await this.device.unlockDevice();
|
|
140
|
-
}
|
|
143
|
+
await unlockProtocolV2IfLocked();
|
|
141
144
|
const refreshedDeviceId = await refreshProtocolV2DeviceId();
|
|
142
145
|
if (refreshedDeviceId !== this.params.deviceId) {
|
|
143
146
|
deviceWalletSessionStore.delete(this.params.deviceId, this.params.passphraseState);
|
|
@@ -151,7 +154,7 @@ export default class OpenWalletSession extends BaseMethod<OpenWalletSessionParam
|
|
|
151
154
|
this.params.deviceId,
|
|
152
155
|
this.params.passphraseState
|
|
153
156
|
);
|
|
154
|
-
if (!cachedSessionId) {
|
|
157
|
+
if (!cachedSessionId && !isProtocolV2) {
|
|
155
158
|
throw ERRORS.TypedError(HardwareErrorCode.WalletSessionInvalid);
|
|
156
159
|
}
|
|
157
160
|
if (!isProtocolV2) {
|
|
@@ -177,15 +180,20 @@ export default class OpenWalletSession extends BaseMethod<OpenWalletSessionParam
|
|
|
177
180
|
walletType: 'hidden',
|
|
178
181
|
deviceId,
|
|
179
182
|
...requireHiddenWalletResponse(session),
|
|
180
|
-
resumed: wasResumed(session) || session.newSession === cachedSessionId,
|
|
183
|
+
resumed: wasResumed(session) || (!isProtocolV2 && session.newSession === cachedSessionId),
|
|
181
184
|
};
|
|
182
185
|
}
|
|
183
186
|
|
|
184
187
|
this.device.passphraseState = undefined;
|
|
188
|
+
await unlockProtocolV2IfLocked();
|
|
185
189
|
const session = isProtocolV2
|
|
186
|
-
? await getProtocolV2WalletSession(this.device, {
|
|
190
|
+
? await getProtocolV2WalletSession(this.device, { forceWalletSelection: true })
|
|
187
191
|
: await getPassphraseStateWithRefreshDeviceInfo(this.device, { initSession: true });
|
|
188
192
|
const deviceId = isProtocolV2 ? await refreshProtocolV2DeviceId() : requireDeviceId();
|
|
193
|
+
if (isProtocolV2 && this.device.getCurrentPassphraseProtection() !== true) {
|
|
194
|
+
this.device.clearInternalState();
|
|
195
|
+
throw ERRORS.TypedError(HardwareErrorCode.DeviceNotOpenedPassphrase);
|
|
196
|
+
}
|
|
189
197
|
const responseBase = {
|
|
190
198
|
protocol,
|
|
191
199
|
deviceId,
|
|
@@ -2,9 +2,9 @@ import { UI_REQUEST } from '../../constants/ui-request';
|
|
|
2
2
|
import { serializedPath, validatePath } from '../helpers/pathUtils';
|
|
3
3
|
import { BaseMethod } from '../BaseMethod';
|
|
4
4
|
import { validateParams, validateResult } from '../helpers/paramsValidator';
|
|
5
|
-
import TransportManager from '../../data-manager/TransportManager';
|
|
6
5
|
import getAddressLegacyV1 from './legacyV1/getAddress';
|
|
7
6
|
import getAddress from './latest/getAddress';
|
|
7
|
+
import { shouldUseLegacyV1EvmMessages } from './protocol';
|
|
8
8
|
|
|
9
9
|
import type { EVMAddress, EVMGetAddressParams } from '../../types';
|
|
10
10
|
import type { EthereumGetAddressOneKey } from '@onekeyfe/hd-transport';
|
|
@@ -48,7 +48,7 @@ export default class EvmGetAddress extends BaseMethod<EthereumGetAddressOneKey[]
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
async getEvmAddress(param: EthereumGetAddressOneKey) {
|
|
51
|
-
if (
|
|
51
|
+
if (shouldUseLegacyV1EvmMessages(this.device)) {
|
|
52
52
|
return getAddressLegacyV1({
|
|
53
53
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
54
54
|
param,
|
|
@@ -2,9 +2,9 @@ import { UI_REQUEST } from '../../constants/ui-request';
|
|
|
2
2
|
import { serializedPath, validatePath } from '../helpers/pathUtils';
|
|
3
3
|
import { BaseMethod } from '../BaseMethod';
|
|
4
4
|
import { validateParams, validateResult } from '../helpers/paramsValidator';
|
|
5
|
-
import TransportManager from '../../data-manager/TransportManager';
|
|
6
5
|
import getPublicKey from './latest/getPublicKey';
|
|
7
6
|
import getPublicKeyLegacyV1 from './legacyV1/getPublicKey';
|
|
7
|
+
import { shouldUseLegacyV1EvmMessages } from './protocol';
|
|
8
8
|
import { batchGetPublickeys, supportBatchPublicKeyByDevice } from '../helpers/batchGetPublickeys';
|
|
9
9
|
|
|
10
10
|
import type { EVMGetPublicKeyParams, EVMPublicKey } from '../../types';
|
|
@@ -60,7 +60,7 @@ export default class EVMGetPublicKey extends BaseMethod<EthereumGetPublicKeyOneK
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
getEvmPublicKey(param: EthereumGetPublicKey) {
|
|
63
|
-
if (
|
|
63
|
+
if (shouldUseLegacyV1EvmMessages(this.device)) {
|
|
64
64
|
return getPublicKeyLegacyV1({
|
|
65
65
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
66
66
|
param,
|
|
@@ -3,9 +3,9 @@ import { validatePath } from '../helpers/pathUtils';
|
|
|
3
3
|
import { BaseMethod } from '../BaseMethod';
|
|
4
4
|
import { validateParams } from '../helpers/paramsValidator';
|
|
5
5
|
import { formatAnyHex } from '../helpers/hexUtils';
|
|
6
|
-
import TransportManager from '../../data-manager/TransportManager';
|
|
7
6
|
import signMessage from './latest/signMessage';
|
|
8
7
|
import signMessageLegacyV1 from './legacyV1/signMessage';
|
|
8
|
+
import { shouldUseLegacyV1EvmMessages } from './protocol';
|
|
9
9
|
|
|
10
10
|
import type { EthereumSignMessageOneKey } from '@onekeyfe/hd-transport';
|
|
11
11
|
|
|
@@ -40,7 +40,7 @@ export default class EVMSignMessage extends BaseMethod<EthereumSignMessageOneKey
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
async run() {
|
|
43
|
-
if (
|
|
43
|
+
if (shouldUseLegacyV1EvmMessages(this.device)) {
|
|
44
44
|
return signMessageLegacyV1({
|
|
45
45
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
46
46
|
params: this.params,
|
|
@@ -5,9 +5,9 @@ import { validatePath } from '../helpers/pathUtils';
|
|
|
5
5
|
import { BaseMethod } from '../BaseMethod';
|
|
6
6
|
import { validateParams } from '../helpers/paramsValidator';
|
|
7
7
|
import { formatAnyHex } from '../helpers/hexUtils';
|
|
8
|
-
import TransportManager from '../../data-manager/TransportManager';
|
|
9
8
|
import { signTransaction } from './latest/signTransaction';
|
|
10
9
|
import { signTransaction as signTransactionLegacyV1 } from './legacyV1/signTransaction';
|
|
10
|
+
import { shouldUseLegacyV1EvmMessages } from './protocol';
|
|
11
11
|
|
|
12
12
|
import type {
|
|
13
13
|
EVMSignTransactionParams,
|
|
@@ -126,7 +126,7 @@ export default class EVMSignTransaction extends BaseMethod {
|
|
|
126
126
|
|
|
127
127
|
if (formattedTx == null) throw ERRORS.TypedError('Runtime', 'formattedTx is not set');
|
|
128
128
|
|
|
129
|
-
if (
|
|
129
|
+
if (shouldUseLegacyV1EvmMessages(this.device)) {
|
|
130
130
|
return signTransactionLegacyV1({
|
|
131
131
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
132
132
|
addressN,
|
|
@@ -15,8 +15,8 @@ import {
|
|
|
15
15
|
type EthereumSignTypedDataMessage,
|
|
16
16
|
type EthereumSignTypedDataTypes,
|
|
17
17
|
} from '../../types';
|
|
18
|
-
import TransportManager from '../../data-manager/TransportManager';
|
|
19
18
|
import { signTypedHash as signTypedHashLegacyV1 } from './legacyV1/signTypedHash';
|
|
19
|
+
import { shouldUseLegacyV1EvmMessages } from './protocol';
|
|
20
20
|
import { signTypedHash } from './latest/signTypedHash';
|
|
21
21
|
import { signTypedData as signTypedDataLegacyV1 } from './legacyV1/signTypedData';
|
|
22
22
|
import { signTypedData } from './latest/signTypedData';
|
|
@@ -278,29 +278,23 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
278
278
|
|
|
279
279
|
let supportTrezor = false;
|
|
280
280
|
let response: MessageResponse<MessageKey>;
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
addressN,
|
|
299
|
-
data,
|
|
300
|
-
metamaskV4Compat,
|
|
301
|
-
chainId,
|
|
302
|
-
});
|
|
303
|
-
break;
|
|
281
|
+
if (shouldUseLegacyV1EvmMessages(this.device)) {
|
|
282
|
+
supportTrezor = true;
|
|
283
|
+
response = await signTypedDataLegacyV1({
|
|
284
|
+
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
285
|
+
addressN,
|
|
286
|
+
data,
|
|
287
|
+
metamaskV4Compat,
|
|
288
|
+
chainId,
|
|
289
|
+
});
|
|
290
|
+
} else {
|
|
291
|
+
response = await signTypedData({
|
|
292
|
+
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
293
|
+
addressN,
|
|
294
|
+
data,
|
|
295
|
+
metamaskV4Compat,
|
|
296
|
+
chainId,
|
|
297
|
+
});
|
|
304
298
|
}
|
|
305
299
|
|
|
306
300
|
return this.handleSignTypedData({
|
|
@@ -326,28 +320,24 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
326
320
|
}) {
|
|
327
321
|
if (!domainHash) throw ERRORS.TypedError('Runtime', 'domainHash is required');
|
|
328
322
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
});
|
|
339
|
-
|
|
340
|
-
case 'v1CurrentSchema':
|
|
341
|
-
default:
|
|
342
|
-
return signTypedHash({
|
|
343
|
-
typedCall,
|
|
344
|
-
addressN,
|
|
345
|
-
domainHash,
|
|
346
|
-
messageHash,
|
|
347
|
-
chainId,
|
|
348
|
-
device: this.device,
|
|
349
|
-
});
|
|
323
|
+
if (shouldUseLegacyV1EvmMessages(this.device)) {
|
|
324
|
+
return signTypedHashLegacyV1({
|
|
325
|
+
typedCall,
|
|
326
|
+
addressN,
|
|
327
|
+
domainHash,
|
|
328
|
+
messageHash,
|
|
329
|
+
chainId,
|
|
330
|
+
device: this.device,
|
|
331
|
+
});
|
|
350
332
|
}
|
|
333
|
+
return signTypedHash({
|
|
334
|
+
typedCall,
|
|
335
|
+
addressN,
|
|
336
|
+
domainHash,
|
|
337
|
+
messageHash,
|
|
338
|
+
chainId,
|
|
339
|
+
device: this.device,
|
|
340
|
+
});
|
|
351
341
|
}
|
|
352
342
|
|
|
353
343
|
getVersionRange() {
|
|
@@ -2,9 +2,9 @@ import { UI_REQUEST } from '../../constants/ui-request';
|
|
|
2
2
|
import { BaseMethod } from '../BaseMethod';
|
|
3
3
|
import { validateParams } from '../helpers/paramsValidator';
|
|
4
4
|
import { formatAnyHex } from '../helpers/hexUtils';
|
|
5
|
-
import TransportManager from '../../data-manager/TransportManager';
|
|
6
5
|
import verifyMessageLegacyV1 from './legacyV1/verifyMessage';
|
|
7
6
|
import verifyMessage from './latest/verifyMessage';
|
|
7
|
+
import { shouldUseLegacyV1EvmMessages } from './protocol';
|
|
8
8
|
|
|
9
9
|
import type { EthereumVerifyMessageOneKey } from '@onekeyfe/hd-transport';
|
|
10
10
|
|
|
@@ -35,7 +35,7 @@ export default class EVMSignMessage extends BaseMethod<EthereumVerifyMessageOneK
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
async run() {
|
|
38
|
-
if (
|
|
38
|
+
if (shouldUseLegacyV1EvmMessages(this.device)) {
|
|
39
39
|
return verifyMessageLegacyV1({
|
|
40
40
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
41
41
|
params: this.params,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import TransportManager from '../../data-manager/TransportManager';
|
|
2
|
+
|
|
3
|
+
import type { Device } from '../../device/Device';
|
|
4
|
+
|
|
5
|
+
export const shouldUseLegacyV1EvmMessages = (device: Pick<Device, 'isProtocolV2'>): boolean =>
|
|
6
|
+
!device.isProtocolV2() && TransportManager.getProtocolV1MessageSchema() === 'v1LegacySchema';
|
|
@@ -12,8 +12,8 @@ export default class DeviceGetOnboardingStatus extends BaseMethod {
|
|
|
12
12
|
|
|
13
13
|
async run() {
|
|
14
14
|
const { message } = await this.device.commands.typedCall(
|
|
15
|
-
'
|
|
16
|
-
'
|
|
15
|
+
'OnboardingStatusGet',
|
|
16
|
+
'OnboardingStatus',
|
|
17
17
|
{}
|
|
18
18
|
);
|
|
19
19
|
return message;
|
|
@@ -74,7 +74,7 @@ export default class DeviceUploadWallpaper extends BaseMethod<DeviceUploadWallpa
|
|
|
74
74
|
this.encoded = encodePro2Wallpaper({ width, height, rgba: rgbaBytes });
|
|
75
75
|
this.path = `${WALLPAPER_DIRECTORY}/${normalizeFileName(fileName, this.encoded.data)}`;
|
|
76
76
|
this.params = { width, height, rgba: rgbaBytes, fileName, chunkSize };
|
|
77
|
-
this.unlockPolicy = '
|
|
77
|
+
this.unlockPolicy = 'none';
|
|
78
78
|
this.skipForceUpdateCheck = true;
|
|
79
79
|
this.useDevicePassphraseState = false;
|
|
80
80
|
}
|