Skip to content

bug: fix coin de-activation logic #2750

Merged
CharlVS merged 13 commits intodevfrom
codex/fix-reactivation-of-disabled-default-coins
Jul 11, 2025
Merged

bug: fix coin de-activation logic #2750
CharlVS merged 13 commits intodevfrom
codex/fix-reactivation-of-disabled-default-coins

Conversation

@CharlVS
Copy link
Copy Markdown
Collaborator

@CharlVS CharlVS commented Jun 5, 2025

This pull request introduces functionality to handle parent-child relationships between coins in the wallet. It ensures that disabling a parent coin also disables its associated child tokens and provides user confirmation dialogs for such actions. The changes span multiple files and address both the backend logic and the user interface.

Backend changes for handling parent-child coin relationships:

  • lib/bloc/coins_bloc/coins_bloc.dart: Refactored the logic for disabling coins to account for child tokens. A new coinsToDisable set aggregates both parent coins and their child tokens before processing deactivation. [1] [2]
  • lib/bloc/coins_bloc/coins_repo.dart: Updated the coin repository to disable child tokens when a parent coin is deactivated, ensuring proper cleanup of balance watchers and broadcasting the state change.

User interface changes for confirmation dialogs:

Miscellaneous changes:

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 5, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2025

Visit the preview URL for this PR (updated for commit 84a016e):

https://walletrc--pull-2750-merge-24g546se.web.app

(expires Fri, 18 Jul 2025 14:54:41 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: f66a4ff03faa546f12f0ae5a841bd9eff2714dcc

@CharlVS CharlVS self-assigned this Jun 5, 2025
@CharlVS CharlVS added the bug Something isn't working label Jun 5, 2025
@CharlVS CharlVS requested a review from smk762 June 6, 2025 13:14
@CharlVS CharlVS added the QA Ready for QA Testing label Jun 6, 2025
@smk762
Copy link
Copy Markdown
Collaborator

smk762 commented Jun 11, 2025

I've hit a possible edge case with this one. Not sure yet if easily reproducible or if pre-requisite steps are relevant but here is goes anyway:

  • Login, activate and deactivate a few coins at random. Make sure to deactivate a parent coin, but keep one of its tokens (e.g. I disabled MATIC, kept 1INCH-PLG20)
  • logout, login.
  • try to activate coins. They disappear from the "activate" list, but do not appear on the "portfolio" list.

No logs were identified which held any information that appeared to be related to this.

Upon logging out and then back in again, all the previously selected coins which were hanging out with the cat of Dr Schrödinger appeared without problem. After disabling half of them, I logged out/in again, and the selection was preserved.

Attempting again to replicate the problem, I disabled MATIC but left 1INCH-PLG20 active. After L.I/O again, this was preserved - MATIC not in portfolio, but 1INCH-PLG20 was.

This is an unnatural state, as I dont understand how it was actually activated when running the token activation methods without parent coin active will return

{
    "mmrpc": "2.0",
    "error": "Platform coin MATIC is not activated",
    "error_path": "token.lp_coins",
    "error_trace": "token:136] lp_coins:5032]",
    "error_type": "PlatformCoinIsNotActivated",
    "error_data": "MATIC",
    "id": null
}

This time around, I was able to activate and deactivate coins as expected, though MATIC ended up something went wrong with a flickering fiat text (at zero, though I am funded) and selected list preservation was degraded.

tl;dr, this works in perfect conditions, but the edge cases as close as walking the plank.

Please recheck the parent/token logics. In legacy desktop, attempts to disable a parent would prompt a pop up to appear threatening to kill its children too unless the parent remains abled.

@CharlVS CharlVS changed the title fix: prevent disabled coins from reactivating bug: fix coin de-activation logic Jun 17, 2025
@smk762
Copy link
Copy Markdown
Collaborator

smk762 commented Jul 4, 2025

I've confirmed that attempting to disable parent shows pop up listing the child tokens which will also be disabled.
From here, cancel or confirm both act as expected.

Next test was to check the case where an attempt is made to disable a token while active swap is in progress, or order is open, then do the same again for a parent coin while a child was in the middle of a swap. I was unable to progress this far, as the following error presented.

image

I subsequently confirmed that MATIC is indeed active, and its wallet page shows balance / addresses / history as expected from an active coin. Attempting a BEP20 token swap led to the same outcome.

image

For reference, if not yet implemented (or towards a separate issue), this should be the flow when disabling during swap:

  • If token / stand alone coin, it should not be possible to disable the coin while it has a swap in progress.
  • If a parent coin, as above, along with the constraint extending to cover child tokens.
  • If an order is open for parent / token to be disabled, a pop up warning to indicate order(s) are open, along with the option to cancel these orders alongside the coin/token.

@gcharang gcharang added P0 Blocker / critical defect and removed P0 Blocker / critical defect labels Jul 4, 2025
@CharlVS CharlVS added this to the v0.9.2 Release milestone Jul 8, 2025
@takenagain takenagain self-requested a review July 9, 2025 20:48
- move confirmation popups to utils.dart for now
- use coins_repo to disable coin in coins_bloc
- flush coins before disabling
- fix syncing loop yielding unnecessary state updates
- exclude excluded coins from syncing steps
- deactivate children before parent coin
- enabledType
- defaultAddress
- nonEmptyHdAddress
- getDerivationPath
- getHdAddress
- reset
coins are automatically reactivated using SDK `.pubkeys` function, so there is no longer a need for a background reactivation task
@takenagain
Copy link
Copy Markdown
Contributor

takenagain commented Jul 10, 2025

Test cases passed after most recent changes:

  • Disabling coin works and persists after logging out and back in again.
  • Disabling parent shows popup listing child tokens.
  • Disabling parent disables children as well.
  • Disabling parent is permanent (does not re-appear, persists through logout/login cycle).
  • Disabling coin with open maker order shows popup warning.
  • Disabling coin with open maker order cancels the order.
  • Disabling parent coin with open maker order cancels the order, disables parent, and disables children.
  • Disabling coin with active swap shows a popup warning and does not allow the user to proceed

@CharlVS CharlVS merged commit 7583aa1 into dev Jul 11, 2025
8 of 12 checks passed
@CharlVS CharlVS deleted the codex/fix-reactivation-of-disabled-default-coins branch July 11, 2025 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working codex QA Ready for QA Testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants