@onekeyfe/hwk-ledger-adapter 1.2.8-alpha.119 → 1.2.8-alpha.120

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/index.d.mts CHANGED
@@ -541,8 +541,8 @@ declare class LedgerConnectorBase implements IConnector {
541
541
  protected _emit<K extends ConnectorEventType>(event: K, data: ConnectorEventMap[K]): void;
542
542
  /**
543
543
  * Return a per-call ctx with the chain's Ledger app name pre-bound to
544
- * UI prompts and wrapError, so chain handlers don't need to repeat the name.
545
- * Falls through unchanged for unknown methods.
544
+ * wrapError, so chain handlers don't need to repeat `{ defaultAppName: 'X' }`
545
+ * at every catch site. Falls through unchanged for unknown methods.
546
546
  */
547
547
  private _ctxForMethod;
548
548
  private _wrapError;
package/dist/index.d.ts CHANGED
@@ -541,8 +541,8 @@ declare class LedgerConnectorBase implements IConnector {
541
541
  protected _emit<K extends ConnectorEventType>(event: K, data: ConnectorEventMap[K]): void;
542
542
  /**
543
543
  * Return a per-call ctx with the chain's Ledger app name pre-bound to
544
- * UI prompts and wrapError, so chain handlers don't need to repeat the name.
545
- * Falls through unchanged for unknown methods.
544
+ * wrapError, so chain handlers don't need to repeat `{ defaultAppName: 'X' }`
545
+ * at every catch site. Falls through unchanged for unknown methods.
546
546
  */
547
547
  private _ctxForMethod;
548
548
  private _wrapError;
package/dist/index.js CHANGED
@@ -1043,7 +1043,6 @@ var _LedgerAdapter = class _LedgerAdapter {
1043
1043
  // need to subscribe in one place. The AppInstallProgress variant re-keys
1044
1044
  // sessionId to connectId via `_sessions`, and drops if no mapping exists.
1045
1045
  this.uiEventForwarder = (event) => {
1046
- const operationId = this._activeOperationId();
1047
1046
  if (event.type === import_hwk_adapter_core4.EConnectorInteraction.AppInstallProgress) {
1048
1047
  let connectId;
1049
1048
  for (const [cid, sid] of this._sessions) {
@@ -1072,7 +1071,6 @@ var _LedgerAdapter = class _LedgerAdapter {
1072
1071
  this._installProgressLastEmittedValue = progress;
1073
1072
  this.emitter.emit("ui-event", {
1074
1073
  type: import_hwk_adapter_core4.EConnectorInteraction.AppInstallProgress,
1075
- ...operationId ? { operationId } : {},
1076
1074
  payload: {
1077
1075
  connectId,
1078
1076
  appName,
@@ -1081,7 +1079,7 @@ var _LedgerAdapter = class _LedgerAdapter {
1081
1079
  });
1082
1080
  return;
1083
1081
  }
1084
- this.emitter.emit("ui-event", operationId ? { ...event, operationId } : event);
1082
+ this.emitter.emit("ui-event", event);
1085
1083
  };
1086
1084
  this.connector = connector;
1087
1085
  this._defaultAutoInstallApp = options?.autoInstallApp ?? false;
@@ -2071,6 +2069,12 @@ var _LedgerAdapter = class _LedgerAdapter {
2071
2069
  } else {
2072
2070
  this._jobQueue.cancelActiveAndPending(void 0, userAbortReason);
2073
2071
  }
2072
+ if (resolvedConnectId) {
2073
+ const sessionId = this._sessions.get(resolvedConnectId) ?? resolvedConnectId;
2074
+ void this.connector.cancel(sessionId);
2075
+ } else {
2076
+ for (const sid of this._sessions.values()) void this.connector.cancel(sid);
2077
+ }
2074
2078
  const connectingConnectId = this._connectingConnectId;
2075
2079
  const targetKeys = new Set(
2076
2080
  [
@@ -2080,14 +2084,6 @@ var _LedgerAdapter = class _LedgerAdapter {
2080
2084
  ].filter(Boolean)
2081
2085
  );
2082
2086
  const ownsPendingConnect = !connectId || activeJobId !== void 0 && queueKeys.has(activeJobId) || connectingConnectId !== void 0 && targetKeys.has(connectingConnectId);
2083
- if (activeJobId === void 0 || ownsPendingConnect) {
2084
- if (resolvedConnectId) {
2085
- const sessionId = this._sessions.get(resolvedConnectId) ?? resolvedConnectId;
2086
- void this.connector.cancel(sessionId);
2087
- } else {
2088
- for (const sid of this._sessions.values()) void this.connector.cancel(sid);
2089
- }
2090
- }
2091
2087
  if (this._connectingPromise && ownsPendingConnect) {
2092
2088
  this._doConnectAbortController?.abort(userAbortReason);
2093
2089
  }
@@ -2270,7 +2266,7 @@ var _LedgerAdapter = class _LedgerAdapter {
2270
2266
  } catch (err) {
2271
2267
  this.emitter.emit(import_hwk_adapter_core4.UI_REQUEST.CLOSE_UI_WINDOW, {
2272
2268
  type: import_hwk_adapter_core4.UI_REQUEST.CLOSE_UI_WINDOW,
2273
- payload: { operationId }
2269
+ payload: {}
2274
2270
  });
2275
2271
  throw Object.assign(new Error("User cancelled Ledger connection"), {
2276
2272
  _tag: ERROR_TAG.UserAborted,
@@ -2334,7 +2330,7 @@ var _LedgerAdapter = class _LedgerAdapter {
2334
2330
  } catch (err) {
2335
2331
  this.emitter.emit(import_hwk_adapter_core4.UI_REQUEST.CLOSE_UI_WINDOW, {
2336
2332
  type: import_hwk_adapter_core4.UI_REQUEST.CLOSE_UI_WINDOW,
2337
- payload: { operationId }
2333
+ payload: {}
2338
2334
  });
2339
2335
  return false;
2340
2336
  }
@@ -2372,7 +2368,7 @@ var _LedgerAdapter = class _LedgerAdapter {
2372
2368
  } catch (err) {
2373
2369
  this.emitter.emit(import_hwk_adapter_core4.UI_REQUEST.CLOSE_UI_WINDOW, {
2374
2370
  type: import_hwk_adapter_core4.UI_REQUEST.CLOSE_UI_WINDOW,
2375
- payload: { operationId }
2371
+ payload: {}
2376
2372
  });
2377
2373
  return false;
2378
2374
  }
@@ -3168,7 +3164,7 @@ var _LedgerAdapter = class _LedgerAdapter {
3168
3164
  }
3169
3165
  this.emitter.emit(import_hwk_adapter_core4.UI_REQUEST.CLOSE_UI_WINDOW, {
3170
3166
  type: import_hwk_adapter_core4.UI_REQUEST.CLOSE_UI_WINDOW,
3171
- payload: { operationId }
3167
+ payload: {}
3172
3168
  });
3173
3169
  return await this._runConnectorCall(
3174
3170
  resolvedConnectId,
@@ -3235,7 +3231,7 @@ var _LedgerAdapter = class _LedgerAdapter {
3235
3231
  if (err?._tag === import_hwk_adapter_core4.UI_REQUEST_PREEMPTED_TAG) {
3236
3232
  this.emitter.emit(import_hwk_adapter_core4.UI_REQUEST.CLOSE_UI_WINDOW, {
3237
3233
  type: import_hwk_adapter_core4.UI_REQUEST.CLOSE_UI_WINDOW,
3238
- payload: { operationId }
3234
+ payload: {}
3239
3235
  });
3240
3236
  throw Object.assign(new Error("Device permission request superseded"), {
3241
3237
  _tag: ERROR_TAG.UserAborted,
@@ -4972,14 +4968,6 @@ var METHOD_PREFIX_TO_APP_NAME = {
4972
4968
  tron: "Tron",
4973
4969
  zcash: "Zcash"
4974
4970
  };
4975
- function withOpenAppName(event, data, appName) {
4976
- if (event !== "ui-event") return data;
4977
- const uiEvent = data;
4978
- if (uiEvent.type !== import_hwk_adapter_core13.EConnectorInteraction.ConfirmOpenApp || uiEvent.payload.appName) {
4979
- return data;
4980
- }
4981
- return { ...uiEvent, payload: { ...uiEvent.payload, appName } };
4982
- }
4983
4971
  var HARDWARE_ERROR_CODE_VALUES = new Set(
4984
4972
  Object.values(import_hwk_adapter_core13.HardwareErrorCode).filter((value) => typeof value === "number")
4985
4973
  );
@@ -5788,8 +5776,8 @@ var LedgerConnectorBase = class {
5788
5776
  // ---------------------------------------------------------------------------
5789
5777
  /**
5790
5778
  * Return a per-call ctx with the chain's Ledger app name pre-bound to
5791
- * UI prompts and wrapError, so chain handlers don't need to repeat the name.
5792
- * Falls through unchanged for unknown methods.
5779
+ * wrapError, so chain handlers don't need to repeat `{ defaultAppName: 'X' }`
5780
+ * at every catch site. Falls through unchanged for unknown methods.
5793
5781
  */
5794
5782
  _ctxForMethod(method) {
5795
5783
  const prefix = /^(evm|btc|sol|tron|zcash)/.exec(method)?.[1];
@@ -5797,8 +5785,7 @@ var LedgerConnectorBase = class {
5797
5785
  if (!defaultAppName) return this._ctx;
5798
5786
  return {
5799
5787
  ...this._ctx,
5800
- wrapError: (err, opts) => this._wrapError(err, { defaultAppName, ...opts }),
5801
- emit: (event, data) => this._ctx.emit(event, withOpenAppName(event, data, defaultAppName))
5788
+ wrapError: (err, opts) => this._wrapError(err, { defaultAppName, ...opts })
5802
5789
  };
5803
5790
  }
5804
5791
  _wrapError(err, opts) {