Skip to content

Commit

Permalink
Add GRPC gateway route for listing module and add hard cap setting (#…
Browse files Browse the repository at this point in the history
…2489)

Signed-off-by: Shrenuj Bansal <[email protected]>
  • Loading branch information
shrenujb authored Oct 15, 2024
1 parent 9449952 commit ca15c4d
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LCDClient } from "@osmonauts/lcd";
import { QueryListingVaultDepositParams, QueryListingVaultDepositParamsResponseSDKType } from "./query";
import { QueryMarketsHardCap, QueryMarketsHardCapResponseSDKType, QueryListingVaultDepositParams, QueryListingVaultDepositParamsResponseSDKType } from "./query";
export class LCDQueryClient {
req: LCDClient;

Expand All @@ -9,8 +9,16 @@ export class LCDQueryClient {
requestClient: LCDClient;
}) {
this.req = requestClient;
this.marketsHardCap = this.marketsHardCap.bind(this);
this.listingVaultDepositParams = this.listingVaultDepositParams.bind(this);
}
/* Queries for the hard cap number of listed markets */


async marketsHardCap(_params: QueryMarketsHardCap = {}): Promise<QueryMarketsHardCapResponseSDKType> {
const endpoint = `dydxprotocol/listing/markets_hard_cap`;
return await this.req.get<QueryMarketsHardCapResponseSDKType>(endpoint);
}
/* Queries the listing vault deposit params */


Expand Down
5 changes: 4 additions & 1 deletion proto/dydxprotocol/listing/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/listing/types";
// Query defines the gRPC querier service.
service Query {
// Queries for the hard cap number of listed markets
rpc MarketsHardCap(QueryMarketsHardCap) returns (QueryMarketsHardCapResponse);
rpc MarketsHardCap(QueryMarketsHardCap)
returns (QueryMarketsHardCapResponse) {
option (google.api.http).get = "/dydxprotocol/listing/markets_hard_cap";
}

// Queries the listing vault deposit params
rpc ListingVaultDepositParams(QueryListingVaultDepositParams)
Expand Down
5 changes: 5 additions & 0 deletions protocol/x/listing/module.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package listing

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

Expand Down Expand Up @@ -76,6 +77,10 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod

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

// GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to
Expand Down
23 changes: 12 additions & 11 deletions protocol/x/listing/types/query.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 65 additions & 0 deletions protocol/x/listing/types/query.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ca15c4d

Please sign in to comment.