near / wallet-selector

This is a wallet selector modal that allows users to interact with NEAR dApps with a selection of available wallets.
https://near.github.io/wallet-selector/
Apache License 2.0
143 stars 146 forks source link

Ledger Support Errors #411

Closed gagdiez closed 2 years ago

gagdiez commented 2 years ago

I have found the following error when using `import

{ setupLedger }

from "@near-wallet-selector/ledger";`. Particularly, the error is:

@parcel/core: Failed to resolve '@ledgerhq/devices/hid-framing' from './node_modules/@ledgerhq/hw-transport-webhid/lib-es/TransportWebHID.js'

To reproduce simply add the ledger package and try to use it.

gagdiez commented 2 years ago

A discord user has reported another error: https://discord.com/channels/490367152054992913/542945453533036544/1009482022290464819

kujtimprenkuSQA commented 2 years ago

Hey, @gagdiez thank you for raising this issue.

After some investigation yesterday in the issue we found that this error is showing up only with parcel and not in other bundlers.

This issue seems to be on the latest version of @ledgerhq/hw-transport-webhid which internaly depends on @ledgerhq/devices and also is a dependency in our @near-wallet-selector/ledger package.

We found this suggestion here to be a good solution: https://github.com/LedgerHQ/ledger-live/issues/763#issuecomment-1211834941.

Basically this si what is being suggested there: adding parcel-style alias to the package.json seems to help:

{ 
  ...
  "alias": {
    "@ledgerhq/devices": "@ledgerhq/devices/lib-es"
  }
}

See their docs on using these packages with parcel: https://developers.ledger.com/docs/transport/web-hid-usb/#packagejson


About the reported issue on discord, there was not enough information to know what the exact issue was so I asked them to open a new issue here in this repo.

gagdiez commented 2 years ago

Thanks, adding the alias resulted in a different error, which I solved by adding a second alias:

"process": { "global": "{}" }

Maybe it would be useful to add that in the README (#414 )

kujtimprenkuSQA commented 2 years ago

Was the error about process caused by @near-walllet-selector/ledger ?

The error about process might be related to something else, can you please share more details or a screenshot?

gagdiez commented 2 years ago

I further tested it, and the error was not being originated from the wallet-selector/ledger.

I saw your comment in the PR, with the Known Issue being added to the Ledger page. I would still recommend to bring it to the front README.md so people can find it easier.

kujtimprenkuSQA commented 2 years ago

Hey, @gagdiez after more investigation on the issue which was happening with dApps that use parcel as a bundler I found that removing the caret (^) symbol from @ledgerhq/hw-transport-webhid and @ledgerhq/hw-transport on our side avoids these errors which are caused by the latest versions of these dependencies.

I also addressed the issue reported on discord. I believe we will need to publish a minor release.

Thank you for your feedback again.