-
Notifications
You must be signed in to change notification settings - Fork 122
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
Enforce state preconditions #267
Conversation
if (!context?.wasRead || context.wasConstrained) continue; | ||
// we accessed a precondition field but not constrained it explicitly - throw an error | ||
let errorMessage = `You used \`this.${key}.get()\` without adding a precondition that links it to the actual on-chain state. | ||
Consider adding this line to your code: |
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.
Great error message :D
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.
Very clean, LGTM!
this._contract.wasConstrained = true; | ||
}, | ||
|
||
assertNothing() { |
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.
Quick question, when is assertNothing
intended to be used?
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.
No specific use case I had in mind, I just wanted to have an escape hatch to get rid of the error if you have some reason to use .get()
without having a precondition
code that looked like this:
will throw an error, and has to be changed to look like this:
this makes it consistent with the behaviour for other preconditions (#179)