@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,59 @@
|
|
|
1
|
+
import { StellarGetAddress as HardwareStellarGetAddress } from '@onekeyfe/hd-transport/src/types/messages';
|
|
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 { StellarGetAddressParams, StellarAddress } from '../../types';
|
|
7
|
+
|
|
8
|
+
export default class StellarGetAddress extends BaseMethod<HardwareStellarGetAddress[]> {
|
|
9
|
+
hasBundle = false;
|
|
10
|
+
|
|
11
|
+
init() {
|
|
12
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
|
|
13
|
+
|
|
14
|
+
this.hasBundle = !!this.payload?.bundle;
|
|
15
|
+
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
16
|
+
|
|
17
|
+
// check payload
|
|
18
|
+
validateParams(payload, [{ name: 'bundle', type: 'array' }]);
|
|
19
|
+
|
|
20
|
+
// init params
|
|
21
|
+
this.params = [];
|
|
22
|
+
payload.bundle.forEach((batch: StellarGetAddressParams) => {
|
|
23
|
+
const addressN = validatePath(batch.path, 3);
|
|
24
|
+
|
|
25
|
+
validateParams(batch, [
|
|
26
|
+
{ name: 'path', required: true },
|
|
27
|
+
{ name: 'showOnOneKey', type: 'boolean' },
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
const showOnOneKey = batch.showOnOneKey ?? true;
|
|
31
|
+
|
|
32
|
+
this.params.push({
|
|
33
|
+
address_n: addressN,
|
|
34
|
+
show_display: showOnOneKey,
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async run() {
|
|
40
|
+
const responses: StellarAddress[] = [];
|
|
41
|
+
|
|
42
|
+
for (let i = 0; i < this.params.length; i++) {
|
|
43
|
+
const param = this.params[i];
|
|
44
|
+
|
|
45
|
+
const res = await this.device.commands.typedCall('StellarGetAddress', 'StellarAddress', {
|
|
46
|
+
...param,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const { address } = res.message;
|
|
50
|
+
|
|
51
|
+
responses.push({
|
|
52
|
+
path: serializedPath(param.address_n),
|
|
53
|
+
address,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return Promise.resolve(this.hasBundle ? responses : responses[0]);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import {
|
|
2
|
+
StellarSignedTx,
|
|
3
|
+
StellarSignTx as HardwareStellarSignTx,
|
|
4
|
+
} from '@onekeyfe/hd-transport/src/types/messages';
|
|
5
|
+
import { UI_REQUEST } from '../../constants/ui-request';
|
|
6
|
+
import { validatePath } from '../helpers/pathUtils';
|
|
7
|
+
import { BaseMethod } from '../BaseMethod';
|
|
8
|
+
import { validateParams } from '../helpers/paramsValidator';
|
|
9
|
+
import { StellarOperation, StellarSignTransactionParams } from '../../types';
|
|
10
|
+
|
|
11
|
+
export default class StellarSignTransaction extends BaseMethod<HardwareStellarSignTx> {
|
|
12
|
+
operations: any[] = [];
|
|
13
|
+
|
|
14
|
+
parseOperation = (op: StellarOperation) => {
|
|
15
|
+
switch (op.type) {
|
|
16
|
+
case 'createAccount':
|
|
17
|
+
validateParams(op, [
|
|
18
|
+
{ name: 'destination', type: 'string', required: true },
|
|
19
|
+
{ name: 'startingBalance', type: 'bigNumber', required: true },
|
|
20
|
+
]);
|
|
21
|
+
return {
|
|
22
|
+
type: 'StellarCreateAccountOp',
|
|
23
|
+
source_account: op.source,
|
|
24
|
+
new_account: op.destination,
|
|
25
|
+
starting_balance: op.startingBalance,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
case 'payment':
|
|
29
|
+
validateParams(op, [
|
|
30
|
+
{ name: 'destination', type: 'string', required: true },
|
|
31
|
+
{ name: 'amount', type: 'bigNumber', required: true },
|
|
32
|
+
{ name: 'asset', required: true },
|
|
33
|
+
]);
|
|
34
|
+
return {
|
|
35
|
+
type: 'StellarPaymentOp',
|
|
36
|
+
source_account: op.source,
|
|
37
|
+
destination_account: op.destination,
|
|
38
|
+
asset: op.asset,
|
|
39
|
+
amount: op.amount,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
case 'pathPayment':
|
|
43
|
+
validateParams(op, [{ name: 'destAmount', type: 'bigNumber', required: true }]);
|
|
44
|
+
return {
|
|
45
|
+
type: 'StellarPathPaymentOp',
|
|
46
|
+
source_account: op.source,
|
|
47
|
+
send_asset: op.sendAsset,
|
|
48
|
+
send_max: op.sendMax,
|
|
49
|
+
destination_account: op.destination,
|
|
50
|
+
destination_asset: op.destAsset,
|
|
51
|
+
destination_amount: op.destAmount,
|
|
52
|
+
paths: op.path,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
case 'createPassiveOffer':
|
|
56
|
+
validateParams(op, [{ name: 'amount', type: 'bigNumber', required: true }]);
|
|
57
|
+
return {
|
|
58
|
+
type: 'StellarCreatePassiveOfferOp',
|
|
59
|
+
source_account: op.source,
|
|
60
|
+
buying_asset: op.buying,
|
|
61
|
+
selling_asset: op.selling,
|
|
62
|
+
amount: op.amount,
|
|
63
|
+
price_n: op.price.n,
|
|
64
|
+
price_d: op.price.d,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
case 'manageOffer':
|
|
68
|
+
validateParams(op, [{ name: 'amount', type: 'bigNumber', required: true }]);
|
|
69
|
+
return {
|
|
70
|
+
type: 'StellarManageOfferOp',
|
|
71
|
+
source_account: op.source,
|
|
72
|
+
buying_asset: op.buying,
|
|
73
|
+
selling_asset: op.selling,
|
|
74
|
+
amount: op.amount,
|
|
75
|
+
offer_id: op.offerId,
|
|
76
|
+
price_n: op.price.n,
|
|
77
|
+
price_d: op.price.d,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
case 'setOptions': {
|
|
81
|
+
const signer = op.signer
|
|
82
|
+
? {
|
|
83
|
+
signer_type: op.signer.type,
|
|
84
|
+
signer_key: op.signer.key,
|
|
85
|
+
signer_weight: op.signer.weight,
|
|
86
|
+
}
|
|
87
|
+
: undefined;
|
|
88
|
+
return {
|
|
89
|
+
type: 'StellarSetOptionsOp',
|
|
90
|
+
source_account: op.source,
|
|
91
|
+
clear_flags: op.clearFlags,
|
|
92
|
+
set_flags: op.setFlags,
|
|
93
|
+
master_weight: op.masterWeight,
|
|
94
|
+
low_threshold: op.lowThreshold,
|
|
95
|
+
medium_threshold: op.medThreshold,
|
|
96
|
+
high_threshold: op.highThreshold,
|
|
97
|
+
home_domain: op.homeDomain,
|
|
98
|
+
inflation_destination_account: op.inflationDest,
|
|
99
|
+
...signer,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
case 'changeTrust':
|
|
104
|
+
validateParams(op, [{ name: 'limit', type: 'bigNumber' }]);
|
|
105
|
+
return {
|
|
106
|
+
type: 'StellarChangeTrustOp',
|
|
107
|
+
source_account: op.source,
|
|
108
|
+
asset: op.line,
|
|
109
|
+
limit: op.limit,
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
case 'allowTrust':
|
|
113
|
+
return {
|
|
114
|
+
type: 'StellarAllowTrustOp',
|
|
115
|
+
source_account: op.source,
|
|
116
|
+
trusted_account: op.trustor,
|
|
117
|
+
asset_type: op.assetType,
|
|
118
|
+
asset_code: op.assetCode,
|
|
119
|
+
is_authorized: op.authorize ? 1 : 0,
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
case 'accountMerge':
|
|
123
|
+
return {
|
|
124
|
+
type: 'StellarAccountMergeOp',
|
|
125
|
+
source_account: op.source,
|
|
126
|
+
destination_account: op.destination,
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
case 'manageData':
|
|
130
|
+
return {
|
|
131
|
+
type: 'StellarManageDataOp',
|
|
132
|
+
source_account: op.source,
|
|
133
|
+
key: op.name,
|
|
134
|
+
value: op.value,
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
case 'bumpSequence':
|
|
138
|
+
return {
|
|
139
|
+
type: 'StellarBumpSequenceOp',
|
|
140
|
+
source_account: op.source,
|
|
141
|
+
bump_to: op.bumpTo,
|
|
142
|
+
};
|
|
143
|
+
default:
|
|
144
|
+
return {};
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
init() {
|
|
149
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
|
|
150
|
+
|
|
151
|
+
// check payload
|
|
152
|
+
validateParams(this.payload, [
|
|
153
|
+
{ name: 'path', required: true },
|
|
154
|
+
{ name: 'networkPassphrase', type: 'string', required: true },
|
|
155
|
+
{ name: 'transaction', type: 'object', required: true },
|
|
156
|
+
]);
|
|
157
|
+
|
|
158
|
+
// init params
|
|
159
|
+
const addressN = validatePath(this.payload.path, 3);
|
|
160
|
+
const { transaction, networkPassphrase } = this.payload as StellarSignTransactionParams;
|
|
161
|
+
|
|
162
|
+
this.params = {
|
|
163
|
+
address_n: addressN,
|
|
164
|
+
network_passphrase: networkPassphrase,
|
|
165
|
+
source_account: transaction.source,
|
|
166
|
+
fee: transaction.fee,
|
|
167
|
+
sequence_number: transaction.sequence,
|
|
168
|
+
num_operations: transaction.operations.length,
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
if (transaction.timebounds) {
|
|
172
|
+
this.params.timebounds_start = transaction.timebounds.minTime;
|
|
173
|
+
this.params.timebounds_end = transaction.timebounds.maxTime;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (transaction.memo) {
|
|
177
|
+
this.params.memo_type = transaction.memo.type;
|
|
178
|
+
this.params.memo_text = transaction.memo.text;
|
|
179
|
+
this.params.memo_id = transaction.memo.id;
|
|
180
|
+
this.params.memo_hash = transaction.memo.hash;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
transaction.operations.forEach(op => {
|
|
184
|
+
const transformed = this.parseOperation(op);
|
|
185
|
+
if (transformed) {
|
|
186
|
+
this.operations.push(transformed);
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
console.log('StellarSignTransactionParams', this.params);
|
|
191
|
+
console.log('StellarSignTransactionOperations', this.operations);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
processTxRequest = async (operations: any, index: number): Promise<StellarSignedTx> => {
|
|
195
|
+
const isLastOp = index + 1 >= operations.length;
|
|
196
|
+
const { type, ...op } = operations[index];
|
|
197
|
+
|
|
198
|
+
if (isLastOp) {
|
|
199
|
+
const response = await this.device.commands.typedCall(type, 'StellarSignedTx', op);
|
|
200
|
+
return response.message;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
await this.device.commands.typedCall(type, 'StellarTxOpRequest', op);
|
|
204
|
+
|
|
205
|
+
return this.processTxRequest(operations, index + 1);
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
async run() {
|
|
209
|
+
await this.device.commands.typedCall('StellarSignTx', 'StellarTxOpRequest', { ...this.params });
|
|
210
|
+
|
|
211
|
+
return this.processTxRequest(this.operations, 0);
|
|
212
|
+
}
|
|
213
|
+
}
|
package/src/core/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import semver from 'semver';
|
|
1
2
|
import EventEmitter from 'events';
|
|
2
3
|
import { OneKeyDeviceInfo } from '@onekeyfe/hd-transport';
|
|
3
4
|
import { ERRORS } from '../constants';
|
|
@@ -25,6 +26,11 @@ import type { BaseMethod } from '../api/BaseMethod';
|
|
|
25
26
|
import type { ConnectSettings, KnownDevice } from '../types';
|
|
26
27
|
import TransportManager from '../data-manager/TransportManager';
|
|
27
28
|
import DeviceConnector from '../device/DeviceConnector';
|
|
29
|
+
import {
|
|
30
|
+
getDeviceFirmwareVersion,
|
|
31
|
+
getDeviceModel,
|
|
32
|
+
getDeviceType,
|
|
33
|
+
} from '../utils/deviceFeaturesUtils';
|
|
28
34
|
|
|
29
35
|
const Log = initLog('Core');
|
|
30
36
|
|
|
@@ -100,11 +106,38 @@ export const callAPI = async (message: CoreMessage) => {
|
|
|
100
106
|
|
|
101
107
|
try {
|
|
102
108
|
const inner = async (): Promise<void> => {
|
|
103
|
-
// check firmware
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
109
|
+
// check firmware version
|
|
110
|
+
const deviceType = getDeviceType(device.features);
|
|
111
|
+
const deviceModel = getDeviceModel(device.features);
|
|
112
|
+
const versionRangeType = method.getVersionRange()[deviceType];
|
|
113
|
+
const versionRangeModel = method.getVersionRange()[deviceModel];
|
|
114
|
+
|
|
115
|
+
// Type has a higher priority than Model
|
|
116
|
+
const versionRange = versionRangeType ?? versionRangeModel;
|
|
117
|
+
|
|
118
|
+
if (versionRange && device.features) {
|
|
119
|
+
const currentVersion = getDeviceFirmwareVersion(device.features).join('.');
|
|
120
|
+
if (semver.valid(versionRange.min) && semver.lt(currentVersion, versionRange.min)) {
|
|
121
|
+
return Promise.reject(
|
|
122
|
+
ERRORS.TypedError(
|
|
123
|
+
'Device_FwException',
|
|
124
|
+
`Device firmware version is too low, please update to ${versionRange.min}`
|
|
125
|
+
)
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
if (
|
|
129
|
+
versionRange.max &&
|
|
130
|
+
semver.valid(versionRange.max) &&
|
|
131
|
+
semver.gt(currentVersion, versionRange.max)
|
|
132
|
+
) {
|
|
133
|
+
return Promise.reject(
|
|
134
|
+
ERRORS.TypedError(
|
|
135
|
+
'Device_FwException',
|
|
136
|
+
`Device firmware version is too high, this method has been deprecated in ${versionRange.max}`
|
|
137
|
+
)
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
108
141
|
|
|
109
142
|
// check call method mode
|
|
110
143
|
const unexpectedMode = device.hasUnexpectedMode(
|
|
@@ -149,6 +182,7 @@ export const callAPI = async (message: CoreMessage) => {
|
|
|
149
182
|
} catch (error) {
|
|
150
183
|
messageResponse = createResponseMessage(method.responseID, false, error);
|
|
151
184
|
_callPromise?.reject(ERRORS.TypedError('Call_API', error));
|
|
185
|
+
Log.debug('Call API - Run Error: ', error);
|
|
152
186
|
} finally {
|
|
153
187
|
const response = messageResponse;
|
|
154
188
|
|
|
@@ -251,7 +285,17 @@ const onDevicePinHandler = async (...[device, type, callback]: DeviceEvents['pin
|
|
|
251
285
|
|
|
252
286
|
const onDeviceButtonHandler = (...[device, request]: [...DeviceEvents['button']]) => {
|
|
253
287
|
postMessage(createDeviceMessage(DEVICE.BUTTON, { ...request, device: device.toMessageObject() }));
|
|
254
|
-
|
|
288
|
+
|
|
289
|
+
if (request.code === 'ButtonRequest_PinEntry') {
|
|
290
|
+
postMessage(
|
|
291
|
+
createUiMessage(UI_REQUEST.REQUEST_PIN, {
|
|
292
|
+
device: device.toMessageObject() as KnownDevice,
|
|
293
|
+
type: 'ButtonRequest_PinEntry',
|
|
294
|
+
})
|
|
295
|
+
);
|
|
296
|
+
} else {
|
|
297
|
+
postMessage(createUiMessage(UI_REQUEST.REQUEST_BUTTON, { device: device.toMessageObject() }));
|
|
298
|
+
}
|
|
255
299
|
};
|
|
256
300
|
|
|
257
301
|
/**
|
package/src/data/version.ts
CHANGED
package/src/events/ui-request.ts
CHANGED
package/src/inject.ts
CHANGED
|
@@ -66,6 +66,8 @@ export const inject = ({
|
|
|
66
66
|
*/
|
|
67
67
|
checkTransportRelease: () => call({ method: 'checkTransportRelease' }),
|
|
68
68
|
|
|
69
|
+
cipherKeyValue: (connectId, params) => call({ ...params, connectId, method: 'cipherKeyValue' }),
|
|
70
|
+
|
|
69
71
|
deviceBackup: connectId => call({ connectId, method: 'deviceBackup' }),
|
|
70
72
|
deviceChangePin: (connectId, params) =>
|
|
71
73
|
call({ ...params, connectId, method: 'deviceChangePin' }),
|
|
@@ -109,6 +111,19 @@ export const inject = ({
|
|
|
109
111
|
call({ ...params, connectId, method: 'starcoinSignTransaction' }),
|
|
110
112
|
starcoinVerifyMessage: (connectId, params) =>
|
|
111
113
|
call({ ...params, connectId, method: 'starcoinVerifyMessage' }),
|
|
114
|
+
|
|
115
|
+
nemGetAddress: (connectId, params) => call({ ...params, connectId, method: 'nemGetAddress' }),
|
|
116
|
+
nemSignTransaction: (connectId, params) =>
|
|
117
|
+
call({ ...params, connectId, method: 'nemSignTransaction' }),
|
|
118
|
+
|
|
119
|
+
solGetAddress: (connectId, params) => call({ ...params, connectId, method: 'solGetAddress' }),
|
|
120
|
+
solSignTransaction: (connectId, params) =>
|
|
121
|
+
call({ ...params, connectId, method: 'solSignTransaction' }),
|
|
122
|
+
|
|
123
|
+
stellarGetAddress: (connectId, params) =>
|
|
124
|
+
call({ ...params, connectId, method: 'stellarGetAddress' }),
|
|
125
|
+
stellarSignTransaction: (connectId, params) =>
|
|
126
|
+
call({ ...params, connectId, method: 'stellarSignTransaction' }),
|
|
112
127
|
};
|
|
113
128
|
return api;
|
|
114
129
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CipheredKeyValue as HardwareCipheredKeyValue } from '@onekeyfe/hd-transport/src/types/messages';
|
|
2
|
+
import type { CommonParams, Response } from '../params';
|
|
3
|
+
|
|
4
|
+
export type CipheredKeyValue = {
|
|
5
|
+
path: string;
|
|
6
|
+
} & HardwareCipheredKeyValue;
|
|
7
|
+
|
|
8
|
+
export type CipheredKeyValueParams = {
|
|
9
|
+
path: string | number[];
|
|
10
|
+
key: string;
|
|
11
|
+
value: string;
|
|
12
|
+
encrypt?: boolean;
|
|
13
|
+
askOnEncrypt?: boolean;
|
|
14
|
+
askOnDecrypt?: boolean;
|
|
15
|
+
iv?: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export declare function cipherKeyValue(
|
|
19
|
+
connectId: string,
|
|
20
|
+
params: CommonParams & CipheredKeyValueParams
|
|
21
|
+
): Response<CipheredKeyValue>;
|
|
22
|
+
|
|
23
|
+
export declare function cipherKeyValue(
|
|
24
|
+
connectId: string,
|
|
25
|
+
params: CommonParams & { bundle?: CipheredKeyValueParams[] }
|
|
26
|
+
): Response<Array<CipheredKeyValue>>;
|
package/src/types/api/export.ts
CHANGED
|
@@ -11,6 +11,8 @@ export type {
|
|
|
11
11
|
TransactionOptions,
|
|
12
12
|
} from './btcSignTransaction';
|
|
13
13
|
|
|
14
|
+
export type { CipheredKeyValue, CipheredKeyValueParams } from './cipherKeyValue';
|
|
15
|
+
|
|
14
16
|
export type { DeviceChangePinParams } from './deviceChangePin';
|
|
15
17
|
export type { DeviceFlagsParams } from './deviceFlags';
|
|
16
18
|
export type { DeviceRecoveryParams } from './deviceRecovery';
|
|
@@ -41,3 +43,28 @@ export type { StarcoinPublicKey, StarcoinGetPublicKeyParams } from './starcoinGe
|
|
|
41
43
|
export type { StarcoinSignMessageParams } from './starcoinSignMessage';
|
|
42
44
|
export type { StarcoinSignTransactionParams } from './starcoinSignTransaction';
|
|
43
45
|
export type { StarcoinVerifyMessageParams } from './starcoinVerifyMessage';
|
|
46
|
+
|
|
47
|
+
export type { NEMAddress, NEMGetAddressParams } from './nemGetAddress';
|
|
48
|
+
export type {
|
|
49
|
+
NEMAggregateModificationTransaction,
|
|
50
|
+
NEMImportanceTransaction,
|
|
51
|
+
NEMMosaic,
|
|
52
|
+
NEMMosaicCreationTransaction,
|
|
53
|
+
NEMMultisigTransaction,
|
|
54
|
+
NEMProvisionNamespaceTransaction,
|
|
55
|
+
NEMSupplyChangeTransaction,
|
|
56
|
+
NEMTransferTransaction,
|
|
57
|
+
NEMTransaction,
|
|
58
|
+
NEMSignTransactionParams,
|
|
59
|
+
} from './nemSignTransaction';
|
|
60
|
+
|
|
61
|
+
export type { SolanaAddress, SolanaGetAddressParams } from './solGetAddress';
|
|
62
|
+
export type { SolanaSignedTx, SolanaSignTransactionParams } from './solSignTransaction';
|
|
63
|
+
|
|
64
|
+
export type { StellarAddress, StellarGetAddressParams } from './stellarGetAddress';
|
|
65
|
+
export type {
|
|
66
|
+
StellarAsset,
|
|
67
|
+
StellarOperation,
|
|
68
|
+
StellarTransaction,
|
|
69
|
+
StellarSignTransactionParams,
|
|
70
|
+
} from './stellarSignTransaction';
|
package/src/types/api/index.ts
CHANGED
|
@@ -32,6 +32,13 @@ import { starcoinGetPublicKey } from './starcoinGetPublicKey';
|
|
|
32
32
|
import { starcoinSignMessage } from './starcoinSignMessage';
|
|
33
33
|
import { starcoinSignTransaction } from './starcoinSignTransaction';
|
|
34
34
|
import { starcoinVerifyMessage } from './starcoinVerifyMessage';
|
|
35
|
+
import { nemGetAddress } from './nemGetAddress';
|
|
36
|
+
import { nemSignTransaction } from './nemSignTransaction';
|
|
37
|
+
import { solGetAddress } from './solGetAddress';
|
|
38
|
+
import { solSignTransaction } from './solSignTransaction';
|
|
39
|
+
import { stellarGetAddress } from './stellarGetAddress';
|
|
40
|
+
import { stellarSignTransaction } from './stellarSignTransaction';
|
|
41
|
+
import { cipherKeyValue } from './cipherKeyValue';
|
|
35
42
|
|
|
36
43
|
export * from './export';
|
|
37
44
|
|
|
@@ -61,6 +68,8 @@ export type CoreApi = {
|
|
|
61
68
|
|
|
62
69
|
checkTransportRelease: typeof checkTransportRelease;
|
|
63
70
|
|
|
71
|
+
cipherKeyValue: typeof cipherKeyValue;
|
|
72
|
+
|
|
64
73
|
deviceBackup: typeof deviceBackup;
|
|
65
74
|
deviceChangePin: typeof deviceChangePin;
|
|
66
75
|
deviceFlags: typeof deviceFlags;
|
|
@@ -90,4 +99,13 @@ export type CoreApi = {
|
|
|
90
99
|
starcoinSignMessage: typeof starcoinSignMessage;
|
|
91
100
|
starcoinSignTransaction: typeof starcoinSignTransaction;
|
|
92
101
|
starcoinVerifyMessage: typeof starcoinVerifyMessage;
|
|
102
|
+
|
|
103
|
+
nemGetAddress: typeof nemGetAddress;
|
|
104
|
+
nemSignTransaction: typeof nemSignTransaction;
|
|
105
|
+
|
|
106
|
+
solGetAddress: typeof solGetAddress;
|
|
107
|
+
solSignTransaction: typeof solSignTransaction;
|
|
108
|
+
|
|
109
|
+
stellarGetAddress: typeof stellarGetAddress;
|
|
110
|
+
stellarSignTransaction: typeof stellarSignTransaction;
|
|
93
111
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { NEMAddress as HardwareNEMAddress } from '@onekeyfe/hd-transport/src/types/messages';
|
|
2
|
+
import type { CommonParams, Response } from '../params';
|
|
3
|
+
|
|
4
|
+
export type NEMAddress = {
|
|
5
|
+
path: string;
|
|
6
|
+
} & HardwareNEMAddress;
|
|
7
|
+
|
|
8
|
+
export type NEMGetAddressParams = {
|
|
9
|
+
path: string | number[];
|
|
10
|
+
network?: number;
|
|
11
|
+
showOnOneKey?: boolean;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export declare function nemGetAddress(
|
|
15
|
+
connectId: string,
|
|
16
|
+
params: CommonParams & NEMGetAddressParams
|
|
17
|
+
): Response<NEMAddress>;
|
|
18
|
+
|
|
19
|
+
export declare function nemGetAddress(
|
|
20
|
+
connectId: string,
|
|
21
|
+
params: CommonParams & { bundle?: NEMGetAddressParams[] }
|
|
22
|
+
): Response<Array<NEMAddress>>;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { NEMSignedTx } from '@onekeyfe/hd-transport/src/types/messages';
|
|
2
|
+
import type { CommonParams, Response } from '../params';
|
|
3
|
+
|
|
4
|
+
type MosaicID = {
|
|
5
|
+
namespaceId: string;
|
|
6
|
+
name: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type MosaicDefinition = {
|
|
10
|
+
levy?: {
|
|
11
|
+
type?: number;
|
|
12
|
+
fee?: number;
|
|
13
|
+
recipient?: string;
|
|
14
|
+
mosaicId?: MosaicID;
|
|
15
|
+
};
|
|
16
|
+
id: MosaicID;
|
|
17
|
+
description: string;
|
|
18
|
+
properties?: Array<{
|
|
19
|
+
name: 'divisibility' | 'initialSupply' | 'supplyMutable' | 'transferable';
|
|
20
|
+
value: string;
|
|
21
|
+
}>;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type NEMMosaic = {
|
|
25
|
+
mosaicId: MosaicID;
|
|
26
|
+
quantity: number;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
type Modification = {
|
|
30
|
+
modificationType: number;
|
|
31
|
+
cosignatoryAccount: string;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
type Message = {
|
|
35
|
+
payload?: string;
|
|
36
|
+
type?: number;
|
|
37
|
+
publicKey?: string;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
type TransactionCommon = {
|
|
41
|
+
version: number;
|
|
42
|
+
timeStamp: number;
|
|
43
|
+
fee: number;
|
|
44
|
+
deadline?: number;
|
|
45
|
+
signer?: string;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type NEMTransferTransaction = TransactionCommon & {
|
|
49
|
+
type: 0x0101;
|
|
50
|
+
recipient: string;
|
|
51
|
+
amount: number | string;
|
|
52
|
+
mosaics?: NEMMosaic[];
|
|
53
|
+
message?: Message;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export type NEMImportanceTransaction = TransactionCommon & {
|
|
57
|
+
type: 0x0801;
|
|
58
|
+
importanceTransfer: {
|
|
59
|
+
mode: number;
|
|
60
|
+
publicKey: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export type NEMAggregateModificationTransaction = TransactionCommon & {
|
|
65
|
+
type: 0x1001;
|
|
66
|
+
modifications?: Modification[];
|
|
67
|
+
minCosignatories: {
|
|
68
|
+
relativeChange: number;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export type NEMProvisionNamespaceTransaction = TransactionCommon & {
|
|
73
|
+
type: 0x2001;
|
|
74
|
+
newPart?: string;
|
|
75
|
+
parent?: string;
|
|
76
|
+
rentalFeeSink?: string;
|
|
77
|
+
rentalFee?: number;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export type NEMMosaicCreationTransaction = TransactionCommon & {
|
|
81
|
+
type: 0x4001;
|
|
82
|
+
mosaicDefinition: MosaicDefinition;
|
|
83
|
+
creationFeeSink?: string;
|
|
84
|
+
creationFee?: number;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export type NEMSupplyChangeTransaction = TransactionCommon & {
|
|
88
|
+
type: 0x4002;
|
|
89
|
+
mosaicId: MosaicID;
|
|
90
|
+
supplyType: number;
|
|
91
|
+
delta?: number;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
type Transaction =
|
|
95
|
+
| NEMTransferTransaction
|
|
96
|
+
| NEMImportanceTransaction
|
|
97
|
+
| NEMAggregateModificationTransaction
|
|
98
|
+
| NEMProvisionNamespaceTransaction
|
|
99
|
+
| NEMMosaicCreationTransaction
|
|
100
|
+
| NEMSupplyChangeTransaction;
|
|
101
|
+
|
|
102
|
+
export type NEMMultisigTransaction = TransactionCommon & {
|
|
103
|
+
type: 0x0102 | 0x1002 | 0x1004;
|
|
104
|
+
otherTrans: Transaction;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export type NEMTransaction = Transaction | NEMMultisigTransaction;
|
|
108
|
+
|
|
109
|
+
export type NEMSignTransactionParams = {
|
|
110
|
+
path: string | number[];
|
|
111
|
+
transaction: NEMTransaction;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export declare function nemSignTransaction(
|
|
115
|
+
connectId: string,
|
|
116
|
+
params: CommonParams & NEMSignTransactionParams
|
|
117
|
+
): Response<NEMSignedTx>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SolanaAddress as HardwareSolanaAddress } from '@onekeyfe/hd-transport/src/types/messages';
|
|
2
|
+
import type { CommonParams, Response } from '../params';
|
|
3
|
+
|
|
4
|
+
export type SolanaAddress = {
|
|
5
|
+
path: string;
|
|
6
|
+
} & HardwareSolanaAddress;
|
|
7
|
+
|
|
8
|
+
export type SolanaGetAddressParams = {
|
|
9
|
+
path: string | number[];
|
|
10
|
+
showOnOneKey?: boolean;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export declare function solGetAddress(
|
|
14
|
+
connectId: string,
|
|
15
|
+
params: CommonParams & SolanaGetAddressParams
|
|
16
|
+
): Response<SolanaAddress>;
|
|
17
|
+
|
|
18
|
+
export declare function solGetAddress(
|
|
19
|
+
connectId: string,
|
|
20
|
+
params: CommonParams & { bundle?: SolanaGetAddressParams[] }
|
|
21
|
+
): Response<Array<SolanaAddress>>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SolanaSignedTx as HardwareSolanaSignedTx } from '@onekeyfe/hd-transport/src/types/messages';
|
|
2
|
+
import type { CommonParams, Response } from '../params';
|
|
3
|
+
|
|
4
|
+
export type SolanaSignedTx = {
|
|
5
|
+
path: string;
|
|
6
|
+
} & HardwareSolanaSignedTx;
|
|
7
|
+
|
|
8
|
+
export type SolanaSignTransactionParams = {
|
|
9
|
+
path: string | number[];
|
|
10
|
+
rawTx?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export declare function solSignTransaction(
|
|
14
|
+
connectId: string,
|
|
15
|
+
params: CommonParams & SolanaSignTransactionParams
|
|
16
|
+
): Response<SolanaSignedTx>;
|
|
17
|
+
|
|
18
|
+
export declare function solSignTransaction(
|
|
19
|
+
connectId: string,
|
|
20
|
+
params: CommonParams & { bundle?: SolanaSignTransactionParams[] }
|
|
21
|
+
): Response<Array<SolanaSignedTx>>;
|