Skip to content

feat: preserve method-specific receipt extension fields#612

Open
IkerAlus wants to merge 1 commit into
wevm:mainfrom
IkerAlus:main
Open

feat: preserve method-specific receipt extension fields#612
IkerAlus wants to merge 1 commit into
wevm:mainfrom
IkerAlus:main

Conversation

@IkerAlus

@IkerAlus IkerAlus commented Jul 2, 2026

Copy link
Copy Markdown

The core spec's Payment-Receipt section allows method specifications to define additional receipt fields, but Receipt.Schema strips unknown fields on parse. Hence servers can't emit them (Receipt.from) and no mppx client can read them (Receipt.fromResponse, the fetch client, the CLI).

This PR loosens the runtime schema while keeping the exported Receipt type unchanged:

  • Receipt.Schema is now z.looseObject(shape); unknown fields survive from / serialize / deserialize / fromResponse round-trips. Known-field validation is unchanged.
  • Producers pass extension fields through Receipt.from; consumers type them via intersection (Receipt.Receipt & { originTxHash: string }).

Motivation: the new nearintents method (cross-chain settlement) requires originTxHash and challengeId in its receipt (a cross-chain payment has two legs, and reference only carries the destination-side tx). Our plan is to ship the method as a standalone package per the custom-payment-methods guide. This is the one core touchpoint a package can't work around, because the stripping happens on the client side.

Also, the repo already assumes extended receipts in places, the CLI renders arbitrary receipt fields (and explorer-links txHash), and tempo session receipts carry channelId / acceptedCumulative / spent. This aligns the core schema with that.

Backward compatible: existing methods emit unchanged receipts; older clients strip extras exactly as today. Tests added for preservation, round-trip, and validation-with-extensions; changeset included.

The core spec's Payment-Receipt section allows method specifications
to define additional receipt fields. Parse receipts with a loose
schema so unknown fields survive from/serialize/deserialize round
trips instead of being stripped, keeping the exported Receipt type
unchanged (base fields only, no index signature).
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