@onekeyfe/hd-core 0.2.16 → 0.2.18

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 (68) hide show
  1. package/dist/api/cardano/helper/cardanoInputs.d.ts.map +1 -1
  2. package/dist/api/device/DeviceUploadResource.d.ts.map +1 -1
  3. package/dist/api/evm/EVMGetAddress.d.ts.map +1 -1
  4. package/dist/api/evm/EVMGetPublicKey.d.ts.map +1 -1
  5. package/dist/api/evm/EVMSignMessage.d.ts.map +1 -1
  6. package/dist/api/evm/EVMSignTypedData.d.ts +1 -0
  7. package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
  8. package/dist/api/evm/EVMVerifyMessage.d.ts.map +1 -1
  9. package/dist/api/filecoin/FilecoinGetAddress.d.ts +17 -0
  10. package/dist/api/filecoin/FilecoinGetAddress.d.ts.map +1 -0
  11. package/dist/api/filecoin/FilecoinSignTransaction.d.ts +19 -0
  12. package/dist/api/filecoin/FilecoinSignTransaction.d.ts.map +1 -0
  13. package/dist/api/index.d.ts +2 -0
  14. package/dist/api/index.d.ts.map +1 -1
  15. package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -1
  16. package/dist/index.d.ts +34 -3
  17. package/dist/index.js +433 -276
  18. package/dist/inject.d.ts.map +1 -1
  19. package/dist/types/api/cardano.d.ts.map +1 -1
  20. package/dist/types/api/evmGetAddress.d.ts +1 -0
  21. package/dist/types/api/evmGetAddress.d.ts.map +1 -1
  22. package/dist/types/api/evmGetPublicKey.d.ts +1 -0
  23. package/dist/types/api/evmGetPublicKey.d.ts.map +1 -1
  24. package/dist/types/api/evmSignMessage.d.ts +1 -0
  25. package/dist/types/api/evmSignMessage.d.ts.map +1 -1
  26. package/dist/types/api/evmSignTypedData.d.ts +1 -0
  27. package/dist/types/api/evmSignTypedData.d.ts.map +1 -1
  28. package/dist/types/api/evmVerifyMessage.d.ts +1 -0
  29. package/dist/types/api/evmVerifyMessage.d.ts.map +1 -1
  30. package/dist/types/api/export.d.ts +2 -0
  31. package/dist/types/api/export.d.ts.map +1 -1
  32. package/dist/types/api/filecoinGetAddress.d.ts +14 -0
  33. package/dist/types/api/filecoinGetAddress.d.ts.map +1 -0
  34. package/dist/types/api/filecoinSignTransaction.d.ts +14 -0
  35. package/dist/types/api/filecoinSignTransaction.d.ts.map +1 -0
  36. package/dist/types/api/index.d.ts +4 -0
  37. package/dist/types/api/index.d.ts.map +1 -1
  38. package/dist/utils/patch.d.ts +1 -1
  39. package/dist/utils/patch.d.ts.map +1 -1
  40. package/package.json +4 -4
  41. package/src/api/device/DeviceUploadResource.ts +6 -0
  42. package/src/api/evm/EVMGetAddress.ts +2 -0
  43. package/src/api/evm/EVMGetPublicKey.ts +2 -0
  44. package/src/api/evm/EVMSignMessage.ts +3 -1
  45. package/src/api/evm/EVMSignTypedData.ts +8 -3
  46. package/src/api/evm/EVMVerifyMessage.ts +2 -0
  47. package/src/api/filecoin/FilecoinGetAddress.ts +71 -0
  48. package/src/api/filecoin/FilecoinSignTransaction.ts +54 -0
  49. package/src/api/helpers/stringUtils.ts +1 -1
  50. package/src/api/index.ts +3 -0
  51. package/src/api/stellar/StellarSignTransaction.ts +5 -2
  52. package/src/api/xrp/XrpGetAddress.ts +1 -1
  53. package/src/api/xrp/XrpSignTransaction.ts +1 -1
  54. package/src/data/messages/messages.json +463 -419
  55. package/src/inject.ts +5 -0
  56. package/src/types/api/cardano.ts +0 -1
  57. package/src/types/api/evmGetAddress.ts +1 -0
  58. package/src/types/api/evmGetPublicKey.ts +1 -0
  59. package/src/types/api/evmSignMessage.ts +1 -0
  60. package/src/types/api/evmSignTypedData.ts +1 -0
  61. package/src/types/api/evmVerifyMessage.ts +1 -0
  62. package/src/types/api/export.ts +3 -0
  63. package/src/types/api/filecoinGetAddress.ts +23 -0
  64. package/src/types/api/filecoinSignTransaction.ts +23 -0
  65. package/src/types/api/index.ts +9 -0
  66. package/src/types/api/nearSignTransaction.ts +1 -1
  67. package/src/types/api/tronGetAddress.ts +2 -2
  68. package/src/types/api/tronSignTransaction.ts +1 -1
