mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 20:29:23 +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:
@@ -53,7 +53,7 @@ use sp_runtime::{
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use primitives::{
|
||||
NetworkId, PublicKey, AccountLookup, SubstrateAmount, Coin, EXTERNAL_NETWORKS,
|
||||
NetworkId, ExternalNetworkId, PublicKey, AccountLookup, SubstrateAmount, Coin, EXTERNAL_NETWORKS,
|
||||
MEDIAN_PRICE_WINDOW_LENGTH, HOURS, DAYS, MINUTES, TARGET_BLOCK_TIME, BLOCK_SIZE,
|
||||
FAST_EPOCH_DURATION,
|
||||
};
|
||||
@@ -374,13 +374,6 @@ mod benches {
|
||||
);
|
||||
}
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
#[api_version(1)]
|
||||
pub trait SeraiRuntimeApi {
|
||||
fn validators(network_id: NetworkId) -> Vec<PublicKey>;
|
||||
}
|
||||
}
|
||||
|
||||
sp_api::impl_runtime_apis! {
|
||||
impl sp_api::Core<Block> for Runtime {
|
||||
fn version() -> RuntimeVersion {
|
||||
@@ -589,7 +582,7 @@ sp_api::impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::SeraiRuntimeApi<Block> for Runtime {
|
||||
impl validator_sets::ValidatorSetsApi<Block> for Runtime {
|
||||
fn validators(network_id: NetworkId) -> Vec<PublicKey> {
|
||||
if network_id == NetworkId::Serai {
|
||||
Babe::authorities()
|
||||
@@ -604,6 +597,10 @@ sp_api::impl_runtime_apis! {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn external_network_key(network: ExternalNetworkId) -> Option<Vec<u8>> {
|
||||
ValidatorSets::external_network_key(network)
|
||||
}
|
||||
}
|
||||
|
||||
impl dex::DexApi<Block> for Runtime {
|
||||
|
||||
Reference in New Issue
Block a user