@onekeyfe/hd-core 1.0.33-alpha.6 → 1.0.33-alpha.8

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.
@@ -5,6 +5,7 @@ type MethodParams = {
5
5
  methodName: keyof CoreApi;
6
6
  params: Parameters<CoreApi[keyof CoreApi]>[0];
7
7
  _originRequestParams: AllNetworkAddressParams;
8
+ _originalIndex: number;
8
9
  };
9
10
  export default class AllNetworkGetAddress extends BaseMethod<{
10
11
  address_n: number[];
@@ -13,9 +14,10 @@ export default class AllNetworkGetAddress extends BaseMethod<{
13
14
  chain_name?: string;
14
15
  }[]> {
15
16
  init(): void;
16
- generateMethodName({ network, payload, }: {
17
+ generateMethodName({ network, payload, originalIndex, }: {
17
18
  network: INetwork;
18
19
  payload: AllNetworkAddressParams;
20
+ originalIndex: number;
19
21
  }): MethodParams;
20
22
  callMethod(methodName: keyof CoreApi, params: any & {
21
23
  bundle: (any & {
@@ -1 +1 @@
1
- {"version":3,"file":"AllNetworkGetAddress.d.ts","sourceRoot":"","sources":["../../../src/api/allnetwork/AllNetworkGetAddress.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,KAAK,EACV,iBAAiB,EACjB,uBAAuB,EAEvB,oBAAoB,EACpB,QAAQ,EACT,MAAM,sCAAsC,CAAC;AA4N9C,KAAK,YAAY,GAAG;IAClB,UAAU,EAAE,MAAM,OAAO,CAAC;IAC1B,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,oBAAoB,EAAE,uBAAuB,CAAC;CAC/C,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,UAAU,CAC1D;IACE,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,EAAE,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OAAO,EACP,aAAa,GACd,EAAE;QACD,OAAO,EAAE,QAAQ,CAAC;QAClB,OAAO,EAAE,uBAAuB,CAAC;QACjC,aAAa,EAAE,MAAM,CAAC;KACvB,GAAG,YAAY;IAqBV,UAAU,CACd,UAAU,EAAE,MAAM,OAAO,EACzB,MAAM,EAAE,GAAG,GAAG;QACZ,MAAM,EAAE,CAAC,GAAG,GAAG;YAAE,oBAAoB,EAAE,oBAAoB,CAAA;SAAE,CAAC,EAAE,CAAC;KAClE;IAyDG,GAAG;CAqDV"}
package/dist/index.js CHANGED
@@ -7376,7 +7376,7 @@ var nested$1 = {
7376
7376
  type: "bool",
7377
7377
  id: 3
7378
7378
  },
7379
- btc_test: {
7379
+ passphrase_state: {
7380
7380
  type: "string",
7381
7381
  id: 8000
7382
7382
  }
@@ -7759,6 +7759,14 @@ var nested$1 = {
7759
7759
  onekey_se04_state: {
7760
7760
  type: "OneKeySEState",
7761
7761
  id: 624
7762
+ },
7763
+ attach_to_pin_user: {
7764
+ type: "bool",
7765
+ id: 625
7766
+ },
7767
+ unlocked_attach_pin: {
7768
+ type: "bool",
7769
+ id: 626
7762
7770
  }
7763
7771
  },
7764
7772
  nested: {
@@ -29923,7 +29931,7 @@ class AllNetworkGetAddress extends BaseMethod {
29923
29931
  ]);
29924
29932
  });
29925
29933
  }
29926
- generateMethodName({ network, payload, }) {
29934
+ generateMethodName({ network, payload, originalIndex, }) {
29927
29935
  var _a, _b;
29928
29936
  const { name: networkName, coin } = networkAliases[network] || {
29929
29937
  name: network,
@@ -29937,6 +29945,7 @@ class AllNetworkGetAddress extends BaseMethod {
29937
29945
  methodName: config.methodName,
29938
29946
  params: Object.assign(Object.assign({}, ((_b = (_a = config === null || config === void 0 ? void 0 : config.getParams) === null || _a === void 0 ? void 0 : _a.call(config, payload, coin, config.methodName)) !== null && _b !== void 0 ? _b : payload)), { originPayload: payload }),
29939
29947
  _originRequestParams: payload,
29948
+ _originalIndex: originalIndex,
29940
29949
  };
29941
29950
  }
29942
29951
  callMethod(methodName, params) {
@@ -29984,10 +29993,11 @@ class AllNetworkGetAddress extends BaseMethod {
29984
29993
  const responses = [];
29985
29994
  const resultMap = {};
29986
29995
  const { bundle } = this.payload;
29987
- const methodReduceParams = bundle
29988
- .map(param => this.generateMethodName({
29996
+ const methodGroups = bundle
29997
+ .map((param, index) => this.generateMethodName({
29989
29998
  network: param.network,
29990
29999
  payload: param,
30000
+ originalIndex: index,
29991
30001
  }))
29992
30002
  .reduce((acc, cur) => {
29993
30003
  if (!acc[cur.methodName]) {
@@ -29996,28 +30006,25 @@ class AllNetworkGetAddress extends BaseMethod {
29996
30006
  acc[cur.methodName].push(cur);
29997
30007
  return acc;
29998
30008
  }, {});
29999
- const methodParamsArray = Object.values(methodReduceParams);
30000
- const generateResponseKey = (payload) => `${payload.path}-${payload.network}-${payload.chainName}-${payload.prefix}`;
30001
- for (let i = 0; i < methodParamsArray.length; i++) {
30002
- const methodParams = methodParamsArray[i];
30003
- const { methodName } = methodParams[0];
30004
- const params = {
30005
- bundle: methodParams.map(param => (Object.assign({}, param.params))),
30009
+ let i = 0;
30010
+ for (const [methodName, params] of Object.entries(methodGroups)) {
30011
+ const methodParams = {
30012
+ bundle: params.map(param => (Object.assign({}, param.params))),
30006
30013
  };
30007
- const response = yield this.callMethod(methodName, params);
30008
- for (let i = 0; i < methodParams.length; i++) {
30009
- const { _originRequestParams } = methodParams[i];
30010
- const responseKey = generateResponseKey(_originRequestParams);
30014
+ const response = yield this.callMethod(methodName, methodParams);
30015
+ for (let i = 0; i < params.length; i++) {
30016
+ const { _originRequestParams, _originalIndex } = params[i];
30017
+ const responseKey = `${_originalIndex}`;
30011
30018
  resultMap[responseKey] = Object.assign(Object.assign({}, _originRequestParams), response[i]);
30012
30019
  }
30013
30020
  if (((_b = (_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle) === null || _b === void 0 ? void 0 : _b.length) > 1) {
30014
30021
  const progress = Math.round(((i + 1) / this.payload.bundle.length) * 100);
30015
30022
  this.postMessage(createUiMessage(UI_REQUEST.DEVICE_PROGRESS, { progress }));
30016
30023
  }
30024
+ i++;
30017
30025
  }
30018
- for (const param of bundle) {
30019
- const responseKey = generateResponseKey(param);
30020
- responses.push(resultMap[responseKey]);
30026
+ for (let i = 0; i < bundle.length; i++) {
30027
+ responses.push(resultMap[i]);
30021
30028
  }
30022
30029
  return Promise.resolve(responses);
30023
30030
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-core",
3
- "version": "1.0.33-alpha.6",
3
+ "version": "1.0.33-alpha.8",
4
4
  "description": "> TODO: description",
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.0.33-alpha.6",
29
- "@onekeyfe/hd-transport": "^1.0.33-alpha.6",
28
+ "@onekeyfe/hd-shared": "^1.0.33-alpha.8",
29
+ "@onekeyfe/hd-transport": "^1.0.33-alpha.8",
30
30
  "axios": "^0.27.2",
31
31
  "bignumber.js": "^9.0.2",
32
32
  "bytebuffer": "^5.0.1",
@@ -46,5 +46,5 @@
46
46
  "@types/web-bluetooth": "^0.0.21",
47
47
  "ripple-keypairs": "^1.1.4"
48
48
  },
49
- "gitHead": "b38e4e40565deb11573fe69ff9090729699227de"
49
+ "gitHead": "9aff42556c0777138dae0bf6bafcba615b18d05a"
50
50
  }
@@ -236,6 +236,7 @@ type MethodParams = {
236
236
  methodName: keyof CoreApi;
237
237
  params: Parameters<CoreApi[keyof CoreApi]>[0];
238
238
  _originRequestParams: AllNetworkAddressParams;
239
+ _originalIndex: number;
239
240
  };
240
241
 
241
242
  export default class AllNetworkGetAddress extends BaseMethod<
@@ -267,9 +268,11 @@ export default class AllNetworkGetAddress extends BaseMethod<
267
268
  generateMethodName({
268
269
  network,
269
270
  payload,
271
+ originalIndex,
270
272
  }: {
271
273
  network: INetwork;
272
274
  payload: AllNetworkAddressParams;
275
+ originalIndex: number;
273
276
  }): MethodParams {
274
277
  const { name: networkName, coin } = networkAliases[network] || {
275
278
  name: network,
@@ -287,6 +290,7 @@ export default class AllNetworkGetAddress extends BaseMethod<
287
290
  originPayload: payload,
288
291
  },
289
292
  _originRequestParams: payload,
293
+ _originalIndex: originalIndex,
290
294
  };
291
295
  }
292
296
 
@@ -355,11 +359,12 @@ export default class AllNetworkGetAddress extends BaseMethod<
355
359
  const responses: AllNetworkAddress[] = [];
356
360
  const resultMap: Record<string, AllNetworkAddress> = {};
357
361
  const { bundle } = this.payload as AllNetworkGetAddressParams;
358
- const methodReduceParams = bundle
359
- .map(param =>
362
+ const methodGroups = bundle
363
+ .map((param, index) =>
360
364
  this.generateMethodName({
361
365
  network: param.network,
362
366
  payload: param,
367
+ originalIndex: index,
363
368
  })
364
369
  )
365
370
  .reduce((acc, cur) => {
@@ -370,27 +375,20 @@ export default class AllNetworkGetAddress extends BaseMethod<
370
375
  return acc;
371
376
  }, {} as Record<keyof CoreApi, MethodParams[]>);
372
377
 
373
- const methodParamsArray = Object.values(methodReduceParams);
374
-
375
- const generateResponseKey = (payload: CommonResponseParams) =>
376
- `${payload.path}-${payload.network}-${payload.chainName}-${payload.prefix}`;
377
-
378
- for (let i = 0; i < methodParamsArray.length; i++) {
379
- const methodParams = methodParamsArray[i];
380
- const { methodName } = methodParams[0];
381
-
382
- const params = {
383
- bundle: methodParams.map(param => ({
378
+ let i = 0;
379
+ for (const [methodName, params] of Object.entries(methodGroups)) {
380
+ const methodParams = {
381
+ bundle: params.map(param => ({
384
382
  ...param.params,
385
383
  })),
386
384
  };
387
385
 
388
386
  // call method
389
- const response = await this.callMethod(methodName, params);
387
+ const response = await this.callMethod(methodName as keyof CoreApi, methodParams);
390
388
 
391
- for (let i = 0; i < methodParams.length; i++) {
392
- const { _originRequestParams } = methodParams[i];
393
- const responseKey = generateResponseKey(_originRequestParams);
389
+ for (let i = 0; i < params.length; i++) {
390
+ const { _originRequestParams, _originalIndex } = params[i];
391
+ const responseKey = `${_originalIndex}`;
394
392
  resultMap[responseKey] = {
395
393
  ..._originRequestParams,
396
394
  ...response[i],
@@ -401,11 +399,11 @@ export default class AllNetworkGetAddress extends BaseMethod<
401
399
  const progress = Math.round(((i + 1) / this.payload.bundle.length) * 100);
402
400
  this.postMessage(createUiMessage(UI_REQUEST.DEVICE_PROGRESS, { progress }));
403
401
  }
402
+ i++;
404
403
  }
405
404
 
406
- for (const param of bundle) {
407
- const responseKey = generateResponseKey(param);
408
- responses.push(resultMap[responseKey]);
405
+ for (let i = 0; i < bundle.length; i++) {
406
+ responses.push(resultMap[i]);
409
407
  }
410
408
 
411
409
  return Promise.resolve(responses);
@@ -6061,7 +6061,7 @@
6061
6061
  "type": "bool",
6062
6062
  "id": 3
6063
6063
  },
6064
- "btc_test": {
6064
+ "passphrase_state": {
6065
6065
  "type": "string",
6066
6066
  "id": 8000
6067
6067
  }
@@ -6442,6 +6442,14 @@
6442
6442
  "onekey_se04_state": {
6443
6443
  "type": "OneKeySEState",
6444
6444
  "id": 624
6445
+ },
6446
+ "attach_to_pin_user": {
6447
+ "type": "bool",
6448
+ "id": 625
6449
+ },
6450
+ "unlocked_attach_pin": {
6451
+ "type": "bool",
6452
+ "id": 626
6445
6453
  }
6446
6454
  },
6447
6455
  "nested": {