@onekeyfe/hwk-ledger-adapter 1.1.27-alpha.4 → 1.1.27-alpha.5

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
@@ -1,4 +1,4 @@
1
- import { IHardwareWallet, IConnector, TransportType, UiResponseEvent, SearchDevicesOptions, DeviceInfo, Response, ChainCapability, EvmGetAddressParams, EvmAddress, EvmSignTxParams, EvmSignedTx, EvmSignMsgParams, EvmSignature, EvmSignTypedDataParams, BtcGetAddressParams, BtcAddress, BtcGetPublicKeyParams, BtcPublicKey, BtcSignTxParams, BtcSignedTx, BtcSignPsbtParams, BtcSignedPsbt, BtcSignMsgParams, BtcSignature, SolGetAddressParams, SolAddress, SolSignTxParams, SolSignedTx, SolSignMsgParams, SolSignature, TronGetAddressParams, TronAddress, TronSignTxParams, TronSignedTx, TronSignMsgParams, TronSignature, HardwareEventMap, DeviceEventListener, ChainForFingerprint, DeviceDescriptor, DeviceChangeEvent, ConnectionType, ConnectorDevice, ConnectorSession, ConnectorEventType, ConnectorEventMap, Failure, HardwareErrorCode } from '@onekeyfe/hwk-adapter-core';
1
+ import { IHardwareWallet, IConnector, TransportType, UiResponseEvent, SearchDevicesOptions, DeviceInfo, Response, ChainCapability, EvmGetAddressParams, ICommonCallParams, EvmAddress, EvmSignTxParams, EvmSignedTx, EvmSignMsgParams, EvmSignature, EvmSignTypedDataParams, BtcGetAddressParams, BtcAddress, BtcGetPublicKeyParams, BtcPublicKey, BtcSignTxParams, BtcSignedTx, BtcSignPsbtParams, BtcSignedPsbt, BtcSignMsgParams, BtcSignature, SolGetAddressParams, SolAddress, SolSignTxParams, SolSignedTx, SolSignMsgParams, SolSignature, TronGetAddressParams, TronAddress, TronSignTxParams, TronSignedTx, TronSignMsgParams, TronSignature, HardwareEventMap, DeviceEventListener, ChainForFingerprint, DeviceDescriptor, DeviceChangeEvent, ConnectionType, ConnectorDevice, ConnectorSession, ConnectorCallResult, ConnectorEventType, ConnectorEventMap, Failure, HardwareErrorCode } from '@onekeyfe/hwk-adapter-core';
2
2
  import { DeviceActionState as DeviceActionState$1, DiscoveredDevice, ExecuteDeviceActionReturnType, DeviceManagementKit } from '@ledgerhq/device-management-kit';
3
3
  import { Address, Signature, SignerEth as SignerEth$1, TypedData } from '@ledgerhq/device-signer-kit-ethereum';
4
4
  import { ContextModule } from '@ledgerhq/context-module';
