Skip to content

Conversation

@runway-github
Copy link
Contributor

@runway-github runway-github bot commented Dec 19, 2025

Description

  • Improves Tron error handling by showing user friendly error messages
    instead of raw error codes.
  • Updates TRX staking input so Max skips the EVM modal.
  • Triggers Tron balances update after the staking operation.
  • Tron snap update to the latest version

Changelog

CHANGELOG entry: null

Related issues

Fixes:

Manual testing steps

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Before

After

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

Improves TRON staking/unstaking UX with localized errors, immediate balance refresh, and live TRX balances in asset overview; also skips EVM max modal for TRX and adds supporting tests.

  • TRON staking/unstaking UX:
    • Localizes error messages via getLocalizedErrorMessage; maps InsufficientBalance to i18n key (en.json).
    • On successful stake/unstake, calls MultichainBalancesController.updateBalance(accountId) and navigates to success sheet; logs on failure.
    • Passes tronAccountId from useTronStake/useTronUnstake to handleTronStakingNavigationResult.
    • Skips EVM MaxInputModal for TRX and treats right action as preview/done; updates tests to assert behavior.
  • Asset overview (TRON):
    • Uses live TRX asset data via selectAsset to source balance/balanceFiat instead of navigation params when on tron: chain.
  • Hooks & tests:
    • useTronStake/useTronUnstake: expose tronAccountId; corresponding unit tests added.
    • Expanded tests for TRON earn input flow and tron utils (localization and balance refresh).
  • Misc:
    • Minor snapshot updates.

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

118250c

