Skip to content

fix: pass the latest block to chain fee hooks in estimateFeesPerGas - #5613

Merged
jxom merged 2 commits into
mainfrom
fix/estimate-fees-hook-block
Nov 19, 2026
Merged

jxom merged 2 commits into
mainfrom
fix/estimate-fees-hook-block

Conversation

@jxom

@jxom jxom commented Nov 19, 2026

Copy link
Copy Markdown
Member

Supersedes #5611 by @mortezashojaei, keeping their commit.

ChainFeesFnParameters.block is documented as the latest block, but when estimateFeesPerGas(client) was called without a block, the chain fees.estimateFeesPerGas and function-valued fees.baseFeeMultiplier hooks received undefined. Both hooks now receive the block the action fetches.

  • No requests are added: when a fee hook is defined the action already fetches the block, and a caller-supplied block is still used as is. prepareTransactionRequest always passes a block and fillTransaction does not use this action, so neither changes.
  • The only ordering change: a static baseFeeMultiplier below 1 now throws BaseFeeScalarError after the block request instead of before it.
  • Tests extend the existing estimateFeesPerGas and baseFeeMultiplier hook cases so the hooks read the received block; both fail on main with TypeError: Cannot read properties of undefined (reading 'baseFeePerGas').

mortezashojaei and others added 2 commits November 19, 2026 21:29
When estimateFeesPerGas was called without a block, the chain
fees.estimateFeesPerGas hook received the caller's undefined block
instead of the block the action had fetched, and fees.baseFeeMultiplier
ran before any block was fetched. Both hooks now receive the latest
block, as ChainFeesFnParameters and the chain fees docs describe.
Replace the separate proxy-backed describe block with assertions in the
existing estimateFeesPerGas and baseFeeMultiplier hook tests, which now
read the block they receive and fail when it is undefined.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1f5b7-efe8-7346-8db3-56d7c75548fe
Co-authored-by: jxom <[email protected]>
@vercel

vercel Bot commented Nov 19, 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 19, 2026 9:47pm UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 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-19T21:45:52.244125Z f05dcc9 PR opened
ℹ️ 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.

@changeset-bot

changeset-bot Bot commented Nov 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f05dcc9

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

@github-actions

Copy link
Copy Markdown
Contributor

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

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

@jxom
jxom merged commit 9381167 into main Nov 19, 2026
39 of 40 checks passed
@jxom
jxom deleted the fix/estimate-fees-hook-block branch November 19, 2026 21:58
@github-actions github-actions Bot mentioned this pull request Nov 19, 2026

This branch had an error being deployed

1 failed deployment
Preview — f05dcc9e Deployed Nov 19, 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