@onekeyfe/hd-core 0.0.7 → 0.0.10

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 (87) hide show
  1. package/dist/api/BaseMethod.d.ts +2 -0
  2. package/dist/api/BaseMethod.d.ts.map +1 -1
  3. package/dist/api/CipherKeyValue.d.ts +9 -0
  4. package/dist/api/CipherKeyValue.d.ts.map +1 -0
  5. package/dist/api/device/DeviceRebootToBootloader.d.ts +8 -0
  6. package/dist/api/device/DeviceRebootToBootloader.d.ts.map +1 -1
  7. package/dist/api/evm/EVMSignMessageEIP712.d.ts +5 -0
  8. package/dist/api/evm/EVMSignMessageEIP712.d.ts.map +1 -1
  9. package/dist/api/evm/EVMSignTransaction.d.ts +5 -0
  10. package/dist/api/evm/EVMSignTransaction.d.ts.map +1 -1
  11. package/dist/api/evm/EVMSignTypedData.d.ts +7 -1
  12. package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
  13. package/dist/api/helpers/hexUtils.d.ts.map +1 -1
  14. package/dist/api/index.d.ts +7 -0
  15. package/dist/api/index.d.ts.map +1 -1
  16. package/dist/api/nem/NEMGetAddress.d.ts +9 -0
  17. package/dist/api/nem/NEMGetAddress.d.ts.map +1 -0
  18. package/dist/api/nem/NEMSignTransaction.d.ts +20 -0
  19. package/dist/api/nem/NEMSignTransaction.d.ts.map +1 -0
  20. package/dist/api/solana/SolGetAddress.d.ts +9 -0
  21. package/dist/api/solana/SolGetAddress.d.ts.map +1 -0
  22. package/dist/api/solana/SolSignTransaction.d.ts +17 -0
  23. package/dist/api/solana/SolSignTransaction.d.ts.map +1 -0
  24. package/dist/api/stellar/StellarGetAddress.d.ts +9 -0
  25. package/dist/api/stellar/StellarGetAddress.d.ts.map +1 -0
  26. package/dist/api/stellar/StellarSignTransaction.d.ts +335 -0
  27. package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -0
  28. package/dist/core/index.d.ts.map +1 -1
  29. package/dist/data/version.d.ts +1 -1
  30. package/dist/data/version.d.ts.map +1 -1
  31. package/dist/events/ui-request.d.ts +1 -1
  32. package/dist/events/ui-request.d.ts.map +1 -1
  33. package/dist/index.d.ts +299 -3
  34. package/dist/index.js +729 -20
  35. package/dist/inject.d.ts.map +1 -1
  36. package/dist/types/api/cipherKeyValue.d.ts +19 -0
  37. package/dist/types/api/cipherKeyValue.d.ts.map +1 -0
  38. package/dist/types/api/export.d.ts +7 -0
  39. package/dist/types/api/export.d.ts.map +1 -1
  40. package/dist/types/api/index.d.ts +14 -0
  41. package/dist/types/api/index.d.ts.map +1 -1
  42. package/dist/types/api/nemGetAddress.d.ts +15 -0
  43. package/dist/types/api/nemGetAddress.d.ts.map +1 -0
  44. package/dist/types/api/nemSignTransaction.d.ts +93 -0
  45. package/dist/types/api/nemSignTransaction.d.ts.map +1 -0
  46. package/dist/types/api/solGetAddress.d.ts +14 -0
  47. package/dist/types/api/solGetAddress.d.ts.map +1 -0
  48. package/dist/types/api/solSignTransaction.d.ts +14 -0
  49. package/dist/types/api/solSignTransaction.d.ts.map +1 -0
  50. package/dist/types/api/stellarGetAddress.d.ts +14 -0
  51. package/dist/types/api/stellarGetAddress.d.ts.map +1 -0
  52. package/dist/types/api/stellarSignTransaction.d.ts +130 -0
  53. package/dist/types/api/stellarSignTransaction.d.ts.map +1 -0
  54. package/dist/types/device.d.ts +7 -0
  55. package/dist/types/device.d.ts.map +1 -1
  56. package/dist/utils/deviceFeaturesUtils.d.ts +49 -2
  57. package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
  58. package/package.json +3 -3
  59. package/src/api/BaseMethod.ts +5 -0
  60. package/src/api/CipherKeyValue.ts +66 -0
  61. package/src/api/device/DeviceRebootToBootloader.ts +11 -0
  62. package/src/api/evm/EVMSignMessageEIP712.ts +8 -0
  63. package/src/api/evm/EVMSignTransaction.ts +15 -0
  64. package/src/api/evm/EVMSignTypedData.ts +55 -15
  65. package/src/api/helpers/hexUtils.ts +0 -1
  66. package/src/api/index.ts +10 -0
  67. package/src/api/nem/NEMGetAddress.ts +61 -0
  68. package/src/api/nem/NEMSignTransaction.ts +246 -0
  69. package/src/api/solana/SolGetAddress.ts +59 -0
  70. package/src/api/solana/SolSignTransaction.ts +69 -0
  71. package/src/api/stellar/StellarGetAddress.ts +59 -0
  72. package/src/api/stellar/StellarSignTransaction.ts +213 -0
  73. package/src/core/index.ts +50 -6
  74. package/src/data/version.ts +1 -1
  75. package/src/events/ui-request.ts +1 -1
  76. package/src/inject.ts +15 -0
  77. package/src/types/api/cipherKeyValue.ts +26 -0
  78. package/src/types/api/export.ts +27 -0
  79. package/src/types/api/index.ts +18 -0
  80. package/src/types/api/nemGetAddress.ts +22 -0
  81. package/src/types/api/nemSignTransaction.ts +117 -0
  82. package/src/types/api/solGetAddress.ts +21 -0
  83. package/src/types/api/solSignTransaction.ts +21 -0
  84. package/src/types/api/stellarGetAddress.ts +21 -0
  85. package/src/types/api/stellarSignTransaction.ts +153 -0
  86. package/src/types/device.ts +8 -0
  87. package/src/utils/deviceFeaturesUtils.ts +16 -2
