Skip to content

fix(tron-wallet-snap): correct behavior for trc20 transfer type transactions - #134

Open
gabrieledm wants to merge 9 commits into
mainfrom
fix/tron/WPN-1745_sun-USDT-swap-incorrect-total-amount-of-0
Open

fix(tron-wallet-snap): correct behavior for trc20 transfer type transactions#134
gabrieledm wants to merge 9 commits into
mainfrom
fix/tron/WPN-1745_sun-USDT-swap-incorrect-total-amount-of-0

Conversation

@gabrieledm

Copy link
Copy Markdown
Contributor

Explanation

Fixes Tron transaction activity displaying 0 SUN or -0 SUN for SUN -> USDT swaps routed through Rango and SunSwap.

TronGrid returns a zero-value Approval event before the actual outgoing SUN Transfer.
The transaction mapper previously selected the first event sent by the account, causing the approval to be treated as the swap’s source leg.

Swap detection now considers only Transfer events when selecting source and destination token movements.
This preserves existing approval handling while displaying the actual SUN amount in activity history.

A regression test covers the reported event ordering and verifies that 276.791363098075785381 SUN -> 4.891342 USDT is mapped correctly.

Testing

  • Added regression coverage for an approval event preceding the SUN transfer.
  • Verified existing TRC-20 swap, send, receive, and approval tests.
  • Ran the complete Tron wallet Snap test suite.
  • Ran TypeScript, ESLint, formatting, and diff checks.

References

Fixes: WPN-1745

Before

WPN-1745  Extension - Before

After

WPN-1745  Extension - After

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

@gabrieledm
gabrieledm requested a review from a team as a code owner August 6, 2026 14:37
@gabrieledm

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/bitcoin-wallet-snap@2.0.1-preview-05ea60a5
@metamask-previews/snap-networks-utils@1.0.0-preview-05ea60a5
@metamask-previews/solana-wallet-snap@5.0.1-preview-05ea60a5
@metamask-previews/tron-wallet-snap@3.0.0-preview-05ea60a5

@gabrieledm gabrieledm changed the title fix: correct behavior for trc20 transfer type transactions fix(tron-wallet-snap): correct behavior for trc20 transfer type transactions Aug 7, 2026
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.

1 participant