Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

[1319.1] Change Network toggler - BASE PR (WIP) #1344

Closed
wants to merge 10 commits into from

Conversation

W3stside
Copy link
Contributor

@W3stside W3stside commented Aug 26, 2021

BASE PR - several will follow

Summary

Part of #1319 - will be broken down into a couple more PRs likely

Implements the core network switching logic and only a simple component, no real styling, no edge case testing, no real sexy UX

image

To Test

  1. click the networks on the top and see how it changes in MM
  2. test other wallets (haven't tested this)

Next:

  1. better styles
  2. error handling
  3. edge case testing

@W3stside W3stside requested review from a team August 26, 2021 20:23
@github-actions
Copy link
Contributor

  • 🔭 GP Swap: Gnosis Protocol v2 Swap UI

Copy link
Contributor

@alfetopito alfetopito left a comment

Choose a reason for hiding this comment

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

Edge case possibly:

  1. Opened the app
  2. Metamask was locked. Unlocked it. It was connected to xDai
  3. This pop up keep showing up
    screenshot_2021-08-26_14-58-18
  4. Switch on MM to mainnet, pop up went away.
  5. Clicked on the switcher to xDai, confirmed change notification on wallet
  6. Pop up is back asking me to import wxdai

@fairlighteth
Copy link
Contributor

fairlighteth commented Aug 27, 2021

@W3stside Great you started this. Here a couple of suggestions:

  • Always show all network connect buttons. Right now we hide the button for the current active network. I'd also show the current active network button with a ✅ for visual confirmation. I think right now it's more evident when you're on mainnet given we don't show you the network card there. I think we essentially have to 'glue' together the current NetworkCard component and your network select/switch menu.
  • For the very simple proof of concept, you could opt using a select menu (<select>).
  • When the user currently is not connected to any wallet, on click of a network button we could catch this and ask the user to connect their wallet (in combination with the right network!). Or we don't show the network selector when you're not connected, and when the user decides to connect their wallet, the default network is the one we detect from the client? 🤔
  • There's a scenario where for some reason, the 'change network' modal from the client wallet (in this case MetaMask) is hidden/currently not visible to the user. When the user then repeatedly presses the network button in our UI, nothing happens. There is an error message being returned which can specifically catch/target this. My thinking is, we could alert the user about this (Network change request already pending...):

Screen Shot 2021-08-27 at 10 28 58

@W3stside
Copy link
Contributor Author

Edge case possibly:

  1. Opened the app
  2. Metamask was locked. Unlocked it. It was connected to xDai
  3. This pop up keep showing up
    screenshot_2021-08-26_14-58-18
  4. Switch on MM to mainnet, pop up went away.
  5. Clicked on the switcher to xDai, confirmed change notification on wallet
  6. Pop up is back asking me to import wxdai

isn't from this PR, this is the behaviour all the time unfortunately. but it goes away quickly on other branches when switching. i think it's accentuated with this pr tho. will investigate

@W3stside
Copy link
Contributor Author

@W3stside Great you started this. Here a couple of suggestions:

  • Always show all network connect buttons. Right now we hide the button for the current active network. I'd also show the current active network button with a ✅ for visual confirmation. I think right now it's more evident when you're on mainnet given we don't show you the network card there. I think we essentially have to 'glue' together the current NetworkCard component and your network select/switch menu.

Yes that's the idea, for now this is very much as u mentioned a proof of concept and leaving it in here was weird.

  • For the very simple proof of concept, you could opt using a select menu (<select>).

sure, but wont change anything here, i think it's best in a follow up PR to just make the pretty comp with all the choices and nothing hooked up.

  • When the user currently is not connected to any wallet, on click of a network button we could catch this and ask the user to connect their wallet (in combination with the right network!). Or we don't show the network selector when you're not connected, and when the user decides to connect their wallet, the default network is the one we detect from the client? 🤔

good idea, imho we shouldn't show it at all until they connect. best not to show too many buttons/things to do before they're even connected. the main CTA when disconnected is the big ass bright orange CONNECT WALLET button and we should keep that the main focus

  • There's a scenario where for some reason, the 'change network' modal from the client wallet (in this case MetaMask) is hidden/currently not visible to the user. When the user then repeatedly presses the network button in our UI, nothing happens. There is an error message being returned which can specifically catch/target this. My thinking is, we could alert the user about this (Network change request already pending...):

good catch, definitely sth to add as a banner maybe since it's close to where this is already happening (header) at least in web. i think even with the "header" in the footer in mobile we can leave it as a top level banner warning

Screen Shot 2021-08-27 at 10 28 58

@elena-zh
Copy link

isn't from this PR, this is the behaviour all the time unfortunately. but it goes away quickly on other branches when switching. i think it's accentuated with this pr tho. will investigate

This issue was mentioned in #1061 (case 1)

@elena-zh
Copy link

elena-zh commented Aug 27, 2021

I think I will start adding comments one by one here.
My first issue is when connect to a MM account using WC:

  1. networks are not changed when swicth them in the connected MM wallet (nether in Android nor in iOS).
  2. the same is when I try to switch networks in the app: no changes in the connected MM in a mobile device.

The same is with imToken wallet

@elena-zh
Copy link

elena-zh commented Aug 27, 2021

The next case is that a lot of wallets do not support several networks.
As an example, TrustWallet, TokenPocket. So it looks a bit odd when I connect such wallet and see an option to switch to xDAI or Rinkeby.

And, as expected, nothing happens when I press on networks buttons in the app.

@elena-zh
Copy link

elena-zh commented Aug 27, 2021

There is no network switcher in a mobile view
image
image

It would be nice to add it to test changes in wallets' integrated browsers
UPD: actually, it is a known issue #1168 is not related exactly to this pr, but nevertheless

@W3stside
Copy link
Contributor Author

thanks @elena-zh

Feel free to add these as a checklist of things to do in the PR base description or to the issue #1319

Keep in mind this PR is not meant to be a finished anything and is simply a POC (kinda)

@W3stside W3stside changed the title [1319.1] Change Network toggler - main logic and simple component [1319.1] Change Network toggler - BASE PR (WIP) Aug 27, 2021
@elena-zh elena-zh mentioned this pull request Aug 27, 2021
@MareenG
Copy link

MareenG commented Aug 31, 2021

Super nice. I like it.
I will add also some thoughts to #1319

W3stside pushed a commit that referenced this pull request Sep 8, 2021
* Move single hop toggle GA event

Move GA event from setSingleHopOnly hook to toggle function

* Fix code style issues with ESLint

* refactor ternary operator out

Co-authored-by: Lint Action <[email protected]>
@W3stside W3stside mentioned this pull request Sep 9, 2021
1 task
@W3stside
Copy link
Contributor Author

closed in favour of the latest uni stuff

@W3stside W3stside closed this Nov 16, 2021
@alfetopito alfetopito deleted the 1319/network-toggler branch November 16, 2021 17:19
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.

5 participants