From 64e60c7d69c4e5c78cca840dc1323f31d6ea1cf4 Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 21 Jul 2021 15:17:06 +0800 Subject: [PATCH] Remove legacy handlers --- x/profiles/handler.go | 80 ---------------------------------- x/profiles/module.go | 9 +--- x/staging/fees/module.go | 9 +--- x/staging/posts/handler.go | 49 --------------------- x/staging/posts/module.go | 9 +--- x/staging/subspaces/handler.go | 49 --------------------- x/staging/subspaces/module.go | 9 +--- 7 files changed, 8 insertions(+), 206 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 750ac31ff9..0000000000 --- a/x/profiles/handler.go +++ /dev/null @@ -1,80 +0,0 @@ -package profiles - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - - "github.com/desmos-labs/desmos/x/profiles/keeper" - "github.com/desmos-labs/desmos/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, msg.Type()) - } - } -} diff --git a/x/profiles/module.go b/x/profiles/module.go index ddc738dd50..943bf06993 100644 --- a/x/profiles/module.go +++ b/x/profiles/module.go @@ -123,14 +123,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 4cad28005d..87a9d9ed13 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 a7c6361a13..0000000000 --- a/x/staging/posts/handler.go +++ /dev/null @@ -1,49 +0,0 @@ -package posts - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - - "github.com/desmos-labs/desmos/x/staging/posts/keeper" - - "github.com/desmos-labs/desmos/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, msg.Type()) - } - } -} diff --git a/x/staging/posts/module.go b/x/staging/posts/module.go index 96f2b6471f..435be2ab07 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 48aee40b3e..0000000000 --- a/x/staging/subspaces/handler.go +++ /dev/null @@ -1,49 +0,0 @@ -package subspaces - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - - "github.com/desmos-labs/desmos/x/staging/subspaces/keeper" - "github.com/desmos-labs/desmos/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, msg.Type()) - } - } -} diff --git a/x/staging/subspaces/module.go b/x/staging/subspaces/module.go index c3f4cba39b..1e56d18d74 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.