-
Notifications
You must be signed in to change notification settings - Fork 41
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
ref: add associated error types for contract traits #251
Conversation
✅ Deploy Preview for contracts-stylus canceled.
|
@@ -60,18 +60,6 @@ pub enum Error { | |||
ECDSA(ecdsa::Error), | |||
} | |||
|
|||
impl MethodError for erc20::Error { |
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.
MethodError
implementation is moved to the corresponding contract
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.
This means that this import can be removed from this file, right?
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.
Looks good but I do not like having impl MethodError
many times...
42f0502
to
bd9049e
Compare
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.
Looks good!
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.
If I understand correctly this change, I would expect it to affect our examples, right? What is the practical result of this change?
@@ -60,18 +60,6 @@ pub enum Error { | |||
ECDSA(ecdsa::Error), | |||
} | |||
|
|||
impl MethodError for erc20::Error { |
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.
This means that this import can be removed from this file, right?
Allows to the library users to reuse our traits with their own error types.
And it is more "rusty" approach having associated error types for traits with fallible functions.
Adds new functional macro for the
MethodError
trait.