Skip to content

Commit

Permalink
Merge branch 'interactor-chain-sim-github' into fix-parse-reason
Browse files Browse the repository at this point in the history
  • Loading branch information
BiancaIalangi committed Oct 16, 2024
2 parents 04d6209 + 5152004 commit 3d84d9f
Show file tree
Hide file tree
Showing 84 changed files with 1,275 additions and 298 deletions.
1 change: 1 addition & 0 deletions contracts/core/price-aggregator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ pub trait PriceAggregator:
}

#[view(getOracles)]
#[title("oracles")]
fn get_oracles(&self) -> MultiValueEncoded<ManagedAddress> {
let mut result = MultiValueEncoded::new();
for key in self.oracle_status().keys() {
Expand Down
2 changes: 2 additions & 0 deletions contracts/core/wegld-swap/src/wegld.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ pub trait EgldEsdtSwap: multiversx_sc_modules::pause::PauseModule {
}

#[view(getLockedEgldBalance)]
#[title("lockedEgldBalance")]
fn get_locked_egld_balance(&self) -> BigUint {
self.blockchain()
.get_sc_balance(&EgldOrEsdtTokenIdentifier::egld(), 0)
}

#[view(getWrappedEgldTokenId)]
#[title("wrappedEgldTokenId")]
#[storage_mapper("wrappedEgldTokenId")]
fn wrapped_egld_token_id(&self) -> SingleValueMapper<TokenIdentifier>;
}
7 changes: 0 additions & 7 deletions contracts/examples/adder/interact/src/basic_interact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ impl AdderInteract {
.code(ADDER_CODE_PATH)
.code_metadata(CodeMetadata::UPGRADEABLE)
.returns(ReturnsNewBech32Address)
.prepare_async()
.run()
.await;

Expand Down Expand Up @@ -183,7 +182,6 @@ impl AdderInteract {
.from(&self.wallet_address)
.to(self.state.current_adder_address())
.egld(NumExpr("0,050000000000000000"))
.prepare_async()
.run()
.await;
}
Expand All @@ -196,7 +194,6 @@ impl AdderInteract {
.gas(6_000_000)
.typed(adder_proxy::AdderProxy)
.add(value)
.prepare_async()
.run()
.await;

Expand All @@ -211,7 +208,6 @@ impl AdderInteract {
.typed(adder_proxy::AdderProxy)
.sum()
.returns(ReturnsResultUnmanaged)
.prepare_async()
.run()
.await;

Expand All @@ -237,7 +233,6 @@ impl AdderInteract {
.code_metadata(CodeMetadata::UPGRADEABLE)
.code(ADDER_CODE_PATH)
.returns(ExpectError(code, msg))
.prepare_async()
.run()
.await;

Expand All @@ -253,7 +248,6 @@ impl AdderInteract {
.upgrade(new_value)
.code_metadata(CodeMetadata::UPGRADEABLE)
.code(ADDER_CODE_PATH)
.prepare_async()
.run()
.await;

Expand All @@ -264,7 +258,6 @@ impl AdderInteract {
.typed(adder_proxy::AdderProxy)
.sum()
.returns(ReturnsResultUnmanaged)
.prepare_async()
.run()
.await;

Expand Down
5 changes: 5 additions & 0 deletions contracts/examples/crowdfunding-esdt/src/crowdfunding_esdt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub trait Crowdfunding {
}

#[view(getCurrentFunds)]
#[title("currentFunds")]
fn get_current_funds(&self) -> BigUint {
let token = self.cf_token_identifier().get();

Expand Down Expand Up @@ -106,18 +107,22 @@ pub trait Crowdfunding {
// storage

#[view(getTarget)]
#[title("target")]
#[storage_mapper("target")]
fn target(&self) -> SingleValueMapper<BigUint>;

#[view(getDeadline)]
#[title("deadline")]
#[storage_mapper("deadline")]
fn deadline(&self) -> SingleValueMapper<u64>;

#[view(getDeposit)]
#[title("deposit")]
#[storage_mapper("deposit")]
fn deposit(&self, donor: &ManagedAddress) -> SingleValueMapper<BigUint>;

#[view(getCrowdfundingTokenIdentifier)]
#[title("tokenIdentifier")]
#[storage_mapper("tokenIdentifier")]
fn cf_token_identifier(&self) -> SingleValueMapper<EgldOrEsdtTokenIdentifier>;
}
8 changes: 0 additions & 8 deletions contracts/examples/multisig/interact/src/multisig_interact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ impl MultisigInteract {
.code(&self.multisig_code)
.gas(NumExpr("100,000,000"))
.returns(ReturnsNewBech32Address)
.prepare_async()
.run()
.await;

Expand Down Expand Up @@ -202,7 +201,6 @@ impl MultisigInteract {
.from(&self.wallet_address)
.to(self.state.current_multisig_address())
.egld(BigUint::from(50_000_000_000_000_000u64)) // 0,05 or 5 * 10^16
.prepare_async()
.run()
.await;
}
Expand All @@ -220,7 +218,6 @@ impl MultisigInteract {
.gas(gas_expr)
.typed(multisig_proxy::MultisigProxy)
.perform_action_endpoint(action_id)
.prepare_async()
.run()
.await;

Expand Down Expand Up @@ -273,7 +270,6 @@ impl MultisigInteract {
.typed(multisig_proxy::MultisigProxy)
.quorum_reached(action_id)
.returns(ReturnsResult)
.prepare_async()
.run()
.await
}
Expand All @@ -285,7 +281,6 @@ impl MultisigInteract {
.typed(multisig_proxy::MultisigProxy)
.signed(signer, action_id)
.returns(ReturnsResult)
.prepare_async()
.run()
.await
}
Expand Down Expand Up @@ -340,7 +335,6 @@ impl MultisigInteract {
.gas(NumExpr("30,000,000"))
.typed(multisig_proxy::MultisigProxy)
.dns_register(dns_address, name)
.prepare_async()
.run()
.await;

Expand All @@ -355,7 +349,6 @@ impl MultisigInteract {
.typed(multisig_proxy::MultisigProxy)
.quorum()
.returns(ReturnsResult)
.prepare_async()
.run()
.await;

Expand All @@ -370,7 +363,6 @@ impl MultisigInteract {
.typed(multisig_proxy::MultisigProxy)
.num_board_members()
.returns(ReturnsResult)
.prepare_async()
.run()
.await;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ impl MultisigInteract {
.argument(&0u32),
)
.returns(ReturnsResult)
.prepare_async()
.run()
.await;

Expand All @@ -75,7 +74,6 @@ impl MultisigInteract {
.typed(multisig_proxy::MultisigProxy)
.perform_action_endpoint(action_id)
.returns(ReturnsNewTokenIdentifier)
.prepare_async()
.run()
.await;
self.collection_token_identifier = new_token_id.to_string();
Expand All @@ -102,7 +100,6 @@ impl MultisigInteract {
.argument(&COLLECTION_TICKER),
)
.returns(ReturnsResult)
.prepare_async()
.run()
.await;

Expand All @@ -127,7 +124,6 @@ impl MultisigInteract {
.typed(multisig_proxy::MultisigProxy)
.perform_action_endpoint(action_id)
.returns(ReturnsNewTokenIdentifier)
.prepare_async()
.run()
.await;
self.collection_token_identifier = new_token_id;
Expand Down Expand Up @@ -156,7 +152,6 @@ impl MultisigInteract {
.argument(&"ESDTRoleNFTCreate"),
)
.returns(ReturnsResult)
.prepare_async()
.run()
.await;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ impl MultisigInteract {
.typed(multisig_proxy::MultisigProxy)
.propose_async_call(&self.config.wegld_address, WRAP_AMOUNT, function_call)
.returns(ReturnsResult)
.prepare_async()
.run()
.await;

Expand All @@ -72,7 +71,6 @@ impl MultisigInteract {
.typed(wegld_proxy::EgldEsdtSwapProxy)
.wrapped_egld_token_id()
.returns(ReturnsResult)
.prepare_async()
.run()
.await;

Expand Down Expand Up @@ -104,7 +102,6 @@ impl MultisigInteract {
.typed(multisig_proxy::MultisigProxy)
.propose_async_call(normalized_to, 0u64, normalized_data)
.returns(ReturnsResult)
.prepare_async()
.run()
.await;

Expand Down
7 changes: 2 additions & 5 deletions contracts/examples/ping-pong-egld/dapp/src/interactor.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
use imports::{Address, Bech32Address, BytesValue};
use multiversx_sc_snippets_dapp::*;
use multiversx_sc_snippets_dapp::imports::*;
use serde::{Deserialize, Serialize};

const GATEWAY: &str = sdk::core::gateway::DEVNET_GATEWAY;
const GATEWAY: &str = multiversx_sc_snippets_dapp::sdk::core::gateway::DEVNET_GATEWAY;
const CONTRACT_ADDRESS: &str = "erd1qqqqqqqqqqqqqpgq6tqvj5f59xrgxwrtwy30elgpu7l4zrv6d8ssnjdwxq";
const PING_PONG_CODE: &[u8] = include_bytes!("../ping-pong-egld.wasm");

use multiversx_sc_snippets_dapp::imports::*;

#[derive(Debug, Default, Serialize, Deserialize)]
pub struct Config {
gateway: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
use crate::interactor::ContractInteract;
use multiversx_sc_snippets_dapp::imports::{
Bech32Address, BigUint, IgnoreValue, InteractorPrepareAsync, OptionalValue, ReturnsMessage,
ReturnsNewBech32Address, ReturnsStatus,
};
use multiversx_sc_snippets_dapp::imports::*;

use super::proxy;

Expand All @@ -29,7 +26,6 @@ pub async fn deploy_sc() -> Result<Bech32Address, String> {
.returns(ReturnsNewBech32Address)
.returns(ReturnsStatus)
.returns(ReturnsMessage)
.prepare_async()
.run()
.await;

Expand Down Expand Up @@ -57,7 +53,6 @@ pub async fn ping() -> Result<String, String> {
.typed(proxy::PingPongProxy)
.ping(_data)
.egld(BigUint::from(amount))
.prepare_async()
.run()
.await;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
},
{
"name": "multi_result_3",
"title": "result-3",
"mutability": "mutable",
"inputs": [],
"outputs": [
Expand Down
1 change: 1 addition & 0 deletions contracts/feature-tests/abi-tester/src/abi_tester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub trait AbiTester {
fn take_managed_type(&self, _arg: AbiManagedType<Self::Api>) {}

#[endpoint]
#[title("result-3")]
#[output_name("multi-result-1")]
#[output_name("multi-result-2")]
#[output_name("multi-result-3")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ impl BasicFeaturesInteract {
.code(&self.code_expr)
.gas(NumExpr("4,000,000"))
.returns(ReturnsNewBech32Address)
.prepare_async()
.run()
.await;

Expand All @@ -103,7 +102,6 @@ impl BasicFeaturesInteract {
.gas(NumExpr("600,000,000"))
.typed(basic_features_proxy::BasicFeaturesProxy)
.store_bytes(value)
.prepare_async()
.run()
.await;

Expand All @@ -118,7 +116,6 @@ impl BasicFeaturesInteract {
.typed(basic_features_proxy::BasicFeaturesProxy)
.load_bytes()
.returns(ReturnsResult)
.prepare_async()
.run()
.await;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ impl ComposabilityInteract {
.to(&root_addr)
.typed(forwarder_queue_proxy::ForwarderQueueProxy)
.forward_queued_calls()
.prepare_async()
.run()
.await;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
"gasLimit": "70,000,000"
},
"expect": {
"out": [],
"out": [
"str:init-result"
],
"status": "0"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
"gasPrice": "0"
},
"expect": {
"out": [],
"out": [
"str:init-result"
],
"status": "",
"logs": "*",
"gas": "*",
Expand Down
9 changes: 8 additions & 1 deletion contracts/feature-tests/scenario-tester/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ pub trait ScenarioTester {
#[storage_mapper("sum")]
fn sum(&self) -> SingleValueMapper<BigUint>;

/// Return value for testing reasons.
#[init]
fn init(&self, initial_value: BigUint) {
fn init(&self, initial_value: BigUint) -> &'static str {
self.sum().set(initial_value);
"init-result"
}

#[upgrade]
Expand All @@ -38,4 +40,9 @@ pub trait ScenarioTester {
let value_plus_one = &value + 1u32;
(value, value_plus_one).into()
}

#[view]
fn sc_panic(&self) {
sc_panic!("sc_panic! example");
}
}
Loading

0 comments on commit 3d84d9f

Please sign in to comment.