diff --git a/framework/snippets/src/account_tool.rs b/framework/snippets/src/account_tool.rs index 70eaafdace..401e68fd9c 100644 --- a/framework/snippets/src/account_tool.rs +++ b/framework/snippets/src/account_tool.rs @@ -4,7 +4,7 @@ use multiversx_sc_scenario::{ scenario_model::{Account, BytesKey, BytesValue, Scenario, SetStateStep, Step}, }; use multiversx_sdk::{ - blockchain::CommunicationProxy, + blockchain::GatewayProxy, data::{address::Address, esdt::EsdtBalance}, }; use std::collections::{BTreeMap, HashMap}; @@ -17,7 +17,7 @@ pub async fn print_account_as_scenario_set_state( api_string: String, address_bech32_string: String, ) { - let api = CommunicationProxy::new(api_string); + let api = GatewayProxy::new(api_string); let address = Bech32Address::from_bech32_string(address_bech32_string); let set_state = retrieve_account_as_scenario_set_state(&api, &address).await; let scenario = build_scenario(set_state); @@ -34,7 +34,7 @@ fn build_scenario(set_state: SetStateStep) -> Scenario { } pub async fn retrieve_account_as_scenario_set_state( - api: &CommunicationProxy, + api: &GatewayProxy, address: &Bech32Address, ) -> SetStateStep { let sdk_address = Address::from_bech32_string(address.to_bech32_str()).unwrap(); diff --git a/framework/snippets/src/interactor.rs b/framework/snippets/src/interactor.rs index 82c59752f6..6daa44b6c8 100644 --- a/framework/snippets/src/interactor.rs +++ b/framework/snippets/src/interactor.rs @@ -5,7 +5,7 @@ use multiversx_sc_scenario::{ scenario_model::AddressValue, }; use multiversx_sdk::{ - blockchain::CommunicationProxy, + blockchain::GatewayProxy, data::{address::Address as ErdrsAddress, network_config::NetworkConfig}, wallet::Wallet, }; @@ -20,7 +20,7 @@ use crate::{account_tool::retrieve_account_as_scenario_set_state, Sender}; pub const INTERACTOR_SCENARIO_TRACE_PATH: &str = "interactor_trace.scen.json"; pub struct Interactor { - pub proxy: CommunicationProxy, + pub proxy: GatewayProxy, pub network_config: NetworkConfig, pub sender_map: HashMap, @@ -33,7 +33,7 @@ pub struct Interactor { impl Interactor { pub async fn new(gateway_url: &str) -> Self { - let proxy = CommunicationProxy::new(gateway_url.to_string()); + let proxy = GatewayProxy::new(gateway_url.to_string()); let network_config = proxy.get_network_config().await.unwrap(); Self { proxy, diff --git a/sdk/core/examples/account.rs b/sdk/core/examples/account.rs index 2ad1d6c4cc..16a9e2d8a9 100644 --- a/sdk/core/examples/account.rs +++ b/sdk/core/examples/account.rs @@ -1,5 +1,5 @@ use multiversx_sdk::{ - blockchain::{CommunicationProxy, DEVNET_GATEWAY}, + blockchain::{GatewayProxy, DEVNET_GATEWAY}, data::address::Address, }; @@ -10,7 +10,7 @@ async fn main() { ) .unwrap(); - let blockchain = CommunicationProxy::new(DEVNET_GATEWAY.to_string()); + let blockchain = GatewayProxy::new(DEVNET_GATEWAY.to_string()); let account = blockchain.get_account(&addr).await.unwrap(); println!("account: {account:#?}"); diff --git a/sdk/core/examples/account_storage.rs b/sdk/core/examples/account_storage.rs index 31adc7d0f9..c081e67e58 100644 --- a/sdk/core/examples/account_storage.rs +++ b/sdk/core/examples/account_storage.rs @@ -1,5 +1,5 @@ use multiversx_sdk::{ - blockchain::{CommunicationProxy, DEVNET_GATEWAY}, + blockchain::{GatewayProxy, DEVNET_GATEWAY}, data::address::Address, }; @@ -10,7 +10,7 @@ async fn main() { ) .unwrap(); - let blockchain = CommunicationProxy::new(DEVNET_GATEWAY.to_string()); + let blockchain = GatewayProxy::new(DEVNET_GATEWAY.to_string()); let account_storage = blockchain.get_account_storage_keys(&addr).await.unwrap(); println!("Account Storage: {account_storage:#?}"); diff --git a/sdk/core/examples/get_esdt_tokens.rs b/sdk/core/examples/get_esdt_tokens.rs index faa4debfba..5dc62b5098 100644 --- a/sdk/core/examples/get_esdt_tokens.rs +++ b/sdk/core/examples/get_esdt_tokens.rs @@ -1,5 +1,5 @@ use multiversx_sdk::{ - blockchain::{CommunicationProxy, DEVNET_GATEWAY}, + blockchain::{GatewayProxy, DEVNET_GATEWAY}, data::address::Address, }; @@ -10,7 +10,7 @@ async fn main() { ) .unwrap(); - let blockchain = CommunicationProxy::new(DEVNET_GATEWAY.to_string()); + let blockchain = GatewayProxy::new(DEVNET_GATEWAY.to_string()); let balances = blockchain.get_account_esdt_tokens(&addr).await.unwrap(); println!("{balances:#?}"); diff --git a/sdk/core/examples/get_hyper_block_by_hash.rs b/sdk/core/examples/get_hyper_block_by_hash.rs index c67b479767..b0f0d34a2d 100644 --- a/sdk/core/examples/get_hyper_block_by_hash.rs +++ b/sdk/core/examples/get_hyper_block_by_hash.rs @@ -1,8 +1,8 @@ -use multiversx_sdk::blockchain::{CommunicationProxy, DEVNET_GATEWAY}; +use multiversx_sdk::blockchain::{GatewayProxy, DEVNET_GATEWAY}; #[tokio::main] async fn main() { - let blockchain = CommunicationProxy::new(DEVNET_GATEWAY.to_string()); + let blockchain = GatewayProxy::new(DEVNET_GATEWAY.to_string()); let result = blockchain .get_hyper_block_by_hash("20b14ba0e68c465810c5ded091f220e51dad41629d7ccd87dab572206185e419") .await; diff --git a/sdk/core/examples/get_hyper_block_by_nonce.rs b/sdk/core/examples/get_hyper_block_by_nonce.rs index c3d270d2bc..e033b57156 100644 --- a/sdk/core/examples/get_hyper_block_by_nonce.rs +++ b/sdk/core/examples/get_hyper_block_by_nonce.rs @@ -1,8 +1,8 @@ -use multiversx_sdk::blockchain::{CommunicationProxy, DEVNET_GATEWAY}; +use multiversx_sdk::blockchain::{GatewayProxy, DEVNET_GATEWAY}; #[tokio::main] async fn main() { - let blockchain = CommunicationProxy::new(DEVNET_GATEWAY.to_string()); + let blockchain = GatewayProxy::new(DEVNET_GATEWAY.to_string()); let result = blockchain.get_hyper_block_by_nonce(7468).await; println!("block by nonce result: {result:?}") diff --git a/sdk/core/examples/get_hyper_block_latest.rs b/sdk/core/examples/get_hyper_block_latest.rs index b9ad946829..1ab8d51350 100644 --- a/sdk/core/examples/get_hyper_block_latest.rs +++ b/sdk/core/examples/get_hyper_block_latest.rs @@ -1,8 +1,8 @@ -use multiversx_sdk::blockchain::{CommunicationProxy, DEVNET_GATEWAY}; +use multiversx_sdk::blockchain::{GatewayProxy, DEVNET_GATEWAY}; #[tokio::main] async fn main() { - let blockchain = CommunicationProxy::new(DEVNET_GATEWAY.to_string()); + let blockchain = GatewayProxy::new(DEVNET_GATEWAY.to_string()); let result = blockchain.get_latest_hyper_block_nonce(false).await; println!("latest block result: {result:?}") diff --git a/sdk/core/examples/get_network_config.rs b/sdk/core/examples/get_network_config.rs index 7ca699b3c8..1c9ada08c6 100644 --- a/sdk/core/examples/get_network_config.rs +++ b/sdk/core/examples/get_network_config.rs @@ -1,8 +1,8 @@ -use multiversx_sdk::blockchain::{CommunicationProxy, DEVNET_GATEWAY}; +use multiversx_sdk::blockchain::{GatewayProxy, DEVNET_GATEWAY}; #[tokio::main] async fn main() { - let blockchain = CommunicationProxy::new(DEVNET_GATEWAY.to_string()); + let blockchain = GatewayProxy::new(DEVNET_GATEWAY.to_string()); let network_config = blockchain.get_network_config().await.unwrap(); println!("network_config: {network_config:#?}") diff --git a/sdk/core/examples/get_network_economics.rs b/sdk/core/examples/get_network_economics.rs index e562f3db46..568c3b8378 100644 --- a/sdk/core/examples/get_network_economics.rs +++ b/sdk/core/examples/get_network_economics.rs @@ -1,8 +1,8 @@ -use multiversx_sdk::blockchain::{CommunicationProxy, DEVNET_GATEWAY}; +use multiversx_sdk::blockchain::{GatewayProxy, DEVNET_GATEWAY}; #[tokio::main] async fn main() { - let blockchain = CommunicationProxy::new(DEVNET_GATEWAY.to_string()); + let blockchain = GatewayProxy::new(DEVNET_GATEWAY.to_string()); let network_economics = blockchain.get_network_economics().await.unwrap(); println!("network_economics: {network_economics:#?}") diff --git a/sdk/core/examples/sign_tx.rs b/sdk/core/examples/sign_tx.rs index 1455061830..e9e7da0225 100644 --- a/sdk/core/examples/sign_tx.rs +++ b/sdk/core/examples/sign_tx.rs @@ -1,5 +1,5 @@ use multiversx_sdk::{ - blockchain::{CommunicationProxy, DEVNET_GATEWAY}, + blockchain::{GatewayProxy, DEVNET_GATEWAY}, data::transaction::Transaction, wallet::Wallet, }; @@ -11,7 +11,7 @@ async fn main() { ) .unwrap(); let addr = wl.address(); - let blockchain = CommunicationProxy::new(DEVNET_GATEWAY.to_string()); + let blockchain = GatewayProxy::new(DEVNET_GATEWAY.to_string()); let network_config = blockchain.get_network_config().await.unwrap(); let arg = blockchain diff --git a/sdk/core/examples/sign_txs.rs b/sdk/core/examples/sign_txs.rs index 6a4a12a231..672cf9f08f 100644 --- a/sdk/core/examples/sign_txs.rs +++ b/sdk/core/examples/sign_txs.rs @@ -1,5 +1,5 @@ use multiversx_sdk::{ - blockchain::{CommunicationProxy, DEVNET_GATEWAY}, + blockchain::{GatewayProxy, DEVNET_GATEWAY}, data::transaction::Transaction, wallet::Wallet, }; @@ -11,7 +11,7 @@ async fn main() { ) .unwrap(); let addr = wl.address(); - let blockchain = CommunicationProxy::new(DEVNET_GATEWAY.to_string()); + let blockchain = GatewayProxy::new(DEVNET_GATEWAY.to_string()); let network_config = blockchain.get_network_config().await.unwrap(); let arg = blockchain diff --git a/sdk/core/examples/tx_cost.rs b/sdk/core/examples/tx_cost.rs index b98cbd2e4b..0e05be8420 100644 --- a/sdk/core/examples/tx_cost.rs +++ b/sdk/core/examples/tx_cost.rs @@ -1,5 +1,5 @@ use multiversx_sdk::{ - blockchain::{CommunicationProxy, DEVNET_GATEWAY}, + blockchain::{GatewayProxy, DEVNET_GATEWAY}, data::{address::Address, transaction::Transaction}, utils::base64_encode, }; @@ -26,7 +26,7 @@ async fn main() { signature: None, }; - let blockchain = CommunicationProxy::new(DEVNET_GATEWAY.to_string()); + let blockchain = GatewayProxy::new(DEVNET_GATEWAY.to_string()); let cost = blockchain.request_transaction_cost(&tx).await.unwrap(); println!("tx cost: {cost:#?}"); diff --git a/sdk/core/examples/tx_default_args.rs b/sdk/core/examples/tx_default_args.rs index dad593eaf8..45dd3b9473 100644 --- a/sdk/core/examples/tx_default_args.rs +++ b/sdk/core/examples/tx_default_args.rs @@ -1,11 +1,11 @@ use multiversx_sdk::{ - blockchain::{CommunicationProxy, DEVNET_GATEWAY}, + blockchain::{GatewayProxy, DEVNET_GATEWAY}, data::address::Address, }; #[tokio::main] async fn main() { - let blockchain = CommunicationProxy::new(DEVNET_GATEWAY.to_string()); + let blockchain = GatewayProxy::new(DEVNET_GATEWAY.to_string()); let network_config = blockchain.get_network_config().await.unwrap(); let addr = Address::from_bech32_string( "erd1qqqqqqqqqqqqqpgqfzydqmdw7m2vazsp6u5p95yxz76t2p9rd8ss0zp9ts", diff --git a/sdk/core/examples/tx_info.rs b/sdk/core/examples/tx_info.rs index 33c929be50..bfad3fb1ca 100644 --- a/sdk/core/examples/tx_info.rs +++ b/sdk/core/examples/tx_info.rs @@ -1,9 +1,9 @@ -use multiversx_sdk::blockchain::{CommunicationProxy, DEVNET_GATEWAY}; +use multiversx_sdk::blockchain::{GatewayProxy, DEVNET_GATEWAY}; #[tokio::main] async fn main() { let tx_hash = "49edb289892a655a0e988b360c19326c21107f9696c6197b435667c6e8c6e1a3"; - let blockchain = CommunicationProxy::new(DEVNET_GATEWAY.to_string()); + let blockchain = GatewayProxy::new(DEVNET_GATEWAY.to_string()); let status = blockchain.get_transaction_status(tx_hash).await; println!("tx status: {status:?}"); diff --git a/sdk/core/examples/vm_query.rs b/sdk/core/examples/vm_query.rs index 41cdfd5dbf..df7d3b43ee 100644 --- a/sdk/core/examples/vm_query.rs +++ b/sdk/core/examples/vm_query.rs @@ -1,5 +1,5 @@ use multiversx_sdk::{ - blockchain::{CommunicationProxy, DEVNET_GATEWAY}, + blockchain::{GatewayProxy, DEVNET_GATEWAY}, data::{address::Address, vm::VmValueRequest}, wallet::Wallet, }; @@ -11,7 +11,7 @@ async fn main() { ) .unwrap(); let addr = wl.address(); - let blockchain = CommunicationProxy::new(DEVNET_GATEWAY.to_string()); + let blockchain = GatewayProxy::new(DEVNET_GATEWAY.to_string()); let req = VmValueRequest { sc_address: Address::from_bech32_string( "erd1qqqqqqqqqqqqqpgqhn3ae8dpc957t7jadn7kywtg503dy7pnj9ts3umqxx", diff --git a/sdk/core/src/blockchain.rs b/sdk/core/src/blockchain.rs index 05bad7198a..35e2668b50 100644 --- a/sdk/core/src/blockchain.rs +++ b/sdk/core/src/blockchain.rs @@ -5,7 +5,7 @@ mod gateway_proxy; mod gateway_tx; mod gateway_tx_retrieve; -pub use gateway_proxy::CommunicationProxy; +pub use gateway_proxy::GatewayProxy; pub const MAINNET_GATEWAY: &str = "https://gateway.multiversx.com"; pub const TESTNET_GATEWAY: &str = "https://testnet-gateway.multiversx.com"; diff --git a/sdk/core/src/blockchain/gateway_account.rs b/sdk/core/src/blockchain/gateway_account.rs index f28cf6f562..7d72258544 100644 --- a/sdk/core/src/blockchain/gateway_account.rs +++ b/sdk/core/src/blockchain/gateway_account.rs @@ -7,12 +7,12 @@ use crate::data::{ use anyhow::{anyhow, Result}; use std::collections::HashMap; -use super::CommunicationProxy; +use super::GatewayProxy; const ACCOUNT_ENDPOINT: &str = "address/"; const KEYS_ENDPOINT: &str = "/keys/"; -impl CommunicationProxy { +impl GatewayProxy { // get_account retrieves an account info from the network (nonce, balance) pub async fn get_account(&self, address: &Address) -> Result { if !address.is_valid() { diff --git a/sdk/core/src/blockchain/gateway_block.rs b/sdk/core/src/blockchain/gateway_block.rs index 38827ea6db..b6daf57abb 100644 --- a/sdk/core/src/blockchain/gateway_block.rs +++ b/sdk/core/src/blockchain/gateway_block.rs @@ -4,14 +4,14 @@ use crate::data::{ }; use anyhow::{anyhow, Result}; -use super::CommunicationProxy; +use super::GatewayProxy; use super::METACHAIN_SHARD_ID; const GET_HYPER_BLOCK_BY_NONCE_ENDPOINT: &str = "hyperblock/by-nonce/"; const GET_HYPER_BLOCK_BY_HASH_ENDPOINT: &str = "hyperblock/by-hash/"; const GET_NETWORK_STATUS_ENDPOINT: &str = "network/status"; -impl CommunicationProxy { +impl GatewayProxy { async fn get_hyper_block(&self, endpoint: &str) -> Result { let endpoint = self.get_endpoint(endpoint); let resp = self diff --git a/sdk/core/src/blockchain/gateway_network.rs b/sdk/core/src/blockchain/gateway_network.rs index 2d425d461e..8b02a57d0d 100644 --- a/sdk/core/src/blockchain/gateway_network.rs +++ b/sdk/core/src/blockchain/gateway_network.rs @@ -4,12 +4,12 @@ use crate::data::{ }; use anyhow::{anyhow, Result}; -use super::CommunicationProxy; +use super::GatewayProxy; const NETWORK_CONFIG_ENDPOINT: &str = "network/config"; const NETWORK_ECONOMICS_ENDPOINT: &str = "network/economics"; -impl CommunicationProxy { +impl GatewayProxy { // get_network_config retrieves the network configuration from the proxy pub async fn get_network_config(&self) -> Result { let endpoint = self.get_endpoint(NETWORK_CONFIG_ENDPOINT); diff --git a/sdk/core/src/blockchain/gateway_proxy.rs b/sdk/core/src/blockchain/gateway_proxy.rs index 9643abd5ca..47925cd79f 100644 --- a/sdk/core/src/blockchain/gateway_proxy.rs +++ b/sdk/core/src/blockchain/gateway_proxy.rs @@ -1,12 +1,13 @@ use reqwest::Client; +/// Allows communication with the MultiversX gateway API. #[derive(Clone, Debug)] -pub struct CommunicationProxy { +pub struct GatewayProxy { pub(crate) proxy_url: String, pub(crate) client: Client, } -impl CommunicationProxy { +impl GatewayProxy { pub fn new(proxy_url: String) -> Self { Self { proxy_url, diff --git a/sdk/core/src/blockchain/gateway_tx.rs b/sdk/core/src/blockchain/gateway_tx.rs index 641e1ae511..47aa8b5a83 100644 --- a/sdk/core/src/blockchain/gateway_tx.rs +++ b/sdk/core/src/blockchain/gateway_tx.rs @@ -10,7 +10,7 @@ use crate::data::{ use anyhow::{anyhow, Result}; use itertools::Itertools; -use super::CommunicationProxy; +use super::GatewayProxy; const COST_TRANSACTION_ENDPOINT: &str = "transaction/cost"; const SEND_TRANSACTION_ENDPOINT: &str = "transaction/send"; @@ -19,7 +19,7 @@ const GET_TRANSACTION_INFO_ENDPOINT: &str = "transaction/"; const WITH_RESULTS_QUERY_PARAM: &str = "?withResults=true"; const VM_VALUES_ENDPOINT: &str = "vm-values/query"; -impl CommunicationProxy { +impl GatewayProxy { // request_transaction_cost retrieves how many gas a transaction will consume pub async fn request_transaction_cost(&self, tx: &Transaction) -> Result { let endpoint = self.get_endpoint(COST_TRANSACTION_ENDPOINT); diff --git a/sdk/core/src/blockchain/gateway_tx_retrieve.rs b/sdk/core/src/blockchain/gateway_tx_retrieve.rs index 44a0357432..821713f972 100644 --- a/sdk/core/src/blockchain/gateway_tx_retrieve.rs +++ b/sdk/core/src/blockchain/gateway_tx_retrieve.rs @@ -2,13 +2,13 @@ use crate::data::transaction::TransactionOnNetwork; use log::info; use std::time::{Duration, Instant}; -use super::CommunicationProxy; +use super::GatewayProxy; const INITIAL_BACKOFF_DELAY: f32 = 1.4; const MAX_RETRIES: usize = 8; const MAX_BACKOFF_DELAY: Duration = Duration::from_secs(6); -impl CommunicationProxy { +impl GatewayProxy { /// Retrieves a transaction from the network. pub async fn retrieve_tx_on_network(&self, tx_hash: String) -> TransactionOnNetwork { let mut retries = 0;