-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Remove Redundant Staking Errors #9231
Remove Redundant Staking Errors #9231
Conversation
30d5bfb
to
f76023b
Compare
Codecov Report
@@ Coverage Diff @@
## master #9231 +/- ##
==========================================
- Coverage 60.38% 60.30% -0.08%
==========================================
Files 587 588 +1
Lines 36920 36999 +79
==========================================
+ Hits 22294 22313 +19
- Misses 12651 12710 +59
- Partials 1975 1976 +1
|
3d237c2
to
f0017fa
Compare
x/staking/client/cli/tx.go
Outdated
return types.ErrMinSelfDelegationInvalid | ||
return sdkerrors.Wrap( | ||
sdkerrors.ErrInvalidRequest, | ||
"minimum self delegation must be a positive integer", |
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.
s/positive/valid
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.
Sorry, not sure what you mean by this...would you like the message argument rephrased?
x/staking/client/cli/tx.go
Outdated
return txBldr, nil, types.ErrMinSelfDelegationInvalid | ||
return txBldr, nil, sdkerrors.Wrap( | ||
sdkerrors.ErrInvalidRequest, | ||
"minimum self delegation must be a positive integer", |
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.
s/positive/valid
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.
See aforementioned
x/staking/keeper/delegation.go
Outdated
return shares, sdkerrors.Wrap( | ||
sdkerrors.ErrInvalidRequest, | ||
"invalid shares amount", | ||
) |
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.
There is no need for all the wrapping. Can we have a single line?
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.
Sure thing. Is there support for such formatting via the package linters/formatters so this can be automated for all contributors?
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.
Addressed in 8c69a6f3c
x/staking/types/msg.go
Outdated
return sdkerrors.Wrap( | ||
sdkerrors.ErrInvalidRequest, | ||
"validator address is invalid", | ||
) |
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.
nit: single line :)
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.
See aforementioned
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.
Addressed in 8c69a6f3c
x/staking/types/msg.go
Outdated
return sdkerrors.Wrap( | ||
sdkerrors.ErrInvalidRequest, | ||
"invalid delegation amount", | ||
) |
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.
single line :)
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.
See aforementioned
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.
Addressed in 8c69a6f3c
f0017fa
to
8c69a6f
Compare
@@ -122,7 +123,7 @@ func NewEditValidatorCmd() *cobra.Command { | |||
if minSelfDelegationString != "" { | |||
msb, ok := sdk.NewIntFromString(minSelfDelegationString) | |||
if !ok { | |||
return types.ErrMinSelfDelegationInvalid | |||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "minimum self delegation must be a positive integer") |
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.
you can use the wrap method of the error, it makes the code a bit shorter
sdkerrors.ErrInvalidRequest.Wrap("minimum self delegation must be a positive integer"
Same in other places.
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.
@robert-zaremba Thanks for bringing this to my attention, I'll take a look at the Wrap()
implementation. I see both implementation strategies in the repository, please let me know which is preferred and whether refactoring should be executed accordingly
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 think this is more of a nit. We use the design currently coded throughout the repo and the one robert mentioned in a few places.
@robert-zaremba want to approve this?
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'm not blocking it - I only made a suggestion. The PR already got enough approvals.
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.
BTW - we implemented the Wrap
method for the error types 2-3 months ago, that why it's not use that much.
…move unused error types
8c69a6f
to
4914118
Compare
* refactor(staking errors): 'invalid' errors: use ErrInvalidRequest, remove unused error types * refactor(staking errors): fix error registration codes * support(staking errors): add changelog entry * fix(staking test suite): update expected error codes relative to refactor * chore(staking errors): code formatting Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Description
closes: #5450
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes