@onekeyfe/hd-core 0.1.57 → 0.1.59
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/FirmwareUpdateV2.d.ts +2 -1
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/algo/AlgoGetAddress.d.ts +14 -0
- package/dist/api/algo/AlgoGetAddress.d.ts.map +1 -0
- package/dist/api/algo/AlgoSignTransaction.d.ts +16 -0
- package/dist/api/algo/AlgoSignTransaction.d.ts.map +1 -0
- package/dist/api/aptos/AptosSignMessage.d.ts +13 -0
- package/dist/api/aptos/AptosSignMessage.d.ts.map +1 -0
- package/dist/api/cosmos/CosmosGetAddress.d.ts +14 -0
- package/dist/api/cosmos/CosmosGetAddress.d.ts.map +1 -0
- package/dist/api/cosmos/CosmosSignTransaction.d.ts +16 -0
- package/dist/api/cosmos/CosmosSignTransaction.d.ts.map +1 -0
- package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
- package/dist/api/index.d.ts +5 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +1 -1
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/index.d.ts +69 -4
- package/dist/index.js +476 -26
- package/dist/inject.d.ts.map +1 -1
- package/dist/types/api/algoGetAddress.d.ts +14 -0
- package/dist/types/api/algoGetAddress.d.ts.map +1 -0
- package/dist/types/api/algoSignTransaction.d.ts +11 -0
- package/dist/types/api/algoSignTransaction.d.ts.map +1 -0
- package/dist/types/api/aptosSignMessage.d.ts +20 -0
- package/dist/types/api/aptosSignMessage.d.ts.map +1 -0
- package/dist/types/api/cosmosGetAddress.d.ts +14 -0
- package/dist/types/api/cosmosGetAddress.d.ts.map +1 -0
- package/dist/types/api/cosmosSignTransaction.d.ts +11 -0
- package/dist/types/api/cosmosSignTransaction.d.ts.map +1 -0
- package/dist/types/api/export.d.ts +5 -0
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +1 -0
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +10 -0
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.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/FirmwareUpdateV2.ts +43 -20
- package/src/api/algo/AlgoGetAddress.ts +68 -0
- package/src/api/algo/AlgoSignTransaction.ts +51 -0
- package/src/api/aptos/AptosSignMessage.ts +78 -0
- package/src/api/cosmos/CosmosGetAddress.ts +68 -0
- package/src/api/cosmos/CosmosSignTransaction.ts +51 -0
- package/src/api/firmware/uploadFirmware.ts +1 -5
- package/src/api/index.ts +7 -0
- package/src/core/index.ts +5 -0
- package/src/data/messages/messages.json +173 -0
- package/src/data-manager/DataManager.ts +5 -3
- package/src/device/DeviceCommands.ts +10 -1
- package/src/inject.ts +12 -0
- package/src/types/api/algoGetAddress.ts +23 -0
- package/src/types/api/algoSignTransaction.ts +17 -0
- package/src/types/api/aptosSignMessage.ts +26 -0
- package/src/types/api/aptosSignTransaction.ts +1 -1
- package/src/types/api/cosmosGetAddress.ts +23 -0
- package/src/types/api/cosmosSignTransaction.ts +17 -0
- package/src/types/api/export.ts +7 -0
- package/src/types/api/firmwareUpdate.ts +1 -0
- package/src/types/api/index.ts +20 -0
- package/src/utils/deviceFeaturesUtils.ts +5 -7
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { AptosSignMessage as HardwareAptosSignMessage } 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 { AptosMessageSignature, AptosSignMessageParams } from '../../types';
|
|
7
|
+
|
|
8
|
+
export default class AptosSignMessage extends BaseMethod<HardwareAptosSignMessage> {
|
|
9
|
+
init() {
|
|
10
|
+
this.checkDeviceId = true;
|
|
11
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
|
|
12
|
+
|
|
13
|
+
// check payload
|
|
14
|
+
validateParams(this.payload, [
|
|
15
|
+
{ name: 'path', required: true },
|
|
16
|
+
{ name: 'payload', type: 'object', required: true },
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
const { path, payload } = this.payload as AptosSignMessageParams;
|
|
20
|
+
const addressN = validatePath(path, 3);
|
|
21
|
+
|
|
22
|
+
validateParams(payload, [
|
|
23
|
+
{ name: 'address', type: 'string' },
|
|
24
|
+
{ name: 'chainId', type: 'string' },
|
|
25
|
+
{ name: 'application', type: 'string' },
|
|
26
|
+
{ name: 'nonce', type: 'string', required: true },
|
|
27
|
+
{ name: 'message', type: 'string', required: true },
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
// init params
|
|
31
|
+
this.params = {
|
|
32
|
+
address_n: addressN,
|
|
33
|
+
payload: {
|
|
34
|
+
address: payload.address,
|
|
35
|
+
chain_id: payload.chainId,
|
|
36
|
+
application: payload.application,
|
|
37
|
+
nonce: payload.nonce,
|
|
38
|
+
message: payload.message,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
getVersionRange() {
|
|
44
|
+
return {
|
|
45
|
+
model_mini: {
|
|
46
|
+
min: '2.6.0',
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async run() {
|
|
52
|
+
let fullMessage = 'APTOS\n';
|
|
53
|
+
if (this.params.payload.address) {
|
|
54
|
+
fullMessage += `address: ${this.params.payload.address}\n`;
|
|
55
|
+
}
|
|
56
|
+
if (this.params.payload.application) {
|
|
57
|
+
fullMessage += `application: ${this.params.payload.application}\n`;
|
|
58
|
+
}
|
|
59
|
+
if (this.params.payload.chain_id) {
|
|
60
|
+
fullMessage += `chainId: ${this.params.payload.chain_id}\n`;
|
|
61
|
+
}
|
|
62
|
+
fullMessage += `message: ${this.params.payload.message}\n`;
|
|
63
|
+
fullMessage += `nonce: ${this.params.payload.nonce}`;
|
|
64
|
+
|
|
65
|
+
const res = await this.device.commands.typedCall('AptosSignMessage', 'AptosMessageSignature', {
|
|
66
|
+
...this.params,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const { address, signature } = res.message;
|
|
70
|
+
|
|
71
|
+
return Promise.resolve<AptosMessageSignature>({
|
|
72
|
+
path: serializedPath(this.params.address_n),
|
|
73
|
+
address,
|
|
74
|
+
signature,
|
|
75
|
+
fullMessage,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { CosmosGetAddress as HardwareCosmosGetAddress } from '@onekeyfe/hd-transport';
|
|
2
|
+
|
|
3
|
+
import { serializedPath, validatePath } from '../helpers/pathUtils';
|
|
4
|
+
import { BaseMethod } from '../BaseMethod';
|
|
5
|
+
import { validateParams } from '../helpers/paramsValidator';
|
|
6
|
+
import { CosmosAddress, CosmosGetAddressParams } from '../../types';
|
|
7
|
+
|
|
8
|
+
export default class CosmosGetAddress extends BaseMethod<HardwareCosmosGetAddress[]> {
|
|
9
|
+
hasBundle = false;
|
|
10
|
+
|
|
11
|
+
init() {
|
|
12
|
+
this.checkDeviceId = true;
|
|
13
|
+
this.allowDeviceMode = [...this.allowDeviceMode];
|
|
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: CosmosGetAddressParams) => {
|
|
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.6.0',
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async run() {
|
|
49
|
+
// TODO: add batch support
|
|
50
|
+
const responses: CosmosAddress[] = [];
|
|
51
|
+
for (let i = 0; i < this.params.length; i++) {
|
|
52
|
+
const param = this.params[i];
|
|
53
|
+
|
|
54
|
+
const res = await this.device.commands.typedCall('CosmosGetAddress', 'CosmosAddress', {
|
|
55
|
+
...param,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const { address } = res.message;
|
|
59
|
+
|
|
60
|
+
responses.push({
|
|
61
|
+
path: serializedPath(param.address_n),
|
|
62
|
+
address,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return Promise.resolve(this.hasBundle ? responses : responses[0]);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { CosmosSignTx as HardwareCosmosSignTx } from '@onekeyfe/hd-transport';
|
|
2
|
+
import { serializedPath, validatePath } from '../helpers/pathUtils';
|
|
3
|
+
import { BaseMethod } from '../BaseMethod';
|
|
4
|
+
import { validateParams } from '../helpers/paramsValidator';
|
|
5
|
+
import { CosmosSignTransactionParams } from '../../types';
|
|
6
|
+
import { formatAnyHex } from '../helpers/hexUtils';
|
|
7
|
+
|
|
8
|
+
export default class CosmosSignTransaction extends BaseMethod<HardwareCosmosSignTx> {
|
|
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 CosmosSignTransactionParams;
|
|
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.6.0',
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async run() {
|
|
40
|
+
const res = await this.device.commands.typedCall('CosmosSignTx', 'CosmosSignedTx', {
|
|
41
|
+
...this.params,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const { signature } = res.message;
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
path: serializedPath(this.params.address_n),
|
|
48
|
+
signature,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -174,11 +174,7 @@ export const updateResources = async (
|
|
|
174
174
|
const name = fileName.split('/').pop();
|
|
175
175
|
if (!file.dir && fileName.indexOf('__MACOSX') === -1 && name) {
|
|
176
176
|
const data = await file.async('arraybuffer');
|
|
177
|
-
|
|
178
|
-
await updateResource(typedCall, name, data);
|
|
179
|
-
} catch (error) {
|
|
180
|
-
Log.error(error);
|
|
181
|
-
}
|
|
177
|
+
await updateResource(typedCall, name, data);
|
|
182
178
|
}
|
|
183
179
|
|
|
184
180
|
progress += stepProgress;
|
package/src/api/index.ts
CHANGED
|
@@ -68,3 +68,10 @@ export { default as nearSignTransaction } from './near/NearSignTransaction';
|
|
|
68
68
|
export { default as aptosGetAddress } from './aptos/AptosGetAddress';
|
|
69
69
|
export { default as aptosGetPublicKey } from './aptos/AptosGetPublicKey';
|
|
70
70
|
export { default as aptosSignTransaction } from './aptos/AptosSignTransaction';
|
|
71
|
+
export { default as aptosSignMessage } from './aptos/AptosSignMessage';
|
|
72
|
+
|
|
73
|
+
export { default as algoGetAddress } from './algo/AlgoGetAddress';
|
|
74
|
+
export { default as algoSignTransaction } from './algo/AlgoSignTransaction';
|
|
75
|
+
|
|
76
|
+
export { default as cosmosGetAddress } from './cosmos/CosmosGetAddress';
|
|
77
|
+
export { default as cosmosSignTransaction } from './cosmos/CosmosSignTransaction';
|
package/src/core/index.ts
CHANGED
|
@@ -150,6 +150,11 @@ export const callAPI = async (message: CoreMessage) => {
|
|
|
150
150
|
if (versionRange && device.features) {
|
|
151
151
|
const currentVersion = getDeviceFirmwareVersion(device.features).join('.');
|
|
152
152
|
if (semver.valid(versionRange.min) && semver.lt(currentVersion, versionRange.min)) {
|
|
153
|
+
const newVersionUnReleased = DataManager.getFirmwareStatus(device.features);
|
|
154
|
+
if (newVersionUnReleased === 'none' || newVersionUnReleased === 'valid') {
|
|
155
|
+
throw ERRORS.TypedError(HardwareErrorCode.NewFirmwareUnRelease);
|
|
156
|
+
}
|
|
157
|
+
|
|
153
158
|
return Promise.reject(
|
|
154
159
|
ERRORS.TypedError(
|
|
155
160
|
HardwareErrorCode.CallMethodNeedUpgradeFirmware,
|
|
@@ -1,5 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"nested": {
|
|
3
|
+
"AlgorandGetAddress": {
|
|
4
|
+
"fields": {
|
|
5
|
+
"address_n": {
|
|
6
|
+
"rule": "repeated",
|
|
7
|
+
"type": "uint32",
|
|
8
|
+
"id": 1,
|
|
9
|
+
"options": {
|
|
10
|
+
"packed": false
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"show_display": {
|
|
14
|
+
"type": "bool",
|
|
15
|
+
"id": 3
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"AlgorandAddress": {
|
|
20
|
+
"fields": {
|
|
21
|
+
"address": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"id": 1
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"AlgorandSignTx": {
|
|
28
|
+
"fields": {
|
|
29
|
+
"address_n": {
|
|
30
|
+
"rule": "repeated",
|
|
31
|
+
"type": "uint32",
|
|
32
|
+
"id": 1,
|
|
33
|
+
"options": {
|
|
34
|
+
"packed": false
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"raw_tx": {
|
|
38
|
+
"rule": "required",
|
|
39
|
+
"type": "bytes",
|
|
40
|
+
"id": 2
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"AlgorandSignedTx": {
|
|
45
|
+
"fields": {
|
|
46
|
+
"signature": {
|
|
47
|
+
"rule": "required",
|
|
48
|
+
"type": "bytes",
|
|
49
|
+
"id": 1
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
3
53
|
"AptosGetAddress": {
|
|
4
54
|
"fields": {
|
|
5
55
|
"address_n": {
|
|
@@ -55,6 +105,65 @@
|
|
|
55
105
|
}
|
|
56
106
|
}
|
|
57
107
|
},
|
|
108
|
+
"AptosSignMessage": {
|
|
109
|
+
"fields": {
|
|
110
|
+
"address_n": {
|
|
111
|
+
"rule": "repeated",
|
|
112
|
+
"type": "uint32",
|
|
113
|
+
"id": 1,
|
|
114
|
+
"options": {
|
|
115
|
+
"packed": false
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
"payload": {
|
|
119
|
+
"rule": "required",
|
|
120
|
+
"type": "AptosMessagePayload",
|
|
121
|
+
"id": 2
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
"nested": {
|
|
125
|
+
"AptosMessagePayload": {
|
|
126
|
+
"fields": {
|
|
127
|
+
"address": {
|
|
128
|
+
"type": "string",
|
|
129
|
+
"id": 2
|
|
130
|
+
},
|
|
131
|
+
"chain_id": {
|
|
132
|
+
"type": "string",
|
|
133
|
+
"id": 3
|
|
134
|
+
},
|
|
135
|
+
"application": {
|
|
136
|
+
"type": "string",
|
|
137
|
+
"id": 4
|
|
138
|
+
},
|
|
139
|
+
"nonce": {
|
|
140
|
+
"rule": "required",
|
|
141
|
+
"type": "string",
|
|
142
|
+
"id": 5
|
|
143
|
+
},
|
|
144
|
+
"message": {
|
|
145
|
+
"rule": "required",
|
|
146
|
+
"type": "string",
|
|
147
|
+
"id": 6
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
"AptosMessageSignature": {
|
|
154
|
+
"fields": {
|
|
155
|
+
"signature": {
|
|
156
|
+
"rule": "required",
|
|
157
|
+
"type": "bytes",
|
|
158
|
+
"id": 1
|
|
159
|
+
},
|
|
160
|
+
"address": {
|
|
161
|
+
"rule": "required",
|
|
162
|
+
"type": "string",
|
|
163
|
+
"id": 2
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
},
|
|
58
167
|
"BinanceGetAddress": {
|
|
59
168
|
"fields": {
|
|
60
169
|
"address_n": {
|
|
@@ -2827,6 +2936,60 @@
|
|
|
2827
2936
|
}
|
|
2828
2937
|
}
|
|
2829
2938
|
},
|
|
2939
|
+
"CosmosGetAddress": {
|
|
2940
|
+
"fields": {
|
|
2941
|
+
"address_n": {
|
|
2942
|
+
"rule": "repeated",
|
|
2943
|
+
"type": "uint32",
|
|
2944
|
+
"id": 1,
|
|
2945
|
+
"options": {
|
|
2946
|
+
"packed": false
|
|
2947
|
+
}
|
|
2948
|
+
},
|
|
2949
|
+
"hrp": {
|
|
2950
|
+
"type": "string",
|
|
2951
|
+
"id": 2
|
|
2952
|
+
},
|
|
2953
|
+
"show_display": {
|
|
2954
|
+
"type": "bool",
|
|
2955
|
+
"id": 3
|
|
2956
|
+
}
|
|
2957
|
+
}
|
|
2958
|
+
},
|
|
2959
|
+
"CosmosAddress": {
|
|
2960
|
+
"fields": {
|
|
2961
|
+
"address": {
|
|
2962
|
+
"type": "string",
|
|
2963
|
+
"id": 1
|
|
2964
|
+
}
|
|
2965
|
+
}
|
|
2966
|
+
},
|
|
2967
|
+
"CosmosSignTx": {
|
|
2968
|
+
"fields": {
|
|
2969
|
+
"address_n": {
|
|
2970
|
+
"rule": "repeated",
|
|
2971
|
+
"type": "uint32",
|
|
2972
|
+
"id": 1,
|
|
2973
|
+
"options": {
|
|
2974
|
+
"packed": false
|
|
2975
|
+
}
|
|
2976
|
+
},
|
|
2977
|
+
"raw_tx": {
|
|
2978
|
+
"rule": "required",
|
|
2979
|
+
"type": "bytes",
|
|
2980
|
+
"id": 2
|
|
2981
|
+
}
|
|
2982
|
+
}
|
|
2983
|
+
},
|
|
2984
|
+
"CosmosSignedTx": {
|
|
2985
|
+
"fields": {
|
|
2986
|
+
"signature": {
|
|
2987
|
+
"rule": "required",
|
|
2988
|
+
"type": "bytes",
|
|
2989
|
+
"id": 1
|
|
2990
|
+
}
|
|
2991
|
+
}
|
|
2992
|
+
},
|
|
2830
2993
|
"CipherKeyValue": {
|
|
2831
2994
|
"fields": {
|
|
2832
2995
|
"address_n": {
|
|
@@ -8508,6 +8671,8 @@
|
|
|
8508
8671
|
"MessageType_AptosAddress": 10601,
|
|
8509
8672
|
"MessageType_AptosSignTx": 10602,
|
|
8510
8673
|
"MessageType_AptosSignedTx": 10603,
|
|
8674
|
+
"MessageType_AptosSignMessage": 10604,
|
|
8675
|
+
"MessageType_AptosMessageSignature": 10605,
|
|
8511
8676
|
"MessageType_WebAuthnListResidentCredentials": 800,
|
|
8512
8677
|
"MessageType_WebAuthnCredentials": 801,
|
|
8513
8678
|
"MessageType_WebAuthnAddResidentCredential": 802,
|
|
@@ -8548,6 +8713,14 @@
|
|
|
8548
8713
|
"MessageType_NearAddress": 10702,
|
|
8549
8714
|
"MessageType_NearSignTx": 10703,
|
|
8550
8715
|
"MessageType_NearSignedTx": 10704,
|
|
8716
|
+
"MessageType_CosmosGetAddress": 10800,
|
|
8717
|
+
"MessageType_CosmosAddress": 10801,
|
|
8718
|
+
"MessageType_CosmosSignTx": 10802,
|
|
8719
|
+
"MessageType_CosmosSignedTx": 10803,
|
|
8720
|
+
"MessageType_AlgorandGetAddress": 10900,
|
|
8721
|
+
"MessageType_AlgorandAddress": 10901,
|
|
8722
|
+
"MessageType_AlgorandSignTx": 10902,
|
|
8723
|
+
"MessageType_AlgorandSignedTx": 10903,
|
|
8551
8724
|
"MessageType_DeviceBackToBoot": 903,
|
|
8552
8725
|
"MessageType_DeviceInfoSettings": 10001,
|
|
8553
8726
|
"MessageType_GetDeviceInfo": 10002,
|
|
@@ -68,7 +68,7 @@ export default class DataManager {
|
|
|
68
68
|
* Touch、Pro System UI Resource Update
|
|
69
69
|
* ** Interval upgrade is not considered **
|
|
70
70
|
*/
|
|
71
|
-
static getSysResourcesLatestRelease = (features: Features) => {
|
|
71
|
+
static getSysResourcesLatestRelease = (features: Features, forcedUpdateRes?: boolean) => {
|
|
72
72
|
const deviceType = getDeviceType(features);
|
|
73
73
|
const deviceFirmwareVersion = getDeviceFirmwareVersion(features);
|
|
74
74
|
|
|
@@ -76,8 +76,10 @@ export default class DataManager {
|
|
|
76
76
|
|
|
77
77
|
const targetDeviceConfigList = this.deviceMap[deviceType]?.firmware ?? [];
|
|
78
78
|
const currentVersion = deviceFirmwareVersion.join('.');
|
|
79
|
-
const targetDeviceConfig = targetDeviceConfigList.filter(
|
|
80
|
-
|
|
79
|
+
const targetDeviceConfig = targetDeviceConfigList.filter(item =>
|
|
80
|
+
forcedUpdateRes
|
|
81
|
+
? !!item.resource
|
|
82
|
+
: semver.gt(item.version.join('.'), currentVersion) && !!item.resource
|
|
81
83
|
);
|
|
82
84
|
|
|
83
85
|
return findLatestRelease(targetDeviceConfig)?.resource;
|
|
@@ -144,7 +144,16 @@ export class DeviceCommands {
|
|
|
144
144
|
res: DefaultMessageResponse,
|
|
145
145
|
callType: MessageKey
|
|
146
146
|
): Promise<DefaultMessageResponse> {
|
|
147
|
-
|
|
147
|
+
try {
|
|
148
|
+
if (DataManager.getSettings('env') === 'react-native') {
|
|
149
|
+
Log.debug('_filterCommonTypes: ', JSON.stringify(res));
|
|
150
|
+
} else {
|
|
151
|
+
Log.debug('_filterCommonTypes: ', res);
|
|
152
|
+
}
|
|
153
|
+
} catch (error) {
|
|
154
|
+
// ignore
|
|
155
|
+
}
|
|
156
|
+
|
|
148
157
|
if (res.type === 'Failure') {
|
|
149
158
|
const { code, message } = res.message as {
|
|
150
159
|
code?: string | FailureType;
|
package/src/inject.ts
CHANGED
|
@@ -175,8 +175,20 @@ export const inject = ({
|
|
|
175
175
|
call({ ...params, connectId, deviceId, method: 'aptosGetAddress' }),
|
|
176
176
|
aptosGetPublicKey: (connectId, deviceId, params) =>
|
|
177
177
|
call({ ...params, connectId, deviceId, method: 'aptosGetPublicKey' }),
|
|
178
|
+
aptosSignMessage: (connectId, deviceId, params) =>
|
|
179
|
+
call({ ...params, connectId, deviceId, method: 'aptosSignMessage' }),
|
|
178
180
|
aptosSignTransaction: (connectId, deviceId, params) =>
|
|
179
181
|
call({ ...params, connectId, deviceId, method: 'aptosSignTransaction' }),
|
|
182
|
+
|
|
183
|
+
algoGetAddress: (connectId, deviceId, params) =>
|
|
184
|
+
call({ ...params, connectId, deviceId, method: 'algoGetAddress' }),
|
|
185
|
+
algoSignTransaction: (connectId, deviceId, params) =>
|
|
186
|
+
call({ ...params, connectId, deviceId, method: 'algoSignTransaction' }),
|
|
187
|
+
|
|
188
|
+
cosmosGetAddress: (connectId, deviceId, params) =>
|
|
189
|
+
call({ ...params, connectId, deviceId, method: 'cosmosGetAddress' }),
|
|
190
|
+
cosmosSignTransaction: (connectId, deviceId, params) =>
|
|
191
|
+
call({ ...params, connectId, deviceId, method: 'cosmosSignTransaction' }),
|
|
180
192
|
};
|
|
181
193
|
return api;
|
|
182
194
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AlgorandAddress as HardwareAlgoGetAddress } from '@onekeyfe/hd-transport';
|
|
2
|
+
import type { CommonParams, Response } from '../params';
|
|
3
|
+
|
|
4
|
+
export type AlgoAddress = {
|
|
5
|
+
path: string;
|
|
6
|
+
} & HardwareAlgoGetAddress;
|
|
7
|
+
|
|
8
|
+
export type AlgoGetAddressParams = {
|
|
9
|
+
path: string | number[];
|
|
10
|
+
showOnOneKey?: boolean;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export declare function algoGetAddress(
|
|
14
|
+
connectId: string,
|
|
15
|
+
deviceId: string,
|
|
16
|
+
params: CommonParams & AlgoGetAddressParams
|
|
17
|
+
): Response<AlgoAddress>;
|
|
18
|
+
|
|
19
|
+
export declare function algoGetAddress(
|
|
20
|
+
connectId: string,
|
|
21
|
+
deviceId: string,
|
|
22
|
+
params: CommonParams & { bundle?: AlgoGetAddressParams[] }
|
|
23
|
+
): Response<Array<AlgoAddress>>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AlgorandSignedTx as HardwareAlgorandSignedTx } from '@onekeyfe/hd-transport';
|
|
2
|
+
import type { CommonParams, Response } from '../params';
|
|
3
|
+
|
|
4
|
+
export type AlgoSignedTx = {
|
|
5
|
+
path: string;
|
|
6
|
+
} & HardwareAlgorandSignedTx;
|
|
7
|
+
|
|
8
|
+
export type AlgoSignTransactionParams = {
|
|
9
|
+
path: string | number[];
|
|
10
|
+
rawTx?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export declare function algoSignTransaction(
|
|
14
|
+
connectId: string,
|
|
15
|
+
deviceId: string,
|
|
16
|
+
params: CommonParams & AlgoSignTransactionParams
|
|
17
|
+
): Response<AlgoSignedTx>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AptosMessageSignature as HardwareAptosMessageSignature } from '@onekeyfe/hd-transport';
|
|
2
|
+
import type { CommonParams, Response } from '../params';
|
|
3
|
+
|
|
4
|
+
export type AptosMessageSignature = {
|
|
5
|
+
path: string;
|
|
6
|
+
fullMessage: string;
|
|
7
|
+
} & HardwareAptosMessageSignature;
|
|
8
|
+
|
|
9
|
+
declare type AptosMessagePayload = {
|
|
10
|
+
address?: string;
|
|
11
|
+
chainId?: string;
|
|
12
|
+
application?: string;
|
|
13
|
+
nonce: string;
|
|
14
|
+
message: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type AptosSignMessageParams = {
|
|
18
|
+
path: string | number[];
|
|
19
|
+
payload: AptosMessagePayload;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export declare function aptosSignMessage(
|
|
23
|
+
connectId: string,
|
|
24
|
+
deviceId: string,
|
|
25
|
+
params: CommonParams & AptosSignMessageParams
|
|
26
|
+
): Response<AptosMessageSignature>;
|
|
@@ -13,5 +13,5 @@ export type AptosSignTransactionParams = {
|
|
|
13
13
|
export declare function aptosSignTransaction(
|
|
14
14
|
connectId: string,
|
|
15
15
|
deviceId: string,
|
|
16
|
-
params: CommonParams & AptosSignTransactionParams
|
|
16
|
+
params: CommonParams & AptosSignTransactionParams
|
|
17
17
|
): Response<AptosSignedTx>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CosmosAddress as HardwareCosmosAddress } from '@onekeyfe/hd-transport';
|
|
2
|
+
import type { CommonParams, Response } from '../params';
|
|
3
|
+
|
|
4
|
+
export type CosmosAddress = {
|
|
5
|
+
path: string;
|
|
6
|
+
} & HardwareCosmosAddress;
|
|
7
|
+
|
|
8
|
+
export type CosmosGetAddressParams = {
|
|
9
|
+
path: string | number[];
|
|
10
|
+
showOnOneKey?: boolean;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export declare function cosmosGetAddress(
|
|
14
|
+
connectId: string,
|
|
15
|
+
deviceId: string,
|
|
16
|
+
params: CommonParams & CosmosGetAddressParams
|
|
17
|
+
): Response<CosmosAddress>;
|
|
18
|
+
|
|
19
|
+
export declare function cosmosGetAddress(
|
|
20
|
+
connectId: string,
|
|
21
|
+
deviceId: string,
|
|
22
|
+
params: CommonParams & { bundle?: CosmosGetAddressParams[] }
|
|
23
|
+
): Response<Array<CosmosAddress>>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CosmosSignedTx as HardwareCosmosSignedTx } from '@onekeyfe/hd-transport';
|
|
2
|
+
import type { CommonParams, Response } from '../params';
|
|
3
|
+
|
|
4
|
+
export type CosmosSignedTx = {
|
|
5
|
+
path: string;
|
|
6
|
+
} & HardwareCosmosSignedTx;
|
|
7
|
+
|
|
8
|
+
export type CosmosSignTransactionParams = {
|
|
9
|
+
path: string | number[];
|
|
10
|
+
rawTx?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export declare function cosmosSignTransaction(
|
|
14
|
+
connectId: string,
|
|
15
|
+
deviceId: string,
|
|
16
|
+
params: CommonParams & CosmosSignTransactionParams
|
|
17
|
+
): Response<CosmosSignedTx>;
|
package/src/types/api/export.ts
CHANGED
|
@@ -97,4 +97,11 @@ export type { NearSignTransactionParams } from './nearSignTransaction';
|
|
|
97
97
|
|
|
98
98
|
export type { AptosAddress, AptosGetAddressParams } from './aptosGetAddress';
|
|
99
99
|
export type { AptosPublicKey, AptosGetPublicKeyParams } from './aptosGetPublicKey';
|
|
100
|
+
export type { AptosMessageSignature, AptosSignMessageParams } from './aptosSignMessage';
|
|
100
101
|
export type { AptosSignedTx, AptosSignTransactionParams } from './aptosSignTransaction';
|
|
102
|
+
|
|
103
|
+
export type { AlgoAddress, AlgoGetAddressParams } from './algoGetAddress';
|
|
104
|
+
export type { AlgoSignedTx, AlgoSignTransactionParams } from './algoSignTransaction';
|
|
105
|
+
|
|
106
|
+
export type { CosmosAddress, CosmosGetAddressParams } from './cosmosGetAddress';
|
|
107
|
+
export type { CosmosSignedTx, CosmosSignTransactionParams } from './cosmosSignTransaction';
|
package/src/types/api/index.ts
CHANGED
|
@@ -72,8 +72,15 @@ import { nearSignTransaction } from './nearSignTransaction';
|
|
|
72
72
|
|
|
73
73
|
import { aptosGetAddress } from './aptosGetAddress';
|
|
74
74
|
import { aptosGetPublicKey } from './aptosGetPublicKey';
|
|
75
|
+
import { aptosSignMessage } from './aptosSignMessage';
|
|
75
76
|
import { aptosSignTransaction } from './aptosSignTransaction';
|
|
76
77
|
|
|
78
|
+
import { algoGetAddress } from './algoGetAddress';
|
|
79
|
+
import { algoSignTransaction } from './algoSignTransaction';
|
|
80
|
+
|
|
81
|
+
import { cosmosGetAddress } from './cosmosGetAddress';
|
|
82
|
+
import { cosmosSignTransaction } from './cosmosSignTransaction';
|
|
83
|
+
|
|
77
84
|
export * from './export';
|
|
78
85
|
|
|
79
86
|
export type CoreApi = {
|
|
@@ -195,5 +202,18 @@ export type CoreApi = {
|
|
|
195
202
|
*/
|
|
196
203
|
aptosGetAddress: typeof aptosGetAddress;
|
|
197
204
|
aptosGetPublicKey: typeof aptosGetPublicKey;
|
|
205
|
+
aptosSignMessage: typeof aptosSignMessage;
|
|
198
206
|
aptosSignTransaction: typeof aptosSignTransaction;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Algo function
|
|
210
|
+
*/
|
|
211
|
+
algoGetAddress: typeof algoGetAddress;
|
|
212
|
+
algoSignTransaction: typeof algoSignTransaction;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Cosmos function
|
|
216
|
+
*/
|
|
217
|
+
cosmosGetAddress: typeof cosmosGetAddress;
|
|
218
|
+
cosmosSignTransaction: typeof cosmosSignTransaction;
|
|
199
219
|
};
|