…improvements (#23927)

<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

- Improves Tron error handling by showing user friendly error messages
instead of raw error codes.
- Updates TRX staking input so Max skips the EVM modal.
- Triggers Tron balances update after the staking operation.
- Tron snap update to the latest version


## **Changelog**

<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`

If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`

(This helps the Release Engineer do their job more quickly and
accurately)
-->

CHANGELOG entry: null

## **Related issues**

Fixes:

## **Manual testing steps**

```gherkin
Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]
```

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [ ] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

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


<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Refines Tron staking/unstaking UX (Max/preview), localizes errors,
refreshes balances after actions, uses live Tron balances in Asset
Overview, and bumps tron-wallet-snap.
> 
> - **Tron staking/unstaking UX**:
> - `EarnInputView`/`EarnWithdrawInputView`: Right action for TRX shows
preview or sets `Max` without EVM modal; passes `tronAccountId` to
navigation result handler.
>   - Hooks `useTronStake`/`useTronUnstake`: expose `tronAccountId`.
> - `handleTronStakingNavigationResult`: refreshes balances via
`MultichainBalancesController.updateBalance(accountId)` on success.
> - **Error localization**:
> - Add `getLocalizedErrorMessage` mapping (e.g., `InsufficientBalance`
→ `stake.tron.errors.insufficient_balance`).
> - Update `locales/languages/en.json` with
`stake.tron.errors.insufficient_balance`.
> - **Asset Overview (TRON)**:
> - Prefer live asset data via `selectAsset` for TRON (`balance`,
`balanceFiat`) instead of navigation params.
> - **Dependencies**:
>   - Bump `@metamask/tron-wallet-snap` to `^1.16.1`.
> - **Tests**:
> - Add/update tests for TRX Max behavior (no MaxInputModal), account ID
exposure, balance refresh, and error localization.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
3871f24. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@runway-github runway-github bot requested review from a team as code owners December 19, 2025 19:08
@github-actions
Copy link
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-bots Bot team (for MetaMask Bot, Runway Bot, etc.) label Dec 19, 2025
@github-actions
Copy link
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeStake, SmokeAssets, SmokeRamps, SmokeAnalytics
  • Risk Level: medium
  • AI Confidence: 85%
click to see 🤖 AI reasoning details

Analysis Summary

The PR introduces new Tron staking/unstaking functionality into the existing Earn feature, along with related UI changes and analytics updates. Here's my detailed analysis:

Changed Files Breakdown:

1. New Tron Staking Hooks (NEW FILES):

  • useTronStake.ts & useTronStake.test.ts - New hook for Tron staking with validation and confirmation logic
  • useTronUnstake.ts & useTronUnstake.test.ts - New hook for Tron unstaking with resource management
  • tron.ts & tron.test.ts - Utility functions for Tron staking navigation and error handling

2. UI Components Modified:

  • EarnInputView.tsx - Major refactor to support Tron staking flow with preview mode, resource toggles, and conditional rendering
  • EarnWithdrawInputView.tsx - Similar changes for Tron unstaking flow
  • AssetOverview.tsx - Enhanced with live Tron balance updates and updated analytics for ramps button click tracking

3. Supporting Changes:

  • EarnInputView.test.tsx.snap - Updated snapshot for tests
  • en.json - Localization strings for Tron staking/unstaking messages and various UI updates

Key Feature Changes:

  1. Tron Staking Integration: Completely new staking/unstaking flow for TRX token with resource type selection (ENERGY vs BANDWIDTH)
  2. Asset Display: Live balance refresh for Tron assets in AssetOverview
  3. Analytics Enhancement: Updated ramps button analytics to use useRampsButtonClickData hook with expanded tracking properties
  4. UI/UX Updates: Preview mode for Tron transactions, "Done" button behavior, resource toggles

Risk Assessment:

Medium Risk because:

  • This is a NEW feature addition (Tron staking) rather than modification of existing critical paths
  • Changes are conditionally compiled (BEGIN:ONLY_INCLUDE_IF(tron)) meaning they won't affect non-Tron functionality
  • No changes to core Engine, Controllers, or critical infrastructure
  • Changes are well-isolated to Earn/Stake components
  • Includes comprehensive unit tests for new functionality
  • Analytics changes could affect tracking but are low-impact

Test Tag Selection Rationale:

1. SmokeStake ✅ PRIMARY TAG

  • Why: Direct changes to staking functionality with new Tron staking/unstaking flows
  • Coverage: The existing stake-action-smoke.spec.ts tests ETH staking; while it doesn't test Tron specifically, it validates the general staking flow that was modified
  • Impact: EarnInputView and EarnWithdrawInputView are core to staking operations

2. SmokeAssets ✅ RECOMMENDED

  • Why: AssetOverview.tsx modified with live balance updates for Tron
  • Coverage: Asset display, balance refresh logic, token overview functionality
  • Impact: Changes affect how asset balances are displayed, particularly for Tron tokens

3. SmokeRamps ✅ RECOMMENDED

  • Why: Analytics changes to ramps button click tracking in AssetOverview
  • Coverage: Ramps button behavior, buy flow initiation, analytics payload
  • Impact: While changes are analytics-focused, they modify the ramps button click handler flow

4. SmokeAnalytics ✅ RECOMMENDED

  • Why: Multiple analytics tracking updates (RAMPS_BUTTON_CLICKED event, expanded properties)
  • Coverage: Validates analytics events are properly fired
  • Impact: Ensures tracking infrastructure works correctly with new data

Tags NOT Selected:

  • SmokeWalletUX: While UI changes occurred, they're isolated to Earn/Stake flows already covered by SmokeStake
  • SmokeNetworkExpansion: Tron isn't a "new" network addition here; this is feature expansion on existing Tron support
  • SmokeCore: No changes to core wallet functionality, Engine, or Controllers
  • Others: Not relevant to these specific changes

Confidence: 85%

High confidence due to:

  • Clear understanding of changes through thorough diff analysis
  • Well-scoped feature addition with conditional compilation
  • Comprehensive unit test coverage indicates stable changes
  • Changes don't touch critical infrastructure

Lower than 100% because:

  • No existing E2E tests specifically for Tron staking (new feature)
  • Some uncertainty about the full extent of analytics tracking validation in E2E tests

View GitHub Actions results

@joaoloureirop joaoloureirop added the skip-e2e skip E2E test jobs label Dec 19, 2025
@joaoloureirop joaoloureirop merged commit 2064816 into release/7.61.3 Dec 19, 2025
49 checks passed
@joaoloureirop joaoloureirop deleted the runway-cherry-pick-7.61.3-1766171278 branch December 19, 2025 19:21
@github-actions github-actions bot locked and limited conversation to collaborators Dec 19, 2025
@metamaskbot metamaskbot added the release-7.61.3 Issue or pull request that will be included in release 7.61.3 label Dec 19, 2025
@metamaskbot
Copy link
Collaborator

No release label on PR. Adding release label release-7.61.3 on PR, as PR was cherry-picked in branch 7.61.3.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.61.3 Issue or pull request that will be included in release 7.61.3 size-M skip-e2e skip E2E test jobs team-bots Bot team (for MetaMask Bot, Runway Bot, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants