@onekeyfe/hd-core 1.2.0-alpha.5 → 1.2.0-alpha.6

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.
@@ -2917,6 +2917,67 @@ describe('Protocol V2 firmware update targets', () => {
2917
2917
  ]);
2918
2918
  });
2919
2919
 
2920
+ test('installs merged Pro2 resource crate as one CRATE request before firmware targets', async () => {
2921
+ const method = new FirmwareUpdateV4({
2922
+ id: 1,
2923
+ payload: {
2924
+ method: 'firmwareUpdateV4',
2925
+ },
2926
+ });
2927
+
2928
+ const operations: string[] = [];
2929
+ method.postTipMessage = jest.fn();
2930
+ method.postProgressMessage = jest.fn();
2931
+ (method as any).protocolV2CommonUpdateProcess = jest
2932
+ .fn()
2933
+ .mockImplementation(params => {
2934
+ operations.push(`write:${params.filePath}`);
2935
+ return Promise.resolve(
2936
+ Number(params.processedSize ?? 0) + Number(params.payload.byteLength)
2937
+ );
2938
+ });
2939
+ (method as any).protocolV2StartFirmwareUpdate = jest.fn().mockImplementation(({ targets }) => {
2940
+ operations.push(
2941
+ `install:${targets.map((target: { path: string }) => target.path).join(',')}`
2942
+ );
2943
+ return Promise.resolve(undefined);
2944
+ });
2945
+ (method as any).waitForProtocolV2FirmwareUpdateComplete = jest
2946
+ .fn()
2947
+ .mockResolvedValue(undefined);
2948
+
2949
+ await (method as any).executeProtocolV2Update({
2950
+ resourceBinaryMap: [
2951
+ {
2952
+ fileName: 'resource-resource.bin',
2953
+ binary: new Uint8Array([1, 2]).buffer,
2954
+ targetId: 1,
2955
+ },
2956
+ ],
2957
+ bootloaderBinary: null,
2958
+ fwBinaryMap: [
2959
+ {
2960
+ fileName: 'application_p1.bin',
2961
+ binary: new Uint8Array([3]).buffer,
2962
+ targetId: 4,
2963
+ },
2964
+ ],
2965
+ });
2966
+
2967
+ expect((method as any).protocolV2StartFirmwareUpdate).toHaveBeenNthCalledWith(1, {
2968
+ targets: [{ target_id: 1, path: 'vol1:resource-resource.bin' }],
2969
+ });
2970
+ expect((method as any).protocolV2StartFirmwareUpdate).toHaveBeenNthCalledWith(2, {
2971
+ targets: [{ target_id: 4, path: 'vol1:application_p1.bin' }],
2972
+ });
2973
+ expect(operations).toEqual([
2974
+ 'write:vol1:resource-resource.bin',
2975
+ 'write:vol1:application_p1.bin',
2976
+ 'install:vol1:resource-resource.bin',
2977
+ 'install:vol1:application_p1.bin',
2978
+ ]);
2979
+ });
2980
+
2920
2981
  test('skips Pro2 firmware components when configured versions are already installed', async () => {
2921
2982
  const method = new FirmwareUpdateV4({
2922
2983
  id: 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-core",
3
- "version": "1.2.0-alpha.5",
3
+ "version": "1.2.0-alpha.6",
4
4
  "description": "Core processes and APIs for communicating with OneKey hardware devices.",
5
5
  "author": "OneKey",
6
6
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
@@ -25,8 +25,8 @@
25
25
  "url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
26
26
  },
27
27
  "dependencies": {
28
- "@onekeyfe/hd-shared": "1.2.0-alpha.5",
29
- "@onekeyfe/hd-transport": "1.2.0-alpha.5",
28
+ "@onekeyfe/hd-shared": "1.2.0-alpha.6",
29
+ "@onekeyfe/hd-transport": "1.2.0-alpha.6",
30
30
  "axios": "1.15.2",
31
31
  "bignumber.js": "^9.0.2",
32
32
  "bytebuffer": "^5.0.1",
@@ -44,5 +44,5 @@
44
44
  "@types/w3c-web-usb": "^1.0.10",
45
45
  "@types/web-bluetooth": "^0.0.21"
46
46
  },
47
- "gitHead": "703cfb4e17c6f9315afcb0522ee23ea016ede659"
47
+ "gitHead": "b0a8d032546250b02bc737d72ac23932bdc07a61"
48
48
  }
@@ -81,7 +81,7 @@ export interface FirmwareUpdateV4Params {
81
81
  se02Binary?: ArrayBuffer;
82
82
  se03Binary?: ArrayBuffer;
83
83
  se04Binary?: ArrayBuffer;
84
- /** 资源包通过 FW_MGMT_TARGET_CRATE = 1 安装;每个元素是一个独立资源包 */
84
+ /** 资源包通过 FW_MGMT_TARGET_CRATE = 1 安装;Pro2 正常升级推荐传入单个合并 CRATE,多个元素仅用于调试/兼容 */
85
85
  resourceBinaries?: ArrayBuffer[];
86
86
  forcedUpdateRes?: boolean;
87
87
  }