@@ -0,0 +1,71 @@
1
+ import { FilecoinGetAddress as HardwareFilecoinGetAddress } from '@onekeyfe/hd-transport';
2
+ import { UI_REQUEST } from '../../constants/ui-request';
3
+ import { serializedPath, validatePath } from '../helpers/pathUtils';
4
+ import { BaseMethod } from '../BaseMethod';
5
+ import { validateParams } from '../helpers/paramsValidator';
6
+ import { FilecoinAddress, FilecoinGetAddressParams } from '../../types';
7
+
8
+ export default class FilecoinGetAddress extends BaseMethod<HardwareFilecoinGetAddress[]> {
9
+ hasBundle = false;
10
+
11
+ init() {
12
+ this.checkDeviceId = true;
13
+ this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
14
+
15
+ this.hasBundle = !!this.payload?.bundle;
16
+ const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
17
+
18
+ // check payload
19
+ validateParams(payload, [{ name: 'bundle', type: 'array' }]);
20
+
21
+ // init params
22
+ this.params = [];
23
+ payload.bundle.forEach((batch: FilecoinGetAddressParams) => {
24
+ const addressN = validatePath(batch.path, 3);
25
+
26
+ validateParams(batch, [
27
+ { name: 'path', required: true },
28
+ { name: 'showOnOneKey', type: 'boolean' },
29
+ ]);
30
+
31
+ const showOnOneKey = batch.showOnOneKey ?? true;
32
+
33
+ this.params.push({
34
+ address_n: addressN,
35
+ show_display: showOnOneKey,
36
+ });
37
+ });
38
+ }
39
+
40
+ getVersionRange() {
41
+ return {
42
+ model_mini: {
43
+ min: '2.10.0',
44
+ },
45
+ model_touch: {
46
+ min: '3.5.0',
47
+ },
48
+ };
49
+ }
50
+
51
+ async run() {
52
+ const responses: FilecoinAddress[] = [];
53
+
54
+ for (let i = 0; i < this.params.length; i++) {
55
+ const param = this.params[i];
56
+
57
+ const res = await this.device.commands.typedCall('FilecoinGetAddress', 'FilecoinAddress', {
58
+ ...param,
59
+ });
60
+
61
+ const { address } = res.message;
62
+
63
+ responses.push({
64
+ path: serializedPath(param.address_n),
65
+ address,
66
+ });
67
+ }
68
+
69
+ return Promise.resolve(this.hasBundle ? responses : responses[0]);
70
+ }
71
+ }
@@ -0,0 +1,54 @@
1
+ import { FilecoinSignTx as HardwareFilecoinSignTx } from '@onekeyfe/hd-transport';
2
+ import { serializedPath, validatePath } from '../helpers/pathUtils';
3
+ import { BaseMethod } from '../BaseMethod';
4
+ import { validateParams } from '../helpers/paramsValidator';
5
+ import { FilecoinSignTransactionParams } from '../../types';
6
+ import { formatAnyHex } from '../helpers/hexUtils';
7
+
8
+ export default class FilecoinSignTransaction extends BaseMethod<HardwareFilecoinSignTx> {
9
+ hasBundle = false;
10
+
11
+ init() {
12
+ this.checkDeviceId = true;
13
+ this.allowDeviceMode = [...this.allowDeviceMode];
14
+
15
+ // check payload
16
+ validateParams(this.payload, [
17
+ { name: 'path', required: true },
18
+ { name: 'rawTx', type: 'hexString', required: true },
19
+ ]);
20
+
21
+ // init params
22
+ const { path, rawTx } = this.payload as FilecoinSignTransactionParams;
23
+ const addressN = validatePath(path, 3);
24
+
25
+ this.params = {
26
+ address_n: addressN,
27
+ raw_tx: formatAnyHex(rawTx),
28
+ };
29
+ }
30
+
31
+ getVersionRange() {
32
+ return {
33
+ model_mini: {
34
+ min: '2.10.0',
35
+ },
36
+ model_touch: {
37
+ min: '3.5.0',
38
+ },
39
+ };
40
+ }
41
+
42
+ async run() {
43
+ const res = await this.device.commands.typedCall('FilecoinSignTx', 'FilecoinSignedTx', {
44
+ ...this.params,
45
+ });
46
+
47
+ const { signature } = res.message;
48
+
49
+ return {
50
+ path: serializedPath(this.params.address_n),
51
+ signature,
52
+ };
53
+ }
54
+ }
@@ -8,4 +8,4 @@ export const cutString = (str: string | undefined, cutLen: number): [string, str
8
8
  };
