-
Notifications
You must be signed in to change notification settings - Fork 447
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
Add trait-incrementer example smart contract #932
Conversation
Codecov Report
@@ Coverage Diff @@
## master #932 +/- ##
==========================================
+ Coverage 84.20% 86.21% +2.00%
==========================================
Files 173 156 -17
Lines 7939 6353 -1586
==========================================
- Hits 6685 5477 -1208
+ Misses 1254 876 -378
Continue to review full report at Codecov.
|
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.
Small comments from my end, but looks good 👍
/// Allows to increment and get the current value. | ||
#[ink::trait_definition] | ||
pub trait Increment { | ||
/// Increments the current value of the implementer by one (1). |
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.
My nitpick here was that it's up to the trait implementer to choose the amount inc
increases by 😉
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.
I do not agree because this would violate the invariant stated by the docs of the trait's message.
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.
Just because our concrete incrementer does _also_support inc_by
does not mean this invariant must not be uphold for the trait implementation in particular. You could say the demonstrated concrete incrementer smart contract provides a richer API than what the ink! trait mandates but that's always fine, also in typical Rust contexts.
New example ink! smart contract extracted from #665.