Skip to content

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

Merged
jeremytsng merged 3 commits into
mainfrom
feat/keyring-transaction-mapper-trustline
Jul 10, 2026
Merged

feat(client-utils): map Stellar trustline keyring transactions#9440
jeremytsng merged 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 mapper and type additions with tests; non-trustline approve/disapprove behavior is unchanged aside from an explicit TokenDisapprove path that still falls back to contractInteraction.

Overview
mapKeyringTransaction now recognizes Stellar trustline operations via details.typeLabel (trustline-approve / trustline-disapprove) instead of treating them like generic token approvals.

TokenApprove with a trustline label maps to assetActivation (token amount cleared so the UI does not show a transfer total). TokenDisapprove gets an explicit branch: trustline → assetDeactivation, otherwise contractInteraction as before.

Shared types add assetActivation and assetDeactivation to ActivityKind and ActivityItem. CustomTransactionTypeLabel and hasTrustlineTypeLabel are exported from the keyring mapper (ported from extension). Tests and changelog updated.

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

@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
…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 force-pushed the feat/keyring-transaction-mapper-trustline branch from 1819d25 to 9c57290 Compare July 10, 2026 04:52
@jeremytsng jeremytsng force-pushed the feat/keyring-transaction-mapper-trustline branch from 9c57290 to dc50e53 Compare July 10, 2026 04:54

@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.

LGTM

@jeremytsng jeremytsng added this pull request to the merge queue Jul 10, 2026
Merged via the queue into main with commit 288b4e9 Jul 10, 2026
421 checks passed
@jeremytsng jeremytsng deleted the feat/keyring-transaction-mapper-trustline branch July 10, 2026 08:25
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.

3 participants