diff --git a/app.go b/app.go index 20215e8486f9..8c77d03c54ad 100644 --- a/app.go +++ b/app.go @@ -11,6 +11,7 @@ import ( bam "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" + simappcodec "github.com/cosmos/cosmos-sdk/simapp/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/version" @@ -78,7 +79,6 @@ var ( } ) -// Verify app interface at compile time var _ App = (*SimApp)(nil) // SimApp extends an ABCI application, but with most of its parameters exported. @@ -124,10 +124,10 @@ func NewSimApp( invCheckPeriod uint, baseAppOptions ...func(*bam.BaseApp), ) *SimApp { - appCodec := NewAppCodec() - // TODO: Remove cdc in favor of appCodec once all modules are migrated. - cdc := MakeCodec() + cdc := simappcodec.MakeCodec(ModuleBasics) + + appCodec := simappcodec.NewAppCodec(cdc) bApp := bam.NewBaseApp(appName, logger, db, auth.DefaultTxDecoder(cdc), baseAppOptions...) bApp.SetCommitMultiStoreTracer(traceStore) @@ -150,7 +150,7 @@ func NewSimApp( } // init params keeper and subspaces - app.ParamsKeeper = params.NewKeeper(appCodec.Params, keys[params.StoreKey], tkeys[params.TStoreKey]) + app.ParamsKeeper = params.NewKeeper(appCodec, keys[params.StoreKey], tkeys[params.TStoreKey]) app.subspaces[auth.ModuleName] = app.ParamsKeeper.Subspace(auth.DefaultParamspace) app.subspaces[bank.ModuleName] = app.ParamsKeeper.Subspace(bank.DefaultParamspace) app.subspaces[staking.ModuleName] = app.ParamsKeeper.Subspace(staking.DefaultParamspace) @@ -163,23 +163,23 @@ func NewSimApp( // add keepers app.AccountKeeper = auth.NewAccountKeeper( - app.cdc, keys[auth.StoreKey], app.subspaces[auth.ModuleName], auth.ProtoBaseAccount, + appCodec, keys[auth.StoreKey], app.subspaces[auth.ModuleName], auth.ProtoBaseAccount, ) app.BankKeeper = bank.NewBaseKeeper( app.cdc, keys[bank.StoreKey], app.AccountKeeper, app.subspaces[bank.ModuleName], app.BlacklistedAccAddrs(), ) app.SupplyKeeper = supply.NewKeeper( - app.cdc, keys[supply.StoreKey], app.AccountKeeper, app.BankKeeper, maccPerms, + appCodec, keys[supply.StoreKey], app.AccountKeeper, app.BankKeeper, maccPerms, ) stakingKeeper := staking.NewKeeper( - appCodec.Staking, keys[staking.StoreKey], app.BankKeeper, app.SupplyKeeper, app.subspaces[staking.ModuleName], + appCodec, keys[staking.StoreKey], app.BankKeeper, app.SupplyKeeper, app.subspaces[staking.ModuleName], ) app.MintKeeper = mint.NewKeeper( app.cdc, keys[mint.StoreKey], app.subspaces[mint.ModuleName], &stakingKeeper, app.SupplyKeeper, auth.FeeCollectorName, ) app.DistrKeeper = distr.NewKeeper( - appCodec.Distribution, keys[distr.StoreKey], app.subspaces[distr.ModuleName], app.BankKeeper, &stakingKeeper, + appCodec, keys[distr.StoreKey], app.subspaces[distr.ModuleName], app.BankKeeper, &stakingKeeper, app.SupplyKeeper, auth.FeeCollectorName, app.ModuleAccountAddrs(), ) app.SlashingKeeper = slashing.NewKeeper( @@ -305,7 +305,7 @@ func (app *SimApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.Re func (app *SimApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { var genesisState GenesisState app.cdc.MustUnmarshalJSON(req.AppStateBytes, &genesisState) - return app.mm.InitGenesis(ctx, genesisState) + return app.mm.InitGenesis(ctx, app.cdc, genesisState) } // LoadHeight loads a particular height diff --git a/codec.go b/codec.go deleted file mode 100644 index 0e8aabe15cb2..000000000000 --- a/codec.go +++ /dev/null @@ -1,46 +0,0 @@ -package simapp - -import ( - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth/vesting" - distr "github.com/cosmos/cosmos-sdk/x/distribution" - "github.com/cosmos/cosmos-sdk/x/params" - "github.com/cosmos/cosmos-sdk/x/staking" -) - -// AppCodec defines the application-level codec. This codec contains all the -// required module-specific codecs that are to be provided upon initialization. -type AppCodec struct { - amino *codec.Codec - - Params *params.Codec - Staking *staking.Codec - Distribution *distr.Codec -} - -func NewAppCodec() *AppCodec { - amino := MakeCodec() - - return &AppCodec{ - amino: amino, - Params: params.NewCodec(amino), - Staking: staking.NewCodec(amino), - Distribution: distr.NewCodec(amino), - } -} - -// MakeCodec creates and returns a reference to an Amino codec that has all the -// necessary types and interfaces registered. This codec is provided to all the -// modules the application depends on. -// -// NOTE: This codec will be deprecated in favor of AppCodec once all modules are -// migrated. -func MakeCodec() *codec.Codec { - var cdc = codec.New() - ModuleBasics.RegisterCodec(cdc) - vesting.RegisterCodec(cdc) - sdk.RegisterCodec(cdc) - codec.RegisterCrypto(cdc) - return cdc -} diff --git a/codec/codec.go b/codec/codec.go new file mode 100644 index 000000000000..912bd355bc86 --- /dev/null +++ b/codec/codec.go @@ -0,0 +1,128 @@ +package codec + +import ( + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/x/auth" + authexported "github.com/cosmos/cosmos-sdk/x/auth/exported" + "github.com/cosmos/cosmos-sdk/x/auth/vesting" + "github.com/cosmos/cosmos-sdk/x/supply" + "github.com/cosmos/cosmos-sdk/x/supply/exported" +) + +var ( + _ auth.Codec = (*Codec)(nil) + _ supply.Codec = (*Codec)(nil) +) + +// Codec defines the application-level codec. This codec contains all the +// required module-specific codecs that are to be provided upon initialization. +type Codec struct { + codec.Marshaler + + // Keep reference to the amino codec to allow backwards compatibility along + // with type, and interface registration. + amino *codec.Codec +} + +func NewAppCodec(amino *codec.Codec) *Codec { + return &Codec{Marshaler: codec.NewHybridCodec(amino), amino: amino} +} + +// MarshalAccount marshals an Account interface. If the given type implements +// the Marshaler interface, it is treated as a Proto-defined message and +// serialized that way. Otherwise, it falls back on the internal Amino codec. +func (c *Codec) MarshalAccount(accI authexported.Account) ([]byte, error) { + acc := &Account{} + if err := acc.SetAccount(accI); err != nil { + return nil, err + } + + return c.Marshaler.MarshalBinaryLengthPrefixed(acc) +} + +// UnmarshalAccount returns an Account interface from raw encoded account bytes +// of a Proto-based Account type. An error is returned upon decoding failure. +func (c *Codec) UnmarshalAccount(bz []byte) (authexported.Account, error) { + acc := &Account{} + if err := c.Marshaler.UnmarshalBinaryLengthPrefixed(bz, acc); err != nil { + return nil, err + } + + return acc.GetAccount(), nil +} + +// MarshalAccountJSON JSON encodes an account object implementing the Account +// interface. +func (c *Codec) MarshalAccountJSON(acc authexported.Account) ([]byte, error) { + return c.Marshaler.MarshalJSON(acc) +} + +// UnmarshalAccountJSON returns an Account from JSON encoded bytes. +func (c *Codec) UnmarshalAccountJSON(bz []byte) (authexported.Account, error) { + acc := &Account{} + if err := c.Marshaler.UnmarshalJSON(bz, acc); err != nil { + return nil, err + } + + return acc.GetAccount(), nil +} + +// MarshalSupply marshals a SupplyI interface. If the given type implements +// the Marshaler interface, it is treated as a Proto-defined message and +// serialized that way. Otherwise, it falls back on the internal Amino codec. +func (c *Codec) MarshalSupply(supplyI exported.SupplyI) ([]byte, error) { + supply := &Supply{} + if err := supply.SetSupplyI(supplyI); err != nil { + return nil, err + } + + return c.Marshaler.MarshalBinaryLengthPrefixed(supply) +} + +// UnmarshalSupply returns a SupplyI interface from raw encoded account bytes +// of a Proto-based SupplyI type. An error is returned upon decoding failure. +func (c *Codec) UnmarshalSupply(bz []byte) (exported.SupplyI, error) { + supply := &Supply{} + if err := c.Marshaler.UnmarshalBinaryLengthPrefixed(bz, supply); err != nil { + return nil, err + } + + return supply.GetSupplyI(), nil +} + +// MarshalSupplyJSON JSON encodes a supply object implementing the SupplyI +// interface. +func (c *Codec) MarshalSupplyJSON(supply exported.SupplyI) ([]byte, error) { + return c.Marshaler.MarshalJSON(supply) +} + +// UnmarshalSupplyJSON returns a SupplyI from JSON encoded bytes. +func (c *Codec) UnmarshalSupplyJSON(bz []byte) (exported.SupplyI, error) { + supply := &Supply{} + if err := c.Marshaler.UnmarshalJSON(bz, supply); err != nil { + return nil, err + } + + return supply.GetSupplyI(), nil +} + +// ---------------------------------------------------------------------------- + +// MakeCodec creates and returns a reference to an Amino codec that has all the +// necessary types and interfaces registered. This codec is provided to all the +// modules the application depends on. +// +// NOTE: This codec will be deprecated in favor of AppCodec once all modules are +// migrated. +func MakeCodec(bm module.BasicManager) *codec.Codec { + cdc := codec.New() + + bm.RegisterCodec(cdc) + vesting.RegisterCodec(cdc) + sdk.RegisterCodec(cdc) + codec.RegisterCrypto(cdc) + + return cdc +} diff --git a/codec/codec.pb.go b/codec/codec.pb.go new file mode 100644 index 000000000000..775948f5a35f --- /dev/null +++ b/codec/codec.pb.go @@ -0,0 +1,1039 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: simapp/codec/codec.proto + +package codec + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_x_auth_exported "github.com/cosmos/cosmos-sdk/x/auth/exported" + types "github.com/cosmos/cosmos-sdk/x/auth/types" + types1 "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" + github_com_cosmos_cosmos_sdk_x_supply_exported "github.com/cosmos/cosmos-sdk/x/supply/exported" + types2 "github.com/cosmos/cosmos-sdk/x/supply/types" + proto "github.com/gogo/protobuf/proto" + _ "github.com/regen-network/cosmos-proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Account defines the application-level Account type. +type Account struct { + // sum defines a list of all acceptable concrete Account implementations. + // + // Types that are valid to be assigned to Sum: + // *Account_BaseAccount + // *Account_ContinuousVestingAccount + // *Account_DelayedVestingAccount + // *Account_PeriodicVestingAccount + // *Account_ModuleAccount + Sum isAccount_Sum `protobuf_oneof:"sum"` +} + +func (m *Account) Reset() { *m = Account{} } +func (m *Account) String() string { return proto.CompactTextString(m) } +func (*Account) ProtoMessage() {} +func (*Account) Descriptor() ([]byte, []int) { + return fileDescriptor_3c6d4085e4065f5a, []int{0} +} +func (m *Account) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Account) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Account.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Account) XXX_Merge(src proto.Message) { + xxx_messageInfo_Account.Merge(m, src) +} +func (m *Account) XXX_Size() int { + return m.Size() +} +func (m *Account) XXX_DiscardUnknown() { + xxx_messageInfo_Account.DiscardUnknown(m) +} + +var xxx_messageInfo_Account proto.InternalMessageInfo + +type isAccount_Sum interface { + isAccount_Sum() + MarshalTo([]byte) (int, error) + Size() int +} + +type Account_BaseAccount struct { + BaseAccount *types.BaseAccount `protobuf:"bytes,1,opt,name=base_account,json=baseAccount,proto3,oneof" json:"base_account,omitempty"` +} +type Account_ContinuousVestingAccount struct { + ContinuousVestingAccount *types1.ContinuousVestingAccount `protobuf:"bytes,2,opt,name=continuous_vesting_account,json=continuousVestingAccount,proto3,oneof" json:"continuous_vesting_account,omitempty"` +} +type Account_DelayedVestingAccount struct { + DelayedVestingAccount *types1.DelayedVestingAccount `protobuf:"bytes,3,opt,name=delayed_vesting_account,json=delayedVestingAccount,proto3,oneof" json:"delayed_vesting_account,omitempty"` +} +type Account_PeriodicVestingAccount struct { + PeriodicVestingAccount *types1.PeriodicVestingAccount `protobuf:"bytes,4,opt,name=periodic_vesting_account,json=periodicVestingAccount,proto3,oneof" json:"periodic_vesting_account,omitempty"` +} +type Account_ModuleAccount struct { + ModuleAccount *types2.ModuleAccount `protobuf:"bytes,5,opt,name=module_account,json=moduleAccount,proto3,oneof" json:"module_account,omitempty"` +} + +func (*Account_BaseAccount) isAccount_Sum() {} +func (*Account_ContinuousVestingAccount) isAccount_Sum() {} +func (*Account_DelayedVestingAccount) isAccount_Sum() {} +func (*Account_PeriodicVestingAccount) isAccount_Sum() {} +func (*Account_ModuleAccount) isAccount_Sum() {} + +func (m *Account) GetSum() isAccount_Sum { + if m != nil { + return m.Sum + } + return nil +} + +func (m *Account) GetBaseAccount() *types.BaseAccount { + if x, ok := m.GetSum().(*Account_BaseAccount); ok { + return x.BaseAccount + } + return nil +} + +func (m *Account) GetContinuousVestingAccount() *types1.ContinuousVestingAccount { + if x, ok := m.GetSum().(*Account_ContinuousVestingAccount); ok { + return x.ContinuousVestingAccount + } + return nil +} + +func (m *Account) GetDelayedVestingAccount() *types1.DelayedVestingAccount { + if x, ok := m.GetSum().(*Account_DelayedVestingAccount); ok { + return x.DelayedVestingAccount + } + return nil +} + +func (m *Account) GetPeriodicVestingAccount() *types1.PeriodicVestingAccount { + if x, ok := m.GetSum().(*Account_PeriodicVestingAccount); ok { + return x.PeriodicVestingAccount + } + return nil +} + +func (m *Account) GetModuleAccount() *types2.ModuleAccount { + if x, ok := m.GetSum().(*Account_ModuleAccount); ok { + return x.ModuleAccount + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*Account) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*Account_BaseAccount)(nil), + (*Account_ContinuousVestingAccount)(nil), + (*Account_DelayedVestingAccount)(nil), + (*Account_PeriodicVestingAccount)(nil), + (*Account_ModuleAccount)(nil), + } +} + +// Supply defines the application-level Supply type. +type Supply struct { + // sum defines a list of all acceptable concrete Supply implementations. + // + // Types that are valid to be assigned to Sum: + // *Supply_Supply + Sum isSupply_Sum `protobuf_oneof:"sum"` +} + +func (m *Supply) Reset() { *m = Supply{} } +func (m *Supply) String() string { return proto.CompactTextString(m) } +func (*Supply) ProtoMessage() {} +func (*Supply) Descriptor() ([]byte, []int) { + return fileDescriptor_3c6d4085e4065f5a, []int{1} +} +func (m *Supply) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Supply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Supply.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Supply) XXX_Merge(src proto.Message) { + xxx_messageInfo_Supply.Merge(m, src) +} +func (m *Supply) XXX_Size() int { + return m.Size() +} +func (m *Supply) XXX_DiscardUnknown() { + xxx_messageInfo_Supply.DiscardUnknown(m) +} + +var xxx_messageInfo_Supply proto.InternalMessageInfo + +type isSupply_Sum interface { + isSupply_Sum() + MarshalTo([]byte) (int, error) + Size() int +} + +type Supply_Supply struct { + Supply *types2.Supply `protobuf:"bytes,1,opt,name=supply,proto3,oneof" json:"supply,omitempty"` +} + +func (*Supply_Supply) isSupply_Sum() {} + +func (m *Supply) GetSum() isSupply_Sum { + if m != nil { + return m.Sum + } + return nil +} + +func (m *Supply) GetSupply() *types2.Supply { + if x, ok := m.GetSum().(*Supply_Supply); ok { + return x.Supply + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*Supply) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*Supply_Supply)(nil), + } +} + +func init() { + proto.RegisterType((*Account)(nil), "cosmos_sdk.simapp.codec.v1.Account") + proto.RegisterType((*Supply)(nil), "cosmos_sdk.simapp.codec.v1.Supply") +} + +func init() { proto.RegisterFile("simapp/codec/codec.proto", fileDescriptor_3c6d4085e4065f5a) } + +var fileDescriptor_3c6d4085e4065f5a = []byte{ + // 444 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0x4f, 0x8b, 0xd3, 0x40, + 0x18, 0xc6, 0x13, 0x77, 0xb7, 0xc2, 0xac, 0x7a, 0x08, 0xa8, 0x21, 0x87, 0xb0, 0x2e, 0x08, 0xfe, + 0xa1, 0x13, 0xd6, 0xf5, 0xef, 0x7a, 0xb2, 0x15, 0xa9, 0x07, 0x45, 0x2a, 0x78, 0xf0, 0x12, 0x92, + 0x99, 0xa1, 0x0d, 0x6d, 0x32, 0x43, 0x66, 0x26, 0x24, 0x5f, 0xc0, 0xb3, 0x1f, 0xa6, 0x47, 0x3f, + 0x80, 0xf4, 0xd4, 0xa3, 0x47, 0x69, 0xbf, 0x88, 0x74, 0x66, 0x6c, 0x22, 0x49, 0xeb, 0x25, 0xf0, + 0xce, 0xf3, 0xbc, 0xcf, 0xef, 0x0d, 0xf3, 0x0e, 0x70, 0x79, 0x92, 0x46, 0x8c, 0x05, 0x88, 0x62, + 0x82, 0xf4, 0x17, 0xb2, 0x9c, 0x0a, 0xea, 0x78, 0x88, 0xf2, 0x94, 0xf2, 0x90, 0xe3, 0x19, 0xd4, + 0x26, 0xa8, 0xe5, 0xe2, 0xc2, 0x7b, 0x2c, 0xa6, 0x49, 0x8e, 0x43, 0x16, 0xe5, 0xa2, 0x0a, 0x94, + 0x3d, 0xd0, 0xee, 0x7e, 0xb3, 0xd0, 0x41, 0x9e, 0x5b, 0x06, 0x91, 0x14, 0xd3, 0x40, 0x54, 0x8c, + 0x70, 0xfd, 0x35, 0xca, 0x99, 0x51, 0x0a, 0xc2, 0x45, 0x92, 0x4d, 0x3a, 0x1c, 0x5e, 0x19, 0x70, + 0xc9, 0xd8, 0xbc, 0x6a, 0x6b, 0xe7, 0x3f, 0x8e, 0xc1, 0xf5, 0x37, 0x08, 0x51, 0x99, 0x09, 0xe7, + 0x1d, 0xb8, 0x11, 0x47, 0x9c, 0x84, 0x91, 0xae, 0x5d, 0xfb, 0xcc, 0x7e, 0x70, 0xfa, 0xe4, 0x1e, + 0x6c, 0xfc, 0x43, 0x09, 0xb7, 0x2c, 0x58, 0x5c, 0xc0, 0x41, 0xc4, 0x89, 0x69, 0x1c, 0x59, 0xe3, + 0xd3, 0xb8, 0x2e, 0x9d, 0x02, 0x78, 0x88, 0x66, 0x22, 0xc9, 0x24, 0x95, 0x3c, 0x34, 0x73, 0xed, + 0x52, 0xaf, 0xa9, 0xd4, 0xe7, 0x5d, 0xa9, 0xda, 0xb9, 0x4d, 0x1f, 0xee, 0xfa, 0xbf, 0xe8, 0xc3, + 0x1a, 0xe5, 0xa2, 0x3d, 0x9a, 0x93, 0x82, 0xbb, 0x98, 0xcc, 0xa3, 0x8a, 0xe0, 0x16, 0xf4, 0x48, + 0x41, 0x2f, 0x0f, 0x43, 0xdf, 0xea, 0xe6, 0x16, 0xf1, 0x36, 0xee, 0x12, 0x1c, 0x06, 0x5c, 0x46, + 0xf2, 0x84, 0xe2, 0x04, 0xb5, 0x78, 0xc7, 0x8a, 0xf7, 0xf4, 0x30, 0xef, 0x93, 0xe9, 0x6e, 0x01, + 0xef, 0xb0, 0x4e, 0xc5, 0xf9, 0x08, 0x6e, 0xa5, 0x14, 0xcb, 0x79, 0x7d, 0x45, 0x27, 0x8a, 0x73, + 0xff, 0x5f, 0x8e, 0xbe, 0xec, 0x2d, 0xe1, 0x83, 0x72, 0xd7, 0xc1, 0x37, 0xd3, 0xe6, 0xc1, 0xd5, + 0xab, 0xe5, 0xa2, 0xff, 0xec, 0xd1, 0x24, 0x11, 0x53, 0x19, 0x43, 0x44, 0x53, 0xb3, 0x72, 0x7f, + 0xd7, 0x90, 0xe3, 0x59, 0x60, 0x96, 0x8b, 0x94, 0x8c, 0xe6, 0x82, 0x60, 0x68, 0x5a, 0x07, 0x27, + 0xe0, 0x88, 0xcb, 0xf4, 0xfc, 0x9b, 0x0d, 0x7a, 0x9f, 0x15, 0xce, 0x79, 0x09, 0x7a, 0x1a, 0x6c, + 0xf6, 0xc6, 0xdf, 0x37, 0x94, 0xf6, 0x8f, 0xac, 0xb1, 0xf1, 0x5f, 0xbd, 0x5e, 0x2e, 0xfa, 0x2f, + 0xfe, 0x37, 0x86, 0xd9, 0xe0, 0xdd, 0x20, 0x3a, 0xe5, 0xbd, 0x19, 0x64, 0x30, 0xfc, 0xb9, 0xf6, + 0xed, 0xd5, 0xda, 0xb7, 0x7f, 0xaf, 0x7d, 0xfb, 0xfb, 0xc6, 0xb7, 0x56, 0x1b, 0xdf, 0xfa, 0xb5, + 0xf1, 0xad, 0xaf, 0x0f, 0x0f, 0x06, 0x37, 0x5f, 0x6e, 0xdc, 0x53, 0x6f, 0xe2, 0xf2, 0x4f, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xdc, 0xbb, 0x4f, 0xcf, 0xd0, 0x03, 0x00, 0x00, +} + +func (this *Account) GetAccount() github_com_cosmos_cosmos_sdk_x_auth_exported.Account { + if x := this.GetBaseAccount(); x != nil { + return x + } + if x := this.GetContinuousVestingAccount(); x != nil { + return x + } + if x := this.GetDelayedVestingAccount(); x != nil { + return x + } + if x := this.GetPeriodicVestingAccount(); x != nil { + return x + } + if x := this.GetModuleAccount(); x != nil { + return x + } + return nil +} + +func (this *Account) SetAccount(value github_com_cosmos_cosmos_sdk_x_auth_exported.Account) error { + if value == nil { + this.Sum = nil + return nil + } + switch vt := value.(type) { + case *types.BaseAccount: + this.Sum = &Account_BaseAccount{vt} + return nil + case *types1.ContinuousVestingAccount: + this.Sum = &Account_ContinuousVestingAccount{vt} + return nil + case *types1.DelayedVestingAccount: + this.Sum = &Account_DelayedVestingAccount{vt} + return nil + case *types1.PeriodicVestingAccount: + this.Sum = &Account_PeriodicVestingAccount{vt} + return nil + case *types2.ModuleAccount: + this.Sum = &Account_ModuleAccount{vt} + return nil + } + return fmt.Errorf("can't encode value of type %T as message Account", value) +} + +func (this *Supply) GetSupplyI() github_com_cosmos_cosmos_sdk_x_supply_exported.SupplyI { + if x := this.GetSupply(); x != nil { + return x + } + return nil +} + +func (this *Supply) SetSupplyI(value github_com_cosmos_cosmos_sdk_x_supply_exported.SupplyI) error { + if value == nil { + this.Sum = nil + return nil + } + switch vt := value.(type) { + case *types2.Supply: + this.Sum = &Supply_Supply{vt} + return nil + } + return fmt.Errorf("can't encode value of type %T as message Supply", value) +} + +func (m *Account) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Account) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Account) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Sum != nil { + { + size := m.Sum.Size() + i -= size + if _, err := m.Sum.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + return len(dAtA) - i, nil +} + +func (m *Account_BaseAccount) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Account_BaseAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.BaseAccount != nil { + { + size, err := m.BaseAccount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCodec(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} +func (m *Account_ContinuousVestingAccount) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Account_ContinuousVestingAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.ContinuousVestingAccount != nil { + { + size, err := m.ContinuousVestingAccount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCodec(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} +func (m *Account_DelayedVestingAccount) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Account_DelayedVestingAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.DelayedVestingAccount != nil { + { + size, err := m.DelayedVestingAccount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCodec(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + return len(dAtA) - i, nil +} +func (m *Account_PeriodicVestingAccount) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Account_PeriodicVestingAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.PeriodicVestingAccount != nil { + { + size, err := m.PeriodicVestingAccount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCodec(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + return len(dAtA) - i, nil +} +func (m *Account_ModuleAccount) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Account_ModuleAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.ModuleAccount != nil { + { + size, err := m.ModuleAccount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCodec(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + return len(dAtA) - i, nil +} +func (m *Supply) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Supply) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Supply) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Sum != nil { + { + size := m.Sum.Size() + i -= size + if _, err := m.Sum.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + return len(dAtA) - i, nil +} + +func (m *Supply_Supply) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Supply_Supply) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Supply != nil { + { + size, err := m.Supply.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCodec(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} +func encodeVarintCodec(dAtA []byte, offset int, v uint64) int { + offset -= sovCodec(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Account) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Sum != nil { + n += m.Sum.Size() + } + return n +} + +func (m *Account_BaseAccount) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BaseAccount != nil { + l = m.BaseAccount.Size() + n += 1 + l + sovCodec(uint64(l)) + } + return n +} +func (m *Account_ContinuousVestingAccount) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ContinuousVestingAccount != nil { + l = m.ContinuousVestingAccount.Size() + n += 1 + l + sovCodec(uint64(l)) + } + return n +} +func (m *Account_DelayedVestingAccount) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.DelayedVestingAccount != nil { + l = m.DelayedVestingAccount.Size() + n += 1 + l + sovCodec(uint64(l)) + } + return n +} +func (m *Account_PeriodicVestingAccount) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PeriodicVestingAccount != nil { + l = m.PeriodicVestingAccount.Size() + n += 1 + l + sovCodec(uint64(l)) + } + return n +} +func (m *Account_ModuleAccount) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ModuleAccount != nil { + l = m.ModuleAccount.Size() + n += 1 + l + sovCodec(uint64(l)) + } + return n +} +func (m *Supply) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Sum != nil { + n += m.Sum.Size() + } + return n +} + +func (m *Supply_Supply) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Supply != nil { + l = m.Supply.Size() + n += 1 + l + sovCodec(uint64(l)) + } + return n +} + +func sovCodec(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozCodec(x uint64) (n int) { + return sovCodec(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Account) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCodec + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Account: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Account: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BaseAccount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCodec + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCodec + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCodec + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &types.BaseAccount{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Sum = &Account_BaseAccount{v} + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContinuousVestingAccount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCodec + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCodec + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCodec + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &types1.ContinuousVestingAccount{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Sum = &Account_ContinuousVestingAccount{v} + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelayedVestingAccount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCodec + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCodec + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCodec + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &types1.DelayedVestingAccount{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Sum = &Account_DelayedVestingAccount{v} + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PeriodicVestingAccount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCodec + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCodec + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCodec + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &types1.PeriodicVestingAccount{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Sum = &Account_PeriodicVestingAccount{v} + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ModuleAccount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCodec + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCodec + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCodec + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &types2.ModuleAccount{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Sum = &Account_ModuleAccount{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCodec(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCodec + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthCodec + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Supply) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCodec + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Supply: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Supply: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Supply", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCodec + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCodec + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCodec + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &types2.Supply{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Sum = &Supply_Supply{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCodec(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCodec + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthCodec + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipCodec(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCodec + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCodec + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCodec + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthCodec + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupCodec + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthCodec + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthCodec = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowCodec = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupCodec = fmt.Errorf("proto: unexpected end of group") +) diff --git a/codec/codec.proto b/codec/codec.proto new file mode 100644 index 000000000000..811e65d514b8 --- /dev/null +++ b/codec/codec.proto @@ -0,0 +1,33 @@ +syntax = "proto3"; +package cosmos_sdk.simapp.codec.v1; + +import "third_party/proto/cosmos-proto/cosmos.proto"; +import "x/auth/types/types.proto"; +import "x/auth/vesting/types/types.proto"; +import "x/supply/types/types.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/simapp/codec"; + +// Account defines the application-level Account type. +message Account { + option (cosmos_proto.interface_type) = "*github.com/cosmos/cosmos-sdk/x/auth/exported.Account"; + + // sum defines a list of all acceptable concrete Account implementations. + oneof sum { + cosmos_sdk.x.auth.v1.BaseAccount base_account = 1; + cosmos_sdk.x.auth.vesting.v1.ContinuousVestingAccount continuous_vesting_account = 2; + cosmos_sdk.x.auth.vesting.v1.DelayedVestingAccount delayed_vesting_account = 3; + cosmos_sdk.x.auth.vesting.v1.PeriodicVestingAccount periodic_vesting_account = 4; + cosmos_sdk.x.supply.v1.ModuleAccount module_account = 5; + } +} + +// Supply defines the application-level Supply type. +message Supply { + option (cosmos_proto.interface_type) = "*github.com/cosmos/cosmos-sdk/x/supply/exported.SupplyI"; + + // sum defines a list of all acceptable concrete Supply implementations. + oneof sum { + cosmos_sdk.x.supply.v1.Supply supply = 1; + } +} diff --git a/export.go b/export.go index 39cf18586f10..23a23527921d 100644 --- a/export.go +++ b/export.go @@ -27,7 +27,7 @@ func (app *SimApp) ExportAppStateAndValidators( app.prepForZeroHeightGenesis(ctx, jailWhiteList) } - genState := app.mm.ExportGenesis(ctx) + genState := app.mm.ExportGenesis(ctx, app.cdc) appState, err = codec.MarshalJSONIndent(app.cdc, genState) if err != nil { return nil, nil, err diff --git a/genesis.go b/genesis.go index d96c6feec954..1a760e3e49a6 100644 --- a/genesis.go +++ b/genesis.go @@ -2,6 +2,8 @@ package simapp import ( "encoding/json" + + simappcodec "github.com/cosmos/cosmos-sdk/simapp/codec" ) // The genesis state of the blockchain is represented here as a map of raw json @@ -15,5 +17,7 @@ type GenesisState map[string]json.RawMessage // NewDefaultGenesisState generates the default state for the application. func NewDefaultGenesisState() GenesisState { - return ModuleBasics.DefaultGenesis() + cdc := simappcodec.MakeCodec(ModuleBasics) + + return ModuleBasics.DefaultGenesis(cdc) } diff --git a/sim_test.go b/sim_test.go index 3d41fa3b8467..e10afad8a4a1 100644 --- a/sim_test.go +++ b/sim_test.go @@ -137,7 +137,7 @@ func TestAppImportExport(t *testing.T) { ctxA := app.NewContext(true, abci.Header{Height: app.LastBlockHeight()}) ctxB := newApp.NewContext(true, abci.Header{Height: app.LastBlockHeight()}) - newApp.mm.InitGenesis(ctxB, genesisState) + newApp.mm.InitGenesis(ctxB, app.Codec(), genesisState) fmt.Printf("comparing stores...\n") diff --git a/utils_test.go b/utils_test.go index 9cadfff0da40..b6d5fa1f358a 100644 --- a/utils_test.go +++ b/utils_test.go @@ -8,12 +8,13 @@ import ( tmkv "github.com/tendermint/tendermint/libs/kv" "github.com/cosmos/cosmos-sdk/codec" + simappcodec "github.com/cosmos/cosmos-sdk/simapp/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" ) func TestGetSimulationLog(t *testing.T) { - cdc := MakeCodec() + cdc := simappcodec.MakeCodec(ModuleBasics) decoders := make(sdk.StoreDecoderRegistry) decoders[auth.StoreKey] = func(cdc *codec.Codec, kvAs, kvBs tmkv.Pair) string { return "10" }