diff --git a/CHANGELOG.md b/CHANGELOG.md index ef67961d2a50..cc391bec7aa7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -165,7 +165,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [\#10466](https://github.com/cosmos/cosmos-sdk/issues/10466) Fixes error with simulation tests when genesis start time is randomly created after the year 2262 * [\#10394](https://github.com/cosmos/cosmos-sdk/issues/10394) Fixes issue related to grpc-gateway of account balance by ibc-denom. -* [#10593](https://github.com/cosmos/cosmos-sdk/pull/10593) Update swagger-ui to v4.1.0 to fix xss vulnerability. +* [\#10593](https://github.com/cosmos/cosmos-sdk/pull/10593) Update swagger-ui to v4.1.0 to fix xss vulnerability. +* [\#10674](https://github.com/cosmos/cosmos-sdk/pull/10674) Fix issue with `Error.Wrap` and `Error.Wrapf` usage with `errors.Is`. ### State Machine Breaking diff --git a/types/errors/errors.go b/types/errors/errors.go index 62dab18adf8c..12a912cc49ce 100644 --- a/types/errors/errors.go +++ b/types/errors/errors.go @@ -266,11 +266,11 @@ func (e *Error) Is(err error) bool { // Wrap extends this error with an additional information. // It's a handy function to call Wrap with sdk errors. -func (e Error) Wrap(desc string) error { return Wrap(e, desc) } +func (e *Error) Wrap(desc string) error { return Wrap(e, desc) } // Wrapf extends this error with an additional information. // It's a handy function to call Wrapf with sdk errors. -func (e Error) Wrapf(desc string, args ...interface{}) error { return Wrapf(e, desc, args...) } +func (e *Error) Wrapf(desc string, args ...interface{}) error { return Wrapf(e, desc, args...) } func isNilErr(err error) bool { // Reflect usage is necessary to correctly compare with diff --git a/types/errors/errors_test.go b/types/errors/errors_test.go index c72344e4f1e9..b7e9c478fe26 100644 --- a/types/errors/errors_test.go +++ b/types/errors/errors_test.go @@ -200,6 +200,11 @@ func (s *errorsTestSuite) TestWrappedIs() { errw := &wrappedError{"msg", errs} require.True(errw.Is(errw), "should match itself") + + require.True(stdlib.Is(ErrInsufficientFee.Wrap("wrapped"), ErrInsufficientFee)) + require.True(IsOf(ErrInsufficientFee.Wrap("wrapped"), ErrInsufficientFee)) + require.True(stdlib.Is(ErrInsufficientFee.Wrapf("wrapped"), ErrInsufficientFee)) + require.True(IsOf(ErrInsufficientFee.Wrapf("wrapped"), ErrInsufficientFee)) } func (s *errorsTestSuite) TestWrappedIsMultiple() {