-
Notifications
You must be signed in to change notification settings - Fork 254
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
introduce jsonrpsee client abstraction + kill HTTP support. #341
Conversation
If you resolve the conflict, you might find that |
I have substrate in my path but it's some issue with connection to the substrate process in the integration tests but I tried However, thanks merged to master let's see that the CI tells us :) |
Yea, I think this should work great, thanks! |
I tested it locally with embedded client and JSON-RPC related stuff works as intended but I got some issues metadata issues in the embedded client (not sure exactly why) when submitting extrinsics but the RPC related code works as intended. In addition it's quite hard/tricky to maintain the For example To conclude, we will not include the embedded client in this repo but because we are migrating to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really good to me; lovely to be able to lean on jsonrpsee more and trim some code from here :)
@@ -332,7 +243,7 @@ impl<T: Config> Rpc<T> { | |||
key: &StorageKey, | |||
hash: Option<T::Hash>, | |||
) -> Result<Option<StorageData>, BasicError> { | |||
let params = &[to_json_value(key)?, to_json_value(hash)?]; | |||
let params = rpc_params![key, hash]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE; this panics if the serialization fails
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess there should be no reason for these things to fail to serialize (afaik it's just maps where you have to be careful with json serializing?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed,
I'm working on a follow-up to replace this with proc macros to get rid of this anyway, so view this as temporary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes these are infallible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
@@ -332,7 +243,7 @@ impl<T: Config> Rpc<T> { | |||
key: &StorageKey, | |||
hash: Option<T::Hash>, | |||
) -> Result<Option<StorageData>, BasicError> { | |||
let params = &[to_json_value(key)?, to_json_value(hash)?]; | |||
let params = rpc_params![key, hash]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes these are infallible
subxt/src/rpc.rs
Outdated
Ok(self.client.request("author_hasKey", params).await?) | ||
} | ||
} | ||
|
||
/// Build WS RPC client from URL | ||
pub async fn build_ws_client(url: &str) -> Result<RpcClient, RpcError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I'd like this named even shorter, perhaps just ws_client
. Matter of taste though.
…ch#341) * PoC async rpc client * add client example should be removed from this repo * fmt * cargo fmt * subxt client tests * cargo fmt * fix some nits * try nightly for all CI jobs * need wasm also for CI * wasm for nightly run too * client: add missing features * update jsonrpsee * hacky update jsonrpsee * use jsonrpsee crates.io release * ci: pin nightly 2021-12-15 * pin nightly to 2021-12-15 * fix build * fmt * compile please * rewrite me * fixes * fixes * pre-generate metadata * fix nit * get rid of needless deps * remove embedded client * Update Cargo.toml * Update subxt/Cargo.toml * Update subxt/Cargo.toml * Update subxt/src/client.rs * Update subxt/src/rpc.rs * Update test-runtime/build.rs * cargo fmt Co-authored-by: James Wilson <james@jsdw.me>
Brings in the
abstract async jsonrpc client
from jsonrpsee and removesHTTP support
.The benefit is that is possible for users can plug in their own transport layer as long the
transport
implements the traitsTransportSenderT
andTransportReceiverT
. For example in memory to talk with an embedded substrate node...Follow-up introduce
proc macros
from jsonrpsee.