Skip to content

Conversation

@ezailWang
Copy link
Contributor

@ezailWang ezailWang commented Dec 29, 2025

Summary by CodeRabbit

  • New Features

    • Multi-token selection support added for the sell side in swap trading.
    • Expanded support for DeFi protocol interactions including borrowing, lending, collateral management, and position management.
    • PIN reset functionality introduced with multi-device support.
  • Documentation

    • Added comprehensive UI text labels for DeFi operations, trading interface, and security features.

✏️ Tip: You can customize this high-level summary in your review settings.

Signed-off-by: ezailWang <jelly@onekey.so>
Signed-off-by: ezailWang <jelly@onekey.so>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 29, 2025

Walkthrough

Changes refactor the Swap Pro Mode limit trading interface to support multi-token selection for the sell side. The action button now renders two-line text, and sell token selection becomes configurable via props. Extensive translation keys are added for DeFi, PIN reset, and market features.

Changes

Cohort / File(s) Summary
Swap UI Layout & Token Selection
packages/kit/src/views/Swap/pages/components/SwapProActionButton.tsx, packages/kit/src/views/Swap/pages/components/SwapProTradeInfoGroup.tsx, packages/kit/src/views/Swap/pages/components/SwapProTradingPanel.tsx
SwapProActionButton: Imports YStack and refactors button label to return two-text-value object (resValue, subValue) instead of string; renders as YStack with conditional secondary text.

SwapProTradeInfoGroup: Adds multi-token selection for sell side with new props (defaultTokens, defaultLimitTokens, cleanInputAmount); introduces TokenSelectorPopover for token switching and computed defaultTokensFromType logic based on trade type; extends SELL UI path with clickable token selector when multiple tokens exist.

SwapProTradingPanel: Passes new props (cleanInputAmount, defaultTokens, defaultLimitTokens) to SwapProTradeInfoGroup component.
Translation Enum Expansion
packages/shared/src/locale/enum/translations.ts
Adds 60+ new public enum members across DeFi domain (supply, borrow, collateral, APY, health factor, liquidation, borrowable/withdrawable caps), PIN management (attempts, cooldown, reset flow), and market features (3m timeframe, global APY/borrow). No existing values modified.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive Title is partially related to the main changes. It mentions 'swap pro add sell for select' which aligns with Swap Pro sell token selection features, but obscures the primary objectives with vague phrasing and issue references. Revise title to clearly describe the main change: 'Add sell token selection UI for Swap Pro limit orders' or 'Support multiple token selection for Swap Pro limit sell mode'.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Changes implement core requirements from both issues: SwapProTradeInfoGroup now supports multi-token selection via defaultTokens/defaultLimitTokens props OK-48285, SwapProActionButton displays two-line button text [OK-48318], and translations are added for 'limit_sell_for' OK-48285. Implementation appears complete for stated objectives.
Out of Scope Changes check ✅ Passed All changes align with linked issue requirements: UI refactor to support token selection (SwapProTradeInfoGroup, SwapProActionButton), prop additions for token lists and clearing input (SwapProTradingPanel), and translation keys for DeFi and limit order features. No unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/swap-proopt

Comment @coderabbitai help to get the list of available commands and usage tips.

@revan-zhang
Copy link
Contributor

revan-zhang commented Dec 29, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e361c73 and ff6a848.

