Skip to content

Commit

Permalink
feat: exchange module state
Browse files Browse the repository at this point in the history
  • Loading branch information
bangjelkoski committed May 17, 2022
1 parent cd5d037 commit ab8fcd2
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/sdk-ts/src/client/chain/grpc/AuthApi.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { Query as AuthQuery } from '@injectivelabs/chain-api/cosmos/auth/v1beta1/query_pb_service'
import {
QueryAccountRequest,
QueryAccountsRequest,
QueryAccountsResponse,
QueryAccountResponse,
} from '@injectivelabs/chain-api/cosmos/auth/v1beta1/query_pb'
import BaseConsumer from '../../BaseGrpcConsumer'
import { PaginationOption } from '../../../types/pagination'
import { paginationRequestFromPagination } from '../../../utils/pagination'

export class AuthApi extends BaseConsumer {
async fetchAccount(address: string) {
Expand All @@ -22,4 +26,25 @@ export class AuthApi extends BaseConsumer {
throw new Error(e.message)
}
}

async fetchAccounts(pagination?: PaginationOption) {
const request = new QueryAccountsRequest()
const paginationForRequest = paginationRequestFromPagination(pagination)

if (paginationForRequest) {
request.setPagination(paginationForRequest)
}

try {
const response = await this.request<
QueryAccountsRequest,
QueryAccountsResponse,
typeof AuthQuery.Accounts
>(request, AuthQuery.Accounts)

return response
} catch (e: any) {
throw new Error(e.message)
}
}
}
18 changes: 18 additions & 0 deletions packages/sdk-ts/src/client/chain/grpc/ExchangeApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
QueryTradeRewardCampaignRequest,
QueryFeeDiscountAccountInfoRequest,
QueryTradeRewardPointsRequest,
QueryModuleStateRequest,
QueryModuleStateResponse,
QueryTradeRewardPointsResponse,
QueryFeeDiscountAccountInfoResponse,
QueryTradeRewardCampaignResponse,
Expand Down Expand Up @@ -34,6 +36,22 @@ export class ExchangeApi extends BaseConsumer {
}
}

async fetchModuleState() {
const request = new QueryModuleStateRequest()

try {
const response = await this.request<
QueryModuleStateRequest,
QueryModuleStateResponse,
typeof ExchangeQuery.ExchangeModuleState
>(request, ExchangeQuery.ExchangeModuleState)

return response
} catch (e: any) {
throw new Error(e.message)
}
}

async fetchFeeDiscountSchedule() {
const request = new QueryFeeDiscountScheduleRequest()

Expand Down

0 comments on commit ab8fcd2

Please sign in to comment.