Skip to content

Commit

Permalink
fix(x/auth): ensure nil .BaseAccounts are reported in ModuleAccount.V…
Browse files Browse the repository at this point in the history
…alidate (backport cosmos#16554) (cosmos#16570)

Co-authored-by: Emmanuel T Odeke <emmanuel@orijtech.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
  • Loading branch information
3 people authored and JeancarloBarrios committed Sep 28, 2024
1 parent a87161f commit c92388a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ Ref: https://keepachangelog.com/en/1.0.0/

* (deps) [#16553](https://github.com/cosmos/cosmos-sdk/pull/16553) Bump CometBFT to [v0.34.29](https://github.com/cometbft/cometbft/blob/v0.34.29/CHANGELOG.md#v03429).

### Bug Fixes

* (x/auth) [#16554](https://github.com/cosmos/cosmos-sdk/pull/16554) `ModuleAccount.Validate` now reports a nil `.BaseAccount` instead of panicking.

## [v0.46.13](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.13) - 2023-06-08

### Features
Expand Down
2 changes: 1 addition & 1 deletion x/auth/types/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func (ma ModuleAccount) Validate() error {
return errors.New("uninitialized ModuleAccount: BaseAccount is nil")
}

if ma.Address != sdk.AccAddress(AddressHash([]byte(ma.Name))).String() {
if ma.Address != sdk.AccAddress(crypto.AddressHash([]byte(ma.Name))).String() {
return fmt.Errorf("address %s cannot be derived from the module name '%s'", ma.Address, ma.Name)
}

Expand Down
6 changes: 0 additions & 6 deletions x/auth/types/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,6 @@ func TestGenesisAccountsContains(t *testing.T) {
require.True(t, genAccounts.Contains(acc.GetAddress()))
}

func TestNewModuleAddressOrBech32Address(t *testing.T) {
input := "cosmos1cwwv22j5ca08ggdv9c2uky355k908694z577tv"
require.Equal(t, input, types.NewModuleAddressOrBech32Address(input).String())
require.Equal(t, "cosmos1jv65s3grqf6v6jl3dp4t6c9t9rk99cd88lyufl", types.NewModuleAddressOrBech32Address("distribution").String())
}

func TestModuleAccountValidateNilBaseAccount(t *testing.T) {
ma := &types.ModuleAccount{Name: "foo"}
_ = ma.Validate()
Expand Down

0 comments on commit c92388a

Please sign in to comment.