Skip to content

fix(stellar-wallet-snap): txn history with empty account - #255

Open
stanleyyconsensys wants to merge 4 commits into
mainfrom
fix/contract-txn-receive
Open

fix(stellar-wallet-snap): txn history with empty account#255
stanleyyconsensys wants to merge 4 commits into
mainfrom
fix/contract-txn-receive

Conversation

@stanleyyconsensys

@stanleyyconsensys stanleyyconsensys commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Explanation

This PR improves @metamask/stellar-wallet-snap transaction history mapping for Soroban invoke-host-function transactions by detecting wallet-credited SAC transfer contract events in result_meta_xdr, allowing these credits (native and classic CODE:ISSUER) to be surfaced as Receive transactions rather than Unknown.

Changes:

  • Add generic parsing utilities to walk contract events from Horizon result_meta_xdr and safely parse SAC transfer events credited to a given account.
  • Extend TransactionMapper to map eligible invoke-host-function transactions as receives based on parsed contract events (native + classic assets).

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

@stanleyyconsensys
stanleyyconsensys requested a review from a team as a code owner September 2, 2026 08:55
@stanleyyconsensys stanleyyconsensys changed the title fix: txn history with empty account fix(stellar-wallet-snap): txn history with empty account Sep 2, 2026

Copilot AI 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.

🟡 Changes recommended

parseContractEventsFromResultMeta contains a confirmed switch fallthrough bug that breaks V3 meta parsing and can cause valid contract events to be dropped.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR improves @metamask/stellar-wallet-snap transaction history mapping for Soroban invoke-host-function transactions by detecting wallet-credited SAC transfer contract events in result_meta_xdr, allowing these credits (native and classic CODE:ISSUER) to be surfaced as Receive transactions rather than Unknown.

Changes:

  • Add generic parsing utilities to walk contract events from Horizon result_meta_xdr and safely parse SAC transfer events credited to a given account.
  • Extend TransactionMapper to map eligible invoke-host-function transactions as receives based on parsed contract events (native + classic assets).
  • Add fixtures and unit tests covering receive mapping for contract swap credits; update the package changelog.
File summaries
File Description
packages/stellar-wallet-snap/src/services/transaction/xdrParser.ts Adds contract-event extraction from result_meta_xdr and a safe SAC transfer parser for receive detection.
packages/stellar-wallet-snap/src/services/transaction/xdrParser.test.ts Adds unit tests for parsing credited SAC transfers from transaction meta.
packages/stellar-wallet-snap/src/services/transaction/TransactionMapper.ts Adds invoke-host-function receive fallback mapping driven by meta contract events.
packages/stellar-wallet-snap/src/services/transaction/TransactionMapper.test.ts Adds mapping coverage for native + USDC contract-swap receive scenarios.
packages/stellar-wallet-snap/src/services/transaction/mocks/horizon-transaction-responses.fixtures.ts Introduces Horizon fixtures containing result_meta_xdr with SAC transfer events.
packages/stellar-wallet-snap/CHANGELOG.md Adds an Unreleased “Fixed” entry describing the improved receive mapping.
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/stellar-wallet-snap/src/services/transaction/xdrParser.ts
Comment on lines +404 to +406
describe('parseContractEventsFromResultMeta', () => {
it('accumulates native SAC transfers credited to the wallet', () => {
const results = parseContractEventsFromResultMeta({

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

we cover it via fixture already

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