mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 08:11:04 +00:00
RPC call to get all RPC methods (#3613)
* Add meta rpc_methods call. * Sort methods. * Bump runtime. * Change format a bit to support versioning.
This commit is contained in:
committed by
Gavin Wood
parent
45d64a711c
commit
c45a15e559
@@ -40,6 +40,19 @@ pub fn rpc_handler<M: PubSubMetadata>(
|
||||
) -> RpcHandler<M> {
|
||||
let mut io = pubsub::PubSubHandler::default();
|
||||
extension.augment(&mut io);
|
||||
|
||||
// add an endpoint to list all available methods.
|
||||
let mut methods = io.iter().map(|x| x.0.clone()).collect::<Vec<String>>();
|
||||
io.add_method("rpc_methods", {
|
||||
methods.sort();
|
||||
let methods = serde_json::to_value(&methods)
|
||||
.expect("Serialization of Vec<String> is infallible; qed");
|
||||
|
||||
move |_| Ok(serde_json::json!({
|
||||
"version": 1,
|
||||
"methods": methods.clone(),
|
||||
}))
|
||||
});
|
||||
io
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user