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

fix(trading): selecting account #17546

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

adderpositive
Copy link
Contributor

Description

Fixing overriding selected account

Related Issue

Resolve #17452

@adderpositive adderpositive added the +Invity Related to Invity project label Mar 10, 2025
@adderpositive adderpositive requested a review from FreeWall March 10, 2025 18:15
@adderpositive adderpositive self-assigned this Mar 10, 2025
@adderpositive adderpositive added the bug Something isn't working as expected label Mar 10, 2025
Copy link

coderabbitai bot commented Mar 10, 2025

Walkthrough

The modifications update the trading form functionality across several components. In one hook, a new line is introduced to update the form state by setting the selected cryptocurrency option. Changes in the trading exchange form hook revise the reset logic to trigger only when valid exchange data is present and initial data is still loading, with the dependency array updated to reflect these conditions. Similarly, the trading sell form hook now checks for initial data loading instead of the form’s dirty status when deciding to reset default values. Additionally, in the account input component for the trading form, the direct call to the field's onChange handler is removed, with the onCryptoCurrencyChange function continuing to handle the selection. No changes have been made to any exported or publicly declared entities.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b54ce1f and e32dadd.

📒 Files selected for processing (4)
  • packages/suite/src/hooks/wallet/trading/form/common/useTradingFormActions.ts (1 hunks)
  • packages/suite/src/hooks/wallet/trading/form/useTradingExchangeForm.ts (1 hunks)
  • packages/suite/src/hooks/wallet/trading/form/useTradingSellForm.ts (1 hunks)
  • packages/suite/src/views/wallet/trading/common/TradingForm/TradingFormInput/TradingFormInputAccount.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: run-desktop-tests (@group=wallet, trezor-user-env-unix bitcoin-regtest)
  • GitHub Check: run-desktop-tests (@group=other, trezor-user-env-unix)
  • GitHub Check: run-desktop-tests (@group=passphrase, trezor-user-env-unix)
  • GitHub Check: run-desktop-tests (@group=settings, trezor-user-env-unix bitcoin-regtest)
  • GitHub Check: run-desktop-tests (@group=device-management, trezor-user-env-unix)
  • GitHub Check: Analyze with CodeQL (javascript)
  • GitHub Check: build-web
  • GitHub Check: Setup and Cache Dependencies
  • GitHub Check: run-desktop-tests (@group=suite, trezor-user-env-unix)
🔇 Additional comments (4)
packages/suite/src/hooks/wallet/trading/form/common/useTradingFormActions.ts (1)

187-188: Good addition to synchronize the form state

Adding this line ensures that the form state is explicitly updated with the selected cryptocurrency option, which aligns with the removal of the direct onChange call in the account input component.

packages/suite/src/hooks/wallet/trading/form/useTradingSellForm.ts (1)

587-590: Good fix for form reset logic

Changing the condition from checking form dirty state to checking if initial data is loading is more appropriate. This ensures that the form is reset only when the sellInfo data is available from the API.

packages/suite/src/views/wallet/trading/common/TradingForm/TradingFormInput/TradingFormInputAccount.tsx (1)

56-63: Fixes the account selection override issue

Removing the direct call to onChange prevents double-updating the form state when selecting a cryptocurrency. Now only onCryptoCurrencyChange is responsible for updating the form state, which prevents the selected account from being overridden.

packages/suite/src/hooks/wallet/trading/form/useTradingExchangeForm.ts (1)

715-720: Good fix for exchange form reset logic

Similar to the sell form changes, this updates the condition for resetting the form to check for both exchangeInfo availability and the initialDataLoading state. This ensures consistent behavior with the sell form and only resets when necessary.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as expected +Invity Related to Invity project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trading - changing swapped coin from any coin/network to any token selects the tokens mainnet instead
1 participant