diff --git a/Cargo.lock b/Cargo.lock index e77b33a027..3098d45f25 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1740,7 +1740,7 @@ dependencies = [ "num-traits 0.2.19", "serde 1.0.208", "wasm-bindgen", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -3695,6 +3695,20 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" +[[package]] +name = "fast-socks5" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f89f36d4ee12370d30d57b16c7e190950a1a916e7dbbb5fd5a412f5ef913fe84" +dependencies = [ + "anyhow", + "async-trait", + "log", + "thiserror", + "tokio", + "tokio-stream", +] + [[package]] name = "fastcrypto" version = "0.1.8" @@ -4784,23 +4798,6 @@ dependencies = [ "tokio-rustls 0.24.1", ] -[[package]] -name = "hyper-rustls" -version = "0.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c" -dependencies = [ - "futures-util", - "http 1.1.0", - "hyper 1.3.1", - "hyper-util", - "rustls 0.22.4", - "rustls-pki-types", - "tokio", - "tokio-rustls 0.25.0", - "tower-service", -] - [[package]] name = "hyper-rustls" version = "0.27.2" @@ -4817,6 +4814,7 @@ dependencies = [ "tokio", "tokio-rustls 0.26.0", "tower-service", + "webpki-roots 0.26.1", ] [[package]] @@ -5775,7 +5773,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -7460,7 +7458,7 @@ dependencies = [ "percent-encoding", "quick-xml 0.31.0", "reqsign", - "reqwest 0.12.4", + "reqwest 0.12.7", "serde 1.0.208", "serde_json", "tokio", @@ -7692,7 +7690,7 @@ dependencies = [ "libc", "redox_syscall 0.5.1", "smallvec", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -8542,6 +8540,54 @@ dependencies = [ "serde 1.0.208", ] +[[package]] +name = "quinn" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b22d8e7369034b9a7132bc2008cac12f2013c8132b45e0554e6e20e2617f2156" +dependencies = [ + "bytes", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash 2.0.0", + "rustls 0.23.10", + "socket2", + "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "quinn-proto" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba92fb39ec7ad06ca2582c0ca834dfeadcaf06ddfc8e635c80aa7e1c05315fdd" +dependencies = [ + "bytes", + "rand 0.8.5", + "ring 0.17.8", + "rustc-hash 2.0.0", + "rustls 0.23.10", + "slab", + "thiserror", + "tinyvec", + "tracing", +] + +[[package]] +name = "quinn-udp" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bffec3605b73c6f1754535084a85229fa8a30f86014e6c81aeec4abb68b0285" +dependencies = [ + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.52.0", +] + [[package]] name = "quote" version = "0.6.13" @@ -8868,7 +8914,7 @@ dependencies = [ "log", "percent-encoding", "rand 0.8.5", - "reqwest 0.12.4", + "reqwest 0.12.7", "rsa 0.9.6", "serde 1.0.208", "serde_json", @@ -8908,7 +8954,7 @@ dependencies = [ "serde_json", "serde_urlencoded", "sync_wrapper 0.1.2", - "system-configuration", + "system-configuration 0.5.1", "tokio", "tokio-native-tls", "tokio-rustls 0.24.1", @@ -8921,14 +8967,14 @@ dependencies = [ "wasm-streams", "web-sys", "webpki-roots 0.25.4", - "winreg 0.50.0", + "winreg", ] [[package]] name = "reqwest" -version = "0.12.4" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10" +checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63" dependencies = [ "base64 0.22.1", "bytes", @@ -8940,7 +8986,7 @@ dependencies = [ "http-body 1.0.0", "http-body-util", "hyper 1.3.1", - "hyper-rustls 0.26.0", + "hyper-rustls 0.27.2", "hyper-tls 0.6.0", "hyper-util", "ipnet", @@ -8951,17 +8997,18 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls 0.22.4", + "quinn", + "rustls 0.23.10", "rustls-pemfile 2.1.2", "rustls-pki-types", "serde 1.0.208", "serde_json", "serde_urlencoded", - "sync_wrapper 0.1.2", - "system-configuration", + "sync_wrapper 1.0.1", + "system-configuration 0.6.1", "tokio", "tokio-native-tls", - "tokio-rustls 0.25.0", + "tokio-rustls 0.26.0", "tokio-util", "tower-service", "url", @@ -8970,7 +9017,7 @@ dependencies = [ "wasm-streams", "web-sys", "webpki-roots 0.26.1", - "winreg 0.52.0", + "windows-registry", ] [[package]] @@ -9683,7 +9730,7 @@ dependencies = [ "moveos-types", "ordinals", "prometheus", - "reqwest 0.12.4", + "reqwest 0.12.7", "rooch-types", "serde 1.0.208", "serde_json", @@ -9795,13 +9842,16 @@ name = "rooch-rpc-client" version = "0.6.9" dependencies = [ "anyhow", + "axum 0.7.5", "bcs", + "fast-socks5", "futures", "hex", "jsonrpsee 0.23.2", "log", "move-core-types", "moveos-types", + "pin-project", "rooch-config", "rooch-key", "rooch-rpc-api", @@ -11449,6 +11499,9 @@ name = "sync_wrapper" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +dependencies = [ + "futures-core", +] [[package]] name = "synthez" @@ -11491,7 +11544,18 @@ checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ "bitflags 1.3.2", "core-foundation", - "system-configuration-sys", + "system-configuration-sys 0.5.0", +] + +[[package]] +name = "system-configuration" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +dependencies = [ + "bitflags 2.5.0", + "core-foundation", + "system-configuration-sys 0.6.0", ] [[package]] @@ -11504,6 +11568,16 @@ dependencies = [ "libc", ] +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "tap" version = "1.0.1" @@ -13166,7 +13240,37 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-registry" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" +dependencies = [ + "windows-result", + "windows-strings", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result", + "windows-targets 0.52.6", ] [[package]] @@ -13197,7 +13301,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -13217,18 +13321,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -13239,9 +13343,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -13257,9 +13361,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -13275,15 +13379,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -13299,9 +13403,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -13317,9 +13421,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -13329,9 +13433,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -13347,9 +13451,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" @@ -13379,16 +13483,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "winreg" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - [[package]] name = "ws_stream_wasm" version = "0.7.4" diff --git a/Cargo.toml b/Cargo.toml index 37191c9d3b..596974944a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -217,6 +217,8 @@ tonic = { version = "0.8", features = ["gzip"] } tracing = "0.1.37" tracing-appender = "0.2.2" tracing-subscriber = { version = "0.3.15" } +fast-socks5 = { version = "0.9.1" } +pin-project = { version = "1.1.5" } codespan-reporting = "0.11.1" codespan = "0.11.1" diff --git a/crates/rooch-rpc-client/Cargo.toml b/crates/rooch-rpc-client/Cargo.toml index b2d7526b24..6a42a576d1 100644 --- a/crates/rooch-rpc-client/Cargo.toml +++ b/crates/rooch-rpc-client/Cargo.toml @@ -23,6 +23,9 @@ jsonrpsee = { workspace = true } serde_json = { workspace = true } log = { workspace = true } hex = { workspace = true } +axum = { workspace = true } +fast-socks5 = { workspace = true } +pin-project = { workspace = true } move-core-types = { workspace = true } diff --git a/crates/rooch-rpc-client/src/client_config.rs b/crates/rooch-rpc-client/src/client_config.rs index 39b60a39ba..2e11960eaf 100644 --- a/crates/rooch-rpc-client/src/client_config.rs +++ b/crates/rooch-rpc-client/src/client_config.rs @@ -71,6 +71,7 @@ pub struct Env { pub alias: String, pub rpc: String, pub ws: Option, + pub proxy: Option, } impl Env { @@ -83,6 +84,9 @@ impl Env { if let Some(ws_url) = &self.ws { builder = builder.ws_url(ws_url); } + if let Some(proxy_url) = &self.proxy { + builder = builder.proxy_url(proxy_url); + } builder.build(&self.rpc).await } @@ -92,6 +96,7 @@ impl Env { alias: BuiltinChainID::Dev.chain_name(), rpc: ROOCH_DEV_NET_URL.into(), ws: None, + proxy: None, } } @@ -100,6 +105,7 @@ impl Env { alias: BuiltinChainID::Test.chain_name(), rpc: ROOCH_TEST_NET_URL.into(), ws: None, + proxy: None, } } @@ -121,6 +127,7 @@ impl Default for Env { alias: BuiltinChainID::Local.chain_name(), rpc: ServerConfig::default().url(false), ws: None, + proxy: None, } } } diff --git a/crates/rooch-rpc-client/src/lib.rs b/crates/rooch-rpc-client/src/lib.rs index 3c85628058..5d282e7c0a 100644 --- a/crates/rooch-rpc-client/src/lib.rs +++ b/crates/rooch-rpc-client/src/lib.rs @@ -2,8 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 use anyhow::Result; +use fast_socks5::client::Socks5Stream; +use fast_socks5::server::{Config, Socks5Socket}; use jsonrpsee::core::client::ClientT; use jsonrpsee::http_client::{HttpClient, HttpClientBuilder}; +use jsonrpsee::ws_client::{WsClient, WsClientBuilder}; use move_core_types::language_storage::ModuleId; use move_core_types::metadata::Metadata; use move_core_types::resolver::ModuleResolver; @@ -15,9 +18,13 @@ use moveos_types::{ function_return_value::FunctionResult, module_binding::MoveFunctionCaller, moveos_std::tx_context::TxContext, transaction::FunctionCall, }; +use pin_project::pin_project; use rooch_client::RoochRpcClient; +use std::env; +use std::net::SocketAddr; use std::sync::Arc; use std::time::Duration; +use tokio::net::{TcpListener, TcpStream}; use tokio::runtime::Handle; pub mod client_config; @@ -27,6 +34,7 @@ pub mod wallet_context; pub struct ClientBuilder { request_timeout: Duration, ws_url: Option, + proxy_url: Option, } impl ClientBuilder { @@ -40,6 +48,11 @@ impl ClientBuilder { self } + pub fn proxy_url(mut self, url: impl AsRef) -> Self { + self.proxy_url = Some(url.as_ref().to_string()); + self + } + pub async fn build(self, http: impl AsRef) -> Result { // TODO: add verison info @@ -50,11 +63,67 @@ impl ClientBuilder { .build(http)?, ); + let server_addr = self.socks_server_no_auth().await; + let server_url = format!("ws://{}", server_addr); + // TODO: build_with_stream + let ws_client = Arc::new(WsClientBuilder::default().build(&server_url).await.unwrap()); + Ok(Client { http: http_client.clone(), + ws: ws_client.clone(), rooch: RoochRpcClient::new(http_client.clone()), }) } + + pub async fn socks_server_no_auth(self) -> SocketAddr { + let mut config = Config::default(); + config.set_dns_resolve(false); + let config = Arc::new(config); + + let proxy_url = if self.proxy_url.is_some() { + self.proxy_url.clone().unwrap() + } else { + env::var("ALL_PROXY").unwrap() + }; + + let listener = TcpListener::bind(proxy_url).await.unwrap(); + let proxy_addr = listener.local_addr().unwrap(); + self.spawn_socks_server(listener, config).await; + + proxy_addr + } + + pub async fn spawn_socks_server(self, listener: TcpListener, config: Arc) { + let addr = listener.local_addr().unwrap(); + tokio::spawn(async move { + loop { + let (stream, _) = listener.accept().await.unwrap(); + let mut socks5_socket = Socks5Socket::new(stream, config.clone()); + socks5_socket.set_reply_ip(addr.ip()); + + socks5_socket.upgrade_to_socks5().await.unwrap(); + } + }); + } + + pub async fn connect_over_socks_stream( + self, + server_addr: SocketAddr, + ) -> Socks5Stream { + let target_addr = server_addr.ip().to_string(); + let target_port = server_addr.port(); + + let socks_server = self.socks_server_no_auth().await; + + Socks5Stream::connect( + socks_server, + target_addr, + target_port, + fast_socks5::client::Config::default(), + ) + .await + .unwrap() + } } impl Default for ClientBuilder { @@ -62,6 +131,7 @@ impl Default for ClientBuilder { Self { request_timeout: Duration::from_secs(60), ws_url: None, + proxy_url: None, } } } @@ -69,6 +139,7 @@ impl Default for ClientBuilder { #[derive(Clone)] pub struct Client { http: Arc, + ws: Arc, pub rooch: RoochRpcClient, } @@ -86,6 +157,14 @@ impl Client { ) -> Result { Ok(self.http.request(method, params).await?) } + + pub async fn request_with_ws( + &self, + method: &str, + params: Vec, + ) -> Result { + Ok(self.ws.request(method, params).await?) + } } impl MoveFunctionCaller for Client { @@ -122,3 +201,14 @@ impl ModuleResolver for &Client { }) } } + +#[pin_project] +pub struct DataStream( + #[pin] Socks5Stream, +); + +impl DataStream { + pub fn new(t: Socks5Stream) -> Self { + Self(t) + } +} diff --git a/crates/rooch/src/commands/env/commands/add.rs b/crates/rooch/src/commands/env/commands/add.rs index fc8447b647..3eea1140b2 100644 --- a/crates/rooch/src/commands/env/commands/add.rs +++ b/crates/rooch/src/commands/env/commands/add.rs @@ -18,14 +18,23 @@ pub struct AddCommand { pub rpc: String, #[clap(long, value_hint = ValueHint::Url)] pub ws: Option, + #[clap(long, value_hint = ValueHint::Url)] + pub proxy: Option, } impl AddCommand { pub async fn execute(self) -> RoochResult<()> { let mut context = self.context_options.build()?; - let AddCommand { alias, rpc, ws, .. } = self; + let AddCommand { + alias, + rpc, + ws, + proxy, + .. + } = self; let env = Env { ws, + proxy, rpc, alias: alias.clone(), }; diff --git a/crates/rooch/src/commands/env/commands/list.rs b/crates/rooch/src/commands/env/commands/list.rs index 8547a192e6..9949aad182 100644 --- a/crates/rooch/src/commands/env/commands/list.rs +++ b/crates/rooch/src/commands/env/commands/list.rs @@ -17,10 +17,10 @@ impl ListCommand { let context = self.context_options.build()?; println!( - "{:^24} | {:^48} | {:^48} | {:^12}", - "Env Alias", "RPC URL", "Websocket URL", "Active Env" + "{:^24} | {:^48} | {:^48} | {:^48} | {:^12}", + "Env Alias", "RPC URL", "Websocket URL", "Proxy", "Active Env" ); - println!("{}", ["-"; 153].join("")); + println!("{}", ["-"; 203].join("")); for env in context.client_config.envs.iter() { let mut active = ""; @@ -29,9 +29,11 @@ impl ListCommand { } let ws = env.ws.clone().unwrap_or("Null".to_owned()); + let proxy = env.proxy.clone().unwrap_or("Null".to_owned()); + println!( - "{:^24} | {:^48} | {:^48} | {:^12}", - env.alias, env.rpc, ws, active + "{:^24} | {:^48} | {:^48} | {:^48} | {:^12}", + env.alias, env.rpc, ws, proxy, active ) } diff --git a/crates/rooch/src/commands/init.rs b/crates/rooch/src/commands/init.rs index 55433b4acc..1a638a9232 100644 --- a/crates/rooch/src/commands/init.rs +++ b/crates/rooch/src/commands/init.rs @@ -77,6 +77,7 @@ impl CommandAction<()> for Init { alias: "custom".to_string(), rpc: chain_url[1].to_owned(), ws: None, + proxy: None, }) } @@ -112,6 +113,7 @@ impl CommandAction<()> for Init { alias, rpc: url, ws: None, + proxy: None, } }) } diff --git a/crates/rooch/src/commands/rpc/commands/request.rs b/crates/rooch/src/commands/rpc/commands/request.rs index 0ae7c0d1aa..cfc49f0ef6 100644 --- a/crates/rooch/src/commands/rpc/commands/request.rs +++ b/crates/rooch/src/commands/rpc/commands/request.rs @@ -27,7 +27,6 @@ pub struct RequestCommand { #[clap(flatten)] pub(crate) context_options: WalletContextOptions, - /// Return command outputs in json format #[clap(long, default_value = "false")] json: bool, @@ -36,7 +35,8 @@ pub struct RequestCommand { #[async_trait] impl CommandAction for RequestCommand { async fn execute(self) -> RoochResult { - let client = self.context_options.build()?.get_client().await?; + let context = self.context_options.build()?; + let client = context.get_client().await?; let params = match self.params { Some(serde_json::Value::Array(array)) => array, Some(value) => { @@ -51,7 +51,8 @@ impl CommandAction for RequestCommand { } None => vec![], }; - Ok(client.request(self.method.as_str(), params).await?) + + Ok(client.request_with_ws(&self.method, params).await?) } /// Executes the command, and serializes it to the common JSON output type