diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c14b4b937..7a1e9bdb5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,79 @@ The format is based on [Keep a Changelog]. [Keep a Changelog]: http://keepachangelog.com/en/1.0.0/ +## [v0.18.0] - 2023-04-21 + +This is a breaking release that removes the `CallError` which was used to represent a JSON-RPC error object that +could happen during JSON-RPC method call and one could assign application specific error code, message and data in a +specific implementation. + +Previously jsonrpsee provided `CallError` that could be converted to/from `jsonrpsee::core::Error` +and in some scenarios the error code was automatically assigned by jsonrpsee. After jsonrpsee +added support for custom error types the `CallError` doesn't provide any benefit because one has to implement `Into` +on the error type anyway. + +Thus, `jsonrpsee::core::Error` can't be used in the proc macro API anymore and the type alias +`RpcResult` has been modified to `Result<(), ErrorObjectOwned>` instead. + +Before it was possible to do: + +```rust +#[derive(thiserror::Error)] +enum Error { + A, + B, +} + +#[rpc(server, client)] +pub trait Rpc +{ + #[method(name = "getKeys")] + async fn keys(&self) -> Result { + Err(jsonrpsee::core::Error::to_call_error(Error::A)) + // or jsonrpsee::core::Error::Call(CallError::Custom(ErrorObject::owned(1, "a", None::<()>))) + } +} +``` + +After this change one has to do: + +```rust +pub enum Error { + A, + B, +} + +impl From for ErrorObjectOwned { + fn from(e: Error) -> Self { + match e { + Error::A => ErrorObject::owned(1, "a", None::<()>), + Error::B => ErrorObject::owned(2, "b", None::<()>), + } + } +} + +#[rpc(server, client)] +pub trait Rpc { + // Use a custom error type that implements `Into` + #[method(name = "custom_err_ty")] + async fn custom_err_type(&self) -> Result { + Err(Error::A) + } + + // Use `ErrorObject` as error type directly. + #[method(name = "err_obj")] + async fn error_obj(&self) -> RpcResult { + Err(ErrorObjectOwned::owned(1, "c", None::<()>)) + } +} +``` + +### [Changed] +- remove `CallError` ([#1087](https://github.com/paritytech/jsonrpsee/pull/1087)) + +### [Fixed] +- fix(proc macros): support parsing params !Result ([#1094](https://github.com/paritytech/jsonrpsee/pull/1094)) + ## [v0.17.1] - 2023-04-21 This release fixes HTTP graceful shutdown for the server. diff --git a/Cargo.toml b/Cargo.toml index 2c788810d1..cc74e3ebeb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ resolver = "2" [workspace.package] authors = ["Parity Technologies ", "Pierre Krieger "] -version = "0.17.1" +version = "0.18.0" edition = "2021" rust-version = "1.64.0" license = "MIT" @@ -30,11 +30,11 @@ keywords = ["jsonrpc", "json", "http", "websocket", "WASM"] readme = "README.md" [workspace.dependencies] -jsonrpsee-types = { path = "types", version = "0.17.1" } -jsonrpsee-core = { path = "core", version = "0.17.1" } -jsonrpsee-server = { path = "server", version = "0.17.1" } -jsonrpsee-ws-client = { path = "client/ws-client", version = "0.17.1" } -jsonrpsee-http-client = { path = "client/http-client", version = "0.17.1" } -jsonrpsee-wasm-client = { path = "client/wasm-client", version = "0.17.1" } -jsonrpsee-client-transport = { path = "client/transport", version = "0.17.1" } -jsonrpsee-proc-macros = { path = "proc-macros", version = "0.17.1" } +jsonrpsee-types = { path = "types", version = "0.18.0" } +jsonrpsee-core = { path = "core", version = "0.18.0" } +jsonrpsee-server = { path = "server", version = "0.18.0" } +jsonrpsee-ws-client = { path = "client/ws-client", version = "0.18.0" } +jsonrpsee-http-client = { path = "client/http-client", version = "0.18.0" } +jsonrpsee-wasm-client = { path = "client/wasm-client", version = "0.18.0" } +jsonrpsee-client-transport = { path = "client/transport", version = "0.18.0" } +jsonrpsee-proc-macros = { path = "proc-macros", version = "0.18.0" } diff --git a/README.md b/README.md index 7309dcfdfc..2eac8ed023 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ![MIT](https://img.shields.io/crates/l/jsonrpsee.svg) [![CI](https://github.com/paritytech/jsonrpsee/actions/workflows/ci.yml/badge.svg)](https://github.com/paritytech/jsonrpsee/actions/workflows/ci.yml) [![Benchmarks](https://github.com/paritytech/jsonrpsee/actions/workflows/benchmarks.yml/badge.svg)](https://github.com/paritytech/jsonrpsee/actions/workflows/benchmarks.yml) -[![dependency status](https://deps.rs/crate/jsonrpsee/0.17.1/status.svg)](https://deps.rs/crate/jsonrpsee/0.17.1) +[![dependency status](https://deps.rs/crate/jsonrpsee/0.18.0/status.svg)](https://deps.rs/crate/jsonrpsee/0.18.0) JSON-RPC library designed for async/await in Rust.