shapeshift / web

ShapeShift Web
https://app.shapeshift.com
MIT License
157 stars 180 forks source link

Handle multiple Ledgers and account management #6814

Open woodenfurniture opened 2 weeks ago

woodenfurniture commented 2 weeks ago

Overview

The ledger device ID is the same for every device, meaning query cache using wallet deviceId will be invalid if a different ledger is connected.

References and additional details

Originally noted here : https://github.com/shapeshift/web/pull/6780#discussion_r1588979619

Acceptance Criteria

Account management operates as intended across different ledger devices for all states and user flows.

Need By Date

No response

Screenshots/Mockups

No response

Estimated effort

No response

woodenfurniture commented 2 days ago

Ledger does not ship with a uniquely identifiable serial number on the device - they are all 0001 (privacy reasons possibly?).

Regardless, it seems storing account configuration keyed by wallet device ID is not desirable because its possible for a user to wipe their device and reinitialize with totally different seed, which when reconnected would have accountIds configured which do not exist for the device. This may not matter as far as account balances etc, since those accountIds wont be accessible by the device so will not appear in-app (we'd have to verify this is the case), but the configured chainIds that are visible throughout the app would have to check what accounts are actually accessible at runtime so as not to display a chainId for an account that is not longer accessible by the device corresponding to the device ID.

We may want to try one of the following:

For reference, this is whats available for a given ledger device:

Image

woodenfurniture commented 1 day ago

To spike:

We can use the first connected account ID for each connected chain to detect if the wallet has changed since the seed it tied to the account derivation.

If the user connects a ledger, ask them to open one of the connectd apps, check the account ID matches, then conditionally proceed or push them into a new connect chains flow.

woodenfurniture commented 1 day ago
  1. Add band-aid text saying something like "Multiple ledger devices are currently not supported, click here to clear your cache" but nicer text
  2. Fast follow with solution