Skip to content

Add possibility to include self-defined Jsonrpsee Client in Wrapper struct #714

@haerdib

Description

@haerdib

E.g. add new function to create a JsonrpseeClient wrapper but with a user defined client here:

impl JsonrpseeClient {
pub async fn with_default_url() -> Result<Self> {
Self::new("ws://127.0.0.1:9944").await
}
pub async fn new(url: &str) -> Result<Self> {
let uri: Uri = url.parse().map_err(|e| Error::Client(Box::new(e)))?;
let (tx, rx) = WsTransportClientBuilder::default()
.build(uri)
.await
.map_err(|e| Error::Client(Box::new(e)))?;
let client = ClientBuilder::default()
.max_notifs_per_subscription(4096)
.build_with_tokio(tx, rx);
Ok(Self { inner: Arc::new(client) })
}

Example:

pub async fn with_client(client: Arc<Client>) -> Self {
	Self { inner: client }
}

I'd also propose to make the inner client public - then the user may change settings any time.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions