From d0bc853f980043b9e296a60229da135f9692d813 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Thu, 7 Jul 2022 12:35:15 -0400 Subject: [PATCH 1/2] updates --- x/epochs/handler.go | 24 ---------------- x/epochs/module.go | 2 +- x/gamm/handler.go | 61 ----------------------------------------- x/gamm/module.go | 2 +- x/incentives/handler.go | 31 --------------------- x/incentives/module.go | 2 +- 6 files changed, 3 insertions(+), 119 deletions(-) delete mode 100644 x/epochs/handler.go delete mode 100644 x/gamm/handler.go delete mode 100644 x/incentives/handler.go diff --git a/x/epochs/handler.go b/x/epochs/handler.go deleted file mode 100644 index d0c49e4e9be..00000000000 --- a/x/epochs/handler.go +++ /dev/null @@ -1,24 +0,0 @@ -package epochs - -import ( - "fmt" - - "github.com/osmosis-labs/osmosis/v7/x/epochs/keeper" - "github.com/osmosis-labs/osmosis/v7/x/epochs/types" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" -) - -// NewHandler returns a handler for epochs module messages. -func NewHandler(k keeper.Keeper) sdk.Handler { - return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { - ctx = ctx.WithEventManager(sdk.NewEventManager()) - - switch msg := msg.(type) { - default: - errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) - return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) - } - } -} diff --git a/x/epochs/module.go b/x/epochs/module.go index b039f640211..ac1201ae189 100644 --- a/x/epochs/module.go +++ b/x/epochs/module.go @@ -109,7 +109,7 @@ func (am AppModule) Name() string { // Route returns the capability module's message routing key. func (am AppModule) Route() sdk.Route { - return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper)) + return sdk.Route{} } // QuerierRoute returns the capability module's query routing key. diff --git a/x/gamm/handler.go b/x/gamm/handler.go deleted file mode 100644 index d9385638a7a..00000000000 --- a/x/gamm/handler.go +++ /dev/null @@ -1,61 +0,0 @@ -package gamm - -import ( - "github.com/osmosis-labs/osmosis/v7/x/gamm/keeper" - "github.com/osmosis-labs/osmosis/v7/x/gamm/pool-models/balancer" - "github.com/osmosis-labs/osmosis/v7/x/gamm/types" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" -) - -// NewHandler returns a handler for "gamm" type messages. -func NewHandler(k *keeper.Keeper) sdk.Handler { - msgServer := keeper.NewMsgServerImpl(k) - msgBalancerServer := keeper.NewBalancerMsgServerImpl(k) - - return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { - ctx = ctx.WithEventManager(sdk.NewEventManager()) - - switch msg := msg.(type) { - case *types.MsgJoinPool: - res, err := msgServer.JoinPool(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgExitPool: - res, err := msgServer.ExitPool(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *balancer.MsgCreateBalancerPool: - res, err := msgBalancerServer.CreateBalancerPool(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgSwapExactAmountIn: - res, err := msgServer.SwapExactAmountIn(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgSwapExactAmountOut: - res, err := msgServer.SwapExactAmountOut(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgJoinSwapExternAmountIn: - res, err := msgServer.JoinSwapExternAmountIn(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgJoinSwapShareAmountOut: - res, err := msgServer.JoinSwapShareAmountOut(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgExitSwapExternAmountOut: - res, err := msgServer.ExitSwapExternAmountOut(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgExitSwapShareAmountIn: - res, err := msgServer.ExitSwapShareAmountIn(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg) - } - } -} diff --git a/x/gamm/module.go b/x/gamm/module.go index b9a73752e36..596e57830ce 100644 --- a/x/gamm/module.go +++ b/x/gamm/module.go @@ -113,7 +113,7 @@ func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { // Route returns the message routing key for the gamm module. func (am AppModule) Route() sdk.Route { - return sdk.NewRoute(types.RouterKey, NewHandler(&am.keeper)) + return sdk.Route{} } // QuerierRoute returns the gamm module's querier route name. diff --git a/x/incentives/handler.go b/x/incentives/handler.go deleted file mode 100644 index 06a8d7630a0..00000000000 --- a/x/incentives/handler.go +++ /dev/null @@ -1,31 +0,0 @@ -package incentives - -import ( - "fmt" - - "github.com/osmosis-labs/osmosis/v7/x/incentives/keeper" - "github.com/osmosis-labs/osmosis/v7/x/incentives/types" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" -) - -// NewHandler returns msg handler for this module. -func NewHandler(k *keeper.Keeper) sdk.Handler { - return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { - ctx = ctx.WithEventManager(sdk.NewEventManager()) - msgServer := keeper.NewMsgServerImpl(k) - - switch msg := msg.(type) { - case *types.MsgCreateGauge: - res, err := msgServer.CreateGauge(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgAddToGauge: - res, err := msgServer.AddToGauge(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - default: - errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) - return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) - } - } -} diff --git a/x/incentives/module.go b/x/incentives/module.go index e2ca494c5e8..33d03c93a53 100644 --- a/x/incentives/module.go +++ b/x/incentives/module.go @@ -129,7 +129,7 @@ func (am AppModule) Name() string { // Route returns the capability module's message routing key. func (am AppModule) Route() sdk.Route { - return sdk.NewRoute(types.RouterKey, NewHandler(&am.keeper)) + return sdk.Route{} } // QuerierRoute returns the capability module's query routing key. From 4bcf10011dde8549111231644d479b13f6e185e5 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Thu, 7 Jul 2022 13:04:04 -0400 Subject: [PATCH 2/2] updates --- x/lockup/handler.go | 34 -------------------------------- x/lockup/module.go | 2 +- x/superfluid/handler.go | 43 ----------------------------------------- x/superfluid/module.go | 2 +- 4 files changed, 2 insertions(+), 79 deletions(-) delete mode 100644 x/lockup/handler.go delete mode 100644 x/superfluid/handler.go diff --git a/x/lockup/handler.go b/x/lockup/handler.go deleted file mode 100644 index 3419731de0a..00000000000 --- a/x/lockup/handler.go +++ /dev/null @@ -1,34 +0,0 @@ -package lockup - -import ( - "fmt" - - "github.com/osmosis-labs/osmosis/v7/x/lockup/keeper" - "github.com/osmosis-labs/osmosis/v7/x/lockup/types" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" -) - -// NewHandler returns a handler for "lockup" type messages. -func NewHandler(k keeper.Keeper) sdk.Handler { - return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { - ctx = ctx.WithEventManager(sdk.NewEventManager()) - msgServer := keeper.NewMsgServerImpl(&k) - - switch msg := msg.(type) { - case *types.MsgLockTokens: - res, err := msgServer.LockTokens(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgBeginUnlocking: - res, err := msgServer.BeginUnlocking(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgBeginUnlockingAll: - res, err := msgServer.BeginUnlockingAll(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - default: - errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) - return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) - } - } -} diff --git a/x/lockup/module.go b/x/lockup/module.go index 9a67eac04d6..1157559f32e 100644 --- a/x/lockup/module.go +++ b/x/lockup/module.go @@ -126,7 +126,7 @@ func (am AppModule) Name() string { // Route returns the capability module's message routing key. func (am AppModule) Route() sdk.Route { - return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper)) + return sdk.Route{} } // QuerierRoute returns the capability module's query routing key. diff --git a/x/superfluid/handler.go b/x/superfluid/handler.go deleted file mode 100644 index 9a26e00d132..00000000000 --- a/x/superfluid/handler.go +++ /dev/null @@ -1,43 +0,0 @@ -package superfluid - -import ( - "fmt" - - "github.com/osmosis-labs/osmosis/v7/x/superfluid/keeper" - "github.com/osmosis-labs/osmosis/v7/x/superfluid/types" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" -) - -// NewHandler returns a handler for "superfluid" type messages. -func NewHandler(k *keeper.Keeper) sdk.Handler { - return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { - ctx = ctx.WithEventManager(sdk.NewEventManager()) - msgServer := keeper.NewMsgServerImpl(k) - - switch msg := msg.(type) { - case *types.MsgSuperfluidDelegate: - res, err := msgServer.SuperfluidDelegate(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgSuperfluidUndelegate: - res, err := msgServer.SuperfluidUndelegate(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgSuperfluidUnbondLock: - res, err := msgServer.SuperfluidUnbondLock(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgLockAndSuperfluidDelegate: - res, err := msgServer.LockAndSuperfluidDelegate(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgUnPoolWhitelistedPool: - res, err := msgServer.UnPoolWhitelistedPool(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - // case *types.MsgSuperfluidRedelegate: - // res, err := msgServer.SuperfluidRedelegate(sdk.WrapSDKContext(ctx), msg) - // return sdk.WrapServiceResult(ctx, res, err) - default: - errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) - return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) - } - } -} diff --git a/x/superfluid/module.go b/x/superfluid/module.go index 1002cba8859..54ae2b9373c 100644 --- a/x/superfluid/module.go +++ b/x/superfluid/module.go @@ -137,7 +137,7 @@ func (am AppModule) Name() string { // Route returns the capability module's message routing key. func (am AppModule) Route() sdk.Route { - return sdk.NewRoute(types.RouterKey, NewHandler(&am.keeper)) + return sdk.Route{} } // QuerierRoute returns the capability module's query routing key.