-
Notifications
You must be signed in to change notification settings - Fork 249
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
near_bindgen
methods with no self
check for attached deposit
#718
Comments
Just to be clear, codegen having a check for the attached deposit is a side effect of such functions being identified as call functions. Also, the markdown is all messed up again, curse you exalate |
I am applying to this issue via OnlyDust platform. My background and how it can be leveragedI have 4 years working in development environments, have encountered several challenges, requests and teams focusing in reusable and efficient code, so that gives me a better understanding of the code and how to solve problems efficiently. How I plan on tackling this issueMy approach here would be adding checks for env::attached_deposit in NEAR contract methods, the solution involves refining the code generation logic to more accurately distinguish between view methods and state-changing methods. |
I am applying to this issue via OnlyDust platform. My background and how it can be leveragedI'm developer working around blockchain |
I’d like to help with this. |
Methods like this will add the codegen assumed when a contract mutates state. A slightly strange pattern we have that defaults to checking this only when the parameter is
&mut self
even though in any function there can be state changes not tied to the contract state.Tying the check for attached deposit to whether or not contract state changes is a strange pattern IMO but the band-aid fix is to just remove this check when contract state isn't used. This needs to be done so that these methods can be called with a view operation, otherwise, the runtime will fail when trying to call
env::attached_deposit
from within a view call.Test for this looks like:
which is currently failing because it adds the extra check
The text was updated successfully, but these errors were encountered: