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

VIP: Generate ABI from Vyper interface #1944

Open
iamdefinitelyahuman opened this issue Apr 30, 2020 · 4 comments
Open

VIP: Generate ABI from Vyper interface #1944

iamdefinitelyahuman opened this issue Apr 30, 2020 · 4 comments
Labels
VIP: Approved VIP Approved

Comments

@iamdefinitelyahuman
Copy link
Contributor

iamdefinitelyahuman commented Apr 30, 2020

Simple Summary

It should be possible to generate an ABI from a Vyper interface.

Currently this fails with an error of "Missing or Unmatched return statements".

Motivation

A Vyper interface and an ABI are essentially different formats of the same information. It should be possible to convert from one to the other.

Specification

  1. Introduce a new suffix .vyi to differentiate between vyper interfaces and vyper contracts.
  2. Encourage the use of the ellipsis ... for the function body within interfaces.

In general - if an ABI is to be compiled from a contract, that contract should be compilable. If an ABI is generated from an interface, the compiler should recognize this and not attempt to compile it. The presence of ..., and nothing else, within a function body, serves as an indicator that this is an interface not a contract.

Backwards Compatibility

No issues.

Copyright

Copyright and related rights waived via CC0

@fubuloubu fubuloubu added the VIP: Discussion Used to denote VIPs and more complex issues that are waiting discussion in a meeting label Apr 30, 2020
@fubuloubu fubuloubu mentioned this issue Apr 30, 2020
7 tasks
@fubuloubu
Copy link
Member

Meeting notes: Introducing the ellipse operator ... only for interface definitions. This would skip the return check and generate an empty body

@iamdefinitelyahuman iamdefinitelyahuman added VIP: Approved VIP Approved and removed VIP: Discussion Used to denote VIPs and more complex issues that are waiting discussion in a meeting labels May 11, 2020
@iamdefinitelyahuman
Copy link
Contributor Author

iamdefinitelyahuman commented Jul 7, 2020

Ran into an issue with this - currently our ABI includes gas estimates for each function, but obviously we can't do that for an interface.

I think the best approach is to separate the gas estimate from the ABI via #1997. But does removing gas estimates from the ABI constitute a breaking change?

Alternatively we could only include gas costs when it's possible to calculate them.

@fubuloubu
Copy link
Member

Alternatively we could only include gas costs when it's possible to calculate them.

This sounds like what we'd want to do

@fubuloubu
Copy link
Member

In relation to your comment here #1951 (comment), I think it may actually be better to encourage people to use json for standalone interface files, reserving Vyper interfaces for normal .vy files. This way we don't have to worry about the distinction, as the main use case is importing the interface from an existing contract, not as a secondary way to create public ABIs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
VIP: Approved VIP Approved
Projects
None yet
Development

No branches or pull requests

2 participants