*expose Response and JsonRpcError

This commit is contained in:
Derrick Hammer 2023-03-26 13:06:48 -04:00
parent ed47eaadad
commit b9cd20b062
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
4 changed files with 28 additions and 11 deletions

20
Cargo.lock generated
View File

@ -4458,9 +4458,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasm-bindgen"
version = "0.2.83"
version = "0.2.84"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268"
checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b"
dependencies = [
"cfg-if 1.0.0",
"serde",
@ -4470,9 +4470,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.83"
version = "0.2.84"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142"
checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9"
dependencies = [
"bumpalo",
"log",
@ -4497,9 +4497,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.83"
version = "0.2.84"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810"
checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@ -4507,9 +4507,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.83"
version = "0.2.84"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c"
checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6"
dependencies = [
"proc-macro2",
"quote",
@ -4520,9 +4520,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.83"
version = "0.2.84"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f"
checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d"
[[package]]
name = "wasm-bindgen-test"

View File

@ -42,6 +42,7 @@ tracing-futures = { version = "0.2.5", default-features = false, features = ["st
bytes = { version = "1.3.0", default-features = false, optional = true }
once_cell = "1.16.0"
hashers = "1.0.1"
wasm-bindgen = "0.2.84"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
# tokio

View File

@ -59,6 +59,22 @@ impl From<ClientError> for ProviderError {
}
}
impl From<wasm_bindgen::JsValue> for ClientError {
fn from(value: wasm_bindgen::JsValue) -> Self {
ClientError::JsonRpcError(value.into())
}
}
impl From<wasm_bindgen::JsValue> for JsonRpcError {
fn from(value: wasm_bindgen::JsValue) -> Self {
JsonRpcError {
code: -1,
message: format!("JsonRpcError {}", value.as_string().unwrap()),
data: None,
}
}
}
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
impl JsonRpcClient for Provider {

View File

@ -1,5 +1,5 @@
mod common;
pub use common::Authorization;
pub use common::{Authorization, Response, JsonRpcError};
// only used with WS
#[cfg(feature = "ws")]