Skip to content

Commit

Permalink
troubleshooting inferred type error in types/math
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-zaremba committed Feb 8, 2024
1 parent c987e43 commit d8ace46
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions types/math/math.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"cosmossdk.io/errors"

Check failure on line 5 in types/math/math.go

View workflow job for this annotation

GitHub Actions / golangci (types)

File is not `goimports`-ed (goimports)
"fmt"
"github.com/cockroachdb/apd/v2"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)

var exactContext = apd.Context{
Expand Down Expand Up @@ -49,7 +48,7 @@ func SafeSubBalance(x Dec, y Dec) (Dec, error) {
}

if z.IsNegative() {
return z, sdkerrors.ErrInsufficientFunds
return z, errNegativeSub
}

return z, nil
Expand All @@ -61,8 +60,7 @@ func SafeAddBalance(x Dec, y Dec) (Dec, error) {
var z Dec

if x.IsNegative() || y.IsNegative() {
return z, sdkerrors.ErrInvalidRequest.Wrap(fmt.Sprintf("AddBalance() requires two non-negative Dec parameters, but received %s and %s", x, y))

return z, fmt.Errorf("SafeAddBalance() requires two non-negative Dec parameters, but received %s and %s", x, y)
}

if _, err := exactContext.Add(&z.dec, &x.dec, &y.dec); err != nil {
Expand Down

0 comments on commit d8ace46

Please sign in to comment.