@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.
- package/dist/api/BaseMethod.d.ts +2 -0
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CipherKeyValue.d.ts +9 -0
- package/dist/api/CipherKeyValue.d.ts.map +1 -0
- package/dist/api/device/DeviceRebootToBootloader.d.ts +8 -0
- package/dist/api/device/DeviceRebootToBootloader.d.ts.map +1 -1
- package/dist/api/evm/EVMSignMessageEIP712.d.ts +5 -0
- package/dist/api/evm/EVMSignMessageEIP712.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTransaction.d.ts +5 -0
- package/dist/api/evm/EVMSignTransaction.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTypedData.d.ts +7 -1
- package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
- package/dist/api/helpers/hexUtils.d.ts.map +1 -1
- package/dist/api/index.d.ts +7 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/nem/NEMGetAddress.d.ts +9 -0
- package/dist/api/nem/NEMGetAddress.d.ts.map +1 -0
- package/dist/api/nem/NEMSignTransaction.d.ts +20 -0
- package/dist/api/nem/NEMSignTransaction.d.ts.map +1 -0
- package/dist/api/solana/SolGetAddress.d.ts +9 -0
- package/dist/api/solana/SolGetAddress.d.ts.map +1 -0
- package/dist/api/solana/SolSignTransaction.d.ts +17 -0
- package/dist/api/solana/SolSignTransaction.d.ts.map +1 -0
- package/dist/api/stellar/StellarGetAddress.d.ts +9 -0
- package/dist/api/stellar/StellarGetAddress.d.ts.map +1 -0
- package/dist/api/stellar/StellarSignTransaction.d.ts +335 -0
- package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data/version.d.ts +1 -1
- package/dist/data/version.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +1 -1
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +299 -3
- package/dist/index.js +729 -20
- package/dist/inject.d.ts.map +1 -1
- package/dist/types/api/cipherKeyValue.d.ts +19 -0
- package/dist/types/api/cipherKeyValue.d.ts.map +1 -0
- package/dist/types/api/export.d.ts +7 -0
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +14 -0
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/nemGetAddress.d.ts +15 -0
- package/dist/types/api/nemGetAddress.d.ts.map +1 -0
- package/dist/types/api/nemSignTransaction.d.ts +93 -0
- package/dist/types/api/nemSignTransaction.d.ts.map +1 -0
- package/dist/types/api/solGetAddress.d.ts +14 -0
- package/dist/types/api/solGetAddress.d.ts.map +1 -0
- package/dist/types/api/solSignTransaction.d.ts +14 -0
- package/dist/types/api/solSignTransaction.d.ts.map +1 -0
- package/dist/types/api/stellarGetAddress.d.ts +14 -0
- package/dist/types/api/stellarGetAddress.d.ts.map +1 -0
- package/dist/types/api/stellarSignTransaction.d.ts +130 -0
- package/dist/types/api/stellarSignTransaction.d.ts.map +1 -0
- package/dist/types/device.d.ts +7 -0
- package/dist/types/device.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +49 -2
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/api/BaseMethod.ts +5 -0
- package/src/api/CipherKeyValue.ts +66 -0
- package/src/api/device/DeviceRebootToBootloader.ts +11 -0
- package/src/api/evm/EVMSignMessageEIP712.ts +8 -0
- package/src/api/evm/EVMSignTransaction.ts +15 -0
- package/src/api/evm/EVMSignTypedData.ts +55 -15
- package/src/api/helpers/hexUtils.ts +0 -1
- package/src/api/index.ts +10 -0
- package/src/api/nem/NEMGetAddress.ts +61 -0
- package/src/api/nem/NEMSignTransaction.ts +246 -0
- package/src/api/solana/SolGetAddress.ts +59 -0
- package/src/api/solana/SolSignTransaction.ts +69 -0
- package/src/api/stellar/StellarGetAddress.ts +59 -0
- package/src/api/stellar/StellarSignTransaction.ts +213 -0
- package/src/core/index.ts +50 -6
- package/src/data/version.ts +1 -1
- package/src/events/ui-request.ts +1 -1
- package/src/inject.ts +15 -0
- package/src/types/api/cipherKeyValue.ts +26 -0
- package/src/types/api/export.ts +27 -0
- package/src/types/api/index.ts +18 -0
- package/src/types/api/nemGetAddress.ts +22 -0
- package/src/types/api/nemSignTransaction.ts +117 -0
- package/src/types/api/solGetAddress.ts +21 -0
- package/src/types/api/solSignTransaction.ts +21 -0
- package/src/types/api/stellarGetAddress.ts +21 -0
- package/src/types/api/stellarSignTransaction.ts +153 -0
- package/src/types/device.ts +8 -0
- 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>;
|
package/src/types/device.ts
CHANGED
|
@@ -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
|
}
|