Skip to content

fix: pass args when decoding simulateBlocks call results - #5620

Merged
jxom merged 1 commit into
wevm:mainfrom
mortezashojaei:fix/simulate-blocks-overload-args
Nov 20, 2026
Merged

jxom merged 1 commit into
wevm:mainfrom
mortezashojaei:fix/simulate-blocks-overload-args

Conversation

@mortezashojaei

Copy link
Copy Markdown
Contributor

simulateBlocks encodes a contract call with its args, so the matching overload runs, but it decodes the result without them. decodeFunctionResult then picks an overload with getAbiItem's no-args fallback: the zero-input overload if there is one, otherwise the first match in the ABI. simulateCalls returns the same results, since it goes through simulateBlocks.

With an overloaded function whose overloads have different outputs, the result comes from the wrong overload:

  • With ownerOf() returns (uint256) next to ownerOf(uint256) returns (address), ownerOf(420n) on the wagmi contract returns 946538057168212150337809235825562151080949086380n instead of 0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC, with no error.
  • When the wrong overload's outputs cannot decode the data (e.g. bool), the whole simulateBlocks call rejects with Bytes value "…" is not a valid boolean.

readContract, simulateContract and multicall already pass args to decodeFunctionResult, and readContract returns the address for the same ABI and args. The simulateBlocks docs describe contract calls as identified by abi, functionName and args.

This passes args to decodeFunctionResult in simulateBlocks, and in Tempo's simulate.simulateBlocks, which has the same decode call. args was already destructured there and passed to getContractError. Results for functions without overloads are unchanged.

  • Added a behavior: overloaded function test to src/actions/public/simulateBlocks.test.ts that runs against Anvil. It fails without this change (the result is the uint256).
  • Added a patch changeset.

Checks run:

  • pnpm test --run src/actions/public/simulateBlocks.test.ts src/actions/public/simulateCalls.test.ts --maxWorkers=1: 48 passed.
  • Biome on the changed files.
  • The Tempo change was not run locally (no Docker here), and pnpm check:types was not run because tsc runs out of memory on my machine.

@vercel

vercel Bot commented Nov 20, 2026

Copy link
Copy Markdown

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

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Nov 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5f9b8a9

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

@erkancamli

Copy link
Copy Markdown
Contributor

Checked the decode step on its own on 5f9b8a9: with the two ownerOf overloads from the new test and the 0x…a5cc3c03… return word, decodeFunctionResult without args picks ownerOf() and returns 946538057168212150337809235825562151080949086380n; with args: [420n] it returns the address. So before this change an overloaded call came back as the wrong type, with no error.

simulateCalls passes each call's abi and args straight into simulateBlocks (simulateCalls.ts:295), so it gets the fix as well; a case there might be worth adding, since that is the entry point most callers use. The Tempo copy in src/tempo/actions/simulate.ts gets the same one-line change but no test.

I also went through the other decodeFunctionResult call sites under src/actions and src/tempo: the ones that take a caller's ABI (readContract, simulateContract, multicall) already pass args, and the rest use fixed internal ABIs without overloads, so this looks like the last one.

@jxom
jxom merged commit 2395eba into wevm:main Nov 20, 2026
28 of 35 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 20, 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.

3 participants