Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove unnecessary module methods #1460

Merged
merged 24 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b6f2579
fix(spot): wire msg server to module
k-yang Jun 28, 2023
eeb06ce
chore(spot): remove handler
k-yang Jun 28, 2023
3666148
test(spot): join pool cmd
k-yang Jun 28, 2023
cae2bba
test(spot): create pool cmd
k-yang Jun 28, 2023
413f092
test(spot): create pool errors
k-yang Jun 28, 2023
413e39e
refactor: rename testutil variables
k-yang Jun 28, 2023
ff8399a
test(spot): create pool errors
k-yang Jun 28, 2023
89f0479
test(spot): create pool cmd
k-yang Jun 28, 2023
e4f03da
test(spot): join stable pool
k-yang Jun 28, 2023
1a62b7c
test(spot): swap assets
k-yang Jun 28, 2023
7681fb8
test(spot): swap stable assets cmd
k-yang Jun 28, 2023
9288a75
test(spot): exit pool cmd
k-yang Jun 28, 2023
703e1c0
test(spot): exit stable pool cmd
k-yang Jun 28, 2023
14fdd42
Update CHANGELOG.md
k-yang Jun 28, 2023
9699d72
refactor(epoch): remove unused methods
k-yang Jun 28, 2023
eb97d97
refactor(inflation): remove unnecessary methods
k-yang Jun 28, 2023
235bdef
refactor(perp): clean up module
k-yang Jun 28, 2023
bdd2759
refactor(spot): clean up module
k-yang Jun 28, 2023
3a77438
refactor(stablecoin): clean up module
k-yang Jun 28, 2023
a55bc24
refactor(sudo): clean up module
k-yang Jun 28, 2023
0dce250
Merge branch 'master' into refactor/module/remove-unnecessary-methods
k-yang Jul 4, 2023
67112b7
Merge branch 'master' into refactor/module/remove-unnecessary-methods
k-yang Jul 4, 2023
fdb0bf1
Merge branch 'master' into refactor/module/remove-unnecessary-methods
k-yang Jul 5, 2023
6023539
Merge branch 'master' into refactor/module/remove-unnecessary-methods
k-yang Jul 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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())
)
Loading