@onekeyfe/hd-core 1.0.9-alpha.1 → 1.0.9

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.
Files changed (60) hide show
  1. package/dist/api/btc/BTCSignMessage.d.ts +4 -0
  2. package/dist/api/btc/BTCSignMessage.d.ts.map +1 -1
  3. package/dist/api/btc/BTCSignPsbt.d.ts +12 -0
  4. package/dist/api/btc/BTCSignPsbt.d.ts.map +1 -0
  5. package/dist/api/device/DeviceUploadResource.d.ts.map +1 -1
  6. package/dist/api/index.d.ts +1 -3
  7. package/dist/api/index.d.ts.map +1 -1
  8. package/dist/device/DeviceCommands.d.ts.map +1 -1
  9. package/dist/index.d.ts +11 -69
  10. package/dist/index.js +110 -507
  11. package/dist/inject.d.ts.map +1 -1
  12. package/dist/types/api/btcSignMessage.d.ts +1 -0
  13. package/dist/types/api/btcSignMessage.d.ts.map +1 -1
  14. package/dist/types/api/btcSignPsbt.d.ts +8 -0
  15. package/dist/types/api/btcSignPsbt.d.ts.map +1 -0
  16. package/dist/types/api/deviceUploadResource.d.ts +0 -1
  17. package/dist/types/api/deviceUploadResource.d.ts.map +1 -1
  18. package/dist/types/api/export.d.ts +0 -3
  19. package/dist/types/api/export.d.ts.map +1 -1
  20. package/dist/types/api/index.d.ts +2 -6
  21. package/dist/types/api/index.d.ts.map +1 -1
  22. package/dist/utils/homescreen.d.ts +1 -13
  23. package/dist/utils/homescreen.d.ts.map +1 -1
  24. package/dist/utils/index.d.ts +1 -1
  25. package/dist/utils/index.d.ts.map +1 -1
  26. package/dist/utils/patch.d.ts +1 -1
  27. package/dist/utils/patch.d.ts.map +1 -1
  28. package/package.json +4 -4
  29. package/src/api/btc/BTCSignMessage.ts +26 -2
  30. package/src/api/btc/BTCSignPsbt.ts +43 -0
  31. package/src/api/device/DeviceUploadResource.ts +4 -5
  32. package/src/api/index.ts +1 -4
  33. package/src/data/messages/messages.json +31 -259
  34. package/src/device/DeviceCommands.ts +1 -0
  35. package/src/inject.ts +2 -7
  36. package/src/types/api/btcSignMessage.ts +1 -0
  37. package/src/types/api/btcSignPsbt.ts +13 -0
  38. package/src/types/api/deviceUploadResource.ts +0 -1
  39. package/src/types/api/export.ts +0 -4
  40. package/src/types/api/index.ts +2 -11
  41. package/src/utils/homescreen.ts +18 -89
  42. package/src/utils/index.ts +1 -1
  43. package/dist/api/ton/TonGetAddress.d.ts +0 -18
  44. package/dist/api/ton/TonGetAddress.d.ts.map +0 -1
  45. package/dist/api/ton/TonSignMessage.d.ts +0 -15
  46. package/dist/api/ton/TonSignMessage.d.ts.map +0 -1
  47. package/dist/api/ton/TonSignProof.d.ts +0 -15
  48. package/dist/api/ton/TonSignProof.d.ts.map +0 -1
  49. package/dist/types/api/tonGetAddress.d.ts +0 -21
  50. package/dist/types/api/tonGetAddress.d.ts.map +0 -1
  51. package/dist/types/api/tonSignMessage.d.ts +0 -21
  52. package/dist/types/api/tonSignMessage.d.ts.map +0 -1
  53. package/dist/types/api/tonSignProof.d.ts +0 -15
  54. package/dist/types/api/tonSignProof.d.ts.map +0 -1
  55. package/src/api/ton/TonGetAddress.ts +0 -94
  56. package/src/api/ton/TonSignMessage.ts +0 -74
  57. package/src/api/ton/TonSignProof.ts +0 -61
  58. package/src/types/api/tonGetAddress.ts +0 -30
  59. package/src/types/api/tonSignMessage.ts +0 -26
  60. package/src/types/api/tonSignProof.ts +0 -20
