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

Prompt switch network if a user's wallet is connected to the wrong network #54

Open
willyogo opened this issue Jan 23, 2024 · 7 comments
Assignees

Comments

@willyogo
Copy link
Member

As a user, I want the member portal/auction app to prompt my wallet to switch if I'm not connected to the right network and attempt to connect wallet or prompt a transaction.

AC:

  1. If a user is not on either ethereum mainnet (prod) or goerli (staging), and attempts to connects a wallet, the app should prompt the user's wallet to switch network
  2. Whenever a user is prompted to execute a transaction (ie. place bid or settle auction), the app first checks to see which network they're connected to
  3. If a user rejects the request to switch network, their wallet is not connected or prompted to execute the transaction (iow, nothing happens and the user can attempt to connect wallet or execute transaction again. if they have switched to the correct network it will work, if not they should get prompted to switch network again. this is the existing behavior for the Switch button on the Rep page)
image

here's an article on how to do this: https://www.freecodecamp.org/news/how-to-switch-blockchains-on-metamask-with-javascript/

we also have this functionality already rocking on the Rep page

image
@JacobHomanics
Copy link

@willyogo Should we remove AC 1 as that popup prevents them from continuing to use the app even if they have no intention of making any transactions? Then only when they attempt to make a transaction is when we check and prompt for a network switch.

Going to to hold off on AC 2 as there were changes to the appropriate code in PR 56. Thus once that PR gets merged in, then we can begin work on AC 2.

AC 3 is also has the same contingencies as AC 2.

@willyogo
Copy link
Member Author

@willyogo Should we remove AC 1 as that popup prevents them from continuing to use the app even if they have no intention of making any transactions? Then only when they attempt to make a transaction is when we check and prompt for a network switch.

Going to to hold off on AC 2 as there were changes to the appropriate code in PR 56. Thus once that PR gets merged in, then we can begin work on AC 2.

AC 3 is also has the same contingencies as AC 2.

great point that users don't really need to switch network unless they're actually going to execute a transaction, which is awesome. is this true for the rep page too? if so, let's just remove that pop up so users aren't prevented from accessing the dapp if they're on the wrong network, and then AC 2 and 3 will take care of ensuring they're on the right network before executing a tx (it's actually possible to get into a state currently where the auction page will let you execute a bid or settle transaction on the wrong network, which can lead to loss of bid 😬).

ty ser!

@JacobHomanics
Copy link

@willyogo Should we remove AC 1 as that popup prevents them from continuing to use the app even if they have no intention of making any transactions? Then only when they attempt to make a transaction is when we check and prompt for a network switch.
Going to to hold off on AC 2 as there were changes to the appropriate code in PR 56. Thus once that PR gets merged in, then we can begin work on AC 2.
AC 3 is also has the same contingencies as AC 2.

great point that users don't really need to switch network unless they're actually going to execute a transaction, which is awesome. is this true for the rep page too? if so, let's just remove that pop up so users aren't prevented from accessing the dapp if they're on the wrong network, and then AC 2 and 3 will take care of ensuring they're on the right network before executing a tx (it's actually possible to get into a state currently where the auction page will let you execute a bid or settle transaction on the wrong network, which can lead to loss of bid 😬).

ty ser!

Yup! Just updated the PR with changes to properly switch network if you try to execute a tx on the wrong network!

@willyogo
Copy link
Member Author

nice! do you know which PR this was? i'm still not seeing any prompt to switch network and can get into this state where the app prompts you to execute txs on the wrong network

steps to repro:

  1. connect wallet on staging that's connected to goerli
  2. switch network in wallet to another network, ie mainnet
  3. attempt to place a bid

expected result:

  1. user is prompted to switch to goerli in their wallet

actual result:

  1. user is able to execute transaction on the wrong network

@JacobHomanics
Copy link

@willyogo Should be this one I believe: PR 56

Taking a closer look at this

@JacobHomanics
Copy link

nice! do you know which PR this was? i'm still not seeing any prompt to switch network and can get into this state where the app prompts you to execute txs on the wrong network

steps to repro:

  1. connect wallet on staging that's connected to goerli
  2. switch network in wallet to another network, ie mainnet
  3. attempt to place a bid

expected result:

  1. user is prompted to switch to goerli in their wallet

actual result:

  1. user is able to execute transaction on the wrong network

This is not reproducible on my end. It properly prompts to switch to the proper network and calls the smart contract on the correct chain.

@willyogo
Copy link
Member Author

confirmed this is working in staging now! it's working in prod for me now too, but it's prompting me to switch to Optimism instead of mainnet. do we have it set to Optimism for prod somewhere?

image

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

No branches or pull requests

2 participants