diff --git a/CHANGELOG.md b/CHANGELOG.md index fef0a425c11..1e7b0bf0c83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Features * [#6416](https://github.com/osmosis-labs/osmosis/pull/6416) feat[CL]: add num initialized ticks query +* [#6488](https://github.com/osmosis-labs/osmosis/pull/6488) v2 SpotPrice CLI and GRPC query with 36 decimals in poolmanager * [#6535](https://github.com/osmosis-labs/osmosis/pull/6535) makefile: add target that tidies all submodules at once ### API Breaks diff --git a/cmd/querygen/main.go b/cmd/querygen/main.go index ad10942a965..584df936cad 100644 --- a/cmd/querygen/main.go +++ b/cmd/querygen/main.go @@ -12,6 +12,8 @@ import ( "github.com/osmosis-labs/osmosis/v19/cmd/querygen/templates" ) +const V2 = "v2" + var grpcTemplate template.Template func main() { @@ -31,7 +33,11 @@ func main() { } func parseTemplates() error { - grpcTemplatePtr, err := template.ParseFiles("cmd/querygen/templates/grpc_template.tmpl") + // Create a function to upper case the version suffix if it exists. + funcMap := template.FuncMap{ + "ToUpper": strings.ToUpper, + } + grpcTemplatePtr, err := template.New("grpc_template.tmpl").Funcs(funcMap).ParseFiles("cmd/querygen/templates/grpc_template.tmpl") if err != nil { return err } @@ -74,16 +80,23 @@ func codegenQueryYml(filepath string) error { func codegenGrpcPackage(queryYml templates.QueryYml) error { grpcTemplateData := templates.GrpcTemplateFromQueryYml(queryYml) + // If proto path contains v2 then add folder and template + // suffix to properly package the files. + grpcTemplateData.VersionSuffix = "" + if strings.Contains(grpcTemplateData.ProtoPath, V2) { + grpcTemplateData.VersionSuffix = V2 + } + // create directory fsClientPath := templates.ParseFilePathFromImportPath(grpcTemplateData.ClientPath) - if err := os.MkdirAll(fsClientPath+"/grpc", os.ModePerm); err != nil { + if err := os.MkdirAll(fsClientPath+"/grpc"+grpcTemplateData.VersionSuffix, os.ModePerm); err != nil { // ignore directory already exists error if !errors.Is(err, os.ErrExist) { return err } } // generate file - f, err := os.Create(fsClientPath + "/grpc/grpc_query.go") + f, err := os.Create(fsClientPath + "/grpc" + grpcTemplateData.VersionSuffix + "/grpc_query.go") if err != nil { return err } diff --git a/cmd/querygen/templates/grpcTemplate.go b/cmd/querygen/templates/grpcTemplate.go index a0c129f7c0a..47f313f251a 100644 --- a/cmd/querygen/templates/grpcTemplate.go +++ b/cmd/querygen/templates/grpcTemplate.go @@ -3,9 +3,10 @@ package templates import "sort" type GrpcTemplate struct { - ProtoPath string - ClientPath string - Queries []GrpcQuery + ProtoPath string + ClientPath string + Queries []GrpcQuery + VersionSuffix string } type GrpcQuery struct { diff --git a/cmd/querygen/templates/grpc_template.tmpl b/cmd/querygen/templates/grpc_template.tmpl index 0b63645e478..d70e1f726eb 100644 --- a/cmd/querygen/templates/grpc_template.tmpl +++ b/cmd/querygen/templates/grpc_template.tmpl @@ -1,4 +1,5 @@ -package grpc +{{ $version := .VersionSuffix }} +package grpc{{$version}} // THIS FILE IS GENERATED CODE, DO NOT EDIT // SOURCE AT `{{.ProtoPath}}` @@ -11,25 +12,25 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "{{.ClientPath}}" - "{{.ClientPath}}/queryproto" + "{{.ClientPath}}/queryproto{{$version}}" ) type Querier struct { - Q client.Querier + Q client.Querier{{ $version | ToUpper }} } -var _ queryproto.QueryServer = Querier{} +var _ queryproto{{$version}}.QueryServer = Querier{} {{range .Queries -}} -func (q Querier) {{.QueryName}}(grpcCtx context.Context, - req *queryproto.{{.QueryName}}Request, -) ({{ if .Response }}{{.Response}}{{else}}*queryproto.{{.QueryName}}Response{{end}}, error) { +func (q Querier) {{.QueryName}}{{ $version | ToUpper }}(grpcCtx context.Context, + req *queryproto{{$version}}.{{.QueryName}}Request, +) ({{ if .Response }}{{.Response}}{{else}}*queryproto{{$version}}.{{.QueryName}}Response{{end}}, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } ctx := sdk.UnwrapSDKContext(grpcCtx) - return q.Q.{{.QueryName}}(ctx, *req) + return q.Q.{{.QueryName}}{{ $version | ToUpper }}(ctx, *req) } {{end -}} diff --git a/proto/osmosis/poolmanager/v2/query.proto b/proto/osmosis/poolmanager/v2/query.proto new file mode 100644 index 00000000000..aeb3f9fd0e4 --- /dev/null +++ b/proto/osmosis/poolmanager/v2/query.proto @@ -0,0 +1,44 @@ +syntax = "proto3"; +package osmosis.poolmanager.v2; + +import "gogoproto/gogo.proto"; + +import "google/api/annotations.proto"; +import "google/protobuf/any.proto"; +import "cosmos_proto/cosmos.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/osmosis-labs/osmosis/v19/x/poolmanager/client/queryprotov2"; + +service Query { + // SpotPriceV2 defines a gRPC query handler that returns the spot price given + // a base denomination and a quote denomination. + // The returned spot price has 36 decimal places. However, some of + // modules perform sig fig rounding so most of the rightmost decimals can be + // zeroes. + rpc SpotPriceV2(SpotPriceRequest) returns (SpotPriceResponse) { + option (google.api.http).get = + "/osmosis/poolmanager/v2/pools/{pool_id}/prices"; + } +} + +// SpotPriceRequest defines the gRPC request structure for a SpotPrice +// query. +message SpotPriceRequest { + uint64 pool_id = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ]; + string base_asset_denom = 2 + [ (gogoproto.moretags) = "yaml:\"base_asset_denom\"" ]; + string quote_asset_denom = 3 + [ (gogoproto.moretags) = "yaml:\"quote_asset_denom\"" ]; +} + +// SpotPriceResponse defines the gRPC response structure for a SpotPrice +// query. +message SpotPriceResponse { + // String of the BigDec. Ex) 10.203uatom + string spot_price = 1 [ + (gogoproto.customtype) = "github.com/osmosis-labs/osmosis/osmomath.BigDec", + (gogoproto.moretags) = "yaml:\"spot_price\"", + (gogoproto.nullable) = false + ]; +} diff --git a/proto/osmosis/poolmanager/v2/query.yml b/proto/osmosis/poolmanager/v2/query.yml new file mode 100644 index 00000000000..ad583478281 --- /dev/null +++ b/proto/osmosis/poolmanager/v2/query.yml @@ -0,0 +1,10 @@ +keeper: + path: "github.com/osmosis-labs/osmosis/v19/x/poolmanager" + struct: "Keeper" +client_path: "github.com/osmosis-labs/osmosis/v19/x/poolmanager/client" +queries: + SpotPrice: + proto_wrapper: + query_func: "k.RouteCalculateSpotPrice" + cli: + cmd: "SpotPrice" diff --git a/x/concentrated-liquidity/client/grpc/grpc_query.go b/x/concentrated-liquidity/client/grpc/grpc_query.go index 0b3fd0fc4b5..ee3c0e66361 100644 --- a/x/concentrated-liquidity/client/grpc/grpc_query.go +++ b/x/concentrated-liquidity/client/grpc/grpc_query.go @@ -1,4 +1,5 @@ -package grpc + +package grpc // THIS FILE IS GENERATED CODE, DO NOT EDIT // SOURCE AT `proto/osmosis/concentrated-liquidity/query.yml` diff --git a/x/cosmwasmpool/client/grpc/grpc_query.go b/x/cosmwasmpool/client/grpc/grpc_query.go index b45bce290fd..abd44c6e103 100644 --- a/x/cosmwasmpool/client/grpc/grpc_query.go +++ b/x/cosmwasmpool/client/grpc/grpc_query.go @@ -1,4 +1,5 @@ -package grpc + +package grpc // THIS FILE IS GENERATED CODE, DO NOT EDIT // SOURCE AT `proto/osmosis/cosmwasmpool/v1beta1/query.yml` diff --git a/x/downtime-detector/client/grpc/grpc_query.go b/x/downtime-detector/client/grpc/grpc_query.go index 18cba74d32f..0c727ace1f1 100644 --- a/x/downtime-detector/client/grpc/grpc_query.go +++ b/x/downtime-detector/client/grpc/grpc_query.go @@ -1,4 +1,5 @@ -package grpc + +package grpc // THIS FILE IS GENERATED CODE, DO NOT EDIT // SOURCE AT `proto/osmosis/downtime-detector/v1beta1/query.yml` diff --git a/x/ibc-rate-limit/client/grpc/grpc_query.go b/x/ibc-rate-limit/client/grpc/grpc_query.go index 56d22c9989e..249209cde9e 100644 --- a/x/ibc-rate-limit/client/grpc/grpc_query.go +++ b/x/ibc-rate-limit/client/grpc/grpc_query.go @@ -1,4 +1,5 @@ -package grpc + +package grpc // THIS FILE IS GENERATED CODE, DO NOT EDIT // SOURCE AT `proto/osmosis/ibc-rate-limit/v1beta1/query.yml` diff --git a/x/poolmanager/client/cli/query.go b/x/poolmanager/client/cli/query.go index f0fea8d598f..b7e4a741f85 100644 --- a/x/poolmanager/client/cli/query.go +++ b/x/poolmanager/client/cli/query.go @@ -9,6 +9,7 @@ import ( "github.com/osmosis-labs/osmosis/osmoutils/osmocli" "github.com/osmosis-labs/osmosis/v19/x/poolmanager/client/queryproto" + "github.com/osmosis-labs/osmosis/v19/x/poolmanager/client/queryprotov2" "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" ) @@ -29,6 +30,7 @@ func GetQueryCmd() *cobra.Command { osmocli.AddQueryCmd(cmd, queryproto.NewQueryClient, GetCmdTotalPoolLiquidity) osmocli.AddQueryCmd(cmd, queryproto.NewQueryClient, GetCmdAllPools) osmocli.AddQueryCmd(cmd, queryproto.NewQueryClient, GetCmdPool) + osmocli.AddQueryCmd(cmd, queryprotov2.NewQueryClient, GetCmdSpotPriceV2) cmd.AddCommand( osmocli.GetParams[*queryproto.ParamsRequest]( types.ModuleName, queryproto.NewQueryClient), @@ -103,6 +105,16 @@ func GetCmdSpotPrice() (*osmocli.QueryDescriptor, *queryproto.SpotPriceRequest) }, &queryproto.SpotPriceRequest{} } +func GetCmdSpotPriceV2() (*osmocli.QueryDescriptor, *queryprotov2.SpotPriceRequest) { + return &osmocli.QueryDescriptor{ + Use: "spot-price-v2", + Short: "Query spot-price with 36 decimals", + Long: `Query spot-price with 36 decimals +{{.CommandPrefix}} spot-price-v2 1 uosmo ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2 +`, + }, &queryprotov2.SpotPriceRequest{} +} + func EstimateSwapExactAmountInParseArgs(args []string, fs *flag.FlagSet) (proto.Message, error) { poolID, err := strconv.Atoi(args[0]) if err != nil { diff --git a/x/poolmanager/client/grpc/grpc_query.go b/x/poolmanager/client/grpc/grpc_query.go index cb4842b39bc..937127d5c8b 100644 --- a/x/poolmanager/client/grpc/grpc_query.go +++ b/x/poolmanager/client/grpc/grpc_query.go @@ -1,4 +1,5 @@ -package grpc + +package grpc // THIS FILE IS GENERATED CODE, DO NOT EDIT // SOURCE AT `proto/osmosis/poolmanager/v1beta1/query.yml` diff --git a/x/poolmanager/client/grpcv2/grpc_query.go b/x/poolmanager/client/grpcv2/grpc_query.go new file mode 100644 index 00000000000..13d59f759c4 --- /dev/null +++ b/x/poolmanager/client/grpcv2/grpc_query.go @@ -0,0 +1,33 @@ + +package grpcv2 + +// THIS FILE IS GENERATED CODE, DO NOT EDIT +// SOURCE AT `proto/osmosis/poolmanager/v2/query.yml` + +import ( + context "context" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/v19/x/poolmanager/client" + "github.com/osmosis-labs/osmosis/v19/x/poolmanager/client/queryprotov2" +) + +type Querier struct { + Q client.QuerierV2 +} + +var _ queryprotov2.QueryServer = Querier{} + +func (q Querier) SpotPriceV2(grpcCtx context.Context, + req *queryprotov2.SpotPriceRequest, +) (*queryprotov2.SpotPriceResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + ctx := sdk.UnwrapSDKContext(grpcCtx) + return q.Q.SpotPriceV2(ctx, *req) +} + diff --git a/x/poolmanager/client/query_proto_wrap.go b/x/poolmanager/client/query_proto_wrap.go index ee3970c8415..5c8dd35dda8 100644 --- a/x/poolmanager/client/query_proto_wrap.go +++ b/x/poolmanager/client/query_proto_wrap.go @@ -9,6 +9,7 @@ import ( "github.com/osmosis-labs/osmosis/v19/x/poolmanager" "github.com/osmosis-labs/osmosis/v19/x/poolmanager/client/queryproto" + "github.com/osmosis-labs/osmosis/v19/x/poolmanager/client/queryprotov2" "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" ) @@ -22,6 +23,16 @@ func NewQuerier(k poolmanager.Keeper) Querier { return Querier{k} } +// QuerierV2 defines a wrapper around the x/poolmanager keeper providing gRPC method +// handlers for v2 queries. +type QuerierV2 struct { + K poolmanager.Keeper +} + +func NewV2Querier(k poolmanager.Keeper) QuerierV2 { + return QuerierV2{K: k} +} + func (q Querier) Params(ctx sdk.Context, req queryproto.ParamsRequest, ) (*queryproto.ParamsResponse, error) { @@ -203,7 +214,7 @@ func (q Querier) AllPools(ctx sdk.Context, req queryproto.AllPoolsRequest) (*que }, nil } -// SpotPrice returns the spot price of the pool with the given quote and base asset denoms. +// SpotPrice returns the spot price of the pool with the given quote and base asset denoms. 18 decimals. func (q Querier) SpotPrice(ctx sdk.Context, req queryproto.SpotPriceRequest) (*queryproto.SpotPriceResponse, error) { if req.BaseAssetDenom == "" { return nil, status.Error(codes.InvalidArgument, "invalid base asset denom") @@ -225,6 +236,27 @@ func (q Querier) SpotPrice(ctx sdk.Context, req queryproto.SpotPriceRequest) (*q }, err } +// SpotPriceV2 returns the spot price of the pool with the given quote and base asset denoms. 36 decimals. +func (q QuerierV2) SpotPriceV2(ctx sdk.Context, req queryprotov2.SpotPriceRequest) (*queryprotov2.SpotPriceResponse, error) { + if req.BaseAssetDenom == "" { + return nil, status.Error(codes.InvalidArgument, "invalid base asset denom") + } + + if req.QuoteAssetDenom == "" { + return nil, status.Error(codes.InvalidArgument, "invalid quote asset denom") + } + + sp, err := q.K.RouteCalculateSpotPrice(ctx, req.PoolId, req.QuoteAssetDenom, req.BaseAssetDenom) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &queryprotov2.SpotPriceResponse{ + // Note: that this is a BigDec yielding 36 decimals. + SpotPrice: sp, + }, err +} + // TotalPoolLiquidity returns the total liquidity of the pool. func (q Querier) TotalPoolLiquidity(ctx sdk.Context, req queryproto.TotalPoolLiquidityRequest) (*queryproto.TotalPoolLiquidityResponse, error) { if req.PoolId == 0 { diff --git a/x/poolmanager/client/queryprotov2/query.pb.go b/x/poolmanager/client/queryprotov2/query.pb.go new file mode 100644 index 00000000000..12049791d39 --- /dev/null +++ b/x/poolmanager/client/queryprotov2/query.pb.go @@ -0,0 +1,694 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/poolmanager/v2/query.proto + +package queryprotov2 + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "github.com/gogo/protobuf/types" + github_com_osmosis_labs_osmosis_osmomath "github.com/osmosis-labs/osmosis/osmomath" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// SpotPriceRequest defines the gRPC request structure for a SpotPrice +// query. +type SpotPriceRequest struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` + BaseAssetDenom string `protobuf:"bytes,2,opt,name=base_asset_denom,json=baseAssetDenom,proto3" json:"base_asset_denom,omitempty" yaml:"base_asset_denom"` + QuoteAssetDenom string `protobuf:"bytes,3,opt,name=quote_asset_denom,json=quoteAssetDenom,proto3" json:"quote_asset_denom,omitempty" yaml:"quote_asset_denom"` +} + +func (m *SpotPriceRequest) Reset() { *m = SpotPriceRequest{} } +func (m *SpotPriceRequest) String() string { return proto.CompactTextString(m) } +func (*SpotPriceRequest) ProtoMessage() {} +func (*SpotPriceRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_eb2850debe8fb398, []int{0} +} +func (m *SpotPriceRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SpotPriceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SpotPriceRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SpotPriceRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_SpotPriceRequest.Merge(m, src) +} +func (m *SpotPriceRequest) XXX_Size() int { + return m.Size() +} +func (m *SpotPriceRequest) XXX_DiscardUnknown() { + xxx_messageInfo_SpotPriceRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_SpotPriceRequest proto.InternalMessageInfo + +func (m *SpotPriceRequest) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *SpotPriceRequest) GetBaseAssetDenom() string { + if m != nil { + return m.BaseAssetDenom + } + return "" +} + +func (m *SpotPriceRequest) GetQuoteAssetDenom() string { + if m != nil { + return m.QuoteAssetDenom + } + return "" +} + +// SpotPriceResponse defines the gRPC response structure for a SpotPrice +// query. +type SpotPriceResponse struct { + // String of the BigDec. Ex) 10.203uatom + SpotPrice github_com_osmosis_labs_osmosis_osmomath.BigDec `protobuf:"bytes,1,opt,name=spot_price,json=spotPrice,proto3,customtype=github.com/osmosis-labs/osmosis/osmomath.BigDec" json:"spot_price" yaml:"spot_price"` +} + +func (m *SpotPriceResponse) Reset() { *m = SpotPriceResponse{} } +func (m *SpotPriceResponse) String() string { return proto.CompactTextString(m) } +func (*SpotPriceResponse) ProtoMessage() {} +func (*SpotPriceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_eb2850debe8fb398, []int{1} +} +func (m *SpotPriceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SpotPriceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SpotPriceResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SpotPriceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_SpotPriceResponse.Merge(m, src) +} +func (m *SpotPriceResponse) XXX_Size() int { + return m.Size() +} +func (m *SpotPriceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_SpotPriceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_SpotPriceResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*SpotPriceRequest)(nil), "osmosis.poolmanager.v2.SpotPriceRequest") + proto.RegisterType((*SpotPriceResponse)(nil), "osmosis.poolmanager.v2.SpotPriceResponse") +} + +func init() { + proto.RegisterFile("osmosis/poolmanager/v2/query.proto", fileDescriptor_eb2850debe8fb398) +} + +var fileDescriptor_eb2850debe8fb398 = []byte{ + // 471 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0x41, 0x8b, 0xd3, 0x40, + 0x14, 0xee, 0xac, 0xba, 0xb2, 0x23, 0xac, 0xdb, 0x20, 0x5a, 0xeb, 0x92, 0x2c, 0x73, 0xaa, 0x88, + 0x19, 0x8d, 0x20, 0xe8, 0xcd, 0xb0, 0x0b, 0x0a, 0x1e, 0x34, 0x82, 0x07, 0x2f, 0x61, 0x92, 0x8e, + 0xd9, 0xc1, 0x24, 0x2f, 0xed, 0x4c, 0x8a, 0x45, 0x04, 0xf1, 0x17, 0x08, 0xde, 0x3c, 0xfb, 0x63, + 0xf6, 0x58, 0xf0, 0x22, 0x1e, 0x82, 0xb4, 0xfe, 0x82, 0xfe, 0x02, 0x99, 0x99, 0xd4, 0xdd, 0xad, + 0x8a, 0x9e, 0xf2, 0xde, 0xfb, 0xbe, 0xf9, 0xde, 0x7b, 0x79, 0x1f, 0x26, 0x20, 0x0b, 0x90, 0x42, + 0xd2, 0x0a, 0x20, 0x2f, 0x58, 0xc9, 0x32, 0x3e, 0xa6, 0x93, 0x80, 0x8e, 0x6a, 0x3e, 0x9e, 0xfa, + 0xd5, 0x18, 0x14, 0x38, 0x97, 0x5b, 0x8e, 0x7f, 0x82, 0xe3, 0x4f, 0x82, 0xfe, 0xa5, 0x0c, 0x32, + 0x30, 0x14, 0xaa, 0x23, 0xcb, 0xee, 0xef, 0x66, 0x00, 0x59, 0xce, 0x29, 0xab, 0x04, 0x65, 0x65, + 0x09, 0x8a, 0x29, 0x01, 0xa5, 0x6c, 0xd1, 0xab, 0x2d, 0x6a, 0xb2, 0xa4, 0x7e, 0x49, 0x59, 0x39, + 0x5d, 0x41, 0xa9, 0xe9, 0x13, 0x5b, 0x45, 0x9b, 0xb4, 0x90, 0xb7, 0xfe, 0x4a, 0x89, 0x82, 0x4b, + 0xc5, 0x8a, 0xca, 0x12, 0xc8, 0x0c, 0xe1, 0x9d, 0x67, 0x15, 0xa8, 0x27, 0x63, 0x91, 0xf2, 0x88, + 0x8f, 0x6a, 0x2e, 0x95, 0x73, 0x03, 0x9f, 0xd7, 0x13, 0xc7, 0x62, 0xd8, 0x43, 0x7b, 0x68, 0x70, + 0x36, 0x74, 0x96, 0x8d, 0xb7, 0x3d, 0x65, 0x45, 0x7e, 0x9f, 0xb4, 0x00, 0x89, 0x36, 0x75, 0xf4, + 0x68, 0xe8, 0x1c, 0xe0, 0x9d, 0x84, 0x49, 0x1e, 0x33, 0x29, 0xb9, 0x8a, 0x87, 0xbc, 0x84, 0xa2, + 0xb7, 0xb1, 0x87, 0x06, 0x5b, 0xe1, 0xb5, 0x65, 0xe3, 0x5d, 0xb1, 0xaf, 0xd6, 0x19, 0x24, 0xda, + 0xd6, 0xa5, 0x07, 0xba, 0xb2, 0xaf, 0x0b, 0xce, 0x43, 0xdc, 0x1d, 0xd5, 0xa0, 0x4e, 0xeb, 0x9c, + 0x31, 0x3a, 0xbb, 0xcb, 0xc6, 0xeb, 0x59, 0x9d, 0xdf, 0x28, 0x24, 0xba, 0x68, 0x6a, 0xc7, 0x4a, + 0xe4, 0x1d, 0xc2, 0xdd, 0x13, 0x2b, 0xc9, 0x0a, 0x4a, 0xc9, 0x9d, 0x57, 0x18, 0xcb, 0x0a, 0x54, + 0x5c, 0xe9, 0xaa, 0x59, 0x6b, 0x2b, 0x7c, 0x7c, 0xd4, 0x78, 0x9d, 0x6f, 0x8d, 0x47, 0x33, 0xa1, + 0x0e, 0xeb, 0xc4, 0x4f, 0xa1, 0xa0, 0xed, 0xc9, 0x6e, 0xe6, 0x2c, 0x91, 0xab, 0xc4, 0x7c, 0x0b, + 0xa6, 0x0e, 0xfd, 0x50, 0x64, 0xfb, 0x3c, 0x5d, 0x36, 0x5e, 0xd7, 0xce, 0x73, 0x2c, 0x49, 0xa2, + 0x2d, 0xb9, 0x6a, 0x1a, 0x7c, 0x46, 0xf8, 0xdc, 0x53, 0x6d, 0x04, 0xe7, 0x13, 0xc2, 0x17, 0x7e, + 0x0d, 0xf3, 0x3c, 0x70, 0x06, 0xfe, 0x9f, 0x3d, 0xe1, 0xaf, 0x1f, 0xa1, 0x7f, 0xfd, 0x3f, 0x98, + 0x76, 0x37, 0x72, 0xf7, 0xfd, 0x97, 0x1f, 0x1f, 0x37, 0x6e, 0x39, 0x3e, 0xfd, 0x8b, 0x29, 0x75, + 0x2a, 0xe9, 0x9b, 0xf6, 0x76, 0x6f, 0xa9, 0x99, 0x58, 0x86, 0xf1, 0xd1, 0xdc, 0x45, 0xb3, 0xb9, + 0x8b, 0xbe, 0xcf, 0x5d, 0xf4, 0x61, 0xe1, 0x76, 0x66, 0x0b, 0xb7, 0xf3, 0x75, 0xe1, 0x76, 0x5e, + 0x1c, 0xfc, 0xeb, 0x8f, 0x4c, 0x6e, 0xdf, 0xa3, 0xaf, 0x4f, 0xb5, 0x49, 0x73, 0xc1, 0x4b, 0x65, + 0xfd, 0x6f, 0xbc, 0x35, 0x09, 0x92, 0x4d, 0x13, 0xdc, 0xf9, 0x19, 0x00, 0x00, 0xff, 0xff, 0x48, + 0xf8, 0xd8, 0x89, 0x2d, 0x03, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // SpotPriceV2 defines a gRPC query handler that returns the spot price given + // a base denomination and a quote denomination. + // The returned spot price has 36 decimal places. However, some of + // modules perform sig fig rounding so most of the rightmost decimals can be + // zeroes. + SpotPriceV2(ctx context.Context, in *SpotPriceRequest, opts ...grpc.CallOption) (*SpotPriceResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) SpotPriceV2(ctx context.Context, in *SpotPriceRequest, opts ...grpc.CallOption) (*SpotPriceResponse, error) { + out := new(SpotPriceResponse) + err := c.cc.Invoke(ctx, "/osmosis.poolmanager.v2.Query/SpotPriceV2", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // SpotPriceV2 defines a gRPC query handler that returns the spot price given + // a base denomination and a quote denomination. + // The returned spot price has 36 decimal places. However, some of + // modules perform sig fig rounding so most of the rightmost decimals can be + // zeroes. + SpotPriceV2(context.Context, *SpotPriceRequest) (*SpotPriceResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) SpotPriceV2(ctx context.Context, req *SpotPriceRequest) (*SpotPriceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SpotPriceV2 not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_SpotPriceV2_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SpotPriceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).SpotPriceV2(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.poolmanager.v2.Query/SpotPriceV2", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).SpotPriceV2(ctx, req.(*SpotPriceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "osmosis.poolmanager.v2.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "SpotPriceV2", + Handler: _Query_SpotPriceV2_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "osmosis/poolmanager/v2/query.proto", +} + +func (m *SpotPriceRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SpotPriceRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SpotPriceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.QuoteAssetDenom) > 0 { + i -= len(m.QuoteAssetDenom) + copy(dAtA[i:], m.QuoteAssetDenom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.QuoteAssetDenom))) + i-- + dAtA[i] = 0x1a + } + if len(m.BaseAssetDenom) > 0 { + i -= len(m.BaseAssetDenom) + copy(dAtA[i:], m.BaseAssetDenom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.BaseAssetDenom))) + i-- + dAtA[i] = 0x12 + } + if m.PoolId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *SpotPriceResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SpotPriceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SpotPriceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.SpotPrice.Size() + i -= size + if _, err := m.SpotPrice.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *SpotPriceRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + l = len(m.BaseAssetDenom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.QuoteAssetDenom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *SpotPriceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.SpotPrice.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *SpotPriceRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SpotPriceRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SpotPriceRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BaseAssetDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BaseAssetDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field QuoteAssetDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.QuoteAssetDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SpotPriceResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SpotPriceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SpotPriceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpotPrice", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.SpotPrice.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/poolmanager/client/queryprotov2/query.pb.gw.go b/x/poolmanager/client/queryprotov2/query.pb.gw.go new file mode 100644 index 00000000000..c1a7669cac7 --- /dev/null +++ b/x/poolmanager/client/queryprotov2/query.pb.gw.go @@ -0,0 +1,207 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: osmosis/poolmanager/v2/query.proto + +/* +Package queryprotov2 is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package queryprotov2 + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +var ( + filter_Query_SpotPriceV2_0 = &utilities.DoubleArray{Encoding: map[string]int{"pool_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_SpotPriceV2_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq SpotPriceRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_SpotPriceV2_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.SpotPriceV2(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_SpotPriceV2_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq SpotPriceRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_SpotPriceV2_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.SpotPriceV2(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// 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_SpotPriceV2_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_SpotPriceV2_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_SpotPriceV2_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_SpotPriceV2_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_SpotPriceV2_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_SpotPriceV2_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_SpotPriceV2_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"osmosis", "poolmanager", "v2", "pools", "pool_id", "prices"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_SpotPriceV2_0 = runtime.ForwardResponseMessage +) diff --git a/x/poolmanager/module/module.go b/x/poolmanager/module/module.go index de231e5e4a8..f5392c571f2 100644 --- a/x/poolmanager/module/module.go +++ b/x/poolmanager/module/module.go @@ -21,7 +21,9 @@ import ( pmclient "github.com/osmosis-labs/osmosis/v19/x/poolmanager/client" "github.com/osmosis-labs/osmosis/v19/x/poolmanager/client/cli" "github.com/osmosis-labs/osmosis/v19/x/poolmanager/client/grpc" + "github.com/osmosis-labs/osmosis/v19/x/poolmanager/client/grpcv2" "github.com/osmosis-labs/osmosis/v19/x/poolmanager/client/queryproto" + "github.com/osmosis-labs/osmosis/v19/x/poolmanager/client/queryprotov2" "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" ) @@ -60,6 +62,9 @@ func (b AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux if err := queryproto.RegisterQueryHandlerClient(context.Background(), mux, queryproto.NewQueryClient(clientCtx)); err != nil { panic(err) } + if err := queryprotov2.RegisterQueryHandlerClient(context.Background(), mux, queryprotov2.NewQueryClient(clientCtx)); err != nil { + panic(err) + } } func (b AppModuleBasic) GetTxCmd() *cobra.Command { @@ -85,6 +90,7 @@ type AppModule struct { func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), poolmanager.NewMsgServerImpl(&am.k)) queryproto.RegisterQueryServer(cfg.QueryServer(), grpc.Querier{Q: pmclient.NewQuerier(am.k)}) + queryprotov2.RegisterQueryServer(cfg.QueryServer(), grpcv2.Querier{Q: pmclient.NewV2Querier(am.k)}) } func NewAppModule(poolmanagerKeeper poolmanager.Keeper, gammKeeper types.PoolModuleI) AppModule { diff --git a/x/twap/client/grpc/grpc_query.go b/x/twap/client/grpc/grpc_query.go index 7dd67e8a897..d2efc90e832 100644 --- a/x/twap/client/grpc/grpc_query.go +++ b/x/twap/client/grpc/grpc_query.go @@ -1,4 +1,5 @@ -package grpc + +package grpc // THIS FILE IS GENERATED CODE, DO NOT EDIT // SOURCE AT `proto/osmosis/twap/v1beta1/query.yml` diff --git a/x/valset-pref/client/grpc/grpc_query.go b/x/valset-pref/client/grpc/grpc_query.go index 93aa3ed639b..c05ad27bb17 100644 --- a/x/valset-pref/client/grpc/grpc_query.go +++ b/x/valset-pref/client/grpc/grpc_query.go @@ -1,4 +1,5 @@ -package grpc + +package grpc // THIS FILE IS GENERATED CODE, DO NOT EDIT // SOURCE AT `proto/osmosis/valset-pref/v1beta1/query.yml`