Skip to content

Commit

Permalink
fix: register emissions grpc server (#1257)
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD authored Oct 12, 2023
1 parent 32b135a commit 0001806
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 133 deletions.
8 changes: 4 additions & 4 deletions docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27677,15 +27677,15 @@ paths:
$ref: '#/definitions/googlerpcStatus'
tags:
- Query
/zeta-chain/zetacore/emissions/get_emmisons_factors:
/zeta-chain/zetacore/emissions/get_emissions_factors:
get:
summary: Queries a list of GetEmmisonsFactors items.
operationId: Query_GetEmmisonsFactors
operationId: Query_GetEmissionsFactors
responses:
"200":
description: A successful response.
schema:
$ref: '#/definitions/emissionsQueryGetEmmisonsFactorsResponse'
$ref: '#/definitions/emissionsQueryGetEmissionsFactorsResponse'
default:
description: An unexpected error response.
schema:
Expand Down Expand Up @@ -50752,7 +50752,7 @@ definitions:
type: string
proved:
type: boolean
emissionsQueryGetEmmisonsFactorsResponse:
emissionsQueryGetEmissionsFactorsResponse:
type: object
properties:
reservesFactor:
Expand Down
8 changes: 4 additions & 4 deletions proto/emissions/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ service Query {
}

// Queries a list of GetEmmisonsFactors items.
rpc GetEmmisonsFactors(QueryGetEmmisonsFactorsRequest) returns (QueryGetEmmisonsFactorsResponse) {
option (google.api.http).get = "/zeta-chain/zetacore/emissions/get_emmisons_factors";
rpc GetEmissionsFactors(QueryGetEmissionsFactorsRequest) returns (QueryGetEmissionsFactorsResponse) {
option (google.api.http).get = "/zeta-chain/zetacore/emissions/get_emissions_factors";
}

// Queries a list of ShowAvailableEmissions items.
Expand Down Expand Up @@ -49,9 +49,9 @@ message QueryListPoolAddressesResponse {
string emission_module_address = 3;
}

message QueryGetEmmisonsFactorsRequest {}
message QueryGetEmissionsFactorsRequest {}

message QueryGetEmmisonsFactorsResponse {
message QueryGetEmissionsFactorsResponse {
string reservesFactor = 1;
string bondFactor = 2;
string durationFactor = 3;
Expand Down
4 changes: 2 additions & 2 deletions x/emissions/client/cli/query_get_emmisons_factors.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ func CmdGetEmmisonsFactors() *cobra.Command {

queryClient := types.NewQueryClient(clientCtx)

params := &types.QueryGetEmmisonsFactorsRequest{}
params := &types.QueryGetEmissionsFactorsRequest{}

res, err := queryClient.GetEmmisonsFactors(cmd.Context(), params)
res, err := queryClient.GetEmissionsFactors(cmd.Context(), params)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions x/emissions/client/tests/observer_rewards_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (s *CliTestSuite) TestObserverRewards() {
s.Require().NoError(s.network.WaitForNextBlock())

// Collect parameter values and build assertion map for the randomised ballot set created
emissionFactors := emmisonstypes.QueryGetEmmisonsFactorsResponse{}
emissionFactors := emmisonstypes.QueryGetEmissionsFactorsResponse{}
out, err = clitestutil.ExecTestCLICmd(val.ClientCtx, emmisonscli.CmdGetEmmisonsFactors(), []string{"--output", "json"})
s.Require().NoError(err)
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &emissionFactors))
Expand All @@ -53,7 +53,7 @@ func (s *CliTestSuite) TestObserverRewards() {
_, err = s.network.WaitForHeight(s.ballots[0].BallotCreationHeight + observerParams.Params.BallotMaturityBlocks)
s.Require().NoError(err)
out, err = clitestutil.ExecTestCLICmd(val.ClientCtx, emmisonscli.CmdGetEmmisonsFactors(), []string{"--output", "json"})
resFactorsNewBlocks := emmisonstypes.QueryGetEmmisonsFactorsResponse{}
resFactorsNewBlocks := emmisonstypes.QueryGetEmissionsFactorsResponse{}
s.Require().NoError(err)
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &resFactorsNewBlocks))
// Duration factor is calculated in the same block,so we need to query based from the committed state at which the distribution is done
Expand Down
4 changes: 2 additions & 2 deletions x/emissions/keeper/grpc_query_get_emmisons_factors.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"github.com/zeta-chain/zetacore/x/emissions/types"
)

func (k Keeper) GetEmmisonsFactors(goCtx context.Context, _ *types.QueryGetEmmisonsFactorsRequest) (*types.QueryGetEmmisonsFactorsResponse, error) {
func (k Keeper) GetEmissionsFactors(goCtx context.Context, _ *types.QueryGetEmissionsFactorsRequest) (*types.QueryGetEmissionsFactorsResponse, error) {

ctx := sdk.UnwrapSDKContext(goCtx)
reservesFactor, bondFactor, durationFactor := k.GetBlockRewardComponents(ctx)
return &types.QueryGetEmmisonsFactorsResponse{
return &types.QueryGetEmissionsFactorsResponse{
ReservesFactor: reservesFactor.String(),
BondFactor: bondFactor.String(),
DurationFactor: durationFactor.String(),
Expand Down
7 changes: 6 additions & 1 deletion x/emissions/module.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package emissions

import (
"context"
"encoding/json"
"fmt"

Expand Down Expand Up @@ -75,7 +76,11 @@ func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {
}

// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module.
func (AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *runtime.ServeMux) {
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx))
if err != nil {
fmt.Println("RegisterQueryHandlerClient err: %w", err)
}
}

// GetTxCmd returns the emissions module's root tx command.
Expand Down
Loading

0 comments on commit 0001806

Please sign in to comment.