Skip to content

feat(tron): add claim button for unstaked TRX withdrawal#27076

Merged
ulissesferreira merged 1 commit into
mainfrom
NEB-576-withdraw-unstaked-tron
Mar 18, 2026
Merged

feat(tron): add claim button for unstaked TRX withdrawal#27076
ulissesferreira merged 1 commit into
mainfrom
NEB-576-withdraw-unstaked-tron

Conversation

@ulissesferreira

@ulissesferreira ulissesferreira commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Description

Add a "Withdraw" button to TronUnstakedBanner so users can claim TRX that has completed the 14-day unstaking lock period. Also migrates Tron staking components (TronStakingButtons, TronStakingCta) from StyleSheet/View to @metamask/design-system-react-native and restructures related i18n keys.

Changes

  • TronUnstakedBanner — Upgraded from info-only to actionable: now accepts chainId, renders a "Withdraw" Button, and wires it to the new useTronClaimUnstakedTrx hook.
  • useTronClaimUnstakedTrx hook (new) — Selects the Tron account via selectSelectedInternalAccountByScope, calls the claimUnstakedTrx snap RPC, and exposes handleClaimUnstakedTrx, isSubmitting, and errors.
  • claimUnstakedTrx snap RPC wrapper (new) — Sends claimUnstakedTrx request to the Tron Wallet Snap via handleSnapRequest.
  • TronClaimUnstakedTrxParams / TronClaimUnstakedTrxResult types (new).
  • TronStakingButtons / TronStakingCta — Migrated from StyleSheet.create/View/component-library Button/Text to design-system Box/Button/Text. Deleted corresponding .styles.ts files and removed useStyles mocks from tests.
  • TronUnstakingBanner — Simplified to use Banner's built-in title/description string props instead of a custom Text wrapper.
  • AssetOverviewContent — Passes chainId to TronUnstakedBanner; replaced View wrappers with Box.
  • i18n — Restructured stake.tron keys from flat (trx_unstaking_in_progress, has_claimable_trx) to nested (unstaking_banner.{title,description}, unstaked_banner.{title,description,button}).
  • Dependencies — Added preview resolutions for @metamask-previews/tron-wallet-snap and @metamask-previews/assets-controllers.
  • Tests — Rewrote TronUnstakedBanner tests (5 cases) and added useTronClaimUnstakedTrx tests (5 cases).
Screen.Recording.2026-03-12.at.15.51.30.mov

Changelog

CHANGELOG entry: Added a "Withdraw" button to the unstaked TRX banner so users can claim TRX that has completed the lock period.

Related issues

Refs: NEB-576

Manual testing steps

Feature: Withdraw unstaked TRX

  Scenario: User sees withdraw banner when unstaking is complete
    Given the user has TRX that has completed the 14-day unstaking lock period
    When the user navigates to the TRX token details view
    Then a green success banner is displayed with title "Unstaking <amount> TRX complete"
    And the banner description reads "Your unstaked TRX can now be withdrawn"
    And a "Withdraw" button is displayed inside the banner

  Scenario: User taps Withdraw
    Given the user sees the withdraw banner with a "Withdraw" button
    When the user taps "Withdraw"
    Then the button is disabled to prevent double-submission
    And the withdrawal transaction is submitted
    And the button re-enables after the transaction completes

  Scenario: User sees unstaking-in-progress banner
    Given the user has TRX currently in the 14-day unstaking lock period
    When the user navigates to the TRX token details view
    Then an info banner is displayed with title "Unstaking <amount> TRX in progress"
    And the banner description reads "It will take 14 days for unstaking"

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.

Note

Medium Risk
Adds a new Tron withdrawal flow that triggers a Snap RPC from the token details screen and introduces new error-toast behavior; failures could affect users’ ability to reclaim funds after unstaking. UI refactors to the design system are lower risk but touch several Tron Earn surfaces and i18n keys.

Overview
Adds an actionable unstaked TRX banner: TronUnstakedBanner now takes a chainId, renders a Withdraw button, calls new hook useTronClaimUnstakedTrx, disables while submitting, and surfaces failures via a new useEarnToasts tronWithdrawal.failed(errors) toast.

Introduces Snap plumbing for withdrawals (claimUnstakedTrx request + new TronClaimUnstakedTrx* types) and updates AssetOverviewContent to pass the Tron chainId into the banner.

Refactors Tron staking CTA/buttons (and related token-detail wrappers) from View/StyleSheet + component-library controls to @metamask/design-system-react-native, simplifies TronUnstakingBanner to use Banner title/description, and restructures related stake.tron i18n keys; tests are updated/added accordingly.

Written by Cursor Bugbot for commit 630084e. 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/Earn/utils/tron-staking-snap.ts
@github-actions