@@ -100,7 +100,10 @@ declare class LedgerAdapter implements IHardwareWallet {
100
100
  private _btcHighIndexConfirmedThisSession;
101
101
  private readonly _jobQueue;
102
102
  private _doConnectAbortController;
103
- constructor(connector: IConnector);
103
+ private readonly _defaultAutoInstallApp;
104
+ constructor(connector: IConnector, options?: {
105
+ autoInstallApp?: boolean;
106
+ });
104
107
  get activeTransport(): TransportType | null;
105
108
  getAvailableTransports(): TransportType[];
106
109
  switchTransport(_type: TransportType): Promise<void>;
@@ -125,24 +128,24 @@ declare class LedgerAdapter implements IHardwareWallet {
125
128
  getDeviceInfo(connectId: string, deviceId: string): Promise<Response<DeviceInfo>>;
126
129
  getSupportedChains(): ChainCapability[];
127
130
  private callChain;
128
- evmGetAddress(connectId: string, deviceId: string, params: EvmGetAddressParams): Promise<Response<EvmAddress>>;
129
- evmSignTransaction(connectId: string, deviceId: string, params: EvmSignTxParams): Promise<Response<EvmSignedTx>>;
130
- evmSignMessage(connectId: string, deviceId: string, params: EvmSignMsgParams): Promise<Response<EvmSignature>>;
131
- evmSignTypedData(connectId: string, deviceId: string, params: EvmSignTypedDataParams): Promise<Response<EvmSignature>>;
132
- btcGetAddress(connectId: string, deviceId: string, params: BtcGetAddressParams): Promise<Response<BtcAddress>>;
133
- btcGetPublicKey(connectId: string, deviceId: string, params: BtcGetPublicKeyParams): Promise<Response<BtcPublicKey>>;
134
- btcSignTransaction(connectId: string, deviceId: string, params: BtcSignTxParams): Promise<Response<BtcSignedTx>>;
135
- btcSignPsbt(connectId: string, deviceId: string, params: BtcSignPsbtParams): Promise<Response<BtcSignedPsbt>>;
136
- btcSignMessage(connectId: string, deviceId: string, params: BtcSignMsgParams): Promise<Response<BtcSignature>>;
137
- btcGetMasterFingerprint(connectId: string, deviceId: string): Promise<Response<{
131
+ evmGetAddress(connectId: string, deviceId: string, params: EvmGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<EvmAddress>>;
132
+ evmSignTransaction(connectId: string, deviceId: string, params: EvmSignTxParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignedTx>>;
133
+ evmSignMessage(connectId: string, deviceId: string, params: EvmSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignature>>;
134
+ evmSignTypedData(connectId: string, deviceId: string, params: EvmSignTypedDataParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignature>>;
135
+ btcGetAddress(connectId: string, deviceId: string, params: BtcGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<BtcAddress>>;
136
+ btcGetPublicKey(connectId: string, deviceId: string, params: BtcGetPublicKeyParams, commonParams?: ICommonCallParams): Promise<Response<BtcPublicKey>>;
137
+ btcSignTransaction(connectId: string, deviceId: string, params: BtcSignTxParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignedTx>>;
138
+ btcSignPsbt(connectId: string, deviceId: string, params: BtcSignPsbtParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignedPsbt>>;
139
+ btcSignMessage(connectId: string, deviceId: string, params: BtcSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignature>>;
140
+ btcGetMasterFingerprint(connectId: string, deviceId: string, commonParams?: ICommonCallParams): Promise<Response<{
138
141
  masterFingerprint: string;
139
142
  }>>;
140
- solGetAddress(connectId: string, deviceId: string, params: SolGetAddressParams): Promise<Response<SolAddress>>;
141
- solSignTransaction(connectId: string, deviceId: string, params: SolSignTxParams): Promise<Response<SolSignedTx>>;
142
- solSignMessage(connectId: string, deviceId: string, params: SolSignMsgParams): Promise<Response<SolSignature>>;
143
- tronGetAddress(connectId: string, deviceId: string, params: TronGetAddressParams): Promise<Response<TronAddress>>;
144
- tronSignTransaction(connectId: string, deviceId: string, params: TronSignTxParams): Promise<Response<TronSignedTx>>;
145
- tronSignMessage(connectId: string, deviceId: string, params: TronSignMsgParams): Promise<Response<TronSignature>>;
143
+ solGetAddress(connectId: string, deviceId: string, params: SolGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<SolAddress>>;
144
+ solSignTransaction(connectId: string, deviceId: string, params: SolSignTxParams, commonParams?: ICommonCallParams): Promise<Response<SolSignedTx>>;
145
+ solSignMessage(connectId: string, deviceId: string, params: SolSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<SolSignature>>;
146
+ tronGetAddress(connectId: string, deviceId: string, params: TronGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<TronAddress>>;
147
+ tronSignTransaction(connectId: string, deviceId: string, params: TronSignTxParams, commonParams?: ICommonCallParams): Promise<Response<TronSignedTx>>;
148
+ tronSignMessage(connectId: string, deviceId: string, params: TronSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<TronSignature>>;
146
149
  installApp(connectId: string, appName: string): Promise<Response<void>>;
147
150
  listInstalledApps(connectId: string): Promise<Response<AppMetadata[]>>;
148
151
  listAvailableApps(connectId: string): Promise<Response<AppMetadata[]>>;
@@ -192,6 +195,7 @@ declare class LedgerAdapter implements IHardwareWallet {
192
195
  */
193
196
  private _gateBtcHighIndex;
194
197
  private _waitForBtcHighIndexConfirm;
198
+ private _waitForInstallAppConfirm;
195
199
  private ensureConnected;
196
200
  private _doConnect;
197
201
  private _connectFirstOrSelect;
@@ -204,6 +208,23 @@ declare class LedgerAdapter implements IHardwareWallet {
204
208
  * 3. Calls connector.call()
205
209
  * 4. On disconnect error: clears stale session, re-connects, retries once
206
210
  */
211
+ /**
212
+ * Unwrap a `ConnectorCallResult` back into the throw-based control flow this
213
+ * class relies on. On failure, rehydrate a FLAT Error (lifting `params.*`
214
+ * back to own-properties) so the downstream recovery predicates
215
+ * (`isStuckAppStateError`, `isDeviceLockedError`, …) and `mapLedgerError`
216
+ * (which read `err._tag` / `err.code` / `err.appName` / `err.originalError`)
217
+ * keep working exactly as before — the Result shape is confined to the
218
+ * connector boundary.
219
+ */
220
+ private _unwrapConnectorResult;
221
+ /**
222
+ * `connector.call` + result unwrap, optionally raced against an abort
223
+ * signal. Returns the call payload or throws the rehydrated error. All
224
+ * `this.connector.call` usage goes through here so the Result→throw seam
225
+ * lives in one place.
226
+ */
227
+ private _callConnector;
207
228
  private connectorCall;
208
229
  /**
209
230
  * Race a promise against an abort signal. On abort, rejects with
@@ -253,7 +274,6 @@ declare class LedgerAdapter implements IHardwareWallet {
253
274
  private deviceConnectHandler;
254
275
  private deviceDisconnectHandler;
255
276
  private uiEventForwarder;
256
- private appInstallProgressForwarder;
257
277
  private registerEventListeners;
258
278
  private unregisterEventListeners;
259
279
  private connectorDeviceToDeviceInfo;
@@ -433,7 +453,7 @@ declare class LedgerConnectorBase implements IConnector {
433
453
  private _watchSessionState;
434
454
  private _unwatchSessionState;
435
455
  private _handleAutonomousDisconnect;
436
- call(sessionId: string, method: string, params: unknown): Promise<unknown>;
456
+ call(sessionId: string, method: string, params: unknown): Promise<ConnectorCallResult>;
437
457
  private _dispatch;
438
458
  cancel(sessionId: string): Promise<void>;
439
459
  uiResponse(_response: UiResponseEvent): void;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { IHardwareWallet, IConnector, TransportType, UiResponseEvent, SearchDevicesOptions, DeviceInfo, Response, ChainCapability, EvmGetAddressParams, EvmAddress, EvmSignTxParams, EvmSignedTx, EvmSignMsgParams, EvmSignature, EvmSignTypedDataParams, BtcGetAddressParams, BtcAddress, BtcGetPublicKeyParams, BtcPublicKey, BtcSignTxParams, BtcSignedTx, BtcSignPsbtParams, BtcSignedPsbt, BtcSignMsgParams, BtcSignature, SolGetAddressParams, SolAddress, SolSignTxParams, SolSignedTx, SolSignMsgParams, SolSignature, TronGetAddressParams, TronAddress, TronSignTxParams, TronSignedTx, TronSignMsgParams, TronSignature, HardwareEventMap, DeviceEventListener, ChainForFingerprint, DeviceDescriptor, DeviceChangeEvent, ConnectionType, ConnectorDevice, ConnectorSession, ConnectorEventType, ConnectorEventMap, Failure, HardwareErrorCode } from '@onekeyfe/hwk-adapter-core';
1
+ import { IHardwareWallet, IConnector, TransportType, UiResponseEvent, SearchDevicesOptions, DeviceInfo, Response, ChainCapability, EvmGetAddressParams, ICommonCallParams, EvmAddress, EvmSignTxParams, EvmSignedTx, EvmSignMsgParams, EvmSignature, EvmSignTypedDataParams, BtcGetAddressParams, BtcAddress, BtcGetPublicKeyParams, BtcPublicKey, BtcSignTxParams, BtcSignedTx, BtcSignPsbtParams, BtcSignedPsbt, BtcSignMsgParams, BtcSignature, SolGetAddressParams, SolAddress, SolSignTxParams, SolSignedTx, SolSignMsgParams, SolSignature, TronGetAddressParams, TronAddress, TronSignTxParams, TronSignedTx, TronSignMsgParams, TronSignature, HardwareEventMap, DeviceEventListener, ChainForFingerprint, DeviceDescriptor, DeviceChangeEvent, ConnectionType, ConnectorDevice, ConnectorSession, ConnectorCallResult, ConnectorEventType, ConnectorEventMap, Failure, HardwareErrorCode } from '@onekeyfe/hwk-adapter-core';
2
2
  import { DeviceActionState as DeviceActionState$1, DiscoveredDevice, ExecuteDeviceActionReturnType, DeviceManagementKit } from '@ledgerhq/device-management-kit';
3
3
  import { Address, Signature, SignerEth as SignerEth$1, TypedData } from '@ledgerhq/device-signer-kit-ethereum';
4
4
  import { ContextModule } from '@ledgerhq/context-module';
@@ -100,7 +100,10 @@ declare class LedgerAdapter implements IHardwareWallet {
100
100
  private _btcHighIndexConfirmedThisSession;
101
101
  private readonly _jobQueue;
102
102
  private _doConnectAbortController;
103
- constructor(connector: IConnector);
103
+ private readonly _defaultAutoInstallApp;
104
+ constructor(connector: IConnector, options?: {
105
+ autoInstallApp?: boolean;
106
+ });
104
107
  get activeTransport(): TransportType | null;
105
108
  getAvailableTransports(): TransportType[];
106
109
  switchTransport(_type: TransportType): Promise<void>;
@@ -125,24 +128,24 @@ declare class LedgerAdapter implements IHardwareWallet {
125
128
  getDeviceInfo(connectId: string, deviceId: string): Promise<Response<DeviceInfo>>;
126
129
  getSupportedChains(): ChainCapability[];
127
130
  private callChain;
128
- evmGetAddress(connectId: string, deviceId: string, params: EvmGetAddressParams): Promise<Response<EvmAddress>>;
129
- evmSignTransaction(connectId: string, deviceId: string, params: EvmSignTxParams): Promise<Response<EvmSignedTx>>;
130
- evmSignMessage(connectId: string, deviceId: string, params: EvmSignMsgParams): Promise<Response<EvmSignature>>;
131
- evmSignTypedData(connectId: string, deviceId: string, params: EvmSignTypedDataParams): Promise<Response<EvmSignature>>;
132
- btcGetAddress(connectId: string, deviceId: string, params: BtcGetAddressParams): Promise<Response<BtcAddress>>;
133
- btcGetPublicKey(connectId: string, deviceId: string, params: BtcGetPublicKeyParams): Promise<Response<BtcPublicKey>>;
134
- btcSignTransaction(connectId: string, deviceId: string, params: BtcSignTxParams): Promise<Response<BtcSignedTx>>;
135
- btcSignPsbt(connectId: string, deviceId: string, params: BtcSignPsbtParams): Promise<Response<BtcSignedPsbt>>;
136
- btcSignMessage(connectId: string, deviceId: string, params: BtcSignMsgParams): Promise<Response<BtcSignature>>;
137
- btcGetMasterFingerprint(connectId: string, deviceId: string): Promise<Response<{
131
+ evmGetAddress(connectId: string, deviceId: string, params: EvmGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<EvmAddress>>;
132
+ evmSignTransaction(connectId: string, deviceId: string, params: EvmSignTxParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignedTx>>;
133
+ evmSignMessage(connectId: string, deviceId: string, params: EvmSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignature>>;
134
+ evmSignTypedData(connectId: string, deviceId: string, params: EvmSignTypedDataParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignature>>;
135
+ btcGetAddress(connectId: string, deviceId: string, params: BtcGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<BtcAddress>>;
136
+ btcGetPublicKey(connectId: string, deviceId: string, params: BtcGetPublicKeyParams, commonParams?: ICommonCallParams): Promise<Response<BtcPublicKey>>;
137
+ btcSignTransaction(connectId: string, deviceId: string, params: BtcSignTxParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignedTx>>;
138
+ btcSignPsbt(connectId: string, deviceId: string, params: BtcSignPsbtParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignedPsbt>>;
139
+ btcSignMessage(connectId: string, deviceId: string, params: BtcSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignature>>;
140
+ btcGetMasterFingerprint(connectId: string, deviceId: string, commonParams?: ICommonCallParams): Promise<Response<{
138
141
  masterFingerprint: string;
139
142
  }>>;
140
- solGetAddress(connectId: string, deviceId: string, params: SolGetAddressParams): Promise<Response<SolAddress>>;
141
- solSignTransaction(connectId: string, deviceId: string, params: SolSignTxParams): Promise<Response<SolSignedTx>>;
142
- solSignMessage(connectId: string, deviceId: string, params: SolSignMsgParams): Promise<Response<SolSignature>>;
143
- tronGetAddress(connectId: string, deviceId: string, params: TronGetAddressParams): Promise<Response<TronAddress>>;
144
- tronSignTransaction(connectId: string, deviceId: string, params: TronSignTxParams): Promise<Response<TronSignedTx>>;
145
- tronSignMessage(connectId: string, deviceId: string, params: TronSignMsgParams): Promise<Response<TronSignature>>;
143
+ solGetAddress(connectId: string, deviceId: string, params: SolGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<SolAddress>>;
144
+ solSignTransaction(connectId: string, deviceId: string, params: SolSignTxParams, commonParams?: ICommonCallParams): Promise<Response<SolSignedTx>>;
145
+ solSignMessage(connectId: string, deviceId: string, params: SolSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<SolSignature>>;
146
+ tronGetAddress(connectId: string, deviceId: string, params: TronGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<TronAddress>>;
147
+ tronSignTransaction(connectId: string, deviceId: string, params: TronSignTxParams, commonParams?: ICommonCallParams): Promise<Response<TronSignedTx>>;
148
+ tronSignMessage(connectId: string, deviceId: string, params: TronSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<TronSignature>>;
146
149
  installApp(connectId: string, appName: string): Promise<Response<void>>;
147
150
  listInstalledApps(connectId: string): Promise<Response<AppMetadata[]>>;
148
151
  listAvailableApps(connectId: string): Promise<Response<AppMetadata[]>>;
@@ -192,6 +195,7 @@ declare class LedgerAdapter implements IHardwareWallet {
192
195
  */
193
196
  private _gateBtcHighIndex;
194
197
  private _waitForBtcHighIndexConfirm;
198
+ private _waitForInstallAppConfirm;
195
199
  private ensureConnected;
196
200
  private _doConnect;
197
201
  private _connectFirstOrSelect;
@@ -204,6 +208,23 @@ declare class LedgerAdapter implements IHardwareWallet {
204
208
  * 3. Calls connector.call()
205
209
  * 4. On disconnect error: clears stale session, re-connects, retries once
206
210
  */
211
+ /**
212
+ * Unwrap a `ConnectorCallResult` back into the throw-based control flow this
213
+ * class relies on. On failure, rehydrate a FLAT Error (lifting `params.*`
214
+ * back to own-properties) so the downstream recovery predicates
215
+ * (`isStuckAppStateError`, `isDeviceLockedError`, …) and `mapLedgerError`
216
+ * (which read `err._tag` / `err.code` / `err.appName` / `err.originalError`)
217
+ * keep working exactly as before — the Result shape is confined to the
218
+ * connector boundary.
219
+ */
220
+ private _unwrapConnectorResult;
221
+ /**
222
+ * `connector.call` + result unwrap, optionally raced against an abort
223
+ * signal. Returns the call payload or throws the rehydrated error. All
224
+ * `this.connector.call` usage goes through here so the Result→throw seam
225
+ * lives in one place.
226
+ */
227
+ private _callConnector;
207
228
  private connectorCall;
208
229
  /**
209
230
  * Race a promise against an abort signal. On abort, rejects with
@@ -253,7 +274,6 @@ declare class LedgerAdapter implements IHardwareWallet {
253
274
  private deviceConnectHandler;
254
275
  private deviceDisconnectHandler;
255
276
  private uiEventForwarder;
256
- private appInstallProgressForwarder;
257
277
  private registerEventListeners;
258
278
  private unregisterEventListeners;
259
279
  private connectorDeviceToDeviceInfo;
@@ -433,7 +453,7 @@ declare class LedgerConnectorBase implements IConnector {
433
453
  private _watchSessionState;
434
454
  private _unwatchSessionState;
435
455
  private _handleAutonomousDisconnect;
436
- call(sessionId: string, method: string, params: unknown): Promise<unknown>;
456
+ call(sessionId: string, method: string, params: unknown): Promise<ConnectorCallResult>;
437
457
  private _dispatch;
438
458
  cancel(sessionId: string): Promise<void>;
439
459
  uiResponse(_response: UiResponseEvent): void;