@@ -1 +0,0 @@
1
- {"version":3,"file":"TonSignProof.d.ts","sourceRoot":"","sources":["../../../src/api/ton/TonSignProof.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAI9E,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,UAAU,CAAC,oBAAoB,CAAC;IACxE,IAAI;IAiCJ,eAAe;;;;;;;;IAWT,GAAG;CAOV"}
@@ -1,21 +0,0 @@
1
- import { TonWalletVersion, TonWorkChain } from '@onekeyfe/hd-transport';
2
- import type { CommonParams, Response } from '../params';
3
- export type TonAddress = {
4
- path: string;
5
- publicKey: string;
6
- address: string;
7
- };
8
- export type TonGetAddressParams = {
9
- path: string | number[];
10
- showOnOneKey?: boolean;
11
- walletVersion?: TonWalletVersion;
12
- isBounceable?: boolean;
13
- isTestnetOnly?: boolean;
14
- workchain?: TonWorkChain;
15
- walletId?: number;
16
- };
17
- export declare function tonGetAddress(connectId: string, deviceId: string, params: CommonParams & TonGetAddressParams): Response<TonAddress>;
18
- export declare function tonGetAddress(connectId: string, deviceId: string, params: CommonParams & {
19
- bundle?: TonGetAddressParams[];
20
- }): Response<Array<TonAddress>>;
21
- //# sourceMappingURL=tonGetAddress.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tonGetAddress.d.ts","sourceRoot":"","sources":["../../../src/types/api/tonGetAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAExD,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,gBAAgB,CAAC;IACjC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,YAAY,GAAG,mBAAmB,GACzC,QAAQ,CAAC,UAAU,CAAC,CAAC;AAExB,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,YAAY,GAAG;IAAE,MAAM,CAAC,EAAE,mBAAmB,EAAE,CAAA;CAAE,GACxD,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC"}
@@ -1,21 +0,0 @@
1
- import { TonSignedMessage, TonWalletVersion, TonWorkChain } from '@onekeyfe/hd-transport';
2
- import type { CommonParams, Response } from '../params';
3
- export type TonSignMessageParams = {
4
- path: string | number[];
5
- destination: string;
6
- jettonMasterAddress?: string;
7
- tonAmount: number;
8
- jettonAmount?: number;
9
- fwdFee?: number;
10
- comment?: string;
11
- mode?: number;
12
- seqno: number;
13
- expireAt: number;
14
- walletVersion?: TonWalletVersion;
15
- walletId?: number;
16
- workchain?: TonWorkChain;
17
- isBounceable?: boolean;
18
- isTestnetOnly?: boolean;
19
- };
20
- export declare function tonSignMessage(connectId: string, deviceId: string, params: CommonParams & TonSignMessageParams): Response<TonSignedMessage>;
21
- //# sourceMappingURL=tonSignMessage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tonSignMessage.d.ts","sourceRoot":"","sources":["../../../src/types/api/tonSignMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC1F,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAExD,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,gBAAgB,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,YAAY,GAAG,oBAAoB,GAC1C,QAAQ,CAAC,gBAAgB,CAAC,CAAC"}
@@ -1,15 +0,0 @@
1
- import { TonSignedProof, TonWalletVersion, TonWorkChain } from '@onekeyfe/hd-transport';
2
- import type { CommonParams, Response } from '../params';
3
- export type TonSignProofParams = {
4
- path: string | number[];
5
- appdomain: string;
6
- comment?: string;
7
- expireAt: number;
8
- walletVersion?: TonWalletVersion;
9
- walletId?: number;
10
- workchain?: TonWorkChain;
11
- isBounceable?: boolean;
12
- isTestnetOnly?: boolean;
13
- };
14
- export declare function tonSignProof(connectId: string, deviceId: string, params: CommonParams & TonSignProofParams): Response<TonSignedProof>;
15
- //# sourceMappingURL=tonSignProof.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tonSignProof.d.ts","sourceRoot":"","sources":["../../../src/types/api/tonSignProof.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACxF,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAExD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,gBAAgB,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,YAAY,GAAG,kBAAkB,GACxC,QAAQ,CAAC,cAAc,CAAC,CAAC"}
@@ -1,94 +0,0 @@
1
- import { TonGetAddress as HardwareTonGetAddress } from '@onekeyfe/hd-transport';
2
-
3
- import { UI_REQUEST } from '../../constants/ui-request';
4
- import { serializedPath, validatePath } from '../helpers/pathUtils';
5
- import { BaseMethod } from '../BaseMethod';
6
- import { validateParams, validateResult } from '../helpers/paramsValidator';
7
- import { TonAddress, TonGetAddressParams } from '../../types';
8
-
9
- export default class TonGetAddress extends BaseMethod<HardwareTonGetAddress[]> {
10
- hasBundle = false;
11
-
12
- shouldConfirm = false;
13
-
14
- init() {
15
- this.checkDeviceId = true;
16
- this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
17
-
18
- this.hasBundle = !!this.payload?.bundle;
19
- const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
20
-
21
- this.shouldConfirm = this.hasBundle
22
- ? this.payload.bundle.some((i: any) => !!i.showOnOneKey)
23
- : false;
24
-
25
- // check payload
26
- validateParams(payload, [{ name: 'bundle', type: 'array' }]);
27
-
28
- // init params
29
- this.params = [];
30
- payload.bundle.forEach((batch: TonGetAddressParams) => {
31
- const addressN = validatePath(batch.path, 3);
32
-
33
- validateParams(batch, [
34
- { name: 'path', required: true },
35
- { name: 'showOnOneKey', type: 'boolean' },
36
- { name: 'walletVersion' },
37
- { name: 'isBounceable', type: 'boolean' },
38
- { name: 'isTestnetOnly', type: 'boolean' },
39
- { name: 'workchain' },
40
- { name: 'walletId', type: 'number' },
41
- ]);
42
-
43
- const showOnOneKey = batch.showOnOneKey ?? true;
44
-
45
- this.params.push({
46
- address_n: addressN,
47
- show_display: showOnOneKey,
48
- wallet_version: batch.walletVersion,
49
- is_bounceable: batch.isBounceable,
50
- is_testnet_only: batch.isTestnetOnly,
51
- workchain: batch.workchain,
52
- wallet_id: batch.walletId,
53
- });
54
- });
55
- }
56
-
57
- getVersionRange() {
58
- return {
59
- model_mini: {
60
- min: '3.0.0',
61
- },
62
- model_touch: {
63
- min: '4.3.0',
64
- },
65
- };
66
- }
67
-
68
- async run() {
69
- const responses: TonAddress[] = [];
70
- for (let i = 0; i < this.params.length; i++) {
71
- const param = this.params[i];
72
-
73
- const res = await this.device.commands.typedCall('TonGetAddress', 'TonAddress', {
74
- ...param,
75
- });
76
-
77
- const { address, public_key } = res.message;
78
-
79
- const result = {
80
- path: serializedPath(param.address_n),
81
- publicKey: public_key,
82
- address,
83
- };
84
- responses.push(result);
85
- this.postPreviousAddressMessage(result);
86
- }
87
-
88
- validateResult(responses, ['address', 'publicKey'], {
89
- expectedLength: this.params.length,
90
- });
91
-
92
- return Promise.resolve(this.hasBundle ? responses : responses[0]);
93
- }
94
- }
@@ -1,74 +0,0 @@
1
- import { TonSignMessage as HardwareTonSignMessage } from '@onekeyfe/hd-transport';
2
-
3
- import { UI_REQUEST } from '../../constants/ui-request';
4
- import { validatePath } from '../helpers/pathUtils';
5
- import { BaseMethod } from '../BaseMethod';
6
- import { validateParams } from '../helpers/paramsValidator';
7
- import { TonSignMessageParams } from '../../types';
8
-
9
- export default class TonSignMessage extends BaseMethod<HardwareTonSignMessage> {
10
- init() {
11
- this.checkDeviceId = true;
12
- this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
13
-
14
- // init params
15
-
16
- validateParams(this.payload, [
17
- { name: 'path', required: true },
18
- { name: 'destination', type: 'string' },
19
- { name: 'jettonMasterAddress', type: 'string' },
20
- { name: 'tonAmount', type: 'number' },
21
- { name: 'jettonAmount', type: 'number' },
22
- { name: 'fwdFee', type: 'number' },
23
- { name: 'comment', type: 'string' },
24
- { name: 'mode', type: 'number' },
25
- { name: 'seqno', type: 'number' },
26
- { name: 'expireAt', type: 'number' },
27
- { name: 'walletVersion' },
28
- { name: 'walletId', type: 'number' },
29
- { name: 'workchain' },
30
- { name: 'isBounceable', type: 'boolean' },
31
- { name: 'isTestnetOnly', type: 'boolean' },
32
- ]);
33
-
34
- const { path } = this.payload as TonSignMessageParams;
35
- const addressN = validatePath(path, 3);
36
-
37
- this.params = {
38
- address_n: addressN,
39
- destination: this.payload.destination,
40
- jetton_master_address: this.payload.jettonMasterAddress,
41
- ton_amount: this.payload.tonAmount,
42
- jetton_amount: this.payload.jettonAmount,
43
- fwd_fee: this.payload.fwdFee,
44
- comment: this.payload.comment,
45
- mode: this.payload.mode,
46
- seqno: this.payload.seqno,
47
- expire_at: this.payload.expireAt,
48
- wallet_version: this.payload.walletVersion,
49
- wallet_id: this.payload.walletId,
50
- workchain: this.payload.workchain,
51
- is_bounceable: this.payload.isBounceable,
52
- is_testnet_only: this.payload.isTestnetOnly,
53
- };
54
- }
55
-
56
- getVersionRange() {
57
- return {
58
- model_mini: {
59
- min: '3.0.0',
60
- },
61
- model_touch: {
62
- min: '4.3.0',
63
- },
64
- };
65
- }
66
-
67
- async run() {
68
- const res = await this.device.commands.typedCall('TonSignMessage', 'TonSignedMessage', {
69
- ...this.params,
70
- });
71
-
72
- return Promise.resolve(res.message);
73
- }
74
- }
@@ -1,61 +0,0 @@
1
- import { TonSignProof as HardwareTonSignProof } from '@onekeyfe/hd-transport';
2
-
3
- import { UI_REQUEST } from '../../constants/ui-request';
4
- import { validatePath } from '../helpers/pathUtils';
5
- import { BaseMethod } from '../BaseMethod';
6
- import { validateParams } from '../helpers/paramsValidator';
7
- import { TonSignProofParams } from '../../types';
8
-
9
- export default class TonSignProof extends BaseMethod<HardwareTonSignProof> {
10
- init() {
11
- this.checkDeviceId = true;
12
- this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
13
-
14
- // init params
15
- validateParams(this.payload, [
16
- { name: 'path', required: true },
17
- { name: 'appdomain', type: 'string' },
18
- { name: 'comment', type: 'string' },
19
- { name: 'expireAt', type: 'number' },
20
- { name: 'walletVersion' },
21
- { name: 'walletId', type: 'number' },
22
- { name: 'workchain' },
23
- { name: 'isBounceable', type: 'boolean' },
24
- { name: 'isTestnetOnly', type: 'boolean' },
25
- ]);
26
-
27
- const { path } = this.payload as TonSignProofParams;
28
- const addressN = validatePath(path, 3);
29
-
30
- this.params = {
31
- address_n: addressN,
32
- appdomain: this.payload.appdomain,
33
- comment: this.payload.comment,
34
- expire_at: this.payload.expireAt,
35
- wallet_version: this.payload.walletVersion,
36
- wallet_id: this.payload.walletId,
37
- workchain: this.payload.workchain,
38
- is_bounceable: this.payload.isBounceable,
39
- is_testnet_only: this.payload.isTestnetOnly,
40
- };
41
- }
42
-
43
- getVersionRange() {
44
- return {
45
- model_mini: {
46
- min: '3.0.0',
47
- },
48
- model_touch: {
49
- min: '4.3.0',
50
- },
51
- };
52
- }
53
-
54
- async run() {
55
- const res = await this.device.commands.typedCall('TonSignProof', 'TonSignedProof', {
56
- ...this.params,
57
- });
58
-
59
- return Promise.resolve(res.message);
60
- }
61
- }
@@ -1,30 +0,0 @@
1
- import { TonWalletVersion, TonWorkChain } from '@onekeyfe/hd-transport';
2
- import type { CommonParams, Response } from '../params';
3
-
4
- export type TonAddress = {
5
- path: string;
6
- publicKey: string;
7
- address: string;
8
- };
9
-
10
- export type TonGetAddressParams = {
11
- path: string | number[];
12
- showOnOneKey?: boolean;
13
- walletVersion?: TonWalletVersion;
14
- isBounceable?: boolean;
15
- isTestnetOnly?: boolean;
16
- workchain?: TonWorkChain;
17
- walletId?: number;
18
- };
19
-
20
- export declare function tonGetAddress(
21
- connectId: string,
22
- deviceId: string,
23
- params: CommonParams & TonGetAddressParams
24
- ): Response<TonAddress>;
25
-
26
- export declare function tonGetAddress(
27
- connectId: string,
28
- deviceId: string,
29
- params: CommonParams & { bundle?: TonGetAddressParams[] }
30
- ): Response<Array<TonAddress>>;
@@ -1,26 +0,0 @@
1
- import { TonSignedMessage, TonWalletVersion, TonWorkChain } from '@onekeyfe/hd-transport';
2
- import type { CommonParams, Response } from '../params';
3
-
4
- export type TonSignMessageParams = {
5
- path: string | number[];
6
- destination: string;
7
- jettonMasterAddress?: string;
8
- tonAmount: number;
9
- jettonAmount?: number;
10
- fwdFee?: number;
11
- comment?: string;
12
- mode?: number;
13
- seqno: number;
14
- expireAt: number;
15
- walletVersion?: TonWalletVersion;
16
- walletId?: number;
17
- workchain?: TonWorkChain;
18
- isBounceable?: boolean;
19
- isTestnetOnly?: boolean;
20
- };
21
-
22
- export declare function tonSignMessage(
23
- connectId: string,
24
- deviceId: string,
25
- params: CommonParams & TonSignMessageParams
26
- ): Response<TonSignedMessage>;
@@ -1,20 +0,0 @@
1
- import { TonSignedProof, TonWalletVersion, TonWorkChain } from '@onekeyfe/hd-transport';
2
- import type { CommonParams, Response } from '../params';
3
-
4
- export type TonSignProofParams = {
5
- path: string | number[];
6
- appdomain: string;
7
- comment?: string;
8
- expireAt: number;
9
- walletVersion?: TonWalletVersion;
10
- walletId?: number;
11
- workchain?: TonWorkChain;
12
- isBounceable?: boolean;
13
- isTestnetOnly?: boolean;
14
- };
15
-
16
- export declare function tonSignProof(
17
- connectId: string,
18
- deviceId: string,
19
- params: CommonParams & TonSignProofParams
20
- ): Response<TonSignedProof>;