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

Only check network before transactions #763

Merged
merged 10 commits into from
Feb 20, 2024
Merged

Conversation

Viterbo
Copy link
Collaborator

@Viterbo Viterbo commented Jan 29, 2024

Fixes #760

Description

This PR includes a new function assertNetworkConnection for the account store that will prompt the user to change the network and block the code until the user either refuses or accepts and effectively changes the network. That allowed us to reduce a lot of redundant code repeated in several places.

image

It also removes the code responsible for warning the user that a network switch has been detected because we don't need it if we are only displaying data. However, when the user tries to sign a transaction we need to explicitly check the network and prompt the user to change it.

Test scenarios

  • Login using Metamask
  • Once logged, open Metamask, change the network, and come back to the web app
    • you should not get any notification
    • you should be able to explore all sections and your data should be correct
  • got to any transaction page and try to perform one: send, wrap, unwrap, etc
    • you should be prompted to change the network
    • if you refuse to switch the network, the transaction cancels quietly
    • if you cancel the switch you get a neutral notification
    • if you accept and continue until effectively change the network, the transaction should go on without the need for you to hit the action button again (see the video).

Screen captures

telos-wallet--switch-network-before-trx.webm

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have cleaned up the code in the areas my change touches
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings
  • I have removed any unnecessary console messages
  • I have included all english text to the translation file and/or created a new issue with the required translations for the currently supported languages
  • I have tested for mobile functionality and responsiveness
  • I have added appropriate test coverage

@Viterbo Viterbo self-assigned this Jan 29, 2024
@Viterbo Viterbo linked an issue Jan 29, 2024 that may be closed by this pull request
5 tasks
Copy link

netlify bot commented Jan 29, 2024

Deploy Preview for wallet-develop-mainnet ready!

Name Link
🔨 Latest commit e2cf099
🔍 Latest deploy log https://app.netlify.com/sites/wallet-develop-mainnet/deploys/65d3eed08e6b210009cc8ef1
😎 Deploy Preview https://deploy-preview-763--wallet-develop-mainnet.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jan 29, 2024

Deploy Preview for wallet-staging ready!

Name Link
🔨 Latest commit e2cf099
🔍 Latest deploy log https://app.netlify.com/sites/wallet-staging/deploys/65d3eed0f7dda20008cf0f8e
😎 Deploy Preview https://deploy-preview-763--wallet-staging.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Viterbo Viterbo marked this pull request as ready for review January 29, 2024 22:52
@Viterbo Viterbo marked this pull request as draft January 29, 2024 22:52
@Viterbo Viterbo marked this pull request as ready for review January 29, 2024 23:18
Copy link
Contributor

@donnyquixotic donnyquixotic left a comment

Choose a reason for hiding this comment

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

@Viterbo

  • Remove the switch notification altogether, add a network check and switch prompt to any signed transaction

  • remove network switch prompt on autologin

@Viterbo
Copy link
Collaborator Author

Viterbo commented Jan 30, 2024

@Viterbo

  • Remove the switch notification altogether, add a network check and switch prompt to any signed transaction
  • remove network switch prompt on autologin

DONE!

@donnyquixotic
Copy link
Contributor

donnyquixotic commented Jan 31, 2024

@Viterbo Cannot transfer NFTs if on a different network (no switch prompt). Attempts to send on incorrect network fail to estimate gas or execute as an empty transaction (no transfer).

@Viterbo
Copy link
Collaborator Author

Viterbo commented Jan 31, 2024

@Viterbo Cannot transfer NFTs if on a different network (no switch prompt). Attempts to send on incorrect network fail to estimate gas or execute as an empty transaction (no transfer).

DONE!

@ezra-sg
Copy link
Contributor

ezra-sg commented Feb 1, 2024

I noticed a problem which is totally not your fault, as it is present in prod, but i think it might fall under the purview of this issue. maybe you can fix it for this PR, what do you think? if not we can make a separate issue to fix it.

On the approvals page, if you attempt to modify an approval while on the wrong network, the transaction will be on the wrong network (note how it says ethereum mainnet):
image

donnyquixotic
donnyquixotic previously approved these changes Feb 6, 2024
@donnyquixotic donnyquixotic merged commit c6c4b32 into develop Feb 20, 2024
9 checks passed
@donnyquixotic donnyquixotic deleted the 760-switch-chains-prompt branch February 20, 2024 00:20
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.

switch chains prompt
3 participants