-
-
Notifications
You must be signed in to change notification settings - Fork 805
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: Interfaces #885
Comments
I think that’s an interesting proposal. As Vyper doesn’t allow for inheritance nor imports but maybe interfaces (which have no functionality - just guidelines) can be a good use case for that. |
Vyper has no current use for imports, this is the most obvious thing that requires it. The next step from defining a standard library is to allow importing packaged interfaces using ethPM from registries such as Zeppelin, Aragon, etc. Finally, importing these from your own project would be very helpful (e.g. header files in C), and enable slightly more complex smart contract systems to built up where each contract can talk to each other using interfaces. I do think when we figure out whatever extension model works for us, that will be another use case for imports (e.g. my composed types proposal), but these three work for now and are broadly useful in and of themselves. Note: This VIP is restricted to these three use cases. |
Sounds good to me. |
Yeah, the extension aspect of things is really tricky, it definitely opens up a whole new vector for malicious code and overall can reduce auditability if used poorly. But if used well, only with pieces of code that have been well audited (import through packages or including in the compiler) or as a part of your internal smart contract system (if used sparingly), it can enable a wider amount of use cases without compromising security and readability. |
Phase2:
|
@jacqueswww is Phase 2 complete? I think we should wait to close until it is all done. |
Yep it's done, just a doc fix and we can close. |
@jacqueswww have the docs been updated? |
Yes, they have! :) |
Preamble
VIP: 885
Title: Interfaces
Author: @fubuloubu
Status: Draft
Created: 2018-06-09
Simple Summary
Have contracts specify and implement interfaces.
Abstract
We need a succinct way of describing how our contracts implement interfaces that is intuitive and easy to understand, so that we can do pretty standard things like write compliant tokens.
Motivation
Currently there is no way for contracts to actually import an interface, only use standard ones we define. When we add the capability to import, we will very soon need a way to actually have a contract implement them.
Specification
UnimplmenetedInterface
Error if any standard ERC20 function (totalSupply()
,balanceOf()
,transfer()
) is unimplemented.UnimplmenetedInterface
Warning for each optional ERC20 function (approve()
,allowance()
,transferFrom()
) that is unimplemented.UnimplmenetedInterface
IncorrectInterface
Error if the interface is not implemented correctly.UnusedEvent
Warning for each event defined in an interface that is not triggered in a function.Imports from files
The vyper compiler (bin/vyper) should know how to import custom defined interfaces, which are read from the compilers execution path (pwd).
Which will read the one.vy contract file and make the given interface is implemented.
External contract calls
Interface should also be able to be used to make external contract calls e.g.
Backwards Compatibility
implements
is backwards compatible.Adding events in contract definition is backwards compatible.
Copyright
Copyright and related rights waived via CC0
The text was updated successfully, but these errors were encountered: