/
protocol.ts
192 lines (167 loc) · 4.22 KB
/
protocol.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
/**
* NEAR RPC API request types and responses
* @module
*/
export interface SyncInfo {
latest_block_hash: string;
latest_block_height: number;
latest_block_time: string;
latest_state_root: string;
syncing: boolean;
}
interface Version {
version: string;
build: string;
}
export interface NodeStatusResult {
chain_id: string;
rpc_addr: string;
sync_info: SyncInfo;
validators: string[];
version: Version;
}
export type BlockHash = string;
export type BlockHeight = number;
export type BlockId = BlockHash | BlockHeight;
export type Finality = 'optimistic' | 'near-final' | 'final'
export type TxExecutionStatus = 'NONE' | 'INCLUDED' | 'INCLUDED_FINAL' | 'EXECUTED' | 'FINAL';
export type BlockReference = { blockId: BlockId } | { finality: Finality } | { sync_checkpoint: 'genesis' | 'earliest_available' }
export interface TotalWeight {
num: number;
}
export interface BlockHeader {
height: number;
epoch_id: string;
next_epoch_id: string;
hash: string;
prev_hash: string;
prev_state_root: string;
chunk_receipts_root: string;
chunk_headers_root: string;
chunk_tx_root: string;
outcome_root: string;
chunks_included: number;
challenges_root: string;
timestamp: number;
timestamp_nanosec: string;
random_value: string;
validator_proposals: any[];
chunk_mask: boolean[];
gas_price: string;
rent_paid: string;
validator_reward: string;
total_supply: string;
challenges_result: any[];
last_final_block: string;
last_ds_final_block: string;
next_bp_hash: string;
block_merkle_root: string;
approvals: string[];
signature: string;
latest_protocol_version: number;
}
export type ChunkHash = string;
export type ShardId = number;
export type BlockShardId = [BlockId, ShardId];
export type ChunkId = ChunkHash | BlockShardId;
export interface ChunkHeader {
balance_burnt: string;
chunk_hash: ChunkHash;
encoded_length: number;
encoded_merkle_root: string;
gas_limit: number;
gas_used: number;
height_created: number;
height_included: number;
outcome_root: string;
outgoing_receipts_root: string;
prev_block_hash: string;
prev_state_root: string;
rent_paid: string;
shard_id: number;
signature: string;
tx_root: string;
validator_proposals: any[];
validator_reward: string;
}
export interface ChunkResult {
author: string;
header: ChunkHeader;
receipts: any[];
transactions: Transaction[];
}
export interface Chunk {
chunk_hash: string;
prev_block_hash: string;
outcome_root: string;
prev_state_root: string;
encoded_merkle_root: string;
encoded_length: number;
height_created: number;
height_included: number;
shard_id: number;
gas_used: number;
gas_limit: number;
rent_paid: string;
validator_reward: string;
balance_burnt: string;
outgoing_receipts_root: string;
tx_root: string;
validator_proposals: any[];
signature: string;
}
export interface Transaction {
actions: Array<any>;
hash: string;
nonce: BigInt;
public_key: string;
receiver_id: string;
signature: string;
signer_id: string;
}
export interface BlockResult {
author: string;
header: BlockHeader;
chunks: Chunk[];
}
export interface BlockChange {
type: string;
account_id: string;
}
export interface BlockChangeResult {
block_hash: string;
changes: BlockChange[];
}
export interface ChangeResult {
block_hash: string;
changes: any[];
}
export interface NearProtocolConfig {
runtime_config: NearProtocolRuntimeConfig;
}
export interface NearProtocolRuntimeConfig {
storage_amount_per_byte: string;
}
export interface MerkleNode {
hash: string;
direction: string;
}
export type MerklePath = MerkleNode[];
export interface BlockHeaderInnerLiteView {
height: number;
epoch_id: string;
next_epoch_id: string;
prev_state_root: string;
outcome_root: string;
timestamp: number;
timestamp_nanosec: string;
next_bp_hash: string;
block_merkle_root: string;
}
export interface GasPrice {
gas_price: string;
}
export interface AccessKeyWithPublicKey {
account_id: string;
public_key: string;
}