Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpc_methods did not include rpc_methods #1627

Closed
xlc opened this issue Sep 19, 2023 · 5 comments · Fixed by #1713
Closed

rpc_methods did not include rpc_methods #1627

xlc opened this issue Sep 19, 2023 · 5 comments · Fixed by #1713

Comments

@xlc
Copy link
Contributor

xlc commented Sep 19, 2023

Previous issue: paritytech/substrate#11728

@bkchr
Copy link
Member

bkchr commented Sep 25, 2023

@bkchr bkchr closed this as completed Sep 25, 2023
@xlc
Copy link
Contributor Author

xlc commented Sep 25, 2023

I don't think we need to modify spec https://paritytech.github.io/json-rpc-interface-spec/api/rpc_methods.html
It is the implementation here is wrong.

@bkchr
Copy link
Member

bkchr commented Sep 26, 2023

I more meant to document that rpc_methods should include rpc_methods as well. The new api is currently implemented one after another.

@bkchr bkchr reopened this Sep 26, 2023
@bkchr
Copy link
Member

bkchr commented Sep 26, 2023

CC @lexnv

@lexnv
Copy link
Contributor

lexnv commented Sep 26, 2023

Indeed the jsonrpsee exposes the available methods registered (so far).

Substrate calls this method before registering the rpc_methods, because the result must be captured by the closure:

let mut available_methods = rpc_api.method_names().collect::<Vec<_>>();
available_methods.sort();
rpc_api
.register_method("rpc_methods", move |_, _| {
Ok(serde_json::json!({
"methods": available_methods,
}))
})
.expect("infallible all other methods have their own address space; qed");

Will create a patch for this, thanks for reporting!

lexnv added a commit that referenced this issue Sep 28, 2023
The PR exposes the `rpc_methods` name in the `rpc_methods` response.
This feature is useful for servers that only forward requests to methods
that are reported by the `rpc_methods`.

Jsonrpsee exposes the available methods registered so far. Registering
the `rpc_methods` requires a closure that already stores the result. As
such, the `rpc_methods` method name is manually added to the available
methods.

Closes: #1627

### Testing Done

```
$> curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "rpc_methods", "params":[]}' http://localhost:9944

{"jsonrpc":"2.0","result":{"methods":["account_nextIndex",... "rpc_methods",..."unsubscribe_newHead"]},"id":1}⏎
```

@paritytech/subxt-team

---------

Signed-off-by: Alexandru Vasile <[email protected]>
bgallois pushed a commit to duniter/duniter-polkadot-sdk that referenced this issue Mar 25, 2024
…ytech#1713)

The PR exposes the `rpc_methods` name in the `rpc_methods` response.
This feature is useful for servers that only forward requests to methods
that are reported by the `rpc_methods`.

Jsonrpsee exposes the available methods registered so far. Registering
the `rpc_methods` requires a closure that already stores the result. As
such, the `rpc_methods` method name is manually added to the available
methods.

Closes: paritytech#1627

### Testing Done

```
$> curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "rpc_methods", "params":[]}' http://localhost:9944

{"jsonrpc":"2.0","result":{"methods":["account_nextIndex",... "rpc_methods",..."unsubscribe_newHead"]},"id":1}⏎
```

@paritytech/subxt-team

---------

Signed-off-by: Alexandru Vasile <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants