diff --git a/src/rpc.rs b/src/rpc.rs index 8ab1755..9893d33 100644 --- a/src/rpc.rs +++ b/src/rpc.rs @@ -22,6 +22,9 @@ use crate::{ time::current_timestamp, }; +/// The OpenRPC specification for the HeroCoordinator JSON-RPC API +const OPENRPC_SPEC: &str = include_str!("../specs/openrpc.json"); + pub struct AppState { pub service: AppService, } @@ -638,6 +641,15 @@ pub fn build_module(state: Arc) -> RpcModule<()> { }) .expect("register message.load"); } + { + module + .register_async_method("rpc.discover", move |_params, _caller, _ctx| async move { + let spec = serde_json::from_str::(OPENRPC_SPEC) + .expect("Failed to parse OpenRPC spec"); + Ok::<_, ErrorObjectOwned>(spec) + }) + .expect("register rpc.discover"); + } module }