-
-
Notifications
You must be signed in to change notification settings - Fork 782
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
VIP: ERC165 support #2619
Comments
I think injecting the IMO, I think it is better to require the |
Yes, got a lot of feedback from @charles-cooper about this too. I think adding the @view
@external
def supportsInterface(interface_id: bytes4) -> bool:
return interface_id in [
ERC20.interface_id,
ERC721.interface_id,
... # as many as you want to support
] This has the most optimal balance of flexibility and convenience |
Wonder if this should also add @external
def marked(amount: uint256):
...
# self.marked.method_id == 0x92e37a93 |
|
meeting notes: |
Simple Summary
ERC165 allows contracts to quickly determine if they are able to interact with a particular contract. Deeper support into Vyper will help improve contracts that would like to implement ERC165
Motivation
ERC721 introduced the concept of mandatory ERC165 interface checks in order to acheive compliance with a given ERC. This has been problematic for Vyper in the past because of the missing
bytes4
type (which is also something we should add and support).Until support is added for
bytes4
, it will not be possible to comply with ERC165 (and thus any ERCs which require ERC165 for full compliance). However, it seems like a potential solution to overload theimplements:
keyword, which currently like Vyper contracts specify what interfaces they comply to, with functionality that adds ERC165 compliance more implicitly to a contractSpecification
When the
implements:
keyword is used in a Vyper contract with an Interface type, Vyper will add thedef supportsInterface(interface_id: bytes4) -> bool
function directly to the contract's bytecode, which returns whether or not the contract supports a giveninterface_id
.ERC165 specifies
interface_id
as the logical XOR of all the mandatorymethod_id
s located in the defined interface. Computing these manually requires adding lines to the constructor function in order to enable it correctly, or otherwise making large view function forsupportsInterface
with lots of manual typing.A discussion point is whether these interface IDs only be limited to defined
ERC
s in Vyper's interfaces library, which would reduce clutter from using non-standardized interfaces with theimplements:
keywordLasty, any contracts which use this feature will also implicitly use the
implements: ERC165
specifier. A discussion could be had that this support would only enabled by adding this specification to a contract (e.g. a contract will not produce theimplementsInterface
function unlessimplements: ERC165
is added), which would make this behavior more "opt in"Backwards Compatibility
Any contracts that use the
implements:
keyword currently would raise an error if thesupportsInterface
function was also defined.Dependencies
Not required for implementation, but the
bytes4
type would make implementation of this VIP likely easier.References
Copyright
Copyright and related rights waived via CC0
The text was updated successfully, but these errors were encountered: