From 761e04b1f31f5da7de8d0330c4a2c6b584998484 Mon Sep 17 00:00:00 2001 From: Salman Pathan Date: Wed, 20 Mar 2024 14:27:08 +0700 Subject: [PATCH] Fix testnet build (#566) * bump jsonrpsee to use v0.20.3 * return error object for api methods * clippy fix --- Cargo.lock | 119 ++---------------------------------- pallets/jobs/rpc/Cargo.toml | 2 +- pallets/jobs/rpc/src/lib.rs | 13 ++-- 3 files changed, 9 insertions(+), 125 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2b0eed9b2..79a42b43e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1268,16 +1268,6 @@ dependencies = [ "regex-automata 0.1.10", ] -[[package]] -name = "bstr" -version = "1.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05efc5cfd9110c8416e471df0e96702d58690178e206e61b7173706673c93706" -dependencies = [ - "memchr", - "serde", -] - [[package]] name = "build-helper" version = "0.1.1" @@ -4799,19 +4789,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" -[[package]] -name = "globset" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" -dependencies = [ - "aho-corasick", - "bstr 1.9.1", - "log", - "regex-automata 0.4.6", - "regex-syntax 0.8.2", -] - [[package]] name = "gloo-timers" version = "0.2.6" @@ -5442,19 +5419,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "jsonrpsee" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "367a292944c07385839818bb71c8d76611138e2dedb0677d035b8da21d29c78b" -dependencies = [ - "jsonrpsee-core 0.16.3", - "jsonrpsee-proc-macros 0.16.3", - "jsonrpsee-server 0.16.3", - "jsonrpsee-types 0.16.3", - "tracing", -] - [[package]] name = "jsonrpsee" version = "0.20.3" @@ -5462,8 +5426,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "affdc52f7596ccb2d7645231fc6163bb314630c989b64998f3699a28b4d5d4dc" dependencies = [ "jsonrpsee-core 0.20.3", - "jsonrpsee-proc-macros 0.20.3", - "jsonrpsee-server 0.20.3", + "jsonrpsee-proc-macros", + "jsonrpsee-server", "jsonrpsee-types 0.20.3", "tokio", "tracing", @@ -5502,32 +5466,6 @@ dependencies = [ "url", ] -[[package]] -name = "jsonrpsee-core" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b5dde66c53d6dcdc8caea1874a45632ec0fcf5b437789f1e45766a1512ce803" -dependencies = [ - "anyhow", - "arrayvec 0.7.4", - "async-trait", - "beef", - "futures-channel", - "futures-util", - "globset", - "hyper", - "jsonrpsee-types 0.16.3", - "parking_lot 0.12.1", - "rand 0.8.5", - "rustc-hash", - "serde", - "serde_json", - "soketto", - "thiserror", - "tokio", - "tracing", -] - [[package]] name = "jsonrpsee-core" version = "0.20.3" @@ -5595,19 +5533,6 @@ dependencies = [ "url", ] -[[package]] -name = "jsonrpsee-proc-macros" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44e8ab85614a08792b9bff6c8feee23be78c98d0182d4c622c05256ab553892a" -dependencies = [ - "heck", - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "jsonrpsee-proc-macros" version = "0.20.3" @@ -5621,28 +5546,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "jsonrpsee-server" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4d945a6008c9b03db3354fb3c83ee02d2faa9f2e755ec1dfb69c3551b8f4ba" -dependencies = [ - "futures-channel", - "futures-util", - "http", - "hyper", - "jsonrpsee-core 0.16.3", - "jsonrpsee-types 0.16.3", - "serde", - "serde_json", - "soketto", - "tokio", - "tokio-stream", - "tokio-util", - "tower", - "tracing", -] - [[package]] name = "jsonrpsee-server" version = "0.20.3" @@ -5666,20 +5569,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "jsonrpsee-types" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245ba8e5aa633dd1c1e4fae72bce06e71f42d34c14a2767c6b4d173b57bee5e5" -dependencies = [ - "anyhow", - "beef", - "serde", - "serde_json", - "thiserror", - "tracing", -] - [[package]] name = "jsonrpsee-types" version = "0.20.3" @@ -8361,7 +8250,7 @@ dependencies = [ name = "pallet-jobs-rpc" version = "0.6.3" dependencies = [ - "jsonrpsee 0.16.3", + "jsonrpsee 0.20.3", "pallet-jobs-rpc-runtime-api", "parity-scale-codec 3.6.9", "sp-api", @@ -12429,7 +12318,7 @@ version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32fea41aca09ee824cc9724996433064c89f7777e60762749a4170a14abbfa21" dependencies = [ - "bstr 0.2.17", + "bstr", "unicode-segmentation", ] diff --git a/pallets/jobs/rpc/Cargo.toml b/pallets/jobs/rpc/Cargo.toml index 3582da634..7b369f1c0 100644 --- a/pallets/jobs/rpc/Cargo.toml +++ b/pallets/jobs/rpc/Cargo.toml @@ -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 } diff --git a/pallets/jobs/rpc/src/lib.rs b/pallets/jobs/rpc/src/lib.rs index 4efd25ca4..06593db6b 100644 --- a/pallets/jobs/rpc/src/lib.rs +++ b/pallets/jobs/rpc/src/lib.rs @@ -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; @@ -304,13 +304,8 @@ impl From 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;