Skip to content

Commit

Permalink
refactor: remove unnecessary module methods (#1460)
Browse files Browse the repository at this point in the history
* fix(spot): wire msg server to module

* chore(spot): remove handler

* test(spot): join pool cmd

* test(spot): create pool cmd

* test(spot): create pool errors

* refactor: rename testutil variables

* test(spot): create pool errors

* test(spot): create pool cmd

* test(spot): join stable pool

* test(spot): swap assets

* test(spot): swap stable assets cmd

* test(spot): exit pool cmd

* test(spot): exit stable pool cmd

* Update CHANGELOG.md

* refactor(epoch): remove unused methods

* refactor(inflation): remove unnecessary methods

* refactor(perp): clean up module

* refactor(spot): clean up module

* refactor(stablecoin): clean up module

* refactor(sudo): clean up module
  • Loading branch information
k-yang authored Jul 11, 2023
1 parent 27c7503 commit 9d4f3dc
Show file tree
Hide file tree
Showing 14 changed files with 19 additions and 159 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Improvements

* [#1463](https://github.com/NibiruChain/nibiru/pull/1463) - feat(oracle): add genesis pricefeeder delegation
* [#1466](https://github.com/NibiruChain/nibiru/pull/1466) - refactor(perp): `PositionLiquidatedEvent`
* [#1462](https://github.com/NibiruChain/nibiru/pull/1462) - fix(perp): Add pair to liquidation failed event.
* [#1424](https://github.com/NibiruChain/nibiru/pull/1424) - feat(perp): Add change type and exchanged margin to position changed events.
* [#1390](https://github.com/NibiruChain/nibiru/pull/1390) - fix(localnet.sh): Fix genesis market initialization + add force exits on failure
Expand Down
23 changes: 0 additions & 23 deletions x/epochs/handler.go

This file was deleted.

20 changes: 4 additions & 16 deletions x/epochs/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,19 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"

"github.com/NibiruChain/nibiru/x/epochs/client/cli"
"github.com/NibiruChain/nibiru/x/epochs/client/rest"
"github.com/NibiruChain/nibiru/x/epochs/keeper"
"github.com/NibiruChain/nibiru/x/epochs/simulation"
"github.com/NibiruChain/nibiru/x/epochs/types"
)

var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ module.AppModuleBasic = AppModuleBasic{}
_ module.AppModule = AppModule{}
_ module.AppModuleSimulation = AppModule{}
)

// ----------------------------------------------------------------------------
Expand All @@ -46,17 +45,11 @@ func (AppModuleBasic) Name() string {
return types.ModuleName
}

func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) {
types.RegisterCodec(cdc)
}

func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
types.RegisterCodec(cdc)
}

// RegisterInterfaces registers the module's interface types.
func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) {
types.RegisterInterfaces(reg)
}

// DefaultGenesis returns the capability module's default genesis state.
Expand All @@ -73,11 +66,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod
return genState.Validate()
}

// RegisterRESTRoutes registers the capability module's REST service handlers.
func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {
rest.RegisterRoutes(clientCtx, rtr)
}

// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module.
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) //nolint:errcheck
Expand Down Expand Up @@ -174,7 +162,7 @@ func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {

// WeightedOperations returns the all the gov module operations with their respective weights.
func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation {
return nil // TODO
return nil
}

// ConsensusVersion implements AppModule/ConsensusVersion.
Expand Down
17 changes: 0 additions & 17 deletions x/epochs/types/codec.go

This file was deleted.

12 changes: 0 additions & 12 deletions x/inflation/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"

Expand Down Expand Up @@ -51,7 +50,6 @@ func (AppModuleBasic) ConsensusVersion() uint64 {
// RegisterInterfaces registers interfaces and implementations of the incentives
// module.
func (AppModuleBasic) RegisterInterfaces(interfaceRegistry codectypes.InterfaceRegistry) {
// types.RegisterInterfaces(interfaceRegistry)
}

// DefaultGenesis returns default genesis state as raw bytes for the incentives
Expand All @@ -70,10 +68,6 @@ func (b AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncoding
return genesisState.Validate()
}

// RegisterRESTRoutes performs a no-op as the inflation module doesn't expose REST
// endpoints
func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {}

// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the inflation module.
func (b AppModuleBasic) RegisterGRPCGatewayRoutes(c client.Context, serveMux *runtime.ServeMux) {
if err := types.RegisterQueryHandlerClient(context.Background(), serveMux, types.NewQueryClient(c)); err != nil {
Expand Down Expand Up @@ -121,15 +115,9 @@ func (AppModule) Name() string {
// RegisterInvariants registers the inflation module invariants.
func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {}

// QuerierRoute returns the inflation module's querier route name.
func (am AppModule) QuerierRoute() string {
return types.RouterKey
}

// RegisterServices registers a gRPC query service to respond to the
// module-specific gRPC queries.
func (am AppModule) RegisterServices(cfg module.Configurator) {
// types.RegisterMsgServer(cfg.MsgServer(), am.keeper)
types.RegisterQueryServer(cfg.QueryServer(), am.keeper)
}

Expand Down
11 changes: 1 addition & 10 deletions x/perp/v2/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"

Expand Down Expand Up @@ -47,12 +46,8 @@ func (AppModuleBasic) RegisterInterfaces(interfaceRegistry codectypes.InterfaceR
types.RegisterInterfaces(interfaceRegistry)
}

func (AppModuleBasic) RegisterCodec(aminoCodec *codec.LegacyAmino) {
types.RegisterCodec(aminoCodec)
}

func (AppModuleBasic) RegisterLegacyAminoCodec(aminoCodec *codec.LegacyAmino) {
types.RegisterCodec(aminoCodec)
types.RegisterLegacyAminoCodec(aminoCodec)
}

// DefaultGenesis returns default genesis state as raw bytes for the erc20
Expand All @@ -72,10 +67,6 @@ func (AppModuleBasic) ValidateGenesis(
return genState.Validate()
}

// RegisterRESTRoutes registers the capability module's REST service handlers.
func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {
}

// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module.
func (AppModuleBasic) RegisterGRPCGatewayRoutes(
clientCtx client.Context, mux *runtime.ServeMux,
Expand Down
2 changes: 1 addition & 1 deletion x/perp/v2/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/msgservice"
)

func RegisterCodec(cdc *codec.LegacyAmino) {
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgAddMargin{}, "perpv2/add_margin", nil)
cdc.RegisterConcrete(&MsgRemoveMargin{}, "perpv2/remove_margin", nil)
cdc.RegisterConcrete(&MsgMarketOrder{}, "perpv2/market_order", nil)
Expand Down
11 changes: 1 addition & 10 deletions x/spot/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"

"github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"

Expand Down Expand Up @@ -45,12 +44,8 @@ func (AppModuleBasic) Name() string {
return types.ModuleName
}

func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) {
types.RegisterCodec(cdc)
}

func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
types.RegisterCodec(cdc)
types.RegisterLegacyAminoCodec(cdc)
}

// RegisterInterfaces registers the module's interface types
Expand All @@ -72,10 +67,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod
return genState.Validate()
}

// RegisterRESTRoutes registers the capability module's REST service handlers.
func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {
}

// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module.
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil {
Expand Down
9 changes: 6 additions & 3 deletions x/spot/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import (
"github.com/cosmos/cosmos-sdk/types/msgservice"
)

func RegisterCodec(cdc *codec.LegacyAmino) {
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgCreatePool{}, "spot/CreatePool", nil)
// TODO(k-yang): register MsgJoinPool
cdc.RegisterConcrete(&MsgJoinPool{}, "spot/JoinPool", nil)
cdc.RegisterConcrete(&MsgExitPool{}, "spot/ExitPool", nil)
cdc.RegisterConcrete(&MsgSwapAssets{}, "spot/SwapAssets", nil)
}

func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
Expand All @@ -18,12 +20,13 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
/* implementations */
&MsgCreatePool{},
&MsgJoinPool{},
&MsgExitPool{},
&MsgSwapAssets{},
)

msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}

var (
Amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry())
)
49 changes: 0 additions & 49 deletions x/stablecoin/handler.go

This file was deleted.

14 changes: 1 addition & 13 deletions x/stablecoin/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"

"github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"

Expand Down Expand Up @@ -48,12 +47,8 @@ func (AppModuleBasic) RegisterInterfaces(interfaceRegistry codectypes.InterfaceR
types.RegisterInterfaces(interfaceRegistry)
}

func (AppModuleBasic) RegisterCodec(aminoCodec *codec.LegacyAmino) {
types.RegisterCodec(aminoCodec)
}

func (AppModuleBasic) RegisterLegacyAminoCodec(aminoCodec *codec.LegacyAmino) {
types.RegisterCodec(aminoCodec)
types.RegisterLegacyAminoCodec(aminoCodec)
}

// DefaultGenesis returns default genesis state as raw bytes for the erc20
Expand All @@ -73,10 +68,6 @@ func (AppModuleBasic) ValidateGenesis(
return genState.Validate()
}

// RegisterRESTRoutes registers the capability module's REST service handlers.
func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {
}

// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module.
func (AppModuleBasic) RegisterGRPCGatewayRoutes(
clientCtx client.Context, mux *runtime.ServeMux,
Expand Down Expand Up @@ -131,9 +122,6 @@ func (am AppModule) Name() string {
return am.AppModuleBasic.Name()
}

// QuerierRoute returns the capability module's query routing key.
func (AppModule) QuerierRoute() string { return types.QuerierRoute }

// RegisterServices registers a GRPC query service to respond to the
// module-specific GRPC queries.
func (am AppModule) RegisterServices(cfg module.Configurator) {
Expand Down
3 changes: 1 addition & 2 deletions x/stablecoin/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/msgservice"
)

func RegisterCodec(cdc *codec.LegacyAmino) {
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgMintStable{}, "stablecoin/MintStable", nil)
cdc.RegisterConcrete(&MsgBurnStable{}, "stablecoin/BurnStable", nil)
}
Expand All @@ -22,6 +22,5 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
}

var (
Amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry())
)
2 changes: 1 addition & 1 deletion x/sudo/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (AppModuleBasic) RegisterInterfaces(interfaceRegistry codectypes.InterfaceR
}

func (AppModuleBasic) RegisterLegacyAminoCodec(aminoCodec *codec.LegacyAmino) {
types.RegisterCodec(aminoCodec)
types.RegisterLegacyAminoCodec(aminoCodec)
}

// DefaultGenesis returns default genesis state as raw bytes for the module.
Expand Down
3 changes: 1 addition & 2 deletions x/sudo/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/msgservice"
)

func RegisterCodec(cdc *codec.LegacyAmino) {
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgEditSudoers{}, "sudo/edit_sudoers", nil)
}

Expand All @@ -22,6 +22,5 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
}

var (
Amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry())
)

0 comments on commit 9d4f3dc

Please sign in to comment.