From a6a17f8e567c876f9ac8a1b6a8d61778875f335b Mon Sep 17 00:00:00 2001 From: Shrenuj Bansal Date: Tue, 15 Oct 2024 13:43:36 -0400 Subject: [PATCH 1/3] Add GRPC query handler for listing module Signed-off-by: Shrenuj Bansal --- protocol/x/listing/module.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/protocol/x/listing/module.go b/protocol/x/listing/module.go index 819e921c13..99ee5943ed 100644 --- a/protocol/x/listing/module.go +++ b/protocol/x/listing/module.go @@ -1,6 +1,7 @@ package listing import ( + "context" "encoding/json" "fmt" @@ -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 From b1b66ec67fa9b2f40d1d2ec9d30b40a20cdb8218 Mon Sep 17 00:00:00 2001 From: Shrenuj Bansal Date: Tue, 15 Oct 2024 14:04:36 -0400 Subject: [PATCH 2/3] add grpc endpoint for markets hard cap setting Signed-off-by: Shrenuj Bansal --- .../codegen/dydxprotocol/listing/query.lcd.ts | 10 ++- proto/dydxprotocol/listing/query.proto | 4 +- protocol/x/listing/types/query.pb.go | 23 +++---- protocol/x/listing/types/query.pb.gw.go | 65 +++++++++++++++++++ 4 files changed, 89 insertions(+), 13 deletions(-) diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/listing/query.lcd.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/listing/query.lcd.ts index a12d33a4a4..70ab686dfb 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/listing/query.lcd.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/listing/query.lcd.ts @@ -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; @@ -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 { + const endpoint = `dydxprotocol/listing/markets_hard_cap`; + return await this.req.get(endpoint); + } /* Queries the listing vault deposit params */ diff --git a/proto/dydxprotocol/listing/query.proto b/proto/dydxprotocol/listing/query.proto index b200a7637d..4639d60710 100644 --- a/proto/dydxprotocol/listing/query.proto +++ b/proto/dydxprotocol/listing/query.proto @@ -10,7 +10,9 @@ 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) diff --git a/protocol/x/listing/types/query.pb.go b/protocol/x/listing/types/query.pb.go index 04b32dc0c8..353a7a49ea 100644 --- a/protocol/x/listing/types/query.pb.go +++ b/protocol/x/listing/types/query.pb.go @@ -205,7 +205,7 @@ func init() { func init() { proto.RegisterFile("dydxprotocol/listing/query.proto", fileDescriptor_6c3602ac8eedf7cc) } var fileDescriptor_6c3602ac8eedf7cc = []byte{ - // 365 bytes of a gzipped FileDescriptorProto + // 382 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0xa9, 0x4c, 0xa9, 0x28, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0xce, 0xcf, 0xd1, 0xcf, 0xc9, 0x2c, 0x2e, 0xc9, 0xcc, 0x4b, 0xd7, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x03, 0x0b, 0x0b, 0x89, 0x20, 0xab, 0xd0, 0x83, 0xaa, @@ -219,16 +219,17 @@ var fileDescriptor_6c3602ac8eedf7cc = []byte{ 0xe9, 0x03, 0xb1, 0x2d, 0x2c, 0xb1, 0x34, 0xa7, 0xc4, 0x25, 0xb5, 0x20, 0xbf, 0x38, 0xb3, 0x24, 0x00, 0x6c, 0xb1, 0x52, 0x39, 0x97, 0x1a, 0x7e, 0x15, 0x70, 0x6b, 0x7c, 0xb9, 0xd8, 0x20, 0x8e, 0x05, 0x5b, 0xc2, 0x6d, 0xa4, 0xaf, 0x87, 0x2d, 0x68, 0xf4, 0x70, 0x1a, 0xe4, 0xc4, 0x72, 0xe2, - 0x9e, 0x3c, 0x43, 0x10, 0xd4, 0x10, 0xa3, 0xbd, 0x4c, 0x5c, 0xac, 0x60, 0x9b, 0x85, 0xf2, 0xb8, - 0xf8, 0x50, 0x7d, 0x26, 0xa4, 0x89, 0xdd, 0x68, 0x2c, 0x81, 0x20, 0x65, 0x48, 0xb4, 0x52, 0xb8, - 0x47, 0x0e, 0x33, 0x72, 0x49, 0xe2, 0x74, 0xa5, 0x90, 0x09, 0x1e, 0x03, 0x71, 0xea, 0x92, 0xb2, - 0x21, 0x47, 0x17, 0xcc, 0x45, 0x4a, 0x46, 0x4d, 0x97, 0x9f, 0x4c, 0x66, 0xd2, 0x11, 0xd2, 0xd2, - 0xc7, 0x9a, 0x46, 0xca, 0x40, 0x3a, 0xe3, 0x53, 0x20, 0x5a, 0xe3, 0x21, 0xe1, 0xe7, 0x14, 0x7c, - 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, - 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x96, 0xe9, 0x99, 0x25, 0x19, 0xa5, - 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xa8, 0xe6, 0x95, 0x99, 0xe8, 0x26, 0x67, 0x24, 0x66, 0xe6, 0xe9, - 0xc3, 0x45, 0x2a, 0xe0, 0x76, 0x94, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x65, 0x8c, 0x01, - 0x01, 0x00, 0x00, 0xff, 0xff, 0x83, 0xa0, 0xd5, 0x6d, 0x18, 0x03, 0x00, 0x00, + 0x9e, 0x3c, 0x43, 0x10, 0xd4, 0x10, 0xa3, 0x77, 0x4c, 0x5c, 0xac, 0x60, 0x9b, 0x85, 0xe6, 0x31, + 0x72, 0xf1, 0xa1, 0x7a, 0x4d, 0x48, 0x13, 0xbb, 0xd9, 0x58, 0x42, 0x41, 0xca, 0x90, 0x68, 0xa5, + 0x30, 0x9f, 0x28, 0xe9, 0x35, 0x5d, 0x7e, 0x32, 0x99, 0x49, 0x43, 0x48, 0x4d, 0x1f, 0x6b, 0x94, + 0xe4, 0x42, 0x74, 0xc5, 0xc3, 0x02, 0x55, 0xe8, 0x30, 0x23, 0x97, 0x24, 0x4e, 0x6f, 0x09, 0x99, + 0xe0, 0x71, 0x00, 0x4e, 0x5d, 0x52, 0x36, 0xe4, 0xe8, 0x82, 0xfb, 0xc0, 0x08, 0xec, 0x03, 0x1d, + 0x21, 0x2d, 0xec, 0x3e, 0x28, 0x03, 0xe9, 0x8c, 0x4f, 0x81, 0x68, 0x8d, 0x87, 0x04, 0xb8, 0x53, + 0xf0, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, + 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x59, 0xa6, 0x67, 0x96, 0x64, + 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xa2, 0x9a, 0x57, 0x66, 0xa2, 0x9b, 0x9c, 0x91, 0x98, 0x99, + 0xa7, 0x0f, 0x17, 0xa9, 0x80, 0xdb, 0x51, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x96, 0x31, + 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x5e, 0x73, 0xf2, 0x36, 0x49, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/protocol/x/listing/types/query.pb.gw.go b/protocol/x/listing/types/query.pb.gw.go index e04eaf7961..092dc87e68 100644 --- a/protocol/x/listing/types/query.pb.gw.go +++ b/protocol/x/listing/types/query.pb.gw.go @@ -33,6 +33,24 @@ var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage var _ = metadata.Join +func request_Query_MarketsHardCap_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryMarketsHardCap + var metadata runtime.ServerMetadata + + msg, err := client.MarketsHardCap(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_MarketsHardCap_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryMarketsHardCap + var metadata runtime.ServerMetadata + + msg, err := server.MarketsHardCap(ctx, &protoReq) + return msg, metadata, err + +} + func request_Query_ListingVaultDepositParams_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryListingVaultDepositParams var metadata runtime.ServerMetadata @@ -57,6 +75,29 @@ func local_request_Query_ListingVaultDepositParams_0(ctx context.Context, marsha // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + mux.Handle("GET", pattern_Query_MarketsHardCap_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_MarketsHardCap_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_MarketsHardCap_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_ListingVaultDepositParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -121,6 +162,26 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + mux.Handle("GET", pattern_Query_MarketsHardCap_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_MarketsHardCap_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_MarketsHardCap_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_ListingVaultDepositParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -145,9 +206,13 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( + pattern_Query_MarketsHardCap_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"dydxprotocol", "listing", "markets_hard_cap"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_ListingVaultDepositParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"dydxprotocol", "listing", "vault_deposit_params"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( + forward_Query_MarketsHardCap_0 = runtime.ForwardResponseMessage + forward_Query_ListingVaultDepositParams_0 = runtime.ForwardResponseMessage ) From 5a652687732897ef57ae7ba404976de3a844eeb9 Mon Sep 17 00:00:00 2001 From: Shrenuj Bansal Date: Tue, 15 Oct 2024 14:16:48 -0400 Subject: [PATCH 3/3] proto-format Signed-off-by: Shrenuj Bansal --- proto/dydxprotocol/listing/query.proto | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/proto/dydxprotocol/listing/query.proto b/proto/dydxprotocol/listing/query.proto index 4639d60710..cc3616cabd 100644 --- a/proto/dydxprotocol/listing/query.proto +++ b/proto/dydxprotocol/listing/query.proto @@ -10,7 +10,8 @@ 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"; }