use crate::error::Result;
use crate::query::JsonRpcClient;
use serde_json::{json, Value};
pub const QOR_METHODS: &[(&str, &str)] = &[
("get_pqc_key_status", "qor_getPQCKeyStatus"),
("get_hybrid_signature_mode", "qor_getHybridSignatureMode"),
("get_ai_stats", "qor_getAIStats"),
("get_cross_vm_message", "qor_getCrossVMMessage"),
("get_reputation_score", "qor_getReputationScore"),
("get_layer_info", "qor_getLayerInfo"),
("get_bridge_status", "qor_getBridgeStatus"),
("get_rl_agent_status", "qor_getRLAgentStatus"),
("get_rl_observation", "qor_getRLObservation"),
("get_rl_reward", "qor_getRLReward"),
("get_pool_classification", "qor_getPoolClassification"),
("get_burn_stats", "qor_getBurnStats"),
("get_xqore_position", "qor_getXQOREPosition"),
("get_inflation_rate", "qor_getInflationRate"),
("get_tokenomics_overview", "qor_getTokenomicsOverview"),
("get_rollup_status", "qor_getRollupStatus"),
("list_rollups", "qor_listRollups"),
("get_settlement_batch", "qor_getSettlementBatch"),
("suggest_rollup_profile", "qor_suggestRollupProfile"),
("get_da_blob_status", "qor_getDABlobStatus"),
("get_btc_staking_position", "qor_getBTCStakingPosition"),
("get_abstract_account", "qor_getAbstractAccount"),
("get_fair_block_status", "qor_getFairBlockStatus"),
("get_gas_abstraction_config", "qor_getGasAbstractionConfig"),
("get_lane_configuration", "qor_getLaneConfiguration"),
];
#[derive(Debug, Clone)]
pub struct QorClient {
rpc: JsonRpcClient,
}
impl QorClient {
pub fn new(url: impl Into<String>) -> Self {
Self {
rpc: JsonRpcClient::new(url),
}
}
pub fn from_jsonrpc(rpc: JsonRpcClient) -> Self {
Self { rpc }
}
pub fn rpc(&self) -> &JsonRpcClient {
&self.rpc
}
pub async fn get_pqc_key_status(&self, address: &str) -> Result<Value> {
self.rpc.call("qor_getPQCKeyStatus", json!([address])).await
}
pub async fn get_hybrid_signature_mode(&self) -> Result<Value> {
self.rpc.call("qor_getHybridSignatureMode", json!([])).await
}
pub async fn get_ai_stats(&self) -> Result<Value> {
self.rpc.call("qor_getAIStats", json!([])).await
}
pub async fn get_cross_vm_message(&self, message_id: &str) -> Result<Value> {
self.rpc
.call("qor_getCrossVMMessage", json!([message_id]))
.await
}
pub async fn get_reputation_score(&self, validator: &str) -> Result<Value> {
self.rpc
.call("qor_getReputationScore", json!([validator]))
.await
}
pub async fn get_pool_classification(&self, validator: &str) -> Result<Value> {
self.rpc
.call("qor_getPoolClassification", json!([validator]))
.await
}
pub async fn get_layer_info(&self, layer_id: &str) -> Result<Value> {
self.rpc.call("qor_getLayerInfo", json!([layer_id])).await
}
pub async fn get_bridge_status(&self, chain_id: &str) -> Result<Value> {
self.rpc
.call("qor_getBridgeStatus", json!([chain_id]))
.await
}
pub async fn get_rl_agent_status(&self) -> Result<Value> {
self.rpc.call("qor_getRLAgentStatus", json!([])).await
}
pub async fn get_rl_observation(&self) -> Result<Value> {
self.rpc.call("qor_getRLObservation", json!([])).await
}
pub async fn get_rl_reward(&self) -> Result<Value> {
self.rpc.call("qor_getRLReward", json!([])).await
}
pub async fn get_burn_stats(&self) -> Result<Value> {
self.rpc.call("qor_getBurnStats", json!([])).await
}
pub async fn get_xqore_position(&self, address: &str) -> Result<Value> {
self.rpc
.call("qor_getXQOREPosition", json!([address]))
.await
}
pub async fn get_inflation_rate(&self) -> Result<Value> {
self.rpc.call("qor_getInflationRate", json!([])).await
}
pub async fn get_tokenomics_overview(&self) -> Result<Value> {
self.rpc.call("qor_getTokenomicsOverview", json!([])).await
}
pub async fn get_rollup_status(&self, rollup_id: &str) -> Result<Value> {
self.rpc
.call("qor_getRollupStatus", json!([rollup_id]))
.await
}
pub async fn list_rollups(&self) -> Result<Value> {
self.rpc.call("qor_listRollups", json!([])).await
}
pub async fn get_settlement_batch(&self, rollup_id: &str, batch_index: u64) -> Result<Value> {
self.rpc
.call("qor_getSettlementBatch", json!([rollup_id, batch_index]))
.await
}
pub async fn suggest_rollup_profile(&self, use_case: &str) -> Result<Value> {
self.rpc
.call("qor_suggestRollupProfile", json!([use_case]))
.await
}
pub async fn get_da_blob_status(&self, rollup_id: &str, blob_index: u64) -> Result<Value> {
self.rpc
.call("qor_getDABlobStatus", json!([rollup_id, blob_index]))
.await
}
pub async fn get_btc_staking_position(&self, address: &str) -> Result<Value> {
self.rpc
.call("qor_getBTCStakingPosition", json!([address]))
.await
}
pub async fn get_abstract_account(&self, address: &str) -> Result<Value> {
self.rpc
.call("qor_getAbstractAccount", json!([address]))
.await
}
pub async fn get_fair_block_status(&self) -> Result<Value> {
self.rpc.call("qor_getFairBlockStatus", json!([])).await
}
pub async fn get_gas_abstraction_config(&self) -> Result<Value> {
self.rpc
.call("qor_getGasAbstractionConfig", json!([]))
.await
}
pub async fn get_lane_configuration(&self) -> Result<Value> {
self.rpc.call("qor_getLaneConfiguration", json!([])).await
}
}