-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.go
125 lines (97 loc) · 3.67 KB
/
api.go
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
package web1337
import (
"strconv"
)
/*
Blocks
*/
func (sdk *Web1337) GetBlockByBlockID(blockID string) ([]byte, error) {
return sdk.getRequest("/block/" + blockID)
}
func (sdk *Web1337) GetBlockBySID(shard string, indexInShard uint) ([]byte, error) {
indexInShardStr := strconv.FormatUint(uint64(indexInShard), 10)
return sdk.getRequest("/block_by_sid/" + shard + "/" + indexInShardStr)
}
func (sdk *Web1337) GetLatestNBlocksOnShard(shard string, startIndex uint, limit uint) ([]byte, error) {
startIndexStr := strconv.FormatUint(uint64(startIndex), 10)
limitStr := strconv.FormatUint(uint64(limit), 10)
return sdk.getRequest("/latest_n_blocks/" + shard + "/" + startIndexStr + "/" + limitStr)
}
func (sdk *Web1337) GetVerificationThreadStats() ([]byte, error) {
return sdk.getRequest("/verification_thread_stats")
}
/*
Epochs
*/
func (sdk *Web1337) GetCurrentEpochOnThreads(threadID string) ([]byte, error) {
return sdk.getRequest("/current_epoch/" + threadID)
}
func (sdk *Web1337) GetCurrentShardLeaders() ([]byte, error) {
return sdk.getRequest("/current_shards_leaders")
}
func (sdk *Web1337) GetEpochByIndex(epochIndex uint) ([]byte, error) {
epochIndexStr := strconv.FormatUint(uint64(epochIndex), 10)
return sdk.getRequest("/epoch_by_index/" + epochIndexStr)
}
func (sdk *Web1337) GetVerificationThreadStatsPerEpoch(epochIndex uint) ([]byte, error) {
epochIndexStr := strconv.FormatUint(uint64(epochIndex), 10)
return sdk.getRequest("/verification_thread_stats_per_epoch/" + epochIndexStr)
}
func (sdk *Web1337) GetHistoricalStatsPerEpoch(startIndex uint, limit uint) ([]byte, error) {
startIndexStr := strconv.FormatUint(uint64(startIndex), 10)
limitStr := strconv.FormatUint(uint64(limit), 10)
return sdk.getRequest("/historical_stats_per_epoch/" + startIndexStr + "/" + limitStr)
}
/*
Transactions
*/
func (sdk *Web1337) GetTransactionReceipt(txID string) ([]byte, error) {
return sdk.getRequest("/tx_receipt/" + txID)
}
func (sdk *Web1337) GetTransactionsWithAccount(shardID string, accountID string) ([]byte, error) {
return sdk.getRequest("/txs_list/" + shardID + "/" + accountID)
}
/*
State
*/
func (sdk *Web1337) GetDataFromState(shard string, cellID string) ([]byte, error) {
return sdk.getRequest("/state/" + shard + "/" + cellID)
}
func (sdk *Web1337) GetPoolStats(poolID string) ([]byte, error) {
return sdk.getRequest("/pool_stats/" + poolID)
}
func (sdk *Web1337) GetAccountFromState(shard string, accountID string) ([]byte, error) {
return sdk.getRequest("/account/" + shard + "/" + accountID)
}
/*
Consensus related
*/
func (sdk *Web1337) GetAggregatedFinalizationProof(blockID string) ([]byte, error) {
return sdk.getRequest("/aggregated_finalization_proof/" + blockID)
}
func (sdk *Web1337) GetAggregatedEpochFinalizationProof(epochIndex uint, shard string) ([]byte, error) {
epochIndexStr := strconv.FormatUint(uint64(epochIndex), 10)
return sdk.getRequest("/aggregated_epoch_finalization_proof/" + epochIndexStr + "/" + shard)
}
/*
Misc
*/
func (sdk *Web1337) GetInfrastructureInfo() ([]byte, error) {
return sdk.getRequest("/infrastructure_info")
}
func (sdk *Web1337) GetChainInfo() ([]byte, error) {
return sdk.getRequest("/chain_info")
}
func (sdk *Web1337) GetKlyEVMMetadata() ([]byte, error) {
return sdk.getRequest("/kly_evm_metadata")
}
func (sdk *Web1337) GetSynchronizationStats() ([]byte, error) {
return sdk.getRequest("/synchronization_stats")
}
func (sdk *Web1337) GetCheckpointByEpochIndex(epochIndex uint) ([]byte, error) {
epochIndexStr := strconv.FormatUint(uint64(epochIndex), 10)
return sdk.getRequest("/checkpoints/" + epochIndexStr)
}
func (sdk *Web1337) GetQuorumUrlsAndPubkeys() ([]byte, error) {
return sdk.getRequest("/quorum_urls_and_pubkeys")
}