@bytezhang/ledger-adapter 0.0.14 → 0.0.16

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.js CHANGED
@@ -241,7 +241,7 @@ var _LedgerAdapter = class _LedgerAdapter {
241
241
  async searchDevices() {
242
242
  await this._ensureDevicePermission();
243
243
  const devices = await this.connector.searchDevices();
244
- console.log("[LedgerAdapter] connector.searchDevices raw:", JSON.stringify(devices));
244
+ console.log("[DMK] adapter.searchDevices raw:", JSON.stringify(devices));
245
245
  for (const d of devices) {
246
246
  if (d.connectId && !this._discoveredDevices.has(d.connectId)) {
247
247
  this._discoveredDevices.set(d.connectId, this.connectorDeviceToDeviceInfo(d));
@@ -363,6 +363,7 @@ var _LedgerAdapter = class _LedgerAdapter {
363
363
  // EVM methods
364
364
  // ---------------------------------------------------------------------------
365
365
  async evmGetAddress(connectId, _deviceId, params) {
366
+ console.log("[DMK] adapter.evmGetAddress called:", { connectId, _deviceId, path: params.path, showOnDevice: params.showOnDevice, chainId: params.chainId });
366
367
  await this._ensureDevicePermission(connectId, _deviceId);
367
368
  if (!await this._verifyDeviceFingerprint(connectId, _deviceId, "evm")) {
368
369
  return (0, import_hardware_wallet_core2.failure)(import_hardware_wallet_core2.HardwareErrorCode.DeviceMismatch, "Wrong device connected");
@@ -926,6 +927,15 @@ var LedgerDeviceManager = class {
926
927
  if (resolved) return;
927
928
  resolved = true;
928
929
  this._discovered.clear();
930
+ console.log("[DMK] enumerate raw devices:", JSON.stringify(devices.map((d) => ({
931
+ id: d.id,
932
+ deviceModel: d.deviceModel,
933
+ transport: d.transport,
934
+ name: d.name,
935
+ rssi: d.rssi,
936
+ // Dump all keys to see what else is available
937
+ _keys: Object.keys(d)
938
+ }))));
929
939
  for (const d of devices) {
930
940
  this._discovered.set(d.id, d);
931
941
  }
@@ -971,7 +981,7 @@ var LedgerDeviceManager = class {
971
981
  const currentIds = new Set(devices.map((d) => d.id));
972
982
  for (const d of devices) {
973
983
  this._discovered.set(d.id, d);
974
- console.log("[LedgerDeviceManager] listen device:", JSON.stringify({
984
+ console.log("[DMK] listen device:", JSON.stringify({
975
985
  id: d.id,
976
986
  deviceModel: d.deviceModel,
977
987
  name: d.name
@@ -1065,6 +1075,13 @@ function deviceActionToPromise(action, onInteraction) {
1065
1075
  let sub;
1066
1076
  sub = action.observable.subscribe({
1067
1077
  next: (state) => {
1078
+ console.log("[DMK-Observable] state:", JSON.stringify({
1079
+ status: state.status,
1080
+ interaction: state.intermediateValue?.requiredUserInteraction,
1081
+ intermediateValue: state.intermediateValue,
1082
+ hasOutput: !!state.output,
1083
+ hasError: !!state.error
1084
+ }));
1068
1085
  if (settled) return;
1069
1086
  if (state.status === "completed") {
1070
1087
  settled = true;
@@ -1114,8 +1131,10 @@ var SignerEth = class {
1114
1131
  this._sdk = _sdk;
1115
1132
  }
1116
1133
  async getAddress(derivationPath, options) {
1134
+ const checkOnDevice = options?.checkOnDevice ?? false;
1135
+ console.log("[DMK] getAddress \u2192 DMK:", { derivationPath, checkOnDevice });
1117
1136
  const action = this._sdk.getAddress(derivationPath, {
1118
- checkOnDevice: options?.checkOnDevice ?? false
1137
+ checkOnDevice
1119
1138
  });
1120
1139
  return deviceActionToPromise(action, this.onInteraction);
1121
1140
  }
@@ -1366,6 +1385,7 @@ var LedgerConnectorBase = class {
1366
1385
  // IConnector -- Method dispatch
1367
1386
  // ---------------------------------------------------------------------------
1368
1387
  async call(sessionId, method, params) {
1388
+ console.log("[DMK] call:", method, JSON.stringify(params));
1369
1389
  switch (method) {
1370
1390
  case "evmGetAddress":
1371
1391
  return this._evmGetAddress(sessionId, params);
@@ -1423,9 +1443,11 @@ var LedgerConnectorBase = class {
1423
1443
  async _evmGetAddress(sessionId, params) {
1424
1444
  const signer = await this._getEthSigner(sessionId);
1425
1445
  const path = normalizePath(params.path);
1446
+ const checkOnDevice = params.showOnDevice ?? false;
1447
+ console.log("[DMK] _evmGetAddress \u2192 signer.getAddress:", { path, checkOnDevice });
1426
1448
  try {
1427
1449
  const result = await signer.getAddress(path, {
1428
- checkOnDevice: params.showOnDevice ?? false
1450
+ checkOnDevice
1429
1451
  });
1430
1452
  return { address: result.address, publicKey: result.publicKey };
1431
1453
  } catch (err) {