Repository navigation
fix: add supportsInterface and correct tokenOfOwnerByIndex in erc721Abi - #5650
Merged
Merged
Conversation
|
@mortezashojaei is attempting to deploy a commit to the Wevm Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: 9f8afaa 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 |
Merged
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.
Refs #5649
Why
erc721Abidoesn't fully match ERC-721:tokenOfOwnerByIndex(address owner, uint256 index)as a secondtokenByIndexoverload. As a result,functionName: 'tokenOfOwnerByIndex'throwsAbiFunctionNotFoundError, andtokenByIndex(owner, index)encodes selector0xcb60f1bf, which reverts on real contracts. viem's own test fixture (test/src/abis.ts) already uses the correct name.supportsInterface, which EIP-721 makes mandatory and whicherc1155Abialready includes.Public code works around both. Rabby ("viem's erc721Abi has no ERC-165
supportsInterface") and Kleros ("viem doesn't export this") extend or supplement the ABI by hand, and SIR-trading multicallstokenOfOwnerByIndexwitherc721Abi. Permalinks are in #5649.What
src/constants/abis.ts: renames the(owner, index)overload totokenOfOwnerByIndexand addssupportsInterface(bytes4) view returns (bool), keeping the existing alphabetical order.tokenByIndex(uint256)is unchanged.src/constants/abis.test.ts: updates the existingexports abisinline snapshot.Usage
Validation
pnpm test --update all --run src/constants/abis.test.ts: 1 passed. The snapshot diff contains only the two ABI entries.tsc -p src/tsconfig.json --noEmit: passes.biome checkon the changed files: clean.NonfungiblePositionManager, an ERC721Enumerable contract:tokenByIndex(owner, 0)reverts, and bothtokenOfOwnerByIndexandsupportsInterfacethrowAbiFunctionNotFoundError.tokenOfOwnerByIndex(owner, 0)returns5n,supportsInterface(0x80ac58cd)returnstrue,supportsInterface(0xd9b67a26)returnsfalse, andtokenByIndex(0)still returns1n.Compatibility
supportsInterfaceis additive. The rename removes only the non-standardtokenByIndex(address,uint256)signature, which can't succeed against a standard ERC-721 contract, so I've treated it as a patch fix (like #3710).AI assistance
I prepared this with help from an AI coding assistant (Claude Code). I reviewed the evidence, diff, and test results.