1use crate::error::Result;
4use crate::query::JsonRpcClient;
5use serde_json::{json, Value};
6
7pub const QOR_METHODS: &[(&str, &str)] = &[
11 ("get_pqc_key_status", "qor_getPQCKeyStatus"),
12 ("get_hybrid_signature_mode", "qor_getHybridSignatureMode"),
13 ("get_ai_stats", "qor_getAIStats"),
14 ("get_cross_vm_message", "qor_getCrossVMMessage"),
15 ("get_reputation_score", "qor_getReputationScore"),
16 ("get_layer_info", "qor_getLayerInfo"),
17 ("get_bridge_status", "qor_getBridgeStatus"),
18 ("get_rl_agent_status", "qor_getRLAgentStatus"),
19 ("get_rl_observation", "qor_getRLObservation"),
20 ("get_rl_reward", "qor_getRLReward"),
21 ("get_pool_classification", "qor_getPoolClassification"),
22 ("get_burn_stats", "qor_getBurnStats"),
23 ("get_xqore_position", "qor_getXQOREPosition"),
24 ("get_inflation_rate", "qor_getInflationRate"),
25 ("get_tokenomics_overview", "qor_getTokenomicsOverview"),
26 ("get_rollup_status", "qor_getRollupStatus"),
27 ("list_rollups", "qor_listRollups"),
28 ("get_settlement_batch", "qor_getSettlementBatch"),
29 ("suggest_rollup_profile", "qor_suggestRollupProfile"),
30 ("get_da_blob_status", "qor_getDABlobStatus"),
31 ("get_btc_staking_position", "qor_getBTCStakingPosition"),
32 ("get_abstract_account", "qor_getAbstractAccount"),
33 ("get_fair_block_status", "qor_getFairBlockStatus"),
34 ("get_gas_abstraction_config", "qor_getGasAbstractionConfig"),
35 ("get_lane_configuration", "qor_getLaneConfiguration"),
36];
37
38#[derive(Debug, Clone)]
41pub struct QorClient {
42 rpc: JsonRpcClient,
43}
44
45impl QorClient {
46 pub fn new(url: impl Into<String>) -> Self {
49 Self {
50 rpc: JsonRpcClient::new(url),
51 }
52 }
53
54 pub fn from_jsonrpc(rpc: JsonRpcClient) -> Self {
56 Self { rpc }
57 }
58
59 pub fn rpc(&self) -> &JsonRpcClient {
61 &self.rpc
62 }
63
64 pub async fn get_pqc_key_status(&self, address: &str) -> Result<Value> {
68 self.rpc.call("qor_getPQCKeyStatus", json!([address])).await
69 }
70
71 pub async fn get_hybrid_signature_mode(&self) -> Result<Value> {
73 self.rpc.call("qor_getHybridSignatureMode", json!([])).await
74 }
75
76 pub async fn get_ai_stats(&self) -> Result<Value> {
80 self.rpc.call("qor_getAIStats", json!([])).await
81 }
82
83 pub async fn get_cross_vm_message(&self, message_id: &str) -> Result<Value> {
87 self.rpc
88 .call("qor_getCrossVMMessage", json!([message_id]))
89 .await
90 }
91
92 pub async fn get_reputation_score(&self, validator: &str) -> Result<Value> {
96 self.rpc
97 .call("qor_getReputationScore", json!([validator]))
98 .await
99 }
100
101 pub async fn get_pool_classification(&self, validator: &str) -> Result<Value> {
103 self.rpc
104 .call("qor_getPoolClassification", json!([validator]))
105 .await
106 }
107
108 pub async fn get_layer_info(&self, layer_id: &str) -> Result<Value> {
112 self.rpc.call("qor_getLayerInfo", json!([layer_id])).await
113 }
114
115 pub async fn get_bridge_status(&self, chain_id: &str) -> Result<Value> {
117 self.rpc
118 .call("qor_getBridgeStatus", json!([chain_id]))
119 .await
120 }
121
122 pub async fn get_rl_agent_status(&self) -> Result<Value> {
126 self.rpc.call("qor_getRLAgentStatus", json!([])).await
127 }
128
129 pub async fn get_rl_observation(&self) -> Result<Value> {
131 self.rpc.call("qor_getRLObservation", json!([])).await
132 }
133
134 pub async fn get_rl_reward(&self) -> Result<Value> {
136 self.rpc.call("qor_getRLReward", json!([])).await
137 }
138
139 pub async fn get_burn_stats(&self) -> Result<Value> {
143 self.rpc.call("qor_getBurnStats", json!([])).await
144 }
145
146 pub async fn get_xqore_position(&self, address: &str) -> Result<Value> {
148 self.rpc
149 .call("qor_getXQOREPosition", json!([address]))
150 .await
151 }
152
153 pub async fn get_inflation_rate(&self) -> Result<Value> {
155 self.rpc.call("qor_getInflationRate", json!([])).await
156 }
157
158 pub async fn get_tokenomics_overview(&self) -> Result<Value> {
160 self.rpc.call("qor_getTokenomicsOverview", json!([])).await
161 }
162
163 pub async fn get_rollup_status(&self, rollup_id: &str) -> Result<Value> {
167 self.rpc
168 .call("qor_getRollupStatus", json!([rollup_id]))
169 .await
170 }
171
172 pub async fn list_rollups(&self) -> Result<Value> {
174 self.rpc.call("qor_listRollups", json!([])).await
175 }
176
177 pub async fn get_settlement_batch(&self, rollup_id: &str, batch_index: u64) -> Result<Value> {
179 self.rpc
180 .call("qor_getSettlementBatch", json!([rollup_id, batch_index]))
181 .await
182 }
183
184 pub async fn suggest_rollup_profile(&self, use_case: &str) -> Result<Value> {
186 self.rpc
187 .call("qor_suggestRollupProfile", json!([use_case]))
188 .await
189 }
190
191 pub async fn get_da_blob_status(&self, rollup_id: &str, blob_index: u64) -> Result<Value> {
193 self.rpc
194 .call("qor_getDABlobStatus", json!([rollup_id, blob_index]))
195 .await
196 }
197
198 pub async fn get_btc_staking_position(&self, address: &str) -> Result<Value> {
202 self.rpc
203 .call("qor_getBTCStakingPosition", json!([address]))
204 .await
205 }
206
207 pub async fn get_abstract_account(&self, address: &str) -> Result<Value> {
209 self.rpc
210 .call("qor_getAbstractAccount", json!([address]))
211 .await
212 }
213
214 pub async fn get_fair_block_status(&self) -> Result<Value> {
218 self.rpc.call("qor_getFairBlockStatus", json!([])).await
219 }
220
221 pub async fn get_gas_abstraction_config(&self) -> Result<Value> {
223 self.rpc
224 .call("qor_getGasAbstractionConfig", json!([]))
225 .await
226 }
227
228 pub async fn get_lane_configuration(&self) -> Result<Value> {
230 self.rpc.call("qor_getLaneConfiguration", json!([])).await
231 }
232}