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

Repeater Connection: Forward requests to new default when default is switched off during dApp connection flow #3462

Merged
merged 9 commits into from
Jun 15, 2023

Conversation

Shadowfiend
Copy link
Contributor

@Shadowfiend Shadowfiend commented Jun 8, 2023

Adds the ability to pass through to the next provider as soon
as the user toggles default wallet off.

Can be reviewed and merged separately from #3451.

Ex:

its-alive.mov

Testing

  • Make sure Taho is set as default and connect to a dApp, waiting for the dApp Connection popup to appear.
  • Switch the default wallet toggle to off in the top bar of the dApp Connection popup.
    • The dApp Connection popup should disappear, and the next wallet should pop up its connection flow immediately.

Note that you can get into a state where you've previously requested a MetaMask connection, but did not complete the flow (e.g. by not unlocking MetaMask). In this case MetaMask will auto-decline the connection request from the dApp, so the above flow will appear not to work. Make sure MetaMask is in an unlocked idle state before testing the flow above.

Testing Env

ENABLE_UPDATED_DAPP_CONNECTIONS=true

Latest build: extension-builds-3462 (as of Thu, 15 Jun 2023 15:12:02 GMT).

@Shadowfiend Shadowfiend changed the base branch from main to dsl-connection June 8, 2023 20:59
Base automatically changed from dsl-connection to main June 12, 2023 01:01
This largely doesn't matter, but we were pushing a notification to all
pages when a single permission was revoked, even if that permission had
not been granted in the first place. This is a tiny step in improving
the permission revocation process.
When called, this pushes an RPC request to the current provider, which
has ostensibly been previously updated. It is meant to be used to
re-forward to MetaMask or another wallet when Taho disables its default
status during an interaction.
In addition to re-routing all in-flight requests to the new wallet when
the Taho-as-default toggle is flipped, we also no longer reload the page
for any dApps.
The way that the provider proxy was set up, changing the current
provider would not route new requests to that provider, instead
requiring the dApp to reconnect. To allow transparent forwarding to the
new default when the connection switches, the proxy now always forwards
to the current provider (when available).
When currentProvider is unset on the router, return `undefined` for
`window.ethereum` as well.
Only when updated dApp connections are enabled, the dApp connection
popup auto-closes (after a 300ms delay to let the user see the toggle
animate). The expectation is that the new default wallet will pop up
immediately as the window provider replays the connection request from
Taho to the new default.
Now that the MetaMask fallback is more seamless, make it so that Taho
behaves as MetaMask on all sites when it is set as default. Only when
updated dApp connections are enabled.
@Shadowfiend Shadowfiend marked this pull request as ready for review June 12, 2023 20:46
Copy link
Contributor

@hyphenized hyphenized left a comment

Choose a reason for hiding this comment

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

Looks great! Found one bug and left a couple of comments.

window-provider/index.ts Outdated Show resolved Hide resolved
window-provider/index.ts Outdated Show resolved Hide resolved
) {
// When default wallet is toggled off, wait for the toggle animation to
// complete and close the window out.
setTimeout(() => window.close(), 300)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is causing an issue when Taho is the only wallet available. On https://pancakeswap.finance/ when Taho is not the default, connecting with the injected option causes the popup to close immediately.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Incidentally this shouldn't trigger in that scenario—it should really only trigger when the user actively toggles it off, i.e. on transition. Let me noodle on this a little.

If this isn't causing that behavior with the feature flag off, let's not let it block the merge since there's a follow-up in the mix.

The resolvers were being cleared immediately, then being cleaned up
again one by one during the rerouting. Let the initial clearing do the
work.
Copy link
Contributor

@hyphenized hyphenized left a comment

Choose a reason for hiding this comment

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

🚢

@hyphenized hyphenized merged commit c8cb3e9 into main Jun 15, 2023
@hyphenized hyphenized deleted the repeater-connection branch June 15, 2023 15:48
@jagodarybacka jagodarybacka mentioned this pull request Jun 22, 2023
jagodarybacka added a commit that referenced this pull request Jun 23, 2023
## What's Changed
* Repeater Connection: Forward requests to new default when default is
switched off during dApp connection flow by @Shadowfiend in
#3462
* Auto-Not-So-Matic: Fix two matic.network URLs to polygon.technology by
@Shadowfiend in #3483
* v0.38.0 by @kkosiorowska in
#3480
* Case Dismissed: Forcibly show DAppConnectionInfoBar popover on first
dApp connection by @Shadowfiend in
#3464
* Add Hardhat Fork Functionality by @0xDaedalus in
#3247
* Faded Jeans: Rename fadeIn class to fade_in by @Shadowfiend in
#3485
* Fix issue for discovery transaction hash by @kkosiorowska in
#3458
* Full Sweep: Drop the USE_UPDATED_SIGNING_UI feature flag by
@Shadowfiend in #3475
* Token Discovery - Remap redux asset balances by @hyphenized in
#3195
* Make specific warnings for adding custom asset by @kkosiorowska in
#3478
* Run NFTs e2e tests on a controlled wallet address by
@michalinacienciala in #3487
* v0.38.1 by @jagodarybacka in
#3484


**Full Changelog**:
v0.38.1...v0.39.0
Latest build:
[extension-builds-3496](https://github.com/tahowallet/extension/suites/13792957673/artifacts/764738599)
(as of Thu, 22 Jun 2023 14:27:32 GMT).
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

Successfully merging this pull request may close these issues.

2 participants