@onekeyfe/hd-core 0.3.40 → 0.3.41
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/btc/BTCGetAddress.d.ts +11 -0
- package/dist/api/btc/BTCGetAddress.d.ts.map +1 -1
- package/dist/api/btc/BTCGetPublicKey.d.ts +11 -0
- package/dist/api/btc/BTCGetPublicKey.d.ts.map +1 -1
- package/dist/api/btc/BTCSignMessage.d.ts +11 -0
- package/dist/api/btc/BTCSignMessage.d.ts.map +1 -1
- package/dist/api/btc/BTCSignTransaction.d.ts +11 -0
- package/dist/api/btc/BTCSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCVerifyMessage.d.ts +11 -0
- package/dist/api/btc/BTCVerifyMessage.d.ts.map +1 -1
- package/dist/api/btc/helpers/versionLimit.d.ts +12 -0
- package/dist/api/btc/helpers/versionLimit.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/nervos/NervosGetAddress.d.ts +17 -0
- package/dist/api/nervos/NervosGetAddress.d.ts.map +1 -0
- package/dist/api/nervos/NervosSignTransaction.d.ts +25 -0
- package/dist/api/nervos/NervosSignTransaction.d.ts.map +1 -0
- package/dist/api/sui/SuiSignTransaction.d.ts +6 -3
- package/dist/api/sui/SuiSignTransaction.d.ts.map +1 -1
- package/dist/index.d.ts +29 -3
- package/dist/index.js +194 -125
- package/dist/inject.d.ts.map +1 -1
- package/dist/types/api/deviceUpdateBootloader.d.ts +1 -1
- package/dist/types/api/deviceUpdateBootloader.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/index.d.ts +4 -0
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/nervosGetAddress.d.ts +15 -0
- package/dist/types/api/nervosGetAddress.d.ts.map +1 -0
- package/dist/types/api/nervosSignTransaction.d.ts +13 -0
- package/dist/types/api/nervosSignTransaction.d.ts.map +1 -0
- package/package.json +4 -4
- package/src/api/btc/BTCGetAddress.ts +5 -0
- package/src/api/btc/BTCGetPublicKey.ts +5 -0
- package/src/api/btc/BTCSignMessage.ts +5 -0
- package/src/api/btc/BTCSignTransaction.ts +5 -0
- package/src/api/btc/BTCVerifyMessage.ts +5 -0
- package/src/api/btc/helpers/versionLimit.ts +25 -0
- package/src/api/device/DeviceUploadResource.ts +2 -2
- package/src/api/index.ts +4 -0
- package/src/api/nervos/NervosGetAddress.ts +76 -0
- package/src/api/nervos/NervosSignTransaction.ts +113 -0
- package/src/api/sui/SuiSignTransaction.ts +12 -11
- package/src/data/coins/bitcoin.json +2 -1
- package/src/data/messages/messages.json +3 -113
- package/src/inject.ts +5 -0
- package/src/types/api/deviceUpdateBootloader.ts +1 -1
- package/src/types/api/export.ts +3 -0
- package/src/types/api/index.ts +8 -0
- package/src/types/api/nervosGetAddress.ts +24 -0
- package/src/types/api/nervosSignTransaction.ts +19 -0
- package/src/utils/deviceFeaturesUtils.ts +1 -1
|
@@ -5,6 +5,7 @@ import { BaseMethod } from '../BaseMethod';
|
|
|
5
5
|
import { validateParams } from '../helpers/paramsValidator';
|
|
6
6
|
import { formatAnyHex } from '../helpers/hexUtils';
|
|
7
7
|
import { getCoinAndScriptType } from './helpers/btcParamsUtils';
|
|
8
|
+
import { getBitcoinForkVersionRange } from './helpers/versionLimit';
|
|
8
9
|
|
|
9
10
|
export default class BTCSignMessage extends BaseMethod<SignMessage> {
|
|
10
11
|
init() {
|
|
@@ -33,6 +34,10 @@ export default class BTCSignMessage extends BaseMethod<SignMessage> {
|
|
|
33
34
|
};
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
getVersionRange() {
|
|
38
|
+
return getBitcoinForkVersionRange([this.params.coin_name]);
|
|
39
|
+
}
|
|
40
|
+
|
|
36
41
|
async run() {
|
|
37
42
|
const res = await this.device.commands.typedCall('SignMessage', 'MessageSignature', {
|
|
38
43
|
...this.params,
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
import signtx from './helpers/signtx';
|
|
15
15
|
import signtxLegacy from './helpers/signtxLegacy';
|
|
16
16
|
import { getCoinInfo } from './helpers/btcParamsUtils';
|
|
17
|
+
import { getBitcoinForkVersionRange } from './helpers/versionLimit';
|
|
17
18
|
|
|
18
19
|
type Params = {
|
|
19
20
|
inputs: TxInputType[];
|
|
@@ -120,6 +121,10 @@ export default class BTCSignTransaction extends BaseMethod<Params> {
|
|
|
120
121
|
};
|
|
121
122
|
}
|
|
122
123
|
|
|
124
|
+
getVersionRange() {
|
|
125
|
+
return getBitcoinForkVersionRange([this.params.coinName]);
|
|
126
|
+
}
|
|
127
|
+
|
|
123
128
|
async run() {
|
|
124
129
|
const { device, params } = this;
|
|
125
130
|
|
|
@@ -5,6 +5,7 @@ import { BaseMethod } from '../BaseMethod';
|
|
|
5
5
|
import { validateParams } from '../helpers/paramsValidator';
|
|
6
6
|
import { formatAnyHex } from '../helpers/hexUtils';
|
|
7
7
|
import { getCoinInfo } from './helpers/btcParamsUtils';
|
|
8
|
+
import { getBitcoinForkVersionRange } from './helpers/versionLimit';
|
|
8
9
|
|
|
9
10
|
export default class BTCVerifyMessage extends BaseMethod<VerifyMessage> {
|
|
10
11
|
init() {
|
|
@@ -31,6 +32,10 @@ export default class BTCVerifyMessage extends BaseMethod<VerifyMessage> {
|
|
|
31
32
|
};
|
|
32
33
|
}
|
|
33
34
|
|
|
35
|
+
getVersionRange() {
|
|
36
|
+
return getBitcoinForkVersionRange([this.params.coin_name]);
|
|
37
|
+
}
|
|
38
|
+
|
|
34
39
|
async run() {
|
|
35
40
|
const res = await this.device.commands.typedCall('VerifyMessage', 'Success', {
|
|
36
41
|
...this.params,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
function isCoinNameInList(coinName: string, coinNames: (string | undefined)[]) {
|
|
2
|
+
for (let i = 0; i < coinNames.length; i++) {
|
|
3
|
+
const coin_name = coinNames[i];
|
|
4
|
+
if (coin_name?.toLowerCase() === coinName?.toLowerCase()) {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function getBitcoinForkVersionRange(params: (string | undefined)[]) {
|
|
12
|
+
if (isCoinNameInList('Neurai', params)) {
|
|
13
|
+
return {
|
|
14
|
+
model_mini: {
|
|
15
|
+
min: '3.7.0',
|
|
16
|
+
},
|
|
17
|
+
model_touch: {
|
|
18
|
+
min: '4.9.0',
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// No version restrictions for other coins
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
@@ -4,7 +4,7 @@ import { bytesToHex } from '@noble/hashes/utils';
|
|
|
4
4
|
import { ResourceUpload, Success } from '@onekeyfe/hd-transport';
|
|
5
5
|
import { blake2s } from '@noble/hashes/blake2s';
|
|
6
6
|
import { TypedResponseMessage } from '../../device/DeviceCommands';
|
|
7
|
-
import { DeviceUploadResourceParams } from '../../types';
|
|
7
|
+
import { DeviceModelToTypes, DeviceUploadResourceParams } from '../../types';
|
|
8
8
|
import { BaseMethod } from '../BaseMethod';
|
|
9
9
|
import { validateParams } from '../helpers/paramsValidator';
|
|
10
10
|
import { hexToBytes } from '../helpers/hexUtils';
|
|
@@ -30,7 +30,7 @@ export default class DeviceUploadResource extends BaseMethod<ResourceUpload> {
|
|
|
30
30
|
checkUploadNFTSupport() {
|
|
31
31
|
const deviceType = getDeviceType(this.device.features);
|
|
32
32
|
const currentVersion = getDeviceFirmwareVersion(this.device.features).join('.');
|
|
33
|
-
if (deviceType
|
|
33
|
+
if (!DeviceModelToTypes.model_touch.includes(deviceType)) {
|
|
34
34
|
throw ERRORS.TypedError(HardwareErrorCode.CallMethodError, 'Device Not Support Upload NFT');
|
|
35
35
|
}
|
|
36
36
|
|
package/src/api/index.ts
CHANGED
|
@@ -113,4 +113,8 @@ export { default as nostrSignEvent } from './nostr/NostrSignEvent';
|
|
|
113
113
|
export { default as nostrEncryptMessage } from './nostr/NostrEncryptMessage';
|
|
114
114
|
export { default as nostrDecryptMessage } from './nostr/NostrDecryptMessage';
|
|
115
115
|
export { default as nostrSignSchnorr } from './nostr/NostrSignSchnorr';
|
|
116
|
+
|
|
116
117
|
export { default as lnurlAuth } from './lightning/LnurlAuth';
|
|
118
|
+
|
|
119
|
+
export { default as nervosGetAddress } from './nervos/NervosGetAddress';
|
|
120
|
+
export { default as nervosSignTransaction } from './nervos/NervosSignTransaction';
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { NervosGetAddress as HardwareNervosGetAddress } 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
|
+
|
|
7
|
+
import type { NervosGetAddressParams, NervosAddress } from '../../types';
|
|
8
|
+
|
|
9
|
+
export default class NervosGetAddress extends BaseMethod<HardwareNervosGetAddress[]> {
|
|
10
|
+
hasBundle = false;
|
|
11
|
+
|
|
12
|
+
init() {
|
|
13
|
+
this.checkDeviceId = true;
|
|
14
|
+
this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
|
|
15
|
+
|
|
16
|
+
this.hasBundle = !!this.payload?.bundle;
|
|
17
|
+
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
18
|
+
|
|
19
|
+
// check payload
|
|
20
|
+
validateParams(payload, [{ name: 'bundle', type: 'array' }]);
|
|
21
|
+
|
|
22
|
+
// init params
|
|
23
|
+
this.params = [];
|
|
24
|
+
payload.bundle.forEach((batch: NervosGetAddressParams) => {
|
|
25
|
+
const addressN = validatePath(batch.path, 3);
|
|
26
|
+
|
|
27
|
+
validateParams(batch, [
|
|
28
|
+
{ name: 'path', required: true },
|
|
29
|
+
{ name: 'showOnOneKey', type: 'boolean' },
|
|
30
|
+
{ name: 'network', type: 'string' },
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
const showOnOneKey = batch.showOnOneKey ?? true;
|
|
34
|
+
|
|
35
|
+
this.params.push({
|
|
36
|
+
address_n: addressN,
|
|
37
|
+
show_display: showOnOneKey,
|
|
38
|
+
network: batch.network,
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
getVersionRange() {
|
|
44
|
+
return {
|
|
45
|
+
model_mini: {
|
|
46
|
+
min: '3.7.0',
|
|
47
|
+
},
|
|
48
|
+
model_touch: {
|
|
49
|
+
min: '4.9.0',
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async run() {
|
|
55
|
+
const responses: NervosAddress[] = [];
|
|
56
|
+
|
|
57
|
+
for (let i = 0; i < this.params.length; i++) {
|
|
58
|
+
const param = this.params[i];
|
|
59
|
+
|
|
60
|
+
const res = await this.device.commands.typedCall('NervosGetAddress', 'NervosAddress', {
|
|
61
|
+
...param,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const { address } = res.message;
|
|
65
|
+
|
|
66
|
+
const result = {
|
|
67
|
+
path: serializedPath(param.address_n),
|
|
68
|
+
address,
|
|
69
|
+
};
|
|
70
|
+
responses.push(result);
|
|
71
|
+
this.postPreviousAddressMessage(result);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return Promise.resolve(this.hasBundle ? responses : responses[0]);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { NervosSignTx as HardwareNervosSignTx, TypedCall } from '@onekeyfe/hd-transport';
|
|
2
|
+
import { serializedPath, validatePath } from '../helpers/pathUtils';
|
|
3
|
+
import { BaseMethod } from '../BaseMethod';
|
|
4
|
+
import { validateParams } from '../helpers/paramsValidator';
|
|
5
|
+
import type { NervosSignTransactionParams, NervosSignedTx } from '../../types';
|
|
6
|
+
import { formatAnyHex } from '../helpers/hexUtils';
|
|
7
|
+
import type { TypedResponseMessage } from '../../device/DeviceCommands';
|
|
8
|
+
|
|
9
|
+
type NervosSignTx = Omit<HardwareNervosSignTx, 'data_initial_chunk' | 'data_length'> & {
|
|
10
|
+
raw_tx: Buffer;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default class NervosSignTransaction extends BaseMethod<NervosSignTx> {
|
|
14
|
+
hasBundle = false;
|
|
15
|
+
|
|
16
|
+
init() {
|
|
17
|
+
this.checkDeviceId = true;
|
|
18
|
+
this.notAllowDeviceMode = [...this.notAllowDeviceMode];
|
|
19
|
+
|
|
20
|
+
// check payload
|
|
21
|
+
validateParams(this.payload, [
|
|
22
|
+
{ name: 'path', required: true },
|
|
23
|
+
{ name: 'rawTx', type: 'hexString', required: true },
|
|
24
|
+
{ name: 'witnessHex', type: 'hexString', required: true },
|
|
25
|
+
{ name: 'network', type: 'string', required: true },
|
|
26
|
+
]);
|
|
27
|
+
|
|
28
|
+
// init params
|
|
29
|
+
const { path, rawTx, witnessHex, network } = this.payload as NervosSignTransactionParams;
|
|
30
|
+
const addressN = validatePath(path, 3);
|
|
31
|
+
|
|
32
|
+
this.params = {
|
|
33
|
+
address_n: addressN,
|
|
34
|
+
raw_tx: Buffer.from(formatAnyHex(rawTx), 'hex'),
|
|
35
|
+
witness_buffer: formatAnyHex(witnessHex),
|
|
36
|
+
network,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
getVersionRange() {
|
|
41
|
+
return {
|
|
42
|
+
model_mini: {
|
|
43
|
+
min: '3.7.0',
|
|
44
|
+
},
|
|
45
|
+
model_touch: {
|
|
46
|
+
min: '4.9.0',
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
chunkByteSize = 1024;
|
|
52
|
+
|
|
53
|
+
processTxRequest = async (
|
|
54
|
+
typedCall: TypedCall,
|
|
55
|
+
res: TypedResponseMessage<'NervosSignedTx'> | TypedResponseMessage<'NervosTxRequest'>,
|
|
56
|
+
data: Buffer,
|
|
57
|
+
offset = 0
|
|
58
|
+
): Promise<NervosSignedTx> => {
|
|
59
|
+
if (res.type === 'NervosSignedTx') {
|
|
60
|
+
if (!res?.message?.signature) {
|
|
61
|
+
throw new Error('No signature returned');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
...res.message,
|
|
66
|
+
path: serializedPath(this.params.address_n),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const { data_length } = res.message;
|
|
71
|
+
|
|
72
|
+
if (!data_length) {
|
|
73
|
+
if (!res?.message?.signature) {
|
|
74
|
+
throw new Error('No signature returned');
|
|
75
|
+
}
|
|
76
|
+
// sign Done
|
|
77
|
+
return {
|
|
78
|
+
...res.message,
|
|
79
|
+
path: serializedPath(this.params.address_n),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const payload = data.subarray(offset, offset + data_length);
|
|
84
|
+
const newOffset = offset + payload.length;
|
|
85
|
+
const resourceAckParams = {
|
|
86
|
+
data_chunk: payload.toString('hex'),
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const response = await typedCall('NervosTxAck', ['NervosSignedTx', 'NervosTxRequest'], {
|
|
90
|
+
...resourceAckParams,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
return this.processTxRequest(typedCall, response, data, newOffset);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
async run() {
|
|
97
|
+
const dataLength = this.params.raw_tx.length;
|
|
98
|
+
const offset = dataLength;
|
|
99
|
+
const data = this.params.raw_tx;
|
|
100
|
+
|
|
101
|
+
const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
|
|
102
|
+
|
|
103
|
+
const res = await typedCall('NervosSignTx', 'NervosSignedTx', {
|
|
104
|
+
address_n: this.params.address_n,
|
|
105
|
+
data_initial_chunk: data.subarray(0, offset).toString('hex'),
|
|
106
|
+
data_length: dataLength,
|
|
107
|
+
witness_buffer: this.params.witness_buffer,
|
|
108
|
+
network: this.params.network,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
return this.processTxRequest(typedCall, res, data, offset);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -9,7 +9,9 @@ import { getDeviceFirmwareVersion, getDeviceType } from '../../utils/deviceFeatu
|
|
|
9
9
|
import { DeviceModelToTypes } from '../../types';
|
|
10
10
|
import type { TypedResponseMessage } from '../../device/DeviceCommands';
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
type SuiSignTx = Omit<HardwareSuiSignTx, 'data_initial_chunk' | 'data_length'> & HardwareSuiSignTx;
|
|
13
|
+
|
|
14
|
+
export default class SuiSignTransaction extends BaseMethod<SuiSignTx> {
|
|
13
15
|
init() {
|
|
14
16
|
this.checkDeviceId = true;
|
|
15
17
|
this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
|
|
@@ -59,12 +61,12 @@ export default class SuiSignTransaction extends BaseMethod<HardwareSuiSignTx> {
|
|
|
59
61
|
return false;
|
|
60
62
|
}
|
|
61
63
|
|
|
62
|
-
|
|
64
|
+
chunkByteSize = 1024;
|
|
63
65
|
|
|
64
66
|
processTxRequest = async (
|
|
65
67
|
typedCall: TypedCall,
|
|
66
68
|
res: TypedResponseMessage<'SuiSignedTx'> | TypedResponseMessage<'SuiTxRequest'>,
|
|
67
|
-
data:
|
|
69
|
+
data: Buffer,
|
|
68
70
|
offset = 0
|
|
69
71
|
): Promise<SuiSignedTx> => {
|
|
70
72
|
if (res.type === 'SuiSignedTx') {
|
|
@@ -78,10 +80,10 @@ export default class SuiSignTransaction extends BaseMethod<HardwareSuiSignTx> {
|
|
|
78
80
|
return res.message;
|
|
79
81
|
}
|
|
80
82
|
|
|
81
|
-
const payload = data.
|
|
83
|
+
const payload = data.subarray(offset, offset + data_length);
|
|
82
84
|
const newOffset = offset + payload.length;
|
|
83
85
|
const resourceAckParams = {
|
|
84
|
-
data_chunk: payload,
|
|
86
|
+
data_chunk: payload.toString('hex'),
|
|
85
87
|
};
|
|
86
88
|
|
|
87
89
|
const response = await typedCall('SuiTxAck', ['SuiSignedTx', 'SuiTxRequest'], {
|
|
@@ -93,18 +95,17 @@ export default class SuiSignTransaction extends BaseMethod<HardwareSuiSignTx> {
|
|
|
93
95
|
|
|
94
96
|
async run() {
|
|
95
97
|
const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
|
|
96
|
-
const dataLength = this.params.raw_tx.length / 2;
|
|
97
98
|
let offset = 0;
|
|
98
|
-
let data
|
|
99
|
+
let data: Buffer;
|
|
99
100
|
|
|
100
101
|
if (this.supportChunkTransfer()) {
|
|
101
|
-
offset = this.
|
|
102
|
-
data = this.params.raw_tx;
|
|
102
|
+
offset = this.chunkByteSize;
|
|
103
|
+
data = Buffer.from(this.params.raw_tx, 'hex');
|
|
103
104
|
this.params = {
|
|
104
105
|
address_n: this.params.address_n,
|
|
105
106
|
raw_tx: '',
|
|
106
|
-
data_initial_chunk:
|
|
107
|
-
data_length:
|
|
107
|
+
data_initial_chunk: data.subarray(0, this.chunkByteSize).toString('hex'),
|
|
108
|
+
data_length: data.length,
|
|
108
109
|
};
|
|
109
110
|
}
|
|
110
111
|
|
|
@@ -39,5 +39,6 @@
|
|
|
39
39
|
{ "name": "Viacoin", "label": "VIA", "slip44": 14 },
|
|
40
40
|
{ "name": "ZCore", "label": "ZCR", "slip44": 428 },
|
|
41
41
|
{ "name": "Zcash", "label": "ZEC", "slip44": 133 },
|
|
42
|
-
{ "name": "Zcash Testnet", "label": "TAZ", "slip44": 1 }
|
|
42
|
+
{ "name": "Zcash Testnet", "label": "TAZ", "slip44": 1 },
|
|
43
|
+
{ "name": "Neurai", "label": "XNA", "slip44": 1900 }
|
|
43
44
|
]
|
|
@@ -5686,15 +5686,15 @@
|
|
|
5686
5686
|
"type": "bytes",
|
|
5687
5687
|
"id": 605
|
|
5688
5688
|
},
|
|
5689
|
-
"
|
|
5689
|
+
"onekey_se_version": {
|
|
5690
5690
|
"type": "string",
|
|
5691
5691
|
"id": 606
|
|
5692
5692
|
},
|
|
5693
|
-
"
|
|
5693
|
+
"onekey_se_hash": {
|
|
5694
5694
|
"type": "bytes",
|
|
5695
5695
|
"id": 607
|
|
5696
5696
|
},
|
|
5697
|
-
"
|
|
5697
|
+
"onekey_se_build_id": {
|
|
5698
5698
|
"type": "string",
|
|
5699
5699
|
"id": 608
|
|
5700
5700
|
},
|
|
@@ -5733,110 +5733,6 @@
|
|
|
5733
5733
|
"onekey_ble_hash": {
|
|
5734
5734
|
"type": "bytes",
|
|
5735
5735
|
"id": 617
|
|
5736
|
-
},
|
|
5737
|
-
"onekey_board_build_id": {
|
|
5738
|
-
"type": "string",
|
|
5739
|
-
"id": 618
|
|
5740
|
-
},
|
|
5741
|
-
"onekey_se01_boot_version": {
|
|
5742
|
-
"type": "string",
|
|
5743
|
-
"id": 619
|
|
5744
|
-
},
|
|
5745
|
-
"onekey_se01_boot_hash": {
|
|
5746
|
-
"type": "bytes",
|
|
5747
|
-
"id": 620
|
|
5748
|
-
},
|
|
5749
|
-
"onekey_se01_boot_build_id": {
|
|
5750
|
-
"type": "string",
|
|
5751
|
-
"id": 621
|
|
5752
|
-
},
|
|
5753
|
-
"onekey_se02_version": {
|
|
5754
|
-
"type": "string",
|
|
5755
|
-
"id": 622
|
|
5756
|
-
},
|
|
5757
|
-
"onekey_se02_hash": {
|
|
5758
|
-
"type": "bytes",
|
|
5759
|
-
"id": 623
|
|
5760
|
-
},
|
|
5761
|
-
"onekey_se02_build_id": {
|
|
5762
|
-
"type": "string",
|
|
5763
|
-
"id": 624
|
|
5764
|
-
},
|
|
5765
|
-
"onekey_se02_boot_version": {
|
|
5766
|
-
"type": "string",
|
|
5767
|
-
"id": 625
|
|
5768
|
-
},
|
|
5769
|
-
"onekey_se02_boot_hash": {
|
|
5770
|
-
"type": "bytes",
|
|
5771
|
-
"id": 626
|
|
5772
|
-
},
|
|
5773
|
-
"onekey_se02_boot_build_id": {
|
|
5774
|
-
"type": "string",
|
|
5775
|
-
"id": 627
|
|
5776
|
-
},
|
|
5777
|
-
"onekey_se03_version": {
|
|
5778
|
-
"type": "string",
|
|
5779
|
-
"id": 628
|
|
5780
|
-
},
|
|
5781
|
-
"onekey_se03_hash": {
|
|
5782
|
-
"type": "bytes",
|
|
5783
|
-
"id": 629
|
|
5784
|
-
},
|
|
5785
|
-
"onekey_se03_build_id": {
|
|
5786
|
-
"type": "string",
|
|
5787
|
-
"id": 630
|
|
5788
|
-
},
|
|
5789
|
-
"onekey_se03_boot_version": {
|
|
5790
|
-
"type": "string",
|
|
5791
|
-
"id": 631
|
|
5792
|
-
},
|
|
5793
|
-
"onekey_se03_boot_hash": {
|
|
5794
|
-
"type": "bytes",
|
|
5795
|
-
"id": 632
|
|
5796
|
-
},
|
|
5797
|
-
"onekey_se03_boot_build_id": {
|
|
5798
|
-
"type": "string",
|
|
5799
|
-
"id": 633
|
|
5800
|
-
},
|
|
5801
|
-
"onekey_se04_version": {
|
|
5802
|
-
"type": "string",
|
|
5803
|
-
"id": 634
|
|
5804
|
-
},
|
|
5805
|
-
"onekey_se04_hash": {
|
|
5806
|
-
"type": "bytes",
|
|
5807
|
-
"id": 635
|
|
5808
|
-
},
|
|
5809
|
-
"onekey_se04_build_id": {
|
|
5810
|
-
"type": "string",
|
|
5811
|
-
"id": 636
|
|
5812
|
-
},
|
|
5813
|
-
"onekey_se04_boot_version": {
|
|
5814
|
-
"type": "string",
|
|
5815
|
-
"id": 637
|
|
5816
|
-
},
|
|
5817
|
-
"onekey_se04_boot_hash": {
|
|
5818
|
-
"type": "bytes",
|
|
5819
|
-
"id": 638
|
|
5820
|
-
},
|
|
5821
|
-
"onekey_se04_boot_build_id": {
|
|
5822
|
-
"type": "string",
|
|
5823
|
-
"id": 639
|
|
5824
|
-
},
|
|
5825
|
-
"onekey_se01_state": {
|
|
5826
|
-
"type": "OneKeySEState",
|
|
5827
|
-
"id": 640
|
|
5828
|
-
},
|
|
5829
|
-
"onekey_se02_state": {
|
|
5830
|
-
"type": "OneKeySEState",
|
|
5831
|
-
"id": 641
|
|
5832
|
-
},
|
|
5833
|
-
"onekey_se03_state": {
|
|
5834
|
-
"type": "OneKeySEState",
|
|
5835
|
-
"id": 642
|
|
5836
|
-
},
|
|
5837
|
-
"onekey_se04_state": {
|
|
5838
|
-
"type": "OneKeySEState",
|
|
5839
|
-
"id": 643
|
|
5840
5736
|
}
|
|
5841
5737
|
},
|
|
5842
5738
|
"nested": {
|
|
@@ -5878,12 +5774,6 @@
|
|
|
5878
5774
|
"THD89": 0,
|
|
5879
5775
|
"SE608A": 1
|
|
5880
5776
|
}
|
|
5881
|
-
},
|
|
5882
|
-
"OneKeySEState": {
|
|
5883
|
-
"values": {
|
|
5884
|
-
"BOOT": 0,
|
|
5885
|
-
"APP": 1
|
|
5886
|
-
}
|
|
5887
5777
|
}
|
|
5888
5778
|
}
|
|
5889
5779
|
},
|
package/src/inject.ts
CHANGED
|
@@ -282,4 +282,9 @@ export const createCoreApi = (
|
|
|
282
282
|
call({ ...params, connectId, deviceId, method: 'nostrSignSchnorr' }),
|
|
283
283
|
lnurlAuth: (connectId, deviceId, params) =>
|
|
284
284
|
call({ ...params, connectId, deviceId, method: 'lnurlAuth' }),
|
|
285
|
+
|
|
286
|
+
nervosGetAddress: (connectId, deviceId, params) =>
|
|
287
|
+
call({ ...params, connectId, deviceId, method: 'nervosGetAddress' }),
|
|
288
|
+
nervosSignTransaction: (connectId, deviceId, params) =>
|
|
289
|
+
call({ ...params, connectId, deviceId, method: 'nervosSignTransaction' }),
|
|
285
290
|
});
|
package/src/types/api/export.ts
CHANGED
|
@@ -146,3 +146,6 @@ export type {
|
|
|
146
146
|
NexaSignInputParams,
|
|
147
147
|
NexaSignOutputParams,
|
|
148
148
|
} from './nexaSignTransaction';
|
|
149
|
+
|
|
150
|
+
export type { NervosAddress, NervosGetAddressParams } from './nervosGetAddress';
|
|
151
|
+
export type { NervosSignedTx, NervosSignTransactionParams } from './nervosSignTransaction';
|
package/src/types/api/index.ts
CHANGED
|
@@ -119,6 +119,8 @@ import { nostrDecryptMessage } from './nostrDecryptMessage';
|
|
|
119
119
|
import { nostrSignSchnorr } from './nostrSignSchnorr';
|
|
120
120
|
|
|
121
121
|
import { lnurlAuth } from './lnurlAuth';
|
|
122
|
+
import { nervosGetAddress } from './nervosGetAddress';
|
|
123
|
+
import { nervosSignTransaction } from './nervosSignTransaction';
|
|
122
124
|
|
|
123
125
|
export * from './export';
|
|
124
126
|
|
|
@@ -323,4 +325,10 @@ export type CoreApi = {
|
|
|
323
325
|
* Lightning Network
|
|
324
326
|
*/
|
|
325
327
|
lnurlAuth: typeof lnurlAuth;
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Nervos Network
|
|
331
|
+
*/
|
|
332
|
+
nervosGetAddress: typeof nervosGetAddress;
|
|
333
|
+
nervosSignTransaction: typeof nervosSignTransaction;
|
|
326
334
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { NervosAddress as HardwareNervosAddress } from '@onekeyfe/hd-transport';
|
|
2
|
+
import type { CommonParams, Response } from '../params';
|
|
3
|
+
|
|
4
|
+
export type NervosAddress = {
|
|
5
|
+
path: string;
|
|
6
|
+
} & HardwareNervosAddress;
|
|
7
|
+
|
|
8
|
+
export type NervosGetAddressParams = {
|
|
9
|
+
path: string | number[];
|
|
10
|
+
network: string;
|
|
11
|
+
showOnOneKey?: boolean;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export declare function nervosGetAddress(
|
|
15
|
+
connectId: string,
|
|
16
|
+
deviceId: string,
|
|
17
|
+
params: CommonParams & NervosGetAddressParams
|
|
18
|
+
): Response<NervosAddress>;
|
|
19
|
+
|
|
20
|
+
export declare function nervosGetAddress(
|
|
21
|
+
connectId: string,
|
|
22
|
+
deviceId: string,
|
|
23
|
+
params: CommonParams & { bundle?: NervosGetAddressParams[] }
|
|
24
|
+
): Response<Array<NervosAddress>>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { NervosSignedTx as HardwareNervosSignedTx } from '@onekeyfe/hd-transport';
|
|
2
|
+
import type { CommonParams, Response } from '../params';
|
|
3
|
+
|
|
4
|
+
export type NervosSignedTx = {
|
|
5
|
+
path: string;
|
|
6
|
+
} & HardwareNervosSignedTx;
|
|
7
|
+
|
|
8
|
+
export type NervosSignTransactionParams = {
|
|
9
|
+
path: string | number[];
|
|
10
|
+
network: string;
|
|
11
|
+
rawTx: string;
|
|
12
|
+
witnessHex: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export declare function nervosSignTransaction(
|
|
16
|
+
connectId: string,
|
|
17
|
+
deviceId: string,
|
|
18
|
+
params: CommonParams & NervosSignTransactionParams
|
|
19
|
+
): Response<NervosSignedTx>;
|
|
@@ -86,7 +86,7 @@ export const getDeviceTypeByDeviceId = (deviceId?: string): IDeviceType => {
|
|
|
86
86
|
export const getDeviceUUID = (features: Features) => {
|
|
87
87
|
const deviceType = getDeviceType(features);
|
|
88
88
|
|
|
89
|
-
if (features
|
|
89
|
+
if (features?.onekey_serial_no) return features.onekey_serial_no;
|
|
90
90
|
|
|
91
91
|
if (deviceType === 'classic') {
|
|
92
92
|
return features.onekey_serial ?? '';
|