diff --git a/CHANGELOG.md b/CHANGELOG.md index 23576f9d06..81576ab9a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (server/grpc) [\#516](https://github.com/line/lbm-sdk/pull/516) restore build norace flag * (genesis) [\#517](https://github.com/line/lbm-sdk/pull/517) fix genesis auth account format(cosmos-sdk style -> lbm-sdk style) * (x/foundation) [\#545](https://github.com/line/lbm-sdk/pull/545) fix genesis and support abstain +* (x/auth) [\#563](https://github.com/line/lbm-sdk/pull/563) fix unmarshal bug of `BaseAccountJSON` ### Breaking Changes diff --git a/x/auth/types/account.go b/x/auth/types/account.go index 1c7a1eb550..5f520d4178 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -438,7 +438,7 @@ type PubKeyJSON struct { type BaseAccountJSON struct { Address string `json:"address"` PubKey PubKeyJSON `json:"pub_key"` - AccountNumber uint64 `json:"account_number"` + AccountNumber uint64 `json:"account_number,string"` Sequence string `json:"sequence"` } diff --git a/x/auth/types/account_test.go b/x/auth/types/account_test.go index 0a5b7179b7..1037621f44 100644 --- a/x/auth/types/account_test.go +++ b/x/auth/types/account_test.go @@ -4,6 +4,7 @@ import ( "encoding/json" "errors" "fmt" + "strings" "testing" "github.com/gogo/protobuf/jsonpb" @@ -237,6 +238,15 @@ func TestModuleAccountJSONPB(t *testing.T) { require.Error(t, err) } +func TestBaseAccountJSONPB(t *testing.T) { + baseAccountJson := `{"address":"link1rrfywnytlm87ywes0hvxn4rhm4grrn9qquqljc","pub_key":{"type":0,"key":null},"account_number":"10","sequence":"50"}` + ba := new(types.BaseAccount) + jum := jsonpb.Unmarshaler{} + err := jum.Unmarshal(strings.NewReader(baseAccountJson), ba) + require.NoError(t, err) + require.Equal(t, ba.AccountNumber, uint64(10)) +} + func TestGenesisAccountsContains(t *testing.T) { pubkey := secp256k1.GenPrivKey().PubKey() addr := sdk.BytesToAccAddress(pubkey.Address())