Skip to content

fix: canonical dispatch, HTTP-only compose, omit from wrap()#170

Merged
brendanjryan merged 2 commits intomainfrom
feat/multi-challenge-offer
Mar 10, 2026
Merged

fix: canonical dispatch, HTTP-only compose, omit from wrap()#170
brendanjryan merged 2 commits intomainfrom
feat/multi-challenge-offer

Conversation

@brendanjryan
Copy link
Collaborator

Summary

Follow-up to #166 — addresses code review findings for compose().

Changes

  1. Canonical dispatch fingerprint_internal now stores _canonicalRequest via PaymentRequest.fromMethod() (the schema-parsed form) instead of raw options. This ensures compose() dispatch narrowing works correctly with real methods like tempo.charge where fields are transformed (e.g. amount normalized by decimals).

  2. Added chainId to the narrowing fields (amount, currency, recipient, chainId).

  3. compose() restricted to HTTP transport:

    • Type-level: compose only appears on Mppx when transport extends Transport.Http
    • Runtime: throws "compose() only supports HTTP transport" on non-HTTP instances
  4. compose omitted from wrapped middlewareWrap type filters it out, wrap() removes it at runtime. Avoids exposing a raw HTTP handler on middleware-shaped objects. Users should use Mppx.compose() static instead.

Test coverage

  • Updated middleware test: compose is omitted from wrapped object
  • All 43 existing tests pass

…omit from wrap()

- Store schema-parsed canonical request in _internal instead of raw options
  so dispatch narrowing works with methods that transform fields (e.g. tempo)
- Add chainId to narrowing fields
- Runtime guard: compose() throws on non-HTTP transports
- Type-level: compose only present when transport extends Transport.Http
- Omit compose from wrapped middleware objects (type + runtime)
- Update test: compose is omitted from wrapped object
@brendanjryan brendanjryan force-pushed the feat/multi-challenge-offer branch from e4bdedc to e860153 Compare March 10, 2026 22:09
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 10, 2026

Open in StackBlitz

npm i https://pkg.pr.new/wevm/mppx@170

commit: 9bb9a25

- One-line if/throw for biome formatter
- Restore flat fields in _internal (method, defaults, options spread)
  so proxy service discovery keeps working
- Exclude _canonicalRequest from proxy resolvePayment spread
@brendanjryan brendanjryan merged commit 39c1ae4 into main Mar 10, 2026
8 checks passed
@brendanjryan brendanjryan deleted the feat/multi-challenge-offer branch March 10, 2026 23:03
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