Skip to content

Commit

Permalink
Merge pull request #532 from Grinion/order-cid
Browse files Browse the repository at this point in the history
Add support CID for fetchOrders/fetchTrades
  • Loading branch information
bangjelkoski authored Dec 23, 2024
2 parents eae2469 + 3d656ac commit fee6851
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ export class IndexerGrpcDerivativesApi extends BaseGrpcConsumer {
orderSide?: OrderSide
isConditional?: boolean
subaccountId?: string
pagination?: PaginationOption
pagination?: PaginationOption,
cid?: string
}) {
const {
marketId,
Expand All @@ -212,6 +213,7 @@ export class IndexerGrpcDerivativesApi extends BaseGrpcConsumer {
orderSide,
isConditional,
pagination,
cid,
} = params || {}

const request = InjectiveDerivativeExchangeRpc.OrdersRequest.create()
Expand All @@ -236,6 +238,10 @@ export class IndexerGrpcDerivativesApi extends BaseGrpcConsumer {
request.isConditional = isConditional ? 'true' : 'false'
}

if (cid) {
request.cid = cid
}

if (pagination) {
if (pagination.skip !== undefined) {
request.skip = pagination.skip.toString()
Expand Down Expand Up @@ -287,6 +293,7 @@ export class IndexerGrpcDerivativesApi extends BaseGrpcConsumer {
direction?: TradeDirection
isConditional?: boolean
state?: OrderState
cid?: string,
pagination?: PaginationOption
}) {
const {
Expand All @@ -299,6 +306,7 @@ export class IndexerGrpcDerivativesApi extends BaseGrpcConsumer {
isConditional,
state,
pagination,
cid,
} = params || {}

const request = InjectiveDerivativeExchangeRpc.OrdersHistoryRequest.create()
Expand Down Expand Up @@ -335,6 +343,10 @@ export class IndexerGrpcDerivativesApi extends BaseGrpcConsumer {
request.state = state
}

if (cid) {
request.cid = cid
}

if (pagination) {
if (pagination.skip !== undefined) {
request.skip = pagination.skip.toString()
Expand Down Expand Up @@ -546,6 +558,7 @@ export class IndexerGrpcDerivativesApi extends BaseGrpcConsumer {
pagination?: PaginationOption
executionSide?: TradeExecutionSide
executionTypes?: TradeExecutionType[]
cid?: string
}) {
const {
endTime,
Expand All @@ -559,6 +572,7 @@ export class IndexerGrpcDerivativesApi extends BaseGrpcConsumer {
executionSide,
executionTypes,
accountAddress,
cid,
} = params || {}

const request = InjectiveDerivativeExchangeRpc.TradesRequest.create()
Expand Down Expand Up @@ -603,6 +617,10 @@ export class IndexerGrpcDerivativesApi extends BaseGrpcConsumer {
request.endTime = endTime.toString()
}

if (cid) {
request.cid = cid
}

if (pagination) {
if (pagination.skip !== undefined) {
request.skip = pagination.skip.toString()
Expand Down
19 changes: 18 additions & 1 deletion packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcSpotApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ export class IndexerGrpcSpotApi extends BaseGrpcConsumer {
orderSide?: OrderSide
isConditional?: boolean
pagination?: PaginationOption
cid?: string
}) {
const { marketId, marketIds, subaccountId, orderSide, pagination } =
const { marketId, marketIds, subaccountId, orderSide, pagination, cid } =
params || {}
const request = InjectiveSpotExchangeRpc.OrdersRequest.create()

Expand All @@ -142,6 +143,10 @@ export class IndexerGrpcSpotApi extends BaseGrpcConsumer {
request.orderSide = orderSide
}

if (cid) {
request.cid = cid
}

/*
if (isConditional !== undefined) {
request.isConditional =isConditional
Expand Down Expand Up @@ -200,6 +205,7 @@ export class IndexerGrpcSpotApi extends BaseGrpcConsumer {
isConditional?: boolean
state?: OrderState
pagination?: PaginationOption
cid?: string
}) {
const {
subaccountId,
Expand All @@ -210,6 +216,7 @@ export class IndexerGrpcSpotApi extends BaseGrpcConsumer {
direction,
state,
pagination,
cid,
} = params || {}

const request = InjectiveSpotExchangeRpc.OrdersHistoryRequest.create()
Expand Down Expand Up @@ -242,6 +249,10 @@ export class IndexerGrpcSpotApi extends BaseGrpcConsumer {
request.state = state
}

if (cid) {
request.cid = cid
}

/*
if (isConditional !== undefined) {
request.isConditional =isConditional
Expand Down Expand Up @@ -304,6 +315,7 @@ export class IndexerGrpcSpotApi extends BaseGrpcConsumer {
pagination?: PaginationOption
executionSide?: TradeExecutionSide
executionTypes?: TradeExecutionType[]
cid?: string
}) {
const {
endTime,
Expand All @@ -317,6 +329,7 @@ export class IndexerGrpcSpotApi extends BaseGrpcConsumer {
executionSide,
executionTypes,
accountAddress,
cid
} = params || {}

const request = InjectiveSpotExchangeRpc.TradesRequest.create()
Expand Down Expand Up @@ -361,6 +374,10 @@ export class IndexerGrpcSpotApi extends BaseGrpcConsumer {
request.endTime = endTime.toString()
}

if (cid) {
request.cid = cid;
}

if (pagination) {
if (pagination.skip !== undefined) {
request.skip = pagination.skip.toString()
Expand Down

0 comments on commit fee6851

Please sign in to comment.