@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.mjs CHANGED
@@ -207,7 +207,7 @@ var _LedgerAdapter = class _LedgerAdapter {
207
207
  async searchDevices() {
208
208
  await this._ensureDevicePermission();
209
209
  const devices = await this.connector.searchDevices();
210
- console.log("[LedgerAdapter] connector.searchDevices raw:", JSON.stringify(devices));
210
+ console.log("[DMK] adapter.searchDevices raw:", JSON.stringify(devices));
211
211
  for (const d of devices) {
212
212
  if (d.connectId && !this._discoveredDevices.has(d.connectId)) {
213
213
  this._discoveredDevices.set(d.connectId, this.connectorDeviceToDeviceInfo(d));
@@ -329,6 +329,7 @@ var _LedgerAdapter = class _LedgerAdapter {
329
329
  // EVM methods
330
330
  // ---------------------------------------------------------------------------
331
331
  async evmGetAddress(connectId, _deviceId, params) {
332
+ console.log("[DMK] adapter.evmGetAddress called:", { connectId, _deviceId, path: params.path, showOnDevice: params.showOnDevice, chainId: params.chainId });
332
333
  await this._ensureDevicePermission(connectId, _deviceId);
333
334
  if (!await this._verifyDeviceFingerprint(connectId, _deviceId, "evm")) {
334
335
  return failure(HardwareErrorCode2.DeviceMismatch, "Wrong device connected");
@@ -892,6 +893,15 @@ var LedgerDeviceManager = class {
892
893
  if (resolved) return;
893
894
  resolved = true;
894
895
  this._discovered.clear();
896
+ console.log("[DMK] enumerate raw devices:", JSON.stringify(devices.map((d) => ({
897
+ id: d.id,
898
+ deviceModel: d.deviceModel,
899
+ transport: d.transport,
900
+ name: d.name,
901
+ rssi: d.rssi,
902
+ // Dump all keys to see what else is available
903
+ _keys: Object.keys(d)
904
+ }))));
895
905
  for (const d of devices) {
896
906
  this._discovered.set(d.id, d);
897
907
  }
@@ -937,7 +947,7 @@ var LedgerDeviceManager = class {
937
947
  const currentIds = new Set(devices.map((d) => d.id));
938
948
  for (const d of devices) {
939
949
  this._discovered.set(d.id, d);
940
- console.log("[LedgerDeviceManager] listen device:", JSON.stringify({
950
+ console.log("[DMK] listen device:", JSON.stringify({
941
951
  id: d.id,
942
952
  deviceModel: d.deviceModel,
943
953
  name: d.name
@@ -1031,6 +1041,13 @@ function deviceActionToPromise(action, onInteraction) {
1031
1041
  let sub;
1032
1042
  sub = action.observable.subscribe({
1033
1043
  next: (state) => {
1044
+ console.log("[DMK-Observable] state:", JSON.stringify({
1045
+ status: state.status,
1046
+ interaction: state.intermediateValue?.requiredUserInteraction,
1047
+ intermediateValue: state.intermediateValue,
1048
+ hasOutput: !!state.output,
1049
+ hasError: !!state.error
1050
+ }));
1034
1051
  if (settled) return;
1035
1052
  if (state.status === "completed") {
1036
1053
  settled = true;
@@ -1080,8 +1097,10 @@ var SignerEth = class {
1080
1097
  this._sdk = _sdk;
1081
1098
  }
1082
1099
  async getAddress(derivationPath, options) {
1100
+ const checkOnDevice = options?.checkOnDevice ?? false;
1101
+ console.log("[DMK] getAddress \u2192 DMK:", { derivationPath, checkOnDevice });
1083
1102
  const action = this._sdk.getAddress(derivationPath, {
1084
- checkOnDevice: options?.checkOnDevice ?? false
1103
+ checkOnDevice
1085
1104
  });
1086
1105
  return deviceActionToPromise(action, this.onInteraction);
1087
1106
  }
@@ -1332,6 +1351,7 @@ var LedgerConnectorBase = class {
1332
1351
  // IConnector -- Method dispatch
1333
1352
  // ---------------------------------------------------------------------------
1334
1353
  async call(sessionId, method, params) {
1354
+ console.log("[DMK] call:", method, JSON.stringify(params));
1335
1355
  switch (method) {
1336
1356
  case "evmGetAddress":
1337
1357
  return this._evmGetAddress(sessionId, params);
@@ -1389,9 +1409,11 @@ var LedgerConnectorBase = class {
1389
1409
  async _evmGetAddress(sessionId, params) {
1390
1410
  const signer = await this._getEthSigner(sessionId);
1391
1411
  const path = normalizePath(params.path);
1412
+ const checkOnDevice = params.showOnDevice ?? false;
1413
+ console.log("[DMK] _evmGetAddress \u2192 signer.getAddress:", { path, checkOnDevice });
1392
1414
  try {
1393
1415
  const result = await signer.getAddress(path, {
1394
- checkOnDevice: params.showOnDevice ?? false
1416
+ checkOnDevice
1395
1417
  });
1396
1418
  return { address: result.address, publicKey: result.publicKey };
1397
1419
  } catch (err) {