⛔ Files ignored due to path filters (19)
  • packages/shared/src/locale/json/bn.json is excluded by !packages/shared/src/locale/json/*.json
  • packages/shared/src/locale/json/de.json is excluded by !packages/shared/src/locale/json/*.json
  • packages/shared/src/locale/json/en_US.json is excluded by !packages/shared/src/locale/json/*.json
  • packages/shared/src/locale/json/es.json is excluded by !packages/shared/src/locale/json/*.json
  • packages/shared/src/locale/json/fr_FR.json is excluded by !packages/shared/src/locale/json/*.json
  • packages/shared/src/locale/json/hi_IN.json is excluded by !packages/shared/src/locale/json/*.json
  • packages/shared/src/locale/json/id.json is excluded by !packages/shared/src/locale/json/*.json
  • packages/shared/src/locale/json/it_IT.json is excluded by !packages/shared/src/locale/json/*.json
  • packages/shared/src/locale/json/ja_JP.json is excluded by !packages/shared/src/locale/json/*.json
  • packages/shared/src/locale/json/ko_KR.json is excluded by !packages/shared/src/locale/json/*.json
  • packages/shared/src/locale/json/pt.json is excluded by !packages/shared/src/locale/json/*.json
  • packages/shared/src/locale/json/pt_BR.json is excluded by !packages/shared/src/locale/json/*.json
  • packages/shared/src/locale/json/ru.json is excluded by !packages/shared/src/locale/json/*.json
  • packages/shared/src/locale/json/th_TH.json is excluded by !packages/shared/src/locale/json/*.json
  • packages/shared/src/locale/json/uk_UA.json is excluded by !packages/shared/src/locale/json/*.json
  • packages/shared/src/locale/json/vi.json is excluded by !packages/shared/src/locale/json/*.json
  • packages/shared/src/locale/json/zh_CN.json is excluded by !packages/shared/src/locale/json/*.json
  • packages/shared/src/locale/json/zh_HK.json is excluded by !packages/shared/src/locale/json/*.json
  • packages/shared/src/locale/json/zh_TW.json is excluded by !packages/shared/src/locale/json/*.json
📒 Files selected for processing (4)
  • packages/kit/src/views/Swap/pages/components/SwapProActionButton.tsx
  • packages/kit/src/views/Swap/pages/components/SwapProTradeInfoGroup.tsx
  • packages/kit/src/views/Swap/pages/components/SwapProTradingPanel.tsx
  • packages/shared/src/locale/enum/translations.ts
🧰 Additional context used
🧬 Code graph analysis (1)
packages/kit/src/views/Swap/pages/components/SwapProActionButton.tsx (1)
packages/components/src/primitives/SizeableText/index.tsx (1)
  • SizableText (7-9)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: unittest (20.x)
  • GitHub Check: lint (20.x)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (java-kotlin)
🔇 Additional comments (4)
packages/kit/src/views/Swap/pages/components/SwapProActionButton.tsx (1)

264-281: Two-line button label wiring looks consistent

actionButtonText now always returns { resValue, subValue }, and the YStack renders those two lines cleanly, with subValue omitted when empty. Character-limit logic and the disabled states stay intact. No issues spotted here.

Also applies to: 321-331, 360-377

packages/shared/src/locale/enum/translations.ts (1)

460-517: New translation keys align with existing naming patterns

The added enum members (DeFi set, global_apy, global_wallet_balance, pin/reset keys, market_3m, and promode_limit_sell_for) fit the current naming scheme and don’t conflict with existing entries. From this file alone, the additions look safe.

Also applies to: 1225-1226, 1246-1247, 1876-1877, 2017-2017, 2117-2117, 2232-2234, 2663-2664, 2850-2850, 3122-3130

packages/kit/src/views/Swap/pages/components/SwapProTradingPanel.tsx (1)

33-45: Trade-type switch clearing and prop wiring look sound

Calling cleanInputAmount() before setSwapProTradeType prevents stale amounts when toggling MARKET/LIMIT, and passing cleanInputAmount, defaultTokens, and defaultLimitTokens down to both SwapProInputContainer and SwapProTradeInfoGroup keeps the data flow consistent. No functional issues here.

Also applies to: 47-59, 90-97, 127-133, 135-142

packages/kit/src/views/Swap/pages/components/SwapProTradeInfoGroup.tsx (1)

41-55: Default token selection by trade type is reasonable

Using defaultTokens for MARKET and defaultLimitTokens for LIMIT via defaultTokensFromType keeps the sell-target list aligned with the current mode. The extended props surface on SwapProTradeInfoGroup matches how SwapProTradingPanel passes config down. No issues here.

Also applies to: 66-77

@ezailWang ezailWang enabled auto-merge (squash) December 30, 2025 02:14
@ezailWang ezailWang merged commit 61d165e into x Dec 30, 2025
11 checks passed
@ezailWang ezailWang deleted the fix/swap-proopt branch December 30, 2025 02:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants