From ddd17155662f5dab738af0805578264600de176a Mon Sep 17 00:00:00 2001 From: vincentwschau <99756290+vincentwschau@users.noreply.github.com> Date: Wed, 27 Mar 2024 14:19:10 -0400 Subject: [PATCH] [TRA-181] Add query function for collateral pool address. (#1256) --- .../dydxprotocol/subaccounts/query.lcd.ts | 18 +- .../subaccounts/query.rpc.Query.ts | 16 +- .../codegen/dydxprotocol/subaccounts/query.ts | 136 ++++++ proto/dydxprotocol/subaccounts/query.proto | 23 +- protocol/mocks/QueryClient.go | 37 ++ .../keeper/grpc_query_collateral_pool.go | 46 ++ .../keeper/grpc_query_collateral_pool_test.go | 68 +++ protocol/x/subaccounts/types/query.pb.go | 462 ++++++++++++++++-- protocol/x/subaccounts/types/query.pb.gw.go | 145 +++++- 9 files changed, 883 insertions(+), 68 deletions(-) create mode 100644 protocol/x/subaccounts/keeper/grpc_query_collateral_pool.go create mode 100644 protocol/x/subaccounts/keeper/grpc_query_collateral_pool_test.go diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/subaccounts/query.lcd.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/subaccounts/query.lcd.ts index 045342f671..8c761428e7 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/subaccounts/query.lcd.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/subaccounts/query.lcd.ts @@ -1,6 +1,6 @@ import { setPaginationParams } from "../../helpers"; import { LCDClient } from "@osmonauts/lcd"; -import { QueryGetSubaccountRequest, QuerySubaccountResponseSDKType, QueryAllSubaccountRequest, QuerySubaccountAllResponseSDKType, QueryGetWithdrawalAndTransfersBlockedInfoRequest, QueryGetWithdrawalAndTransfersBlockedInfoResponseSDKType } from "./query"; +import { QueryGetSubaccountRequest, QuerySubaccountResponseSDKType, QueryAllSubaccountRequest, QuerySubaccountAllResponseSDKType, QueryGetWithdrawalAndTransfersBlockedInfoRequest, QueryGetWithdrawalAndTransfersBlockedInfoResponseSDKType, QueryCollateralPoolAddressRequest, QueryCollateralPoolAddressResponseSDKType } from "./query"; export class LCDQueryClient { req: LCDClient; @@ -13,6 +13,7 @@ export class LCDQueryClient { this.subaccount = this.subaccount.bind(this); this.subaccountAll = this.subaccountAll.bind(this); this.getWithdrawalAndTransfersBlockedInfo = this.getWithdrawalAndTransfersBlockedInfo.bind(this); + this.collateralPoolAddress = this.collateralPoolAddress.bind(this); } /* Queries a Subaccount by id */ @@ -43,16 +44,15 @@ export class LCDQueryClient { async getWithdrawalAndTransfersBlockedInfo(params: QueryGetWithdrawalAndTransfersBlockedInfoRequest): Promise { - const options: any = { - params: {} - }; + const endpoint = `dydxprotocol/subaccounts/withdrawals_and_transfers_blocked_info/${params.perpetualId}`; + return await this.req.get(endpoint); + } + /* Queries the collateral pool account address for a perpetual id. */ - if (typeof params?.perpetualId !== "undefined") { - options.params.perpetual_id = params.perpetualId; - } - const endpoint = `dydxprotocol/subaccounts/withdrawals_and_transfers_blocked_info`; - return await this.req.get(endpoint, options); + async collateralPoolAddress(params: QueryCollateralPoolAddressRequest): Promise { + const endpoint = `dydxprotocol/subaccounts/collateral_pool_address/${params.perpetualId}`; + return await this.req.get(endpoint); } } \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/subaccounts/query.rpc.Query.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/subaccounts/query.rpc.Query.ts index 1e76701fcf..69ea5b399d 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/subaccounts/query.rpc.Query.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/subaccounts/query.rpc.Query.ts @@ -1,7 +1,7 @@ import { Rpc } from "../../helpers"; import * as _m0 from "protobufjs/minimal"; import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; -import { QueryGetSubaccountRequest, QuerySubaccountResponse, QueryAllSubaccountRequest, QuerySubaccountAllResponse, QueryGetWithdrawalAndTransfersBlockedInfoRequest, QueryGetWithdrawalAndTransfersBlockedInfoResponse } from "./query"; +import { QueryGetSubaccountRequest, QuerySubaccountResponse, QueryAllSubaccountRequest, QuerySubaccountAllResponse, QueryGetWithdrawalAndTransfersBlockedInfoRequest, QueryGetWithdrawalAndTransfersBlockedInfoResponse, QueryCollateralPoolAddressRequest, QueryCollateralPoolAddressResponse } from "./query"; /** Query defines the gRPC querier service. */ export interface Query { @@ -16,6 +16,9 @@ export interface Query { */ getWithdrawalAndTransfersBlockedInfo(request: QueryGetWithdrawalAndTransfersBlockedInfoRequest): Promise; + /** Queries the collateral pool account address for a perpetual id. */ + + collateralPoolAddress(request: QueryCollateralPoolAddressRequest): Promise; } export class QueryClientImpl implements Query { private readonly rpc: Rpc; @@ -25,6 +28,7 @@ export class QueryClientImpl implements Query { this.subaccount = this.subaccount.bind(this); this.subaccountAll = this.subaccountAll.bind(this); this.getWithdrawalAndTransfersBlockedInfo = this.getWithdrawalAndTransfersBlockedInfo.bind(this); + this.collateralPoolAddress = this.collateralPoolAddress.bind(this); } subaccount(request: QueryGetSubaccountRequest): Promise { @@ -47,6 +51,12 @@ export class QueryClientImpl implements Query { return promise.then(data => QueryGetWithdrawalAndTransfersBlockedInfoResponse.decode(new _m0.Reader(data))); } + collateralPoolAddress(request: QueryCollateralPoolAddressRequest): Promise { + const data = QueryCollateralPoolAddressRequest.encode(request).finish(); + const promise = this.rpc.request("dydxprotocol.subaccounts.Query", "CollateralPoolAddress", data); + return promise.then(data => QueryCollateralPoolAddressResponse.decode(new _m0.Reader(data))); + } + } export const createRpcQueryExtension = (base: QueryClient) => { const rpc = createProtobufRpcClient(base); @@ -62,6 +72,10 @@ export const createRpcQueryExtension = (base: QueryClient) => { getWithdrawalAndTransfersBlockedInfo(request: QueryGetWithdrawalAndTransfersBlockedInfoRequest): Promise { return queryService.getWithdrawalAndTransfersBlockedInfo(request); + }, + + collateralPoolAddress(request: QueryCollateralPoolAddressRequest): Promise { + return queryService.collateralPoolAddress(request); } }; diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/subaccounts/query.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/subaccounts/query.ts index 0464bd1359..d5512b12fe 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/subaccounts/query.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/subaccounts/query.ts @@ -84,6 +84,52 @@ export interface QueryGetWithdrawalAndTransfersBlockedInfoResponseSDKType { chain_outage_seen_at_block: number; withdrawals_and_transfers_unblocked_at_block: number; } +/** + * QueryCollateralPoolAddressRequest is the request type for fetching the + * account address of the collateral pool associated with the passed in + * perpetual id. + */ + +export interface QueryCollateralPoolAddressRequest { + /** + * QueryCollateralPoolAddressRequest is the request type for fetching the + * account address of the collateral pool associated with the passed in + * perpetual id. + */ + perpetualId: number; +} +/** + * QueryCollateralPoolAddressRequest is the request type for fetching the + * account address of the collateral pool associated with the passed in + * perpetual id. + */ + +export interface QueryCollateralPoolAddressRequestSDKType { + /** + * QueryCollateralPoolAddressRequest is the request type for fetching the + * account address of the collateral pool associated with the passed in + * perpetual id. + */ + perpetual_id: number; +} +/** + * QueryCollateralPoolAddressResponse is a response type for fetching the + * account address of the collateral pool associated with the passed in + * perpetual id. + */ + +export interface QueryCollateralPoolAddressResponse { + collateralPoolAddress: string; +} +/** + * QueryCollateralPoolAddressResponse is a response type for fetching the + * account address of the collateral pool associated with the passed in + * perpetual id. + */ + +export interface QueryCollateralPoolAddressResponseSDKType { + collateral_pool_address: string; +} function createBaseQueryGetSubaccountRequest(): QueryGetSubaccountRequest { return { @@ -393,4 +439,94 @@ export const QueryGetWithdrawalAndTransfersBlockedInfoResponse = { return message; } +}; + +function createBaseQueryCollateralPoolAddressRequest(): QueryCollateralPoolAddressRequest { + return { + perpetualId: 0 + }; +} + +export const QueryCollateralPoolAddressRequest = { + encode(message: QueryCollateralPoolAddressRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.perpetualId !== 0) { + writer.uint32(8).uint32(message.perpetualId); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryCollateralPoolAddressRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryCollateralPoolAddressRequest(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.perpetualId = reader.uint32(); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial): QueryCollateralPoolAddressRequest { + const message = createBaseQueryCollateralPoolAddressRequest(); + message.perpetualId = object.perpetualId ?? 0; + return message; + } + +}; + +function createBaseQueryCollateralPoolAddressResponse(): QueryCollateralPoolAddressResponse { + return { + collateralPoolAddress: "" + }; +} + +export const QueryCollateralPoolAddressResponse = { + encode(message: QueryCollateralPoolAddressResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.collateralPoolAddress !== "") { + writer.uint32(10).string(message.collateralPoolAddress); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryCollateralPoolAddressResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryCollateralPoolAddressResponse(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.collateralPoolAddress = reader.string(); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial): QueryCollateralPoolAddressResponse { + const message = createBaseQueryCollateralPoolAddressResponse(); + message.collateralPoolAddress = object.collateralPoolAddress ?? ""; + return message; + } + }; \ No newline at end of file diff --git a/proto/dydxprotocol/subaccounts/query.proto b/proto/dydxprotocol/subaccounts/query.proto index 7533366d0f..63a1578dec 100644 --- a/proto/dydxprotocol/subaccounts/query.proto +++ b/proto/dydxprotocol/subaccounts/query.proto @@ -29,7 +29,15 @@ service Query { QueryGetWithdrawalAndTransfersBlockedInfoRequest) returns (QueryGetWithdrawalAndTransfersBlockedInfoResponse) { option (google.api.http).get = - "/dydxprotocol/subaccounts/withdrawals_and_transfers_blocked_info"; + "/dydxprotocol/subaccounts/withdrawals_and_transfers_blocked_info/" + "{perpetual_id}"; + } + + // Queries the collateral pool account address for a perpetual id. + rpc CollateralPoolAddress(QueryCollateralPoolAddressRequest) + returns (QueryCollateralPoolAddressResponse) { + option (google.api.http).get = + "/dydxprotocol/subaccounts/collateral_pool_address/{perpetual_id}"; } } @@ -69,3 +77,16 @@ message QueryGetWithdrawalAndTransfersBlockedInfoResponse { uint32 chain_outage_seen_at_block = 2; uint32 withdrawals_and_transfers_unblocked_at_block = 3; } + +// QueryCollateralPoolAddressRequest is the request type for fetching the +// account address of the collateral pool associated with the passed in +// perpetual id. +message QueryCollateralPoolAddressRequest { uint32 perpetual_id = 1; } + +// QueryCollateralPoolAddressResponse is a response type for fetching the +// account address of the collateral pool associated with the passed in +// perpetual id. +message QueryCollateralPoolAddressResponse { + string collateral_pool_address = 1 + [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; +} diff --git a/protocol/mocks/QueryClient.go b/protocol/mocks/QueryClient.go index e04a613c33..81b7f9a05f 100644 --- a/protocol/mocks/QueryClient.go +++ b/protocol/mocks/QueryClient.go @@ -363,6 +363,43 @@ func (_m *QueryClient) ClobPairAll(ctx context.Context, in *clobtypes.QueryAllCl return r0, r1 } +// CollateralPoolAddress provides a mock function with given fields: ctx, in, opts +func (_m *QueryClient) CollateralPoolAddress(ctx context.Context, in *subaccountstypes.QueryCollateralPoolAddressRequest, opts ...grpc.CallOption) (*subaccountstypes.QueryCollateralPoolAddressResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for CollateralPoolAddress") + } + + var r0 *subaccountstypes.QueryCollateralPoolAddressResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *subaccountstypes.QueryCollateralPoolAddressRequest, ...grpc.CallOption) (*subaccountstypes.QueryCollateralPoolAddressResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *subaccountstypes.QueryCollateralPoolAddressRequest, ...grpc.CallOption) *subaccountstypes.QueryCollateralPoolAddressResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*subaccountstypes.QueryCollateralPoolAddressResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *subaccountstypes.QueryCollateralPoolAddressRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // DowntimeParams provides a mock function with given fields: ctx, in, opts func (_m *QueryClient) DowntimeParams(ctx context.Context, in *types.QueryDowntimeParamsRequest, opts ...grpc.CallOption) (*types.QueryDowntimeParamsResponse, error) { _va := make([]interface{}, len(opts)) diff --git a/protocol/x/subaccounts/keeper/grpc_query_collateral_pool.go b/protocol/x/subaccounts/keeper/grpc_query_collateral_pool.go new file mode 100644 index 0000000000..339194b241 --- /dev/null +++ b/protocol/x/subaccounts/keeper/grpc_query_collateral_pool.go @@ -0,0 +1,46 @@ +package keeper + +import ( + "context" + "errors" + "fmt" + + "github.com/dydxprotocol/v4-chain/protocol/lib" + perptypes "github.com/dydxprotocol/v4-chain/protocol/x/perpetuals/types" + "github.com/dydxprotocol/v4-chain/protocol/x/subaccounts/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) CollateralPoolAddress( + c context.Context, + req *types.QueryCollateralPoolAddressRequest, +) (*types.QueryCollateralPoolAddressResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := lib.UnwrapSDKContext(c, types.ModuleName) + + collateralPool, err := k.GetCollateralPoolFromPerpetualId( + ctx, + req.PerpetualId, + ) + if err != nil { + if errors.Is(err, perptypes.ErrPerpetualDoesNotExist) { + return nil, + status.Error( + codes.NotFound, + fmt.Sprintf( + "Perpetual id %+v not found.", + req.PerpetualId, + ), + ) + } + + return nil, status.Error(codes.Internal, "internal error") + } + + return &types.QueryCollateralPoolAddressResponse{ + CollateralPoolAddress: collateralPool.String(), + }, nil +} diff --git a/protocol/x/subaccounts/keeper/grpc_query_collateral_pool_test.go b/protocol/x/subaccounts/keeper/grpc_query_collateral_pool_test.go new file mode 100644 index 0000000000..ec476552da --- /dev/null +++ b/protocol/x/subaccounts/keeper/grpc_query_collateral_pool_test.go @@ -0,0 +1,68 @@ +package keeper_test + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/dydxprotocol/v4-chain/protocol/testutil/constants" + keepertest "github.com/dydxprotocol/v4-chain/protocol/testutil/keeper" + "github.com/dydxprotocol/v4-chain/protocol/x/subaccounts/types" +) + +func TestQueryCollateralPoolAddress(t *testing.T) { + for testName, tc := range map[string]struct { + // Parameters + request *types.QueryCollateralPoolAddressRequest + + // Expectations + response *types.QueryCollateralPoolAddressResponse + err error + }{ + "Nil request results in error": { + err: status.Error(codes.InvalidArgument, "invalid request"), + }, + "Cross perpetual": { + request: &types.QueryCollateralPoolAddressRequest{ + PerpetualId: constants.BtcUsd_NoMarginRequirement.Params.Id, + }, + response: &types.QueryCollateralPoolAddressResponse{ + CollateralPoolAddress: types.ModuleAddress.String(), + }, + }, + "Isolated perpetual": { + request: &types.QueryCollateralPoolAddressRequest{ + PerpetualId: constants.IsoUsd_IsolatedMarket.Params.Id, + }, + response: &types.QueryCollateralPoolAddressResponse{ + CollateralPoolAddress: constants.IsoCollateralPoolAddress.String(), + }, + }, + "Perpetual not found": { + request: &types.QueryCollateralPoolAddressRequest{ + PerpetualId: uint32(1000), + }, + err: status.Error(codes.NotFound, fmt.Sprintf( + "Perpetual id %+v not found.", + uint32(1000), + )), + }, + } { + t.Run(testName, func(t *testing.T) { + ctx, keeper, pricesKeeper, perpetualsKeeper, _, _, _, _, _ := keepertest.SubaccountsKeepers(t, true) + keepertest.CreateTestMarkets(t, ctx, pricesKeeper) + keepertest.CreateTestLiquidityTiers(t, ctx, perpetualsKeeper) + keepertest.CreateTestPerpetuals(t, ctx, perpetualsKeeper) + response, err := keeper.CollateralPoolAddress(ctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + require.Equal(t, tc.response, response) + } + }) + } +} diff --git a/protocol/x/subaccounts/types/query.pb.go b/protocol/x/subaccounts/types/query.pb.go index 9c0bc41dc2..25bbbc13ac 100644 --- a/protocol/x/subaccounts/types/query.pb.go +++ b/protocol/x/subaccounts/types/query.pb.go @@ -344,6 +344,100 @@ func (m *QueryGetWithdrawalAndTransfersBlockedInfoResponse) GetWithdrawalsAndTra return 0 } +// QueryCollateralPoolAddressRequest is the request type for fetching the +// account address of the collateral pool associated with the passed in +// perpetual id. +type QueryCollateralPoolAddressRequest struct { + PerpetualId uint32 `protobuf:"varint,1,opt,name=perpetual_id,json=perpetualId,proto3" json:"perpetual_id,omitempty"` +} + +func (m *QueryCollateralPoolAddressRequest) Reset() { *m = QueryCollateralPoolAddressRequest{} } +func (m *QueryCollateralPoolAddressRequest) String() string { return proto.CompactTextString(m) } +func (*QueryCollateralPoolAddressRequest) ProtoMessage() {} +func (*QueryCollateralPoolAddressRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_adc19ff1d5b72954, []int{6} +} +func (m *QueryCollateralPoolAddressRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCollateralPoolAddressRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCollateralPoolAddressRequest.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 *QueryCollateralPoolAddressRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCollateralPoolAddressRequest.Merge(m, src) +} +func (m *QueryCollateralPoolAddressRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryCollateralPoolAddressRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCollateralPoolAddressRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCollateralPoolAddressRequest proto.InternalMessageInfo + +func (m *QueryCollateralPoolAddressRequest) GetPerpetualId() uint32 { + if m != nil { + return m.PerpetualId + } + return 0 +} + +// QueryCollateralPoolAddressResponse is a response type for fetching the +// account address of the collateral pool associated with the passed in +// perpetual id. +type QueryCollateralPoolAddressResponse struct { + CollateralPoolAddress string `protobuf:"bytes,1,opt,name=collateral_pool_address,json=collateralPoolAddress,proto3" json:"collateral_pool_address,omitempty"` +} + +func (m *QueryCollateralPoolAddressResponse) Reset() { *m = QueryCollateralPoolAddressResponse{} } +func (m *QueryCollateralPoolAddressResponse) String() string { return proto.CompactTextString(m) } +func (*QueryCollateralPoolAddressResponse) ProtoMessage() {} +func (*QueryCollateralPoolAddressResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_adc19ff1d5b72954, []int{7} +} +func (m *QueryCollateralPoolAddressResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCollateralPoolAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCollateralPoolAddressResponse.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 *QueryCollateralPoolAddressResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCollateralPoolAddressResponse.Merge(m, src) +} +func (m *QueryCollateralPoolAddressResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryCollateralPoolAddressResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCollateralPoolAddressResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCollateralPoolAddressResponse proto.InternalMessageInfo + +func (m *QueryCollateralPoolAddressResponse) GetCollateralPoolAddress() string { + if m != nil { + return m.CollateralPoolAddress + } + return "" +} + func init() { proto.RegisterType((*QueryGetSubaccountRequest)(nil), "dydxprotocol.subaccounts.QueryGetSubaccountRequest") proto.RegisterType((*QuerySubaccountResponse)(nil), "dydxprotocol.subaccounts.QuerySubaccountResponse") @@ -351,6 +445,8 @@ func init() { proto.RegisterType((*QuerySubaccountAllResponse)(nil), "dydxprotocol.subaccounts.QuerySubaccountAllResponse") proto.RegisterType((*QueryGetWithdrawalAndTransfersBlockedInfoRequest)(nil), "dydxprotocol.subaccounts.QueryGetWithdrawalAndTransfersBlockedInfoRequest") proto.RegisterType((*QueryGetWithdrawalAndTransfersBlockedInfoResponse)(nil), "dydxprotocol.subaccounts.QueryGetWithdrawalAndTransfersBlockedInfoResponse") + proto.RegisterType((*QueryCollateralPoolAddressRequest)(nil), "dydxprotocol.subaccounts.QueryCollateralPoolAddressRequest") + proto.RegisterType((*QueryCollateralPoolAddressResponse)(nil), "dydxprotocol.subaccounts.QueryCollateralPoolAddressResponse") } func init() { @@ -358,50 +454,56 @@ func init() { } var fileDescriptor_adc19ff1d5b72954 = []byte{ - // 687 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x4f, 0x4f, 0xd4, 0x4e, - 0x18, 0xde, 0x2e, 0x7f, 0x92, 0xdf, 0xf0, 0xe3, 0x32, 0x21, 0xb8, 0x34, 0x66, 0xc5, 0xcd, 0x0a, - 0x68, 0xa0, 0x75, 0x01, 0x63, 0x62, 0x42, 0xe2, 0xee, 0x41, 0x04, 0x0f, 0x68, 0x81, 0x90, 0x98, - 0x98, 0x66, 0xda, 0xbe, 0x94, 0xc6, 0x32, 0x53, 0x3a, 0x53, 0xfe, 0x84, 0x70, 0xf1, 0xe6, 0xcd, - 0xc4, 0x0f, 0xe0, 0xd5, 0xab, 0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0xb5, 0x20, 0xac, 0x94, - 0x27, 0x95, 0x99, 0x51, 0x23, 0x79, 0xab, 0x01, 0xba, 0x26, 0x9b, 0xe4, 0x3b, 0xf0, 0x80, 0x51, - 0x0e, 0x78, 0x15, 0xa1, 0x4c, 0x93, 0xec, 0x33, 0x32, 0x5f, 0xd7, 0x8a, 0x42, 0xd5, 0x32, 0x86, - 0xd6, 0xe0, 0xe9, 0xb7, 0x1b, 0x25, 0x23, 0x87, 0xee, 0x78, 0x69, 0xfa, 0xfe, 0x55, 0x2f, 0x8f, - 0x10, 0xca, 0x72, 0x4a, 0x1a, 0x4d, 0x69, 0x89, 0x9b, 0x76, 0xa8, 0x5a, 0xfc, 0x59, 0x93, 0x50, - 0xb5, 0xa7, 0xc4, 0x85, 0x04, 0x6b, 0xe4, 0x90, 0xb5, 0x0f, 0x0a, 0x52, 0x2f, 0x99, 0x69, 0xfa, - 0x7e, 0xa1, 0x9f, 0x81, 0xbf, 0xf7, 0x83, 0x97, 0xbb, 0x24, 0x97, 0xa5, 0xe4, 0xe9, 0x9e, 0x92, - 0x63, 0x21, 0x5d, 0x9a, 0x37, 0xd1, 0xdd, 0xf4, 0x23, 0x6f, 0x79, 0x62, 0xc7, 0x09, 0xc9, 0x01, - 0xf1, 0x9b, 0xd4, 0xd9, 0x08, 0x09, 0xe5, 0xdb, 0x10, 0xf2, 0x96, 0xcf, 0xec, 0x97, 0xe0, 0xac, - 0xd0, 0x6d, 0x96, 0xe6, 0x75, 0x13, 0xfd, 0x1f, 0x40, 0x18, 0x80, 0x88, 0x88, 0x6f, 0x7a, 0x8e, - 0x4c, 0x6c, 0xd4, 0x18, 0xe9, 0x9c, 0xad, 0x38, 0xb5, 0x77, 0x65, 0xd4, 0xf8, 0x03, 0xde, 0x24, - 0xa1, 0x35, 0x74, 0x8b, 0x82, 0x4b, 0x84, 0xb7, 0x0f, 0xa6, 0xa0, 0xb6, 0x99, 0x19, 0x36, 0x39, - 0x00, 0x35, 0x89, 0x30, 0xad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 0xad, 0xad, 0xd3, 0xf3, 0xaa, 0x72, - 0x76, 0x5e, 0x55, 0xbe, 0x9f, 0x57, 0x95, 0x37, 0x17, 0xd5, 0xd2, 0xd9, 0x45, 0xb5, 0xf4, 0xf5, - 0xa2, 0x5a, 0x7a, 0xbe, 0xe4, 0x7a, 0x62, 0x27, 0xb2, 0x34, 0x9b, 0xed, 0x76, 0x77, 0xd9, 0x5f, - 0x9c, 0x93, 0x2b, 0xa2, 0x77, 0x4e, 0x0e, 0xbb, 0x3a, 0x8b, 0xa3, 0x00, 0xb8, 0x35, 0x2c, 0x6f, - 0x17, 0x7e, 0x05, 0x00, 0x00, 0xff, 0xff, 0xed, 0x0b, 0x2a, 0xec, 0x1c, 0x07, 0x00, 0x00, + // 774 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcf, 0x4f, 0xdb, 0x48, + 0x18, 0x8d, 0xc3, 0x82, 0xb4, 0xc3, 0x72, 0x19, 0xf1, 0x23, 0x58, 0xab, 0x2c, 0x58, 0x59, 0x60, + 0x57, 0x60, 0x6f, 0x80, 0xd5, 0x4a, 0xbb, 0x8b, 0xd4, 0xa4, 0x12, 0x14, 0x7a, 0x00, 0x02, 0x08, + 0xa9, 0x52, 0x65, 0x8d, 0xed, 0xc1, 0x58, 0x35, 0x33, 0xc6, 0x33, 0x0e, 0x20, 0xc4, 0xa5, 0x7f, + 0x41, 0xa5, 0x5e, 0x7a, 0xeb, 0xb5, 0xd7, 0xaa, 0xfd, 0x23, 0x38, 0xa2, 0xf6, 0xd2, 0x43, 0x55, + 0x55, 0xa1, 0x7f, 0x48, 0x95, 0xf1, 0x24, 0x76, 0x00, 0x93, 0x80, 0x7a, 0xb3, 0x67, 0xbe, 0xf7, + 0xbe, 0xf7, 0x9e, 0xfd, 0x7d, 0xa0, 0xe4, 0x9c, 0x38, 0xc7, 0x41, 0x48, 0x39, 0xb5, 0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, 0x37, + 0xe1, 0x7a, 0xb6, 0xdf, 0xec, 0x59, 0x6b, 0x4d, 0x9a, 0x47, 0xf6, 0xa8, 0x71, 0x9a, 0x9e, 0x87, + 0x33, 0xf8, 0x59, 0x01, 0x23, 0x37, 0xfe, 0xf9, 0xf0, 0xbf, 0x2e, 0xfa, 0x6f, 0x9b, 0x3b, 0xf5, + 0xff, 0xfb, 0x81, 0xa5, 0xdb, 0x47, 0xc2, 0x6d, 0x15, 0x3e, 0xc8, 0x76, 0x9b, 0x31, 0x8c, 0x57, + 0xec, 0x55, 0x77, 0xcf, 0x1b, 0x45, 0xe5, 0xa2, 0x51, 0x54, 0xbe, 0x36, 0x8a, 0xca, 0x8b, 0xcb, + 0x62, 0xee, 0xe2, 0xb2, 0x98, 0xfb, 0x74, 0x59, 0xcc, 0x3d, 0x59, 0x72, 0x3d, 0xbe, 0x1f, 0x59, + 0xba, 0x4d, 0x0f, 0x3a, 0xbb, 0xd4, 0x17, 0xe7, 0xc4, 0x42, 0x33, 0xda, 0x27, 0xc7, 0x1d, 0x9d, + 0xf9, 0x49, 0x80, 0x99, 0x35, 0x20, 0x6e, 0x17, 0xbe, 0x07, 0x00, 0x00, 0xff, 0xff, 0x6d, 0x51, + 0x19, 0x95, 0xca, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -423,6 +525,8 @@ type QueryClient interface { // Queries information about whether withdrawal and transfers are blocked, and // if so which block they are re-enabled on. GetWithdrawalAndTransfersBlockedInfo(ctx context.Context, in *QueryGetWithdrawalAndTransfersBlockedInfoRequest, opts ...grpc.CallOption) (*QueryGetWithdrawalAndTransfersBlockedInfoResponse, error) + // Queries the collateral pool account address for a perpetual id. + CollateralPoolAddress(ctx context.Context, in *QueryCollateralPoolAddressRequest, opts ...grpc.CallOption) (*QueryCollateralPoolAddressResponse, error) } type queryClient struct { @@ -460,6 +564,15 @@ func (c *queryClient) GetWithdrawalAndTransfersBlockedInfo(ctx context.Context, return out, nil } +func (c *queryClient) CollateralPoolAddress(ctx context.Context, in *QueryCollateralPoolAddressRequest, opts ...grpc.CallOption) (*QueryCollateralPoolAddressResponse, error) { + out := new(QueryCollateralPoolAddressResponse) + err := c.cc.Invoke(ctx, "/dydxprotocol.subaccounts.Query/CollateralPoolAddress", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Queries a Subaccount by id @@ -469,6 +582,8 @@ type QueryServer interface { // Queries information about whether withdrawal and transfers are blocked, and // if so which block they are re-enabled on. GetWithdrawalAndTransfersBlockedInfo(context.Context, *QueryGetWithdrawalAndTransfersBlockedInfoRequest) (*QueryGetWithdrawalAndTransfersBlockedInfoResponse, error) + // Queries the collateral pool account address for a perpetual id. + CollateralPoolAddress(context.Context, *QueryCollateralPoolAddressRequest) (*QueryCollateralPoolAddressResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -484,6 +599,9 @@ func (*UnimplementedQueryServer) SubaccountAll(ctx context.Context, req *QueryAl func (*UnimplementedQueryServer) GetWithdrawalAndTransfersBlockedInfo(ctx context.Context, req *QueryGetWithdrawalAndTransfersBlockedInfoRequest) (*QueryGetWithdrawalAndTransfersBlockedInfoResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetWithdrawalAndTransfersBlockedInfo not implemented") } +func (*UnimplementedQueryServer) CollateralPoolAddress(ctx context.Context, req *QueryCollateralPoolAddressRequest) (*QueryCollateralPoolAddressResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CollateralPoolAddress not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -543,6 +661,24 @@ func _Query_GetWithdrawalAndTransfersBlockedInfo_Handler(srv interface{}, ctx co return interceptor(ctx, in, info, handler) } +func _Query_CollateralPoolAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryCollateralPoolAddressRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).CollateralPoolAddress(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dydxprotocol.subaccounts.Query/CollateralPoolAddress", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).CollateralPoolAddress(ctx, req.(*QueryCollateralPoolAddressRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "dydxprotocol.subaccounts.Query", HandlerType: (*QueryServer)(nil), @@ -559,6 +695,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "GetWithdrawalAndTransfersBlockedInfo", Handler: _Query_GetWithdrawalAndTransfersBlockedInfo_Handler, }, + { + MethodName: "CollateralPoolAddress", + Handler: _Query_CollateralPoolAddress_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "dydxprotocol/subaccounts/query.proto", @@ -782,6 +922,64 @@ func (m *QueryGetWithdrawalAndTransfersBlockedInfoResponse) MarshalToSizedBuffer return len(dAtA) - i, nil } +func (m *QueryCollateralPoolAddressRequest) 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 *QueryCollateralPoolAddressRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCollateralPoolAddressRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PerpetualId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PerpetualId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryCollateralPoolAddressResponse) 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 *QueryCollateralPoolAddressResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCollateralPoolAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CollateralPoolAddress) > 0 { + i -= len(m.CollateralPoolAddress) + copy(dAtA[i:], m.CollateralPoolAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.CollateralPoolAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -882,6 +1080,31 @@ func (m *QueryGetWithdrawalAndTransfersBlockedInfoResponse) Size() (n int) { return n } +func (m *QueryCollateralPoolAddressRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PerpetualId != 0 { + n += 1 + sovQuery(uint64(m.PerpetualId)) + } + return n +} + +func (m *QueryCollateralPoolAddressResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.CollateralPoolAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1454,6 +1677,157 @@ func (m *QueryGetWithdrawalAndTransfersBlockedInfoResponse) Unmarshal(dAtA []byt } return nil } +func (m *QueryCollateralPoolAddressRequest) 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: QueryCollateralPoolAddressRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryCollateralPoolAddressRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PerpetualId", wireType) + } + m.PerpetualId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PerpetualId |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 *QueryCollateralPoolAddressResponse) 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: QueryCollateralPoolAddressResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryCollateralPoolAddressResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CollateralPoolAddress", 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.CollateralPoolAddress = 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 skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/protocol/x/subaccounts/types/query.pb.gw.go b/protocol/x/subaccounts/types/query.pb.gw.go index 9aebee906d..cf3f87be63 100644 --- a/protocol/x/subaccounts/types/query.pb.gw.go +++ b/protocol/x/subaccounts/types/query.pb.gw.go @@ -145,19 +145,26 @@ func local_request_Query_SubaccountAll_0(ctx context.Context, marshaler runtime. } -var ( - filter_Query_GetWithdrawalAndTransfersBlockedInfo_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - func request_Query_GetWithdrawalAndTransfersBlockedInfo_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryGetWithdrawalAndTransfersBlockedInfoRequest var metadata runtime.ServerMetadata - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["perpetual_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "perpetual_id") } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GetWithdrawalAndTransfersBlockedInfo_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + + protoReq.PerpetualId, err = runtime.Uint32(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "perpetual_id", err) } msg, err := client.GetWithdrawalAndTransfersBlockedInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) @@ -169,11 +176,22 @@ func local_request_Query_GetWithdrawalAndTransfersBlockedInfo_0(ctx context.Cont var protoReq QueryGetWithdrawalAndTransfersBlockedInfoRequest var metadata runtime.ServerMetadata - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["perpetual_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "perpetual_id") } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GetWithdrawalAndTransfersBlockedInfo_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + + protoReq.PerpetualId, err = runtime.Uint32(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "perpetual_id", err) } msg, err := server.GetWithdrawalAndTransfersBlockedInfo(ctx, &protoReq) @@ -181,6 +199,60 @@ func local_request_Query_GetWithdrawalAndTransfersBlockedInfo_0(ctx context.Cont } +func request_Query_CollateralPoolAddress_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCollateralPoolAddressRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["perpetual_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "perpetual_id") + } + + protoReq.PerpetualId, err = runtime.Uint32(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "perpetual_id", err) + } + + msg, err := client.CollateralPoolAddress(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_CollateralPoolAddress_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCollateralPoolAddressRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["perpetual_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "perpetual_id") + } + + protoReq.PerpetualId, err = runtime.Uint32(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "perpetual_id", err) + } + + msg, err := server.CollateralPoolAddress(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. @@ -256,6 +328,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_CollateralPoolAddress_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_CollateralPoolAddress_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_CollateralPoolAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -357,6 +452,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_CollateralPoolAddress_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_CollateralPoolAddress_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_CollateralPoolAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -365,7 +480,9 @@ var ( pattern_Query_SubaccountAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"dydxprotocol", "subaccounts", "subaccount"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_GetWithdrawalAndTransfersBlockedInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"dydxprotocol", "subaccounts", "withdrawals_and_transfers_blocked_info"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_GetWithdrawalAndTransfersBlockedInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"dydxprotocol", "subaccounts", "withdrawals_and_transfers_blocked_info", "perpetual_id"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_CollateralPoolAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"dydxprotocol", "subaccounts", "collateral_pool_address", "perpetual_id"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -374,4 +491,6 @@ var ( forward_Query_SubaccountAll_0 = runtime.ForwardResponseMessage forward_Query_GetWithdrawalAndTransfersBlockedInfo_0 = runtime.ForwardResponseMessage + + forward_Query_CollateralPoolAddress_0 = runtime.ForwardResponseMessage )