Skip to content

feat(tron): display TRX ready for withdrawal#27075

Merged
ulissesferreira merged 3 commits into
mainfrom
NEB-582-tron-claim-banner-ui
Mar 10, 2026
Merged

feat(tron): display TRX ready for withdrawal#27075
ulissesferreira merged 3 commits into
mainfrom
NEB-582-tron-claim-banner-ui

Conversation

@ulissesferreira
Copy link
Copy Markdown
Contributor

@ulissesferreira ulissesferreira commented Mar 5, 2026

Description

Display TRX that has completed the unstaking lock period and is ready for withdrawal on the token details view. Refactor Tron staking UI so AssetOverviewContent orchestrates all Tron staking components directly.

Added

  • TronUnstakedBanner component — Info-only success banner displaying "You can claim X TRX..." when TRX has completed the 14-day unstaking lock period and is ready for withdrawal. No action button (claim button deferred to NEB-576).
  • TronStakingCta component — "Stake your TRX" promotional CTA with APR percentage and an "Earn" button, shown to eligible users who have no staked TRX positions. Gated behind useStakingEligibility so geo-blocked users never see it.
  • readyForWithdrawalBalance derivation in useTokenBalance — Parses trxReadyForWithdrawal from the Tron special assets selector and exposes it as a formatted string (only when > 0 and numeric).
  • stake.tron.has_claimable_trx locale string — New i18n key for the claimable TRX banner text.
  • Unit tests for TronUnstakedBanner, TronStakingCta (including eligibility guard), and readyForWithdrawalBalance edge cases in useTokenBalance.

Changed

  • AssetOverviewContent is now the orchestrator for all Tron staking UI. It directly renders, in order: native Balance → staked Balance → TronUnstakedBannerTronUnstakingBannerTronStakingButtons (if staked) or TronStakingCta (if not staked). Previously, staking buttons/CTA were rendered inside EarnBalance.
  • EarnBalance no longer renders any Tron staking UI. When the Tron staking flag is enabled and the asset is a Tron chain asset, it returns null — all Tron staking rendering responsibility moved to AssetOverviewContent.
  • TronStakingButtons simplified — Removed showUnstake, hasStakedPositions, and aprText props. The CTA section was extracted into the new TronStakingCta. Now always renders "Unstake" and conditionally renders "Stake more" based on useStakingEligibility. Removed the if (!isEligible && !hasStakedPositions) return null early exit since the parent now controls when to render it.
  • useTokenBalance guards stakedTrxAsset with totalStaked > 0 — Previously createStakedTrxAsset was always called for Tron native tokens, producing a truthy object even with zero balance. Now stakedTrxAsset is undefined when no TRX is actually staked, which correctly drives the conditional rendering in AssetOverviewContent.

Note: This PR intentionally does not include a claim button. The button and snap interaction are in NEB-576.

Changelog

CHANGELOG entry: Added a banner to display TRX that is ready for withdrawal on the token details view

Related issues

Refs: NEB-582

Manual testing steps

Feature: TRX ready for withdrawal display

  Scenario: user views TRX token details with TRX ready for withdrawal
    Given user has TRX that has completed the 14-day unstaking lock period

    When user navigates to the TRX token details view
    Then a success banner is displayed showing "You can claim X TRX. Once claimed you'll get TRX back in your wallet."
    And no action button is displayed in the banner

  Scenario: user views TRX token details without TRX ready for withdrawal
    Given user has no TRX ready for withdrawal

    When user navigates to the TRX token details view
    Then no claim banner is displayed

Screenshots/Recordings

Before

N/A - new feature

After

Screenshot 2026-03-09 at 22 42 19

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Made with Cursor


Note

Medium Risk
Updates Tron token details balance derivation and reorganizes staking/unstaking UI rendering paths, which could affect when/where staking CTAs and banners appear for TRX users; changes are UI/formatting focused with test coverage.

Overview
Adds a Tron-only “claimable TRX” success banner on the token details view by deriving a new readyForWithdrawalBalance from trxReadyForWithdrawal in useTokenBalance (with numeric/zero guards) and wiring it through TokenDetails into AssetOverviewContent.

Refactors Tron staking UI ownership: AssetOverviewContent now directly renders Tron staking/unstaking components (including a new TronStakingCta for eligible users with no staked TRX), while EarnBalance no longer renders any Tron staking UI and returns null when Tron staking is enabled.

Simplifies TronStakingButtons by removing CTA-related props/markup, always showing Unstake and conditionally showing “Stake more” based on eligibility, and introduces shared test IDs; adds/updates unit tests and introduces the new stake.tron.has_claimable_trx locale string.

Written by Cursor Bugbot for commit 4fbff82. This will update automatically on new commits. Configure here.