github-actions Bot commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

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): add claim button for unstaked TRX withdrawal (NEB-576) feat(tron): add claim button for unstaked TRX withdrawal Mar 5, 2026
Base automatically changed from cursor/tron-additional-assets-34a0 to main March 6, 2026 10:35
@ulissesferreira ulissesferreira force-pushed the NEB-576-withdraw-unstaked-tron branch from 81bab44 to a717f8c Compare March 10, 2026 14:39
@ulissesferreira ulissesferreira changed the base branch from main to NEB-582-tron-claim-banner-ui March 10, 2026 14:40
@ulissesferreira ulissesferreira force-pushed the NEB-576-withdraw-unstaked-tron branch from a717f8c to e9689ce Compare March 10, 2026 14:44
@github-actions github-actions Bot added size-M and removed size-XL labels Mar 10, 2026
@ulissesferreira ulissesferreira force-pushed the NEB-576-withdraw-unstaked-tron branch from e9689ce to fd08859 Compare March 10, 2026 14:56
Base automatically changed from NEB-582-tron-claim-banner-ui to main March 10, 2026 15:35
@ulissesferreira ulissesferreira force-pushed the NEB-576-withdraw-unstaked-tron branch 4 times, most recently from 70ebc1a to d3ec54c Compare March 11, 2026 16:51
@github-actions github-actions Bot added size-L and removed size-M labels Mar 11, 2026
@ulissesferreira ulissesferreira force-pushed the NEB-576-withdraw-unstaked-tron branch from d3ec54c to 6775b65 Compare March 11, 2026 16:57
Comment thread app/components/UI/Earn/components/Tron/TronStakingCta/TronStakingCta.styles.ts Outdated
Comment thread app/components/UI/TokenDetails/components/AssetOverviewContent.tsx
@ulissesferreira

Copy link
Copy Markdown
Contributor Author

Quick question @ulissesferreira - Do we display the TRX withdrawal in the Activity list? Non-blocking, just curious! 😄

Yes I believe we do!

@ulissesferreira ulissesferreira force-pushed the NEB-576-withdraw-unstaked-tron branch from db58b1e to 18c731b Compare March 17, 2026 22:37
@github-actions github-actions Bot added the risk-high Extensive testing required · High bug introduction risk label Mar 17, 2026
@socket-security

socket-security Bot commented Mar 17, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednpm/​@​metamask/​tron-wallet-snap@​1.22.1 ⏵ 1.24.01001009699100

View full report

@ulissesferreira ulissesferreira force-pushed the NEB-576-withdraw-unstaked-tron branch from 18c731b to 169bc22 Compare March 18, 2026 10:06
@github-actions github-actions Bot added risk-high Extensive testing required · High bug introduction risk and removed risk-high Extensive testing required · High bug introduction risk labels Mar 18, 2026
@ulissesferreira ulissesferreira force-pushed the NEB-576-withdraw-unstaked-tron branch from 169bc22 to aa66c06 Compare March 18, 2026 10:15
@github-actions github-actions Bot added risk-high Extensive testing required · High bug introduction risk and removed risk-high Extensive testing required · High bug introduction risk labels Mar 18, 2026
@ulissesferreira ulissesferreira force-pushed the NEB-576-withdraw-unstaked-tron branch 2 times, most recently from ff48390 to ea1becd Compare March 18, 2026 13:22
@github-actions github-actions Bot added risk-high Extensive testing required · High bug introduction risk and removed risk-high Extensive testing required · High bug introduction risk labels Mar 18, 2026
Replace the read-only TronUnstakedBanner with an actionable
TronClaimBanner that has a "Claim TRX" button triggering the
claimUnstakedTrx snap method. Wire up the full claim flow including
the useTronClaim hook, snap RPC methods (claimUnstakedTrx and
claimTrxStakingRewards), and the associated types.

Made-with: Cursor
@ulissesferreira ulissesferreira force-pushed the NEB-576-withdraw-unstaked-tron branch from ea1becd to 630084e Compare March 18, 2026 13:58
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-high Extensive testing required · High bug introduction risk labels Mar 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeTrade, SmokeConfirmations, SmokeWalletPlatform, FlaskBuildTests
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 76%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes are focused on the Earn feature, specifically Tron staking (UI components, hooks, utils, and related tests), plus updates to AssetOverviewContent and locales. This affects the Earn entry point from TradeWalletActions and potentially on-chain staking/claim flows.

Key impact areas:

  • Earn section integration via TradeWalletActions → covered under SmokeTrade (Earn is explicitly listed as part of TradeWalletActions entry points).
  • On-chain staking/unstaking/claim flows (Tron) → these likely trigger transaction confirmations, so SmokeConfirmations is required to validate the confirmation UI and signing flows.
  • Wallet platform surface (Trending/Wallet actions integration, asset overview updates) → SmokeWalletPlatform ensures no regression in wallet core surfaces and activity display.
  • Tron staking appears to rely on snap-related utilities (tron-staking-snap.ts), indicating Snap-based integration for non-EVM functionality → FlaskBuildTests is required to validate Snap lifecycle, permissions, and provider interactions.

No Engine/Controller-level changes were made, and no modifications to core network or account architecture were detected. Therefore, broader tags like SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeIdentity, or SmokeAccounts are not required.

package.json changes introduce some systemic risk (dependency updates), but changes are feature-scoped to Earn/Tron and do not affect core initialization paths.

Performance Test Selection:
Changes are limited to feature-specific UI components, hooks, and Snap utilities for Tron staking. There are no modifications to core rendering infrastructure, large lists (accounts/tokens), Engine initialization, onboarding, login, swaps, predictions, perps, or asset loading mechanisms. Therefore, no measurable performance-critical paths are impacted.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@Matt561 Matt561 self-requested a review March 18, 2026 14:43
@github-actions

Copy link
Copy Markdown
Contributor

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

@ulissesferreira ulissesferreira added this pull request to the merge queue Mar 18, 2026
Merged via the queue into main with commit d350b8d Mar 18, 2026
199 of 201 checks passed
@ulissesferreira ulissesferreira deleted the NEB-576-withdraw-unstaked-tron branch March 18, 2026 15:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

INVALID-PR-TEMPLATE PR's body doesn't match template release-7.71.0 Issue or pull request that will be included in release 7.71.0 risk-medium Moderate testing recommended · Possible bug introduction risk size-L team-networks Networks team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants