diff --git a/CHANGELOG.md b/CHANGELOG.md index f11371c63493..6461297889d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/authz) [#13047](https://github.com/cosmos/cosmos-sdk/pull/13047) Add a GetAuthorization function to the keeper. +### Improvements + +* (x/auth) [#13048](https://github.com/cosmos/cosmos-sdk/pull/13048) Add handling of AccountNumberStoreKeyPrefix to the simulation decoder. + ### Bug Fixes * (export) [#13029](https://github.com/cosmos/cosmos-sdk/pull/13029) Fix exporting the blockParams regression. diff --git a/x/auth/simulation/decoder.go b/x/auth/simulation/decoder.go index 61a551ba5208..df4a202744f1 100644 --- a/x/auth/simulation/decoder.go +++ b/x/auth/simulation/decoder.go @@ -7,6 +7,7 @@ import ( gogotypes "github.com/gogo/protobuf/types" "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" "github.com/cosmos/cosmos-sdk/x/auth/types" ) @@ -41,6 +42,20 @@ func NewDecodeStore(ak AuthUnmarshaler) func(kvA, kvB kv.Pair) string { return fmt.Sprintf("GlobalAccNumberA: %d\nGlobalAccNumberB: %d", globalAccNumberA, globalAccNumberB) + case bytes.HasPrefix(kvA.Key, types.AccountNumberStoreKeyPrefix): + var accNumA, accNumB sdk.AccAddress + err := accNumA.Unmarshal(kvA.Value) + if err != nil { + panic(err) + } + + err = accNumB.Unmarshal(kvB.Value) + if err != nil { + panic(err) + } + + return fmt.Sprintf("AccNumA: %s\nAccNumB: %s", accNumA, accNumB) + default: panic(fmt.Sprintf("unexpected %s key %X (%s)", types.ModuleName, kvA.Key, kvA.Key)) } diff --git a/x/auth/simulation/decoder_test.go b/x/auth/simulation/decoder_test.go index c79f5c4595d9..95a966a005fa 100644 --- a/x/auth/simulation/decoder_test.go +++ b/x/auth/simulation/decoder_test.go @@ -41,6 +41,10 @@ func TestDecodeStore(t *testing.T) { Key: types.GlobalAccountNumberKey, Value: cdc.MustMarshal(&globalAccNumber), }, + { + Key: types.AccountNumberStoreKey(5), + Value: acc.GetAddress().Bytes(), + }, { Key: []byte{0x99}, Value: []byte{0x99}, @@ -53,6 +57,7 @@ func TestDecodeStore(t *testing.T) { }{ {"Account", fmt.Sprintf("%v\n%v", acc, acc)}, {"GlobalAccNumber", fmt.Sprintf("GlobalAccNumberA: %d\nGlobalAccNumberB: %d", globalAccNumber, globalAccNumber)}, + {"AccNum", fmt.Sprintf("AccNumA: %s\nAccNumB: %s", acc.GetAddress(), acc.GetAddress())}, {"other", ""}, }