From ed1f6f09bc8fc924900ec18451441900fdce17b0 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Tue, 26 Oct 2021 15:29:24 +0530 Subject: [PATCH 1/3] check for error on all modules RegisterGRPCGatewayRoutes --- x/authz/module/module.go | 4 +++- x/bank/module.go | 4 +++- x/distribution/module.go | 5 +++-- x/evidence/module.go | 6 +++--- x/feegrant/module/module.go | 5 +++-- x/gov/module.go | 4 +++- x/mint/module.go | 5 +++-- x/params/module.go | 5 +++-- x/slashing/module.go | 6 +++--- x/staking/module.go | 5 +++-- x/upgrade/module.go | 4 +++- 11 files changed, 33 insertions(+), 20 deletions(-) diff --git a/x/authz/module/module.go b/x/authz/module/module.go index b1afdc06e12f..5e779244aa48 100644 --- a/x/authz/module/module.go +++ b/x/authz/module/module.go @@ -76,7 +76,9 @@ func (AppModuleBasic) RegisterRESTRoutes(_ sdkclient.Context, _ *mux.Router) {} // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the authz module. func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, mux *runtime.ServeMux) { - authz.RegisterQueryHandlerClient(context.Background(), mux, authz.NewQueryClient(clientCtx)) + if err := authz.RegisterQueryHandlerClient(context.Background(), mux, authz.NewQueryClient(clientCtx)); err != nil { + panic(err) + } } // GetQueryCmd returns the cli query commands for the authz module diff --git a/x/bank/module.go b/x/bank/module.go index 62038da8b7b8..169f5b26ac4b 100644 --- a/x/bank/module.go +++ b/x/bank/module.go @@ -68,7 +68,9 @@ func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the bank module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } } // GetTxCmd returns the root tx command for the bank module. diff --git a/x/distribution/module.go b/x/distribution/module.go index 09232331e333..13cf674e3be0 100644 --- a/x/distribution/module.go +++ b/x/distribution/module.go @@ -8,7 +8,6 @@ import ( "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -69,7 +68,9 @@ func (AppModuleBasic) RegisterRESTRoutes(_ sdkclient.Context, _ *mux.Router) {} // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the distribution module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, mux *runtime.ServeMux) { - types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } } // GetTxCmd returns the root tx command for the distribution module. diff --git a/x/evidence/module.go b/x/evidence/module.go index cb6a358c164a..2d65ef8ead8a 100644 --- a/x/evidence/module.go +++ b/x/evidence/module.go @@ -8,9 +8,7 @@ import ( "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" - abci "github.com/tendermint/tendermint/abci/types" "github.com/cosmos/cosmos-sdk/client" @@ -80,7 +78,9 @@ func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the evidence module. func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } } // GetTxCmd returns the evidence module's root tx command. diff --git a/x/feegrant/module/module.go b/x/feegrant/module/module.go index df6089b40fba..44107bc733da 100644 --- a/x/feegrant/module/module.go +++ b/x/feegrant/module/module.go @@ -8,7 +8,6 @@ import ( "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" - abci "github.com/tendermint/tendermint/abci/types" sdkclient "github.com/cosmos/cosmos-sdk/client" @@ -87,7 +86,9 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx sdkclient.Context, rtr *mux.R // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the feegrant module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, mux *runtime.ServeMux) { - feegrant.RegisterQueryHandlerClient(context.Background(), mux, feegrant.NewQueryClient(clientCtx)) + if err := feegrant.RegisterQueryHandlerClient(context.Background(), mux, feegrant.NewQueryClient(clientCtx)); err != nil { + panic(err) + } } // GetTxCmd returns the root tx command for the feegrant module. diff --git a/x/gov/module.go b/x/gov/module.go index 659e5559275c..311ef7ffa0df 100644 --- a/x/gov/module.go +++ b/x/gov/module.go @@ -78,7 +78,9 @@ func (a AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Ro // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the gov module. func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } } // GetTxCmd returns the root tx command for the gov module. diff --git a/x/mint/module.go b/x/mint/module.go index e923790dc0fb..27fb7beba05c 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -70,8 +70,9 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the mint module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) - + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } } // GetTxCmd returns no root tx command for the mint module. diff --git a/x/params/module.go b/x/params/module.go index e27eaf44a2ef..f17ab2199d44 100644 --- a/x/params/module.go +++ b/x/params/module.go @@ -7,7 +7,6 @@ import ( "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -58,7 +57,9 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the params module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - proposal.RegisterQueryHandlerClient(context.Background(), mux, proposal.NewQueryClient(clientCtx)) + if err := proposal.RegisterQueryHandlerClient(context.Background(), mux, proposal.NewQueryClient(clientCtx)); err != nil { + panic(err) + } } // GetTxCmd returns no root tx command for the params module. diff --git a/x/slashing/module.go b/x/slashing/module.go index 68c3c2919cdd..cf51b57066ad 100644 --- a/x/slashing/module.go +++ b/x/slashing/module.go @@ -8,9 +8,7 @@ import ( "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" - abci "github.com/tendermint/tendermint/abci/types" "github.com/cosmos/cosmos-sdk/client" @@ -77,7 +75,9 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the slashig module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } } // GetTxCmd returns the root tx command for the slashing module. diff --git a/x/staking/module.go b/x/staking/module.go index 6dfd0c67f8a9..ffe1e69fdd70 100644 --- a/x/staking/module.go +++ b/x/staking/module.go @@ -8,7 +8,6 @@ import ( "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -79,7 +78,9 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the staking module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } } // GetTxCmd returns the root tx command for the staking module. diff --git a/x/upgrade/module.go b/x/upgrade/module.go index 00e966912d13..ed4b6e0ed9f3 100644 --- a/x/upgrade/module.go +++ b/x/upgrade/module.go @@ -48,7 +48,9 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the upgrade module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } } // GetQueryCmd returns the cli query commands for this module From 00c13258da63508acee1afc18c399c358b45abc1 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Thu, 28 Oct 2021 15:13:26 +0530 Subject: [PATCH 2/3] add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23d99e27e275..219893f67ea9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -119,6 +119,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements +* [\#10439](https://github.com/cosmos/cosmos-sdk/pull/10439) Check error for `RegisterQueryHandlerClient` in all modules `RegisterGRPCGatewayRoutes`. * [\#10327](https://github.com/cosmos/cosmos-sdk/pull/10327) Add null guard for possible nil `Amount` in tx fee `Coins` * [\#9780](https://github.com/cosmos/cosmos-sdk/pull/9780) Remove gogoproto `moretags` YAML annotations and add `sigs.k8s.io/yaml` for YAML marshalling. * (x/bank) [\#10134](https://github.com/cosmos/cosmos-sdk/pull/10134) Add `HasDenomMetadata` function to bank `Keeper` to check if a client coin denom metadata exists in state. From 9b5422703e2e6c2504acf335581913a7c64562d7 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Thu, 28 Oct 2021 15:30:27 +0530 Subject: [PATCH 3/3] fix something --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70185a907e59..787ddee263c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -115,7 +115,6 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements * [\#10439](https://github.com/cosmos/cosmos-sdk/pull/10439) Check error for `RegisterQueryHandlerClient` in all modules `RegisterGRPCGatewayRoutes`. -* [\#10327](https://github.com/cosmos/cosmos-sdk/pull/10327) Add null guard for possible nil `Amount` in tx fee `Coins` * [\#9780](https://github.com/cosmos/cosmos-sdk/pull/9780) Remove gogoproto `moretags` YAML annotations and add `sigs.k8s.io/yaml` for YAML marshalling. * (x/bank) [\#10134](https://github.com/cosmos/cosmos-sdk/pull/10134) Add `HasDenomMetadata` function to bank `Keeper` to check if a client coin denom metadata exists in state. * (types) [\#10076](https://github.com/cosmos/cosmos-sdk/pull/10076) Significantly speedup and lower allocations for `Coins.String()`.