Repository navigation
feat: add erc165Abi - #5669
Closed
mortezashojaei wants to merge 1 commit into
Closed
feat: add erc165Abi#5669mortezashojaei wants to merge 1 commit into
erc165Abi#5669mortezashojaei wants to merge 1 commit into
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: 263d221 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 |
Member
|
Thanks @mortezashojaei, this is a useful addition. I opened #5670 to carry it forward with your commit kept. It adds one small change: the output is declared as |
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 #5668
Why
Viem ships
erc20Abi,erc721Abi,erc1155Abianderc4626Abi, but no standalone ERC-165 ABI. Projects that need to find out what kind of contract an address is (ERC-721 vs ERC-1155, receiver hooks, ERC-7984 tokens, …) redeclare the one-functionsupportsInterfaceABI next to Viem. Examples include RabbyHub/Rabby, tempoxyz/tempo-apps, zama-ai/sdk, PaulRBerg/prb-effect, 3loop/loop-decoder, Swader/rescuekit and NaniDAO/agentek, plus roughly 40 more repos from a code search. Permalinks are in #5668.What
src/constants/abis.ts: addserc165AbiwithsupportsInterface(bytes4 interfaceId) view returns (bool). The entry is identical to thesupportsInterfaceitem already inerc721Abi/erc1155Abi, and the TSDoc link follows the other token ABIs.src/index.ts: exports it next to the other token ABIs.src/constants/abis.test.tsandsrc/index.test.ts: update the existingexports abisandexportsinline snapshots.Usage
Validation
SKIP_GLOBAL_SETUP=true pnpm test --run --update all --project core src/constants/abis.test.ts src/index.test.ts: 2 passed. The snapshot diff contains only the new entries.tsc -p src/tsconfig.json --noEmit: passes.biome checkon the changed files: clean.size-limitwas not run locally. An esbuild minify+gzip ofexport * from 'viem'grows by 15 B.multicallwithallowFailure: truegives BAYCerc165/erc721 = true, erc1155 = falseand the ENS NameWrappererc165/erc1155 = true, erc721 = false. USDC (no ERC-165) returns failures.readContractinfersboolean.encodeFunctionDataoutput matcheserc721Abi'ssupportsInterface.tscrejects unknown function names.Compatibility
This adds one export and changes nothing else. There are no new dependencies, and tree-shaken imports are unaffected. Interface-ID constants (#3752) are out of scope.
AI assistance
I prepared this with help from an AI coding assistant (Claude Code). I reviewed the evidence, diff, and test results.