-
-
Notifications
You must be signed in to change notification settings - Fork 804
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
implements
does not respect public getter of interface type
#3954
Comments
@charles-cooper it's not fully fixed yet IMHO. PoC# lib.vy
# pragma version ~=0.4.0rc2
from ethereum.ercs import IERC20
asset: public(immutable(IERC20))
@deploy
def __init__(asset_: IERC20):
asset = asset_ # main.vy
# pragma version ~=0.4.0rc2
from ethereum.ercs import IERC20
import lib
initializes: lib
interface IAsset:
def asset() -> address: view # --> Vyper returns the `address` type for interface types by default.
implements: IAsset
exports: lib.__interface__ # exports the external getter function for `asset`
@deploy
def __init__(asset_: IERC20):
lib.__init__(asset_) This won't compile: vyper.exceptions.InterfaceViolation: Contract does not implement all interface functions: asset()
contract "main.vy:12", line 12:0
11
---> 12 implements: IAsset
--------^
13 The underlying issue I currently face is that I use the built-in vyper/vyper/builtins/interfaces/IERC4626.vyi Lines 15 to 19 in e1adb7b
declare it in a module via (the module itself compiles): asset: public(immutable(IERC20)) and I import into my my main contract, export everything and initialise it. But it throws with the error above. The compiler tells me however, if I do something like |
### 🕓 Changelog This PR refactors the `ERC4626` contract to make it module-friendly and ready for the breaking `0.4.0` release. Please note that due to an open issue (see vyperlang/vyper#3954) on how to handle public getters of interface types in conjunction with `implements`, we fix this issue by storing the interface object as an `immutable` variable called `_ASSET` and assigning `asset` a `public` `immutable` `address` type, which gets assigned at contract creation time via the `.address` member of `_ASSET`: ```vy asset: public(immutable(address)) _ASSET: immutable(IERC20) @Deploy @payable def __init__(..., asset_: IERC20, ...): _ASSET = asset_ asset = _ASSET.address .... ``` --------- Signed-off-by: Pascal Marco Caversaccio <[email protected]>
Public getter of interface type is currently not respected by
implements
if implemented as module:will throw with:
The text was updated successfully, but these errors were encountered: