From 0c021f4fb49fd5c899748fcda287793b4bb5b120 Mon Sep 17 00:00:00 2001 From: BiancaIalangi Date: Fri, 15 Nov 2024 17:21:34 +0200 Subject: [PATCH 01/13] 0.54 upgrade - fair launch --- contracts/fair-launch/sc-config.toml | 2 + .../fair-launch/src/fair_launch_proxy.rs | 328 ++++++++ contracts/fair-launch/src/lib.rs | 1 + .../fair-launch/tests/fair_launch_test.rs | 743 ++++++++---------- contracts/fair-launch/tests/tests_common.rs | 197 ++--- contracts/fair-launch/wasm/Cargo.lock | 27 +- contracts/fair-launch/wasm/Cargo.toml | 6 + 7 files changed, 768 insertions(+), 536 deletions(-) create mode 100644 contracts/fair-launch/sc-config.toml create mode 100644 contracts/fair-launch/src/fair_launch_proxy.rs diff --git a/contracts/fair-launch/sc-config.toml b/contracts/fair-launch/sc-config.toml new file mode 100644 index 00000000..b60fe738 --- /dev/null +++ b/contracts/fair-launch/sc-config.toml @@ -0,0 +1,2 @@ +[[proxy]] +path = "src/fair_launch_proxy.rs" \ No newline at end of file diff --git a/contracts/fair-launch/src/fair_launch_proxy.rs b/contracts/fair-launch/src/fair_launch_proxy.rs new file mode 100644 index 00000000..f44fe05b --- /dev/null +++ b/contracts/fair-launch/src/fair_launch_proxy.rs @@ -0,0 +1,328 @@ +// Code generated by the multiversx-sc proxy generator. DO NOT EDIT. + +//////////////////////////////////////////////////// +////////////////// AUTO-GENERATED ////////////////// +//////////////////////////////////////////////////// + +#![allow(dead_code)] +#![allow(clippy::all)] + +use multiversx_sc::proxy_imports::*; + +pub struct FairLaunchProxy; + +impl TxProxyTrait for FairLaunchProxy +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + type TxProxyMethods = FairLaunchProxyMethods; + + fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { + FairLaunchProxyMethods { wrapped_tx: tx } + } +} + +pub struct FairLaunchProxyMethods +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + wrapped_tx: Tx, +} + +#[rustfmt::skip] +impl FairLaunchProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + Gas: TxGas, +{ + /// Percentages have to be between 0 and 10_000 + /// Start percentage >= End percentage + pub fn init< + Arg0: ProxyArg, + Arg1: ProxyArg>, + Arg2: ProxyArg>, + Arg3: ProxyArg, + Arg4: ProxyArg, + Arg5: ProxyArg, + Arg6: ProxyArg, + >( + self, + initial_launch_duration_blocks: Arg0, + account_buy_limit: Arg1, + tx_buy_limit: Arg2, + buy_fee_percentage_start: Arg3, + buy_fee_percentage_end: Arg4, + sell_fee_percentage_start: Arg5, + sell_fee_percentage_end: Arg6, + ) -> TxTypedDeploy { + self.wrapped_tx + .payment(NotPayable) + .raw_deploy() + .argument(&initial_launch_duration_blocks) + .argument(&account_buy_limit) + .argument(&tx_buy_limit) + .argument(&buy_fee_percentage_start) + .argument(&buy_fee_percentage_end) + .argument(&sell_fee_percentage_start) + .argument(&sell_fee_percentage_end) + .original_result() + } +} + +#[rustfmt::skip] +impl FairLaunchProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn upgrade( + self, + ) -> TxTypedUpgrade { + self.wrapped_tx + .payment(NotPayable) + .raw_upgrade() + .original_result() + } +} + +#[rustfmt::skip] +impl FairLaunchProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn token_fees< + Arg0: ProxyArg>, + >( + self, + token_id: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getTokenFees") + .argument(&token_id) + .original_result() + } + + /// Arguments: endpoint_name, + /// input_fee_percentage: between 0 and 10_000, + /// burn_input: bool, burn input tokens taken as fee, + /// output_fee_percentage: between 0 and 10_000, + /// burn_output: bool, burn output taken as fee + pub fn add_exchange_endpoint< + Arg0: ProxyArg>, + Arg1: ProxyArg, u32, bool, u32, bool>>>, + >( + self, + sc_addr: Arg0, + endpoint_name_fee_percentage_pairs: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("addExchangeEndpoint") + .argument(&sc_addr) + .argument(&endpoint_name_fee_percentage_pairs) + .original_result() + } + + pub fn remove_exchange_endpoint< + Arg0: ProxyArg>, + Arg1: ProxyArg>>, + >( + self, + sc_addr: Arg0, + endpoint_names: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("removeExchangeEndpoint") + .argument(&sc_addr) + .argument(&endpoint_names) + .original_result() + } + + /// forward an execute on dest context call on an exchange SC + pub fn forward_execute_on_dest< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + Arg2: ProxyArg>>, + >( + self, + dest: Arg0, + endpoint_name: Arg1, + extra_args: Arg2, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("forwardExecuteOnDest") + .argument(&dest) + .argument(&endpoint_name) + .argument(&extra_args) + .original_result() + } + + pub fn buy_token< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + >( + self, + pair_adddress: Arg0, + amount_out_min: Arg1, + ) -> TxTypedCall> { + self.wrapped_tx + .raw_call("buyToken") + .argument(&pair_adddress) + .argument(&amount_out_min) + .original_result() + } + + pub fn sell_token< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + Arg2: ProxyArg>, + >( + self, + pair_adddress: Arg0, + out_token_id: Arg1, + amount_out_min: Arg2, + ) -> TxTypedCall> { + self.wrapped_tx + .raw_call("sellToken") + .argument(&pair_adddress) + .argument(&out_token_id) + .argument(&amount_out_min) + .original_result() + } + + pub fn issue_token< + Arg0: ProxyArg, + Arg1: ProxyArg>, + Arg2: ProxyArg>, + Arg3: ProxyArg, + >( + self, + token_type: Arg0, + token_display_name: Arg1, + token_ticker: Arg2, + num_decimals: Arg3, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("issueToken") + .argument(&token_type) + .argument(&token_display_name) + .argument(&token_ticker) + .argument(&num_decimals) + .original_result() + } + + pub fn set_transfer_role( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setTransferRole") + .original_result() + } + + /// Percentage should be between 0 and 10_000 + pub fn set_token_fees< + Arg0: ProxyArg>, + Arg1: ProxyArg, + >( + self, + token_id: Arg0, + fees_percentage: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setTokenFees") + .argument(&token_id) + .argument(&fees_percentage) + .original_result() + } + + /// users in whitelist can transfer without fees + pub fn add_users_to_whitelist< + Arg0: ProxyArg>>, + >( + self, + users: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("addUsersToWhitelist") + .argument(&users) + .original_result() + } + + pub fn remove_users_from_whitelist< + Arg0: ProxyArg>>, + >( + self, + users: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("removeUsersFromWhitelist") + .argument(&users) + .original_result() + } + + /// Forward the transfer to the specified address + /// Part of the tokens is taken as fees + /// If the destination is a SC, the first argument is the function name + pub fn forward_transfer< + Arg0: ProxyArg>, + Arg1: ProxyArg>>, + >( + self, + dest: Arg0, + extra_args: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("forwardTransfer") + .argument(&dest) + .argument(&extra_args) + .original_result() + } + + pub fn pause_endpoint( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("pause") + .original_result() + } + + pub fn unpause_endpoint( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("unpause") + .original_result() + } + + pub fn paused_status( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("isPaused") + .original_result() + } +} diff --git a/contracts/fair-launch/src/lib.rs b/contracts/fair-launch/src/lib.rs index d08c465b..fb5b9710 100644 --- a/contracts/fair-launch/src/lib.rs +++ b/contracts/fair-launch/src/lib.rs @@ -9,6 +9,7 @@ use multiversx_sc::imports::*; pub mod common; pub mod exchange_actions; +pub mod fair_launch_proxy; pub mod initial_launch; pub mod pair_mock_proxy; pub mod token_info; diff --git a/contracts/fair-launch/tests/fair_launch_test.rs b/contracts/fair-launch/tests/fair_launch_test.rs index 394f7c6a..c3370862 100644 --- a/contracts/fair-launch/tests/fair_launch_test.rs +++ b/contracts/fair-launch/tests/fair_launch_test.rs @@ -1,45 +1,49 @@ -#![allow(deprecated)] - -mod tests_common; - -use crowdfunding_esdt::Crowdfunding; -use fair_launch::{ - common::CommonModule, exchange_actions::ExchangeActionsModule, - initial_launch::InitialLaunchModule, transfer::TransferModule, -}; -use multiversx_sc::types::{ManagedBuffer, MultiValueEncoded}; +use crowdfunding_esdt::crowdfunding_esdt_proxy; +use fair_launch::{common::CommonModule, fair_launch_proxy, initial_launch::InitialLaunchModule}; +use multiversx_sc::types::{ManagedAddress, ManagedBuffer, MultiValueEncoded, TestEsdtTransfer}; use multiversx_sc_scenario::{ - managed_address, managed_biguint, managed_buffer, managed_token_id, managed_token_id_wrapped, - rust_biguint, + managed_biguint, managed_buffer, ExpectMessage, ScenarioTxRun, ScenarioTxWhitebox, +}; +use tests_common::{ + FairLaunchSetup, BUY_FEE_PERCENTAGE_END, BUY_FEE_PERCENTAGE_START, CODE_PATH_CROWDFUNDING, + CROWDFUNDING_ADDRESS, FAIR_LAUNCH_ADDRESS, FIRST_ADDRESS, OTHER_TOKEN_ID, OWNER, + PAIR_MOCK_ADDRESS, SECOND_ADDRESS, TOKEN_ID, }; -use tests_common::*; + +mod tests_common; #[test] fn init_test() { - let _ = FairLaunchSetup::new(fair_launch::contract_obj, pair_mock::contract_obj); + let _ = FairLaunchSetup::new(None, 0); } #[test] fn percentage_test() { - let mut fl_setup = FairLaunchSetup::new(fair_launch::contract_obj, pair_mock::contract_obj); - fl_setup.b_mock.set_block_nonce(10); + let mut fl_setup = FairLaunchSetup::new(None, 0); + fl_setup.world.current_block().block_nonce(10); fl_setup - .b_mock - .execute_query(&fl_setup.fl_wrapper, |sc| { + .world + .tx() + .from(OWNER) + .to(FAIR_LAUNCH_ADDRESS) + .whitebox(fair_launch::contract_obj, |sc| { let percentage = sc.get_fee_percentage(BUY_FEE_PERCENTAGE_START, BUY_FEE_PERCENTAGE_END); let expected_percentage = BUY_FEE_PERCENTAGE_START - 808; // (BUY_FEE_PERCENTAGE_END - BUY_FEE_PERCENTAGE_START) * 10 blocks / (100 blocks - 1) ~= 808 assert_eq!(percentage, expected_percentage); }) - .assert_ok(); } #[test] fn calculate_fee_test() { - let mut fl_setup = FairLaunchSetup::new(fair_launch::contract_obj, pair_mock::contract_obj); + let mut fl_setup = FairLaunchSetup::new(None, 0); + fl_setup - .b_mock - .execute_query(&fl_setup.fl_wrapper, |sc| { + .world + .tx() + .from(OWNER) + .to(FAIR_LAUNCH_ADDRESS) + .whitebox(fair_launch::contract_obj, |sc| { let fee = sc.calculate_fee_rounded_up(&managed_biguint!(1_000), 4_000); let expected_fee = managed_biguint!(400); assert_eq!(fee, expected_fee); @@ -52,467 +56,332 @@ fn calculate_fee_test() { let expected_fee = managed_biguint!(401); assert_eq!(fee, expected_fee); }) - .assert_ok(); } #[test] fn transfer_user_test() { - let mut fl_setup = FairLaunchSetup::new(fair_launch::contract_obj, pair_mock::contract_obj); - fl_setup - .b_mock - .execute_tx( - &fl_setup.owner_address, - &fl_setup.fl_wrapper, - &rust_biguint!(0), - |sc| { - sc.set_token_fees(managed_token_id!(TOKEN_ID), 4_000); - }, - ) - .assert_ok(); - - fl_setup.b_mock.set_esdt_balance( - &fl_setup.first_user_address, - TOKEN_ID, - &rust_biguint!(1_000), - ); - - fl_setup - .b_mock - .execute_esdt_transfer( - &fl_setup.first_user_address, - &fl_setup.fl_wrapper, - TOKEN_ID, - 0, - &rust_biguint!(1_000), - |sc| { - sc.forward_transfer( - managed_address!(&fl_setup.second_user_address), - MultiValueEncoded::new(), - ); - }, - ) - .assert_ok(); - - fl_setup - .b_mock - .check_esdt_balance(&fl_setup.first_user_address, TOKEN_ID, &rust_biguint!(0)); - - fl_setup.b_mock.check_esdt_balance( - &fl_setup.second_user_address, - TOKEN_ID, - &rust_biguint!(600), - ); - - fl_setup - .b_mock - .check_esdt_balance(&fl_setup.owner_address, TOKEN_ID, &rust_biguint!(400)); + let mut fl_setup = FairLaunchSetup::new(None, 0); + fl_setup + .world + .tx() + .from(OWNER) + .to(FAIR_LAUNCH_ADDRESS) + .typed(fair_launch_proxy::FairLaunchProxy) + .set_token_fees(TOKEN_ID, 4_000u32) + .run(); + + fl_setup + .world + .account(FIRST_ADDRESS) + .esdt_balance(TOKEN_ID, 1_000); + + fl_setup + .world + .tx() + .from(FIRST_ADDRESS) + .to(FAIR_LAUNCH_ADDRESS) + .typed(fair_launch_proxy::FairLaunchProxy) + .forward_transfer(SECOND_ADDRESS, MultiValueEncoded::new()) + .esdt(TestEsdtTransfer(TOKEN_ID, 0, 1000)) + .run(); + + fl_setup + .world + .check_account(FIRST_ADDRESS) + .esdt_balance(TOKEN_ID, 0); + fl_setup + .world + .check_account(SECOND_ADDRESS) + .esdt_balance(TOKEN_ID, 600); + fl_setup + .world + .check_account(OWNER) + .esdt_balance(TOKEN_ID, 400); } #[test] fn transfer_sc_ok_test() { - let mut fl_setup = FairLaunchSetup::new(fair_launch::contract_obj, pair_mock::contract_obj); - fl_setup - .b_mock - .execute_tx( - &fl_setup.owner_address, - &fl_setup.fl_wrapper, - &rust_biguint!(0), - |sc| { - sc.set_token_fees(managed_token_id!(TOKEN_ID), 4_000); - }, - ) - .assert_ok(); - - fl_setup.b_mock.set_esdt_balance( - &fl_setup.first_user_address, - TOKEN_ID, - &rust_biguint!(1_000), - ); - - let cf_wrapper = fl_setup.b_mock.create_sc_account( - &rust_biguint!(0), - Some(&fl_setup.owner_address), - crowdfunding_esdt::contract_obj, - "cf wasm path", - ); - fl_setup - .b_mock - .execute_tx( - &fl_setup.owner_address, - &cf_wrapper, - &rust_biguint!(0), - |sc| { - sc.init( - managed_biguint!(2_000), - 1_000, - managed_token_id_wrapped!(TOKEN_ID), - ); - }, - ) - .assert_ok(); - - fl_setup - .b_mock - .execute_esdt_transfer( - &fl_setup.first_user_address, - &fl_setup.fl_wrapper, - TOKEN_ID, - 0, - &rust_biguint!(1_000), - |sc| { - let mut args = MultiValueEncoded::new(); - args.push(ManagedBuffer::from(b"fund")); - - sc.forward_transfer(managed_address!(cf_wrapper.address_ref()), args); - }, - ) - .assert_ok(); - - fl_setup - .b_mock - .check_esdt_balance(&fl_setup.first_user_address, TOKEN_ID, &rust_biguint!(0)); - - fl_setup - .b_mock - .check_esdt_balance(cf_wrapper.address_ref(), TOKEN_ID, &rust_biguint!(600)); - - fl_setup.b_mock.check_esdt_balance( - fl_setup.fl_wrapper.address_ref(), - TOKEN_ID, - &rust_biguint!(400), - ); + let mut fl_setup = FairLaunchSetup::new(None, 0); + fl_setup + .world + .tx() + .from(OWNER) + .to(FAIR_LAUNCH_ADDRESS) + .typed(fair_launch_proxy::FairLaunchProxy) + .set_token_fees(TOKEN_ID, 4000u32) + .run(); + + fl_setup + .world + .account(FIRST_ADDRESS) + .esdt_balance(TOKEN_ID, 1_000); + + fl_setup + .world + .tx() + .from(OWNER) + .typed(crowdfunding_esdt_proxy::CrowdfundingProxy) + .init(2000u32, 1000u32, TOKEN_ID) + .new_address(CROWDFUNDING_ADDRESS) + .code(CODE_PATH_CROWDFUNDING) + .run(); + + let mut args = MultiValueEncoded::new(); + args.push(managed_buffer!(b"fund")); + fl_setup + .world + .tx() + .from(FIRST_ADDRESS) + .to(FAIR_LAUNCH_ADDRESS) + .typed(fair_launch_proxy::FairLaunchProxy) + .forward_transfer(CROWDFUNDING_ADDRESS, args) + .esdt(TestEsdtTransfer(TOKEN_ID, 0, 1_000)) + .run(); + + fl_setup + .world + .check_account(FIRST_ADDRESS) + .esdt_balance(TOKEN_ID, 0); + fl_setup + .world + .check_account(CROWDFUNDING_ADDRESS) + .esdt_balance(TOKEN_ID, 600); + fl_setup + .world + .check_account(FAIR_LAUNCH_ADDRESS) + .esdt_balance(TOKEN_ID, 400); } #[test] fn transfer_sc_fail_test() { - let mut fl_setup = FairLaunchSetup::new(fair_launch::contract_obj, pair_mock::contract_obj); - fl_setup - .b_mock - .execute_tx( - &fl_setup.owner_address, - &fl_setup.fl_wrapper, - &rust_biguint!(0), - |sc| { - sc.set_token_fees(managed_token_id!(TOKEN_ID), 4_000); - }, - ) - .assert_ok(); - - fl_setup.b_mock.set_esdt_balance( - &fl_setup.first_user_address, - TOKEN_ID, - &rust_biguint!(1_000), - ); - - let cf_wrapper = fl_setup.b_mock.create_sc_account( - &rust_biguint!(0), - Some(&fl_setup.owner_address), - crowdfunding_esdt::contract_obj, - "cf wasm path", - ); - fl_setup - .b_mock - .execute_tx( - &fl_setup.owner_address, - &cf_wrapper, - &rust_biguint!(0), - |sc| { - sc.init( - managed_biguint!(2_000), - 1_000, - managed_token_id_wrapped!(TOKEN_ID), - ); - }, - ) - .assert_ok(); - - fl_setup - .b_mock - .execute_esdt_transfer( - &fl_setup.first_user_address, - &fl_setup.fl_wrapper, - TOKEN_ID, - 0, - &rust_biguint!(0), - |sc| { - let mut args = MultiValueEncoded::new(); - args.push(ManagedBuffer::from(b"claim")); - - sc.forward_transfer(managed_address!(cf_wrapper.address_ref()), args); - }, - ) - .assert_ok(); - - fl_setup.b_mock.check_esdt_balance( - &fl_setup.first_user_address, - TOKEN_ID, - &rust_biguint!(1_000), - ); - - fl_setup - .b_mock - .check_esdt_balance(cf_wrapper.address_ref(), TOKEN_ID, &rust_biguint!(0)); - - fl_setup - .b_mock - .check_esdt_balance(&fl_setup.owner_address, TOKEN_ID, &rust_biguint!(0)); + let mut fl_setup = FairLaunchSetup::new(None, 0); + fl_setup + .world + .tx() + .from(OWNER) + .to(FAIR_LAUNCH_ADDRESS) + .typed(fair_launch_proxy::FairLaunchProxy) + .set_token_fees(TOKEN_ID, 4000u32) + .run(); + + fl_setup + .world + .account(FIRST_ADDRESS) + .esdt_balance(TOKEN_ID, 1_000); + + fl_setup + .world + .tx() + .from(OWNER) + .typed(crowdfunding_esdt_proxy::CrowdfundingProxy) + .init(2000u32, 1000u32, TOKEN_ID) + .new_address(CROWDFUNDING_ADDRESS) + .code(CODE_PATH_CROWDFUNDING) + .run(); + + let mut args = MultiValueEncoded::new(); + args.push(managed_buffer!(b"claim")); + fl_setup + .world + .tx() + .from(FIRST_ADDRESS) + .to(FAIR_LAUNCH_ADDRESS) + .typed(fair_launch_proxy::FairLaunchProxy) + .forward_transfer(CROWDFUNDING_ADDRESS, args) + .esdt(TestEsdtTransfer(TOKEN_ID, 0, 0)) + .run(); + + fl_setup + .world + .check_account(FIRST_ADDRESS) + .esdt_balance(TOKEN_ID, 1000); + fl_setup + .world + .check_account(CROWDFUNDING_ADDRESS) + .esdt_balance(TOKEN_ID, 0); + fl_setup + .world + .check_account(FAIR_LAUNCH_ADDRESS) + .esdt_balance(TOKEN_ID, 0); } #[test] fn transfer_whitelist_test() { - let mut fl_setup = FairLaunchSetup::new(fair_launch::contract_obj, pair_mock::contract_obj); - fl_setup - .b_mock - .execute_tx( - &fl_setup.owner_address, - &fl_setup.fl_wrapper, - &rust_biguint!(0), - |sc| { - sc.set_token_fees(managed_token_id!(TOKEN_ID), 4_000); - }, - ) - .assert_ok(); - - fl_setup.b_mock.set_esdt_balance( - &fl_setup.first_user_address, - TOKEN_ID, - &rust_biguint!(1_000), - ); - - fl_setup - .b_mock - .execute_tx( - &fl_setup.first_user_address, - &fl_setup.fl_wrapper, - &rust_biguint!(0), - |sc| { - let mut users = MultiValueEncoded::new(); - users.push(managed_address!(&fl_setup.first_user_address)); - sc.add_users_to_whitelist(users); - }, - ) - .assert_ok(); - - fl_setup - .b_mock - .execute_esdt_transfer( - &fl_setup.first_user_address, - &fl_setup.fl_wrapper, - TOKEN_ID, - 0, - &rust_biguint!(1_000), - |sc| { - sc.forward_transfer( - managed_address!(&fl_setup.second_user_address), - MultiValueEncoded::new(), - ); - }, - ) - .assert_ok(); - - fl_setup - .b_mock - .check_esdt_balance(&fl_setup.first_user_address, TOKEN_ID, &rust_biguint!(0)); - - fl_setup.b_mock.check_esdt_balance( - &fl_setup.second_user_address, - TOKEN_ID, - &rust_biguint!(1_000), - ); - - fl_setup - .b_mock - .check_esdt_balance(&fl_setup.owner_address, TOKEN_ID, &rust_biguint!(0)); + let mut fl_setup = FairLaunchSetup::new(None, 0); + fl_setup + .world + .tx() + .from(OWNER) + .to(FAIR_LAUNCH_ADDRESS) + .typed(fair_launch_proxy::FairLaunchProxy) + .set_token_fees(TOKEN_ID, 4000u32) + .run(); + + fl_setup + .world + .account(FIRST_ADDRESS) + .esdt_balance(TOKEN_ID, 1_000); + + let mut users = MultiValueEncoded::new(); + users.push(ManagedAddress::from_address(&FIRST_ADDRESS.to_address())); + + fl_setup + .world + .tx() + .from(OWNER) + .to(FAIR_LAUNCH_ADDRESS) + .typed(fair_launch_proxy::FairLaunchProxy) + .add_users_to_whitelist(users) + .run(); + + fl_setup + .world + .tx() + .from(FIRST_ADDRESS) + .to(FAIR_LAUNCH_ADDRESS) + .typed(fair_launch_proxy::FairLaunchProxy) + .forward_transfer(SECOND_ADDRESS, MultiValueEncoded::new()) + .esdt(TestEsdtTransfer(TOKEN_ID, 0, 1000)) + .run(); + + fl_setup + .world + .check_account(FIRST_ADDRESS) + .esdt_balance(TOKEN_ID, 0); + fl_setup + .world + .check_account(SECOND_ADDRESS) + .esdt_balance(TOKEN_ID, 1000); + fl_setup + .world + .check_account(OWNER) + .esdt_balance(TOKEN_ID, 0); } #[test] fn buy_token_test() { - let mut fl_setup = FairLaunchSetup::new(fair_launch::contract_obj, pair_mock::contract_obj); - fl_setup.b_mock.set_esdt_balance( - &fl_setup.first_user_address, - OTHER_TOKEN_ID, - &rust_biguint!(1_000), - ); - fl_setup.b_mock.set_esdt_balance( - fl_setup.pair_wrapper.address_ref(), - TOKEN_ID, - &rust_biguint!(50), - ); + let mut fl_setup = FairLaunchSetup::new(Some(TOKEN_ID), 50); + fl_setup + .world + .account(FIRST_ADDRESS) + .esdt_balance(OTHER_TOKEN_ID, 1000); // 90% of the initial value is kept as fee fl_setup - .b_mock - .execute_esdt_transfer( - &fl_setup.first_user_address, - &fl_setup.fl_wrapper, - OTHER_TOKEN_ID, - 0, - &rust_biguint!(1_000), - |sc| { - sc.buy_token( - managed_address!(fl_setup.pair_wrapper.address_ref()), - managed_biguint!(1u32), - ); - }, - ) - .assert_ok(); - - fl_setup - .b_mock - .check_esdt_balance(&fl_setup.first_user_address, TOKEN_ID, &rust_biguint!(50)); - - fl_setup.b_mock.check_esdt_balance( - fl_setup.fl_wrapper.address_ref(), - OTHER_TOKEN_ID, - &rust_biguint!(900), - ); - - fl_setup.b_mock.check_esdt_balance( - fl_setup.pair_wrapper.address_ref(), - OTHER_TOKEN_ID, - &rust_biguint!(100), - ); + .world + .tx() + .from(FIRST_ADDRESS) + .to(FAIR_LAUNCH_ADDRESS) + .typed(fair_launch_proxy::FairLaunchProxy) + .buy_token(PAIR_MOCK_ADDRESS, 1u32) + .esdt(TestEsdtTransfer(OTHER_TOKEN_ID, 0, 1000)) + .run(); + + fl_setup + .world + .check_account(FIRST_ADDRESS) + .esdt_balance(TOKEN_ID, 50); + fl_setup + .world + .check_account(FAIR_LAUNCH_ADDRESS) + .esdt_balance(OTHER_TOKEN_ID, 900); + fl_setup + .world + .check_account(PAIR_MOCK_ADDRESS) + .esdt_balance(OTHER_TOKEN_ID, 100); } #[test] fn sell_token_test() { - let mut fl_setup = FairLaunchSetup::new(fair_launch::contract_obj, pair_mock::contract_obj); - fl_setup.b_mock.set_block_nonce(50); - fl_setup.b_mock.set_esdt_balance( - &fl_setup.first_user_address, - TOKEN_ID, - &rust_biguint!(1_000), - ); - fl_setup.b_mock.set_esdt_balance( - fl_setup.pair_wrapper.address_ref(), - OTHER_TOKEN_ID, - &rust_biguint!(5000), - ); + let mut fl_setup = FairLaunchSetup::new(Some(OTHER_TOKEN_ID), 5000); + fl_setup.world.current_block().block_nonce(50); + fl_setup + .world + .account(FIRST_ADDRESS) + .esdt_balance(TOKEN_ID, 1000); // 75% of the initial value is kept as fee fl_setup - .b_mock - .execute_esdt_transfer( - &fl_setup.first_user_address, - &fl_setup.fl_wrapper, - TOKEN_ID, - 0, - &rust_biguint!(1_000), - |sc| { - sc.sell_token( - managed_address!(fl_setup.pair_wrapper.address_ref()), - managed_token_id!(OTHER_TOKEN_ID), - managed_biguint!(1u32), - ); - }, - ) - .assert_ok(); + .world + .tx() + .from(FIRST_ADDRESS) + .to(FAIR_LAUNCH_ADDRESS) + .typed(fair_launch_proxy::FairLaunchProxy) + .sell_token(PAIR_MOCK_ADDRESS, OTHER_TOKEN_ID, 1u32) + .esdt(TestEsdtTransfer(TOKEN_ID, 0, 1000)) + .run(); // values slightly differ due to biguint division errors - - fl_setup.b_mock.check_esdt_balance( - &fl_setup.first_user_address, - OTHER_TOKEN_ID, - &rust_biguint!(504), - ); - - fl_setup.b_mock.check_esdt_balance( - fl_setup.fl_wrapper.address_ref(), - TOKEN_ID, - &rust_biguint!(748), - ); - - fl_setup.b_mock.check_esdt_balance( - fl_setup.pair_wrapper.address_ref(), - TOKEN_ID, - &rust_biguint!(252), - ); + fl_setup + .world + .check_account(FIRST_ADDRESS) + .esdt_balance(OTHER_TOKEN_ID, 504); + fl_setup + .world + .check_account(FAIR_LAUNCH_ADDRESS) + .esdt_balance(TOKEN_ID, 748); + fl_setup + .world + .check_account(PAIR_MOCK_ADDRESS) + .esdt_balance(TOKEN_ID, 252); } #[test] fn try_buy_after_deadline() { - let mut fl_setup = FairLaunchSetup::new(fair_launch::contract_obj, pair_mock::contract_obj); - fl_setup.b_mock.set_esdt_balance( - &fl_setup.first_user_address, - OTHER_TOKEN_ID, - &rust_biguint!(1_000), - ); - fl_setup.b_mock.set_esdt_balance( - fl_setup.pair_wrapper.address_ref(), - TOKEN_ID, - &rust_biguint!(50), - ); - - fl_setup.b_mock.set_block_nonce(120); + let mut fl_setup = FairLaunchSetup::new(Some(TOKEN_ID), 50); + fl_setup + .world + .account(FIRST_ADDRESS) + .esdt_balance(OTHER_TOKEN_ID, 1000); + + fl_setup.world.current_block().block_nonce(120); // 90% of the initial value is kept as fee fl_setup - .b_mock - .execute_esdt_transfer( - &fl_setup.first_user_address, - &fl_setup.fl_wrapper, - OTHER_TOKEN_ID, - 0, - &rust_biguint!(1_000), - |sc| { - sc.buy_token( - managed_address!(fl_setup.pair_wrapper.address_ref()), - managed_biguint!(1u32), - ); - }, - ) - .assert_user_error("Cannot call this endpoint, initial launch period passed"); + .world + .tx() + .from(FIRST_ADDRESS) + .to(FAIR_LAUNCH_ADDRESS) + .typed(fair_launch_proxy::FairLaunchProxy) + .buy_token(PAIR_MOCK_ADDRESS, 1u32) + .esdt(TestEsdtTransfer(OTHER_TOKEN_ID, 0, 1000)) + .with_result(ExpectMessage( + "Cannot call this endpoint, initial launch period passed", + )) + .run(); } #[test] fn forward_swap_sync_test() { - let mut fl_setup = FairLaunchSetup::new(fair_launch::contract_obj, pair_mock::contract_obj); - fl_setup.b_mock.set_block_nonce(101); - fl_setup.b_mock.set_esdt_balance( - &fl_setup.first_user_address, - OTHER_TOKEN_ID, - &rust_biguint!(100_000), - ); - fl_setup.b_mock.set_esdt_balance( - fl_setup.pair_wrapper.address_ref(), - TOKEN_ID, - &rust_biguint!(500_000), - ); + let mut fl_setup = FairLaunchSetup::new(Some(TOKEN_ID), 500_000); + fl_setup.world.current_block().block_nonce(101); + fl_setup + .world + .account(FIRST_ADDRESS) + .esdt_balance(OTHER_TOKEN_ID, 100_000); + let mut args = MultiValueEncoded::new(); + args.push(TOKEN_ID.to_token_identifier().into_managed_buffer()); + args.push(ManagedBuffer::from(b"0")); // 40% of the initial value is kept as fee fl_setup - .b_mock - .execute_esdt_transfer( - &fl_setup.first_user_address, - &fl_setup.fl_wrapper, - OTHER_TOKEN_ID, - 0, - &rust_biguint!(100_000), - |sc| { - let mut args = MultiValueEncoded::new(); - args.push(managed_buffer!(TOKEN_ID)); - args.push(managed_buffer!(b"0")); - - sc.forward_execute_on_dest( - managed_address!(fl_setup.pair_wrapper.address_ref()), - managed_buffer!(b"swapTokensFixedInput"), - args, - ); - }, - ) - .assert_ok(); - - fl_setup.b_mock.check_esdt_balance( - &fl_setup.first_user_address, - TOKEN_ID, - &rust_biguint!(30_000), - ); - - fl_setup.b_mock.check_esdt_balance( - fl_setup.fl_wrapper.address_ref(), - OTHER_TOKEN_ID, - &rust_biguint!(40_000), - ); + .world + .tx() + .from(FIRST_ADDRESS) + .to(FAIR_LAUNCH_ADDRESS) + .typed(fair_launch_proxy::FairLaunchProxy) + .forward_execute_on_dest(PAIR_MOCK_ADDRESS, b"swapTokensFixedInput", args) + .esdt(TestEsdtTransfer(OTHER_TOKEN_ID, 0, 100_000)) + .run(); + + fl_setup + .world + .check_account(FIRST_ADDRESS) + .esdt_balance(TOKEN_ID, 30_000); + fl_setup + .world + .check_account(FAIR_LAUNCH_ADDRESS) + .esdt_balance(OTHER_TOKEN_ID, 40_000); } // #[test] diff --git a/contracts/fair-launch/tests/tests_common.rs b/contracts/fair-launch/tests/tests_common.rs index 902b87ac..ddb2d8c3 100644 --- a/contracts/fair-launch/tests/tests_common.rs +++ b/contracts/fair-launch/tests/tests_common.rs @@ -1,23 +1,13 @@ -#![allow(deprecated)] - -use fair_launch::{ - common::Percentage, exchange_actions::ExchangeActionsModule, token_info::TokenInfoModule, - FairLaunch, -}; +use fair_launch::{common::Percentage, fair_launch_proxy, token_info::TokenInfoModule}; use multiversx_sc::{ - storage::mappers::StorageTokenWrapper, - types::{Address, MultiValueEncoded}, -}; -use multiversx_sc_modules::pause::PauseModule; -use multiversx_sc_scenario::{ - managed_address, managed_biguint, managed_buffer, managed_token_id, rust_biguint, - testing_framework::{BlockchainStateWrapper, ContractObjWrapper}, - DebugApi, + imports::StorageTokenWrapper, + types::{ManagedBuffer, MultiValueEncoded, TestAddress, TestSCAddress, TestTokenIdentifier}, }; +use multiversx_sc_scenario::{imports::MxscPath, ScenarioTxRun, ScenarioTxWhitebox, ScenarioWorld}; use pair_mock::PairMock; -pub static TOKEN_ID: &[u8] = b"MYTOKEN-123456"; -pub static OTHER_TOKEN_ID: &[u8] = b"OTHER-123456"; +pub const TOKEN_ID: TestTokenIdentifier = TestTokenIdentifier::new("MYTOKEN-123456"); +pub const OTHER_TOKEN_ID: TestTokenIdentifier = TestTokenIdentifier::new("OTHER-123456"); pub const LAUNCH_DURATION_BLOCKS: u64 = 100; pub const ACCOUNT_BUY_LIMIT: u64 = 2_000; pub const TX_BUY_LIMIT: u64 = 1_000; @@ -25,91 +15,116 @@ pub const BUY_FEE_PERCENTAGE_START: Percentage = 9_000; pub const BUY_FEE_PERCENTAGE_END: Percentage = 1_000; pub const SELL_FEE_PERCENTAGE_START: Percentage = 10_000; pub const SELL_FEE_PERCENTAGE_END: Percentage = 5_000; +pub const CODE_PATH_FAIR_LAUNCH: MxscPath = MxscPath::new("output/fair-launch.mxsc.json"); +pub const CODE_PATH_PAIR_MOCK: MxscPath = MxscPath::new("../pair-mock/output/pair-mock.mxsc.json"); +pub const CODE_PATH_CROWDFUNDING: MxscPath = + MxscPath::new("../crowdfunding-esdt/output/crowdfunding-esdt.mxsc.json"); +pub const OWNER: TestAddress = TestAddress::new("owner"); +pub const FIRST_ADDRESS: TestAddress = TestAddress::new("first-address"); +pub const SECOND_ADDRESS: TestAddress = TestAddress::new("second-address"); +pub const PAIR_MOCK_ADDRESS: TestSCAddress = TestSCAddress::new("pair-mock"); +pub const FAIR_LAUNCH_ADDRESS: TestSCAddress = TestSCAddress::new("fair-launch"); +pub const CROWDFUNDING_ADDRESS: TestSCAddress = TestSCAddress::new("crowdfunding-esdt"); + +fn world() -> ScenarioWorld { + let mut blockchain = ScenarioWorld::new(); + + blockchain.set_current_dir_from_workspace("contracts/fair-launch"); + blockchain.register_contract(CODE_PATH_FAIR_LAUNCH, fair_launch::ContractBuilder); + blockchain.register_contract(CODE_PATH_PAIR_MOCK, pair_mock::ContractBuilder); + blockchain.register_contract(CODE_PATH_CROWDFUNDING, crowdfunding_esdt::ContractBuilder); -pub struct FairLaunchSetup -where - FairLaunchObjBuilder: 'static + Copy + Fn() -> fair_launch::ContractObj, - PairObjBuilder: 'static + Copy + Fn() -> pair_mock::ContractObj, -{ - pub b_mock: BlockchainStateWrapper, - pub owner_address: Address, - pub first_user_address: Address, - pub second_user_address: Address, - pub fl_wrapper: ContractObjWrapper, FairLaunchObjBuilder>, - pub pair_wrapper: ContractObjWrapper, PairObjBuilder>, + blockchain } -impl FairLaunchSetup -where - FairLaunchObjBuilder: 'static + Copy + Fn() -> fair_launch::ContractObj, - PairObjBuilder: 'static + Copy + Fn() -> pair_mock::ContractObj, -{ - pub fn new(fl_builder: FairLaunchObjBuilder, pair_builder: PairObjBuilder) -> Self { - let rust_zero = rust_biguint!(0u64); - let mut b_mock = BlockchainStateWrapper::new(); - let first_user_address = b_mock.create_user_account(&rust_zero); - let second_user_address = b_mock.create_user_account(&rust_zero); - let owner_address = b_mock.create_user_account(&rust_zero); +pub struct FairLaunchSetup { + pub world: ScenarioWorld, +} - let pair_wrapper = b_mock.create_sc_account( - &rust_zero, - Some(&owner_address), - pair_builder, - "pair wasm path", - ); +impl FairLaunchSetup { + pub fn new(token: Option, balance: u64) -> Self { + let mut world = world(); - b_mock - .execute_tx(&owner_address, &pair_wrapper, &rust_zero, |sc| { - sc.init( - managed_token_id!(TOKEN_ID), - managed_token_id!(OTHER_TOKEN_ID), - ); - }) - .assert_ok(); + world.account(OWNER).nonce(1); + world.account(SECOND_ADDRESS).nonce(1); - let fl_wrapper = b_mock.create_sc_account( - &rust_zero, - Some(&owner_address), - fl_builder, - "fair launch wasm path", - ); - b_mock - .execute_tx(&owner_address, &fl_wrapper, &rust_zero, |sc| { + match token { + Some(t) => world + .account(PAIR_MOCK_ADDRESS) + .code(CODE_PATH_PAIR_MOCK) + .owner(OWNER) + .esdt_balance(t, balance), + None => world + .account(PAIR_MOCK_ADDRESS) + .code(CODE_PATH_PAIR_MOCK) + .owner(OWNER), + }; + + world + .tx() + .from(OWNER) + .to(PAIR_MOCK_ADDRESS) + .whitebox(pair_mock::contract_obj, |sc| { sc.init( - LAUNCH_DURATION_BLOCKS, - managed_biguint!(ACCOUNT_BUY_LIMIT), - managed_biguint!(TX_BUY_LIMIT), - BUY_FEE_PERCENTAGE_START, - BUY_FEE_PERCENTAGE_END, - SELL_FEE_PERCENTAGE_START, - SELL_FEE_PERCENTAGE_END, + TOKEN_ID.to_token_identifier(), + OTHER_TOKEN_ID.to_token_identifier(), ); + }); + + world + .tx() + .from(OWNER) + .typed(fair_launch_proxy::FairLaunchProxy) + .init( + LAUNCH_DURATION_BLOCKS, + ACCOUNT_BUY_LIMIT, + TX_BUY_LIMIT, + BUY_FEE_PERCENTAGE_START, + BUY_FEE_PERCENTAGE_END, + SELL_FEE_PERCENTAGE_START, + SELL_FEE_PERCENTAGE_END, + ) + .new_address(FAIR_LAUNCH_ADDRESS) + .code(CODE_PATH_FAIR_LAUNCH) + .run(); + + world + .tx() + .from(OWNER) + .to(FAIR_LAUNCH_ADDRESS) + .whitebox(fair_launch::contract_obj, |sc| { sc.non_fungible_token() - .set_token_id(managed_token_id!(TOKEN_ID)); + .set_token_id(TOKEN_ID.to_token_identifier()); + }); - let mut pairs = MultiValueEncoded::new(); - pairs.push( - ( - managed_buffer!(b"swapTokensFixedInput"), - 4_000u32, - false, - 0u32, - false, - ) - .into(), - ); - sc.add_exchange_endpoint(managed_address!(pair_wrapper.address_ref()), pairs); - sc.set_paused(false); - }) - .assert_ok(); + let mut pairs = MultiValueEncoded::new(); + pairs.push( + ( + ManagedBuffer::from("swapTokensFixedInput"), + 4_000u32, + false, + 0u32, + false, + ) + .into(), + ); + + world + .tx() + .from(OWNER) + .to(FAIR_LAUNCH_ADDRESS) + .typed(fair_launch_proxy::FairLaunchProxy) + .add_exchange_endpoint(PAIR_MOCK_ADDRESS, pairs) + .run(); + + world + .tx() + .from(OWNER) + .to(FAIR_LAUNCH_ADDRESS) + .typed(fair_launch_proxy::FairLaunchProxy) + .unpause_endpoint() + .run(); - Self { - b_mock, - owner_address, - first_user_address, - second_user_address, - fl_wrapper, - pair_wrapper, - } + Self { world } } } diff --git a/contracts/fair-launch/wasm/Cargo.lock b/contracts/fair-launch/wasm/Cargo.lock index 04e53d91..80a0851a 100644 --- a/contracts/fair-launch/wasm/Cargo.lock +++ b/contracts/fair-launch/wasm/Cargo.lock @@ -54,14 +54,25 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "multiversx-chain-core" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c1088b268cad0d8c1146df9ca71a1f2baaee78267ab75e2202c0c0c71cc4b6e" +dependencies = [ + "bitflags", + "multiversx-sc-codec", +] + [[package]] name = "multiversx-sc" -version = "0.53.2" +version = "0.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" +checksum = "c4abf60eb027d0b005a1778dc9d670a473065ab8e5bea22eeb6ace7f118dc36f" dependencies = [ "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -93,9 +104,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.53.2" +version = "0.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" +checksum = "3caeda89d90190c4002f7482e934e3981968d6853f70f865d23c8d2938bd907b" dependencies = [ "hex", "proc-macro2", @@ -106,18 +117,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.53.2" +version = "0.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daeb48acbd39255868a3241798df2f85050f0ae8d82d6417bd2cd0e30a241855" +checksum = "624f7a758e2d5dc3e87fd095cb76d47f3cf4b0cee41b5415aa95b8e323ffe162" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.53.2" +version = "0.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" +checksum = "b10f0b29d4bcd7520e659ae2429ea9a4f02b7203a77d7788bebc79786babd250" dependencies = [ "multiversx-sc", ] diff --git a/contracts/fair-launch/wasm/Cargo.toml b/contracts/fair-launch/wasm/Cargo.toml index 56d7a50a..abf4ea3b 100644 --- a/contracts/fair-launch/wasm/Cargo.toml +++ b/contracts/fair-launch/wasm/Cargo.toml @@ -1,3 +1,9 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "fair-launch-wasm" version = "0.0.0" From fee75a08a704cd38866fa0a43a41d720ed615e11 Mon Sep 17 00:00:00 2001 From: BiancaIalangi Date: Mon, 18 Nov 2024 14:39:43 +0200 Subject: [PATCH 02/13] 0.54 upgrade - fractional nfts, liquid locking, lottery esdt, mvx game sc, mystery box --- contracts/fractional-nfts/wasm/Cargo.lock | 27 +- contracts/fractional-nfts/wasm/Cargo.toml | 6 + .../tests/liquid_locking_test.rs | 64 ++--- contracts/liquid-locking/wasm/Cargo.lock | 23 +- contracts/liquid-locking/wasm/Cargo.toml | 6 + .../tests/lottery_esdt_scenario_rs_test.rs | 1 + contracts/lottery-esdt/wasm/Cargo.lock | 23 +- contracts/lottery-esdt/wasm/Cargo.toml | 6 + .../tests/game_sc_blackbox_tests.rs | 148 +++++------ contracts/mvx-game-sc/wasm/Cargo.lock | 23 +- contracts/mvx-game-sc/wasm/Cargo.toml | 6 + contracts/mystery-box/sc-config.toml | 2 + contracts/mystery-box/src/lib.rs | 1 + .../mystery-box/src/mystery_box_proxy.rs | 229 +++++++++++++++++ .../mystery-box/tests/mystery_box_mod.rs | 192 ++++++++++++++ .../tests/mystery_box_setup/mod.rs | 242 ------------------ .../mystery-box/tests/mystery_box_test.rs | 39 +-- contracts/mystery-box/wasm/Cargo.toml | 6 + 18 files changed, 631 insertions(+), 413 deletions(-) create mode 100644 contracts/mystery-box/sc-config.toml create mode 100644 contracts/mystery-box/src/mystery_box_proxy.rs create mode 100644 contracts/mystery-box/tests/mystery_box_mod.rs delete mode 100644 contracts/mystery-box/tests/mystery_box_setup/mod.rs diff --git a/contracts/fractional-nfts/wasm/Cargo.lock b/contracts/fractional-nfts/wasm/Cargo.lock index 4a68d9af..b75f8706 100644 --- a/contracts/fractional-nfts/wasm/Cargo.lock +++ b/contracts/fractional-nfts/wasm/Cargo.lock @@ -54,14 +54,25 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "multiversx-chain-core" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c1088b268cad0d8c1146df9ca71a1f2baaee78267ab75e2202c0c0c71cc4b6e" +dependencies = [ + "bitflags", + "multiversx-sc-codec", +] + [[package]] name = "multiversx-sc" -version = "0.53.2" +version = "0.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" +checksum = "c4abf60eb027d0b005a1778dc9d670a473065ab8e5bea22eeb6ace7f118dc36f" dependencies = [ "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -93,9 +104,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.53.2" +version = "0.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" +checksum = "3caeda89d90190c4002f7482e934e3981968d6853f70f865d23c8d2938bd907b" dependencies = [ "hex", "proc-macro2", @@ -106,18 +117,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.53.2" +version = "0.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daeb48acbd39255868a3241798df2f85050f0ae8d82d6417bd2cd0e30a241855" +checksum = "624f7a758e2d5dc3e87fd095cb76d47f3cf4b0cee41b5415aa95b8e323ffe162" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.53.2" +version = "0.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" +checksum = "b10f0b29d4bcd7520e659ae2429ea9a4f02b7203a77d7788bebc79786babd250" dependencies = [ "multiversx-sc", ] diff --git a/contracts/fractional-nfts/wasm/Cargo.toml b/contracts/fractional-nfts/wasm/Cargo.toml index e11edd53..7e9d3d4b 100644 --- a/contracts/fractional-nfts/wasm/Cargo.toml +++ b/contracts/fractional-nfts/wasm/Cargo.toml @@ -1,3 +1,9 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "fractional-nfts-wasm" version = "0.0.0" diff --git a/contracts/liquid-locking/tests/liquid_locking_test.rs b/contracts/liquid-locking/tests/liquid_locking_test.rs index a357049d..ecd0ce7d 100644 --- a/contracts/liquid-locking/tests/liquid_locking_test.rs +++ b/contracts/liquid-locking/tests/liquid_locking_test.rs @@ -1,6 +1,6 @@ use liquid_locking::*; use multiversx_sc::types::{ - BigUint, EgldOrEsdtTokenIdentifier, EsdtTokenPayment, ManagedVec, TestAddress, TestSCAddress, + BigUint, EsdtTokenPayment, ManagedVec, TestAddress, TestEsdtTransfer, TestSCAddress, TestTokenIdentifier, TokenIdentifier, }; use multiversx_sc_scenario::{ @@ -13,15 +13,13 @@ const CODE_PATH: MxscPath = MxscPath::new("output/liquid-locking.mxsc.json"); const FIRST_USER_ADDRESS: TestAddress = TestAddress::new("user1"); const SECOND_USER_ADDRESS: TestAddress = TestAddress::new("user2"); const WHITELIST_TOKEN_1: TestTokenIdentifier = TestTokenIdentifier::new("AAA-111111"); -const WHITELIST_TOKEN_1_ID: &[u8] = b"AAA-111111"; const WHITELIST_TOKEN_2: TestTokenIdentifier = TestTokenIdentifier::new("BBB-222222"); -const WHITELIST_TOKEN_2_ID: &[u8] = b"BBB-222222"; const BLACKLIST_TOKEN: TestTokenIdentifier = TestTokenIdentifier::new("CCC-333333"); -const BLACKLIST_TOKEN_ID: &[u8] = b"CCC-333333"; fn world() -> ScenarioWorld { let mut blockchain = ScenarioWorld::new(); + blockchain.set_current_dir_from_workspace("contracts/liquid-locking"); blockchain.register_contract(CODE_PATH, liquid_locking::ContractBuilder); blockchain } @@ -71,7 +69,7 @@ fn test() { .from(OWNER_ADDRESS) .to(LIQUID_STAKING_ADDRESS) .typed(liquid_locking_proxy::LiquidLockingProxy) - .whitelist_token(WHITELIST_TOKEN_1_ID) + .whitelist_token(WHITELIST_TOKEN_1) .run(); world @@ -79,7 +77,7 @@ fn test() { .from(OWNER_ADDRESS) .to(LIQUID_STAKING_ADDRESS) .typed(liquid_locking_proxy::LiquidLockingProxy) - .whitelist_token(WHITELIST_TOKEN_2_ID) + .whitelist_token(WHITELIST_TOKEN_2) .run(); world.check_account(OWNER_ADDRESS); @@ -110,11 +108,7 @@ fn test() { .to(LIQUID_STAKING_ADDRESS) .typed(liquid_locking_proxy::LiquidLockingProxy) .lock() - .egld_or_single_esdt( - &EgldOrEsdtTokenIdentifier::esdt(BLACKLIST_TOKEN_ID), - 0u64, - &BigUint::from(500u64), - ) + .esdt(TestEsdtTransfer(BLACKLIST_TOKEN, 0u64, 500u64)) .with_result(ExpectError(4, "token is not whitelisted")) .run(); @@ -145,11 +139,7 @@ fn test() { .to(LIQUID_STAKING_ADDRESS) .typed(liquid_locking_proxy::LiquidLockingProxy) .lock() - .egld_or_single_esdt( - &EgldOrEsdtTokenIdentifier::esdt(WHITELIST_TOKEN_2_ID), - 0u64, - &BigUint::from(500u64), - ) + .esdt(TestEsdtTransfer(WHITELIST_TOKEN_2, 0, 500)) .run(); world @@ -158,11 +148,7 @@ fn test() { .to(LIQUID_STAKING_ADDRESS) .typed(liquid_locking_proxy::LiquidLockingProxy) .lock() - .egld_or_single_esdt( - &EgldOrEsdtTokenIdentifier::esdt(WHITELIST_TOKEN_2_ID), - 0u64, - &BigUint::from(500u64), - ) + .esdt(TestEsdtTransfer(WHITELIST_TOKEN_2, 0, 500)) .run(); world @@ -171,11 +157,7 @@ fn test() { .to(LIQUID_STAKING_ADDRESS) .typed(liquid_locking_proxy::LiquidLockingProxy) .lock() - .egld_or_single_esdt( - &EgldOrEsdtTokenIdentifier::esdt(WHITELIST_TOKEN_1_ID), - 0u64, - &BigUint::from(1000u64), - ) + .esdt(TestEsdtTransfer(WHITELIST_TOKEN_1, 0, 1000)) .run(); world @@ -184,11 +166,7 @@ fn test() { .to(LIQUID_STAKING_ADDRESS) .typed(liquid_locking_proxy::LiquidLockingProxy) .lock() - .egld_or_single_esdt( - &EgldOrEsdtTokenIdentifier::esdt(WHITELIST_TOKEN_2_ID), - 0u64, - &BigUint::from(1000u64), - ) + .esdt(TestEsdtTransfer(WHITELIST_TOKEN_2, 0, 1000)) .run(); world.check_account(OWNER_ADDRESS); @@ -252,17 +230,17 @@ fn test() { let mut unlock_multiple_esdt = ManagedVec::>::new(); unlock_single_esdt.push(EsdtTokenPayment { - token_identifier: TokenIdentifier::from(BLACKLIST_TOKEN_ID), + token_identifier: BLACKLIST_TOKEN.to_token_identifier(), token_nonce: 0, amount: BigUint::from(1500u64), }); unlock_multiple_esdt.push(EsdtTokenPayment { - token_identifier: TokenIdentifier::from(WHITELIST_TOKEN_1_ID), + token_identifier: WHITELIST_TOKEN_1.to_token_identifier(), token_nonce: 0, amount: BigUint::zero(), }); unlock_multiple_esdt.push(EsdtTokenPayment { - token_identifier: TokenIdentifier::from(WHITELIST_TOKEN_1_ID), + token_identifier: WHITELIST_TOKEN_1.to_token_identifier(), token_nonce: 0, amount: BigUint::from(300u64), }); @@ -291,17 +269,17 @@ fn test() { unlock_multiple_esdt = ManagedVec::>::new(); unlock_single_esdt.push(EsdtTokenPayment { - token_identifier: TokenIdentifier::from(WHITELIST_TOKEN_2_ID), + token_identifier: WHITELIST_TOKEN_2.to_token_identifier(), token_nonce: 0, amount: BigUint::from(200u64), }); unlock_multiple_esdt.push(EsdtTokenPayment { - token_identifier: TokenIdentifier::from(WHITELIST_TOKEN_1_ID), + token_identifier: WHITELIST_TOKEN_1.to_token_identifier(), token_nonce: 0, amount: BigUint::from(1000u64), }); unlock_multiple_esdt.push(EsdtTokenPayment { - token_identifier: TokenIdentifier::from(WHITELIST_TOKEN_2_ID), + token_identifier: WHITELIST_TOKEN_2.to_token_identifier(), token_nonce: 0, amount: BigUint::from(300u64), }); @@ -470,7 +448,7 @@ fn test() { // unbond fail let mut unbond_tokens = ManagedVec::>::new(); - unbond_tokens.push(TokenIdentifier::from(BLACKLIST_TOKEN_ID)); + unbond_tokens.push(BLACKLIST_TOKEN.to_token_identifier()); world .tx() .from(SECOND_USER_ADDRESS) @@ -481,7 +459,7 @@ fn test() { .run(); unbond_tokens = ManagedVec::>::new(); - unbond_tokens.push(TokenIdentifier::from(WHITELIST_TOKEN_2_ID)); + unbond_tokens.push(WHITELIST_TOKEN_2.to_token_identifier()); world .tx() .from(SECOND_USER_ADDRESS) @@ -494,7 +472,7 @@ fn test() { // unbond success unbond_tokens = ManagedVec::>::new(); - unbond_tokens.push(TokenIdentifier::from(WHITELIST_TOKEN_2_ID)); + unbond_tokens.push(WHITELIST_TOKEN_2.to_token_identifier()); world.current_block().block_epoch(11); world .tx() @@ -505,7 +483,7 @@ fn test() { .run(); unbond_tokens = ManagedVec::>::new(); - unbond_tokens.push(TokenIdentifier::from(WHITELIST_TOKEN_2_ID)); + unbond_tokens.push(WHITELIST_TOKEN_2.to_token_identifier()); world.current_block().block_epoch(22); world .tx() @@ -516,8 +494,8 @@ fn test() { .run(); unbond_tokens = ManagedVec::>::new(); - unbond_tokens.push(TokenIdentifier::from(WHITELIST_TOKEN_2_ID)); - unbond_tokens.push(TokenIdentifier::from(WHITELIST_TOKEN_1_ID)); + unbond_tokens.push(WHITELIST_TOKEN_2.to_token_identifier()); + unbond_tokens.push(WHITELIST_TOKEN_1.to_token_identifier()); world .tx() .from(FIRST_USER_ADDRESS) diff --git a/contracts/liquid-locking/wasm/Cargo.lock b/contracts/liquid-locking/wasm/Cargo.lock index 7e05ca33..a81dd48e 100644 --- a/contracts/liquid-locking/wasm/Cargo.lock +++ b/contracts/liquid-locking/wasm/Cargo.lock @@ -53,14 +53,25 @@ dependencies = [ "multiversx-sc-wasm-adapter", ] +[[package]] +name = "multiversx-chain-core" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c1088b268cad0d8c1146df9ca71a1f2baaee78267ab75e2202c0c0c71cc4b6e" +dependencies = [ + "bitflags", + "multiversx-sc-codec", +] + [[package]] name = "multiversx-sc" -version = "0.53.2" +version = "0.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" +checksum = "c4abf60eb027d0b005a1778dc9d670a473065ab8e5bea22eeb6ace7f118dc36f" dependencies = [ "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -92,9 +103,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.53.2" +version = "0.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" +checksum = "3caeda89d90190c4002f7482e934e3981968d6853f70f865d23c8d2938bd907b" dependencies = [ "hex", "proc-macro2", @@ -105,9 +116,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.53.2" +version = "0.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" +checksum = "b10f0b29d4bcd7520e659ae2429ea9a4f02b7203a77d7788bebc79786babd250" dependencies = [ "multiversx-sc", ] diff --git a/contracts/liquid-locking/wasm/Cargo.toml b/contracts/liquid-locking/wasm/Cargo.toml index 0b0424d3..bd05d586 100644 --- a/contracts/liquid-locking/wasm/Cargo.toml +++ b/contracts/liquid-locking/wasm/Cargo.toml @@ -1,3 +1,9 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "liquid-locking-wasm" version = "0.0.0" diff --git a/contracts/lottery-esdt/tests/lottery_esdt_scenario_rs_test.rs b/contracts/lottery-esdt/tests/lottery_esdt_scenario_rs_test.rs index 4d6cf072..67ad8780 100644 --- a/contracts/lottery-esdt/tests/lottery_esdt_scenario_rs_test.rs +++ b/contracts/lottery-esdt/tests/lottery_esdt_scenario_rs_test.rs @@ -3,6 +3,7 @@ use multiversx_sc_scenario::*; fn world() -> ScenarioWorld { let mut blockchain = ScenarioWorld::new(); + blockchain.set_current_dir_from_workspace("contracts/lottery-esdt"); blockchain.register_contract( "mxsc:output/lottery-esdt.mxsc.json", lottery_esdt::ContractBuilder, diff --git a/contracts/lottery-esdt/wasm/Cargo.lock b/contracts/lottery-esdt/wasm/Cargo.lock index 54692f8b..b8be796f 100644 --- a/contracts/lottery-esdt/wasm/Cargo.lock +++ b/contracts/lottery-esdt/wasm/Cargo.lock @@ -53,14 +53,25 @@ dependencies = [ "multiversx-sc-wasm-adapter", ] +[[package]] +name = "multiversx-chain-core" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c1088b268cad0d8c1146df9ca71a1f2baaee78267ab75e2202c0c0c71cc4b6e" +dependencies = [ + "bitflags", + "multiversx-sc-codec", +] + [[package]] name = "multiversx-sc" -version = "0.53.2" +version = "0.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" +checksum = "c4abf60eb027d0b005a1778dc9d670a473065ab8e5bea22eeb6ace7f118dc36f" dependencies = [ "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -92,9 +103,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.53.2" +version = "0.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" +checksum = "3caeda89d90190c4002f7482e934e3981968d6853f70f865d23c8d2938bd907b" dependencies = [ "hex", "proc-macro2", @@ -105,9 +116,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.53.2" +version = "0.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" +checksum = "b10f0b29d4bcd7520e659ae2429ea9a4f02b7203a77d7788bebc79786babd250" dependencies = [ "multiversx-sc", ] diff --git a/contracts/lottery-esdt/wasm/Cargo.toml b/contracts/lottery-esdt/wasm/Cargo.toml index aa16265e..8bbd4f74 100644 --- a/contracts/lottery-esdt/wasm/Cargo.toml +++ b/contracts/lottery-esdt/wasm/Cargo.toml @@ -1,3 +1,9 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "lottery-esdt-wasm" version = "0.0.0" diff --git a/contracts/mvx-game-sc/tests/game_sc_blackbox_tests.rs b/contracts/mvx-game-sc/tests/game_sc_blackbox_tests.rs index 50ba607d..d51923d4 100644 --- a/contracts/mvx-game-sc/tests/game_sc_blackbox_tests.rs +++ b/contracts/mvx-game-sc/tests/game_sc_blackbox_tests.rs @@ -1,23 +1,18 @@ use imports::{ - MxscPath, ReturnsResult, ReturnsResultUnmanaged, TestAddress, TestSCAddress, + MxscPath, ReturnsResult, ReturnsResultUnmanaged, TestAddress, TestEsdtTransfer, TestSCAddress, TestTokenIdentifier, }; use multiversx_sc::{ codec::multi_types::OptionalValue, storage::mappers::SingleValue, - types::{ - BigUint, EgldOrEsdtTokenIdentifier, ManagedAddress, MultiValueEncoded, TokenIdentifier, - }, + types::{BigUint, ManagedAddress, MultiValueEncoded}, }; use multiversx_sc_scenario::{api::StaticApi, scenario_model::*, *}; use mvx_game_sc::game_proxy; -type RustBigUint = num_bigint::BigUint; - const GAME_SC_PATH: MxscPath = MxscPath::new("output/mvx-game-sc.mxsc.json"); const BALANCE: u64 = 100_000_000u64; const TOKEN_GAME: TestTokenIdentifier = TestTokenIdentifier::new("GAME-123456"); -const TOKEN_GAME_ID: &[u8] = b"GAME-123456"; const STARTING_FEE: u64 = 20u64; const USER1_ADDR: TestAddress = TestAddress::new("user1"); const USER2_ADDR: TestAddress = TestAddress::new("user2"); @@ -90,9 +85,7 @@ impl GameContractState { .init( OptionalValue::Some(true), OptionalValue::Some(BigUint::from(STARTING_FEE)), - OptionalValue::Some(EgldOrEsdtTokenIdentifier::esdt(TokenIdentifier::from( - TOKEN_GAME_ID, - ))), + OptionalValue::Some(TOKEN_GAME), ) .code(GAME_SC_PATH) .new_address(GAME_SC_ADDR) @@ -106,7 +99,7 @@ impl GameContractState { waiting_time: u64, number_of_players_min: u64, number_of_players_max: u64, - wager: RustBigUint, + wager: u64, caller: TestAddress, expected_game_id: u64, ) -> &mut Self { @@ -121,11 +114,7 @@ impl GameContractState { number_of_players_max, wager, ) - .egld_or_single_esdt( - &EgldOrEsdtTokenIdentifier::esdt(TOKEN_GAME_ID), - 0u64, - &BigUint::from(STARTING_FEE), - ) + .esdt(TestEsdtTransfer(TOKEN_GAME, 0, STARTING_FEE)) .with_result(ExpectValue(expected_game_id)) .run(); @@ -136,37 +125,29 @@ impl GameContractState { &mut self, game_id: u64, caller: TestAddress, - amount: RustBigUint, - expected_error: OptionalValue<(u64, &str)>, + amount: u64, + expected_error: Option<(u64, &str)>, ) -> &mut Self { match expected_error { - OptionalValue::Some(val) => { + Some(val) => { self.world .tx() .from(caller) .to(GAME_SC_ADDR) .typed(game_proxy::MvxGameScProxy) .join_game(game_id) - .egld_or_single_esdt( - &EgldOrEsdtTokenIdentifier::esdt(TOKEN_GAME_ID), - 0u64, - &BigUint::from(amount), - ) + .esdt(TestEsdtTransfer(TOKEN_GAME, 0, amount)) .with_result(ExpectError(val.0, val.1)) .run(); } - OptionalValue::None => { + None => { self.world .tx() .from(caller) .to(GAME_SC_ADDR) .typed(game_proxy::MvxGameScProxy) .join_game(game_id) - .egld_or_single_esdt( - &EgldOrEsdtTokenIdentifier::esdt(TOKEN_GAME_ID), - 0u64, - &BigUint::from(amount), - ) + .esdt(TestEsdtTransfer(TOKEN_GAME, 0, amount)) .run(); } } @@ -178,10 +159,10 @@ impl GameContractState { &mut self, game_id: u64, caller: TestAddress, - expected_error: OptionalValue<(u64, &str)>, + expected_error: Option<(u64, &str)>, ) -> &mut Self { match expected_error { - OptionalValue::Some(val) => { + Some(val) => { self.world .tx() .from(caller) @@ -191,7 +172,7 @@ impl GameContractState { .with_result(ExpectError(val.0, val.1)) .run(); } - OptionalValue::None => { + None => { self.world .tx() .from(caller) @@ -209,10 +190,10 @@ impl GameContractState { &mut self, game_id: u64, winners: OptionalValue, u64)>>, - expected_error: OptionalValue<(u64, &str)>, + expected_error: Option<(u64, &str)>, ) -> &mut Self { match expected_error { - OptionalValue::Some(val) => { + Some(val) => { self.world .tx() .from(OWNER_ADDR) @@ -222,7 +203,7 @@ impl GameContractState { .with_result(ExpectError(val.0, val.1)) .run(); } - OptionalValue::None => { + None => { self.world .tx() .from(OWNER_ADDR) @@ -251,7 +232,7 @@ fn game_sc_simple_game_flow() { let waiting_time = 100u64; let number_of_players_min = 1u64; let number_of_players_max = 4u64; - let wager = RustBigUint::from(100u64); + let wager = 100u64; // deploy state.deploy(); @@ -270,7 +251,7 @@ fn game_sc_simple_game_flow() { waiting_time, number_of_players_min, number_of_players_max, - wager.clone(), + wager, OWNER_ADDR, 1u64, ); @@ -286,7 +267,7 @@ fn game_sc_simple_game_flow() { .run(); // user1 tries to join the game, timestamp is ok, max players not reached, should work - state.join_game(1u64, USER1_ADDR, wager.clone(), OptionalValue::None); + state.join_game(1u64, USER1_ADDR, wager, None); // min number of players reached, game should be valid let game_setting = state @@ -302,7 +283,7 @@ fn game_sc_simple_game_flow() { assert_eq!(game_settings.into().status, game_proxy::Status::Valid); // user2 tries to join the game, shuld work - state.join_game(1u64, USER2_ADDR, wager, OptionalValue::None); + state.join_game(1u64, USER2_ADDR, wager, None); // both users should be in players vec let players = state @@ -312,35 +293,35 @@ fn game_sc_simple_game_flow() { .to(GAME_SC_ADDR) .typed(game_proxy::MvxGameScProxy) .players(1u64) - .returns(ReturnsResult) + .returns(ReturnsResultUnmanaged) .run(); - let players_vec = players.to_vec(); + let players_vec = players.0.to_vec(); - assert!(players_vec.contains(&ManagedAddress::from(USER1_ADDR.eval_to_array()))); - assert!(players_vec.contains(&ManagedAddress::from(USER2_ADDR.eval_to_array()))); + assert!(players_vec.contains(&USER1_ADDR.to_address())); + assert!(players_vec.contains(&USER2_ADDR.to_address())); // game should be in users'storage - let games_per_user1: MultiValueEncoded = state + let games_per_user1 = state .world .tx() .from(USER2_ADDR) .to(GAME_SC_ADDR) .typed(game_proxy::MvxGameScProxy) - .games_per_user(USER1_ADDR.eval_to_array()) - .returns(ReturnsResult) + .games_per_user(USER1_ADDR) + .returns(ReturnsResultUnmanaged) .run(); - let games_per_user1_vec = games_per_user1.to_vec(); + let games_per_user1_vec = games_per_user1.0.to_vec(); - let games_per_user2: MultiValueEncoded = state + let games_per_user2 = state .world .tx() .from(USER2_ADDR) .to(GAME_SC_ADDR) .typed(game_proxy::MvxGameScProxy) - .games_per_user(USER2_ADDR.eval_to_array()) - .returns(ReturnsResult) + .games_per_user(USER2_ADDR) + .returns(ReturnsResultUnmanaged) .run(); - let games_per_user2_vec = games_per_user2.to_vec(); + let games_per_user2_vec = games_per_user2.0.to_vec(); assert!((games_per_user1_vec.contains(&1u64) && games_per_user2_vec.contains(&1u64))); } @@ -353,8 +334,8 @@ fn game_sc_complex_flow() { let waiting_time = 100u64; // => timestamp 102 should be out of waiting time let number_of_players_min = 2u64; let number_of_players_max = 4u64; - let wager = RustBigUint::from(100u64); - let diff_amount = RustBigUint::from(5u64); + let wager = 100u64; + let diff_amount = 5u64; // deploy state.deploy(); @@ -367,13 +348,13 @@ fn game_sc_complex_flow() { waiting_time, number_of_players_min, number_of_players_max, - wager.clone(), + wager, OWNER_ADDR, 1, ); // user1 joins - state.join_game(1u64, USER1_ADDR, wager.clone(), OptionalValue::None); + state.join_game(1u64, USER1_ADDR, wager, None); let game_setting = state .world @@ -389,26 +370,22 @@ fn game_sc_complex_flow() { assert_eq!(game_settings.into().status, game_proxy::Status::Invalid); // user1 tries to claim back wager, should fail (waiting time not passed) - state.claim_back_wager( - 1u64, - USER1_ADDR, - OptionalValue::Some((4, "waiting time is not over yet")), - ); + state.claim_back_wager(1u64, USER1_ADDR, Some((4, "waiting time is not over yet"))); // user2 joins state.join_game( 1u64, USER2_ADDR, diff_amount, - OptionalValue::Some((4, "wrong amount paid")), + Some((4, "wrong amount paid")), ); // wrong amount paid - state.join_game(1u64, USER2_ADDR, wager.clone(), OptionalValue::None); + state.join_game(1u64, USER2_ADDR, wager, None); state.join_game( 1u64, USER2_ADDR, - wager.clone(), - OptionalValue::Some((4, "user already joined this game")), + wager, + Some((4, "user already joined this game")), ); // user already joined let game_setting = state @@ -418,14 +395,12 @@ fn game_sc_complex_flow() { .to(GAME_SC_ADDR) .typed(game_proxy::MvxGameScProxy) .game_settings(1u64) - .returns(ReturnsResultUnmanaged) + .returns(ReturnsResult) .run(); - let game_settings = SingleValue::from(game_setting); - - assert_eq!(game_settings.into().status, game_proxy::Status::Valid); + assert_eq!(game_setting.status, game_proxy::Status::Valid); // user3 joins - state.join_game(1u64, USER3_ADDR, wager.clone(), OptionalValue::None); + state.join_game(1u64, USER3_ADDR, wager, None); // set timestamp after time limit state.world.current_block().block_timestamp(102u64); @@ -435,21 +410,21 @@ fn game_sc_complex_flow() { 1u64, USER4_ADDR, wager, - OptionalValue::Some((4, "waiting time has passed")), + Some((4, "waiting time has passed")), ); // user4 tries to claim back wager, fails state.claim_back_wager( 1u64, USER4_ADDR, - OptionalValue::Some((4, "caller has not joined the game")), + Some((4, "caller has not joined the game")), ); // user1 tries to claim back wager, fails state.claim_back_wager( 1u64, USER1_ADDR, - OptionalValue::Some(( + Some(( 4, "can manually claim back wager only if the game is invalid", )), @@ -458,9 +433,9 @@ fn game_sc_complex_flow() { // send tokens to sc state.world.transfer_step( TransferStep::new() - .from(OWNER_ADDR.eval_to_expr().as_str()) - .to(GAME_SC_ADDR.eval_to_expr().as_str()) - .esdt_transfer(TOKEN_GAME_ID, 0, "10_000"), + .from(OWNER_ADDR) + .to(GAME_SC_ADDR) + .esdt_transfer(TOKEN_GAME.eval_to_expr(), 0, "10_000"), ); state @@ -470,8 +445,8 @@ fn game_sc_complex_flow() { // owner sends rewards let mut winners = MultiValueEncoded::, u64)>::new(); - winners.push((ManagedAddress::from(USER1_ADDR.eval_to_array()), 8000u64)); // 80% - winners.push((ManagedAddress::from(USER2_ADDR.eval_to_array()), 2000u64)); // 20% + winners.push((ManagedAddress::from(USER1_ADDR.to_address()), 8000u64)); // 80% + winners.push((ManagedAddress::from(USER2_ADDR.to_address()), 2000u64)); // 20% // make owner admin first state @@ -484,7 +459,7 @@ fn game_sc_complex_flow() { .run(); // send reward - state.send_reward(1u64, OptionalValue::Some(winners), OptionalValue::None); + state.send_reward(1u64, OptionalValue::Some(winners), None); // user1 should receive 80% of the reward // reward = 3 * wager = 300 => user1's reward = 240 @@ -508,7 +483,7 @@ fn invalid_game_test() { let waiting_time = 100u64; // => timestamp 102 should be out of waiting time let number_of_players_min = 3u64; let number_of_players_max = 5u64; - let wager = RustBigUint::from(100u64); + let wager = 100u64; // deploy state.deploy(); @@ -521,16 +496,16 @@ fn invalid_game_test() { waiting_time, number_of_players_min, number_of_players_max, - wager.clone(), + wager, OWNER_ADDR, 1, ); // user1 joins - state.join_game(1u64, USER1_ADDR, wager.clone(), OptionalValue::None); + state.join_game(1u64, USER1_ADDR, wager, None); // user2 joins - state.join_game(1u64, USER2_ADDR, wager, OptionalValue::None); + state.join_game(1u64, USER2_ADDR, wager, None); // game is still invalid, min number of players not reached let game_setting = state @@ -540,11 +515,10 @@ fn invalid_game_test() { .to(GAME_SC_ADDR) .typed(game_proxy::MvxGameScProxy) .game_settings(1u64) - .returns(ReturnsResultUnmanaged) + .returns(ReturnsResult) .run(); - let game_settings = SingleValue::from(game_setting); - assert_eq!(game_settings.into().status, game_proxy::Status::Invalid); + assert_eq!(game_setting.status, game_proxy::Status::Invalid); // set now = 102, past waiting time state.world.current_block().block_timestamp(102); @@ -560,7 +534,7 @@ fn invalid_game_test() { .run(); // send reward, invalid game => players should receive back wager, creator should receive the creation fee back - state.send_reward(1u64, OptionalValue::None, OptionalValue::None); + state.send_reward(1u64, OptionalValue::None, None); state .world diff --git a/contracts/mvx-game-sc/wasm/Cargo.lock b/contracts/mvx-game-sc/wasm/Cargo.lock index aeb383de..f0690f0e 100644 --- a/contracts/mvx-game-sc/wasm/Cargo.lock +++ b/contracts/mvx-game-sc/wasm/Cargo.lock @@ -38,14 +38,25 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "multiversx-chain-core" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c1088b268cad0d8c1146df9ca71a1f2baaee78267ab75e2202c0c0c71cc4b6e" +dependencies = [ + "bitflags", + "multiversx-sc-codec", +] + [[package]] name = "multiversx-sc" -version = "0.53.2" +version = "0.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" +checksum = "c4abf60eb027d0b005a1778dc9d670a473065ab8e5bea22eeb6ace7f118dc36f" dependencies = [ "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -77,9 +88,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.53.2" +version = "0.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" +checksum = "3caeda89d90190c4002f7482e934e3981968d6853f70f865d23c8d2938bd907b" dependencies = [ "hex", "proc-macro2", @@ -90,9 +101,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.53.2" +version = "0.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" +checksum = "b10f0b29d4bcd7520e659ae2429ea9a4f02b7203a77d7788bebc79786babd250" dependencies = [ "multiversx-sc", ] diff --git a/contracts/mvx-game-sc/wasm/Cargo.toml b/contracts/mvx-game-sc/wasm/Cargo.toml index 776c7d2f..c48e5158 100644 --- a/contracts/mvx-game-sc/wasm/Cargo.toml +++ b/contracts/mvx-game-sc/wasm/Cargo.toml @@ -1,3 +1,9 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "mvx-game-sc-wasm" version = "0.0.0" diff --git a/contracts/mystery-box/sc-config.toml b/contracts/mystery-box/sc-config.toml new file mode 100644 index 00000000..04be0bf0 --- /dev/null +++ b/contracts/mystery-box/sc-config.toml @@ -0,0 +1,2 @@ +[[proxy]] +path = "src/mystery_box_proxy.rs" \ No newline at end of file diff --git a/contracts/mystery-box/src/lib.rs b/contracts/mystery-box/src/lib.rs index 85999dd4..0d46885f 100644 --- a/contracts/mystery-box/src/lib.rs +++ b/contracts/mystery-box/src/lib.rs @@ -4,6 +4,7 @@ use multiversx_sc::imports::*; pub mod config; pub mod events; +pub mod mystery_box_proxy; pub mod rewards; pub mod token_attributes; diff --git a/contracts/mystery-box/src/mystery_box_proxy.rs b/contracts/mystery-box/src/mystery_box_proxy.rs new file mode 100644 index 00000000..1ea21fae --- /dev/null +++ b/contracts/mystery-box/src/mystery_box_proxy.rs @@ -0,0 +1,229 @@ +// Code generated by the multiversx-sc proxy generator. DO NOT EDIT. + +//////////////////////////////////////////////////// +////////////////// AUTO-GENERATED ////////////////// +//////////////////////////////////////////////////// + +#![allow(dead_code)] +#![allow(clippy::all)] + +use multiversx_sc::proxy_imports::*; + +pub struct MysteryBoxProxy; + +impl TxProxyTrait for MysteryBoxProxy +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + type TxProxyMethods = MysteryBoxProxyMethods; + + fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { + MysteryBoxProxyMethods { wrapped_tx: tx } + } +} + +pub struct MysteryBoxProxyMethods +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + wrapped_tx: Tx, +} + +#[rustfmt::skip] +impl MysteryBoxProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + Gas: TxGas, +{ + pub fn init< + Arg0: ProxyArg>, + >( + self, + mystery_box_token_id: Arg0, + ) -> TxTypedDeploy { + self.wrapped_tx + .payment(NotPayable) + .raw_deploy() + .argument(&mystery_box_token_id) + .original_result() + } +} + +#[rustfmt::skip] +impl MysteryBoxProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn setup_mystery_box< + Arg0: ProxyArg, BigUint, ManagedBuffer, u64, u64>>>, + >( + self, + winning_rates_list: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setupMysteryBox") + .argument(&winning_rates_list) + .original_result() + } + + pub fn update_mystery_box_uris< + Arg0: ProxyArg>>, + >( + self, + uris: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("updateMysteryBoxUris") + .argument(&uris) + .original_result() + } + + pub fn create_mystery_box< + Arg0: ProxyArg>, + >( + self, + amount: Arg0, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("createMysteryBox") + .argument(&amount) + .original_result() + } + + pub fn open_mystery_box( + self, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("openMysteryBox") + .original_result() + } + + pub fn mystery_box_token_id( + self, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getMysteryBoxTokenIdentifier") + .original_result() + } + + pub fn global_cooldown_epoch< + Arg0: ProxyArg, + >( + self, + reward: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getGlobalCooldownEpoch") + .argument(&reward) + .original_result() + } + + pub fn winning_rates( + self, + ) -> TxTypedCall>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getWinningRates") + .original_result() + } + + pub fn mystery_box_uris( + self, + ) -> TxTypedCall>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getMysteryBoxUris") + .original_result() + } + + pub fn is_admin< + Arg0: ProxyArg>, + >( + self, + address: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("isAdmin") + .argument(&address) + .original_result() + } + + pub fn add_admin< + Arg0: ProxyArg>, + >( + self, + address: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("addAdmin") + .argument(&address) + .original_result() + } + + pub fn remove_admin< + Arg0: ProxyArg>, + >( + self, + address: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("removeAdmin") + .argument(&address) + .original_result() + } + + pub fn admins( + self, + ) -> TxTypedCall>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getAdmins") + .original_result() + } +} + +#[type_abi] +#[derive(ManagedVecItem, NestedEncode, NestedDecode, TopEncode, TopDecode, PartialEq, Eq, Clone)] +pub enum RewardType { + None, + ExperiencePoints, + MysteryBox, + SFT, + PercentValue, + FixedValue, + CustomReward, +} + +#[type_abi] +#[derive(ManagedVecItem, NestedEncode, NestedDecode, TopEncode, TopDecode, PartialEq, Eq, Clone)] +pub struct Reward +where + Api: ManagedTypeApi, +{ + pub reward_type: RewardType, + pub reward_token_id: EgldOrEsdtTokenIdentifier, + pub value: BigUint, + pub description: ManagedBuffer, + pub percentage_chance: u64, + pub epochs_cooldown: u64, +} diff --git a/contracts/mystery-box/tests/mystery_box_mod.rs b/contracts/mystery-box/tests/mystery_box_mod.rs new file mode 100644 index 00000000..684e3b88 --- /dev/null +++ b/contracts/mystery-box/tests/mystery_box_mod.rs @@ -0,0 +1,192 @@ +use multiversx_sc::{ + imports::MultiValue6, + types::{ + BigUint, EgldOrEsdtTokenIdentifier, EsdtLocalRole, ManagedBuffer, MultiValueEncoded, + ReturnsResult, TestAddress, TestEsdtTransfer, TestSCAddress, TestTokenIdentifier, + }, +}; +use multiversx_sc_scenario::{ + api::StaticApi, imports::MxscPath, managed_buffer, ScenarioTxRun, ScenarioTxWhitebox, + ScenarioWorld, +}; +use mystery_box::{mystery_box_proxy, MysteryBox}; + +pub const CODE_PATH: MxscPath = MxscPath::new("output/mystery-box.mxsc.json"); +pub const MB_TOKEN: TestTokenIdentifier = TestTokenIdentifier::new("MBTOK-abcdef"); +pub const MYSTERY_BOX_ADDRESS: TestSCAddress = TestSCAddress::new("mystery-box"); +pub const OWNER: TestAddress = TestAddress::new("owner"); + +fn world() -> ScenarioWorld { + let mut blockchain = ScenarioWorld::new(); + + blockchain.set_current_dir_from_workspace("contracts/mystery-box"); + blockchain.register_contract(CODE_PATH, mystery_box::ContractBuilder); + blockchain +} + +pub struct MysteryBoxSetup { + pub world: ScenarioWorld, +} + +impl MysteryBoxSetup { + pub fn new() -> Self { + let mut mystery_box = MysteryBoxSetup { world: world() }; + + mystery_box.world.account(OWNER).nonce(1); + + let mb_token_roles = vec![ + EsdtLocalRole::NftCreate.name().to_string(), + EsdtLocalRole::NftAddQuantity.name().to_string(), + EsdtLocalRole::NftBurn.name().to_string(), + ]; + mystery_box + .world + .account(MYSTERY_BOX_ADDRESS) + .code(CODE_PATH) + .owner(OWNER) + .esdt_roles(MB_TOKEN, mb_token_roles); + mystery_box + .world + .tx() + .from(OWNER) + .to(MYSTERY_BOX_ADDRESS) + .whitebox(mystery_box::contract_obj, |sc| { + sc.init(MB_TOKEN.to_token_identifier()); + }); + + mystery_box.setup_mystery_box(900, 5_999, 1, 3_000, 0, 1_500, 1_000, 0, 50, 1, 1, 1, 0, 0); + + mystery_box + } + + #[allow(clippy::too_many_arguments)] + pub fn setup_mystery_box( + &mut self, + experience_points_amount: u64, + experience_points_percentage: u64, + experience_points_cooldown: u64, + sft_reward_percentage: u64, + sft_reward_cooldown: u64, + percent_reward_amount: u64, + percent_reward_percentage: u64, + percent_reward_cooldown: u64, + fixed_value_reward_amount: u64, + fixed_value_reward_percentage: u64, + fixed_value_reward_cooldown: u64, + custom_reward_amount: u64, + custom_reward_percentage: u64, + custom_reward_cooldown: u64, + ) { + let mut rewards_list: MultiValueEncoded< + StaticApi, + MultiValue6< + mystery_box_proxy::RewardType, + EgldOrEsdtTokenIdentifier, + BigUint, + ManagedBuffer, + u64, + u64, + >, + > = MultiValueEncoded::new(); + let mut reward = ( + mystery_box_proxy::RewardType::ExperiencePoints, + EgldOrEsdtTokenIdentifier::egld(), + BigUint::from(experience_points_amount), + ManagedBuffer::from(b"ExperiencePoints"), + experience_points_percentage, + experience_points_cooldown, + ) + .into(); + rewards_list.push(reward); + + reward = ( + mystery_box_proxy::RewardType::MysteryBox, + EgldOrEsdtTokenIdentifier::esdt(MB_TOKEN.to_token_identifier()), + BigUint::from(1u64), + ManagedBuffer::from(b"MysteryBox"), + sft_reward_percentage, + sft_reward_cooldown, + ) + .into(); + rewards_list.push(reward); + + reward = ( + mystery_box_proxy::RewardType::PercentValue, + EgldOrEsdtTokenIdentifier::egld(), + BigUint::from(percent_reward_amount), + ManagedBuffer::from(b"Percent"), + percent_reward_percentage, + percent_reward_cooldown, + ) + .into(); + rewards_list.push(reward); + + reward = ( + mystery_box_proxy::RewardType::FixedValue, + EgldOrEsdtTokenIdentifier::egld(), + BigUint::from(fixed_value_reward_amount), + ManagedBuffer::from(b"FixedValue"), + fixed_value_reward_percentage, + fixed_value_reward_cooldown, + ) + .into(); + rewards_list.push(reward); + + reward = ( + mystery_box_proxy::RewardType::CustomReward, + EgldOrEsdtTokenIdentifier::egld(), + BigUint::from(custom_reward_amount), + ManagedBuffer::from(b"CustomText"), + custom_reward_percentage, + custom_reward_cooldown, + ) + .into(); + rewards_list.push(reward); + + self.world + .tx() + .from(OWNER) + .to(MYSTERY_BOX_ADDRESS) + .typed(mystery_box_proxy::MysteryBoxProxy) + .setup_mystery_box(rewards_list) + .run(); + + let mut uris = MultiValueEncoded::new(); + uris.push(managed_buffer!(b"www.cool_nft.com/my_nft.jpg")); + uris.push(managed_buffer!(b"www.cool_nft.com/my_nft.json")); + self.world + .tx() + .from(OWNER) + .to(MYSTERY_BOX_ADDRESS) + .typed(mystery_box_proxy::MysteryBoxProxy) + .update_mystery_box_uris(uris) + .run(); + } + + pub fn create_mystery_box(&mut self, amount: u64) -> u64 { + let token = self + .world + .tx() + .from(OWNER) + .to(MYSTERY_BOX_ADDRESS) + .typed(mystery_box_proxy::MysteryBoxProxy) + .create_mystery_box(amount) + .returns(ReturnsResult) + .run(); + + assert_eq!(token.amount, BigUint::from(amount)); + + token.token_nonce + } + + pub fn open_mystery_box(&mut self, mb_token_nonce: u64) { + self.world + .tx() + .from(OWNER) + .to(MYSTERY_BOX_ADDRESS) + .typed(mystery_box_proxy::MysteryBoxProxy) + .open_mystery_box() + .esdt(TestEsdtTransfer(MB_TOKEN, mb_token_nonce, 1)) + .run(); + } +} diff --git a/contracts/mystery-box/tests/mystery_box_setup/mod.rs b/contracts/mystery-box/tests/mystery_box_setup/mod.rs deleted file mode 100644 index 551523ac..00000000 --- a/contracts/mystery-box/tests/mystery_box_setup/mod.rs +++ /dev/null @@ -1,242 +0,0 @@ -use multiversx_sc::types::{Address, EgldOrEsdtTokenIdentifier, EsdtLocalRole, MultiValueEncoded}; -use multiversx_sc_scenario::{ - managed_biguint, managed_buffer, managed_token_id, rust_biguint, whitebox_legacy::*, DebugApi, -}; -use mystery_box::{config::RewardType, MysteryBox}; - -pub const MYSTERY_BOX_WASM_PATH: &str = "mystery-box/output/mystery-box.mxsc.json"; -pub const MB_TOKEN_ID: &[u8] = b"MBTOK-abcdef"; - -#[allow(dead_code)] -pub struct MysteryBoxSetup -where - MysteryBoxObjBuilder: 'static + Copy + Fn() -> mystery_box::ContractObj, -{ - pub b_mock: BlockchainStateWrapper, - pub owner_address: Address, - pub mystery_box_wrapper: - ContractObjWrapper, MysteryBoxObjBuilder>, -} - -impl MysteryBoxSetup -where - MysteryBoxObjBuilder: 'static + Copy + Fn() -> mystery_box::ContractObj, -{ - pub fn new(mystery_box_builder: MysteryBoxObjBuilder) -> Self { - let rust_zero = rust_biguint!(0u64); - let mut b_mock = BlockchainStateWrapper::new(); - let owner_addr = b_mock.create_user_account(&rust_biguint!(100_000_000)); - let mystery_box_wrapper = b_mock.create_sc_account( - &rust_zero, - Some(&owner_addr), - mystery_box_builder, - MYSTERY_BOX_WASM_PATH, - ); - - b_mock - .execute_tx(&owner_addr, &mystery_box_wrapper, &rust_zero, |sc| { - sc.init(managed_token_id!(MB_TOKEN_ID)); - }) - .assert_ok(); - - let mb_token_roles = [ - EsdtLocalRole::NftCreate, - EsdtLocalRole::NftAddQuantity, - EsdtLocalRole::NftBurn, - ]; - b_mock.set_esdt_local_roles( - mystery_box_wrapper.address_ref(), - MB_TOKEN_ID, - &mb_token_roles[..], - ); - - Self::internal_setup_mystery_box( - 900, - 5_999, - 1, - 3_000, - 0, - 1_500, - 1_000, - 0, - 50, - 1, - 1, - 1, - 0, - 0, - &owner_addr, - &mystery_box_wrapper, - &mut b_mock, - ); - - MysteryBoxSetup { - b_mock, - owner_address: owner_addr, - mystery_box_wrapper, - } - } - - #[allow(clippy::too_many_arguments)] - pub fn internal_setup_mystery_box( - experience_points_amount: u64, - experience_points_percentage: u64, - experience_points_cooldown: u64, - sft_reward_percentage: u64, - sft_reward_cooldown: u64, - percent_reward_amount: u64, - percent_reward_percentage: u64, - percent_reward_cooldown: u64, - fixed_value_reward_amount: u64, - fixed_value_reward_percentage: u64, - fixed_value_reward_cooldown: u64, - custom_reward_amount: u64, - custom_reward_percentage: u64, - custom_reward_cooldown: u64, - owner_address: &Address, - mb_wrapper: &ContractObjWrapper, MysteryBoxObjBuilder>, - b_mock: &mut BlockchainStateWrapper, - ) where - MysteryBoxObjBuilder: 'static + Copy + Fn() -> mystery_box::ContractObj, - { - b_mock - .execute_tx(owner_address, mb_wrapper, &rust_biguint!(0), |sc| { - let mut rewards_list = MultiValueEncoded::new(); - let mut reward = ( - RewardType::ExperiencePoints, - EgldOrEsdtTokenIdentifier::egld(), - managed_biguint!(experience_points_amount), - managed_buffer!(b"ExperiencePoints"), - experience_points_percentage, - experience_points_cooldown, - ) - .into(); - rewards_list.push(reward); - - reward = ( - RewardType::MysteryBox, - EgldOrEsdtTokenIdentifier::esdt(managed_token_id!(MB_TOKEN_ID)), - managed_biguint!(1), - managed_buffer!(b"MysteryBox"), - sft_reward_percentage, - sft_reward_cooldown, - ) - .into(); - rewards_list.push(reward); - - reward = ( - RewardType::PercentValue, - EgldOrEsdtTokenIdentifier::egld(), - managed_biguint!(percent_reward_amount), - managed_buffer!(b"Percent"), - percent_reward_percentage, - percent_reward_cooldown, - ) - .into(); - rewards_list.push(reward); - - reward = ( - RewardType::FixedValue, - EgldOrEsdtTokenIdentifier::egld(), - managed_biguint!(fixed_value_reward_amount), - managed_buffer!(b"FixedValue"), - fixed_value_reward_percentage, - fixed_value_reward_cooldown, - ) - .into(); - rewards_list.push(reward); - - reward = ( - RewardType::CustomReward, - EgldOrEsdtTokenIdentifier::egld(), - managed_biguint!(custom_reward_amount), - managed_buffer!(b"CustomText"), - custom_reward_percentage, - custom_reward_cooldown, - ) - .into(); - rewards_list.push(reward); - - sc.setup_mystery_box(rewards_list); - - let mut uris = MultiValueEncoded::new(); - uris.push(managed_buffer!(b"www.cool_nft.com/my_nft.jpg")); - uris.push(managed_buffer!(b"www.cool_nft.com/my_nft.json")); - sc.update_mystery_box_uris(uris); - }) - .assert_ok(); - } - - pub fn create_mystery_box(&mut self, amount: u64) -> u64 { - let mut new_nonce = 0; - self.b_mock - .execute_tx( - &self.owner_address, - &self.mystery_box_wrapper, - &rust_biguint!(0), - |sc| { - let payment = sc.create_mystery_box(managed_biguint!(amount)); - new_nonce = payment.token_nonce; - - assert_eq!(payment.amount, managed_biguint!(amount)); - }, - ) - .assert_ok(); - - new_nonce - } - - pub fn open_mystery_box(&mut self, mb_token_nonce: u64) { - self.b_mock - .execute_esdt_transfer( - &self.owner_address, - &self.mystery_box_wrapper, - MB_TOKEN_ID, - mb_token_nonce, - &rust_biguint!(1), - |sc| { - sc.open_mystery_box(); - }, - ) - .assert_ok(); - } - - #[allow(clippy::too_many_arguments)] - pub fn setup_mystery_box( - &mut self, - experience_points_amount: u64, - experience_points_percentage: u64, - experience_points_cooldown: u64, - sft_reward_percentage: u64, - sft_reward_cooldown: u64, - percent_reward_amount: u64, - percent_reward_percentage: u64, - percent_reward_cooldown: u64, - fixed_value_reward_amount: u64, - fixed_value_reward_percentage: u64, - fixed_value_reward_cooldown: u64, - custom_reward_amount: u64, - custom_reward_percentage: u64, - custom_reward_cooldown: u64, - ) { - Self::internal_setup_mystery_box( - experience_points_amount, - experience_points_percentage, - experience_points_cooldown, - sft_reward_percentage, - sft_reward_cooldown, - percent_reward_amount, - percent_reward_percentage, - percent_reward_cooldown, - fixed_value_reward_amount, - fixed_value_reward_percentage, - fixed_value_reward_cooldown, - custom_reward_amount, - custom_reward_percentage, - custom_reward_cooldown, - &self.owner_address, - &self.mystery_box_wrapper, - &mut self.b_mock, - ); - } -} diff --git a/contracts/mystery-box/tests/mystery_box_test.rs b/contracts/mystery-box/tests/mystery_box_test.rs index 5c12a62f..43fdeb1d 100644 --- a/contracts/mystery-box/tests/mystery_box_test.rs +++ b/contracts/mystery-box/tests/mystery_box_test.rs @@ -1,24 +1,24 @@ -#![allow(deprecated)] +use multiversx_sc_scenario::imports::BytesValue; +use mystery_box_mod::MysteryBoxSetup; -mod mystery_box_setup; -use mystery_box_setup::*; +mod mystery_box_mod; #[test] fn test_mystery_box_setup() { - let _ = MysteryBoxSetup::new(mystery_box::contract_obj); + MysteryBoxSetup::new(); } #[test] fn test_mb_token_nonce_stacking() { - let mut mb_setup = MysteryBoxSetup::new(mystery_box::contract_obj); + let mut mb_setup = MysteryBoxSetup::new(); - mb_setup.b_mock.set_block_epoch(1); + mb_setup.world.current_block().block_epoch(1); let first_mb_token_nonce = mb_setup.create_mystery_box(1); let second_mb_token_nonce = mb_setup.create_mystery_box(1); assert_eq!(first_mb_token_nonce, second_mb_token_nonce); - mb_setup.b_mock.set_block_epoch(2); + mb_setup.world.current_block().block_epoch(2); mb_setup.open_mystery_box(second_mb_token_nonce); mb_setup.setup_mystery_box( @@ -29,31 +29,40 @@ fn test_mb_token_nonce_stacking() { // Should be different, as they were with different attributes assert_ne!(first_mb_token_nonce, third_mb_token_nonce); - mb_setup.b_mock.set_block_epoch(3); + mb_setup.world.current_block().block_epoch(3); mb_setup.open_mystery_box(third_mb_token_nonce); } #[test] fn test_open_multiple_mystery_box() { - let mut mb_setup = MysteryBoxSetup::new(mystery_box::contract_obj); + let mut mb_setup = MysteryBoxSetup::new(); - mb_setup.b_mock.set_block_epoch(1); + mb_setup.world.current_block().block_epoch(1); let mb_token_nonce = mb_setup.create_mystery_box(3); // We need to change the block random seed to properly test the RandomnessSource functionality - mb_setup.b_mock.set_block_epoch(2); - mb_setup.b_mock.set_block_random_seed(&Box::from([2u8; 48])); + mb_setup.world.current_block().block_epoch(2); + mb_setup + .world + .current_block() + .block_random_seed(BytesValue::from(vec![2u8; 48])); mb_setup.open_mystery_box(mb_token_nonce); // We're still in epoch 2 // The first chosen reward (ExperiencePoints) is on global cooldown, // So a MysteryBox reward is chosen next (which has no cooldown) // The user receives directly a new MysteryBox, with a different nonce (new epoch) - mb_setup.b_mock.set_block_random_seed(&Box::from([3u8; 48])); + mb_setup + .world + .current_block() + .block_random_seed(BytesValue::from(vec![3u8; 48])); mb_setup.open_mystery_box(mb_token_nonce); - mb_setup.b_mock.set_block_epoch(4); - mb_setup.b_mock.set_block_random_seed(&Box::from([4u8; 48])); + mb_setup.world.current_block().block_epoch(4); + mb_setup + .world + .current_block() + .block_random_seed(BytesValue::from(vec![4u8; 48])); mb_setup.open_mystery_box(mb_token_nonce); mb_setup.open_mystery_box(mb_token_nonce); } diff --git a/contracts/mystery-box/wasm/Cargo.toml b/contracts/mystery-box/wasm/Cargo.toml index 96e3b1bf..895aae21 100644 --- a/contracts/mystery-box/wasm/Cargo.toml +++ b/contracts/mystery-box/wasm/Cargo.toml @@ -1,3 +1,9 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "mystery-box-wasm" version = "0.0.0" From d2e10a373209d9fc69c14ffe13f60766c06da105 Mon Sep 17 00:00:00 2001 From: BiancaIalangi Date: Mon, 18 Nov 2024 18:57:25 +0200 Subject: [PATCH 03/13] 0.54 upgrade - nft escrow, nft minter, nft storage prepay, on chain claim --- .../tests/nft_escrow_scenario_rs_test.rs | 9 +- contracts/nft-escrow/wasm/Cargo.lock | 31 +- contracts/nft-escrow/wasm/Cargo.toml | 6 + .../tests/nft_minter_scenario_rs_test.rs | 9 +- contracts/nft-minter/wasm/Cargo.lock | 31 +- contracts/nft-minter/wasm/Cargo.toml | 6 + contracts/nft-storage-prepay/wasm/Cargo.lock | 31 +- contracts/nft-storage-prepay/wasm/Cargo.toml | 6 + contracts/on-chain-claim/tests/tests.rs | 1159 ++++++++--------- contracts/on-chain-claim/wasm/Cargo.lock | 35 +- contracts/on-chain-claim/wasm/Cargo.toml | 6 + 11 files changed, 665 insertions(+), 664 deletions(-) diff --git a/contracts/nft-escrow/tests/nft_escrow_scenario_rs_test.rs b/contracts/nft-escrow/tests/nft_escrow_scenario_rs_test.rs index b78c1d9f..ac6bea07 100644 --- a/contracts/nft-escrow/tests/nft_escrow_scenario_rs_test.rs +++ b/contracts/nft-escrow/tests/nft_escrow_scenario_rs_test.rs @@ -1,7 +1,14 @@ use multiversx_sc_scenario::*; fn world() -> ScenarioWorld { - todo!() + let mut blockchain = ScenarioWorld::new(); + + blockchain.set_current_dir_from_workspace("contracts/nft-escrow"); + blockchain.register_contract( + "mxsc:output/nft-escrow.mxsc.json", + nft_escrow::ContractBuilder, + ); + blockchain } #[test] diff --git a/contracts/nft-escrow/wasm/Cargo.lock b/contracts/nft-escrow/wasm/Cargo.lock index c4dcccc7..febf566b 100644 --- a/contracts/nft-escrow/wasm/Cargo.lock +++ b/contracts/nft-escrow/wasm/Cargo.lock @@ -38,14 +38,25 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "multiversx-chain-core" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" +dependencies = [ + "bitflags", + "multiversx-sc-codec", +] + [[package]] name = "multiversx-sc" -version = "0.53.2" +version = "0.54.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" +checksum = "c2e8edabd1e3eea1c85f96485d88116a95f57429b8e4f002444d6465608d1bf5" dependencies = [ "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -54,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -65,9 +76,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -77,9 +88,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.53.2" +version = "0.54.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" +checksum = "c8712fed727b0f22094616c6398c821899e03f5998dab619acd54ece669de3e8" dependencies = [ "hex", "proc-macro2", @@ -90,9 +101,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.53.2" +version = "0.54.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" +checksum = "6c143d26d1b683d96b10c49f373d980fe573c77f5f7826f97a2214cfd65348f3" dependencies = [ "multiversx-sc", ] diff --git a/contracts/nft-escrow/wasm/Cargo.toml b/contracts/nft-escrow/wasm/Cargo.toml index 991b27c3..06776c12 100644 --- a/contracts/nft-escrow/wasm/Cargo.toml +++ b/contracts/nft-escrow/wasm/Cargo.toml @@ -1,3 +1,9 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "nft-escrow-wasm" version = "0.0.0" diff --git a/contracts/nft-minter/tests/nft_minter_scenario_rs_test.rs b/contracts/nft-minter/tests/nft_minter_scenario_rs_test.rs index 3d3961f1..1a8df920 100644 --- a/contracts/nft-minter/tests/nft_minter_scenario_rs_test.rs +++ b/contracts/nft-minter/tests/nft_minter_scenario_rs_test.rs @@ -1,7 +1,14 @@ use multiversx_sc_scenario::*; fn world() -> ScenarioWorld { - todo!() + let mut blockchain = ScenarioWorld::new(); + + blockchain.set_current_dir_from_workspace("contracts/nft-minter"); + blockchain.register_contract( + "mxsc:output/nft-minter.mxsc.json", + nft_minter::ContractBuilder, + ); + blockchain } #[test] diff --git a/contracts/nft-minter/wasm/Cargo.lock b/contracts/nft-minter/wasm/Cargo.lock index e9e615cd..fc67ef21 100644 --- a/contracts/nft-minter/wasm/Cargo.lock +++ b/contracts/nft-minter/wasm/Cargo.lock @@ -38,14 +38,25 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "multiversx-chain-core" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" +dependencies = [ + "bitflags", + "multiversx-sc-codec", +] + [[package]] name = "multiversx-sc" -version = "0.53.2" +version = "0.54.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" +checksum = "c2e8edabd1e3eea1c85f96485d88116a95f57429b8e4f002444d6465608d1bf5" dependencies = [ "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -54,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -65,9 +76,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -77,9 +88,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.53.2" +version = "0.54.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" +checksum = "c8712fed727b0f22094616c6398c821899e03f5998dab619acd54ece669de3e8" dependencies = [ "hex", "proc-macro2", @@ -90,9 +101,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.53.2" +version = "0.54.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" +checksum = "6c143d26d1b683d96b10c49f373d980fe573c77f5f7826f97a2214cfd65348f3" dependencies = [ "multiversx-sc", ] diff --git a/contracts/nft-minter/wasm/Cargo.toml b/contracts/nft-minter/wasm/Cargo.toml index 172064bd..fbd3a92c 100644 --- a/contracts/nft-minter/wasm/Cargo.toml +++ b/contracts/nft-minter/wasm/Cargo.toml @@ -1,3 +1,9 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "nft-minter-wasm" version = "0.0.0" diff --git a/contracts/nft-storage-prepay/wasm/Cargo.lock b/contracts/nft-storage-prepay/wasm/Cargo.lock index 55b0859d..1da03583 100644 --- a/contracts/nft-storage-prepay/wasm/Cargo.lock +++ b/contracts/nft-storage-prepay/wasm/Cargo.lock @@ -38,14 +38,25 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "multiversx-chain-core" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" +dependencies = [ + "bitflags", + "multiversx-sc-codec", +] + [[package]] name = "multiversx-sc" -version = "0.53.2" +version = "0.54.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" +checksum = "c2e8edabd1e3eea1c85f96485d88116a95f57429b8e4f002444d6465608d1bf5" dependencies = [ "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -54,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -65,9 +76,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -77,9 +88,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.53.2" +version = "0.54.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" +checksum = "c8712fed727b0f22094616c6398c821899e03f5998dab619acd54ece669de3e8" dependencies = [ "hex", "proc-macro2", @@ -90,9 +101,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.53.2" +version = "0.54.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" +checksum = "6c143d26d1b683d96b10c49f373d980fe573c77f5f7826f97a2214cfd65348f3" dependencies = [ "multiversx-sc", ] diff --git a/contracts/nft-storage-prepay/wasm/Cargo.toml b/contracts/nft-storage-prepay/wasm/Cargo.toml index 2030d28c..f1b7e7d3 100644 --- a/contracts/nft-storage-prepay/wasm/Cargo.toml +++ b/contracts/nft-storage-prepay/wasm/Cargo.toml @@ -1,3 +1,9 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "nft-storage-prepay-wasm" version = "0.0.0" diff --git a/contracts/on-chain-claim/tests/tests.rs b/contracts/on-chain-claim/tests/tests.rs index 98a83db2..4060bc17 100644 --- a/contracts/on-chain-claim/tests/tests.rs +++ b/contracts/on-chain-claim/tests/tests.rs @@ -1,176 +1,139 @@ use config::ConfigModule; -use multiversx_sc::types::{BigUint, EsdtTokenPayment, ManagedAddress, TokenIdentifier}; +use imports::{ + EsdtLocalRole, MxscPath, TestAddress, TestEsdtTransfer, TestSCAddress, TestTokenIdentifier, +}; +use multiversx_sc::types::{BigUint, EsdtTokenPayment, ManagedAddress}; use multiversx_sc_modules::only_admin::OnlyAdminModule; -use multiversx_sc_scenario::{scenario_model::*, *}; +use multiversx_sc_scenario::*; use on_chain_claim::*; -const ON_CHAIN_CLAIM_PATH_EXPR: &str = "mxsc:output/on-chain-claim.mxsc.json"; -const TOKEN_IDENTIFIER: &str = "XREPAIR-abcdef"; -const OTHER_TOKEN_IDENTIFIER_EXPR: &str = "str:XREPAIRRR-abcdef"; -const TOKEN_IDENTIFIER_EXPR: &str = "str:XREPAIR-abcdef"; +const ON_CHAIN_CLAIM_PATH: MxscPath = MxscPath::new("mxsc:output/on-chain-claim.mxsc.json"); +const XREPAIR_TOKEN_2: TestTokenIdentifier = TestTokenIdentifier::new("XREPAIRRR-abcdef"); +const XREPAIR_TOKEN: TestTokenIdentifier = TestTokenIdentifier::new("XREPAIR-abcdef"); const TOKEN_NONCE: u64 = 1; -const USER1_ADDR: &str = "address:user1"; -const OWNER_ADDR: &str = "address:owner"; -const SC_ADDR: &str = "sc:on-chain-claim"; +const USER: TestAddress = TestAddress::new("user"); +const OWNER: TestAddress = TestAddress::new("owner"); +const SC_ADDR: TestSCAddress = TestSCAddress::new("on-chain-claim"); fn world() -> ScenarioWorld { let mut blockchain = ScenarioWorld::new(); - blockchain.register_contract( - "mxsc:output/on-chain-claim.mxsc.json", - on_chain_claim::ContractBuilder, - ); + blockchain.set_current_dir_from_workspace("contracts/on-chain-claim"); + blockchain.register_contract(ON_CHAIN_CLAIM_PATH, on_chain_claim::ContractBuilder); + blockchain } +fn setup_with_one_token(world: &mut ScenarioWorld) { + let roles: Vec = vec![EsdtLocalRole::NftBurn.name().to_string()]; + + world.account(OWNER).nonce(1); + world + .account(USER) + .nonce(1) + .esdt_nft_balance(XREPAIR_TOKEN, TOKEN_NONCE, 1, ()); + world + .account(SC_ADDR) + .nonce(1) + .code(ON_CHAIN_CLAIM_PATH) + .owner(OWNER) + .esdt_roles(XREPAIR_TOKEN, roles); + + world.current_block().block_epoch(20); + world.new_address(OWNER, TOKEN_NONCE, SC_ADDR); +} + +fn setup_with_two_token(world: &mut ScenarioWorld) { + let roles: Vec = vec![EsdtLocalRole::NftBurn.name().to_string()]; + + world.account(OWNER).nonce(1); + world + .account(USER) + .nonce(1) + .esdt_nft_balance(XREPAIR_TOKEN, TOKEN_NONCE, 100, ()) + .esdt_nft_balance(XREPAIR_TOKEN_2, TOKEN_NONCE, 1, ()); + world + .account(SC_ADDR) + .nonce(1) + .code(ON_CHAIN_CLAIM_PATH) + .owner(OWNER) + .esdt_roles(XREPAIR_TOKEN, roles); + + world.current_block().block_epoch(20); + world.new_address(OWNER, TOKEN_NONCE, SC_ADDR); +} + #[test] fn check_token_identifier() { let mut world = world(); - let on_chain_claim_whitebox = WhiteboxContract::new(SC_ADDR, on_chain_claim::contract_obj); - let on_chain_claim_code = world.code_expression(ON_CHAIN_CLAIM_PATH_EXPR); - - let roles: Vec = vec!["ESDTRoleNFTBurn".to_string()]; - - world - .set_state_step( - SetStateStep::new() - .put_account(OWNER_ADDR, Account::new().nonce(1)) - .put_account( - USER1_ADDR, - Account::new().nonce(1).esdt_nft_balance( - TOKEN_IDENTIFIER_EXPR, - TOKEN_NONCE, - "1", - Option::Some(()), - ), - ) - .put_account( - SC_ADDR, - Account::new() - .nonce(1) - .code(&on_chain_claim_code) - .owner(OWNER_ADDR) - .esdt_roles(TOKEN_IDENTIFIER_EXPR, roles), - ) - .block_epoch(20) - .new_address(OWNER_ADDR, TOKEN_NONCE, SC_ADDR), - ) - .whitebox_call( - &on_chain_claim_whitebox, - ScCallStep::new().from(SC_ADDR), - |sc| { - let payment = EsdtTokenPayment::new( - TokenIdentifier::from(TOKEN_IDENTIFIER), - 1u64, - BigUint::from(1u64), - ); - sc.repair_streak_payment().set(payment); - }, - ); + setup_with_one_token(&mut world); + + world + .tx() + .from(OWNER) + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let payment = EsdtTokenPayment::new( + XREPAIR_TOKEN.to_token_identifier(), + 1u64, + BigUint::from(1u64), + ); + sc.repair_streak_payment().set(payment); + }); } #[test] fn check_before_claim() { let mut world = world(); - let on_chain_claim_whitebox = WhiteboxContract::new(SC_ADDR, on_chain_claim::contract_obj); - let on_chain_claim_code = world.code_expression(ON_CHAIN_CLAIM_PATH_EXPR); - - let roles: Vec = vec!["ESDTRoleNFTBurn".to_string()]; - - world - .set_state_step( - SetStateStep::new() - .put_account(OWNER_ADDR, Account::new().nonce(1)) - .put_account( - USER1_ADDR, - Account::new().nonce(1).esdt_nft_balance( - TOKEN_IDENTIFIER_EXPR, - TOKEN_NONCE, - "1", - Option::Some(()), - ), - ) - .put_account( - SC_ADDR, - Account::new() - .nonce(1) - .code(&on_chain_claim_code) - .owner(OWNER_ADDR) - .esdt_roles(TOKEN_IDENTIFIER_EXPR, roles), - ) - .block_epoch(20) - .new_address(OWNER_ADDR, TOKEN_NONCE, SC_ADDR), - ) - .whitebox_query(&on_chain_claim_whitebox, |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); + setup_with_one_token(&mut world); + + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); let address_info_mapper = sc.address_info(managed_address); assert!(address_info_mapper.is_empty()); - }); + }) } #[test] fn check_update_state() { let mut world = world(); - let on_chain_claim_whitebox = WhiteboxContract::new(SC_ADDR, on_chain_claim::contract_obj); - let on_chain_claim_code = world.code_expression(ON_CHAIN_CLAIM_PATH_EXPR); - - let roles: Vec = vec!["ESDTRoleNFTBurn".to_string()]; - - world - .set_state_step( - SetStateStep::new() - .put_account(OWNER_ADDR, Account::new().nonce(1)) - .put_account( - USER1_ADDR, - Account::new().nonce(1).esdt_nft_balance( - TOKEN_IDENTIFIER_EXPR, - TOKEN_NONCE, - "1", - Option::Some(()), - ), - ) - .put_account( - SC_ADDR, - Account::new() - .nonce(1) - .code(&on_chain_claim_code) - .owner(OWNER_ADDR) - .esdt_roles(TOKEN_IDENTIFIER_EXPR, roles), - ) - .block_epoch(20) - .new_address(OWNER_ADDR, TOKEN_NONCE, SC_ADDR), - ) - .whitebox_query(&on_chain_claim_whitebox, |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); + setup_with_one_token(&mut world); + + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); let address_info_mapper = sc.address_info(managed_address); assert!(address_info_mapper.is_empty()); - }) - .whitebox_call( - &on_chain_claim_whitebox, - ScCallStep::new().from(SC_ADDR), - |sc| { - let address = AddressValue::from(OWNER_ADDR).to_address(); - let managed_address = ManagedAddress::from(address); - - sc.add_admin(managed_address); - }, - ) - .whitebox_call( - &on_chain_claim_whitebox, - ScCallStep::new().from(OWNER_ADDR), - |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); - sc.update_state(managed_address, 5u64, 21u64, 7u64, 5u64); - }, - ) - .whitebox_query(&on_chain_claim_whitebox, |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); + }); + world + .tx() + .from(OWNER) + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = ManagedAddress::from(OWNER.to_address()); + + sc.add_admin(managed_address); + }); + world + .tx() + .from(OWNER) + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); + sc.update_state(managed_address, 5u64, 21u64, 7u64, 5u64); + }); + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); let address_info = sc.address_info(managed_address).get(); assert_eq!(address_info.current_streak, 5); @@ -182,73 +145,61 @@ fn check_update_state() { #[test] fn check_after_claim() { let mut world = world(); - let on_chain_claim_whitebox = WhiteboxContract::new(SC_ADDR, on_chain_claim::contract_obj); - let on_chain_claim_code = world.code_expression(ON_CHAIN_CLAIM_PATH_EXPR); - - let roles: Vec = vec!["ESDTRoleNFTBurn".to_string()]; - - world - .set_state_step( - SetStateStep::new() - .put_account(OWNER_ADDR, Account::new().nonce(1)) - .put_account( - USER1_ADDR, - Account::new().nonce(1).esdt_nft_balance( - TOKEN_IDENTIFIER_EXPR, - TOKEN_NONCE, - "1", - Option::Some(()), - ), - ) - .put_account( - SC_ADDR, - Account::new() - .nonce(1) - .code(&on_chain_claim_code) - .owner(OWNER_ADDR) - .esdt_roles(TOKEN_IDENTIFIER_EXPR, roles), - ) - .block_epoch(20) - .new_address(OWNER_ADDR, TOKEN_NONCE, SC_ADDR), - ) - .whitebox_call( - &on_chain_claim_whitebox, - ScCallStep::new().from(USER1_ADDR), - |sc| sc.claim(), - ) - .whitebox_query(&on_chain_claim_whitebox, |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); + setup_with_one_token(&mut world); + + world + .tx() + .from(USER) + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + sc.claim(); + }); + + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); let address_info = sc.address_info(managed_address).get(); assert_eq!(address_info.current_streak, 1); assert_eq!(address_info.total_epochs_claimed, 1); assert_eq!(address_info.last_epoch_claimed, 20); - }) - .set_state_step(SetStateStep::new().block_epoch(21)) - .whitebox_call( - &on_chain_claim_whitebox, - ScCallStep::new().from(USER1_ADDR), - |sc| sc.claim(), - ) - .whitebox_query(&on_chain_claim_whitebox, |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); + }); + + world.current_block().block_epoch(21); + world + .tx() + .from(USER) + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + sc.claim(); + }); + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); let address_info = sc.address_info(managed_address).get(); assert_eq!(address_info.current_streak, 2); assert_eq!(address_info.total_epochs_claimed, 2); assert_eq!(address_info.last_epoch_claimed, 21); - }) - .set_state_step(SetStateStep::new().block_epoch(25)) - .whitebox_call( - &on_chain_claim_whitebox, - ScCallStep::new().from(USER1_ADDR), - |sc| sc.claim(), - ) - .whitebox_query(&on_chain_claim_whitebox, |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); + }); + + world.current_block().block_epoch(25); + world + .tx() + .from(USER) + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + sc.claim(); + }); + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); let address_info = sc.address_info(managed_address).get(); assert_eq!(address_info.current_streak, 1); @@ -260,333 +211,303 @@ fn check_after_claim() { #[test] fn check_claim_and_repair() { let mut world = world(); - let on_chain_claim_whitebox = WhiteboxContract::new(SC_ADDR, on_chain_claim::contract_obj); - let on_chain_claim_code = world.code_expression(ON_CHAIN_CLAIM_PATH_EXPR); - - let roles: Vec = vec!["ESDTRoleNFTBurn".to_string()]; - - world - .set_state_step( - SetStateStep::new() - .put_account(OWNER_ADDR, Account::new().nonce(1)) - .put_account( - USER1_ADDR, - Account::new() - .nonce(1) - .esdt_nft_balance( - TOKEN_IDENTIFIER_EXPR, - TOKEN_NONCE, - "100", - Option::Some(()), - ) - .esdt_nft_balance( - OTHER_TOKEN_IDENTIFIER_EXPR, - TOKEN_NONCE, - "1", - Option::Some(()), - ), - ) - .put_account( - SC_ADDR, - Account::new() - .nonce(1) - .code(&on_chain_claim_code) - .owner(OWNER_ADDR) - .esdt_roles(TOKEN_IDENTIFIER_EXPR, roles), - ) - .block_epoch(20) - .new_address(OWNER_ADDR, TOKEN_NONCE, SC_ADDR), - ) - .whitebox_call( - &on_chain_claim_whitebox, - ScCallStep::new().from(SC_ADDR), - |sc| { - let payment = EsdtTokenPayment::new( - TokenIdentifier::from(TOKEN_IDENTIFIER), - 1u64, - BigUint::from(1u64), - ); - sc.repair_streak_payment().set(payment); - }, - ) - .whitebox_query(&on_chain_claim_whitebox, |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); + + setup_with_two_token(&mut world); + + world + .tx() + .from(OWNER) + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let payment = EsdtTokenPayment::new( + XREPAIR_TOKEN.to_token_identifier(), + 1u64, + BigUint::from(1u64), + ); + sc.repair_streak_payment().set(payment); + }); + + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); let address_info_mapper = sc.address_info(managed_address); assert!(address_info_mapper.is_empty()); - }) - .whitebox_call_check( - &on_chain_claim_whitebox, - ScCallStep::new() - .from(USER1_ADDR) - .to(SC_ADDR) - .esdt_transfer(TOKEN_IDENTIFIER_EXPR, 1, "1") - .no_expect(), - |sc| { - sc.claim_and_repair(); - }, - |r| { - r.assert_user_error("can't repair streak for address"); - }, - ) - .whitebox_query(&on_chain_claim_whitebox, |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); + }); + + world + .tx() + .from(USER) + .to(SC_ADDR) + .esdt(TestEsdtTransfer(XREPAIR_TOKEN, TOKEN_NONCE, 1)) + .with_result(ExpectMessage("can't repair streak for address")) + .whitebox(on_chain_claim::contract_obj, |sc| { + sc.claim_and_repair(); + }); + + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); let address_info_mapper = sc.address_info(managed_address); assert!(address_info_mapper.is_empty()); - }) - .whitebox_call( - &on_chain_claim_whitebox, - ScCallStep::new().from(USER1_ADDR), - |sc| sc.claim(), - ) - .whitebox_query(&on_chain_claim_whitebox, |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); + }); + world + .tx() + .from(USER) + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + sc.claim(); + }); + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); let address_info = sc.address_info(managed_address).get(); assert_eq!(address_info.current_streak, 1); assert_eq!(address_info.total_epochs_claimed, 1); assert_eq!(address_info.last_epoch_claimed, 20); - }) - .set_state_step(SetStateStep::new().block_epoch(21)) - .whitebox_call_check( - &on_chain_claim_whitebox, - ScCallStep::new() - .from(USER1_ADDR) - .to(SC_ADDR) - .esdt_transfer(TOKEN_IDENTIFIER_EXPR, TOKEN_NONCE, "1") - .no_expect(), - |sc| { - sc.claim_and_repair(); - }, - |r| { - r.assert_user_error("can't repair streak for current epoch"); - }, - ) - .whitebox_query(&on_chain_claim_whitebox, |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); + }); + + world.current_block().block_epoch(21); + + world + .tx() + .from(USER) + .to(SC_ADDR) + .esdt(TestEsdtTransfer(XREPAIR_TOKEN, TOKEN_NONCE, 1)) + .with_result(ExpectMessage("can't repair streak for current epoch")) + .whitebox(on_chain_claim::contract_obj, |sc| { + sc.claim_and_repair(); + }); + + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); let address_info = sc.address_info(managed_address).get(); assert_eq!(address_info.current_streak, 1); assert_eq!(address_info.total_epochs_claimed, 1); assert_eq!(address_info.last_epoch_claimed, 20); - }) - .set_state_step(SetStateStep::new().block_epoch(22)) - .whitebox_call_check( - &on_chain_claim_whitebox, - ScCallStep::new() - .from(USER1_ADDR) - .to(SC_ADDR) - .esdt_transfer(OTHER_TOKEN_IDENTIFIER_EXPR, 1, "1") - .no_expect(), - |sc| { - sc.claim_and_repair(); - }, - |r| { - r.assert_user_error("Bad payment token/amount"); - }, - ) - .whitebox_call_check( - &on_chain_claim_whitebox, - ScCallStep::new() - .from(USER1_ADDR) - .to(SC_ADDR) - .esdt_transfer(TOKEN_IDENTIFIER_EXPR, TOKEN_NONCE, "2") - .no_expect(), - |sc| { - sc.claim_and_repair(); - }, - |r| { - r.assert_user_error("Bad payment token/amount"); - }, - ) - .whitebox_call( - &on_chain_claim_whitebox, - ScCallStep::new() - .from(USER1_ADDR) - .to(SC_ADDR) - .esdt_transfer(TOKEN_IDENTIFIER_EXPR, 1, "1"), - |sc| { - sc.claim_and_repair(); - }, - ) - .whitebox_query(&on_chain_claim_whitebox, |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); + }); + + world.current_block().block_epoch(22); + world + .tx() + .from(USER) + .to(SC_ADDR) + .esdt(TestEsdtTransfer(XREPAIR_TOKEN_2, TOKEN_NONCE, 1)) + .with_result(ExpectMessage("Bad payment token/amount")) + .whitebox(on_chain_claim::contract_obj, |sc| { + sc.claim_and_repair(); + }); + world + .tx() + .from(USER) + .to(SC_ADDR) + .esdt(TestEsdtTransfer(XREPAIR_TOKEN, TOKEN_NONCE, 2)) + .with_result(ExpectMessage("Bad payment token/amount")) + .whitebox(on_chain_claim::contract_obj, |sc| { + sc.claim_and_repair(); + }); + world + .tx() + .from(USER) + .to(SC_ADDR) + .esdt(TestEsdtTransfer(XREPAIR_TOKEN, TOKEN_NONCE, 2)) + .with_result(ExpectMessage("Bad payment token/amount")) + .whitebox(on_chain_claim::contract_obj, |sc| { + sc.claim_and_repair(); + }); + + world + .tx() + .from(USER) + .to(SC_ADDR) + .esdt(TestEsdtTransfer(XREPAIR_TOKEN, TOKEN_NONCE, 1)) + .whitebox(on_chain_claim::contract_obj, |sc| { + sc.claim_and_repair(); + }); + + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); let address_info = sc.address_info(managed_address).get(); + assert_eq!(address_info.current_streak, 3); assert_eq!(address_info.total_epochs_claimed, 3); assert_eq!(address_info.last_epoch_claimed, 22); assert_eq!(address_info.best_streak, 3); - }) - .set_state_step(SetStateStep::new().block_epoch(28)) - .whitebox_call( - &on_chain_claim_whitebox, - ScCallStep::new() - .from(USER1_ADDR) - .to(SC_ADDR) - .esdt_transfer(TOKEN_IDENTIFIER_EXPR, 1, "1"), - |sc| { - sc.claim_and_repair(); - }, - ) - .whitebox_query(&on_chain_claim_whitebox, |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); + }); + + world.current_block().block_epoch(28); + + world + .tx() + .from(USER) + .to(SC_ADDR) + .esdt(TestEsdtTransfer(XREPAIR_TOKEN, TOKEN_NONCE, 1)) + .whitebox(on_chain_claim::contract_obj, |sc| { + sc.claim_and_repair(); + }); + + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); let address_info = sc.address_info(managed_address).get(); + assert_eq!(address_info.current_streak, 9); assert_eq!(address_info.total_epochs_claimed, 9); assert_eq!(address_info.last_epoch_claimed, 28); assert_eq!(address_info.best_streak, 9); - }) - .set_state_step(SetStateStep::new().block_epoch(36)) - .whitebox_call_check( - &on_chain_claim_whitebox, - ScCallStep::new() - .from(USER1_ADDR) - .to(SC_ADDR) - .esdt_transfer(TOKEN_IDENTIFIER_EXPR, TOKEN_NONCE, "1") - .no_expect(), - |sc| { - sc.claim_and_repair(); - }, - |r| { - r.assert_user_error("can't repair streak for current epoch"); - }, - ); + }); + + world + .tx() + .from(USER) + .to(SC_ADDR) + .esdt(TestEsdtTransfer(XREPAIR_TOKEN, TOKEN_NONCE, 1)) + .with_result(ExpectMessage("can't repair streak for current epoch")) + .whitebox(on_chain_claim::contract_obj, |sc| { + sc.claim_and_repair(); + }); } #[test] fn test_best_streak() { let mut world = world(); - let on_chain_claim_whitebox = WhiteboxContract::new(SC_ADDR, on_chain_claim::contract_obj); - let on_chain_claim_code = world.code_expression(ON_CHAIN_CLAIM_PATH_EXPR); - - let roles: Vec = vec!["ESDTRoleNFTBurn".to_string()]; - - world - .set_state_step( - SetStateStep::new() - .put_account(OWNER_ADDR, Account::new().nonce(1)) - .put_account( - USER1_ADDR, - Account::new().nonce(1).esdt_nft_balance( - TOKEN_IDENTIFIER_EXPR, - TOKEN_NONCE, - "1", - Option::Some(()), - ), - ) - .put_account( - SC_ADDR, - Account::new() - .nonce(1) - .code(&on_chain_claim_code) - .owner(OWNER_ADDR) - .esdt_roles(TOKEN_IDENTIFIER_EXPR, roles), - ) - .block_epoch(20) - .new_address(OWNER_ADDR, TOKEN_NONCE, SC_ADDR), - ) - .whitebox_call( - &on_chain_claim_whitebox, - ScCallStep::new().from(SC_ADDR), - |sc| { - let payment = EsdtTokenPayment::new( - TokenIdentifier::from(TOKEN_IDENTIFIER), - 1u64, - BigUint::from(1u64), - ); - sc.repair_streak_payment().set(payment); - }, - ) - .whitebox_call( - &on_chain_claim_whitebox, - ScCallStep::new().from(SC_ADDR), - |sc| { - let address = AddressValue::from(OWNER_ADDR).to_address(); - let managed_address = ManagedAddress::from(address); - - sc.add_admin(managed_address); - }, - ) - .whitebox_query(&on_chain_claim_whitebox, |sc| { + + setup_with_one_token(&mut world); + + world + .tx() + .from(OWNER) + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let payment = EsdtTokenPayment::new( + XREPAIR_TOKEN.to_token_identifier(), + 1u64, + BigUint::from(1u64), + ); + sc.repair_streak_payment().set(payment); + }); + world + .tx() + .from(OWNER) + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = ManagedAddress::from(OWNER.to_address()); + + sc.add_admin(managed_address); + }); + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { let repair_streak_payment = sc.repair_streak_payment().get(); - let identifier = TokenIdentifier::from(TOKEN_IDENTIFIER); - assert_eq!(repair_streak_payment.token_identifier, identifier); - }) - .whitebox_call( - &on_chain_claim_whitebox, - ScCallStep::new().from(USER1_ADDR), - |sc| sc.claim(), - ) - .whitebox_query(&on_chain_claim_whitebox, |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); + assert_eq!( + repair_streak_payment.token_identifier, + XREPAIR_TOKEN.to_token_identifier() + ); + }); + + world + .tx() + .from(USER) + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| sc.claim()); + + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); let address_info = sc.address_info(managed_address).get(); assert_eq!(address_info.current_streak, 1); assert_eq!(address_info.total_epochs_claimed, 1); assert_eq!(address_info.last_epoch_claimed, 20); assert_eq!(address_info.best_streak, 1); - }) - .set_state_step(SetStateStep::new().block_epoch(21)) - .whitebox_call( - &on_chain_claim_whitebox, - ScCallStep::new().from(USER1_ADDR), - |sc| sc.claim(), - ) - .whitebox_query(&on_chain_claim_whitebox, |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); + }); + + world.current_block().block_epoch(21); + world + .tx() + .from(USER) + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| sc.claim()); + + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); let address_info = sc.address_info(managed_address).get(); assert_eq!(address_info.current_streak, 2); assert_eq!(address_info.total_epochs_claimed, 2); assert_eq!(address_info.last_epoch_claimed, 21); assert_eq!(address_info.best_streak, 2); - }) - .set_state_step(SetStateStep::new().block_epoch(25)) - .whitebox_call( - &on_chain_claim_whitebox, - ScCallStep::new().from(USER1_ADDR), - |sc| sc.claim(), - ) - .whitebox_query(&on_chain_claim_whitebox, |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); + }); + + world.current_block().block_epoch(25); + world + .tx() + .from(USER) + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| sc.claim()); + + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); let address_info = sc.address_info(managed_address).get(); assert_eq!(address_info.current_streak, 1); assert_eq!(address_info.total_epochs_claimed, 3); assert_eq!(address_info.last_epoch_claimed, 25); assert_eq!(address_info.best_streak, 2); - }) - .set_state_step(SetStateStep::new().block_epoch(26)) - .whitebox_call( - &on_chain_claim_whitebox, - ScCallStep::new().from(USER1_ADDR), - |sc| sc.claim(), - ) - .whitebox_query(&on_chain_claim_whitebox, |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); + }); + + world.current_block().block_epoch(26); + world + .tx() + .from(USER) + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| sc.claim()); + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); let address_info = sc.address_info(managed_address).get(); assert_eq!(address_info.current_streak, 2); assert_eq!(address_info.total_epochs_claimed, 4); assert_eq!(address_info.last_epoch_claimed, 26); assert_eq!(address_info.best_streak, 2); - }) - .set_state_step(SetStateStep::new().block_epoch(27)) - .whitebox_call( - &on_chain_claim_whitebox, - ScCallStep::new().from(USER1_ADDR), - |sc| sc.claim(), - ) - .whitebox_query(&on_chain_claim_whitebox, |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); + }); + + world.current_block().block_epoch(27); + world + .tx() + .from(USER) + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| sc.claim()); + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); let address_info = sc.address_info(managed_address).get(); assert_eq!(address_info.current_streak, 3); assert_eq!(address_info.total_epochs_claimed, 5); @@ -598,181 +519,179 @@ fn test_best_streak() { #[test] fn on_chain_claim_whitebox() { let mut world = world(); - let on_chain_claim_whitebox = WhiteboxContract::new(SC_ADDR, on_chain_claim::contract_obj); - let on_chain_claim_code = world.code_expression(ON_CHAIN_CLAIM_PATH_EXPR); - - let roles: Vec = vec!["ESDTRoleNFTBurn".to_string()]; - - world - .set_state_step( - SetStateStep::new() - .put_account(OWNER_ADDR, Account::new().nonce(1)) - .put_account( - USER1_ADDR, - Account::new().nonce(1).esdt_nft_balance( - TOKEN_IDENTIFIER_EXPR, - TOKEN_NONCE, - "1", - Option::Some(()), - ), - ) - .put_account( - SC_ADDR, - Account::new() - .nonce(1) - .code(&on_chain_claim_code) - .owner(OWNER_ADDR) - .esdt_roles(TOKEN_IDENTIFIER_EXPR, roles), - ) - .block_epoch(20) - .new_address(OWNER_ADDR, TOKEN_NONCE, SC_ADDR), - ) - .whitebox_call( - &on_chain_claim_whitebox, - ScCallStep::new().from(SC_ADDR), - |sc| { - let payment = EsdtTokenPayment::new( - TokenIdentifier::from(TOKEN_IDENTIFIER), - 1u64, - BigUint::from(1u64), - ); - sc.repair_streak_payment().set(payment); - }, - ) - .whitebox_call( - &on_chain_claim_whitebox, - ScCallStep::new().from(SC_ADDR), - |sc| { - let address = AddressValue::from(OWNER_ADDR).to_address(); - let managed_address = ManagedAddress::from(address); - - sc.add_admin(managed_address); - }, - ) - .whitebox_query(&on_chain_claim_whitebox, |sc| { + + setup_with_one_token(&mut world); + + world + .tx() + .from(OWNER) + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let payment = EsdtTokenPayment::new( + XREPAIR_TOKEN.to_token_identifier(), + 1u64, + BigUint::from(1u64), + ); + sc.repair_streak_payment().set(payment); + }); + + world + .tx() + .from(OWNER) + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = ManagedAddress::from(OWNER.to_address()); + + sc.add_admin(managed_address); + }); + + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { let repair_streak_payment = sc.repair_streak_payment().get(); - let identifier = TokenIdentifier::from(TOKEN_IDENTIFIER); - assert_eq!(repair_streak_payment.token_identifier, identifier); - }) - .whitebox_call( - &on_chain_claim_whitebox, - ScCallStep::new().from(USER1_ADDR), - |sc| sc.claim(), - ) - .whitebox_query(&on_chain_claim_whitebox, |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); + assert_eq!( + repair_streak_payment.token_identifier, + XREPAIR_TOKEN.to_token_identifier() + ); + }); + world + .tx() + .from(USER) + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| sc.claim()); + + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); let address_info = sc.address_info(managed_address).get(); assert_eq!(address_info.current_streak, 1); assert_eq!(address_info.total_epochs_claimed, 1); assert_eq!(address_info.last_epoch_claimed, 20); - }) - .whitebox_query(&on_chain_claim_whitebox, |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); + + let managed_address = &ManagedAddress::from(USER.to_address()); let can_be_repaired = sc.can_be_repaired(managed_address); assert!(!can_be_repaired); - }) - .set_state_step(SetStateStep::new().block_epoch(21)) - .whitebox_query(&on_chain_claim_whitebox, |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); + }); + + world.current_block().block_epoch(21); + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); let can_be_repaired = sc.can_be_repaired(managed_address); assert!(!can_be_repaired); - }) - .set_state_step(SetStateStep::new().block_epoch(22)) - .whitebox_query(&on_chain_claim_whitebox, |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); + }); + + world.current_block().block_epoch(22); + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); let can_be_repaired = sc.can_be_repaired(managed_address); assert!(can_be_repaired); - }) - .set_state_step(SetStateStep::new().block_epoch(26)) - .whitebox_query(&on_chain_claim_whitebox, |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); + }); + + world.current_block().block_epoch(26); + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); let can_be_repaired = sc.can_be_repaired(managed_address); assert!(can_be_repaired); - }) - .set_state_step(SetStateStep::new().block_epoch(27)) - .whitebox_query(&on_chain_claim_whitebox, |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); + }); + + world.current_block().block_epoch(27); + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); let can_be_repaired = sc.can_be_repaired(managed_address); assert!(!can_be_repaired); - }) - .set_state_step(SetStateStep::new().block_epoch(28)) - .whitebox_query(&on_chain_claim_whitebox, |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); + }); + + world.current_block().block_epoch(28); + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); let can_be_repaired = sc.can_be_repaired(managed_address); assert!(!can_be_repaired); - }) - .whitebox_call_check( - &on_chain_claim_whitebox, - ScCallStep::new() - .from(USER1_ADDR) - .to(SC_ADDR) - .esdt_transfer(TOKEN_IDENTIFIER_EXPR, 1, "1") - .no_expect(), - |sc| { - sc.claim_and_repair(); - }, - |r| { - r.assert_user_error("can't repair streak for current epoch"); - }, - ) - .whitebox_call( - &on_chain_claim_whitebox, - ScCallStep::new().from(USER1_ADDR), - |sc| sc.claim(), - ) - .whitebox_query(&on_chain_claim_whitebox, |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); + }); + + world + .tx() + .from(USER) + .to(SC_ADDR) + .esdt(TestEsdtTransfer(XREPAIR_TOKEN, TOKEN_NONCE, 1)) + .with_result(ExpectMessage("can't repair streak for current epoch")) + .whitebox(on_chain_claim::contract_obj, |sc| { + sc.claim_and_repair(); + }); + + world + .tx() + .from(USER) + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| sc.claim()); + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); let address_info = sc.address_info(managed_address).get(); assert_eq!(address_info.current_streak, 1); assert_eq!(address_info.total_epochs_claimed, 2); assert_eq!(address_info.last_epoch_claimed, 28); assert_eq!(address_info.best_streak, 1); - }) - .whitebox_call( - &on_chain_claim_whitebox, - ScCallStep::new().from(OWNER_ADDR), - |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); - sc.update_state(managed_address, 5u64, 21u64, 7u64, 5u64); - }, - ) - .whitebox_query(&on_chain_claim_whitebox, |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); + }); + world + .tx() + .from(OWNER) + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); + sc.update_state(managed_address, 5u64, 21u64, 7u64, 5u64); + }); + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); let can_be_repaired = sc.can_be_repaired(managed_address); assert!(!can_be_repaired); - }) - .whitebox_query(&on_chain_claim_whitebox, |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); + }); + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); let address_info = sc.address_info(managed_address).get(); assert_eq!(address_info.current_streak, 5); assert_eq!(address_info.total_epochs_claimed, 7); assert_eq!(address_info.last_epoch_claimed, 21); assert_eq!(address_info.best_streak, 5); - }) - .whitebox_call( - &on_chain_claim_whitebox, - ScCallStep::new() - .from(USER1_ADDR) - .to(SC_ADDR) - .esdt_transfer(TOKEN_IDENTIFIER_EXPR, 1, "1"), - |sc| { - sc.claim_and_repair(); - }, - ) - .whitebox_query(&on_chain_claim_whitebox, |sc| { - let address = AddressValue::from(USER1_ADDR).to_address(); - let managed_address = &ManagedAddress::from(address); + }); + world + .tx() + .from(USER) + .to(SC_ADDR) + .esdt(TestEsdtTransfer(XREPAIR_TOKEN, TOKEN_NONCE, 1)) + .whitebox(on_chain_claim::contract_obj, |sc| { + sc.claim_and_repair(); + }); + world + .query() + .to(SC_ADDR) + .whitebox(on_chain_claim::contract_obj, |sc| { + let managed_address = &ManagedAddress::from(USER.to_address()); let address_info = sc.address_info(managed_address).get(); assert_eq!(address_info.current_streak, 12); assert_eq!(address_info.total_epochs_claimed, 14); diff --git a/contracts/on-chain-claim/wasm/Cargo.lock b/contracts/on-chain-claim/wasm/Cargo.lock index 387bf6d6..9e1a3daa 100644 --- a/contracts/on-chain-claim/wasm/Cargo.lock +++ b/contracts/on-chain-claim/wasm/Cargo.lock @@ -38,14 +38,25 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "multiversx-chain-core" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" +dependencies = [ + "bitflags", + "multiversx-sc-codec", +] + [[package]] name = "multiversx-sc" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -54,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -65,9 +76,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -77,9 +88,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -90,18 +101,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daeb48acbd39255868a3241798df2f85050f0ae8d82d6417bd2cd0e30a241855" +checksum = "74b31cfc990a3052a0e014f749104752a0208f3d11d4dee3c0dd6e6d4ce1908c" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/on-chain-claim/wasm/Cargo.toml b/contracts/on-chain-claim/wasm/Cargo.toml index fa416dc0..3d5aadd6 100644 --- a/contracts/on-chain-claim/wasm/Cargo.toml +++ b/contracts/on-chain-claim/wasm/Cargo.toml @@ -1,3 +1,9 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "on-chain-claim-wasm" version = "0.0.0" From 8561a3de03dd02be82c65e71144742f06fbf7fb1 Mon Sep 17 00:00:00 2001 From: BiancaIalangi Date: Mon, 18 Nov 2024 23:53:31 +0200 Subject: [PATCH 04/13] 0.54 upgrade - order book, pair mock, price aggregator, proxy deployer --- contracts/order-book/factory/wasm/Cargo.lock | 31 +- contracts/order-book/factory/wasm/Cargo.toml | 6 + .../pair/tests/pair_scenario_rs_test.rs | 1 + contracts/order-book/pair/wasm/Cargo.lock | 31 +- contracts/order-book/pair/wasm/Cargo.toml | 6 + contracts/pair-mock/wasm/Cargo.lock | 31 +- contracts/pair-mock/wasm/Cargo.toml | 6 + .../scenarios/stress_submit_test.scen.json | 100 +-- .../tests/price_aggregator_blackbox_test.rs | 128 ++-- .../tests/price_aggregator_stress_blackbox.rs | 37 +- .../tests/price_aggregator_whitebox_test.rs | 601 +++++++++--------- contracts/price-aggregator/wasm/Cargo.lock | 35 +- contracts/price-aggregator/wasm/Cargo.toml | 6 + contracts/price-aggregator/wasm/src/lib.rs | 4 +- .../tests/proxy_deployer_blackbox_test.rs | 10 +- contracts/proxy-deployer/wasm/Cargo.lock | 27 +- contracts/proxy-deployer/wasm/Cargo.toml | 6 + 17 files changed, 583 insertions(+), 483 deletions(-) diff --git a/contracts/order-book/factory/wasm/Cargo.lock b/contracts/order-book/factory/wasm/Cargo.lock index 6698fa55..b7fee70d 100644 --- a/contracts/order-book/factory/wasm/Cargo.lock +++ b/contracts/order-book/factory/wasm/Cargo.lock @@ -38,14 +38,25 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "multiversx-chain-core" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" +dependencies = [ + "bitflags", + "multiversx-sc-codec", +] + [[package]] name = "multiversx-sc" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -54,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -65,9 +76,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -77,9 +88,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -90,9 +101,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/order-book/factory/wasm/Cargo.toml b/contracts/order-book/factory/wasm/Cargo.toml index 7c183418..61c61d45 100644 --- a/contracts/order-book/factory/wasm/Cargo.toml +++ b/contracts/order-book/factory/wasm/Cargo.toml @@ -1,3 +1,9 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "order-book-factory-wasm" version = "0.0.0" diff --git a/contracts/order-book/pair/tests/pair_scenario_rs_test.rs b/contracts/order-book/pair/tests/pair_scenario_rs_test.rs index cc5df5d8..6ceb6b23 100644 --- a/contracts/order-book/pair/tests/pair_scenario_rs_test.rs +++ b/contracts/order-book/pair/tests/pair_scenario_rs_test.rs @@ -3,6 +3,7 @@ use multiversx_sc_scenario::*; fn world() -> ScenarioWorld { let mut blockchain = ScenarioWorld::new(); + blockchain.set_current_dir_from_workspace("contracts/order-book/pair"); blockchain.register_contract( "mxsc:output/order-book-pair.mxsc.json", order_book_pair::ContractBuilder, diff --git a/contracts/order-book/pair/wasm/Cargo.lock b/contracts/order-book/pair/wasm/Cargo.lock index e0c5bb2b..c448cc86 100644 --- a/contracts/order-book/pair/wasm/Cargo.lock +++ b/contracts/order-book/pair/wasm/Cargo.lock @@ -38,14 +38,25 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "multiversx-chain-core" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" +dependencies = [ + "bitflags", + "multiversx-sc-codec", +] + [[package]] name = "multiversx-sc" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -54,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -65,9 +76,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -77,9 +88,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -90,9 +101,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/order-book/pair/wasm/Cargo.toml b/contracts/order-book/pair/wasm/Cargo.toml index 9ed189be..38e5dda2 100644 --- a/contracts/order-book/pair/wasm/Cargo.toml +++ b/contracts/order-book/pair/wasm/Cargo.toml @@ -1,3 +1,9 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "order-book-pair-wasm" version = "0.0.0" diff --git a/contracts/pair-mock/wasm/Cargo.lock b/contracts/pair-mock/wasm/Cargo.lock index 424ade8c..6b7c093c 100644 --- a/contracts/pair-mock/wasm/Cargo.lock +++ b/contracts/pair-mock/wasm/Cargo.lock @@ -38,14 +38,25 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "multiversx-chain-core" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" +dependencies = [ + "bitflags", + "multiversx-sc-codec", +] + [[package]] name = "multiversx-sc" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -54,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -65,9 +76,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -77,9 +88,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -90,9 +101,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/pair-mock/wasm/Cargo.toml b/contracts/pair-mock/wasm/Cargo.toml index db19f59f..44e42b8e 100644 --- a/contracts/pair-mock/wasm/Cargo.toml +++ b/contracts/pair-mock/wasm/Cargo.toml @@ -1,3 +1,9 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "pair-mock-wasm" version = "0.0.0" diff --git a/contracts/price-aggregator/scenarios/stress_submit_test.scen.json b/contracts/price-aggregator/scenarios/stress_submit_test.scen.json index d1a4f775..7843f73b 100644 --- a/contracts/price-aggregator/scenarios/stress_submit_test.scen.json +++ b/contracts/price-aggregator/scenarios/stress_submit_test.scen.json @@ -1383,7 +1383,7 @@ "0x45474c44", "0x55534443", "0x5f", - "0xeb355ce76cc35c45", + "0x9524d52f5b28299f", "0x" ], "gasLimit": "7000000" @@ -1404,7 +1404,7 @@ "0x45474c44", "0x55534443", "0x64", - "0x26f18ae15401784f", + "0xb386adc5bdf4094c", "0x" ], "gasLimit": "7000000" @@ -1425,7 +1425,7 @@ "0x45474c44", "0x55534443", "0x64", - "0xa9f870444aee18a9", + "0xf5bb68727c74570f", "0x" ], "gasLimit": "7000000" @@ -1446,7 +1446,7 @@ "0x45474c44", "0x55534443", "0x64", - "0xef37d404c37065ea", + "0x9927b574c7573a71", "0x" ], "gasLimit": "7000000" @@ -1467,7 +1467,7 @@ "0x45474c44", "0x55534443", "0x64", - "0x3400039b45c451f5", + "0xf723cae821c105ba", "0x" ], "gasLimit": "7000000" @@ -1488,7 +1488,7 @@ "0x45474c44", "0x55534443", "0x64", - "0x93f3ce6896a2e9cc", + "0x8f33149064f2f1d2", "0x" ], "gasLimit": "7000000" @@ -1509,7 +1509,7 @@ "0x45474c44", "0x55534443", "0x64", - "0xca9ec7c020ccec1d", + "0xe3ec23f3c6ed195d", "0x" ], "gasLimit": "7000000" @@ -1530,7 +1530,7 @@ "0x45474c44", "0x55534443", "0x64", - "0x356b4c7c3127cfa5", + "0x1006131adfe2aa3f", "0x" ], "gasLimit": "7000000" @@ -1551,7 +1551,7 @@ "0x45474c44", "0x55534443", "0x64", - "0xc936fb760790fafd", + "0x1fb7dfec5d764e10", "0x" ], "gasLimit": "7000000" @@ -1572,7 +1572,7 @@ "0x45474c44", "0x55534443", "0x64", - "0x38511cc3782c8bf1", + "0x9a1e05efcd7aa3d4", "0x" ], "gasLimit": "7000000" @@ -1593,7 +1593,7 @@ "0x45474c44", "0x55534443", "0x64", - "0xb90f846af743abfa", + "0x717652d2bbec0eaa", "0x" ], "gasLimit": "7000000" @@ -1614,7 +1614,7 @@ "0x45474c44", "0x55534443", "0x64", - "0xbfbc0be78c9ee6af", + "0xc1c67798a15812ef", "0x" ], "gasLimit": "7000000" @@ -1635,7 +1635,7 @@ "0x45474c44", "0x55534443", "0x64", - "0xd492d9604ccb9928", + "0xd1236359a3f88a45", "0x" ], "gasLimit": "7000000" @@ -1656,7 +1656,7 @@ "0x45474c44", "0x55534443", "0x64", - "0x154061e0562cd99c", + "0x6dcef17b87566bae", "0x" ], "gasLimit": "7000000" @@ -1677,7 +1677,7 @@ "0x45474c44", "0x55534443", "0x64", - "0xcd9a3f710f2fd5e6", + "0xfbecbc53d0b08296", "0x" ], "gasLimit": "7000000" @@ -1698,7 +1698,7 @@ "0x45474c44", "0x55534443", "0x64", - "0x168ef6d2ec49a56c", + "0x5250ce0360f25fa3", "0x" ], "gasLimit": "7000000" @@ -1719,7 +1719,7 @@ "0x45474c44", "0x55534443", "0x64", - "0x294fe2057f303869", + "0xa16516dccd8be70d", "0x" ], "gasLimit": "7000000" @@ -1740,7 +1740,7 @@ "0x45474c44", "0x55534443", "0x64", - "0xcab0d5307dfb4ffa", + "0xb3ac971baafb44b1", "0x" ], "gasLimit": "7000000" @@ -1761,7 +1761,7 @@ "0x45474c44", "0x55534443", "0x64", - "0xdbecfadddc338ea1", + "0xfb2753a20318ac7f", "0x" ], "gasLimit": "7000000" @@ -1782,7 +1782,7 @@ "0x45474c44", "0x55534443", "0x64", - "0xcebee46aa2d23823", + "0x7203ef4c4f3798ef", "0x" ], "gasLimit": "7000000" @@ -1803,7 +1803,7 @@ "0x45474c44", "0x55534443", "0x64", - "0xea4018424b0a40f4", + "0x346c88220a0ed730", "0x" ], "gasLimit": "7000000" @@ -1824,7 +1824,7 @@ "0x45474c44", "0x55534443", "0x64", - "0x94e1c6bda78d51a6", + "0xf8428d79345c491e", "0x" ], "gasLimit": "7000000" @@ -1845,7 +1845,7 @@ "0x45474c44", "0x55534443", "0x64", - "0x646bccd8dd92ca47", + "0x5fb7bf2d9d156c2a", "0x" ], "gasLimit": "7000000" @@ -1866,7 +1866,7 @@ "0x45474c44", "0x55534443", "0x64", - "0x2e8ae293793788a2", + "0xc1fdcb0c0557fed1", "0x" ], "gasLimit": "7000000" @@ -1887,7 +1887,7 @@ "0x45474c44", "0x55534443", "0x64", - "0x0e101645789ca669", + "0x18d0517be2c4e22b", "0x" ], "gasLimit": "7000000" @@ -1908,7 +1908,7 @@ "0x45474c44", "0x55534443", "0x64", - "0xeaa29431e44cff52", + "0xf96f488642d50f0a", "0x" ], "gasLimit": "7000000" @@ -1929,7 +1929,7 @@ "0x45474c44", "0x55534443", "0x64", - "0x2cb93de20217087a", + "0xb028e9d3a6bf6799", "0x" ], "gasLimit": "7000000" @@ -1950,7 +1950,7 @@ "0x45474c44", "0x55534443", "0x64", - "0x5f44d4e412632190", + "0x7c5d07f3b2d167d5", "0x" ], "gasLimit": "7000000" @@ -1971,7 +1971,7 @@ "0x45474c44", "0x55534443", "0x64", - "0x4de2d24bba0256f4", + "0xc2732fd7b5b92e66", "0x" ], "gasLimit": "7000000" @@ -1992,7 +1992,7 @@ "0x45474c44", "0x55534443", "0x64", - "0xa196cf95c8f5c7c3", + "0xa82e5732ddb59f60", "0x" ], "gasLimit": "7000000" @@ -2013,7 +2013,7 @@ "0x45474c44", "0x55534443", "0x64", - "0xc1d285f3a6bc3402", + "0xa4833a6c1ff18770", "0x" ], "gasLimit": "7000000" @@ -2034,7 +2034,7 @@ "0x45474c44", "0x55534443", "0x64", - "0x469833d717d10294", + "0xb99b6df66506176e", "0x" ], "gasLimit": "7000000" @@ -2055,7 +2055,7 @@ "0x45474c44", "0x55534443", "0x64", - "0x6be779eae6aec51d", + "0xcf3e3253a17e1c3f", "0x" ], "gasLimit": "7000000" @@ -2076,7 +2076,7 @@ "0x45474c44", "0x55534443", "0x64", - "0x161326f649ebc862", + "0x0856cc19b5d854bb", "0x" ], "gasLimit": "7000000" @@ -2097,7 +2097,7 @@ "0x45474c44", "0x55534443", "0x64", - "0x8895e0b010dba3aa", + "0x5c6fc277cf4bfa8d", "0x" ], "gasLimit": "7000000" @@ -2118,7 +2118,7 @@ "0x45474c44", "0x55534443", "0x64", - "0x419f459f6058ff58", + "0xfd3574b9205f67d3", "0x" ], "gasLimit": "7000000" @@ -2139,7 +2139,7 @@ "0x45474c44", "0x55534443", "0x64", - "0xf81e8fce89681d3d", + "0x12cefe80de7f452d", "0x" ], "gasLimit": "7000000" @@ -2160,7 +2160,7 @@ "0x45474c44", "0x55534443", "0x64", - "0x401ea5c77ba58d4f", + "0x5ab0c3d4e23a54ac", "0x" ], "gasLimit": "7000000" @@ -2181,7 +2181,7 @@ "0x45474c44", "0x55534443", "0x64", - "0xb3e2c5888a5439f6", + "0x21a461a5c581696b", "0x" ], "gasLimit": "7000000" @@ -2202,7 +2202,7 @@ "0x45474c44", "0x55534443", "0x64", - "0xe2b9feeeeeb5c098", + "0x988a0c3bcdd9c65d", "0x" ], "gasLimit": "7000000" @@ -2223,7 +2223,7 @@ "0x45474c44", "0x55534443", "0x64", - "0x74361e9368db8d6e", + "0x7c0541f3b7e1b92b", "0x" ], "gasLimit": "7000000" @@ -2244,7 +2244,7 @@ "0x45474c44", "0x55534443", "0x64", - "0x3aa379980c3657bb", + "0xf4e2e1e4068592a6", "0x" ], "gasLimit": "7000000" @@ -2265,7 +2265,7 @@ "0x45474c44", "0x55534443", "0x64", - "0xe828141eb64f7e4c", + "0x0db07c8170a6ac3c", "0x" ], "gasLimit": "7000000" @@ -2286,7 +2286,7 @@ "0x45474c44", "0x55534443", "0x64", - "0xf2ada34c305639d0", + "0x52e3037f044dbe6b", "0x" ], "gasLimit": "7000000" @@ -2307,7 +2307,7 @@ "0x45474c44", "0x55534443", "0x64", - "0xd1d74d1aa2a36c0c", + "0xb452cc92e38df581", "0x" ], "gasLimit": "7000000" @@ -2328,7 +2328,7 @@ "0x45474c44", "0x55534443", "0x64", - "0x4459ee0424f994d2", + "0xb2d81def7abc8e79", "0x" ], "gasLimit": "7000000" @@ -2349,7 +2349,7 @@ "0x45474c44", "0x55534443", "0x64", - "0x5c6d66e39e80f4bb", + "0x9e2ce5b27fc9a1dc", "0x" ], "gasLimit": "7000000" @@ -2370,7 +2370,7 @@ "0x45474c44", "0x55534443", "0x64", - "0x149bdea8012a4a34", + "0x93611190d2e5e4c2", "0x" ], "gasLimit": "7000000" @@ -2391,7 +2391,7 @@ "0x45474c44", "0x55534443", "0x64", - "0xbc6cb60c9c227dab", + "0xc594937b149232a1", "0x" ], "gasLimit": "7000000" @@ -2412,7 +2412,7 @@ "0x45474c44", "0x55534443", "0x64", - "0xeca22096ae4bfcf1", + "0x6ca760f8499a3e44", "0x" ], "gasLimit": "7000000" diff --git a/contracts/price-aggregator/tests/price_aggregator_blackbox_test.rs b/contracts/price-aggregator/tests/price_aggregator_blackbox_test.rs index 5c3def0d..089b3498 100644 --- a/contracts/price-aggregator/tests/price_aggregator_blackbox_test.rs +++ b/contracts/price-aggregator/tests/price_aggregator_blackbox_test.rs @@ -1,6 +1,6 @@ use multiversx_price_aggregator_sc::{ price_aggregator_data::{OracleStatus, TimestampedPrice, TokenPair}, - ContractObj, PriceAggregator, MAX_ROUND_DURATION_SECONDS, + PriceAggregator, MAX_ROUND_DURATION_SECONDS, }; use multiversx_sc_scenario::imports::*; @@ -8,13 +8,13 @@ use multiversx_sc_scenario::imports::*; mod price_aggregator_proxy; const DECIMALS: u8 = 0; -const EGLD_TICKER: &[u8] = b"EGLD"; +const EGLD_TICKER: TestTokenIdentifier = TestTokenIdentifier::new("EGLD"); const NR_ORACLES: usize = 4; const SLASH_AMOUNT: u64 = 10; const SLASH_QUORUM: usize = 3; const STAKE_AMOUNT: u64 = 20; const SUBMISSION_COUNT: usize = 3; -const USD_TICKER: &[u8] = b"USDC"; +const USD_TICKER: TestTokenIdentifier = TestTokenIdentifier::new("USDC"); const PRICE_AGGREGATOR_ADDRESS: TestSCAddress = TestSCAddress::new("price-aggregator"); const OWNER_ADDRESS: TestAddress = TestAddress::new("owner"); @@ -24,6 +24,7 @@ const PRICE_AGGREGATOR_PATH: MxscPath = fn world() -> ScenarioWorld { let mut blockchain = ScenarioWorld::new(); + blockchain.set_current_dir_from_workspace("contracts/price-aggregator"); blockchain.register_contract( PRICE_AGGREGATOR_PATH, multiversx_price_aggregator_sc::ContractBuilder, @@ -35,7 +36,6 @@ fn world() -> ScenarioWorld { struct PriceAggregatorTestState { world: ScenarioWorld, oracles: Vec, - price_aggregator_whitebox: WhiteboxContract>, } impl PriceAggregatorTestState { @@ -57,16 +57,7 @@ impl PriceAggregatorTestState { oracles.push(address_value); } - let price_aggregator_whitebox = WhiteboxContract::new( - PRICE_AGGREGATOR_ADDRESS, - multiversx_price_aggregator_sc::contract_obj, - ); - - Self { - world, - oracles, - price_aggregator_whitebox, - } + Self { world, oracles } } fn deploy(&mut self) -> &mut Self { @@ -112,7 +103,7 @@ impl PriceAggregatorTestState { .from(OWNER_ADDRESS) .to(PRICE_AGGREGATOR_ADDRESS) .typed(price_aggregator_proxy::PriceAggregatorProxy) - .set_pair_decimals(EGLD_TICKER, USD_TICKER, DECIMALS) + .set_pair_decimals(EGLD_TICKER.as_bytes(), USD_TICKER.as_bytes(), DECIMALS) .run(); } @@ -143,8 +134,8 @@ impl PriceAggregatorTestState { .to(PRICE_AGGREGATOR_ADDRESS) .typed(price_aggregator_proxy::PriceAggregatorProxy) .submit( - EGLD_TICKER, - USD_TICKER, + EGLD_TICKER.as_str(), + USD_TICKER.as_str(), submission_timestamp, price, DECIMALS, @@ -165,8 +156,8 @@ impl PriceAggregatorTestState { .to(PRICE_AGGREGATOR_ADDRESS) .typed(price_aggregator_proxy::PriceAggregatorProxy) .submit( - EGLD_TICKER, - USD_TICKER, + EGLD_TICKER.as_str(), + USD_TICKER.as_str(), submission_timestamp, price, DECIMALS, @@ -213,12 +204,12 @@ fn test_price_aggregator_submit() { state.submit(&state.oracles[0].clone(), 95, 100); let current_timestamp = 100; - state - .world - .whitebox_query(&state.price_aggregator_whitebox, |sc| { + state.world.query().to(PRICE_AGGREGATOR_ADDRESS).whitebox( + multiversx_price_aggregator_sc::contract_obj, + |sc| { let token_pair = TokenPair { - from: managed_buffer!(EGLD_TICKER), - to: managed_buffer!(USD_TICKER), + from: ManagedBuffer::from(EGLD_TICKER.as_str()), + to: ManagedBuffer::from(USD_TICKER.as_str()), }; assert_eq!( sc.first_submission_timestamp(&token_pair).get(), @@ -233,38 +224,40 @@ fn test_price_aggregator_submit() { assert_eq!(submissions.len(), 1); assert_eq!( submissions - .get(&managed_address!(&state.oracles[0].to_address())) + .get(&ManagedAddress::from(&state.oracles[0].to_address())) .unwrap(), managed_biguint!(100) ); assert_eq!( sc.oracle_status() - .get(&managed_address!(&state.oracles[0].to_address())) + .get(&ManagedAddress::from(&state.oracles[0].to_address())) .unwrap(), OracleStatus { total_submissions: 1, accepted_submissions: 1 } ); - }); + }, + ); // first oracle submit again - submission not accepted state.submit(&state.oracles[0].clone(), 95, 100); - state - .world - .whitebox_query(&state.price_aggregator_whitebox, |sc| { + state.world.query().to(PRICE_AGGREGATOR_ADDRESS).whitebox( + multiversx_price_aggregator_sc::contract_obj, + |sc| { assert_eq!( sc.oracle_status() - .get(&managed_address!(&state.oracles[0].to_address())) + .get(&ManagedAddress::from(&state.oracles[0].to_address())) .unwrap(), OracleStatus { total_submissions: 2, accepted_submissions: 1 } - ); - }); + ) + }, + ); } #[test] @@ -293,16 +286,51 @@ fn test_price_aggregator_submit_round_ok() { // submit third state.submit(&state.oracles[2].clone(), 105, 12_000); - state - .world - .whitebox_query(&state.price_aggregator_whitebox, |sc| { - let result = - sc.latest_price_feed(managed_buffer!(EGLD_TICKER), managed_buffer!(USD_TICKER)); + state.world.query().to(PRICE_AGGREGATOR_ADDRESS).whitebox( + multiversx_price_aggregator_sc::contract_obj, + |sc| { + let result = sc.latest_price_feed( + ManagedBuffer::from(EGLD_TICKER.as_str()), + ManagedBuffer::from(USD_TICKER.as_str()), + ); + + let (round_id, from, to, timestamp, price, decimals) = result.into_tuple(); + assert_eq!(round_id, 1); + assert_eq!(from, ManagedBuffer::from(EGLD_TICKER.as_str())); + assert_eq!(to, ManagedBuffer::from(USD_TICKER.as_str())); + assert_eq!(timestamp, current_timestamp); + assert_eq!(price, managed_biguint!(11_000)); + assert_eq!(decimals, DECIMALS); + + // submissions are deleted after round is created + let token_pair = TokenPair { from, to }; + let submissions = sc.submissions().get(&token_pair).unwrap(); + assert_eq!(submissions.len(), 0); + + let rounds = sc.rounds().get(&token_pair).unwrap(); + assert_eq!(rounds.len(), 1); + assert_eq!( + rounds.get(1), + TimestampedPrice { + timestamp, + price, + decimals + } + ); + }, + ); + state.world.query().to(PRICE_AGGREGATOR_ADDRESS).whitebox( + multiversx_price_aggregator_sc::contract_obj, + |sc| { + let result = sc.latest_price_feed( + ManagedBuffer::from(EGLD_TICKER.as_str()), + ManagedBuffer::from(USD_TICKER.as_str()), + ); let (round_id, from, to, timestamp, price, decimals) = result.into_tuple(); assert_eq!(round_id, 1); - assert_eq!(from, managed_buffer!(EGLD_TICKER)); - assert_eq!(to, managed_buffer!(USD_TICKER)); + assert_eq!(from, ManagedBuffer::from(EGLD_TICKER.as_str())); + assert_eq!(to, ManagedBuffer::from(USD_TICKER.as_str())); assert_eq!(timestamp, current_timestamp); assert_eq!(price, managed_biguint!(11_000)); assert_eq!(decimals, DECIMALS); @@ -322,7 +350,8 @@ fn test_price_aggregator_submit_round_ok() { decimals } ); - }); + }, + ); } #[test] @@ -348,22 +377,23 @@ fn test_price_aggregator_discarded_round() { // submit second - this will discard the previous submission state.submit(&state.oracles[1].clone(), current_timestamp - 1, 11_000); - state - .world - .whitebox_query(&state.price_aggregator_whitebox, |sc| { + state.world.query().to(PRICE_AGGREGATOR_ADDRESS).whitebox( + multiversx_price_aggregator_sc::contract_obj, + |sc| { let token_pair = TokenPair { - from: managed_buffer!(EGLD_TICKER), - to: managed_buffer!(USD_TICKER), + from: ManagedBuffer::from(EGLD_TICKER.as_str()), + to: ManagedBuffer::from(USD_TICKER.as_str()), }; let submissions = sc.submissions().get(&token_pair).unwrap(); assert_eq!(submissions.len(), 1); assert_eq!( submissions - .get(&managed_address!(&state.oracles[1].to_address())) + .get(&ManagedAddress::from(&state.oracles[1].to_address())) .unwrap(), managed_biguint!(11_000) ); - }); + }, + ); } #[test] @@ -413,7 +443,7 @@ fn test_set_decimals_pause() { .from(OWNER_ADDRESS) .to(PRICE_AGGREGATOR_ADDRESS) .typed(price_aggregator_proxy::PriceAggregatorProxy) - .set_pair_decimals(EGLD_TICKER, USD_TICKER, DECIMALS) + .set_pair_decimals(EGLD_TICKER.as_str(), USD_TICKER.as_str(), DECIMALS) .returns(ExpectError(4, "Contract is not paused")) .run(); diff --git a/contracts/price-aggregator/tests/price_aggregator_stress_blackbox.rs b/contracts/price-aggregator/tests/price_aggregator_stress_blackbox.rs index 660bbf1d..cde4b09c 100644 --- a/contracts/price-aggregator/tests/price_aggregator_stress_blackbox.rs +++ b/contracts/price-aggregator/tests/price_aggregator_stress_blackbox.rs @@ -1,12 +1,12 @@ use multiversx_price_aggregator_sc::{ price_aggregator_data::{OracleStatus, TokenPair}, - ContractObj, PriceAggregator, + PriceAggregator, }; use multiversx_sc_scenario::imports::*; const DECIMALS: u8 = 0; -const EGLD_TICKER: &[u8] = b"EGLD"; +const EGLD_TICKER: TestTokenIdentifier = TestTokenIdentifier::new("EGLD"); const NR_ORACLES: usize = 50; const OWNER: TestAddress = TestAddress::new("owner"); const PRICE_AGGREGATOR_ADDRESS: TestSCAddress = TestSCAddress::new("price-aggregator"); @@ -16,7 +16,7 @@ const SLASH_AMOUNT: u64 = 10; const SLASH_QUORUM: usize = 3; const STAKE_AMOUNT: u64 = 20; const SUBMISSION_COUNT: usize = 50; -const USD_TICKER: &[u8] = b"USDC"; +const USD_TICKER: TestTokenIdentifier = TestTokenIdentifier::new("USDC"); mod price_aggregator_proxy; @@ -34,7 +34,6 @@ fn world() -> ScenarioWorld { struct PriceAggregatorTestState { world: ScenarioWorld, oracles: Vec, - price_aggregator_whitebox: WhiteboxContract>, } impl PriceAggregatorTestState { @@ -60,16 +59,7 @@ impl PriceAggregatorTestState { oracles.push(address_value); } - let price_aggregator_whitebox = WhiteboxContract::new( - PRICE_AGGREGATOR_ADDRESS, - multiversx_price_aggregator_sc::contract_obj, - ); - - Self { - world, - oracles, - price_aggregator_whitebox, - } + Self { world, oracles } } fn deploy(&mut self) -> &mut Self { @@ -117,7 +107,7 @@ impl PriceAggregatorTestState { .from(OWNER) .to(PRICE_AGGREGATOR_ADDRESS) .typed(price_aggregator_proxy::PriceAggregatorProxy) - .set_pair_decimals(EGLD_TICKER, USD_TICKER, DECIMALS) + .set_pair_decimals(EGLD_TICKER.as_str(), USD_TICKER.as_str(), DECIMALS) .run(); } @@ -140,8 +130,8 @@ impl PriceAggregatorTestState { .gas(7_000_000u64) .typed(price_aggregator_proxy::PriceAggregatorProxy) .submit( - EGLD_TICKER, - USD_TICKER, + EGLD_TICKER.as_str(), + USD_TICKER.as_str(), submission_timestamp, price, DECIMALS, @@ -170,14 +160,14 @@ fn test_price_aggregator_submit() { } let current_timestamp = 100; - state - .world - .whitebox_query(&state.price_aggregator_whitebox, |sc| { + state.world.query().to(PRICE_AGGREGATOR_ADDRESS).whitebox( + multiversx_price_aggregator_sc::contract_obj, + |sc| { let blockchain_timestamp = sc.blockchain().get_block_timestamp(); let token_pair = TokenPair { - from: managed_buffer!(EGLD_TICKER), - to: managed_buffer!(USD_TICKER), + from: ManagedBuffer::from(EGLD_TICKER.as_str()), + to: ManagedBuffer::from(USD_TICKER.as_str()), }; assert_eq!(blockchain_timestamp, current_timestamp); @@ -207,7 +197,8 @@ fn test_price_aggregator_submit() { } ); } - }); + }, + ); // submit last that resets the round state.submit( diff --git a/contracts/price-aggregator/tests/price_aggregator_whitebox_test.rs b/contracts/price-aggregator/tests/price_aggregator_whitebox_test.rs index 180301b6..05f9b4bd 100644 --- a/contracts/price-aggregator/tests/price_aggregator_whitebox_test.rs +++ b/contracts/price-aggregator/tests/price_aggregator_whitebox_test.rs @@ -4,26 +4,28 @@ use multiversx_price_aggregator_sc::{ }; use multiversx_sc_modules::{ pause::EndpointWrappers as PauseEndpointWrappers, - staking::EndpointWrappers as StakingEndpointWrappers, + staking::{EndpointWrappers as StakingEndpointWrappers, StakingModule}, }; use multiversx_sc_scenario::imports::*; pub const DECIMALS: u8 = 0; -pub const EGLD_TICKER: &[u8] = b"EGLD"; +pub const EGLD_TICKER: TestTokenIdentifier = TestTokenIdentifier::new("EGLD"); pub const NR_ORACLES: usize = 4; pub const SLASH_AMOUNT: u64 = 10; pub const SLASH_QUORUM: usize = 3; pub const STAKE_AMOUNT: u64 = 20; pub const SUBMISSION_COUNT: usize = 3; -pub const USD_TICKER: &[u8] = b"USDC"; +pub const USD_TICKER: TestTokenIdentifier = TestTokenIdentifier::new("USDC"); -const OWNER_ADDRESS_EXPR: &str = "address:owner"; -const PRICE_AGGREGATOR_ADDRESS_EXPR: &str = "sc:price-aggregator"; -const PRICE_AGGREGATOR_PATH_EXPR: &str = "mxsc:output/multiversx-price-aggregator-sc.mxsc.json"; +const OWNER_ADDRESS: TestAddress = TestAddress::new("owner"); +const PRICE_AGGREGATOR_ADDRESS: TestSCAddress = TestSCAddress::new("price-aggregator"); +const PRICE_AGGREGATOR_PATH_EXPR: MxscPath = + MxscPath::new("output/multiversx-price-aggregator-sc.mxsc.json"); fn world() -> ScenarioWorld { let mut blockchain = ScenarioWorld::new(); + blockchain.set_current_dir_from_workspace("contracts/price-aggregator"); blockchain.register_contract( PRICE_AGGREGATOR_PATH_EXPR, multiversx_price_aggregator_sc::ContractBuilder, @@ -35,430 +37,419 @@ fn world() -> ScenarioWorld { #[test] fn test_price_aggregator_submit() { let (mut world, oracles) = setup(); - let price_aggregator_whitebox = WhiteboxContract::new( - PRICE_AGGREGATOR_ADDRESS_EXPR, - multiversx_price_aggregator_sc::contract_obj, - ); // configure the number of decimals - world.whitebox_call( - &price_aggregator_whitebox, - ScCallStep::new().from(OWNER_ADDRESS_EXPR), - |sc| { + world + .tx() + .from(OWNER_ADDRESS) + .to(PRICE_AGGREGATOR_ADDRESS) + .whitebox(multiversx_price_aggregator_sc::contract_obj, |sc| { sc.set_pair_decimals( - managed_buffer!(EGLD_TICKER), - managed_buffer!(USD_TICKER), + ManagedBuffer::from(EGLD_TICKER.as_str()), + ManagedBuffer::from(USD_TICKER.as_str()), DECIMALS, ) - }, - ); + }); // try submit while paused - world.whitebox_call_check( - &price_aggregator_whitebox, - ScCallStep::new() - .from(&oracles[0]) - .expect(TxExpect::user_error("str:Contract is paused")), - |sc| { + world + .tx() + .from(&oracles[0]) + .to(PRICE_AGGREGATOR_ADDRESS) + .returns(ExpectError(4u64, "Contract is paused")) + .whitebox(multiversx_price_aggregator_sc::contract_obj, |sc| { sc.submit( - managed_buffer!(EGLD_TICKER), - managed_buffer!(USD_TICKER), + ManagedBuffer::from(EGLD_TICKER.as_str()), + ManagedBuffer::from(USD_TICKER.as_str()), 99, managed_biguint!(100), DECIMALS, ) - }, - |r| r.assert_user_error("Contract is paused"), - ); + }); // unpause - world.whitebox_call( - &price_aggregator_whitebox, - ScCallStep::new().from(OWNER_ADDRESS_EXPR), - |sc| sc.call_unpause_endpoint(), - ); + world + .tx() + .from(OWNER_ADDRESS) + .to(PRICE_AGGREGATOR_ADDRESS) + .whitebox(multiversx_price_aggregator_sc::contract_obj, |sc| { + sc.call_unpause_endpoint(); + }); // submit first timestamp too old - world.whitebox_call_check( - &price_aggregator_whitebox, - ScCallStep::new().from(&oracles[0]).no_expect(), - |sc| { + world + .tx() + .from(&oracles[0]) + .to(PRICE_AGGREGATOR_ADDRESS) + .returns(ExpectError(4u64, "First submission too old")) + .whitebox(multiversx_price_aggregator_sc::contract_obj, |sc| { sc.submit( - managed_buffer!(EGLD_TICKER), - managed_buffer!(USD_TICKER), + ManagedBuffer::from(EGLD_TICKER.as_str()), + ManagedBuffer::from(USD_TICKER.as_str()), 10, managed_biguint!(100), DECIMALS, ) - }, - |r| { - r.assert_user_error("First submission too old"); - }, - ); + }); // submit ok - world.whitebox_call( - &price_aggregator_whitebox, - ScCallStep::new().from(&oracles[0]), - |sc| { + world + .tx() + .from(&oracles[0]) + .to(PRICE_AGGREGATOR_ADDRESS) + .whitebox(multiversx_price_aggregator_sc::contract_obj, |sc| { sc.submit( - managed_buffer!(EGLD_TICKER), - managed_buffer!(USD_TICKER), + ManagedBuffer::from(EGLD_TICKER.as_str()), + ManagedBuffer::from(USD_TICKER.as_str()), 95, managed_biguint!(100), DECIMALS, ) - }, - ); + }); let current_timestamp = 100; - world.whitebox_query(&price_aggregator_whitebox, |sc| { - let token_pair = TokenPair { - from: managed_buffer!(EGLD_TICKER), - to: managed_buffer!(USD_TICKER), - }; - assert_eq!( - sc.first_submission_timestamp(&token_pair).get(), - current_timestamp - ); - assert_eq!( - sc.last_submission_timestamp(&token_pair).get(), - current_timestamp - ); - - let submissions = sc.submissions().get(&token_pair).unwrap(); - assert_eq!(submissions.len(), 1); - assert_eq!( - submissions - .get(&managed_address!(&oracles[0].to_address())) - .unwrap(), - managed_biguint!(100) - ); - - assert_eq!( - sc.oracle_status() - .get(&managed_address!(&oracles[0].to_address())) - .unwrap(), - OracleStatus { - total_submissions: 1, - accepted_submissions: 1 - } - ); - }); + world.query().to(PRICE_AGGREGATOR_ADDRESS).whitebox( + multiversx_price_aggregator_sc::contract_obj, + |sc| { + let token_pair = TokenPair { + from: ManagedBuffer::from(EGLD_TICKER.as_str()), + to: ManagedBuffer::from(USD_TICKER.as_str()), + }; + assert_eq!( + sc.first_submission_timestamp(&token_pair).get(), + current_timestamp + ); + assert_eq!( + sc.last_submission_timestamp(&token_pair).get(), + current_timestamp + ); + + let submissions = sc.submissions().get(&token_pair).unwrap(); + assert_eq!(submissions.len(), 1); + assert_eq!( + submissions.get(&ManagedAddress::from(&oracles[0])).unwrap(), + managed_biguint!(100) + ); + + assert_eq!( + sc.oracle_status() + .get(&ManagedAddress::from(&oracles[0])) + .unwrap(), + OracleStatus { + total_submissions: 1, + accepted_submissions: 1 + } + ); + }, + ); // first oracle submit again - submission not accepted - world.whitebox_call( - &price_aggregator_whitebox, - ScCallStep::new().from(&oracles[0]), - |sc| { + world + .tx() + .from(&oracles[0]) + .to(PRICE_AGGREGATOR_ADDRESS) + .whitebox(multiversx_price_aggregator_sc::contract_obj, |sc| { sc.submit( - managed_buffer!(EGLD_TICKER), - managed_buffer!(USD_TICKER), + ManagedBuffer::from(EGLD_TICKER.as_str()), + ManagedBuffer::from(USD_TICKER.as_str()), 95, managed_biguint!(100), DECIMALS, ) + }); + + world.query().to(PRICE_AGGREGATOR_ADDRESS).whitebox( + multiversx_price_aggregator_sc::contract_obj, + |sc| { + assert_eq!( + sc.oracle_status() + .get(&ManagedAddress::from(&oracles[0])) + .unwrap(), + OracleStatus { + total_submissions: 2, + accepted_submissions: 1 + } + ); }, ); - - world.whitebox_query(&price_aggregator_whitebox, |sc| { - assert_eq!( - sc.oracle_status() - .get(&managed_address!(&oracles[0].to_address())) - .unwrap(), - OracleStatus { - total_submissions: 2, - accepted_submissions: 1 - } - ); - }); } #[test] fn test_price_aggregator_submit_round_ok() { let (mut world, oracles) = setup(); - let price_aggregator_whitebox = WhiteboxContract::new( - PRICE_AGGREGATOR_ADDRESS_EXPR, - multiversx_price_aggregator_sc::contract_obj, - ); // configure the number of decimals - world.whitebox_call( - &price_aggregator_whitebox, - ScCallStep::new().from(OWNER_ADDRESS_EXPR), - |sc| { + world + .tx() + .from(OWNER_ADDRESS) + .to(PRICE_AGGREGATOR_ADDRESS) + .whitebox(multiversx_price_aggregator_sc::contract_obj, |sc| { sc.set_pair_decimals( - managed_buffer!(EGLD_TICKER), - managed_buffer!(USD_TICKER), + ManagedBuffer::from(EGLD_TICKER.as_str()), + ManagedBuffer::from(USD_TICKER.as_str()), DECIMALS, ) - }, - ); + }); // unpause - world.whitebox_call( - &price_aggregator_whitebox, - ScCallStep::new().from(OWNER_ADDRESS_EXPR), - |sc| sc.call_unpause_endpoint(), - ); + world + .tx() + .from(OWNER_ADDRESS) + .to(PRICE_AGGREGATOR_ADDRESS) + .whitebox(multiversx_price_aggregator_sc::contract_obj, |sc| { + sc.call_unpause_endpoint(); + }); // submit first - world.whitebox_call( - &price_aggregator_whitebox, - ScCallStep::new().from(&oracles[0]), - |sc| { + world + .tx() + .from(&oracles[0]) + .to(PRICE_AGGREGATOR_ADDRESS) + .whitebox(multiversx_price_aggregator_sc::contract_obj, |sc| { sc.submit( - managed_buffer!(EGLD_TICKER), - managed_buffer!(USD_TICKER), + ManagedBuffer::from(EGLD_TICKER.as_str()), + ManagedBuffer::from(USD_TICKER.as_str()), 95, managed_biguint!(10_000), DECIMALS, ) - }, - ); + }); let current_timestamp = 110; - world.set_state_step(SetStateStep::new().block_timestamp(current_timestamp)); + world.current_block().block_timestamp(current_timestamp); // submit second - world.whitebox_call( - &price_aggregator_whitebox, - ScCallStep::new().from(&oracles[1]), - |sc| { + world + .tx() + .from(&oracles[1]) + .to(PRICE_AGGREGATOR_ADDRESS) + .whitebox(multiversx_price_aggregator_sc::contract_obj, |sc| { sc.submit( - managed_buffer!(EGLD_TICKER), - managed_buffer!(USD_TICKER), + ManagedBuffer::from(EGLD_TICKER.as_str()), + ManagedBuffer::from(USD_TICKER.as_str()), 101, managed_biguint!(11_000), DECIMALS, ) - }, - ); + }); // submit third - world.whitebox_call( - &price_aggregator_whitebox, - ScCallStep::new().from(&oracles[2]), - |sc| { + world + .tx() + .from(&oracles[2]) + .to(PRICE_AGGREGATOR_ADDRESS) + .whitebox(multiversx_price_aggregator_sc::contract_obj, |sc| { sc.submit( - managed_buffer!(EGLD_TICKER), - managed_buffer!(USD_TICKER), + ManagedBuffer::from(EGLD_TICKER.as_str()), + ManagedBuffer::from(USD_TICKER.as_str()), 105, managed_biguint!(12_000), DECIMALS, ) + }); + + world.query().to(PRICE_AGGREGATOR_ADDRESS).whitebox( + multiversx_price_aggregator_sc::contract_obj, + |sc| { + let result = sc.latest_price_feed( + ManagedBuffer::from(EGLD_TICKER.as_str()), + ManagedBuffer::from(USD_TICKER.as_str()), + ); + + let (round_id, from, to, timestamp, price, decimals) = result.into_tuple(); + assert_eq!(round_id, 1); + assert_eq!(from, ManagedBuffer::from(EGLD_TICKER.as_str())); + assert_eq!(to, ManagedBuffer::from(USD_TICKER.as_str())); + assert_eq!(timestamp, current_timestamp); + assert_eq!(price, managed_biguint!(11_000)); + assert_eq!(decimals, DECIMALS); + + // submissions are deleted after round is created + let token_pair = TokenPair { from, to }; + let submissions = sc.submissions().get(&token_pair).unwrap(); + assert_eq!(submissions.len(), 0); + + let rounds = sc.rounds().get(&token_pair).unwrap(); + assert_eq!(rounds.len(), 1); + assert_eq!( + rounds.get(1), + TimestampedPrice { + timestamp, + price, + decimals + } + ); }, ); - - world.whitebox_query(&price_aggregator_whitebox, |sc| { - let result = - sc.latest_price_feed(managed_buffer!(EGLD_TICKER), managed_buffer!(USD_TICKER)); - - let (round_id, from, to, timestamp, price, decimals) = result.into_tuple(); - assert_eq!(round_id, 1); - assert_eq!(from, managed_buffer!(EGLD_TICKER)); - assert_eq!(to, managed_buffer!(USD_TICKER)); - assert_eq!(timestamp, current_timestamp); - assert_eq!(price, managed_biguint!(11_000)); - assert_eq!(decimals, DECIMALS); - - // submissions are deleted after round is created - let token_pair = TokenPair { from, to }; - let submissions = sc.submissions().get(&token_pair).unwrap(); - assert_eq!(submissions.len(), 0); - - let rounds = sc.rounds().get(&token_pair).unwrap(); - assert_eq!(rounds.len(), 1); - assert_eq!( - rounds.get(1), - TimestampedPrice { - timestamp, - price, - decimals - } - ); - }); } #[test] fn test_price_aggregator_discarded_round() { let (mut world, oracles) = setup(); - let price_aggregator_whitebox = WhiteboxContract::new( - PRICE_AGGREGATOR_ADDRESS_EXPR, - multiversx_price_aggregator_sc::contract_obj, - ); // configure the number of decimals - world.whitebox_call( - &price_aggregator_whitebox, - ScCallStep::new().from(OWNER_ADDRESS_EXPR), - |sc| { + world + .tx() + .from(OWNER_ADDRESS) + .to(PRICE_AGGREGATOR_ADDRESS) + .whitebox(multiversx_price_aggregator_sc::contract_obj, |sc| { sc.set_pair_decimals( - managed_buffer!(EGLD_TICKER), - managed_buffer!(USD_TICKER), + ManagedBuffer::from(EGLD_TICKER.as_str()), + ManagedBuffer::from(USD_TICKER.as_str()), DECIMALS, ) - }, - ); + }); // unpause - world.whitebox_call( - &price_aggregator_whitebox, - ScCallStep::new().from(OWNER_ADDRESS_EXPR), - |sc| sc.call_unpause_endpoint(), - ); + world + .tx() + .from(OWNER_ADDRESS) + .to(PRICE_AGGREGATOR_ADDRESS) + .whitebox(multiversx_price_aggregator_sc::contract_obj, |sc| { + sc.call_unpause_endpoint(); + }); // submit first - world.whitebox_call( - &price_aggregator_whitebox, - ScCallStep::new().from(&oracles[0]), - |sc| { + world + .tx() + .from(&oracles[0]) + .to(PRICE_AGGREGATOR_ADDRESS) + .whitebox(multiversx_price_aggregator_sc::contract_obj, |sc| { sc.submit( - managed_buffer!(EGLD_TICKER), - managed_buffer!(USD_TICKER), + ManagedBuffer::from(EGLD_TICKER.as_str()), + ManagedBuffer::from(USD_TICKER.as_str()), 95, managed_biguint!(10_000), DECIMALS, ) - }, - ); + }); let current_timestamp = 100 + MAX_ROUND_DURATION_SECONDS + 1; - world.set_state_step(SetStateStep::new().block_timestamp(current_timestamp)); + world.current_block().block_timestamp(current_timestamp); // submit second - this will discard the previous submission - world.whitebox_call( - &price_aggregator_whitebox, - ScCallStep::new().from(&oracles[1]), - |sc| { + world + .tx() + .from(&oracles[1]) + .to(PRICE_AGGREGATOR_ADDRESS) + .whitebox(multiversx_price_aggregator_sc::contract_obj, |sc| { sc.submit( - managed_buffer!(EGLD_TICKER), - managed_buffer!(USD_TICKER), + ManagedBuffer::from(EGLD_TICKER.as_str()), + ManagedBuffer::from(USD_TICKER.as_str()), current_timestamp - 1, managed_biguint!(11_000), DECIMALS, ) + }); + + world.query().to(PRICE_AGGREGATOR_ADDRESS).whitebox( + multiversx_price_aggregator_sc::contract_obj, + |sc| { + let token_pair = TokenPair { + from: ManagedBuffer::from(EGLD_TICKER.as_str()), + to: ManagedBuffer::from(USD_TICKER.as_str()), + }; + let submissions = sc.submissions().get(&token_pair).unwrap(); + assert_eq!(submissions.len(), 1); + assert_eq!( + submissions.get(&managed_address!(&oracles[1])).unwrap(), + managed_biguint!(11_000) + ); }, ); - - world.whitebox_query(&price_aggregator_whitebox, |sc| { - let token_pair = TokenPair { - from: managed_buffer!(EGLD_TICKER), - to: managed_buffer!(USD_TICKER), - }; - let submissions = sc.submissions().get(&token_pair).unwrap(); - assert_eq!(submissions.len(), 1); - assert_eq!( - submissions - .get(&managed_address!(&oracles[1].to_address())) - .unwrap(), - managed_biguint!(11_000) - ); - }); } #[test] fn test_price_aggregator_slashing() { let (mut world, oracles) = setup(); - let price_aggregator_whitebox = WhiteboxContract::new( - PRICE_AGGREGATOR_ADDRESS_EXPR, - multiversx_price_aggregator_sc::contract_obj, - ); // unpause - world.whitebox_call( - &price_aggregator_whitebox, - ScCallStep::new().from(OWNER_ADDRESS_EXPR), - |sc| sc.call_unpause_endpoint(), - ); - - world.whitebox_call( - &price_aggregator_whitebox, - ScCallStep::new() - .from(&oracles[0]) - .argument(BytesValue::from(oracles[1].to_address().as_bytes())), - |sc| sc.call_vote_slash_member(), - ); - - world.whitebox_call( - &price_aggregator_whitebox, - ScCallStep::new() - .from(&oracles[2]) - .argument(BytesValue::from(oracles[1].to_address().as_bytes())), - |sc| sc.call_vote_slash_member(), - ); - - world.whitebox_call( - &price_aggregator_whitebox, - ScCallStep::new() - .from(&oracles[3]) - .argument(BytesValue::from(oracles[1].to_address().as_bytes())), - |sc| sc.call_vote_slash_member(), - ); - - world.whitebox_call( - &price_aggregator_whitebox, - ScCallStep::new() - .from(&oracles[0]) - .argument(BytesValue::from(oracles[1].to_address().as_bytes())), - |sc| sc.call_slash_member(), - ); + world + .tx() + .from(OWNER_ADDRESS) + .to(PRICE_AGGREGATOR_ADDRESS) + .whitebox(multiversx_price_aggregator_sc::contract_obj, |sc| { + sc.call_unpause_endpoint() + }); + + world + .tx() + .from(&oracles[0]) + .to(PRICE_AGGREGATOR_ADDRESS) + .whitebox(multiversx_price_aggregator_sc::contract_obj, |sc| { + sc.vote_slash_member(ManagedAddress::from(oracles[1].clone())) + }); + + world + .tx() + .from(&oracles[2]) + .to(PRICE_AGGREGATOR_ADDRESS) + .whitebox(multiversx_price_aggregator_sc::contract_obj, |sc| { + sc.vote_slash_member(ManagedAddress::from(oracles[1].clone())) + }); + + world + .tx() + .from(&oracles[3]) + .to(PRICE_AGGREGATOR_ADDRESS) + .whitebox(multiversx_price_aggregator_sc::contract_obj, |sc| { + sc.vote_slash_member(ManagedAddress::from(oracles[1].clone())) + }); + + world + .tx() + .from(&oracles[0]) + .to(PRICE_AGGREGATOR_ADDRESS) + .whitebox(multiversx_price_aggregator_sc::contract_obj, |sc| { + sc.slash_member(ManagedAddress::from(oracles[1].clone())) + }); // oracle 1 try submit after slashing - world.whitebox_call_check( - &price_aggregator_whitebox, - ScCallStep::new().from(&oracles[1]).no_expect(), - |sc| { + world + .tx() + .from(&oracles[1]) + .to(PRICE_AGGREGATOR_ADDRESS) + .with_result(ExpectMessage("only oracles allowed")) + .whitebox(multiversx_price_aggregator_sc::contract_obj, |sc| { sc.submit( - managed_buffer!(EGLD_TICKER), - managed_buffer!(USD_TICKER), + ManagedBuffer::from(EGLD_TICKER.as_str()), + ManagedBuffer::from(USD_TICKER.as_str()), 95, managed_biguint!(10_000), DECIMALS, - ) - }, - |r| { - r.assert_user_error("only oracles allowed"); - }, - ); + ); + }); } -fn setup() -> (ScenarioWorld, Vec) { +fn setup() -> (ScenarioWorld, Vec
) { // setup let mut world = world(); - let price_aggregator_whitebox = WhiteboxContract::new( - PRICE_AGGREGATOR_ADDRESS_EXPR, - multiversx_price_aggregator_sc::contract_obj, - ); - let price_aggregator_code = world.code_expression(PRICE_AGGREGATOR_PATH_EXPR); - let mut set_state_step = SetStateStep::new() - .put_account(OWNER_ADDRESS_EXPR, Account::new().nonce(1)) - .new_address(OWNER_ADDRESS_EXPR, 1, PRICE_AGGREGATOR_ADDRESS_EXPR) - .block_timestamp(100); + world.account(OWNER_ADDRESS).nonce(1); + world.new_address(OWNER_ADDRESS, 1, PRICE_AGGREGATOR_ADDRESS); + world.current_block().block_timestamp(100); let mut oracles = Vec::new(); for i in 1..=NR_ORACLES { let oracle_address_expr = format!("address:oracle{i}"); - let oracle_address = AddressValue::from(oracle_address_expr.as_str()); + let oracle_address = TestAddress::new(&oracle_address_expr); + + world.account(oracle_address).nonce(1).balance(STAKE_AMOUNT); - set_state_step = set_state_step.put_account( - oracle_address_expr.as_str(), - Account::new().nonce(1).balance(STAKE_AMOUNT), - ); - oracles.push(oracle_address); + oracles.push(oracle_address.to_address()); } // init price aggregator - world.set_state_step(set_state_step).whitebox_deploy( - &price_aggregator_whitebox, - ScDeployStep::new() - .from(OWNER_ADDRESS_EXPR) - .code(price_aggregator_code), - |sc| { + world + .tx() + .from(OWNER_ADDRESS) + .raw_deploy() + .code(PRICE_AGGREGATOR_PATH_EXPR) + .new_address(PRICE_AGGREGATOR_ADDRESS) + .whitebox(multiversx_price_aggregator_sc::contract_obj, |sc| { let mut oracle_args = MultiValueEncoded::new(); for oracle_address in &oracles { - oracle_args.push(managed_address!(&oracle_address.to_address())); + oracle_args.push(ManagedAddress::from(oracle_address)); } sc.init( @@ -469,17 +460,17 @@ fn setup() -> (ScenarioWorld, Vec) { SUBMISSION_COUNT, oracle_args, ) - }, - ); + }); for oracle_address in &oracles { - world.whitebox_call( - &price_aggregator_whitebox, - ScCallStep::new() - .from(oracle_address) - .egld_value(STAKE_AMOUNT), - |sc| sc.call_stake(), - ); + world + .tx() + .from(oracle_address) + .to(PRICE_AGGREGATOR_ADDRESS) + .egld(STAKE_AMOUNT) + .whitebox(multiversx_price_aggregator_sc::contract_obj, |sc| { + sc.call_stake(); + }); } (world, oracles) diff --git a/contracts/price-aggregator/wasm/Cargo.lock b/contracts/price-aggregator/wasm/Cargo.lock index 563ca3be..858be925 100644 --- a/contracts/price-aggregator/wasm/Cargo.lock +++ b/contracts/price-aggregator/wasm/Cargo.lock @@ -90,6 +90,16 @@ version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +[[package]] +name = "multiversx-chain-core" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" +dependencies = [ + "bitflags", + "multiversx-sc-codec", +] + [[package]] name = "multiversx-price-aggregator-sc" version = "0.47.1" @@ -111,12 +121,13 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -125,9 +136,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -136,9 +147,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -148,9 +159,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -161,18 +172,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daeb48acbd39255868a3241798df2f85050f0ae8d82d6417bd2cd0e30a241855" +checksum = "74b31cfc990a3052a0e014f749104752a0208f3d11d4dee3c0dd6e6d4ce1908c" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/price-aggregator/wasm/Cargo.toml b/contracts/price-aggregator/wasm/Cargo.toml index 3a0d34e2..f9631dcd 100644 --- a/contracts/price-aggregator/wasm/Cargo.toml +++ b/contracts/price-aggregator/wasm/Cargo.toml @@ -1,3 +1,9 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "multiversx-price-aggregator-sc-wasm" version = "0.0.0" diff --git a/contracts/price-aggregator/wasm/src/lib.rs b/contracts/price-aggregator/wasm/src/lib.rs index 667c425a..a8e75f49 100644 --- a/contracts/price-aggregator/wasm/src/lib.rs +++ b/contracts/price-aggregator/wasm/src/lib.rs @@ -5,9 +5,10 @@ //////////////////////////////////////////////////// // Init: 1 +// Upgrade: 1 // Endpoints: 21 // Async Callback (empty): 1 -// Total number of exported functions: 23 +// Total number of exported functions: 24 #![no_std] @@ -18,6 +19,7 @@ multiversx_sc_wasm_adapter::endpoints! { multiversx_price_aggregator_sc ( init => init + upgrade => upgrade changeAmounts => change_amounts addOracles => add_oracles removeOracles => remove_oracles diff --git a/contracts/proxy-deployer/tests/proxy_deployer_blackbox_test.rs b/contracts/proxy-deployer/tests/proxy_deployer_blackbox_test.rs index 1e6fcd70..16245aaf 100644 --- a/contracts/proxy-deployer/tests/proxy_deployer_blackbox_test.rs +++ b/contracts/proxy-deployer/tests/proxy_deployer_blackbox_test.rs @@ -21,6 +21,8 @@ const DEPLOYED_CONTRACT_PATH_EXPR: MxscPath = MxscPath::new("../adder/output/add fn world() -> ScenarioWorld { let mut blockchain = ScenarioWorld::new(); + + blockchain.set_current_dir_from_workspace("contracts/proxy-developer"); blockchain.register_contract(PROXY_DEPLOYER_PATH_EXPR, proxy_deployer::ContractBuilder); blockchain.register_contract(DEPLOYED_CONTRACT_PATH_EXPR, adder::ContractBuilder); @@ -72,9 +74,7 @@ impl ProxyDeployerTestState { .from(OWNER_ADDRESS_EXPR) .to(PROXY_DEPLOYER_ADDRESS_EXPR) .typed(proxy_deployer_proxy::ProxyDeployerProxy) - .add_template_address(ManagedAddress::from_address( - &AddressValue::from(TEMPLATE_CONTRACT_ADDRESS_EXPR).to_address(), - )) + .add_template_address(TEMPLATE_CONTRACT_ADDRESS_EXPR.to_address()) .run(); self @@ -96,7 +96,7 @@ impl ProxyDeployerTestState { .from(user) .to(PROXY_DEPLOYER_ADDRESS_EXPR) .typed(proxy_deployer_proxy::ProxyDeployerProxy) - .contract_deploy(ManagedAddress::from(template_address.eval_to_array()), args) + .contract_deploy(template_address.to_managed_address(), args) .returns(ReturnsResult) .run(); self.deployed_contracts.push(deploy_address.to_address()); @@ -135,7 +135,7 @@ impl ProxyDeployerTestState { .typed(proxy_deployer_proxy::ProxyDeployerProxy) .upgrade_contracts_by_template( gas, - OptionalValue::Some(ManagedAddress::from(template_address.eval_to_array())), + OptionalValue::Some(template_address.to_managed_address()), args, ) .run(); diff --git a/contracts/proxy-deployer/wasm/Cargo.lock b/contracts/proxy-deployer/wasm/Cargo.lock index b606e6de..1103d4d0 100644 --- a/contracts/proxy-deployer/wasm/Cargo.lock +++ b/contracts/proxy-deployer/wasm/Cargo.lock @@ -38,14 +38,25 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "multiversx-chain-core" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c1088b268cad0d8c1146df9ca71a1f2baaee78267ab75e2202c0c0c71cc4b6e" +dependencies = [ + "bitflags", + "multiversx-sc-codec", +] + [[package]] name = "multiversx-sc" -version = "0.53.2" +version = "0.54.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" +checksum = "b9e5cee0b8c5fbaa9edfee2e38f2162adb01700a0028942d2cd14808cd26b130" dependencies = [ "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -77,9 +88,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.53.2" +version = "0.54.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" +checksum = "931669b080cf793b205bf08b5d1f4a658d0ac0ad628844d9a9d13649a73c7540" dependencies = [ "hex", "proc-macro2", @@ -90,18 +101,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.53.2" +version = "0.54.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daeb48acbd39255868a3241798df2f85050f0ae8d82d6417bd2cd0e30a241855" +checksum = "5373903a01dd7d33547b83f0034dc6e12fbbc8e49fcb316a3efb6ef4ff6573a8" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.53.2" +version = "0.54.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" +checksum = "c034ae143cfd971cf0c4d67476af1920a9a0165bd99713458397ac06762fca0d" dependencies = [ "multiversx-sc", ] diff --git a/contracts/proxy-deployer/wasm/Cargo.toml b/contracts/proxy-deployer/wasm/Cargo.toml index 36f7df31..d0923c44 100644 --- a/contracts/proxy-deployer/wasm/Cargo.toml +++ b/contracts/proxy-deployer/wasm/Cargo.toml @@ -1,3 +1,9 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "proxy-deployer-wasm" version = "0.0.0" From 09920ec9fe03614de132d3f594498fe07f01584e Mon Sep 17 00:00:00 2001 From: BiancaIalangi Date: Tue, 19 Nov 2024 17:23:51 +0200 Subject: [PATCH 05/13] 0.54 upgrade - price aggregator, multisig whitebox Co-authored-by: Bianca Ialangi Co-authored-by: Alin Cruceat --- .../multisig/tests/multisig_whitebox_test.rs | 902 ++++++++---------- .../tests/price_aggregator_blackbox_test.rs | 33 - .../tests/price_aggregator_whitebox_test.rs | 25 +- 3 files changed, 425 insertions(+), 535 deletions(-) diff --git a/contracts/multisig/tests/multisig_whitebox_test.rs b/contracts/multisig/tests/multisig_whitebox_test.rs index 185ba048..ec78eb28 100644 --- a/contracts/multisig/tests/multisig_whitebox_test.rs +++ b/contracts/multisig/tests/multisig_whitebox_test.rs @@ -1,40 +1,27 @@ -#![allow(unused)] - -use std::borrow::Borrow; - use adder::Adder; use factorial::Factorial; use multisig::{ action::GasLimit, multisig_perform::MultisigPerformModule, multisig_propose::MultisigProposeModule, multisig_sign::MultisigSignModule, - multisig_state::GroupId, user_role::UserRole, Multisig, + user_role::UserRole, Multisig, }; use multiversx_sc::{ api::ManagedTypeApi, - codec::multi_types::OptionalValue, - storage::mappers::SingleValue, types::{ - Address, BigUint, BoxedBytes, CodeMetadata, FunctionCall, ManagedAddress, ManagedBuffer, - ManagedVec, + Address, BigUint, BoxedBytes, CodeMetadata, FunctionCall, ManagedBuffer, ManagedVec, + TestAddress, TestSCAddress, }, }; use multiversx_sc_scenario::{ - managed_address, managed_biguint, - multiversx_chain_vm::types::VMAddress, - rust_biguint, - scenario_model::{ - Account, AddressValue, CheckAccount, CheckStateStep, ScCallStep, ScDeployStep, ScQueryStep, - SetStateStep, TxExpect, TypedScQuery, - }, - testing_framework::TxResult, - DebugApi, ScenarioWorld, WhiteboxContract, + imports::MxscPath, managed_address, managed_biguint, rust_biguint, ExpectMessage, + ReturnsHandledOrError, ScenarioTxWhitebox, ScenarioWorld, }; -const OWNER_ADDRESS_EXPR: &str = "address:owner"; -const PROPOSER_ADDRESS_EXPR: &str = "address:proposer"; -const BOARD_MEMBER_ADDRESS_EXPR: &str = "address:board-member"; -const MULTISIG_ADDRESS_EXPR: &str = "sc:multisig"; -const MULTISIG_PATH_EXPR: &str = "file:output/multisig.wasm"; +const OWNER: TestAddress = TestAddress::new("owner"); +const PROPOSER: TestAddress = TestAddress::new("proposer"); +const BOARD_MEMBER: TestAddress = TestAddress::new("board-member"); +const MULTISIG: TestSCAddress = TestSCAddress::new("multisig"); +const CODE_PATH: MxscPath = MxscPath::new("output/multisig.mxsc.json"); const QUORUM_SIZE: usize = 1; type RustBigUint = num_bigint::BigUint; @@ -72,47 +59,36 @@ pub struct CallActionDataRaw { fn world() -> ScenarioWorld { let mut blockchain: ScenarioWorld = ScenarioWorld::new(); - blockchain.register_contract(MULTISIG_PATH_EXPR, multisig::ContractBuilder); + blockchain.set_current_dir_from_workspace("contracts/multisig"); + blockchain.register_contract(CODE_PATH, multisig::ContractBuilder); blockchain } fn setup() -> ScenarioWorld { // setup let mut world = world(); - let multisig_whitebox = WhiteboxContract::new(MULTISIG_ADDRESS_EXPR, multisig::contract_obj); - let multisig_code = world.code_expression(MULTISIG_PATH_EXPR); - - world.set_state_step( - SetStateStep::new() - .put_account(OWNER_ADDRESS_EXPR, Account::new().nonce(1)) - .new_address(OWNER_ADDRESS_EXPR, 1, MULTISIG_ADDRESS_EXPR) - .put_account( - PROPOSER_ADDRESS_EXPR, - Account::new().nonce(1).balance(100_000_000u64), - ) - .put_account(BOARD_MEMBER_ADDRESS_EXPR, Account::new().nonce(1)), - ); + + world + .account(OWNER) + .nonce(1) + .new_address(OWNER, 1, MULTISIG); + world.account(PROPOSER).nonce(1).balance(100_000_000u64); + world.account(BOARD_MEMBER).nonce(1); // init multisig - world.whitebox_deploy( - &multisig_whitebox, - ScDeployStep::new() - .from(OWNER_ADDRESS_EXPR) - .code(multisig_code), - |sc| { + world + .tx() + .from(OWNER) + .raw_deploy() + .code(CODE_PATH) + .new_address(MULTISIG) + .whitebox(multisig::contract_obj, |sc| { let mut board_members = ManagedVec::new(); - board_members.push(managed_address!(&address_expr_to_address( - BOARD_MEMBER_ADDRESS_EXPR - ))); + board_members.push(BOARD_MEMBER.to_managed_address()); sc.init(QUORUM_SIZE, board_members.into()); - sc.change_user_role( - 0, - managed_address!(&address_expr_to_address(PROPOSER_ADDRESS_EXPR)), - UserRole::Proposer, - ); - }, - ); + sc.change_user_role(0, PROPOSER.to_managed_address(), UserRole::Proposer); + }); world } @@ -134,20 +110,16 @@ fn call_propose( ActionRaw::SCUpgradeFromSource { amount, .. } => amount.clone(), _ => rust_biguint!(0), }; - let amount_bytes = egld_amount.to_bytes_be(); - let amount_rust_biguint = num_bigint::BigUint::from_bytes_be(amount_bytes.as_slice()); let mut action_id = 0; - let multisig_whitebox = WhiteboxContract::new(MULTISIG_ADDRESS_EXPR, multisig::contract_obj); - - world.whitebox_call_check( - &multisig_whitebox, - ScCallStep::new() - .from(PROPOSER_ADDRESS_EXPR) - .egld_value(amount_rust_biguint) - .no_expect(), - |sc| { + let result = world + .tx() + .from(PROPOSER) + .to(MULTISIG) + .egld(BigUint::from(egld_amount)) + .returns(ReturnsHandledOrError::new()) + .whitebox(multisig::contract_obj, |sc| { action_id = match action { ActionRaw::_Nothing => panic!("Invalid action"), ActionRaw::AddBoardMember(addr) => { @@ -199,12 +171,11 @@ fn call_propose( boxed_bytes_vec_to_managed(arguments).into(), ), } - }, - |r| match expected_message { - Some(msg) => r.assert_user_error(msg), - None => r.assert_ok(), - }, - ); + }); + + if let Err(err) = result { + assert_eq!(expected_message.unwrap_or_default(), err.message); + } action_id } @@ -212,341 +183,296 @@ fn call_propose( #[test] fn test_add_board_member() { let mut world = setup(); - let multisig_whitebox = WhiteboxContract::new(MULTISIG_ADDRESS_EXPR, multisig::contract_obj); - const NEW_BOARD_MEMBER_ADDRESS_EXPR: &str = "address:new-board-member"; - world.set_state_step( - SetStateStep::new().put_account(NEW_BOARD_MEMBER_ADDRESS_EXPR, Account::new().nonce(1)), - ); + let new_board_member: TestAddress = TestAddress::new("new-board-member"); + world.account(new_board_member).nonce(1); - world.whitebox_query(&multisig_whitebox, |sc| { - // check role before - let user_role = sc.user_role(managed_address!(&address_expr_to_address( - NEW_BOARD_MEMBER_ADDRESS_EXPR - ))); - assert_eq!(user_role, UserRole::None); - }); + world + .query() + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| { + // check role before + let user_role = sc.user_role(new_board_member.to_managed_address()); + assert_eq!(user_role, UserRole::None); + }); let action_id = call_propose( &mut world, - ActionRaw::AddBoardMember(address_expr_to_address(NEW_BOARD_MEMBER_ADDRESS_EXPR)), + ActionRaw::AddBoardMember(new_board_member.to_address()), None, ); - world.whitebox_call( - &multisig_whitebox, - ScCallStep::new().from(BOARD_MEMBER_ADDRESS_EXPR), - |sc| sc.sign(action_id), - ); + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| { + sc.sign(action_id); + }); - world.whitebox_call( - &multisig_whitebox, - ScCallStep::new().from(BOARD_MEMBER_ADDRESS_EXPR), - |sc| { + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| { let _ = sc.perform_action_endpoint(action_id); - }, - ); + }); - world.whitebox_query(&multisig_whitebox, |sc| { - // check role after - let user_role = sc.user_role(managed_address!(&address_expr_to_address( - NEW_BOARD_MEMBER_ADDRESS_EXPR - ))); - assert_eq!(user_role, UserRole::BoardMember); - - let board_members = sc.get_all_board_members().to_vec(); - assert_eq!( - (board_members.get(0).borrow() as &ManagedAddress).clone(), - managed_address!(&address_expr_to_address(BOARD_MEMBER_ADDRESS_EXPR)) - ); - assert_eq!( - (board_members.get(1).borrow() as &ManagedAddress).clone(), - managed_address!(&address_expr_to_address(NEW_BOARD_MEMBER_ADDRESS_EXPR)) - ); - }); + world + .query() + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| { + // check role after + let user_role = sc.user_role(new_board_member.to_managed_address()); + assert_eq!(user_role, UserRole::BoardMember); + + let board_members = sc.get_all_board_members().to_vec(); + + assert_eq!(*board_members.get(0), BOARD_MEMBER); + assert_eq!(*board_members.get(1), new_board_member); + }); } #[test] fn test_add_proposer() { let mut world = setup(); - let multisig_whitebox = WhiteboxContract::new(MULTISIG_ADDRESS_EXPR, multisig::contract_obj); - const NEW_PROPOSER_ADDRESS_EXPR: &str = "address:new-proposer"; - world.set_state_step( - SetStateStep::new().put_account(NEW_PROPOSER_ADDRESS_EXPR, Account::new().nonce(1)), - ); + let new_proposer: TestAddress = TestAddress::new("new-proposer"); + world.account(new_proposer).nonce(1); - world.whitebox_query(&multisig_whitebox, |sc| { - // check role before - let user_role = sc.user_role(managed_address!(&address_expr_to_address( - NEW_PROPOSER_ADDRESS_EXPR - ))); - assert_eq!(user_role, UserRole::None); - }); + world + .query() + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| { + // check role before + let user_role = sc.user_role(new_proposer.to_managed_address()); + + assert_eq!(user_role, UserRole::None); + }); let action_id = call_propose( &mut world, - ActionRaw::AddProposer(address_expr_to_address(NEW_PROPOSER_ADDRESS_EXPR)), + ActionRaw::AddProposer(new_proposer.to_address()), None, ); - world.whitebox_call( - &multisig_whitebox, - ScCallStep::new().from(BOARD_MEMBER_ADDRESS_EXPR), - |sc| sc.sign(action_id), - ); - - world.whitebox_call( - &multisig_whitebox, - ScCallStep::new().from(BOARD_MEMBER_ADDRESS_EXPR), - |sc| { + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| sc.sign(action_id)); + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| { let _ = sc.perform_action_endpoint(action_id); - }, - ); + }); - world.whitebox_query(&multisig_whitebox, |sc| { - // check role after - let user_role = sc.user_role(managed_address!(&address_expr_to_address( - NEW_PROPOSER_ADDRESS_EXPR - ))); - assert_eq!(user_role, UserRole::Proposer); - - let proposers = sc.get_all_proposers().to_vec(); - assert_eq!( - (proposers.get(0).borrow() as &ManagedAddress).clone(), - managed_address!(&address_expr_to_address(PROPOSER_ADDRESS_EXPR)) - ); - assert_eq!( - (proposers.get(1).borrow() as &ManagedAddress).clone(), - managed_address!(&address_expr_to_address(NEW_PROPOSER_ADDRESS_EXPR)) - ); - }); + world + .query() + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| { + // check role after + let user_role = sc.user_role(new_proposer.to_managed_address()); + + assert_eq!(user_role, UserRole::Proposer); + + let proposers = sc.get_all_proposers().to_vec(); + assert_eq!(*proposers.get(0), PROPOSER); + assert_eq!(*proposers.get(1), new_proposer); + }); } #[test] fn test_remove_proposer() { let mut world = setup(); - let multisig_whitebox = WhiteboxContract::new(MULTISIG_ADDRESS_EXPR, multisig::contract_obj); - world.whitebox_query(&multisig_whitebox, |sc| { - // check role before - let user_role = sc.user_role(managed_address!(&address_expr_to_address( - PROPOSER_ADDRESS_EXPR - ))); - assert_eq!(user_role, UserRole::Proposer); - }); + world + .query() + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| { + // check role before + let user_role = sc.user_role(PROPOSER.to_managed_address()); + + assert_eq!(user_role, UserRole::Proposer); + }); let action_id = call_propose( &mut world, - ActionRaw::RemoveUser(address_expr_to_address(PROPOSER_ADDRESS_EXPR)), + ActionRaw::RemoveUser(PROPOSER.to_address()), None, ); - world.whitebox_call( - &multisig_whitebox, - ScCallStep::new().from(BOARD_MEMBER_ADDRESS_EXPR), - |sc| sc.sign(action_id), - ); - - world.whitebox_call( - &multisig_whitebox, - ScCallStep::new().from(BOARD_MEMBER_ADDRESS_EXPR), - |sc| { + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| sc.sign(action_id)); + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| { let _ = sc.perform_action_endpoint(action_id); - }, - ); + }); - world.whitebox_query(&multisig_whitebox, |sc| { - // check role after - let user_role = sc.user_role(managed_address!(&address_expr_to_address( - PROPOSER_ADDRESS_EXPR - ))); - assert_eq!(user_role, UserRole::None); + world + .query() + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| { + // check role after + let user_role = sc.user_role(PROPOSER.to_managed_address()); - let proposers = sc.get_all_proposers().to_vec(); - assert!(proposers.is_empty()); - }); + assert_eq!(user_role, UserRole::None); + + let proposers = sc.get_all_proposers(); + assert!(proposers.is_empty()); + }); } #[test] fn test_try_remove_all_board_members() { let mut world = setup(); - let multisig_whitebox = WhiteboxContract::new(MULTISIG_ADDRESS_EXPR, multisig::contract_obj); let action_id = call_propose( &mut world, - ActionRaw::RemoveUser(address_expr_to_address(BOARD_MEMBER_ADDRESS_EXPR)), + ActionRaw::RemoveUser(BOARD_MEMBER.to_address()), None, ); - world.whitebox_call( - &multisig_whitebox, - ScCallStep::new().from(BOARD_MEMBER_ADDRESS_EXPR), - |sc| sc.sign(action_id), - ); - - world.whitebox_call_check( - &multisig_whitebox, - ScCallStep::new() - .from(BOARD_MEMBER_ADDRESS_EXPR) - .no_expect(), - |sc| { + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| sc.sign(action_id)); + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .returns(ExpectMessage("quorum cannot exceed board size")) + .whitebox(multisig::contract_obj, |sc| { let _ = sc.perform_action_endpoint(action_id); - }, - |r| { - r.assert_user_error("quorum cannot exceed board size"); - }, - ); + }); } #[test] fn test_change_quorum() { let mut world = setup(); - let multisig_whitebox = WhiteboxContract::new(MULTISIG_ADDRESS_EXPR, multisig::contract_obj); let new_quorum_size = 2; // try change quorum > board size let action_id = call_propose(&mut world, ActionRaw::ChangeQuorum(new_quorum_size), None); - world.whitebox_call( - &multisig_whitebox, - ScCallStep::new().from(BOARD_MEMBER_ADDRESS_EXPR), - |sc| sc.sign(action_id), - ); - - world.whitebox_call_check( - &multisig_whitebox, - ScCallStep::new() - .from(BOARD_MEMBER_ADDRESS_EXPR) - .no_expect(), - |sc| { + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| sc.sign(action_id)); + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .returns(ExpectMessage("quorum cannot exceed board size")) + .whitebox(multisig::contract_obj, |sc| { let _ = sc.perform_action_endpoint(action_id); - }, - |r| { - r.assert_user_error("quorum cannot exceed board size"); - }, - ); + }); // try discard before unsigning - world.whitebox_call_check( - &multisig_whitebox, - ScCallStep::new() - .from(BOARD_MEMBER_ADDRESS_EXPR) - .no_expect(), - |sc| { - sc.discard_action(action_id); - }, - |r| { - r.assert_user_error("cannot discard action with valid signatures"); - }, - ); + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .returns(ExpectMessage("cannot discard action with valid signatures")) + .whitebox(multisig::contract_obj, |sc| sc.discard_action(action_id)); // unsign and discard action - world.whitebox_call( - &multisig_whitebox, - ScCallStep::new().from(BOARD_MEMBER_ADDRESS_EXPR), - |sc| sc.unsign(action_id), - ); - - world.whitebox_call( - &multisig_whitebox, - ScCallStep::new().from(BOARD_MEMBER_ADDRESS_EXPR), - |sc| { - sc.discard_action(action_id); - }, - ); + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| sc.unsign(action_id)); + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| sc.discard_action(action_id)); // try sign discarded action - world.whitebox_call_check( - &multisig_whitebox, - ScCallStep::new() - .from(BOARD_MEMBER_ADDRESS_EXPR) - .no_expect(), - |sc| { + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .returns(ExpectMessage("action does not exist")) + .whitebox(multisig::contract_obj, |sc| { sc.sign(action_id); - }, - |r| { - r.assert_user_error("action does not exist"); - }, - ); + }); // add another board member - const NEW_BOARD_MEMBER_ADDRESS_EXPR: &str = "address:new-board-member"; - world.set_state_step( - SetStateStep::new().put_account(NEW_BOARD_MEMBER_ADDRESS_EXPR, Account::new().nonce(1)), - ); + let new_board_member: TestAddress = TestAddress::new("new-board-member"); + world.account(new_board_member).nonce(1); let action_id = call_propose( &mut world, - ActionRaw::AddBoardMember(address_expr_to_address(NEW_BOARD_MEMBER_ADDRESS_EXPR)), + ActionRaw::AddBoardMember(new_board_member.to_address()), None, ); - world.whitebox_call( - &multisig_whitebox, - ScCallStep::new().from(BOARD_MEMBER_ADDRESS_EXPR), - |sc| sc.sign(action_id), - ); - - world.whitebox_call( - &multisig_whitebox, - ScCallStep::new().from(BOARD_MEMBER_ADDRESS_EXPR), - |sc| { + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| sc.sign(action_id)); + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| { let _ = sc.perform_action_endpoint(action_id); - }, - ); + }); // change quorum to 2 let action_id = call_propose(&mut world, ActionRaw::ChangeQuorum(new_quorum_size), None); - world.whitebox_call( - &multisig_whitebox, - ScCallStep::new().from(BOARD_MEMBER_ADDRESS_EXPR), - |sc| sc.sign(action_id), - ); - - world.whitebox_call( - &multisig_whitebox, - ScCallStep::new().from(BOARD_MEMBER_ADDRESS_EXPR), - |sc| { + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| sc.sign(action_id)); + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| { let _ = sc.perform_action_endpoint(action_id); - }, - ); + }); } #[test] fn test_transfer_execute_to_user() { let mut world = setup(); - let multisig_whitebox = WhiteboxContract::new(MULTISIG_ADDRESS_EXPR, multisig::contract_obj); - const NEW_USER_ADDRESS_EXPR: &str = "address:new-user"; - world.set_state_step( - SetStateStep::new().put_account(NEW_USER_ADDRESS_EXPR, Account::new().nonce(1)), - ); + let new_user: TestAddress = TestAddress::new("new-user"); + world.account(new_user).nonce(1); - const EGLD_AMOUNT: u64 = 100; + let egld_amount: u64 = 100; - world.whitebox_call( - &multisig_whitebox, - ScCallStep::new() - .from(PROPOSER_ADDRESS_EXPR) - .egld_value(EGLD_AMOUNT), - |sc| { + world + .tx() + .from(PROPOSER) + .to(MULTISIG) + .egld(egld_amount) + .whitebox(multisig::contract_obj, |sc| { sc.deposit(); - }, - ); - - world.check_state_step(CheckStateStep::new().put_account( - MULTISIG_ADDRESS_EXPR, - CheckAccount::new().balance(EGLD_AMOUNT.to_string().as_str()), - )); + }); + world.check_account(MULTISIG).balance(egld_amount); // failed attempt - let action_id = call_propose( + call_propose( &mut world, ActionRaw::SendTransferExecute(CallActionDataRaw { - to: address_expr_to_address(NEW_USER_ADDRESS_EXPR), + to: new_user.to_address(), egld_amount: rust_biguint!(0), endpoint_name: BoxedBytes::empty(), arguments: Vec::new(), @@ -558,67 +484,58 @@ fn test_transfer_execute_to_user() { let action_id = call_propose( &mut world, ActionRaw::SendTransferExecute(CallActionDataRaw { - to: address_expr_to_address(NEW_USER_ADDRESS_EXPR), - egld_amount: rust_biguint!(EGLD_AMOUNT), + to: new_user.to_address(), + egld_amount: rust_biguint!(egld_amount), endpoint_name: BoxedBytes::empty(), arguments: Vec::new(), }), None, ); - world.whitebox_call( - &multisig_whitebox, - ScCallStep::new().from(BOARD_MEMBER_ADDRESS_EXPR), - |sc| sc.sign(action_id), - ); - - world.whitebox_call( - &multisig_whitebox, - ScCallStep::new().from(BOARD_MEMBER_ADDRESS_EXPR), - |sc| { + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| sc.sign(action_id)); + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| { let _ = sc.perform_action_endpoint(action_id); - }, - ); + }); - world.check_state_step(CheckStateStep::new().put_account( - NEW_USER_ADDRESS_EXPR, - CheckAccount::new().balance(EGLD_AMOUNT.to_string().as_str()), - )); + world.check_account(new_user).balance(egld_amount); } #[test] fn test_transfer_execute_sc_all() { let mut world = setup(); - let multisig_whitebox = WhiteboxContract::new(MULTISIG_ADDRESS_EXPR, multisig::contract_obj); - - let adder_whitebox = WhiteboxContract::new(ADDER_ADDRESS_EXPR, adder::contract_obj); - let adder_code = world.code_expression(ADDER_PATH_EXPR); - const ADDER_OWNER_ADDRESS_EXPR: &str = "address:adder-owner"; - const ADDER_ADDRESS_EXPR: &str = "sc:adder"; - const ADDER_PATH_EXPR: &str = "file:test-contracts/adder.wasm"; + let adder_owner: TestAddress = TestAddress::new("adder-owner"); + let adder_address: TestSCAddress = TestSCAddress::new("adder"); + let adder_code_path: MxscPath = MxscPath::new("test-contracts/adder.mxsc.json"); - world.register_contract(ADDER_PATH_EXPR, adder::ContractBuilder); - world.set_state_step( - SetStateStep::new() - .put_account(ADDER_OWNER_ADDRESS_EXPR, Account::new().nonce(1)) - .new_address(ADDER_OWNER_ADDRESS_EXPR, 1, ADDER_ADDRESS_EXPR), - ); + world.register_contract(adder_code_path, adder::ContractBuilder); + world + .account(adder_owner) + .nonce(1) + .new_address(adder_owner, 1, adder_address); - world.whitebox_deploy( - &adder_whitebox, - ScDeployStep::new() - .from(ADDER_OWNER_ADDRESS_EXPR) - .code(adder_code), - |sc| { - sc.init(managed_biguint!(5)); - }, - ); + world + .tx() + .raw_deploy() + .from(adder_owner) + .code(adder_code_path) + .new_address(adder_address) + .whitebox(adder::contract_obj, |sc| { + sc.init(BigUint::from(5u64)); + }); let action_id = call_propose( &mut world, ActionRaw::SendTransferExecute(CallActionDataRaw { - to: address_expr_to_address(ADDER_ADDRESS_EXPR), + to: adder_address.to_address(), egld_amount: 0u64.into(), endpoint_name: BoxedBytes::from(&b"add"[..]), arguments: vec![BoxedBytes::from(&[5u8][..])], @@ -626,60 +543,57 @@ fn test_transfer_execute_sc_all() { None, ); - world.whitebox_call( - &multisig_whitebox, - ScCallStep::new().from(BOARD_MEMBER_ADDRESS_EXPR), - |sc| sc.sign(action_id), - ); - - world.whitebox_call( - &multisig_whitebox, - ScCallStep::new().from(BOARD_MEMBER_ADDRESS_EXPR), - |sc| { + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| sc.sign(action_id)); + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| { let _ = sc.perform_action_endpoint(action_id); - }, - ); + }); - world.whitebox_query(&adder_whitebox, |sc| { - let actual_sum = sc.sum().get(); - let expected_sum = managed_biguint!(10); - assert_eq!(actual_sum, expected_sum); - }); + world + .query() + .to(adder_address) + .whitebox(adder::contract_obj, |sc| { + let actual_sum = sc.sum().get(); + let expected_sum = managed_biguint!(10); + assert_eq!(actual_sum, expected_sum); + }); } #[test] fn test_async_call_to_sc() { let mut world = setup(); - let multisig_whitebox = WhiteboxContract::new(MULTISIG_ADDRESS_EXPR, multisig::contract_obj); - let adder_whitebox = WhiteboxContract::new(ADDER_ADDRESS_EXPR, adder::contract_obj); - let adder_code = world.code_expression(ADDER_PATH_EXPR); + let adder_owner: TestAddress = TestAddress::new("adder-owner"); + let adder_address: TestSCAddress = TestSCAddress::new("adder"); + let adder_code_path: MxscPath = MxscPath::new("test-contracts/adder.mxsc.json"); - const ADDER_OWNER_ADDRESS_EXPR: &str = "address:adder-owner"; - const ADDER_ADDRESS_EXPR: &str = "sc:adder"; - const ADDER_PATH_EXPR: &str = "file:test-contracts/adder.wasm"; - - world.register_contract(ADDER_PATH_EXPR, adder::ContractBuilder); - world.set_state_step( - SetStateStep::new() - .put_account(ADDER_OWNER_ADDRESS_EXPR, Account::new().nonce(1)) - .new_address(ADDER_OWNER_ADDRESS_EXPR, 1, ADDER_ADDRESS_EXPR), - ); + world.register_contract(adder_code_path, adder::ContractBuilder); + world + .account(adder_owner) + .nonce(1) + .new_address(adder_owner, 1, adder_address); - world.whitebox_deploy( - &adder_whitebox, - ScDeployStep::new() - .from(ADDER_OWNER_ADDRESS_EXPR) - .code(adder_code), - |sc| { - sc.init(managed_biguint!(5)); - }, - ); + world + .tx() + .raw_deploy() + .from(adder_owner) + .code(adder_code_path) + .new_address(adder_address) + .whitebox(adder::contract_obj, |sc| { + sc.init(BigUint::from(5u64)); + }); let action_id = call_propose( &mut world, ActionRaw::SendAsyncCall(CallActionDataRaw { - to: address_expr_to_address(ADDER_ADDRESS_EXPR), + to: adder_address.to_address(), egld_amount: 0u64.into(), endpoint_name: BoxedBytes::from(&b"add"[..]), arguments: vec![BoxedBytes::from(&[5u8][..])], @@ -687,93 +601,84 @@ fn test_async_call_to_sc() { None, ); - world.whitebox_call( - &multisig_whitebox, - ScCallStep::new().from(BOARD_MEMBER_ADDRESS_EXPR), - |sc| sc.sign(action_id), - ); - - world.whitebox_call( - &multisig_whitebox, - ScCallStep::new().from(BOARD_MEMBER_ADDRESS_EXPR), - |sc| { + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| sc.sign(action_id)); + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| { let _ = sc.perform_action_endpoint(action_id); - }, - ); - - world.whitebox_query(&adder_whitebox, |sc| { - let actual_sum = sc.sum().get(); - let expected_sum = managed_biguint!(10); - assert_eq!(actual_sum, expected_sum); - }); + }); + world + .query() + .to(adder_address) + .whitebox(adder::contract_obj, |sc| { + let actual_sum = sc.sum().get(); + let expected_sum = managed_biguint!(10); + assert_eq!(actual_sum, expected_sum); + }); } #[test] fn test_deploy_and_upgrade_from_source() { let mut world = setup(); - let multisig_whitebox = WhiteboxContract::new(MULTISIG_ADDRESS_EXPR, multisig::contract_obj); - - let adder_whitebox = WhiteboxContract::new(ADDER_ADDRESS_EXPR, adder::contract_obj); - let adder_code = world.code_expression(ADDER_PATH_EXPR); - let new_adder_whitebox = WhiteboxContract::new(NEW_ADDER_ADDRESS_EXPR, adder::contract_obj); + let new_adder_address: TestSCAddress = TestSCAddress::new("new-adder"); + let adder_owner: TestAddress = TestAddress::new("adder-owner"); + let adder_address: TestSCAddress = TestSCAddress::new("adder"); + let adder_path: MxscPath = MxscPath::new("test-contracts/adder.mxsc.json"); - const ADDER_OWNER_ADDRESS_EXPR: &str = "address:adder-owner"; - const ADDER_ADDRESS_EXPR: &str = "sc:adder"; - const NEW_ADDER_ADDRESS_EXPR: &str = "sc:new-adder"; - const ADDER_PATH_EXPR: &str = "file:test-contracts/adder.wasm"; - - world.register_contract(ADDER_PATH_EXPR, adder::ContractBuilder); - world.set_state_step( - SetStateStep::new() - .put_account(ADDER_OWNER_ADDRESS_EXPR, Account::new().nonce(1)) - .new_address(ADDER_OWNER_ADDRESS_EXPR, 1, ADDER_ADDRESS_EXPR) - .new_address(MULTISIG_ADDRESS_EXPR, 0, NEW_ADDER_ADDRESS_EXPR), - ); + world.register_contract(adder_path, adder::ContractBuilder); + world + .account(adder_owner) + .nonce(1) + .new_address(adder_owner, 1, adder_address) + .new_address(MULTISIG, 0, new_adder_address); - world.whitebox_deploy( - &adder_whitebox, - ScDeployStep::new() - .from(ADDER_OWNER_ADDRESS_EXPR) - .code(adder_code), - |sc| { - sc.init(managed_biguint!(5)); - }, - ); + world + .tx() + .raw_deploy() + .from(adder_owner) + .code(adder_path) + .new_address(adder_address) + .whitebox(adder::contract_obj, |sc| { + sc.init(BigUint::from(5u64)); + }); let action_id = call_propose( &mut world, ActionRaw::SCDeployFromSource { amount: 0u64.into(), - source: address_expr_to_address(ADDER_ADDRESS_EXPR), + source: adder_address.to_address(), code_metadata: CodeMetadata::all(), arguments: vec![BoxedBytes::from(&[5u8][..])], }, None, ); - world.whitebox_call( - &multisig_whitebox, - ScCallStep::new().from(BOARD_MEMBER_ADDRESS_EXPR), - |sc| sc.sign(action_id), - ); - - let mut addr = Address::zero(); - world.whitebox_call( - &multisig_whitebox, - ScCallStep::new().from(BOARD_MEMBER_ADDRESS_EXPR), - |sc| { + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| sc.sign(action_id)); + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| { let opt_address = sc.perform_action_endpoint(action_id); - addr = opt_address.into_option().unwrap().to_address(); - }, - ); - - assert_eq!(address_expr_to_address(NEW_ADDER_ADDRESS_EXPR), addr); + let addr = opt_address.into_option().unwrap().to_address(); + assert_eq!(new_adder_address.to_address(), addr); + }); let action_id = call_propose( &mut world, ActionRaw::SendTransferExecute(CallActionDataRaw { - to: address_expr_to_address(NEW_ADDER_ADDRESS_EXPR), + to: new_adder_address.to_address(), egld_amount: 0u64.into(), endpoint_name: BoxedBytes::from(&b"add"[..]), arguments: vec![BoxedBytes::from(&[5u8][..])], @@ -781,71 +686,66 @@ fn test_deploy_and_upgrade_from_source() { None, ); - world.whitebox_call( - &multisig_whitebox, - ScCallStep::new().from(BOARD_MEMBER_ADDRESS_EXPR), - |sc| sc.sign(action_id), - ); - - world.whitebox_call( - &multisig_whitebox, - ScCallStep::new().from(BOARD_MEMBER_ADDRESS_EXPR), - |sc| { + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| sc.sign(action_id)); + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| { let _ = sc.perform_action_endpoint(action_id); - }, - ); - - world.whitebox_query(&new_adder_whitebox, |sc| { - let actual_sum = sc.sum().get(); - let expected_sum = managed_biguint!(10); - assert_eq!(actual_sum, expected_sum); - }); - - let factorial_code = world.code_expression(FACTORIAL_PATH_EXPR); - - const FACTORIAL_ADDRESS_EXPR: &str = "sc:factorial"; - const FACTORIAL_PATH_EXPR: &str = "file:test-contracts/factorial.wasm"; - - world.register_contract(FACTORIAL_PATH_EXPR, factorial::ContractBuilder); - world.set_state_step(SetStateStep::new().put_account( - FACTORIAL_ADDRESS_EXPR, - Account::new().nonce(1).code(factorial_code.clone()), - )); + }); + world + .query() + .to(new_adder_address) + .whitebox(adder::contract_obj, |sc| { + let actual_sum = sc.sum().get(); + let expected_sum = managed_biguint!(10); + assert_eq!(actual_sum, expected_sum); + }); + + let factorial_address: TestSCAddress = TestSCAddress::new("factorial"); + let factorial_code: MxscPath = MxscPath::new("test-contracts/factorial.mxsc.json"); + + world.register_contract(factorial_code, factorial::ContractBuilder); + world + .tx() + .raw_deploy() + .from(OWNER) + .code(factorial_code) + .new_address(factorial_address) + .whitebox(factorial::contract_obj, |sc| { + sc.init(); + }); let action_id = call_propose( &mut world, ActionRaw::SCUpgradeFromSource { - source: address_expr_to_address(FACTORIAL_ADDRESS_EXPR), + source: factorial_address.to_address(), amount: 0u64.into(), code_metadata: CodeMetadata::all(), arguments: Vec::new(), - sc_address: address_expr_to_address(ADDER_ADDRESS_EXPR), + sc_address: adder_address.to_address(), }, None, ); - world.whitebox_call( - &multisig_whitebox, - ScCallStep::new().from(BOARD_MEMBER_ADDRESS_EXPR), - |sc| sc.sign(action_id), - ); - - world.whitebox_call( - &multisig_whitebox, - ScCallStep::new().from(BOARD_MEMBER_ADDRESS_EXPR), - |sc| { + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| sc.sign(action_id)); + world + .tx() + .from(BOARD_MEMBER) + .to(MULTISIG) + .whitebox(multisig::contract_obj, |sc| { let _ = sc.perform_action_endpoint(action_id); - }, - ); - - world.check_state_step( - CheckStateStep::new() - .put_account(ADDER_ADDRESS_EXPR, CheckAccount::new().code(factorial_code)), - ); -} - -fn address_expr_to_address(address_expr: &str) -> Address { - AddressValue::from(address_expr).to_address() + }); + world.check_account(adder_address).code(factorial_code); } fn boxed_bytes_vec_to_managed( diff --git a/contracts/price-aggregator/tests/price_aggregator_blackbox_test.rs b/contracts/price-aggregator/tests/price_aggregator_blackbox_test.rs index 089b3498..25809f55 100644 --- a/contracts/price-aggregator/tests/price_aggregator_blackbox_test.rs +++ b/contracts/price-aggregator/tests/price_aggregator_blackbox_test.rs @@ -319,39 +319,6 @@ fn test_price_aggregator_submit_round_ok() { ); }, ); - state.world.query().to(PRICE_AGGREGATOR_ADDRESS).whitebox( - multiversx_price_aggregator_sc::contract_obj, - |sc| { - let result = sc.latest_price_feed( - ManagedBuffer::from(EGLD_TICKER.as_str()), - ManagedBuffer::from(USD_TICKER.as_str()), - ); - - let (round_id, from, to, timestamp, price, decimals) = result.into_tuple(); - assert_eq!(round_id, 1); - assert_eq!(from, ManagedBuffer::from(EGLD_TICKER.as_str())); - assert_eq!(to, ManagedBuffer::from(USD_TICKER.as_str())); - assert_eq!(timestamp, current_timestamp); - assert_eq!(price, managed_biguint!(11_000)); - assert_eq!(decimals, DECIMALS); - - // submissions are deleted after round is created - let token_pair = TokenPair { from, to }; - let submissions = sc.submissions().get(&token_pair).unwrap(); - assert_eq!(submissions.len(), 0); - - let rounds = sc.rounds().get(&token_pair).unwrap(); - assert_eq!(rounds.len(), 1); - assert_eq!( - rounds.get(1), - TimestampedPrice { - timestamp, - price, - decimals - } - ); - }, - ); } #[test] diff --git a/contracts/price-aggregator/tests/price_aggregator_whitebox_test.rs b/contracts/price-aggregator/tests/price_aggregator_whitebox_test.rs index 05f9b4bd..8a142e9b 100644 --- a/contracts/price-aggregator/tests/price_aggregator_whitebox_test.rs +++ b/contracts/price-aggregator/tests/price_aggregator_whitebox_test.rs @@ -363,6 +363,19 @@ fn test_price_aggregator_discarded_round() { fn test_price_aggregator_slashing() { let (mut world, oracles) = setup(); + // configure the number of decimals + world + .tx() + .from(OWNER_ADDRESS) + .to(PRICE_AGGREGATOR_ADDRESS) + .whitebox(multiversx_price_aggregator_sc::contract_obj, |sc| { + sc.set_pair_decimals( + ManagedBuffer::from(EGLD_TICKER.as_str()), + ManagedBuffer::from(USD_TICKER.as_str()), + DECIMALS, + ) + }); + // unpause world .tx() @@ -396,6 +409,16 @@ fn test_price_aggregator_slashing() { sc.vote_slash_member(ManagedAddress::from(oracles[1].clone())) }); + world.query().to(PRICE_AGGREGATOR_ADDRESS).whitebox( + multiversx_price_aggregator_sc::contract_obj, + |sc| { + let list = sc.slashing_proposal_voters(&ManagedAddress::from(&oracles[1])); + assert!(list.contains(&ManagedAddress::from(&oracles[0]))); + assert!(list.contains(&ManagedAddress::from(&oracles[2]))); + assert!(list.contains(&ManagedAddress::from(&oracles[3]))); + }, + ); + world .tx() .from(&oracles[0]) @@ -431,7 +454,7 @@ fn setup() -> (ScenarioWorld, Vec
) { let mut oracles = Vec::new(); for i in 1..=NR_ORACLES { - let oracle_address_expr = format!("address:oracle{i}"); + let oracle_address_expr = format!("oracle{i}"); let oracle_address = TestAddress::new(&oracle_address_expr); world.account(oracle_address).nonce(1).balance(STAKE_AMOUNT); From 2684cd246a3c41725127bc6c16ddc86e775dfdd6 Mon Sep 17 00:00:00 2001 From: BiancaIalangi Date: Thu, 21 Nov 2024 00:00:12 +0200 Subject: [PATCH 06/13] 0.54 upgrade - proxy pause, seed-nft-minter, token-release, wegld swap --- .../tests/proxy_pause_scenario_rs_test.rs | 1 + contracts/proxy-pause/wasm/Cargo.lock | 31 ++++++++++------ contracts/proxy-pause/wasm/Cargo.toml | 6 ++++ contracts/seed-nft-minter/wasm/Cargo.lock | 35 ++++++++++++------- contracts/seed-nft-minter/wasm/Cargo.toml | 6 ++++ .../tests/token_release_scenario_rs_test.rs | 1 + contracts/token-release/wasm/Cargo.lock | 31 ++++++++++------ contracts/token-release/wasm/Cargo.toml | 6 ++++ .../tests/wegld_swap_scenario_rs_test.rs | 1 + contracts/wegld-swap/wasm/Cargo.lock | 35 ++++++++++++------- contracts/wegld-swap/wasm/Cargo.toml | 6 ++++ 11 files changed, 115 insertions(+), 44 deletions(-) diff --git a/contracts/proxy-pause/tests/proxy_pause_scenario_rs_test.rs b/contracts/proxy-pause/tests/proxy_pause_scenario_rs_test.rs index 08a9f922..1b812c23 100644 --- a/contracts/proxy-pause/tests/proxy_pause_scenario_rs_test.rs +++ b/contracts/proxy-pause/tests/proxy_pause_scenario_rs_test.rs @@ -3,6 +3,7 @@ use multiversx_sc_scenario::*; fn world() -> ScenarioWorld { let mut blockchain = ScenarioWorld::new(); + blockchain.set_current_dir_from_workspace("contracts/proxy-pause"); blockchain.register_contract( "mxsc:output/proxy-pause.mxsc.json", proxy_pause::ContractBuilder, diff --git a/contracts/proxy-pause/wasm/Cargo.lock b/contracts/proxy-pause/wasm/Cargo.lock index a9601827..060203cf 100644 --- a/contracts/proxy-pause/wasm/Cargo.lock +++ b/contracts/proxy-pause/wasm/Cargo.lock @@ -38,14 +38,25 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "multiversx-chain-core" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" +dependencies = [ + "bitflags", + "multiversx-sc-codec", +] + [[package]] name = "multiversx-sc" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -54,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -65,9 +76,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -77,9 +88,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -90,9 +101,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/proxy-pause/wasm/Cargo.toml b/contracts/proxy-pause/wasm/Cargo.toml index f84aa1ad..29c0d8b5 100644 --- a/contracts/proxy-pause/wasm/Cargo.toml +++ b/contracts/proxy-pause/wasm/Cargo.toml @@ -1,3 +1,9 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "proxy-pause-wasm" version = "0.0.0" diff --git a/contracts/seed-nft-minter/wasm/Cargo.lock b/contracts/seed-nft-minter/wasm/Cargo.lock index 5d4cf660..a3a80bdf 100644 --- a/contracts/seed-nft-minter/wasm/Cargo.lock +++ b/contracts/seed-nft-minter/wasm/Cargo.lock @@ -38,14 +38,25 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "multiversx-chain-core" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" +dependencies = [ + "bitflags", + "multiversx-sc-codec", +] + [[package]] name = "multiversx-sc" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -54,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -65,9 +76,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -77,9 +88,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -90,18 +101,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daeb48acbd39255868a3241798df2f85050f0ae8d82d6417bd2cd0e30a241855" +checksum = "74b31cfc990a3052a0e014f749104752a0208f3d11d4dee3c0dd6e6d4ce1908c" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/seed-nft-minter/wasm/Cargo.toml b/contracts/seed-nft-minter/wasm/Cargo.toml index 034535f9..009112f6 100644 --- a/contracts/seed-nft-minter/wasm/Cargo.toml +++ b/contracts/seed-nft-minter/wasm/Cargo.toml @@ -1,3 +1,9 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "seed-nft-minter-wasm" version = "0.0.0" diff --git a/contracts/token-release/tests/token_release_scenario_rs_test.rs b/contracts/token-release/tests/token_release_scenario_rs_test.rs index eefa11be..05e0b8a5 100644 --- a/contracts/token-release/tests/token_release_scenario_rs_test.rs +++ b/contracts/token-release/tests/token_release_scenario_rs_test.rs @@ -3,6 +3,7 @@ use multiversx_sc_scenario::*; fn world() -> ScenarioWorld { let mut blockchain = ScenarioWorld::new(); + blockchain.set_current_dir_from_workspace("contracts/token-release"); blockchain.register_contract( "mxsc:output/token-release.mxsc.json", token_release::ContractBuilder, diff --git a/contracts/token-release/wasm/Cargo.lock b/contracts/token-release/wasm/Cargo.lock index 6ef1b685..5b23d190 100644 --- a/contracts/token-release/wasm/Cargo.lock +++ b/contracts/token-release/wasm/Cargo.lock @@ -38,14 +38,25 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "multiversx-chain-core" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" +dependencies = [ + "bitflags", + "multiversx-sc-codec", +] + [[package]] name = "multiversx-sc" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -54,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -65,9 +76,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -77,9 +88,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -90,9 +101,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/token-release/wasm/Cargo.toml b/contracts/token-release/wasm/Cargo.toml index 0fff178b..7fdaad41 100644 --- a/contracts/token-release/wasm/Cargo.toml +++ b/contracts/token-release/wasm/Cargo.toml @@ -1,3 +1,9 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "token-release-wasm" version = "0.0.0" diff --git a/contracts/wegld-swap/tests/wegld_swap_scenario_rs_test.rs b/contracts/wegld-swap/tests/wegld_swap_scenario_rs_test.rs index a93bedb1..9bde0081 100644 --- a/contracts/wegld-swap/tests/wegld_swap_scenario_rs_test.rs +++ b/contracts/wegld-swap/tests/wegld_swap_scenario_rs_test.rs @@ -3,6 +3,7 @@ use multiversx_sc_scenario::*; fn world() -> ScenarioWorld { let mut blockchain = ScenarioWorld::new(); + blockchain.set_current_dir_from_workspace("contracts/wegld-swap"); blockchain.register_contract( "mxsc:output/multiversx-wegld-swap-sc.mxsc.json", multiversx_wegld_swap_sc::ContractBuilder, diff --git a/contracts/wegld-swap/wasm/Cargo.lock b/contracts/wegld-swap/wasm/Cargo.lock index 0b8d5a93..7167af5d 100644 --- a/contracts/wegld-swap/wasm/Cargo.lock +++ b/contracts/wegld-swap/wasm/Cargo.lock @@ -38,14 +38,25 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "multiversx-chain-core" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" +dependencies = [ + "bitflags", + "multiversx-sc-codec", +] + [[package]] name = "multiversx-sc" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -54,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -65,9 +76,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -77,9 +88,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -90,18 +101,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daeb48acbd39255868a3241798df2f85050f0ae8d82d6417bd2cd0e30a241855" +checksum = "74b31cfc990a3052a0e014f749104752a0208f3d11d4dee3c0dd6e6d4ce1908c" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/wegld-swap/wasm/Cargo.toml b/contracts/wegld-swap/wasm/Cargo.toml index 7af02632..4e5b9fcc 100644 --- a/contracts/wegld-swap/wasm/Cargo.toml +++ b/contracts/wegld-swap/wasm/Cargo.toml @@ -1,3 +1,9 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "multiversx-wegld-swap-sc-wasm" version = "0.0.0" From 9180b3478b4d2549fd519c61f45c792816444d4f Mon Sep 17 00:00:00 2001 From: BiancaIalangi Date: Thu, 21 Nov 2024 12:19:33 +0200 Subject: [PATCH 07/13] 0.54 upgrade - multisig, paymaster --- contracts/fair-launch/tests/tests_common.rs | 5 +- contracts/multisig/interact/config.toml | 3 +- .../interact/src/multisig_interact.rs | 26 +++---- .../interact/src/multisig_interact_config.rs | 23 ++++++- .../interact/src/multisig_interact_nfts.rs | 5 -- .../interact/src/multisig_interact_wegld.rs | 3 - .../tests/multisig_scenario_rs_test.rs | 1 + contracts/paymaster/interactor/Cargo.toml | 3 + contracts/paymaster/interactor/config.toml | 3 +- .../interactor/src/interactor_main.rs | 12 ++-- .../interactor/src/paymaster_config.rs | 24 ++++++- contracts/paymaster/interactor/state.toml | 2 +- .../tests/paymaster_blackbox_test.rs | 68 +++++-------------- contracts/paymaster/wasm/Cargo.lock | 31 ++++++--- contracts/paymaster/wasm/Cargo.toml | 6 ++ 15 files changed, 117 insertions(+), 98 deletions(-) diff --git a/contracts/fair-launch/tests/tests_common.rs b/contracts/fair-launch/tests/tests_common.rs index ddb2d8c3..baf19f83 100644 --- a/contracts/fair-launch/tests/tests_common.rs +++ b/contracts/fair-launch/tests/tests_common.rs @@ -1,7 +1,6 @@ use fair_launch::{common::Percentage, fair_launch_proxy, token_info::TokenInfoModule}; -use multiversx_sc::{ - imports::StorageTokenWrapper, - types::{ManagedBuffer, MultiValueEncoded, TestAddress, TestSCAddress, TestTokenIdentifier}, +use multiversx_sc::types::{ + ManagedBuffer, MultiValueEncoded, TestAddress, TestSCAddress, TestTokenIdentifier, }; use multiversx_sc_scenario::{imports::MxscPath, ScenarioTxRun, ScenarioTxWhitebox, ScenarioWorld}; use pair_mock::PairMock; diff --git a/contracts/multisig/interact/config.toml b/contracts/multisig/interact/config.toml index 029fab5a..148ebb58 100644 --- a/contracts/multisig/interact/config.toml +++ b/contracts/multisig/interact/config.toml @@ -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" diff --git a/contracts/multisig/interact/src/multisig_interact.rs b/contracts/multisig/interact/src/multisig_interact.rs index 792e5e81..25e3467f 100644 --- a/contracts/multisig/interact/src/multisig_interact.rs +++ b/contracts/multisig/interact/src/multisig_interact.rs @@ -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 { @@ -86,11 +86,13 @@ 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()) .await + .use_chain_simulator(config.use_chain_simulator()) .with_tracer(INTERACTOR_SCENARIO_TRACE_PATH) .await; - let wallet_address = interactor.register_wallet(test_wallets::mike()); + interactor.set_current_dir_from_workspace("contracts/multisig/interact"); + let wallet_address = interactor.register_wallet(test_wallets::mike()).await; let multisig_code = BytesValue::interpret_from( "mxsc:../output/multisig.mxsc.json", &InterpreterContext::default(), @@ -106,13 +108,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; } } @@ -145,7 +147,6 @@ impl MultisigInteract { .code(&self.multisig_code) .gas(NumExpr("100,000,000")) .returns(ReturnsNewBech32Address) - .prepare_async() .run() .await; @@ -190,9 +191,9 @@ impl MultisigInteract { MultiValueVec::from([ self.wallet_address.to_address(), - carol.address().to_bytes().into(), - dan.address().to_bytes().into(), - eve.address().to_bytes().into(), + carol.to_address(), + dan.to_address(), + eve.to_address(), ]) } @@ -202,7 +203,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; } @@ -220,7 +220,6 @@ impl MultisigInteract { .gas(gas_expr) .typed(multisig_proxy::MultisigProxy) .perform_action_endpoint(action_id) - .prepare_async() .run() .await; @@ -273,7 +272,6 @@ impl MultisigInteract { .typed(multisig_proxy::MultisigProxy) .quorum_reached(action_id) .returns(ReturnsResult) - .prepare_async() .run() .await } @@ -285,7 +283,6 @@ impl MultisigInteract { .typed(multisig_proxy::MultisigProxy) .signed(signer, action_id) .returns(ReturnsResult) - .prepare_async() .run() .await } @@ -340,7 +337,6 @@ impl MultisigInteract { .gas(NumExpr("30,000,000")) .typed(multisig_proxy::MultisigProxy) .dns_register(dns_address, name) - .prepare_async() .run() .await; @@ -355,7 +351,6 @@ impl MultisigInteract { .typed(multisig_proxy::MultisigProxy) .quorum() .returns(ReturnsResult) - .prepare_async() .run() .await; @@ -370,7 +365,6 @@ impl MultisigInteract { .typed(multisig_proxy::MultisigProxy) .num_board_members() .returns(ReturnsResult) - .prepare_async() .run() .await; diff --git a/contracts/multisig/interact/src/multisig_interact_config.rs b/contracts/multisig/interact/src/multisig_interact_config.rs index 4aa9903c..c11c2c44 100644 --- a/contracts/multisig/interact/src/multisig_interact_config.rs +++ b/contracts/multisig/interact/src/multisig_interact_config.rs @@ -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, } @@ -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, + } + } } diff --git a/contracts/multisig/interact/src/multisig_interact_nfts.rs b/contracts/multisig/interact/src/multisig_interact_nfts.rs index daa56f8d..d63ed6c9 100644 --- a/contracts/multisig/interact/src/multisig_interact_nfts.rs +++ b/contracts/multisig/interact/src/multisig_interact_nfts.rs @@ -52,7 +52,6 @@ impl MultisigInteract { .argument(&0u32), ) .returns(ReturnsResult) - .prepare_async() .run() .await; @@ -77,7 +76,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(); @@ -105,7 +103,6 @@ impl MultisigInteract { .argument(&COLLECTION_TICKER), ) .returns(ReturnsResult) - .prepare_async() .run() .await; @@ -130,7 +127,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; @@ -160,7 +156,6 @@ impl MultisigInteract { .argument(&"ESDTRoleNFTCreate"), ) .returns(ReturnsResult) - .prepare_async() .run() .await; diff --git a/contracts/multisig/interact/src/multisig_interact_wegld.rs b/contracts/multisig/interact/src/multisig_interact_wegld.rs index f7bc215a..08ebf6e0 100644 --- a/contracts/multisig/interact/src/multisig_interact_wegld.rs +++ b/contracts/multisig/interact/src/multisig_interact_wegld.rs @@ -62,7 +62,6 @@ impl MultisigInteract { function_call, ) .returns(ReturnsResult) - .prepare_async() .run() .await; @@ -78,7 +77,6 @@ impl MultisigInteract { .typed(wegld_proxy::EgldEsdtSwapProxy) .wrapped_egld_token_id() .returns(ReturnsResult) - .prepare_async() .run() .await; @@ -115,7 +113,6 @@ impl MultisigInteract { normalized_data, ) .returns(ReturnsResult) - .prepare_async() .run() .await; diff --git a/contracts/multisig/tests/multisig_scenario_rs_test.rs b/contracts/multisig/tests/multisig_scenario_rs_test.rs index 603b53ea..827026a6 100644 --- a/contracts/multisig/tests/multisig_scenario_rs_test.rs +++ b/contracts/multisig/tests/multisig_scenario_rs_test.rs @@ -5,6 +5,7 @@ const WEGLD_SWAP_EXPR: &str = "0x0061736d0100000001661160000060017f0060027f7f017 fn world() -> ScenarioWorld { let mut blockchain = ScenarioWorld::new(); + blockchain.set_current_dir_from_workspace("contracts/multisig"); blockchain.register_partial_contract::( "file:output/multisig.wasm", multisig::ContractBuilder, diff --git a/contracts/paymaster/interactor/Cargo.toml b/contracts/paymaster/interactor/Cargo.toml index 4c593f64..7d9093a5 100644 --- a/contracts/paymaster/interactor/Cargo.toml +++ b/contracts/paymaster/interactor/Cargo.toml @@ -28,3 +28,6 @@ features = ["derive"] [dependencies.serde] version = "1.0" features = ["derive"] + +[features] +chain-simulator-tests = [] diff --git a/contracts/paymaster/interactor/config.toml b/contracts/paymaster/interactor/config.toml index 0e212a6c..95d7ffd0 100644 --- a/contracts/paymaster/interactor/config.toml +++ b/contracts/paymaster/interactor/config.toml @@ -1,4 +1,5 @@ -gateway = 'https://devnet-gateway.multiversx.com' +chain_type = 'real' +gateway_uri = 'https://devnet-gateway.multiversx.com' relayer_addr = "erd19azy5vlq343un82cqz03744vmta9ya8l5xwj3ywz7r8m8pkttd0syhkffa" egld_mex_pair_address = "erd1qqqqqqqqqqqqqpgqzw0d0tj25qme9e4ukverjjjqle6xamay0n4s5r0v9g" diff --git a/contracts/paymaster/interactor/src/interactor_main.rs b/contracts/paymaster/interactor/src/interactor_main.rs index c32d4b34..9aa0fe7e 100644 --- a/contracts/paymaster/interactor/src/interactor_main.rs +++ b/contracts/paymaster/interactor/src/interactor_main.rs @@ -4,7 +4,6 @@ mod paymaster_config; mod proxy; use multiversx_sc_snippets::imports::*; -use multiversx_sc_snippets::sdk; use paymaster_config::Config; use serde::{Deserialize, Serialize}; use std::{ @@ -12,7 +11,6 @@ use std::{ path::Path, }; -const GATEWAY: &str = sdk::gateway::DEVNET_GATEWAY; const STATE_FILE: &str = "state.toml"; const ONE_UNIT: u64 = 1_000_000_000_000_000_000; @@ -92,9 +90,13 @@ struct ContractInteract { impl ContractInteract { async fn new() -> Self { - let mut interactor = Interactor::new(GATEWAY).await; - let wallet_address = interactor.register_wallet(test_wallets::alice()); + let config = Config::load_config(); + let mut interactor = Interactor::new(config.gateway_uri()) + .await + .use_chain_simulator(config.use_chain_simulator()); + let wallet_address = interactor.register_wallet(test_wallets::alice()).await; + interactor.set_current_dir_from_workspace("contracts/paymaster/interactor"); let contract_code = BytesValue::interpret_from( "mxsc:../output/paymaster.mxsc.json", &InterpreterContext::default(), @@ -119,7 +121,6 @@ impl ContractInteract { .init() .code(&self.contract_code) .returns(ReturnsNewAddress) - .prepare_async() .run() .await; let new_address_bech32 = bech32::encode(&new_address); @@ -171,7 +172,6 @@ impl ContractInteract { ) .payment(payments) .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; diff --git a/contracts/paymaster/interactor/src/paymaster_config.rs b/contracts/paymaster/interactor/src/paymaster_config.rs index 02371b7a..43f83ed0 100644 --- a/contracts/paymaster/interactor/src/paymaster_config.rs +++ b/contracts/paymaster/interactor/src/paymaster_config.rs @@ -5,9 +5,18 @@ use std::io::Read; /// Config file const CONFIG_FILE: &str = "config.toml"; -/// Multisig Interact configuration +#[derive(Debug, Deserialize)] +#[serde(rename_all = "lowercase")] +pub enum ChainType { + Real, + Simulator, +} + +/// Paymaster Interact configuration #[derive(Debug, Deserialize)] pub struct Config { + pub gateway_uri: String, + pub chain_type: ChainType, pub relayer_addr: Bech32Address, pub egld_mex_pair_address: Bech32Address, } @@ -20,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, + } + } } diff --git a/contracts/paymaster/interactor/state.toml b/contracts/paymaster/interactor/state.toml index a413fe02..56e32190 100644 --- a/contracts/paymaster/interactor/state.toml +++ b/contracts/paymaster/interactor/state.toml @@ -1 +1 @@ -contract_address = "erd1qqqqqqqqqqqqqpgqgr7585knhje7ns7w662pptwtjc03hn34d8sspl0nd4" +contract_address = "erd1qqqqqqqqqqqqqpgqxl7k7weu3przhkkccdqskkjq2kjqsjwkd8sshcly0k" diff --git a/contracts/paymaster/tests/paymaster_blackbox_test.rs b/contracts/paymaster/tests/paymaster_blackbox_test.rs index 9736b508..c1f7f79d 100644 --- a/contracts/paymaster/tests/paymaster_blackbox_test.rs +++ b/contracts/paymaster/tests/paymaster_blackbox_test.rs @@ -1,21 +1,21 @@ use adder::adder_proxy; use imports::{ - EgldOrEsdtTokenIdentifier, EsdtTokenPayment, MultiEsdtPayment, MxscPath, TestAddress, - TestSCAddress, TestTokenIdentifier, TokenIdentifier, + EgldOrEsdtTokenIdentifier, MxscPath, TestAddress, TestEsdtTransfer, TestSCAddress, + TestTokenIdentifier, }; use multiversx_sc::{ codec::{multi_types::MultiValueVec, top_encode_to_vec_u8_or_panic}, types::{BigUint, MultiValueEncoded}, }; -use multiversx_sc_scenario::{api::StaticApi, *}; +use multiversx_sc_scenario::*; use multiversx_wegld_swap_sc::wegld_proxy; use paymaster::paymaster_proxy; const PAYMASTER_ADDRESS_EXPR: TestSCAddress = TestSCAddress::new("paymaster"); const RELAYER_ADDRESS_EXPR: TestAddress = TestAddress::new("relayer"); const CALLEE_SC_ADDER_ADDRESS_EXPR: TestSCAddress = TestSCAddress::new("adder"); -const CALLEE_SC_WEGLD_ADDRESS_EXPR: TestSCAddress = TestSCAddress::new("sc:wegld"); -const PAYMASTER_PATH_EXPR: MxscPath = MxscPath::new("../output/paymaster.mxsc.json"); +const CALLEE_SC_WEGLD_ADDRESS_EXPR: TestSCAddress = TestSCAddress::new("wegld"); +const PAYMASTER_PATH_EXPR: MxscPath = MxscPath::new("output/paymaster.mxsc.json"); const ADDER_PATH_EXPR: MxscPath = MxscPath::new("../adder/output/adder.mxsc.json"); const WEGLD_PATH_EXPR: MxscPath = MxscPath::new("../wegld-swap/output/multiversx-wegld-swap-sc.mxsc.json"); @@ -25,7 +25,6 @@ const OWNER_ADDRESS_EXPR: TestAddress = TestAddress::new("owner"); const BALANCE: u64 = 100_000_000; const PAYMASTER_TOKEN_ID_EXPR: TestTokenIdentifier = TestTokenIdentifier::new("PAYMSTR-123456"); const WEGLD_TOKEN_ID_EXPR: TestTokenIdentifier = TestTokenIdentifier::new("WEGLD-123456"); -const WEGLD_TOKEN_ID: &[u8] = b"WEGLD-123456"; const FEE_TOKEN_ID_EXPR: TestTokenIdentifier = TestTokenIdentifier::new("FEE-123456"); const ADDITIONAL_TOKEN_ID_EXPR: TestTokenIdentifier = TestTokenIdentifier::new("ADDIT-123456"); const FEE_AMOUNT: u64 = 20_000; @@ -36,6 +35,7 @@ const UNWRAP_ENDPOINT_NAME: &[u8] = b"unwrap"; fn world() -> ScenarioWorld { let mut blockchain = ScenarioWorld::new(); + blockchain.set_current_dir_from_workspace("contracts/paymaster"); blockchain.register_contract(PAYMASTER_PATH_EXPR, paymaster::ContractBuilder); blockchain.register_contract(ADDER_PATH_EXPR, adder::ContractBuilder); blockchain.register_contract(WEGLD_PATH_EXPR, multiversx_wegld_swap_sc::ContractBuilder); @@ -110,7 +110,7 @@ impl PaymasterTestState { .tx() .from(OWNER_ADDRESS_EXPR) .typed(wegld_proxy::EgldEsdtSwapProxy) - .init(WEGLD_TOKEN_ID) + .init(WEGLD_TOKEN_ID_EXPR) .code(WEGLD_PATH_EXPR) .new_address(CALLEE_SC_WEGLD_ADDRESS_EXPR) .run(); @@ -221,11 +221,7 @@ fn test_forward_call_sc_adder() { b"add", MultiValueVec::from([top_encode_to_vec_u8_or_panic(&ADDITIONAL_ADD_VALUE)]), ) - .single_esdt( - &TokenIdentifier::from(FEE_TOKEN_ID_EXPR), - 0, - &BigUint::from(FEE_AMOUNT), - ) + .esdt(TestEsdtTransfer(FEE_TOKEN_ID_EXPR, 0, FEE_AMOUNT)) .run(); let expected_adder_sum = INITIAL_ADD_VALUE + ADDITIONAL_ADD_VALUE; @@ -263,11 +259,7 @@ fn test_forward_call_sc_adder_with_relayer_address() { b"add", MultiValueVec::from([top_encode_to_vec_u8_or_panic(&ADDITIONAL_ADD_VALUE)]), ) - .single_esdt( - &TokenIdentifier::from(FEE_TOKEN_ID_EXPR), - 0, - &BigUint::from(FEE_AMOUNT), - ) + .esdt(TestEsdtTransfer(FEE_TOKEN_ID_EXPR, 0, FEE_AMOUNT)) .run(); let expected_adder_sum = INITIAL_ADD_VALUE + ADDITIONAL_ADD_VALUE; @@ -292,17 +284,9 @@ fn test_forward_call_wegld() { state.check_esdt_balance(CALLER_ADDRESS_EXPR, FEE_TOKEN_ID_EXPR, BALANCE); state.check_esdt_balance(CALLER_ADDRESS_EXPR, WEGLD_TOKEN_ID_EXPR, BALANCE); - let mut payments: MultiEsdtPayment = MultiEsdtPayment::new(); - payments.push(EsdtTokenPayment::new( - TokenIdentifier::from(FEE_TOKEN_ID_EXPR), - 0, - BigUint::from(FEE_AMOUNT), - )); - payments.push(EsdtTokenPayment::new( - TokenIdentifier::from(WEGLD_TOKEN_ID_EXPR), - 0, - BigUint::from(FEE_AMOUNT), - )); + let mut payments = Vec::new(); + payments.push(TestEsdtTransfer(FEE_TOKEN_ID_EXPR, 0, FEE_AMOUNT)); + payments.push(TestEsdtTransfer(WEGLD_TOKEN_ID_EXPR, 0, FEE_AMOUNT)); // Call fails because unwrap amount is 0 state @@ -341,17 +325,9 @@ fn test_forward_call_fails_wegld_0_amount() { let failling_amount = 0u64; - let mut payments: MultiEsdtPayment = MultiEsdtPayment::new(); - payments.push(EsdtTokenPayment::new( - TokenIdentifier::from(FEE_TOKEN_ID_EXPR), - 0, - BigUint::from(FEE_AMOUNT), - )); - payments.push(EsdtTokenPayment::new( - TokenIdentifier::from(WEGLD_TOKEN_ID_EXPR), - 0, - BigUint::from(failling_amount), - )); + let mut payments = Vec::new(); + payments.push(TestEsdtTransfer(FEE_TOKEN_ID_EXPR, 0, FEE_AMOUNT)); + payments.push(TestEsdtTransfer(WEGLD_TOKEN_ID_EXPR, 0, failling_amount)); // Call fails because unwrap amount is 0 state @@ -388,19 +364,11 @@ fn test_forward_call_fails_check_amounts() { state.check_esdt_balance(CALLER_ADDRESS_EXPR, FEE_TOKEN_ID_EXPR, BALANCE); state.check_esdt_balance(CALLER_ADDRESS_EXPR, WEGLD_TOKEN_ID_EXPR, BALANCE); - let mut payments: MultiEsdtPayment = MultiEsdtPayment::new(); - payments.push(EsdtTokenPayment::new( - TokenIdentifier::from(FEE_TOKEN_ID_EXPR), - 0, - BigUint::from(FEE_AMOUNT), - )); + let mut payments = Vec::new(); + payments.push(TestEsdtTransfer(FEE_TOKEN_ID_EXPR, 0, FEE_AMOUNT)); let sent_amount = 1_000u64; - payments.push(EsdtTokenPayment::new( - TokenIdentifier::from(WEGLD_TOKEN_ID), - 0, - BigUint::from(sent_amount), - )); + payments.push(TestEsdtTransfer(WEGLD_TOKEN_ID_EXPR, 0, sent_amount)); state .world diff --git a/contracts/paymaster/wasm/Cargo.lock b/contracts/paymaster/wasm/Cargo.lock index b297ea9e..36725678 100644 --- a/contracts/paymaster/wasm/Cargo.lock +++ b/contracts/paymaster/wasm/Cargo.lock @@ -38,14 +38,25 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "multiversx-chain-core" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" +dependencies = [ + "bitflags", + "multiversx-sc-codec", +] + [[package]] name = "multiversx-sc" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -54,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -65,9 +76,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -77,9 +88,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -90,9 +101,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/paymaster/wasm/Cargo.toml b/contracts/paymaster/wasm/Cargo.toml index a779d741..1072e245 100644 --- a/contracts/paymaster/wasm/Cargo.toml +++ b/contracts/paymaster/wasm/Cargo.toml @@ -1,3 +1,9 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "paymaster-wasm" version = "0.0.0" From d5e0165a151d3f06e8e2ee43ad0770c85eac920c Mon Sep 17 00:00:00 2001 From: BiancaIalangi Date: Thu, 21 Nov 2024 13:03:23 +0200 Subject: [PATCH 08/13] 0.54 upgrade - adder --- .../adder/interact/src/basic_interact.rs | 262 ------------------ .../adder/interact/src/basic_interact_main.rs | 6 - .../adder/{interact => interactor}/.gitignore | 3 - .../adder/{interact => interactor}/Cargo.toml | 26 +- .../{interact => interactor}/config.toml | 0 .../adder/interactor/src/basic_interactor.rs | 137 +++++++++ .../src/basic_interactor_cli.rs} | 16 +- .../src/basic_interactor_config.rs} | 0 .../interactor/src/basic_interactor_main.rs | 6 + .../src/basic_interactor_state.rs} | 2 +- .../tests/basic_interactor_cs_test.rs} | 16 +- contracts/adder/mxsc-template.toml | 9 +- 12 files changed, 175 insertions(+), 308 deletions(-) delete mode 100644 contracts/adder/interact/src/basic_interact.rs delete mode 100644 contracts/adder/interact/src/basic_interact_main.rs rename contracts/adder/{interact => interactor}/.gitignore (74%) rename contracts/adder/{interact => interactor}/Cargo.toml (68%) rename contracts/adder/{interact => interactor}/config.toml (100%) create mode 100644 contracts/adder/interactor/src/basic_interactor.rs rename contracts/adder/{interact/src/basic_interact_cli.rs => interactor/src/basic_interactor_cli.rs} (79%) rename contracts/adder/{interact/src/basic_interact_config.rs => interactor/src/basic_interactor_config.rs} (100%) create mode 100644 contracts/adder/interactor/src/basic_interactor_main.rs rename contracts/adder/{interact/src/basic_interact_state.rs => interactor/src/basic_interactor_state.rs} (97%) rename contracts/adder/{interact/tests/basic_interact_cs_test.rs => interactor/tests/basic_interactor_cs_test.rs} (56%) diff --git a/contracts/adder/interact/src/basic_interact.rs b/contracts/adder/interact/src/basic_interact.rs deleted file mode 100644 index ccfd0999..00000000 --- a/contracts/adder/interact/src/basic_interact.rs +++ /dev/null @@ -1,262 +0,0 @@ -mod basic_interact_cli; -mod basic_interact_config; -mod basic_interact_state; - -use crate::basic_interact_state::State; -use adder::adder_proxy; -pub use basic_interact_config::Config; -use clap::Parser; - -use multiversx_sc_snippets::imports::*; - -const INTERACTOR_SCENARIO_TRACE_PATH: &str = "interactor_trace.scen.json"; - -const ADDER_CODE_PATH: MxscPath = MxscPath::new("../output/adder.mxsc.json"); - -pub async fn adder_cli() { - env_logger::init(); - - let config = Config::load_config(); - - let mut basic_interact = AdderInteract::init(config).await; - - let cli = basic_interact_cli::InteractCli::parse(); - match &cli.command { - Some(basic_interact_cli::InteractCliCommand::Add(args)) => { - if args.count == 1 { - basic_interact.add(args.value).await; - } else { - basic_interact.multi_add(args.value, args.count).await; - } - } - Some(basic_interact_cli::InteractCliCommand::Deploy) => { - basic_interact.deploy().await; - } - Some(basic_interact_cli::InteractCliCommand::Feed) => { - basic_interact.feed_contract_egld().await; - } - Some(basic_interact_cli::InteractCliCommand::MultiDeploy(args)) => { - basic_interact.multi_deploy(args.count).await; - } - Some(basic_interact_cli::InteractCliCommand::Sum) => { - let sum = basic_interact.get_sum().await; - println!("sum: {sum}"); - } - Some(basic_interact_cli::InteractCliCommand::Upgrade(args)) => { - let owner_address = basic_interact.adder_owner_address.clone(); - basic_interact - .upgrade(args.value, &owner_address, None) - .await - } - None => {} - } -} - -#[allow(unused)] -pub struct AdderInteract { - pub interactor: Interactor, - pub adder_owner_address: Bech32Address, - pub wallet_address: Bech32Address, - pub state: State, -} - -impl AdderInteract { - pub async fn init(config: Config) -> Self { - let mut interactor = Interactor::new(config.gateway_uri(), config.use_chain_simulator()) - .await - .with_tracer(INTERACTOR_SCENARIO_TRACE_PATH) - .await; - - interactor.set_current_dir_from_workspace("contracts/adder/interact"); - - let adder_owner_address = interactor.register_wallet(test_wallets::alice()).await; - let wallet_address = interactor.register_wallet(test_wallets::frank()).await; - - // generate blocks until ESDTSystemSCAddress is enabled - interactor.generate_blocks_until_epoch(1).await.unwrap(); - - Self { - interactor, - adder_owner_address: adder_owner_address.into(), - wallet_address: wallet_address.into(), - state: State::load_state(), - } - } - - pub async fn set_state(&mut self) { - println!("wallet address: {}", self.wallet_address); - self.interactor - .retrieve_account(&self.adder_owner_address) - .await; - self.interactor.retrieve_account(&self.wallet_address).await; - } - - pub async fn deploy(&mut self) { - // warning: multi deploy not yet fully supported - // only works with last deployed address - - self.set_state().await; - - let new_address = self - .interactor - .tx() - .from(&self.adder_owner_address) - .gas(6_000_000) - .typed(adder_proxy::AdderProxy) - .init(0u32) - .code(ADDER_CODE_PATH) - .code_metadata(CodeMetadata::UPGRADEABLE) - .returns(ReturnsNewBech32Address) - .run() - .await; - - println!("new address: {new_address}"); - self.state.set_adder_address(new_address); - } - - pub async fn multi_deploy(&mut self, count: usize) { - if count == 0 { - println!("count must be greater than 0"); - return; - } - - self.set_state().await; - println!("deploying {count} contracts..."); - - let mut buffer = self.interactor.homogenous_call_buffer(); - for _ in 0..count { - buffer.push_tx(|tx| { - tx.from(&self.wallet_address) - .typed(adder_proxy::AdderProxy) - .init(0u32) - .code(ADDER_CODE_PATH) - .gas(6_000_000) - .returns(ReturnsNewBech32Address) - }); - } - - let results = buffer.run().await; - - // warning: multi deploy not yet fully supported - // only works with last deployed address - - for new_address in results { - println!("new address: {new_address}"); - - self.state.set_adder_address(new_address); - } - } - - pub async fn multi_add(&mut self, value: u32, count: usize) { - self.set_state().await; - println!("calling contract {count} times..."); - - let mut buffer = self.interactor.homogenous_call_buffer(); - for _ in 0..count { - buffer.push_tx(|tx| { - tx.from(&self.wallet_address) - .to(self.state.current_adder_address()) - .typed(adder_proxy::AdderProxy) - .add(value) - .returns(ReturnsGasUsed) - .gas(6_000_000) - }); - } - - let gas_used = buffer.run().await; - let gas_used_sum = gas_used.iter().sum::(); - - println!( - "successfully performed add {count} times, total gas used: {}, avg gas used: {}", - gas_used_sum, - gas_used_sum / count as u64 - ); - } - - pub async fn feed_contract_egld(&mut self) { - self.interactor - .tx() - .from(&self.wallet_address) - .to(self.state.current_adder_address()) - .egld(NumExpr("0,050000000000000000")) - .run() - .await; - } - - pub async fn add(&mut self, value: u32) { - self.interactor - .tx() - .from(&self.wallet_address) - .to(self.state.current_adder_address()) - .gas(6_000_000) - .typed(adder_proxy::AdderProxy) - .add(value) - .run() - .await; - - println!("successfully performed add"); - } - - pub async fn get_sum(&mut self) -> RustBigUint { - self.interactor - .query() - .to(self.state.current_adder_address()) - .typed(adder_proxy::AdderProxy) - .sum() - .returns(ReturnsResultUnmanaged) - .run() - .await - } - - pub async fn upgrade( - &mut self, - new_value: u32, - sender: &Bech32Address, - expected_result: Option<(u64, &str)>, - ) { - match expected_result { - Some((code, msg)) => { - let response = self - .interactor - .tx() - .from(sender) - .to(self.state.current_adder_address()) - .gas(6_000_000) - .typed(adder_proxy::AdderProxy) - .upgrade(new_value) - .code_metadata(CodeMetadata::UPGRADEABLE) - .code(ADDER_CODE_PATH) - .returns(ExpectError(code, msg)) - .run() - .await; - - println!("response: {response:?}"); - } - None => { - self.interactor - .tx() - .from(sender) - .to(self.state.current_adder_address()) - .gas(6_000_000) - .typed(adder_proxy::AdderProxy) - .upgrade(new_value) - .code_metadata(CodeMetadata::UPGRADEABLE) - .code(ADDER_CODE_PATH) - .run() - .await; - - let sum = self - .interactor - .query() - .to(self.state.current_adder_address()) - .typed(adder_proxy::AdderProxy) - .sum() - .returns(ReturnsResultUnmanaged) - .run() - .await; - - assert_eq!(sum, RustBigUint::from(new_value)); - } - } - } -} diff --git a/contracts/adder/interact/src/basic_interact_main.rs b/contracts/adder/interact/src/basic_interact_main.rs deleted file mode 100644 index 352cdc8e..00000000 --- a/contracts/adder/interact/src/basic_interact_main.rs +++ /dev/null @@ -1,6 +0,0 @@ -extern crate basic_interact; - -#[tokio::main] -pub async fn main() { - basic_interact::adder_cli().await; -} diff --git a/contracts/adder/interact/.gitignore b/contracts/adder/interactor/.gitignore similarity index 74% rename from contracts/adder/interact/.gitignore rename to contracts/adder/interactor/.gitignore index ea1b9200..88af50ac 100644 --- a/contracts/adder/interact/.gitignore +++ b/contracts/adder/interactor/.gitignore @@ -3,6 +3,3 @@ # Temporary storage of deployed contract address, so we can preserve the context between executions. state.toml - -# Trace file of interactor tooling -interactor_trace.scen.json diff --git a/contracts/adder/interact/Cargo.toml b/contracts/adder/interactor/Cargo.toml similarity index 68% rename from contracts/adder/interact/Cargo.toml rename to contracts/adder/interactor/Cargo.toml index 191d284f..b48f0d7b 100644 --- a/contracts/adder/interact/Cargo.toml +++ b/contracts/adder/interactor/Cargo.toml @@ -1,22 +1,16 @@ -[[bin]] -name = "basic-interact" -path = "src/basic_interact_main.rs" - [package] -name = "basic-interact" +name = "basic-interactor" version = "0.0.0" -authors = ["Ovidiu Stinga "] +authors = ["MultiversX "] edition = "2021" publish = false -[lib] -path = "src/basic_interact.rs" +[[bin]] +name = "basic-interactor" +path = "src/basic_interactor_main.rs" -[dependencies] -clap = { version = "4.4.7", features = ["derive"] } -serde = { version = "1.0", features = ["derive"] } -toml = "0.8.6" -tokio = { version = "1.24" } +[lib] +path = "src/basic_interactor.rs" [dependencies.adder] path = ".." @@ -24,5 +18,11 @@ path = ".." [dependencies.multiversx-sc-snippets] version = "0.54.3" +[dependencies] +clap = { version = "4.4.7", features = ["derive"] } +serde = { version = "1.0", features = ["derive"] } +toml = "0.8.6" +tokio = { version = "1.24" } + [features] chain-simulator-tests = [] diff --git a/contracts/adder/interact/config.toml b/contracts/adder/interactor/config.toml similarity index 100% rename from contracts/adder/interact/config.toml rename to contracts/adder/interactor/config.toml diff --git a/contracts/adder/interactor/src/basic_interactor.rs b/contracts/adder/interactor/src/basic_interactor.rs new file mode 100644 index 00000000..9c8579f0 --- /dev/null +++ b/contracts/adder/interactor/src/basic_interactor.rs @@ -0,0 +1,137 @@ +mod basic_interactor_cli; +mod basic_interactor_config; +mod basic_interactor_state; + +use adder::adder_proxy; +pub use basic_interactor_config::Config; +use basic_interactor_state::State; +use clap::Parser; + +use multiversx_sc_snippets::imports::*; + +const ADDER_CODE_PATH: MxscPath = MxscPath::new("../output/adder.mxsc.json"); + +pub async fn adder_cli() { + env_logger::init(); + + let config = Config::load_config(); + + let mut basic_interact = AdderInteract::new(config).await; + + let cli = basic_interactor_cli::InteractCli::parse(); + match &cli.command { + Some(basic_interactor_cli::InteractCliCommand::Deploy) => { + basic_interact.deploy().await; + }, + Some(basic_interactor_cli::InteractCliCommand::Upgrade(args)) => { + let owner_address = basic_interact.adder_owner_address.clone(); + basic_interact + .upgrade(args.value, &owner_address, None) + .await + }, + Some(basic_interactor_cli::InteractCliCommand::Add(args)) => { + basic_interact.add(args.value).await; + }, + Some(basic_interactor_cli::InteractCliCommand::Sum) => { + let sum = basic_interact.get_sum().await; + println!("sum: {sum}"); + }, + None => {}, + } +} + +pub struct AdderInteract { + pub interactor: Interactor, + pub adder_owner_address: Bech32Address, + pub wallet_address: Bech32Address, + pub state: State, +} + +impl AdderInteract { + pub async fn new(config: Config) -> Self { + let mut interactor = Interactor::new(config.gateway_uri()) + .await + .use_chain_simulator(config.use_chain_simulator()); + interactor.set_current_dir_from_workspace("contracts/adder/interactor"); + + let adder_owner_address = interactor.register_wallet(test_wallets::heidi()).await; + let wallet_address = interactor.register_wallet(test_wallets::ivan()).await; + + interactor.generate_blocks_until_epoch(1).await.unwrap(); + + AdderInteract { + interactor, + adder_owner_address: adder_owner_address.into(), + wallet_address: wallet_address.into(), + state: State::load_state(), + } + } + + pub async fn deploy(&mut self) { + let new_address = self + .interactor + .tx() + .from(&self.adder_owner_address.clone()) + .gas(6_000_000) + .typed(adder_proxy::AdderProxy) + .init(0u64) + .code(ADDER_CODE_PATH) + .returns(ReturnsNewBech32Address) + .run() + .await; + + println!("new address: {new_address}"); + self.state.set_adder_address(new_address); + } + + pub async fn upgrade(&mut self, new_value: u32, sender: &Bech32Address, err: Option<&str>) { + let response = self + .interactor + .tx() + .from(sender) + .to(self.state.current_adder_address()) + .gas(6_000_000) + .typed(adder_proxy::AdderProxy) + .upgrade(new_value) + .code(ADDER_CODE_PATH) + .code_metadata(CodeMetadata::UPGRADEABLE) + .returns(ReturnsHandledOrError::new()) + .run() + .await; + + match response { + Ok(_) => { + println!("Contract successfully upgraded."); + }, + Err(tx_err) => { + println!("Contract failed upgrade with error: {}", tx_err.message); + assert_eq!(tx_err.message, err.unwrap_or_default()); + }, + } + } + + pub async fn add(&mut self, value: u32) { + self.interactor + .tx() + .from(&self.wallet_address) + .to(self.state.current_adder_address()) + .gas(6_000_000u64) + .typed(adder_proxy::AdderProxy) + .add(value) + .run() + .await; + + println!("Successfully performed add"); + } + + pub async fn get_sum(&mut self) -> RustBigUint { + self.interactor + .query() + .to(self.state.current_adder_address()) + .typed(adder_proxy::AdderProxy) + .sum() + .returns(ReturnsResultUnmanaged) + .run() + .await + } +} diff --git a/contracts/adder/interact/src/basic_interact_cli.rs b/contracts/adder/interactor/src/basic_interactor_cli.rs similarity index 79% rename from contracts/adder/interact/src/basic_interact_cli.rs rename to contracts/adder/interactor/src/basic_interactor_cli.rs index 67669818..3a4a98e5 100644 --- a/contracts/adder/interact/src/basic_interact_cli.rs +++ b/contracts/adder/interactor/src/basic_interactor_cli.rs @@ -12,18 +12,14 @@ pub struct InteractCli { /// Adder Interact CLI Commands #[derive(Clone, PartialEq, Eq, Debug, Subcommand)] pub enum InteractCliCommand { - #[command(name = "add", about = "Add value")] - Add(AddArgs), #[command(name = "deploy", about = "Deploy contract")] Deploy, - #[command(name = "feed", about = "Feed contract EGLD")] - Feed, - #[command(name = "multi-deploy", about = "Multiple deploy contracts")] - MultiDeploy(MultiDeployArgs), - #[command(name = "sum", about = "Print sum")] - Sum, #[command(name = "upgrade", about = "Upgrade contract")] Upgrade(UpgradeArgs), + #[command(name = "sum", about = "Print sum")] + Sum, + #[command(name = "add", about = "Add value")] + Add(AddArgs), } #[derive(Default, Clone, PartialEq, Eq, Debug, Args)] @@ -31,10 +27,6 @@ pub struct AddArgs { /// The value to add #[arg(short = 'v', long = "value")] pub value: u32, - - /// Repeat this number of times - #[arg(short = 'c', long = "count", default_value = "1")] - pub count: usize, } #[derive(Default, Clone, PartialEq, Eq, Debug, Args)] diff --git a/contracts/adder/interact/src/basic_interact_config.rs b/contracts/adder/interactor/src/basic_interactor_config.rs similarity index 100% rename from contracts/adder/interact/src/basic_interact_config.rs rename to contracts/adder/interactor/src/basic_interactor_config.rs diff --git a/contracts/adder/interactor/src/basic_interactor_main.rs b/contracts/adder/interactor/src/basic_interactor_main.rs new file mode 100644 index 00000000..72c82913 --- /dev/null +++ b/contracts/adder/interactor/src/basic_interactor_main.rs @@ -0,0 +1,6 @@ +extern crate basic_interactor; + +#[tokio::main] +pub async fn main() { + basic_interactor::adder_cli().await; +} diff --git a/contracts/adder/interact/src/basic_interact_state.rs b/contracts/adder/interactor/src/basic_interactor_state.rs similarity index 97% rename from contracts/adder/interact/src/basic_interact_state.rs rename to contracts/adder/interactor/src/basic_interactor_state.rs index 41453e36..bcab7741 100644 --- a/contracts/adder/interact/src/basic_interact_state.rs +++ b/contracts/adder/interactor/src/basic_interactor_state.rs @@ -8,7 +8,7 @@ use std::{ /// State file const STATE_FILE: &str = "state.toml"; -/// Multisig Interact state +/// Adder Interact state #[derive(Debug, Default, Serialize, Deserialize)] pub struct State { adder_address: Option, diff --git a/contracts/adder/interact/tests/basic_interact_cs_test.rs b/contracts/adder/interactor/tests/basic_interactor_cs_test.rs similarity index 56% rename from contracts/adder/interact/tests/basic_interact_cs_test.rs rename to contracts/adder/interactor/tests/basic_interactor_cs_test.rs index b7af7d35..1f07ee4c 100644 --- a/contracts/adder/interact/tests/basic_interact_cs_test.rs +++ b/contracts/adder/interactor/tests/basic_interactor_cs_test.rs @@ -1,12 +1,9 @@ -use basic_interact::{AdderInteract, Config}; +use basic_interactor::{AdderInteract, Config}; #[tokio::test] #[cfg_attr(not(feature = "chain-simulator-tests"), ignore)] async fn simulator_upgrade_test() { - let mut basic_interact = AdderInteract::init(Config::chain_simulator_config()).await; - let wallet_address = basic_interact.wallet_address.clone(); - let adder_owner_address = basic_interact.adder_owner_address.clone(); - let error_not_owner = (4, "upgrade is allowed only for owner"); + let mut basic_interact = AdderInteract::new(Config::chain_simulator_config()).await; basic_interact.deploy().await; basic_interact.add(1u32).await; @@ -16,15 +13,20 @@ async fn simulator_upgrade_test() { assert_eq!(sum, 1u32.into()); basic_interact - .upgrade(7u32, &adder_owner_address, None) + .upgrade(7u32, &basic_interact.adder_owner_address.clone(), None) .await; // Sum will be the updated value of 7 let sum = basic_interact.get_sum().await; assert_eq!(sum, 7u32.into()); + // Upgrade fails basic_interact - .upgrade(10u32, &wallet_address, Some(error_not_owner)) + .upgrade( + 10u32, + &basic_interact.wallet_address.clone(), + Some("upgrade is allowed only for owner"), + ) .await; // Sum will remain 7 diff --git a/contracts/adder/mxsc-template.toml b/contracts/adder/mxsc-template.toml index 490557cc..f6a6bb78 100644 --- a/contracts/adder/mxsc-template.toml +++ b/contracts/adder/mxsc-template.toml @@ -16,9 +16,10 @@ files_include = [ "README.md", "sc-config.toml", "multiversx.json", - "interact/Cargo.toml", - "interact/config.toml", - "interact/.gitignore", - "interact/src", + "interactor/Cargo.toml", + "interactor/config.toml", + "interactor/.gitignore", + "interactor/src", + "interactor/tests", ] has_interactor = true From a8277b01e5b063945143d13a8495a6eb9f8fa0e3 Mon Sep 17 00:00:00 2001 From: BiancaIalangi Date: Thu, 21 Nov 2024 13:05:06 +0200 Subject: [PATCH 09/13] 0.54 upgrade - rewards distribution --- ...t.rs => compute_brackets_whitebox_test.rs} | 52 +++++++++++-------- 1 file changed, 30 insertions(+), 22 deletions(-) rename contracts/rewards-distribution/tests/{test_compute_brackets_legacy_test.rs => compute_brackets_whitebox_test.rs} (52%) diff --git a/contracts/rewards-distribution/tests/test_compute_brackets_legacy_test.rs b/contracts/rewards-distribution/tests/compute_brackets_whitebox_test.rs similarity index 52% rename from contracts/rewards-distribution/tests/test_compute_brackets_legacy_test.rs rename to contracts/rewards-distribution/tests/compute_brackets_whitebox_test.rs index 9c4c7510..e5605513 100644 --- a/contracts/rewards-distribution/tests/test_compute_brackets_legacy_test.rs +++ b/contracts/rewards-distribution/tests/compute_brackets_whitebox_test.rs @@ -1,40 +1,49 @@ -#![allow(deprecated)] // TODO: migrate tests - use core::iter::zip; -use multiversx_sc_scenario::{rust_biguint, testing_framework::BlockchainStateWrapper, DebugApi}; -use rewards_distribution::{RewardsDistribution, DIVISION_SAFETY_CONSTANT}; +use multiversx_sc_scenario::{imports::MxscPath, DebugApi, ScenarioTxWhitebox, ScenarioWorld}; +use rewards_distribution::{Bracket, RewardsDistribution, DIVISION_SAFETY_CONSTANT}; + +const OWNER: TestAddress = TestAddress::new("owner"); +const REWARDS_DISTRIBUTION_ADDRESS: TestSCAddress = TestSCAddress::new("rewards_distribution"); +const CODE_PATH: MxscPath = MxscPath::new("output/rewards-distribution.mxsc.json"); mod utils; -#[allow(unused_imports)] use multiversx_sc::imports::*; -#[test] -fn test_compute_brackets() { - DebugApi::dummy(); +fn world() -> ScenarioWorld { + let mut blockchain: ScenarioWorld = ScenarioWorld::new(); - let mut wrapper = BlockchainStateWrapper::new(); + blockchain.set_current_dir_from_workspace("contracts/rewards-distribution"); + blockchain.register_contract(CODE_PATH, rewards_distribution::ContractBuilder); + blockchain +} - let owner = wrapper.create_user_account(&rust_biguint!(0u64)); +#[test] +fn test_compute_brackets() { + let mut world = world(); - let rewards_distribution_sc = wrapper.create_sc_account( - &rust_biguint!(0u64), - Some(&owner), - rewards_distribution::contract_obj, - "rewards-distribution.mxsc.json", - ); + world.account(OWNER).nonce(1); + world + .account(REWARDS_DISTRIBUTION_ADDRESS) + .nonce(1) + .owner(OWNER) + .code(CODE_PATH); - wrapper - .execute_tx(&owner, &rewards_distribution_sc, &rust_biguint!(0), |sc| { - let brackets = utils::to_brackets(&[ + world + .tx() + .from(OWNER) + .to(REWARDS_DISTRIBUTION_ADDRESS) + .whitebox(rewards_distribution::contract_obj, |sc| { + let brackets: ManagedVec = utils::to_brackets(&[ (10, 2_000), (90, 6_000), (400, 7_000), (2_500, 10_000), (25_000, 35_000), (72_000, 40_000), - ]); + ]) + .into(); let computed_brackets = sc.compute_brackets(brackets, 10_000); @@ -53,6 +62,5 @@ fn test_compute_brackets() { assert_eq!(computed.end_index, expected_end_index); assert_eq!(computed.nft_reward_percent, expected_reward_percent); } - }) - .assert_ok(); + }); } From 96b3ffec68c61df0ae9cb73dce08d31bdf7bace4 Mon Sep 17 00:00:00 2001 From: BiancaIalangi Date: Thu, 21 Nov 2024 13:06:34 +0200 Subject: [PATCH 10/13] ping-pong - framework alignment --- Cargo.lock | 15 +- Cargo.toml | 5 +- .../ping-pong-egld/interactor/.gitignore | 9 + .../ping-pong-egld/interactor/Cargo.toml | 31 ++ .../ping-pong-egld/interactor/config.toml | 5 + .../ping-pong-egld/interactor/src/interact.rs | 375 ++++++++++++++++++ .../interactor/src/interact_cli.rs | 81 ++++ .../interactor/src/interact_config.rs | 49 +++ .../interactor/src/interact_main.rs | 6 + .../interactor/src/interact_state.rs | 50 +++ .../interactor/src/proxy_ping_pong_egld.rs | 263 ++++++++++++ .../interactor/tests/interact_cs_test.rs | 138 +++++++ contracts/ping-pong-egld/src/ping_pong.rs | 89 ++++- contracts/ping-pong-egld/src/types.rs | 20 + contracts/ping-pong-egld/src/user_status.rs | 9 - .../tests/ping_pong_egld_scenario_rs_test.rs | 1 + contracts/ping-pong-egld/wasm/Cargo.lock | 31 +- contracts/ping-pong-egld/wasm/Cargo.toml | 6 + contracts/ping-pong-egld/wasm/src/lib.rs | 7 +- 19 files changed, 1150 insertions(+), 40 deletions(-) create mode 100644 contracts/ping-pong-egld/interactor/.gitignore create mode 100644 contracts/ping-pong-egld/interactor/Cargo.toml create mode 100644 contracts/ping-pong-egld/interactor/config.toml create mode 100644 contracts/ping-pong-egld/interactor/src/interact.rs create mode 100644 contracts/ping-pong-egld/interactor/src/interact_cli.rs create mode 100644 contracts/ping-pong-egld/interactor/src/interact_config.rs create mode 100644 contracts/ping-pong-egld/interactor/src/interact_main.rs create mode 100644 contracts/ping-pong-egld/interactor/src/interact_state.rs create mode 100644 contracts/ping-pong-egld/interactor/src/proxy_ping_pong_egld.rs create mode 100644 contracts/ping-pong-egld/interactor/tests/interact_cs_test.rs create mode 100644 contracts/ping-pong-egld/src/types.rs delete mode 100644 contracts/ping-pong-egld/src/user_status.rs diff --git a/Cargo.lock b/Cargo.lock index 28498c10..089fd037 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -160,7 +160,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] -name = "basic-interact" +name = "basic-interactor" version = "0.0.0" dependencies = [ "adder", @@ -1954,6 +1954,19 @@ dependencies = [ "multiversx-sc-scenario", ] +[[package]] +name = "ping-pong-egld-interact" +version = "0.0.0" +dependencies = [ + "clap", + "multiversx-sc", + "multiversx-sc-snippets", + "ping-pong-egld", + "serde", + "tokio", + "toml", +] + [[package]] name = "ping-pong-egld-meta" version = "0.0.0" diff --git a/Cargo.toml b/Cargo.toml index 5fb5dd18..630cc5d9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ members = [ "contracts/adder", "contracts/adder/meta", - "contracts/adder/interact", + "contracts/adder/interactor", "contracts/esdt-transfer-with-fee", "contracts/esdt-transfer-with-fee/meta", "contracts/bonding-curve-contract", @@ -70,6 +70,7 @@ members = [ "contracts/paymaster/interactor", "contracts/ping-pong-egld", "contracts/ping-pong-egld/meta", + "contracts/ping-pong-egld/interactor", "contracts/proxy-deployer", "contracts/proxy-deployer/meta", "contracts/proxy-pause", @@ -81,5 +82,5 @@ members = [ "contracts/token-release", "contracts/token-release/meta", "contracts/mvx-game-sc", - "contracts/mvx-game-sc/meta" + "contracts/mvx-game-sc/meta", ] diff --git a/contracts/ping-pong-egld/interactor/.gitignore b/contracts/ping-pong-egld/interactor/.gitignore new file mode 100644 index 00000000..ac5c74ec --- /dev/null +++ b/contracts/ping-pong-egld/interactor/.gitignore @@ -0,0 +1,9 @@ +# Pem files are used for interactions, but shouldn't be committed +*.pem +*.json + +# Temporary storage of deployed contract address, so we can preserve the context between executions. +state.toml + +# Trace file of interactor tooling +interactor_trace.scen.json diff --git a/contracts/ping-pong-egld/interactor/Cargo.toml b/contracts/ping-pong-egld/interactor/Cargo.toml new file mode 100644 index 00000000..beec9ed5 --- /dev/null +++ b/contracts/ping-pong-egld/interactor/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "ping-pong-egld-interact" +version = "0.0.0" +authors = ["MultiversX "] +edition = "2021" +publish = false + +[[bin]] +name = "ping-pong-egld-interact" +path = "src/interact_main.rs" + +[lib] +path = "src/interact.rs" + +[dependencies] +clap = { version = "4.4.7", features = ["derive"] } +serde = { version = "1.0", features = ["derive"] } +toml = "0.8.6" +tokio = { version = "1.24" } + +[dependencies.ping-pong-egld] +path = ".." + +[dependencies.multiversx-sc-snippets] +version = "0.54.3" + +[dependencies.multiversx-sc] +version = "0.54.3" + +[features] +chain-simulator-tests = [] diff --git a/contracts/ping-pong-egld/interactor/config.toml b/contracts/ping-pong-egld/interactor/config.toml new file mode 100644 index 00000000..aca74870 --- /dev/null +++ b/contracts/ping-pong-egld/interactor/config.toml @@ -0,0 +1,5 @@ +chain_type = 'simulator' +gateway_uri = 'http://localhost:8085' + +# chain_type = 'real' +# gateway_uri = 'https://devnet-gateway.multiversx.com' diff --git a/contracts/ping-pong-egld/interactor/src/interact.rs b/contracts/ping-pong-egld/interactor/src/interact.rs new file mode 100644 index 00000000..4ba9f501 --- /dev/null +++ b/contracts/ping-pong-egld/interactor/src/interact.rs @@ -0,0 +1,375 @@ +mod interact_cli; +mod interact_config; +mod interact_state; +mod proxy_ping_pong_egld; + +use crate::interact_state::State; +use clap::Parser; +pub use interact_config::Config; + +use multiversx_sc_snippets::imports::*; +use proxy_ping_pong_egld::{ContractState, UserStatus}; + +const INTERACTOR_SCENARIO_TRACE_PATH: &str = "interactor_trace.scen.json"; + +const PING_PONG_CODE: MxscPath = MxscPath::new("../output/ping-pong-egld.mxsc.json"); + +pub async fn ping_pong_egld_cli() { + env_logger::init(); + + let config = Config::load_config(); + + let mut interact = PingPongEgldInteract::init(config).await; + + let cli = interact_cli::InteractCli::parse(); + match &cli.command { + Some(interact_cli::InteractCliCommand::Deploy(args)) => { + interact + .deploy( + args.ping_amount.clone(), + args.duration_in_seconds, + args.opt_activation_timestamp, + OptionalValue::from(args.max_funds.clone()), + ) + .await; + } + Some(interact_cli::InteractCliCommand::Upgrade(args)) => { + interact + .upgrade( + args.ping_amount.clone(), + args.duration_in_seconds, + args.opt_activation_timestamp, + OptionalValue::from(args.max_funds.clone()), + ) + .await + } + Some(interact_cli::InteractCliCommand::Ping(args)) => { + let sender = interact.ping_pong_owner_address.clone(); + interact + .ping(args.cost.unwrap_or_default(), None, &sender) + .await + } + Some(interact_cli::InteractCliCommand::Pong) => { + let sender = interact.ping_pong_owner_address.clone(); + interact.pong(None, &sender).await; + } + Some(interact_cli::InteractCliCommand::PongAll) => { + let sender = interact.ping_pong_owner_address.clone(); + interact.pong_all(None, &sender).await; + } + Some(interact_cli::InteractCliCommand::GetUserAddresses) => { + let user_addresses = interact.get_user_addresses().await; + println!("User addresses: "); + for address in user_addresses { + print!("{address} "); + } + } + Some(interact_cli::InteractCliCommand::GetContractState) => { + let contract_state = interact.get_contract_state().await; + println!("Contract state: ping_amount -> {:#?} | deadline -> {:#?} | activation_timestamp -> {:#?} | max_funds -> {:#?} | pong_all_last_user -> {:#?}", + contract_state.ping_amount, + contract_state.deadline, + contract_state.activation_timestamp, + contract_state.max_funds, + contract_state.pong_all_last_user); + } + Some(interact_cli::InteractCliCommand::GetPingAmount) => { + let ping_amount = interact.get_ping_amount().await; + println!("Ping amount: {}", ping_amount); + } + Some(interact_cli::InteractCliCommand::GetDeadline) => { + let deadline = interact.get_deadline().await; + println!("Deadline: {}", deadline); + } + Some(interact_cli::InteractCliCommand::GetActivationTimestamp) => { + let activation_timestamp = interact.get_activation_timestamp().await; + println!("Activation timestamp: {}", activation_timestamp); + } + Some(interact_cli::InteractCliCommand::GetMaxFunds) => { + let max_funds = interact.get_max_funds().await; + match max_funds { + Some(funds) => println!("Max funds: {}", funds), + None => println!("Max funds: none"), + } + } + Some(interact_cli::InteractCliCommand::GetUserStatus(args)) => { + let user_status = interact.get_user_status(args.id).await; + match user_status { + UserStatus::New => println!("User status: unknown"), + UserStatus::Registered => println!("User status: `ping`-ed"), + UserStatus::Withdrawn => println!("User status: `pong`-ed"), + } + } + Some(interact_cli::InteractCliCommand::PongAllLastUser) => { + let pong_all_last_user = interact.pong_all_last_user().await; + println!("Pong all last user: {pong_all_last_user}"); + } + None => {} + } +} + +pub struct PingPongEgldInteract { + pub interactor: Interactor, + pub ping_pong_owner_address: Bech32Address, + pub wallet_address: Bech32Address, + pub state: State, +} + +impl PingPongEgldInteract { + pub async fn init(config: Config) -> Self { + let mut interactor = Interactor::new(config.gateway_uri()) + .await + .use_chain_simulator(config.use_chain_simulator()) + .with_tracer(INTERACTOR_SCENARIO_TRACE_PATH) + .await; + + interactor.set_current_dir_from_workspace("contracts/ping-pong-egld/interactor"); + let ping_pong_owner_address = interactor.register_wallet(test_wallets::eve()).await; + let wallet_address = interactor.register_wallet(test_wallets::mallory()).await; + + // generate blocks until ESDTSystemSCAddress is enabled + interactor.generate_blocks_until_epoch(1).await.unwrap(); + + Self { + interactor, + ping_pong_owner_address: ping_pong_owner_address.into(), + wallet_address: wallet_address.into(), + state: State::load_state(), + } + } + + pub async fn set_state(&mut self) { + println!("wallet address: {}", self.wallet_address); + self.interactor + .retrieve_account(&self.ping_pong_owner_address) + .await; + self.interactor.retrieve_account(&self.wallet_address).await; + } + + pub async fn deploy( + &mut self, + ping_amount: RustBigUint, + duration_in_seconds: u64, + opt_activation_timestamp: Option, + max_funds: OptionalValue, + ) -> (u64, String) { + self.set_state().await; + + let (new_address, status, message) = self + .interactor + .tx() + .from(&self.ping_pong_owner_address) + .gas(30_000_000u64) + .typed(proxy_ping_pong_egld::PingPongProxy) + .init( + ping_amount, + duration_in_seconds, + opt_activation_timestamp, + max_funds, + ) + .code(PING_PONG_CODE) + .returns(ReturnsNewBech32Address) + .returns(ReturnsStatus) + .returns(ReturnsMessage) + .run() + .await; + + println!("new address: {new_address}"); + self.state.set_ping_pong_egld_address(new_address); + + (status, message) + } + + pub async fn upgrade( + &mut self, + ping_amount: RustBigUint, + duration_in_seconds: u64, + opt_activation_timestamp: Option, + max_funds: OptionalValue, + ) { + let response = self + .interactor + .tx() + .to(self.state.current_ping_pong_egld_address()) + .from(&self.wallet_address) + .gas(30_000_000u64) + .typed(proxy_ping_pong_egld::PingPongProxy) + .upgrade( + ping_amount, + duration_in_seconds, + opt_activation_timestamp, + max_funds, + ) + .code(PING_PONG_CODE) + .returns(ReturnsNewAddress) + .run() + .await; + + println!("Result: {response:?}"); + } + + pub async fn ping(&mut self, egld_amount: u64, message: Option<&str>, sender: &Bech32Address) { + let _data: IgnoreValue = IgnoreValue; + + let response = self + .interactor + .tx() + .from(sender) + .to(self.state.current_ping_pong_egld_address()) + .gas(30_000_000u64) + .typed(proxy_ping_pong_egld::PingPongProxy) + .ping(_data) + .egld(egld_amount) + .returns(ReturnsHandledOrError::new()) + .run() + .await; + + match response { + Ok(_) => println!("Ping successful!"), + Err(err) => { + println!("Ping failed with message: {}", err.message); + assert_eq!(message.unwrap_or_default(), err.message); + } + } + } + + pub async fn pong(&mut self, message: Option<&str>, sender: &Bech32Address) { + let response = self + .interactor + .tx() + .from(sender) + .to(self.state.current_ping_pong_egld_address()) + .gas(30_000_000u64) + .typed(proxy_ping_pong_egld::PingPongProxy) + .pong() + .returns(ReturnsHandledOrError::new()) + .run() + .await; + + match response { + Ok(_) => println!("Pong successful!"), + Err(err) => { + println!("Pong failed with message: {}", err.message); + assert_eq!(message.unwrap_or_default(), err.message); + } + } + } + + pub async fn pong_all(&mut self, message: Option, sender: &Bech32Address) { + let response = self + .interactor + .tx() + .from(sender) + .to(self.state.current_ping_pong_egld_address()) + .gas(30_000_000u64) + .typed(proxy_ping_pong_egld::PingPongProxy) + .pong_all() + .returns(ReturnsHandledOrError::new()) + .run() + .await; + + match response { + Ok(_) => println!("Pong All successful!"), + Err(err) => { + println!("Pong All failed with message: {}", err.message); + assert_eq!(message.unwrap_or_default(), err.message); + } + } + } + + pub async fn get_user_addresses(&mut self) -> Vec { + let response = self + .interactor + .query() + .to(self.state.current_ping_pong_egld_address()) + .typed(proxy_ping_pong_egld::PingPongProxy) + .get_user_addresses() + .returns(ReturnsResult) + .run() + .await; + + let mut response_vec: Vec = Vec::new(); + for r in response.to_vec().into_vec() { + response_vec.push(r.as_managed_buffer().to_string()); + } + + response_vec + } + + pub async fn get_contract_state(&mut self) -> ContractState { + self.interactor + .query() + .to(self.state.current_ping_pong_egld_address()) + .typed(proxy_ping_pong_egld::PingPongProxy) + .get_contract_state() + .returns(ReturnsResult) + .run() + .await + } + + pub async fn get_ping_amount(&mut self) -> RustBigUint { + self.interactor + .query() + .to(self.state.current_ping_pong_egld_address()) + .typed(proxy_ping_pong_egld::PingPongProxy) + .ping_amount() + .returns(ReturnsResultUnmanaged) + .run() + .await + } + + pub async fn get_deadline(&mut self) -> u64 { + self.interactor + .query() + .to(self.state.current_ping_pong_egld_address()) + .typed(proxy_ping_pong_egld::PingPongProxy) + .deadline() + .returns(ReturnsResultUnmanaged) + .run() + .await + } + + pub async fn get_activation_timestamp(&mut self) -> u64 { + self.interactor + .query() + .to(self.state.current_ping_pong_egld_address()) + .typed(proxy_ping_pong_egld::PingPongProxy) + .activation_timestamp() + .returns(ReturnsResultUnmanaged) + .run() + .await + } + + pub async fn get_max_funds(&mut self) -> Option { + self.interactor + .query() + .to(self.state.current_ping_pong_egld_address()) + .typed(proxy_ping_pong_egld::PingPongProxy) + .max_funds() + .returns(ReturnsResultUnmanaged) + .run() + .await + } + + pub async fn get_user_status(&mut self, user_id: usize) -> UserStatus { + self.interactor + .query() + .to(self.state.current_ping_pong_egld_address()) + .typed(proxy_ping_pong_egld::PingPongProxy) + .user_status(user_id) + .returns(ReturnsResultUnmanaged) + .run() + .await + } + + pub async fn pong_all_last_user(&mut self) -> usize { + self.interactor + .query() + .to(self.state.current_ping_pong_egld_address()) + .typed(proxy_ping_pong_egld::PingPongProxy) + .pong_all_last_user() + .returns(ReturnsResultUnmanaged) + .run() + .await + } +} diff --git a/contracts/ping-pong-egld/interactor/src/interact_cli.rs b/contracts/ping-pong-egld/interactor/src/interact_cli.rs new file mode 100644 index 00000000..700f6949 --- /dev/null +++ b/contracts/ping-pong-egld/interactor/src/interact_cli.rs @@ -0,0 +1,81 @@ +use clap::{Args, Parser, Subcommand}; +use multiversx_sc_snippets::imports::RustBigUint; + +/// Ping Pong Interact CLI +#[derive(Default, PartialEq, Eq, Debug, Parser)] +#[command(version, about)] +#[command(propagate_version = true)] +pub struct InteractCli { + #[command(subcommand)] + pub command: Option, +} + +/// Ping Pong Interact CLI Commands +#[derive(Clone, PartialEq, Eq, Debug, Subcommand)] +pub enum InteractCliCommand { + #[command(name = "deploy", about = "Deploy contract.")] + Deploy(DeployArgs), + #[command(name = "upgrade", about = "Upgrade contract.")] + Upgrade(DeployArgs), + #[command( + name = "ping", + about = "User sends some EGLD to be locked in the contract for a period of time." + )] + Ping(PingArgs), + #[command(name = "pong", about = "User can take back funds from the contract.")] + Pong, + #[command(name = "pong-all", about = "Send back funds to all users who pinged.")] + PongAll, + #[command( + name = "user-addresses", + about = "Lists the addresses of all users that have `ping`-ed in the order they have `ping`-ed." + )] + GetUserAddresses, + #[command(name = "contract-state", about = "Returns the current contract state.")] + GetContractState, + #[command(name = "ping-amount", about = "Returns the ping amount.")] + GetPingAmount, + #[command(name = "deadline", about = "Return deadline.")] + GetDeadline, + #[command( + name = "activation-timestamp", + about = "Block timestamp of the block where the contract got activated. If not specified in the constructor it is the the deploy block timestamp." + )] + GetActivationTimestamp, + #[command(name = "max-funds", about = "Optional funding cap.")] + GetMaxFunds, + #[command(name = "user-status", about = "State of user funds.")] + GetUserStatus(UserStatusArgs), + #[command( + name = "pong-all-last-user", + about = "`pongAll` status, the last user to be processed. 0 if never called `pongAll` or `pongAll` completed." + )] + PongAllLastUser, +} + +#[derive(Default, Clone, PartialEq, Eq, Debug, Args)] +pub struct DeployArgs { + #[arg(short = 'p', long = "ping-amount")] + pub ping_amount: RustBigUint, + + #[arg(short = 'd', long = "duration-in-seconds")] + pub duration_in_seconds: u64, + + #[arg(short = 'a', long = "activation-timestamp")] + pub opt_activation_timestamp: Option, + + #[arg(short = 'm', long = "max-funds")] + pub max_funds: Option, +} + +#[derive(Default, Clone, PartialEq, Eq, Debug, Args)] +pub struct PingArgs { + #[arg(short = 'c', long = "cost", default_value = "50000000000000000")] + pub cost: Option, +} + +#[derive(Default, Clone, PartialEq, Eq, Debug, Args)] +pub struct UserStatusArgs { + #[arg(short = 'i')] + pub id: usize, +} diff --git a/contracts/ping-pong-egld/interactor/src/interact_config.rs b/contracts/ping-pong-egld/interactor/src/interact_config.rs new file mode 100644 index 00000000..013e1671 --- /dev/null +++ b/contracts/ping-pong-egld/interactor/src/interact_config.rs @@ -0,0 +1,49 @@ +use serde::Deserialize; +use std::io::Read; + +/// Config file +const CONFIG_FILE: &str = "config.toml"; + +#[derive(Debug, Deserialize)] +#[serde(rename_all = "lowercase")] +pub enum ChainType { + Real, + Simulator, +} + +/// Ping Pong Interact configuration +#[derive(Debug, Deserialize)] +pub struct Config { + pub gateway_uri: String, + pub chain_type: ChainType, +} + +impl Config { + // Deserializes config from file + pub fn load_config() -> Self { + let mut file = std::fs::File::open(CONFIG_FILE).unwrap(); + let mut content = String::new(); + file.read_to_string(&mut content).unwrap(); + toml::from_str(&content).unwrap() + } + + pub fn chain_simulator_config() -> Self { + Config { + gateway_uri: "http://localhost:8085".to_owned(), + chain_type: ChainType::Simulator, + } + } + + // 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, + } + } +} diff --git a/contracts/ping-pong-egld/interactor/src/interact_main.rs b/contracts/ping-pong-egld/interactor/src/interact_main.rs new file mode 100644 index 00000000..1e090c46 --- /dev/null +++ b/contracts/ping-pong-egld/interactor/src/interact_main.rs @@ -0,0 +1,6 @@ +extern crate ping_pong_egld_interact; + +#[tokio::main] +pub async fn main() { + ping_pong_egld_interact::ping_pong_egld_cli().await; +} diff --git a/contracts/ping-pong-egld/interactor/src/interact_state.rs b/contracts/ping-pong-egld/interactor/src/interact_state.rs new file mode 100644 index 00000000..38fb3d32 --- /dev/null +++ b/contracts/ping-pong-egld/interactor/src/interact_state.rs @@ -0,0 +1,50 @@ +use multiversx_sc_snippets::imports::*; +use serde::{Deserialize, Serialize}; +use std::{ + io::{Read, Write}, + path::Path, +}; + +/// State file +const STATE_FILE: &str = "state.toml"; + +/// Multisig Interact state +#[derive(Debug, Default, Serialize, Deserialize)] +pub struct State { + ping_pong_egld_address: Option, +} + +impl State { + // Deserializes state from file + pub fn load_state() -> Self { + if Path::new(STATE_FILE).exists() { + let mut file = std::fs::File::open(STATE_FILE).unwrap(); + let mut content = String::new(); + file.read_to_string(&mut content).unwrap(); + toml::from_str(&content).unwrap() + } else { + Self::default() + } + } + + /// Sets the ping pong address + pub fn set_ping_pong_egld_address(&mut self, address: Bech32Address) { + self.ping_pong_egld_address = Some(address); + } + + /// Returns the ping pong contract + pub fn current_ping_pong_egld_address(&self) -> &Bech32Address { + self.ping_pong_egld_address + .as_ref() + .expect("no known ping pong contract, deploy first") + } +} + +impl Drop for State { + // Serializes state to file + fn drop(&mut self) { + let mut file = std::fs::File::create(STATE_FILE).unwrap(); + file.write_all(toml::to_string(self).unwrap().as_bytes()) + .unwrap(); + } +} diff --git a/contracts/ping-pong-egld/interactor/src/proxy_ping_pong_egld.rs b/contracts/ping-pong-egld/interactor/src/proxy_ping_pong_egld.rs new file mode 100644 index 00000000..ad894441 --- /dev/null +++ b/contracts/ping-pong-egld/interactor/src/proxy_ping_pong_egld.rs @@ -0,0 +1,263 @@ +// Code generated by the multiversx-sc proxy generator. DO NOT EDIT. + +//////////////////////////////////////////////////// +////////////////// AUTO-GENERATED ////////////////// +//////////////////////////////////////////////////// + +#![allow(dead_code)] +#![allow(clippy::all)] + +use multiversx_sc::proxy_imports::*; + +pub struct PingPongProxy; + +impl TxProxyTrait for PingPongProxy +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + type TxProxyMethods = PingPongProxyMethods; + + fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { + PingPongProxyMethods { wrapped_tx: tx } + } +} + +pub struct PingPongProxyMethods +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + wrapped_tx: Tx, +} + +#[rustfmt::skip] +impl PingPongProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + Gas: TxGas, +{ + /// Necessary configuration when deploying: + /// `ping_amount` - the exact EGLD amount that needs to be sent when `ping`-ing. + /// `duration_in_seconds` - how much time (in seconds) until contract expires. + /// `opt_activation_timestamp` - optionally specify the contract to only activate at a later date. + /// `max_funds` - optional funding cap, no more funds than this can be added to the contract. + pub fn init< + Arg0: ProxyArg>, + Arg1: ProxyArg, + Arg2: ProxyArg>, + Arg3: ProxyArg>>, + >( + self, + ping_amount: Arg0, + duration_in_seconds: Arg1, + opt_activation_timestamp: Arg2, + max_funds: Arg3, + ) -> TxTypedDeploy { + self.wrapped_tx + .payment(NotPayable) + .raw_deploy() + .argument(&ping_amount) + .argument(&duration_in_seconds) + .argument(&opt_activation_timestamp) + .argument(&max_funds) + .original_result() + } +} + +#[rustfmt::skip] +impl PingPongProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn upgrade< + Arg0: ProxyArg>, + Arg1: ProxyArg, + Arg2: ProxyArg>, + Arg3: ProxyArg>>, + >( + self, + ping_amount: Arg0, + duration_in_seconds: Arg1, + opt_activation_timestamp: Arg2, + max_funds: Arg3, + ) -> TxTypedUpgrade { + self.wrapped_tx + .payment(NotPayable) + .raw_upgrade() + .argument(&ping_amount) + .argument(&duration_in_seconds) + .argument(&opt_activation_timestamp) + .argument(&max_funds) + .original_result() + } +} + +#[rustfmt::skip] +impl PingPongProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + /// User sends some EGLD to be locked in the contract for a period of time. + /// Optional `_data` argument is ignored. + pub fn ping< + Arg0: ProxyArg, + >( + self, + _data: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("ping") + .argument(&_data) + .original_result() + } + + /// User can take back funds from the contract. + /// Can only be called after expiration. + pub fn pong( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("pong") + .original_result() + } + + /// Send back funds to all users who pinged. + /// Returns + /// - `completed` if everything finished + /// - `interrupted` if run out of gas midway. + /// Can only be called after expiration. + pub fn pong_all( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("pongAll") + .original_result() + } + + /// Lists the addresses of all users that have `ping`-ed, + /// in the order they have `ping`-ed + pub fn get_user_addresses( + self, + ) -> TxTypedCall>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getUserAddresses") + .original_result() + } + + /// Returns the current contract state as a struct + /// for faster fetching from external parties + pub fn get_contract_state( + self, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getContractState") + .original_result() + } + + pub fn ping_amount( + self, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getPingAmount") + .original_result() + } + + pub fn deadline( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getDeadline") + .original_result() + } + + /// Block timestamp of the block where the contract got activated. + /// If not specified in the constructor it is the the deploy block timestamp. + pub fn activation_timestamp( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getActivationTimestamp") + .original_result() + } + + /// Optional funding cap. + pub fn max_funds( + self, + ) -> TxTypedCall>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getMaxFunds") + .original_result() + } + + /// State of user funds. + /// 0 - user unknown, never `ping`-ed + /// 1 - `ping`-ed + /// 2 - `pong`-ed + pub fn user_status< + Arg0: ProxyArg, + >( + self, + user_id: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getUserStatus") + .argument(&user_id) + .original_result() + } + + /// Part of the `pongAll` status, the last user to be processed. + /// 0 if never called `pongAll` or `pongAll` completed. + pub fn pong_all_last_user( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("pongAllLastUser") + .original_result() + } +} + +#[type_abi] +#[derive(TopEncode, TopDecode, Default)] +pub struct ContractState +where + Api: ManagedTypeApi, +{ + pub ping_amount: BigUint, + pub deadline: u64, + pub activation_timestamp: u64, + pub max_funds: Option>, + pub pong_all_last_user: usize, +} + +#[type_abi] +#[derive(TopEncode, TopDecode, PartialEq, Eq, Clone, Copy)] +pub enum UserStatus { + New, + Registered, + Withdrawn, +} diff --git a/contracts/ping-pong-egld/interactor/tests/interact_cs_test.rs b/contracts/ping-pong-egld/interactor/tests/interact_cs_test.rs new file mode 100644 index 00000000..f25bcfde --- /dev/null +++ b/contracts/ping-pong-egld/interactor/tests/interact_cs_test.rs @@ -0,0 +1,138 @@ +use multiversx_sc_snippets::imports::RustBigUint; +use ping_pong_egld_interact::{Config, PingPongEgldInteract}; + +#[tokio::test] +#[cfg_attr(not(feature = "chain-simulator-tests"), ignore)] +async fn test_ping_pong_egld() { + let mut interact = PingPongEgldInteract::init(Config::chain_simulator_config()).await; + let wallet_address = interact.wallet_address.clone(); + let ping_pong_owner_address = interact.ping_pong_owner_address.clone(); + + let ping_amount = 1u64; + + // test_ping_unmatched_amount + let duration_in_seconds = 5u64; + let opt_activation_timestamp = 2u64; + let max_funds = 100_000u64; + + interact + .deploy( + ping_amount.into(), + duration_in_seconds, + Some(opt_activation_timestamp), + multiversx_sc_snippets::imports::OptionalValue::Some(max_funds.into()), + ) + .await; + + interact + .ping( + 0u64, + Some("the payment must match the fixed sum"), + &wallet_address, + ) + .await; + + // test_ping_inactive_contracts + let duration_in_seconds = 5u64; + let opt_activation_timestamp = 2_000_000_000u64; + let max_funds = 100_000u64; + + interact + .deploy( + ping_amount.into(), + duration_in_seconds, + Some(opt_activation_timestamp), + multiversx_sc_snippets::imports::OptionalValue::Some(max_funds.into()), + ) + .await; + + interact + .ping(1u64, Some("smart contract not active yet"), &wallet_address) + .await; + + // test_ping_passed_deadline + let duration_in_seconds = 5u64; + let opt_activation_timestamp = 2u64; + let max_funds = 100_000u64; + + interact + .deploy( + ping_amount.into(), + duration_in_seconds, + Some(opt_activation_timestamp), + multiversx_sc_snippets::imports::OptionalValue::Some(max_funds.into()), + ) + .await; + + interact + .ping(1u64, Some("deadline has passed"), &wallet_address) + .await; + + // test_ping_max_funds + let ping_amount = 10u64; + let duration_in_seconds = 30000u64; + let max_funds = 10u64; + + interact + .deploy( + ping_amount.into(), + duration_in_seconds, + None, + multiversx_sc_snippets::imports::OptionalValue::Some(max_funds.into()), + ) + .await; + + interact + .ping(10u64, Some("smart contract full"), &wallet_address) + .await; + + // test ping + let ping_amount = 1u64; + let duration_in_seconds = 20u64; + let max_funds = 100_000u64; + + interact + .deploy( + ping_amount.into(), + duration_in_seconds, + None, + multiversx_sc_snippets::imports::OptionalValue::Some(max_funds.into()), + ) + .await; + + interact.ping(1u64, None, &wallet_address).await; + interact + .ping(1u64, Some("can only ping once"), &wallet_address) + .await; + + assert_eq!(interact.get_ping_amount().await, RustBigUint::from(1u64)); + + interact + .pong(Some("can't withdraw before deadline"), &wallet_address) + .await; + + interact.pong(None, &wallet_address).await; + + // test_pong_all + let ping_amount = 1u64; + let duration_in_seconds = 18u64; + let max_funds = 100_000u64; + + interact + .deploy( + ping_amount.into(), + duration_in_seconds, + None, + multiversx_sc_snippets::imports::OptionalValue::Some(max_funds.into()), + ) + .await; + + interact.ping(1u64, None, &ping_pong_owner_address).await; + + interact.ping(1u64, None, &wallet_address).await; + + interact.pong_all(None, &ping_pong_owner_address).await; + interact + .pong(Some("already withdrawn"), &wallet_address) + .await; +} diff --git a/contracts/ping-pong-egld/src/ping_pong.rs b/contracts/ping-pong-egld/src/ping_pong.rs index aee3fa3f..3e0d4ffc 100644 --- a/contracts/ping-pong-egld/src/ping_pong.rs +++ b/contracts/ping-pong-egld/src/ping_pong.rs @@ -2,9 +2,9 @@ use multiversx_sc::imports::*; -mod user_status; +mod types; -use user_status::UserStatus; +use types::{ContractState, UserStatus}; /// Derived empirically. const PONG_ALL_LOW_GAS_LIMIT: u64 = 3_000_000; @@ -25,10 +25,11 @@ const PONG_ALL_LOW_GAS_LIMIT: u64 = 3_000_000; #[multiversx_sc::contract] pub trait PingPong { /// Necessary configuration when deploying: - /// `ping_amount` - the exact EGLD amounf that needs to be sent when `ping`-ing. + /// `ping_amount` - the exact EGLD amount that needs to be sent when `ping`-ing. /// `duration_in_seconds` - how much time (in seconds) until contract expires. - /// `opt_activation_timestamp` - optionally specify the contract to only actvivate at a later date. + /// `opt_activation_timestamp` - optionally specify the contract to only activate at a later date. /// `max_funds` - optional funding cap, no more funds than this can be added to the contract. + #[allow_multiple_var_args] #[init] fn init( &self, @@ -46,6 +47,22 @@ pub trait PingPong { self.max_funds().set(max_funds.into_option()); } + #[upgrade] + fn upgrade( + &self, + ping_amount: &BigUint, + duration_in_seconds: u64, + opt_activation_timestamp: Option, + max_funds: OptionalValue, + ) { + self.init( + ping_amount, + duration_in_seconds, + opt_activation_timestamp, + max_funds, + ) + } + /// User sends some EGLD to be locked in the contract for a period of time. /// Optional `_data` argument is ignored. #[payable("EGLD")] @@ -86,14 +103,16 @@ pub trait PingPong { match user_status { UserStatus::New => { self.user_status(user_id).set(UserStatus::Registered); - } + }, UserStatus::Registered => { sc_panic!("can only ping once") - } + }, UserStatus::Withdrawn => { sc_panic!("already withdrawn") - } + }, } + + self.ping_event(&caller, &payment); } fn pong_by_user_id(&self, user_id: usize) -> Result<(), &'static str> { @@ -103,15 +122,14 @@ pub trait PingPong { UserStatus::Registered => { self.user_status(user_id).set(UserStatus::Withdrawn); if let Some(user_address) = self.user_mapper().get_user_address(user_id) { - self.tx() - .to(&user_address) - .egld(self.ping_amount().get()) - .transfer(); + let amount = self.ping_amount().get(); + self.tx().to(&user_address).egld(&amount).transfer(); + self.pong_event(&user_address, &amount); Result::Ok(()) } else { Result::Err("unknown user") } - } + }, UserStatus::Withdrawn => Result::Err("already withdrawn"), } } @@ -140,24 +158,27 @@ pub trait PingPong { /// Can only be called after expiration. #[endpoint(pongAll)] fn pong_all(&self) -> OperationCompletionStatus { + let now = self.blockchain().get_block_timestamp(); require!( - self.blockchain().get_block_timestamp() >= self.deadline().get(), + now >= self.deadline().get(), "can't withdraw before deadline" ); let num_users = self.user_mapper().get_user_count(); let mut pong_all_last_user = self.pong_all_last_user().get(); + let mut status = OperationCompletionStatus::InterruptedBeforeOutOfGas; loop { if pong_all_last_user >= num_users { // clear field and reset to 0 pong_all_last_user = 0; self.pong_all_last_user().set(pong_all_last_user); - return OperationCompletionStatus::Completed; + status = OperationCompletionStatus::Completed; + break; } if self.blockchain().get_gas_left() < PONG_ALL_LOW_GAS_LIMIT { self.pong_all_last_user().set(pong_all_last_user); - return OperationCompletionStatus::InterruptedBeforeOutOfGas; + break; } pong_all_last_user += 1; @@ -165,6 +186,10 @@ pub trait PingPong { // in case of error just ignore the error and skip let _ = self.pong_by_user_id(pong_all_last_user); } + + self.pong_all_event(now, &status, pong_all_last_user); + + status } /// Lists the addresses of all users that have `ping`-ed, @@ -174,6 +199,19 @@ pub trait PingPong { self.user_mapper().get_all_addresses().into() } + /// Returns the current contract state as a struct + /// for faster fetching from external parties + #[view(getContractState)] + fn get_contract_state(&self) -> ContractState { + ContractState { + ping_amount: self.ping_amount().get(), + deadline: self.deadline().get(), + activation_timestamp: self.activation_timestamp().get(), + max_funds: self.max_funds().get(), + pong_all_last_user: self.pong_all_last_user().get(), + } + } + // storage #[view(getPingAmount)] @@ -207,8 +245,27 @@ pub trait PingPong { fn user_status(&self, user_id: usize) -> SingleValueMapper; /// Part of the `pongAll` status, the last user to be processed. - /// 0 if never called `pongAll` or `pongAll` completed.. + /// 0 if never called `pongAll` or `pongAll` completed. #[view(pongAllLastUser)] #[storage_mapper("pongAllLastUser")] fn pong_all_last_user(&self) -> SingleValueMapper; + + // events + + /// Signals a successful ping by user with amount + #[event] + fn ping_event(&self, #[indexed] caller: &ManagedAddress, pinged_amount: &BigUint); + + /// Signals a successful pong by user with amount + #[event] + fn pong_event(&self, #[indexed] caller: &ManagedAddress, ponged_amount: &BigUint); + + /// Signals the beginning of the pong_all operation, status and last user + #[event] + fn pong_all_event( + &self, + #[indexed] timestamp: u64, + #[indexed] status: &OperationCompletionStatus, + #[indexed] pong_all_last_user: usize, + ); } diff --git a/contracts/ping-pong-egld/src/types.rs b/contracts/ping-pong-egld/src/types.rs new file mode 100644 index 00000000..e83cc714 --- /dev/null +++ b/contracts/ping-pong-egld/src/types.rs @@ -0,0 +1,20 @@ +use multiversx_sc::derive_imports::*; +use multiversx_sc::imports::*; + +#[type_abi] +#[derive(TopEncode, TopDecode, PartialEq, Eq, Clone, Copy)] +pub enum UserStatus { + New, + Registered, + Withdrawn, +} + +#[type_abi] +#[derive(TopEncode, TopDecode, Default)] +pub struct ContractState { + pub ping_amount: BigUint, + pub deadline: u64, + pub activation_timestamp: u64, + pub max_funds: Option>, + pub pong_all_last_user: usize, +} diff --git a/contracts/ping-pong-egld/src/user_status.rs b/contracts/ping-pong-egld/src/user_status.rs deleted file mode 100644 index a464b742..00000000 --- a/contracts/ping-pong-egld/src/user_status.rs +++ /dev/null @@ -1,9 +0,0 @@ -use multiversx_sc::derive_imports::*; - -#[type_abi] -#[derive(TopEncode, TopDecode, PartialEq, Eq, Clone, Copy)] -pub enum UserStatus { - New, - Registered, - Withdrawn, -} diff --git a/contracts/ping-pong-egld/tests/ping_pong_egld_scenario_rs_test.rs b/contracts/ping-pong-egld/tests/ping_pong_egld_scenario_rs_test.rs index 55a8e591..46d6d0c1 100644 --- a/contracts/ping-pong-egld/tests/ping_pong_egld_scenario_rs_test.rs +++ b/contracts/ping-pong-egld/tests/ping_pong_egld_scenario_rs_test.rs @@ -3,6 +3,7 @@ use multiversx_sc_scenario::*; fn world() -> ScenarioWorld { let mut blockchain = ScenarioWorld::new(); + blockchain.set_current_dir_from_workspace("contracts/ping-pong-egld"); blockchain.register_contract( "mxsc:output/ping-pong-egld.mxsc.json", ping_pong_egld::ContractBuilder, diff --git a/contracts/ping-pong-egld/wasm/Cargo.lock b/contracts/ping-pong-egld/wasm/Cargo.lock index a39836ef..9f873830 100644 --- a/contracts/ping-pong-egld/wasm/Cargo.lock +++ b/contracts/ping-pong-egld/wasm/Cargo.lock @@ -38,14 +38,25 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "multiversx-chain-core" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" +dependencies = [ + "bitflags", + "multiversx-sc-codec", +] + [[package]] name = "multiversx-sc" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -54,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -65,9 +76,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -77,9 +88,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -90,9 +101,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/ping-pong-egld/wasm/Cargo.toml b/contracts/ping-pong-egld/wasm/Cargo.toml index d130e245..b25e1086 100644 --- a/contracts/ping-pong-egld/wasm/Cargo.toml +++ b/contracts/ping-pong-egld/wasm/Cargo.toml @@ -1,3 +1,9 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "ping-pong-egld-wasm" version = "0.0.0" diff --git a/contracts/ping-pong-egld/wasm/src/lib.rs b/contracts/ping-pong-egld/wasm/src/lib.rs index b7f15fc3..ece506bf 100644 --- a/contracts/ping-pong-egld/wasm/src/lib.rs +++ b/contracts/ping-pong-egld/wasm/src/lib.rs @@ -5,9 +5,10 @@ //////////////////////////////////////////////////// // Init: 1 -// Endpoints: 10 +// Upgrade: 1 +// Endpoints: 11 // Async Callback (empty): 1 -// Total number of exported functions: 12 +// Total number of exported functions: 14 #![no_std] @@ -18,10 +19,12 @@ multiversx_sc_wasm_adapter::endpoints! { ping_pong_egld ( init => init + upgrade => upgrade ping => ping pong => pong pongAll => pong_all getUserAddresses => get_user_addresses + getContractState => get_contract_state getPingAmount => ping_amount getDeadline => deadline getActivationTimestamp => activation_timestamp From 74b44bd613afacb4e1900c8d8ff85e8a770b4531 Mon Sep 17 00:00:00 2001 From: BiancaIalangi Date: Thu, 21 Nov 2024 13:31:02 +0200 Subject: [PATCH 11/13] 0.54 upgrade - Cargo.lock --- Cargo.lock | 2 +- Cargo.toml | 2 +- contracts/adder/wasm/Cargo.lock | 24 ++++++------- .../bonding-curve-contract/wasm/Cargo.lock | 28 +++++++-------- contracts/check-pause/wasm/Cargo.lock | 28 +++++++-------- contracts/crowdfunding-esdt/wasm/Cargo.lock | 24 ++++++------- contracts/crypto-bubbles/wasm/Cargo.lock | 24 ++++++------- .../kitty-auction/wasm/Cargo.lock | 24 ++++++------- .../kitty-genetic-alg/wasm/Cargo.lock | 24 ++++++------- .../kitty-ownership/wasm/Cargo.lock | 24 ++++++------- contracts/crypto-zombies/wasm/Cargo.lock | 24 ++++++------- contracts/digital-cash/wasm/Cargo.lock | 24 ++++++------- contracts/dn404/wasm/Cargo.lock | 28 +++++++-------- contracts/empty/wasm/Cargo.lock | 24 ++++++------- contracts/erc3643/wasm/Cargo.lock | 28 +++++++-------- .../esdt-transfer-with-fee/wasm/Cargo.lock | 24 ++++++------- contracts/factorial/wasm/Cargo.lock | 24 ++++++------- contracts/fair-launch/wasm/Cargo.lock | 28 +++++++-------- contracts/fractional-nfts/wasm/Cargo.lock | 28 +++++++-------- contracts/liquid-locking/wasm/Cargo.lock | 24 ++++++------- contracts/lottery-esdt/wasm/Cargo.lock | 24 ++++++------- .../multisig/wasm-multisig-full/Cargo.lock | 35 ++++++++++++------- .../multisig/wasm-multisig-full/Cargo.toml | 6 ++++ .../multisig/wasm-multisig-view/Cargo.lock | 35 ++++++++++++------- .../multisig/wasm-multisig-view/Cargo.toml | 6 ++++ contracts/multisig/wasm/Cargo.lock | 35 ++++++++++++------- contracts/multisig/wasm/Cargo.toml | 6 ++++ contracts/mvx-game-sc/wasm/Cargo.lock | 24 ++++++------- contracts/mystery-box/wasm/Cargo.lock | 35 ++++++++++++------- contracts/nft-escrow/wasm/Cargo.lock | 12 +++---- contracts/nft-minter/wasm/Cargo.lock | 12 +++---- contracts/nft-storage-prepay/wasm/Cargo.lock | 12 +++---- contracts/ping-pong-egld/wasm/Cargo.lock | 31 ++++++++++------ contracts/ping-pong-egld/wasm/Cargo.toml | 6 ++++ contracts/proxy-deployer/wasm/Cargo.lock | 28 +++++++-------- .../rewards-distribution/wasm/Cargo.lock | 35 ++++++++++++------- .../rewards-distribution/wasm/Cargo.toml | 6 ++++ 37 files changed, 452 insertions(+), 356 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 28498c10..9af9f055 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -160,7 +160,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] -name = "basic-interact" +name = "basic-interactor" version = "0.0.0" dependencies = [ "adder", diff --git a/Cargo.toml b/Cargo.toml index 5fb5dd18..68169812 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ members = [ "contracts/adder", "contracts/adder/meta", - "contracts/adder/interact", + "contracts/adder/interactor", "contracts/esdt-transfer-with-fee", "contracts/esdt-transfer-with-fee/meta", "contracts/bonding-curve-contract", diff --git a/contracts/adder/wasm/Cargo.lock b/contracts/adder/wasm/Cargo.lock index 97680dcc..2b0e4916 100644 --- a/contracts/adder/wasm/Cargo.lock +++ b/contracts/adder/wasm/Cargo.lock @@ -55,9 +55,9 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "multiversx-chain-core" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1088b268cad0d8c1146df9ca71a1f2baaee78267ab75e2202c0c0c71cc4b6e" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" dependencies = [ "bitflags", "multiversx-sc-codec", @@ -65,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e5cee0b8c5fbaa9edfee2e38f2162adb01700a0028942d2cd14808cd26b130" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", @@ -80,9 +80,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -91,9 +91,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -103,9 +103,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "931669b080cf793b205bf08b5d1f4a658d0ac0ad628844d9a9d13649a73c7540" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -116,9 +116,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c034ae143cfd971cf0c4d67476af1920a9a0165bd99713458397ac06762fca0d" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/bonding-curve-contract/wasm/Cargo.lock b/contracts/bonding-curve-contract/wasm/Cargo.lock index a49718c7..612aac4b 100644 --- a/contracts/bonding-curve-contract/wasm/Cargo.lock +++ b/contracts/bonding-curve-contract/wasm/Cargo.lock @@ -56,9 +56,9 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "multiversx-chain-core" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1088b268cad0d8c1146df9ca71a1f2baaee78267ab75e2202c0c0c71cc4b6e" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" dependencies = [ "bitflags", "multiversx-sc-codec", @@ -66,9 +66,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e5cee0b8c5fbaa9edfee2e38f2162adb01700a0028942d2cd14808cd26b130" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", @@ -81,9 +81,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -92,9 +92,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -104,9 +104,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "931669b080cf793b205bf08b5d1f4a658d0ac0ad628844d9a9d13649a73c7540" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -117,18 +117,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5373903a01dd7d33547b83f0034dc6e12fbbc8e49fcb316a3efb6ef4ff6573a8" +checksum = "74b31cfc990a3052a0e014f749104752a0208f3d11d4dee3c0dd6e6d4ce1908c" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c034ae143cfd971cf0c4d67476af1920a9a0165bd99713458397ac06762fca0d" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/check-pause/wasm/Cargo.lock b/contracts/check-pause/wasm/Cargo.lock index e7c797b7..ba266e78 100644 --- a/contracts/check-pause/wasm/Cargo.lock +++ b/contracts/check-pause/wasm/Cargo.lock @@ -56,9 +56,9 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "multiversx-chain-core" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1088b268cad0d8c1146df9ca71a1f2baaee78267ab75e2202c0c0c71cc4b6e" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" dependencies = [ "bitflags", "multiversx-sc-codec", @@ -66,9 +66,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e5cee0b8c5fbaa9edfee2e38f2162adb01700a0028942d2cd14808cd26b130" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", @@ -81,9 +81,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -92,9 +92,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -104,9 +104,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "931669b080cf793b205bf08b5d1f4a658d0ac0ad628844d9a9d13649a73c7540" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -117,18 +117,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5373903a01dd7d33547b83f0034dc6e12fbbc8e49fcb316a3efb6ef4ff6573a8" +checksum = "74b31cfc990a3052a0e014f749104752a0208f3d11d4dee3c0dd6e6d4ce1908c" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c034ae143cfd971cf0c4d67476af1920a9a0165bd99713458397ac06762fca0d" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/crowdfunding-esdt/wasm/Cargo.lock b/contracts/crowdfunding-esdt/wasm/Cargo.lock index f849b019..c16b157d 100644 --- a/contracts/crowdfunding-esdt/wasm/Cargo.lock +++ b/contracts/crowdfunding-esdt/wasm/Cargo.lock @@ -55,9 +55,9 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "multiversx-chain-core" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1088b268cad0d8c1146df9ca71a1f2baaee78267ab75e2202c0c0c71cc4b6e" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" dependencies = [ "bitflags", "multiversx-sc-codec", @@ -65,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e5cee0b8c5fbaa9edfee2e38f2162adb01700a0028942d2cd14808cd26b130" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", @@ -80,9 +80,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -91,9 +91,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -103,9 +103,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "931669b080cf793b205bf08b5d1f4a658d0ac0ad628844d9a9d13649a73c7540" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -116,9 +116,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c034ae143cfd971cf0c4d67476af1920a9a0165bd99713458397ac06762fca0d" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/crypto-bubbles/wasm/Cargo.lock b/contracts/crypto-bubbles/wasm/Cargo.lock index a7e0176b..a46ca3c4 100644 --- a/contracts/crypto-bubbles/wasm/Cargo.lock +++ b/contracts/crypto-bubbles/wasm/Cargo.lock @@ -55,9 +55,9 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "multiversx-chain-core" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1088b268cad0d8c1146df9ca71a1f2baaee78267ab75e2202c0c0c71cc4b6e" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" dependencies = [ "bitflags", "multiversx-sc-codec", @@ -65,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e5cee0b8c5fbaa9edfee2e38f2162adb01700a0028942d2cd14808cd26b130" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", @@ -80,9 +80,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -91,9 +91,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -103,9 +103,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "931669b080cf793b205bf08b5d1f4a658d0ac0ad628844d9a9d13649a73c7540" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -116,9 +116,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c034ae143cfd971cf0c4d67476af1920a9a0165bd99713458397ac06762fca0d" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/crypto-kitties/kitty-auction/wasm/Cargo.lock b/contracts/crypto-kitties/kitty-auction/wasm/Cargo.lock index e2d6aec2..5dece95c 100644 --- a/contracts/crypto-kitties/kitty-auction/wasm/Cargo.lock +++ b/contracts/crypto-kitties/kitty-auction/wasm/Cargo.lock @@ -84,9 +84,9 @@ dependencies = [ [[package]] name = "multiversx-chain-core" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1088b268cad0d8c1146df9ca71a1f2baaee78267ab75e2202c0c0c71cc4b6e" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" dependencies = [ "bitflags", "multiversx-sc-codec", @@ -94,9 +94,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e5cee0b8c5fbaa9edfee2e38f2162adb01700a0028942d2cd14808cd26b130" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", @@ -109,9 +109,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -120,9 +120,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -132,9 +132,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "931669b080cf793b205bf08b5d1f4a658d0ac0ad628844d9a9d13649a73c7540" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -145,9 +145,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c034ae143cfd971cf0c4d67476af1920a9a0165bd99713458397ac06762fca0d" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/crypto-kitties/kitty-genetic-alg/wasm/Cargo.lock b/contracts/crypto-kitties/kitty-genetic-alg/wasm/Cargo.lock index 5870e534..645b9ac1 100644 --- a/contracts/crypto-kitties/kitty-genetic-alg/wasm/Cargo.lock +++ b/contracts/crypto-kitties/kitty-genetic-alg/wasm/Cargo.lock @@ -65,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-chain-core" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1088b268cad0d8c1146df9ca71a1f2baaee78267ab75e2202c0c0c71cc4b6e" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" dependencies = [ "bitflags", "multiversx-sc-codec", @@ -75,9 +75,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e5cee0b8c5fbaa9edfee2e38f2162adb01700a0028942d2cd14808cd26b130" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", @@ -90,9 +90,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -101,9 +101,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -113,9 +113,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "931669b080cf793b205bf08b5d1f4a658d0ac0ad628844d9a9d13649a73c7540" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -126,9 +126,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c034ae143cfd971cf0c4d67476af1920a9a0165bd99713458397ac06762fca0d" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/crypto-kitties/kitty-ownership/wasm/Cargo.lock b/contracts/crypto-kitties/kitty-ownership/wasm/Cargo.lock index ab2e1bd4..c703b0f2 100644 --- a/contracts/crypto-kitties/kitty-ownership/wasm/Cargo.lock +++ b/contracts/crypto-kitties/kitty-ownership/wasm/Cargo.lock @@ -75,9 +75,9 @@ dependencies = [ [[package]] name = "multiversx-chain-core" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1088b268cad0d8c1146df9ca71a1f2baaee78267ab75e2202c0c0c71cc4b6e" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" dependencies = [ "bitflags", "multiversx-sc-codec", @@ -85,9 +85,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e5cee0b8c5fbaa9edfee2e38f2162adb01700a0028942d2cd14808cd26b130" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", @@ -100,9 +100,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -111,9 +111,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -123,9 +123,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "931669b080cf793b205bf08b5d1f4a658d0ac0ad628844d9a9d13649a73c7540" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -136,9 +136,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c034ae143cfd971cf0c4d67476af1920a9a0165bd99713458397ac06762fca0d" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/crypto-zombies/wasm/Cargo.lock b/contracts/crypto-zombies/wasm/Cargo.lock index f1248090..343f68c7 100644 --- a/contracts/crypto-zombies/wasm/Cargo.lock +++ b/contracts/crypto-zombies/wasm/Cargo.lock @@ -55,9 +55,9 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "multiversx-chain-core" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1088b268cad0d8c1146df9ca71a1f2baaee78267ab75e2202c0c0c71cc4b6e" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" dependencies = [ "bitflags", "multiversx-sc-codec", @@ -65,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e5cee0b8c5fbaa9edfee2e38f2162adb01700a0028942d2cd14808cd26b130" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", @@ -80,9 +80,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -91,9 +91,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -103,9 +103,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "931669b080cf793b205bf08b5d1f4a658d0ac0ad628844d9a9d13649a73c7540" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -116,9 +116,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c034ae143cfd971cf0c4d67476af1920a9a0165bd99713458397ac06762fca0d" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/digital-cash/wasm/Cargo.lock b/contracts/digital-cash/wasm/Cargo.lock index 6a594032..77969eab 100644 --- a/contracts/digital-cash/wasm/Cargo.lock +++ b/contracts/digital-cash/wasm/Cargo.lock @@ -55,9 +55,9 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "multiversx-chain-core" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1088b268cad0d8c1146df9ca71a1f2baaee78267ab75e2202c0c0c71cc4b6e" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" dependencies = [ "bitflags", "multiversx-sc-codec", @@ -65,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e5cee0b8c5fbaa9edfee2e38f2162adb01700a0028942d2cd14808cd26b130" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", @@ -80,9 +80,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -91,9 +91,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -103,9 +103,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "931669b080cf793b205bf08b5d1f4a658d0ac0ad628844d9a9d13649a73c7540" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -116,9 +116,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c034ae143cfd971cf0c4d67476af1920a9a0165bd99713458397ac06762fca0d" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/dn404/wasm/Cargo.lock b/contracts/dn404/wasm/Cargo.lock index b97157b7..ed17b3d4 100644 --- a/contracts/dn404/wasm/Cargo.lock +++ b/contracts/dn404/wasm/Cargo.lock @@ -56,9 +56,9 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "multiversx-chain-core" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1088b268cad0d8c1146df9ca71a1f2baaee78267ab75e2202c0c0c71cc4b6e" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" dependencies = [ "bitflags", "multiversx-sc-codec", @@ -66,9 +66,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e5cee0b8c5fbaa9edfee2e38f2162adb01700a0028942d2cd14808cd26b130" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", @@ -81,9 +81,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -92,9 +92,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -104,9 +104,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "931669b080cf793b205bf08b5d1f4a658d0ac0ad628844d9a9d13649a73c7540" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -117,18 +117,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5373903a01dd7d33547b83f0034dc6e12fbbc8e49fcb316a3efb6ef4ff6573a8" +checksum = "74b31cfc990a3052a0e014f749104752a0208f3d11d4dee3c0dd6e6d4ce1908c" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c034ae143cfd971cf0c4d67476af1920a9a0165bd99713458397ac06762fca0d" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/empty/wasm/Cargo.lock b/contracts/empty/wasm/Cargo.lock index 49aae427..7a7da7d2 100644 --- a/contracts/empty/wasm/Cargo.lock +++ b/contracts/empty/wasm/Cargo.lock @@ -55,9 +55,9 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "multiversx-chain-core" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1088b268cad0d8c1146df9ca71a1f2baaee78267ab75e2202c0c0c71cc4b6e" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" dependencies = [ "bitflags", "multiversx-sc-codec", @@ -65,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.54.1" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4abf60eb027d0b005a1778dc9d670a473065ab8e5bea22eeb6ace7f118dc36f" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", @@ -80,9 +80,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -91,9 +91,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -103,9 +103,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.54.1" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3caeda89d90190c4002f7482e934e3981968d6853f70f865d23c8d2938bd907b" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -116,9 +116,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.54.1" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b10f0b29d4bcd7520e659ae2429ea9a4f02b7203a77d7788bebc79786babd250" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/erc3643/wasm/Cargo.lock b/contracts/erc3643/wasm/Cargo.lock index b1f5a82a..8571c5bc 100644 --- a/contracts/erc3643/wasm/Cargo.lock +++ b/contracts/erc3643/wasm/Cargo.lock @@ -56,9 +56,9 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "multiversx-chain-core" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1088b268cad0d8c1146df9ca71a1f2baaee78267ab75e2202c0c0c71cc4b6e" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" dependencies = [ "bitflags", "multiversx-sc-codec", @@ -66,9 +66,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e5cee0b8c5fbaa9edfee2e38f2162adb01700a0028942d2cd14808cd26b130" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", @@ -81,9 +81,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -92,9 +92,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -104,9 +104,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "931669b080cf793b205bf08b5d1f4a658d0ac0ad628844d9a9d13649a73c7540" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -117,18 +117,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5373903a01dd7d33547b83f0034dc6e12fbbc8e49fcb316a3efb6ef4ff6573a8" +checksum = "74b31cfc990a3052a0e014f749104752a0208f3d11d4dee3c0dd6e6d4ce1908c" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c034ae143cfd971cf0c4d67476af1920a9a0165bd99713458397ac06762fca0d" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/esdt-transfer-with-fee/wasm/Cargo.lock b/contracts/esdt-transfer-with-fee/wasm/Cargo.lock index 16b34fa9..336386c2 100644 --- a/contracts/esdt-transfer-with-fee/wasm/Cargo.lock +++ b/contracts/esdt-transfer-with-fee/wasm/Cargo.lock @@ -55,9 +55,9 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "multiversx-chain-core" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1088b268cad0d8c1146df9ca71a1f2baaee78267ab75e2202c0c0c71cc4b6e" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" dependencies = [ "bitflags", "multiversx-sc-codec", @@ -65,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.54.1" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4abf60eb027d0b005a1778dc9d670a473065ab8e5bea22eeb6ace7f118dc36f" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", @@ -80,9 +80,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -91,9 +91,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -103,9 +103,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.54.1" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3caeda89d90190c4002f7482e934e3981968d6853f70f865d23c8d2938bd907b" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -116,9 +116,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.54.1" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b10f0b29d4bcd7520e659ae2429ea9a4f02b7203a77d7788bebc79786babd250" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/factorial/wasm/Cargo.lock b/contracts/factorial/wasm/Cargo.lock index 9891532e..13aa5fe3 100644 --- a/contracts/factorial/wasm/Cargo.lock +++ b/contracts/factorial/wasm/Cargo.lock @@ -55,9 +55,9 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "multiversx-chain-core" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1088b268cad0d8c1146df9ca71a1f2baaee78267ab75e2202c0c0c71cc4b6e" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" dependencies = [ "bitflags", "multiversx-sc-codec", @@ -65,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.54.1" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4abf60eb027d0b005a1778dc9d670a473065ab8e5bea22eeb6ace7f118dc36f" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", @@ -80,9 +80,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -91,9 +91,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -103,9 +103,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.54.1" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3caeda89d90190c4002f7482e934e3981968d6853f70f865d23c8d2938bd907b" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -116,9 +116,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.54.1" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b10f0b29d4bcd7520e659ae2429ea9a4f02b7203a77d7788bebc79786babd250" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/fair-launch/wasm/Cargo.lock b/contracts/fair-launch/wasm/Cargo.lock index 80a0851a..ac2f4166 100644 --- a/contracts/fair-launch/wasm/Cargo.lock +++ b/contracts/fair-launch/wasm/Cargo.lock @@ -56,9 +56,9 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "multiversx-chain-core" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1088b268cad0d8c1146df9ca71a1f2baaee78267ab75e2202c0c0c71cc4b6e" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" dependencies = [ "bitflags", "multiversx-sc-codec", @@ -66,9 +66,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.54.1" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4abf60eb027d0b005a1778dc9d670a473065ab8e5bea22eeb6ace7f118dc36f" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", @@ -81,9 +81,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -92,9 +92,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -104,9 +104,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.54.1" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3caeda89d90190c4002f7482e934e3981968d6853f70f865d23c8d2938bd907b" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -117,18 +117,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.54.1" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624f7a758e2d5dc3e87fd095cb76d47f3cf4b0cee41b5415aa95b8e323ffe162" +checksum = "74b31cfc990a3052a0e014f749104752a0208f3d11d4dee3c0dd6e6d4ce1908c" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.54.1" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b10f0b29d4bcd7520e659ae2429ea9a4f02b7203a77d7788bebc79786babd250" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/fractional-nfts/wasm/Cargo.lock b/contracts/fractional-nfts/wasm/Cargo.lock index b75f8706..a567fd60 100644 --- a/contracts/fractional-nfts/wasm/Cargo.lock +++ b/contracts/fractional-nfts/wasm/Cargo.lock @@ -56,9 +56,9 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "multiversx-chain-core" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1088b268cad0d8c1146df9ca71a1f2baaee78267ab75e2202c0c0c71cc4b6e" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" dependencies = [ "bitflags", "multiversx-sc-codec", @@ -66,9 +66,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.54.1" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4abf60eb027d0b005a1778dc9d670a473065ab8e5bea22eeb6ace7f118dc36f" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", @@ -81,9 +81,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -92,9 +92,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -104,9 +104,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.54.1" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3caeda89d90190c4002f7482e934e3981968d6853f70f865d23c8d2938bd907b" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -117,18 +117,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.54.1" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624f7a758e2d5dc3e87fd095cb76d47f3cf4b0cee41b5415aa95b8e323ffe162" +checksum = "74b31cfc990a3052a0e014f749104752a0208f3d11d4dee3c0dd6e6d4ce1908c" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.54.1" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b10f0b29d4bcd7520e659ae2429ea9a4f02b7203a77d7788bebc79786babd250" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/liquid-locking/wasm/Cargo.lock b/contracts/liquid-locking/wasm/Cargo.lock index a81dd48e..312eda07 100644 --- a/contracts/liquid-locking/wasm/Cargo.lock +++ b/contracts/liquid-locking/wasm/Cargo.lock @@ -55,9 +55,9 @@ dependencies = [ [[package]] name = "multiversx-chain-core" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1088b268cad0d8c1146df9ca71a1f2baaee78267ab75e2202c0c0c71cc4b6e" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" dependencies = [ "bitflags", "multiversx-sc-codec", @@ -65,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.54.1" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4abf60eb027d0b005a1778dc9d670a473065ab8e5bea22eeb6ace7f118dc36f" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", @@ -80,9 +80,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -91,9 +91,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -103,9 +103,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.54.1" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3caeda89d90190c4002f7482e934e3981968d6853f70f865d23c8d2938bd907b" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -116,9 +116,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.54.1" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b10f0b29d4bcd7520e659ae2429ea9a4f02b7203a77d7788bebc79786babd250" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/lottery-esdt/wasm/Cargo.lock b/contracts/lottery-esdt/wasm/Cargo.lock index b8be796f..876d4f18 100644 --- a/contracts/lottery-esdt/wasm/Cargo.lock +++ b/contracts/lottery-esdt/wasm/Cargo.lock @@ -55,9 +55,9 @@ dependencies = [ [[package]] name = "multiversx-chain-core" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1088b268cad0d8c1146df9ca71a1f2baaee78267ab75e2202c0c0c71cc4b6e" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" dependencies = [ "bitflags", "multiversx-sc-codec", @@ -65,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.54.1" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4abf60eb027d0b005a1778dc9d670a473065ab8e5bea22eeb6ace7f118dc36f" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", @@ -80,9 +80,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -91,9 +91,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -103,9 +103,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.54.1" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3caeda89d90190c4002f7482e934e3981968d6853f70f865d23c8d2938bd907b" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -116,9 +116,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.54.1" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b10f0b29d4bcd7520e659ae2429ea9a4f02b7203a77d7788bebc79786babd250" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/multisig/wasm-multisig-full/Cargo.lock b/contracts/multisig/wasm-multisig-full/Cargo.lock index ca46ed6b..aac6f0a9 100644 --- a/contracts/multisig/wasm-multisig-full/Cargo.lock +++ b/contracts/multisig/wasm-multisig-full/Cargo.lock @@ -54,14 +54,25 @@ dependencies = [ "multiversx-sc-wasm-adapter", ] +[[package]] +name = "multiversx-chain-core" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" +dependencies = [ + "bitflags", + "multiversx-sc-codec", +] + [[package]] name = "multiversx-sc" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -70,9 +81,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -81,9 +92,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -93,9 +104,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -106,18 +117,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daeb48acbd39255868a3241798df2f85050f0ae8d82d6417bd2cd0e30a241855" +checksum = "74b31cfc990a3052a0e014f749104752a0208f3d11d4dee3c0dd6e6d4ce1908c" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/multisig/wasm-multisig-full/Cargo.toml b/contracts/multisig/wasm-multisig-full/Cargo.toml index 116e7d34..50795ea3 100644 --- a/contracts/multisig/wasm-multisig-full/Cargo.toml +++ b/contracts/multisig/wasm-multisig-full/Cargo.toml @@ -1,3 +1,9 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "multisig-full-wasm" version = "0.0.0" diff --git a/contracts/multisig/wasm-multisig-view/Cargo.lock b/contracts/multisig/wasm-multisig-view/Cargo.lock index bd285c2e..ec0fc486 100644 --- a/contracts/multisig/wasm-multisig-view/Cargo.lock +++ b/contracts/multisig/wasm-multisig-view/Cargo.lock @@ -54,14 +54,25 @@ dependencies = [ "multiversx-sc-wasm-adapter", ] +[[package]] +name = "multiversx-chain-core" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" +dependencies = [ + "bitflags", + "multiversx-sc-codec", +] + [[package]] name = "multiversx-sc" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -70,9 +81,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -81,9 +92,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -93,9 +104,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -106,18 +117,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daeb48acbd39255868a3241798df2f85050f0ae8d82d6417bd2cd0e30a241855" +checksum = "74b31cfc990a3052a0e014f749104752a0208f3d11d4dee3c0dd6e6d4ce1908c" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/multisig/wasm-multisig-view/Cargo.toml b/contracts/multisig/wasm-multisig-view/Cargo.toml index 987070e4..694104cd 100644 --- a/contracts/multisig/wasm-multisig-view/Cargo.toml +++ b/contracts/multisig/wasm-multisig-view/Cargo.toml @@ -1,3 +1,9 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "multisig-view-wasm" version = "0.0.0" diff --git a/contracts/multisig/wasm/Cargo.lock b/contracts/multisig/wasm/Cargo.lock index 7407eae9..8f3739d4 100644 --- a/contracts/multisig/wasm/Cargo.lock +++ b/contracts/multisig/wasm/Cargo.lock @@ -54,14 +54,25 @@ dependencies = [ "multiversx-sc-wasm-adapter", ] +[[package]] +name = "multiversx-chain-core" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" +dependencies = [ + "bitflags", + "multiversx-sc-codec", +] + [[package]] name = "multiversx-sc" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -70,9 +81,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -81,9 +92,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -93,9 +104,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -106,18 +117,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daeb48acbd39255868a3241798df2f85050f0ae8d82d6417bd2cd0e30a241855" +checksum = "74b31cfc990a3052a0e014f749104752a0208f3d11d4dee3c0dd6e6d4ce1908c" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/multisig/wasm/Cargo.toml b/contracts/multisig/wasm/Cargo.toml index cbca4764..d93ce7fe 100644 --- a/contracts/multisig/wasm/Cargo.toml +++ b/contracts/multisig/wasm/Cargo.toml @@ -1,3 +1,9 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "multisig-wasm" version = "0.0.0" diff --git a/contracts/mvx-game-sc/wasm/Cargo.lock b/contracts/mvx-game-sc/wasm/Cargo.lock index f0690f0e..c8b39341 100644 --- a/contracts/mvx-game-sc/wasm/Cargo.lock +++ b/contracts/mvx-game-sc/wasm/Cargo.lock @@ -40,9 +40,9 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "multiversx-chain-core" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1088b268cad0d8c1146df9ca71a1f2baaee78267ab75e2202c0c0c71cc4b6e" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" dependencies = [ "bitflags", "multiversx-sc-codec", @@ -50,9 +50,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.54.1" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4abf60eb027d0b005a1778dc9d670a473065ab8e5bea22eeb6ace7f118dc36f" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", @@ -65,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -76,9 +76,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -88,9 +88,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.54.1" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3caeda89d90190c4002f7482e934e3981968d6853f70f865d23c8d2938bd907b" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -101,9 +101,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.54.1" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b10f0b29d4bcd7520e659ae2429ea9a4f02b7203a77d7788bebc79786babd250" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/mystery-box/wasm/Cargo.lock b/contracts/mystery-box/wasm/Cargo.lock index ca8f6ec2..3bb1999d 100644 --- a/contracts/mystery-box/wasm/Cargo.lock +++ b/contracts/mystery-box/wasm/Cargo.lock @@ -38,14 +38,25 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "multiversx-chain-core" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" +dependencies = [ + "bitflags", + "multiversx-sc-codec", +] + [[package]] name = "multiversx-sc" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -54,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -65,9 +76,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -77,9 +88,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -90,18 +101,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daeb48acbd39255868a3241798df2f85050f0ae8d82d6417bd2cd0e30a241855" +checksum = "74b31cfc990a3052a0e014f749104752a0208f3d11d4dee3c0dd6e6d4ce1908c" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/nft-escrow/wasm/Cargo.lock b/contracts/nft-escrow/wasm/Cargo.lock index febf566b..8c798794 100644 --- a/contracts/nft-escrow/wasm/Cargo.lock +++ b/contracts/nft-escrow/wasm/Cargo.lock @@ -50,9 +50,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.54.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e8edabd1e3eea1c85f96485d88116a95f57429b8e4f002444d6465608d1bf5" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", @@ -88,9 +88,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.54.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8712fed727b0f22094616c6398c821899e03f5998dab619acd54ece669de3e8" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -101,9 +101,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.54.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c143d26d1b683d96b10c49f373d980fe573c77f5f7826f97a2214cfd65348f3" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/nft-minter/wasm/Cargo.lock b/contracts/nft-minter/wasm/Cargo.lock index fc67ef21..bd013f85 100644 --- a/contracts/nft-minter/wasm/Cargo.lock +++ b/contracts/nft-minter/wasm/Cargo.lock @@ -50,9 +50,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.54.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e8edabd1e3eea1c85f96485d88116a95f57429b8e4f002444d6465608d1bf5" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", @@ -88,9 +88,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.54.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8712fed727b0f22094616c6398c821899e03f5998dab619acd54ece669de3e8" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -101,9 +101,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.54.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c143d26d1b683d96b10c49f373d980fe573c77f5f7826f97a2214cfd65348f3" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/nft-storage-prepay/wasm/Cargo.lock b/contracts/nft-storage-prepay/wasm/Cargo.lock index 1da03583..f164a81e 100644 --- a/contracts/nft-storage-prepay/wasm/Cargo.lock +++ b/contracts/nft-storage-prepay/wasm/Cargo.lock @@ -50,9 +50,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.54.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e8edabd1e3eea1c85f96485d88116a95f57429b8e4f002444d6465608d1bf5" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", @@ -88,9 +88,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.54.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8712fed727b0f22094616c6398c821899e03f5998dab619acd54ece669de3e8" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -101,9 +101,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.54.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c143d26d1b683d96b10c49f373d980fe573c77f5f7826f97a2214cfd65348f3" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/ping-pong-egld/wasm/Cargo.lock b/contracts/ping-pong-egld/wasm/Cargo.lock index a39836ef..9f873830 100644 --- a/contracts/ping-pong-egld/wasm/Cargo.lock +++ b/contracts/ping-pong-egld/wasm/Cargo.lock @@ -38,14 +38,25 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "multiversx-chain-core" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" +dependencies = [ + "bitflags", + "multiversx-sc-codec", +] + [[package]] name = "multiversx-sc" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -54,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -65,9 +76,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -77,9 +88,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -90,9 +101,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/ping-pong-egld/wasm/Cargo.toml b/contracts/ping-pong-egld/wasm/Cargo.toml index d130e245..b25e1086 100644 --- a/contracts/ping-pong-egld/wasm/Cargo.toml +++ b/contracts/ping-pong-egld/wasm/Cargo.toml @@ -1,3 +1,9 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "ping-pong-egld-wasm" version = "0.0.0" diff --git a/contracts/proxy-deployer/wasm/Cargo.lock b/contracts/proxy-deployer/wasm/Cargo.lock index 1103d4d0..c7ca6487 100644 --- a/contracts/proxy-deployer/wasm/Cargo.lock +++ b/contracts/proxy-deployer/wasm/Cargo.lock @@ -40,9 +40,9 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "multiversx-chain-core" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1088b268cad0d8c1146df9ca71a1f2baaee78267ab75e2202c0c0c71cc4b6e" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" dependencies = [ "bitflags", "multiversx-sc-codec", @@ -50,9 +50,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e5cee0b8c5fbaa9edfee2e38f2162adb01700a0028942d2cd14808cd26b130" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", @@ -65,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -76,9 +76,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -88,9 +88,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "931669b080cf793b205bf08b5d1f4a658d0ac0ad628844d9a9d13649a73c7540" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -101,18 +101,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5373903a01dd7d33547b83f0034dc6e12fbbc8e49fcb316a3efb6ef4ff6573a8" +checksum = "74b31cfc990a3052a0e014f749104752a0208f3d11d4dee3c0dd6e6d4ce1908c" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.54.0" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c034ae143cfd971cf0c4d67476af1920a9a0165bd99713458397ac06762fca0d" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/rewards-distribution/wasm/Cargo.lock b/contracts/rewards-distribution/wasm/Cargo.lock index 2c5b6956..141c2c39 100644 --- a/contracts/rewards-distribution/wasm/Cargo.lock +++ b/contracts/rewards-distribution/wasm/Cargo.lock @@ -38,14 +38,25 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "multiversx-chain-core" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" +dependencies = [ + "bitflags", + "multiversx-sc-codec", +] + [[package]] name = "multiversx-sc" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" +checksum = "ef92d6ad383937403c2055b273153d8d487d7535e4882c614626d0bc2e55ae03" dependencies = [ "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -54,9 +65,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -65,9 +76,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -77,9 +88,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" +checksum = "e823a3b80b6a864ad992c22808e851dacee4387e6d22006bdb1bd9de32f7c9d8" dependencies = [ "hex", "proc-macro2", @@ -90,18 +101,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daeb48acbd39255868a3241798df2f85050f0ae8d82d6417bd2cd0e30a241855" +checksum = "74b31cfc990a3052a0e014f749104752a0208f3d11d4dee3c0dd6e6d4ce1908c" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.53.2" +version = "0.54.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" +checksum = "d780e724ea8262df19e49cf3c06bab8716b6508e785809dc770747e9341282a8" dependencies = [ "multiversx-sc", ] diff --git a/contracts/rewards-distribution/wasm/Cargo.toml b/contracts/rewards-distribution/wasm/Cargo.toml index 7cf71f0c..4a6d6320 100644 --- a/contracts/rewards-distribution/wasm/Cargo.toml +++ b/contracts/rewards-distribution/wasm/Cargo.toml @@ -1,3 +1,9 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "rewards-distribution-wasm" version = "0.0.0" From 96f60c60d20b1c58b13d02ff8f03f92062f90a38 Mon Sep 17 00:00:00 2001 From: BiancaIalangi Date: Thu, 21 Nov 2024 13:54:16 +0200 Subject: [PATCH 12/13] clippy fix --- .../paymaster/tests/paymaster_blackbox_test.rs | 14 ++++++++------ .../tests/compute_brackets_whitebox_test.rs | 3 +-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/contracts/paymaster/tests/paymaster_blackbox_test.rs b/contracts/paymaster/tests/paymaster_blackbox_test.rs index c1f7f79d..816f0498 100644 --- a/contracts/paymaster/tests/paymaster_blackbox_test.rs +++ b/contracts/paymaster/tests/paymaster_blackbox_test.rs @@ -284,9 +284,10 @@ fn test_forward_call_wegld() { state.check_esdt_balance(CALLER_ADDRESS_EXPR, FEE_TOKEN_ID_EXPR, BALANCE); state.check_esdt_balance(CALLER_ADDRESS_EXPR, WEGLD_TOKEN_ID_EXPR, BALANCE); - let mut payments = Vec::new(); - payments.push(TestEsdtTransfer(FEE_TOKEN_ID_EXPR, 0, FEE_AMOUNT)); - payments.push(TestEsdtTransfer(WEGLD_TOKEN_ID_EXPR, 0, FEE_AMOUNT)); + let payments = vec![ + TestEsdtTransfer(FEE_TOKEN_ID_EXPR, 0, FEE_AMOUNT), + TestEsdtTransfer(WEGLD_TOKEN_ID_EXPR, 0, FEE_AMOUNT), + ]; // Call fails because unwrap amount is 0 state @@ -325,9 +326,10 @@ fn test_forward_call_fails_wegld_0_amount() { let failling_amount = 0u64; - let mut payments = Vec::new(); - payments.push(TestEsdtTransfer(FEE_TOKEN_ID_EXPR, 0, FEE_AMOUNT)); - payments.push(TestEsdtTransfer(WEGLD_TOKEN_ID_EXPR, 0, failling_amount)); + let payments = vec![ + TestEsdtTransfer(FEE_TOKEN_ID_EXPR, 0, FEE_AMOUNT), + TestEsdtTransfer(WEGLD_TOKEN_ID_EXPR, 0, failling_amount), + ]; // Call fails because unwrap amount is 0 state diff --git a/contracts/rewards-distribution/tests/compute_brackets_whitebox_test.rs b/contracts/rewards-distribution/tests/compute_brackets_whitebox_test.rs index e5605513..76b7e245 100644 --- a/contracts/rewards-distribution/tests/compute_brackets_whitebox_test.rs +++ b/contracts/rewards-distribution/tests/compute_brackets_whitebox_test.rs @@ -42,8 +42,7 @@ fn test_compute_brackets() { (2_500, 10_000), (25_000, 35_000), (72_000, 40_000), - ]) - .into(); + ]); let computed_brackets = sc.compute_brackets(brackets, 10_000); From cdb5d407e3b2079a7e1609c49bcf5f6b8a075432 Mon Sep 17 00:00:00 2001 From: BiancaIalangi Date: Thu, 21 Nov 2024 14:59:50 +0200 Subject: [PATCH 13/13] fix clippy --- .../mystery-box/tests/mystery_box_mod.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/contracts/mystery-box/tests/mystery_box_mod.rs b/contracts/mystery-box/tests/mystery_box_mod.rs index 684e3b88..8ce0684d 100644 --- a/contracts/mystery-box/tests/mystery_box_mod.rs +++ b/contracts/mystery-box/tests/mystery_box_mod.rs @@ -28,6 +28,12 @@ pub struct MysteryBoxSetup { pub world: ScenarioWorld, } +impl Default for MysteryBoxSetup { + fn default() -> Self { + Self::new() + } +} + impl MysteryBoxSetup { pub fn new() -> Self { let mut mystery_box = MysteryBoxSetup { world: world() }; @@ -77,17 +83,8 @@ impl MysteryBoxSetup { custom_reward_percentage: u64, custom_reward_cooldown: u64, ) { - let mut rewards_list: MultiValueEncoded< - StaticApi, - MultiValue6< - mystery_box_proxy::RewardType, - EgldOrEsdtTokenIdentifier, - BigUint, - ManagedBuffer, - u64, - u64, - >, - > = MultiValueEncoded::new(); + let mut rewards_list: MultiValueEncoded> = + MultiValueEncoded::new(); let mut reward = ( mystery_box_proxy::RewardType::ExperiencePoints, EgldOrEsdtTokenIdentifier::egld(),