Skip to content

feat(client-utils): map Stellar trustline keyring transactions#9440

Open
jeremytsng wants to merge 3 commits into
mainfrom
feat/keyring-transaction-mapper-trustline
Open

feat(client-utils): map Stellar trustline keyring transactions#9440
jeremytsng wants to merge 3 commits into
mainfrom
feat/keyring-transaction-mapper-trustline

Conversation

@jeremytsng

@jeremytsng jeremytsng commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Explanation

@metamask/client-utils's mapKeyringTransaction (#9376) doesn't yet handle Stellar trustline TokenApprove/TokenDisapprove transactions — they fall through to approveSpendingCap/contractInteraction like any other token approval, which shows a spending-cap UI for what's actually a trustline activation/deactivation (not a token transfer).

metamask-extension#44200 added this mapping locally in its own adapter ahead of Core support, keyed off a details.typeLabel of trustline-approve/trustline-disapprove. This PR ports that mapping into the canonical keyring-transaction-mapper so Extension can switch over to it, per review discussion on that PR.

Changes:

  • Add assetActivation/assetDeactivation to ActivityKind and a matching
    ActivityItem data shape ({ from?, token?, fees? }).
  • Port CustomTransactionTypeLabel and hasTrustlineTypeLabel from the extension adapter.
  • TokenApprove now branches to assetActivation for trustline ops before falling into the existing approveSpendingCap logic.
  • Add a TokenDisapprove case (previously unhandled — fell through to contractInteraction via default): branches to assetDeactivation for trustline
    ops, otherwise keeps the existing contractInteraction fallback.
  • Trustline items clear the token amount (matching the spending-cap "unlimited" pattern) since a trustline change isn't a token transfer and shouldn't show a total.

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

Note

Low Risk
Scoped to activity-type mapping in client-utils; behavior change is limited to trustline-labeled keyring transactions, with non-trustline paths unchanged.

Overview
Adds assetActivation and assetDeactivation to shared activity types and teaches mapKeyringTransaction to recognize Stellar trustline operations via details.typeLabel (trustline-approve / trustline-disapprove).

TokenApprove with a trustline label now maps to assetActivation instead of approveSpendingCap. A dedicated TokenDisapprove branch maps trustline revokes to assetDeactivation; other disapproves still become contractInteraction. Trustline items strip token amount so the activity UI does not imply a transfer.

Includes fixtures, unit tests, and an unreleased changelog entry so extension can drop its local adapter.

Reviewed by Cursor Bugbot for commit 1819d25. Bugbot is set up for automated code reviews on this repo. Configure here.

…etActivation/assetDeactivation

Ports the trustline mapping added in metamask-extension#44200 into
the canonical keyring-transaction-mapper: TokenApprove/TokenDisapprove
transactions carrying a trustline details.typeLabel now map to new
assetActivation/assetDeactivation activity kinds instead of
approveSpendingCap/contractInteraction, with the token amount cleared
to avoid showing a zero total. Non-trustline TokenDisapprove now maps
to contractInteraction (previously unhandled, falling through to the
same default).
@jeremytsng jeremytsng marked this pull request as ready for review July 9, 2026 06:06
@jeremytsng jeremytsng requested review from a team as code owners July 9, 2026 06:06

@stanleyyconsensys stanleyyconsensys left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plz change the PR title to skip stellar
it doesnt have to be stellar, xrpl (the next non evm) using trustline to

Comment thread packages/client-utils/CHANGELOG.md Outdated
Co-authored-by: Stanley Yuen <102275989+stanleyyconsensys@users.noreply.github.com>
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