mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
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:
@@ -26,6 +26,7 @@ serde = { version = "1", default-features = false, features = ["derive", "alloc"
|
||||
sp-core = { git = "https://github.com/serai-dex/substrate", default-features = false }
|
||||
sp-io = { git = "https://github.com/serai-dex/substrate", default-features = false }
|
||||
sp-std = { git = "https://github.com/serai-dex/substrate", default-features = false }
|
||||
sp-api = { git = "https://github.com/serai-dex/substrate", default-features = false }
|
||||
sp-application-crypto = { git = "https://github.com/serai-dex/substrate", default-features = false }
|
||||
sp-runtime = { git = "https://github.com/serai-dex/substrate", default-features = false }
|
||||
sp-session = { git = "https://github.com/serai-dex/substrate", default-features = false }
|
||||
@@ -65,6 +66,7 @@ std = [
|
||||
"sp-core/std",
|
||||
"sp-io/std",
|
||||
"sp-std/std",
|
||||
"sp-api/std",
|
||||
"sp-application-crypto/std",
|
||||
"sp-runtime/std",
|
||||
"sp-session/std",
|
||||
|
||||
@@ -994,6 +994,14 @@ pub mod pallet {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the external network key for a given external network
|
||||
pub fn external_network_key(network: ExternalNetworkId) -> Option<Vec<u8>> {
|
||||
let current_session = Self::session(NetworkId::from(network))?;
|
||||
let keys = Keys::<T>::get(ExternalValidatorSet { network, session: current_session })?;
|
||||
|
||||
Some(keys.1.into_inner())
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::call]
|
||||
@@ -1365,4 +1373,17 @@ pub mod pallet {
|
||||
}
|
||||
}
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
#[api_version(1)]
|
||||
pub trait ValidatorSetsApi {
|
||||
/// Returns the validator set for a given network.
|
||||
fn validators(network_id: NetworkId) -> Vec<PublicKey>;
|
||||
|
||||
/// Returns the external network key for a given external network.
|
||||
fn external_network_key(
|
||||
network: ExternalNetworkId,
|
||||
) -> Option<Vec<u8>>;
|
||||
}
|
||||
}
|
||||
|
||||
pub use pallet::*;
|
||||
|
||||
Reference in New Issue
Block a user