add Serai JSON-RPC methods (#627)

* add serai rpc methods

* fix machete & dex quote price api

* fix validators api

---------

Co-authored-by: Luke Parker <lukeparker5132@gmail.com>
This commit is contained in:
akildemir
2025-01-30 12:23:03 +03:00
committed by GitHub
parent e4cc23b72d
commit 11d48d0685
13 changed files with 393 additions and 42 deletions

View File

@@ -16,7 +16,8 @@ pub use abi::{primitives, Transaction};
use abi::*;
pub use primitives::{SeraiAddress, Signature, Amount};
use primitives::{Header, ExternalNetworkId};
use primitives::{Header, NetworkId, ExternalNetworkId, QuotePriceParams};
use crate::in_instructions::primitives::Shorthand;
pub mod coins;
pub use coins::SeraiCoins;
@@ -317,6 +318,24 @@ impl Serai {
) -> Result<Vec<multiaddr::Multiaddr>, SeraiError> {
self.call("p2p_validators", network).await
}
// TODO: move this to SeraiValidatorSets?
pub async fn external_network_address(
&self,
network: ExternalNetworkId,
) -> Result<String, SeraiError> {
self.call("external_network_address", network).await
}
// TODO: move this to SeraiInInstructions?
pub async fn encoded_shorthand(&self, shorthand: Shorthand) -> Result<Vec<u8>, SeraiError> {
self.call("encoded_shorthand", shorthand).await
}
// TODO: move this to SeraiDex?
pub async fn quote_price(&self, params: QuotePriceParams) -> Result<u64, SeraiError> {
self.call("quote_price", params).await
}
}
impl TemporalSerai<'_> {

View File

@@ -179,7 +179,7 @@ impl SeraiValidatorSets<'_> {
&self,
network: NetworkId,
) -> Result<Vec<Public>, SeraiError> {
self.0.runtime_api("SeraiRuntimeApi_validators", network).await
self.0.runtime_api("ValidatorSetsApi_validators", network).await
}
// TODO: Store these separately since we almost never need both at once?