Refactor RegisterQueryServices -> RegisterServices (#7518)

* Refactor RegisterQueryServices -> RegisterServices

* Fix tests
This commit is contained in:
Aaron Craelius 2020-10-12 12:31:51 -04:00 committed by GitHub
parent 647ad0dd3c
commit 228728cce2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 84 additions and 71 deletions

View File

@ -359,7 +359,7 @@ func NewSimApp(
app.mm.RegisterInvariants(&app.CrisisKeeper) app.mm.RegisterInvariants(&app.CrisisKeeper)
app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino) app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino)
app.mm.RegisterQueryServices(app.GRPCQueryRouter()) app.mm.RegisterServices(module.NewConfigurator(app.GRPCQueryRouter()))
// add test gRPC service for testing gRPC queries in isolation // add test gRPC service for testing gRPC queries in isolation
testdata.RegisterTestServiceServer(app.GRPCQueryRouter(), testdata.TestServiceImpl{}) testdata.RegisterTestServiceServer(app.GRPCQueryRouter(), testdata.TestServiceImpl{})

View File

@ -10,10 +10,10 @@ import (
codec "github.com/cosmos/cosmos-sdk/codec" codec "github.com/cosmos/cosmos-sdk/codec"
types "github.com/cosmos/cosmos-sdk/codec/types" types "github.com/cosmos/cosmos-sdk/codec/types"
types0 "github.com/cosmos/cosmos-sdk/types" types0 "github.com/cosmos/cosmos-sdk/types"
grpc "github.com/gogo/protobuf/grpc" module "github.com/cosmos/cosmos-sdk/types/module"
gomock "github.com/golang/mock/gomock" gomock "github.com/golang/mock/gomock"
mux "github.com/gorilla/mux" mux "github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime" runtime "github.com/grpc-ecosystem/grpc-gateway/runtime"
cobra "github.com/spf13/cobra" cobra "github.com/spf13/cobra"
types1 "github.com/tendermint/tendermint/abci/types" types1 "github.com/tendermint/tendermint/abci/types"
reflect "reflect" reflect "reflect"
@ -264,7 +264,7 @@ func (mr *MockAppModuleGenesisMockRecorder) RegisterRESTRoutes(arg0, arg1 interf
// RegisterGRPCRoutes mocks base method // RegisterGRPCRoutes mocks base method
func (m *MockAppModuleGenesis) RegisterGRPCRoutes(arg0 client.Context, arg1 *runtime.ServeMux) { func (m *MockAppModuleGenesis) RegisterGRPCRoutes(arg0 client.Context, arg1 *runtime.ServeMux) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
m.ctrl.Call(m, "RegisterRESTRoutes", arg0, arg1) m.ctrl.Call(m, "RegisterGRPCRoutes", arg0, arg1)
} }
// RegisterGRPCRoutes indicates an expected call of RegisterGRPCRoutes // RegisterGRPCRoutes indicates an expected call of RegisterGRPCRoutes
@ -539,29 +539,29 @@ func (mr *MockAppModuleMockRecorder) QuerierRoute() *gomock.Call {
} }
// LegacyQuerierHandler mocks base method // LegacyQuerierHandler mocks base method
func (m *MockAppModule) LegacyQuerierHandler(*codec.LegacyAmino) types0.Querier { func (m *MockAppModule) LegacyQuerierHandler(arg0 *codec.LegacyAmino) types0.Querier {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LegacyQuerierHandler") ret := m.ctrl.Call(m, "LegacyQuerierHandler", arg0)
ret0, _ := ret[0].(types0.Querier) ret0, _ := ret[0].(types0.Querier)
return ret0 return ret0
} }
// LegacyQuerierHandler indicates an expected call of LegacyQuerierHandler // LegacyQuerierHandler indicates an expected call of LegacyQuerierHandler
func (mr *MockAppModuleMockRecorder) NewQuerierHandler() *gomock.Call { func (mr *MockAppModuleMockRecorder) LegacyQuerierHandler(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LegacyQuerierHandler", reflect.TypeOf((*MockAppModule)(nil).LegacyQuerierHandler)) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LegacyQuerierHandler", reflect.TypeOf((*MockAppModule)(nil).LegacyQuerierHandler), arg0)
} }
// RegisterQueryService mocks base method // RegisterServices mocks base method
func (m *MockAppModule) RegisterQueryService(arg0 grpc.Server) { func (m *MockAppModule) RegisterServices(arg0 module.Configurator) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
m.ctrl.Call(m, "RegisterQueryService", arg0) m.ctrl.Call(m, "RegisterServices", arg0)
} }
// RegisterQueryService indicates an expected call of RegisterQueryService // RegisterServices indicates an expected call of RegisterServices
func (mr *MockAppModuleMockRecorder) RegisterQueryService(arg0 interface{}) *gomock.Call { func (mr *MockAppModuleMockRecorder) RegisterServices(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterQueryService", reflect.TypeOf((*MockAppModule)(nil).RegisterQueryService), arg0) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterServices", reflect.TypeOf((*MockAppModule)(nil).RegisterServices), arg0)
} }
// BeginBlock mocks base method // BeginBlock mocks base method

