-
Notifications
You must be signed in to change notification settings - Fork 204
Expand file tree
/
Copy pathChainGrpcAuctionApi.ts
More file actions
77 lines (61 loc) · 2.79 KB
/
ChainGrpcAuctionApi.ts
File metadata and controls
77 lines (61 loc) · 2.79 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import * as InjectiveAuctionV1Beta1QueryPb from '@injectivelabs/core-proto-ts-v2/generated/injective/auction/v1beta1/query_pb'
import { QueryClient as InjectiveAuctionV1Beta1QueryClient } from '@injectivelabs/core-proto-ts-v2/generated/injective/auction/v1beta1/query_pb.client'
import { ChainModule } from '../types/index.js'
import BaseGrpcConsumer from '../../base/BaseGrpcConsumer.js'
import { ChainGrpcAuctionTransformer } from '../transformers/index.js'
import type { GrpcWebTransportAdditionalOptions } from '../../../utils/grpc.js'
/**
* @category Chain Grpc API
*/
export class ChainGrpcAuctionApi extends BaseGrpcConsumer {
protected module: string = ChainModule.Auction
private client: InjectiveAuctionV1Beta1QueryClient
constructor(endpoint: string, options?: GrpcWebTransportAdditionalOptions) {
super(endpoint, options)
this.client = new InjectiveAuctionV1Beta1QueryClient(this.transport)
}
async fetchModuleParams() {
const request =
InjectiveAuctionV1Beta1QueryPb.QueryAuctionParamsRequest.create()
const response = await this.executeGrpcCall<
InjectiveAuctionV1Beta1QueryPb.QueryAuctionParamsRequest,
InjectiveAuctionV1Beta1QueryPb.QueryAuctionParamsResponse
>(request, this.client.auctionParams.bind(this.client))
return ChainGrpcAuctionTransformer.moduleParamsResponseToModuleParams(
response,
)
}
async fetchCurrentBasket() {
const request =
InjectiveAuctionV1Beta1QueryPb.QueryCurrentAuctionBasketRequest.create()
const response = await this.executeGrpcCall<
InjectiveAuctionV1Beta1QueryPb.QueryCurrentAuctionBasketRequest,
InjectiveAuctionV1Beta1QueryPb.QueryCurrentAuctionBasketResponse
>(request, this.client.currentAuctionBasket.bind(this.client))
return ChainGrpcAuctionTransformer.currentBasketResponseToCurrentBasket(
response,
)
}
async fetchModuleState() {
const request =
InjectiveAuctionV1Beta1QueryPb.QueryModuleStateRequest.create()
const response = await this.executeGrpcCall<
InjectiveAuctionV1Beta1QueryPb.QueryModuleStateRequest,
InjectiveAuctionV1Beta1QueryPb.QueryModuleStateResponse
>(request, this.client.auctionModuleState.bind(this.client))
return ChainGrpcAuctionTransformer.auctionModuleStateResponseToAuctionModuleState(
response,
)
}
async fetchLastAuctionResult() {
const request =
InjectiveAuctionV1Beta1QueryPb.QueryLastAuctionResultRequest.create()
const response = await this.executeGrpcCall<
InjectiveAuctionV1Beta1QueryPb.QueryLastAuctionResultRequest,
InjectiveAuctionV1Beta1QueryPb.QueryLastAuctionResultResponse
>(request, this.client.lastAuctionResult.bind(this.client))
return ChainGrpcAuctionTransformer.lastAuctionResultResponseToLastAuctionResult(
response,
)
}
}