Skip to content

Commit

Permalink
add rpc client(fix #157)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fred0327 committed Dec 22, 2023
1 parent 10ea3aa commit 76af19a
Show file tree
Hide file tree
Showing 5 changed files with 379 additions and 23 deletions.
111 changes: 95 additions & 16 deletions Cargo.lock

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

6 changes: 4 additions & 2 deletions provider/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ zklink_sdk_signers = { path = "../signers" }
zklink_sdk_types = { path = "../types" }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
jsonrpsee = { version = "0.20.1", features = ["http-client","macros"] }
jsonrpsee = { version = "0.21", features = ["http-client","macros"] }
jsonrpsee-http-client = "0.21"
jsonrpsee-core = "0.21"

[target.'cfg(target_arch = "wasm32")'.dependencies]
jsonrpsee = { version = "0.20.1", features = ["macros","jsonrpsee-types","client-core"] }
jsonrpsee = { version = "0.21", features = ["macros","jsonrpsee-types","client-core"] }
getrandom = { version = "0.2.11", features = ["js"] }
uuid = "0.8"

Expand Down
3 changes: 0 additions & 3 deletions provider/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use jsonrpsee::core::error::Error as jsonrpseeError;
use thiserror::Error;
use wasm_bindgen::JsValue;

Expand All @@ -8,8 +7,6 @@ pub enum RpcError {
InvalidNetwork,
#[error("Invalid input parameter")]
InvalidInputParameter,
#[error("Parse params error: {0}")]
ParseParamsError(jsonrpseeError),
#[error("HTTP request error: {0}")]
RequestError(reqwest::Error),
#[error("Parse response error: {0}")]
Expand Down
3 changes: 1 addition & 2 deletions provider/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pub mod network;
pub mod response;
#[cfg(not(any(feature = "ffi", target_arch = "wasm32")))]
pub mod rpc;
pub mod rpc_client;

#[cfg(not(any(feature = "ffi", target_arch = "wasm32")))]
mod not_ffi {
Expand Down Expand Up @@ -39,6 +40,4 @@ mod not_ffi {
#[cfg(not(any(feature = "ffi", target_arch = "wasm32")))]
pub use crate::rpc::ZkLinkRpcClient;
#[cfg(not(any(feature = "ffi", target_arch = "wasm32")))]
pub use jsonrpsee::core::Error as RpcError;
#[cfg(not(any(feature = "ffi", target_arch = "wasm32")))]
pub use not_ffi::*;
Loading

0 comments on commit 76af19a

Please sign in to comment.