-
-
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
payable
decorator in interface functions not enforced by implements
#3774
Comments
EDIT: Non-issue for
interface Self:
def protected_view_fn() -> String[100]: view
_counter: uint256
@external
def bar() -> String[100]:
return Self(self).protected_view_fn()
@external
def protected_view_fn() -> String[100]:
# state-changing function vs the `view` interface definition
self._counter += 1
return empty(String[100]) |
Is there a missing |
Good catch, thanks for pointing out @tserg! It's indeed a non-issue for |
In my opinion, if this is prevented, we should go even further and enforce that the modifiability of the interface function matches exactly the modifiability of the defined function. For example, preventing also such cases: interface Self:
def protected_view_fn() -> String[100]: nonpayable
implements: Self
@external
@pure
def protected_view_fn() -> String[100]:
return empty(String[100]) interface Self:
def protected_view_fn() -> String[100]: view
implements: Self
@external
@pure
def protected_view_fn() -> String[100]:
return empty(String[100]) Another possibility would be to allow implementing an interface function with modifiability An example of this from @pcaversaccio where for As a side note this will behaviour will conflict with a potential fix to #3743 since the compiler will warn that the modifiability of a function can be reduced but also prevent the user from doing that. |
Great observation @trocher! Yeah, my general point of view has always been that we must optimise for maximum correctness and thus I second enforcing the modifiability of the interface function to match exactly the modifiability of the defined function. |
Version Information
vyper --version
):0.3.11+commit.819de669
linux
python --version
):3.11.3
What's your issue about?
If an interface function (in a
.vyi
file) is marked aspayable
, it is not enforced viaimplements
keyword.Example
vyper Test.vy
0x61002661000f6000396100266000f35f3560e01c63c2985578811861001e5734610022575f60405260206040f35b5f5ffd5b5f80fd8418268000a16576797065728300030b001
This should not compile actually.
How can it be fixed?
Enforce
payable
decorator viaimplements
keyword.The text was updated successfully, but these errors were encountered: