diff --git a/x/auth/legacy/v040/migrate.go b/x/auth/legacy/v040/migrate.go index 5e190ffea..4fe663a48 100644 --- a/x/auth/legacy/v040/migrate.go +++ b/x/auth/legacy/v040/migrate.go @@ -1,8 +1,6 @@ package v040 import ( - pt "github.com/gogo/protobuf/types" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" v039auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v039" @@ -13,20 +11,15 @@ import ( // convertBaseAccount converts a 0.39 BaseAccount to a 0.40 BaseAccount. func convertBaseAccount(old *v039auth.BaseAccount) *v040auth.BaseAccount { - // In `x/auth/legacy/v038/migrate.go`, when creating a BaseAccount, we - // explicitly set the PublicKey field to nil. This propagates until 0.40, - // and we don't know the PubKey for those accounts, so we just put an empty - // string inside the Any. var any *codectypes.Any - var err error + // If the old genesis had a pubkey, we pack it inside an Any. Or else, we + // just leave it nil. if old.PubKey != nil { + var err error any, err = tx.PubKeyToAny(old.PubKey) - } else { - s := pt.Empty{} - any, err = codectypes.NewAnyWithValue(&s) - } - if err != nil { - panic(err) + if err != nil { + panic(err) + } } return &v040auth.BaseAccount{ diff --git a/x/auth/legacy/v040/migrate_test.go b/x/auth/legacy/v040/migrate_test.go index f8994315b..519b3cb48 100644 --- a/x/auth/legacy/v040/migrate_test.go +++ b/x/auth/legacy/v040/migrate_test.go @@ -228,10 +228,7 @@ func TestMigrate(t *testing.T) { "@type": "/cosmos.auth.v1beta1.BaseAccount", "account_number": "1", "address": "cosmos16ydaqh0fcnh4qt7a3jme4mmztm2qel5axcpw00", - "pub_key": { - "@type": "/google.protobuf.Empty", - "value": {} - }, + "pub_key": null, "sequence": "0" } ], diff --git a/x/auth/types/codec.go b/x/auth/types/codec.go index 52b1eac4a..beb14eab7 100644 --- a/x/auth/types/codec.go +++ b/x/auth/types/codec.go @@ -19,7 +19,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { legacytx.RegisterLegacyAminoCodec(cdc) } -// RegisterInterface associates protoName with AccountI interface +// RegisterInterfaces associates protoName with AccountI interface // and creates a registry of it's concrete implementations func RegisterInterfaces(registry types.InterfaceRegistry) { registry.RegisterInterface(