Repository navigation
fix: treat indistinguishable ABI overloads as ambiguous - #5339
Merged
jxom merged 3 commits intoNov 1, 2026
Merged
Conversation
Last-wins encoding could call the wrong function for bytes vs bytes32 and uint vs int overloads, including Safe ERC-1271 isValidSignature.
🦋 Changeset detectedLatest commit: 473484f 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 |
|
@mortezashojaei is attempting to deploy a commit to the Wevm Team on Vercel. A member of the Team first needs to authorize it. |
Array overloads such as uint256[] and uint256[2] encode differently even when they accept the same value, so getAbiItem now throws instead of keeping the last match. The ambiguity error also says a selector can choose the overload.
Merged
jxom
added a commit
to wevm/ox
that referenced
this pull request
Nov 1, 2026
…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]>
jxom
added a commit
to wevm/ox
that referenced
this pull request
Nov 1, 2026
…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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
getAmbiguousTypes(source, target, args) if address vs bytes20 throw if address vs string|bytes and value looks like an address throw + if the two ABI types differ + throw last matching overload winsgetAbiItemalready throwsAbiItemAmbiguityErrorforaddress/bytes20. Other overloads that both accept the same JavaScript value still last-wins by ABI order. That encodes the wrong selector.The Safe/ERC-1271 case is the sharp one:
isValidSignature(bytes32,bytes)vsisValidSignature(bytes,bytes)with a 32-byte hash currently encodes0x20c13b0binstead of0x1626ba7e. The same last-wins flip happens foruint256/int256if the ABI array is reversed.This also closes the gap reported in #1799.
Evidence
encodeFunctionDatawith bothisValidSignatureoverloads returned selector0x20c13b0b(legacybytes,bytes).getAbiItem({ args: [1n] })forfoo(uint256)/foo(int256)returned whichever overload was last in the ABI.AbiItemAmbiguityError. A unique ERC-1271 ABI still encodes0x1626ba7e. Existing address/string/bytes helper cases that are not actually addresses stay non-ambiguous.SKIP_GLOBAL_SETUP=true pnpm test --run --project core \ src/utils/abi/getAbiItem.test.ts \ src/utils/abi/encodeFunctionData.test.ts \ src/utils/abi/decodeFunctionResult.test.ts \ src/utils/abi/prepareEncodeFunctionData.test.ts \ src/utils/abi/encodeErrorResult.test.ts92 tests passed.
Test plan
getAbiItemthrows forbytesvsbytes32(isValidSignature)getAbiItemthrows foruint256vsint256encodeFunctionDatastill encodes ERC-1271 when onlybytes32,bytesis on the ABIaddress/bytes20ambiguity tests still passfunctionNameselectorMerge Danger
Door: two-way
Patch-level behavior change: previously silent last-wins now throws. Rollback is a revert. Callers who relied on ABI JSON order to pick
bytesvsbytes32(oruintvsint) need to pass a selector or trim the ABI. That is the same workaround already documented in discussion 1799.Blast Radius: encoding
Wrong-selector calls become explicit errors. Unique overloads (
mint(uint256)vsmint(string)) are unchanged.