@onekeyfe/hardware-cli 1.2.8-alpha.20 → 1.2.8-alpha.22
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/cli.js +4 -12
- package/package.json +6 -6
- package/src/__tests__/firmware-update-v4-command.test.ts +5 -1
- package/src/cli.ts +7 -13
package/dist/cli.js
CHANGED
|
@@ -964,20 +964,12 @@ function getFirmwareUpdateV4TotalBytes(params) {
|
|
|
964
964
|
params.se04Binary,
|
|
965
965
|
].reduce((total, binary) => total + (binary?.byteLength ?? 0), 0);
|
|
966
966
|
}
|
|
967
|
-
function
|
|
967
|
+
function isProtocolV2UsbProbeTransientResult(result) {
|
|
968
968
|
if (!result || typeof result !== 'object')
|
|
969
|
-
return
|
|
969
|
+
return false;
|
|
970
970
|
const { payload } = result;
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
const { error } = payload;
|
|
974
|
-
return typeof error === 'string' ? error : '';
|
|
975
|
-
}
|
|
976
|
-
function isProtocolV2UsbProbeTransientResult(result) {
|
|
977
|
-
const error = getFirmwareUpdateV4ErrorText(result);
|
|
978
|
-
return (error.includes('Device protocol mismatch') &&
|
|
979
|
-
error.includes('expected V2') &&
|
|
980
|
-
error.includes('did not respond to expected protocol'));
|
|
971
|
+
return (payload?.code === hd_shared_1.HardwareErrorCode.TransportProtocolProbeFailed &&
|
|
972
|
+
payload.params?.expectedProtocol === 'V2');
|
|
981
973
|
}
|
|
982
974
|
function isSuccessResult(result) {
|
|
983
975
|
return (!!result && typeof result === 'object' && result.success === true);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hardware-cli",
|
|
3
|
-
"version": "1.2.8-alpha.
|
|
3
|
+
"version": "1.2.8-alpha.22",
|
|
4
4
|
"description": "OneKey hardware wallet CLI for testing device communication",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
"test": "jest"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@onekeyfe/hd-common-connect-sdk": "1.2.8-alpha.
|
|
35
|
-
"@onekeyfe/hd-core": "1.2.8-alpha.
|
|
36
|
-
"@onekeyfe/hd-shared": "1.2.8-alpha.
|
|
37
|
-
"@onekeyfe/hd-transport-usb": "1.2.8-alpha.
|
|
34
|
+
"@onekeyfe/hd-common-connect-sdk": "1.2.8-alpha.22",
|
|
35
|
+
"@onekeyfe/hd-core": "1.2.8-alpha.22",
|
|
36
|
+
"@onekeyfe/hd-shared": "1.2.8-alpha.22",
|
|
37
|
+
"@onekeyfe/hd-transport-usb": "1.2.8-alpha.22",
|
|
38
38
|
"@stoprocent/noble": "2.3.16",
|
|
39
39
|
"commander": "^12.0.0"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "94bc5d4b79170d7113d26f0d5ad67e166538824d"
|
|
42
42
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
|
+
|
|
1
3
|
import { createSDK, disposeSDK } from '../sdk';
|
|
2
4
|
import { program, runFirmwareUpdateV4WithRetry } from '../cli';
|
|
3
5
|
|
|
@@ -9,7 +11,9 @@ jest.mock('../sdk', () => ({
|
|
|
9
11
|
const transientProbeFailure = {
|
|
10
12
|
success: false,
|
|
11
13
|
payload: {
|
|
12
|
-
|
|
14
|
+
code: HardwareErrorCode.TransportProtocolProbeFailed,
|
|
15
|
+
error: 'probe diagnostic wording may change',
|
|
16
|
+
params: { expectedProtocol: 'V2' },
|
|
13
17
|
},
|
|
14
18
|
};
|
|
15
19
|
|
package/src/cli.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { readFileSync } from 'node:fs';
|
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
import { UI_EVENT, UI_REQUEST, getDeviceType } from '@onekeyfe/hd-core';
|
|
5
|
-
import { EDeviceType, isSameOnekeyBleName } from '@onekeyfe/hd-shared';
|
|
5
|
+
import { EDeviceType, HardwareErrorCode, isSameOnekeyBleName } from '@onekeyfe/hd-shared';
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
resolveBatchGetAddress,
|
|
@@ -1259,20 +1259,14 @@ function getFirmwareUpdateV4TotalBytes(params: ReturnType<typeof buildFirmwareUp
|
|
|
1259
1259
|
].reduce((total, binary) => total + (binary?.byteLength ?? 0), 0);
|
|
1260
1260
|
}
|
|
1261
1261
|
|
|
1262
|
-
function getFirmwareUpdateV4ErrorText(result: unknown) {
|
|
1263
|
-
if (!result || typeof result !== 'object') return '';
|
|
1264
|
-
const { payload } = result as { payload?: unknown };
|
|
1265
|
-
if (!payload || typeof payload !== 'object') return '';
|
|
1266
|
-
const { error } = payload as { error?: unknown };
|
|
1267
|
-
return typeof error === 'string' ? error : '';
|
|
1268
|
-
}
|
|
1269
|
-
|
|
1270
1262
|
function isProtocolV2UsbProbeTransientResult(result: unknown) {
|
|
1271
|
-
|
|
1263
|
+
if (!result || typeof result !== 'object') return false;
|
|
1264
|
+
const { payload } = result as {
|
|
1265
|
+
payload?: { code?: unknown; params?: { expectedProtocol?: unknown } };
|
|
1266
|
+
};
|
|
1272
1267
|
return (
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
error.includes('did not respond to expected protocol')
|
|
1268
|
+
payload?.code === HardwareErrorCode.TransportProtocolProbeFailed &&
|
|
1269
|
+
payload.params?.expectedProtocol === 'V2'
|
|
1276
1270
|
);
|
|
1277
1271
|
}
|
|
1278
1272
|
|