Skip to content

Commit

Permalink
[rooch-networkgh-2406] remove unused reqwest.
Browse files Browse the repository at this point in the history
  • Loading branch information
Feliciss committed Sep 2, 2024
1 parent 8f6efc5 commit 7e08072
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 91 deletions.
51 changes: 3 additions & 48 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ tonic = { version = "0.8", features = ["gzip"] }
tracing = "0.1.37"
tracing-appender = "0.2.2"
tracing-subscriber = { version = "0.3.15" }
reqwest = { version = "0.12.7", features = ["json"] }

codespan-reporting = "0.11.1"
codespan = "0.11.1"
Expand Down
2 changes: 0 additions & 2 deletions crates/rooch-rpc-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ jsonrpsee = { workspace = true }
serde_json = { workspace = true }
log = { workspace = true }
hex = { workspace = true }
reqwest = { workspace = true }
axum = { workspace = true }

move-core-types = { workspace = true }

Expand Down
40 changes: 0 additions & 40 deletions crates/rooch-rpc-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ use moveos_types::{
function_return_value::FunctionResult, module_binding::MoveFunctionCaller,
moveos_std::tx_context::TxContext, transaction::FunctionCall,
};
use reqwest::Proxy;
use rooch_client::RoochRpcClient;
use serde_json::json;
use std::sync::Arc;
use std::time::Duration;
use tokio::runtime::Handle;
Expand Down Expand Up @@ -58,24 +56,9 @@ impl ClientBuilder {
.build(http)?,
);

if let Some(proxy_url) = self.proxy_url {
let reqwest_client = Some(Arc::new(
reqwest::Client::builder()
.proxy(Proxy::https(proxy_url.clone())?)
.proxy(Proxy::all(proxy_url)?)
.build()?,
));
return Ok(Client {
http: http_client.clone(),
rooch: RoochRpcClient::new(http_client.clone()),
reqwest: reqwest_client,
});
};

Ok(Client {
http: http_client.clone(),
rooch: RoochRpcClient::new(http_client.clone()),
reqwest: None,
})
}
}
Expand All @@ -93,7 +76,6 @@ impl Default for ClientBuilder {
#[derive(Clone)]
pub struct Client {
http: Arc<HttpClient>,
reqwest: Option<Arc<reqwest::Client>>,
pub rooch: RoochRpcClient,
}

Expand All @@ -111,28 +93,6 @@ impl Client {
) -> Result<serde_json::Value> {
Ok(self.http.request(method, params).await?)
}

pub async fn request_by_proxy(
&self,
url: &str,
method: &str,
params: Vec<serde_json::Value>,
) -> Result<serde_json::Value> {
if let Some(reqwest) = &self.reqwest {
let response = reqwest
.post(url)
.header("Content-Type", "application/json")
.json(&json!({
"method": method,
"params": params,
}))
.send()
.await?;
return Ok(response.json::<serde_json::Value>().await?);
};

Ok(serde_json::Value::Null)
}
}

impl MoveFunctionCaller for Client {
Expand Down

0 comments on commit 7e08072

Please sign in to comment.