question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Clear Receive page component state when user switches wallets

See original GitHub issue

There’s a minimum of two issues here:

  1. 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
  2. If you enter start and end blocks with startBlockLocal and endBlockLocal those values are also persisted

To resolve this issue, options are:

  1. 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 because userAddress 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 in wallet.ts we call resetState() 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
  2. Add a resetState() method to AccountReceive.vue that runs any time userAddress 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:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
apbendicommented, Oct 11, 2021

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.

0reactions
mds1commented, Oct 11, 2021

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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found