@@ -0,0 +1,21 @@
1
+ import { StellarAddress as HardwareStellarAddress } from '@onekeyfe/hd-transport/src/types/messages';
2
+ import type { CommonParams, Response } from '../params';
3
+
4
+ export type StellarAddress = {
5
+ path: string;
6
+ } & HardwareStellarAddress;
7
+
8
+ export type StellarGetAddressParams = {
9
+ path: string | number[];
10
+ showOnOneKey?: boolean;
11
+ };
12
+
13
+ export declare function stellarGetAddress(
14
+ connectId: string,
15
+ params: CommonParams & StellarGetAddressParams
16
+ ): Response<StellarAddress>;
17
+
18
+ export declare function stellarGetAddress(
19
+ connectId: string,
20
+ params: CommonParams & { bundle?: StellarGetAddressParams[] }
21
+ ): Response<Array<StellarAddress>>;
@@ -0,0 +1,153 @@
1
+ import { StellarSignedTx } from '@onekeyfe/hd-transport/src/types/messages';
2
+ import { CommonParams, Response } from '../params';
3
+
4
+ export type StellarAsset = {
5
+ type: 0 | 1 | 2; // 0: native, 1: credit_alphanum4, 2: credit_alphanum12
6
+ code: string;
7
+ issuer?: string;
8
+ };
9
+
10
+ type StellarCreateAccountOperation = {
11
+ type: 'createAccount';
12
+ source?: string;
13
+ destination: string;
14
+ startingBalance: string;
15
+ };
16
+
17
+ type StellarPaymentOperation = {
18
+ type: 'payment';
19
+ source?: string;
20
+ destination: string;
21
+ asset?: StellarAsset | typeof undefined;
22
+ amount: string;
23
+ };
24
+
25
+ type StellarPathPaymentOperation = {
26
+ type: 'pathPayment';
27
+ source?: string;
28
+ sendAsset: StellarAsset;
29
+ sendMax: string;
30
+ destination: string;
31
+ destAsset: StellarAsset;
32
+ destAmount: string;
33
+ path?: StellarAsset[];
34
+ };
35
+
36
+ type StellarPassiveOfferOperation = {
37
+ type: 'createPassiveOffer';
38
+ source?: string;
39
+ buying: StellarAsset;
40
+ selling: StellarAsset;
41
+ amount: string;
42
+ price: { n: number; d: number };
43
+ };
44
+
45
+ type StellarManageOfferOperation = {
46
+ type: 'manageOffer';
47
+ source?: string;
48
+ buying: StellarAsset;
49
+ selling: StellarAsset;
50
+ amount: string;
51
+ offerId?: string;
52
+ price: { n: number; d: number };
53
+ };
54
+
55
+ type StellarSetOptionsOperation = {
56
+ type: 'setOptions';
57
+ source?: string;
58
+ signer?: {
59
+ type: 0 | 1 | 2;
60
+ key: string | Buffer;
61
+ weight?: number;
62
+ };
63
+ inflationDest?: string;
64
+ clearFlags?: number;
65
+ setFlags?: number;
66
+ masterWeight?: number | string;
67
+ lowThreshold?: number | string;
68
+ medThreshold?: number | string;
69
+ highThreshold?: number | string;
70
+ homeDomain?: string;
71
+ };
72
+
73
+ type StellarChangeTrustOperation = {
74
+ type: 'changeTrust';
75
+ source?: string;
76
+ line: StellarAsset;
77
+ limit?: string;
78
+ };
79
+
80
+ type StellarAllowTrustOperation = {
81
+ type: 'allowTrust';
82
+ source?: string;
83
+ trustor: string;
84
+ assetCode: string;
85
+ assetType: number;
86
+ authorize?: boolean | typeof undefined;
87
+ };
88
+
89
+ type StellarAccountMergeOperation = {
90
+ type: 'accountMerge';
91
+ source?: string;
92
+ destination: string;
93
+ };
94
+
95
+ type StellarManageDataOperation = {
96
+ type: 'manageData';
97
+ source?: string;
98
+ name: string;
99
+ value?: Buffer | string;
100
+ };
101
+
102
+ type StellarBumpSequenceOperation = {
103
+ type: 'bumpSequence';
104
+ source?: string;
105
+ bumpTo: string;
106
+ };
107
+
108
+ type StellarInflationOperation = {
109
+ type: 'inflation';
110
+ source?: string;
111
+ };
112
+
113
+ export type StellarOperation =
114
+ | StellarCreateAccountOperation
115
+ | StellarPaymentOperation
116
+ | StellarPathPaymentOperation
117
+ | StellarPassiveOfferOperation
118
+ | StellarManageOfferOperation
119
+ | StellarSetOptionsOperation
120
+ | StellarChangeTrustOperation
121
+ | StellarAllowTrustOperation
122
+ | StellarAccountMergeOperation
123
+ | StellarInflationOperation
124
+ | StellarManageDataOperation
125
+ | StellarBumpSequenceOperation;
126
+
127
+ export type StellarTransaction = {
128
+ source: string;
129
+ fee: number;
130
+ sequence: string | number;
131
+ timebounds?: {
132
+ minTime: number;
133
+ maxTime: number;
134
+ };
135
+ memo?: {
136
+ type: 0 | 1 | 2 | 3 | 4;
137
+ id?: string;
138
+ text?: string;
139
+ hash?: string | Buffer;
140
+ };
141
+ operations: StellarOperation[];
142
+ };
143
+
144
+ export type StellarSignTransactionParams = {
145
+ path: string | number[];
146
+ networkPassphrase: string;
147
+ transaction: StellarTransaction;
148
+ };
149
+
150
+ export declare function stellarSignTransaction(
151
+ connectId: string,
152
+ params: CommonParams & StellarSignTransactionParams
153
+ ): Response<StellarSignedTx>;
@@ -73,8 +73,16 @@ export type Features = PROTO.Features;
73
73
 
