Commit 5fd9eb9
authored
chore: broadcast staking TRX transaction (MetaMask#22522)
<!--
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**
Staking and unstaking methods connected to the tron-snap:
https://github.com/user-attachments/assets/a7f66644-1a44-4035-9e06-64c2ff71322f
<img width="1323" height="45" alt="Screenshot 2025-11-19 at 17 54 46"
src="https://github.com/user-attachments/assets/9ebe514b-2333-4b0a-ab12-969c48aa22bd"
/>
Example:
https://tronscan.org/address/TGXFnQBLAdbdkupHUGSpeBfbxB72hkMsh2#/transaction/85bfd85b620e6a8fc5966458cbfcf3a9757454917f78c36b675e223b68564499
## **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]
> Integrates TRON staking and unstaking via Snap, updating Earn flows,
lists, and selectors to support TRX with new validation, previews, and
navigation.
>
> - **TRON staking/unstaking integration**:
> - Add `useTronStake` and `useTronUnstake` hooks for
validation/confirmation via `tron-staking-snap`.
> - New utils: `tron-staking-snap` (Snap RPCs), `tron`
(navigation/result handling, token builder, staked total).
> - Add `TronStakePreview` UI for fee preview; reuse `ResourceToggle`.
> - **Earn Input/Withdraw flows** (`EarnInputView.tsx`,
`EarnWithdrawInputView.tsx`):
> - Wire TRX validation on keypad input; confirm flows call Snap and
navigate to success/error sheets.
> - Show Tron-specific UI (resource toggle, fee preview) and simplified
button labels; adjust disabled/loading states.
> - Limit gas-cost warning to `isETH` only; debounce validation handler.
> - **Token list and selection**:
> - `EarnTokenList`: include TRX native in deposit list (even with zero
balance when enabled); navigate without EVM network switch; sorting
updated.
> - `EarnTokenSelector`: render output token for withdraw; earn token
for stake.
> - **Selectors and data plumbing**:
> - Support non-EVM (TRX) balances/tokens in earn selectors; default TRX
pooled-staking APR to `0`.
> - Add unified multichain token selector including non-EVM; filter Tron
resource/testnet assets; use `getDecimalChainId`.
> - **Utilities/constants/i18n**:
> - Add `normalizeToDotDecimal`; `TronResourceType` constant; new TRON
strings (fee, success/error copy).
> - **Tests**: Extensive new/updated tests for views, hooks, lists,
buttons, selectors, and utils; snapshot updates.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
0989d7f. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent e179270 commit 5fd9eb9
35 files changed
Lines changed: 2850 additions & 208 deletions
File tree
- app
- components/UI
- Earn
- Views
- EarnInputView
- __snapshots__
- EarnWithdrawInputView
- components
- EarnTokenList
- EarnTokenSelector
- Tron
- StakePreview
- TronStakingButtons
- hooks
- types
- utils
- Stake/components/StakeButton
- core/Multichain
- selectors
- earnController/earn
- multichain
- util/number
- locales/languages
Lines changed: 66 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
583 | 583 | | |
584 | 584 | | |
585 | 585 | | |
586 | | - | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
587 | 603 | | |
588 | 604 | | |
589 | 605 | | |
590 | 606 | | |
591 | 607 | | |
592 | 608 | | |
593 | 609 | | |
594 | | - | |
595 | | - | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
596 | 613 | | |
597 | 614 | | |
598 | 615 | | |
| |||
609 | 626 | | |
610 | 627 | | |
611 | 628 | | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
612 | 675 | | |
613 | 676 | | |
614 | 677 | | |
| |||
Lines changed: 101 additions & 64 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | | - | |
| 24 | + | |
27 | 25 | | |
28 | 26 | | |
29 | 27 | | |
| |||
76 | 74 | | |
77 | 75 | | |
78 | 76 | | |
79 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
80 | 83 | | |
81 | 84 | | |
82 | 85 | | |
| |||
113 | 116 | | |
114 | 117 | | |
115 | 118 | | |
116 | | - | |
117 | | - | |
118 | 119 | | |
119 | 120 | | |
120 | 121 | | |
| |||
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
131 | | - | |
132 | | - | |
133 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
134 | 142 | | |
135 | 143 | | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
156 | 149 | | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
| 150 | + | |
166 | 151 | | |
167 | 152 | | |
168 | 153 | | |
| |||
479 | 464 | | |
480 | 465 | | |
481 | 466 | | |
482 | | - | |
| 467 | + | |
483 | 468 | | |
484 | 469 | | |
485 | 470 | | |
| |||
589 | 574 | | |
590 | 575 | | |
591 | 576 | | |
| 577 | + | |
592 | 578 | | |
593 | 579 | | |
594 | 580 | | |
| |||
598 | 584 | | |
599 | 585 | | |
600 | 586 | | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
601 | 595 | | |
602 | 596 | | |
603 | 597 | | |
| |||
612 | 606 | | |
613 | 607 | | |
614 | 608 | | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
615 | 615 | | |
616 | 616 | | |
617 | 617 | | |
| |||
700 | 700 | | |
701 | 701 | | |
702 | 702 | | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
703 | 722 | | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
704 | 730 | | |
705 | 731 | | |
706 | 732 | | |
| |||
867 | 893 | | |
868 | 894 | | |
869 | 895 | | |
870 | | - | |
| 896 | + | |
871 | 897 | | |
872 | 898 | | |
873 | 899 | | |
| |||
889 | 915 | | |
890 | 916 | | |
891 | 917 | | |
892 | | - | |
893 | | - | |
894 | | - | |
895 | | - | |
896 | | - | |
897 | | - | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
898 | 940 | | |
899 | | - | |
900 | | - | |
901 | | - | |
902 | | - | |
903 | | - | |
904 | | - | |
905 | | - | |
906 | | - | |
907 | | - | |
908 | | - | |
909 | | - | |
910 | | - | |
911 | | - | |
912 | | - | |
913 | | - | |
914 | | - | |
| 941 | + | |
915 | 942 | | |
916 | 943 | | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
917 | 954 | | |
918 | 955 | | |
919 | 956 | | |
| |||
922 | 959 | | |
923 | 960 | | |
924 | 961 | | |
925 | | - | |
| 962 | + | |
926 | 963 | | |
927 | 964 | | |
928 | 965 | | |
| |||
938 | 975 | | |
939 | 976 | | |
940 | 977 | | |
941 | | - | |
| 978 | + | |
942 | 979 | | |
943 | 980 | | |
944 | 981 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1947 | 1947 | | |
1948 | 1948 | | |
1949 | 1949 | | |
1950 | | - | |
| 1950 | + | |
1951 | 1951 | | |
1952 | 1952 | | |
1953 | 1953 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
782 | 782 | | |
783 | 783 | | |
784 | 784 | | |
785 | | - | |
| 785 | + | |
786 | 786 | | |
787 | 787 | | |
788 | 788 | | |
| |||
0 commit comments