@onekeyfe/hwk-ledger-adapter 1.1.29 → 1.1.30

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,5 +1,5 @@
1
1
  import * as _onekeyfe_hwk_adapter_core from '@onekeyfe/hwk-adapter-core';
2
- 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
+ import { IHardwareWallet, IConnector, TransportType, UiResponseEvent, SearchDevicesOptions, DeviceInfo, Response, ChainCapability, NullableCallArg, IHardwareCallParams, EvmGetAddressParams, EvmAddress, EvmSignTxLedgerParams, EvmSignedTx, EvmSignMsgParams, EvmSignature, EvmSignTypedDataParams, BtcGetAddressParams, BtcAddress, BtcGetPublicKeyParams, BtcPublicKey, BtcSignTxParams, BtcSignedTx, BtcSignPsbtParams, BtcSignedPsbt, BtcSignMsgParams, BtcSignature, IHardwareCommonCallParams, 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';
3
3
  import { DeviceActionState as DeviceActionState$1, DiscoveredDevice, ExecuteDeviceActionReturnType, DeviceManagementKit } from '@ledgerhq/device-management-kit';
4
4
  import { Address, Signature, SignerEth as SignerEth$1, TypedData } from '@ledgerhq/device-signer-kit-ethereum';
5
5
  import { ContextModule } from '@ledgerhq/context-module';
@@ -91,6 +91,8 @@ interface LedgerDeviceInfo extends FirmwareVersion {
91
91
  seFlagsHex: string;
92
92
  }
93
93
 
94
+ type LedgerCallParams<T> = NullableCallArg<IHardwareCallParams<T>>;
95
+ type LedgerCommonParams = NullableCallArg<IHardwareCommonCallParams>;
94
96
  declare class LedgerAdapter implements IHardwareWallet {
95
97
  readonly vendor: "ledger";
96
98
  private readonly connector;
@@ -133,24 +135,27 @@ declare class LedgerAdapter implements IHardwareWallet {
133
135
  getSupportedChains(): ChainCapability[];
134
136
  allNetworkGetAddress: (connectId: string, _deviceId: string, params: _onekeyfe_hwk_adapter_core.AllNetworkGetAddressParams) => Promise<Response<_onekeyfe_hwk_adapter_core.AllNetworkAddressResponse[]>>;
135
137
  private callChain;
136
- evmGetAddress(connectId: string, deviceId: string, params: EvmGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<EvmAddress>>;
137
- evmSignTransaction(connectId: string, deviceId: string, params: EvmSignTxParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignedTx>>;
138
- evmSignMessage(connectId: string, deviceId: string, params: EvmSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignature>>;
139
- evmSignTypedData(connectId: string, deviceId: string, params: EvmSignTypedDataParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignature>>;
140
- btcGetAddress(connectId: string, deviceId: string, params: BtcGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<BtcAddress>>;
141
- btcGetPublicKey(connectId: string, deviceId: string, params: BtcGetPublicKeyParams, commonParams?: ICommonCallParams): Promise<Response<BtcPublicKey>>;
142
- btcSignTransaction(connectId: string, deviceId: string, params: BtcSignTxParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignedTx>>;
143
- btcSignPsbt(connectId: string, deviceId: string, params: BtcSignPsbtParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignedPsbt>>;
144
- btcSignMessage(connectId: string, deviceId: string, params: BtcSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignature>>;
145
- btcGetMasterFingerprint(connectId: string, deviceId: string, commonParams?: ICommonCallParams): Promise<Response<{
138
+ private static normalizeCallArgs;
139
+ private static splitCommonParams;
140
+ private callChainWithMergedParams;
141
+ evmGetAddress(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<EvmGetAddressParams>): Promise<Response<EvmAddress>>;
142
+ evmSignTransaction(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<EvmSignTxLedgerParams>): Promise<Response<EvmSignedTx>>;
143
+ evmSignMessage(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<EvmSignMsgParams>): Promise<Response<EvmSignature>>;
144
+ evmSignTypedData(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<EvmSignTypedDataParams>): Promise<Response<EvmSignature>>;
145
+ btcGetAddress(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<BtcGetAddressParams>): Promise<Response<BtcAddress>>;
146
+ btcGetPublicKey(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<BtcGetPublicKeyParams>): Promise<Response<BtcPublicKey>>;
147
+ btcSignTransaction(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<BtcSignTxParams>): Promise<Response<BtcSignedTx>>;
148
+ btcSignPsbt(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<BtcSignPsbtParams>): Promise<Response<BtcSignedPsbt>>;
149
+ btcSignMessage(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<BtcSignMsgParams>): Promise<Response<BtcSignature>>;
150
+ btcGetMasterFingerprint(connectId?: string | null, deviceId?: string | null, params?: LedgerCommonParams): Promise<Response<{
146
151
  masterFingerprint: string;
147
152
  }>>;
148
- solGetAddress(connectId: string, deviceId: string, params: SolGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<SolAddress>>;
149
- solSignTransaction(connectId: string, deviceId: string, params: SolSignTxParams, commonParams?: ICommonCallParams): Promise<Response<SolSignedTx>>;
150
- solSignMessage(connectId: string, deviceId: string, params: SolSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<SolSignature>>;
151
- tronGetAddress(connectId: string, deviceId: string, params: TronGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<TronAddress>>;
152
- tronSignTransaction(connectId: string, deviceId: string, params: TronSignTxParams, commonParams?: ICommonCallParams): Promise<Response<TronSignedTx>>;
153
- tronSignMessage(connectId: string, deviceId: string, params: TronSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<TronSignature>>;
153
+ solGetAddress(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<SolGetAddressParams>): Promise<Response<SolAddress>>;
154
+ solSignTransaction(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<SolSignTxParams>): Promise<Response<SolSignedTx>>;
155
+ solSignMessage(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<SolSignMsgParams>): Promise<Response<SolSignature>>;
156
+ tronGetAddress(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<TronGetAddressParams>): Promise<Response<TronAddress>>;
157
+ tronSignTransaction(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<TronSignTxParams>): Promise<Response<TronSignedTx>>;
158
+ tronSignMessage(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<TronSignMsgParams>): Promise<Response<TronSignature>>;
154
159
  installApp(connectId: string, appName: string): Promise<Response<void>>;
155
160
  listInstalledApps(connectId: string): Promise<Response<AppMetadata[]>>;
156
161
  listInstalledNames(connectId: string): Promise<Response<string[]>>;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _onekeyfe_hwk_adapter_core from '@onekeyfe/hwk-adapter-core';
2
- 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
+ import { IHardwareWallet, IConnector, TransportType, UiResponseEvent, SearchDevicesOptions, DeviceInfo, Response, ChainCapability, NullableCallArg, IHardwareCallParams, EvmGetAddressParams, EvmAddress, EvmSignTxLedgerParams, EvmSignedTx, EvmSignMsgParams, EvmSignature, EvmSignTypedDataParams, BtcGetAddressParams, BtcAddress, BtcGetPublicKeyParams, BtcPublicKey, BtcSignTxParams, BtcSignedTx, BtcSignPsbtParams, BtcSignedPsbt, BtcSignMsgParams, BtcSignature, IHardwareCommonCallParams, 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';
3
3
  import { DeviceActionState as DeviceActionState$1, DiscoveredDevice, ExecuteDeviceActionReturnType, DeviceManagementKit } from '@ledgerhq/device-management-kit';
4
4
  import { Address, Signature, SignerEth as SignerEth$1, TypedData } from '@ledgerhq/device-signer-kit-ethereum';
5
5
  import { ContextModule } from '@ledgerhq/context-module';
@@ -91,6 +91,8 @@ interface LedgerDeviceInfo extends FirmwareVersion {
91
91
  seFlagsHex: string;
92
92
  }
93
93
 
94
+ type LedgerCallParams<T> = NullableCallArg<IHardwareCallParams<T>>;
95
+ type LedgerCommonParams = NullableCallArg<IHardwareCommonCallParams>;
94
96
  declare class LedgerAdapter implements IHardwareWallet {
95
97
  readonly vendor: "ledger";
96
98
  private readonly connector;
@@ -133,24 +135,27 @@ declare class LedgerAdapter implements IHardwareWallet {
133
135
  getSupportedChains(): ChainCapability[];
134
136
  allNetworkGetAddress: (connectId: string, _deviceId: string, params: _onekeyfe_hwk_adapter_core.AllNetworkGetAddressParams) => Promise<Response<_onekeyfe_hwk_adapter_core.AllNetworkAddressResponse[]>>;
135
137
  private callChain;
136
- evmGetAddress(connectId: string, deviceId: string, params: EvmGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<EvmAddress>>;
137
- evmSignTransaction(connectId: string, deviceId: string, params: EvmSignTxParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignedTx>>;
138
- evmSignMessage(connectId: string, deviceId: string, params: EvmSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignature>>;
139
- evmSignTypedData(connectId: string, deviceId: string, params: EvmSignTypedDataParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignature>>;
140
- btcGetAddress(connectId: string, deviceId: string, params: BtcGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<BtcAddress>>;
141
- btcGetPublicKey(connectId: string, deviceId: string, params: BtcGetPublicKeyParams, commonParams?: ICommonCallParams): Promise<Response<BtcPublicKey>>;
142
- btcSignTransaction(connectId: string, deviceId: string, params: BtcSignTxParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignedTx>>;
143
- btcSignPsbt(connectId: string, deviceId: string, params: BtcSignPsbtParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignedPsbt>>;
144
- btcSignMessage(connectId: string, deviceId: string, params: BtcSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignature>>;
145
- btcGetMasterFingerprint(connectId: string, deviceId: string, commonParams?: ICommonCallParams): Promise<Response<{
138
+ private static normalizeCallArgs;
139
+ private static splitCommonParams;
140
+ private callChainWithMergedParams;
141
+ evmGetAddress(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<EvmGetAddressParams>): Promise<Response<EvmAddress>>;
142
+ evmSignTransaction(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<EvmSignTxLedgerParams>): Promise<Response<EvmSignedTx>>;
143
+ evmSignMessage(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<EvmSignMsgParams>): Promise<Response<EvmSignature>>;
144
+ evmSignTypedData(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<EvmSignTypedDataParams>): Promise<Response<EvmSignature>>;
145
+ btcGetAddress(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<BtcGetAddressParams>): Promise<Response<BtcAddress>>;
146
+ btcGetPublicKey(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<BtcGetPublicKeyParams>): Promise<Response<BtcPublicKey>>;
147
+ btcSignTransaction(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<BtcSignTxParams>): Promise<Response<BtcSignedTx>>;
148
+ btcSignPsbt(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<BtcSignPsbtParams>): Promise<Response<BtcSignedPsbt>>;
149
+ btcSignMessage(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<BtcSignMsgParams>): Promise<Response<BtcSignature>>;
150
+ btcGetMasterFingerprint(connectId?: string | null, deviceId?: string | null, params?: LedgerCommonParams): Promise<Response<{
146
151
  masterFingerprint: string;
147
152
  }>>;
148
- solGetAddress(connectId: string, deviceId: string, params: SolGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<SolAddress>>;
149
- solSignTransaction(connectId: string, deviceId: string, params: SolSignTxParams, commonParams?: ICommonCallParams): Promise<Response<SolSignedTx>>;
150
- solSignMessage(connectId: string, deviceId: string, params: SolSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<SolSignature>>;
151
- tronGetAddress(connectId: string, deviceId: string, params: TronGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<TronAddress>>;
152
- tronSignTransaction(connectId: string, deviceId: string, params: TronSignTxParams, commonParams?: ICommonCallParams): Promise<Response<TronSignedTx>>;
153
- tronSignMessage(connectId: string, deviceId: string, params: TronSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<TronSignature>>;
153
+ solGetAddress(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<SolGetAddressParams>): Promise<Response<SolAddress>>;
154
+ solSignTransaction(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<SolSignTxParams>): Promise<Response<SolSignedTx>>;
155
+ solSignMessage(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<SolSignMsgParams>): Promise<Response<SolSignature>>;
156
+ tronGetAddress(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<TronGetAddressParams>): Promise<Response<TronAddress>>;
157
+ tronSignTransaction(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<TronSignTxParams>): Promise<Response<TronSignedTx>>;
158
+ tronSignMessage(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<TronSignMsgParams>): Promise<Response<TronSignature>>;
154
159
  installApp(connectId: string, appName: string): Promise<Response<void>>;
155
160
  listInstalledApps(connectId: string): Promise<Response<AppMetadata[]>>;
156
161
  listInstalledNames(connectId: string): Promise<Response<string[]>>;
package/dist/index.js CHANGED
@@ -541,10 +541,10 @@ function debugError(...args) {
541
541
  var LEDGER_BTC_NETWORK_COIN_MAP = {
542
542
  tbtc: "Testnet",
543
543
  bch: "Bcash",
544
- doge: "Dogecoin",
545
544
  ltc: "Litecoin",
546
545
  neurai: "Neurai"
547
546
  };
547
+ var LEDGER_UNSUPPORTED_ALLNETWORK_NETWORKS = /* @__PURE__ */ new Set(["doge", "dogecoin"]);
548
548
  function createAllNetworkGetAddress({
549
549
  callChain,
550
550
  getChainFingerprint
@@ -555,49 +555,46 @@ function createAllNetworkGetAddress({
555
555
  const commonParams = {
556
556
  autoInstallApp: params.autoInstallApp
557
557
  };
558
- const responses = [];
559
558
  const chainFingerprints = /* @__PURE__ */ new Map();
560
- for (const item of params.bundle) {
561
- const method = getAllNetworkMethod(item);
562
- if (!method) {
563
- responses.push(buildUnsupportedMethodResponse(item));
564
- } else {
565
- const chain = getFingerprintChain(method);
559
+ const result = await (0, import_hwk_adapter_core2.runAllNetworkGetAddress)({
560
+ connectId,
561
+ deviceId: _deviceId,
562
+ params,
563
+ normalizeItem: normalizeLedgerAllNetworkItem,
564
+ buildUnsupportedNetworkResponse: (item) => isUnsupportedLedgerAllNetworkNetwork(item) ? buildUnsupportedNetworkResponse(item) : void 0,
565
+ callItem: async ({ method, chain, item }) => {
566
566
  const itemDeviceId = getItemDeviceId(item) ?? chainFingerprints.get(chain) ?? "";
567
- const normalizedItem = normalizeLedgerAllNetworkItem(method, item);
568
- const response = await callAllNetworkItem(
567
+ return callAllNetworkMethod(
569
568
  callChain,
570
- getChainFingerprint,
571
569
  connectId,
572
570
  itemDeviceId,
573
- chain,
574
571
  method,
575
- normalizedItem,
572
+ item,
576
573
  commonParams,
577
- installContext,
578
- chainFingerprints
574
+ installContext
575
+ );
576
+ },
577
+ attachIdentity: async ({ item, chain, payload }) => attachLedgerIdentity(
578
+ getChainFingerprint,
579
+ connectId,
580
+ item,
581
+ chain,
582
+ payload,
583
+ chainFingerprints
584
+ ),
585
+ shouldAbortBundle: isTopLevelAllNetworkFailure,
586
+ buildTopLevelFailure: (response) => {
587
+ const code = response.payload?.code ?? import_hwk_adapter_core2.HardwareErrorCode.DeviceMismatch;
588
+ return (0, import_hwk_adapter_core2.failure)(
589
+ code,
590
+ response.payload?.error ?? "All-network get-address aborted",
591
+ response.payload?.params
579
592
  );
580
- if (isTopLevelAllNetworkFailure(response)) {
581
- const code = response.payload?.code ?? import_hwk_adapter_core2.HardwareErrorCode.DeviceMismatch;
582
- const result2 = (0, import_hwk_adapter_core2.failure)(
583
- code,
584
- response.payload?.error ?? "All-network get-address aborted",
585
- response.payload?.params
586
- );
587
- debugLog("[LedgerAdapter][RES]", {
588
- method: "allNetworkGetAddress",
589
- success: false,
590
- payload: result2
591
- });
592
- return result2;
593
- }
594
- responses.push(response);
595
593
  }
596
- }
597
- const result = (0, import_hwk_adapter_core2.success)(responses);
594
+ });
598
595
  debugLog("[LedgerAdapter][RES]", {
599
596
  method: "allNetworkGetAddress",
600
- success: true,
597
+ success: result.success,
601
598
  payload: result
602
599
  });
603
600
  return result;
@@ -614,25 +611,16 @@ function getItemDeviceId(item) {
614
611
  const { deviceId } = item;
615
612
  return typeof deviceId === "string" && deviceId.length > 0 ? deviceId : void 0;
616
613
  }
617
- function getAllNetworkMethod(item) {
618
- switch (item.methodName) {
619
- case "evmGetAddress":
620
- case "btcGetAddress":
621
- case "btcGetPublicKey":
622
- case "solGetAddress":
623
- case "tronGetAddress":
624
- return item.methodName;
625
- default:
626
- return void 0;
627
- }
614
+ function isUnsupportedLedgerAllNetworkNetwork(item) {
615
+ return LEDGER_UNSUPPORTED_ALLNETWORK_NETWORKS.has(item.network.toLowerCase());
628
616
  }
629
- function buildUnsupportedMethodResponse(item) {
617
+ function buildUnsupportedNetworkResponse(item) {
630
618
  return {
631
619
  ...item,
632
620
  success: false,
633
621
  payload: {
634
- code: import_hwk_adapter_core2.HardwareErrorCode.InvalidParams,
635
- error: `Unsupported allNetwork method: ${String(item.methodName)}`
622
+ code: import_hwk_adapter_core2.HardwareErrorCode.ChainNotSupported,
623
+ error: `Ledger allNetwork does not support ${item.network.toLowerCase() === "doge" ? "Dogecoin" : item.network}`
636
624
  }
637
625
  };
638
626
  }
@@ -647,21 +635,8 @@ function normalizeLedgerAllNetworkItem(method, item) {
647
635
  const coin = LEDGER_BTC_NETWORK_COIN_MAP[item.network];
648
636
  return coin ? { ...item, coin } : item;
649
637
  }
650
- async function callAllNetworkItem(callChain, getChainFingerprint, connectId, deviceId, chain, method, item, commonParams, installContext, chainFingerprints) {
651
- const response = await callAllNetworkMethod(
652
- callChain,
653
- connectId,
654
- deviceId,
655
- method,
656
- item,
657
- commonParams,
658
- installContext
659
- );
660
- if (!response.success) {
661
- return { ...item, success: false, payload: response.payload };
662
- }
663
- const payload = response.payload;
664
- const fingerprint = deviceId || chainFingerprints.get(chain) || await bootstrapChainFingerprint(getChainFingerprint, connectId, chain);
638
+ async function attachLedgerIdentity(getChainFingerprint, connectId, item, chain, payload, chainFingerprints) {
639
+ const fingerprint = getItemDeviceId(item) || chainFingerprints.get(chain) || await bootstrapChainFingerprint(getChainFingerprint, connectId, chain);
665
640
  if (!fingerprint) {
666
641
  return buildFingerprintBootstrapFailure(item, chain);
667
642
  }
@@ -671,6 +646,12 @@ async function callAllNetworkItem(callChain, getChainFingerprint, connectId, dev
671
646
  success: true,
672
647
  payload: {
673
648
  ...payload,
649
+ deviceIdentity: {
650
+ vendor: "ledger",
651
+ type: "chainFingerprint",
652
+ chain,
653
+ value: fingerprint
654
+ },
674
655
  chainFingerprint: fingerprint,
675
656
  chainFingerprintChain: chain
676
657
  }
@@ -690,23 +671,6 @@ function buildFingerprintBootstrapFailure(item, chain) {
690
671
  }
691
672
  };
692
673
  }
693
- function getFingerprintChain(method) {
694
- switch (method) {
695
- case "evmGetAddress":
696
- return "evm";
697
- case "btcGetAddress":
698
- case "btcGetPublicKey":
699
- return "btc";
700
- case "solGetAddress":
701
- return "sol";
702
- case "tronGetAddress":
703
- return "tron";
704
- default:
705
- throw Object.assign(new Error(`Unsupported allNetwork method: ${method}`), {
706
- code: import_hwk_adapter_core2.HardwareErrorCode.InvalidParams
707
- });
708
- }
709
- }
710
674
  async function callAllNetworkMethod(callChain, connectId, deviceId, method, item, commonParams, installContext) {
711
675
  switch (method) {
712
676
  case "evmGetAddress":
@@ -1112,176 +1076,196 @@ var _LedgerAdapter = class _LedgerAdapter {
1112
1076
  return this.errorToFailure(err);
1113
1077
  }
1114
1078
  }
1079
+ static normalizeCallArgs(connectId, deviceId, params) {
1080
+ return {
1081
+ connectId: connectId ?? "",
1082
+ deviceId: deviceId ?? "",
1083
+ params: params ?? {}
1084
+ };
1085
+ }
1086
+ static splitCommonParams(params) {
1087
+ if (params && typeof params === "object") {
1088
+ const {
1089
+ autoInstallApp,
1090
+ passphraseState: _passphraseState,
1091
+ useEmptyPassphrase: _useEmptyPassphrase,
1092
+ ...rest
1093
+ } = params;
1094
+ return {
1095
+ commonParams: {
1096
+ autoInstallApp: typeof autoInstallApp === "boolean" ? autoInstallApp : void 0
1097
+ },
1098
+ rest
1099
+ };
1100
+ }
1101
+ return { commonParams: {}, rest: params ?? {} };
1102
+ }
1103
+ callChainWithMergedParams(connectId, deviceId, chain, method, params) {
1104
+ const normalized = _LedgerAdapter.normalizeCallArgs(connectId, deviceId, params);
1105
+ const { commonParams, rest } = _LedgerAdapter.splitCommonParams(normalized.params);
1106
+ return this.callChain(
1107
+ normalized.connectId,
1108
+ normalized.deviceId,
1109
+ chain,
1110
+ method,
1111
+ rest,
1112
+ commonParams
1113
+ );
1114
+ }
1115
1115
  // ---------------------------------------------------------------------------
1116
1116
  // EVM chain methods
1117
1117
  // ---------------------------------------------------------------------------
1118
- evmGetAddress(connectId, deviceId, params, commonParams) {
1119
- return this.callChain(
1118
+ evmGetAddress(connectId, deviceId, params) {
1119
+ return this.callChainWithMergedParams(
1120
1120
  connectId,
1121
1121
  deviceId,
1122
1122
  "evm",
1123
1123
  "evmGetAddress",
1124
- params,
1125
- commonParams
1124
+ params
1126
1125
  );
1127
1126
  }
1128
- evmSignTransaction(connectId, deviceId, params, commonParams) {
1129
- return this.callChain(
1127
+ evmSignTransaction(connectId, deviceId, params) {
1128
+ return this.callChainWithMergedParams(
1130
1129
  connectId,
1131
1130
  deviceId,
1132
1131
  "evm",
1133
1132
  "evmSignTransaction",
1134
- params,
1135
- commonParams
1133
+ params
1136
1134
  );
1137
1135
  }
1138
- evmSignMessage(connectId, deviceId, params, commonParams) {
1139
- return this.callChain(
1136
+ evmSignMessage(connectId, deviceId, params) {
1137
+ return this.callChainWithMergedParams(
1140
1138
  connectId,
1141
1139
  deviceId,
1142
1140
  "evm",
1143
1141
  "evmSignMessage",
1144
- params,
1145
- commonParams
1142
+ params
1146
1143
  );
1147
1144
  }
1148
- evmSignTypedData(connectId, deviceId, params, commonParams) {
1149
- return this.callChain(
1145
+ evmSignTypedData(connectId, deviceId, params) {
1146
+ return this.callChainWithMergedParams(
1150
1147
  connectId,
1151
1148
  deviceId,
1152
1149
  "evm",
1153
1150
  "evmSignTypedData",
1154
- params,
1155
- commonParams
1151
+ params
1156
1152
  );
1157
1153
  }
1158
1154
  // ---------------------------------------------------------------------------
1159
1155
  // BTC chain methods
1160
1156
  // ---------------------------------------------------------------------------
1161
- btcGetAddress(connectId, deviceId, params, commonParams) {
1162
- return this.callChain(
1157
+ btcGetAddress(connectId, deviceId, params) {
1158
+ return this.callChainWithMergedParams(
1163
1159
  connectId,
1164
1160
  deviceId,
1165
1161
  "btc",
1166
1162
  "btcGetAddress",
1167
- params,
1168
- commonParams
1163
+ params
1169
1164
  );
1170
1165
  }
1171
- btcGetPublicKey(connectId, deviceId, params, commonParams) {
1172
- return this.callChain(
1166
+ btcGetPublicKey(connectId, deviceId, params) {
1167
+ return this.callChainWithMergedParams(
1173
1168
  connectId,
1174
1169
  deviceId,
1175
1170
  "btc",
1176
1171
  "btcGetPublicKey",
1177
- params,
1178
- commonParams
1172
+ params
1179
1173
  );
1180
1174
  }
1181
- btcSignTransaction(connectId, deviceId, params, commonParams) {
1182
- return this.callChain(
1175
+ btcSignTransaction(connectId, deviceId, params) {
1176
+ return this.callChainWithMergedParams(
1183
1177
  connectId,
1184
1178
  deviceId,
1185
1179
  "btc",
1186
1180
  "btcSignTransaction",
1187
- params,
1188
- commonParams
1181
+ params
1189
1182
  );
1190
1183
  }
1191
- btcSignPsbt(connectId, deviceId, params, commonParams) {
1192
- return this.callChain(
1184
+ btcSignPsbt(connectId, deviceId, params) {
1185
+ return this.callChainWithMergedParams(
1193
1186
  connectId,
1194
1187
  deviceId,
1195
1188
  "btc",
1196
1189
  "btcSignPsbt",
1197
- params,
1198
- commonParams
1190
+ params
1199
1191
  );
1200
1192
  }
1201
- btcSignMessage(connectId, deviceId, params, commonParams) {
1202
- return this.callChain(
1193
+ btcSignMessage(connectId, deviceId, params) {
1194
+ return this.callChainWithMergedParams(
1203
1195
  connectId,
1204
1196
  deviceId,
1205
1197
  "btc",
1206
1198
  "btcSignMessage",
1207
- params,
1208
- commonParams
1199
+ params
1209
1200
  );
1210
1201
  }
1211
- btcGetMasterFingerprint(connectId, deviceId, commonParams) {
1212
- return this.callChain(
1202
+ btcGetMasterFingerprint(connectId, deviceId, params) {
1203
+ return this.callChainWithMergedParams(
1213
1204
  connectId,
1214
1205
  deviceId,
1215
1206
  "btc",
1216
1207
  "btcGetMasterFingerprint",
1217
- {},
1218
- commonParams
1208
+ params
1219
1209
  );
1220
1210
  }
1221
1211
  // ---------------------------------------------------------------------------
1222
1212
  // SOL chain methods
1223
1213
  // ---------------------------------------------------------------------------
1224
- solGetAddress(connectId, deviceId, params, commonParams) {
1225
- return this.callChain(
1214
+ solGetAddress(connectId, deviceId, params) {
1215
+ return this.callChainWithMergedParams(
1226
1216
  connectId,
1227
1217
  deviceId,
1228
1218
  "sol",
1229
1219
  "solGetAddress",
1230
- params,
1231
- commonParams
1220
+ params
1232
1221
  );
1233
1222
  }
1234
- solSignTransaction(connectId, deviceId, params, commonParams) {
1235
- return this.callChain(
1223
+ solSignTransaction(connectId, deviceId, params) {
1224
+ return this.callChainWithMergedParams(
1236
1225
  connectId,
1237
1226
  deviceId,
1238
1227
  "sol",
1239
1228
  "solSignTransaction",
1240
- params,
1241
- commonParams
1229
+ params
1242
1230
  );
1243
1231
  }
1244
- solSignMessage(connectId, deviceId, params, commonParams) {
1245
- return this.callChain(
1232
+ solSignMessage(connectId, deviceId, params) {
1233
+ return this.callChainWithMergedParams(
1246
1234
  connectId,
1247
1235
  deviceId,
1248
1236
  "sol",
1249
1237
  "solSignMessage",
1250
- params,
1251
- commonParams
1238
+ params
1252
1239
  );
1253
1240
  }
1254
1241
  // ---------------------------------------------------------------------------
1255
1242
  // TRON chain methods
1256
1243
  // ---------------------------------------------------------------------------
1257
- tronGetAddress(connectId, deviceId, params, commonParams) {
1258
- return this.callChain(
1244
+ tronGetAddress(connectId, deviceId, params) {
1245
+ return this.callChainWithMergedParams(
1259
1246
  connectId,
1260
1247
  deviceId,
1261
1248
  "tron",
1262
1249
  "tronGetAddress",
1263
- params,
1264
- commonParams
1250
+ params
1265
1251
  );
1266
1252
  }
1267
- tronSignTransaction(connectId, deviceId, params, commonParams) {
1268
- return this.callChain(
1253
+ tronSignTransaction(connectId, deviceId, params) {
1254
+ return this.callChainWithMergedParams(
1269
1255
  connectId,
1270
1256
  deviceId,
1271
1257
  "tron",
1272
1258
  "tronSignTransaction",
1273
- params,
1274
- commonParams
1259
+ params
1275
1260
  );
1276
1261
  }
1277
- tronSignMessage(connectId, deviceId, params, commonParams) {
1278
- return this.callChain(
1262
+ tronSignMessage(connectId, deviceId, params) {
1263
+ return this.callChainWithMergedParams(
1279
1264
  connectId,
1280
1265
  deviceId,
1281
1266
  "tron",
1282
1267
  "tronSignMessage",
1283
- params,
1284
- commonParams
1268
+ params
1285
1269
  );
1286
1270
  }
1287
1271
  // ---------------------------------------------------------------------------
@@ -1628,7 +1612,7 @@ var _LedgerAdapter = class _LedgerAdapter {
1628
1612
  if (devices.length === 0) {
1629
1613
  for (let i = 0; i < 3 && !internalSignal.aborted; i += 1) {
1630
1614
  await new Promise((resolve) => {
1631
- setTimeout(resolve, 1e3);
1615
+ setTimeout(resolve, import_hwk_adapter_core3.DEVICE_CONNECT_RETRY_DELAY_MS);
1632
1616
  });
1633
1617
  devices = await this.searchDevices();
1634
1618
  if (devices.length > 0) break;
@@ -4199,7 +4183,7 @@ var LedgerConnectorBase = class {
4199
4183
  async searchDevices() {
4200
4184
  const dm = await this._getDeviceManager();
4201
4185
  const descriptors = await this._discoverDescriptors(dm);
4202
- const resolvedDescriptors = descriptors.map((d) => ({
4186
+ const resolvedDescriptors = descriptors.filter((d) => !(0, import_hwk_adapter_core13.isKnownNonTargetHardwareVendor)(d, "ledger")).map((d) => ({
4203
4187
  descriptor: d,
4204
4188
  connectId: this._resolveConnectId(d)
4205
4189
  }));