74
74
  export type IDeviceType = 'classic' | 'mini' | 'touch' | 'pro';
75
75
 
76
+ // model_mini: 'classic' | 'mini'
77
+ // model_touch: 'touch' | 'pro'
78
+ export type IDeviceModel = 'model_mini' | 'model_touch';
79
+
76
80
  export type IDeviceFirmwareStatus = 'valid' | 'outdated' | 'required' | 'unknown' | 'none';
77
81
 
78
82
  export type IDeviceBLEFirmwareStatus = 'valid' | 'outdated' | 'required' | 'unknown' | 'none';
79
83
 
80
84
  export type ITransportStatus = 'valid' | 'outdated';
85
+
86
+ export type DeviceFirmwareRange = {
87
+ [deviceType in IDeviceType | IDeviceModel]?: { min: string; max?: string };
88
+ };
@@ -1,4 +1,16 @@
1
- import type { Features, IVersionArray, IDeviceType } from '../types';
1
+ import type { Features, IVersionArray, IDeviceType, IDeviceModel } from '../types';
2
+
3
+ export const getDeviceModel = (features?: Features): IDeviceModel => {
4
+ if (!features || typeof features !== 'object') {
5
+ return 'model_mini';
6
+ }
7
+
8
+ if (features.model === '1') {
9
+ return 'model_mini';
10
+ }
11
+ // model === 'T'
12
+ return 'model_touch';
13
+ };
2
14
 
3
15
  export const getDeviceType = (features?: Features): IDeviceType => {
4
16
  if (!features || typeof features !== 'object' || !features.serial_no) {
@@ -49,7 +61,9 @@ export const getDeviceLabel = (features: Features) => {
49
61
  /**
50
62
  * Get Connected Device version by features
51
63
  */
52
- export const getDeviceFirmwareVersion = (features: Features): IVersionArray => {
64
+ export const getDeviceFirmwareVersion = (features: Features | undefined): IVersionArray => {
65
+ if (!features) return [0, 0, 0];
66
+
53
67
  if (features.onekey_version) {
54
68
  return features.onekey_version.split('.') as unknown as IVersionArray;
55
69
  }