question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

LedgerSigner.connect always throws an error

See original GitHub issue

Describe the bug calling connect on a LedgerSigner instance throws an error

Likely related to the underlying HID transport holding the device, and the new signer making a second acquisition attempt that fails

Reproduction steps

import { LedgerSigner } from '@ethersproject/hardware-wallets'
import * as ethers from 'ethers'

const provider = ethers.providers.getDefaultProvider()
const signer = new LedgerSigner()

signer.connect(provider)

/// Error: cannot open device with path

Environment ts-node w/ node@16.6.2 on an M1 macbook

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
mdnormancommented, Mar 9, 2022

@prestwich thanks! I had issues with the 5.5.0 version as well, and your version seems to work for me. I was thinking of doing something similar after spending a while digging into the @ledgerhq code, so I appreciate it!

Can a contributor get this change added?

1reaction
prestwichcommented, Jan 9, 2022

I fixed the issue in Node. This makes ledger Eth objects into singletons, so they are reused by LedgerSigner. This allows instantiation of multiple LedgerSigners, as well as using the Signer.connect() function without error.

I have not yet tested these changes in browser, as that would require updating u2f. Tried to design eth.ts it such that a build system could simply swap out ledger-transport.ts for browser-ledger-transport.ts at build time without issues, and such that we could add more transports easily

Uploading as a zip file, as I can’t find contributor documentation on build/formatting/lint systems. This is intended for packages/hardware-wallets/src.ts

src.ts.zip

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create LedgerSigner instances form a Ledger wallet
I want to create Ledger signer instances from ledger wallet. However, I always got an error that says "cannot open device".
Read more >
Error: invalid object key - from - using Ledger Signer #936
Hi, I have noticed there is a similar issue to #862 when using the LedgerSigner. "@ethersproject/hardware-wallets": "^5.0.1", ...
Read more >
Documentation - Ethers.js
signer.connect( provider ) ⇒ Signer. Sub-classes must implement this, however they may simply throw an error if changing providers is not supported.
Read more >
@ethersproject/wallet | Yarn - Package Manager
A complete Ethereum wallet implementation and utilities in JavaScript (and TypeScript). Features: Keep your private keys in your client, safe and sound; Import ......
Read more >
Sorry, connection failed - error message in Ledger Live
This might be a simple troubleshooting step but can sometimes be the solution to connecting here. For Windows users only - always run...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found