From 1d83c11f70b8556c4adda1d96bba361e4b53cce5 Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 21 Jul 2021 15:17:06 +0800 Subject: [PATCH 1/2] Remove legacy handlers --- x/profiles/handler.go | 81 ---------------------------------- x/profiles/module.go | 9 +--- x/staging/fees/module.go | 9 +--- x/staging/posts/handler.go | 50 --------------------- x/staging/posts/module.go | 9 +--- x/staging/subspaces/handler.go | 50 --------------------- x/staging/subspaces/module.go | 9 +--- 7 files changed, 8 insertions(+), 209 deletions(-) delete mode 100644 x/profiles/handler.go delete mode 100644 x/staging/posts/handler.go delete mode 100644 x/staging/subspaces/handler.go diff --git a/x/profiles/handler.go b/x/profiles/handler.go deleted file mode 100644 index c278e8f983..0000000000 --- a/x/profiles/handler.go +++ /dev/null @@ -1,81 +0,0 @@ -package profiles - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/gogo/protobuf/proto" - - "github.com/desmos-labs/desmos/v2/x/profiles/keeper" - "github.com/desmos-labs/desmos/v2/x/profiles/types" -) - -// NewHandler returns a handler for "profile" type messages. -func NewHandler(k keeper.Keeper) sdk.Handler { - msgServer := keeper.NewMsgServerImpl(k) - - return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { - ctx = ctx.WithEventManager(sdk.NewEventManager()) - - switch msg := msg.(type) { - case *types.MsgSaveProfile: - res, err := msgServer.SaveProfile(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgDeleteProfile: - res, err := msgServer.DeleteProfile(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgRequestDTagTransfer: - res, err := msgServer.RequestDTagTransfer(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgAcceptDTagTransferRequest: - res, err := msgServer.AcceptDTagTransferRequest(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgRefuseDTagTransferRequest: - res, err := msgServer.RefuseDTagTransferRequest(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgCancelDTagTransferRequest: - res, err := msgServer.CancelDTagTransferRequest(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgCreateRelationship: - res, err := msgServer.CreateRelationship(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgDeleteRelationship: - res, err := msgServer.DeleteRelationship(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgBlockUser: - res, err := msgServer.BlockUser(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgUnblockUser: - res, err := msgServer.UnblockUser(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgLinkChainAccount: - res, err := msgServer.LinkChainAccount(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgUnlinkChainAccount: - res, err := msgServer.UnlinkChainAccount(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgLinkApplication: - res, err := msgServer.LinkApplication(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgUnlinkApplication: - res, err := msgServer.UnlinkApplication(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, - "unrecognized %s message type: %v", types.ModuleName, proto.MessageName(msg)) - } - } -} diff --git a/x/profiles/module.go b/x/profiles/module.go index 481d912f88..bd6fe659f6 100644 --- a/x/profiles/module.go +++ b/x/profiles/module.go @@ -127,14 +127,9 @@ func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { keeper.RegisterInvariants(ir, am.keeper) } -// Route returns the message routing key for the profiles module. +// Deprecated: Route returns the message routing key for the profiles module. func (am AppModule) Route() sdk.Route { - return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper)) -} - -// NewHandler returns an sdk.Handler for the profiles module. -func (am AppModule) NewHandler() sdk.Handler { - return NewHandler(am.keeper) + return sdk.Route{} } // QuerierRoute returns the profiles module's querier route name. diff --git a/x/staging/fees/module.go b/x/staging/fees/module.go index 838e1d3195..172180a628 100644 --- a/x/staging/fees/module.go +++ b/x/staging/fees/module.go @@ -114,14 +114,9 @@ func (AppModule) Name() string { // RegisterInvariants performs a no-op. func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} -// Route returns the message routing key for the fees module. +// Deprecated: Route returns the message routing key for the fees module. func (am AppModule) Route() sdk.Route { - return sdk.NewRoute(types.RouterKey, nil) -} - -// NewHandler returns an sdk.Handler for the fees module. -func (am AppModule) NewHandler() sdk.Handler { - return nil + return sdk.Route{} } // QuerierRoute returns the fees module's querier route name. diff --git a/x/staging/posts/handler.go b/x/staging/posts/handler.go deleted file mode 100644 index 16fb0a5769..0000000000 --- a/x/staging/posts/handler.go +++ /dev/null @@ -1,50 +0,0 @@ -package posts - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/gogo/protobuf/proto" - - "github.com/desmos-labs/desmos/v2/x/staging/posts/keeper" - - "github.com/desmos-labs/desmos/v2/x/staging/posts/types" -) - -// NewHandler returns a handler for "posts" type messages. -func NewHandler(k keeper.Keeper) sdk.Handler { - msgServer := keeper.NewMsgServerImpl(k) - - return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { - ctx = ctx.WithEventManager(sdk.NewEventManager()) - - switch msg := msg.(type) { - case *types.MsgCreatePost: - res, err := msgServer.CreatePost(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgEditPost: - res, err := msgServer.EditPost(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgAddPostReaction: - res, err := msgServer.AddPostReaction(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgRemovePostReaction: - res, err := msgServer.RemovePostReaction(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgAnswerPoll: - res, err := msgServer.AnswerPoll(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgRegisterReaction: - res, err := msgServer.RegisterReaction(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, - "unrecognized %s message type: %v", types.ModuleName, proto.MessageName(msg)) - } - } -} diff --git a/x/staging/posts/module.go b/x/staging/posts/module.go index 79acd7278b..73bf00a463 100644 --- a/x/staging/posts/module.go +++ b/x/staging/posts/module.go @@ -126,14 +126,9 @@ func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { keeper.RegisterInvariants(ir, am.keeper) } -// Route returns the message routing key for the posts module. +// Deprecated: Route returns the message routing key for the posts module. func (am AppModule) Route() sdk.Route { - return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper)) -} - -// NewHandler returns an sdk.Handler for the posts module. -func (am AppModule) NewHandler() sdk.Handler { - return NewHandler(am.keeper) + return sdk.Route{} } // QuerierRoute returns the posts module's querier route name. diff --git a/x/staging/subspaces/handler.go b/x/staging/subspaces/handler.go deleted file mode 100644 index 72116c2a77..0000000000 --- a/x/staging/subspaces/handler.go +++ /dev/null @@ -1,50 +0,0 @@ -package subspaces - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/gogo/protobuf/proto" - - "github.com/desmos-labs/desmos/v2/x/staging/subspaces/keeper" - "github.com/desmos-labs/desmos/v2/x/staging/subspaces/types" -) - -// NewHandler returns a handler for subspaces type messages -func NewHandler(k keeper.Keeper) sdk.Handler { - msgServer := keeper.NewMsgServerImpl(k) - - return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { - ctx = ctx.WithEventManager(sdk.NewEventManager()) - - switch msg := msg.(type) { - case *types.MsgCreateSubspace: - res, err := msgServer.CreateSubspace(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgEditSubspace: - res, err := msgServer.EditSubspace(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgAddAdmin: - res, err := msgServer.AddAdmin(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgRemoveAdmin: - res, err := msgServer.RemoveAdmin(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgRegisterUser: - res, err := msgServer.RegisterUser(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgUnregisterUser: - res, err := msgServer.UnregisterUser(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgBanUser: - res, err := msgServer.BanUser(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgUnbanUser: - res, err := msgServer.UnbanUser(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, - "unrecognized %s message type: %v", types.ModuleName, proto.MessageName(msg)) - } - } -} diff --git a/x/staging/subspaces/module.go b/x/staging/subspaces/module.go index 7b6e11c1bd..52ca1b6b67 100644 --- a/x/staging/subspaces/module.go +++ b/x/staging/subspaces/module.go @@ -122,14 +122,9 @@ func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { keeper.RegisterInvariants(ir, am.keeper) } -// Route returns the message routing key for the subspaces module. +// Deprecated: Route returns the message routing key for the subspaces module. func (am AppModule) Route() sdk.Route { - return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper)) -} - -// NewHandler returns an sdk.Handler for the subspaces module. -func (am AppModule) NewHandler() sdk.Handler { - return NewHandler(am.keeper) + return sdk.Route{} } // QuerierRoute returns the subspaces module's querier route name. From 98d0883ae485db6f47747a0a60c0565c07e0e6f3 Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 28 Sep 2021 13:18:21 +0800 Subject: [PATCH 2/2] Add changeset --- ...d994d97e4371162713d76266959687d7e990aa54b258d308fea.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/entries/4a71b9f3e6d12d994d97e4371162713d76266959687d7e990aa54b258d308fea.yaml diff --git a/.changeset/entries/4a71b9f3e6d12d994d97e4371162713d76266959687d7e990aa54b258d308fea.yaml b/.changeset/entries/4a71b9f3e6d12d994d97e4371162713d76266959687d7e990aa54b258d308fea.yaml new file mode 100644 index 0000000000..a9b787a14f --- /dev/null +++ b/.changeset/entries/4a71b9f3e6d12d994d97e4371162713d76266959687d7e990aa54b258d308fea.yaml @@ -0,0 +1,6 @@ +type: perf +module: other +pull_request: 569 +description: Deprecated legacy handlers +backward_compatible: true +date: 2021-09-28T05:12:27.0203831Z