Skip to content

fix(zksync): include dependency errors in two action error unions - #5587

Merged
jxom merged 4 commits into
mainfrom
zksync-dependency-error-unions
Nov 18, 2026
Merged

jxom merged 4 commits into
mainfrom
zksync-dependency-error-unions

Conversation

@jxom

@jxom jxom commented Nov 18, 2026

Copy link
Copy Markdown
Member

Supersedes #5585 by @mortezashojaei (their commit is kept as-is).

GetL1TokenBalanceErrorType and IsWithdrawalFinalizedErrorType now compose the error types of the functions each action calls:

  • getL1TokenBalance: ReadContractErrorType replaces BaseErrorType (readContract wraps every failure in ContractFunctionExecutionError, and nothing on this path throws a plain BaseError).
  • isWithdrawalFinalized: adds GetTransactionReceiptErrorType (via getWithdrawalLog and getWithdrawalL2ToL1Log), RequestErrorType (getLogProof and getDefaultBridgeAddresses call client.request), and ReadContractErrorType.

Runtime behavior is unchanged; only type aliases and imports change.

On top of #5585, the follow-up commit tightens the type tests: it imports public types from the viem and zksync entrypoints, replaces assertions that only compared a value with its own declared type with expectTypeOf<Dependency>().toExtend<ActionError>(), and checks HttpRequestError fields instead of re-asserting a narrowed name literal. The tests fail against main and when ReadContractErrorType is removed from IsWithdrawalFinalizedErrorType.

mortezashojaei and others added 2 commits November 18, 2026 20:20
@changeset-bot

changeset-bot Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 621b366

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

@vercel

vercel Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
viem Error Error Nov 18, 2026 8:54pm UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T20:52:02.963273Z 621b366 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 903f258995

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

import type { ReadContractErrorType } from 'viem'
import { expectTypeOf, test } from 'vitest'

import type { GetL1TokenBalanceErrorType } from '../index.js'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Import the tested public types through viem/zksync

Both new public-surface type tests import their action error types through ../index.js, contrary to the root AGENTS.md requirement to use package aliases for public exports. This bypasses consumer-facing package-path resolution in tests intended to verify the public types. Change this import and the corresponding import in isWithdrawalFinalized.test-d.ts to 'viem/zksync'.

AGENTS.md reference: AGENTS.md:L188-L190

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in 0941678: both type tests now import from viem/zksync. The test tsconfig had no path for it, so I added viem/zksync next to the other viem/* mappings.

Map viem/zksync in the test tsconfig so type tests resolve the public
entrypoint like the other viem/* aliases.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1f05b-6d85-706b-9dcc-4f07a520335d
Co-authored-by: jxom <[email protected]>

Copy link
Copy Markdown
Contributor

Thanks for keeping my commit and improving the tests. During follow-up validation, I found that the withdrawal-log helpers can also propagate InvalidAddressError through isAddressEqual. I reproduced this with a local HTTP test. Commit 5548d8c adds IsAddressEqualErrorType and a regression test. Would you prefer including that here or handling it separately?

jxom commented Nov 18, 2026

Copy link
Copy Markdown
Member Author

Thanks @mortezashojaei, good catch: both helpers pass RPC-provided addresses to isAddressEqual, so InvalidAddressError can propagate. I included it here as 621b366, cherry-picked under your authorship from 5548d8c and adapted to the updated type tests (the inclusion check is now expectTypeOf<IsAddressEqualErrorType>().toExtend<IsWithdrawalFinalizedErrorType>()).

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Published [email protected] under the pr-5587 dist-tag, which follows this pull request until it closes.

pnpm add viem@pr-5587
pnpm add [email protected]

@jxom
jxom merged commit 26e438a into main Nov 18, 2026
39 of 40 checks passed
@jxom
jxom deleted the zksync-dependency-error-unions branch November 18, 2026 21:35
@github-actions github-actions Bot mentioned this pull request Nov 18, 2026

This branch had an error being deployed

1 failed deployment
Preview — 621b3661 Deployed Nov 18, 2026 by vercel[bot]
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