@ulissesferreira ulissesferreira self-assigned this Mar 5, 2026
@ulissesferreira ulissesferreira changed the base branch from main to cursor/tron-additional-assets-34a0 March 5, 2026 17:54
@ulissesferreira ulissesferreira marked this pull request as ready for review March 5, 2026 17:54
@ulissesferreira ulissesferreira requested review from a team as code owners March 5, 2026 17:54
@ulissesferreira ulissesferreira marked this pull request as draft March 5, 2026 17:55
Comment thread app/components/UI/Earn/components/Tron/TronClaimBanner/TronClaimBanner.test.tsx Outdated
Comment thread app/components/UI/AssetOverview/utils/createTronDerivedAsset.ts Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 5, 2026

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot metamaskbot added the team-networks Networks team label Mar 5, 2026
@ulissesferreira ulissesferreira changed the title feat(tron): display TRX ready for withdrawal (NEB-582) feat(tron): display TRX ready for withdrawal Mar 5, 2026
@github-actions github-actions Bot added the size-L label Mar 5, 2026
@ulissesferreira ulissesferreira force-pushed the NEB-582-tron-claim-banner-ui branch from 296ad74 to a3ca53c Compare March 6, 2026 03:03
@github-actions github-actions Bot added size-M and removed size-L labels Mar 6, 2026
@ulissesferreira ulissesferreira force-pushed the NEB-582-tron-claim-banner-ui branch 3 times, most recently from 9e8c3f0 to 52586fa Compare March 6, 2026 04:34
@ulissesferreira ulissesferreira marked this pull request as ready for review March 6, 2026 04:55
shane-t
shane-t previously approved these changes Mar 6, 2026
@ulissesferreira ulissesferreira changed the base branch from cursor/tron-additional-assets-34a0 to main March 6, 2026 10:22
@ulissesferreira ulissesferreira dismissed stale reviews from shane-t and Prithpal-Sooriya March 6, 2026 10:22

The base branch was changed.

@ulissesferreira ulissesferreira requested a review from a team as a code owner March 6, 2026 10:22
@ulissesferreira ulissesferreira force-pushed the NEB-582-tron-claim-banner-ui branch 2 times, most recently from 598e6b6 to 8838893 Compare March 6, 2026 10:44
Comment thread app/components/UI/TokenDetails/hooks/useTokenBalance.ts
@ulissesferreira ulissesferreira force-pushed the NEB-582-tron-claim-banner-ui branch from 8838893 to 7a42f76 Compare March 6, 2026 11:06
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Mar 9, 2026
@ulissesferreira ulissesferreira dismissed stale reviews from shane-t and Prithpal-Sooriya via 924103b March 9, 2026 12:15
@ulissesferreira ulissesferreira force-pushed the NEB-582-tron-claim-banner-ui branch 2 times, most recently from 924103b to 4474d4e Compare March 9, 2026 19:14
Comment thread app/components/UI/TokenDetails/components/AssetOverviewContent.tsx
@ulissesferreira ulissesferreira force-pushed the NEB-582-tron-claim-banner-ui branch from 4474d4e to 685fd5f Compare March 9, 2026 19:22
shane-t
shane-t previously approved these changes Mar 10, 2026
Add info-only TronClaimBanner component to show TRX that has completed
the unstaking lock period and is ready for withdrawal. The banner
displays the claimable amount without any action button. The claim
action will be added in a follow-up PR.

Made-with: Cursor
@ulissesferreira ulissesferreira force-pushed the NEB-582-tron-claim-banner-ui branch from 685fd5f to ff386ec Compare March 10, 2026 11:32
@github-actions github-actions Bot added size-L and removed size-M labels Mar 10, 2026
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Ineligible users (e.g. geo-blocked) without staked positions were
shown the "Stake your TRX" CTA with a functional button they could
not actually use. Add useStakingEligibility guard so the CTA returns
null when the user is not eligible, matching TronStakingButtons
behavior. Add test coverage for the new guard.

Made-with: Cursor
Add TronStakingButtons.testIds.ts for consistency with TronStakingCta
and TronUnstakedBanner, replacing inline string literals.

Made-with: Cursor
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeTrade, SmokeConfirmations, SmokeWalletPlatform
  • Selected Performance tags: @PerformanceAssetLoading
  • Risk Level: medium
  • AI Confidence: 74%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes are focused on Earn UI components (including new/updated Tron staking buttons, CTAs, and banners), TokenDetails view updates, and the useTokenBalance hook.

  1. Earn/Tron staking components are part of the Earn experience accessed via the Trade wallet actions menu. SmokeTrade explicitly covers wallet actions entry points (Swap, Bridge, Perps, Predictions, Earn) and staking-related flows. Even if Tron staking is a new/variant path, changes in Earn UI could affect navigation and integration from the Trade entry point.

  2. SmokeTrade requires SmokeConfirmations for on-chain flows (staking/deposit-like interactions). While this PR appears UI- and hook-focused, Earn flows typically trigger transactions, so confirmations must be validated.

  3. TokenDetails and useTokenBalance changes can affect asset balance display and token detail screens, which are core wallet surfaces. SmokeWalletPlatform covers transaction history, core wallet views, and general wallet platform behavior where token balances and details are surfaced. This ensures no regression in wallet core flows due to balance logic updates.

No controller, Engine, or network permission changes were introduced, so NetworkAbstractions, MultiChainAPI, Identity, or Accounts-specific tags are not required.

Overall risk is medium due to balance hook changes and UI updates in user-facing wallet surfaces.

Performance Test Selection:
Changes to useTokenBalance and TokenDetails can impact balance fetching, token list rendering, and asset display performance. Running @PerformanceAssetLoading ensures no regressions in balance loading and token rendering performance. No evidence of changes affecting launch, onboarding, login, swaps execution timing, predictions, or perps performance.

View GitHub Actions results

@github-actions
Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
11 value mismatches detected (expected — fixture represents an existing user).
View details

@sonarqubecloud
Copy link
Copy Markdown

@ulissesferreira ulissesferreira added this pull request to the merge queue Mar 10, 2026
Merged via the queue into main with commit a559161 Mar 10, 2026
114 checks passed
@ulissesferreira ulissesferreira deleted the NEB-582-tron-claim-banner-ui branch March 10, 2026 15:35
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 10, 2026
@metamaskbot metamaskbot added the release-7.70.0 Issue or pull request that will be included in release 7.70.0 label Mar 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.70.0 Issue or pull request that will be included in release 7.70.0 size-L team-networks Networks team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants