Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LedgerSigner.connect always throws an error #3

Open
prestwich opened this issue Sep 13, 2021 · 6 comments
Open

LedgerSigner.connect always throws an error #3

prestwich opened this issue Sep 13, 2021 · 6 comments

Comments

@prestwich
Copy link

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/ [email protected] on an M1 macbook

@ricmoo
Copy link
Member

ricmoo commented Sep 13, 2021

The hardware-wallets package is quite out of date right now as a result of Chrome removing u2f support, the new LedgerLive web-socket proxy work-around and some major bumps in dependencies.

I'm working on this as an ancillary package so I can recruit the help of others to keep it maintained, but also trying to get v6 out, so I won't be able to get to this right away. :s

@timrowley-dev
Copy link

The hardware-wallets package is quite out of date right now as a result of Chrome removing u2f support, the new LedgerLive web-socket proxy work-around and some major bumps in dependencies.

I'm working on this as an ancillary package so I can recruit the help of others to keep it maintained, but also trying to get v6 out, so I won't be able to get to this right away. :s

So would it be safe to say the Ledger package is broken right now? I can't connect at all, even when trying to change the type to "hid" I get:
-> ledger = new LedgerSigner(provider, "hid");
Uncaught (in promise) Error: unknown or unsupported type (argument="type", value="hid", code=INVALID_ARGUMENT, version=hardware-wallets/5.4.0)

@FrozenKiwi
Copy link

Hi @ricmoo - is the ancillary package available? I've run into issued deploying to polygon. I'd be happy to fork hardware-signers and submit a fix; forking the whole ethers package isn't a big deal but it does make it slightly more complicated to refer to my custom package while waiting for the PR to merge.

The package is mostly working, but ledger has an issue with chain Ids > 127: https://github.com/LedgerHQ/ledgerjs-legacy/blob/6d655aa89b748e50ae15c0cfb30c08f2215f6d84/packages/web3-subprovider/src/index.js#L143

@prestwich
Copy link
Author

prestwich commented 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

@mdnorman
Copy link

mdnorman commented 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?

@ricmoo ricmoo transferred this issue from ethers-io/ethers.js Jan 18, 2023
@ricmoo ricmoo transferred this issue from ethers-io/ext-signer Jul 21, 2023
@ricmoo
Copy link
Member

ricmoo commented Jul 21, 2023

Can you try out this latest version and see if you still have issues with it? I believe the underlying issue may have been fixed by Ledger, as this package creates a new Eth object for each necessary call, and it has worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants