fix: replace string() with hex.EncodeToString() (#24638)

Co-authored-by: Alex | Interchain Labs <alex@interchainlabs.io>
This commit is contained in:
Clockwork 2025-05-02 20:06:11 +03:00 committed by GitHub
parent 2bd11af78d
commit f88a397bc0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 1 deletions

View File

@ -38,6 +38,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
## [Unreleased]
### Bug Fixes
* (x/authz) [#24638](https://github.com/cosmos/cosmos-sdk/pull/24638) Fixed a minor bug where the grant key was cast as a string and dumped directly into the error message leading to an error string possibly containing invalid UTF-8.
### Deprecated
* (x/nft) [#24575](https://github.com/cosmos/cosmos-sdk/pull/24575) Deprecate the `x/nft` module in the Cosmos SDK repository. This module will not be maintained to the extent that our core modules will and will be kept in a [legacy repo](https://github.com/cosmos/cosmos-legacy).

View File

@ -3,6 +3,7 @@ package keeper
import (
"bytes"
"context"
"encoding/hex"
"fmt"
"strconv"
"time"
@ -241,7 +242,7 @@ func (k Keeper) DeleteGrant(ctx context.Context, grantee, granter sdk.AccAddress
skey := grantStoreKey(grantee, granter, msgType)
grant, found := k.getGrant(ctx, skey)
if !found {
return errorsmod.Wrapf(authz.ErrNoAuthorizationFound, "failed to delete grant with key %s", string(skey))
return errorsmod.Wrapf(authz.ErrNoAuthorizationFound, "failed to delete grant with key %s", hex.EncodeToString(skey))
}
if grant.Expiration != nil {

View File

@ -137,6 +137,10 @@ func (s *TestSuite) TestKeeper() {
s.T().Log("verify removing non existing authorization returns error")
err = s.authzKeeper.DeleteGrant(ctx, granterAddr, granteeAddr, "abcd")
s.Require().Error(err)
s.T().Log("verify removing non existing authorization returns error with grant key in hex")
err = s.authzKeeper.DeleteGrant(ctx, granterAddr, granteeAddr, "abcd")
s.Require().Equal("failed to delete grant with key 0114a58856f0fd53bf058b4909a21aec019107ba610114a58856f0fd53bf058b4909a21aec019107ba610061626364: authorization not found", err.Error())
}
func (s *TestSuite) TestKeeperIter() {