9
9
 
10
10
  export const toSnakeCase = (val: string): string =>
11
- val.replace(/([A-Z])/g, el => '_' + el.toLowerCase());
11
+ val.replace(/([A-Z])/g, el => `_${el.toLowerCase()}`);
package/src/api/index.ts CHANGED
@@ -90,3 +90,6 @@ export { default as suiSignTransaction } from './sui/SuiSignTransaction';
90
90
  export { default as cardanoGetAddress } from './cardano/CardanoGetAddress';
91
91
  export { default as cardanoGetPublicKey } from './cardano/CardanoGetPublicKey';
92
92
  export { default as cardanoSignTransaction } from './cardano/CardanoSignTransaction';
93
+
94
+ export { default as filecoinGetAddress } from './filecoin/FilecoinGetAddress';
95
+ export { default as filecoinSignTransaction } from './filecoin/FilecoinSignTransaction';
@@ -3,12 +3,12 @@ import {
3
3
  StellarSignedTx,
4
4
  StellarSignTx as HardwareStellarSignTx,
5
5
  } from '@onekeyfe/hd-transport';
6
+ import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
6
7
  import { UI_REQUEST } from '../../constants/ui-request';
7
8
  import { validatePath } from '../helpers/pathUtils';
8
9
  import { BaseMethod } from '../BaseMethod';
9
10
  import { validateParams } from '../helpers/paramsValidator';
10
11
  import { StellarOperation, StellarSignTransactionParams } from '../../types';
11
- import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
12
12
 
13
13
  export default class StellarSignTransaction extends BaseMethod<HardwareStellarSignTx> {
14
14
  operations: any[] = [];
@@ -160,7 +160,10 @@ export default class StellarSignTransaction extends BaseMethod<HardwareStellarSi
160
160
 
161
161
  const { transaction, networkPassphrase } = this.payload as StellarSignTransactionParams;
162
162
  if (!transaction.timebounds) {
163
- throw ERRORS.TypedError(HardwareErrorCode.CallMethodInvalidParameter, 'timebounds is required');
163
+ throw ERRORS.TypedError(
164
+ HardwareErrorCode.CallMethodInvalidParameter,
165
+ 'timebounds is required'
166
+ );
164
167
  }
165
168
 
166
169
  // init params
@@ -44,7 +44,7 @@ export default class XrpGetAddress extends BaseMethod<
44
44
  getVersionRange() {
45
45
  return {
46
46
  model_mini: {
47
- min: '2.6.0',
47
+ min: '2.9.0',
48
48
  },
49
49
  };
50
50
  }
@@ -50,7 +50,7 @@ export default class XrpGetAddress extends BaseMethod<XrpSignTransactionParams>
50
50
  getVersionRange() {
51
51
  return {
52
52
  model_mini: {
53
- min: '2.6.0',
53
+ min: '2.9.0',
54
54
  },
55
55
  };
56
56
  }