-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
feat[lang]: export interfaces #3919
feat[lang]: export interfaces #3919
Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #3919 +/- ##
==========================================
- Coverage 90.85% 89.10% -1.75%
==========================================
Files 95 95
Lines 14416 14436 +20
Branches 3192 3201 +9
==========================================
- Hits 13097 12863 -234
- Misses 913 1118 +205
- Partials 406 455 +49 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add at least a few tests
this test crashes the compiler (btw it tries to test selector clashes when exporting via interfaces, though the issue seems unrelated) ifoo = """
@external
def gsf():
...
"""
lib1 = """
import ifoo
@external
@view
def tgeo() -> uint256:
return 1
"""
main = """
import lib1
exports: lib1.ifoo
"""
input_bundle = make_input_bundle({"lib1.vy": lib1, "ifoo.vyi": ifoo})
c = get_contract(main, input_bundle=input_bundle)
|
add exports tests
only allow exporting `implement`ed interfaces
fixed in 6650768 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is currently an issue wrt the __init__
handling:
During handling of the above exception, another exception occurred:
vyper.exceptions.CompilerPanic: unhandled exception '__init__'
To replicate: use my TimelockControllerMock.vy
and replace the exports
with:
exports: tc.__interface__
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on snekmate contracts and tests pass. I recommend adding an additional test for __default__
function. Otherwise, lgtm.
Fixed via 0450173. |
…devdoc` Sanity Check (#235) ### 🕓 Changelog This PR refactors the existing module-friendly contracts to use the new dunder method `__interface__` (see vyperlang/vyper#3919), which allows you to export all functions of a module without specifying the individual functions. We apply the following rules: - Library modules keep the individual list `exports` syntax due to explicitness (application developers can thus identify faster what is exported within a library module), - Mocks might use it if more than one `external` function is exported. We do not use it in mock contracts if critical code comments for exported functions would be lost. Furthermore, we remove the `userdoc` and `devdoc` compilation script & CI pipeline since it's now computed as part of the standard compilation pipeline (vyperlang/vyper#3946). --------- Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch> Co-authored-by: sudo rm -rf --no-preserve-root / <pcaversaccio@users.noreply.github.com> Co-authored-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
this commit allows exporting of `module.<interface>`, and also adds `module.__interface__` which gives the interface type of the module. in particular, this makes it easier for users to export all functions from a module, since they do not need to list out every single function manually. note that since `module.__interface__` is actually an interface type, it can theoretically be used in type expressions, e.g., ```vyper x: module.__interface__ = module.__interface__(msg.sender) ``` however, it doesn't work yet as some additional work is required to properly thread the type into the type analysis system (see related: GH vyperlang#3943). this commit includes the restriction that only `implement`ed interfaces can be exported, this makes the most sense from a UX / user intuition perspective. --------- Co-authored-by: cyberthirst <cyberthirst.eth@gmail.com>
What I did
How I did it
How to verify it
examples:
Commit message
Description for the changelog
Cute Animal Picture