Skip to content

Commit

Permalink
Merge branch 'rc/v0.54' into merge-53-1
Browse files Browse the repository at this point in the history
  • Loading branch information
BiancaIalangi authored Oct 1, 2024
2 parents 68adc07 + 1448840 commit 5a7ab59
Show file tree
Hide file tree
Showing 144 changed files with 2,234 additions and 1,356 deletions.
55 changes: 55 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ members = [
# "tools/plotter",
"tools/interactor-system-func-calls/",

"vm-core",
"vm",

"contracts/modules",
Expand Down
6 changes: 5 additions & 1 deletion contracts/examples/adder/interact/config.toml
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
gateway = 'https://devnet-gateway.multiversx.com'
# chain_type = 'simulator'
# gateway_uri = 'http://localhost:8085'

chain_type = 'real'
gateway_uri = 'https://devnet-gateway.multiversx.com'
25 changes: 16 additions & 9 deletions contracts/examples/adder/interact/src/basic_interact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ mod basic_interact_cli;
mod basic_interact_config;
mod basic_interact_state;

use core::str;

use adder::adder_proxy;
use basic_interact_config::Config;
use basic_interact_state::State;
Expand Down Expand Up @@ -61,22 +63,27 @@ struct AdderInteract {
impl AdderInteract {
async fn init() -> Self {
let config = Config::load_config();
let mut interactor = Interactor::new(config.gateway())
let mut interactor = Interactor::new(config.gateway_uri(), config.use_chain_simulator())
.await
.with_tracer(INTERACTOR_SCENARIO_TRACE_PATH)
.await;

let adder_owner_address =
interactor.register_wallet(Wallet::from_pem_file("adder-owner.pem").unwrap());
let adder_owner_address = interactor
.register_wallet(Wallet::from_pem_file("adder-owner.pem").unwrap())
.await;
// PASSWORD: "alice"
// InsertPassword::Plaintext("alice".to_string()) || InsertPassword::StandardInput
let wallet_address = interactor.register_wallet(
Wallet::from_keystore_secret(
"alice.json",
InsertPassword::Plaintext("alice".to_string()),
let wallet_address = interactor
.register_wallet(
Wallet::from_keystore_secret(
"alice.json",
InsertPassword::Plaintext("alice".to_string()),
)
.unwrap(),
)
.unwrap(),
);
.await;

interactor.proxy.generate_blocks(1).await.unwrap();

Self {
interactor,
Expand Down
24 changes: 20 additions & 4 deletions contracts/examples/adder/interact/src/basic_interact_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ use std::io::Read;
/// Config file
const CONFIG_FILE: &str = "config.toml";

#[derive(Debug, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum ChainType {
Real,
Simulator,
}

/// Adder Interact configuration
#[derive(Debug, Deserialize)]
pub struct Config {
gateway: String,
gateway_uri: String,
chain_type: ChainType,
}

impl Config {
Expand All @@ -19,8 +27,16 @@ impl Config {
toml::from_str(&content).unwrap()
}

// Returns the gateway
pub fn gateway(&self) -> &str {
&self.gateway
// Returns the gateway URI
pub fn gateway_uri(&self) -> &str {
&self.gateway_uri
}

// Returns if chain type is chain simulator
pub fn use_chain_simulator(&self) -> bool {
match self.chain_type {
ChainType::Real => false,
ChainType::Simulator => true,
}
}
}
3 changes: 2 additions & 1 deletion contracts/examples/multisig/interact/config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
gateway = 'https://devnet-gateway.multiversx.com'
chain_type = 'real'
gateway_uri = 'https://devnet-gateway.multiversx.com'
quorum = 2
wegld_address = "erd1qqqqqqqqqqqqqpgqqkwzsxkjc83vlfex9dmznwm7tjvxlqqkpauqx0n782"
10 changes: 5 additions & 5 deletions contracts/examples/multisig/interact/src/multisig_interact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async fn main() {
env_logger::init();

let mut multisig_interact = MultisigInteract::init().await;
multisig_interact.register_wallets();
multisig_interact.register_wallets().await;

let cli = multisig_interact_cli::InteractCli::parse();
match &cli.command {
Expand Down Expand Up @@ -86,11 +86,11 @@ struct MultisigInteract {
impl MultisigInteract {
async fn init() -> Self {
let config = Config::load_config();
let mut interactor = Interactor::new(&config.gateway)
let mut interactor = Interactor::new(config.gateway_uri(), config.use_chain_simulator())
.await
.with_tracer(INTERACTOR_SCENARIO_TRACE_PATH)
.await;
let wallet_address = interactor.register_wallet(test_wallets::mike());
let wallet_address = interactor.register_wallet(test_wallets::mike()).await;
let multisig_code = BytesValue::interpret_from(
"mxsc:../output/multisig.mxsc.json",
&InterpreterContext::default(),
Expand All @@ -106,13 +106,13 @@ impl MultisigInteract {
}
}

fn register_wallets(&mut self) {
async fn register_wallets(&mut self) {
let carol = test_wallets::carol();
let dan = test_wallets::dan();
let eve = test_wallets::eve();

for wallet in &[carol, dan, eve] {
self.interactor.register_wallet(*wallet);
self.interactor.register_wallet(*wallet).await;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@ use std::io::Read;
/// Config file
const CONFIG_FILE: &str = "config.toml";

#[derive(Debug, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum ChainType {
Real,
Simulator,
}

/// Multisig Interact configuration
#[derive(Debug, Deserialize)]
pub struct Config {
pub gateway: String,
pub gateway_uri: String,
pub chain_type: ChainType,
pub quorum: usize,
pub wegld_address: Bech32Address,
}
Expand All @@ -21,4 +29,17 @@ impl Config {
file.read_to_string(&mut content).unwrap();
toml::from_str(&content).unwrap()
}

// Returns the gateway URI
pub fn gateway_uri(&self) -> &str {
&self.gateway_uri
}

// Returns if chain type is chain simulator
pub fn use_chain_simulator(&self) -> bool {
match self.chain_type {
ChainType::Real => false,
ChainType::Simulator => true,
}
}
}
4 changes: 2 additions & 2 deletions contracts/examples/nft-minter/src/nft_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ pub trait NftModule {
self.send()
.esdt_system_sc_proxy()
.set_special_roles(
&self.blockchain().get_sc_address(),
&self.nft_token_id().get(),
self.blockchain().get_sc_address(),
self.nft_token_id().get(),
[EsdtLocalRole::NftCreate][..].iter().cloned(),
)
.async_call_and_exit()
Expand Down
3 changes: 2 additions & 1 deletion contracts/feature-tests/basic-features/interact/config.toml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
gateway = 'https://devnet-gateway.multiversx.com'
chain_type = 'real'
gateway_uri = 'https://devnet-gateway.multiversx.com'
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ struct BasicFeaturesInteract {
impl BasicFeaturesInteract {
async fn init() -> Self {
let config = Config::load_config();
let mut interactor = Interactor::new(config.gateway())
let mut interactor = Interactor::new(config.gateway_uri(), config.use_chain_simulator())
.await
.with_tracer(INTERACTOR_SCENARIO_TRACE_PATH)
.await;
let wallet_address = interactor.register_wallet(test_wallets::mike());
let wallet_address = interactor.register_wallet(test_wallets::mike()).await;
let code_expr = BytesValue::interpret_from(
"mxsc:../output/basic-features-storage-bytes.mxsc.json",
&InterpreterContext::default(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ use std::io::Read;
/// Config file
const CONFIG_FILE: &str = "config.toml";

#[derive(Debug, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum ChainType {
Real,
Simulator,
}

/// Adder Interact configuration
#[derive(Debug, Deserialize)]
pub struct Config {
gateway: String,
gateway_uri: String,
chain_type: ChainType,
}

impl Config {
Expand All @@ -19,8 +27,16 @@ impl Config {
toml::from_str(&content).unwrap()
}

// Returns the gateway
pub fn gateway(&self) -> &str {
&self.gateway
// Returns the gateway URI
pub fn gateway_uri(&self) -> &str {
&self.gateway_uri
}

// Returns if chain type is chain simulator
pub fn use_chain_simulator(&self) -> bool {
match self.chain_type {
ChainType::Real => false,
ChainType::Simulator => true,
}
}
}
9 changes: 5 additions & 4 deletions contracts/feature-tests/composability/interact/config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
gateway = 'https://testnet-gateway.multiversx.com'
call_type = "LegacyAsync" # Sync / LegacyAsync / TransferExecute
chain_type = 'real'
gateway_uri = 'https://testnet-gateway.multiversx.com'
call_type = "LegacyAsync" # Sync / LegacyAsync / TransferExecute
# token_id = "CMPT-4e9332"
token_id = "EGLD"
token_nonce = 0 # is 0 if fungible
amount = '50000000000000000'
token_nonce = 0 # is 0 if fungible
amount = '50000000000000000'
Loading

0 comments on commit 5a7ab59

Please sign in to comment.