Skip to content

feat(tron): populate transaction_type on lifecycle events - #399

Merged
Battambang merged 3 commits into
mainfrom
feat/tron-non-evm-transaction-type-lifecycle-events
Oct 1, 2026
Merged

Battambang merged 3 commits into
mainfrom
feat/tron-non-evm-transaction-type-lifecycle-events

Conversation

@Battambang

Copy link
Copy Markdown
Contributor

Explanation

Stacked on #393. Transaction lifecycle events emitted by the Tron snap could not be attributed to a flow: the payload carried origin but no classification, so an in-app send, a dApp signTransaction, and a staking operation were indistinguishable.

This adopts the optional transaction_type property that #393 introduces in @metamask/snap-networks-utils, following the same pattern as the Bitcoin change.

mapRawTransactionType (new, src/utils/transactionType.ts) classifies a transaction from its contract type using the @metamask/keyring-api TransactionType vocabulary:

Contract type transaction_type
TransferContract, TransferAssetContract send
FreezeBalanceContract, FreezeBalanceV2Contract stake:deposit
UnfreezeBalanceContract, UnfreezeBalanceV2Contract, WithdrawExpireUnfreezeContract stake:withdraw
anything else unknown

Call sites

  • ConfirmationHandler reports the contract type for dApp signTransaction confirmations, and send for the unified send confirmation, which is only reachable from the send flow.
  • SendService and the Wallet Standard signAndSendTransaction report the type of the transaction they broadcast.
  • CronHandler reports the type resolved at submit time, carried through the onTrackTransaction background event.

Two notes on the classification

  • A smart-contract call is reported as unknown. It cannot be classified before confirmation without an ABI, which matches the Bitcoin precedent of reporting unknown for the arbitrary-PSBT confirmation.
  • The type is carried through the background event rather than re-derived in the cron because gettransactioninfobyid does not return raw_data. Without this, Transaction Finalized could not report a type at all.

References

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

@Battambang
Battambang added this pull request to stack #400 October 1, 2026 08:53
@Battambang
Battambang requested a review from a team as a code owner October 1, 2026 08:53
@Battambang
Battambang deployed to default-branch October 1, 2026 08:53 — with GitHub Actions Active
Base automatically changed from feat/non-evm-transaction-type-lifecycle-events to main October 1, 2026 14:09
Transaction lifecycle events could not be attributed to a flow: the
payload carried `origin` but no classification, so an in-app send, a dApp
`signTransaction`, and a staking operation were indistinguishable.

Classify each event from the contract type with a new
`mapRawTransactionType` helper, reusing the `@metamask/keyring-api`
`TransactionType` vocabulary:

- `ConfirmationHandler` reports the contract type for dApp
  `signTransaction` confirmations, and `send` for the unified send
  confirmation, which is only reachable from the send flow.
- `SendService` and the Wallet Standard `signAndSendTransaction` report
  the type of the transaction they broadcast.
- `CronHandler` reports the type resolved at submit time, carried through
  the background event, because `gettransactioninfobyid` does not return
  `raw_data` to re-derive it from.

A smart-contract call is reported as `unknown`: it cannot be classified
before confirmation without an ABI.
The entry referenced the stack base (#393) because the branch had no PR
number yet. Use the actual PR.
@Battambang
Battambang force-pushed the feat/tron-non-evm-transaction-type-lifecycle-events branch from 82f501a to 8f86c24 Compare October 1, 2026 14:13
The cron job stored the submit-time classification as a string, which
no longer matches the lifecycle event property.
@sonarqubecloud

sonarqubecloud Bot commented Oct 1, 2026

Copy link
Copy Markdown

@Battambang

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@Battambang
Battambang added this pull request to the merge queue Oct 1, 2026
Merged via the queue into main with commit 55ca3b9 Oct 1, 2026
56 checks passed
@Battambang
Battambang deleted the feat/tron-non-evm-transaction-type-lifecycle-events branch October 1, 2026 14:53
@github-actions

github-actions Bot commented Oct 1, 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@3.1.0-preview-4953702
@metamask-previews/snap-networks-utils@1.0.0-preview-4953702
@metamask-previews/solana-wallet-snap@7.0.0-preview-4953702
@metamask-previews/stellar-wallet-snap@1.1.0-preview-4953702
@metamask-previews/tron-wallet-snap@4.0.0-preview-4953702

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.

2 participants