28 lines
1.1 KiB
Rust
28 lines
1.1 KiB
Rust
// Method dispatch — each handler maps to a nu.rpc.api method name.
|
|
// Handlers are stubs; implementation wired in Faz 1.
|
|
|
|
use crate::types::{JsonRpcRequest, JsonRpcResponse};
|
|
|
|
pub fn dispatch(req: JsonRpcRequest) -> JsonRpcResponse {
|
|
match req.method.as_str() {
|
|
"nu_getBlock" => stub(&req, "nu_getBlock"),
|
|
"nu_getTx" => stub(&req, "nu_getTx"),
|
|
"nu_getAccount" => stub(&req, "nu_getAccount"),
|
|
"nu_getStory" => stub(&req, "nu_getStory"),
|
|
"nu_getNode" => stub(&req, "nu_getNode"),
|
|
"nu_getNft" => stub(&req, "nu_getNft"),
|
|
"nu_listStories" => stub(&req, "nu_listStories"),
|
|
"nu_listPendingVotes" => stub(&req, "nu_listPendingVotes"),
|
|
"nu_sendRawTx" => stub(&req, "nu_sendRawTx"),
|
|
"nu_chainInfo" => stub(&req, "nu_chainInfo"),
|
|
_ => JsonRpcResponse::err(req.id, -32601, "Method not found".into()),
|
|
}
|
|
}
|
|
|
|
fn stub(req: &JsonRpcRequest, method: &str) -> JsonRpcResponse {
|
|
JsonRpcResponse::err(
|
|
req.id.clone(),
|
|
-32000,
|
|
format!("{method} not implemented yet"),
|
|
)
|
|
}
|