diff --git a/Cargo.lock b/Cargo.lock index 699420da34..e7d39bfcc6 100755 --- a/Cargo.lock +++ b/Cargo.lock @@ -2161,6 +2161,7 @@ dependencies = [ "hmac", "itertools", "log", + "multiversx-chain-core", "pbkdf2", "pem", "rand", @@ -2319,9 +2320,12 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1" +dependencies = [ + "portable-atomic", +] [[package]] name = "openssl" @@ -2554,6 +2558,12 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" +[[package]] +name = "portable-atomic" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" + [[package]] name = "ppv-lite86" version = "0.2.20" @@ -2738,18 +2748,18 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "355ae415ccd3a04315d3f8246e86d67689ea74d88d915576e1589a351062a13b" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ "bitflags", ] [[package]] name = "regex" -version = "1.10.6" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", @@ -2759,9 +2769,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", @@ -2770,9 +2780,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" @@ -2956,9 +2966,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" +checksum = "0e696e35370c65c9c541198af4543ccd580cf17fc25d8e05c5a242b202488c55" [[package]] name = "rustls-webpki" @@ -3389,9 +3399,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.12.0" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" +checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" dependencies = [ "cfg-if", "fastrand", diff --git a/contracts/examples/adder/interact/config.toml b/contracts/examples/adder/interact/config.toml index 64846243cc..c6f9a97a1d 100644 --- a/contracts/examples/adder/interact/config.toml +++ b/contracts/examples/adder/interact/config.toml @@ -1,2 +1,5 @@ -chain_type = 'simulator' -gateway_uri = 'http://localhost:8085' +# chain_type = 'simulator' +# gateway_uri = 'http://localhost:8085' + +chain_type = 'real' +gateway_uri = 'https://devnet-gateway.multiversx.com' diff --git a/framework/snippets/src/interactor.rs b/framework/snippets/src/interactor.rs index 3102d88d64..41a4db046e 100644 --- a/framework/snippets/src/interactor.rs +++ b/framework/snippets/src/interactor.rs @@ -2,13 +2,8 @@ use multiversx_sc_scenario::{ imports::{Bech32Address, ScenarioRunner}, mandos_system::{run_list::ScenarioRunnerList, run_trace::ScenarioTraceFile}, multiversx_sc::types::Address, - scenario_model::AddressValue, -}; -use multiversx_sdk::{ - data::{address::Address as ErdrsAddress, network_config::NetworkConfig}, - gateway::GatewayProxy, - wallet::Wallet, }; +use multiversx_sdk::{data::network_config::NetworkConfig, gateway::GatewayProxy, wallet::Wallet}; use std::{ collections::HashMap, path::{Path, PathBuf}, @@ -47,12 +42,13 @@ impl Interactor { } pub async fn register_wallet(&mut self, wallet: Wallet) -> Address { - let address = erdrs_address_to_h256(wallet.address()); + let wallet_address = wallet.address(); self.proxy - .send_user_funds(&Bech32Address::from(&address).to_bech32_string()) + .send_user_funds(&wallet_address.to_bech32_string().unwrap()) .await .unwrap(); + let address: Address = wallet_address.into(); self.sender_map.insert( address.clone(), Sender { @@ -80,17 +76,3 @@ impl Interactor { self.post_runners.run_set_state_step(&set_state); } } - -pub(crate) fn mandos_to_erdrs_address(mandos_address: &AddressValue) -> ErdrsAddress { - let bytes = mandos_address.value.as_array(); - ErdrsAddress::from_bytes(*bytes) -} - -pub(crate) fn address_h256_to_erdrs(address: &Address) -> ErdrsAddress { - let bytes = address.as_array(); - ErdrsAddress::from_bytes(*bytes) -} - -pub(crate) fn erdrs_address_to_h256(erdrs_address: ErdrsAddress) -> Address { - erdrs_address.to_bytes().into() -} diff --git a/framework/snippets/src/interactor_scenario/interactor_sc_call.rs b/framework/snippets/src/interactor_scenario/interactor_sc_call.rs index a9d3930eb6..fa84d7ac04 100644 --- a/framework/snippets/src/interactor_scenario/interactor_sc_call.rs +++ b/framework/snippets/src/interactor_scenario/interactor_sc_call.rs @@ -1,4 +1,4 @@ -use crate::{address_h256_to_erdrs, mandos_to_erdrs_address, network_response, Interactor}; +use crate::{network_response, Interactor}; use log::info; use multiversx_sc_scenario::{ api::StaticApi, @@ -61,8 +61,8 @@ impl Interactor { Transaction { nonce: 0, value: contract_call.egld_payment.to_alloc().to_string(), - sender: mandos_to_erdrs_address(&tx_call.from), - receiver: address_h256_to_erdrs(&contract_call.basic.to.to_address()), + sender: tx_call.from.to_address().into(), + receiver: contract_call.basic.to.to_address().into(), gas_price: self.network_config.min_gas_price, gas_limit: tx_call.gas_limit.value, data, diff --git a/framework/snippets/src/interactor_scenario/interactor_sc_deploy.rs b/framework/snippets/src/interactor_scenario/interactor_sc_deploy.rs index 20d45649d8..852307cf5a 100644 --- a/framework/snippets/src/interactor_scenario/interactor_sc_deploy.rs +++ b/framework/snippets/src/interactor_scenario/interactor_sc_deploy.rs @@ -1,24 +1,19 @@ -use crate::{mandos_to_erdrs_address, network_response, Interactor}; +use crate::{network_response, Interactor}; use log::info; use multiversx_sc_scenario::{ - imports::Bech32Address, + imports::{Address, Bech32Address}, mandos_system::ScenarioRunner, scenario_model::{ScDeployStep, SetStateStep}, }; -use multiversx_sdk::{ - data::{address::Address as ErdrsAddress, transaction::Transaction}, - utils::base64_encode, -}; - -const DEPLOY_RECEIVER: [u8; 32] = [0u8; 32]; +use multiversx_sdk::{data::transaction::Transaction, utils::base64_encode}; impl Interactor { pub(crate) fn sc_deploy_to_blockchain_tx(&self, sc_deploy_step: &ScDeployStep) -> Transaction { Transaction { nonce: 0, value: sc_deploy_step.tx.egld_value.value.to_string(), - sender: mandos_to_erdrs_address(&sc_deploy_step.tx.from), - receiver: ErdrsAddress::from_bytes(DEPLOY_RECEIVER), + sender: sc_deploy_step.tx.from.to_address().into(), + receiver: Address::zero().into(), gas_price: self.network_config.min_gas_price, gas_limit: sc_deploy_step.tx.gas_limit.value, data: Some(base64_encode(sc_deploy_step.tx.to_tx_data())), diff --git a/framework/snippets/src/interactor_scenario/interactor_vm_query.rs b/framework/snippets/src/interactor_scenario/interactor_vm_query.rs index aa9f87efb7..c28774eed4 100644 --- a/framework/snippets/src/interactor_scenario/interactor_vm_query.rs +++ b/framework/snippets/src/interactor_scenario/interactor_vm_query.rs @@ -1,6 +1,6 @@ #![allow(deprecated)] -use crate::{address_h256_to_erdrs, Interactor}; +use crate::Interactor; use log::info; use multiversx_sc_scenario::{ api::StaticApi, @@ -20,9 +20,9 @@ impl Interactor { } pub async fn perform_sc_query(&mut self, step: &mut ScQueryStep) { - let sc_address = address_h256_to_erdrs(&step.tx.to.to_address()); - let req = VmValueRequest { - sc_address: sc_address.clone(), + let sc_address = step.tx.to.to_address(); + let req = VmValueRequest { + sc_address: sc_address.clone().into(), func_name: step.tx.function.clone(), args: step .tx @@ -30,7 +30,7 @@ impl Interactor { .iter() .map(|arg| hex::encode(&arg.value)) .collect(), - caller: sc_address, + caller: sc_address.into(), value: "0".to_string(), }; let result = self diff --git a/framework/snippets/src/interactor_sender.rs b/framework/snippets/src/interactor_sender.rs index 86d6abcada..75d8e01198 100644 --- a/framework/snippets/src/interactor_sender.rs +++ b/framework/snippets/src/interactor_sender.rs @@ -2,7 +2,7 @@ use log::debug; use multiversx_sc_scenario::multiversx_sc::types::Address; use multiversx_sdk::{data::transaction::Transaction, wallet::Wallet}; -use crate::{address_h256_to_erdrs, Interactor}; +use crate::Interactor; /// A user account that can sign transactions (a pem is present). pub struct Sender { @@ -13,10 +13,9 @@ pub struct Sender { impl Interactor { pub async fn recall_nonce(&self, address: &Address) -> u64 { - let erdrs_address = address_h256_to_erdrs(address); let account = self .proxy - .get_account(&erdrs_address) + .get_account(&address.clone().into()) .await .expect("failed to retrieve account nonce"); account.nonce diff --git a/sdk/core/Cargo.toml b/sdk/core/Cargo.toml index 1dc7b129f5..283f74c2d0 100644 --- a/sdk/core/Cargo.toml +++ b/sdk/core/Cargo.toml @@ -38,4 +38,8 @@ log = "0.4.17" scrypt = "0.11" aes = "0.8" ctr = "0.9.2" -uuid = {version = "1.10.0", features = ["v4"]} \ No newline at end of file +uuid = {version = "1.10.0", features = ["v4"]} + +[dependencies.multiversx-chain-core] +version = "=0.10.0" +path = "../../vm-core" diff --git a/sdk/core/src/data/mod.rs b/sdk/core/src/data.rs similarity index 100% rename from sdk/core/src/data/mod.rs rename to sdk/core/src/data.rs diff --git a/sdk/core/src/data/address.rs b/sdk/core/src/data/address.rs index 49d92ea608..f41723219d 100644 --- a/sdk/core/src/data/address.rs +++ b/sdk/core/src/data/address.rs @@ -40,6 +40,18 @@ impl Address { } } +impl From for Address { + fn from(value: multiversx_chain_core::types::Address) -> Self { + Address(*value.as_array()) + } +} + +impl From
for multiversx_chain_core::types::Address { + fn from(value: Address) -> Self { + multiversx_chain_core::types::Address::new(value.0) + } +} + impl<'a> From<&'a PublicKey> for Address { fn from(public_key: &PublicKey) -> Address { let bytes = public_key.to_bytes();