@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.
- package/dist/api/cardano/helper/cardanoInputs.d.ts.map +1 -1
- package/dist/api/device/DeviceUploadResource.d.ts.map +1 -1
- package/dist/api/evm/EVMGetAddress.d.ts.map +1 -1
- package/dist/api/evm/EVMGetPublicKey.d.ts.map +1 -1
- package/dist/api/evm/EVMSignMessage.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTypedData.d.ts +1 -0
- package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
- package/dist/api/evm/EVMVerifyMessage.d.ts.map +1 -1
- package/dist/api/filecoin/FilecoinGetAddress.d.ts +17 -0
- package/dist/api/filecoin/FilecoinGetAddress.d.ts.map +1 -0
- package/dist/api/filecoin/FilecoinSignTransaction.d.ts +19 -0
- package/dist/api/filecoin/FilecoinSignTransaction.d.ts.map +1 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -1
- package/dist/index.d.ts +34 -3
- package/dist/index.js +433 -276
- package/dist/inject.d.ts.map +1 -1
- package/dist/types/api/cardano.d.ts.map +1 -1
- package/dist/types/api/evmGetAddress.d.ts +1 -0
- package/dist/types/api/evmGetAddress.d.ts.map +1 -1
- package/dist/types/api/evmGetPublicKey.d.ts +1 -0
- package/dist/types/api/evmGetPublicKey.d.ts.map +1 -1
- package/dist/types/api/evmSignMessage.d.ts +1 -0
- package/dist/types/api/evmSignMessage.d.ts.map +1 -1
- package/dist/types/api/evmSignTypedData.d.ts +1 -0
- package/dist/types/api/evmSignTypedData.d.ts.map +1 -1
- package/dist/types/api/evmVerifyMessage.d.ts +1 -0
- package/dist/types/api/evmVerifyMessage.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +2 -0
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/filecoinGetAddress.d.ts +14 -0
- package/dist/types/api/filecoinGetAddress.d.ts.map +1 -0
- package/dist/types/api/filecoinSignTransaction.d.ts +14 -0
- package/dist/types/api/filecoinSignTransaction.d.ts.map +1 -0
- package/dist/types/api/index.d.ts +4 -0
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/device/DeviceUploadResource.ts +6 -0
- package/src/api/evm/EVMGetAddress.ts +2 -0
- package/src/api/evm/EVMGetPublicKey.ts +2 -0
- package/src/api/evm/EVMSignMessage.ts +3 -1
- package/src/api/evm/EVMSignTypedData.ts +8 -3
- package/src/api/evm/EVMVerifyMessage.ts +2 -0
- package/src/api/filecoin/FilecoinGetAddress.ts +71 -0
- package/src/api/filecoin/FilecoinSignTransaction.ts +54 -0
- package/src/api/helpers/stringUtils.ts +1 -1
- package/src/api/index.ts +3 -0
- package/src/api/stellar/StellarSignTransaction.ts +5 -2
- package/src/api/xrp/XrpGetAddress.ts +1 -1
- package/src/api/xrp/XrpSignTransaction.ts +1 -1
- package/src/data/messages/messages.json +463 -419
- package/src/inject.ts +5 -0
- package/src/types/api/cardano.ts +0 -1
- package/src/types/api/evmGetAddress.ts +1 -0
- package/src/types/api/evmGetPublicKey.ts +1 -0
- package/src/types/api/evmSignMessage.ts +1 -0
- package/src/types/api/evmSignTypedData.ts +1 -0
- package/src/types/api/evmVerifyMessage.ts +1 -0
- package/src/types/api/export.ts +3 -0
- package/src/types/api/filecoinGetAddress.ts +23 -0
- package/src/types/api/filecoinSignTransaction.ts +23 -0
- package/src/types/api/index.ts +9 -0
- package/src/types/api/nearSignTransaction.ts +1 -1
- package/src/types/api/tronGetAddress.ts +2 -2
- 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
|
+
}
|
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(
|
|
163
|
+
throw ERRORS.TypedError(
|
|
164
|
+
HardwareErrorCode.CallMethodInvalidParameter,
|
|
165
|
+
'timebounds is required'
|
|
166
|
+
);
|
|
164
167
|
}
|
|
165
168
|
|
|
166
169
|
// init params
|