Skip to content

Commit

Permalink
Fix testnet build (#566)
Browse files Browse the repository at this point in the history
* bump  jsonrpsee to use v0.20.3

* return error object for api methods

* clippy fix
  • Loading branch information
salman01zp authored Mar 20, 2024
1 parent ad32b51 commit 761e04b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 125 deletions.
119 changes: 4 additions & 115 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pallets/jobs/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repository = { workspace = true }
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
jsonrpsee = { version = "0.16.2", features = ["client-core", "server", "macros"] }
jsonrpsee = { workspace = true, features = ["client-core", "server", "macros"] }
pallet-jobs-rpc-runtime-api = { path = "./runtime-api", default-features = false }
parity-scale-codec = { workspace = true }
sp-api = { workspace = true }
Expand Down
13 changes: 4 additions & 9 deletions pallets/jobs/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
#![allow(clippy::unnecessary_mut_passed)]
#![allow(clippy::type_complexity)]
use jsonrpsee::{
core::{Error as JsonRpseeError, RpcResult},
core::RpcResult,
proc_macros::rpc,
types::error::{CallError, ErrorObject},
types::error::{ErrorObject, ErrorObjectOwned},
};
pub use pallet_jobs_rpc_runtime_api::JobsApi as JobsRuntimeApi;
use parity_scale_codec::Codec;
Expand Down Expand Up @@ -304,13 +304,8 @@ impl From<Error> for i32 {
}

/// Converts a runtime trap into an RPC error.
fn runtime_error_into_rpc_err(err: impl std::fmt::Debug) -> JsonRpseeError {
CallError::Custom(ErrorObject::owned(
RUNTIME_ERROR,
"Runtime error",
Some(format!("{:?}", err)),
))
.into()
fn runtime_error_into_rpc_err(err: impl std::fmt::Debug) -> ErrorObjectOwned {
ErrorObject::owned(RUNTIME_ERROR, "Runtime error", Some(format!("{:?}", err)))
}

const RUNTIME_ERROR: i32 = 1;

0 comments on commit 761e04b

Please sign in to comment.