diff --git a/x/swap/handler.go b/x/swap/handler.go index efe50c67..4db8d112 100644 --- a/x/swap/handler.go +++ b/x/swap/handler.go @@ -19,7 +19,7 @@ func NewHandler(k keeper.Keeper) sdk.Handler { res, err := server.MsgSwap(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) default: - return nil, errors.Wrapf(types.ErrorUnknownMsgType, "%s", msg.Type()) + return nil, errors.Wrapf(types.ErrorUnknownMsgType, "%T", msg) } } } diff --git a/x/swap/keeper/keeper.go b/x/swap/keeper/keeper.go index cefe408b..c77ab684 100644 --- a/x/swap/keeper/keeper.go +++ b/x/swap/keeper/keeper.go @@ -11,14 +11,14 @@ import ( ) type Keeper struct { - cdc codec.BinaryMarshaler + cdc codec.BinaryCodec key sdk.StoreKey params paramstypes.Subspace account expected.AccountKeeper bank expected.BankKeeper } -func NewKeeper(cdc codec.BinaryMarshaler, key sdk.StoreKey, params paramstypes.Subspace, account expected.AccountKeeper, bank expected.BankKeeper) Keeper { +func NewKeeper(cdc codec.BinaryCodec, key sdk.StoreKey, params paramstypes.Subspace, account expected.AccountKeeper, bank expected.BankKeeper) Keeper { return Keeper{ cdc: cdc, key: key, diff --git a/x/swap/keeper/query_server.go b/x/swap/keeper/query_server.go index 1696be0c..a6aafd70 100644 --- a/x/swap/keeper/query_server.go +++ b/x/swap/keeper/query_server.go @@ -55,7 +55,7 @@ func (q *queryServer) QuerySwaps(c context.Context, req *types.QuerySwapsRequest pagination, err := query.FilteredPaginate(store, req.Pagination, func(_, value []byte, accumulate bool) (bool, error) { var item types.Swap - if err := q.cdc.UnmarshalBinaryBare(value, &item); err != nil { + if err := q.cdc.Unmarshal(value, &item); err != nil { return false, err } diff --git a/x/swap/keeper/swap.go b/x/swap/keeper/swap.go index 2c8d9659..b4556f7c 100644 --- a/x/swap/keeper/swap.go +++ b/x/swap/keeper/swap.go @@ -9,7 +9,7 @@ import ( func (k *Keeper) SetSwap(ctx sdk.Context, swap types.Swap) { key := types.SwapKey(swap.GetTxHash()) - value := k.cdc.MustMarshalBinaryBare(&swap) + value := k.cdc.MustMarshal(&swap) store := k.Store(ctx) store.Set(key, value) @@ -24,7 +24,7 @@ func (k *Keeper) GetSwap(ctx sdk.Context, txHash types.EthereumHash) (swap types return swap, false } - k.cdc.MustUnmarshalBinaryBare(value, &swap) + k.cdc.MustUnmarshal(value, &swap) return swap, true } @@ -48,7 +48,7 @@ func (k *Keeper) GetSwaps(ctx sdk.Context, skip, limit int64) (items types.Swaps iter.Skip(skip) iter.Limit(limit, func(iter sdk.Iterator) { var item types.Swap - k.cdc.MustUnmarshalBinaryBare(iter.Value(), &item) + k.cdc.MustUnmarshal(iter.Value(), &item) items = append(items, item) }) diff --git a/x/swap/module.go b/x/swap/module.go index ef93ab34..8bef3d13 100644 --- a/x/swap/module.go +++ b/x/swap/module.go @@ -43,11 +43,11 @@ func (a AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry types.RegisterInterfaces(registry) } -func (a AppModuleBasic) DefaultGenesis(cdc codec.JSONMarshaler) json.RawMessage { +func (a AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { return cdc.MustMarshalJSON(types.DefaultGenesisState()) } -func (a AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, _ client.TxEncodingConfig, message json.RawMessage) error { +func (a AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, message json.RawMessage) error { var state types.GenesisState if err := cdc.UnmarshalJSON(message, &state); err != nil { return err @@ -74,18 +74,18 @@ func (a AppModuleBasic) GetQueryCmd() *cobra.Command { type AppModule struct { AppModuleBasic - cdc codec.Marshaler + cdc codec.Codec k keeper.Keeper } -func NewAppModule(cdc codec.Marshaler, k keeper.Keeper) AppModule { +func NewAppModule(cdc codec.Codec, k keeper.Keeper) AppModule { return AppModule{ cdc: cdc, k: k, } } -func (a AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONMarshaler, message json.RawMessage) []abcitypes.ValidatorUpdate { +func (a AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, message json.RawMessage) []abcitypes.ValidatorUpdate { var state types.GenesisState cdc.MustUnmarshalJSON(message, &state) InitGenesis(ctx, a.k, &state) @@ -93,7 +93,7 @@ func (a AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONMarshaler, message return nil } -func (a AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONMarshaler) json.RawMessage { +func (a AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { return cdc.MustMarshalJSON(ExportGenesis(ctx, a.k)) } @@ -115,6 +115,8 @@ func (a AppModule) RegisterServices(configurator module.Configurator) { types.RegisterQueryServiceServer(configurator.QueryServer(), keeper.NewQueryServiceServer(a.k)) } +func (a AppModule) ConsensusVersion() uint64 { return 1 } + func (a AppModule) BeginBlock(_ sdk.Context, _ abcitypes.RequestBeginBlock) {} func (a AppModule) EndBlock(_ sdk.Context, _ abcitypes.RequestEndBlock) []abcitypes.ValidatorUpdate { diff --git a/x/swap/simulation/decoder.go b/x/swap/simulation/decoder.go index 701a18dd..b39f580d 100644 --- a/x/swap/simulation/decoder.go +++ b/x/swap/simulation/decoder.go @@ -10,12 +10,12 @@ import ( "github.com/sentinel-official/hub/x/swap/types" ) -func NewStoreDecoder(cdc codec.Marshaler) func(kvA, kvB kv.Pair) string { +func NewStoreDecoder(cdc codec.Codec) func(kvA, kvB kv.Pair) string { return func(kvA, kvB kv.Pair) string { if bytes.Equal(kvA.Key[:1], types.SwapKeyPrefix) { var swapA, swapB types.MsgSwapRequest - cdc.MustUnmarshalBinaryBare(kvA.Value, &swapA) - cdc.MustUnmarshalBinaryBare(kvB.Value, &swapB) + cdc.MustUnmarshal(kvA.Value, &swapA) + cdc.MustUnmarshal(kvB.Value, &swapB) return fmt.Sprintf("%v\n%v", swapA, swapB) }