-
Notifications
You must be signed in to change notification settings - Fork 18
/
responses.d.ts
262 lines (262 loc) · 7.28 KB
/
responses.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
import { ReadonlyDate } from "readonly-date";
import { IpPortString, TxBytes, TxHash, ValidatorPubkey, ValidatorSignature } from "./types";
export declare type Response =
| AbciInfoResponse
| AbciQueryResponse
| BlockResponse
| BlockResultsResponse
| BlockchainResponse
| BroadcastTxAsyncResponse
| BroadcastTxSyncResponse
| BroadcastTxCommitResponse
| CommitResponse
| GenesisResponse
| HealthResponse
| StatusResponse
| TxResponse
| TxSearchResponse
| ValidatorsResponse;
export interface AbciInfoResponse {
readonly data?: string;
readonly lastBlockHeight?: number;
readonly lastBlockAppHash?: Uint8Array;
}
export interface AbciQueryResponse {
readonly key: Uint8Array;
readonly value: Uint8Array;
readonly height?: number;
readonly index?: number;
readonly code?: number;
readonly log?: string;
}
export interface BlockResponse {
readonly blockMeta: BlockMeta;
readonly block: Block;
}
export interface BlockResultsResponse {
readonly height: number;
readonly results: readonly TxData[];
readonly endBlock: {
readonly validatorUpdates: readonly Validator[];
readonly consensusUpdates?: ConsensusParams;
readonly tags?: readonly Tag[];
};
}
export interface BlockchainResponse {
readonly lastHeight: number;
readonly blockMetas: readonly BlockMeta[];
}
/** No data in here because RPC method BroadcastTxAsync "returns right away, with no response" */
export interface BroadcastTxAsyncResponse {}
export interface BroadcastTxSyncResponse extends TxData {
readonly hash: TxHash;
}
/**
* Returns true iff transaction made it sucessfully into the transaction pool
*/
export declare function broadcastTxSyncSuccess(res: BroadcastTxSyncResponse): boolean;
export interface BroadcastTxCommitResponse {
readonly height?: number;
readonly hash: TxHash;
readonly checkTx: TxData;
readonly deliverTx?: TxData;
}
/**
* Returns true iff transaction made it sucessfully into a block
* (i.e. sucess in `check_tx` and `deliver_tx` field)
*/
export declare function broadcastTxCommitSuccess(res: BroadcastTxCommitResponse): boolean;
export interface CommitResponse {
readonly header: Header;
readonly commit: Commit;
readonly canonical: boolean;
}
export interface GenesisResponse {
readonly genesisTime: ReadonlyDate;
readonly chainId: string;
readonly consensusParams: ConsensusParams;
readonly validators: readonly Validator[];
readonly appHash: Uint8Array;
readonly appState: {} | undefined;
}
export declare type HealthResponse = null;
export interface StatusResponse {
readonly nodeInfo: NodeInfo;
readonly syncInfo: SyncInfo;
readonly validatorInfo: Validator;
}
/**
* A transaction from RPC calls like search.
*
* Try to keep this compatible to TxEvent
*/
export interface TxResponse {
readonly tx: TxBytes;
readonly hash: TxHash;
readonly height: number;
readonly index: number;
readonly result: TxData;
readonly proof?: TxProof;
}
export interface TxSearchResponse {
readonly txs: readonly TxResponse[];
readonly totalCount: number;
}
export interface ValidatorsResponse {
readonly blockHeight: number;
readonly results: readonly Validator[];
}
export interface NewBlockEvent extends Block {}
export interface NewBlockHeaderEvent extends Header {}
export interface TxEvent {
readonly tx: TxBytes;
readonly hash: TxHash;
readonly height: number;
readonly index: number;
readonly result: TxData;
}
export declare const getTxEventHeight: (event: TxEvent) => number;
export declare const getHeaderEventHeight: (event: NewBlockHeaderEvent) => number;
export declare const getBlockEventHeight: (event: NewBlockEvent) => number;
export interface Tag {
readonly key: Uint8Array;
readonly value: Uint8Array;
}
export interface Event {
readonly type: string;
readonly attributes: readonly Tag[];
}
export interface TxData {
readonly code: number;
readonly log?: string;
readonly data?: Uint8Array;
readonly tags?: readonly Tag[];
readonly events?: readonly Event[];
}
export interface TxProof {
readonly data: Uint8Array;
readonly rootHash: Uint8Array;
readonly proof: {
readonly total: number;
readonly index: number;
/** Optional because does not exist in Tendermint 0.25.x */
readonly leafHash?: Uint8Array;
readonly aunts: readonly Uint8Array[];
};
}
export interface BlockMeta {
readonly blockId: BlockId;
readonly header: Header;
}
export interface BlockId {
readonly hash: Uint8Array;
readonly parts: {
readonly total: number;
readonly hash: Uint8Array;
};
}
export interface Block {
readonly header: Header;
readonly lastCommit: Commit;
readonly txs: readonly Uint8Array[];
readonly evidence?: readonly Evidence[];
}
export interface Evidence {
readonly type: string;
readonly validator: Validator;
readonly height: number;
readonly time: number;
readonly totalVotingPower: number;
}
export interface Commit {
readonly blockId: BlockId;
readonly precommits: readonly Vote[];
}
/**
* raw values from https://github.com/tendermint/tendermint/blob/dfa9a9a30a666132425b29454e90a472aa579a48/types/vote.go#L44
*/
export declare enum VoteType {
PREVOTE = 1,
PRECOMMIT = 2,
}
export interface Vote {
readonly type: VoteType;
readonly validatorAddress: Uint8Array;
readonly validatorIndex: number;
readonly height: number;
readonly round: number;
readonly timestamp: ReadonlyDate;
readonly blockId: BlockId;
readonly signature: ValidatorSignature;
}
export interface Version {
readonly block: number;
readonly app: number;
}
export interface ReadonlyDateWithNanoseconds extends ReadonlyDate {
readonly nanoseconds?: number;
}
export interface Header {
readonly version: Version;
readonly chainId: string;
readonly height: number;
readonly time: ReadonlyDateWithNanoseconds;
readonly numTxs: number;
readonly totalTxs: number;
readonly lastBlockId: BlockId;
readonly lastCommitHash: Uint8Array;
readonly dataHash: Uint8Array;
readonly validatorsHash: Uint8Array;
readonly nextValidatorsHash: Uint8Array;
readonly consensusHash: Uint8Array;
readonly appHash: Uint8Array;
readonly lastResultsHash: Uint8Array;
readonly evidenceHash: Uint8Array;
readonly proposerAddress: Uint8Array;
}
export interface NodeInfo {
readonly id: Uint8Array;
readonly listenAddr: IpPortString;
readonly network: string;
readonly version: string;
readonly channels: string;
readonly moniker: string;
readonly other: Map<string, string>;
readonly protocolVersion: {
readonly p2p: number;
readonly block: number;
readonly app: number;
};
}
export interface SyncInfo {
readonly latestBlockHash: Uint8Array;
readonly latestAppHash: Uint8Array;
readonly latestBlockHeight: number;
readonly latestBlockTime: ReadonlyDate;
readonly catchingUp: boolean;
}
export interface Validator {
readonly address?: Uint8Array;
readonly pubkey: ValidatorPubkey;
readonly votingPower: number;
readonly accum?: number;
readonly name?: string;
}
export interface ConsensusParams {
readonly block: BlockParams;
readonly evidence: EvidenceParams;
}
export interface BlockParams {
readonly maxBytes: number;
readonly maxGas: number;
}
export interface TxSizeParams {
readonly maxBytes: number;
readonly maxGas: number;
}
export interface BlockGossipParams {
readonly blockPartSizeBytes: number;
}
export interface EvidenceParams {
readonly maxAge: number;
}