Skip to content

fix(core): prevent distributive conditional type in GetClientReturnType#5136

Open
quentin-lian wants to merge 1 commit into
wevm:mainfrom
quentin-lian:fix/getClient-multichain-type
Open

fix(core): prevent distributive conditional type in GetClientReturnType#5136
quentin-lian wants to merge 1 commit into
wevm:mainfrom
quentin-lian:fix/getClient-multichain-type

Conversation

@quentin-lian
Copy link
Copy Markdown

Summary

Wraps the conditional in GetClientReturnType with tuple types ([resolvedChainId] extends [...]) to prevent TypeScript from distributing over multi-chain resolvedChainId unions.

Without this fix, getClient(config) on a multi-chain config returns Client<_, chainA> | Client<_, chainB> (a union of clients), which is incompatible with viem actions that expect Client<Transport, chain>. With the fix, it returns Client<_, chainA | chainB> (a single client with a union chain), which TypeScript can match correctly.

Changes

  • packages/core/src/actions/getClient.ts — one-line fix: [resolvedChainId] extends [config['chains'][number]['id']]
  • packages/core/src/actions/getClient.test-d.ts — type regression test covering waitForTransactionReceipt, getBlock, and getTransaction with a two-chain config
  • .changeset/fix-getClient-multichain-type.md — patch changeset for @wagmi/core

Validation

  • pnpm --filter @wagmi/core check:types passes with no errors
  • biome check passes

Closes #3635

Wrap the conditional in `GetClientReturnType` with tuple types to stop
TypeScript from distributing over multi-chain `resolvedChainId` unions.
This allows the client returned by `getClient` to be passed directly
into viem actions (waitForTransactionReceipt, getBlock, getTransaction)
when the config has multiple chains.

Closes wevm#3635
@vercel
Copy link
Copy Markdown

vercel Bot commented May 24, 2026

@quentin-lian 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: c5e7e1d

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

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.

bug: waitForTransactionReceipt doesn't accept client with multiple possible chains

1 participant