Skip to content

Allow multiple Ledger & Trezor hardware accounts#10505

Merged
darkwing merged 14 commits intoMetaMask:developfrom
darkwing:ledger-multiple-accounts
Mar 9, 2021
Merged

Allow multiple Ledger & Trezor hardware accounts#10505
darkwing merged 14 commits intoMetaMask:developfrom
darkwing:ledger-multiple-accounts

Conversation

@darkwing
Copy link
Copy Markdown
Contributor

@darkwing darkwing commented Feb 23, 2021

Fix:

Explanation:

This PR will allow users to add multiple hardware wallet accounts and keep them for any given amount of time. While that in itself is awesome, this should also prevent the need for users to re-add tokens each time they use a different hardware wallet account.

Manual testing steps:

  • Click "Connect Hardware Wallet", unlock your Ledger, choose "Ledger", click multiple address checkboxes, and Add them
  • You should see the accounts you had selected
  • Send ETH between them, use the test dapp to sign, etc.
  • Remove individual accounts, ensure correct account is removed
  • (Do the same with Trezor)

To do:

  • Disable checkboxes in the account listing for addresses that have already been added
  • Remove the need for setTimeout
  • What do we want to do re: naming if the user has two Ledgers and add two accounts with the same index?

This PR will require an update from both of our keyring repos:

@darkwing darkwing requested a review from a team as a code owner February 23, 2021 17:25
@darkwing darkwing marked this pull request as draft February 23, 2021 17:25
@github-actions
Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@darkwing darkwing force-pushed the ledger-multiple-accounts branch 3 times, most recently from 6584bab to 7315ba1 Compare February 24, 2021 03:02
@darkwing darkwing force-pushed the ledger-multiple-accounts branch 3 times, most recently from 7e989be to 07c8a3b Compare February 24, 2021 19:00
@darkwing darkwing dismissed a stale review via 5742d7e February 24, 2021 19:55
@darkwing darkwing force-pushed the ledger-multiple-accounts branch from 07c8a3b to 5742d7e Compare February 24, 2021 19:55
@darkwing darkwing dismissed a stale review via fef5139 February 24, 2021 20:54
@darkwing darkwing requested review from brad-decker and removed request for NiranjanaBinoy February 24, 2021 21:29
@darkwing darkwing marked this pull request as ready for review February 24, 2021 21:30
Copy link
Copy Markdown
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this out yesterday and today, and tried adding/removing accounts, switching between wallets (Ledger Nano S => Ledger X => Trezor model T). Overall this is pretty slick!

The one additional thing I noticed was that routing was pretty... strange when using this. I'm not sure where this routing logic is - I didn't see it the diff so maybe it's out of scope of this PR? But here are the issues I ran into:

  • When navigating to the "connect hardware" page with accounts already connected, I'd see a flash of the normal page rendered, then a loading screen, then the account list. If the intent is to auto-navigate to the account list, it should go straight to the loading screen without that initial render if possible.
  • When clicking "Forget device", all of my hardware wallet accounts remained in the account list. When I click on these accounts, I'd be redirected to the connect hardware page. This prevents me from viewing the account balance and transaction history, and prevents removing the account. I would expect either that the accounts would be removed when clicking "Forget device", or that I'd at least be able to look at them. This weird in-between state is unexpected, to me at least.

Edit: After revisiting that second scenario, I think I misunderstood what was going on. Here are updated notes on the 'Forget device' UX:

  • After clicking 'Forget device', I was routed to the connect hardware landing page (where you choose between Ledger and Trezor). From this page, attempting to navigate to any account in the account menu fails. It just refreshes the page.
  • When trying to remove an account from a hardware wallet that has been forgotten, the removal succeeds but the remove account modal stays visible, despite the account having been removed already. It stays up until dismissing/cancelling the removal.
  • After removing a hardware wallet account from a forgotten device, the next attempt to connect accounts on this device will also automatically disconnect any accounts that remain from prior to the device being forgotten.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to ensure that all accounts are on the current page here. This tests that at least one account is on the current page.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed all this :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it preserves the selected accounts on pages that aren't visible. This could be confusing 🤔

But it's required to connect a set of accounts that spans multiple pages...

I guess this is fine for now, but the design is sub-optimal. We should have some indicator that there are accounts selected that aren't shown. Or maybe a list of all selected accounts? Not sure.

@darkwing darkwing force-pushed the ledger-multiple-accounts branch 2 times, most recently from 529583f to 3e502fd Compare March 2, 2021 20:35
@jekkos
Copy link
Copy Markdown

jekkos commented Mar 2, 2021

HI I have tried to run your latest change here, but getting a white dialog (nothing loads). The debug screen show the following

Screenshot from 2021-03-03 00-27-57

jgallegos91
jgallegos91 previously approved these changes Mar 3, 2021
Copy link
Copy Markdown
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM aside from the extraneous prop!

The one remaining nice-to-have for this PR would be having some representation of the HD path in the auto-generated account names, but that doesn't need to block. The routing / "Forget device" issues are probably best handled in a separate PR, since they're pre-existing.

@darkwing darkwing force-pushed the ledger-multiple-accounts branch from 77bfdbb to edca0b6 Compare March 5, 2021 18:57
@darkwing darkwing force-pushed the ledger-multiple-accounts branch 2 times, most recently from 066419d to 353c2c6 Compare March 8, 2021 19:13
@darkwing darkwing requested a review from Gudahtt March 8, 2021 19:51
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious that hdPath wasn't being set before 🤔
I investigated this and found that the HD path was being set correctly when we retrieve a page of accounts, and it persists in the keyring after that point. So luckily it's almost always set correctly.

I did discover that on develop if you add an account on one path, start the connect flow again, switch paths, then cancel, it leaves the pre-existing account but in a broken state. So that's interesting. That is fixed by this PR though.

Gudahtt
Gudahtt previously approved these changes Mar 9, 2021
Copy link
Copy Markdown
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

The localization isn't great here because we're still baking in the assumption that it makes sense to attach an equivalent to "(legacy)" as a suffix in every locale. We'd have to generate the entire account name with a localized message to ensure this is flexible enough to handle any locale (e.g. have the message be $1 $2 (legacy), where $1 and $2 are "Ledger" and "1" respectively for the first Ledger account). But this wasn't localized well to begin with, so doesn't seem worth blocking on at this point.

@darkwing darkwing changed the title Allow multiple ledger hardware accounts Allow multiple Ledger & Trezor hardware accounts Mar 9, 2021
@darkwing
Copy link
Copy Markdown
Contributor Author

darkwing commented Mar 9, 2021

Updated to throw instead of reject.

Gudahtt
Gudahtt previously approved these changes Mar 9, 2021
@darkwing darkwing merged commit 92680cf into MetaMask:develop Mar 9, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Mar 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants