Skip to content

fix: handle prefilled Tempo fee payer signatures#4660

Merged
jxom merged 6 commits into
wevm:mainfrom
struong:struong/fix-tempo-single-roundtrip-sponsorship
May 24, 2026
Merged

fix: handle prefilled Tempo fee payer signatures#4660
jxom merged 6 commits into
wevm:mainfrom
struong:struong/fix-tempo-single-roundtrip-sponsorship

Conversation

@struong
Copy link
Copy Markdown
Contributor

@struong struong commented May 24, 2026

Summary

Fixes single-roundtrip Tempo sponsorship when eth_fillTransaction returns a prefilled fee payer signature. Keeps fill-response call expansion opt-in via _capabilities.autoSwap instead of automatically trusting transaction.calls returned by the relay.

Motivation

serializeTempo previously emitted a partial sponsorship handoff even when both sender and fee payer signatures were already present, so withRelay made an unnecessary second eth_signRawTransaction round trip. The sponsorship sign payload also needed tighter feeToken handling so the sender does not commit to the fee token before final broadcast. Relay-provided transaction.calls should not be adopted automatically because a malicious relay could alter the call set; callers can explicitly include _capabilities.autoSwap.calls when they want that behavior.

Changes

  • Preserved caller-provided calls in prepareTransactionRequest and exposed autoSwap.calls through _capabilities for explicit caller opt-in.
  • Emitted a full 0x76 broadcast envelope when both signatures are present, allowing withRelay to broadcast without a second fee payer signing request.
  • Normalized prefilled fee payer signature handling and stripped feeToken from sender sign payloads and partial sponsorship handoffs while keeping it on the final broadcast envelope.
  • Added a patch changeset for the Tempo sponsorship serialization fix.

Testing

  • Added regression coverage that prepareTransactionRequest ignores relay transaction calls while exposing autoSwap.calls.
  • Added Tempo serialization coverage for full-envelope broadcast and feeToken stripping cases.
  • SKIP_GLOBAL_SETUP=true pnpm test --project core src/actions/wallet/prepareTransactionRequest.test.ts -t "ignores relay transaction"
  • pnpm test --project tempo src/tempo/Transaction.test.ts src/tempo/Transport.test.ts
  • pnpm biome check src/actions/wallet/prepareTransactionRequest.ts src/actions/wallet/prepareTransactionRequest.test.ts src/tempo/Transaction.ts src/tempo/Transaction.test.ts

@vercel
Copy link
Copy Markdown

vercel Bot commented May 24, 2026

@struong is attempting to deploy a commit to the Wevm Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 24, 2026

🦋 Changeset detected

Latest commit: b48edaf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
viem Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 24, 2026

Open in StackBlitz

npm i https://pkg.pr.new/viem@4660

commit: b48edaf

struong added 2 commits May 23, 2026 23:35
…eth_fillTransaction

The withRelay transport always made a second round trip to the relay
(eth_signRawTransaction) even when the fill response already carried
a feePayerSignature. Two fixes in serializeTempo:

1. When a feePayerSignature is already attached and the sender has
   signed, emit a full broadcast envelope (0x76) with both signatures
   instead of the partial fee-payer-format envelope (0x78).

2. Always strip feeToken from the sender's sign payload under
   sponsorship — previously this only happened when no
   feePayerSignature was present, causing the sender to commit to
   feeToken once the relay had pre-signed (violating TIP-76 and
   producing an invalid envelope).
…on` response

Relay fillers (e.g. Tempo sponsor autoSwap) may expand the user's calls
with additional preamble (token approvals, swaps) and sign over the
expanded set. Dropping the relay's calls during the fill-result merge
caused the broadcast envelope to omit the preamble, making the fee
payer signature unrecoverable on chain.
@struong struong force-pushed the struong/fix-tempo-single-roundtrip-sponsorship branch from 341abff to a66772d Compare May 24, 2026 03:35
@struong struong marked this pull request as ready for review May 24, 2026 03:40
Comment on lines +431 to +442
// Adopt expanded calls from the fill response so the
// broadcast envelope matches what the fee payer signed over.
...('calls' in rest &&
Array.isArray(rest.calls) &&
rest.calls.length > 0
? {
calls: rest.calls,
to: undefined,
data: undefined,
value: undefined,
}
: {}),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think we should do this, as an eth_fillTransaction to a malicious relay may return "different" calls.
The prepareTransactionRequest action returns an autoSwap capability, so the consumer should use that to fill the calls for sign tx instead.

const request = client.prepareTransactionRequest(...)
const autoSwap = request._capabilities.autoSwap
const signature = await client.signTransaction(client, {
  ...request,
  calls: [...autoSwap.calls, ...request.calls]
})

@struong struong changed the title fix: handle single-roundtrip Tempo sponsorship fix: handle prefilled Tempo fee payer signatures May 24, 2026
@struong struong requested a review from jxom May 24, 2026 17:17
@jxom jxom merged commit c5cc58e into wevm:main May 24, 2026
21 of 28 checks passed
@github-actions github-actions Bot mentioned this pull request May 24, 2026
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