Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Implement IErc165 for All Contracts #592

Open
1 of 4 tasks
0xNeshi opened this issue Mar 5, 2025 · 2 comments
Open
1 of 4 tasks

[Feature]: Implement IErc165 for All Contracts #592

0xNeshi opened this issue Mar 5, 2025 · 2 comments
Assignees
Labels
effort: medium Default level of effort. good first issue Good for newcomers. type: feature New feature request.

Comments

@0xNeshi
Copy link
Collaborator

0xNeshi commented Mar 5, 2025

What is the feature you would like to see?

We can implement this as a "convenience" impl for users who may wish to easily support IErc165 while using our contracts.

This implementation would not be part of the ABI unless the user of the library makes their intention to make it so explicit by declaring a supports_interface method in their inheriting contract(s).

TODO:

  • implement IErc165 for all base contracts where it might be missing
  • implement IErc165 for all extensions/utils where it might be missing
  • add unit tests (for inspiration see
    fn interface_id() {
    let actual = <Erc2981 as IErc2981>::INTERFACE_ID;
    // Value taken from official EIP
    // https://eips.ethereum.org/EIPS/eip-2981#checking-if-the-nft-being-sold-on-your-marketplace-implemented-royalties
    let expected = 0x2a55_205a;
    assert_eq!(actual, expected);
    }
    #[motsu::test]
    fn supports_interface() {
    assert!(Erc2981::supports_interface(
    <Erc2981 as IErc2981>::INTERFACE_ID.into()
    ));
    assert!(Erc2981::supports_interface(
    <Erc2981 as IErc165>::INTERFACE_ID.into()
    ));
    let fake_interface_id = 0x12345678u32;
    assert!(!Erc2981::supports_interface(fake_interface_id.into()));
    }
    )

We don't need to update examples or docs.

Contribution Guidelines

  • I agree to follow this project's Contribution Guidelines
@0xNeshi 0xNeshi added effort: medium Default level of effort. good first issue Good for newcomers. type: feature New feature request. labels Mar 5, 2025
0xNeshi added a commit that referenced this issue Mar 6, 2025
<!--
Thank you for your interest in contributing to OpenZeppelin!

Consider opening an issue for discussion prior to submitting a PR. New
features will be merged faster if they were first discussed and designed
with the team.

Describe the changes introduced in this pull request. Include any
context necessary for understanding the PR's purpose.
-->

Reverts change introduced in
#570

<!-- Fill in with issue number -->
Towards #592

#### PR Checklist

<!--
Before merging the pull request all of the following must be completed.
Feel free to submit a PR or Draft PR even if some items are pending.
Some of the items may not apply.
-->

- [x] Tests
- [x] Documentation
- [x] Changelog
@B1n4ryR41nb0w
Copy link

Hello, can I get it assigned and have a go at it, please?

@bidzyyys
Copy link
Collaborator

Hey @B1n4ryR41nb0w!
Thanks for your interest in contributing to our library 🚀
If you have any questions around scope, feel free to ask me or @0xNeshi.

@bidzyyys bidzyyys moved this from Todo to In Progress in Rust Contracts Stylus Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort: medium Default level of effort. good first issue Good for newcomers. type: feature New feature request.
Projects
Status: In Progress
Development

No branches or pull requests

3 participants