Skip to content

Implement ERC-165 facet and library for interface detection#137

Merged
mudgen merged 5 commits into
Perfect-Abstractions:mainfrom
ogazboiz:feat/erc165-facet
Oct 28, 2025
Merged

Implement ERC-165 facet and library for interface detection#137
mudgen merged 5 commits into
Perfect-Abstractions:mainfrom
ogazboiz:feat/erc165-facet

Conversation

@ogazboiz

Copy link
Copy Markdown
Contributor

Added ERC-165 support to the diamond pattern.
Created:

  • IERC165 interface in src/interfaces/IERC165.sol
  • LibERC165 library in src/libraries/LibERC165.sol
  • ERC165Facet in src/diamond/ERC165Facet.sol

Behavior:

  • supportsInterface() returns true for the ERC-165 interface ID
  • Use registerInterface() during initialization to register other interfaces
  • Mapping-based storage at compose.erc165

Files compile without errors and follow the project’s ERC-8042 storage layout.
Addresses #123.

@github-actions

github-actions Bot commented Oct 27, 2025

Copy link
Copy Markdown
Contributor

Coverage Report

Coverage

Metric Coverage Details
Lines 40% 423/1059 lines
Functions 54% 101/187 functions
Branches 25% 45/178 branches

Last updated: Mon, 27 Oct 2025 23:36:13 GMT for commit c7c53a0

@ogazboiz ogazboiz closed this Oct 27, 2025
@ogazboiz ogazboiz reopened this Oct 27, 2025
@ogazboiz

Copy link
Copy Markdown
Contributor Author

@mudgen please kindly review

@mudgen

mudgen commented Oct 27, 2025

Copy link
Copy Markdown
Contributor

@ogazboiz We have two pull requests for this. Should we have two for some reason? Or can you close one of them?

@mudgen mudgen self-requested a review October 27, 2025 13:28
@ogazboiz

Copy link
Copy Markdown
Contributor Author

@mudgen it was a mistake

@ogazboiz

Copy link
Copy Markdown
Contributor Author

@mudgen i have close one

@mudgen mudgen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ogazboiz Thanks for submitting this.

Please review my comments. The README and CONTRIBUTING documentation has been updated. Please read them, so you can better understand how we are designing Compose.

Please create this new directory: src/interfaceDetection. And create this directory in that: ERC165. Put all your source code in that directory, including your IERC165.sol. No libraries directory.

Thanks for your work on this and I look forward to merging the pull request when the changes are done.

Comment thread src/diamond/ERC165Facet.sol Outdated
Comment on lines +4 to +5
import {IERC165} from "../interfaces/IERC165.sol";
import {LibERC165} from "../libraries/LibERC165.sol";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove these imports. Each facet is a standard alone source code file.

Comment thread src/diamond/ERC165Facet.sol Outdated
/// @title ERC165Facet — ERC-165 Standard Interface Detection Facet
/// @notice Facet implementation of ERC-165 for diamond proxy pattern
/// @dev Allows querying which interfaces are implemented by the diamond
contract ERC165Facet is IERC165 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uh-oh, submitting a pull request with a facet that uses inheritance is a finable offense. Well, since I really appreciate you working on this and it is valuable, we'll let you pass this time.

Please remove the inheritance.

Comment thread src/libraries/LibERC165.sol Outdated
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.30;

import {IERC165} from "../interfaces/IERC165.sol";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this. We currently do not use interfaces.

@ogazboiz

Copy link
Copy Markdown
Contributor Author

thanks for the feedback because i want to be good in this open source contribution

@mudgen

mudgen commented Oct 27, 2025

Copy link
Copy Markdown
Contributor

thanks for the feedback because i want to be good in this open source contribution

Excellent. I look forward to your changes.

@ogazboiz

ogazboiz commented Oct 27, 2025

Copy link
Copy Markdown
Contributor Author

thanks for the feedback because i want to be good in this open source contribution

Excellent. I look forward to your changes.

should i still create a standalone interfaces for the 165 too in the interface folder?

@ogazboiz

Copy link
Copy Markdown
Contributor Author

Created directory src/interfaceDetection/ERC165.

Moved the ERC165Facet into that directory. Removed passage and imports. The facet is standalone with the interface defined inline.

Removed the library file and separate interface file.

The facet follows SCOP principles. No inheritance. No imports. Uses ERC-8042 diamond storage.

Files formatted and building. Ready for your review.

@mudgen

@ogazboiz

Copy link
Copy Markdown
Contributor Author

@mudgen did i get it right

@panditdhamdhere

Copy link
Copy Markdown
Collaborator

Hi @ogazboiz your willingness to learn and adapt to our project's architecture is commendable. Once these changes are made, this will be a valuable addition to the Compose library.

Please let us know if you need clarification on any of these requirements!

@ogazboiz

ogazboiz commented Oct 27, 2025

Copy link
Copy Markdown
Contributor Author

Hi @ogazboiz your willingness to learn and adapt to our project's architecture is commendable. Once these changes are made, this will be a valuable addition to the Compose library.

Please let us know if you need clarification on any of these requirements!

I have made the changes and am now waiting for feedback. I follow you on Twitter and have been following your journey since you applied for jobs.

@mudgen mudgen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ogazboiz Did you read the README and the CONTRIBUTING files so you can understand how we are writing these files? Do those make sense to you? Any questions about them?

ERC165Facet.sol is in the right directory now, thanks.

ERC165Facet.sol looks good now, but please remove the registerInterface internal function, since it is unused. The interface defined inline like that is fine.

Please undelete the LibERC165.sol file. It belongs in the same directory as ERC165Facet.sol. But please delete the supportsInterface function from LibERC165.sol because I don't think it is needed in the library file.

Thanks.

Comment thread src/interfaceDetection/ERC165/ERC165Facet.sol Outdated
@ogazboiz

Copy link
Copy Markdown
Contributor Author

@ogazboiz Did you read the README and the CONTRIBUTING files so you can understand how we are writing these files? Do those make sense to you? Any questions about them?

ERC165Facet.sol is in the right directory now, thanks.

ERC165Facet.sol looks good now, but please remove the registerInterface internal function, since it is unused. The interface defined inline like that is fine.

Please undelete the LibERC165.sol file. It belongs in the same directory as ERC165Facet.sol. But please delete the supportsInterface function from LibERC165.sol because I don't think it is needed in the library file.

Thanks.

@mudgen Thank you for your patience and the detailed feedback.

Yes, I read both files.

I now understand the project's approach. Facets are standalone with all code in one file. Libraries help developers integrate with those facets.

Here’s what I did:

  • Removed registerInterface from ERC165Facet.sol.
  • Created LibERC165.sol in src/interfaceDetection/ERC165/.
  • LibERC165 includes:
    • Same storage struct and getStorage function
    • registerInterface only
    • No supportsInterface
  • Both files share the same storage slot keccak256("compose.erc165").

Changes are committed. Ready for review.

@mudgen

mudgen commented Oct 28, 2025

Copy link
Copy Markdown
Contributor

@ogazboiz Very good. Good job. Merged.

@mudgen mudgen merged commit c77fabb into Perfect-Abstractions:main Oct 28, 2025
3 checks passed
JackieXu pushed a commit to JackieXu/Compose that referenced this pull request Nov 6, 2025
…-facet

Implement ERC-165 facet and library for interface detection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants