-
Notifications
You must be signed in to change notification settings - Fork 992
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
APIv2 proposal #2425
Comments
Looks excellent, exactly the direction I was imagining going in. I had the same process of elimination you had when looking into existing options, they were either too heavyweight, incomplete, or unsuitable for some reason or another. A small, targeted lib to generate stubs from our existing APIs is definitely the best way to go here. I'd probably use option 3 for error reporting. The errors need to be as clear as possible and properly propagated out from the deepest parts of the system. I'd imagine that the majority of clients would be non-rust. We probably want to provide a client lib in js and/or another target language to go alongside this (that's another issue). And I think we also want to rewrite the wallet CLI to use the generated API (and that's a further issue). Overall, great. Let me know if you need any questions or further help with this |
@yeastplume I guess this issue can be closed now and more specific issues opened in grin-wallet? |
Closing. Feel free to ping me if you'd like me to reopen it. |
Regarding the wallet API. I'm working on an update that uses jsonrpc.
The new API will be less work to maintain as it will be automatically generated using a proceedural
macro. The jsonrpc api will be isomophic to the rust api so documentation can be shared between the two.
Readers are encouraged to provide feedback.
Proposed changes
jsonrpc_derive
.jsonrpc_derive
will provide a macro to converta trait definition into a jsonrpc api.
#[derive()]
.Trait definitions will contain api documentation including doctests.
Implementaions may contain implementaion specific documentaion. Implementaions
may define additional methods not accessable to jsonrpc clients.
Future steps
External crates
There are at least two existing crates that attempt to provide the functionality needed. As of now, neither of them
matches our needs.
API generation utilities provided by the first crate are not ready for production IMO. The second crate does not target stable rust.
Consideration on error handling
We should to condider how this api should report errors. I can think of several
options.
be a security concern as structured errors may leak sensitive data to api clients.
reported as an opaque "Internal Error".
https://www.jsonrpc.org/specification#error_object
Use of this mechanism has pros and cons:
pros:
- Conforms to jsonrpc user expectations
- More easily consumable by non-rust clients
cons:
- According to the spec, each error type must have an associated number id.
Assigning ids will likely be a manual process.
Jsonrpc errors MAY include a structured "data" field. Internal errors
would be serialized into the field using serde. As with option 1, detailed
error messages could leak sensitive information.
"Internal Error".
Request for feedback
If anyone wants to comment on these plans, please do.
I intend to start a WIP pr if this proposal is well accepted.
Previous issue: https://github.com/mimblewimble/grin/issues/2048
The text was updated successfully, but these errors were encountered: