-
Notifications
You must be signed in to change notification settings - Fork 18
/
requests.d.ts
151 lines (151 loc) · 3.88 KB
/
requests.d.ts
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import { As } from "type-tagger";
/**
* RPC methods as documented in https://tendermint.com/rpc/
*
* Enum raw value must match the spelling in the "shell" example call (snake_case)
*/
export declare enum Method {
AbciInfo = "abci_info",
AbciQuery = "abci_query",
Block = "block",
Blockchain = "blockchain",
BlockResults = "block_results",
BroadcastTxAsync = "broadcast_tx_async",
BroadcastTxSync = "broadcast_tx_sync",
BroadcastTxCommit = "broadcast_tx_commit",
Commit = "commit",
Genesis = "genesis",
Health = "health",
Status = "status",
Subscribe = "subscribe",
Tx = "tx",
TxSearch = "tx_search",
Validators = "validators",
Unsubscribe = "unsubscribe",
}
export declare type Request =
| AbciInfoRequest
| AbciQueryRequest
| BlockRequest
| BlockchainRequest
| BlockResultsRequest
| BroadcastTxRequest
| CommitRequest
| GenesisRequest
| HealthRequest
| StatusRequest
| TxRequest
| TxSearchRequest
| ValidatorsRequest;
/**
* Raw values must match the tendermint event name
*
* @see https://godoc.org/github.com/tendermint/tendermint/types#pkg-constants
*/
export declare enum SubscriptionEventType {
NewBlock = "NewBlock",
NewBlockHeader = "NewBlockHeader",
Tx = "Tx",
}
export interface AbciInfoRequest {
readonly method: Method.AbciInfo;
}
export interface AbciQueryRequest {
readonly method: Method.AbciQuery;
readonly params: AbciQueryParams;
}
export interface AbciQueryParams {
readonly path: string;
readonly data: Uint8Array;
readonly height?: number;
/**
* A flag that defines if proofs are included in the response or not.
*
* Internally this is mapped to the old inverse name `trusted` for Tendermint < 0.26.
* Starting with Tendermint 0.26, the default value changed from true to false.
*/
readonly prove?: boolean;
}
export interface BlockRequest {
readonly method: Method.Block;
readonly params: {
readonly height?: number;
};
}
export interface BlockchainRequest {
readonly method: Method.Blockchain;
readonly params: BlockchainRequestParams;
}
export interface BlockchainRequestParams {
readonly minHeight?: number;
readonly maxHeight?: number;
}
export interface BlockResultsRequest {
readonly method: Method.BlockResults;
readonly params: {
readonly height?: number;
};
}
export interface BroadcastTxRequest {
readonly method: Method.BroadcastTxAsync | Method.BroadcastTxSync | Method.BroadcastTxCommit;
readonly params: BroadcastTxParams;
}
export interface BroadcastTxParams {
readonly tx: Uint8Array;
}
export interface CommitRequest {
readonly method: Method.Commit;
readonly params: {
readonly height?: number;
};
}
export interface GenesisRequest {
readonly method: Method.Genesis;
}
export interface HealthRequest {
readonly method: Method.Health;
}
export interface StatusRequest {
readonly method: Method.Status;
}
export interface SubscribeRequest {
readonly method: Method.Subscribe;
readonly query: {
readonly type: SubscriptionEventType;
readonly raw?: QueryString;
};
}
export declare type QueryString = string & As<"query">;
export interface QueryTag {
readonly key: string;
readonly value: string;
}
export interface TxRequest {
readonly method: Method.Tx;
readonly params: TxParams;
}
export interface TxParams {
readonly hash: Uint8Array;
readonly prove?: boolean;
}
export interface TxSearchRequest {
readonly method: Method.TxSearch;
readonly params: TxSearchParams;
}
export interface TxSearchParams {
readonly query: QueryString;
readonly prove?: boolean;
readonly page?: number;
readonly per_page?: number;
}
export interface ValidatorsRequest {
readonly method: Method.Validators;
readonly params: {
readonly height?: number;
};
}
export interface BuildQueryComponents {
readonly tags?: readonly QueryTag[];
readonly raw?: QueryString;
}
export declare function buildQuery(components: BuildQueryComponents): QueryString;