Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,343 changes: 1,343 additions & 0 deletions docs/workflows/align-proto-workflow.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
"publish:core-proto-ts": "./protoV2/core/publish.sh",
"generate:abacus-proto-ts": "./protoV2/abacus/gen.sh",
"publish:abacus-proto-ts": "./protoV2/abacus/publish.sh",
"generate:tc-abacus-proto-ts": "./protoV2/tcAbacus/gen.sh",
"publish:tc-abacus-proto-ts": "./protoV2/tcAbacus/publish.sh",
"generate:indexer-proto-ts": "./protoV2/indexer/gen.sh",
"publish:indexer-proto-ts": "./protoV2/indexer/publish.sh",
"release:patch": "pnpm build:fresh && lerna version patch --conventional-commits --force-git-tag --yes && pnpm publish -r --access public --tag latest --no-git-checks",
Expand Down
1 change: 1 addition & 0 deletions packages/exceptions/src/exceptions/types/modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const IndexerErrorModule = {
Derivatives: 'indexer-derivatives',
Transaction: 'indexer-transaction',
ChronosSpot: 'indexer-chronos-spot',
TcDerivatives: 'indexer-tc-derivatives',
InsuranceFund: 'indexer-insurance-fund',
ChronosMarkets: 'indexer-chronos-markets',
ChronosDerivative: 'indexer-chronos-derivative',
Expand Down
25 changes: 23 additions & 2 deletions packages/sdk-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,26 @@
"default": "./dist/cjs/client/olp.cjs"
}
},
"./client/tcAbacus": {
"react-native": {
"import": "./dist/esm/client/tcAbacus.js",
"require": "./dist/cjs/client/tcAbacus.cjs",
"types": "./dist/cjs/client/tcAbacus.d.cts",
"default": "./dist/cjs/client/tcAbacus.cjs"
},
"require": {
"types": "./dist/cjs/client/tcAbacus.d.cts",
"default": "./dist/cjs/client/tcAbacus.cjs"
},
"import": {
"types": "./dist/esm/client/tcAbacus.d.ts",
"default": "./dist/esm/client/tcAbacus.js"
},
"default": {
"types": "./dist/cjs/client/tcAbacus.d.cts",
"default": "./dist/cjs/client/tcAbacus.cjs"
}
},
"./core/modules": {
"react-native": {
"import": "./dist/esm/core/modules.js",
Expand Down Expand Up @@ -322,13 +342,14 @@
"@cosmjs/amino": "catalog:",
"@cosmjs/proto-signing": "catalog:",
"@cosmjs/stargate": "catalog:",
"@injectivelabs/abacus-proto-ts-v2": "1.17.4",
"@injectivelabs/abacus-proto-ts-v2": "1.17.5",
"@injectivelabs/tc-abacus-proto-ts-v2": "1.18.1",
"@injectivelabs/core-proto-ts-v2": "1.18.0",
"@injectivelabs/exceptions": "workspace:*",
"@injectivelabs/grpc-web": "^0.0.1",
"@injectivelabs/grpc-web-node-http-transport": "^0.0.2",
"@injectivelabs/grpc-web-react-native-transport": "^0.0.2",
"@injectivelabs/indexer-proto-ts-v2": "1.18.6",
"@injectivelabs/indexer-proto-ts-v2": "1.18.9",
"@injectivelabs/mito-proto-ts-v2": "1.17.3",
"@injectivelabs/networks": "workspace:*",
"@injectivelabs/olp-proto-ts-v2": "1.17.6",
Expand Down
1 change: 1 addition & 0 deletions packages/sdk-ts/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from './wasm/index.js'
export * from './chain/index.js'
export * from './abacus/index.js'
export * from './indexer/index.js'
export * from './tcAbacus/index.js'
167 changes: 167 additions & 0 deletions packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcTcDerivativesApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
import * as InjectiveTCDerivativesRpcPb from '@injectivelabs/indexer-proto-ts-v2/generated/injective_tc_derivatives_rpc_pb'
import { InjectiveTCDerivativesRPCClient } from '@injectivelabs/indexer-proto-ts-v2/generated/injective_tc_derivatives_rpc_pb.client'
import { IndexerModule } from '../types/index.js'
import BaseIndexerGrpcConsumer from '../../base/BaseIndexerGrpcConsumer.js'
import { IndexerGrpcTcDerivativesTransformer } from '../transformers/index.js'

/**
* @category Indexer Grpc API
*/
export class IndexerGrpcTcDerivativesApi extends BaseIndexerGrpcConsumer {
protected module: string = IndexerModule.TcDerivatives

private get client() {
return this.initClient(InjectiveTCDerivativesRPCClient)
}

async fetchOrdersHistory(params?: {
token?: string
perPage?: number
marketId?: string
direction?: string
}) {
const { marketId, direction, perPage, token } = params || {}

const request = InjectiveTCDerivativesRpcPb.OrdersHistoryRequest.create()

if (marketId) {
request.marketIds = [marketId]
}

if (direction) {
request.direction = direction
}

if (perPage) {
request.perPage = perPage
}

if (token) {
request.token = token
}

const response = await this.executeGrpcCall<
InjectiveTCDerivativesRpcPb.OrdersHistoryRequest,
InjectiveTCDerivativesRpcPb.OrdersHistoryResponse
>(request, this.client.ordersHistory.bind(this.client))

return IndexerGrpcTcDerivativesTransformer.ordersHistoryResponseToOrdersHistory(
response,
)
}

async fetchTradesHistory(params?: {
token?: string
perPage?: number
marketId?: string
direction?: string
}) {
const { marketId, direction, perPage, token } = params || {}

const request = InjectiveTCDerivativesRpcPb.TradesRequest.create()

if (marketId) {
request.marketIds = [marketId]
}

if (direction) {
request.direction = direction
}

if (perPage) {
request.perPage = perPage
}

if (token) {
request.token = token
}

const response = await this.executeGrpcCall<
InjectiveTCDerivativesRpcPb.TradesRequest,
InjectiveTCDerivativesRpcPb.TradesResponse
>(request, this.client.trades.bind(this.client))

return IndexerGrpcTcDerivativesTransformer.tradesResponseToTrades(response)
}

async fetchPositions(params?: {
token?: string
perPage?: number
marketId?: string
direction?: string
withCount?: boolean
accountAddress?: string
}) {
const { marketId, direction, perPage, token, accountAddress, withCount } =
params || {}

const request = InjectiveTCDerivativesRpcPb.PositionsRequest.create()

if (marketId) {
request.marketIds = [marketId]
}

if (direction) {
request.direction = direction
}

if (accountAddress) {
request.accountAddress = accountAddress
}

if (withCount !== undefined) {
request.withCount = withCount
}

if (perPage) {
request.perPage = perPage
}

if (token) {
request.token = token
}

const response = await this.executeGrpcCall<
InjectiveTCDerivativesRpcPb.PositionsRequest,
InjectiveTCDerivativesRpcPb.PositionsResponse
>(request, this.client.positions.bind(this.client))

return IndexerGrpcTcDerivativesTransformer.positionsResponseToPositions(
response,
)
}

async fetchOrders(params?: {
token?: string
perPage?: number
marketId?: string
direction?: string
}) {
const { marketId, direction, perPage, token } = params || {}

const request = InjectiveTCDerivativesRpcPb.OrdersRequest.create()

if (marketId) {
request.marketIds = [marketId]
}

if (direction) {
request.direction = direction
}

if (perPage) {
request.perPage = perPage
}

if (token) {
request.token = token
}

const response = await this.executeGrpcCall<
InjectiveTCDerivativesRpcPb.OrdersRequest,
InjectiveTCDerivativesRpcPb.OrdersResponse
>(request, this.client.orders.bind(this.client))

return IndexerGrpcTcDerivativesTransformer.ordersResponseToOrders(response)
}
}
1 change: 1 addition & 0 deletions packages/sdk-ts/src/client/indexer/grpc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ export { IndexerGrpcMegaVaultApi } from './IndexerGrpcMegaVaultApi.js'
export { IndexerGrpcDerivativesApi } from './IndexerGrpcDerivativesApi.js'
export { IndexerGrpcTransactionApi } from './IndexerGrpcTransactionApi.js'
export { IndexerGrpcAccountPortfolioApi } from './IndexerGrpcPortfolioApi.js'
export { IndexerGrpcTcDerivativesApi } from './IndexerGrpcTcDerivativesApi.js'
export { IndexerGrpcInsuranceFundApi } from './IndexerGrpcInsuranceFundApi.js'
1 change: 1 addition & 0 deletions packages/sdk-ts/src/client/indexer/grpc_stream/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export * from './streamV2/IndexerGrpcTradingStreamV2.js'
export * from './streamV2/IndexerGrpcArchiverStreamV2.js'
export * from './streamV2/IndexerGrpcExplorerStreamV2.js'
export * from './streamV2/IndexerGrpcDerivativesStreamV2.js'
export * from './streamV2/IndexerGrpcTcDerivativesStreamV2.js'
export * from './streamV2/IndexerGrpcAccountPortfolioStreamV2.js'

export * from './streamV2/StreamManagerV2.js'
Expand Down
Loading