Skip to content

fix: clear tokens from other networks #660

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

Merged
merged 4 commits into from
Mar 19, 2025
Merged

fix: clear tokens from other networks #660

merged 4 commits into from
Mar 19, 2025

Conversation

tuliomir
Copy link
Contributor

@tuliomir tuliomir commented Mar 5, 2025

Motivation

When changing networks, the registered tokens were not being cleaned properly. This resulted in situations like testnet tokens being exhibited while the user is on mainnet. This was raised by #385 .

Acceptance Criteria

  • All registered custom tokens and nano contracts should be cleaned when changing networks

Alternative Solutions

A more user-friendly approach to this issue would be comparing the genesis block of the previous network ( if any ) and the current network, and only cleaning those tokens if these hashes changed.

This would ensure that changing the fullnode while staying inside the same network ( for example, changing from https://node1.mainnet.hathor.network/v1a/ to https://node2.mainnet.hathor.network/v1a/ ) would not remove all registered tokens unnecessarily.

This solution was not implemented here so that the bug is fixed immediately, while this greater refactor is left to #667 .

Security Checklist

  • Make sure you do not include new dependencies in the project unless strictly necessary and do not include dev-dependencies as production ones. More dependencies increase the possibility of one of them being hijacked and affecting us.

@tuliomir tuliomir added the bug Something isn't working label Mar 5, 2025
@tuliomir tuliomir requested a review from andreabadesso March 5, 2025 16:28
@tuliomir tuliomir requested a review from pedroferreira1 as a code owner March 5, 2025 16:28
@tuliomir tuliomir self-assigned this Mar 5, 2025
@tuliomir tuliomir moved this from Todo to In Progress (Done) in Hathor Network Mar 5, 2025
@tuliomir tuliomir linked an issue Mar 5, 2025 that may be closed by this pull request
@@ -162,7 +162,10 @@ export function* startWallet(action) {
// but the wallet may be closed unexpectedly
const storage = STORE.getStorage();
yield call([storage.store, storage.store.cleanMetadata]); // clean metadata on memory
yield call([storage, storage.cleanStorage], true); // clean transaction history
// clean transaction history, addresses, token and nano-contract indexes
// XXX: It would be better to keep registered tokens and nano contracts
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have an issue created describing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@andreabadesso andreabadesso moved this from In Progress (Done) to In Review (WIP) in Hathor Network Mar 10, 2025
@pedroferreira1 pedroferreira1 moved this from In Review (WIP) to In Review (Done) in Hathor Network Mar 11, 2025
@tuliomir tuliomir force-pushed the fix/leftover-tokens branch from 76dd706 to 9cfb479 Compare March 11, 2025 16:22
@tuliomir tuliomir force-pushed the fix/leftover-tokens branch from 9cfb479 to dd01b71 Compare March 11, 2025 16:23
@tuliomir tuliomir moved this from In Review (Done) to In Progress (WIP) in Hathor Network Mar 11, 2025
@tuliomir tuliomir moved this from In Progress (WIP) to In Progress (Done) in Hathor Network Mar 12, 2025
@github-project-automation github-project-automation bot moved this from In Progress (Done) to In Review (WIP) in Hathor Network Mar 13, 2025
@tuliomir tuliomir merged commit dd23954 into master Mar 19, 2025
1 check passed
@github-project-automation github-project-automation bot moved this from In Review (WIP) to Waiting to be deployed in Hathor Network Mar 19, 2025
@tuliomir tuliomir deleted the fix/leftover-tokens branch March 19, 2025 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Waiting to be deployed
Development

Successfully merging this pull request may close these issues.

bug: Testnet tokens don't get removed when changing network to mainnet
3 participants