-
-
Notifications
You must be signed in to change notification settings - Fork 823
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
Importing interfaces not as docs describe #2900
Comments
So, you can't import types from other Vyper contracts. What the docs mean by "regular vyper syntax" is that your file structure and internals should look like this:
@view
@external
def read_stuff() -> uint256:
pass
# @version ^0.3.3
import interfaces.IFace as IFace
@view
@external
def read_contract(some_address: address) -> uint256:
myContract: IFace = IFace(some_address)
return myContract.read_stuff() |
Got it. We should probably update the docs to be more clear - been slamming my head. |
There's also a longer term fix with libraries that is coming in #2431 |
I'm still so confused by this. I have this one file named @external
def interface_func():
pass And then this other file named import contract1 as Contract1
@external
def main_func(_to_call: address):
other_contract: Contract1 = Contract1(_to_call)
to_call.interface_func() However, compilation of
|
Try this import .contract1 as Contract1 |
I tried this before, but it yields in a syntax error:
I also tried putting a separate interface in a subfolder as people mentioned before, but that did not seem to work either. |
this should be closed by the language redesign done in #3663 and #3725. there are still two ways of importing interfaces, via importing
honestly now that you can import types from other modules, we could remove the |
Version Information
vyper --version
): 0.3.3python --version
): 3.9.5What's your issue about?
Please include information like:
I have an interface that looks like such:
And a contract that looks as such:
However, when I run
vyper contracts/MyContract.vy
I get:According to the documentation, when importing interfaces, you need to use regular vyper syntax. However, adjusting my interface as such:
Results in this error:
How can it be fixed?
I'm not sure
The text was updated successfully, but these errors were encountered: