Repository navigation
fix: raise TipAboveFeeCapError when parsing a zero maxFeePerGas - #5318
Conversation
…n fee cap guards
Decode `maxPriorityFeePerGas` first and only read a `0x` `maxFeePerGas` as `0n` when the decoded tip is non-zero. A malformed (non-hex) tip no longer adds a `maxFeePerGas` field, and a non-canonical zero tip (`0x00`) no longer adds `maxFeePerGas: 0n`. Also covers zero fees for EIP-7702 and EIP-4844. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01D3nmWewDJAYwLexGahtJ1H
🦋 Changeset detectedLatest commit: c1962b8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c1962b8b7a
ℹ️ 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".
| "viem": patch | ||
| --- | ||
|
|
||
| Fixed `parseTransaction` not raising `TipAboveFeeCapError` when the encoded `maxFeePerGas` is zero. |
There was a problem hiding this comment.
Consolidate the duplicate changeset
Remove this changeset and retain the broader tip-above-zero-fee-cap.md entry, which already covers the same parseTransaction zero-fee-cap fix; keeping both causes the patch to appear twice in the generated release notes and conflicts with the repository requirement to update an existing same-area changeset rather than adding a duplicate.
AGENTS.md reference: AGENTS.md:L240-L244
Useful? React with 👍 / 👎.
| test('args: maxFeePerGas (zero, under default tip)', async () => { | ||
| await setup() |
There was a problem hiding this comment.
Replace the mock-dependent fee test
Move this new case out of the mocked without eth_fillTransaction suite or exercise the unsupported-method path against a configured test node: the suite's beforeEach replaces fillTransaction with vi.spyOn(...).mockRejectedValue(...), so this coverage depends on a stub rather than real behavior and violates the repository's explicit prohibition on mocks in tests.
AGENTS.md reference: AGENTS.md:L153-L157
Useful? React with 👍 / 👎.
|
Published pnpm add viem@pr-5318
pnpm add [email protected] |
…s, and `AbiItem` (#561) * fix: validate struct names and field types in `TypedData.assert` Ports wevm/viem#5308 and wevm/viem#5370. A struct name must contain only letters, digits, `_` and `$`, and must not be a Solidity type. A field type must be a struct in `types` or an EIP-712 atomic or dynamic type, so `uint`, `uint7` and `bytes0` throw the new `TypedData.InvalidTypeError`. Every struct is checked, including structs referenced only as array elements. `findTypeDependencies` strips only the array suffix, so struct names with `$` are encoded. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01D3nmWgFaNg3t1E6VyYCzXq * fix: reject a tip above a zero `maxFeePerGas` in transaction envelopes Ports wevm/viem#5318 and wevm/viem#5319. `TxEnvelopeEip1559.assert` and `TxEnvelopeTempo.assert` compared fees only when both were truthy, so a zero `maxFeePerGas` skipped the check. `deserialize` for EIP-1559, EIP-4844, EIP-7702, and Tempo envelopes reads an empty `maxFeePerGas` as zero when a tip is set. `TipAboveFeeCapError` and `FeeCapTooHighError` now show zero values. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01D3nmWgFaNg3t1E6VyYCzXq * fix: treat indistinguishable overloads as ambiguous in `AbiItem.fromAbi` Ports wevm/viem#5339. Distinct types that both match an argument, such as `bytes32` and `bytes` or `uint256` and `int256`, and arrays of the same element type with different shapes now throw `AbiItem.AmbiguityError` instead of resolving to the last match. An integer overload matches only a value in its range, and a fixed bytes overload matches only a value of its size. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01D3nmWgFaNg3t1E6VyYCzXq --------- Co-authored-by: Claude <[email protected]>
…d `AbiItem` (#560) * fix: validate struct names and field types in `TypedData.assert` Ports wevm/viem#5308 and wevm/viem#5370. A struct name must contain only letters, digits, `_` and `$`, and must not be a Solidity type. A field type must be a struct in `types` or an EIP-712 atomic or dynamic type, so `uint`, `uint7` and `bytes0` throw the new `TypedData.InvalidTypeError`. Every struct is checked, including structs referenced only as array elements. `findTypeDependencies` strips only the array suffix, so struct names with `$` are encoded. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01D3nmWgFaNg3t1E6VyYCzXq * fix: reject a tip above a zero `maxFeePerGas` in transaction envelopes Ports wevm/viem#5318 and wevm/viem#5319. `TxEnvelopeEip1559.assert` and `TxEnvelopeTempo.assert` compared fees only when both were truthy, so a zero `maxFeePerGas` skipped the check. `deserialize` for EIP-1559, EIP-4844, EIP-7702, and Tempo envelopes reads an empty `maxFeePerGas` as zero when a tip is set. `TipAboveFeeCapError` and `FeeCapTooHighError` now show zero values. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01D3nmWgFaNg3t1E6VyYCzXq * fix: treat indistinguishable overloads as ambiguous in `AbiItem.fromAbi` Ports wevm/viem#5339. Distinct types that both match an argument, such as `bytes32` and `bytes` or `uint256` and `int256`, and arrays of the same element type with different shapes now throw `AbiItem.AmbiguityError` instead of resolving to the last match. An integer overload matches only a value in its range, and a fixed bytes overload matches only a value of its size. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01D3nmWgFaNg3t1E6VyYCzXq --------- Co-authored-by: Claude <[email protected]>
Replaces #5316. Stacked on #5313; until it merges, review only the last two commits (
1bbf73c,c1962b8). Onmain,assertTransactionEIP1559still skips a0nfee cap, so this needs #5313.Summary
RLP encodes
0as0x, and the EIP-1559, EIP-7702 and EIP-4844 parsers dropped0xfields. A zero fee cap came back asundefined, soassertTransactionEIP1559skipped the tip check and a transaction with a tip above a zero fee cap parsed without error.1bbf73c(from fix: raise TipAboveFeeCapError when parsing a zero maxFeePerGas #5316, authored by @mortezashojaei): decodes a0xfee cap as0nwhen the tip is present, soTipAboveFeeCapErroris raised.c1962b8: decodes the tip first and keys the0nfee cap on the decoded, non-zero tip instead of the raw tip field. Before, a malformed (non-hex) tip addedmaxFeePerGas: 0nwhile the tip was dropped, and a non-canonical0x00tip addedmaxFeePerGas: 0n, unlike a canonical zero-fee transaction. Also addszero feestests for EIP-7702 and EIP-4844.If both fees are zero, the output is unchanged (no fee fields).
Tests
parseTransaction,assertTransaction, Celo and OP Stack parser tests pass (125). The newzero fee cap with zero tiptest fails withoutc1962b8.Not included: Celo's CIP-42 and CIP-64 parsers have the same gap, and their asserts use
isPresent, which treats0nas empty. That is a separate fix.Generated by Claude Code