@onekeyfe/hd-core 1.1.14-alpha.1 → 1.1.14-alpha.3
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/evm/EVMSignMessageEIP712.d.ts +3 -0
- package/dist/api/evm/EVMSignMessageEIP712.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
- package/dist/index.js +10 -0
- package/package.json +4 -4
- package/src/api/evm/EVMSignMessageEIP712.ts +6 -0
- package/src/api/evm/EVMSignTypedData.ts +16 -3
- package/src/data/messages/messages.json +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EVMSignMessageEIP712.d.ts","sourceRoot":"","sources":["../../../src/api/evm/EVMSignMessageEIP712.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAGnE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"EVMSignMessageEIP712.d.ts","sourceRoot":"","sources":["../../../src/api/evm/EVMSignMessageEIP712.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAGnE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAO3C,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,UAAU,CAAC,yBAAyB,CAAC;IACrF,IAAI;IAqBJ,eAAe;;;;;;;;IAWT,GAAG;CAWV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EVMSignTypedData.d.ts","sourceRoot":"","sources":["../../../src/api/evm/EVMSignTypedData.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EVMSignTypedData.d.ts","sourceRoot":"","sources":["../../../src/api/evm/EVMSignTypedData.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,UAAU,EACV,eAAe,EACf,SAAS,EAEV,MAAM,wB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/dist/index.js
CHANGED
|
@@ -7986,6 +7986,7 @@ var nested$1 = {
|
|
|
7986
7986
|
Capability_Shamir: 15,
|
|
7987
7987
|
Capability_ShamirGroups: 16,
|
|
7988
7988
|
Capability_PassphraseEntry: 17,
|
|
7989
|
+
Capability_EthereumTypedData: 1000,
|
|
7989
7990
|
Capability_AttachToPin: 8000
|
|
7990
7991
|
}
|
|
7991
7992
|
}
|
|
@@ -32223,6 +32224,9 @@ class EVMSignMessageEIP712 extends BaseMethod {
|
|
|
32223
32224
|
model_mini: {
|
|
32224
32225
|
min: '2.1.9',
|
|
32225
32226
|
},
|
|
32227
|
+
model_classic1s: {
|
|
32228
|
+
min: '3.14.0',
|
|
32229
|
+
},
|
|
32226
32230
|
};
|
|
32227
32231
|
}
|
|
32228
32232
|
run() {
|
|
@@ -32955,6 +32959,12 @@ class EVMSignTypedData extends BaseMethod {
|
|
|
32955
32959
|
const { addressN, chainId } = this.params;
|
|
32956
32960
|
const deviceType = getDeviceType(this.device.features);
|
|
32957
32961
|
if (DeviceModelToTypes.model_mini.includes(deviceType)) {
|
|
32962
|
+
const currentVersion = getDeviceFirmwareVersion(this.device.features).join('.');
|
|
32963
|
+
const isClassic1sOrPure = deviceType === hdShared.EDeviceType.Classic1s || deviceType === hdShared.EDeviceType.ClassicPure;
|
|
32964
|
+
if ((isClassic1sOrPure && semver__default["default"].gte(currentVersion, '3.14.0')) ||
|
|
32965
|
+
existCapability(this.device.features, hdTransport.Enum_Capability.Capability_EthereumTypedData)) {
|
|
32966
|
+
return this.signTypedData();
|
|
32967
|
+
}
|
|
32958
32968
|
validateParams(this.params, [
|
|
32959
32969
|
{ name: 'domainHash', type: 'hexString', required: true },
|
|
32960
32970
|
{ name: 'messageHash', type: 'hexString', required: true },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "1.1.14-alpha.
|
|
3
|
+
"version": "1.1.14-alpha.3",
|
|
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.14-alpha.
|
|
29
|
-
"@onekeyfe/hd-transport": "1.1.14-alpha.
|
|
28
|
+
"@onekeyfe/hd-shared": "1.1.14-alpha.3",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.1.14-alpha.3",
|
|
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": "9c0aef9a81aa18afc97da4db39c0b71bbde65e84"
|
|
50
50
|
}
|
|
@@ -5,6 +5,9 @@ import { BaseMethod } from '../BaseMethod';
|
|
|
5
5
|
import { validateParams } from '../helpers/paramsValidator';
|
|
6
6
|
import { formatAnyHex } from '../helpers/hexUtils';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated Use EVMSignTypedData instead.
|
|
10
|
+
*/
|
|
8
11
|
export default class EVMSignMessageEIP712 extends BaseMethod<EthereumSignMessageEIP712> {
|
|
9
12
|
init() {
|
|
10
13
|
this.checkDeviceId = true;
|
|
@@ -32,6 +35,9 @@ export default class EVMSignMessageEIP712 extends BaseMethod<EthereumSignMessage
|
|
|
32
35
|
model_mini: {
|
|
33
36
|
min: '2.1.9',
|
|
34
37
|
},
|
|
38
|
+
model_classic1s: {
|
|
39
|
+
min: '3.14.0',
|
|
40
|
+
},
|
|
35
41
|
};
|
|
36
42
|
}
|
|
37
43
|
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import semver from 'semver';
|
|
2
|
-
import {
|
|
2
|
+
import { get } from 'lodash';
|
|
3
|
+
import BigNumber from 'bignumber.js';
|
|
4
|
+
import { ERRORS, HardwareErrorCode, EDeviceType } from '@onekeyfe/hd-shared';
|
|
3
5
|
import {
|
|
4
6
|
EthereumTypedDataSignature,
|
|
5
7
|
EthereumTypedDataStructAck,
|
|
6
8
|
MessageKey,
|
|
7
9
|
MessageResponse,
|
|
8
10
|
TypedCall,
|
|
11
|
+
Enum_Capability,
|
|
9
12
|
} from '@onekeyfe/hd-transport';
|
|
10
|
-
import { get } from 'lodash';
|
|
11
|
-
import BigNumber from 'bignumber.js';
|
|
12
13
|
import { UI_REQUEST } from '../../constants/ui-request';
|
|
13
14
|
import { validatePath } from '../helpers/pathUtils';
|
|
14
15
|
import { BaseMethod } from '../BaseMethod';
|
|
15
16
|
import { validateParams } from '../helpers/paramsValidator';
|
|
16
17
|
import { formatAnyHex, parseChainId, stripHexStartZeroes } from '../helpers/hexUtils';
|
|
17
18
|
import { getDeviceFirmwareVersion, getDeviceType } from '../../utils';
|
|
19
|
+
import { existCapability } from '../../utils/capabilitieUtils';
|
|
18
20
|
import {
|
|
19
21
|
DeviceModelToTypes,
|
|
20
22
|
type EthereumSignTypedDataMessage,
|
|
@@ -402,6 +404,17 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
402
404
|
// For Classic、Mini device we use EthereumSignTypedData
|
|
403
405
|
const deviceType = getDeviceType(this.device.features);
|
|
404
406
|
if (DeviceModelToTypes.model_mini.includes(deviceType)) {
|
|
407
|
+
// Classic1s / ClassicPure 3.14.0+, supported EthereumSignTypedDataOneKey
|
|
408
|
+
const currentVersion = getDeviceFirmwareVersion(this.device.features).join('.');
|
|
409
|
+
const isClassic1sOrPure =
|
|
410
|
+
deviceType === EDeviceType.Classic1s || deviceType === EDeviceType.ClassicPure;
|
|
411
|
+
if (
|
|
412
|
+
(isClassic1sOrPure && semver.gte(currentVersion, '3.14.0')) ||
|
|
413
|
+
existCapability(this.device.features, Enum_Capability.Capability_EthereumTypedData)
|
|
414
|
+
) {
|
|
415
|
+
return this.signTypedData();
|
|
416
|
+
}
|
|
417
|
+
|
|
405
418
|
validateParams(this.params, [
|
|
406
419
|
{ name: 'domainHash', type: 'hexString', required: true },
|
|
407
420
|
{ name: 'messageHash', type: 'hexString', required: true },
|