#![deny(missing_docs)]
#[allow(clippy::tabs_in_doc_comments)]
#[macro_export]
macro_rules! impl_apis {
{
$prefix:ident {
$(
$method:ident {
params: [
$(
$param:ident
),*
],
opt_params: [
$(
$opt_param:ident
),*
]
}
)+
}
} => {
$(
affix::paste! {
pub fn $method(
id: usize,
$($param: impl serde::Serialize,)*
$($opt_param: Option<impl serde::Serialize>,)*
) -> serde_json::Value {
$crate::rpc(
id,
stringify!([<$prefix _ $method:camel>]),
serde_json::json!([
$($param,)*
$($opt_param,)*
])
)
}
#[doc = concat!("Similar to [`", stringify!($method), "`], but return the method name and parameters directly.")]
pub fn [<$method _raw>](
$($param: impl serde::Serialize,)*
$($opt_param: Option<impl serde::Serialize>,)*
) -> (&'static str, serde_json::Value) {
(
stringify!([<$prefix _ $method:camel>]),
serde_json::json!([
$($param,)*
$($opt_param,)*
])
)
}
}
)+
};
}
pub mod author;
pub mod babe;
pub mod chain;
pub mod grandpa;
pub mod net;
pub mod offchain;
pub mod payment;
pub mod rpc;
pub mod state;
pub mod system;
#[cfg(any(feature = "reqwest-client", feature = "ureq-client"))] mod client;
use serde_json::Value;
pub fn rpc(id: usize, method: &str, params: Value) -> Value {
serde_json::json!({
"jsonrpc": "2.0",
"id": id,
"method": method,
"params": params
})
}
#[cfg(feature = "tracing")]
pub fn debug(rpc: Value) -> Value {
tracing::trace!("{rpc:?}");
rpc
}