@onekeyfe/hd-core 1.1.19 → 1.1.20-alpha.0
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/cosmos/CosmosSignTransaction.d.ts +1 -1
- package/dist/api/cosmos/CosmosSignTransaction.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +18 -8
- package/package.json +4 -4
- package/src/api/cosmos/CosmosSignTransaction.ts +24 -10
- package/src/data-manager/TransportManager.ts +1 -1
- package/src/device/DeviceCommands.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CosmosSignTx as HardwareCosmosSignTx } from '@onekeyfe/hd-transport';
|
|
2
1
|
import { BaseMethod } from '../BaseMethod';
|
|
2
|
+
import type { CosmosSignTx as HardwareCosmosSignTx } from '@onekeyfe/hd-transport';
|
|
3
3
|
export default class CosmosSignTransaction extends BaseMethod<HardwareCosmosSignTx> {
|
|
4
4
|
hasBundle: boolean;
|
|
5
5
|
init(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CosmosSignTransaction.d.ts","sourceRoot":"","sources":["../../../src/api/cosmos/CosmosSignTransaction.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CosmosSignTransaction.d.ts","sourceRoot":"","sources":["../../../src/api/cosmos/CosmosSignTransaction.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,OAAO,KAAK,EAAE,YAAY,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAGnF,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,UAAU,CAAC,oBAAoB,CAAC;IACjF,SAAS,UAAS;IAElB,IAAI;IAoBJ,eAAe;;;;;;;;IAWT,GAAG;;;;CAuBV"}
|
|
@@ -31,7 +31,7 @@ export declare const cancelDeviceInPrompt: (device: Device, expectResponse?: boo
|
|
|
31
31
|
};
|
|
32
32
|
} | {
|
|
33
33
|
success: boolean;
|
|
34
|
-
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 900 | 901 | 902;
|
|
34
|
+
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 900 | 901 | 902;
|
|
35
35
|
payload: {
|
|
36
36
|
message: string;
|
|
37
37
|
};
|
|
@@ -50,7 +50,7 @@ export declare const cancelDeviceWithInitialize: (device: Device) => Promise<{
|
|
|
50
50
|
};
|
|
51
51
|
} | {
|
|
52
52
|
success: boolean;
|
|
53
|
-
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 900 | 901 | 902;
|
|
53
|
+
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 900 | 901 | 902;
|
|
54
54
|
payload: {
|
|
55
55
|
message: string;
|
|
56
56
|
};
|
|
@@ -80,7 +80,7 @@ export declare class DeviceCommands {
|
|
|
80
80
|
};
|
|
81
81
|
} | {
|
|
82
82
|
success: boolean;
|
|
83
|
-
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 900 | 901 | 902;
|
|
83
|
+
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 900 | 901 | 902;
|
|
84
84
|
payload: {
|
|
85
85
|
message: string;
|
|
86
86
|
};
|
|
@@ -99,7 +99,7 @@ export declare class DeviceCommands {
|
|
|
99
99
|
};
|
|
100
100
|
} | {
|
|
101
101
|
success: boolean;
|
|
102
|
-
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 900 | 901 | 902;
|
|
102
|
+
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 900 | 901 | 902;
|
|
103
103
|
payload: {
|
|
104
104
|
message: string;
|
|
105
105
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -2963,7 +2963,7 @@ declare class DeviceCommands {
|
|
|
2963
2963
|
};
|
|
2964
2964
|
} | {
|
|
2965
2965
|
success: boolean;
|
|
2966
|
-
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 900 | 901 | 902;
|
|
2966
|
+
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 900 | 901 | 902;
|
|
2967
2967
|
payload: {
|
|
2968
2968
|
message: string;
|
|
2969
2969
|
};
|
|
@@ -2982,7 +2982,7 @@ declare class DeviceCommands {
|
|
|
2982
2982
|
};
|
|
2983
2983
|
} | {
|
|
2984
2984
|
success: boolean;
|
|
2985
|
-
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 900 | 901 | 902;
|
|
2985
|
+
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 900 | 901 | 902;
|
|
2986
2986
|
payload: {
|
|
2987
2987
|
message: string;
|
|
2988
2988
|
};
|
package/dist/index.js
CHANGED
|
@@ -26536,7 +26536,7 @@ class TransportManager {
|
|
|
26536
26536
|
else if (env === 'desktop-web-ble') {
|
|
26537
26537
|
yield this.transport.init(WebBleLogger, DevicePool.emitter);
|
|
26538
26538
|
}
|
|
26539
|
-
else if (env === 'webusb') {
|
|
26539
|
+
else if (env === 'webusb' || env === 'desktop-webusb') {
|
|
26540
26540
|
yield this.transport.init(WebUsbLogger);
|
|
26541
26541
|
}
|
|
26542
26542
|
else {
|
|
@@ -26910,7 +26910,7 @@ class DeviceCommands {
|
|
|
26910
26910
|
if (error) {
|
|
26911
26911
|
return Promise.reject(error);
|
|
26912
26912
|
}
|
|
26913
|
-
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `${code || 'Failure_UnknownCode'},${message || '
|
|
26913
|
+
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `${code || 'Failure_UnknownCode'},${message || 'no error message'}`));
|
|
26914
26914
|
}
|
|
26915
26915
|
if (res.type === 'Features') {
|
|
26916
26916
|
return Promise.resolve(patchFeatures(res));
|
|
@@ -35344,12 +35344,22 @@ class CosmosSignTransaction extends BaseMethod {
|
|
|
35344
35344
|
}
|
|
35345
35345
|
run() {
|
|
35346
35346
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35347
|
-
|
|
35348
|
-
|
|
35349
|
-
|
|
35350
|
-
|
|
35351
|
-
|
|
35352
|
-
|
|
35347
|
+
try {
|
|
35348
|
+
const res = yield this.device.commands.typedCall('CosmosSignTx', 'CosmosSignedTx', Object.assign({}, this.params));
|
|
35349
|
+
const { signature } = res.message;
|
|
35350
|
+
return {
|
|
35351
|
+
path: serializedPath(this.params.address_n),
|
|
35352
|
+
signature,
|
|
35353
|
+
};
|
|
35354
|
+
}
|
|
35355
|
+
catch (error) {
|
|
35356
|
+
const { message } = error;
|
|
35357
|
+
if (message.includes('Failure_DataError,Json parse failed') ||
|
|
35358
|
+
message.includes('Failure_DataError,Invalid message')) {
|
|
35359
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CosmosInvalidJsonMessage, message);
|
|
35360
|
+
}
|
|
35361
|
+
throw error;
|
|
35362
|
+
}
|
|
35353
35363
|
});
|
|
35354
35364
|
}
|
|
35355
35365
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.20-alpha.0",
|
|
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.
|
|
29
|
-
"@onekeyfe/hd-transport": "1.1.
|
|
28
|
+
"@onekeyfe/hd-shared": "1.1.20-alpha.0",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.1.20-alpha.0",
|
|
30
30
|
"axios": "1.12.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": "bff28f2906ab17d7843f4e0d634bf4acf6b375b4"
|
|
48
48
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
|
+
|
|
2
3
|
import { serializedPath, validatePath } from '../helpers/pathUtils';
|
|
3
4
|
import { BaseMethod } from '../BaseMethod';
|
|
4
5
|
import { validateParams } from '../helpers/paramsValidator';
|
|
5
|
-
import { CosmosSignTransactionParams } from '../../types';
|
|
6
6
|
import { formatAnyHex } from '../helpers/hexUtils';
|
|
7
7
|
|
|
8
|
+
import type { CosmosSignTx as HardwareCosmosSignTx } from '@onekeyfe/hd-transport';
|
|
9
|
+
import type { CosmosSignTransactionParams } from '../../types';
|
|
10
|
+
|
|
8
11
|
export default class CosmosSignTransaction extends BaseMethod<HardwareCosmosSignTx> {
|
|
9
12
|
hasBundle = false;
|
|
10
13
|
|
|
@@ -40,15 +43,26 @@ export default class CosmosSignTransaction extends BaseMethod<HardwareCosmosSign
|
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
async run() {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
try {
|
|
47
|
+
const res = await this.device.commands.typedCall('CosmosSignTx', 'CosmosSignedTx', {
|
|
48
|
+
...this.params,
|
|
49
|
+
});
|
|
46
50
|
|
|
47
|
-
|
|
51
|
+
const { signature } = res.message;
|
|
48
52
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
return {
|
|
54
|
+
path: serializedPath(this.params.address_n),
|
|
55
|
+
signature,
|
|
56
|
+
};
|
|
57
|
+
} catch (error) {
|
|
58
|
+
const { message } = error;
|
|
59
|
+
if (
|
|
60
|
+
message.includes('Failure_DataError,Json parse failed') ||
|
|
61
|
+
message.includes('Failure_DataError,Invalid message')
|
|
62
|
+
) {
|
|
63
|
+
throw ERRORS.TypedError(HardwareErrorCode.CosmosInvalidJsonMessage, message);
|
|
64
|
+
}
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
53
67
|
}
|
|
54
68
|
}
|
|
@@ -60,7 +60,7 @@ export default class TransportManager {
|
|
|
60
60
|
await this.transport.init(LowLevelLogger, DevicePool.emitter, this.plugin);
|
|
61
61
|
} else if (env === 'desktop-web-ble') {
|
|
62
62
|
await this.transport.init(WebBleLogger, DevicePool.emitter);
|
|
63
|
-
} else if (env === 'webusb') {
|
|
63
|
+
} else if (env === 'webusb' || env === 'desktop-webusb') {
|
|
64
64
|
await this.transport.init(WebUsbLogger);
|
|
65
65
|
} else {
|
|
66
66
|
await this.transport.init(HttpLogger);
|
|
@@ -441,7 +441,7 @@ export class DeviceCommands {
|
|
|
441
441
|
ERRORS.TypedError(
|
|
442
442
|
HardwareErrorCode.RuntimeError,
|
|
443
443
|
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
444
|
-
`${(code as any) || 'Failure_UnknownCode'},${message || '
|
|
444
|
+
`${(code as any) || 'Failure_UnknownCode'},${message || 'no error message'}`
|
|
445
445
|
)
|
|
446
446
|
);
|
|
447
447
|
}
|