Skip to content

fix(errors): preserve original provider cause in getContractError#4402

Closed
jasonandjay wants to merge 1 commit into
wevm:mainfrom
jasonandjay:fix/get-contract-error-preserve-cause
Closed

fix(errors): preserve original provider cause in getContractError#4402
jasonandjay wants to merge 1 commit into
wevm:mainfrom
jasonandjay:fix/get-contract-error-preserve-cause

Conversation

@jasonandjay
Copy link
Copy Markdown

Fixes #4387

Summary

When a custom provider throws an execution error (e.g. { code: 3, data, name: 'CustomProviderExecutionError' }), getContractError currently wraps it into ContractFunctionRevertedError but can lose the original nested cause.

This PR preserves that cause chain:

  • getContractError now passes the discovered low-level error as cause into ContractFunctionRevertedError.
  • ContractFunctionRevertedError now accepts an optional cause parameter and keeps it unless replaced by ABI decode failures.
  • Added a regression test asserting error.cause.cause?.name === 'CustomProviderExecutionError'.

Notes

I couldn't fully run local repo checks in this environment because viem currently requires Node >= 24.5 and this runner is Node 22. CI should validate on the project's standard toolchain.

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 16, 2026

Someone 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 Mar 16, 2026

⚠️ No Changeset found

Latest commit: f943d51

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@jxom
Copy link
Copy Markdown
Member

jxom commented Mar 16, 2026

already a pr for this #4388

@jxom jxom closed this Mar 16, 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.

getContractError can loose the error cause when a custom provider is used

2 participants