@onekeyfe/hd-core 0.2.27 → 0.2.28
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/EVMGetPublicKey.d.ts +5 -1
- package/dist/api/evm/EVMGetPublicKey.d.ts.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +16 -2
- package/dist/types/api/evmGetPublicKey.d.ts +5 -0
- package/dist/types/api/evmGetPublicKey.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/evm/EVMGetPublicKey.ts +17 -0
- package/src/types/api/evmGetPublicKey.ts +7 -0
|
@@ -3,7 +3,11 @@ import { BaseMethod } from '../BaseMethod';
|
|
|
3
3
|
import { EVMPublicKey } from '../../types/api/evmGetPublicKey';
|
|
4
4
|
export default class EVMGetPublicKey extends BaseMethod<EthereumGetPublicKey[]> {
|
|
5
5
|
hasBundle: boolean;
|
|
6
|
+
useBatch: boolean;
|
|
6
7
|
init(): void;
|
|
7
|
-
run(): Promise<EVMPublicKey |
|
|
8
|
+
run(): Promise<EVMPublicKey | {
|
|
9
|
+
path: string;
|
|
10
|
+
publicKey: string;
|
|
11
|
+
}[]>;
|
|
8
12
|
}
|
|
9
13
|
//# sourceMappingURL=EVMGetPublicKey.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EVMGetPublicKey.d.ts","sourceRoot":"","sources":["../../../src/api/evm/EVMGetPublicKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAG9D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAyB,YAAY,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"EVMGetPublicKey.d.ts","sourceRoot":"","sources":["../../../src/api/evm/EVMGetPublicKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAG9D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAyB,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAGtF,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,UAAU,CAAC,oBAAoB,EAAE,CAAC;IAC7E,SAAS,UAAS;IAElB,QAAQ,UAAS;IAEjB,IAAI;IAgCE,GAAG;;;;CAmCV"}
|
package/dist/index.d.ts
CHANGED
|
@@ -404,6 +404,7 @@ declare function evmGetAddress(connectId: string, deviceId: string, params: Comm
|
|
|
404
404
|
|
|
405
405
|
declare type EVMPublicKey = {
|
|
406
406
|
path: string;
|
|
407
|
+
publicKey: string;
|
|
407
408
|
} & EthereumPublicKey;
|
|
408
409
|
declare type EVMGetPublicKeyParams = {
|
|
409
410
|
path: string | number[];
|
|
@@ -414,6 +415,10 @@ declare function evmGetPublicKey(connectId: string, deviceId: string, params: Co
|
|
|
414
415
|
declare function evmGetPublicKey(connectId: string, deviceId: string, params: CommonParams & {
|
|
415
416
|
bundle?: EVMGetPublicKeyParams[];
|
|
416
417
|
}): Response<Array<EVMPublicKey>>;
|
|
418
|
+
declare function evmGetPublicKey(connectId: string, deviceId: string, params: CommonParams & {
|
|
419
|
+
bundle?: EVMGetPublicKeyParams[];
|
|
420
|
+
useBatch?: boolean;
|
|
421
|
+
}): Response<Omit<EVMPublicKey, 'node' | 'xpub'>>;
|
|
417
422
|
|
|
418
423
|
declare type EVMSignMessageParams = {
|
|
419
424
|
path: string | number[];
|
package/dist/index.js
CHANGED
|
@@ -14738,12 +14738,14 @@ class EVMGetPublicKey extends BaseMethod {
|
|
|
14738
14738
|
constructor() {
|
|
14739
14739
|
super(...arguments);
|
|
14740
14740
|
this.hasBundle = false;
|
|
14741
|
+
this.useBatch = false;
|
|
14741
14742
|
}
|
|
14742
14743
|
init() {
|
|
14743
|
-
var _a;
|
|
14744
|
+
var _a, _b;
|
|
14744
14745
|
this.checkDeviceId = true;
|
|
14745
14746
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
|
|
14746
14747
|
this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
|
|
14748
|
+
this.useBatch = !!((_b = this.payload) === null || _b === void 0 ? void 0 : _b.useBatch);
|
|
14747
14749
|
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
14748
14750
|
validateParams(payload, [{ name: 'bundle', type: 'array' }]);
|
|
14749
14751
|
this.params = [];
|
|
@@ -14764,12 +14766,24 @@ class EVMGetPublicKey extends BaseMethod {
|
|
|
14764
14766
|
});
|
|
14765
14767
|
}
|
|
14766
14768
|
run() {
|
|
14769
|
+
var _a;
|
|
14767
14770
|
return __awaiter(this, void 0, void 0, function* () {
|
|
14768
14771
|
const responses = [];
|
|
14772
|
+
if (this.useBatch && this.hasBundle && supportBatchPublicKey((_a = this.device) === null || _a === void 0 ? void 0 : _a.features)) {
|
|
14773
|
+
const res = yield this.device.commands.typedCall('BatchGetPublickeys', 'EcdsaPublicKeys', {
|
|
14774
|
+
paths: this.params,
|
|
14775
|
+
ecdsa_curve_name: 'secp256k1',
|
|
14776
|
+
});
|
|
14777
|
+
const result = res.message.public_keys.map((publicKey, index) => ({
|
|
14778
|
+
path: serializedPath(this.params[index].address_n),
|
|
14779
|
+
publicKey,
|
|
14780
|
+
}));
|
|
14781
|
+
return Promise.resolve(result);
|
|
14782
|
+
}
|
|
14769
14783
|
for (let i = 0; i < this.params.length; i++) {
|
|
14770
14784
|
const param = this.params[i];
|
|
14771
14785
|
const res = yield this.device.commands.typedCall('EthereumGetPublicKey', 'EthereumPublicKey', Object.assign({}, param));
|
|
14772
|
-
responses.push(Object.assign({ path: serializedPath(param.address_n) }, res.message));
|
|
14786
|
+
responses.push(Object.assign({ path: serializedPath(param.address_n), publicKey: res.message.node.public_key }, res.message));
|
|
14773
14787
|
}
|
|
14774
14788
|
return Promise.resolve(this.hasBundle ? responses : responses[0]);
|
|
14775
14789
|
});
|
|
@@ -2,6 +2,7 @@ import { EthereumPublicKey } from '@onekeyfe/hd-transport';
|
|
|
2
2
|
import type { CommonParams, Response } from '../params';
|
|
3
3
|
export declare type EVMPublicKey = {
|
|
4
4
|
path: string;
|
|
5
|
+
publicKey: string;
|
|
5
6
|
} & EthereumPublicKey;
|
|
6
7
|
export declare type EVMGetPublicKeyParams = {
|
|
7
8
|
path: string | number[];
|
|
@@ -12,4 +13,8 @@ export declare function evmGetPublicKey(connectId: string, deviceId: string, par
|
|
|
12
13
|
export declare function evmGetPublicKey(connectId: string, deviceId: string, params: CommonParams & {
|
|
13
14
|
bundle?: EVMGetPublicKeyParams[];
|
|
14
15
|
}): Response<Array<EVMPublicKey>>;
|
|
16
|
+
export declare function evmGetPublicKey(connectId: string, deviceId: string, params: CommonParams & {
|
|
17
|
+
bundle?: EVMGetPublicKeyParams[];
|
|
18
|
+
useBatch?: boolean;
|
|
19
|
+
}): Response<Omit<EVMPublicKey, 'node' | 'xpub'>>;
|
|
15
20
|
//# sourceMappingURL=evmGetPublicKey.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evmGetPublicKey.d.ts","sourceRoot":"","sources":["../../../src/types/api/evmGetPublicKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAExD,oBAAY,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"evmGetPublicKey.d.ts","sourceRoot":"","sources":["../../../src/types/api/evmGetPublicKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAExD,oBAAY,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,iBAAiB,CAAC;AAEtB,oBAAY,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,YAAY,GAAG,qBAAqB,GAC3C,QAAQ,CAAC,YAAY,CAAC,CAAC;AAE1B,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,YAAY,GAAG;IAAE,MAAM,CAAC,EAAE,qBAAqB,EAAE,CAAA;CAAE,GAC1D,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;AAEjC,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,YAAY,GAAG;IAAE,MAAM,CAAC,EAAE,qBAAqB,EAAE,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,GAC9E,QAAQ,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.28",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@onekeyfe/hd-shared": "^0.2.
|
|
28
|
-
"@onekeyfe/hd-transport": "^0.2.
|
|
27
|
+
"@onekeyfe/hd-shared": "^0.2.28",
|
|
28
|
+
"@onekeyfe/hd-transport": "^0.2.28",
|
|
29
29
|
"axios": "^0.27.2",
|
|
30
30
|
"bignumber.js": "^9.0.2",
|
|
31
31
|
"jszip": "^3.10.1",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"@types/semver": "^7.3.9",
|
|
43
43
|
"ripple-keypairs": "^1.1.4"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "a6cf73ada3cfd4fbb5f77ca82856e3e3767c8c4c"
|
|
46
46
|
}
|
|
@@ -4,15 +4,19 @@ import { serializedPath, validatePath } from '../helpers/pathUtils';
|
|
|
4
4
|
import { BaseMethod } from '../BaseMethod';
|
|
5
5
|
import { validateParams } from '../helpers/paramsValidator';
|
|
6
6
|
import { EVMGetPublicKeyParams, EVMPublicKey } from '../../types/api/evmGetPublicKey';
|
|
7
|
+
import { supportBatchPublicKey } from '../../utils/deviceFeaturesUtils';
|
|
7
8
|
|
|
8
9
|
export default class EVMGetPublicKey extends BaseMethod<EthereumGetPublicKey[]> {
|
|
9
10
|
hasBundle = false;
|
|
10
11
|
|
|
12
|
+
useBatch = false;
|
|
13
|
+
|
|
11
14
|
init() {
|
|
12
15
|
this.checkDeviceId = true;
|
|
13
16
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
|
|
14
17
|
|
|
15
18
|
this.hasBundle = !!this.payload?.bundle;
|
|
19
|
+
this.useBatch = !!this.payload?.useBatch;
|
|
16
20
|
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
17
21
|
|
|
18
22
|
// check payload
|
|
@@ -42,6 +46,18 @@ export default class EVMGetPublicKey extends BaseMethod<EthereumGetPublicKey[]>
|
|
|
42
46
|
async run() {
|
|
43
47
|
const responses: EVMPublicKey[] = [];
|
|
44
48
|
|
|
49
|
+
if (this.useBatch && this.hasBundle && supportBatchPublicKey(this.device?.features)) {
|
|
50
|
+
const res = await this.device.commands.typedCall('BatchGetPublickeys', 'EcdsaPublicKeys', {
|
|
51
|
+
paths: this.params,
|
|
52
|
+
ecdsa_curve_name: 'secp256k1',
|
|
53
|
+
});
|
|
54
|
+
const result = res.message.public_keys.map((publicKey: string, index: number) => ({
|
|
55
|
+
path: serializedPath((this.params as unknown as any[])[index].address_n),
|
|
56
|
+
publicKey,
|
|
57
|
+
}));
|
|
58
|
+
return Promise.resolve(result);
|
|
59
|
+
}
|
|
60
|
+
|
|
45
61
|
for (let i = 0; i < this.params.length; i++) {
|
|
46
62
|
const param = this.params[i];
|
|
47
63
|
|
|
@@ -55,6 +71,7 @@ export default class EVMGetPublicKey extends BaseMethod<EthereumGetPublicKey[]>
|
|
|
55
71
|
|
|
56
72
|
responses.push({
|
|
57
73
|
path: serializedPath(param.address_n),
|
|
74
|
+
publicKey: res.message.node.public_key,
|
|
58
75
|
...res.message,
|
|
59
76
|
});
|
|
60
77
|
}
|
|
@@ -3,6 +3,7 @@ import type { CommonParams, Response } from '../params';
|
|
|
3
3
|
|
|
4
4
|
export type EVMPublicKey = {
|
|
5
5
|
path: string;
|
|
6
|
+
publicKey: string;
|
|
6
7
|
} & EthereumPublicKey;
|
|
7
8
|
|
|
8
9
|
export type EVMGetPublicKeyParams = {
|
|
@@ -22,3 +23,9 @@ export declare function evmGetPublicKey(
|
|
|
22
23
|
deviceId: string,
|
|
23
24
|
params: CommonParams & { bundle?: EVMGetPublicKeyParams[] }
|
|
24
25
|
): Response<Array<EVMPublicKey>>;
|
|
26
|
+
|
|
27
|
+
export declare function evmGetPublicKey(
|
|
28
|
+
connectId: string,
|
|
29
|
+
deviceId: string,
|
|
30
|
+
params: CommonParams & { bundle?: EVMGetPublicKeyParams[]; useBatch?: boolean }
|
|
31
|
+
): Response<Omit<EVMPublicKey, 'node' | 'xpub'>>;
|