@onekeyfe/hwk-ledger-adapter 1.2.8-alpha.112 → 1.2.8-alpha.114

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
- * wrapError, so chain handlers don't need to repeat `{ defaultAppName: 'X' }`
545
- * at every catch site. Falls through unchanged for unknown methods.
544
+ * UI prompts and wrapError, so chain handlers don't need to repeat the name.
545
+ * 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
- * wrapError, so chain handlers don't need to repeat `{ defaultAppName: 'X' }`
545
- * at every catch site. Falls through unchanged for unknown methods.
544
+ * UI prompts and wrapError, so chain handlers don't need to repeat the name.
545
+ * Falls through unchanged for unknown methods.
546
546
  */
547
547
  private _ctxForMethod;
548
548
  private _wrapError;
package/dist/index.js CHANGED
@@ -4968,6 +4968,14 @@ var METHOD_PREFIX_TO_APP_NAME = {
4968
4968
  tron: "Tron",
4969
4969
  zcash: "Zcash"
4970
4970
  };
4971
+ function withOpenAppName(event, data, appName) {
4972
+ if (event !== "ui-event") return data;
4973
+ const uiEvent = data;
4974
+ if (uiEvent.type !== import_hwk_adapter_core13.EConnectorInteraction.ConfirmOpenApp || uiEvent.payload.appName) {
4975
+ return data;
4976
+ }
4977
+ return { ...uiEvent, payload: { ...uiEvent.payload, appName } };
4978
+ }
4971
4979
  var HARDWARE_ERROR_CODE_VALUES = new Set(
4972
4980
  Object.values(import_hwk_adapter_core13.HardwareErrorCode).filter((value) => typeof value === "number")
4973
4981
  );
@@ -5776,8 +5784,8 @@ var LedgerConnectorBase = class {
5776
5784
  // ---------------------------------------------------------------------------
5777
5785
  /**
5778
5786
  * Return a per-call ctx with the chain's Ledger app name pre-bound to
5779
- * wrapError, so chain handlers don't need to repeat `{ defaultAppName: 'X' }`
5780
- * at every catch site. Falls through unchanged for unknown methods.
5787
+ * UI prompts and wrapError, so chain handlers don't need to repeat the name.
5788
+ * Falls through unchanged for unknown methods.
5781
5789
  */
5782
5790
  _ctxForMethod(method) {
5783
5791
  const prefix = /^(evm|btc|sol|tron|zcash)/.exec(method)?.[1];
@@ -5785,7 +5793,8 @@ var LedgerConnectorBase = class {
5785
5793
  if (!defaultAppName) return this._ctx;
5786
5794
  return {
5787
5795
  ...this._ctx,
5788
- wrapError: (err, opts) => this._wrapError(err, { defaultAppName, ...opts })
5796
+ wrapError: (err, opts) => this._wrapError(err, { defaultAppName, ...opts }),
5797
+ emit: (event, data) => this._ctx.emit(event, withOpenAppName(event, data, defaultAppName))
5789
5798
  };
5790
5799
  }
5791
5800
  _wrapError(err, opts) {