Skip to content

fix: allow prepareTransactionRequest with calls and no top-level to#5079

Merged
tmm merged 3 commits into
wevm:mainfrom
deodad:fix/prepare-transaction-request-calls-without-to
Apr 28, 2026
Merged

fix: allow prepareTransactionRequest with calls and no top-level to#5079
tmm merged 3 commits into
wevm:mainfrom
deodad:fix/prepare-transaction-request-calls-without-to

Conversation

@deodad
Copy link
Copy Markdown
Contributor

@deodad deodad commented Apr 24, 2026

Problem

prepareTransactionRequest (both the core action and the query options used by usePrepareTransactionRequest) requires a top-level to parameter. The query options hardcode:

enabled: Boolean(options.to && (options.query?.enabled ?? true))
// ...
if (!parameters.to) throw new Error('to is required')

This makes it impossible to use with batched calls (e.g. EIP-5792 sendCalls flows) where each call carries its own to address and no top-level to is needed. Viem's underlying prepareTransactionRequest does not have this restriction.

Fix

  • Make to optional in the action's type definition
  • Update enabled guard to accept calls as an alternative to to
  • Update queryFn guard to allow calls without to
  • Add test for calls-only usage

prepareTransactionRequest (both the action and query options) previously
required a top-level `to` parameter. This made it impossible to use with
batched `calls` where each call carries its own `to` address (e.g.
EIP-5792 sendCalls flows).

- Make `to` optional in the action's type definition
- Update `enabled` guard to accept `calls` as an alternative to `to`
- Update `queryFn` guard to allow `calls` without `to`
- Add test for calls-only usage

Amp-Thread-ID: https://ampcode.com/threads/T-019dc057-ceff-76be-b95e-13c3135b46a2
Co-authored-by: Amp <amp@ampcode.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 24, 2026

@deodad 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 Apr 24, 2026

🦋 Changeset detected

Latest commit: faefa62

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

This PR includes changesets to release 5 packages
Name Type
@wagmi/core Patch
@wagmi/connectors Patch
wagmi Patch
@wagmi/solid Patch
@wagmi/vue 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

@tmm tmm merged commit 2a9795d into wevm:main Apr 28, 2026
6 of 20 checks passed
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