Clear Receive page component state when user switches wallets
See original GitHub issueThere’s a minimum of two issues here:
- If you enter a specific private key with advanced mode on, scan for funds, and change accounts, the
scanPrivateKeyLocal
variable is still defined with the manually specific private key. As a result, funds from that account are shown instead of the new account. This data should be cleared - If you enter start and end blocks with
startBlockLocal
andendBlockLocal
those values are also persisted
To resolve this issue, options are:
- Just reload the page when the user changes wallets. This is a little tricky because just reloading if
userAddress
changes gets you an infinite reload loop becauseuserAddress
is undefined when the app first loads, until the wallet is connected. Additionally, only reloading if the last userAddress is defined AND there is a new one doesn’t currently work because inwallet.ts
we callresetState()
when the user changes wallets, so you really have oldAddress -> undefined -> newAddress, and can’t distinguish between that type of “intermediate”undefined
user address vs a true “no wallet connected yet”undefined
- Add a
resetState()
method toAccountReceive.vue
that runs any timeuserAddress
changes to just reset all state in that component to their default values. This is probably the way to go and shouldn’t be too difficult
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How do I clear location.state in react-router on page reload?
If you're using react hooks, you can use window.history directly to clear the state without triggering a rerender. This is better than using...
Read more >How to Fetch and Update Data From Ethereum With React ...
Here's how to configure your dapp's frontend so token balances and fund transfers update in your users' Ethereum wallets.
Read more >Web3 Dapp Developer Guide: React Hooks for Ethereum
With Web3 Onboard's Ethereum react hooks, any developer can quickly set up their dapp to interact with the best web3 wallets.
Read more >Wallet - Technologies - Human Interface Guidelines - Design
Wallet helps people securely store their credit and debit cards, driver's license or state ID, transit cards, event tickets, keys, and more on...
Read more >Integrating Your Smart Contract with the Frontend | Medium
In this tutorial, we'll teach you how to create a full stack dApp by connecting your Hello World smart contract to a React...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think for now we should not store them in local storage. It might be nice to have these setting stick at some point. If we do that, it would need to be in a more accessible/discoverable “settings” page or something like that. As it stands, these features are hidden behind the advanced mode flag and not visible in the form after they’re set. It’d be too easy to get into a situation where the user has no idea they’re set but they’re still applied.
Cool, so let’s go that route
So @radchukd for this PR, the first set of changes you have in #243 are good, then if you could also just blow away everything related to saving the start/end block values in local storage (in the same PR) that would be perfect!