Skip to content

Commit

Permalink
[rooch-networkgh-2385] add https_proxy and all_proxy to env file.
Browse files Browse the repository at this point in the history
  • Loading branch information
Feliciss committed Aug 18, 2024
1 parent 3cc6756 commit 5f05a74
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions crates/rooch/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

use std::env;

use anyhow::Result;
use vergen_git2::{BuildBuilder, CargoBuilder, Emitter, Git2Builder, RustcBuilder};

Expand All @@ -11,5 +13,11 @@ fn main() -> Result<()> {
.add_instructions(&Git2Builder::all_git()?)?
.add_instructions(&RustcBuilder::all_rustc()?)?
.emit()?;
read_proxy_from_env();
Ok(())
}

fn read_proxy_from_env() {
println!("cargo:rerun-if-env-changed=https_proxy");
println!("cargo:rerun-if-env-changed=all_proxy");
}
7 changes: 6 additions & 1 deletion crates/rooch/src/commands/rpc/commands/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::cli_types::{CommandAction, WalletContextOptions};
use async_trait::async_trait;
use clap::Parser;
use rooch_types::error::RoochResult;
use std::env;

use rooch_rpc_api::jsonrpc_types::{
HumanReadableDisplay, IndexerObjectStatePageView, ObjectStateView,
Expand All @@ -27,7 +28,6 @@ pub struct RequestCommand {

#[clap(flatten)]
pub(crate) context_options: WalletContextOptions,

/// Return command outputs in json format
#[clap(long, default_value = "false")]
json: bool,
Expand All @@ -36,6 +36,11 @@ pub struct RequestCommand {
#[async_trait]
impl CommandAction<serde_json::Value> for RequestCommand {
async fn execute(self) -> RoochResult<serde_json::Value> {
let https_proxy = env::var("https_proxy").ok();
let all_proxy = env::var("all_proxy").ok();
// TODO: proxy url
let proxy_url = https_proxy.or(all_proxy);

let client = self.context_options.build()?.get_client().await?;
let params = match self.params {
Some(serde_json::Value::Array(array)) => array,
Expand Down

0 comments on commit 5f05a74

Please sign in to comment.