Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(transport): Add shouldThrow as an option to fallback transport #3414

Merged
merged 5 commits into from
Mar 7, 2025

Conversation

spalladino
Copy link
Contributor

@spalladino spalladino commented Mar 5, 2025

Adds a shouldThrow option to the fallback transport, to customize which errors trigger a fallback vs a throw. We are using this so a contract error (eg a failed require in contract code) does not trigger the fallback and fails immediately.

Happy to add some tests if this contribution makes sense.

Adds a `shouldThrow` option to the fallback transport, to customize
which errors trigger a fallback vs a throw.
Copy link

changeset-bot bot commented Mar 5, 2025

🦋 Changeset detected

Latest commit: c48a1d5

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

Copy link

vercel bot commented Mar 5, 2025

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

A member of the Team first needs to authorize it.

@@ -203,7 +206,7 @@ export function fallback<const transports extends readonly Transport[]>(
}) as FallbackTransport<transports>
}

function shouldThrow(error: Error) {
function defaultShouldThrow(error: Error) {
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we export this, so others can use it in their custom shouldThrow function.

@jxom
Copy link
Member

jxom commented Mar 6, 2025

Looks good. Needs some tests.

@spalladino
Copy link
Contributor Author

@jxom thanks for reviewing! Added a test and changeset entry.

@jxom jxom merged commit 71b9003 into wevm:main Mar 7, 2025
2 of 3 checks passed
@github-actions github-actions bot mentioned this pull request Mar 7, 2025
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