From 6f43513f742b1d00954430a3fc4a272d53cf4f0c Mon Sep 17 00:00:00 2001 From: Andrei Marinica Date: Wed, 2 Oct 2024 23:43:33 +0300 Subject: [PATCH] SdkAddress rename --- framework/meta/src/cmd/wallet.rs | 4 +-- framework/snippets-dapp/src/account_tool.rs | 4 +-- framework/snippets-dapp/src/interactor.rs | 2 +- .../interactor_sc_deploy.rs | 2 +- framework/snippets/src/account_tool.rs | 4 +-- .../src/interactor_chain_simulator.rs | 4 +-- .../tests/test_tx_deployed_address.rs | 2 +- sdk/core/src/data.rs | 2 +- sdk/core/src/data/account.rs | 4 +-- .../src/data/{address.rs => sdk_address.rs} | 32 +++++++++---------- sdk/core/src/data/transaction.rs | 22 ++++++------- sdk/core/src/data/vm.rs | 10 +++--- sdk/core/src/gateway/gateway_account.rs | 6 ++-- .../src/gateway/gateway_account_esdt_roles.rs | 6 ++-- .../gateway/gateway_account_esdt_tokens.rs | 6 ++-- .../src/gateway/gateway_account_storage.rs | 6 ++-- sdk/core/src/wallet.rs | 14 +++++--- sdk/core/tests/wallet_test.rs | 10 +++--- sdk/http/examples/account.rs | 4 +-- sdk/http/examples/account_storage.rs | 4 +-- sdk/http/examples/get_esdt_tokens.rs | 4 +-- sdk/http/examples/tx_cost.rs | 6 ++-- sdk/http/examples/tx_default_args.rs | 4 +-- sdk/http/examples/vm_query.rs | 4 +-- .../src/gateway_http_proxy/http_account.rs | 10 +++--- sdk/http/src/gateway_http_proxy/http_tx.rs | 4 +-- sdk/wbg/src/gateway/gateway_account.rs | 10 +++--- sdk/wbg/src/gateway/gateway_tx.rs | 4 +-- 28 files changed, 100 insertions(+), 94 deletions(-) rename sdk/core/src/data/{address.rs => sdk_address.rs} (77%) diff --git a/framework/meta/src/cmd/wallet.rs b/framework/meta/src/cmd/wallet.rs index b3833da517..673c00bdec 100644 --- a/framework/meta/src/cmd/wallet.rs +++ b/framework/meta/src/cmd/wallet.rs @@ -3,7 +3,7 @@ use core::str; use crate::cli::{WalletAction, WalletArgs, WalletBech32Args, WalletConvertArgs, WalletNewArgs}; use multiversx_sc::types::{self}; use multiversx_sc_snippets::sdk::{ - crypto::public_key::PublicKey, data::address::Address, wallet::Wallet, + crypto::public_key::PublicKey, data::sdk_address::SdkAddress, wallet::Wallet, }; use multiversx_sc_snippets::{hex, imports::Bech32Address}; use std::{ @@ -137,7 +137,7 @@ fn bech32_conversion(bech32_args: &WalletBech32Args) { } } -fn get_wallet_address(private_key: &str) -> Address { +fn get_wallet_address(private_key: &str) -> SdkAddress { let wallet = Wallet::from_private_key(private_key).unwrap(); wallet.address() } diff --git a/framework/snippets-dapp/src/account_tool.rs b/framework/snippets-dapp/src/account_tool.rs index fad13ab314..b36df31183 100644 --- a/framework/snippets-dapp/src/account_tool.rs +++ b/framework/snippets-dapp/src/account_tool.rs @@ -4,7 +4,7 @@ use multiversx_sc_scenario::{ scenario_model::{Account, BytesKey, BytesValue, Scenario, SetStateStep, Step}, }; use multiversx_sdk_wbg::{ - data::{address::Address, esdt::EsdtBalance}, + data::{esdt::EsdtBalance, sdk_address::SdkAddress}, gateway::GatewayProxy, }; use std::collections::{BTreeMap, HashMap}; @@ -37,7 +37,7 @@ pub async fn retrieve_account_as_scenario_set_state( api: &GatewayProxy, address: &Bech32Address, ) -> SetStateStep { - let sdk_address = Address::from_bech32_string(address.to_bech32_str()).unwrap(); + let sdk_address = SdkAddress::from_bech32_string(address.to_bech32_str()).unwrap(); let sdk_account = api.get_account(&sdk_address).await.unwrap(); let account_esdt = api diff --git a/framework/snippets-dapp/src/interactor.rs b/framework/snippets-dapp/src/interactor.rs index 882fb0440d..d8edb7fdd8 100644 --- a/framework/snippets-dapp/src/interactor.rs +++ b/framework/snippets-dapp/src/interactor.rs @@ -6,7 +6,7 @@ use multiversx_sc_scenario::{ scenario_model::AddressValue, }; use multiversx_sdk_wbg::{ - data::{address::Address as ErdrsAddress, network_config::NetworkConfig}, + data::{network_config::NetworkConfig, sdk_address::SdkAddress as ErdrsAddress}, gateway::GatewayProxy, wallet::Wallet, }; diff --git a/framework/snippets-dapp/src/interactor_scenario/interactor_sc_deploy.rs b/framework/snippets-dapp/src/interactor_scenario/interactor_sc_deploy.rs index 83bcd10f94..e5b731757e 100644 --- a/framework/snippets-dapp/src/interactor_scenario/interactor_sc_deploy.rs +++ b/framework/snippets-dapp/src/interactor_scenario/interactor_sc_deploy.rs @@ -6,7 +6,7 @@ use multiversx_sc_scenario::{ scenario_model::{ScDeployStep, SetStateStep}, }; use multiversx_sdk_wbg::{ - data::{address::Address as ErdrsAddress, transaction::Transaction}, + data::{sdk_address::SdkAddress as ErdrsAddress, transaction::Transaction}, utils::base64_encode, }; diff --git a/framework/snippets/src/account_tool.rs b/framework/snippets/src/account_tool.rs index 660f27e10a..9b259296ef 100644 --- a/framework/snippets/src/account_tool.rs +++ b/framework/snippets/src/account_tool.rs @@ -1,4 +1,4 @@ -use crate::sdk_core::data::{address::Address, esdt::EsdtBalance}; +use crate::sdk_core::data::{esdt::EsdtBalance, sdk_address::SdkAddress}; use multiversx_chain_scenario_format::interpret_trait::IntoRaw; use multiversx_sc_scenario::{ imports::Bech32Address, @@ -38,7 +38,7 @@ pub async fn retrieve_account_as_scenario_set_state( use_chain_simulator: bool, address: &Bech32Address, ) -> SetStateStep { - let sdk_address = Address::from_bech32_string(address.to_bech32_str()).unwrap(); + let sdk_address = SdkAddress::from_bech32_string(address.to_bech32_str()).unwrap(); let sdk_account = api.get_account(&sdk_address).await.unwrap(); let (account_esdt, account_esdt_roles, account_storage) = if use_chain_simulator { diff --git a/framework/snippets/src/interactor_chain_simulator.rs b/framework/snippets/src/interactor_chain_simulator.rs index b0c9fb92c0..89898b8e23 100644 --- a/framework/snippets/src/interactor_chain_simulator.rs +++ b/framework/snippets/src/interactor_chain_simulator.rs @@ -1,6 +1,6 @@ use anyhow::Error; use multiversx_sdk::{ - data::address::Address, + data::sdk_address::SdkAddress, gateway::{ ChainSimulatorGenerateBlocksRequest, ChainSimulatorSendFundsRequest, GatewayAsyncService, }, @@ -9,7 +9,7 @@ use multiversx_sdk::{ use crate::Interactor; impl Interactor { - pub async fn send_user_funds(&self, receiver: &Address) -> Result { + pub async fn send_user_funds(&self, receiver: &SdkAddress) -> Result { if !self.use_chain_simulator { return Ok(String::from("no-simulator")); } diff --git a/framework/snippets/tests/test_tx_deployed_address.rs b/framework/snippets/tests/test_tx_deployed_address.rs index 702f069cf8..69a397e371 100644 --- a/framework/snippets/tests/test_tx_deployed_address.rs +++ b/framework/snippets/tests/test_tx_deployed_address.rs @@ -55,7 +55,7 @@ fn test_deployed_address() { .transaction; let tx_response = network_response::parse_tx_response(tx_on_network); let opt_address = tx_response.new_deployed_address.map(|e| { - multiversx_sc_snippets::sdk::data::address::Address::from_bytes(*e.as_array()) + multiversx_sc_snippets::sdk::data::sdk_address::SdkAddress::from_bytes(*e.as_array()) .to_bech32_string() .unwrap() }); diff --git a/sdk/core/src/data.rs b/sdk/core/src/data.rs index 9a270211df..ce4af36eca 100644 --- a/sdk/core/src/data.rs +++ b/sdk/core/src/data.rs @@ -1,11 +1,11 @@ pub mod account; pub mod account_storage; -pub mod address; pub mod esdt; pub mod hyperblock; pub mod keystore; pub mod network_config; pub mod network_economics; pub mod network_status; +pub mod sdk_address; pub mod transaction; pub mod vm; diff --git a/sdk/core/src/data/account.rs b/sdk/core/src/data/account.rs index cf3f4caa8c..dae88a83c7 100644 --- a/sdk/core/src/data/account.rs +++ b/sdk/core/src/data/account.rs @@ -1,11 +1,11 @@ -use super::address::Address; +use super::sdk_address::SdkAddress; use serde::{Deserialize, Serialize}; // Account holds an Account's information #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Account { - pub address: Address, + pub address: SdkAddress, pub nonce: u64, pub balance: String, pub username: String, diff --git a/sdk/core/src/data/address.rs b/sdk/core/src/data/sdk_address.rs similarity index 77% rename from sdk/core/src/data/address.rs rename to sdk/core/src/data/sdk_address.rs index f41723219d..0e9594bb42 100644 --- a/sdk/core/src/data/address.rs +++ b/sdk/core/src/data/sdk_address.rs @@ -9,9 +9,9 @@ use serde::{ }; #[derive(Clone)] -pub struct Address([u8; 32]); +pub struct SdkAddress([u8; 32]); -impl Address { +impl SdkAddress { pub fn from_bytes(bytes: [u8; 32]) -> Self { Self(bytes) } @@ -40,48 +40,48 @@ impl Address { } } -impl From for Address { +impl From for SdkAddress { fn from(value: multiversx_chain_core::types::Address) -> Self { - Address(*value.as_array()) + SdkAddress(*value.as_array()) } } -impl From
for multiversx_chain_core::types::Address { - fn from(value: Address) -> Self { +impl From for multiversx_chain_core::types::Address { + fn from(value: SdkAddress) -> Self { multiversx_chain_core::types::Address::new(value.0) } } -impl<'a> From<&'a PublicKey> for Address { - fn from(public_key: &PublicKey) -> Address { +impl<'a> From<&'a PublicKey> for SdkAddress { + fn from(public_key: &PublicKey) -> SdkAddress { let bytes = public_key.to_bytes(); let mut bits: [u8; 32] = [0u8; 32]; bits.copy_from_slice(&bytes); - Address(bits) + SdkAddress(bits) } } -impl Display for Address { +impl Display for SdkAddress { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.write_str(self.to_bech32_string().unwrap().as_str()) } } -impl Debug for Address { +impl Debug for SdkAddress { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.write_str(self.to_bech32_string().unwrap().as_str()) } } -impl Default for Address { +impl Default for SdkAddress { fn default() -> Self { - Address::from_bytes([0u8; 32]) + SdkAddress::from_bytes([0u8; 32]) } } -impl Serialize for Address { +impl Serialize for SdkAddress { fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -90,7 +90,7 @@ impl Serialize for Address { } } -impl<'de> Deserialize<'de> for Address { +impl<'de> Deserialize<'de> for SdkAddress { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, @@ -106,7 +106,7 @@ pub mod tests { #[test] fn test_decode_address() { - let addr = Address::from_bech32_string( + let addr = SdkAddress::from_bech32_string( "erd1qqqqqqqqqqqqqpgqyfjjn43spw7teklwtpz4x5waygq2mluyj9ts0mdwn6", ) .unwrap(); diff --git a/sdk/core/src/data/transaction.rs b/sdk/core/src/data/transaction.rs index 264d4fca49..29f04e6e68 100644 --- a/sdk/core/src/data/transaction.rs +++ b/sdk/core/src/data/transaction.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use super::{address::Address, vm::CallType}; +use super::{sdk_address::SdkAddress, vm::CallType}; use serde::{Deserialize, Serialize}; // Transaction holds the fields of a transaction to be broadcasted to the network @@ -9,8 +9,8 @@ use serde::{Deserialize, Serialize}; pub struct Transaction { pub nonce: u64, pub value: String, - pub receiver: Address, - pub sender: Address, + pub receiver: SdkAddress, + pub sender: SdkAddress, pub gas_price: u64, pub gas_limit: u64, #[serde(skip_serializing_if = "Option::is_none")] @@ -58,8 +58,8 @@ pub struct TransactionOnNetwork { pub round: u64, pub epoch: u64, pub value: String, - pub receiver: Address, - pub sender: Address, + pub receiver: SdkAddress, + pub sender: SdkAddress, pub gas_price: u64, pub gas_limit: u64, #[serde(default)] @@ -90,7 +90,7 @@ pub struct TransactionOnNetwork { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Events { - pub address: Address, + pub address: SdkAddress, pub identifier: String, pub topics: Option>, #[serde(default)] @@ -120,7 +120,7 @@ impl LogData { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct ApiLogs { - pub address: Address, + pub address: SdkAddress, pub events: Vec, } @@ -130,8 +130,8 @@ pub struct ApiSmartContractResult { pub hash: String, pub nonce: u64, pub value: u64, - pub receiver: Address, - pub sender: Address, + pub receiver: SdkAddress, + pub sender: SdkAddress, pub data: String, pub prev_tx_hash: String, pub original_tx_hash: String, @@ -192,8 +192,8 @@ pub struct TransactionProcessStatus { pub struct ArgCreateTransaction { pub nonce: u64, pub value: String, - pub rcv_addr: Address, - pub snd_addr: Address, + pub rcv_addr: SdkAddress, + pub snd_addr: SdkAddress, pub gas_price: u64, pub gas_limit: u64, pub data: Option, diff --git a/sdk/core/src/data/vm.rs b/sdk/core/src/data/vm.rs index df741ccd4e..4b63afed68 100644 --- a/sdk/core/src/data/vm.rs +++ b/sdk/core/src/data/vm.rs @@ -1,4 +1,4 @@ -use super::address::Address; +use super::sdk_address::SdkAddress; use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; use std::collections::HashMap; @@ -26,7 +26,7 @@ pub enum CallType { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct VMQueryInput { - pub sc_address: Address, + pub sc_address: SdkAddress, pub func_name: String, pub args: Vec, } @@ -36,7 +36,7 @@ pub struct VMQueryInput { #[serde(rename_all = "camelCase")] pub struct LogEntryApi { pub identifier: String, - pub address: Address, + pub address: SdkAddress, pub topics: Vec, pub data: String, } @@ -49,14 +49,14 @@ pub struct OutputTransferApi { pub gas_limit: u64, pub data: String, pub call_type: CallType, - pub sender_address: Address, + pub sender_address: SdkAddress, } // OutputAccountApi is a wrapper over vmcommon's OutputAccount #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct OutputAccountApi { - address: Address, + address: SdkAddress, nonce: u64, // TODO: unknow type of data diff --git a/sdk/core/src/gateway/gateway_account.rs b/sdk/core/src/gateway/gateway_account.rs index f6b97c8ebd..daeaa3fd41 100644 --- a/sdk/core/src/gateway/gateway_account.rs +++ b/sdk/core/src/gateway/gateway_account.rs @@ -1,6 +1,6 @@ use crate::data::{ account::{Account, AccountResponse}, - address::Address, + sdk_address::SdkAddress, }; use anyhow::anyhow; @@ -9,11 +9,11 @@ use super::{GatewayRequest, GatewayRequestType}; /// Retrieves an account info from the network (nonce, balance). pub struct GetAccountRequest<'a> { - pub address: &'a Address, + pub address: &'a SdkAddress, } impl<'a> GetAccountRequest<'a> { - pub fn new(address: &'a Address) -> Self { + pub fn new(address: &'a SdkAddress) -> Self { Self { address } } } diff --git a/sdk/core/src/gateway/gateway_account_esdt_roles.rs b/sdk/core/src/gateway/gateway_account_esdt_roles.rs index 5152ec99c1..98017843c7 100644 --- a/sdk/core/src/gateway/gateway_account_esdt_roles.rs +++ b/sdk/core/src/gateway/gateway_account_esdt_roles.rs @@ -1,4 +1,4 @@ -use crate::data::{address::Address, esdt::EsdtRolesResponse}; +use crate::data::{esdt::EsdtRolesResponse, sdk_address::SdkAddress}; use anyhow::anyhow; use std::collections::HashMap; @@ -8,11 +8,11 @@ const ACCOUNT_ENDPOINT: &str = "address/"; /// Retrieves an all esdt roles of an account from the network. pub struct GetAccountEsdtRolesRequest<'a> { - pub address: &'a Address, + pub address: &'a SdkAddress, } impl<'a> GetAccountEsdtRolesRequest<'a> { - pub fn new(address: &'a Address) -> Self { + pub fn new(address: &'a SdkAddress) -> Self { Self { address } } } diff --git a/sdk/core/src/gateway/gateway_account_esdt_tokens.rs b/sdk/core/src/gateway/gateway_account_esdt_tokens.rs index e539521511..5fbb37614a 100644 --- a/sdk/core/src/gateway/gateway_account_esdt_tokens.rs +++ b/sdk/core/src/gateway/gateway_account_esdt_tokens.rs @@ -1,6 +1,6 @@ use crate::data::{ - address::Address, esdt::{EsdtBalance, EsdtBalanceResponse}, + sdk_address::SdkAddress, }; use anyhow::anyhow; use std::collections::HashMap; @@ -9,11 +9,11 @@ use super::{GatewayRequest, GatewayRequestType, ACCOUNT_ENDPOINT}; /// Retrieves an all esdt tokens of an account from the network. pub struct GetAccountEsdtTokensRequest<'a> { - pub address: &'a Address, + pub address: &'a SdkAddress, } impl<'a> GetAccountEsdtTokensRequest<'a> { - pub fn new(address: &'a Address) -> Self { + pub fn new(address: &'a SdkAddress) -> Self { Self { address } } } diff --git a/sdk/core/src/gateway/gateway_account_storage.rs b/sdk/core/src/gateway/gateway_account_storage.rs index 4793c84053..57f69943ad 100644 --- a/sdk/core/src/gateway/gateway_account_storage.rs +++ b/sdk/core/src/gateway/gateway_account_storage.rs @@ -1,4 +1,4 @@ -use crate::data::{account_storage::AccountStorageResponse, address::Address}; +use crate::data::{account_storage::AccountStorageResponse, sdk_address::SdkAddress}; use anyhow::anyhow; use std::collections::HashMap; @@ -6,11 +6,11 @@ use super::{GatewayRequest, GatewayRequestType, ACCOUNT_ENDPOINT, KEYS_ENDPOINT} /// Retrieves an account storage from the network. pub struct GetAccountStorageRequest<'a> { - pub address: &'a Address, + pub address: &'a SdkAddress, } impl<'a> GetAccountStorageRequest<'a> { - pub fn new(address: &'a Address) -> Self { + pub fn new(address: &'a SdkAddress) -> Self { Self { address } } } diff --git a/sdk/core/src/wallet.rs b/sdk/core/src/wallet.rs index df9b9dc43a..3f9de1f350 100644 --- a/sdk/core/src/wallet.rs +++ b/sdk/core/src/wallet.rs @@ -24,7 +24,7 @@ use crate::{ private_key::{PrivateKey, PRIVATE_KEY_LENGTH}, public_key::PublicKey, }, - data::{address::Address, keystore::*, transaction::Transaction}, + data::{keystore::*, sdk_address::SdkAddress, transaction::Transaction}, utils::*, }; @@ -192,9 +192,9 @@ impl Wallet { Ok(priv_key) } - pub fn address(&self) -> Address { + pub fn address(&self) -> SdkAddress { let public_key = PublicKey::from(&self.priv_key); - Address::from(&public_key) + SdkAddress::from(&public_key) } pub fn sign_tx(&self, unsign_tx: &Transaction) -> [u8; 64] { @@ -287,7 +287,7 @@ impl Wallet { pub fn encrypt_keystore( data: &[u8], - address: &Address, + address: &SdkAddress, public_key: &str, password: &str, ) -> String { @@ -344,7 +344,11 @@ impl Wallet { keystore_json } - pub fn generate_pem_content(address: &Address, private_key: &str, public_key: &str) -> String { + pub fn generate_pem_content( + address: &SdkAddress, + private_key: &str, + public_key: &str, + ) -> String { let concat_keys = format!("{}{}", private_key, public_key); let concat_keys_b64 = base64_encode(concat_keys); diff --git a/sdk/core/tests/wallet_test.rs b/sdk/core/tests/wallet_test.rs index 103166e430..6149996852 100644 --- a/sdk/core/tests/wallet_test.rs +++ b/sdk/core/tests/wallet_test.rs @@ -1,6 +1,8 @@ use bip39::Mnemonic; -use multiversx_sdk::{crypto::public_key::PublicKey, data::address::Address, wallet::Wallet}; +use multiversx_sdk::{ + crypto::public_key::PublicKey, data::sdk_address::SdkAddress, wallet::Wallet, +}; use std::fs::{self, File}; use std::io::Write; @@ -18,7 +20,7 @@ fn test_private_key_from_mnemonic() { let private_key = Wallet::get_private_key_from_mnemonic(mnemonic.clone(), 0, 0); let public_key = PublicKey::from(&private_key); - let address = Address::from(&public_key); + let address = SdkAddress::from(&public_key); assert_eq!( "0b7966138e80b8f3bb64046f56aea4250fd7bacad6ed214165cea6767fd0bc2c", private_key.to_string() @@ -34,7 +36,7 @@ fn test_private_key_from_mnemonic() { let private_key = Wallet::get_private_key_from_mnemonic(mnemonic, 0, 1); let public_key = PublicKey::from(&private_key); - let address = Address::from(&public_key); + let address = SdkAddress::from(&public_key); assert_eq!( "1648ad209d6b157a289884933e3bb30f161ec7113221ec16f87c3578b05830b0", private_key.to_string() @@ -64,7 +66,7 @@ fn write_to_file(content: &str, file: &str) { file.write_all(content.as_bytes()).unwrap(); } -fn create_keystore_file_from_scratch(file: &str) -> Address { +fn create_keystore_file_from_scratch(file: &str) -> SdkAddress { let wallet = Wallet::from_private_key(ALICE_PRIVATE_KEY).unwrap(); let address = wallet.address(); diff --git a/sdk/http/examples/account.rs b/sdk/http/examples/account.rs index a7265af3d3..86e72e2d42 100644 --- a/sdk/http/examples/account.rs +++ b/sdk/http/examples/account.rs @@ -1,9 +1,9 @@ -use multiversx_sdk::data::address::Address; +use multiversx_sdk::data::sdk_address::SdkAddress; use multiversx_sdk_http::{GatewayHttpProxy, DEVNET_GATEWAY}; #[tokio::main] async fn main() { - let addr = Address::from_bech32_string( + let addr = SdkAddress::from_bech32_string( "erd1qqqqqqqqqqqqqpgqfzydqmdw7m2vazsp6u5p95yxz76t2p9rd8ss0zp9ts", ) .unwrap(); diff --git a/sdk/http/examples/account_storage.rs b/sdk/http/examples/account_storage.rs index 688805b4e5..a5825e5140 100644 --- a/sdk/http/examples/account_storage.rs +++ b/sdk/http/examples/account_storage.rs @@ -1,9 +1,9 @@ -use multiversx_sdk::data::address::Address; +use multiversx_sdk::data::sdk_address::SdkAddress; use multiversx_sdk_http::{GatewayHttpProxy, DEVNET_GATEWAY}; #[tokio::main] async fn main() { - let addr = Address::from_bech32_string( + let addr = SdkAddress::from_bech32_string( "erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th", ) .unwrap(); diff --git a/sdk/http/examples/get_esdt_tokens.rs b/sdk/http/examples/get_esdt_tokens.rs index 1ff4116919..9c175931f0 100644 --- a/sdk/http/examples/get_esdt_tokens.rs +++ b/sdk/http/examples/get_esdt_tokens.rs @@ -1,9 +1,9 @@ -use multiversx_sdk::data::address::Address; +use multiversx_sdk::data::sdk_address::SdkAddress; use multiversx_sdk_http::{GatewayHttpProxy, DEVNET_GATEWAY}; #[tokio::main] async fn main() { - let addr = Address::from_bech32_string( + let addr = SdkAddress::from_bech32_string( "erd1pdv0h3ddqyzlraek02y5rhmjnwwapjyhqm983kfcdfzmr6axqhdsfg4akx", ) .unwrap(); diff --git a/sdk/http/examples/tx_cost.rs b/sdk/http/examples/tx_cost.rs index a01c7dae3e..8fd15decd6 100644 --- a/sdk/http/examples/tx_cost.rs +++ b/sdk/http/examples/tx_cost.rs @@ -1,5 +1,5 @@ use multiversx_sdk::{ - data::{address::Address, transaction::Transaction}, + data::{sdk_address::SdkAddress, transaction::Transaction}, utils::base64_encode, }; use multiversx_sdk_http::{GatewayHttpProxy, DEVNET_GATEWAY}; @@ -9,11 +9,11 @@ async fn main() { let tx = Transaction { nonce: 1, value: "50".to_string(), - receiver: Address::from_bech32_string( + receiver: SdkAddress::from_bech32_string( "erd1rh5ws22jxm9pe7dtvhfy6j3uttuupkepferdwtmslms5fydtrh5sx3xr8r", ) .unwrap(), - sender: Address::from_bech32_string( + sender: SdkAddress::from_bech32_string( "erd1rh5ws22jxm9pe7dtvhfy6j3uttuupkepferdwtmslms5fydtrh5sx3xr8r", ) .unwrap(), diff --git a/sdk/http/examples/tx_default_args.rs b/sdk/http/examples/tx_default_args.rs index bb9914b1a0..49e58cfea9 100644 --- a/sdk/http/examples/tx_default_args.rs +++ b/sdk/http/examples/tx_default_args.rs @@ -1,11 +1,11 @@ -use multiversx_sdk::data::address::Address; +use multiversx_sdk::data::sdk_address::SdkAddress; use multiversx_sdk_http::{GatewayHttpProxy, DEVNET_GATEWAY}; #[tokio::main] async fn main() { let blockchain = GatewayHttpProxy::new(DEVNET_GATEWAY.to_string()); let network_config = blockchain.get_network_config().await.unwrap(); - let addr = Address::from_bech32_string( + let addr = SdkAddress::from_bech32_string( "erd1qqqqqqqqqqqqqpgqfzydqmdw7m2vazsp6u5p95yxz76t2p9rd8ss0zp9ts", ) .unwrap(); diff --git a/sdk/http/examples/vm_query.rs b/sdk/http/examples/vm_query.rs index b933026dcd..1845b25ff2 100644 --- a/sdk/http/examples/vm_query.rs +++ b/sdk/http/examples/vm_query.rs @@ -1,10 +1,10 @@ -use multiversx_sdk::data::{address::Address, vm::VMQueryInput}; +use multiversx_sdk::data::{sdk_address::SdkAddress, vm::VMQueryInput}; use multiversx_sdk_http::{GatewayHttpProxy, DEVNET_GATEWAY}; #[tokio::main] async fn main() { let blockchain = GatewayHttpProxy::new(DEVNET_GATEWAY.to_string()); - let sc_address = Address::from_bech32_string( + let sc_address = SdkAddress::from_bech32_string( "erd1qqqqqqqqqqqqqpgq5dvvkmka7sujfsx7cfmygnx0n7luv8k0d8sskpqcec", ) .unwrap(); diff --git a/sdk/http/src/gateway_http_proxy/http_account.rs b/sdk/http/src/gateway_http_proxy/http_account.rs index 1ec2f489cf..41e8b24160 100644 --- a/sdk/http/src/gateway_http_proxy/http_account.rs +++ b/sdk/http/src/gateway_http_proxy/http_account.rs @@ -1,6 +1,6 @@ use anyhow::Result; use multiversx_sdk::{ - data::{account::Account, address::Address, esdt::EsdtBalance}, + data::{account::Account, esdt::EsdtBalance, sdk_address::SdkAddress}, gateway::{ GetAccountEsdtRolesRequest, GetAccountEsdtTokensRequest, GetAccountRequest, GetAccountStorageRequest, @@ -12,14 +12,14 @@ use super::GatewayHttpProxy; impl GatewayHttpProxy { // get_account retrieves an account info from the network (nonce, balance) - pub async fn get_account(&self, address: &Address) -> Result { + pub async fn get_account(&self, address: &SdkAddress) -> Result { self.http_request(GetAccountRequest::new(address)).await } // get_account_esdt_roles retrieves an all esdt roles of an account from the network pub async fn get_account_esdt_roles( &self, - address: &Address, + address: &SdkAddress, ) -> Result>> { self.http_request(GetAccountEsdtRolesRequest::new(address)) .await @@ -28,7 +28,7 @@ impl GatewayHttpProxy { // get_account_esdt_tokens retrieves an all esdt token of an account from the network pub async fn get_account_esdt_tokens( &self, - address: &Address, + address: &SdkAddress, ) -> Result> { self.http_request(GetAccountEsdtTokensRequest::new(address)) .await @@ -37,7 +37,7 @@ impl GatewayHttpProxy { // get_account_esdt_tokens retrieves an all esdt token of an account from the network pub async fn get_account_storage_keys( &self, - address: &Address, + address: &SdkAddress, ) -> Result> { self.http_request(GetAccountStorageRequest::new(address)) .await diff --git a/sdk/http/src/gateway_http_proxy/http_tx.rs b/sdk/http/src/gateway_http_proxy/http_tx.rs index 7ae18bc77d..36da680b05 100644 --- a/sdk/http/src/gateway_http_proxy/http_tx.rs +++ b/sdk/http/src/gateway_http_proxy/http_tx.rs @@ -1,8 +1,8 @@ use anyhow::Result; use multiversx_sdk::{ data::{ - address::Address, network_config::NetworkConfig, + sdk_address::SdkAddress, transaction::{ ArgCreateTransaction, Transaction, TransactionOnNetwork, TxCostResponseData, }, @@ -48,7 +48,7 @@ impl GatewayHttpProxy { // get_default_transaction_arguments will prepare the transaction creation argument by querying the account's info pub async fn get_default_transaction_arguments( &self, - address: &Address, + address: &SdkAddress, network_configs: &NetworkConfig, ) -> Result { let account = self.get_account(address).await?; diff --git a/sdk/wbg/src/gateway/gateway_account.rs b/sdk/wbg/src/gateway/gateway_account.rs index b298cc3fbc..8742f50f3e 100644 --- a/sdk/wbg/src/gateway/gateway_account.rs +++ b/sdk/wbg/src/gateway/gateway_account.rs @@ -3,8 +3,8 @@ use gloo_net::http::Request; use multiversx_sdk::data::{ account::{Account, AccountResponse}, account_storage::AccountStorageResponse, - address::Address, esdt::{EsdtBalance, EsdtBalanceResponse, EsdtRolesResponse}, + sdk_address::SdkAddress, }; use std::collections::HashMap; @@ -15,7 +15,7 @@ const KEYS_ENDPOINT: &str = "/keys/"; impl GatewayProxy { // get_account retrieves an account info from the network (nonce, balance) - pub async fn get_account(&self, address: &Address) -> Result { + pub async fn get_account(&self, address: &SdkAddress) -> Result { if !address.is_valid() { return Err(anyhow!("invalid address")); } @@ -37,7 +37,7 @@ impl GatewayProxy { // get_account_esdt_roles retrieves an all esdt roles of an account from the network pub async fn get_account_esdt_roles( &self, - address: &Address, + address: &SdkAddress, ) -> Result>> { if !address.is_valid() { return Err(anyhow!("invalid address")); @@ -61,7 +61,7 @@ impl GatewayProxy { // get_account_esdt_tokens retrieves an all esdt token of an account from the network pub async fn get_account_esdt_tokens( &self, - address: &Address, + address: &SdkAddress, ) -> Result> { if !address.is_valid() { return Err(anyhow!("invalid address")); @@ -84,7 +84,7 @@ impl GatewayProxy { // get_account_esdt_tokens retrieves an all esdt token of an account from the network pub async fn get_account_storage_keys( &self, - address: &Address, + address: &SdkAddress, ) -> Result> { if !address.is_valid() { return Err(anyhow!("invalid address")); diff --git a/sdk/wbg/src/gateway/gateway_tx.rs b/sdk/wbg/src/gateway/gateway_tx.rs index 9087822d25..25573dd827 100644 --- a/sdk/wbg/src/gateway/gateway_tx.rs +++ b/sdk/wbg/src/gateway/gateway_tx.rs @@ -2,8 +2,8 @@ use anyhow::{anyhow, Result}; use gloo_net::http::Request; use itertools::Itertools; use multiversx_sdk::data::{ - address::Address, network_config::NetworkConfig, + sdk_address::SdkAddress, transaction::{ ArgCreateTransaction, ResponseTxCost, SendTransactionResponse, SendTransactionsResponse, Transaction, TransactionInfo, TransactionOnNetwork, TransactionProcessStatus, @@ -112,7 +112,7 @@ impl GatewayProxy { // get_default_transaction_arguments will prepare the transaction creation argument by querying the account's info pub async fn get_default_transaction_arguments( &self, - address: &Address, + address: &SdkAddress, network_configs: &NetworkConfig, ) -> Result { let account = self.get_account(address).await?;