-
Notifications
You must be signed in to change notification settings - Fork 204
Expand file tree
/
Copy pathChainGrpcIbcApi.ts
More file actions
53 lines (42 loc) · 2.02 KB
/
ChainGrpcIbcApi.ts
File metadata and controls
53 lines (42 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import * as IbcApplicationsTransferV1QueryPb from '@injectivelabs/core-proto-ts-v2/generated/ibc/applications/transfer/v1/query_pb'
import { QueryClient as IbcApplicationsTransferV1QueryClient } from '@injectivelabs/core-proto-ts-v2/generated/ibc/applications/transfer/v1/query_pb.client'
import { ChainModule } from '../types/index.js'
import BaseGrpcConsumer from '../../base/BaseGrpcConsumer.js'
import { ChainGrpcCommonTransformer } from '../transformers/ChainGrpcCommonTransformer.js'
import type { PaginationOption } from '../../../types/pagination.js'
import type { GrpcWebTransportAdditionalOptions } from '../../../utils/grpc.js'
/**
* @category Chain Grpc API
*/
export class ChainGrpcIbcApi extends BaseGrpcConsumer {
protected module: string = ChainModule.Ibc
private client: IbcApplicationsTransferV1QueryClient
constructor(endpoint: string, options?: GrpcWebTransportAdditionalOptions) {
super(endpoint, options)
this.client = new IbcApplicationsTransferV1QueryClient(this.transport)
}
async fetchDenomTrace(hash: string) {
const request =
IbcApplicationsTransferV1QueryPb.QueryDenomTraceRequest.create()
request.hash = hash
const response = await this.executeGrpcCall<
IbcApplicationsTransferV1QueryPb.QueryDenomTraceRequest,
IbcApplicationsTransferV1QueryPb.QueryDenomTraceResponse
>(request, this.client.denomTrace.bind(this.client))
return response.denomTrace!
}
async fetchDenomsTrace(pagination?: PaginationOption) {
const request =
IbcApplicationsTransferV1QueryPb.QueryDenomTracesRequest.create()
const paginationForRequest =
ChainGrpcCommonTransformer.pageRequestToGrpcPageRequestV2(pagination)
if (paginationForRequest) {
request.pagination = paginationForRequest
}
const response = await this.executeGrpcCall<
IbcApplicationsTransferV1QueryPb.QueryDenomTracesRequest,
IbcApplicationsTransferV1QueryPb.QueryDenomTracesResponse
>(request, this.client.denomTraces.bind(this.client))
return response.denomTraces
}
}