Repository navigation
Conversation
|
@Revinand is attempting to deploy a commit to the Wevm Team on Vercel. A member of the Team first needs to authorize it. |
Revinand
force-pushed
the
fix/abiitem-array-regex
branch
from
October 23, 2026 10:59
5e65959 to
3792af5
Compare
…iguity in AbiItem.fromAbi
This branch has not been deployed
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.
AbiItem.fromAbipicks an overload withisArgOfTypeand checks it withgetAmbiguousTypes. Several array and tuple arguments resolved to the wrong overload, soAbiFunction.encodeDataencoded against the wrong function or threw:/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/. Its[1-9]class rejects any element size with a0in it, souint160[],bytes20[],int40[2]anduint120[][]never matched, andfromAbifell back to the first overload, as above.foo(uint256[3])andfoo(uint256[2]),[1n, 2n, 3n]resolved tofoo(uint256[2])and encoding threwArrayLengthMismatchError.Object.values. Withfoo((address a, string b))andfoo((string a, address b)),{ b: 'hello', a: <address> }resolved to the second one and encoding threwInvalidAddressError.getAmbiguousTypesreturned at the first pair of tuple parameters, sofoo((uint256), address)/foo((uint256), bytes20)resolved to the last one instead of throwing. It also threw aTypeErrorwhen the two tuples had a different number of components, e.g.foo((uint256[] a))andfoo((uint256[] a, uint256 b))with{ a: [1n], b: 2n }.Arrays are now matched with the existing
getArrayComponentshelper frominternal/abiParameters, which also gives the length to check. Tuple object values are read by component name, asAbiParameters.encodedoes. The element type is still checked by the recursiveisArgOfTypecall, so an invalid size such asuint69[]is still rejected, as the existing test expects.Now that
bytes20[]can match,getAmbiguousTypesalso compares the element types of two array parameters, using the first item. Anaddress[]/bytes20[]overload pair then throwsAbiItem.AmbiguityError, likeaddress/bytes20, instead of picking the last item. An empty array matches both element types, soaddress[]againststring[]orbytes[]is ambiguous too when the array is empty.These are the same changes as wevm/viem#5281, which merged this fix in viem.
Added
isArgOfTyperows foruint160[],int40[2],uint120[][],bytes20[]and a too-longuint256[2], overload tests for the zero digit, fixed-length and tuple object cases, ambiguity tests for array, empty array and tuple overloads, andgetAmbiguousTypescases for arrays. They fail without the change.