@onekeyfe/hd-core 0.1.22 → 0.1.23

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAQlC,OAAO,EACL,WAAW,EAYZ,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,UAAU,CAAC;AAE7D,OAAO,eAAe,MAAM,2BAA2B,CAAC;AAoBxD,eAAO,MAAM,OAAO,YAAmB,WAAW,iBA6KjD,CAAC;AAuKF,eAAO,MAAM,MAAM,0CAkBlB,CAAC;AAiFF,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,YAAY;IACtC,aAAa,CAAC,OAAO,EAAE,WAAW;IA+BxC,OAAO;CAGR;AAED,eAAO,MAAM,QAAQ,YAGpB,CAAC;AAEF,eAAO,MAAM,aAAa,uBAGzB,CAAC;AAMF,eAAO,MAAM,IAAI,aAAoB,eAAe,aAAa,GAAG,8BAmBnE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAQlC,OAAO,EACL,WAAW,EAYZ,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,UAAU,CAAC;AAE7D,OAAO,eAAe,MAAM,2BAA2B,CAAC;AAoBxD,eAAO,MAAM,OAAO,YAAmB,WAAW,iBAkLjD,CAAC;AAwKF,eAAO,MAAM,MAAM,0CAkBlB,CAAC;AAiFF,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,YAAY;IACtC,aAAa,CAAC,OAAO,EAAE,WAAW;IA+BxC,OAAO;CAGR;AAED,eAAO,MAAM,QAAQ,YAGpB,CAAC;AAEF,eAAO,MAAM,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ports {
10567
10567
  _runInner(fn, options) {
10568
10568
  return __awaiter(this, void 0, void 0, function* () {
10569
10569
  if (!this.isUsedHere() || this.commands.disposed) {
10570
- yield this.acquire();
10571
- try {
10572
- if (fn) {
10573
- yield this.initialize();
10570
+ const env = DataManager.getSettings('env');
10571
+ if (env !== 'react-native') {
10572
+ yield this.acquire();
10573
+ try {
10574
+ if (fn) {
10575
+ yield this.initialize();
10576
+ }
10574
10577
  }
10575
- }
10576
- catch (error) {
10577
- this.runPromise = null;
10578
- if (error instanceof hdShared.HardwareError) {
10579
- return Promise.reject(error);
10578
+ catch (error) {
10579
+ this.runPromise = null;
10580
+ if (error instanceof hdShared.HardwareError) {
10581
+ return Promise.reject(error);
10582
+ }
10583
+ return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInitializeFailed, `Initialize failed: ${error.message}, code: ${error.code}`));
10580
10584
  }
10581
- return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInitializeFailed, `Initialize failed: ${error.message}, code: ${error.code}`));
10582
10585
  }
10583
10586
  }
10584
10587
  if (options.keepSession) {
@@ -13702,7 +13705,7 @@ const callAPI = (message) => __awaiter(void 0, void 0, void 0, function* () {
13702
13705
  }
13703
13706
  callApiQueue.push(method);
13704
13707
  if (callApiQueue.length > 1) {
13705
- Log.debug('should cancel the previous method execution: ', callApiQueue);
13708
+ Log.debug('should cancel the previous method execution: ', callApiQueue.map(m => m.name));
13706
13709
  }
13707
13710
  if (pollingState[pollingId]) {
13708
13711
  pollingState[pollingId] = false;
@@ -13790,12 +13793,12 @@ const callAPI = (message) => __awaiter(void 0, void 0, void 0, function* () {
13790
13793
  method.dispose();
13791
13794
  }
13792
13795
  }
13793
- const index = messageResponse && messageResponse.id
13794
- ? callApiQueue.findIndex(m => m.responseID === messageResponse.id)
13796
+ const index = method.responseID
13797
+ ? callApiQueue.findIndex(m => m.responseID === method.responseID)
13795
13798
  : -1;
13796
13799
  if (index > -1) {
13797
13800
  callApiQueue.splice(index, 1);
13798
- Log.debug('Remove the finished method from the queue: ', callApiQueue);
13801
+ Log.debug('Remove the finished method from the queue: ', callApiQueue.map(m => m.name));
13799
13802
  }
13800
13803
  closePopup();
13801
13804
  cleanup();
@@ -13920,6 +13923,7 @@ const ensureConnected = (method, pollingId) => __awaiter(void 0, void 0, void 0,
13920
13923
  hdShared.HardwareErrorCode.BleLocationError,
13921
13924
  hdShared.HardwareErrorCode.BleDeviceNotBonded,
13922
13925
  hdShared.HardwareErrorCode.BleCharacteristicNotifyError,
13926
+ hdShared.HardwareErrorCode.BleWriteCharacteristicError,
13923
13927
  ].includes(error.errorCode)) {
13924
13928
  reject(error);
13925
13929
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-core",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
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": "^0.1.22",
29
- "@onekeyfe/hd-transport": "^0.1.22",
28
+ "@onekeyfe/hd-shared": "^0.1.23",
29
+ "@onekeyfe/hd-transport": "^0.1.23",
30
30
  "axios": "^0.27.2",
31
31
  "bignumber.js": "^9.0.2",
32
32
  "js-sha256": "^0.9.0",
@@ -37,5 +37,5 @@
37
37
  "@types/parse-uri": "^1.0.0",
38
38
  "@types/semver": "^7.3.9"
39
39
  },
40
- "gitHead": "ebc730c7be2b0d11fc8ec5f3ee08b1440d345c7a"
40
+ "gitHead": "1d460705e90267f20fff95c9cd118c8ba818c7bc"
41
41
  }
package/src/core/index.ts CHANGED
@@ -74,7 +74,10 @@ export const callAPI = async (message: CoreMessage) => {
74
74
  callApiQueue.push(method);
75
75
 
76
76
  if (callApiQueue.length > 1) {
77
- Log.debug('should cancel the previous method execution: ', callApiQueue);
77
+ Log.debug(
78
+ 'should cancel the previous method execution: ',
79
+ callApiQueue.map(m => m.name)
80
+ );
78
81
  }
79
82
 
80
83
  /**
@@ -201,13 +204,15 @@ export const callAPI = async (message: CoreMessage) => {
201
204
  }
202
205
 
203
206
  // remove method from queue
204
- const index =
205
- messageResponse && messageResponse.id
206
- ? callApiQueue.findIndex(m => m.responseID === messageResponse.id)
207
- : -1;
207
+ const index = method.responseID
208
+ ? callApiQueue.findIndex(m => m.responseID === method.responseID)
209
+ : -1;
208
210
  if (index > -1) {
209
211
  callApiQueue.splice(index, 1);
210
- Log.debug('Remove the finished method from the queue: ', callApiQueue);
212
+ Log.debug(
213
+ 'Remove the finished method from the queue: ',
214
+ callApiQueue.map(m => m.name)
215
+ );
211
216
  }
212
217
 
213
218
  closePopup();
@@ -362,6 +367,7 @@ const ensureConnected = async (method: BaseMethod, pollingId: number) => {
362
367
  HardwareErrorCode.BleLocationError,
363
368
  HardwareErrorCode.BleDeviceNotBonded,
364
369
  HardwareErrorCode.BleCharacteristicNotifyError,
370
+ HardwareErrorCode.BleWriteCharacteristicError,
365
371
  ].includes(error.errorCode)
366
372
  ) {
367
373
  reject(error);
@@ -318,22 +318,25 @@ export class Device extends EventEmitter {
318
318
 
319
319
  async _runInner<T>(fn: (() => Promise<T>) | undefined, options: RunOptions) {
320
320
  if (!this.isUsedHere() || this.commands.disposed) {
321
- await this.acquire();
322
- try {
323
- if (fn) {
324
- await this.initialize();
325
- }
326
- } catch (error) {
327
- this.runPromise = null;
328
- if (error instanceof HardwareError) {
329
- return Promise.reject(error);
321
+ const env = DataManager.getSettings('env');
322
+ if (env !== 'react-native') {
323
+ await this.acquire();
324
+ try {
325
+ if (fn) {
326
+ await this.initialize();
327
+ }
328
+ } catch (error) {
329
+ this.runPromise = null;
330
+ if (error instanceof HardwareError) {
331
+ return Promise.reject(error);
332
+ }
333
+ return Promise.reject(
334
+ ERRORS.TypedError(
335
+ HardwareErrorCode.DeviceInitializeFailed,
336
+ `Initialize failed: ${error.message as string}, code: ${error.code as string}`
337
+ )
338
+ );
330
339
  }
331
- return Promise.reject(
332
- ERRORS.TypedError(
333
- HardwareErrorCode.DeviceInitializeFailed,
334
- `Initialize failed: ${error.message as string}, code: ${error.code as string}`
335
- )
336
- );
337
340
  }
338
341
  }
339
342