View File

@ -0,0 +1,27 @@
package module
import "github.com/gogo/protobuf/grpc"
// Configurator provides the hooks to allow modules to configure and register
// their services in the RegisterServices method. It is designed to eventually
// support module object capabilities isolation as described in
// https://github.com/cosmos/cosmos-sdk/issues/7093
type Configurator interface {
QueryServer() grpc.Server
}
type configurator struct {
queryServer grpc.Server
}
// NewConfigurator returns a new Configurator instance
func NewConfigurator(queryServer grpc.Server) Configurator {
return configurator{queryServer: queryServer}
}
var _ Configurator = configurator{}
// QueryServer implements the Configurator.QueryServer method
func (c configurator) QueryServer() grpc.Server {
return c.queryServer
}

View File

@ -31,7 +31,6 @@ package module
import ( import (
"encoding/json" "encoding/json"
"github.com/gogo/protobuf/grpc"
"github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/gorilla/mux" "github.com/gorilla/mux"
@ -173,8 +172,8 @@ type AppModule interface {
// Deprecated: use RegisterQueryService // Deprecated: use RegisterQueryService
LegacyQuerierHandler(*codec.LegacyAmino) sdk.Querier LegacyQuerierHandler(*codec.LegacyAmino) sdk.Querier
// RegisterQueryService allows a module to register a gRPC query service // RegisterServices allows a module to register services
RegisterQueryService(grpc.Server) RegisterServices(Configurator)
// ABCI // ABCI
BeginBlock(sdk.Context, abci.RequestBeginBlock) BeginBlock(sdk.Context, abci.RequestBeginBlock)
@ -207,8 +206,8 @@ func (GenesisOnlyAppModule) QuerierRoute() string { return "" }
// LegacyQuerierHandler returns an empty module querier // LegacyQuerierHandler returns an empty module querier
func (gam GenesisOnlyAppModule) LegacyQuerierHandler(*codec.LegacyAmino) sdk.Querier { return nil } func (gam GenesisOnlyAppModule) LegacyQuerierHandler(*codec.LegacyAmino) sdk.Querier { return nil }
// RegisterQueryService registers all gRPC query services. // RegisterServices registers all services.
func (gam GenesisOnlyAppModule) RegisterQueryService(grpc.Server) {} func (gam GenesisOnlyAppModule) RegisterServices(Configurator) {}
// BeginBlock returns an empty module begin-block // BeginBlock returns an empty module begin-block
func (gam GenesisOnlyAppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {} func (gam GenesisOnlyAppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {}
@ -288,10 +287,10 @@ func (m *Manager) RegisterRoutes(router sdk.Router, queryRouter sdk.QueryRouter,
} }
} }
// RegisterQueryServices registers all module query services // RegisterServices registers all module services
func (m *Manager) RegisterQueryServices(grpcRouter grpc.Server) { func (m *Manager) RegisterServices(cfg Configurator) {
for _, module := range m.Modules { for _, module := range m.Modules {
module.RegisterQueryService(grpcRouter) module.RegisterServices(cfg)
} }
} }

View File

@ -162,10 +162,10 @@ func TestManager_RegisterRoutes(t *testing.T) {
mockAppModule1.EXPECT().QuerierRoute().Times(2).Return("querierRoute1") mockAppModule1.EXPECT().QuerierRoute().Times(2).Return("querierRoute1")
mockAppModule2.EXPECT().QuerierRoute().Times(1).Return("") mockAppModule2.EXPECT().QuerierRoute().Times(1).Return("")
handler3 := sdk.Querier(nil) handler3 := sdk.Querier(nil)
mockAppModule1.EXPECT().NewQuerierHandler().Times(1).Return(handler3) amino := codec.NewLegacyAmino()
mockAppModule1.EXPECT().LegacyQuerierHandler(amino).Times(1).Return(handler3)
queryRouter.EXPECT().AddRoute(gomock.Eq("querierRoute1"), gomock.Eq(handler3)).Times(1) queryRouter.EXPECT().AddRoute(gomock.Eq("querierRoute1"), gomock.Eq(handler3)).Times(1)
amino := codec.NewLegacyAmino()
mm.RegisterRoutes(router, queryRouter, amino) mm.RegisterRoutes(router, queryRouter, amino)
} }
@ -182,10 +182,11 @@ func TestManager_RegisterQueryServices(t *testing.T) {
require.Equal(t, 2, len(mm.Modules)) require.Equal(t, 2, len(mm.Modules))
queryRouter := mocks.NewMockServer(mockCtrl) queryRouter := mocks.NewMockServer(mockCtrl)
mockAppModule1.EXPECT().RegisterQueryService(queryRouter).Times(1) cfg := module.NewConfigurator(queryRouter)
mockAppModule2.EXPECT().RegisterQueryService(queryRouter).Times(1) mockAppModule1.EXPECT().RegisterServices(cfg).Times(1)
mockAppModule2.EXPECT().RegisterServices(cfg).Times(1)
mm.RegisterQueryServices(queryRouter) mm.RegisterServices(cfg)
} }
func TestManager_InitGenesis(t *testing.T) { func TestManager_InitGenesis(t *testing.T) {

View File

@ -6,7 +6,6 @@ import (
"fmt" "fmt"
"math/rand" "math/rand"
"github.com/gogo/protobuf/grpc"
"github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/gorilla/mux" "github.com/gorilla/mux"
@ -128,8 +127,8 @@ func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sd
// RegisterQueryService registers a GRPC query service to respond to the // RegisterQueryService registers a GRPC query service to respond to the
// module-specific GRPC queries. // module-specific GRPC queries.
func (am AppModule) RegisterQueryService(server grpc.Server) { func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterQueryServer(server, am.accountKeeper) types.RegisterQueryServer(cfg.QueryServer(), am.accountKeeper)
} }
// InitGenesis performs genesis initialization for the auth module. It returns // InitGenesis performs genesis initialization for the auth module. It returns

View File

@ -3,7 +3,6 @@ package vesting
import ( import (
"encoding/json" "encoding/json"
"github.com/gogo/protobuf/grpc"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -102,7 +101,7 @@ func (am AppModule) Route() sdk.Route {
func (AppModule) QuerierRoute() string { return "" } func (AppModule) QuerierRoute() string { return "" }
// RegisterQueryService performs a no-op. // RegisterQueryService performs a no-op.
func (am AppModule) RegisterQueryService(_ grpc.Server) {} func (am AppModule) RegisterServices(_ module.Configurator) {}
// LegacyQuerierHandler performs a no-op. // LegacyQuerierHandler performs a no-op.
func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier {

View File

@ -6,7 +6,6 @@ import (
"fmt" "fmt"
"math/rand" "math/rand"
"github.com/gogo/protobuf/grpc"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -97,8 +96,8 @@ type AppModule struct {
// RegisterQueryService registers a GRPC query service to respond to the // RegisterQueryService registers a GRPC query service to respond to the
// module-specific GRPC queries. // module-specific GRPC queries.
func (am AppModule) RegisterQueryService(server grpc.Server) { func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterQueryServer(server, am.keeper) types.RegisterQueryServer(cfg.QueryServer(), am.keeper)
} }
// NewAppModule creates a new AppModule object // NewAppModule creates a new AppModule object

View File

@ -5,7 +5,6 @@ import (
"fmt" "fmt"
"math/rand" "math/rand"
"github.com/gogo/protobuf/grpc"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -114,7 +113,7 @@ func (am AppModule) LegacyQuerierHandler(*codec.LegacyAmino) sdk.Querier { retur
// RegisterQueryService registers a GRPC query service to respond to the // RegisterQueryService registers a GRPC query service to respond to the
// module-specific GRPC queries. // module-specific GRPC queries.
func (am AppModule) RegisterQueryService(grpc.Server) {} func (am AppModule) RegisterServices(module.Configurator) {}
// RegisterInvariants registers the capability module's invariants. // RegisterInvariants registers the capability module's invariants.
func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {}

View File

@ -4,7 +4,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/gogo/protobuf/grpc"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -115,7 +114,7 @@ func (AppModule) LegacyQuerierHandler(*codec.LegacyAmino) sdk.Querier { return n
// RegisterQueryService registers a GRPC query service to respond to the // RegisterQueryService registers a GRPC query service to respond to the
// module-specific GRPC queries. // module-specific GRPC queries.
func (am AppModule) RegisterQueryService(grpc.Server) {} func (am AppModule) RegisterServices(module.Configurator) {}
// InitGenesis performs genesis initialization for the crisis module. It returns // InitGenesis performs genesis initialization for the crisis module. It returns
// no validator updates. // no validator updates.

View File

@ -6,7 +6,6 @@ import (
"fmt" "fmt"
"math/rand" "math/rand"
"github.com/gogo/protobuf/grpc"
"github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/gorilla/mux" "github.com/gorilla/mux"
@ -142,8 +141,8 @@ func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sd
// RegisterQueryService registers a GRPC query service to respond to the // RegisterQueryService registers a GRPC query service to respond to the
// module-specific GRPC queries. // module-specific GRPC queries.
func (am AppModule) RegisterQueryService(server grpc.Server) { func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterQueryServer(server, am.keeper) types.RegisterQueryServer(cfg.QueryServer(), am.keeper)
} }
// InitGenesis performs genesis initialization for the distribution module. It returns // InitGenesis performs genesis initialization for the distribution module. It returns

View File

@ -6,7 +6,6 @@ import (
"fmt" "fmt"
"math/rand" "math/rand"
"github.com/gogo/protobuf/grpc"
"github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/gorilla/mux" "github.com/gorilla/mux"
@ -151,8 +150,8 @@ func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sd
// RegisterQueryService registers a GRPC query service to respond to the // RegisterQueryService registers a GRPC query service to respond to the
// module-specific GRPC queries. // module-specific GRPC queries.
func (am AppModule) RegisterQueryService(server grpc.Server) { func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterQueryServer(server, am.keeper) types.RegisterQueryServer(cfg.QueryServer(), am.keeper)
} }
// RegisterInvariants registers the evidence module's invariants. // RegisterInvariants registers the evidence module's invariants.

View File

@ -8,7 +8,6 @@ import (
"fmt" "fmt"
"math/rand" "math/rand"
"github.com/gogo/protobuf/grpc"
"github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/gorilla/mux" "github.com/gorilla/mux"
@ -158,8 +157,8 @@ func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sd
// RegisterQueryService registers a GRPC query service to respond to the // RegisterQueryService registers a GRPC query service to respond to the
// module-specific GRPC queries. // module-specific GRPC queries.
func (am AppModule) RegisterQueryService(server grpc.Server) { func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterQueryServer(server, am.keeper) types.RegisterQueryServer(cfg.QueryServer(), am.keeper)
} }
// InitGenesis performs genesis initialization for the gov module. It returns // InitGenesis performs genesis initialization for the gov module. It returns

View File

@ -6,7 +6,6 @@ import (
"fmt" "fmt"
"math/rand" "math/rand"
"github.com/gogo/protobuf/grpc"
"github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/gorilla/mux" "github.com/gorilla/mux"
@ -123,8 +122,8 @@ func (am AppModule) LegacyQuerierHandler(*codec.LegacyAmino) sdk.Querier {
// RegisterQueryService registers a GRPC query service to respond to the // RegisterQueryService registers a GRPC query service to respond to the
// module-specific GRPC queries. // module-specific GRPC queries.
func (am AppModule) RegisterQueryService(server grpc.Server) { func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterQueryServer(server, am.keeper) types.RegisterQueryServer(cfg.QueryServer(), am.keeper)
} }
// InitGenesis performs genesis initialization for the ibc-transfer module. It returns // InitGenesis performs genesis initialization for the ibc-transfer module. It returns

View File

@ -6,7 +6,6 @@ import (
"fmt" "fmt"
"math/rand" "math/rand"
"github.com/gogo/protobuf/grpc"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -132,8 +131,8 @@ func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sd
} }
// RegisterQueryService registers the gRPC query service for the ibc module. // RegisterQueryService registers the gRPC query service for the ibc module.
func (am AppModule) RegisterQueryService(server grpc.Server) { func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterQueryService(server, am.keeper) types.RegisterQueryService(cfg.QueryServer(), am.keeper)
} }
// InitGenesis performs genesis initialization for the ibc module. It returns // InitGenesis performs genesis initialization for the ibc module. It returns

View File

@ -3,7 +3,8 @@ package mock
import ( import (
"encoding/json" "encoding/json"
"github.com/gogo/protobuf/grpc" "github.com/cosmos/cosmos-sdk/types/module"
"github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/gorilla/mux" "github.com/gorilla/mux"
@ -102,7 +103,7 @@ func (am AppModule) LegacyQuerierHandler(*codec.LegacyAmino) sdk.Querier {
} }
// RegisterQueryService implements the AppModule interface. // RegisterQueryService implements the AppModule interface.
func (am AppModule) RegisterQueryService(server grpc.Server) {} func (am AppModule) RegisterServices(module.Configurator) {}
// InitGenesis implements the AppModule interface. // InitGenesis implements the AppModule interface.
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONMarshaler, data json.RawMessage) []abci.ValidatorUpdate { func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONMarshaler, data json.RawMessage) []abci.ValidatorUpdate {

View File

@ -6,7 +6,6 @@ import (
"fmt" "fmt"
"math/rand" "math/rand"
"github.com/gogo/protobuf/grpc"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -126,8 +125,8 @@ func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sd
// RegisterQueryService registers a gRPC query service to respond to the // RegisterQueryService registers a gRPC query service to respond to the
// module-specific gRPC queries. // module-specific gRPC queries.
func (am AppModule) RegisterQueryService(server grpc.Server) { func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterQueryServer(server, am.keeper) types.RegisterQueryServer(cfg.QueryServer(), am.keeper)
} }
// InitGenesis performs genesis initialization for the mint module. It returns // InitGenesis performs genesis initialization for the mint module. It returns

View File

@ -5,7 +5,6 @@ import (
"encoding/json" "encoding/json"
"math/rand" "math/rand"
"github.com/gogo/protobuf/grpc"
"github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/gorilla/mux" "github.com/gorilla/mux"
@ -112,8 +111,8 @@ func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sd
// RegisterQueryService registers a gRPC query service to respond to the // RegisterQueryService registers a gRPC query service to respond to the
// module-specific gRPC queries. // module-specific gRPC queries.
func (am AppModule) RegisterQueryService(server grpc.Server) { func (am AppModule) RegisterServices(cfg module.Configurator) {
proposal.RegisterQueryServer(server, am.keeper) proposal.RegisterQueryServer(cfg.QueryServer(), am.keeper)
} }
// ProposalContents returns all the params content functions used to // ProposalContents returns all the params content functions used to

View File

@ -6,7 +6,6 @@ import (
"fmt" "fmt"
"math/rand" "math/rand"
"github.com/gogo/protobuf/grpc"
"github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/gorilla/mux" "github.com/gorilla/mux"
@ -140,8 +139,8 @@ func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sd
// RegisterQueryService registers a GRPC query service to respond to the // RegisterQueryService registers a GRPC query service to respond to the
// module-specific GRPC queries. // module-specific GRPC queries.
func (am AppModule) RegisterQueryService(server grpc.Server) { func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterQueryServer(server, am.keeper) types.RegisterQueryServer(cfg.QueryServer(), am.keeper)
} }
// InitGenesis performs genesis initialization for the slashing module. It returns // InitGenesis performs genesis initialization for the slashing module. It returns

View File

@ -6,7 +6,6 @@ import (
"fmt" "fmt"
"math/rand" "math/rand"
"github.com/gogo/protobuf/grpc"
"github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/gorilla/mux" "github.com/gorilla/mux"
@ -136,9 +135,9 @@ func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sd
// RegisterQueryService registers a GRPC query service to respond to the // RegisterQueryService registers a GRPC query service to respond to the
// module-specific GRPC queries. // module-specific GRPC queries.
func (am AppModule) RegisterQueryService(server grpc.Server) { func (am AppModule) RegisterServices(cfg module.Configurator) {
querier := keeper.Querier{Keeper: am.keeper} querier := keeper.Querier{Keeper: am.keeper}
types.RegisterQueryServer(server, querier) types.RegisterQueryServer(cfg.QueryServer(), querier)
} }
// InitGenesis performs genesis initialization for the staking module. It returns // InitGenesis performs genesis initialization for the staking module. It returns

View File

@ -4,7 +4,6 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"github.com/gogo/protobuf/grpc"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -97,8 +96,8 @@ func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sd
// RegisterQueryService registers a GRPC query service to respond to the // RegisterQueryService registers a GRPC query service to respond to the
// module-specific GRPC queries. // module-specific GRPC queries.
func (am AppModule) RegisterQueryService(server grpc.Server) { func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterQueryServer(server, am.keeper) types.RegisterQueryServer(cfg.QueryServer(), am.keeper)
} }
// InitGenesis is ignored, no sense in serializing future upgrades // InitGenesis is ignored, no sense in serializing future upgrades