From ea3d5254b10f16be4614bc3c8ed13effb29a6028 Mon Sep 17 00:00:00 2001 From: Andrei Baltariu Date: Tue, 22 Oct 2024 14:23:57 +0300 Subject: [PATCH 01/15] Added fee-market contract and removed mock scs Signed-off-by: Andrei Baltariu --- Cargo.lock | 36 -- Cargo.toml | 4 - esdt-safe/wasm-esdt-safe-full/Cargo.lock | 16 - esdt-safe/wasm-esdt-safe-view/Cargo.lock | 16 - esdt-safe/wasm/Cargo.lock | 16 - fee-market/Cargo.toml | 6 - fee-market/src/fee_market_proxy.rs | 54 ++- fee-market/src/fee_type.rs | 31 +- fee-market/src/lib.rs | 37 +- fee-market/src/safe_price_query.rs | 3 +- fee-market/src/subtract_fee.rs | 28 +- fee-market/tests/fee_market_blackbox_test.rs | 359 ++++++++++++++++++ fee-market/wasm-fee-marker-full/Cargo.lock | 16 - fee-market/wasm-fee-marker-full/src/lib.rs | 11 +- fee-market/wasm-multisig-view/Cargo.lock | 16 - fee-market/wasm/Cargo.lock | 16 - fee-market/wasm/src/lib.rs | 11 +- pair-mock/Cargo.toml | 18 - pair-mock/meta/Cargo.toml | 12 - pair-mock/meta/src/main.rs | 3 - pair-mock/multiversx.json | 3 - pair-mock/scenarios/pair_mock.scen.json | 39 -- pair-mock/src/pair_mock.rs | 30 -- pair-mock/tests/pair_mock_scenario_go_test.rs | 10 - pair-mock/tests/pair_mock_scenario_rs_test.rs | 14 - pair-mock/wasm/Cargo.lock | 188 --------- pair-mock/wasm/Cargo.toml | 34 -- pair-mock/wasm/src/lib.rs | 25 -- router-mock/Cargo.toml | 18 - router-mock/meta/Cargo.toml | 12 - router-mock/meta/src/main.rs | 3 - router-mock/multiversx.json | 3 - router-mock/scenarios/router_mock.scen.json | 39 -- router-mock/src/router_mock.rs | 32 -- .../tests/router_mock_scenario_go_test.rs | 10 - .../tests/router_mock_scenario_rs_test.rs | 14 - router-mock/wasm/Cargo.lock | 188 --------- router-mock/wasm/Cargo.toml | 34 -- router-mock/wasm/src/lib.rs | 25 -- 39 files changed, 452 insertions(+), 978 deletions(-) create mode 100644 fee-market/tests/fee_market_blackbox_test.rs delete mode 100644 pair-mock/Cargo.toml delete mode 100644 pair-mock/meta/Cargo.toml delete mode 100644 pair-mock/meta/src/main.rs delete mode 100644 pair-mock/multiversx.json delete mode 100644 pair-mock/scenarios/pair_mock.scen.json delete mode 100644 pair-mock/src/pair_mock.rs delete mode 100644 pair-mock/tests/pair_mock_scenario_go_test.rs delete mode 100644 pair-mock/tests/pair_mock_scenario_rs_test.rs delete mode 100644 pair-mock/wasm/Cargo.lock delete mode 100644 pair-mock/wasm/Cargo.toml delete mode 100644 pair-mock/wasm/src/lib.rs delete mode 100644 router-mock/Cargo.toml delete mode 100644 router-mock/meta/Cargo.toml delete mode 100644 router-mock/meta/src/main.rs delete mode 100644 router-mock/multiversx.json delete mode 100644 router-mock/scenarios/router_mock.scen.json delete mode 100644 router-mock/src/router_mock.rs delete mode 100644 router-mock/tests/router_mock_scenario_go_test.rs delete mode 100644 router-mock/tests/router_mock_scenario_rs_test.rs delete mode 100644 router-mock/wasm/Cargo.lock delete mode 100644 router-mock/wasm/Cargo.toml delete mode 100644 router-mock/wasm/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index db68513d..82d2ae03 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -382,8 +382,6 @@ dependencies = [ "multiversx-sc", "multiversx-sc-scenario", "num-bigint", - "pair-mock", - "router-mock", "transaction", "utils", ] @@ -729,23 +727,6 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "pair-mock" -version = "0.0.0" -dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", - "num-bigint", -] - -[[package]] -name = "pair-mock-meta" -version = "0.0.0" -dependencies = [ - "multiversx-sc-meta-lib", - "pair-mock", -] - [[package]] name = "pathdiff" version = "0.2.1" @@ -835,23 +816,6 @@ dependencies = [ "rand_core", ] -[[package]] -name = "router-mock" -version = "0.0.0" -dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", - "num-bigint", -] - -[[package]] -name = "router-mock-meta" -version = "0.0.0" -dependencies = [ - "multiversx-sc-meta-lib", - "router-mock", -] - [[package]] name = "rustc_version" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index f2d4c760..709827ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,10 +8,6 @@ members = [ "esdt-safe/meta", "fee-market", "fee-market/meta", - "pair-mock", - "pair-mock/meta", - "router-mock", - "router-mock/meta", "header-verifier", "header-verifier/meta", ] diff --git a/esdt-safe/wasm-esdt-safe-full/Cargo.lock b/esdt-safe/wasm-esdt-safe-full/Cargo.lock index 8f8f272f..a5162c4b 100644 --- a/esdt-safe/wasm-esdt-safe-full/Cargo.lock +++ b/esdt-safe/wasm-esdt-safe-full/Cargo.lock @@ -65,8 +65,6 @@ version = "0.0.0" dependencies = [ "bls-signature", "multiversx-sc", - "pair-mock", - "router-mock", "transaction", "utils", ] @@ -185,13 +183,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "pair-mock" -version = "0.0.0" -dependencies = [ - "multiversx-sc", -] - [[package]] name = "proc-macro2" version = "1.0.86" @@ -220,13 +211,6 @@ dependencies = [ "nibble_vec", ] -[[package]] -name = "router-mock" -version = "0.0.0" -dependencies = [ - "multiversx-sc", -] - [[package]] name = "setup-phase" version = "0.0.0" diff --git a/esdt-safe/wasm-esdt-safe-view/Cargo.lock b/esdt-safe/wasm-esdt-safe-view/Cargo.lock index 6abc1bb2..b94ceaa7 100644 --- a/esdt-safe/wasm-esdt-safe-view/Cargo.lock +++ b/esdt-safe/wasm-esdt-safe-view/Cargo.lock @@ -65,8 +65,6 @@ version = "0.0.0" dependencies = [ "bls-signature", "multiversx-sc", - "pair-mock", - "router-mock", "transaction", "utils", ] @@ -185,13 +183,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "pair-mock" -version = "0.0.0" -dependencies = [ - "multiversx-sc", -] - [[package]] name = "proc-macro2" version = "1.0.86" @@ -220,13 +211,6 @@ dependencies = [ "nibble_vec", ] -[[package]] -name = "router-mock" -version = "0.0.0" -dependencies = [ - "multiversx-sc", -] - [[package]] name = "setup-phase" version = "0.0.0" diff --git a/esdt-safe/wasm/Cargo.lock b/esdt-safe/wasm/Cargo.lock index 8e74ec24..f19ccf47 100644 --- a/esdt-safe/wasm/Cargo.lock +++ b/esdt-safe/wasm/Cargo.lock @@ -65,8 +65,6 @@ version = "0.0.0" dependencies = [ "bls-signature", "multiversx-sc", - "pair-mock", - "router-mock", "transaction", "utils", ] @@ -185,13 +183,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "pair-mock" -version = "0.0.0" -dependencies = [ - "multiversx-sc", -] - [[package]] name = "proc-macro2" version = "1.0.86" @@ -220,13 +211,6 @@ dependencies = [ "nibble_vec", ] -[[package]] -name = "router-mock" -version = "0.0.0" -dependencies = [ - "multiversx-sc", -] - [[package]] name = "setup-phase" version = "0.0.0" diff --git a/fee-market/Cargo.toml b/fee-market/Cargo.toml index ccf4693d..f4b3423a 100644 --- a/fee-market/Cargo.toml +++ b/fee-market/Cargo.toml @@ -17,12 +17,6 @@ path = "../common/transaction" [dependencies.bls-signature] path = "../common/bls-signature" -[dependencies.pair-mock] -path = "../pair-mock" - -[dependencies.router-mock] -path = "../router-mock" - [dependencies.multiversx-sc] version = "=0.53.2" diff --git a/fee-market/src/fee_market_proxy.rs b/fee-market/src/fee_market_proxy.rs index 4f4528f4..36ed1bc8 100644 --- a/fee-market/src/fee_market_proxy.rs +++ b/fee-market/src/fee_market_proxy.rs @@ -45,23 +45,17 @@ where { pub fn init< Arg0: ProxyArg>, - Arg1: ProxyArg>, - Arg2: ProxyArg>, - Arg3: ProxyArg>, + Arg1: ProxyArg>>, >( self, esdt_safe_address: Arg0, - price_aggregator_address: Arg1, - usdc_token_id: Arg2, - wegld_token_id: Arg3, + fee: Arg1, ) -> TxTypedDeploy { self.wrapped_tx .payment(NotPayable) .raw_deploy() .argument(&esdt_safe_address) - .argument(&price_aggregator_address) - .argument(&usdc_token_id) - .argument(&wegld_token_id) + .argument(&fee) .original_result() } } @@ -94,41 +88,33 @@ where To: TxTo, Gas: TxGas, { - pub fn enable_fee( - self, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("enableFee") - .original_result() - } - - pub fn disable_fee( + pub fn set_price_aggregator_address< + Arg0: ProxyArg>, + >( self, + price_aggregator_address: Arg0, ) -> TxTypedCall { self.wrapped_tx .payment(NotPayable) - .raw_call("disableFee") + .raw_call("setPriceAggregatorAddress") + .argument(&price_aggregator_address) .original_result() } - pub fn add_fee< - Arg0: ProxyArg>, - Arg1: ProxyArg>, + pub fn set_fee< + Arg0: ProxyArg>, >( self, - base_token: Arg0, - fee_type: Arg1, + fee_struct: Arg0, ) -> TxTypedCall { self.wrapped_tx .payment(NotPayable) .raw_call("addFee") - .argument(&base_token) - .argument(&fee_type) + .argument(&fee_struct) .original_result() } - pub fn remove_fee< + pub fn disable_fee< Arg0: ProxyArg>, >( self, @@ -261,9 +247,19 @@ where } } +#[type_abi] +#[derive(TopDecode, TopEncode, NestedEncode, NestedDecode, Clone)] +pub struct FeeStruct +where + Api: ManagedTypeApi, +{ + pub base_token: TokenIdentifier, + pub fee_type: FeeType, +} + #[rustfmt::skip] #[type_abi] -#[derive(TopEncode, TopDecode)] +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, Clone)] pub enum FeeType where Api: ManagedTypeApi, diff --git a/fee-market/src/fee_type.rs b/fee-market/src/fee_type.rs index 77248d12..9621d436 100644 --- a/fee-market/src/fee_type.rs +++ b/fee-market/src/fee_type.rs @@ -1,7 +1,8 @@ multiversx_sc::imports!(); multiversx_sc::derive_imports!(); -#[derive(TypeAbi, TopEncode, TopDecode)] +#[type_abi] +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, Clone)] pub enum FeeType { None, Fixed { @@ -16,21 +17,28 @@ pub enum FeeType { }, } +#[type_abi] +#[derive(TopDecode, TopEncode, NestedEncode, NestedDecode, Clone)] +pub struct FeeStruct { + pub base_token: TokenIdentifier, + pub fee_type: FeeType, +} + #[multiversx_sc::module] pub trait FeeTypeModule: utils::UtilsModule + bls_signature::BlsSignatureModule { #[only_owner] #[endpoint(addFee)] - fn add_fee(&self, base_token: TokenIdentifier, fee_type: FeeType) { - self.require_valid_token_id(&base_token); + fn set_fee(&self, fee_struct: FeeStruct) { + self.require_valid_token_id(&fee_struct.base_token); - let token = match &fee_type { + let token = match &fee_struct.fee_type { FeeType::None => sc_panic!("Invalid fee type"), FeeType::Fixed { token, per_transfer: _, per_gas: _, } => { - require!(&base_token == token, "Invalid fee"); + require!(&fee_struct.base_token == token, "Invalid fee"); token } @@ -42,17 +50,26 @@ pub trait FeeTypeModule: utils::UtilsModule + bls_signature::BlsSignatureModule }; self.require_valid_token_id(token); + self.fee_enabled().set(true); + self.token_fee(&fee_struct.base_token) + .set(fee_struct.fee_type); + } - self.token_fee(&base_token).set(fee_type); + fn is_fee_enabled(&self) -> bool { + self.fee_enabled().get() } #[only_owner] #[endpoint(removeFee)] - fn remove_fee(&self, base_token: TokenIdentifier) { + fn disable_fee(&self, base_token: TokenIdentifier) { self.token_fee(&base_token).clear(); + self.fee_enabled().set(false); } #[view(getTokenFee)] #[storage_mapper("tokenFee")] fn token_fee(&self, token_id: &TokenIdentifier) -> SingleValueMapper>; + + #[storage_mapper("feeEnabledFlag")] + fn fee_enabled(&self) -> SingleValueMapper; } diff --git a/fee-market/src/lib.rs b/fee-market/src/lib.rs index fe82004b..64cf2562 100644 --- a/fee-market/src/lib.rs +++ b/fee-market/src/lib.rs @@ -1,45 +1,42 @@ #![no_std] +use fee_type::FeeStruct; + multiversx_sc::imports!(); -pub mod enable_fee; pub mod fee_common; +pub mod fee_market_proxy; pub mod fee_type; pub mod price_aggregator; -pub mod safe_price_query; pub mod subtract_fee; -pub mod fee_market_proxy; #[multiversx_sc::contract] pub trait FeeMarket: - enable_fee::EnableFeeModule - + fee_common::CommonFeeModule + fee_common::CommonFeeModule + fee_type::FeeTypeModule + subtract_fee::SubtractFeeModule + price_aggregator::PriceAggregatorModule - + safe_price_query::SafePriceQueryModule + utils::UtilsModule + bls_signature::BlsSignatureModule { #[init] - fn init( - &self, - esdt_safe_address: ManagedAddress, - price_aggregator_address: ManagedAddress, - usdc_token_id: TokenIdentifier, - wegld_token_id: TokenIdentifier, - ) { + fn init(&self, esdt_safe_address: ManagedAddress, fee: Option>) { self.require_sc_address(&esdt_safe_address); - self.require_sc_address(&price_aggregator_address); - self.esdt_safe_address().set(esdt_safe_address); - self.price_aggregator_address() - .set(price_aggregator_address); - self.usdc_token_id().set(usdc_token_id); - self.wegld_token_id().set(wegld_token_id); - self.fee_enabled().set(true); + + match fee { + Some(fee_struct) => self.set_fee(fee_struct), + _ => self.fee_enabled().set(false), + } } #[upgrade] fn upgrade(&self) {} + + #[endpoint(setPriceAggregatorAddress)] + fn set_price_aggregator_address(&self, price_aggregator_address: ManagedAddress) { + self.require_sc_address(&price_aggregator_address); + self.price_aggregator_address() + .set(price_aggregator_address); + } } diff --git a/fee-market/src/safe_price_query.rs b/fee-market/src/safe_price_query.rs index 7949c532..755c5a2a 100644 --- a/fee-market/src/safe_price_query.rs +++ b/fee-market/src/safe_price_query.rs @@ -58,8 +58,7 @@ pub trait SafePriceQueryModule: price_aggregator::PriceAggregatorModule { let token_to_wegld_pair = self.call_get_pair(token_id, &wegld_token_id); if !token_to_wegld_pair.is_zero() { - let wegld_to_usdc_pair = - self.call_get_pair(&wegld_token_id, &usdc_token_id); + let wegld_to_usdc_pair = self.call_get_pair(&wegld_token_id, &usdc_token_id); require!( !wegld_to_usdc_pair.is_zero(), "Invalid WEGLD-USDC pair address from router" diff --git a/fee-market/src/subtract_fee.rs b/fee-market/src/subtract_fee.rs index 458eda40..db5e440f 100644 --- a/fee-market/src/subtract_fee.rs +++ b/fee-market/src/subtract_fee.rs @@ -30,8 +30,7 @@ pub struct SubtractPaymentArguments { #[multiversx_sc::module] pub trait SubtractFeeModule: - crate::enable_fee::EnableFeeModule - + crate::fee_type::FeeTypeModule + crate::fee_type::FeeTypeModule + crate::fee_common::CommonFeeModule + crate::price_aggregator::PriceAggregatorModule + utils::UtilsModule @@ -68,6 +67,7 @@ pub trait SubtractFeeModule: }); percentage_sum += percentage as u64; } + require!( percentage_sum == TOTAL_PERCENTAGE as u64, "Invalid percentage sum" @@ -80,7 +80,6 @@ pub trait SubtractFeeModule: } let mut remaining_fees = accumulated_fees.clone(); - for pair in &pairs { let amount_to_send = &(&accumulated_fees * &BigUint::from(pair.percentage)) / &percentage_total; @@ -88,8 +87,10 @@ pub trait SubtractFeeModule: if amount_to_send > 0 { remaining_fees -= &amount_to_send; - self.send() - .direct_esdt(&pair.address, &token_id, 0, &amount_to_send); + self.tx() + .to(&pair.address) + .payment(EsdtTokenPayment::new(token_id.clone(), 0, amount_to_send)) + .transfer(); } } @@ -113,8 +114,7 @@ pub trait SubtractFeeModule: let payment = self.call_value().single_esdt(); if !self.is_fee_enabled() || self.users_whitelist().contains(&original_caller) { - self.send() - .direct_esdt(&caller, &payment.token_identifier, 0, &payment.amount); + self.tx().to(&caller).payment(&payment).transfer(); return FinalPayment { fee: EsdtTokenPayment::new(payment.token_identifier.clone(), 0, BigUint::zero()), @@ -123,14 +123,19 @@ pub trait SubtractFeeModule: } let final_payment = self.subtract_fee_by_type(payment, total_transfers, opt_gas_limit); - let _ = self - .tokens_for_fees() + + self.tokens_for_fees() .insert(final_payment.fee.token_identifier.clone()); + self.accumulated_fees(&final_payment.fee.token_identifier) .update(|amt| *amt += &final_payment.fee.amount); - self.send() - .direct_non_zero_esdt_payment(&caller, &final_payment.remaining_tokens); + if final_payment.remaining_tokens.amount > 0 { + self.tx() + .to(&original_caller) + .payment(&final_payment.remaining_tokens) + .transfer(); + } final_payment } @@ -197,7 +202,6 @@ pub trait SubtractFeeModule: } let mut payment = args.payment; - require!(total_fee <= payment.amount, "Payment does not cover fee"); payment.amount -= &total_fee; diff --git a/fee-market/tests/fee_market_blackbox_test.rs b/fee-market/tests/fee_market_blackbox_test.rs new file mode 100644 index 00000000..f7d43b25 --- /dev/null +++ b/fee-market/tests/fee_market_blackbox_test.rs @@ -0,0 +1,359 @@ +use fee_market::fee_market_proxy::{self, FeeStruct, FeeType}; + +use multiversx_sc::{ + imports::OptionalValue, + types::{ + BigUint, EsdtTokenPayment, ManagedVec, MultiValueEncoded, ReturnsResultUnmanaged, + TestAddress, TestSCAddress, TestTokenIdentifier, + }, +}; +use multiversx_sc_scenario::{ + api::StaticApi, imports::MxscPath, ExpectError, ScenarioTxRun, ScenarioWorld, +}; + +const FEE_MARKET_CODE_PATH: MxscPath = MxscPath::new("output/fee-market.mxsc.json"); +const FEE_MARKET_ADDRESS: TestSCAddress = TestSCAddress::new("fee-market"); + +const ESDT_SAFE_ADDRESS: TestSCAddress = TestSCAddress::new("esdt-safe"); +const ESDT_SAFE_CODE_PATH: MxscPath = MxscPath::new("../esdt-safe/output/esdt-safe.mxsc.json"); + +const OWNER_ADDRESS: TestAddress = TestAddress::new("owner"); +const USER_ADDRESS: TestAddress = TestAddress::new("user"); + +const TOKEN_ID: TestTokenIdentifier = TestTokenIdentifier::new("TDK-123456"); +const DIFFERENT_TOKEN_ID: TestTokenIdentifier = TestTokenIdentifier::new("WRONG-123456"); +const ANOTHER_TOKEN_ID: TestTokenIdentifier = TestTokenIdentifier::new("ANOTHER-123456"); +const WRONG_TOKEN_ID: TestTokenIdentifier = TestTokenIdentifier::new("WRONG-TOKEN"); + +fn world() -> ScenarioWorld { + let mut blockchain = ScenarioWorld::new(); + + blockchain.register_contract(FEE_MARKET_CODE_PATH, fee_market::ContractBuilder); + + blockchain +} + +struct FeeMarketTestState { + world: ScenarioWorld, +} + +impl FeeMarketTestState { + fn new() -> Self { + let mut world = world(); + + world + .account(OWNER_ADDRESS) + .esdt_balance(TOKEN_ID, 1000) + .nonce(1); + + world + .account(USER_ADDRESS) + .esdt_balance(TOKEN_ID, 1000) + .nonce(1); + + world + .account(ESDT_SAFE_ADDRESS) + .code(ESDT_SAFE_CODE_PATH) + .esdt_balance(TOKEN_ID, 1000) + .esdt_balance(DIFFERENT_TOKEN_ID, 1000) + .esdt_balance(ANOTHER_TOKEN_ID, 1000) + .nonce(1); + + Self { world } + } + + fn deploy_fee_market(&mut self) -> &mut Self { + let fee = FeeStruct { + base_token: TOKEN_ID.to_token_identifier(), + fee_type: FeeType::Fixed { + token: TOKEN_ID.to_token_identifier(), + per_transfer: BigUint::from(100u64), + per_gas: BigUint::from(0u64), + }, + }; + + self.world + .tx() + .from(OWNER_ADDRESS) + .typed(fee_market_proxy::FeeMarketProxy) + .init(ESDT_SAFE_ADDRESS, Option::Some(fee)) + .code(FEE_MARKET_CODE_PATH) + .new_address(FEE_MARKET_ADDRESS) + .run(); + + self + } + + fn substract_fee(&mut self, payment_wanted: &str, error_status: Option) { + let payment: EsdtTokenPayment = match payment_wanted { + "Correct" => { + EsdtTokenPayment::new(TOKEN_ID.to_token_identifier(), 0u64, BigUint::from(200u64)) + } + "InvalidToken" => EsdtTokenPayment::new( + DIFFERENT_TOKEN_ID.to_token_identifier::(), + 0u64, + BigUint::from(10u64), + ), + "AnyToken" => EsdtTokenPayment::new( + ANOTHER_TOKEN_ID.to_token_identifier(), + 0u64, + BigUint::from(10u64), + ), + "Less than fee" => { + EsdtTokenPayment::new(TOKEN_ID.to_token_identifier(), 0u64, BigUint::from(0u64)) + } + _ => { + panic!("Invalid payment wanted"); + } + }; + + match error_status { + Some(error) => { + self.world + .tx() + .from(ESDT_SAFE_ADDRESS) + .to(FEE_MARKET_ADDRESS) + .typed(fee_market_proxy::FeeMarketProxy) + .subtract_fee(USER_ADDRESS, 1u8, OptionalValue::Some(30u64)) + .payment(payment) + .returns(error) + .run(); + } + None => { + self.world + .tx() + .from(ESDT_SAFE_ADDRESS) + .to(FEE_MARKET_ADDRESS) + .typed(fee_market_proxy::FeeMarketProxy) + .subtract_fee(USER_ADDRESS, 1u8, OptionalValue::Some(30u64)) + .payment(payment) + .returns(ReturnsResultUnmanaged) + .run(); + } + } + } + + fn disable_fee(&mut self) { + self.world + .tx() + .from(OWNER_ADDRESS) + .to(FEE_MARKET_ADDRESS) + .typed(fee_market_proxy::FeeMarketProxy) + .disable_fee(TOKEN_ID) + .run(); + } + + fn add_fee( + &mut self, + token_id: TestTokenIdentifier, + fee_type: &str, + error_status: Option, + ) { + let fee_struct: FeeStruct = match fee_type { + "None" => { + let fee_type = FeeType::None; + FeeStruct { + base_token: token_id.to_token_identifier(), + fee_type, + } + } + "Fixed" => { + let fee_type = FeeType::Fixed { + token: TOKEN_ID.to_token_identifier(), + per_transfer: BigUint::from(10u8), + per_gas: BigUint::from(10u8), + }; + FeeStruct { + base_token: token_id.to_token_identifier(), + fee_type, + } + } + "AnyToken" => { + let fee_type = FeeType::AnyToken { + base_fee_token: DIFFERENT_TOKEN_ID.to_token_identifier(), + per_transfer: BigUint::from(10u8), + per_gas: BigUint::from(10u8), + }; + FeeStruct { + base_token: token_id.to_token_identifier(), + fee_type, + } + } + "AnyTokenWrong" => { + let fee_type = FeeType::AnyToken { + base_fee_token: WRONG_TOKEN_ID.to_token_identifier(), + per_transfer: BigUint::from(10u8), + per_gas: BigUint::from(10u8), + }; + FeeStruct { + base_token: token_id.to_token_identifier(), + fee_type, + } + } + _ => { + panic!("Invalid fee type"); + } + }; + + match error_status { + Some(error) => { + self.world + .tx() + .from(OWNER_ADDRESS) + .to(FEE_MARKET_ADDRESS) + .typed(fee_market_proxy::FeeMarketProxy) + .set_fee(fee_struct) + .returns(error) + .run(); + } + None => { + self.world + .tx() + .from(OWNER_ADDRESS) + .to(FEE_MARKET_ADDRESS) + .typed(fee_market_proxy::FeeMarketProxy) + .set_fee(fee_struct) + .run(); + } + } + } + + fn add_users_to_whitelist(&mut self) { + let mut users_vec = ManagedVec::new(); + users_vec.push(USER_ADDRESS.to_managed_address()); + let users = MultiValueEncoded::from(users_vec); + self.world + .tx() + .from(OWNER_ADDRESS) + .to(FEE_MARKET_ADDRESS) + .typed(fee_market_proxy::FeeMarketProxy) + .add_users_to_whitelist(users) + .run(); + } + + fn check_balance_sc(&mut self, address: TestSCAddress, expected_balance: u64) { + self.world + .check_account(address) + .esdt_balance(TOKEN_ID, expected_balance); + } + + fn check_account(&mut self, address: TestAddress, expected_balance: u64) { + self.world + .check_account(address) + .esdt_balance(TOKEN_ID, expected_balance); + } +} + +#[test] +fn test_deploy_fee_market() { + let mut state = FeeMarketTestState::new(); + + state.deploy_fee_market(); +} + +#[test] +fn test_add_fee_wrong_params() { + let mut state = FeeMarketTestState::new(); + + state.deploy_fee_market(); + + state.add_fee( + WRONG_TOKEN_ID, + "Fixed", + Some(ExpectError(4, "Invalid token ID")), + ); + + state.add_fee(TOKEN_ID, "None", Some(ExpectError(4, "Invalid fee type"))); + + state.add_fee( + DIFFERENT_TOKEN_ID, + "Fixed", + Some(ExpectError(4, "Invalid fee")), + ); + + state.add_fee( + TOKEN_ID, + "AnyTokenWrong", + Some(ExpectError(4, "Invalid token ID")), + ); +} + +#[test] +fn test_substract_fee_no_fee() { + let mut state = FeeMarketTestState::new(); + + state.deploy_fee_market(); + state.disable_fee(); + + state.substract_fee("Correct", None); + + state.check_balance_sc(ESDT_SAFE_ADDRESS, 1000); + state.check_account(USER_ADDRESS, 1000); +} + +#[test] +fn test_substract_fee_whitelisted() { + let mut state = FeeMarketTestState::new(); + + state.deploy_fee_market(); + state.add_users_to_whitelist(); + + state.substract_fee("Correct", None); + + state.check_balance_sc(ESDT_SAFE_ADDRESS, 1000); + state.check_account(USER_ADDRESS, 1000); +} + +#[test] +fn test_substract_fee_invalid_payment_token() { + let mut state = FeeMarketTestState::new(); + + state.deploy_fee_market(); + + state.substract_fee( + "InvalidToken", + Some(ExpectError(4, "Token not accepted as fee")), + ); + + state.check_balance_sc(ESDT_SAFE_ADDRESS, 1000); + state.check_account(USER_ADDRESS, 1000); +} + +// FAILS => get_safe_price should be mocked here in order to make this test work +// #[test] +// fn test_substract_fee_any_token() { +// let mut state = FeeMarketTestState::new(); + +// state.deploy_fee_market(); +// state.add_fee(ANOTHER_TOKEN_ID, "AnyToken", None); + +// state.substract_fee("AnyToken", Some(ExpectError(4, "Invalid token provided for fee"))); + +// } + +#[test] +fn test_substract_fixed_fee_payment_not_covered() { + let mut state = FeeMarketTestState::new(); + + state.deploy_fee_market(); + + state.substract_fee( + "Less than fee", + Some(ExpectError(4, "Payment does not cover fee")), + ); + + state.check_balance_sc(ESDT_SAFE_ADDRESS, 1000); + state.check_account(USER_ADDRESS, 1000); +} + +#[test] +fn test_substract_fee_fixed_payment_bigger_than_fee() { + let mut state = FeeMarketTestState::new(); + + state.deploy_fee_market(); + + state.substract_fee("Correct", None); + + state.check_balance_sc(ESDT_SAFE_ADDRESS, 800); + state.check_account(USER_ADDRESS, 1100); +} diff --git a/fee-market/wasm-fee-marker-full/Cargo.lock b/fee-market/wasm-fee-marker-full/Cargo.lock index 5dec687e..6d42739d 100644 --- a/fee-market/wasm-fee-marker-full/Cargo.lock +++ b/fee-market/wasm-fee-marker-full/Cargo.lock @@ -48,8 +48,6 @@ version = "0.0.0" dependencies = [ "bls-signature", "multiversx-sc", - "pair-mock", - "router-mock", "transaction", "utils", ] @@ -143,13 +141,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "pair-mock" -version = "0.0.0" -dependencies = [ - "multiversx-sc", -] - [[package]] name = "proc-macro2" version = "1.0.86" @@ -178,13 +169,6 @@ dependencies = [ "nibble_vec", ] -[[package]] -name = "router-mock" -version = "0.0.0" -dependencies = [ - "multiversx-sc", -] - [[package]] name = "smallvec" version = "1.13.2" diff --git a/fee-market/wasm-fee-marker-full/src/lib.rs b/fee-market/wasm-fee-marker-full/src/lib.rs index 9f2c6a7e..a07b92d6 100644 --- a/fee-market/wasm-fee-marker-full/src/lib.rs +++ b/fee-market/wasm-fee-marker-full/src/lib.rs @@ -6,9 +6,9 @@ // Init: 1 // Upgrade: 1 -// Endpoints: 13 +// Endpoints: 12 // Async Callback (empty): 1 -// Total number of exported functions: 16 +// Total number of exported functions: 15 #![no_std] @@ -20,10 +20,9 @@ multiversx_sc_wasm_adapter::endpoints! { ( init => init upgrade => upgrade - enableFee => enable_fee - disableFee => disable_fee - addFee => add_fee - removeFee => remove_fee + setPriceAggregatorAddress => set_price_aggregator_address + addFee => set_fee + removeFee => disable_fee getTokenFee => token_fee addUsersToWhitelist => add_users_to_whitelist removeUsersFromWhitelist => remove_users_from_whitelist diff --git a/fee-market/wasm-multisig-view/Cargo.lock b/fee-market/wasm-multisig-view/Cargo.lock index f5d7b007..e72e7c7f 100644 --- a/fee-market/wasm-multisig-view/Cargo.lock +++ b/fee-market/wasm-multisig-view/Cargo.lock @@ -40,8 +40,6 @@ version = "0.0.0" dependencies = [ "bls-signature", "multiversx-sc", - "pair-mock", - "router-mock", "transaction", "utils", ] @@ -143,13 +141,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "pair-mock" -version = "0.0.0" -dependencies = [ - "multiversx-sc", -] - [[package]] name = "proc-macro2" version = "1.0.86" @@ -178,13 +169,6 @@ dependencies = [ "nibble_vec", ] -[[package]] -name = "router-mock" -version = "0.0.0" -dependencies = [ - "multiversx-sc", -] - [[package]] name = "smallvec" version = "1.13.2" diff --git a/fee-market/wasm/Cargo.lock b/fee-market/wasm/Cargo.lock index 68bf5c22..4381e40d 100644 --- a/fee-market/wasm/Cargo.lock +++ b/fee-market/wasm/Cargo.lock @@ -40,8 +40,6 @@ version = "0.0.0" dependencies = [ "bls-signature", "multiversx-sc", - "pair-mock", - "router-mock", "transaction", "utils", ] @@ -143,13 +141,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "pair-mock" -version = "0.0.0" -dependencies = [ - "multiversx-sc", -] - [[package]] name = "proc-macro2" version = "1.0.86" @@ -178,13 +169,6 @@ dependencies = [ "nibble_vec", ] -[[package]] -name = "router-mock" -version = "0.0.0" -dependencies = [ - "multiversx-sc", -] - [[package]] name = "smallvec" version = "1.13.2" diff --git a/fee-market/wasm/src/lib.rs b/fee-market/wasm/src/lib.rs index 9f2c6a7e..a07b92d6 100644 --- a/fee-market/wasm/src/lib.rs +++ b/fee-market/wasm/src/lib.rs @@ -6,9 +6,9 @@ // Init: 1 // Upgrade: 1 -// Endpoints: 13 +// Endpoints: 12 // Async Callback (empty): 1 -// Total number of exported functions: 16 +// Total number of exported functions: 15 #![no_std] @@ -20,10 +20,9 @@ multiversx_sc_wasm_adapter::endpoints! { ( init => init upgrade => upgrade - enableFee => enable_fee - disableFee => disable_fee - addFee => add_fee - removeFee => remove_fee + setPriceAggregatorAddress => set_price_aggregator_address + addFee => set_fee + removeFee => disable_fee getTokenFee => token_fee addUsersToWhitelist => add_users_to_whitelist removeUsersFromWhitelist => remove_users_from_whitelist diff --git a/pair-mock/Cargo.toml b/pair-mock/Cargo.toml deleted file mode 100644 index 10e5f309..00000000 --- a/pair-mock/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "pair-mock" -version = "0.0.0" -authors = ["you"] -edition = "2021" -publish = false - -[lib] -path = "src/pair_mock.rs" - -[dependencies.multiversx-sc] -version = "0.53.2" - -[dev-dependencies] -num-bigint = "0.4" - -[dev-dependencies.multiversx-sc-scenario] -version = "0.53.2" diff --git a/pair-mock/meta/Cargo.toml b/pair-mock/meta/Cargo.toml deleted file mode 100644 index c76b044f..00000000 --- a/pair-mock/meta/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "pair-mock-meta" -version = "0.0.0" -edition = "2021" -publish = false - -[dependencies.pair-mock] -path = ".." - -[dependencies.multiversx-sc-meta-lib] -version = "0.53.2" -default-features = false diff --git a/pair-mock/meta/src/main.rs b/pair-mock/meta/src/main.rs deleted file mode 100644 index 17e5421a..00000000 --- a/pair-mock/meta/src/main.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - multiversx_sc_meta_lib::cli_main::(); -} diff --git a/pair-mock/multiversx.json b/pair-mock/multiversx.json deleted file mode 100644 index 73655396..00000000 --- a/pair-mock/multiversx.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "language": "rust" -} \ No newline at end of file diff --git a/pair-mock/scenarios/pair_mock.scen.json b/pair-mock/scenarios/pair_mock.scen.json deleted file mode 100644 index 98fb2699..00000000 --- a/pair-mock/scenarios/pair_mock.scen.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "name": "empty", - "steps": [ - { - "step": "setState", - "accounts": { - "address:owner": { - "nonce": "1", - "balance": "0" - } - }, - "newAddresses": [ - { - "creatorAddress": "address:owner", - "creatorNonce": "1", - "newAddress": "sc:empty" - } - ] - }, - { - "step": "scDeploy", - "id": "deploy", - "tx": { - "from": "address:owner", - "contractCode": "mxsc:../output/pair-mock.mxsc.json", - "arguments": ["str:usdc"], - "gasLimit": "5,000,000", - "gasPrice": "0" - }, - "expect": { - "out": [], - "status": "", - "logs": [], - "gas": "*", - "refund": "*" - } - } - ] -} diff --git a/pair-mock/src/pair_mock.rs b/pair-mock/src/pair_mock.rs deleted file mode 100644 index f2d85de3..00000000 --- a/pair-mock/src/pair_mock.rs +++ /dev/null @@ -1,30 +0,0 @@ -#![no_std] - -multiversx_sc::imports!(); - -pub const DEFAULT_TOKEN_PRICE: u64 = 1_000_000; // $1 -pub const DEFAULT_TOKEN_DECIMALS: u32 = 18; - -#[multiversx_sc::derive::contract] -pub trait PairMock { - #[init] - fn init(&self, usdc_token_id: TokenIdentifier) { - self.usdc_token_id().set(usdc_token_id); - } - - #[view(getSafePriceByTimestampOffset)] - fn get_safe_price_by_timestamp_offset( - &self, - _pair_address: ManagedAddress, - _timestamp_offset: u64, - input_payment: EsdtTokenPayment, - ) -> EsdtTokenPayment { - let amount = input_payment.amount * BigUint::from(DEFAULT_TOKEN_PRICE) - / BigUint::from(10u32.pow(DEFAULT_TOKEN_DECIMALS)); - - EsdtTokenPayment::new(self.usdc_token_id().get(), 0, amount) - } - - #[storage_mapper("usdcTokenId")] - fn usdc_token_id(&self) -> SingleValueMapper; -} diff --git a/pair-mock/tests/pair_mock_scenario_go_test.rs b/pair-mock/tests/pair_mock_scenario_go_test.rs deleted file mode 100644 index 2e9f780b..00000000 --- a/pair-mock/tests/pair_mock_scenario_go_test.rs +++ /dev/null @@ -1,10 +0,0 @@ -use multiversx_sc_scenario::*; - -fn world() -> ScenarioWorld { - ScenarioWorld::vm_go() -} - -#[test] -fn empty_go() { - world().run("scenarios/pair_mock.scen.json"); -} diff --git a/pair-mock/tests/pair_mock_scenario_rs_test.rs b/pair-mock/tests/pair_mock_scenario_rs_test.rs deleted file mode 100644 index 92af7b8e..00000000 --- a/pair-mock/tests/pair_mock_scenario_rs_test.rs +++ /dev/null @@ -1,14 +0,0 @@ -use multiversx_sc_scenario::*; - -fn world() -> ScenarioWorld { - let mut blockchain = ScenarioWorld::new(); - // blockchain.set_current_dir_from_workspace("relative path to your workspace, if applicable"); - - blockchain.register_contract("mxsc:output/pair-mock.mxsc.json", pair_mock::ContractBuilder); - blockchain -} - -#[test] -fn empty_rs() { - world().run("scenarios/pair_mock.scen.json"); -} diff --git a/pair-mock/wasm/Cargo.lock b/pair-mock/wasm/Cargo.lock deleted file mode 100644 index 424ade8c..00000000 --- a/pair-mock/wasm/Cargo.lock +++ /dev/null @@ -1,188 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "arrayvec" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" - -[[package]] -name = "autocfg" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" - -[[package]] -name = "bitflags" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" - -[[package]] -name = "endian-type" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hex-literal" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" - -[[package]] -name = "multiversx-sc" -version = "0.53.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" -dependencies = [ - "bitflags", - "hex-literal", - "multiversx-sc-codec", - "multiversx-sc-derive", - "num-traits", - "unwrap-infallible", -] - -[[package]] -name = "multiversx-sc-codec" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" -dependencies = [ - "arrayvec", - "multiversx-sc-codec-derive", - "unwrap-infallible", -] - -[[package]] -name = "multiversx-sc-codec-derive" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" -dependencies = [ - "hex", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "multiversx-sc-derive" -version = "0.53.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" -dependencies = [ - "hex", - "proc-macro2", - "quote", - "radix_trie", - "syn", -] - -[[package]] -name = "multiversx-sc-wasm-adapter" -version = "0.53.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" -dependencies = [ - "multiversx-sc", -] - -[[package]] -name = "nibble_vec" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a5d83df9f36fe23f0c3648c6bbb8b0298bb5f1939c8f2704431371f4b84d43" -dependencies = [ - "smallvec", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - -[[package]] -name = "pair-mock" -version = "0.0.0" -dependencies = [ - "multiversx-sc", -] - -[[package]] -name = "pair-mock-wasm" -version = "0.0.0" -dependencies = [ - "multiversx-sc-wasm-adapter", - "pair-mock", -] - -[[package]] -name = "proc-macro2" -version = "1.0.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "radix_trie" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c069c179fcdc6a2fe24d8d18305cf085fdbd4f922c041943e203685d6a1c58fd" -dependencies = [ - "endian-type", - "nibble_vec", -] - -[[package]] -name = "smallvec" -version = "1.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" - -[[package]] -name = "syn" -version = "2.0.77" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "unicode-ident" -version = "1.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" - -[[package]] -name = "unwrap-infallible" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "151ac09978d3c2862c4e39b557f4eceee2cc72150bc4cb4f16abf061b6e381fb" diff --git a/pair-mock/wasm/Cargo.toml b/pair-mock/wasm/Cargo.toml deleted file mode 100644 index bc95dafd..00000000 --- a/pair-mock/wasm/Cargo.toml +++ /dev/null @@ -1,34 +0,0 @@ -# Code generated by the multiversx-sc build system. DO NOT EDIT. - -# ########################################## -# ############## AUTO-GENERATED ############# -# ########################################## - -[package] -name = "pair-mock-wasm" -version = "0.0.0" -edition = "2021" -publish = false - -[lib] -crate-type = ["cdylib"] - -[profile.release] -codegen-units = 1 -opt-level = "z" -lto = true -debug = false -panic = "abort" -overflow-checks = false - -[profile.dev] -panic = "abort" - -[dependencies.pair-mock] -path = ".." - -[dependencies.multiversx-sc-wasm-adapter] -version = "0.53.2" - -[workspace] -members = ["."] diff --git a/pair-mock/wasm/src/lib.rs b/pair-mock/wasm/src/lib.rs deleted file mode 100644 index e87dd4d4..00000000 --- a/pair-mock/wasm/src/lib.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Code generated by the multiversx-sc build system. DO NOT EDIT. - -//////////////////////////////////////////////////// -////////////////// AUTO-GENERATED ////////////////// -//////////////////////////////////////////////////// - -// Init: 1 -// Endpoints: 1 -// Async Callback (empty): 1 -// Total number of exported functions: 3 - -#![no_std] - -multiversx_sc_wasm_adapter::allocator!(); -multiversx_sc_wasm_adapter::panic_handler!(); - -multiversx_sc_wasm_adapter::endpoints! { - pair_mock - ( - init => init - getSafePriceByTimestampOffset => get_safe_price_by_timestamp_offset - ) -} - -multiversx_sc_wasm_adapter::async_callback_empty! {} diff --git a/router-mock/Cargo.toml b/router-mock/Cargo.toml deleted file mode 100644 index 8d34cdf4..00000000 --- a/router-mock/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "router-mock" -version = "0.0.0" -authors = ["you"] -edition = "2021" -publish = false - -[lib] -path = "src/router_mock.rs" - -[dependencies.multiversx-sc] -version = "0.53.2" - -[dev-dependencies] -num-bigint = "0.4" - -[dev-dependencies.multiversx-sc-scenario] -version = "0.53.2" diff --git a/router-mock/meta/Cargo.toml b/router-mock/meta/Cargo.toml deleted file mode 100644 index 7d8feaa4..00000000 --- a/router-mock/meta/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "router-mock-meta" -version = "0.0.0" -edition = "2021" -publish = false - -[dependencies.router-mock] -path = ".." - -[dependencies.multiversx-sc-meta-lib] -version = "0.53.2" -default-features = false diff --git a/router-mock/meta/src/main.rs b/router-mock/meta/src/main.rs deleted file mode 100644 index c0eaaddb..00000000 --- a/router-mock/meta/src/main.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - multiversx_sc_meta_lib::cli_main::(); -} diff --git a/router-mock/multiversx.json b/router-mock/multiversx.json deleted file mode 100644 index 73655396..00000000 --- a/router-mock/multiversx.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "language": "rust" -} \ No newline at end of file diff --git a/router-mock/scenarios/router_mock.scen.json b/router-mock/scenarios/router_mock.scen.json deleted file mode 100644 index e040fe9c..00000000 --- a/router-mock/scenarios/router_mock.scen.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "name": "empty", - "steps": [ - { - "step": "setState", - "accounts": { - "address:owner": { - "nonce": "1", - "balance": "0" - } - }, - "newAddresses": [ - { - "creatorAddress": "address:owner", - "creatorNonce": "1", - "newAddress": "sc:empty" - } - ] - }, - { - "step": "scDeploy", - "id": "deploy", - "tx": { - "from": "address:owner", - "contractCode": "mxsc:../output/router-mock.mxsc.json", - "arguments": ["address:pair", "str:usdc"], - "gasLimit": "5,000,000", - "gasPrice": "0" - }, - "expect": { - "out": [], - "status": "", - "logs": [], - "gas": "*", - "refund": "*" - } - } - ] -} diff --git a/router-mock/src/router_mock.rs b/router-mock/src/router_mock.rs deleted file mode 100644 index bad72f5b..00000000 --- a/router-mock/src/router_mock.rs +++ /dev/null @@ -1,32 +0,0 @@ -#![no_std] - -multiversx_sc::imports!(); - -#[multiversx_sc::contract] -pub trait RouterMock { - #[init] - fn init(&self, pair_addr: ManagedAddress, usdc_token_id: TokenIdentifier) { - self.pair_address().set(pair_addr); - self.usdc_token_id().set(usdc_token_id); - } - - #[view(getPair)] - fn get_pair( - &self, - first_token_id: TokenIdentifier, - second_token_id: TokenIdentifier, - ) -> ManagedAddress { - let usdc_token_id = self.usdc_token_id().get(); - if first_token_id == usdc_token_id || second_token_id == usdc_token_id { - self.pair_address().get() - } else { - ManagedAddress::zero() - } - } - - #[storage_mapper("pairAddress")] - fn pair_address(&self) -> SingleValueMapper; - - #[storage_mapper("usdcTokenId")] - fn usdc_token_id(&self) -> SingleValueMapper; -} diff --git a/router-mock/tests/router_mock_scenario_go_test.rs b/router-mock/tests/router_mock_scenario_go_test.rs deleted file mode 100644 index 6f0120df..00000000 --- a/router-mock/tests/router_mock_scenario_go_test.rs +++ /dev/null @@ -1,10 +0,0 @@ -use multiversx_sc_scenario::*; - -fn world() -> ScenarioWorld { - ScenarioWorld::vm_go() -} - -#[test] -fn empty_go() { - world().run("scenarios/router_mock.scen.json"); -} diff --git a/router-mock/tests/router_mock_scenario_rs_test.rs b/router-mock/tests/router_mock_scenario_rs_test.rs deleted file mode 100644 index f765bd83..00000000 --- a/router-mock/tests/router_mock_scenario_rs_test.rs +++ /dev/null @@ -1,14 +0,0 @@ -use multiversx_sc_scenario::*; - -fn world() -> ScenarioWorld { - let mut blockchain = ScenarioWorld::new(); - // blockchain.set_current_dir_from_workspace("relative path to your workspace, if applicable"); - - blockchain.register_contract("mxsc:output/router-mock.mxsc.json", router_mock::ContractBuilder); - blockchain -} - -#[test] -fn empty_rs() { - world().run("scenarios/router_mock.scen.json"); -} diff --git a/router-mock/wasm/Cargo.lock b/router-mock/wasm/Cargo.lock deleted file mode 100644 index 1fb9e568..00000000 --- a/router-mock/wasm/Cargo.lock +++ /dev/null @@ -1,188 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "arrayvec" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" - -[[package]] -name = "autocfg" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" - -[[package]] -name = "bitflags" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" - -[[package]] -name = "endian-type" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hex-literal" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" - -[[package]] -name = "multiversx-sc" -version = "0.53.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" -dependencies = [ - "bitflags", - "hex-literal", - "multiversx-sc-codec", - "multiversx-sc-derive", - "num-traits", - "unwrap-infallible", -] - -[[package]] -name = "multiversx-sc-codec" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" -dependencies = [ - "arrayvec", - "multiversx-sc-codec-derive", - "unwrap-infallible", -] - -[[package]] -name = "multiversx-sc-codec-derive" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" -dependencies = [ - "hex", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "multiversx-sc-derive" -version = "0.53.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" -dependencies = [ - "hex", - "proc-macro2", - "quote", - "radix_trie", - "syn", -] - -[[package]] -name = "multiversx-sc-wasm-adapter" -version = "0.53.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" -dependencies = [ - "multiversx-sc", -] - -[[package]] -name = "nibble_vec" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a5d83df9f36fe23f0c3648c6bbb8b0298bb5f1939c8f2704431371f4b84d43" -dependencies = [ - "smallvec", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - -[[package]] -name = "proc-macro2" -version = "1.0.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "radix_trie" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c069c179fcdc6a2fe24d8d18305cf085fdbd4f922c041943e203685d6a1c58fd" -dependencies = [ - "endian-type", - "nibble_vec", -] - -[[package]] -name = "router-mock" -version = "0.0.0" -dependencies = [ - "multiversx-sc", -] - -[[package]] -name = "router-mock-wasm" -version = "0.0.0" -dependencies = [ - "multiversx-sc-wasm-adapter", - "router-mock", -] - -[[package]] -name = "smallvec" -version = "1.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" - -[[package]] -name = "syn" -version = "2.0.77" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "unicode-ident" -version = "1.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" - -[[package]] -name = "unwrap-infallible" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "151ac09978d3c2862c4e39b557f4eceee2cc72150bc4cb4f16abf061b6e381fb" diff --git a/router-mock/wasm/Cargo.toml b/router-mock/wasm/Cargo.toml deleted file mode 100644 index 04f6a288..00000000 --- a/router-mock/wasm/Cargo.toml +++ /dev/null @@ -1,34 +0,0 @@ -# Code generated by the multiversx-sc build system. DO NOT EDIT. - -# ########################################## -# ############## AUTO-GENERATED ############# -# ########################################## - -[package] -name = "router-mock-wasm" -version = "0.0.0" -edition = "2021" -publish = false - -[lib] -crate-type = ["cdylib"] - -[profile.release] -codegen-units = 1 -opt-level = "z" -lto = true -debug = false -panic = "abort" -overflow-checks = false - -[profile.dev] -panic = "abort" - -[dependencies.router-mock] -path = ".." - -[dependencies.multiversx-sc-wasm-adapter] -version = "0.53.2" - -[workspace] -members = ["."] diff --git a/router-mock/wasm/src/lib.rs b/router-mock/wasm/src/lib.rs deleted file mode 100644 index 3b28f061..00000000 --- a/router-mock/wasm/src/lib.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Code generated by the multiversx-sc build system. DO NOT EDIT. - -//////////////////////////////////////////////////// -////////////////// AUTO-GENERATED ////////////////// -//////////////////////////////////////////////////// - -// Init: 1 -// Endpoints: 1 -// Async Callback (empty): 1 -// Total number of exported functions: 3 - -#![no_std] - -multiversx_sc_wasm_adapter::allocator!(); -multiversx_sc_wasm_adapter::panic_handler!(); - -multiversx_sc_wasm_adapter::endpoints! { - router_mock - ( - init => init - getPair => get_pair - ) -} - -multiversx_sc_wasm_adapter::async_callback_empty! {} From 667233931cb599dfd0afbbe71545c736ab8e05e0 Mon Sep 17 00:00:00 2001 From: Andrei Baltariu Date: Tue, 22 Oct 2024 16:02:30 +0300 Subject: [PATCH 02/15] Header-Verifier copy paste Signed-off-by: Andrei Baltariu --- header-verifier/src/lib.rs | 15 +- .../tests/header_verifier_blackbox_test.rs | 395 ++++++++++++++---- 2 files changed, 322 insertions(+), 88 deletions(-) diff --git a/header-verifier/src/lib.rs b/header-verifier/src/lib.rs index 3791c78d..bd51ce17 100644 --- a/header-verifier/src/lib.rs +++ b/header-verifier/src/lib.rs @@ -33,7 +33,6 @@ pub trait Headerverifier: bls_signature::BlsSignatureModule { ); let is_bls_valid = self.verify_bls(&signature, &bridge_operations_hash); - require!(is_bls_valid, "BLS signature is not valid"); self.calculate_and_check_transfers_hashes( @@ -57,8 +56,12 @@ pub trait Headerverifier: bls_signature::BlsSignatureModule { #[endpoint(removeExecutedHash)] fn remove_executed_hash(&self, hash_of_hashes: &ManagedBuffer, operation_hash: &ManagedBuffer) { - let caller = self.blockchain().get_caller(); + require!( + !self.esdt_safe_address().is_empty(), + "There is no registered ESDT address" + ); + let caller = self.blockchain().get_caller(); require!( caller == self.esdt_safe_address().get(), "Only ESDT Safe contract can call this endpoint" @@ -74,7 +77,6 @@ pub trait Headerverifier: bls_signature::BlsSignatureModule { transfers_data: MultiValueEncoded, ) { let mut transfers_hashes = ManagedBuffer::new(); - for transfer in transfers_data { transfers_hashes.append(&transfer); } @@ -88,6 +90,7 @@ pub trait Headerverifier: bls_signature::BlsSignatureModule { ); } + // TODO fn verify_bls( &self, _signature: &BlsSignature, @@ -103,13 +106,13 @@ pub trait Headerverifier: bls_signature::BlsSignatureModule { pub_keys_count > minimum_signatures } - #[storage_mapper("bls_pub_keys")] + #[storage_mapper("blsPubKeys")] fn bls_pub_keys(&self) -> SetMapper; - #[storage_mapper("pending_hashes")] + #[storage_mapper("pendingHashes")] fn pending_hashes(&self, hash_of_hashes: &ManagedBuffer) -> UnorderedSetMapper; - #[storage_mapper("hash_of_hashes_history")] + #[storage_mapper("hashOfHashesHistory")] fn hash_of_hashes_history(&self) -> UnorderedSetMapper; #[storage_mapper("esdtSafeAddress")] diff --git a/header-verifier/tests/header_verifier_blackbox_test.rs b/header-verifier/tests/header_verifier_blackbox_test.rs index 18b1dce8..50a62073 100644 --- a/header-verifier/tests/header_verifier_blackbox_test.rs +++ b/header-verifier/tests/header_verifier_blackbox_test.rs @@ -1,125 +1,356 @@ -#![allow(deprecated)] - use bls_signature::BlsSignature; -use header_verifier::ProxyTrait; -use multiversx_sc::types::{ManagedBuffer, ManagedByteArray, MultiValueEncoded}; +use header_verifier::{header_verifier_proxy, Headerverifier}; +use multiversx_sc::types::ManagedBuffer; +use multiversx_sc::{ + api::ManagedTypeApi, + types::{BigUint, ManagedByteArray, MultiValueEncoded, TestAddress, TestSCAddress}, +}; use multiversx_sc_scenario::{ - api::StaticApi, - scenario_model::{Account, ScCallStep, ScDeployStep, SetStateStep, TxExpect}, - ContractInfo, ScenarioWorld, + api::StaticApi, imports::MxscPath, multiversx_chain_vm::crypto_functions::sha256, DebugApi, + ExpectError, ScenarioTxRun, ScenarioTxWhitebox, ScenarioWorld, }; -const HEADER_VERIFIER_PATH_EXPR: &str = "file:output/header-verifier.wasm"; -const OWNER_ADDRESS_EXPR: &str = "address:owner"; -const LEADER_ADDRESS_EXPR: &str = "address:proposer"; -const VALIDATOR_ADDRESS_EXPR: &str = "address:board-member"; -const HEADER_VERIFIER_ADDRESS_EXPR: &str = "sc:header_verifier"; +const HEADER_VERIFIER_CODE_PATH: MxscPath = MxscPath::new("ouput/header-verifier.mxsc-json"); +const HEADER_VERIFIER_ADDRESS: TestSCAddress = TestSCAddress::new("header-verifier"); + +// NOTE: This is a mock path +const ENSHRINE_ADDRESS: TestAddress = TestAddress::new("enshrine"); -type HeaderVerifierContract = ContractInfo>; +const OWNER: TestAddress = TestAddress::new("owner"); +const WEGLD_BALANCE: u128 = 100_000_000_000_000_000; + +type BlsKeys = MultiValueEncoded>; + +#[derive(Clone)] +pub struct BridgeOperation { + signature: BlsSignature, + bridge_operation_hash: ManagedBuffer, + operations_hashes: MultiValueEncoded>, +} fn world() -> ScenarioWorld { let mut blockchain = ScenarioWorld::new(); - blockchain.set_current_dir_from_workspace("header-verifier/src/lib"); - - blockchain.register_contract(HEADER_VERIFIER_PATH_EXPR, header_verifier::ContractBuilder); + blockchain.register_contract(HEADER_VERIFIER_CODE_PATH, header_verifier::ContractBuilder); blockchain } struct HeaderVerifierTestState { world: ScenarioWorld, - header_verifier_contract: HeaderVerifierContract, } impl HeaderVerifierTestState { fn new() -> Self { let mut world = world(); - world.set_state_step( - SetStateStep::new() - .put_account(OWNER_ADDRESS_EXPR, Account::new().nonce(1)) - .new_address(OWNER_ADDRESS_EXPR, 1, HEADER_VERIFIER_ADDRESS_EXPR) - .put_account( - LEADER_ADDRESS_EXPR, - Account::new().nonce(1).balance(LEADER_ADDRESS_EXPR), - ) - .put_account(VALIDATOR_ADDRESS_EXPR, Account::new().nonce(1)), - ); - - let header_verifier_contract = HeaderVerifierContract::new(HEADER_VERIFIER_ADDRESS_EXPR); - - Self { - world, - header_verifier_contract, - } - } + world + .account(OWNER) + .balance(BigUint::from(WEGLD_BALANCE)) + .nonce(1); - fn deploy_header_verifier_contract(&mut self) -> &mut Self { - let header_verifier_code = self.world.code_expression(HEADER_VERIFIER_PATH_EXPR); + world + .account(ENSHRINE_ADDRESS) + .balance(BigUint::from(WEGLD_BALANCE)) + .nonce(1); + + Self { world } + } - self.world.sc_deploy( - ScDeployStep::new() - .from(OWNER_ADDRESS_EXPR) - .code(header_verifier_code), - ); + fn deploy_header_verifier_contract(&mut self, bls_keys: BlsKeys) -> &mut Self { + self.world + .tx() + .from(OWNER) + .typed(header_verifier_proxy::HeaderverifierProxy) + .init(bls_keys) + .code(HEADER_VERIFIER_CODE_PATH) + .new_address(HEADER_VERIFIER_ADDRESS) + .run(); self } - fn _propose_register_bridge_ops( + fn propose_register_esdt_address(&mut self, esdt_address: TestAddress) { + self.world + .tx() + .from(OWNER) + .to(HEADER_VERIFIER_ADDRESS) + .typed(header_verifier_proxy::HeaderverifierProxy) + .set_esdt_safe_address(esdt_address) + .run(); + } + + fn propose_register_operations(&mut self, operation: BridgeOperation) { + self.world + .tx() + .from(OWNER) + .to(HEADER_VERIFIER_ADDRESS) + .typed(header_verifier_proxy::HeaderverifierProxy) + .register_bridge_operations( + operation.signature, + operation.bridge_operation_hash, + operation.operations_hashes, + ) + .run(); + } + + fn propose_remove_executed_hash( &mut self, - bridge_operations_hash: &ManagedBuffer, - operations_hashes: MultiValueEncoded>, - signature: &BlsSignature, + caller: TestAddress, + hash_of_hashes: &ManagedBuffer, + operation_hash: ManagedBuffer, + expected_result: Option>, ) { - self.world - .sc_call_get_result(ScCallStep::new().from(LEADER_ADDRESS_EXPR).call( - self.header_verifier_contract.register_bridge_operations( - signature, - bridge_operations_hash, - operations_hashes, - ), - )) + let transaction = self + .world + .tx() + .from(caller) + .to(HEADER_VERIFIER_ADDRESS) + .typed(header_verifier_proxy::HeaderverifierProxy) + .remove_executed_hash(hash_of_hashes, operation_hash); + + match expected_result { + Some(error) => transaction.returns(error).run(), + None => transaction.run(), + } + } + + fn get_bls_keys(&mut self, bls_keys_vec: Vec>) -> BlsKeys { + let bls_keys = bls_keys_vec.iter().map(|key| key).cloned().collect(); + + bls_keys + } + + fn generate_bridge_operation_struct( + &mut self, + operation_hashes: Vec<&ManagedBuffer>, + ) -> BridgeOperation { + let mock_signature: BlsSignature = ManagedByteArray::new_from_bytes(&[0; 48]); + + let mut bridge_operations: MultiValueEncoded> = + MultiValueEncoded::new(); + let mut appended_hashes = ManagedBuffer::new(); + + for operation_hash in operation_hashes { + appended_hashes.append(operation_hash); + bridge_operations.push(operation_hash.clone()); + } + + let hash_of_hashes = self.get_operation_hash(&appended_hashes); + + BridgeOperation { + signature: mock_signature, + bridge_operation_hash: hash_of_hashes, + operations_hashes: bridge_operations, + } + } + + fn get_operation_hash( + &mut self, + operation: &ManagedBuffer, + ) -> ManagedBuffer { + let mut array = [0; 1024]; + + let len = { + let byte_array = operation.load_to_byte_array(&mut array); + byte_array.len() + }; + + let trimmed_slice = &array[..len]; + let hash = sha256(trimmed_slice); + + ManagedBuffer::from(&hash) } } #[test] fn test_deploy() { let mut state = HeaderVerifierTestState::new(); - state.deploy_header_verifier_contract(); + let bls_key_1 = ManagedBuffer::from("bls_key_1"); + let managed_bls_keys = state.get_bls_keys(vec![bls_key_1]); + + state.deploy_header_verifier_contract(managed_bls_keys); +} + +#[test] +fn test_register_esdt_address() { + let mut state = HeaderVerifierTestState::new(); + let bls_key_1 = ManagedBuffer::from("bls_key_1"); + let managed_bls_keys = state.get_bls_keys(vec![bls_key_1]); + + state.deploy_header_verifier_contract(managed_bls_keys); + state.propose_register_esdt_address(ENSHRINE_ADDRESS); + + state + .world + .query() + .to(HEADER_VERIFIER_ADDRESS) + .whitebox(header_verifier::contract_obj, |sc| { + let esdt_address = sc.esdt_safe_address().get(); + + assert_eq!(esdt_address, ENSHRINE_ADDRESS); + }) +} + +#[test] +fn test_register_bridge_operation() { + let mut state = HeaderVerifierTestState::new(); + let bls_key_1 = ManagedBuffer::from("bls_key_1"); + let managed_bls_keys = state.get_bls_keys(vec![bls_key_1]); + + state.deploy_header_verifier_contract(managed_bls_keys); + + let operation_1 = ManagedBuffer::from("operation_1"); + let operation_2 = ManagedBuffer::from("operation_2"); + let operation = state.generate_bridge_operation_struct(vec![&operation_1, &operation_2]); + + state.propose_register_operations(operation.clone()); + + state + .world + .query() + .to(HEADER_VERIFIER_ADDRESS) + .whitebox(header_verifier::contract_obj, |sc| { + let hash_of_hashes: ManagedBuffer = + ManagedBuffer::from(operation.bridge_operation_hash.to_vec()); + + assert!(!sc.hash_of_hashes_history().is_empty()); + assert!(sc.hash_of_hashes_history().len() == 1); + assert!(sc.hash_of_hashes_history().contains(&hash_of_hashes)); + assert!(!sc.pending_hashes(&hash_of_hashes).is_empty()); + + for (mut i, operation_hash) in operation.operations_hashes.into_iter().enumerate() { + i += 1; + let pending_hash = sc.pending_hashes(&hash_of_hashes).get_by_index(i); + let expected_hash_debug_api: ManagedBuffer = + ManagedBuffer::from(operation_hash.to_vec()); + assert_eq!(pending_hash, expected_hash_debug_api); + } + }); +} + +#[test] +fn test_remove_executed_hash_caller_not_esdt_address() { + let mut state = HeaderVerifierTestState::new(); + let bls_key_1 = ManagedBuffer::from("bls_key_1"); + let managed_bls_keys = state.get_bls_keys(vec![bls_key_1]); + + state.deploy_header_verifier_contract(managed_bls_keys); + + let operation_1 = ManagedBuffer::from("operation_1"); + let operation_2 = ManagedBuffer::from("operation_2"); + let operation = state.generate_bridge_operation_struct(vec![&operation_1, &operation_2]); + + state.propose_register_operations(operation.clone()); + state.propose_register_esdt_address(ENSHRINE_ADDRESS); + state.propose_remove_executed_hash( + OWNER, + &operation.bridge_operation_hash, + operation_1, + Some(ExpectError( + 4, + "Only ESDT Safe contract can call this endpoint", + )), + ); +} + +#[test] +fn test_remove_executed_hash_no_esdt_address_registered() { + let mut state = HeaderVerifierTestState::new(); + let bls_key_1 = ManagedBuffer::from("bls_key_1"); + let managed_bls_keys = state.get_bls_keys(vec![bls_key_1]); + + state.deploy_header_verifier_contract(managed_bls_keys); + + let operation_1 = ManagedBuffer::from("operation_1"); + let operation_2 = ManagedBuffer::from("operation_2"); + let operation = state.generate_bridge_operation_struct(vec![&operation_1, &operation_2]); + + state.propose_register_operations(operation.clone()); + state.propose_remove_executed_hash( + ENSHRINE_ADDRESS, + &operation.bridge_operation_hash, + operation_1, + Some(ExpectError(4, "There is no registered ESDT address")), + ); +} + +#[test] +fn test_remove_one_executed_hash() { + let mut state = HeaderVerifierTestState::new(); + let bls_key_1 = ManagedBuffer::from("bls_key_1"); + let managed_bls_keys = state.get_bls_keys(vec![bls_key_1]); + + state.deploy_header_verifier_contract(managed_bls_keys); + + let operation_hash_1 = ManagedBuffer::from("operation_1"); + let operation_hash_2 = ManagedBuffer::from("operation_2"); + let operation = + state.generate_bridge_operation_struct(vec![&operation_hash_1, &operation_hash_2]); + + state.propose_register_operations(operation.clone()); + state.propose_register_esdt_address(ENSHRINE_ADDRESS); + + state.propose_remove_executed_hash( + ENSHRINE_ADDRESS, + &operation.bridge_operation_hash, + operation_hash_1, + None, + ); + + state + .world + .query() + .to(HEADER_VERIFIER_ADDRESS) + .whitebox(header_verifier::contract_obj, |sc| { + let hash_of_hashes: ManagedBuffer = + ManagedBuffer::from(operation.bridge_operation_hash.to_vec()); + assert!(!sc.pending_hashes(&hash_of_hashes).is_empty()); + assert!(sc.pending_hashes(&hash_of_hashes).len() == 1); + + let pending_hash_2 = sc.pending_hashes(&hash_of_hashes).get_by_index(1); + let expected_hash_2_debug_api: ManagedBuffer = + ManagedBuffer::from(operation_hash_2.to_vec()); + + assert_eq!(pending_hash_2, expected_hash_2_debug_api); + }); } #[test] -fn test_register_bridge_ops_wrong_hashes() { +fn test_remove_all_executed_hashes() { let mut state = HeaderVerifierTestState::new(); - state.deploy_header_verifier_contract(); + let bls_key_1 = ManagedBuffer::from("bls_key_1"); + let managed_bls_keys = state.get_bls_keys(vec![bls_key_1]); + + state.deploy_header_verifier_contract(managed_bls_keys); + + let operation_1 = ManagedBuffer::from("operation_1"); + let operation_2 = ManagedBuffer::from("operation_2"); + let operation = state.generate_bridge_operation_struct(vec![&operation_1, &operation_2]); + + state.propose_register_operations(operation.clone()); + state.propose_register_esdt_address(ENSHRINE_ADDRESS); - let bridge_operations_hash = - ManagedBuffer::from("6ee1e00813a74f8293d2c63172c062d38bf780d8811ff63984813a49cd61ff9e"); - let mock_signature: BlsSignature = ManagedByteArray::new_from_bytes( - b"EIZ2\x05\xf7q\xc7G\x96\x1f\xba0\xe2\xd1\xf5pE\x14\xd7?\xac\xff\x8d\x1a\x0c\x11\x900f5\xfb\xff4\x94\xb8@\xc5^\xc2,exn0\xe3\xf0\n" + state.propose_remove_executed_hash( + ENSHRINE_ADDRESS, + &operation.bridge_operation_hash, + operation_1, + None, ); - let first_operation: ManagedBuffer = - ManagedBuffer::from("95cdb166d6e12a8c4a783a48d2e4f647e15fac4e5a115d4483f95881630a5433"); - let second_operation = - ManagedBuffer::from("4851cd6e4a4799ad0d8e8ead37c88d930874302ab11edcc60f608654be14b2ed"); - - let mut bridge_operations: MultiValueEncoded> = - MultiValueEncoded::new(); - bridge_operations.push(first_operation); - bridge_operations.push(second_operation); - - state.world.sc_call( - ScCallStep::new() - .from(OWNER_ADDRESS_EXPR) - .call(state.header_verifier_contract.register_bridge_operations( - mock_signature, - bridge_operations_hash, - bridge_operations, - )) - .expect(TxExpect::user_error( - "str:Hash of all operations doesn't match the hash of transfer data", - )), + state.propose_remove_executed_hash( + ENSHRINE_ADDRESS, + &operation.bridge_operation_hash, + operation_2, + None, ); + state + .world + .query() + .to(HEADER_VERIFIER_ADDRESS) + .whitebox(header_verifier::contract_obj, |sc| { + let hash_of_hashes: ManagedBuffer = + ManagedBuffer::from(operation.bridge_operation_hash.to_vec()); + assert!(sc.pending_hashes(&hash_of_hashes).is_empty()); + assert!(sc.hash_of_hashes_history().contains(&hash_of_hashes)); + }); } From 40b26c0bc3255d3c5006831dcbd4364388130cff Mon Sep 17 00:00:00 2001 From: Andrei Baltariu Date: Tue, 22 Oct 2024 16:07:38 +0300 Subject: [PATCH 03/15] Clippy fix Signed-off-by: Andrei Baltariu --- header-verifier/tests/header_verifier_blackbox_test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/header-verifier/tests/header_verifier_blackbox_test.rs b/header-verifier/tests/header_verifier_blackbox_test.rs index 50a62073..cdd1cdee 100644 --- a/header-verifier/tests/header_verifier_blackbox_test.rs +++ b/header-verifier/tests/header_verifier_blackbox_test.rs @@ -115,7 +115,7 @@ impl HeaderVerifierTestState { } fn get_bls_keys(&mut self, bls_keys_vec: Vec>) -> BlsKeys { - let bls_keys = bls_keys_vec.iter().map(|key| key).cloned().collect(); + let bls_keys = bls_keys_vec.iter().cloned().collect(); bls_keys } From ea47e04634ca17ba33e9fe2a8318ce048bfe75cd Mon Sep 17 00:00:00 2001 From: Andrei Baltariu Date: Mon, 28 Oct 2024 15:23:43 +0200 Subject: [PATCH 04/15] Esdt-Safe copy paste Signed-off-by: Andrei Baltariu --- esdt-safe/interactor/.gitignore | 2 + esdt-safe/interactor/Cargo.toml | 39 + .../contract-codes/fee-market.mxsc.json | 347 +++++++ .../contract-codes/header-verifier.mxsc.json | 160 +++ .../multiversx-price-aggregator-sc.mxsc.json | 593 +++++++++++ esdt-safe/interactor/src/fee_market_proxy.rs | 278 +++++ .../interactor/src/header_verifier_proxy.rs | 174 ++++ esdt-safe/interactor/src/interactor_main.rs | 948 ++++++++++++++++++ .../interactor/src/price_aggregator_proxy.rs | 416 ++++++++ esdt-safe/interactor/src/proxy.rs | 458 +++++++++ esdt-safe/interactor/state.toml | 4 + esdt-safe/tests/bridge_blackbox_tests.rs | 432 ++++++++ 12 files changed, 3851 insertions(+) create mode 100644 esdt-safe/interactor/.gitignore create mode 100644 esdt-safe/interactor/Cargo.toml create mode 100644 esdt-safe/interactor/contract-codes/fee-market.mxsc.json create mode 100644 esdt-safe/interactor/contract-codes/header-verifier.mxsc.json create mode 100644 esdt-safe/interactor/contract-codes/multiversx-price-aggregator-sc.mxsc.json create mode 100644 esdt-safe/interactor/src/fee_market_proxy.rs create mode 100644 esdt-safe/interactor/src/header_verifier_proxy.rs create mode 100644 esdt-safe/interactor/src/interactor_main.rs create mode 100644 esdt-safe/interactor/src/price_aggregator_proxy.rs create mode 100644 esdt-safe/interactor/src/proxy.rs create mode 100644 esdt-safe/interactor/state.toml create mode 100644 esdt-safe/tests/bridge_blackbox_tests.rs diff --git a/esdt-safe/interactor/.gitignore b/esdt-safe/interactor/.gitignore new file mode 100644 index 00000000..5a64d09a --- /dev/null +++ b/esdt-safe/interactor/.gitignore @@ -0,0 +1,2 @@ +# Pem files are used for interactions, but shouldn't be committed +*.pem diff --git a/esdt-safe/interactor/Cargo.toml b/esdt-safe/interactor/Cargo.toml new file mode 100644 index 00000000..b6256c44 --- /dev/null +++ b/esdt-safe/interactor/Cargo.toml @@ -0,0 +1,39 @@ +[package] +name = "rust-interact" +version = "0.0.0" +authors = ["you"] +edition = "2021" +publish = false + +[[bin]] +name = "rust-interact" +path = "src/interactor_main.rs" + +[dependencies.esdt-safe] +path = ".." + +[dependencies.transaction] +path = "../../common/transaction" + +[dependencies.tx-batch-module] +path = "../../common/tx-batch-module" + +[dependencies.fee-market] +path = "../../fee-market" + +[dependencies.multiversx-sc-snippets] +version = "0.53.2" + +[dependencies.multiversx-sc] +version = "0.53.2" + +[dependencies.multiversx-sc-scenario] +version = "=0.53.2" + +[dependencies] +clap = { version = "4.4.7", features = ["derive"] } +serde = { version = "1.0", features = ["derive"] } +toml = "0.8.6" + +# [workspace] + diff --git a/esdt-safe/interactor/contract-codes/fee-market.mxsc.json b/esdt-safe/interactor/contract-codes/fee-market.mxsc.json new file mode 100644 index 00000000..a6fce293 --- /dev/null +++ b/esdt-safe/interactor/contract-codes/fee-market.mxsc.json @@ -0,0 +1,347 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.79.0", + "commitHash": "129f3b9964af4d4a709d1383930ade12dfe7c081", + "commitDate": "2024-06-10", + "channel": "Stable", + "short": "rustc 1.79.0 (129f3b996 2024-06-10)" + }, + "contractCrate": { + "name": "fee-market", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.53.0" + } + }, + "abi": { + "name": "FeeMarket", + "constructor": { + "inputs": [ + { + "name": "esdt_safe_address", + "type": "Address" + }, + { + "name": "price_aggregator_address", + "type": "Address" + }, + { + "name": "fee", + "type": "Option" + } + ], + "outputs": [] + }, + "upgradeConstructor": { + "inputs": [], + "outputs": [] + }, + "endpoints": [ + { + "name": "addFee", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "fee_struct", + "type": "FeeStruct" + } + ], + "outputs": [] + }, + { + "name": "removeFee", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "base_token", + "type": "TokenIdentifier" + } + ], + "outputs": [] + }, + { + "name": "getTokenFee", + "mutability": "readonly", + "inputs": [ + { + "name": "token_id", + "type": "TokenIdentifier" + } + ], + "outputs": [ + { + "type": "FeeType" + } + ] + }, + { + "name": "addUsersToWhitelist", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "users", + "type": "variadic
", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "removeUsersFromWhitelist", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "users", + "type": "variadic
", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "docs": [ + "Percentages have to be between 0 and 10_000, and must all add up to 100% (i.e. 10_000)" + ], + "name": "distributeFees", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "address_percentage_pairs", + "type": "variadic>", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "subtractFee", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [ + { + "name": "original_caller", + "type": "Address" + }, + { + "name": "total_transfers", + "type": "u32" + }, + { + "name": "opt_gas_limit", + "type": "optional", + "multi_arg": true + } + ], + "outputs": [ + { + "type": "FinalPayment" + } + ] + }, + { + "name": "getUsersWhitelist", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "variadic
", + "multi_result": true + } + ] + }, + { + "name": "setMinValidSigners", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "new_value", + "type": "u32" + } + ], + "outputs": [] + }, + { + "name": "addSigners", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "signers", + "type": "variadic
", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "removeSigners", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "signers", + "type": "variadic
", + "multi_arg": true + } + ], + "outputs": [] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": { + "EsdtTokenPayment": { + "type": "struct", + "fields": [ + { + "name": "token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "token_nonce", + "type": "u64" + }, + { + "name": "amount", + "type": "BigUint" + } + ] + }, + "FeeStruct": { + "type": "struct", + "fields": [ + { + "name": "base_token", + "type": "TokenIdentifier" + }, + { + "name": "fee_type", + "type": "FeeType" + } + ] + }, + "FeeType": { + "type": "enum", + "variants": [ + { + "name": "None", + "discriminant": 0 + }, + { + "name": "Fixed", + "discriminant": 1, + "fields": [ + { + "name": "token", + "type": "TokenIdentifier" + }, + { + "name": "per_transfer", + "type": "BigUint" + }, + { + "name": "per_gas", + "type": "BigUint" + } + ] + }, + { + "name": "AnyToken", + "discriminant": 2, + "fields": [ + { + "name": "base_fee_token", + "type": "TokenIdentifier" + }, + { + "name": "per_transfer", + "type": "BigUint" + }, + { + "name": "per_gas", + "type": "BigUint" + } + ] + } + ] + }, + "FinalPayment": { + "type": "struct", + "fields": [ + { + "name": "fee", + "type": "EsdtTokenPayment" + }, + { + "name": "remaining_tokens", + "type": "EsdtTokenPayment" + } + ] + } + } + }, + "code": "0061736d0100000001791460027f7f0060017f017f60027f7f017f60000060017f0060037f7f7f006000017f60037f7f7f017f60047f7f7f7f017f60047f7f7f7f0060027f7e0060017f017e60057f7f7e7f7f017f60017e006000017e60067e7f7f7f7f7f017f60057f7f7f7f7f0060047f7e7f7f0060027f7f017e60037f7f7f017e02e8062503656e760e626967496e74536574496e743634000a03656e7609626967496e74416464000503656e760b7369676e616c4572726f72000003656e7609626967496e744d756c000503656e760a6d4275666665724e6577000603656e760d6d427566666572417070656e64000203656e76096d4275666665724571000203656e760d6d42756666657246696e697368000103656e76106d4275666665724765744c656e677468000103656e760d6d616e6167656443616c6c6572000403656e76136d616e616765644f776e657241646472657373000403656e76126d427566666572476574417267756d656e74000203656e76126d427566666572417070656e644279746573000703656e76126d616e616765645369676e616c4572726f72000403656e761b736d616c6c496e74476574556e7369676e6564417267756d656e74000b03656e760f6765744e756d417267756d656e7473000603656e7609626967496e74537562000503656e76226d616e616765644d756c74695472616e73666572455344544e465445786563757465000c03656e76146d427566666572436f707942797465536c696365000803656e760f6d4275666665725365744279746573000703656e761776616c6964617465546f6b656e4964656e746966696572000103656e76196d42756666657246726f6d426967496e74556e7369676e6564000203656e76176d427566666572546f426967496e74556e7369676e6564000203656e76126d42756666657253746f726167654c6f6164000203656e76136d42756666657253746f7261676553746f7265000203656e7609626967496e74436d70000203656e760f6d4275666665724765744279746573000203656e760f6973536d617274436f6e7472616374000103656e760e636865636b4e6f5061796d656e74000303656e7616736d616c6c496e7446696e697368556e7369676e6564000d03656e760a626967496e7454446976000503656e761c6d616e616765644765744d756c74694553445443616c6c56616c7565000403656e760a6765744761734c656674000e03656e761b6d616e61676564457865637574654f6e44657374436f6e74657874000f03656e760f636c65616e52657475726e44617461000303656e760a626967496e745369676e000103656e76136d42756666657247657442797465536c69636500080379780106000200010001010904040600010a060000000009070907070100000202040001020201010603070706000704040403050109050004090510000101080800020801000004000201010011050001020205020002020012050007000100130104040604040106040303030303030303030303030303030305030100030616037f01418080080b7f0041a5d6080b7f0041b0d6080b07880211066d656d6f7279020004696e6974008d010775706772616465008e0106616464466565008f010972656d6f76654665650090010b676574546f6b656e466565009101136164645573657273546f57686974656c6973740092011872656d6f7665557365727346726f6d57686974656c6973740093010e64697374726962757465466565730094010b737562747261637446656500950111676574557365727357686974656c697374009701127365744d696e56616c69645369676e6572730098010a6164645369676e6572730099010d72656d6f76655369676e657273009a010863616c6c4261636b009b010a5f5f646174615f656e6403010b5f5f686561705f6261736503020ae94a781601017f1026220142001000200120012000100120010b1901017f41e4870841e4870828020041016b220036020020000bdf0102047f017e0240024020012802182204200128022010280440200128022421024172200135022c100020022002417210032001290300500440200129030822064200530d0220012802282103417220061000200320034172100320022002200310010b417f2002200128021c22031019220541004720054100481b41ff01714101460d022003200210292004102a21032000200236020c2000200336020820004200370300200041186a200141186a290300370300200020012903103703100f0b41b18108411e102b000b41ba840841111002000b41cf8108411a102b000b0b0020002001100641004a0b0a0020002000200110560b0f01017f10042201200010051a20010b0900200020011002000b3c01017f230041106b220124002000102d450440419582084117102b000b200141086a200041002000100841076b102e200128020c200141106a24000b0900200010144100470b1f0020012002200310042201101221022000200136020420002002453602000bbe0101047f2000280210220210300240024002400240024002402000280200220141016b0e020201000b41c382084110102b000b200028020421030c010b2002200028020422031028450d010b20031030103141011032200041106a10332104200028020c210220002802082100024002400240200141016b0e020102000b2004420010340f0b41011035220110360c020b41021035220110360c010b41d38208410b102b000b2003200110372000200110382002200110382004200110390b13002000102d45044041c786084110102b000b0b0a0041898608410e10430b3701017f230041106b220224002002420037030820022001ad4101200241086a10702000200228020020022802041071200241106a24000b1901017f4197860841081043210120002802002001107b20010b3601017f230041106b2202240020024200370308200220014100200241086a10702000200228020020022802041071200241106a24000b08004101410010430b2601017f230041106b22022400200220003a000f20012002410f6a4101107d200241106a24000b4f01027f230041106b22022400200220001008220341187420034180fe03714108747220034108764180fe03712003411876727236020c20012002410c6a4104107d200120001064200241106a24000b0a002000104a200110370b09002000200110181a0ba40101027f0240024002400240200120022003103b41ff01710e03010203000b2002200341808008410d103c000b200041003602000f0b200120022003103d2104200120022003103e21052000200120022003103e36020c2000200536020820002004360204200041013602000f0b200120022003103d2104200120022003103e21052000200120022003103e36020c2000200536020820002004360204200041023602000b2f01017f230041106b22032400200341003a000f20002003410f6a410120012002105e20032d000f200341106a24000b2e01017f419a830841171043220420002001100c1a200441b183084103100c1a200420022003100c1a2004100d000b890101037f230041106b220324002003410036020c20002003410c6a410420012002105e2003200028020820002802002205200328020c220441187420044180fe03714108747220044108764180fe0371200441187672722204102e200328020041014704402001200241ab8408410f103c000b20032802042000200420056a360200200341106a24000b0c00200020012002103d10490b0f01017f102622012000ad100020010b3002017f017e2001280208102a2102200129030021032000200128020c102536020c20002003370300200020023602080b4301017f2001280204220220012802084b047f4100052001200241016a3602042001280200280200200210421067210141010b210220002001360204200020023602000b5401017f230041106b220224002000102a220041eb84084105100c1a2002200141187420014180fe03714108747220014108764180fe03712001411876727236020c20002002410c6a105f200241106a240020000b1101017f102622022000200110131a20020b0700200010071a0b3101017f20011046220210082101200041003a00102000200136020c2000200236020820002001360204200041003602000b0d00200010262200100b1a20000b0a0020002001104810490b850101037f230041106b220224002002410036020c20002002410c6a41042001105c2002200028020820002802002204200228020c220341187420034180fe03714108747220034108764180fe0371200341187672722203102e20022802004101470440200141ab8408410f105d000b20022802042000200320046a360200200241106a24000b0d0020001026220010161a20000b0f01017f10262201200010151a20010b0c01017f10262200100920000b1d01017f10262200100a2000104b102804400f0b419e870841241002000b2f01017f200028020022034180d6082802004e04402001200241b483084111103c000b2000200341016a36020020030b2e01017f104f2103034020002802004180d6082802004e4504402003200020012002104d104610500c010b0b20030b1101017f102622004101410010131a20000b4601017f230041106b220224002002200141187420014180fe03714108747220014108764180fe03712001411876727236020c20002002410c6a4104100c1a200241106a24000b1f00200010462200100841204704402001200241ae85084110103c000b20000b190020004180d6082802004e04400f0b41c5830841121002000b1400100f20004604400f0b41d7830841191002000b190020004180d6082802004c04400f0b41b4830841111002000b0b004180d608100f3602000b1f0020002001200210102000105741ff017104400f0b41f0830841301002000b1500410241012000102322001b4100200041004e1b0bf30102017e037f230041106b2206240020002903002104200028020c2000280208104f2107280200102a2100280200102521052006200442388620044280fe0383422886842004428080fc0783421886200442808080f80f834208868484200442088842808080f80f832004421888428080fc07838420044228884280fe038320044238888484843702042006200041187420004180fe03714108747220004108764180fe0371200041187672723602002006200541187420054180fe03714108747220054108764180fe03712005411876727236020c200720064110100c1a2001200742002002200310111a200641106a24000b2c01017f2001280204104f1a2002102a1050200041086a200141086a280200360200200020012902003702000b5401037f230041206b22022400200241086a105b200228020c2103200228020821042002200141086a36021820022001410c6a36021c20022001290300370310200241106a2000200420031058200241206a24000b1601017f104f21012000104f360204200020013602000b2d00200041086a20002802002001200210660440200341ab8408410f105d000b2000200028020020026a3602000b2c01017f41f68408411b10432203200010051a200341b183084103100c1a200320012002100c1a2003100d000b2f00200041086a200028020020012002106604402003200441ab8408410f103c000b2000200028020020026a3602000b0b00200020014104100c1a0b0b002000106141ff0171450b09002000105741016b0b0c00200020012002200310630b0f00200020012003200210244100470b09002000200110051a0b1001017f1026220220002001100320020bc70301067f02400240027f024020002d000845044020002802002204100822054190ce004b0d0141fcd5082d00000d0141f8d508200536020041fcd50841013a00002004410041e88708200510621a200041013a00080b4101200120036a220041f8d5082802004b0d011a20002001490d0220004190ce004b0d03200141e887086a2100200341104f04402002410020026b41037122046a210520040440200021010340200220012d00003a0000200141016a2101200241016a22022005490d000b0b2005200320046b2203417c7122066a21020240200020046a22044103710440200641004c0d012004410374220141187121072004417c71220841046a2100410020016b4118712109200828020021010340200520012007762000280200220120097472360200200041046a2100200541046a22052002490d000b0c010b200641004c0d0020042100034020052000280200360200200041046a2100200541046a22052002490d000b0b20034103712103200420066a21000b20030440200220036a21010340200220002d00003a0000200041016a2100200241016a22022001490d000b0b41000f0b200041003a0008200420012002200310620b0f0b109c01000b109601000b0d0020001026220010171a20000b08002000200110390b0b0020002001104a10181a0b1200416c4101410010131a2000416c10181a0b090020002001ad10340b0a00200020011042106d0b1f01017f20001067220110084120470440200041ae85084110105d000b20010b2401017e20002000107c22014280808080105a04402000418d8008410e105d000b2001a70b08002000200110680b900101037f200320013c00072003410036000020032001420888a722063a000620032001421088a722053a000520032001421888a722043a000420004108200420057241ff017145220541044105200441ff01711b6a41002005200641ff01711b22046a200441002001501b6a2204200320044107716a2c00004100482002716b22026b3602042000200220036a3602000b0d00200020012002104310181a0b860201057f230041206b220224002001416710171a02400240416710084504400c010b20011067220510082103200241003a001820022003360214200220053602102002200336020c20024100360208200241003a001f200241086a2002411f6a41012001105c024002400240024020022d001f22040e03030201000b200141808008410d105d000b410221040b200241086a22032001104821052003200110472103200241086a2001104721060b200228020c2002280208470d0120022d0018450d0041f8d508410036020041fcd50841003a00000b2000200636020c200020033602082000200536020420002004360200200241206a24000f0b2001418d8008410e105d000b08002000106710490ba30101067f02402000280208220520011075220204400240200220002802042204106e22034d044020022003460d012004106e2003490d03200028020022072003106c21062004106e2002490d03200720021042200610680c010b0c020b2004106e2003490d01200028020020031042106a2004200341016b106b2002200347044020052006200210760b200520011077106a0b20024100470f0b41c2870841121002000b0a00200020011077106e0b0d002000200110772002ad10340b19002000102a220041f084084106100c1a20002001106420000b4001037f200028020822032001107945044020002802042202106e21042000280200200441016a220010422001106820022000106b200320012002106e10760b0b0b002000200110754100470b19002000102a220041f084084106100c1a20012000107b20000b4d01027f230041106b22022400200220001008220341187420034180fe03714108747220034108764180fe03712003411876727236020c20012002410c6a105f200120001064200241106a24000ba30102017e027f230041106b22032400200342003703082000106722041008220041094f04402001418d8008410e105d000b20044100200320006b41106a200010631a20032903082102200341106a2400200242388620024280fe0383422886842002428080fc0783421886200242808080f80f834208868484200242088842808080f80f832002421888428080fc07838420024228884280fe038320024238888484840b0b00200020012002100c1a0b900102017e017f230041106b2203240020002802082001103720032000290300220242388620024280fe0383422886842002428080fc0783421886200242808080f80f834208868484200242088842808080f80f832002421888428080fc07838420024228884280fe038320024238888484843703082001200341086a4108107d200028020c20011038200341106a24000b7b01027f230041106b22032400200028020821042003410036020c200028020020044102742003410c6a41041062450440200328020c21012000200441016a360208200141187420014180fe03714108747220014108764180fe037120014118767272102a200341106a24000f0b2001200241b483084111103c000b2e01017f200128020820012802044f047f4100052001108101210141010b210220002001360204200020023602000b2900200041be85084108107f102a22001008412047044041be8508410841ae85084110103c000b20000b2e01027f2001102a21022001102a220341aa85084104100c1a2000200336020420002001360200200020023602080ba10102017e027f230041106b220424002004420037030820001008220541094f044020012002418d8008410e103c000b20004100200420056b41106a200510631a20042903082103200441106a2400200342388620034280fe0383422886842003428080fc0783421886200342808080f80f834208868484200342088842808080f80f832003421888428080fc07838420034228884280fe038320034238888484840b0d002000106141ff01714101460b0f00200041f08508410a10431082010bbc0101077f230041206b2201240002400240200010084120460440200141186a4200370300200141106a4200370300200141086a420037030020014200370300200041002001412010631a200121024120210541cb840821030240034020022d0000220620032d00002207460440200241016a2102200341016a2103200541016b22050d010c020b0b200620076b21040b2004450d010b20004185d608101a1a4185d608101b41004a0d010b41b586084112102b000b200141206a24000b0a0041d78608410f10430b3601037f41e68608410d10432201102a21022001102a220341aa85084104100c1a2000200336020420002001360200200020023602080b0f00200041f38608410e10431082010b1901017f4181870841071043210120002802002001107b20010b0a0041888708411610430b0f00200041a08408410b107f102a1a0bc10301077f230041306b22012400101c41031053410041848208411110512105410141ec81084118105121062001411c6a2104230041406a22002400200041046a220341021045410321020240024020002802082000280204470440024002400240200341e981084103103b41ff01710e020201000b41e98108410341808008410d103c000b200041046a220241e981084103103d2103200041286a200241e981084103103a20002003360238200041206a200041346a2902003703002000200029022c370318200028022821020b20002802082000280204470d01200041306a200041206a290300370300200020002903183703280b20002d0014044041f8d508410036020041fcd50841003a00000b20042002360200200420002903283702042004410c6a200041306a290300370200200041406b24000c010b41e981084103418d8008410e103c000b200141106a2202200141286a220329020037030020012001290220370308200128021c2100200510860120061086011087012005106f108b012006106f024020004103470440200320022903003702002001200036021c200120012903083702202004102f0c010b1031410010320b200141306a24000b0800101c410010530bd30101057f230041206b22032400101c104c410110532003410c6a2101230041406a220024002000411c6a220241001045200241de8208410a103d2104200041306a200241de8208410a103a02402000280220200028021c460440200041106a2202200041386a2902003703002000200029023037030820002d002c044041f8d508410036020041fcd50841003a00000b2001200029030837020020012004360210200141086a2002290300370200200041406b24000c010b41de8208410a418d8008410e103c000b2001102f200341206a24000b3401017f230041106b22002400101c104c4101105320004100104636020c2000410c6a1033106a103141001032200041106a24000ba00101027f230041206b22002400101c4101105320004100104636020c200041106a2000410c6a103310720240024002400240200028021041016b0e020102000b4200101d0c020b4101103522011036200028021420011037200028021820011038200028021c20011038200110440c010b4102103522011036200028021420011037200028021820011038200028021c20011038200110440b200041206a24000b840101037f230041206b22002400101c104c10554100105420004100360214200041146a41fd80084105104e210120002802141052200041086a1089012001100821022000410036021c200020024102763602182000200136021403402000200041146a10800120002802000440200041086a200028020410780c010b0b200041206a24000b900101037f230041206b22002400101c104c10554100105420004100360214200041146a41fd80084105104e210120002802141052200041086a1089012001100821022000410036021c2000200241027636021820002001360214024003402000200041146a1080012000280200450d01200041086a200028020410740d000b419f86084116102b000b200041206a24000bc506020e7f027e230041e0006b22002400101c104c10554100105420004100360250200041d0006a41e580084118104e2102200028025010524190ce00103f2108104f210520021008210320004100360258200020034102762203360254200020023602500240034020012003490440200041d0006a22021081012101200241be85084108107f41be85084108108301220f4280808080105a0d022000200141187420014180fe03714108747220014108764180fe0371200141187672723602402000200fa7220141187420014180fe03714108747220014108764180fe0371200141187672723602442005200041406b4108100c1a200e200f7c210e20002802542103200028025821010c010b0b200e4290ce00510440200041246a220110880120002000280228106e3602382000410136023420002001360230200041cc006a2109200041c8006a210a03400240200041186a200041306a10412000280218450440200041406b220110880120002000280244106e36025820004101360254200020013602500340200041086a200041d0006a1041200028020804402000280248200028020c107a106a0c0105410021032000280244106e21024101210103402003200120024b720d04200028024020011042106a200120024f2103200120012002496a21010c000b000b000b000b2000200028021c220b36023c2000413c6a108a011073220610600d014100210120061025210720051008210c0340200c200141086a22024904402000413c6a108a01200710690c030b2000420037035020052001200041d0006a220d410810631a2000280250210320062000280254220141187420014180fe03714108747220014108764180fe037120014118767272103f106521011026220420012008101e200221012004108401450d00200720041029200b102a21022000200436024c2000200236024820004200370340200041106a105b20002802142102200028021021042000200a3602582000200936025c20002000290340370350200d200341187420034180fe03714108747220034108764180fe0371200341187672722004200210580c000b000b0b200028024442001034200041e0006a24000f0b418281084116102b000b41be85084108418d8008410e103c000bbb0d020c7f037e230041d0016b22002400105541021054410041d68008410f105121074101100e220d4280808080105a044041c78008410f418d8008410e103c000b200da7210820004102360260200041e0006a22012802004180d6082802004e047e420105200141ba8008410d104d100e210e42000b210d2000200e3703082000200d3703002000290308210e2000290300210d200028026010520240024002400240104b108701106d10280440104b210b416b210602404184d6082d000022010440416b41ffffffff0720011b21060c010b4184d60841013a0000416b101f0b0240200610084170714110460440200610082105200041e8006a2103410121090340200241106a220120054b0d02200342003703002000420037036020062002200041e0006a411010631a200904402000290264220c423886200c4280fe038342288684200c428080fc0783421886200c42808080f80f834208868484200c42088842808080f80f83200c421888428080fc078384200c4228884280fe0383200c423888848484210c2000280260220241187420024180fe03714108747220024108764180fe037120024118767272210a200028026c220241187420024180fe03714108747220024108764180fe037120024118767272210441002109200121020c010b0b109601000b41f8820841221002000b2000200436021c2000200a3602182000200c3703100240103122012001107c220c4201580440200ca741016b0d040c010b200141c685084112105d000b200041e0006a1089012000280268200710790d02200041c8006a2201200041186a29030037030020002000290310370340200041d0006a2001103310720240024002400240200028025041016b0e020102000b419881084119102b000b200041f8006a2001290300370300200020002903403703702000200836028c012000200028025c3602880120002000290254370380012000200e3703682000200d370360200041206a200041e0006a10270c010b2000290258210c20002802542202102a2105200041f0006a2201200041406b10402000200836028c012000200c3702840120002005360280012000200e3703682000200d37036020022000280248102845044020004190016a20011040108b01106d21032000280278102c21042005102c2102200341feffffff07460d0341ac82084117104321012000104f3602a401200020013602a001200020033602a801200041206a2201200041a0016a220320041059200041c4016a2001200210591020210c20002802c801210420002802c401210220002802cc012101417642001000200c42a08d067d200c200c42a08d06561b20014176200220041026220210211a1022200210082101200041003602a801200020023602a001200020014102763602a4010240200141044f0440200341a08408410b107f41a08408410b1083014280808080105a0d082003108c012003108c01200341a08408410b107f41a08408410b1083011a200041a0016a41a08408410b107f10492102200041a0016a41a08408410b107f41a08408410b108301428002540d010c080b41d8850841181002000b2005102a210120002002102536027c2000200136027820004200370370200041a0016a200041e0006a102720002802bc01106045044020002802ac01200028029c0122041065220120012002101e2004200420011056200041286a200041a8016a2903003703002000200436023c20004200370330200020002903a00137032020002000280298013602380c020b200041386a200041b8016a290300370300200041306a200041b0016a290300370300200041286a200041a8016a290300370300200020002903a0013703200c010b200041206a200041e0006a10270b200041e0006a1088012000280228102a2103200028026822022003107a106e45044020002802642204106e21012000280260200141016a22011042200310181a20042001106b2004106e210120022003107a2001ad10340b200041286a108a012201107322022002200028022c1001200120021069200028023c10840104402007200041306a105a0b200041f8006a200041386a290300370300200041f0006a200041306a290300370300200041e8006a200041286a290300370300200020002903203703600c030b419b8008411f102b000b4191850841191002000b200b200041106a105a200a102a21021026220142001000200041f8006a200041186a2903003703002000200136026c2000200236026820004200370360200020002903103703700b200041e0006a10352201107e200041f0006a2001107e20011044200041d0016a24000f0b41a08408410b418d8008410e103c000b0600109c01000b5401047f230041106b22002400101c41001053200041046a1089012000280208106e210220002802042103410121010340200120024b45044020032001106c10071a200141016a21010c010b0b200041106a24000b3f02017e017f101c104c410110534100100e22004280808080105a044041ef82084109418d8008410e103c000b2000a7210141fa8508410f10432001ad10340b870101037f230041206b22002400101c104c10554100105420004100360214200041146a41e882084107104e210120002802141052200110082102200041003602102000200241027636020c2000200136020803402000200041086a1080012000280200044020002802042101200041146a22021085012002200110780c010b0b200041206a24000b880101037f230041206b22002400101c104c10554100105420004100360214200041146a41e882084107104e210120002802141052200110082102200041003602102000200241027636020c2000200136020803402000200041086a1080012000280200044020002802042101200041146a22021085012002200110741a0c010b0b200041206a24000b02000b0b0041d48708410e1002000b0bde070300418080080bcb04696e76616c69642076616c7565696e70757420746f6f206c6f6e674f6e6c7920455344542053616665206d61792063616c6c20746869732053436f70745f6761735f6c696d6974746f74616c5f7472616e73666572736f726967696e616c5f63616c6c6572616464726573735f70657263656e746167655f70616972737573657273496e76616c69642070657263656e746167652073756d546f6b656e206e6f7420616363657074656420617320666565496e76616c696420746f6b656e2070726f766964656420666f72206665655061796d656e7420646f6573206e6f7420636f7665722066656566656570726963655f61676772656761746f725f61646472657373657364745f736166655f61646472657373496e76616c69642045534454206964656e7469666965726c61746573745072696365466565644f7074696f6e616c496e76616c6964206665652074797065496e76616c6964206665656665655f7374727563747369676e6572736e65775f76616c7565696e636f7272656374206e756d626572206f662045534454207472616e7366657273617267756d656e74206465636f6465206572726f722028293a20746f6f2066657720617267756d656e7473746f6f206d616e7920617267756d656e747377726f6e67206e756d626572206f6620617267756d656e747363616e6e6f74207375627472616374206265636175736520726573756c7420776f756c64206265206e6567617469766573796e6320726573756c74696e70757420746f6f2073686f72746361737420746f20693634206572726f720041eb84080bf7022e6974656d2e696e64657873746f72616765206465636f6465206572726f7220286b65793a20726563697069656e742061646472657373206e6f74207365742e6c656e626164206172726179206c656e6774687661722061726773696e707574206f7574206f662072616e6765496e76616c69642061676772656761746f722076616c7565616c6c5369676e6572736d696e56616c69645369676e657273666565456e61626c6564466c6167746f6b656e4665654974656d206e6f7420666f756e6420696e206c697374496e76616c69642053432061646472657373496e76616c696420746f6b656e204944657364745361666541646472657373746f6b656e73466f7246656573757365727357686974656c69737461636346656573707269636541676772656761746f7241646472657373456e64706f696e742063616e206f6e6c792062652063616c6c6564206279206f776e6572696e646578206f7574206f662072616e676570616e6963206f636375727265640041e487080b0438ffffff", + "report": { + "imports": [ + "bigIntAdd", + "bigIntCmp", + "bigIntMul", + "bigIntSetInt64", + "bigIntSign", + "bigIntSub", + "bigIntTDiv", + "checkNoPayment", + "cleanReturnData", + "getGasLeft", + "getNumArguments", + "isSmartContract", + "mBufferAppend", + "mBufferAppendBytes", + "mBufferCopyByteSlice", + "mBufferEq", + "mBufferFinish", + "mBufferFromBigIntUnsigned", + "mBufferGetArgument", + "mBufferGetByteSlice", + "mBufferGetBytes", + "mBufferGetLength", + "mBufferNew", + "mBufferSetBytes", + "mBufferStorageLoad", + "mBufferStorageStore", + "mBufferToBigIntUnsigned", + "managedCaller", + "managedExecuteOnDestContext", + "managedGetMultiESDTCallValue", + "managedMultiTransferESDTNFTExecute", + "managedOwnerAddress", + "managedSignalError", + "signalError", + "smallIntFinishUnsigned", + "smallIntGetUnsignedArgument", + "validateTokenIdentifier" + ], + "isMemGrow": false, + "eiCheck": { + "eiVersion": "1.3", + "ok": true + }, + "codeReport": { + "path": "../output/fee-market.wasm", + "size": 11998, + "hasAllocator": false, + "hasPanic": "without message" + } + } +} diff --git a/esdt-safe/interactor/contract-codes/header-verifier.mxsc.json b/esdt-safe/interactor/contract-codes/header-verifier.mxsc.json new file mode 100644 index 00000000..d6e87f36 --- /dev/null +++ b/esdt-safe/interactor/contract-codes/header-verifier.mxsc.json @@ -0,0 +1,160 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.79.0", + "commitHash": "129f3b9964af4d4a709d1383930ade12dfe7c081", + "commitDate": "2024-06-10", + "channel": "Stable", + "short": "rustc 1.79.0 (129f3b996 2024-06-10)" + }, + "contractCrate": { + "name": "header-verifier", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.53.0" + } + }, + "abi": { + "name": "Headerverifier", + "constructor": { + "inputs": [ + { + "name": "bls_pub_keys", + "type": "variadic", + "multi_arg": true + } + ], + "outputs": [] + }, + "upgradeConstructor": { + "inputs": [], + "outputs": [] + }, + "endpoints": [ + { + "name": "registerBridgeOps", + "mutability": "mutable", + "inputs": [ + { + "name": "signature", + "type": "array48" + }, + { + "name": "bridge_operations_hash", + "type": "bytes" + }, + { + "name": "operations_hashes", + "type": "variadic", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "setEsdtSafeAddress", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "esdt_safe_address", + "type": "Address" + } + ], + "outputs": [] + }, + { + "name": "removeExecutedHash", + "mutability": "mutable", + "inputs": [ + { + "name": "hash_of_hashes", + "type": "bytes" + }, + { + "name": "operation_hash", + "type": "bytes" + } + ], + "outputs": [] + }, + { + "name": "setMinValidSigners", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "new_value", + "type": "u32" + } + ], + "outputs": [] + }, + { + "name": "addSigners", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "signers", + "type": "variadic
", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "removeSigners", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "signers", + "type": "variadic
", + "multi_arg": true + } + ], + "outputs": [] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": {} + }, + "code": "0061736d0100000001480d60027f7f0060027f7f017f60000060017f017f60017f006000017f60037f7f7f0060047f7f7f7f017f60037f7f7f017f60047f7f7f7f0060017f017e60027f7e0060027f7f017e029c031203656e760b7369676e616c4572726f72000003656e760a6d4275666665724e6577000503656e760d6d427566666572417070656e64000103656e76096d4275666665724571000103656e76106d4275666665724765744c656e677468000303656e760d6d616e6167656443616c6c6572000403656e76136d616e616765644f776e657241646472657373000403656e76126d427566666572417070656e644279746573000803656e76126d616e616765645369676e616c4572726f72000403656e761b736d616c6c496e74476574556e7369676e6564417267756d656e74000a03656e760f6765744e756d417267756d656e7473000503656e76136d42756666657247657442797465536c696365000703656e760f6d4275666665725365744279746573000803656e76126d42756666657253746f726167654c6f6164000103656e76136d42756666657253746f7261676553746f7265000103656e76126d427566666572476574417267756d656e74000103656e760e636865636b4e6f5061796d656e74000203656e760d6d616e6167656453686132353600010344430301000300050502090103050300040404020007000000040100000b030100090705000300010606010101010606030c0300000001000504040202020202020202020205030100030616037f01418080080b7f0041ecd2080b7f0041f0d2080b07b1010c066d656d6f7279020004696e6974004b0775706772616465004c1172656769737465724272696467654f7073004d12736574457364745361666541646472657373004e1272656d6f7665457865637574656448617368004f127365744d696e56616c69645369676e65727300500a6164645369676e65727300510d72656d6f76655369676e65727300520863616c6c4261636b00530a5f5f646174615f656e6403010b5f5f686561705f6261736503020a8e1f430f01017f10012201200010021a20010b0b0020002001100341004a0b3101017f20011015220210042101200041003a00102000200136020c2000200236020820002001360204200041003602000b0d00200010182200100d1a20000b0900200020011000000b0c01017f10182200100520000b1901017f41cc840841cc840828020041016b220036020020000b1d01017f10182200100620001017101304400f0b4187840841241000000b2e01017f419e80084117101b22042000200110071a200441b58008410310071a20042002200310071a20041008000b1101017f1018220220002001100c1a20020b3b01037f101d210220002802002101034041e8d20828020020014a04402000200141016a220336020020022001101e101f200321010c010b0b20020b1101017f1018220041014100100c1a20000b0d00200010182200100f1a20000b4601017f230041106b220224002002200141187420014180fe03714108747220014108764180fe03712001411876727236020c20002002410c6a410410071a200241106a24000b1900200041e8d2082802004e04400f0b41c9800841121000000b1400100a20004604400f0b41db800841191000000b1900200041e8d2082802004c04400f0b41b8800841111000000b0b0041e8d208100a3602000b0b0020002001410410071a0b0f002000200120032002100b4100470b09002000200110021a0b08002000200110280b090020002001100e1a0b1200416c41014100100c1a2000416c100e1a0b190020001012220041f48008410810071a20012000102b20000b4d01027f230041106b22022400200220001004220341187420034180fe03714108747220034108764180fe03712003411876727236020c20012002410c6a1024200120001026200241106a24000b090020002001ad102d0b890101047f230041106b22022400200220013c000f20022001421888a722033a000c20022001421088a722043a000d20022001420888a722053a000e200241003602082000200320047241ff017145220041044105200341ff01711b6a41002000200541ff01711b22006a200041002001501b6a2200200241086a6a410820006b103e200241106a24000b2401017e20002000104122014280808080105a0440200041808008410e103f000b2001a70b190020001012220041fc8008410510071a20012000103020000b4301017f230041106b220224002002200041187420004180fe03714108747220004108764180fe03712000411876727236020c20012002410c6a1024200241106a24000b2000200041868108410b200110322002103322001034200320001034200010280b17002000101222002001200210071a20032000103020000b080041014100101b0b4601017f230041106b220224002002200041187420004180fe03714108747220004108764180fe03712000411876727236020c20012002410c6a410410071a200241106a24000b130020001012220041818108410510071a20000b4001037f200028020822032001103745044020002802042202102e21042000280200200441016a2200102f2001102720022000102c200320012002102e10380b0b0b0020002001103c4100470b0d0020002001103b2002ad102d0b0d0020002001103a2002ad102d0b190020001012220041978108410610071a20002001102620000b190020001012220041978108410610071a20012000102b20000b0a0020002001103b102e0b0a0020002001103a102e0b0d00200020012002101b100e1a0b2c01017f419d8108411b101b2203200010021a200341b58008410310071a20032001200210071a20031008000b1f01017f20001015220110044120470440200041bc81084110103f000b20010ba30102017e027f230041106b22032400200342003703082000101522041004220041094f0440200141808008410e103f000b20044100200320006b41106a200010251a20032903082102200341106a2400200242388620024280fe0383422886842002428080fc0783421886200242808080f80f834208868484200242088842808080f80f832002421888428080fc07838420024228884280fe038320024238888484840b7d01037f230041106b22012400200028020821032001410036020c200028020020034102742001410c6a41041025450440200128020c21022000200341016a360208200241187420024180fe03714108747220024108764180fe0371200241187672721012200141106a24000f0b419e8308410841b880084111101a000b4701017f0240200128020820012802044f04400c010b41012102200110421012220110044120460d00419e8308410841bc81084110101a000b20002001360204200020023602000b2f01017f200128020820012802044f047f410005200110421012210141010b210220002001360204200020023602000b2e01027f20011012210220011012220341b88108410410071a2000200336020420002001360200200020023602080b8a0201047f230041106b220524002005410036020c20002802002103024002400240027f0240024020002d001045044020002802082202100422044190ce004b0d0141e4d2082d00000d0141e0d208200436020041e4d20841013a00002002410041d08408200410251a200041013a00100b200341046a220241e0d2082802004d0d010c050b200041003a0010200220032005410c6a2204410410250d04200341046a210220040c010b2003417b4b0d0120024190ce004b0d02200341d084086a0b200020023602002800002100200541106a2400200041187420004180fe03714108747220004108764180fe0371200041187672720f0b1054000b1054000b200141a68308410f103f000b1600200141bf8308410d101b2201102b2000200110450b0a0041cc8308410f101b0b0e00200041db83084113101b10450b3601037f41ee8308410a101b22011012210220011012220341b88108410410071a2000200336020420002001360200200020023602080ba304020a7f017e230041306b2200240010101023410010222000410036021c2000411c6a101c2101200028021c102020011004210520004100360218200020054102763602142000200136021002400240024003400240200041086a200041106a10442000280208450d00200028020c210741b58308410a101b2202101222092007102a220120011041220a4280808080105a0d02200a4200520d012002103522014167100d1a024041671004450440410121014101210341012105410021040c010b2000411c6a22052001101420052001104621082000411c6a2001104621052000411c6a2001104621042000411c6a200110462000280220200028021c470d0420002d002c044041e0d208410036020041e4d20841003a00000b4101210341016a2101200845044020012105410021040c010b2000411c6a2206200241868108410b200410322203101420062003104621062000411c6a200310461a2000280220200028021c470d0520002d002c044041e0d208410036020041e4d20841003a00000b20022004200620011031200841016a21030b200220012004410010312002419181084106200110322007102720021035210402402003044020031033220210342005200210342001200210342001200210342004200210280c010b200441014100103e0b20092007102a2001ad102d0c010b0b200041306a24000f0b200141808008410e103f000b200141808008410e103f000b200341808008410e103f000b08001010410010210b990301077f230041306b2200240010101023410210224100101e1004413047044041898308410941bc81084110101a000b4101101e210320004102360224200041246a2201101c21042000280224102020011049200028022c20031037450440101d21052004100421064100210103402006200141046a22024f04402000410036022420042001200041246a410410251a20052000280224220141187420014180fe03714108747220014108764180fe0371200141187672721012101f200221010c010b0b101d21012005100421022000410036022c200020024102763602282000200536022403400240200041106a200041246a1044200028021004402001200028021410021a0c020520011018220110111a200320011013450d01200410042101200041003602202000200141027636021c200020043602180340200041086a200041186a104420002802080440200028020c2101200041246a2202200310472002200110360c010b0b200041246a22011049200120031036200041306a24000f0b000b0b41a98208413e1016000b41fa8108412f1016000b2f01017f10101019410110214100101e22001004412047044041e78208411141bc81084110101a000b1048200010270bdf0101087f230041106b220124001010410210214100101e21004101101e210402400240024010171048104010130440200141046a20001047200128020c22052004103c2202450d0220012802082203102e22002002490d0320002002460d012003102e2000490d03200128020422072000102f101521062003102e2002490d0320072002102f200610270c010b41cc8108412e1016000b2003102e2000490d0120012802042000102f10292003200041016b102c2000200247044020052006200210380b20052004103b10290b200141106a24000f0b41ab840841121000000b3f02017e017f10101019410110214100100922004280808080105a044041958008410941808008410e101a000b2000a7210141f88308410f101b2001ad102d0bb40101057f230041206b220024001010101910234100102220004100360214200041146a101c210120002802141020200110042102200041003602102000200241027636020c20002001360208034002402000200041086a10432000280200450d0020002802042101200041146a104a200028021c22042001103d0d0120002802182202102e21032000280214200341016a2203102f2001102720022003102c200420012002102e10390c010b0b200041206a24000b930201087f230041206b220024001010101910234100102220004100360214200041146a101c210120002802141020200110042102200041003602102000200241027636020c20002001360208034002402000200041086a104302402000280200044020002802042104200041146a104a200028021c22052004103d2202450d0320002802182203102e22012002490d0220012002460d012003102e2001490d02200028021422072001102f104021062003102e2002490d0220072002102f200610270c010b200041206a24000f0b2003102e20014904400c010b20002802142001102f10292003200141016b102c2001200247044020052006200210390b20052004103a10290c010b0b41ab840841121000000b02000b0b0041bd8408410e1000000b0bdf040200418080080bcb04696e70757420746f6f206c6f6e677369676e6572736e65775f76616c7565617267756d656e74206465636f6465206572726f722028293a20746f6f2066657720617267756d656e7473746f6f206d616e7920617267756d656e747377726f6e67206e756d626572206f6620617267756d656e74732e6e6f64655f69642e6974656d2e696e666f2e6e6f64655f6c696e6b732e76616c75652e696e64657873746f72616765206465636f6465206572726f7220286b65793a202e6c656e626164206172726179206c656e6774684f6e6c792045534454205361666520636f6e74726163742063616e2063616c6c207468697320656e64706f696e74546865204f7574476f696e67547873486173682068617320616c7265616479206265656e207265676973746572656448617368206f6620616c6c206f7065726174696f6e7320646f65736e2774206d61746368207468652068617368206f66207472616e736665722064617461657364745f736166655f616464726573736f7065726174696f6e735f6861736865737369676e6174757265626c735f7075625f6b6579737661722061726773696e70757420746f6f2073686f7274626c735075624b65797370656e64696e67486173686573657364745361666541646472657373686173684f66486173686573486973746f7279616c6c5369676e6572736d696e56616c69645369676e657273456e64706f696e742063616e206f6e6c792062652063616c6c6564206279206f776e6572696e646578206f7574206f662072616e676570616e6963206f636375727265640041cc84080b0438ffffff", + "report": { + "imports": [ + "checkNoPayment", + "getNumArguments", + "mBufferAppend", + "mBufferAppendBytes", + "mBufferEq", + "mBufferGetArgument", + "mBufferGetByteSlice", + "mBufferGetLength", + "mBufferNew", + "mBufferSetBytes", + "mBufferStorageLoad", + "mBufferStorageStore", + "managedCaller", + "managedOwnerAddress", + "managedSha256", + "managedSignalError", + "signalError", + "smallIntGetUnsignedArgument" + ], + "isMemGrow": false, + "eiCheck": { + "eiVersion": "1.3", + "ok": true + }, + "codeReport": { + "path": "../output/header-verifier.wasm", + "size": 5371, + "hasAllocator": false, + "hasPanic": "without message" + } + } +} diff --git a/esdt-safe/interactor/contract-codes/multiversx-price-aggregator-sc.mxsc.json b/esdt-safe/interactor/contract-codes/multiversx-price-aggregator-sc.mxsc.json new file mode 100644 index 00000000..563ffeee --- /dev/null +++ b/esdt-safe/interactor/contract-codes/multiversx-price-aggregator-sc.mxsc.json @@ -0,0 +1,593 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.79.0", + "commitHash": "129f3b9964af4d4a709d1383930ade12dfe7c081", + "commitDate": "2024-06-10", + "channel": "Stable", + "short": "rustc 1.79.0 (129f3b996 2024-06-10)" + }, + "contractCrate": { + "name": "multiversx-price-aggregator-sc", + "version": "0.53.2" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.53.2" + } + }, + "abi": { + "name": "PriceAggregator", + "constructor": { + "inputs": [ + { + "name": "staking_token", + "type": "EgldOrEsdtTokenIdentifier" + }, + { + "name": "staking_amount", + "type": "BigUint" + }, + { + "name": "slash_amount", + "type": "BigUint" + }, + { + "name": "slash_quorum", + "type": "u32" + }, + { + "name": "submission_count", + "type": "u32" + }, + { + "name": "oracles", + "type": "variadic
", + "multi_arg": true + } + ], + "outputs": [] + }, + "upgradeConstructor": { + "inputs": [], + "outputs": [] + }, + "endpoints": [ + { + "name": "changeAmounts", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "staking_amount", + "type": "BigUint" + }, + { + "name": "slash_amount", + "type": "BigUint" + } + ], + "outputs": [] + }, + { + "name": "addOracles", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "oracles", + "type": "variadic
", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "docs": [ + "Also receives submission count,", + "so the owner does not have to update it manually with setSubmissionCount before this call" + ], + "name": "removeOracles", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "submission_count", + "type": "u32" + }, + { + "name": "oracles", + "type": "variadic
", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "submit", + "mutability": "mutable", + "inputs": [ + { + "name": "from", + "type": "bytes" + }, + { + "name": "to", + "type": "bytes" + }, + { + "name": "submission_timestamp", + "type": "u64" + }, + { + "name": "price", + "type": "BigUint" + }, + { + "name": "decimals", + "type": "u8" + } + ], + "outputs": [] + }, + { + "name": "submitBatch", + "mutability": "mutable", + "inputs": [ + { + "name": "submissions", + "type": "variadic>", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "latestRoundData", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "variadic", + "multi_result": true + } + ] + }, + { + "name": "latestPriceFeed", + "mutability": "readonly", + "inputs": [ + { + "name": "from", + "type": "bytes" + }, + { + "name": "to", + "type": "bytes" + } + ], + "outputs": [ + { + "type": "u32" + }, + { + "type": "bytes" + }, + { + "type": "bytes" + }, + { + "type": "u64" + }, + { + "type": "BigUint" + }, + { + "type": "u8" + } + ] + }, + { + "name": "latestPriceFeedOptional", + "mutability": "readonly", + "inputs": [ + { + "name": "from", + "type": "bytes" + }, + { + "name": "to", + "type": "bytes" + } + ], + "outputs": [ + { + "type": "optional>", + "multi_result": true + } + ] + }, + { + "name": "setSubmissionCount", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "submission_count", + "type": "u32" + } + ], + "outputs": [] + }, + { + "name": "getOracles", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "variadic
", + "multi_result": true + } + ] + }, + { + "name": "setPairDecimals", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "from", + "type": "bytes" + }, + { + "name": "to", + "type": "bytes" + }, + { + "name": "decimals", + "type": "u8" + } + ], + "outputs": [] + }, + { + "name": "getPairDecimals", + "mutability": "readonly", + "inputs": [ + { + "name": "from", + "type": "bytes" + }, + { + "name": "to", + "type": "bytes" + } + ], + "outputs": [ + { + "type": "u8" + } + ] + }, + { + "name": "submission_count", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "name": "pause", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "unpause", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "isPaused", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "bool" + } + ] + }, + { + "name": "stake", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [], + "outputs": [] + }, + { + "name": "unstake", + "mutability": "mutable", + "inputs": [ + { + "name": "unstake_amount", + "type": "BigUint" + } + ], + "outputs": [] + }, + { + "name": "voteSlashMember", + "mutability": "mutable", + "inputs": [ + { + "name": "member_to_slash", + "type": "Address" + } + ], + "outputs": [] + }, + { + "name": "cancelVoteSlashMember", + "mutability": "mutable", + "inputs": [ + { + "name": "member_to_slash", + "type": "Address" + } + ], + "outputs": [] + }, + { + "name": "slashMember", + "mutability": "mutable", + "inputs": [ + { + "name": "member_to_slash", + "type": "Address" + } + ], + "outputs": [] + } + ], + "events": [ + { + "identifier": "pauseContract", + "inputs": [] + }, + { + "identifier": "unpauseContract", + "inputs": [] + }, + { + "identifier": "new_round", + "inputs": [ + { + "name": "from", + "type": "bytes", + "indexed": true + }, + { + "name": "to", + "type": "bytes", + "indexed": true + }, + { + "name": "round", + "type": "u32", + "indexed": true + }, + { + "name": "new_round_event", + "type": "NewRoundEvent" + } + ] + }, + { + "identifier": "discard_submission", + "inputs": [ + { + "name": "from", + "type": "bytes", + "indexed": true + }, + { + "name": "to", + "type": "bytes", + "indexed": true + }, + { + "name": "round", + "type": "u32", + "indexed": true + }, + { + "name": "discard_submission_event", + "type": "DiscardSubmissionEvent" + } + ] + }, + { + "identifier": "discard_round", + "inputs": [ + { + "name": "from", + "type": "bytes", + "indexed": true + }, + { + "name": "to", + "type": "bytes", + "indexed": true + }, + { + "name": "round", + "type": "u32", + "indexed": true + } + ] + }, + { + "identifier": "add_submission", + "inputs": [ + { + "name": "from", + "type": "bytes", + "indexed": true + }, + { + "name": "to", + "type": "bytes", + "indexed": true + }, + { + "name": "round", + "type": "u32", + "indexed": true + }, + { + "name": "price", + "type": "BigUint" + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": { + "DiscardSubmissionEvent": { + "type": "struct", + "fields": [ + { + "name": "submission_timestamp", + "type": "u64" + }, + { + "name": "first_submission_timestamp", + "type": "u64" + }, + { + "name": "has_caller_already_submitted", + "type": "bool" + } + ] + }, + "NewRoundEvent": { + "type": "struct", + "fields": [ + { + "name": "price", + "type": "BigUint" + }, + { + "name": "timestamp", + "type": "u64" + }, + { + "name": "decimals", + "type": "u8" + }, + { + "name": "block", + "type": "u64" + }, + { + "name": "epoch", + "type": "u64" + } + ] + }, + "PriceFeed": { + "type": "struct", + "fields": [ + { + "name": "round_id", + "type": "u32" + }, + { + "name": "from", + "type": "bytes" + }, + { + "name": "to", + "type": "bytes" + }, + { + "name": "timestamp", + "type": "u64" + }, + { + "name": "price", + "type": "BigUint" + }, + { + "name": "decimals", + "type": "u8" + } + ] + } + } + }, + "code": "0061736d0100000001751460027f7f0060000060027f7f017f60017f017f60017f0060037f7f7f006000017f60047f7f7f7f0060037f7f7f017f60047f7f7f7f017f60057f7f7f7f7f0060017e006000017e60027f7e0060017f017e60057f7f7e7f7f017f60027f7f017e60057f7f7f7e7e0060027e7f0060047f7e7f7f0002ac072703656e760e626967496e74536574496e743634000d03656e7609626967496e74416464000503656e760b7369676e616c4572726f72000003656e760a6d4275666665724e6577000603656e760d6d427566666572417070656e64000203656e76096d4275666665724571000203656e76136d42756666657253746f7261676553746f7265000203656e76106d4275666665724765744c656e677468000303656e760d6d616e6167656443616c6c6572000403656e76136d616e616765644f776e657241646472657373000403656e76126d427566666572476574417267756d656e74000203656e76126d427566666572417070656e644279746573000803656e76126d616e616765645369676e616c4572726f72000403656e7619626967496e74476574556e7369676e6564417267756d656e74000003656e761b736d616c6c496e74476574556e7369676e6564417267756d656e74000e03656e760f6765744e756d417267756d656e7473000603656e7609626967496e74537562000503656e76146d427566666572436f707942797465536c696365000903656e760f6d4275666665725365744279746573000803656e7609626967496e74436d70000203656e76196d42756666657246726f6d426967496e74556e7369676e6564000203656e76176d427566666572546f426967496e74556e7369676e6564000203656e76126d42756666657253746f726167654c6f6164000203656e7616736d616c6c496e7446696e697368556e7369676e6564000b03656e760d6d42756666657246696e697368000303656e7614626967496e7446696e697368556e7369676e6564000403656e7611676574426c6f636b54696d657374616d70000c03656e760f6d616e6167656457726974654c6f67000003656e760a626967496e7454446976000503656e760d676574426c6f636b45706f6368000c03656e760d676574426c6f636b4e6f6e6365000c03656e760e636865636b4e6f5061796d656e74000103656e7614736d616c6c496e7446696e6973685369676e6564000b03656e761c6d616e616765644765744d756c74694553445443616c6c56616c7565000403656e7612626967496e7447657443616c6c56616c7565000403656e761b6d616e616765645472616e7366657256616c756545786563757465000f03656e76226d616e616765644d756c74695472616e73666572455344544e465445786563757465000f03656e760a626967496e745369676e000303656e76136d42756666657247657442797465536c696365000903ba01b80103060a010503020002000502000300030000000601030702030600030308060304040401050302020505090900020003030405000000060004110702120505100702030002070800070903080d00020305030002030000000a000a0003031000020202050002001300020400030400000407000e0200060406010306030402040405020a0704030304060a020501040b0302020701050705050106060600030101010101010101010101010101010101010101010101010505030100030616037f01418080080b7f0041a5dd080b7f0041b0dd080b079b031b066d656d6f7279020004696e697400c601077570677261646500c7010d6368616e6765416d6f756e747300c8010a6164644f7261636c657300c9010d72656d6f76654f7261636c657300ca01067375626d697400cb010b7375626d6974426174636800cc010f6c6174657374526f756e644461746100cd010f6c617465737450726963654665656400ce01176c61746573745072696365466565644f7074696f6e616c00cf01127365745375626d697373696f6e436f756e7400d0010a6765744f7261636c657300d1010f73657450616972446563696d616c7300d2010f67657450616972446563696d616c7300d301107375626d697373696f6e5f636f756e7400d40105706175736500d50107756e706175736500d60108697350617573656400d701057374616b6500d80107756e7374616b6500d9010f766f7465536c6173684d656d62657200da011563616e63656c566f7465536c6173684d656d62657200db010b736c6173684d656d62657200dc010863616c6c4261636b00dd010a5f5f646174615f656e6403010b5f5f686561705f6261736503020af97cb8011601017f1028220142001000200120012000100120010b1901017f41808f0841808f0828020041016b220036020020000b31000240200120024d0440200220044d0d01102a000b102a000b2000200220016b3602042000200320014102746a3602000b060010bb01000b18002001102c210120002002102c360204200020013602000b0f01017f10032201200010041a20010b0b0020002001100541004a0b4101017f2001280204220220012802084b047f4100052001200241016a36020420012802002802002002102f210141010b210220002001360204200020023602000b0a0020002001107a107b0b5b01037f230041106b2203240020012802042202047f200341086a20012802002204280200200210312001200328020c360204200428020020021032210241010541000b21012000200236020420002001360200200341106a24000b800101027f230041206b220324002003410c6a22042001419e8208410b200210702201103520042001104e21022003410c6a2001104e21042003280210200328020c46044020032d001c04404194dd0841003602004198dd0841003a00000b2000200436020420002002360200200341206a24000f0b200141808008410e104f000b1000200041a98208410620011070107b0b0b0020012000103410061a0b0f01017f10282201200010141a20010b3101017f20011036220210072101200041003a00102000200136020c2000200236020820002001360204200041003602000b0d0020001028220010161a20000b0a0020001034200110380b4f01027f230041106b22022400200220001007220341187420034180fe03714108747220034108764180fe03712003411876727236020c20012002410c6a41041050200120001053200241106a24000b0900200020011002000b0c01017f10282200100820000b1d01017f1028220010092000103a102d04400f0b41a98e0841241002000b0d00200010282200100a1a20000b2e01017f41d480084117103e220420002001100b1a200441eb80084103100b1a200420022003100b1a2004100c000b1101017f102822022000200110121a20020b3b01037f10402102200028020021010340419cdd0828020020014a04402000200141016a220336020020022001103c1041200321010c010b0b20020b1101017f102822004101410010121a20000b4601017f230041106b220224002002200141187420014180fe03714108747220014108764180fe03712001411876727236020c20002002410c6a4104100b1a200241106a24000b0c00200010282200100d20000b2301017e2000100e22014280025a044041898908410841808008410e103d000b2001a70b2401017e2000100e22034280808080105a04402001200241808008410e103d000b2003a70b2301017f4100103c22001007412047044041d18608410f41e182084110103d000b20000b4c01017f230041106b220124002000100741044604402001410036020c200041002001410c6a410410521a41feffffff072000200128020c41c58eb1a204461b21000b200141106a240020000b19002000419cdd082802004e04400f0b41ff800841121002000b1400100f20004604400f0b4191810841191002000b19002000419cdd082802004c04400f0b41ee800841111002000b0b00419cdd08100f3602000b1f0020002001200210102000104c41ff017104400f0b41aa810841301002000b1500410241012000102522001b4100200041004e1b0b3e01037f20002001104e21022000280200210310032104200028020820032002200410110440200141da8108410f104f000b2000200220036a36020020040b5101017f230041106b220224002002410036020c20002002410c6a41042001109801200228020c2100200241106a2400200041187420004180fe03714108747220004108764180fe0371200041187672720b2c01017f41c28208411b103e2203200010041a200341eb80084103100b1a200320012002100b1a2003100c000b0b00200020012002100b1a0b0c00200020012002200310520b0f00200020012003200210264100470b09002000200110041a0b1500417f200020011013220041004720004100481b0b0a0020002000200110010b0d0020001028220010151a20000b0d002000416710161a416710070b0a0020004101410010590b0d00200020012002103e10061a0b080020002001105b0b09002000200110061a0b4001017f2001280200220204402002105d2202105e20012802042002105e20012802082002105e200128020c2002105e20002002105b0f0b20004101410010590b080041014100103e0b4501017f230041106b220224002002200041187420004180fe03714108747220004108764180fe03712000411876727236020c20012002410c6a41041050200241106a24000b1200416c4101410010121a2000416c10061a0b3b01027f20002001280200220520012802082200200210612000200210622003105d220010632004200010632000105b20052001280204200210640b4902017f017e230041106b220424002000200120031068047e200420022003106520042903002105200020042903083703102000200537030842010542000b370300200441106a24000b19002000102c2200418a82084107100b1a20002001105320000b7701017f230041106b220224002002200042388620004280fe0383422886842000428080fc0783421886200042808080f80f834208868484200042088842808080f80f832000421888428080fc07838420004228884280fe038320004238888484843703082001200241086a41081050200241106a24000ba90101047f230041206b22032400200020021068450440200341106a2001106e2003200328021c41016a220436021c024020032802102206450440200320043602140c010b200341086a20012003280218220510312001200520032802082004106f0b2001200420054100106f20032004360218200141a982084106200410702002105a2003200641016a3602102001200341106a107420002002106b2004ad10730b200341206a24000b7c02027f027e230041206b220324002003410c6a22042001200210622201103520042001106621052003410c6a2001106621062003280210200328020c46044020032d001c04404194dd0841003602004198dd0841003a00000b2000200637030820002005370300200341206a24000f0b200141808008410e104f000b850102017e017f230041106b22032400200342003703082000200341086a4108200110980120032903082102200341106a2400200242388620024280fe0383422886842002428080fc0783421886200242808080f80f834208868484200242088842808080f80f832002421888428080fc07838420024228884280fe038320024238888484840b2a00200120031068047f2002200310621069210341010541000b210120002003360204200020013602000b0b002000200110754100470b08002000103610560b0a0020002001106b10580b19002000102c2200419182084108100b1a20002001105320000bbd0101057f230041206b22042400200020022003106d450440200441106a2001106e2004200428021c41016a220536021c024020042802102207450440200420053602140c010b200441086a20012004280218220610312001200620042802082005106f0b2001200520064100106f20042005360218200141a982084106200510702002105d220610382003200610382006105b2004200741016a36021020011071200441106a105c20002002200310722005ad10730b200441206a24000b0f00200020012002107210764100470bab0101057f230041206b220224000240024020011071220110574504400c010b2002410c6a22032001103520032001104e21062002410c6a2001104e21032002410c6a2001104e21042002410c6a2001104e21052002280210200228020c470d0120022d001c450d004194dd0841003602004198dd0841003a00000b2000200536020c200020043602082000200336020420002006360200200241206a24000f0b200141808008410e104f000b20002000419e8208410b200110702002105d2200105e20032000105e2000105b0b17002000102c220020012002100b1a20032000105e20000b13002000102c220041af82084105100b1a20000b1b002000102c2200419182084108100b1a200120022000107720000b3701017f230041106b2202240020024200370308200220014100200241086a108e012000200228020020022802041059200241106a24000b0a00200010712001105c0b0a0020002001106b10760b2501017e2000200010850122014280808080105a0440200041808008410e104f000b2001a70b0e002000200210382001200210380b1f01017f230041106b2201240020012000106e2001280200200141106a24000b090020002001ad10730b19002000102c2200419982084105100b1a20012000105e20000b1f01017f20001036220110074120470440200041e182084110104f000b20010b10002000419e8208410b2001107010580b1000200041a9820841062001107010580b2e01017f230041106b2202240020022001280200106e2000200228020436020420002001360200200241106a24000b6702027f017e230041106b220524002000200120032004106d047f2002102c220141b482084108100b1a20032004200110772001102c2102200541086a2001108001200529030821072000200236020c2000200737020441010541000b360200200541106a24000b1801017f2001102c210220002001360204200020023602000b4d01017f2000200120032004106d047f2002102c220141b482084108100b1a20032004200110772001102c220241dd82084104100b1a200020023602082000200136020441010541000b3602000b08002001200010330b08002000103610460b3301017e027f0240200020001085012201420158044041002001a741016b0d021a0c010b2000418683084112104f000b41010b0ba30102017e027f230041106b22032400200342003703082000103622041007220041094f0440200141808008410e104f000b20044100200320006b41106a200010521a20032903082102200341106a2400200242388620024280fe0383422886842002428080fc0783421886200242808080f80f834208868484200242088842808080f80f832002421888428080fc07838420024228884280fe038320024238888484840b0b0020002001108701105f0b19002000102c220041bc82084106100b1a20002001105320000ba40101067f0240200028020822052001108901220204400240200220002802042204107622034d044020022003460d01200410762003490d03200028020022072003102f2106200410762002490d0320072002107a2006105a0c010b0c020b200410762003490d0120002802002003107a105f2004200341016b107920022003470440200520062002108a010b200520011086010b20024100470f0b41cd8e0841121002000b0b002000200110870110760b0e00200020011087012002ad10730b4201037f200028020822032001108c0145044020002802042202107621042000280200200441016a2200107a2001105a2002200010792003200120021076108a010b0b0c00200020011089014100470b4301027f230041106b22022400104021032002420037030820022001ad4100200241086a108e0120032002280200200228020410121a200020031041200241106a24000baa0202047f027e2003200142388620014280fe0383422886842001428080fc0783421886200142808080f80f834208868484200142088842808080f80f832001421888428080fc07838420014238882208200142288822094280fe0383848484370000200041084100200142005322072002716b41ff017122042008a746220520042001423088a741ff01714671220620056a2006410020042009a741ff0171461b22056a2005410020042001422088a741ff0171461b22056a2005410020042001a72205411876461b22066a200641002004200541107641ff0171461b22066a200641002004200541087641ff0171461b22046a200441002001501b6a22042007200320044107716a2c0000410048732004410047712002716b22026b3602042000200220036a3602000b0d0010401a20002001102c10410b1201017f1040220220002001103e104120020bf60101037f230041d0006b22012400200141286a200041046a2202107e200120012903283702400340200141206a200141406b103020012802200440200028020820012802241062105f0c0105200141186a2002107e2001200129031837024003400240200141106a200141406b10302001280210044020002802002001280214106a0c0205200141306a2002280200106e2001280234210003402000450d02200141086a200228020020001031200128020c20022802002000107c20022802002000107d21000c000b000b000b0b200141c8006a4200370300200142003703402002280200200141406b1074200141d0006a24000b0b0b8a0101047f230041106b220324002001280204220241046a220420012802084b047f41000520012802002003410036020c28020020022003410c6a410410511a200328020c210220012004360204200241187420024180fe03714108747220024108764180fe037120024118767272210241010b21012000200236020420002001360200200341106a24000b7d01037f230041106b22012400200028020821032001410036020c200028020020034102742001410c6a41041051450440200128020c21022000200341016a360208200241187420024180fe03714108747220024108764180fe037120024118767272102c200141106a24000f0b41f18208410841ee80084111103d000b980101047f230041206b2201240020012000280204107636021c20014101360218200120003602140340200141086a200141146a102e200128020804402000280208200128020c1086010c01052000280204107621034101210203402004200220034b7245044020002802002002107a105f200220034f2104200220022003496a21020c010b0b200028020441001079200141206a24000b0b0b4801017f0240200128020820012802044f04400c010b410121022001109301102c220110074120460d0041f18208410841e182084110103d000b20002001360204200020023602000b2e01027f2001102c21022001102c220341dd82084104100b1a2000200336020420002001360200200020023602080b2e0020003502081017200028020c10181a200028021010181a2000290300101720002802141019200031001810170bef0301077f2000280200210702400240024002400240024020002d001045044020002802082204100722054190ce004b0d014198dd082d00000d014194dd0820053602004198dd0841013a00002004410041848f08200510511a200041013a00100b200220076a22084194dd082802004d0d010c050b200041003a0010200420072001200210510d04200220076a21080c010b200720084b0d0120084190ce004b0d02200741848f086a210320012104200241104f04402004410020046b41037122016a210620010440200321050340200420052d00003a0000200541016a2105200441016a22042006490d000b0b2006200220016b220a417c7122096a21040240200120036a22014103710440200941004c0d012001410374220241187121072001417c71220541046a2103410020026b4118712102200528020021050340200620052007762003280200220520027472360200200341046a2103200641046a22062004490d000b0c010b200941004c0d0020012103034020062003280200360200200341046a2103200641046a22062004490d000b0b200120096a2103200a41037121020b20020440200220046a21010340200420032d00003a0000200341016a2103200441016a22042001490d000b0b0b200020083602000f0b102a000b102a000b200341da8108410f104f000b2601017f230041106b22022400200220003a000f20012002410f6a41011050200241106a24000ba30102017e027f230041106b220224002002420037030820001007220341094f044041f18208410841808008410e103d000b20004100200220036b41106a200310521a20022903082101200241106a2400200142388620014280fe0383422886842001428080fc0783421886200142808080f80f834208868484200142088842808080f80f832001421888428080fc07838420014228884280fe038320014238888484840b2e01017f230041106b22022400200241003a000f20002002410f6a4101200110980120022d000f200241106a24000b2601017f230041106b22022400200220013a000f20002002410f6a41011050200241106a24000b0b00109f011084014101730b3901027f230041106b22012400109f012001420037030820012000ad4101200141086a108e01200128020020012802041059200141106a24000b0a0041c98a084113103e0b1200109d0145044041ae830841121039000b0b4401047f230041106b2201240010a20110692103200010a30110692104200141046a10a401200128020c2000108c0104402004200310a50121020b200141106a240020020b0a0041928c084122103e0b1401017f419f8b08411b103e22012000105320010b0f00200041d58b08411c103e1096010b0f0020002001105441ff01714102490ba60101037f230041406a22012400200141106a10a70120001007210220014100360224200120024102763602202001200036021c2001280210210202400340200141086a2001411c6a1095012001280208450d012002200128020c220010680d00200141286a2203200141106a2000102c420042001060200310a40120032000108b01200310a401200128022c107641e500490d000b41d2830841161039000b200141406b24000b0d002000410d41d98c0810de010b20002000200110a90141ff0171200241ff0171470440419f870841181039000b0bbf0101027f230041206b220224002002410c6a2000200110b201220310350240024002402002280210200228020c460440410021010c010b410021010240024002402002410c6a2003109b0141ff01710e020201000b200341f98208410d104f000b410121012002410c6a2003109b0121000b2002280210200228020c470d010b20022d001c04404194dd0841003602004198dd0841003a00000b2001450d01200241206a240020000f0b200341808008410e104f000b41e68708411c1039000bc00102037f017e230041206b2205240002400240200410762207450d00200410762007490d002005410c6a220620032007107a2203103520062003104d10562104200620031066210820062003109b0121062005280210200528020c470d0120052d001c04404194dd0841003602004198dd0841003a00000b200020023602102000200136020c20002007360208200020063a00182000200436021420002008370300200541206a24000f0b41cd8e0841121002000b200341808008410e104f000bcd0b02097f037e230041f0026b220424002004200136024c20042000360248200441e4026a10ac01200441406b20002001102b20042802e40222052004280240220920042802442206106d450440200441386a20092006102b200520042802e8022004280238200428023c106c0b20044180016a2207200520042802ec0220092006107f0240200428028001450d00200441d8006a2004418c016a2802003602002004200429028401370350200441c8006a220910ad012105200910ae012106200710af01200441dc006a20042802800120042802880120002001108101200428025c047f2004280264107641016a0541000b2109101a210d20044180016a2004280254106e027f027e20042802800122070440200520051085010c010b2005200d1073200d0b220e42880e7c200d5a04402007450c010b200441d0006a1091012005200d10732006200d10732000102c21072001102c210a41b58d08410d10900122052007108f012005200a108f0120052009108d0120051040101b200d210e41010b2107103a2105027e200428025020051068220a200745200d200e54717204402000102c21022001102c210141d08d08411210900122002002108f0120002001108f0120002009108d01200d1040102c22011063200e20011063200a200110990120002001101b42000c010b2005102c210520021027200441306a2004280250200441d8006a220828020020051067200828020020051062103320042802502004280254200510642006200d1073200441286a20002001102b20042802282107200428022c210a200441f0006a2008280200360200200420042903503703682004200a36027c200420073602780240200428026c1078220510b0011076490d000240024020054133490440410021052004410036028001200441206a200441e8006a2206410472107e200420042903203702e402200420063602ec0220044184016a220621080340200441186a200441e4026a1030024020042802184101460440200420042802ec02220b280200200b41086a280200200428021c106720042802000d010c080b027f20054504404100210541040c010b20062005200441e4026a410041202005676b10b10120054101762108024020054101714504402005200841016b220b4b04402006200b4102746a280200102722052005200620084102746a28020010271001417242021000200520054172101c0c020b41bf890841151039000b200620084102746a280200102721050b200441013602d00241080b200441cc026a6a200536020020042802d002450d0320042802d4022106101a210d200441e8006a109101200441f8006a220510ad01105f200510ae01105f200441d8026a10af01200441106a2007200a102b20042802d8022205200428021022082004280214220b106d450440200441086a2008200b102b200520042802dc022004280208200428020c106c0b200441e4026a200520042802e0022008200b10810120042802e402450d0720042802e80220042802ec022208107641016a220b107a105d21052006103420051038200d2005106320052003109c012005105b2008200bad1073101d2007102c2105200a102c210720061027101e210f41ac8d08410910900122062005108f0120062007108f0120062009108d011040102c22051037200d2005106320032005109901200f200510632005106320062005101b0c050b20054132460d03200820042802043602002004200541016a220536028001200841046a21080c000b000b41b7870841211039000b41d88708410e1039000b10c001000b2000102c21032001102c210141c28d08410e10900122002003108f0120002001108f0120002009108d0110401a200020021034101b42010b210d200441e4026a220110a701103a210020042802e402220220001068044020044180016a2203200220042802ec0220001061200429038001500d01200429039001210e200429038801210f200320012000102c200d200f7c200e42017c10600b200441f0026a24000f0b10bb01000b0d002000410b4198890810de010b1e01017f418c8d08411a103e2101200028020020002802042001107720010b1e01017f41f38c084119103e2101200028020020002802042001107720010b0d002000410641a68d0810de010b0a0041a389084110103e0bfa1201127f230041d0026b22072400410121144101210f02400340200121082000210b024003400240200841154f044020040d01200841017641016b210503402005417f46044020082105034020054102490d08200b20084100200541016b220510ba01200741086a41002005200b200810292007280208200728020c410010bf010c000b0005200b2008200510bf01200541016b21050c010b000b000b200841014d0d04200b2008410110be010c040b200f450440200841017641feffffff0771210c417f2105417f200841016b6776210920082106034020054102470440200b20082005200c6a2006410d74200673220641117620067322064105742006732206200971220a200841002008200a4d1b6b10ba01200541016a21050c010b0b200441016b21040b20072008410276220636023c2007200641017422053602402007200641036c220c36024420074100360248200720083602d8012007200b3602d401200720023602d0012007200741c8006a3602dc01200841314b04402007200641016b36024c2007200641016a360250200741d0016a2206200741cc006a22092007413c6a200741d0006a220a10bd012007200541016b36024c2007200541017236025020062009200741406b200a10bd012007200c41016b36024c2007200c41016a36025020062009200741c4006a200a10bd010b200741d0016a2007413c6a200741406b200741c4006a10bd0102400240200f027f20072802482206410c4f0440200741306a410020084101762205200b200510292007280234210920072802302106200741286a41002005200b20084102746a2005410274220c6b20051029200541016b21052007280228200c6a41046b210a200728022c210c024003402005417f460d012009450d042005200c4904402006280200210d2006200a280200360200200a200d360200200941016b2109200641046a2106200a41046b210a200541016b21050c010b0b10bb01000b20082007280240417f736a210c41010c010b2007280240210c2006450b20147171450d01200b41046b2112410121054100210d200841324921130340200d4105460d0220052008200520084b1b210a200d41016a210d201220054102746a21060340024002402005200a460440200a21050c010b200641046a2209280200200628020010b901450d010b2013200520084672450440200b2008200541016b2206200510ba0120054102490d03200741206a41002005200b2008102920072802202007280224200610be01200741186a41002005200b2008102920072802182109200728021c2106230041106b220a24000240200641014b0440200a41086a41002006200920061029200a28020c210e200a2802082209280204200928020010b901450d01200941046a21062009280200211020092009280204360200200e41026b21112009200e4102746a41046b210e034002402011047f200641046a2209280200201010b9010d01200605200e0b20103602000c030b20062009280200360200201141016b2111200921060c000b000b10bb01000b200a41106a24000c030b20052008460d080c040b200541016a2105200921060c000b000b000b10bb01000b2003450440200121080c020b2008200c4d044010bb01000b2003280200200b200c4102746a28020010b9010440200b21000c020b41002105200b20084100200c10ba01200b41046a210d200841016b210a200b280200210c0340200a20052005200a491b2109200d20054102746a21060240034020052009460d01200c200628020010b901450440200641046a2106200541016a21050c010b0b200521090b200b200a4102746a2105024003402009200a41016b220a4f0d0120052802002106200541046b2105200c200610b9010d000b200d20094102746a220628020021112006200541046a220628020036020020062011360200200941016a21050c010b0b200b200c360200200941016a220620084d0440200820066b2108200b20064102746a210b0c010b0b102a000b4100210f200020084100200c10ba01200841016b210120002802002110200041046a220c210503400240024002402001200f4604402001210f0c010b2005280200201010b9010d010b200020084102746a41046b2105200121060340200f2006220b4f2214450440200641016b21062005280200200541046b2105201010b901450d010b0b200741106a200f200b200c200110292007280210221120072802144102746a210b41800121014100210e41002105410021094100210d41800121122011210c03400240200b200c6b220a418408492215450d00200a41027621062009200d4b22132005200e49722216044020064180016b220a200120131b21012012200a200620161b20131b21120c010b2006200a41037622126b21010b02402009200d470d0041002106200c210a200741d0006a220d2109034020062012460d01200920063a0000200641016a21062009200a280200201010b9014101736a2109200a41046a210a0c000b000b02402005200e470d00200b41046b210a41002106200741d0016a2205210e034020012006460d01200e20063a0000200641016a2106200a280200201010b901200e6a210e200a41046b210a0c000b000b2009200d6b2206200e20056b220a2006200a491b220a0440200d41016a2106200a41016b210a200c200d2d00004102746a220d2802002113037f200d200b20052d0000417f734102746a220d280200360200200a047f200d200c20062d00004102746a220d280200360200200641016a2106200a41016b210a200541016a21050c0105200d20133602002006210d200541016a0b0b21050b200b410020016b41002005200e461b4102746a210b200c201241002009200d461b4102746a210c2015450d000b02402009200d4d04402005200e4f0d0103402005200e4f0d02200c2802002101200c200b200e41016b220e2d0000417f734102746a220628020036020020062001360200200c41046a210c0c000b000b03402009200d4b0440200c200941016b22092d00004102746a220128020021062001200b41046b220b280200360200200b20063602000c010b0b200b210c0b20002010360200200020084100200c20116b410276200f6a220110ba012001200846200120084b720d0120084103762001200820016b220520012005491b4d210f200020014102746a220641046a2108200541016b220520014d04402008200520022006200410b1010c040b2000200120022003200410b1012006210320052101200821000c030b200541046a2105200f41016a210f0c010b0b0b10c001000b200741d0026a24000b2201017f41e68c08410d103e210220002802002002103820012802002002103820020b930101027f230041306b220324000240109d010440200341106a220410af01200341046a20032802102003280218200120021081012003280204450d012004200120022003280208200328020c10aa01200020032d00283a0018200020032903203703102000200329031837030820002003290310370300200341306a24000f0b41ae830841121039000b4182880841141039000b3f01027f230041106b22002400103a2101200041046a10a70102402000280204200110680440200110a1010d010b41a9880841141039000b200041106a24000b4201017f230041106b220124000240200041024d0d00200141046a10a70120012802081078200049200041324b720d00200141106a24000f0b41bd880841181039000b2e01017e02402000101a2201580440200120007d421f5a0d010f0b41d58808411c1039000b41f1880841181039000b0d002000104c41ff017141014b0b0f0020002001105441ff01714101470b100020002001105441ff017141ff01460b44000240200120024b0440200120034b0d0110bb01000b10bb01000b200020024102746a220128020021022001200020034102746a2200280200360200200020023602000b060010c001000b4f01037f20002802042203200228020022044102746a2802002003200128020022054102746a28020010b90104402002200536020020012004360200200028020c2200200028020041016a3602000b0b1d0020002001200210bc0120002002200310bc0120002001200210bc010bd40101077f230041106b2205240002402001200241016b4b0440034020012002460d02200541086a4100200241016a220220002001102920052802082207200528020c22084102746a220341046b2204280200200341086b220928020010b901450d002004280200210620042009280200360200200841026b21042003410c6b2103034002402004047f2006200328020010b9010d01200341046a0520070b20063602000c020b200341046a2003280200360200200441016b2104200341046b21030c000b000b000b10bb01000b200541106a24000b900101027f024002400340024020024101742204410172220320014f0d002001200441026a22044b0440200020034102746a280200200020044102746a28020010b90120036a21030b200120024d0d02200120034d0d03200020024102746a280200200020034102746a28020010b901450d00200020012002200310ba01200321020c010b0b0f0b10bb01000b10bb01000b0b0041ef8e08410e1002000b0a0041eb8a08411a103e0b0a0041858b08411a103e0b0a0041ba8b08411b103e0b1901017f41b48c084125103e220220011053200020021096010b09002000109301102c0bc904010b7f230041206b22012400101f104a410510494100103c10462106410110422102410210422103410341b38908410c10442104410441a3890841101044210720014105360214200141146a103f2100200128021410472001200036020c1040210520012000100736021c2001410036021820012001410c6a3602140240034002402001200141146a1092012001280200450d002001280204102c102c220010074120470d022001200041187420004180fe03714108747220004108764180fe0371200041187672723602102005200141106a4104100b1a0c010b0b200510072109410021000240024002400240024003402009200041046a220a4904400240200141146a10a401200128021810762200450d00200041e5004f0d03200020044d0d04200441014d0d05200210b701450d06200310b701450d062003200210b801450d0710c30121000240200641feffffff074704402000200610061a0c010b200041868208410410590b200210a2011033200310c101103310c20120041079200128020c10a601200710b50110b001200710794101109e01200141206a24000f0b052001410036021420052000200141146a2208410410521a20012802142100200810a4012008200041187420004180fe03714108747220004108764180fe037120004118767272108b01200a21000c010b0b418f840841101039000b41d2830841161039000b419f8408412f1039000b41ce840841301039000b41fe840841241039000b41a2850841311039000b419980084119103e220041e182084110100b1a2000100c000b0d00101f410010484101109e010bda0101057f230041206b22002400101f103b4102104841001042210241011042210302400240200210b701450d00200310b701450d002003200210b8010440200041086a220110a40110c201107621042000200028020c107636021c20004101360218200020013602144100210103402000200041146a102e2000280200450d032002200028020410a301106910b90120016a220120044d0d000b0c020b41a2850841311039000b41fe840841241039000b200120044b044010a201200210820110c1012003108201200041206a24000f0b41e08608413f1039000b3601027f230041106b22002400101f103b104a410010492000410036020c2000410c6a103f200028020c104710a601200041106a24000b880401097f23004180016b22002400101f103b104a41011049410041a3890841101044210620004101360258200041d8006a103f210120002802581047200041406b10a70120011007210320004100360254200020034102763602502000200136024c200028024821072000280244210120002802402108024003400240200041386a200041cc006a1095012000280238450d002008200028023c2203107522040440200041306a2001200410312000280234210220002802302105200041d8006a2001106e024020050440200041286a2001200510312001200520002802282002106f0c010b2000200236025c0b024020020440200041206a2001200210312001200220052000280224106f0c010b200020053602600b20012004107c2001200410321a20012004107d2000200028025841016b3602582001200041d8006a107420082003106a200041106a200720031065200720031062105f0b200041e8006a220410a40110c2011076210220042003108801200028026c107620024d0d02450d012000200028026c107636027c20004101360278200020043602740340200041086a200041f4006a102e20002802080440200041d8006a2202200028020c10c401200220031088011a0c0105200041d8006a2202200310c40120021094010c030b000b000b0b200610b50110b0012006107920004180016a24000f0b41d3850841c7001039000b6902057f017e230041106b22002400101f410510484100103c21014101103c21024102100e4103104221044104104321032000200236020c2000200136020810a00110b40110b601200041086a2000410c6a200310a801200120022004200310ab01200041106a24000bf40102057f027e230041206b22002400101f104a410010492000410036020c2000410c6a103f2103200028020c104710a00110b401200310072101200041003602142000200141027622013602102000200336020c02400340200120024b04402000410c6a220110c50121022000410c6a10c50121032001109301109a012000410c6a109301105621012000410c6a109301109a0122064280025a0d02200020023602182000200336021c10b601200041186a2000411c6a2006a7220410a801200220032001200410ab0120002802102101200028021421020c010b0b200041206a24000f0b41f18208410841808008410e103d000ba70301097f230041406a22002400101f4100104810a001200041146a220110af01200041206a22032000280218106e024002402000280220044010402104200110af01200320002802182205106e20002802242101200028021c210720002802142108034020010440200041086a200520011031200028020c200041206a2202200541a982084106200110702201103520022001104d2102200041206a2001104d210620002802242000280220470d0320002d003004404194dd0841003602004198dd0841003a00000b200041206a220120082007200220061081012000280220450d042001200220062000280224200028022810aa011040102c210120002802282001105e200028022c2001103820002802302001103820002903202001106320002802342001103720002d0038200110990120042001104121010c010b0b20002004360210200020041007360228200041003602242000200041106a36022003402000200041206a10920120002802000440200028020410181a0c010b0b200041406b24000f0b4196880841131039000b200141808008410e104f000b418e8008410b1039000b2c01017f230041206b22002400101f4102104820004100103c4101103c10b3012000109701200041206a24000b3801027f230041306b22002400101f41021048200041106a22014100103c4101103c10b301200042003703082001109701200041306a24000b2201017f101f103b41011048410041a3890841101044220010b50110b001200010790ba70101037f230041306b22002400101f4100104810402101200041246a10a701200041106a200041286a107e2000200029031037021c0340200041086a2000411c6a103020002802080440200028020c210210401a20012002102c10410c010b0b2000200136021820002001100736022c200041003602282000200041186a36022403402000200041246a10920120002802000440200028020410181a0c010b0b200041306a24000be40101067f230041406a22002400101f103b410310484100103c21014101103c210241021043210420002002360208200020013602040240200041046a200041086a10b201220510570440109f01108401450d010b105d22034101109c0120032004109c0120052003105b200020023602102000200136020c200041246a10ac01200041146a2000280224200028022c20012002107f20002802140440200041386a200041206a28020036020020002000290218370330200041306a1091010b2000410c6a220110ad01105f200110ae01105f200041406b24000f0b4198830841161039000b4801037f230041106b22002400101f410210484100103c21014101103c2102200020013602082000200236020c200041086a2000410c6a10a901ad42ff01831017200041106a24000b1000101f4100104810b0011076ad10170b1c00101f103b410010484101109e0141bc8a08410d1090011040101b0b1c00101f103b410010484100109e0141dc8a08410f1090011040101b0b1100101f41001048109f01108401ad10200ba20301047f230041106b2202240041001048416b2100024041a4dd082d000022010440416b41ffffffff0720011b21000c010b41a4dd0841013a0000416b10210b0240024002400240027f024002400240200010074104760e020102000b41b2800841221002000b41752101024041a0dd082d000022000440417541ffffffff0720001b21010c010b41a0dd0841013a0000417510220b20011027210141feffffff070c010b200241086a420037030020024200370300200041002002411010520d01200229020450450d02200228020c220141187420014180fe03714108747220014108764180fe03712001411876727221012002280200220041187420004180fe03714108747220004108764180fe0371200041187672720b220010c3011083012203470440200041feffffff0746200341feffffff0746720d0320002003102d450d030b103a2100200210a40120022802082000108c01450d03200010a3012200106922032001105520002003108201200241106a24000f0b41e98108411d1002000b418d8e08411c1002000b419a860841151039000b41af860841221039000ba50201077f230041106b22022400101f41011048410010422201103a220510a30122041069220310b80104401028220020032001104b10a20110692103200210a40102400240024020022802082005108c0104402000200310a501450d010b20002004103310c30110830121001040210410402103200041feffffff07470d012005200142002004200310231a0c020b41df8e0841101039000b104021062000102c2100200110272101200242003702042002200041187420004180fe03714108747220004108764180fe0371200041187672723602002002200141187420014180fe03714108747220014108764180fe03712001411876727236020c200620024110100b1a2005200642002004200310241a0b200241106a24000f0b41df8e0841101039000b5701047f230041106b22002400101f4101104802401045220110a1010440103a220210a101450d01200041046a2203200110c40120032002108b01200041106a24000f0b41e8830841271039000b41df8e0841101039000b3601047f230041106b22002400101f4101104810452101103a2102200041046a2203200110c401200320021088011a200041106a24000b850101047f230041106b22012400101f410110481045210010c20110762102200141046a200010c40120012802081076200249044041c0830841121039000b10c10110692102200010a30122031069220020002002104b2003200010820141f18b084121103e2200106922032002105520002003108201200141046a109401200141106a24000b02000b3b01037f230041106b2203240020022001103e2204102c2105200341086a20041080012000200329030837020020002005360208200341106a24000b0b910f0200418080080bfd0e696e70757420746f6f206c6f6e676d697373696e67206b657973657269616c697a6572206465636f6465206572726f723a20696e636f7272656374206e756d626572206f662045534454207472616e7366657273617267756d656e74206465636f6465206572726f722028293a20746f6f2066657720617267756d656e7473746f6f206d616e7920617267756d656e747377726f6e67206e756d626572206f6620617267756d656e747363616e6e6f74207375627472616374206265636175736520726573756c7420776f756c64206265206e65676174697665696e70757420746f6f2073686f72744d616e6167656456656320696e646578206f7574206f662072616e676545474c442e6d61707065642e6e6f64655f69642e6974656d2e6e6f64655f6c696e6b732e76616c75652e696e666f2e73746f726167652e696e64657873746f72616765206465636f6465206572726f7220286b65793a202e6c656e626164206172726179206c656e6774687661722061726773696e76616c69642076616c7565696e707574206f7574206f662072616e6765436f6e7472616374206973206e6f7420706175736564436f6e74726163742069732070617573656451756f72756d206e6f742072656163686564546f6f206d616e7920626f617264206d656d62657273566f7465642075736572206973206e6f742061207374616b656420626f617264206d656d6265724e6f20626f617264206d656d6265727351756f72756d20686967686572207468616e20746f74616c20706f737369626c6520626f617264206d656d6265727351756f72756d206d696e696d756d20626f617264206d656d6265727320726571756972656d656e74206e6f74206d65745374616b696e6720616e6420736c61736820616d6f756e742063616e6e6f742062652030536c61736820616d6f756e742063616e6e6f7420626520686967686572207468616e207265717569726564207374616b6572656d61696e696e67206e756d626572206f6620626f617264206d656d62657273206d7573742062652067726561746572207468616e2074686520736c6173682071756f72756d496e76616c6964207061796d656e7420746f6b656e4f6e6c792077686974656c6973746564206d656d626572732063616e207374616b656d656d6265725f746f5f736c6173684e6577207374616b696e6720616d6f756e7420697320746f6f2062696720636f6d706172656420746f206d656d62657273207374616b656420616d6f756e7477726f6e67206e756d626572206f6620646563696d616c737375626d697373696f6e206c6973742063617061636974792065786365656465646e6f207375626d697373696f6e737061697220646563696d616c73206e6f7420636f6e66696775726564746f6b656e2070616972206e6f7420666f756e646e6f20636f6d706c6574656420726f756e64736f6e6c79206f7261636c657320616c6c6f776564496e76616c6964207375626d697373696f6e20636f756e7454696d657374616d702069732066726f6d20746865206675747572654669727374207375626d697373696f6e20746f6f206f6c64646563696d616c736f7261636c65737375626d697373696f6e737375626d697373696f6e5f636f756e74736c6173685f71756f72756d6d656469616e3120696e76616c696420696e646578617373657274696f6e206661696c65643a206f666673657420213d2030202626206f6666736574203c3d206c656e617373657274696f6e206661696c65643a206f666673657420213d2030202626206f6666736574203c3d206c656e202626206c656e203e3d20327061757365436f6e747261637470617573655f6d6f64756c653a706175736564756e7061757365436f6e74726163747374616b696e675f6d6f64756c653a736c617368416d6f756e747374616b696e675f6d6f64756c653a736c61736851756f72756d7374616b696e675f6d6f64756c653a7374616b6564416d6f756e747374616b696e675f6d6f64756c653a7374616b696e67546f6b656e7374616b696e675f6d6f64756c653a7573657257686974656c6973747374616b696e675f6d6f64756c653a746f74616c536c6173686564416d6f756e747374616b696e675f6d6f64756c653a72657175697265645374616b65416d6f756e747374616b696e675f6d6f64756c653a736c617368696e6750726f706f73616c566f746572736f7261636c655f737461747573706169725f646563696d616c736c6173745f7375626d697373696f6e5f74696d657374616d7066697273745f7375626d697373696f6e5f74696d657374616d70726f756e64736e65775f726f756e64646973636172645f726f756e646164645f7375626d697373696f6e646973636172645f7375626d697373696f6e63616c6c656420604f7074696f6e3a3a756e77726170282960206f6e206120604e6f6e65602076616c756566756e6769626c65204553445420746f6b656e206578706563746564456e64706f696e742063616e206f6e6c792062652063616c6c6564206279206f776e6572696e646578206f7574206f662072616e67654e6f7420656e6f756768207374616b6570616e6963206f636375727265640041808f080b0438ffffff", + "report": { + "imports": [ + "bigIntAdd", + "bigIntCmp", + "bigIntFinishUnsigned", + "bigIntGetCallValue", + "bigIntGetUnsignedArgument", + "bigIntSetInt64", + "bigIntSign", + "bigIntSub", + "bigIntTDiv", + "checkNoPayment", + "getBlockEpoch", + "getBlockNonce", + "getBlockTimestamp", + "getNumArguments", + "mBufferAppend", + "mBufferAppendBytes", + "mBufferCopyByteSlice", + "mBufferEq", + "mBufferFinish", + "mBufferFromBigIntUnsigned", + "mBufferGetArgument", + "mBufferGetByteSlice", + "mBufferGetLength", + "mBufferNew", + "mBufferSetBytes", + "mBufferStorageLoad", + "mBufferStorageStore", + "mBufferToBigIntUnsigned", + "managedCaller", + "managedGetMultiESDTCallValue", + "managedMultiTransferESDTNFTExecute", + "managedOwnerAddress", + "managedSignalError", + "managedTransferValueExecute", + "managedWriteLog", + "signalError", + "smallIntFinishSigned", + "smallIntFinishUnsigned", + "smallIntGetUnsignedArgument" + ], + "isMemGrow": false, + "eiCheck": { + "eiVersion": "1.3", + "ok": true + }, + "codeReport": { + "path": "../output/multiversx-price-aggregator-sc.wasm", + "size": 19638, + "hasAllocator": false, + "hasPanic": "without message" + } + } +} diff --git a/esdt-safe/interactor/src/fee_market_proxy.rs b/esdt-safe/interactor/src/fee_market_proxy.rs new file mode 100644 index 00000000..b595c0f6 --- /dev/null +++ b/esdt-safe/interactor/src/fee_market_proxy.rs @@ -0,0 +1,278 @@ +// 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 FeeMarketProxy; + +impl TxProxyTrait for FeeMarketProxy +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + type TxProxyMethods = FeeMarketProxyMethods; + + fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { + FeeMarketProxyMethods { wrapped_tx: tx } + } +} + +pub struct FeeMarketProxyMethods +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + wrapped_tx: Tx, +} + +#[rustfmt::skip] +impl FeeMarketProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + Gas: TxGas, +{ + pub fn init< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + Arg2: ProxyArg>>, + >( + self, + esdt_safe_address: Arg0, + price_aggregator_address: Arg1, + fee: Arg2, + ) -> TxTypedDeploy { + self.wrapped_tx + .payment(NotPayable) + .raw_deploy() + .argument(&esdt_safe_address) + .argument(&price_aggregator_address) + .argument(&fee) + .original_result() + } +} + +#[rustfmt::skip] +impl FeeMarketProxyMethods +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 FeeMarketProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn set_fee< + Arg0: ProxyArg>, + >( + self, + fee_struct: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("addFee") + .argument(&fee_struct) + .original_result() + } + + pub fn disable_fee< + Arg0: ProxyArg>, + >( + self, + base_token: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("removeFee") + .argument(&base_token) + .original_result() + } + + pub fn token_fee< + Arg0: ProxyArg>, + >( + self, + token_id: Arg0, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getTokenFee") + .argument(&token_id) + .original_result() + } + + 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() + } + + /// Percentages have to be between 0 and 10_000, and must all add up to 100% (i.e. 10_000) + pub fn distribute_fees< + Arg0: ProxyArg, usize>>>, + >( + self, + address_percentage_pairs: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("distributeFees") + .argument(&address_percentage_pairs) + .original_result() + } + + pub fn subtract_fee< + Arg0: ProxyArg>, + Arg1: ProxyArg, + Arg2: ProxyArg>, + >( + self, + original_caller: Arg0, + total_transfers: Arg1, + opt_gas_limit: Arg2, + ) -> TxTypedCall> { + self.wrapped_tx + .raw_call("subtractFee") + .argument(&original_caller) + .argument(&total_transfers) + .argument(&opt_gas_limit) + .original_result() + } + + pub fn users_whitelist( + self, + ) -> TxTypedCall>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getUsersWhitelist") + .original_result() + } + + pub fn set_min_valid_signers< + Arg0: ProxyArg, + >( + self, + new_value: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setMinValidSigners") + .argument(&new_value) + .original_result() + } + + pub fn add_signers< + Arg0: ProxyArg>>, + >( + self, + signers: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("addSigners") + .argument(&signers) + .original_result() + } + + pub fn remove_signers< + Arg0: ProxyArg>>, + >( + self, + signers: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("removeSigners") + .argument(&signers) + .original_result() + } +} + +#[type_abi] +#[derive(TopDecode, TopEncode, NestedEncode, NestedDecode, Clone)] +pub struct FeeStruct +where + Api: ManagedTypeApi, +{ + pub base_token: TokenIdentifier, + pub fee_type: FeeType, +} + +#[rustfmt::skip] +#[type_abi] +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, Clone)] +pub enum FeeType +where + Api: ManagedTypeApi, +{ + None, + Fixed { + token: TokenIdentifier, + per_transfer: BigUint, + per_gas: BigUint, + }, + AnyToken { + base_fee_token: TokenIdentifier, + per_transfer: BigUint, + per_gas: BigUint, + }, +} + +#[type_abi] +#[derive(TopEncode, TopDecode)] +pub struct FinalPayment +where + Api: ManagedTypeApi, +{ + pub fee: EsdtTokenPayment, + pub remaining_tokens: EsdtTokenPayment, +} diff --git a/esdt-safe/interactor/src/header_verifier_proxy.rs b/esdt-safe/interactor/src/header_verifier_proxy.rs new file mode 100644 index 00000000..4f57c709 --- /dev/null +++ b/esdt-safe/interactor/src/header_verifier_proxy.rs @@ -0,0 +1,174 @@ +// 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 HeaderverifierProxy; + +impl TxProxyTrait for HeaderverifierProxy +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + type TxProxyMethods = HeaderverifierProxyMethods; + + fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { + HeaderverifierProxyMethods { wrapped_tx: tx } + } +} + +pub struct HeaderverifierProxyMethods +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + wrapped_tx: Tx, +} + +#[rustfmt::skip] +impl HeaderverifierProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + Gas: TxGas, +{ + pub fn init< + Arg0: ProxyArg>>, + >( + self, + bls_pub_keys: Arg0, + ) -> TxTypedDeploy { + self.wrapped_tx + .payment(NotPayable) + .raw_deploy() + .argument(&bls_pub_keys) + .original_result() + } +} + +#[rustfmt::skip] +impl HeaderverifierProxyMethods +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 HeaderverifierProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn register_bridge_operations< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + Arg2: ProxyArg>>, + >( + self, + signature: Arg0, + bridge_operations_hash: Arg1, + operations_hashes: Arg2, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("registerBridgeOps") + .argument(&signature) + .argument(&bridge_operations_hash) + .argument(&operations_hashes) + .original_result() + } + + pub fn set_esdt_safe_address< + Arg0: ProxyArg>, + >( + self, + esdt_safe_address: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setEsdtSafeAddress") + .argument(&esdt_safe_address) + .original_result() + } + + pub fn remove_executed_hash< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + >( + self, + hash_of_hashes: Arg0, + operation_hash: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("removeExecutedHash") + .argument(&hash_of_hashes) + .argument(&operation_hash) + .original_result() + } + + pub fn set_min_valid_signers< + Arg0: ProxyArg, + >( + self, + new_value: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setMinValidSigners") + .argument(&new_value) + .original_result() + } + + pub fn add_signers< + Arg0: ProxyArg>>, + >( + self, + signers: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("addSigners") + .argument(&signers) + .original_result() + } + + pub fn remove_signers< + Arg0: ProxyArg>>, + >( + self, + signers: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("removeSigners") + .argument(&signers) + .original_result() + } +} diff --git a/esdt-safe/interactor/src/interactor_main.rs b/esdt-safe/interactor/src/interactor_main.rs new file mode 100644 index 00000000..536cb988 --- /dev/null +++ b/esdt-safe/interactor/src/interactor_main.rs @@ -0,0 +1,948 @@ +#![allow(non_snake_case)] +// TODO: Remove this when interactor setup is complete +#![allow(dead_code)] + +mod price_aggregator_proxy; +mod proxy; + +use fee_market::fee_market_proxy::FeeMarketProxy; +use fee_market::fee_market_proxy::{self, FeeStruct, FeeType}; +use multiversx_sc_scenario::multiversx_chain_vm::crypto_functions::sha256; +use multiversx_sc_snippets::imports::*; +use multiversx_sc_snippets::sdk; +use serde::{Deserialize, Serialize}; +use std::{ + io::{Read, Write}, + path::Path, +}; +use transaction::OperationEsdtPayment; +use transaction::{GasLimit, Operation, OperationData, PaymentsVec}; + +const GATEWAY: &str = sdk::gateway::DEVNET_GATEWAY; +const STATE_FILE: &str = "state.toml"; +const TOKEN_ID: &[u8] = b"SVT-805b28"; +const WHITELISTED_TOKEN_ID: &[u8] = b"CHOCOLATE-daf625"; + +type OptionalTransferData = + OptionalValue, ManagedVec>>>; + +#[tokio::main] +async fn main() { + env_logger::init(); + + let mut args = std::env::args(); + let _ = args.next(); + let cmd = args.next().expect("at least one argument required"); + let mut interact = ContractInteract::new().await; + match cmd.as_str() { + "deploy" => interact.deploy(false).await, + "upgrade" => interact.upgrade().await, + "setFeeMarketAddress" => interact.set_fee_market_address().await, + "setHeaderVerifierAddress" => interact.set_header_verifier_address().await, + "deposit" => interact.deposit(OptionalTransferData::None, None).await, + "setMinValidSigners" => interact.set_min_valid_signers().await, + "addSigners" => interact.add_signers().await, + "removeSigners" => interact.remove_signers().await, + "registerToken" => interact.register_token().await, + "executeBridgeOps" => interact.execute_operations().await, + "setMaxTxBatchSize" => interact.set_max_tx_batch_size().await, + "setMaxTxBatchBlockDuration" => interact.set_max_tx_batch_block_duration().await, + "getCurrentTxBatch" => interact.get_current_tx_batch().await, + "getFirstBatchAnyStatus" => interact.get_first_batch_any_status().await, + "getBatch" => interact.get_batch().await, + "getBatchStatus" => interact.get_batch_status().await, + "getFirstBatchId" => interact.first_batch_id().await, + "getLastBatchId" => interact.last_batch_id().await, + "setMaxBridgedAmount" => interact.set_max_bridged_amount().await, + "getMaxBridgedAmount" => interact.max_bridged_amount().await, + "endSetupPhase" => interact.end_setup_phase().await, + "addTokensToWhitelist" => interact.add_tokens_to_whitelist(b"").await, + "removeTokensFromWhitelist" => interact.remove_tokens_from_whitelist().await, + "addTokensToBlacklist" => interact.add_tokens_to_blacklist(b"").await, + "removeTokensFromBlacklist" => interact.remove_tokens_from_blacklist().await, + "getTokenWhitelist" => interact.token_whitelist().await, + "getTokenBlacklist" => interact.token_blacklist().await, + "pause" => interact.pause_endpoint().await, + "unpause" => interact.unpause_endpoint().await, + "isPaused" => interact.paused_status().await, + _ => panic!("unknown command: {}", &cmd), + } +} + +#[derive(Debug, Default, Serialize, Deserialize)] +struct State { + contract_address: Option, + fee_market_address: Option, + price_aggregator_address: Option, + header_verifier_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 contract address + pub fn set_address(&mut self, address: Bech32Address) { + self.contract_address = Some(address); + } + + pub fn set_fee_market_address(&mut self, address: Bech32Address) { + self.fee_market_address = Some(address); + } + + pub fn set_price_aggregator_address(&mut self, address: Bech32Address) { + self.price_aggregator_address = Some(address); + } + + pub fn set_header_verifier_address(&mut self, address: Bech32Address) { + self.header_verifier_address = Some(address); + } + + /// Returns the contract address + pub fn current_address(&self) -> &Bech32Address { + self.contract_address + .as_ref() + .expect("no known 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(); + } +} + +struct ContractInteract { + interactor: Interactor, + wallet_address: Address, + bob_address: Address, + alice_address: Address, + mike_address: Address, + judy_address: Address, + contract_code: BytesValue, + fee_market_code: BytesValue, + price_aggregator_code: BytesValue, + header_verifier_code: BytesValue, + state: State, +} + +impl ContractInteract { + async fn new() -> Self { + let mut interactor = Interactor::new(GATEWAY).await; + let wallet_address = interactor.register_wallet(test_wallets::frank()); + let bob_address = interactor.register_wallet(test_wallets::bob()); + let alice_address = interactor.register_wallet(test_wallets::alice()); + let mike_address = interactor.register_wallet(test_wallets::mike()); + let judy_address = interactor.register_wallet(test_wallets::judy()); + + let contract_code = BytesValue::interpret_from( + "mxsc:../output/esdt-safe.mxsc.json", + &InterpreterContext::default(), + ); + + let fee_market_code = BytesValue::interpret_from( + "mxsc:contract-codes/fee-market.mxsc.json", + &InterpreterContext::default(), + ); + + let price_aggregator_code = BytesValue::interpret_from( + "mxsc:contract-codes/multiversx-price-aggregator-sc.mxsc.json", + &InterpreterContext::default(), + ); + + let header_verifier_code = BytesValue::interpret_from( + "mxsc:contract-codes/header-verifier.mxsc.json", + &InterpreterContext::default(), + ); + + ContractInteract { + interactor, + wallet_address, + bob_address, + alice_address, + mike_address, + judy_address, + contract_code, + fee_market_code, + price_aggregator_code, + header_verifier_code, + state: State::load_state(), + } + } + + async fn deploy(&mut self, is_sov_chain: bool) { + let new_address = self + .interactor + .tx() + .from(&self.wallet_address) + .gas(110_000_000u64) + .typed(proxy::EsdtSafeProxy) + .init(is_sov_chain) + .code(&self.contract_code) + .returns(ReturnsNewAddress) + .prepare_async() + .run() + .await; + let new_address_bech32 = bech32::encode(&new_address); + self.state.set_address(Bech32Address::from_bech32_string( + new_address_bech32.clone(), + )); + + println!("new address: {new_address_bech32}"); + } + + async fn deploy_fee_market(&mut self) { + let fee = FeeStruct { + base_token: TokenIdentifier::from_esdt_bytes(TOKEN_ID), + fee_type: FeeType::Fixed { + token: TokenIdentifier::from_esdt_bytes(TOKEN_ID), + per_transfer: BigUint::from(10u64), + per_gas: BigUint::from(0u64), + }, + }; + + let new_address = self + .interactor + .tx() + .from(&self.wallet_address) + .gas(100_000_000u64) + .typed(fee_market_proxy::FeeMarketProxy) + .init(self.state.current_address(), Option::Some(fee)) + .code(&self.fee_market_code) + .returns(ReturnsNewAddress) + .prepare_async() + .run() + .await; + let new_address_bech32 = bech32::encode(&new_address); + self.state + .set_fee_market_address(Bech32Address::from_bech32_string( + new_address_bech32.clone(), + )); + println!("new fee_market_address: {new_address_bech32}"); + } + + async fn deploy_price_aggregator(&mut self) { + let mut oracles = MultiValueEncoded::new(); + let first_oracle_adress = managed_address!(&self.bob_address.clone()); + let second_oracle_adress = managed_address!(&self.alice_address.clone()); + let third_oracle_adress = managed_address!(&self.mike_address.clone()); + let forth_oracle_address = managed_address!(&self.judy_address.clone()); + oracles.push(first_oracle_adress); + oracles.push(second_oracle_adress); + oracles.push(third_oracle_adress); + oracles.push(forth_oracle_address); + + let new_address = self + .interactor + .tx() + .from(&self.wallet_address) + .gas(100_000_000u64) + .typed(price_aggregator_proxy::PriceAggregatorProxy) + .init( + TokenIdentifier::from_esdt_bytes(TOKEN_ID), + BigUint::from(1u64), + BigUint::from(1u64), + 3u8, + 3u8, + oracles, + ) + .code(&self.price_aggregator_code) + .returns(ReturnsNewAddress) + .prepare_async() + .run() + .await; + let new_address_bech32 = bech32::encode(&new_address); + self.state + .set_price_aggregator_address(Bech32Address::from_bech32_string( + new_address_bech32.clone(), + )); + println!("new token_handler_address: {new_address_bech32}"); + } + + async fn deploy_header_verifier_contract(&mut self) { + let new_address = self + .interactor + .tx() + .from(&self.wallet_address) + .gas(100_000_000u64) + .typed(proxy::EsdtSafeProxy) + .init(false) + .code(&self.header_verifier_code) + .returns(ReturnsNewAddress) + .prepare_async() + .run() + .await; + let new_address_bech32 = bech32::encode(&new_address); + self.state + .set_header_verifier_address(Bech32Address::from_bech32_string( + new_address_bech32.clone(), + )); + + println!("new header_verifier_address: {new_address_bech32}"); + } + + async fn upgrade(&mut self) { + let response = self + .interactor + .tx() + .to(self.state.current_address()) + .from(&self.wallet_address) + .gas(30_000_000u64) + .typed(proxy::EsdtSafeProxy) + .upgrade() + .code(&self.contract_code) + .code_metadata(CodeMetadata::UPGRADEABLE) + .returns(ReturnsNewAddress) + .prepare_async() + .run() + .await; + + println!("Result: {response:?}"); + } + + async fn set_fee_market_address(&mut self) { + let fee_market_address = self.state.fee_market_address.clone().unwrap(); + let response = self + .interactor + .tx() + .from(&self.wallet_address) + .to(self.state.current_address()) + .gas(30_000_000u64) + .typed(proxy::EsdtSafeProxy) + .set_fee_market_address(fee_market_address) + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + + println!("Result: {response:?}"); + } + + async fn set_header_verifier_address(&mut self) { + let header_verifier_address = self.state.header_verifier_address.clone().unwrap(); + + let response = self + .interactor + .tx() + .from(&self.wallet_address) + .to(self.state.current_address()) + .gas(30_000_000u64) + .typed(proxy::EsdtSafeProxy) + .set_header_verifier_address(header_verifier_address) + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + + println!("Result: {response:?}"); + } + + async fn deposit( + &mut self, + transfer_data: OptionalTransferData, + expect_error: Option>, + ) { + let token_id = TOKEN_ID; + let token_nonce = 0u64; + let token_amount = BigUint::::from(20u64); + + let to = &self.bob_address; + let mut payments = PaymentsVec::new(); + payments.push(EsdtTokenPayment::new( + TokenIdentifier::from(token_id), + token_nonce, + token_amount, + )); + + match expect_error { + Some(error) => { + self.interactor + .tx() + .from(&self.wallet_address) + .to(self.state.current_address()) + .gas(90_000_000u64) + .typed(proxy::EsdtSafeProxy) + .deposit(to, transfer_data) + .payment(payments) + .returns(error) + .prepare_async() + .run() + .await; + } + None => { + self.interactor + .tx() + .from(&self.wallet_address) + .to(self.state.current_address()) + .gas(90_000_000u64) + .typed(proxy::EsdtSafeProxy) + .deposit(to, transfer_data) + .payment(payments) + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + } + } + } + + async fn set_min_valid_signers(&mut self) { + let new_value = 0u32; + + let response = self + .interactor + .tx() + .from(&self.wallet_address) + .to(self.state.current_address()) + .gas(30_000_000u64) + .typed(proxy::EsdtSafeProxy) + .set_min_valid_signers(new_value) + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + + println!("Result: {response:?}"); + } + + async fn add_signers(&mut self) { + let signers = MultiValueVec::from(vec![bech32::decode("")]); + + let response = self + .interactor + .tx() + .from(&self.wallet_address) + .to(self.state.current_address()) + .gas(30_000_000u64) + .typed(proxy::EsdtSafeProxy) + .add_signers(signers) + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + + println!("Result: {response:?}"); + } + + async fn remove_signers(&mut self) { + let signers = MultiValueVec::from(vec![bech32::decode("")]); + + let response = self + .interactor + .tx() + .from(&self.wallet_address) + .to(self.state.current_address()) + .gas(30_000_000u64) + .typed(proxy::EsdtSafeProxy) + .remove_signers(signers) + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + + println!("Result: {response:?}"); + } + + async fn register_token(&mut self) { + let egld_amount = BigUint::::from(50_000_000_000_000_000u64); + + let sov_token_id = TokenIdentifier::from_esdt_bytes(&b"SOV"[..]); + let token_type = EsdtTokenType::Fungible; + let token_display_name = ManagedBuffer::new_from_bytes(&b"SOVEREIGN"[..]); + let token_ticker = ManagedBuffer::new_from_bytes(&b"SVCT"[..]); + let num_decimals = 18u32; + + let response = self + .interactor + .tx() + .from(&self.wallet_address) + .to(self.state.current_address()) + .gas(90_000_000u64) + .typed(proxy::EsdtSafeProxy) + .register_token( + sov_token_id, + token_type, + token_display_name, + token_ticker, + num_decimals, + ) + .egld(egld_amount) + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + + println!("Result: {response:?}"); + } + + async fn execute_operations(&mut self) { + let (tokens, data) = self.setup_payments().await; + let to = managed_address!(&self.bob_address); + let operation = Operation::new(to, tokens, data); + let operation_hash = self.get_operation_hash(&operation).await; + + let response = self + .interactor + .tx() + .from(&self.wallet_address) + .to(self.state.current_address()) + .gas(30_000_000u64) + .typed(proxy::EsdtSafeProxy) + .execute_operations(operation_hash, operation) + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + + println!("Result: {response:?}"); + } + + async fn execute_operations_with_error(&mut self, error_msg: ExpectError<'_>) { + let (tokens, data) = self.setup_payments().await; + let to = managed_address!(&self.bob_address); + let operation = Operation::new(to, tokens, data); + let operation_hash = self.get_operation_hash(&operation).await; + + let response = self + .interactor + .tx() + .from(&self.wallet_address) + .to(self.state.current_address()) + .gas(30_000_000u64) + .typed(proxy::EsdtSafeProxy) + .execute_operations(operation_hash, operation) + .returns(error_msg) + .prepare_async() + .run() + .await; + + println!("Result: {response:?}"); + } + + async fn set_max_tx_batch_size(&mut self) { + let new_max_tx_batch_size = 0u32; + + let response = self + .interactor + .tx() + .from(&self.wallet_address) + .to(self.state.current_address()) + .gas(30_000_000u64) + .typed(proxy::EsdtSafeProxy) + .set_max_tx_batch_size(new_max_tx_batch_size) + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + + println!("Result: {response:?}"); + } + + async fn set_max_tx_batch_block_duration(&mut self) { + let new_max_tx_batch_block_duration = 0u64; + + let response = self + .interactor + .tx() + .from(&self.wallet_address) + .to(self.state.current_address()) + .gas(30_000_000u64) + .typed(proxy::EsdtSafeProxy) + .set_max_tx_batch_block_duration(new_max_tx_batch_block_duration) + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + + println!("Result: {response:?}"); + } + + async fn get_current_tx_batch(&mut self) { + let _ = self + .interactor + .query() + .to(self.state.current_address()) + .typed(proxy::EsdtSafeProxy) + .get_current_tx_batch() + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + } + + async fn get_first_batch_any_status(&mut self) { + let _ = self + .interactor + .query() + .to(self.state.current_address()) + .typed(proxy::EsdtSafeProxy) + .get_first_batch_any_status() + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + } + + async fn get_batch(&mut self) { + let batch_id = 0u64; + + let _ = self + .interactor + .query() + .to(self.state.current_address()) + .typed(proxy::EsdtSafeProxy) + .get_batch(batch_id) + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + } + + async fn get_batch_status(&mut self) { + let batch_id = 0u64; + + self.interactor + .query() + .to(self.state.current_address()) + .typed(proxy::EsdtSafeProxy) + .get_batch_status(batch_id) + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + } + + async fn first_batch_id(&mut self) { + let result_value = self + .interactor + .query() + .to(self.state.current_address()) + .typed(proxy::EsdtSafeProxy) + .first_batch_id() + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + + println!("Result: {result_value:?}"); + } + + async fn last_batch_id(&mut self) { + let result_value = self + .interactor + .query() + .to(self.state.current_address()) + .typed(proxy::EsdtSafeProxy) + .last_batch_id() + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + + println!("Result: {result_value:?}"); + } + + async fn set_max_bridged_amount(&mut self) { + let token_id = TokenIdentifier::from_esdt_bytes(&b""[..]); + let max_amount = BigUint::::from(0u128); + + let response = self + .interactor + .tx() + .from(&self.wallet_address) + .to(self.state.current_address()) + .gas(30_000_000u64) + .typed(proxy::EsdtSafeProxy) + .set_max_bridged_amount(token_id, max_amount) + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + + println!("Result: {response:?}"); + } + + async fn max_bridged_amount(&mut self) { + let token_id = TokenIdentifier::from_esdt_bytes(&b""[..]); + + let result_value = self + .interactor + .query() + .to(self.state.current_address()) + .typed(proxy::EsdtSafeProxy) + .max_bridged_amount(token_id) + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + + println!("Result: {result_value:?}"); + } + + async fn end_setup_phase(&mut self) { + let response = self + .interactor + .tx() + .from(&self.wallet_address) + .to(self.state.current_address()) + .gas(30_000_000u64) + .typed(proxy::EsdtSafeProxy) + .end_setup_phase() + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + + println!("Result: {response:?}"); + } + + async fn add_tokens_to_whitelist(&mut self, token_id: &[u8]) { + let tokens = MultiValueVec::from(vec![TokenIdentifier::from_esdt_bytes(token_id)]); + + let response = self + .interactor + .tx() + .from(&self.wallet_address) + .to(self.state.current_address()) + .gas(30_000_000u64) + .typed(proxy::EsdtSafeProxy) + .add_tokens_to_whitelist(tokens) + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + + println!("Result: {response:?}"); + } + + async fn remove_tokens_from_whitelist(&mut self) { + let tokens = MultiValueVec::from(vec![TokenIdentifier::from_esdt_bytes(&b""[..])]); + + let response = self + .interactor + .tx() + .from(&self.wallet_address) + .to(self.state.current_address()) + .gas(30_000_000u64) + .typed(proxy::EsdtSafeProxy) + .remove_tokens_from_whitelist(tokens) + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + + println!("Result: {response:?}"); + } + + async fn add_tokens_to_blacklist(&mut self, token_id: &[u8]) { + let tokens = MultiValueVec::from(vec![TokenIdentifier::from_esdt_bytes(token_id)]); + + let response = self + .interactor + .tx() + .from(&self.wallet_address) + .to(self.state.current_address()) + .gas(30_000_000u64) + .typed(proxy::EsdtSafeProxy) + .add_tokens_to_blacklist(tokens) + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + + println!("Result: {response:?}"); + } + + async fn remove_tokens_from_blacklist(&mut self) { + let tokens = MultiValueVec::from(vec![TokenIdentifier::from_esdt_bytes(&b""[..])]); + + let response = self + .interactor + .tx() + .from(&self.wallet_address) + .to(self.state.current_address()) + .gas(30_000_000u64) + .typed(proxy::EsdtSafeProxy) + .remove_tokens_from_blacklist(tokens) + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + + println!("Result: {response:?}"); + } + + async fn token_whitelist(&mut self) { + let result_value = self + .interactor + .query() + .to(self.state.current_address()) + .typed(proxy::EsdtSafeProxy) + .token_whitelist() + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + + println!("Result: {result_value:?}"); + } + + async fn token_blacklist(&mut self) { + let result_value = self + .interactor + .query() + .to(self.state.current_address()) + .typed(proxy::EsdtSafeProxy) + .token_blacklist() + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + + println!("Result: {result_value:?}"); + } + + async fn pause_endpoint(&mut self) { + let response = self + .interactor + .tx() + .from(&self.wallet_address) + .to(self.state.current_address()) + .gas(30_000_000u64) + .typed(proxy::EsdtSafeProxy) + .pause_endpoint() + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + + println!("Result: {response:?}"); + } + + async fn unpause_endpoint(&mut self) { + let response = self + .interactor + .tx() + .from(&self.wallet_address) + .to(self.state.current_address()) + .gas(30_000_000u64) + .typed(proxy::EsdtSafeProxy) + .unpause_endpoint() + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + + println!("Result: {response:?}"); + } + + async fn paused_status(&mut self) { + let result_value = self + .interactor + .query() + .to(self.state.current_address()) + .typed(proxy::EsdtSafeProxy) + .paused_status() + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + + println!("Result: {result_value:?}"); + } + + async fn remove_fee(&mut self) { + let response = self + .interactor + .tx() + .from(&self.wallet_address) + .to(self.state.fee_market_address.clone().unwrap().as_address()) + .gas(30_000_000u64) + .typed(FeeMarketProxy) + .remove_fee(TOKEN_ID) + .returns(ReturnsResultUnmanaged) + .prepare_async() + .run() + .await; + + println!("Result: {response:?}"); + } + + async fn setup_payments( + &mut self, + ) -> ( + ManagedVec>, + OperationData, + ) { + let mut tokens: ManagedVec> = ManagedVec::new(); + let token_ids = vec![TOKEN_ID]; + + for token_id in token_ids { + let payment: OperationEsdtPayment = OperationEsdtPayment { + token_identifier: token_id.into(), + token_nonce: 1, + token_data: EsdtTokenData::default(), + }; + + tokens.push(payment); + } + + let op_sender = managed_address!(&self.wallet_address); + let data: OperationData = OperationData { + op_nonce: 1, + op_sender, + opt_transfer_data: Option::None, + }; + + (tokens, data) + } + + async fn get_operation_hash( + &mut self, + operation: &Operation, + ) -> ManagedBuffer { + let mut serialized_operation: ManagedBuffer = ManagedBuffer::new(); + let _ = operation.top_encode(&mut serialized_operation); + let sha256 = sha256(&serialized_operation.to_vec()); + + ManagedBuffer::new_from_bytes(&sha256) + } +} + +#[tokio::test] +#[ignore] +async fn test_deploy() { + let mut interact = ContractInteract::new().await; + interact.deploy(false).await; + interact.deploy_price_aggregator().await; + interact.deploy_fee_market().await; + interact.set_fee_market_address().await; + interact.remove_fee().await; + interact.unpause_endpoint().await; +} + +#[tokio::test] +#[ignore] +async fn test_deploy_sov() { + let mut interact = ContractInteract::new().await; + interact.deploy(true).await; + interact.deploy_price_aggregator().await; + interact.deploy_fee_market().await; + interact.set_fee_market_address().await; + interact.remove_fee().await; + interact.deploy_header_verifier_contract().await; + interact.set_header_verifier_address().await; + interact.unpause_endpoint().await; +} diff --git a/esdt-safe/interactor/src/price_aggregator_proxy.rs b/esdt-safe/interactor/src/price_aggregator_proxy.rs new file mode 100644 index 00000000..7a7e2aaa --- /dev/null +++ b/esdt-safe/interactor/src/price_aggregator_proxy.rs @@ -0,0 +1,416 @@ +// 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 PriceAggregatorProxy; + +impl TxProxyTrait for PriceAggregatorProxy +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + type TxProxyMethods = PriceAggregatorProxyMethods; + + fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { + PriceAggregatorProxyMethods { wrapped_tx: tx } + } +} + +pub struct PriceAggregatorProxyMethods +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + wrapped_tx: Tx, +} + +#[rustfmt::skip] +impl PriceAggregatorProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + Gas: TxGas, +{ + pub fn init< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + Arg2: ProxyArg>, + Arg3: ProxyArg, + Arg4: ProxyArg, + Arg5: ProxyArg>>, + >( + self, + staking_token: Arg0, + staking_amount: Arg1, + slash_amount: Arg2, + slash_quorum: Arg3, + submission_count: Arg4, + oracles: Arg5, + ) -> TxTypedDeploy { + self.wrapped_tx + .payment(NotPayable) + .raw_deploy() + .argument(&staking_token) + .argument(&staking_amount) + .argument(&slash_amount) + .argument(&slash_quorum) + .argument(&submission_count) + .argument(&oracles) + .original_result() + } +} + +#[rustfmt::skip] +impl PriceAggregatorProxyMethods +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 PriceAggregatorProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn change_amounts< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + >( + self, + staking_amount: Arg0, + slash_amount: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("changeAmounts") + .argument(&staking_amount) + .argument(&slash_amount) + .original_result() + } + + pub fn add_oracles< + Arg0: ProxyArg>>, + >( + self, + oracles: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("addOracles") + .argument(&oracles) + .original_result() + } + + /// Also receives submission count, + /// so the owner does not have to update it manually with setSubmissionCount before this call + pub fn remove_oracles< + Arg0: ProxyArg, + Arg1: ProxyArg>>, + >( + self, + submission_count: Arg0, + oracles: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("removeOracles") + .argument(&submission_count) + .argument(&oracles) + .original_result() + } + + pub fn submit< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + Arg2: ProxyArg, + Arg3: ProxyArg>, + Arg4: ProxyArg, + >( + self, + from: Arg0, + to: Arg1, + submission_timestamp: Arg2, + price: Arg3, + decimals: Arg4, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("submit") + .argument(&from) + .argument(&to) + .argument(&submission_timestamp) + .argument(&price) + .argument(&decimals) + .original_result() + } + + pub fn submit_batch< + Arg0: ProxyArg, ManagedBuffer, u64, BigUint, u8>>>, + >( + self, + submissions: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("submitBatch") + .argument(&submissions) + .original_result() + } + + pub fn latest_round_data( + self, + ) -> TxTypedCall>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("latestRoundData") + .original_result() + } + + pub fn latest_price_feed< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + >( + self, + from: Arg0, + to: Arg1, + ) -> TxTypedCall, ManagedBuffer, u64, BigUint, u8>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("latestPriceFeed") + .argument(&from) + .argument(&to) + .original_result() + } + + pub fn latest_price_feed_optional< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + >( + self, + from: Arg0, + to: Arg1, + ) -> TxTypedCall, ManagedBuffer, u64, BigUint, u8>>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("latestPriceFeedOptional") + .argument(&from) + .argument(&to) + .original_result() + } + + pub fn set_submission_count< + Arg0: ProxyArg, + >( + self, + submission_count: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setSubmissionCount") + .argument(&submission_count) + .original_result() + } + + pub fn get_oracles( + self, + ) -> TxTypedCall>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getOracles") + .original_result() + } + + pub fn set_pair_decimals< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + Arg2: ProxyArg, + >( + self, + from: Arg0, + to: Arg1, + decimals: Arg2, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setPairDecimals") + .argument(&from) + .argument(&to) + .argument(&decimals) + .original_result() + } + + pub fn get_pair_decimals< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + >( + self, + from: Arg0, + to: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getPairDecimals") + .argument(&from) + .argument(&to) + .original_result() + } + + pub fn submission_count( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("submission_count") + .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() + } + + pub fn stake( + self, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("stake") + .original_result() + } + + pub fn unstake< + Arg0: ProxyArg>, + >( + self, + unstake_amount: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("unstake") + .argument(&unstake_amount) + .original_result() + } + + pub fn vote_slash_member< + Arg0: ProxyArg>, + >( + self, + member_to_slash: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("voteSlashMember") + .argument(&member_to_slash) + .original_result() + } + + pub fn cancel_vote_slash_member< + Arg0: ProxyArg>, + >( + self, + member_to_slash: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("cancelVoteSlashMember") + .argument(&member_to_slash) + .original_result() + } + + pub fn slash_member< + Arg0: ProxyArg>, + >( + self, + member_to_slash: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("slashMember") + .argument(&member_to_slash) + .original_result() + } +} + +#[type_abi] +#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode)] +pub struct PriceFeed +where + Api: ManagedTypeApi, +{ + pub round_id: u32, + pub from: ManagedBuffer, + pub to: ManagedBuffer, + pub timestamp: u64, + pub price: BigUint, + pub decimals: u8, +} + +#[type_abi] +#[derive(TopEncode)] +pub struct NewRoundEvent +where + Api: ManagedTypeApi, +{ + pub price: BigUint, + pub timestamp: u64, + pub decimals: u8, + pub block: u64, + pub epoch: u64, +} + +#[type_abi] +#[derive(TopEncode)] +pub struct DiscardSubmissionEvent { + pub submission_timestamp: u64, + pub first_submission_timestamp: u64, + pub has_caller_already_submitted: bool, +} diff --git a/esdt-safe/interactor/src/proxy.rs b/esdt-safe/interactor/src/proxy.rs new file mode 100644 index 00000000..81e2e31d --- /dev/null +++ b/esdt-safe/interactor/src/proxy.rs @@ -0,0 +1,458 @@ +// 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 EsdtSafeProxy; + +impl TxProxyTrait for EsdtSafeProxy +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + type TxProxyMethods = EsdtSafeProxyMethods; + + fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { + EsdtSafeProxyMethods { wrapped_tx: tx } + } +} + +pub struct EsdtSafeProxyMethods +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + wrapped_tx: Tx, +} + +#[rustfmt::skip] +impl EsdtSafeProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + Gas: TxGas, +{ + pub fn init< + Arg0: ProxyArg, + >( + self, + is_sovereign_chain: Arg0, + ) -> TxTypedDeploy { + self.wrapped_tx + .payment(NotPayable) + .raw_deploy() + .argument(&is_sovereign_chain) + .original_result() + } +} + +#[rustfmt::skip] +impl EsdtSafeProxyMethods +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 EsdtSafeProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn set_fee_market_address< + Arg0: ProxyArg>, + >( + self, + fee_market_address: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setFeeMarketAddress") + .argument(&fee_market_address) + .original_result() + } + + pub fn set_header_verifier_address< + Arg0: ProxyArg>, + >( + self, + header_verifier_address: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setHeaderVerifierAddress") + .argument(&header_verifier_address) + .original_result() + } + + pub fn set_max_user_tx_gas_limit< + Arg0: ProxyArg, + >( + self, + max_user_tx_gas_limit: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setMaxTxGasLimit") + .argument(&max_user_tx_gas_limit) + .original_result() + } + + pub fn set_banned_endpoint< + Arg0: ProxyArg>, + >( + self, + endpoint_name: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setBannedEndpoint") + .argument(&endpoint_name) + .original_result() + } + + pub fn deposit< + Arg0: ProxyArg>, + Arg1: ProxyArg, ManagedVec>>>>, + >( + self, + to: Arg0, + optional_transfer_data: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("deposit") + .argument(&to) + .argument(&optional_transfer_data) + .original_result() + } + + pub fn set_min_valid_signers< + Arg0: ProxyArg, + >( + self, + new_value: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setMinValidSigners") + .argument(&new_value) + .original_result() + } + + pub fn add_signers< + Arg0: ProxyArg>>, + >( + self, + signers: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("addSigners") + .argument(&signers) + .original_result() + } + + pub fn remove_signers< + Arg0: ProxyArg>>, + >( + self, + signers: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("removeSigners") + .argument(&signers) + .original_result() + } + + pub fn register_token< + Arg0: ProxyArg>, + Arg1: ProxyArg, + Arg2: ProxyArg>, + Arg3: ProxyArg>, + Arg4: ProxyArg, + >( + self, + sov_token_id: Arg0, + token_type: Arg1, + token_display_name: Arg2, + token_ticker: Arg3, + num_decimals: Arg4, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("registerToken") + .argument(&sov_token_id) + .argument(&token_type) + .argument(&token_display_name) + .argument(&token_ticker) + .argument(&num_decimals) + .original_result() + } + + pub fn execute_operations< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + >( + self, + hash_of_hashes: Arg0, + operation: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("executeBridgeOps") + .argument(&hash_of_hashes) + .argument(&operation) + .original_result() + } + + pub fn set_max_tx_batch_size< + Arg0: ProxyArg, + >( + self, + new_max_tx_batch_size: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setMaxTxBatchSize") + .argument(&new_max_tx_batch_size) + .original_result() + } + + pub fn set_max_tx_batch_block_duration< + Arg0: ProxyArg, + >( + self, + new_max_tx_batch_block_duration: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setMaxTxBatchBlockDuration") + .argument(&new_max_tx_batch_block_duration) + .original_result() + } + + pub fn get_current_tx_batch( + self, + ) -> TxTypedCall, ManagedAddress, ManagedVec>, ManagedVec>, Option>>>>>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getCurrentTxBatch") + .original_result() + } + + pub fn get_first_batch_any_status( + self, + ) -> TxTypedCall, ManagedAddress, ManagedVec>, ManagedVec>, Option>>>>>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getFirstBatchAnyStatus") + .original_result() + } + + pub fn get_batch< + Arg0: ProxyArg, + >( + self, + batch_id: Arg0, + ) -> TxTypedCall, ManagedAddress, ManagedVec>, ManagedVec>, Option>>>>>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getBatch") + .argument(&batch_id) + .original_result() + } + + pub fn get_batch_status< + Arg0: ProxyArg, + >( + self, + batch_id: Arg0, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getBatchStatus") + .argument(&batch_id) + .original_result() + } + + pub fn first_batch_id( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getFirstBatchId") + .original_result() + } + + pub fn last_batch_id( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getLastBatchId") + .original_result() + } + + pub fn set_max_bridged_amount< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + >( + self, + token_id: Arg0, + max_amount: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setMaxBridgedAmount") + .argument(&token_id) + .argument(&max_amount) + .original_result() + } + + pub fn max_bridged_amount< + Arg0: ProxyArg>, + >( + self, + token_id: Arg0, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getMaxBridgedAmount") + .argument(&token_id) + .original_result() + } + + pub fn end_setup_phase( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("endSetupPhase") + .original_result() + } + + /// Tokens in the whitelist can be transferred without fees + pub fn add_tokens_to_whitelist< + Arg0: ProxyArg>>, + >( + self, + tokens: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("addTokensToWhitelist") + .argument(&tokens) + .original_result() + } + + pub fn remove_tokens_from_whitelist< + Arg0: ProxyArg>>, + >( + self, + tokens: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("removeTokensFromWhitelist") + .argument(&tokens) + .original_result() + } + + /// Tokens in blacklist cannot be transferred + pub fn add_tokens_to_blacklist< + Arg0: ProxyArg>>, + >( + self, + tokens: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("addTokensToBlacklist") + .argument(&tokens) + .original_result() + } + + pub fn remove_tokens_from_blacklist< + Arg0: ProxyArg>>, + >( + self, + tokens: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("removeTokensFromBlacklist") + .argument(&tokens) + .original_result() + } + + pub fn token_whitelist( + self, + ) -> TxTypedCall>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getTokenWhitelist") + .original_result() + } + + pub fn token_blacklist( + self, + ) -> TxTypedCall>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getTokenBlacklist") + .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/esdt-safe/interactor/state.toml b/esdt-safe/interactor/state.toml new file mode 100644 index 00000000..76c22a65 --- /dev/null +++ b/esdt-safe/interactor/state.toml @@ -0,0 +1,4 @@ +contract_address = "erd1qqqqqqqqqqqqqpgqyczw89pfr8aj54j4crvr7z700duqge4xt7asyhkfsm" +fee_market_address = "erd1qqqqqqqqqqqqqpgq0r6lzfdz4uhqar7kmspxhg0kr8ezmw64t7aswthejh" +price_aggregator_address = "erd1qqqqqqqqqqqqqpgqxutn5wwtjesh73fl3pz0ua9p9tqsys8vt7as36y3vf" +header_verifier_address = "erd1qqqqqqqqqqqqqpgqzt6lf09qhz8fdq4k67mz3e8h8yjmmlcvt7asftyk47" diff --git a/esdt-safe/tests/bridge_blackbox_tests.rs b/esdt-safe/tests/bridge_blackbox_tests.rs new file mode 100644 index 00000000..a2313502 --- /dev/null +++ b/esdt-safe/tests/bridge_blackbox_tests.rs @@ -0,0 +1,432 @@ +use bls_signature::BlsSignature; +use esdt_safe::esdt_safe_proxy::{self}; +use fee_market::fee_market_proxy::{self, FeeStruct, FeeType}; +use header_verifier::header_verifier_proxy; +use multiversx_sc::codec::TopEncode; +use multiversx_sc::types::{ + Address, EsdtTokenData, ManagedByteArray, MultiValueEncoded, TestTokenIdentifier, + TokenIdentifier, +}; +use multiversx_sc::{ + imports::{MultiValue3, OptionalValue}, + types::{ + BigUint, EsdtTokenPayment, ManagedBuffer, ManagedVec, ReturnsResult, TestAddress, + TestSCAddress, + }, +}; +use multiversx_sc_scenario::managed_address; +use multiversx_sc_scenario::multiversx_chain_vm::crypto_functions::sha256; +use multiversx_sc_scenario::{ + api::StaticApi, imports::MxscPath, ExpectError, ScenarioTxRun, ScenarioWorld, +}; +use transaction::{Operation, OperationData, OperationEsdtPayment}; + +const BRIDGE_ADDRESS: TestSCAddress = TestSCAddress::new("bridge"); +const BRIDGE_CODE_PATH: MxscPath = MxscPath::new("output/esdt-safe.mxsc.json"); +const BRIDGE_OWNER_ADDRESS: TestAddress = TestAddress::new("bridge_owner"); + +const FEE_MARKET_ADDRESS: TestSCAddress = TestSCAddress::new("fee_market"); +const FEE_MARKET_CODE_PATH: MxscPath = MxscPath::new("../fee-market/output/fee-market.mxsc.json"); + +const HEADER_VERIFIER_ADDRESS: TestSCAddress = TestSCAddress::new("header_verifier"); +const HEADER_VERIFIER_CODE_PATH: MxscPath = + MxscPath::new("../header-verifier/output/header-verifier.mxsc.json"); + +const USER_ADDRESS: TestAddress = TestAddress::new("user"); +const RECEIVER_ADDRESS: TestAddress = TestAddress::new("receiver"); + +const BRIDGE_OWNER_BALANCE: u64 = 100_000_000; +const USER_EGLD_BALANCE: u64 = 100_000_000; + +const NFT_TOKEN_ID: TestTokenIdentifier = TestTokenIdentifier::new("NFT-123456"); +const FUNGIBLE_TOKEN_ID: TestTokenIdentifier = TestTokenIdentifier::new("CROWD-123456"); + +fn world() -> ScenarioWorld { + let mut blockchain = ScenarioWorld::new(); + + blockchain.register_contract(BRIDGE_CODE_PATH, esdt_safe::ContractBuilder); + blockchain.register_contract(FEE_MARKET_CODE_PATH, fee_market::ContractBuilder); + blockchain.register_contract(HEADER_VERIFIER_CODE_PATH, header_verifier::ContractBuilder); + + blockchain +} + +struct BridgeTestState { + world: ScenarioWorld, +} + +impl BridgeTestState { + fn new() -> Self { + let mut world = world(); + + world + .account(BRIDGE_OWNER_ADDRESS) + .esdt_nft_balance(NFT_TOKEN_ID, 1, 100_000, ManagedBuffer::new()) + .esdt_balance(FUNGIBLE_TOKEN_ID, 100_000) + .nonce(1) + .balance(BRIDGE_OWNER_BALANCE); + + world + .account(USER_ADDRESS) + .esdt_nft_balance(NFT_TOKEN_ID, 1, 100_000, ManagedBuffer::new()) + .esdt_balance(FUNGIBLE_TOKEN_ID, 100_000) + .balance(USER_EGLD_BALANCE) + .nonce(1); + + world.account(RECEIVER_ADDRESS).nonce(1); + + Self { world } + } + + fn deploy_bridge_contract(&mut self, is_sovereign_chain: bool) -> &mut Self { + self.world + .tx() + .from(BRIDGE_OWNER_ADDRESS) + .typed(esdt_safe_proxy::EsdtSafeProxy) + .init(is_sovereign_chain) + .code(BRIDGE_CODE_PATH) + .new_address(BRIDGE_ADDRESS) + .run(); + + self.deploy_fee_market_contract(); + self.propose_set_fee_market_address(); + self.propose_set_unpaused(); + + self + } + + fn deploy_fee_market_contract(&mut self) -> &mut Self { + let fee_struct: Option> = None; + + self.world + .tx() + .from(BRIDGE_OWNER_ADDRESS) + .typed(fee_market_proxy::FeeMarketProxy) + .init(BRIDGE_ADDRESS, fee_struct) + .code(FEE_MARKET_CODE_PATH) + .new_address(FEE_MARKET_ADDRESS) + .run(); + + self + } + + fn deploy_header_verifier_contract(&mut self) -> &mut Self { + let bls_pub_key: ManagedBuffer = ManagedBuffer::new(); + let mut bls_pub_keys = MultiValueEncoded::new(); + bls_pub_keys.push(bls_pub_key); + + self.world + .tx() + .from(BRIDGE_OWNER_ADDRESS) + .typed(header_verifier_proxy::HeaderverifierProxy) + .init(bls_pub_keys) + .code(HEADER_VERIFIER_CODE_PATH) + .new_address(HEADER_VERIFIER_ADDRESS) + .run(); + + self + } + + fn propose_set_fee_market_address(&mut self) { + self.world + .tx() + .from(BRIDGE_OWNER_ADDRESS) + .to(BRIDGE_ADDRESS) + .typed(esdt_safe_proxy::EsdtSafeProxy) + .set_fee_market_address(FEE_MARKET_ADDRESS) + .run(); + } + + fn propose_set_header_verifier_address(&mut self) { + self.world + .tx() + .from(BRIDGE_OWNER_ADDRESS) + .to(BRIDGE_ADDRESS) + .typed(esdt_safe_proxy::EsdtSafeProxy) + .set_header_verifier_address(HEADER_VERIFIER_ADDRESS) + .run(); + } + + fn propose_egld_deposit_and_expect_err(&mut self, err_message: &str) { + let transfer_data = OptionalValue::< + MultiValue3< + u64, + ManagedBuffer, + ManagedVec>, + >, + >::None; + + self.world + .tx() + .from(USER_ADDRESS) + .to(BRIDGE_ADDRESS) + .typed(esdt_safe_proxy::EsdtSafeProxy) + .deposit(RECEIVER_ADDRESS, transfer_data) + .egld(10) + .with_result(ExpectError(4, err_message)) + .run(); + } + + fn _propose_set_fee_token(&mut self, token_identifier: TestTokenIdentifier) { + let fee_type = FeeType::AnyToken { + base_fee_token: token_identifier.into(), + per_transfer: BigUint::from(10u64), + per_gas: BigUint::from(10u64), + }; + let fee_token_identifier: TokenIdentifier = + TokenIdentifier::from(token_identifier); + + let fee_struct = FeeStruct { + base_token: fee_token_identifier, + fee_type, + }; + + self.world + .tx() + .from(BRIDGE_OWNER_ADDRESS) + .to(FEE_MARKET_ADDRESS) + .typed(fee_market_proxy::FeeMarketProxy) + .set_fee(fee_struct) + .run(); + } + + fn _propose_esdt_deposit_and_expect_err(&mut self, err_message: &str) { + let transfer_data = OptionalValue::< + MultiValue3< + u64, + ManagedBuffer, + ManagedVec>, + >, + >::None; + + let mut payments = ManagedVec::new(); + let nft_payment = EsdtTokenPayment::new(NFT_TOKEN_ID.into(), 1, BigUint::from(10u64)); + let fungible_payment: EsdtTokenPayment = + EsdtTokenPayment::new(FUNGIBLE_TOKEN_ID.into(), 0, BigUint::from(10u64)); + + payments.push(nft_payment); + payments.push(fungible_payment); + + self.world + .tx() + .from(USER_ADDRESS) + .to(BRIDGE_ADDRESS) + .typed(esdt_safe_proxy::EsdtSafeProxy) + .deposit(RECEIVER_ADDRESS, transfer_data) + .payment(payments) + .returns(ExpectError(4, err_message)) + .run(); + } + + fn propose_esdt_deposit(&mut self) { + let transfer_data = OptionalValue::< + MultiValue3< + u64, + ManagedBuffer, + ManagedVec>, + >, + >::None; + + let mut payments = ManagedVec::new(); + let nft_payment = EsdtTokenPayment::new(NFT_TOKEN_ID.into(), 1, BigUint::from(10u64)); + let fungible_payment: EsdtTokenPayment = + EsdtTokenPayment::new(FUNGIBLE_TOKEN_ID.into(), 0, BigUint::from(10u64)); + + payments.push(fungible_payment); + payments.push(nft_payment); + + self.world + .tx() + .from(USER_ADDRESS) + .to(BRIDGE_ADDRESS) + .typed(esdt_safe_proxy::EsdtSafeProxy) + .deposit(RECEIVER_ADDRESS, transfer_data) + .payment(payments) + .run(); + } + + fn propose_execute_operation_and_expect_err(&mut self, err_message: &str) { + let (tokens, data) = self.setup_payments(vec![NFT_TOKEN_ID, FUNGIBLE_TOKEN_ID]); + let to = managed_address!(&Address::from(&RECEIVER_ADDRESS.eval_to_array())); + let operation = Operation { to, tokens, data }; + let operation_hash = self.get_operation_hash(&operation); + + self.world + .tx() + .from(USER_ADDRESS) + .to(BRIDGE_ADDRESS) + .typed(esdt_safe_proxy::EsdtSafeProxy) + .execute_operations(operation_hash, operation) + .returns(ExpectError(4, err_message)) + .run(); + } + + fn propose_execute_operation(&mut self) { + let (tokens, data) = self.setup_payments(vec![NFT_TOKEN_ID, FUNGIBLE_TOKEN_ID]); + let to = managed_address!(&Address::from(&RECEIVER_ADDRESS.eval_to_array())); + let operation = Operation { to, tokens, data }; + let operation_hash = self.get_operation_hash(&operation); + let hash_of_hashes: ManagedBuffer = + ManagedBuffer::from(&sha256(&operation_hash.to_vec())); + + self.world + .tx() + .from(USER_ADDRESS) + .to(BRIDGE_ADDRESS) + .typed(esdt_safe_proxy::EsdtSafeProxy) + .execute_operations(hash_of_hashes, operation) + .run(); + } + + fn propose_set_unpaused(&mut self) { + self.world + .tx() + .from(BRIDGE_OWNER_ADDRESS) + .to(BRIDGE_ADDRESS) + .typed(esdt_safe_proxy::EsdtSafeProxy) + .unpause_endpoint() + .returns(ReturnsResult) + .run(); + } + + fn propose_register_operation(&mut self) { + let (tokens, data) = self.setup_payments(vec![NFT_TOKEN_ID, FUNGIBLE_TOKEN_ID]); + let to = managed_address!(&Address::from(RECEIVER_ADDRESS.eval_to_array())); + let operation = Operation { to, tokens, data }; + let operation_hash = self.get_operation_hash(&operation); + let mut operations_hashes = MultiValueEncoded::new(); + + operations_hashes.push(operation_hash.clone()); + + let mock_signature = self.mock_bls_signature(&operation_hash); + let hash_of_hashes = ManagedBuffer::new_from_bytes(&sha256(&operation_hash.to_vec())); + + self.world + .tx() + .from(BRIDGE_OWNER_ADDRESS) + .to(HEADER_VERIFIER_ADDRESS) + .typed(header_verifier_proxy::HeaderverifierProxy) + .register_bridge_operations( + mock_signature, + hash_of_hashes.clone(), + operations_hashes.clone(), + ) + .run(); + } + + fn setup_payments( + &mut self, + token_ids: Vec, + ) -> ( + ManagedVec>, + OperationData, + ) { + let mut tokens: ManagedVec> = ManagedVec::new(); + + for token_id in token_ids { + let payment: OperationEsdtPayment = OperationEsdtPayment { + token_identifier: token_id.into(), + token_nonce: 1, + token_data: EsdtTokenData::default(), + }; + + tokens.push(payment); + } + + let op_sender = managed_address!(&Address::from(&USER_ADDRESS.eval_to_array())); + let data: OperationData = OperationData { + op_nonce: 1, + op_sender, + opt_transfer_data: Option::None, + }; + + (tokens, data) + } + + fn get_operation_hash(&mut self, operation: &Operation) -> ManagedBuffer { + let mut serialized_operation: ManagedBuffer = ManagedBuffer::new(); + let _ = operation.top_encode(&mut serialized_operation); + let sha256 = sha256(&serialized_operation.to_vec()); + + ManagedBuffer::new_from_bytes(&sha256) + } + + fn mock_bls_signature( + &mut self, + operation_hash: &ManagedBuffer, + ) -> BlsSignature { + let byte_arr: &mut [u8; 48] = &mut [0; 48]; + operation_hash.load_to_byte_array(byte_arr); + let mock_signature: BlsSignature = ManagedByteArray::new_from_bytes(byte_arr); + + mock_signature + } +} + +#[test] +fn test_deploy() { + let mut state = BridgeTestState::new(); + + state.deploy_bridge_contract(false); +} + +#[test] +fn test_main_to_sov_egld_deposit_nothing_to_transfer() { + let mut state = BridgeTestState::new(); + let err_message = "Nothing to transfer"; + + state.deploy_bridge_contract(false); + + state.propose_egld_deposit_and_expect_err(err_message); +} + +#[test] +fn test_main_to_sov_deposit_ok() { + let mut state = BridgeTestState::new(); + + state.deploy_bridge_contract(false); + + state.propose_esdt_deposit(); +} + +#[test] +fn test_execute_operation_not_registered() { + let mut state = BridgeTestState::new(); + let err_message = "Operation is not registered"; + + state.deploy_bridge_contract(false); + + state.deploy_header_verifier_contract(); + + state.propose_set_header_verifier_address(); + + state.propose_execute_operation_and_expect_err(err_message); +} + +#[test] +fn test_register_operation() { + let mut state = BridgeTestState::new(); + + state.deploy_bridge_contract(false); + + state.deploy_header_verifier_contract(); + + state.propose_set_header_verifier_address(); + + state.propose_register_operation(); +} + +#[test] +fn test_execute_operation() { + let mut state = BridgeTestState::new(); + + state.deploy_bridge_contract(false); + + state.deploy_header_verifier_contract(); + + state.propose_set_header_verifier_address(); + + state.propose_register_operation(); + + state.propose_execute_operation(); +} From 6178aa7dc97ecedb2018a16f4a48622a84c9d1d9 Mon Sep 17 00:00:00 2001 From: Andrei Baltariu Date: Mon, 28 Oct 2024 15:26:06 +0200 Subject: [PATCH 05/15] common copy-paste Signed-off-by: Andrei Baltariu --- common/token-whitelist/src/lib.rs | 29 ++--- common/transaction/src/lib.rs | 209 ++++++++++++++++++++---------- common/utils/src/lib.rs | 54 +++++--- 3 files changed, 187 insertions(+), 105 deletions(-) diff --git a/common/token-whitelist/src/lib.rs b/common/token-whitelist/src/lib.rs index 75af79a9..56524102 100644 --- a/common/token-whitelist/src/lib.rs +++ b/common/token-whitelist/src/lib.rs @@ -1,7 +1,5 @@ #![no_std] -use bls_signature::BlsSignature; - multiversx_sc::imports!(); #[multiversx_sc::module] @@ -12,7 +10,7 @@ pub trait TokenWhitelistModule: #[endpoint(addTokensToWhitelist)] fn add_tokens_to_whitelist( &self, - opt_signature: Option>, + // opt_signature: Option>, tokens: MultiValueEncoded, ) { if !self.is_setup_phase_complete() { @@ -22,14 +20,14 @@ pub trait TokenWhitelistModule: return; } - let token_list = self.verify_items_signature(opt_signature, tokens); - self.token_whitelist().extend(&token_list); + // let token_list = self.verify_items_signature(opt_signature, tokens); + self.token_whitelist().extend(tokens); } #[endpoint(removeTokensFromWhitelist)] fn remove_tokens_from_whitelist( &self, - opt_signature: Option>, + // opt_signature: Option>, tokens: MultiValueEncoded, ) { if !self.is_setup_phase_complete() { @@ -39,8 +37,8 @@ pub trait TokenWhitelistModule: return; } - let token_list = self.verify_items_signature(opt_signature, tokens); - self.remove_items(&mut self.token_whitelist(), &token_list); + // let token_list = self.verify_items_signature(opt_signature, tokens); + self.remove_items(&mut self.token_whitelist(), tokens); } fn require_token_not_blacklisted(&self, token_id: &TokenIdentifier) { @@ -54,7 +52,7 @@ pub trait TokenWhitelistModule: #[endpoint(addTokensToBlacklist)] fn add_tokens_to_blacklist( &self, - opt_signature: Option>, + // opt_signature: Option>, tokens: MultiValueEncoded, ) { if !self.is_setup_phase_complete() { @@ -64,16 +62,12 @@ pub trait TokenWhitelistModule: return; } - let token_list = self.verify_items_signature(opt_signature, tokens); - self.token_blacklist().extend(&token_list); + // let token_list = self.verify_items_signature(opt_signature, tokens); + self.token_blacklist().extend(tokens); } #[endpoint(removeTokensFromBlacklist)] - fn remove_tokens_from_blacklist( - &self, - opt_signature: Option>, - tokens: MultiValueEncoded, - ) { + fn remove_tokens_from_blacklist(&self, tokens: MultiValueEncoded) { if !self.is_setup_phase_complete() { self.require_caller_initiator(); self.remove_items(&mut self.token_blacklist(), tokens); @@ -81,8 +75,7 @@ pub trait TokenWhitelistModule: return; } - let token_list = self.verify_items_signature(opt_signature, tokens); - self.remove_items(&mut self.token_blacklist(), &token_list); + self.remove_items(&mut self.token_blacklist(), tokens); } #[view(getTokenWhitelist)] diff --git a/common/transaction/src/lib.rs b/common/transaction/src/lib.rs index 550155a4..93d5ceba 100644 --- a/common/transaction/src/lib.rs +++ b/common/transaction/src/lib.rs @@ -22,11 +22,16 @@ pub type TxAsMultiValue = MultiValue7< SenderAddress, ReceiverAddress, ManagedVec>, - ManagedVec>, + ManagedVec>, Option>, >; pub type PaymentsVec = ManagedVec>; +pub type EventPaymentTuple = MultiValue3, u64, EsdtTokenData>; pub type TxBatchSplitInFields = MultiValue2>>; +pub type ExtractedFeeResult = + MultiValue2>, ManagedVec>>; +pub type OptionalValueTransferDataTuple = + OptionalValue, ManagedVec>>>; #[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, ManagedVecItem, Clone)] pub struct Operation { @@ -36,20 +41,25 @@ pub struct Operation { } impl Operation { - pub fn get_tokens_as_tuple_arr( + #[inline] + pub fn new( + to: ManagedAddress, + tokens: ManagedVec>, + data: OperationData, + ) -> Self { + Operation { to, tokens, data } + } + + pub fn map_tokens_to_multi_value_encoded( &self, ) -> MultiValueEncoded, u64, EsdtTokenData>> { - let mut tuple_arr = MultiValueEncoded::new(); + let mut tuples = MultiValueEncoded::new(); for token in &self.tokens { - tuple_arr.push(MultiValue3::from(( - token.token_identifier, - token.token_nonce, - token.token_data.into(), - ))); + tuples.push((token.token_identifier, token.token_nonce, token.token_data).into()); } - tuple_arr + tuples } } @@ -60,6 +70,32 @@ pub struct TransferData { pub args: ManagedVec>, } +impl TransferData { + #[inline] + pub fn new( + gas_limit: GasLimit, + function: ManagedBuffer, + args: ManagedVec>, + ) -> Self { + TransferData { + gas_limit, + function, + args, + } + } + + pub fn from_optional_value( + opt_value_transfer_data: OptionalValueTransferDataTuple, + ) -> Option { + match opt_value_transfer_data { + OptionalValue::Some(multi_value_transfer_data) => { + Option::Some(multi_value_transfer_data.into()) + } + OptionalValue::None => Option::None, + } + } +} + #[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, ManagedVecItem, Clone)] pub struct OperationData { pub op_nonce: TxId, @@ -67,20 +103,107 @@ pub struct OperationData { pub opt_transfer_data: Option>, } +impl OperationData { + #[inline] + pub fn new( + op_nonce: TxId, + op_sender: ManagedAddress, + opt_transfer_data: Option>, + ) -> Self { + OperationData { + op_nonce, + op_sender, + opt_transfer_data, + } + } +} + +impl + From, ManagedVec>>> + for TransferData +{ + fn from( + value: MultiValue3, ManagedVec>>, + ) -> Self { + let (gas_limit, function, vec) = value.into_tuple(); + TransferData::new(gas_limit, function, vec) + } +} + +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, ManagedVecItem, Clone)] +pub struct EventPayment { + pub identifier: TokenIdentifier, + pub nonce: u64, + pub data: EsdtTokenData, +} + +impl From> for EventPayment { + fn from(value: EventPaymentTuple) -> Self { + let (identifier, nonce, data) = value.into_tuple(); + + EventPayment::new(identifier, nonce, data) + } +} + +impl From> for EventPaymentTuple { + fn from(value: EventPayment) -> EventPaymentTuple { + MultiValue3((value.identifier, value.nonce, value.data)) + } +} + +impl EventPayment { + pub fn new(identifier: TokenIdentifier, nonce: u64, data: EsdtTokenData) -> Self { + EventPayment { + identifier, + nonce, + data, + } + } + + pub fn map_to_tuple_multi_value( + array: MultiValueEncoded, + ) -> MultiValueEncoded> { + array.into_iter().map(|payment| payment.into()).collect() + } +} + #[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, ManagedVecItem, Clone)] pub struct OperationTuple { pub op_hash: ManagedBuffer, pub operation: Operation, } +impl OperationTuple { + #[inline] + pub fn new(op_hash: ManagedBuffer, operation: Operation) -> Self { + OperationTuple { op_hash, operation } + } +} + #[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, ManagedVecItem, Clone)] pub struct OperationEsdtPayment { pub token_identifier: TokenIdentifier, pub token_nonce: u64, - pub token_data: StolenFromFrameworkEsdtTokenData, + pub token_data: EsdtTokenData, +} + +impl OperationEsdtPayment { + #[inline] + pub fn new( + token_identifier: TokenIdentifier, + token_nonce: u64, + token_data: EsdtTokenData, + ) -> Self { + Self { + token_identifier, + token_nonce, + token_data, + } + } } impl From> for EsdtTokenPayment { + #[inline] fn from(payment: OperationEsdtPayment) -> Self { EsdtTokenPayment { token_identifier: payment.token_identifier, @@ -90,66 +213,12 @@ impl From> for EsdtTokenPayment { } } -// Temporary until Clone is implemented for EsdtTokenData -#[derive( - TopDecode, TopEncode, NestedDecode, NestedEncode, TypeAbi, Debug, ManagedVecItem, Clone, -)] -pub struct StolenFromFrameworkEsdtTokenData { - pub token_type: EsdtTokenType, - pub amount: BigUint, - pub frozen: bool, - pub hash: ManagedBuffer, - pub name: ManagedBuffer, - pub attributes: ManagedBuffer, - pub creator: ManagedAddress, - pub royalties: BigUint, - pub uris: ManagedVec>, -} - -impl Default for StolenFromFrameworkEsdtTokenData { +impl Default for OperationEsdtPayment { fn default() -> Self { - StolenFromFrameworkEsdtTokenData { - token_type: EsdtTokenType::Fungible, - amount: BigUint::zero(), - frozen: false, - hash: ManagedBuffer::new(), - name: ManagedBuffer::new(), - attributes: ManagedBuffer::new(), - creator: ManagedAddress::zero(), - royalties: BigUint::zero(), - uris: ManagedVec::new(), - } - } -} - -impl From> for StolenFromFrameworkEsdtTokenData { - fn from(value: EsdtTokenData) -> Self { - StolenFromFrameworkEsdtTokenData { - token_type: value.token_type, - amount: value.amount, - frozen: value.frozen, - hash: value.hash, - name: value.name, - attributes: value.attributes, - creator: value.creator, - royalties: value.royalties, - uris: value.uris, - } - } -} - -impl From> for EsdtTokenData { - fn from(token_data: StolenFromFrameworkEsdtTokenData) -> Self { - EsdtTokenData { - token_type: token_data.token_type, - amount: token_data.amount, - frozen: token_data.frozen, - hash: token_data.hash, - name: token_data.name, - attributes: token_data.attributes, - creator: token_data.creator, - royalties: token_data.royalties, - uris: token_data.uris, + OperationEsdtPayment { + token_identifier: TokenIdentifier::from(ManagedBuffer::new()), + token_nonce: 0, + token_data: EsdtTokenData::default(), } } } @@ -161,7 +230,7 @@ pub struct Transaction { pub from: ManagedAddress, pub to: ManagedAddress, pub tokens: ManagedVec>, - pub token_data: ManagedVec>, + pub token_data: ManagedVec>, pub opt_transfer_data: Option>, pub is_refund_tx: bool, } diff --git a/common/utils/src/lib.rs b/common/utils/src/lib.rs index 61ed078e..6700e77e 100644 --- a/common/utils/src/lib.rs +++ b/common/utils/src/lib.rs @@ -1,15 +1,15 @@ #![no_std] -use bls_signature::BlsSignature; - multiversx_sc::imports!(); pub type PaymentsVec = ManagedVec>; static ERR_EMPTY_PAYMENTS: &[u8] = b"No payments"; +const DASH: u8 = b'-'; +const MAX_TOKEN_ID_LEN: usize = 32; #[multiversx_sc::module] -pub trait UtilsModule: bls_signature::BlsSignatureModule { +pub trait UtilsModule { fn require_sc_address(&self, address: &ManagedAddress) { require!( !address.is_zero() && self.blockchain().is_smart_contract(address), @@ -47,22 +47,42 @@ pub trait UtilsModule: bls_signature::BlsSignatureModule { first_payment } - fn verify_items_signature( - &self, - opt_signature: Option>, - items: MultiValueEncoded, - ) -> ManagedVec { - require!(opt_signature.is_some(), "Must provide signature"); - - let list = items.to_vec(); - let signature = unsafe { opt_signature.unwrap_unchecked() }; - let mut signature_data = ManagedBuffer::new(); - for token in &list { - let _ = token.dep_encode(&mut signature_data); + fn has_prefix(&self, token_id: &TokenIdentifier) -> bool { + let buffer = token_id.as_managed_buffer(); + let mut array_buffer = [0u8; MAX_TOKEN_ID_LEN]; + let slice = buffer.load_to_byte_array(&mut array_buffer); + + let counter = slice.iter().filter(|&&c| c == DASH).count(); + + if counter == 2 { + return true; } - self.multi_verify_signature(&signature_data, &signature); + false + } + + #[inline] + fn require_token_has_prefix(&self, token_id: &TokenIdentifier) { + require!(self.has_prefix(token_id), "Token Id does not have prefix"); + } + + fn has_sov_prefix(&self, token_id: &TokenIdentifier, chain_prefix: &ManagedBuffer) -> bool { + if !self.has_prefix(token_id) { + return false; + } + + let buffer = token_id.as_managed_buffer(); + let mut array_buffer = [0u8; MAX_TOKEN_ID_LEN]; + let slice = buffer.load_to_byte_array(&mut array_buffer); + + if let Some(index) = slice.iter().position(|&b| b == DASH) { + let prefix = ManagedBuffer::from(&slice[..index]); + + if prefix == chain_prefix.clone() { + return true; + } + } - list + false } } From 694038f20e200f9ff2770a2a394ece0b6d48a9fa Mon Sep 17 00:00:00 2001 From: Andrei Baltariu Date: Mon, 28 Oct 2024 15:38:04 +0200 Subject: [PATCH 06/15] Esdt-Safe copy paste Signed-off-by: Andrei Baltariu --- esdt-safe/sc-config.toml | 4 + esdt-safe/src/esdt_safe_proxy.rs | 199 +--------- esdt-safe/src/from_sovereign/events.rs | 4 +- esdt-safe/src/from_sovereign/mod.rs | 1 - esdt-safe/src/from_sovereign/token_mapping.rs | 200 ++++++---- .../src/from_sovereign/transfer_tokens.rs | 288 +++++++------- esdt-safe/src/lib.rs | 35 +- esdt-safe/src/to_sovereign/create_tx.rs | 364 ++++++------------ esdt-safe/src/to_sovereign/events.rs | 13 +- esdt-safe/src/to_sovereign/mod.rs | 2 - esdt-safe/wasm-esdt-safe-full/src/lib.rs | 24 +- esdt-safe/wasm/src/lib.rs | 24 +- 12 files changed, 456 insertions(+), 702 deletions(-) diff --git a/esdt-safe/sc-config.toml b/esdt-safe/sc-config.toml index 3e73d304..04faa00b 100644 --- a/esdt-safe/sc-config.toml +++ b/esdt-safe/sc-config.toml @@ -17,3 +17,7 @@ add-labels = ["esdt-safe-external-view"] [[proxy]] path = "src/esdt_safe_proxy.rs" + +[[proxy]] +path = "interactor/src/proxy.rs" + diff --git a/esdt-safe/src/esdt_safe_proxy.rs b/esdt-safe/src/esdt_safe_proxy.rs index 48a12bd9..81e2e31d 100644 --- a/esdt-safe/src/esdt_safe_proxy.rs +++ b/esdt-safe/src/esdt_safe_proxy.rs @@ -111,163 +111,44 @@ where .original_result() } - pub fn set_sovereign_bridge_address< - Arg0: ProxyArg>, - >( - self, - bridge_address: Arg0, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("setSovereignBridgeAddress") - .argument(&bridge_address) - .original_result() - } - pub fn set_max_user_tx_gas_limit< Arg0: ProxyArg, - Arg1: ProxyArg>>, >( self, - new_value: Arg0, - opt_sig: Arg1, + max_user_tx_gas_limit: Arg0, ) -> TxTypedCall { self.wrapped_tx .payment(NotPayable) - .raw_call("setMaxUserTxGasLimit") - .argument(&new_value) - .argument(&opt_sig) + .raw_call("setMaxTxGasLimit") + .argument(&max_user_tx_gas_limit) .original_result() } - pub fn set_burn_and_mint< - Arg0: ProxyArg>>, - Arg1: ProxyArg>>, - >( - self, - opt_signature: Arg0, - tokens: Arg1, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("setBurnAndMint") - .argument(&opt_signature) - .argument(&tokens) - .original_result() - } - - pub fn remove_burn_and_mint< - Arg0: ProxyArg>>, - Arg1: ProxyArg>>, - >( - self, - opt_signature: Arg0, - tokens: Arg1, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("removeBurnAndMint") - .argument(&opt_signature) - .argument(&tokens) - .original_result() - } - - pub fn add_banned_endpoint_names< - Arg0: ProxyArg>>, - Arg1: ProxyArg>>, - >( - self, - opt_signature: Arg0, - names: Arg1, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("addBannedEndpointNames") - .argument(&opt_signature) - .argument(&names) - .original_result() - } - - pub fn remove_banned_endpoint_names< - Arg0: ProxyArg>>, - Arg1: ProxyArg>>, + pub fn set_banned_endpoint< + Arg0: ProxyArg>, >( self, - opt_signature: Arg0, - names: Arg1, + endpoint_name: Arg0, ) -> TxTypedCall { self.wrapped_tx .payment(NotPayable) - .raw_call("removeBannedEndpointNames") - .argument(&opt_signature) - .argument(&names) + .raw_call("setBannedEndpoint") + .argument(&endpoint_name) .original_result() } - pub fn deposit_back< - Arg0: ProxyArg>, - >( - self, - to: Arg0, - ) -> TxTypedCall { - self.wrapped_tx - .raw_call("depositBack") - .argument(&to) - .original_result() - } - - /// Create an Elrond -> Sovereign transaction. pub fn deposit< Arg0: ProxyArg>, Arg1: ProxyArg, ManagedVec>>>>, >( self, to: Arg0, - opt_transfer_data: Arg1, + optional_transfer_data: Arg1, ) -> TxTypedCall { self.wrapped_tx .raw_call("deposit") .argument(&to) - .argument(&opt_transfer_data) - .original_result() - } - - /// Claim funds for failed Elrond -> Sovereign transactions. - /// These are not sent automatically to prevent the contract getting stuck. - /// For example, if the receiver is a SC, a frozen account, etc. - pub fn claim_refund< - Arg0: ProxyArg>, - >( - self, - token_id: Arg0, - ) -> TxTypedCall>> { - self.wrapped_tx - .payment(NotPayable) - .raw_call("claimRefund") - .argument(&token_id) - .original_result() - } - - /// Sets the statuses for the transactions, after they were executed on the Sovereign side. - /// - /// Only TransactionStatus::Executed (3) and TransactionStatus::Rejected (4) values are allowed. - /// Number of provided statuses must be equal to number of transactions in the batch. - pub fn set_transaction_batch_status< - Arg0: ProxyArg, - Arg1: ProxyArg>, - Arg2: ProxyArg>, - >( - self, - batch_id: Arg0, - signature: Arg1, - tx_statuses: Arg2, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("setTransactionBatchStatus") - .argument(&batch_id) - .argument(&signature) - .argument(&tx_statuses) + .argument(&optional_transfer_data) .original_result() } @@ -334,32 +215,6 @@ where .original_result() } - pub fn clear_registered_sovereign_token< - Arg0: ProxyArg>, - >( - self, - sov_token_id: Arg0, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("clearRegisteredSovereignToken") - .argument(&sov_token_id) - .original_result() - } - - pub fn clear_registered_multiversx_token< - Arg0: ProxyArg>, - >( - self, - mvx_token_id: Arg0, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("clearRegisteredMultiversxToken") - .argument(&mvx_token_id) - .original_result() - } - pub fn execute_operations< Arg0: ProxyArg>, Arg1: ProxyArg>, @@ -404,7 +259,7 @@ where pub fn get_current_tx_batch( self, - ) -> TxTypedCall, ManagedAddress, ManagedVec>, ManagedVec>, Option>>>>>> { + ) -> TxTypedCall, ManagedAddress, ManagedVec>, ManagedVec>, Option>>>>>> { self.wrapped_tx .payment(NotPayable) .raw_call("getCurrentTxBatch") @@ -413,7 +268,7 @@ where pub fn get_first_batch_any_status( self, - ) -> TxTypedCall, ManagedAddress, ManagedVec>, ManagedVec>, Option>>>>>> { + ) -> TxTypedCall, ManagedAddress, ManagedVec>, ManagedVec>, Option>>>>>> { self.wrapped_tx .payment(NotPayable) .raw_call("getFirstBatchAnyStatus") @@ -425,7 +280,7 @@ where >( self, batch_id: Arg0, - ) -> TxTypedCall, ManagedAddress, ManagedVec>, ManagedVec>, Option>>>>>> { + ) -> TxTypedCall, ManagedAddress, ManagedVec>, ManagedVec>, Option>>>>>> { self.wrapped_tx .payment(NotPayable) .raw_call("getBatch") @@ -504,66 +359,54 @@ where /// Tokens in the whitelist can be transferred without fees pub fn add_tokens_to_whitelist< - Arg0: ProxyArg>>, - Arg1: ProxyArg>>, + Arg0: ProxyArg>>, >( self, - opt_signature: Arg0, - tokens: Arg1, + tokens: Arg0, ) -> TxTypedCall { self.wrapped_tx .payment(NotPayable) .raw_call("addTokensToWhitelist") - .argument(&opt_signature) .argument(&tokens) .original_result() } pub fn remove_tokens_from_whitelist< - Arg0: ProxyArg>>, - Arg1: ProxyArg>>, + Arg0: ProxyArg>>, >( self, - opt_signature: Arg0, - tokens: Arg1, + tokens: Arg0, ) -> TxTypedCall { self.wrapped_tx .payment(NotPayable) .raw_call("removeTokensFromWhitelist") - .argument(&opt_signature) .argument(&tokens) .original_result() } /// Tokens in blacklist cannot be transferred pub fn add_tokens_to_blacklist< - Arg0: ProxyArg>>, - Arg1: ProxyArg>>, + Arg0: ProxyArg>>, >( self, - opt_signature: Arg0, - tokens: Arg1, + tokens: Arg0, ) -> TxTypedCall { self.wrapped_tx .payment(NotPayable) .raw_call("addTokensToBlacklist") - .argument(&opt_signature) .argument(&tokens) .original_result() } pub fn remove_tokens_from_blacklist< - Arg0: ProxyArg>>, - Arg1: ProxyArg>>, + Arg0: ProxyArg>>, >( self, - opt_signature: Arg0, - tokens: Arg1, + tokens: Arg0, ) -> TxTypedCall { self.wrapped_tx .payment(NotPayable) .raw_call("removeTokensFromBlacklist") - .argument(&opt_signature) .argument(&tokens) .original_result() } diff --git a/esdt-safe/src/from_sovereign/events.rs b/esdt-safe/src/from_sovereign/events.rs index ec07f3a7..620d947d 100644 --- a/esdt-safe/src/from_sovereign/events.rs +++ b/esdt-safe/src/from_sovereign/events.rs @@ -5,7 +5,7 @@ pub trait EventsModule { #[event("executedBridgeOp")] fn execute_bridge_operation_event( &self, - #[indexed] hash_of_hashes: ManagedBuffer, - #[indexed] hash_of_bridge_op: ManagedBuffer, + #[indexed] hash_of_hashes: &ManagedBuffer, + #[indexed] hash_of_bridge_op: &ManagedBuffer, ); } diff --git a/esdt-safe/src/from_sovereign/mod.rs b/esdt-safe/src/from_sovereign/mod.rs index 8564e0ab..51dbf34b 100644 --- a/esdt-safe/src/from_sovereign/mod.rs +++ b/esdt-safe/src/from_sovereign/mod.rs @@ -1,4 +1,3 @@ pub mod events; -pub mod refund; pub mod token_mapping; pub mod transfer_tokens; diff --git a/esdt-safe/src/from_sovereign/token_mapping.rs b/esdt-safe/src/from_sovereign/token_mapping.rs index fa825d0e..dc4ca566 100644 --- a/esdt-safe/src/from_sovereign/token_mapping.rs +++ b/esdt-safe/src/from_sovereign/token_mapping.rs @@ -1,17 +1,26 @@ -const DEFAULT_ISSUE_COST: u64 = 50000000000000000; multiversx_sc::imports!(); multiversx_sc::derive_imports!(); +const DEFAULT_ISSUE_COST: u64 = 50_000_000_000_000_000; // 0.05 EGLD +const REGISTER_GAS: u64 = 60_000_000; + #[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, ManagedVecItem, Clone)] -pub struct EsdtTokenInfo { +pub struct EsdtInfo { pub token_identifier: TokenIdentifier, pub token_nonce: u64, } +struct IssueEsdtArgs { + sov_token_id: TokenIdentifier, + token_type: EsdtTokenType, + issue_cost: BigUint, + token_display_name: ManagedBuffer, + token_ticker: ManagedBuffer, + num_decimals: usize, +} + #[multiversx_sc::module] -pub trait TokenMappingModule: - multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule -{ +pub trait TokenMappingModule: utils::UtilsModule { #[payable("EGLD")] #[endpoint(registerToken)] fn register_token( @@ -22,132 +31,161 @@ pub trait TokenMappingModule: token_ticker: ManagedBuffer, num_decimals: usize, ) { + let is_sovereign_chain = self.is_sovereign_chain().get(); require!( - !self.is_sovereign_chain().get(), + !is_sovereign_chain, "Invalid method to call in current chain" ); + self.require_token_has_prefix(&sov_token_id); + let issue_cost = self.call_value().egld_value().clone_value(); + require!( + issue_cost == DEFAULT_ISSUE_COST, + "eGLD value should be 0.05" + ); - require!(issue_cost == DEFAULT_ISSUE_COST, "eGLD value should be 0.5"); + self.require_sov_token_id_not_registered(&sov_token_id); match token_type { EsdtTokenType::Invalid => sc_panic!("Invalid type"), - EsdtTokenType::Fungible => self.handle_fungible_token_type( - sov_token_id.clone(), + _ => self.handle_token_issue(IssueEsdtArgs { + sov_token_id: sov_token_id.clone(), issue_cost, token_display_name, token_ticker, - num_decimals, - ), - _ => self.handle_nonfungible_token_type( - sov_token_id.clone(), token_type, - issue_cost, - token_display_name, - token_ticker, num_decimals, - ), + }), } + } - match self.sovereign_to_multiversx_token_id(&sov_token_id).get() { - TokenMapperState::NotSet => sc_panic!("Token ID not set"), - TokenMapperState::Pending => {} - TokenMapperState::Token(mx_token_id) => { - self.multiversx_to_sovereign_token_id(&mx_token_id) - .set(sov_token_id); + fn handle_token_issue(&self, args: IssueEsdtArgs) { + self.tx() + .to(ESDTSystemSCAddress) + .typed(ESDTSystemSCProxy) + .issue_and_set_all_roles( + args.issue_cost, + args.token_display_name, + args.token_ticker, + args.token_type, + args.num_decimals, + ) + .gas(REGISTER_GAS) + .callback( + ::callbacks(self).issue_callback(&args.sov_token_id), + ) + .register_promise(); + } + + #[promises_callback] + fn issue_callback( + &self, + sov_token_id: &TokenIdentifier, + #[call_result] result: ManagedAsyncCallResult>, + ) { + match result { + ManagedAsyncCallResult::Ok(mvx_token_id) => { + self.set_corresponding_token_ids(sov_token_id, &mvx_token_id); + } + ManagedAsyncCallResult::Err(error) => { + sc_panic!("There was an error at issuing token: '{}'", error.err_msg); } } } - fn handle_fungible_token_type( + fn set_corresponding_token_ids( &self, - sov_token_id: TokenIdentifier, - issue_cost: BigUint, - token_display_name: ManagedBuffer, - token_ticker: ManagedBuffer, - num_decimals: usize, + sov_token_id: &TokenIdentifier, + mvx_token_id: &TokenIdentifier, ) { - self.multiversx_to_sovereign_token_id(&sov_token_id) - .set(sov_token_id.clone()); - - self.fungible_token(&sov_token_id).issue_and_set_all_roles( - issue_cost, - token_display_name, - token_ticker, - num_decimals, - None, - ); + self.sovereign_to_multiversx_token_id_mapper(sov_token_id) + .set(mvx_token_id); + + self.multiversx_to_sovereign_token_id_mapper(mvx_token_id) + .set(sov_token_id); } - fn handle_nonfungible_token_type( + fn update_esdt_info_mappers( &self, - sov_token_id: TokenIdentifier, - token_type: EsdtTokenType, - issue_cost: BigUint, - token_display_name: ManagedBuffer, - token_ticker: ManagedBuffer, - num_decimals: usize, + sov_id: &TokenIdentifier, + sov_nonce: u64, + mvx_id: &TokenIdentifier, + new_nft_nonce: u64, ) { - self.multiversx_to_sovereign_token_id(&sov_token_id) - .set(sov_token_id.clone()); + self.sovereign_to_multiversx_esdt_info_mapper(sov_id, sov_nonce) + .set(EsdtInfo { + token_identifier: mvx_id.clone(), + token_nonce: new_nft_nonce, + }); + + self.multiversx_to_sovereign_esdt_info_mapper(mvx_id, new_nft_nonce) + .set(EsdtInfo { + token_identifier: sov_id.clone(), + token_nonce: sov_nonce, + }); + } - self.non_fungible_token(&sov_token_id) - .issue_and_set_all_roles( - token_type, - issue_cost, - token_display_name, - token_ticker, - num_decimals, - None, - ); + #[inline] + fn clear_sov_to_mvx_esdt_info_mapper(&self, id: &TokenIdentifier, nonce: u64) { + self.sovereign_to_multiversx_esdt_info_mapper(id, nonce) + .take(); } - #[only_owner] - #[endpoint(clearRegisteredSovereignToken)] - fn clear_registered_sovereign_token(&self, sov_token_id: TokenIdentifier) { - self.sovereign_to_multiversx_token_id(&sov_token_id).clear(); + #[inline] + fn clear_mvx_to_sov_esdt_info_mapper(&self, id: &TokenIdentifier, nonce: u64) { + self.multiversx_to_sovereign_esdt_info_mapper(id, nonce) + .take(); } - #[only_owner] - #[endpoint(clearRegisteredMultiversxToken)] - fn clear_registered_multiversx_token(&self, mvx_token_id: TokenIdentifier) { - self.multiversx_to_sovereign_token_id(&mvx_token_id).clear(); + #[inline] + fn is_fungible(self, token_type: &EsdtTokenType) -> bool { + *token_type == EsdtTokenType::Fungible } - // WARNING: All mappers must have the exact same storage key! + #[inline] + fn is_sft_or_meta(self, token_type: &EsdtTokenType) -> bool { + *token_type == EsdtTokenType::SemiFungible || *token_type == EsdtTokenType::Meta + } + + #[inline] + fn is_nft(self, token_type: &EsdtTokenType) -> bool { + *token_type == EsdtTokenType::NonFungible + } + + #[inline] + fn require_sov_token_id_not_registered(&self, id: &TokenIdentifier) { + require!( + self.sovereign_to_multiversx_token_id_mapper(id).is_empty(), + "This token was already registered" + ); + } #[storage_mapper("sovToMxTokenId")] - fn sovereign_to_multiversx_token_id( + fn sovereign_to_multiversx_token_id_mapper( &self, sov_token_id: &TokenIdentifier, - ) -> SingleValueMapper>; + ) -> SingleValueMapper; #[storage_mapper("mxToSovTokenId")] - fn multiversx_to_sovereign_token_id( + fn multiversx_to_sovereign_token_id_mapper( &self, mx_token_id: &TokenIdentifier, ) -> SingleValueMapper; - #[storage_mapper("sovToMxTokenId")] - fn fungible_token(&self, sov_token_id: &TokenIdentifier) -> FungibleTokenMapper; - - #[storage_mapper("sovToMxTokenId")] - fn non_fungible_token(&self, sov_token_id: &TokenIdentifier) -> NonFungibleTokenMapper; - #[storage_mapper("sovEsdtTokenInfoMapper")] - fn sovereign_esdt_token_info_mapper( + fn sovereign_to_multiversx_esdt_info_mapper( &self, token_identifier: &TokenIdentifier, - nonce: &u64, - ) -> SingleValueMapper>; + nonce: u64, + ) -> SingleValueMapper>; #[storage_mapper("mxEsdtTokenInfoMapper")] - fn multiversx_esdt_token_info_mapper( + fn multiversx_to_sovereign_esdt_info_mapper( &self, token_identifier: &TokenIdentifier, - nonce: &u64, - ) -> SingleValueMapper>; + nonce: u64, + ) -> SingleValueMapper>; #[storage_mapper("isSovereignChain")] fn is_sovereign_chain(&self) -> SingleValueMapper; diff --git a/esdt-safe/src/from_sovereign/transfer_tokens.rs b/esdt-safe/src/from_sovereign/transfer_tokens.rs index 6d143b8a..9e2ff236 100644 --- a/esdt-safe/src/from_sovereign/transfer_tokens.rs +++ b/esdt-safe/src/from_sovereign/transfer_tokens.rs @@ -1,44 +1,37 @@ +use builtin_func_names::ESDT_MULTI_TRANSFER_FUNC_NAME; use header_verifier::header_verifier_proxy; -use multiversx_sc::{api::ESDT_MULTI_TRANSFER_FUNC_NAME, storage::StorageKey}; -use transaction::{ - BatchId, GasLimit, Operation, OperationData, OperationEsdtPayment, OperationTuple, -}; +use transaction::{GasLimit, Operation, OperationData, OperationEsdtPayment, OperationTuple}; use crate::to_sovereign; -use super::token_mapping::EsdtTokenInfo; - multiversx_sc::imports!(); const CALLBACK_GAS: GasLimit = 10_000_000; // Increase if not enough const TRANSACTION_GAS: GasLimit = 30_000_000; -pub type MultiOperationEsdtPayment = ManagedVec>; - #[multiversx_sc::module] pub trait TransferTokensModule: bls_signature::BlsSignatureModule + super::events::EventsModule - + super::refund::RefundModule + super::token_mapping::TokenMappingModule + tx_batch_module::TxBatchModule + max_bridged_amount_module::MaxBridgedAmountModule + multiversx_sc_modules::pause::PauseModule - + multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule + utils::UtilsModule + to_sovereign::events::EventsModule { #[endpoint(executeBridgeOps)] fn execute_operations(&self, hash_of_hashes: ManagedBuffer, operation: Operation) { + let is_sovereign_chain = self.is_sovereign_chain().get(); require!( - !self.is_sovereign_chain().get(), + !is_sovereign_chain, "Invalid method to call in current chain" ); require!(self.not_paused(), "Cannot transfer while paused"); let (operation_hash, is_registered) = - self.calculate_operation_hash(hash_of_hashes.clone(), operation.clone()); + self.calculate_operation_hash(&hash_of_hashes, &operation); if !is_registered { sc_panic!("Operation is not registered"); @@ -50,7 +43,7 @@ pub trait TransferTokensModule: operation, }; - self.distribute_payments(hash_of_hashes, operation_tuple, minted_operation_tokens); + self.distribute_payments(&hash_of_hashes, &operation_tuple, &minted_operation_tokens); } fn mint_tokens( @@ -60,28 +53,29 @@ pub trait TransferTokensModule: let mut output_payments = ManagedVec::new(); for operation_token in operation_tokens.iter() { - let mx_token_id_state = self - .sovereign_to_multiversx_token_id(&operation_token.token_identifier) - .get(); - - let mx_token_id = match mx_token_id_state { - // token is from sovereign -> continue and mint - TokenMapperState::Token(token_id) => token_id, - // token is from mainchain -> push token - _ => { - // TODO: will use sovereign prefix - output_payments.push(operation_token.clone()); - - continue; - } - }; + let sov_to_mvx_token_id_mapper = + self.sovereign_to_multiversx_token_id_mapper(&operation_token.token_identifier); + + // token is from mainchain -> push token + if sov_to_mvx_token_id_mapper.is_empty() { + output_payments.push(operation_token.clone()); + + continue; + } - if operation_token.token_nonce == 0 { - self.send() - .esdt_local_mint(&mx_token_id, 0, &operation_token.token_data.amount); + // token is from sovereign -> continue and mint + let mvx_token_id = sov_to_mvx_token_id_mapper.get(); + let current_token_type_ref = &operation_token.token_data.token_type; + + if self.is_fungible(current_token_type_ref) { + self.tx() + .to(ToSelf) + .typed(system_proxy::UserBuiltinProxy) + .esdt_local_mint(&mvx_token_id, 0, &operation_token.token_data.amount) + .sync_call(); output_payments.push(OperationEsdtPayment { - token_identifier: mx_token_id, + token_identifier: mvx_token_id, token_nonce: 0, token_data: operation_token.token_data, }); @@ -89,10 +83,10 @@ pub trait TransferTokensModule: continue; } - let nft_nonce = self.mint_and_save_token(&mx_token_id, &operation_token); + let nft_nonce = self.esdt_create_and_update_mapper(&mvx_token_id, &operation_token); output_payments.push(OperationEsdtPayment { - token_identifier: mx_token_id, + token_identifier: mvx_token_id, token_nonce: nft_nonce, token_data: operation_token.token_data, }); @@ -101,107 +95,116 @@ pub trait TransferTokensModule: output_payments } - fn mint_and_save_token( + fn esdt_create_and_update_mapper( self, - mx_token_id: &TokenIdentifier, + mvx_token_id: &TokenIdentifier, operation_token: &OperationEsdtPayment, ) -> u64 { + let mut nonce = 0; + + let current_token_type_ref = &operation_token.token_data.token_type; + + // if doesn't exist in mapper nonce will be 0 and we need to create the SFT/MetaESDT, otherwise mint + if self.is_sft_or_meta(current_token_type_ref) { + nonce = self.get_mvx_nonce_from_mapper( + &operation_token.token_identifier, + operation_token.token_nonce, + ) + } + // mint NFT - let nft_nonce = self.send().esdt_nft_create( - mx_token_id, - &operation_token.token_data.amount, - &operation_token.token_data.name, - &operation_token.token_data.royalties, - &operation_token.token_data.hash, - &operation_token.token_data.attributes, - &operation_token.token_data.uris, - ); + if nonce == 0 { + // if NFT/DyNFT => esdt_nft_create + nonce = self.mint_nft_tx(mvx_token_id, &operation_token.token_data); + + // save token id and nonce + self.update_esdt_info_mappers( + &operation_token.token_identifier, + operation_token.token_nonce, + mvx_token_id, + nonce, + ); + } else { + // if SFT/DySFT/Meta/DyMeta => esdt_local_mint (add quantity) + self.tx() + .to(ToSelf) + .typed(system_proxy::UserBuiltinProxy) + .esdt_local_mint(mvx_token_id, nonce, &operation_token.token_data.amount) + .sync_call(); + } - // save token id and nonce - self.sovereign_esdt_token_info_mapper( - &operation_token.token_identifier, - &operation_token.token_nonce, - ) - .set(EsdtTokenInfo { - token_identifier: mx_token_id.clone(), - token_nonce: nft_nonce, - }); - - self.multiversx_esdt_token_info_mapper(mx_token_id, &nft_nonce) - .set(EsdtTokenInfo { - token_identifier: operation_token.token_identifier.clone(), - token_nonce: operation_token.token_nonce, - }); + nonce + } + + fn mint_nft_tx( + &self, + mvx_token_id: &TokenIdentifier, + token_data: &EsdtTokenData, + ) -> u64 { + let mut amount = token_data.amount.clone(); + if self.is_sft_or_meta(&token_data.token_type) { + amount += BigUint::from(1u32); + } - nft_nonce + self.tx() + .to(ToSelf) + .typed(system_proxy::UserBuiltinProxy) + .esdt_nft_create( + mvx_token_id, + &amount, + &token_data.name, + &token_data.royalties, + &token_data.hash, + &token_data.attributes, + &token_data.uris, + ) + .returns(ReturnsResult) + .sync_call() } + // TODO: create a callback module fn distribute_payments( &self, - hash_of_hashes: ManagedBuffer, - operation_tuple: OperationTuple, - tokens_list: ManagedVec>, + hash_of_hashes: &ManagedBuffer, + operation_tuple: &OperationTuple, + tokens_list: &ManagedVec>, ) { let mapped_tokens: ManagedVec> = tokens_list.iter().map(|token| token.into()).collect(); match &operation_tuple.operation.data.opt_transfer_data { Some(transfer_data) => { - let mut args = ManagedArgBuffer::new(); - for arg in &transfer_data.args { - args.push_arg(arg); - } + let args = ManagedArgBuffer::from(transfer_data.args.clone()); self.tx() .to(&operation_tuple.operation.to) .raw_call(transfer_data.function.clone()) - .arguments_raw(args.clone()) - .multi_esdt(mapped_tokens.clone()) + .arguments_raw(args) + .payment(&mapped_tokens) .gas(transfer_data.gas_limit) .callback( ::callbacks(self) - .execute(&hash_of_hashes, &operation_tuple), + .execute(hash_of_hashes, operation_tuple), ) .gas_for_callback(CALLBACK_GAS) .register_promise(); } None => { - let own_address = self.blockchain().get_sc_address(); - let args = - self.get_contract_call_args(&operation_tuple.operation.to, mapped_tokens); - self.tx() - .to(own_address) + .to(&operation_tuple.operation.to) .raw_call(ESDT_MULTI_TRANSFER_FUNC_NAME) - .arguments_raw(args) + .payment(&mapped_tokens) .gas(TRANSACTION_GAS) .callback( ::callbacks(self) - .execute(&hash_of_hashes, &operation_tuple), + .execute(hash_of_hashes, operation_tuple), ) + .gas_for_callback(CALLBACK_GAS) .register_promise(); } } } - fn get_contract_call_args( - self, - to: &ManagedAddress, - mapped_tokens: ManagedVec>, - ) -> ManagedArgBuffer { - let mut args = ManagedArgBuffer::new(); - args.push_arg(to); - args.push_arg(mapped_tokens.len()); - - for token in &mapped_tokens { - args.push_arg(token.token_identifier); - args.push_arg(token.token_nonce); - args.push_arg(token.amount); - } - - args - } - #[promises_callback] fn execute( &self, @@ -211,10 +214,7 @@ pub trait TransferTokensModule: ) { match result { ManagedAsyncCallResult::Ok(_) => { - self.execute_bridge_operation_event( - hash_of_hashes.clone(), - operation_tuple.op_hash.clone(), - ); + self.execute_bridge_operation_event(hash_of_hashes, &operation_tuple.op_hash); } ManagedAsyncCallResult::Err(_) => { self.emit_transfer_failed_events(hash_of_hashes, operation_tuple); @@ -235,36 +235,44 @@ pub trait TransferTokensModule: operation_tuple: &OperationTuple, ) { // confirmation event - self.execute_bridge_operation_event( - hash_of_hashes.clone(), - operation_tuple.op_hash.clone(), - ); + self.execute_bridge_operation_event(hash_of_hashes, &operation_tuple.op_hash); for operation_token in &operation_tuple.operation.tokens { - let mx_token_id_state = self - .sovereign_to_multiversx_token_id(&operation_token.token_identifier) - .get(); + let sov_to_mvx_token_id_mapper = + self.sovereign_to_multiversx_token_id_mapper(&operation_token.token_identifier); - if let TokenMapperState::Token(mx_token_id) = mx_token_id_state { - let mut mx_token_nonce = 0; + if !sov_to_mvx_token_id_mapper.is_empty() { + let mvx_token_id = sov_to_mvx_token_id_mapper.get(); + let mut mvx_token_nonce = 0; if operation_token.token_nonce > 0 { - mx_token_nonce = self - .sovereign_esdt_token_info_mapper( + mvx_token_nonce = self + .sovereign_to_multiversx_esdt_info_mapper( &operation_token.token_identifier, - &operation_token.token_nonce, + operation_token.token_nonce, ) - .take() + .get() .token_nonce; - self.multiversx_esdt_token_info_mapper(&mx_token_id, &mx_token_nonce); + if self.is_nft(&operation_token.token_data.token_type) { + self.clear_sov_to_mvx_esdt_info_mapper( + &operation_token.token_identifier, + operation_token.token_nonce, + ); + + self.clear_mvx_to_sov_esdt_info_mapper(&mvx_token_id, mvx_token_nonce); + } } - self.send().esdt_local_burn( - &mx_token_id, - mx_token_nonce, - &operation_token.token_data.amount, - ); + self.tx() + .to(ToSelf) + .typed(system_proxy::UserBuiltinProxy) + .esdt_local_burn( + &mvx_token_id, + mvx_token_nonce, + &operation_token.token_data.amount, + ) + .sync_call(); } } @@ -274,27 +282,23 @@ pub trait TransferTokensModule: self.deposit_event( &operation_tuple.operation.data.op_sender, - &operation_tuple.operation.get_tokens_as_tuple_arr(), - OperationData { - op_nonce: tx_nonce, - op_sender: sc_address.clone(), - opt_transfer_data: None, - }, + &operation_tuple + .operation + .map_tokens_to_multi_value_encoded(), + OperationData::new(tx_nonce, sc_address.clone(), None), ); } // use pending_operations as param fn calculate_operation_hash( &self, - hash_of_hashes: ManagedBuffer, - operation: Operation, + hash_of_hashes: &ManagedBuffer, + operation: &Operation, ) -> (ManagedBuffer, bool) { let mut serialized_data = ManagedBuffer::new(); - let mut storage_key = StorageKey::from("pending_hashes"); - storage_key.append_item(&hash_of_hashes); - + let header_verifier_address = self.header_verifier_address().get(); let pending_operations_mapper = - UnorderedSetMapper::new_from_address(self.header_verifier_address().get(), storage_key); + self.external_pending_hashes(header_verifier_address, hash_of_hashes); if let core::result::Result::Err(err) = operation.top_encode(&mut serialized_data) { sc_panic!("Transfer data encode error: {}", err.message_bytes()); @@ -302,7 +306,6 @@ pub trait TransferTokensModule: let sha256 = self.crypto().sha256(&serialized_data); let hash = sha256.as_managed_buffer().clone(); - if pending_operations_mapper.contains(&hash) { (hash, true) } else { @@ -310,15 +313,24 @@ pub trait TransferTokensModule: } } - #[storage_mapper("nextBatchId")] - fn next_batch_id(&self) -> SingleValueMapper; + fn get_mvx_nonce_from_mapper(self, token_id: &TokenIdentifier, nonce: u64) -> u64 { + let esdt_info_mapper = self.sovereign_to_multiversx_esdt_info_mapper(token_id, nonce); + if esdt_info_mapper.is_empty() { + return 0; + } + esdt_info_mapper.get().token_nonce + } - #[storage_mapper("pending_hashes")] + #[storage_mapper("pendingHashes")] fn pending_hashes(&self, hash_of_hashes: &ManagedBuffer) -> UnorderedSetMapper; - #[storage_mapper("header_verifier_address")] + #[storage_mapper("headerVerifierAddress")] fn header_verifier_address(&self) -> SingleValueMapper; - #[storage_mapper("sovereign_bridge_address")] - fn sovereign_bridge_address(&self) -> SingleValueMapper; + #[storage_mapper_from_address("pendingHashes")] + fn external_pending_hashes( + &self, + sc_address: ManagedAddress, + hash_of_hashes: &ManagedBuffer, + ) -> UnorderedSetMapper; } diff --git a/esdt-safe/src/lib.rs b/esdt-safe/src/lib.rs index 161f06d6..249fd5b2 100644 --- a/esdt-safe/src/lib.rs +++ b/esdt-safe/src/lib.rs @@ -1,21 +1,22 @@ #![no_std] +use transaction::GasLimit; + multiversx_sc::imports!(); multiversx_sc::derive_imports!(); +pub mod esdt_safe_proxy; pub mod from_sovereign; pub mod to_sovereign; -pub mod esdt_safe_proxy; + +const MAX_USER_TX_GAS_LIMIT: GasLimit = 60_000_000; #[multiversx_sc::contract] pub trait EsdtSafe: to_sovereign::create_tx::CreateTxModule + to_sovereign::events::EventsModule - + to_sovereign::refund::RefundModule - + to_sovereign::set_tx_status::SetTxStatusModule + bls_signature::BlsSignatureModule + from_sovereign::events::EventsModule - + from_sovereign::refund::RefundModule + from_sovereign::token_mapping::TokenMappingModule + from_sovereign::transfer_tokens::TransferTokensModule + tx_batch_module::TxBatchModule @@ -24,17 +25,17 @@ pub trait EsdtSafe: + token_whitelist::TokenWhitelistModule + utils::UtilsModule + multiversx_sc_modules::pause::PauseModule - + multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule { #[init] - fn init( - &self, - is_sovereign_chain: bool, - ) { + fn init(&self, is_sovereign_chain: bool) { self.is_sovereign_chain().set(is_sovereign_chain); + self.max_user_tx_gas_limit().set(MAX_USER_TX_GAS_LIMIT); self.set_paused(true); } + #[upgrade] + fn upgrade(&self) {} + #[only_owner] #[endpoint(setFeeMarketAddress)] fn set_fee_market_address(&self, fee_market_address: ManagedAddress) { @@ -52,14 +53,14 @@ pub trait EsdtSafe: } #[only_owner] - #[endpoint(setSovereignBridgeAddress)] - fn set_sovereign_bridge_address(&self, bridge_address: ManagedAddress) { - self.require_sc_address(&bridge_address); - - self.sovereign_bridge_address().set(bridge_address); + #[endpoint(setMaxTxGasLimit)] + fn set_max_user_tx_gas_limit(&self, max_user_tx_gas_limit: GasLimit) { + self.max_user_tx_gas_limit().set(max_user_tx_gas_limit); } - #[upgrade] - fn upgrade(&self) {} - + #[only_owner] + #[endpoint(setBannedEndpoint)] + fn set_banned_endpoint(&self, endpoint_name: ManagedBuffer) { + self.banned_endpoint_names().insert(endpoint_name); + } } diff --git a/esdt-safe/src/to_sovereign/create_tx.rs b/esdt-safe/src/to_sovereign/create_tx.rs index bf743603..ef9dac88 100644 --- a/esdt-safe/src/to_sovereign/create_tx.rs +++ b/esdt-safe/src/to_sovereign/create_tx.rs @@ -1,13 +1,13 @@ use crate::from_sovereign::token_mapping; -use bls_signature::BlsSignature; use fee_market::fee_market_proxy; -use multiversx_sc::{hex_literal::hex, storage::StorageKey}; -use transaction::{GasLimit, OperationData, TransferData}; +use multiversx_sc::storage::StorageKey; +use transaction::{ + EventPaymentTuple, ExtractedFeeResult, GasLimit, OperationData, OptionalValueTransferDataTuple, + TransferData, +}; multiversx_sc::imports!(); -pub const ESDT_SYSTEM_SC_ADDRESS: [u8; 32] = - hex!("000000000000000000010000000000000000000000000000000000000002ffff"); const MAX_TRANSFERS_PER_TX: usize = 10; #[multiversx_sc::module] @@ -21,205 +21,35 @@ pub trait CreateTxModule: + utils::UtilsModule + multiversx_sc_modules::pause::PauseModule + token_mapping::TokenMappingModule - + multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule { - #[endpoint(setMaxUserTxGasLimit)] - fn set_max_user_tx_gas_limit( - &self, - new_value: GasLimit, - opt_sig: OptionalValue>, - ) { - if !self.is_setup_phase_complete() { - self.require_caller_initiator(); - self.max_user_tx_gas_limit().set(new_value); - - return; - } - - let opt_signature = opt_sig.into_option(); - require!(opt_signature.is_some(), "Must provide signature"); - let signature = unsafe { opt_signature.unwrap_unchecked() }; - let mut signature_data = ManagedBuffer::new(); - let _ = new_value.dep_encode(&mut signature_data); - - self.multi_verify_signature(&signature_data, &signature); - - self.max_user_tx_gas_limit().set(new_value); - } - - #[endpoint(setBurnAndMint)] - fn set_burn_and_mint( - &self, - opt_signature: Option>, - tokens: MultiValueEncoded, - ) { - if !self.is_setup_phase_complete() { - self.require_caller_initiator(); - self.burn_tokens().extend(tokens); - - return; - } - - let all_tokens = self.verify_items_signature(opt_signature, tokens); - self.burn_tokens().extend(&all_tokens); - } - - #[endpoint(removeBurnAndMint)] - fn remove_burn_and_mint( - &self, - opt_signature: Option>, - tokens: MultiValueEncoded, - ) { - if !self.is_setup_phase_complete() { - self.require_caller_initiator(); - self.remove_items(&mut self.burn_tokens(), tokens); - - return; - } - - let all_tokens = self.verify_items_signature(opt_signature, tokens); - self.remove_items(&mut self.burn_tokens(), &all_tokens); - } - - #[endpoint(addBannedEndpointNames)] - fn add_banned_endpoint_names( - &self, - opt_signature: Option>, - names: MultiValueEncoded, - ) { - if !self.is_setup_phase_complete() { - self.require_caller_initiator(); - self.banned_endpoint_names().extend(names); - - return; - } - - let all_names = self.verify_items_signature(opt_signature, names); - self.banned_endpoint_names().extend(&all_names); - } - - #[endpoint(removeBannedEndpointNames)] - fn remove_banned_endpoint_names( - &self, - opt_signature: Option>, - names: MultiValueEncoded, - ) { - if !self.is_setup_phase_complete() { - self.require_caller_initiator(); - self.remove_items(&mut self.banned_endpoint_names(), names); - - return; - } - - let all_names = self.verify_items_signature(opt_signature, names); - self.remove_items(&mut self.banned_endpoint_names(), &all_names); - } - - #[payable("*")] - #[endpoint(depositBack)] - fn deposit_back(&self, to: ManagedAddress) { - require!(self.not_paused(), "Cannot create transaction while paused"); - - let caller = self.blockchain().get_caller(); - require!( - caller == ManagedAddress::from(ESDT_SYSTEM_SC_ADDRESS), - "Caller is invalid" - ); - - let payments = self.call_value().all_esdt_transfers(); - - require!(!payments.is_empty(), "Nothing to transfer"); - require!(payments.len() <= MAX_TRANSFERS_PER_TX, "Too many tokens"); - - // self.send().direct_multi(&to, &payments); - self.tx().to(&to).payment(payments).transfer(); - } - - fn check_and_extract_fee( - &self, - ) -> MultiValue2, ManagedVec> { - let mut payments = self.call_value().all_esdt_transfers().clone_value(); - - require!(!payments.is_empty(), "Nothing to transfer"); - require!(payments.len() <= MAX_TRANSFERS_PER_TX, "Too many tokens"); - - let fee_market_address = self.fee_market_address().get(); - let fee_enabled_mapper = SingleValueMapper::new_from_address( - fee_market_address.clone(), - StorageKey::from("feeEnabledFlag"), - ) - .get(); - - let opt_transfer_data = if fee_enabled_mapper { - OptionalValue::Some(self.pop_first_payment(&mut payments)) - } else { - OptionalValue::None - }; - - MultiValue2::from((opt_transfer_data, payments)) - } - - fn process_transfer_data( - &self, - opt_transfer_data: OptionalValue< - MultiValue3>, - >, - ) -> Option> { - match &opt_transfer_data { - OptionalValue::Some(transfer_data) => { - let (gas_limit, function, args) = transfer_data.clone().into_tuple(); - let max_gas_limit = self.max_user_tx_gas_limit().get(); - - require!(gas_limit <= max_gas_limit, "Gas limit too high"); - - require!( - !self.banned_endpoint_names().contains(&function), - "Banned endpoint name" - ); - - Some(TransferData { - gas_limit, - function, - args, - }) - } - OptionalValue::None => None, - } - } - - /// Create an Elrond -> Sovereign transaction. #[payable("*")] #[endpoint] fn deposit( &self, to: ManagedAddress, - opt_transfer_data: OptionalValue< - MultiValue3>, - >, + optional_transfer_data: OptionalValueTransferDataTuple, ) { require!(self.not_paused(), "Cannot create transaction while paused"); let (fees_payment, payments) = self.check_and_extract_fee().into_tuple(); - require!(!payments.is_empty(), "Nothing to transfer"); require!(payments.len() <= MAX_TRANSFERS_PER_TX, "Too many tokens"); - let opt_transfer_data = self.process_transfer_data(opt_transfer_data); - let own_sc_address = self.blockchain().get_sc_address(); let mut total_tokens_for_fees = 0usize; - let mut event_payments: MultiValueEncoded< - MultiValue3, - > = MultiValueEncoded::new(); - let mut refundable_payments: ManagedVec> = - ManagedVec::new(); + let mut event_payments = + MultiValueEncoded::>::new(); + let mut refundable_payments = ManagedVec::::new(); + + let own_sc_address = self.blockchain().get_sc_address(); + let is_sov_chain = self.is_sovereign_chain().get(); for payment in &payments { self.require_below_max_amount(&payment.token_identifier, &payment.amount); self.require_token_not_blacklisted(&payment.token_identifier); + let is_token_whitelist_empty = self.token_whitelist().is_empty(); + let is_token_whitelisted = self.token_whitelist().contains(&payment.token_identifier); - if !self.token_whitelist().is_empty() - && !self.token_whitelist().contains(&payment.token_identifier) - { + if !is_token_whitelist_empty && !is_token_whitelisted { refundable_payments.push(payment.clone()); continue; @@ -232,89 +62,139 @@ pub trait CreateTxModule: &payment.token_identifier, payment.token_nonce, ); - current_token_data.amount = payment.amount.clone(); - if self.is_sovereign_chain().get() { - self.send().esdt_local_burn( - &payment.token_identifier, - payment.token_nonce, - &payment.amount, - ); + if is_sov_chain { + self.tx() + .to(ToSelf) + .typed(system_proxy::UserBuiltinProxy) + .esdt_local_burn( + &payment.token_identifier, + payment.token_nonce, + &payment.amount, + ) + .sync_call(); - event_payments.push(MultiValue3(( - payment.token_identifier.clone(), + event_payments.push(MultiValue3::from(( + payment.token_identifier, payment.token_nonce, - current_token_data.clone(), + current_token_data, ))); } else { - let sov_token_id = self - .multiversx_to_sovereign_token_id(&payment.token_identifier) - .get(); - - if !sov_token_id.is_valid_esdt_identifier() { - event_payments.push(MultiValue3(( + let mvx_to_sov_token_id_mapper = + self.multiversx_to_sovereign_token_id_mapper(&payment.token_identifier); + if !mvx_to_sov_token_id_mapper.is_empty() { + let sov_token_id = mvx_to_sov_token_id_mapper.get(); + let sov_token_nonce = self.burn_mainchain_token( + payment, + ¤t_token_data.token_type, + &sov_token_id, + ); + + event_payments.push(MultiValue3::from(( + sov_token_id, + sov_token_nonce, + current_token_data, + ))); + } else { + event_payments.push(MultiValue3::from(( payment.token_identifier, payment.token_nonce, - current_token_data.clone(), + current_token_data, ))); - - continue; } - - let sov_token_nonce = self.remove_sovereign_token(payment, &sov_token_id); - - event_payments.push(MultiValue3(( - sov_token_id, - sov_token_nonce, - current_token_data.clone(), - ))); } } - let caller = self.blockchain().get_caller(); + let option_transfer_data = TransferData::from_optional_value(optional_transfer_data); - self.match_fee_payment(total_tokens_for_fees, &fees_payment, &opt_transfer_data); + if let Some(transfer_data) = option_transfer_data.as_ref() { + self.require_gas_limit_under_limit(transfer_data.gas_limit); + self.require_endpoint_not_banned(&transfer_data.function); + } + self.match_fee_payment(total_tokens_for_fees, &fees_payment, &option_transfer_data); // refund refundable_tokens - for payment in &refundable_payments { - self.tx().to(&caller).payment(payment).transfer(); - } + let caller = self.blockchain().get_caller(); + self.refund_tokens(&caller, &refundable_payments); let tx_nonce = self.get_and_save_next_tx_id(); - self.deposit_event( &to, &event_payments, - OperationData { - op_nonce: tx_nonce, - op_sender: caller, - opt_transfer_data, - }, + OperationData::new(tx_nonce, caller, option_transfer_data), ); } - fn remove_sovereign_token( + fn check_and_extract_fee(&self) -> ExtractedFeeResult { + let mut payments = self.call_value().all_esdt_transfers().clone_value(); + + require!(!payments.is_empty(), "Nothing to transfer"); + require!(payments.len() <= MAX_TRANSFERS_PER_TX, "Too many tokens"); + + let fee_market_address = self.fee_market_address().get(); + let fee_enabled_mapper = SingleValueMapper::new_from_address( + fee_market_address.clone(), + StorageKey::from("feeEnabledFlag"), + ) + .get(); + + let opt_transfer_data = if fee_enabled_mapper { + OptionalValue::Some(self.pop_first_payment(&mut payments)) + } else { + OptionalValue::None + }; + + MultiValue2::from((opt_transfer_data, payments)) + } + + fn refund_tokens( + &self, + caller: &ManagedAddress, + refundable_payments: &ManagedVec, + ) { + for payment in refundable_payments { + if payment.amount > 0 { + self.tx().to(caller).payment(&payment).transfer(); + } + } + } + + fn burn_mainchain_token( &self, payment: EsdtTokenPayment, + payment_token_type: &EsdtTokenType, sov_token_id: &TokenIdentifier, ) -> u64 { - self.send().esdt_local_burn( - &payment.token_identifier, - payment.token_nonce, - &payment.amount, - ); + self.tx() + .to(ToSelf) + .typed(system_proxy::UserBuiltinProxy) + .esdt_local_burn( + &payment.token_identifier, + payment.token_nonce, + &payment.amount, + ) + .sync_call(); let mut sov_token_nonce = 0; if payment.token_nonce > 0 { sov_token_nonce = self - .multiversx_esdt_token_info_mapper(&payment.token_identifier, &payment.token_nonce) - .take() + .multiversx_to_sovereign_esdt_info_mapper( + &payment.token_identifier, + payment.token_nonce, + ) + .get() .token_nonce; - self.sovereign_esdt_token_info_mapper(sov_token_id, &sov_token_nonce) - .take(); + if self.is_nft(payment_token_type) { + self.clear_mvx_to_sov_esdt_info_mapper( + &payment.token_identifier, + payment.token_nonce, + ); + + self.clear_sov_to_mvx_esdt_info_mapper(sov_token_id, sov_token_nonce); + } } sov_token_nonce @@ -324,7 +204,7 @@ pub trait CreateTxModule: &self, total_tokens_for_fees: usize, fees_payment: &OptionalValue>, - opt_transfer_data: &Option::Api>>, + opt_transfer_data: &Option>, ) { match fees_payment { OptionalValue::Some(fee) => { @@ -348,8 +228,17 @@ pub trait CreateTxModule: }; } - #[proxy] - fn fee_market_proxy(&self, sc_address: ManagedAddress) -> fee_market::Proxy; + fn require_gas_limit_under_limit(&self, gas_limit: GasLimit) { + let max_gas_limit = self.max_user_tx_gas_limit().get(); + require!(gas_limit <= max_gas_limit, "Gas limit too high"); + } + + fn require_endpoint_not_banned(&self, function: &ManagedBuffer) { + require!( + !self.banned_endpoint_names().contains(function), + "Banned endpoint name" + ); + } #[storage_mapper("feeMarketAddress")] fn fee_market_address(&self) -> SingleValueMapper; @@ -362,7 +251,4 @@ pub trait CreateTxModule: #[storage_mapper("bannedEndpointNames")] fn banned_endpoint_names(&self) -> UnorderedSetMapper; - - #[storage_mapper("feeEnabledFlag")] - fn fee_enabled(&self) -> SingleValueMapper; } diff --git a/esdt-safe/src/to_sovereign/events.rs b/esdt-safe/src/to_sovereign/events.rs index ba1d55a0..15439c68 100644 --- a/esdt-safe/src/to_sovereign/events.rs +++ b/esdt-safe/src/to_sovereign/events.rs @@ -1,6 +1,4 @@ -use transaction::{ - transaction_status::TransactionStatus, BatchId, OperationData, TxId -}; +use transaction::OperationData; multiversx_sc::imports!(); multiversx_sc::derive_imports!(); @@ -9,18 +7,9 @@ multiversx_sc::derive_imports!(); pub trait EventsModule { #[event("deposit")] fn deposit_event( - // TODO: Use ManagedVec of EsdtTokenPaymentInfo(EsdtTokenDataPayment, EsdtTokenData) &self, #[indexed] dest_address: &ManagedAddress, #[indexed] tokens: &MultiValueEncoded>, event_data: OperationData, ); - - #[event("setStatusEvent")] - fn set_status_event( - &self, - #[indexed] batch_id: BatchId, - #[indexed] tx_id: TxId, - #[indexed] tx_status: TransactionStatus, - ); } diff --git a/esdt-safe/src/to_sovereign/mod.rs b/esdt-safe/src/to_sovereign/mod.rs index 72718603..5c2924da 100644 --- a/esdt-safe/src/to_sovereign/mod.rs +++ b/esdt-safe/src/to_sovereign/mod.rs @@ -1,4 +1,2 @@ pub mod create_tx; pub mod events; -pub mod refund; -pub mod set_tx_status; diff --git a/esdt-safe/wasm-esdt-safe-full/src/lib.rs b/esdt-safe/wasm-esdt-safe-full/src/lib.rs index a3f02bbd..83bd0032 100644 --- a/esdt-safe/wasm-esdt-safe-full/src/lib.rs +++ b/esdt-safe/wasm-esdt-safe-full/src/lib.rs @@ -6,10 +6,10 @@ // Init: 1 // Upgrade: 1 -// Endpoints: 39 -// Async Callback: 1 -// Promise callbacks: 1 -// Total number of exported functions: 43 +// Endpoints: 30 +// Async Callback (empty): 1 +// Promise callbacks: 2 +// Total number of exported functions: 35 #![no_std] @@ -23,22 +23,13 @@ multiversx_sc_wasm_adapter::endpoints! { upgrade => upgrade setFeeMarketAddress => set_fee_market_address setHeaderVerifierAddress => set_header_verifier_address - setSovereignBridgeAddress => set_sovereign_bridge_address - setMaxUserTxGasLimit => set_max_user_tx_gas_limit - setBurnAndMint => set_burn_and_mint - removeBurnAndMint => remove_burn_and_mint - addBannedEndpointNames => add_banned_endpoint_names - removeBannedEndpointNames => remove_banned_endpoint_names - depositBack => deposit_back + setMaxTxGasLimit => set_max_user_tx_gas_limit + setBannedEndpoint => set_banned_endpoint deposit => deposit - claimRefund => claim_refund - setTransactionBatchStatus => set_transaction_batch_status setMinValidSigners => set_min_valid_signers addSigners => add_signers removeSigners => remove_signers registerToken => register_token - clearRegisteredSovereignToken => clear_registered_sovereign_token - clearRegisteredMultiversxToken => clear_registered_multiversx_token executeBridgeOps => execute_operations setMaxTxBatchSize => set_max_tx_batch_size setMaxTxBatchBlockDuration => set_max_tx_batch_block_duration @@ -60,8 +51,9 @@ multiversx_sc_wasm_adapter::endpoints! { pause => pause_endpoint unpause => unpause_endpoint isPaused => paused_status + issue_callback => issue_callback execute => execute ) } -multiversx_sc_wasm_adapter::async_callback! { esdt_safe } +multiversx_sc_wasm_adapter::async_callback_empty! {} diff --git a/esdt-safe/wasm/src/lib.rs b/esdt-safe/wasm/src/lib.rs index a3f02bbd..83bd0032 100644 --- a/esdt-safe/wasm/src/lib.rs +++ b/esdt-safe/wasm/src/lib.rs @@ -6,10 +6,10 @@ // Init: 1 // Upgrade: 1 -// Endpoints: 39 -// Async Callback: 1 -// Promise callbacks: 1 -// Total number of exported functions: 43 +// Endpoints: 30 +// Async Callback (empty): 1 +// Promise callbacks: 2 +// Total number of exported functions: 35 #![no_std] @@ -23,22 +23,13 @@ multiversx_sc_wasm_adapter::endpoints! { upgrade => upgrade setFeeMarketAddress => set_fee_market_address setHeaderVerifierAddress => set_header_verifier_address - setSovereignBridgeAddress => set_sovereign_bridge_address - setMaxUserTxGasLimit => set_max_user_tx_gas_limit - setBurnAndMint => set_burn_and_mint - removeBurnAndMint => remove_burn_and_mint - addBannedEndpointNames => add_banned_endpoint_names - removeBannedEndpointNames => remove_banned_endpoint_names - depositBack => deposit_back + setMaxTxGasLimit => set_max_user_tx_gas_limit + setBannedEndpoint => set_banned_endpoint deposit => deposit - claimRefund => claim_refund - setTransactionBatchStatus => set_transaction_batch_status setMinValidSigners => set_min_valid_signers addSigners => add_signers removeSigners => remove_signers registerToken => register_token - clearRegisteredSovereignToken => clear_registered_sovereign_token - clearRegisteredMultiversxToken => clear_registered_multiversx_token executeBridgeOps => execute_operations setMaxTxBatchSize => set_max_tx_batch_size setMaxTxBatchBlockDuration => set_max_tx_batch_block_duration @@ -60,8 +51,9 @@ multiversx_sc_wasm_adapter::endpoints! { pause => pause_endpoint unpause => unpause_endpoint isPaused => paused_status + issue_callback => issue_callback execute => execute ) } -multiversx_sc_wasm_adapter::async_callback! { esdt_safe } +multiversx_sc_wasm_adapter::async_callback_empty! {} From ceed878d333571c5bf35bd2cf55b16388ccbf98c Mon Sep 17 00:00:00 2001 From: Andrei Baltariu Date: Mon, 4 Nov 2024 13:53:53 +0200 Subject: [PATCH 07/15] Added lock logic for operation hash Signed-off-by: Andrei Baltariu --- .../src/from_sovereign/transfer_tokens.rs | 68 ++++++++----------- esdt-safe/src/to_sovereign/create_tx.rs | 2 +- esdt-safe/tests/bridge_blackbox_tests.rs | 22 ++++-- 3 files changed, 44 insertions(+), 48 deletions(-) diff --git a/esdt-safe/src/from_sovereign/transfer_tokens.rs b/esdt-safe/src/from_sovereign/transfer_tokens.rs index 9e2ff236..720fb537 100644 --- a/esdt-safe/src/from_sovereign/transfer_tokens.rs +++ b/esdt-safe/src/from_sovereign/transfer_tokens.rs @@ -7,7 +7,7 @@ use crate::to_sovereign; multiversx_sc::imports!(); const CALLBACK_GAS: GasLimit = 10_000_000; // Increase if not enough -const TRANSACTION_GAS: GasLimit = 30_000_000; +const ESDT_TRANSACTION_GAS: GasLimit = 5_000_000; #[multiversx_sc::module] pub trait TransferTokensModule: @@ -30,12 +30,9 @@ pub trait TransferTokensModule: require!(self.not_paused(), "Cannot transfer while paused"); - let (operation_hash, is_registered) = - self.calculate_operation_hash(&hash_of_hashes, &operation); + let operation_hash = self.calculate_operation_hash(&operation); - if !is_registered { - sc_panic!("Operation is not registered"); - } + self.lock_operation_hash(&operation_hash, &hash_of_hashes); let minted_operation_tokens = self.mint_tokens(&operation.tokens); let operation_tuple = OperationTuple { @@ -74,22 +71,22 @@ pub trait TransferTokensModule: .esdt_local_mint(&mvx_token_id, 0, &operation_token.token_data.amount) .sync_call(); - output_payments.push(OperationEsdtPayment { - token_identifier: mvx_token_id, - token_nonce: 0, - token_data: operation_token.token_data, - }); + output_payments.push(OperationEsdtPayment::new( + mvx_token_id, + 0, + operation_token.token_data, + )); continue; } let nft_nonce = self.esdt_create_and_update_mapper(&mvx_token_id, &operation_token); - output_payments.push(OperationEsdtPayment { - token_identifier: mvx_token_id, - token_nonce: nft_nonce, - token_data: operation_token.token_data, - }); + output_payments.push(OperationEsdtPayment::new( + mvx_token_id, + nft_nonce, + operation_token.token_data, + )); } output_payments @@ -194,7 +191,7 @@ pub trait TransferTokensModule: .to(&operation_tuple.operation.to) .raw_call(ESDT_MULTI_TRANSFER_FUNC_NAME) .payment(&mapped_tokens) - .gas(TRANSACTION_GAS) + .gas(ESDT_TRANSACTION_GAS) .callback( ::callbacks(self) .execute(hash_of_hashes, operation_tuple), @@ -289,16 +286,8 @@ pub trait TransferTokensModule: ); } - // use pending_operations as param - fn calculate_operation_hash( - &self, - hash_of_hashes: &ManagedBuffer, - operation: &Operation, - ) -> (ManagedBuffer, bool) { + fn calculate_operation_hash(&self, operation: &Operation) -> ManagedBuffer { let mut serialized_data = ManagedBuffer::new(); - let header_verifier_address = self.header_verifier_address().get(); - let pending_operations_mapper = - self.external_pending_hashes(header_verifier_address, hash_of_hashes); if let core::result::Result::Err(err) = operation.top_encode(&mut serialized_data) { sc_panic!("Transfer data encode error: {}", err.message_bytes()); @@ -306,11 +295,18 @@ pub trait TransferTokensModule: let sha256 = self.crypto().sha256(&serialized_data); let hash = sha256.as_managed_buffer().clone(); - if pending_operations_mapper.contains(&hash) { - (hash, true) - } else { - (hash, false) - } + + hash + } + + fn lock_operation_hash(&self, operation_hash: &ManagedBuffer, hash_of_hashes: &ManagedBuffer) { + let header_verifier_address = self.header_verifier_address().get(); + + self.tx() + .to(header_verifier_address) + .typed(header_verifier_proxy::HeaderverifierProxy) + .lock_operation_hash(hash_of_hashes, operation_hash) + .sync_call(); } fn get_mvx_nonce_from_mapper(self, token_id: &TokenIdentifier, nonce: u64) -> u64 { @@ -321,16 +317,6 @@ pub trait TransferTokensModule: esdt_info_mapper.get().token_nonce } - #[storage_mapper("pendingHashes")] - fn pending_hashes(&self, hash_of_hashes: &ManagedBuffer) -> UnorderedSetMapper; - #[storage_mapper("headerVerifierAddress")] fn header_verifier_address(&self) -> SingleValueMapper; - - #[storage_mapper_from_address("pendingHashes")] - fn external_pending_hashes( - &self, - sc_address: ManagedAddress, - hash_of_hashes: &ManagedBuffer, - ) -> UnorderedSetMapper; } diff --git a/esdt-safe/src/to_sovereign/create_tx.rs b/esdt-safe/src/to_sovereign/create_tx.rs index ef9dac88..738b2862 100644 --- a/esdt-safe/src/to_sovereign/create_tx.rs +++ b/esdt-safe/src/to_sovereign/create_tx.rs @@ -222,7 +222,7 @@ pub trait CreateTxModule: .typed(fee_market_proxy::FeeMarketProxy) .subtract_fee(caller, total_tokens_for_fees, OptionalValue::Some(gas)) .payment(fee) - .async_call_and_exit(); + .sync_call(); } OptionalValue::None => (), }; diff --git a/esdt-safe/tests/bridge_blackbox_tests.rs b/esdt-safe/tests/bridge_blackbox_tests.rs index a2313502..6bd3b153 100644 --- a/esdt-safe/tests/bridge_blackbox_tests.rs +++ b/esdt-safe/tests/bridge_blackbox_tests.rs @@ -9,10 +9,7 @@ use multiversx_sc::types::{ }; use multiversx_sc::{ imports::{MultiValue3, OptionalValue}, - types::{ - BigUint, EsdtTokenPayment, ManagedBuffer, ManagedVec, ReturnsResult, TestAddress, - TestSCAddress, - }, + types::{BigUint, EsdtTokenPayment, ManagedBuffer, ManagedVec, TestAddress, TestSCAddress}, }; use multiversx_sc_scenario::managed_address; use multiversx_sc_scenario::multiversx_chain_vm::crypto_functions::sha256; @@ -285,7 +282,16 @@ impl BridgeTestState { .to(BRIDGE_ADDRESS) .typed(esdt_safe_proxy::EsdtSafeProxy) .unpause_endpoint() - .returns(ReturnsResult) + .run(); + } + + fn propose_set_esdt_safe_address(&mut self) { + self.world + .tx() + .from(BRIDGE_OWNER_ADDRESS) + .to(HEADER_VERIFIER_ADDRESS) + .typed(header_verifier_proxy::HeaderverifierProxy) + .set_esdt_safe_address(BRIDGE_ADDRESS) .run(); } @@ -392,7 +398,7 @@ fn test_main_to_sov_deposit_ok() { #[test] fn test_execute_operation_not_registered() { let mut state = BridgeTestState::new(); - let err_message = "Operation is not registered"; + let err_message = "The current operation is not registered"; state.deploy_bridge_contract(false); @@ -400,6 +406,8 @@ fn test_execute_operation_not_registered() { state.propose_set_header_verifier_address(); + state.propose_set_esdt_safe_address(); + state.propose_execute_operation_and_expect_err(err_message); } @@ -426,6 +434,8 @@ fn test_execute_operation() { state.propose_set_header_verifier_address(); + state.propose_set_esdt_safe_address(); + state.propose_register_operation(); state.propose_execute_operation(); From 8655c9e37f81ce4bc47c608eb73ec6e534b84941 Mon Sep 17 00:00:00 2001 From: Andrei Baltariu Date: Mon, 4 Nov 2024 13:55:00 +0200 Subject: [PATCH 08/15] Copy paste of Header-Verifier lock logic Signed-off-by: Andrei Baltariu --- header-verifier/src/header_verifier_proxy.rs | 16 ++ header-verifier/src/lib.rs | 68 +++++++-- .../tests/header_verifier_blackbox_test.rs | 142 +++++++++++++++--- .../wasm-header-verifier-full/src/lib.rs | 5 +- header-verifier/wasm/src/lib.rs | 5 +- 5 files changed, 196 insertions(+), 40 deletions(-) diff --git a/header-verifier/src/header_verifier_proxy.rs b/header-verifier/src/header_verifier_proxy.rs index 4f57c709..f850ab26 100644 --- a/header-verifier/src/header_verifier_proxy.rs +++ b/header-verifier/src/header_verifier_proxy.rs @@ -133,6 +133,22 @@ where .original_result() } + pub fn lock_operation_hash< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + >( + self, + hash_of_hashes: Arg0, + operation_hash: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("lockOperationHash") + .argument(&hash_of_hashes) + .argument(&operation_hash) + .original_result() + } + pub fn set_min_valid_signers< Arg0: ProxyArg, >( diff --git a/header-verifier/src/lib.rs b/header-verifier/src/lib.rs index bd51ce17..da861c22 100644 --- a/header-verifier/src/lib.rs +++ b/header-verifier/src/lib.rs @@ -1,11 +1,18 @@ #![no_std] use bls_signature::BlsSignature; - +use multiversx_sc::codec; +use multiversx_sc::proxy_imports::{TopDecode, TopEncode}; pub mod header_verifier_proxy; multiversx_sc::imports!(); +#[derive(TopEncode, TopDecode, PartialEq)] +pub enum OperationHashStatus { + NotLocked = 1, + Locked, +} + #[multiversx_sc::contract] pub trait Headerverifier: bls_signature::BlsSignatureModule { #[init] @@ -25,10 +32,10 @@ pub trait Headerverifier: bls_signature::BlsSignatureModule { bridge_operations_hash: ManagedBuffer, operations_hashes: MultiValueEncoded, ) { + let mut hash_of_hashes_history_mapper = self.hash_of_hashes_history(); + require!( - !self - .hash_of_hashes_history() - .contains(&bridge_operations_hash), + !hash_of_hashes_history_mapper.contains(&bridge_operations_hash), "The OutGoingTxsHash has already been registered" ); @@ -41,11 +48,11 @@ pub trait Headerverifier: bls_signature::BlsSignatureModule { ); for operation_hash in operations_hashes { - self.pending_hashes(&bridge_operations_hash) - .insert(operation_hash); + self.operation_hash_status(&bridge_operations_hash, &operation_hash) + .set(OperationHashStatus::NotLocked); } - self.hash_of_hashes_history().insert(bridge_operations_hash); + hash_of_hashes_history_mapper.insert(bridge_operations_hash); } #[only_owner] @@ -56,19 +63,48 @@ pub trait Headerverifier: bls_signature::BlsSignatureModule { #[endpoint(removeExecutedHash)] fn remove_executed_hash(&self, hash_of_hashes: &ManagedBuffer, operation_hash: &ManagedBuffer) { + self.require_caller_esdt_safe(); + + self.operation_hash_status(hash_of_hashes, operation_hash) + .clear(); + } + + #[endpoint(lockOperationHash)] + fn lock_operation_hash(&self, hash_of_hashes: ManagedBuffer, operation_hash: ManagedBuffer) { + self.require_caller_esdt_safe(); + + let operation_hash_status_mapper = + self.operation_hash_status(&hash_of_hashes, &operation_hash); + require!( - !self.esdt_safe_address().is_empty(), + !operation_hash_status_mapper.is_empty(), + "The current operation is not registered" + ); + + let is_hash_in_execution = operation_hash_status_mapper.get(); + match is_hash_in_execution { + OperationHashStatus::NotLocked => { + operation_hash_status_mapper.set(OperationHashStatus::Locked) + } + OperationHashStatus::Locked => { + sc_panic!("The current operation is already in execution") + } + } + } + + fn require_caller_esdt_safe(&self) { + let esdt_safe_mapper = self.esdt_safe_address(); + + require!( + !esdt_safe_mapper.is_empty(), "There is no registered ESDT address" ); let caller = self.blockchain().get_caller(); require!( - caller == self.esdt_safe_address().get(), + caller == esdt_safe_mapper.get(), "Only ESDT Safe contract can call this endpoint" ); - - self.pending_hashes(hash_of_hashes) - .swap_remove(operation_hash); } fn calculate_and_check_transfers_hashes( @@ -109,8 +145,12 @@ pub trait Headerverifier: bls_signature::BlsSignatureModule { #[storage_mapper("blsPubKeys")] fn bls_pub_keys(&self) -> SetMapper; - #[storage_mapper("pendingHashes")] - fn pending_hashes(&self, hash_of_hashes: &ManagedBuffer) -> UnorderedSetMapper; + #[storage_mapper("operationHashStatus")] + fn operation_hash_status( + &self, + hash_of_hashes: &ManagedBuffer, + operation_hash: &ManagedBuffer, + ) -> SingleValueMapper; #[storage_mapper("hashOfHashesHistory")] fn hash_of_hashes_history(&self) -> UnorderedSetMapper; diff --git a/header-verifier/tests/header_verifier_blackbox_test.rs b/header-verifier/tests/header_verifier_blackbox_test.rs index cdd1cdee..eaaf3725 100644 --- a/header-verifier/tests/header_verifier_blackbox_test.rs +++ b/header-verifier/tests/header_verifier_blackbox_test.rs @@ -1,5 +1,5 @@ use bls_signature::BlsSignature; -use header_verifier::{header_verifier_proxy, Headerverifier}; +use header_verifier::{header_verifier_proxy, Headerverifier, OperationHashStatus}; use multiversx_sc::types::ManagedBuffer; use multiversx_sc::{ api::ManagedTypeApi, @@ -97,7 +97,7 @@ impl HeaderVerifierTestState { &mut self, caller: TestAddress, hash_of_hashes: &ManagedBuffer, - operation_hash: ManagedBuffer, + operation_hash: &ManagedBuffer, expected_result: Option>, ) { let transaction = self @@ -114,6 +114,27 @@ impl HeaderVerifierTestState { } } + fn propose_lock_operation_hash( + &mut self, + caller: TestAddress, + hash_of_hashes: &ManagedBuffer, + operation_hash: &ManagedBuffer, + expected_result: Option>, + ) { + let transaction = self + .world + .tx() + .from(caller) + .to(HEADER_VERIFIER_ADDRESS) + .typed(header_verifier_proxy::HeaderverifierProxy) + .lock_operation_hash(hash_of_hashes, operation_hash); + + match expected_result { + Some(error) => transaction.returns(error).run(), + None => transaction.run(), + } + } + fn get_bls_keys(&mut self, bls_keys_vec: Vec>) -> BlsKeys { let bls_keys = bls_keys_vec.iter().cloned().collect(); @@ -216,14 +237,18 @@ fn test_register_bridge_operation() { assert!(!sc.hash_of_hashes_history().is_empty()); assert!(sc.hash_of_hashes_history().len() == 1); assert!(sc.hash_of_hashes_history().contains(&hash_of_hashes)); - assert!(!sc.pending_hashes(&hash_of_hashes).is_empty()); - - for (mut i, operation_hash) in operation.operations_hashes.into_iter().enumerate() { - i += 1; - let pending_hash = sc.pending_hashes(&hash_of_hashes).get_by_index(i); - let expected_hash_debug_api: ManagedBuffer = - ManagedBuffer::from(operation_hash.to_vec()); - assert_eq!(pending_hash, expected_hash_debug_api); + + for operation_hash in operation.operations_hashes { + let operation_hash_debug_api = ManagedBuffer::from(operation_hash.to_vec()); + + let pending_hashes_mapper = + sc.operation_hash_status(&hash_of_hashes, &operation_hash_debug_api); + + let is_mapper_empty = pending_hashes_mapper.is_empty(); + let is_operation_hash_locked = pending_hashes_mapper.get(); + + assert!(!is_mapper_empty); + assert!(is_operation_hash_locked == OperationHashStatus::NotLocked); } }); } @@ -245,7 +270,7 @@ fn test_remove_executed_hash_caller_not_esdt_address() { state.propose_remove_executed_hash( OWNER, &operation.bridge_operation_hash, - operation_1, + &operation_1, Some(ExpectError( 4, "Only ESDT Safe contract can call this endpoint", @@ -269,7 +294,7 @@ fn test_remove_executed_hash_no_esdt_address_registered() { state.propose_remove_executed_hash( ENSHRINE_ADDRESS, &operation.bridge_operation_hash, - operation_1, + &operation_1, Some(ExpectError(4, "There is no registered ESDT address")), ); } @@ -293,7 +318,7 @@ fn test_remove_one_executed_hash() { state.propose_remove_executed_hash( ENSHRINE_ADDRESS, &operation.bridge_operation_hash, - operation_hash_1, + &operation_hash_1, None, ); @@ -304,14 +329,16 @@ fn test_remove_one_executed_hash() { .whitebox(header_verifier::contract_obj, |sc| { let hash_of_hashes: ManagedBuffer = ManagedBuffer::from(operation.bridge_operation_hash.to_vec()); - assert!(!sc.pending_hashes(&hash_of_hashes).is_empty()); - assert!(sc.pending_hashes(&hash_of_hashes).len() == 1); + let operation_hash_debug_api = ManagedBuffer::from(operation_hash_2.to_vec()); + + let pending_hashes_mapper = + sc.operation_hash_status(&hash_of_hashes, &operation_hash_debug_api); - let pending_hash_2 = sc.pending_hashes(&hash_of_hashes).get_by_index(1); - let expected_hash_2_debug_api: ManagedBuffer = - ManagedBuffer::from(operation_hash_2.to_vec()); + let is_hash_locked = pending_hashes_mapper.get(); + let is_mapper_empty = pending_hashes_mapper.is_empty(); - assert_eq!(pending_hash_2, expected_hash_2_debug_api); + assert!(!is_mapper_empty); + assert!(is_hash_locked == OperationHashStatus::NotLocked); }); } @@ -333,14 +360,14 @@ fn test_remove_all_executed_hashes() { state.propose_remove_executed_hash( ENSHRINE_ADDRESS, &operation.bridge_operation_hash, - operation_1, + &operation_1, None, ); state.propose_remove_executed_hash( ENSHRINE_ADDRESS, &operation.bridge_operation_hash, - operation_2, + &operation_2, None, ); state @@ -350,7 +377,78 @@ fn test_remove_all_executed_hashes() { .whitebox(header_verifier::contract_obj, |sc| { let hash_of_hashes: ManagedBuffer = ManagedBuffer::from(operation.bridge_operation_hash.to_vec()); - assert!(sc.pending_hashes(&hash_of_hashes).is_empty()); + let operation_hash_debug_api_1 = ManagedBuffer::from(operation_1.to_vec()); + let operation_hash_debug_api_2 = ManagedBuffer::from(operation_2.to_vec()); + assert!(sc + .operation_hash_status(&hash_of_hashes, &operation_hash_debug_api_1) + .is_empty()); + assert!(sc + .operation_hash_status(&hash_of_hashes, &operation_hash_debug_api_2) + .is_empty()); assert!(sc.hash_of_hashes_history().contains(&hash_of_hashes)); }); } + +#[test] +fn test_lock_operation_not_registered() { + let mut state = HeaderVerifierTestState::new(); + let bls_key_1 = ManagedBuffer::from("bls_key_1"); + let managed_bls_keys = state.get_bls_keys(vec![bls_key_1]); + + state.deploy_header_verifier_contract(managed_bls_keys); + state.propose_register_esdt_address(ENSHRINE_ADDRESS); + + let operation_1 = ManagedBuffer::from("operation_1"); + let operation_2 = ManagedBuffer::from("operation_2"); + let operation = state.generate_bridge_operation_struct(vec![&operation_1, &operation_2]); + + state.propose_lock_operation_hash( + ENSHRINE_ADDRESS, + &operation.bridge_operation_hash, + &operation_1, + Some(ExpectError(4, "The current operation is not registered")), + ); +} + +#[test] +fn test_lock_operation() { + let mut state = HeaderVerifierTestState::new(); + let bls_key_1 = ManagedBuffer::from("bls_key_1"); + let managed_bls_keys = state.get_bls_keys(vec![bls_key_1]); + + state.deploy_header_verifier_contract(managed_bls_keys); + state.propose_register_esdt_address(ENSHRINE_ADDRESS); + + let operation_1 = ManagedBuffer::from("operation_1"); + let operation_2 = ManagedBuffer::from("operation_2"); + let operation = state.generate_bridge_operation_struct(vec![&operation_1, &operation_2]); + + state.propose_register_operations(operation.clone()); + + state.propose_lock_operation_hash( + ENSHRINE_ADDRESS, + &operation.bridge_operation_hash, + &operation_1, + None, + ); + + state + .world + .query() + .to(HEADER_VERIFIER_ADDRESS) + .whitebox(header_verifier::contract_obj, |sc| { + let hash_of_hashes: ManagedBuffer = + ManagedBuffer::from(operation.bridge_operation_hash.to_vec()); + let operation_hash_debug_api_1 = ManagedBuffer::from(operation_1.to_vec()); + let operation_hash_debug_api_2 = ManagedBuffer::from(operation_2.to_vec()); + let is_hash_1_locked = sc + .operation_hash_status(&hash_of_hashes, &operation_hash_debug_api_1) + .get(); + let is_hash_2_locked = sc + .operation_hash_status(&hash_of_hashes, &operation_hash_debug_api_2) + .get(); + + assert!(is_hash_1_locked == OperationHashStatus::Locked); + assert!(is_hash_2_locked == OperationHashStatus::NotLocked); + }) +} diff --git a/header-verifier/wasm-header-verifier-full/src/lib.rs b/header-verifier/wasm-header-verifier-full/src/lib.rs index 8ae77c80..627b95c0 100644 --- a/header-verifier/wasm-header-verifier-full/src/lib.rs +++ b/header-verifier/wasm-header-verifier-full/src/lib.rs @@ -6,9 +6,9 @@ // Init: 1 // Upgrade: 1 -// Endpoints: 6 +// Endpoints: 7 // Async Callback (empty): 1 -// Total number of exported functions: 9 +// Total number of exported functions: 10 #![no_std] @@ -23,6 +23,7 @@ multiversx_sc_wasm_adapter::endpoints! { registerBridgeOps => register_bridge_operations setEsdtSafeAddress => set_esdt_safe_address removeExecutedHash => remove_executed_hash + lockOperationHash => lock_operation_hash setMinValidSigners => set_min_valid_signers addSigners => add_signers removeSigners => remove_signers diff --git a/header-verifier/wasm/src/lib.rs b/header-verifier/wasm/src/lib.rs index 8ae77c80..627b95c0 100644 --- a/header-verifier/wasm/src/lib.rs +++ b/header-verifier/wasm/src/lib.rs @@ -6,9 +6,9 @@ // Init: 1 // Upgrade: 1 -// Endpoints: 6 +// Endpoints: 7 // Async Callback (empty): 1 -// Total number of exported functions: 9 +// Total number of exported functions: 10 #![no_std] @@ -23,6 +23,7 @@ multiversx_sc_wasm_adapter::endpoints! { registerBridgeOps => register_bridge_operations setEsdtSafeAddress => set_esdt_safe_address removeExecutedHash => remove_executed_hash + lockOperationHash => lock_operation_hash setMinValidSigners => set_min_valid_signers addSigners => add_signers removeSigners => remove_signers From 69571e801c9692c24ef4fd0959e2feba81407715 Mon Sep 17 00:00:00 2001 From: Andrei Baltariu Date: Wed, 13 Nov 2024 08:54:01 +0200 Subject: [PATCH 09/15] FW upgrade Signed-off-by: Andrei Baltariu --- Cargo.lock | 101 +++++++++++++++--- chain-config/Cargo.toml | 6 +- chain-config/meta/Cargo.toml | 2 +- chain-config/wasm/Cargo.lock | 27 +++-- chain-config/wasm/Cargo.toml | 2 +- chain-factory/Cargo.toml | 4 +- chain-factory/meta/Cargo.toml | 2 +- chain-factory/wasm/Cargo.lock | 27 +++-- chain-factory/wasm/Cargo.toml | 2 +- common/bls-signature/Cargo.toml | 4 +- common/max-bridged-amount-module/Cargo.toml | 4 +- common/setup-phase/Cargo.toml | 4 +- common/token-whitelist/Cargo.toml | 4 +- common/transaction/Cargo.toml | 2 +- common/tx-batch-module/Cargo.toml | 4 +- common/utils/Cargo.toml | 2 +- esdt-safe/Cargo.toml | 6 +- esdt-safe/interactor/Cargo.toml | 27 ++--- esdt-safe/meta/Cargo.toml | 2 +- .../src/from_sovereign/transfer_tokens.rs | 2 +- esdt-safe/wasm-esdt-safe-full/Cargo.lock | 27 +++-- esdt-safe/wasm-esdt-safe-full/Cargo.toml | 2 +- esdt-safe/wasm-esdt-safe-view/Cargo.lock | 27 +++-- esdt-safe/wasm-esdt-safe-view/Cargo.toml | 2 +- esdt-safe/wasm/Cargo.lock | 27 +++-- esdt-safe/wasm/Cargo.toml | 2 +- fee-market/Cargo.toml | 4 +- fee-market/meta/Cargo.toml | 2 +- fee-market/wasm-fee-marker-full/Cargo.lock | 23 ++-- fee-market/wasm-fee-marker-full/Cargo.toml | 2 +- fee-market/wasm-multisig-view/Cargo.lock | 23 ++-- fee-market/wasm-multisig-view/Cargo.toml | 2 +- fee-market/wasm/Cargo.lock | 23 ++-- fee-market/wasm/Cargo.toml | 2 +- header-verifier/Cargo.toml | 4 +- header-verifier/meta/Cargo.toml | 2 +- .../wasm-header-verifier-full/Cargo.lock | 23 ++-- .../wasm-header-verifier-full/Cargo.toml | 2 +- header-verifier/wasm-multisig-view/Cargo.lock | 23 ++-- header-verifier/wasm-multisig-view/Cargo.toml | 2 +- header-verifier/wasm/Cargo.lock | 23 ++-- header-verifier/wasm/Cargo.toml | 2 +- 42 files changed, 340 insertions(+), 143 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 82d2ae03..8f9d906f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -122,6 +122,12 @@ dependencies = [ "transaction", ] +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + [[package]] name = "cfg-if" version = "1.0.0" @@ -509,6 +515,12 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "leb128" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" + [[package]] name = "libc" version = "0.2.153" @@ -535,6 +547,16 @@ version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +[[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-chain-scenario-format" version = "0.23.0" @@ -552,9 +574,9 @@ dependencies = [ [[package]] name = "multiversx-chain-vm" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c537d27dfc7a8e295d4f7c5f67a967ce66b6c3fc8e31a160e8cf28e14ecb2d" +checksum = "0d885c04e117cf5ca37303825a578385dbc880ee89890b0649dbbb22ad19dc59" dependencies = [ "bitflags", "colored", @@ -562,6 +584,7 @@ dependencies = [ "hex", "hex-literal", "itertools", + "multiversx-chain-core", "multiversx-chain-vm-executor", "num-bigint", "num-traits", @@ -579,12 +602,13 @@ checksum = "b59072fa0624b55ae5ae3fa6bfa91515bbeb4ac440214bc4a509e2c8806d6e9f" [[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", @@ -617,9 +641,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", @@ -630,9 +654,9 @@ dependencies = [ [[package]] name = "multiversx-sc-meta-lib" -version = "0.53.2" +version = "0.54.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef023806e14a8a6245408c4a7dfdf17d4a1eb39425cedfe50cd2c48f96708ab6" +checksum = "f9e6e7f9091e647e1a51d147de1029c753eef254f5a5c19fc6ecc4c5292359be" dependencies = [ "clap", "colored", @@ -645,24 +669,25 @@ dependencies = [ "serde", "serde_json", "toml", - "wasmparser", + "wasmparser 0.216.0", "wasmprinter", + "wat", ] [[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-scenario" -version = "0.53.2" +version = "0.54.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd16e3bf1f6696d0add36b7b905b1ffdd13b836e584da000f5e265c11e2bfc8d" +checksum = "1eae4de5e3ae0de3631ad0777b97ef14c92d13894a7e55e2d3d304a2e5f40aa5" dependencies = [ "base64", "bech32", @@ -1043,6 +1068,12 @@ version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + [[package]] name = "unwrap-infallible" version = "0.1.5" @@ -1075,6 +1106,16 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasm-encoder" +version = "0.220.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebf48234b389415b226a4daef6562933d38c7b28a8b8f64c5c4130dad1561ab7" +dependencies = [ + "leb128", + "wasmparser 0.220.0", +] + [[package]] name = "wasmparser" version = "0.216.0" @@ -1089,6 +1130,16 @@ dependencies = [ "serde", ] +[[package]] +name = "wasmparser" +version = "0.220.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e246c2772ce3ebc83f89a2d4487ac5794cad6c309b2071818a88c7db7c36d87b" +dependencies = [ + "bitflags", + "indexmap", +] + [[package]] name = "wasmprinter" version = "0.216.0" @@ -1097,7 +1148,29 @@ checksum = "8f82916f3892e53620639217d6ec78fe15c678352a3fbf3f3745b6417d0bd70f" dependencies = [ "anyhow", "termcolor", - "wasmparser", + "wasmparser 0.216.0", +] + +[[package]] +name = "wast" +version = "220.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e708c8de08751fd66e70961a32bae9d71901f14a70871e181cb8461a3bb3165" +dependencies = [ + "bumpalo", + "leb128", + "memchr", + "unicode-width", + "wasm-encoder", +] + +[[package]] +name = "wat" +version = "1.220.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de4f1d7d59614ba690541360102b995c4eb1b9ed373701d5102cc1a968b1c5a3" +dependencies = [ + "wast", ] [[package]] diff --git a/chain-config/Cargo.toml b/chain-config/Cargo.toml index 2c50fa75..2f30c7f5 100644 --- a/chain-config/Cargo.toml +++ b/chain-config/Cargo.toml @@ -12,10 +12,10 @@ path = "src/lib.rs" num-bigint = "0.4.2" [dev-dependencies.multiversx-sc-scenario] -version = "=0.53.2" +version = "=0.54.0" [dependencies.multiversx-sc] -version = "=0.53.2" +version = "=0.54.0" [dependencies.multiversx-sc-modules] -version = "=0.53.2" +version = "=0.54.0" diff --git a/chain-config/meta/Cargo.toml b/chain-config/meta/Cargo.toml index 6b3ac65f..8128b0dd 100644 --- a/chain-config/meta/Cargo.toml +++ b/chain-config/meta/Cargo.toml @@ -11,4 +11,4 @@ authors = ["you"] path = ".." [dependencies.multiversx-sc-meta-lib] -version = "=0.53.2" +version = "=0.54.0" diff --git a/chain-config/wasm/Cargo.lock b/chain-config/wasm/Cargo.lock index ae53e5bc..71f0a3f0 100644 --- a/chain-config/wasm/Cargo.lock +++ b/chain-config/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.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", @@ -93,9 +104,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", @@ -106,18 +117,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/chain-config/wasm/Cargo.toml b/chain-config/wasm/Cargo.toml index 338d37b3..3e4e107a 100644 --- a/chain-config/wasm/Cargo.toml +++ b/chain-config/wasm/Cargo.toml @@ -28,7 +28,7 @@ panic = "abort" path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "=0.53.2" +version = "=0.54.0" [workspace] members = ["."] diff --git a/chain-factory/Cargo.toml b/chain-factory/Cargo.toml index 23f2b3b3..652abd76 100644 --- a/chain-factory/Cargo.toml +++ b/chain-factory/Cargo.toml @@ -12,10 +12,10 @@ path = "src/lib.rs" num-bigint = "0.4.2" [dev-dependencies.multiversx-sc-scenario] -version = "=0.53.2" +version = "=0.54.0" [dependencies.multiversx-sc] -version = "=0.53.2" +version = "=0.54.0" [dependencies.utils] path = "../common/utils" diff --git a/chain-factory/meta/Cargo.toml b/chain-factory/meta/Cargo.toml index cb29aa4c..49bad95a 100644 --- a/chain-factory/meta/Cargo.toml +++ b/chain-factory/meta/Cargo.toml @@ -11,4 +11,4 @@ authors = ["you"] path = ".." [dependencies.multiversx-sc-meta-lib] -version = "=0.53.2" +version = "=0.54.0" diff --git a/chain-factory/wasm/Cargo.lock b/chain-factory/wasm/Cargo.lock index 9ecb087f..6b4bc5f5 100644 --- a/chain-factory/wasm/Cargo.lock +++ b/chain-factory/wasm/Cargo.lock @@ -72,14 +72,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", @@ -111,9 +122,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", @@ -124,18 +135,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/chain-factory/wasm/Cargo.toml b/chain-factory/wasm/Cargo.toml index 29f5c1b8..1cb3ec30 100644 --- a/chain-factory/wasm/Cargo.toml +++ b/chain-factory/wasm/Cargo.toml @@ -28,7 +28,7 @@ panic = "abort" path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "=0.53.2" +version = "=0.54.0" [workspace] members = ["."] diff --git a/common/bls-signature/Cargo.toml b/common/bls-signature/Cargo.toml index 969c2b38..30bf2faf 100644 --- a/common/bls-signature/Cargo.toml +++ b/common/bls-signature/Cargo.toml @@ -5,10 +5,10 @@ authors = ["dorin-iancu "] edition = "2018" [dependencies.multiversx-sc] -version = "=0.53.2" +version = "=0.54.0" [dependencies.transaction] path = "../transaction" [dev-dependencies.multiversx-sc-scenario] -version = "=0.53.2" +version = "=0.54.0" diff --git a/common/max-bridged-amount-module/Cargo.toml b/common/max-bridged-amount-module/Cargo.toml index 02409a83..6436805c 100644 --- a/common/max-bridged-amount-module/Cargo.toml +++ b/common/max-bridged-amount-module/Cargo.toml @@ -5,7 +5,7 @@ authors = ["dorin-iancu "] edition = "2018" [dependencies.multiversx-sc] -version = "=0.53.2" +version = "=0.54.0" [dev-dependencies.multiversx-sc-scenario] -version = "=0.53.2" +version = "=0.54.0" diff --git a/common/setup-phase/Cargo.toml b/common/setup-phase/Cargo.toml index 83128ab1..9ff4aba3 100644 --- a/common/setup-phase/Cargo.toml +++ b/common/setup-phase/Cargo.toml @@ -5,7 +5,7 @@ authors = ["dorin-iancu "] edition = "2018" [dependencies.multiversx-sc] -version = "=0.53.2" +version = "=0.54.0" [dev-dependencies.multiversx-sc-scenario] -version = "=0.53.2" +version = "=0.54.0" diff --git a/common/token-whitelist/Cargo.toml b/common/token-whitelist/Cargo.toml index 9c2320a7..a5bad4a1 100644 --- a/common/token-whitelist/Cargo.toml +++ b/common/token-whitelist/Cargo.toml @@ -14,7 +14,7 @@ path = "../setup-phase" path = "../utils" [dependencies.multiversx-sc] -version = "=0.53.2" +version = "=0.54.0" [dev-dependencies.multiversx-sc-scenario] -version = "=0.53.2" +version = "=0.54.0" diff --git a/common/transaction/Cargo.toml b/common/transaction/Cargo.toml index 1e7a9472..2eb77cd5 100644 --- a/common/transaction/Cargo.toml +++ b/common/transaction/Cargo.toml @@ -8,4 +8,4 @@ edition = "2018" path = "src/lib.rs" [dependencies.multiversx-sc] -version = "=0.53.2" +version = "=0.54.0" diff --git a/common/tx-batch-module/Cargo.toml b/common/tx-batch-module/Cargo.toml index 190c9082..75db54c5 100644 --- a/common/tx-batch-module/Cargo.toml +++ b/common/tx-batch-module/Cargo.toml @@ -5,10 +5,10 @@ authors = ["dorin-iancu "] edition = "2018" [dependencies.multiversx-sc] -version = "=0.53.2" +version = "=0.54.0" [dependencies.transaction] path = "../transaction" [dev-dependencies.multiversx-sc-scenario] -version = "=0.53.2" +version = "=0.54.0" diff --git a/common/utils/Cargo.toml b/common/utils/Cargo.toml index b09521e5..2b60ab45 100644 --- a/common/utils/Cargo.toml +++ b/common/utils/Cargo.toml @@ -11,5 +11,5 @@ path = "src/lib.rs" path = "../bls-signature" [dependencies.multiversx-sc] -version = "=0.53.2" +version = "=0.54.0" features = ["esdt-token-payment-legacy-decode"] diff --git a/esdt-safe/Cargo.toml b/esdt-safe/Cargo.toml index 7550e0f2..c7e4268c 100644 --- a/esdt-safe/Cargo.toml +++ b/esdt-safe/Cargo.toml @@ -36,10 +36,10 @@ path = "../fee-market" path = "../header-verifier" [dependencies.multiversx-sc] -version = "=0.53.2" +version = "=0.54.0" [dependencies.multiversx-sc-modules] -version = "=0.53.2" +version = "=0.54.0" [dev-dependencies] num-bigint = "0.4.2" @@ -47,4 +47,4 @@ num-traits = "0.2" hex = "0.4" [dev-dependencies.multiversx-sc-scenario] -version = "=0.53.2" +version = "=0.54.0" diff --git a/esdt-safe/interactor/Cargo.toml b/esdt-safe/interactor/Cargo.toml index b6256c44..871543da 100644 --- a/esdt-safe/interactor/Cargo.toml +++ b/esdt-safe/interactor/Cargo.toml @@ -1,3 +1,7 @@ +[[bin]] +name = "rust-interact" +path = "src/interactor_main.rs" + [package] name = "rust-interact" version = "0.0.0" @@ -5,9 +9,8 @@ authors = ["you"] edition = "2021" publish = false -[[bin]] -name = "rust-interact" -path = "src/interactor_main.rs" +[dependencies] +toml = "0.8.6" [dependencies.esdt-safe] path = ".." @@ -22,18 +25,18 @@ path = "../../common/tx-batch-module" path = "../../fee-market" [dependencies.multiversx-sc-snippets] -version = "0.53.2" +version = "0.54.0" [dependencies.multiversx-sc] -version = "0.53.2" +version = "0.54.0" [dependencies.multiversx-sc-scenario] -version = "=0.53.2" - -[dependencies] -clap = { version = "4.4.7", features = ["derive"] } -serde = { version = "1.0", features = ["derive"] } -toml = "0.8.6" +version = "=0.54.0" -# [workspace] +[dependencies.clap] +version = "4.4.7" +features = ["derive"] +[dependencies.serde] +version = "1.0" +features = ["derive"] diff --git a/esdt-safe/meta/Cargo.toml b/esdt-safe/meta/Cargo.toml index b242d4ee..ac415d02 100644 --- a/esdt-safe/meta/Cargo.toml +++ b/esdt-safe/meta/Cargo.toml @@ -11,4 +11,4 @@ publish = false path = ".." [dependencies.multiversx-sc-meta-lib] -version = "=0.53.2" +version = "=0.54.0" diff --git a/esdt-safe/src/from_sovereign/transfer_tokens.rs b/esdt-safe/src/from_sovereign/transfer_tokens.rs index 720fb537..7cde06ce 100644 --- a/esdt-safe/src/from_sovereign/transfer_tokens.rs +++ b/esdt-safe/src/from_sovereign/transfer_tokens.rs @@ -1,5 +1,5 @@ -use builtin_func_names::ESDT_MULTI_TRANSFER_FUNC_NAME; use header_verifier::header_verifier_proxy; +use multiversx_sc::api::ESDT_MULTI_TRANSFER_FUNC_NAME; use transaction::{GasLimit, Operation, OperationData, OperationEsdtPayment, OperationTuple}; use crate::to_sovereign; diff --git a/esdt-safe/wasm-esdt-safe-full/Cargo.lock b/esdt-safe/wasm-esdt-safe-full/Cargo.lock index a5162c4b..12d2a31c 100644 --- a/esdt-safe/wasm-esdt-safe-full/Cargo.lock +++ b/esdt-safe/wasm-esdt-safe-full/Cargo.lock @@ -97,14 +97,25 @@ dependencies = [ "multiversx-sc", ] +[[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", @@ -136,9 +147,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", @@ -149,18 +160,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/esdt-safe/wasm-esdt-safe-full/Cargo.toml b/esdt-safe/wasm-esdt-safe-full/Cargo.toml index 167d5173..718f70f9 100644 --- a/esdt-safe/wasm-esdt-safe-full/Cargo.toml +++ b/esdt-safe/wasm-esdt-safe-full/Cargo.toml @@ -28,7 +28,7 @@ panic = "abort" path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "=0.53.2" +version = "=0.54.0" [workspace] members = ["."] diff --git a/esdt-safe/wasm-esdt-safe-view/Cargo.lock b/esdt-safe/wasm-esdt-safe-view/Cargo.lock index b94ceaa7..3bb75c6d 100644 --- a/esdt-safe/wasm-esdt-safe-view/Cargo.lock +++ b/esdt-safe/wasm-esdt-safe-view/Cargo.lock @@ -97,14 +97,25 @@ dependencies = [ "multiversx-sc", ] +[[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", @@ -136,9 +147,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", @@ -149,18 +160,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/esdt-safe/wasm-esdt-safe-view/Cargo.toml b/esdt-safe/wasm-esdt-safe-view/Cargo.toml index 4753497c..0454607f 100644 --- a/esdt-safe/wasm-esdt-safe-view/Cargo.toml +++ b/esdt-safe/wasm-esdt-safe-view/Cargo.toml @@ -28,7 +28,7 @@ panic = "abort" path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "=0.53.2" +version = "=0.54.0" [workspace] members = ["."] diff --git a/esdt-safe/wasm/Cargo.lock b/esdt-safe/wasm/Cargo.lock index f19ccf47..d54e9276 100644 --- a/esdt-safe/wasm/Cargo.lock +++ b/esdt-safe/wasm/Cargo.lock @@ -97,14 +97,25 @@ dependencies = [ "multiversx-sc", ] +[[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", @@ -136,9 +147,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", @@ -149,18 +160,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/esdt-safe/wasm/Cargo.toml b/esdt-safe/wasm/Cargo.toml index f2ef2089..4ec2b576 100644 --- a/esdt-safe/wasm/Cargo.toml +++ b/esdt-safe/wasm/Cargo.toml @@ -28,7 +28,7 @@ panic = "abort" path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "=0.53.2" +version = "=0.54.0" [workspace] members = ["."] diff --git a/fee-market/Cargo.toml b/fee-market/Cargo.toml index f4b3423a..40a568a3 100644 --- a/fee-market/Cargo.toml +++ b/fee-market/Cargo.toml @@ -18,10 +18,10 @@ path = "../common/transaction" path = "../common/bls-signature" [dependencies.multiversx-sc] -version = "=0.53.2" +version = "=0.54.0" [dev-dependencies] num-bigint = "0.4.2" [dev-dependencies.multiversx-sc-scenario] -version = "=0.53.2" +version = "=0.54.0" diff --git a/fee-market/meta/Cargo.toml b/fee-market/meta/Cargo.toml index 41b8b31a..5cc16f7b 100644 --- a/fee-market/meta/Cargo.toml +++ b/fee-market/meta/Cargo.toml @@ -8,5 +8,5 @@ publish = false path = ".." [dependencies.multiversx-sc-meta-lib] -version = "=0.53.2" +version = "=0.54.0" default-features = false diff --git a/fee-market/wasm-fee-marker-full/Cargo.lock b/fee-market/wasm-fee-marker-full/Cargo.lock index 6d42739d..7b77577f 100644 --- a/fee-market/wasm-fee-marker-full/Cargo.lock +++ b/fee-market/wasm-fee-marker-full/Cargo.lock @@ -64,14 +64,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", @@ -103,9 +114,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", @@ -116,9 +127,9 @@ dependencies = [ [[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/fee-market/wasm-fee-marker-full/Cargo.toml b/fee-market/wasm-fee-marker-full/Cargo.toml index d2522cb0..f03a1d84 100644 --- a/fee-market/wasm-fee-marker-full/Cargo.toml +++ b/fee-market/wasm-fee-marker-full/Cargo.toml @@ -28,7 +28,7 @@ panic = "abort" path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "=0.53.2" +version = "=0.54.0" [workspace] members = ["."] diff --git a/fee-market/wasm-multisig-view/Cargo.lock b/fee-market/wasm-multisig-view/Cargo.lock index e72e7c7f..3af841e5 100644 --- a/fee-market/wasm-multisig-view/Cargo.lock +++ b/fee-market/wasm-multisig-view/Cargo.lock @@ -64,14 +64,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.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", @@ -103,9 +114,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", @@ -116,9 +127,9 @@ dependencies = [ [[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/fee-market/wasm-multisig-view/Cargo.toml b/fee-market/wasm-multisig-view/Cargo.toml index 5ede84bd..9923d939 100644 --- a/fee-market/wasm-multisig-view/Cargo.toml +++ b/fee-market/wasm-multisig-view/Cargo.toml @@ -28,7 +28,7 @@ panic = "abort" path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "=0.53.2" +version = "=0.54.0" [workspace] members = ["."] diff --git a/fee-market/wasm/Cargo.lock b/fee-market/wasm/Cargo.lock index 4381e40d..a891b798 100644 --- a/fee-market/wasm/Cargo.lock +++ b/fee-market/wasm/Cargo.lock @@ -64,14 +64,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", @@ -103,9 +114,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", @@ -116,9 +127,9 @@ dependencies = [ [[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/fee-market/wasm/Cargo.toml b/fee-market/wasm/Cargo.toml index 370fa907..cdf095e2 100644 --- a/fee-market/wasm/Cargo.toml +++ b/fee-market/wasm/Cargo.toml @@ -28,7 +28,7 @@ panic = "abort" path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "=0.53.2" +version = "=0.54.0" [workspace] members = ["."] diff --git a/header-verifier/Cargo.toml b/header-verifier/Cargo.toml index 4e5a6c94..1347c179 100644 --- a/header-verifier/Cargo.toml +++ b/header-verifier/Cargo.toml @@ -9,7 +9,7 @@ publish = false path = "src/lib.rs" [dependencies.multiversx-sc] -version = "0.53.2" +version = "0.54.0" [dependencies.bls-signature] path = "../common/bls-signature" @@ -21,4 +21,4 @@ path = "../common/transaction" num-bigint = "0.4.2" [dev-dependencies.multiversx-sc-scenario] -version = "0.53.2" +version = "0.54.0" diff --git a/header-verifier/meta/Cargo.toml b/header-verifier/meta/Cargo.toml index bb33e707..3d50f525 100644 --- a/header-verifier/meta/Cargo.toml +++ b/header-verifier/meta/Cargo.toml @@ -8,5 +8,5 @@ publish = false path = ".." [dependencies.multiversx-sc-meta-lib] -version = "0.53.2" +version = "0.54.0" default-features = false diff --git a/header-verifier/wasm-header-verifier-full/Cargo.lock b/header-verifier/wasm-header-verifier-full/Cargo.lock index f719a19c..6adaa848 100644 --- a/header-verifier/wasm-header-verifier-full/Cargo.lock +++ b/header-verifier/wasm-header-verifier-full/Cargo.lock @@ -63,14 +63,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", @@ -102,9 +113,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", @@ -115,9 +126,9 @@ dependencies = [ [[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/header-verifier/wasm-header-verifier-full/Cargo.toml b/header-verifier/wasm-header-verifier-full/Cargo.toml index bc788ca8..5007a7fa 100644 --- a/header-verifier/wasm-header-verifier-full/Cargo.toml +++ b/header-verifier/wasm-header-verifier-full/Cargo.toml @@ -28,7 +28,7 @@ panic = "abort" path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.53.2" +version = "0.54.0" [workspace] members = ["."] diff --git a/header-verifier/wasm-multisig-view/Cargo.lock b/header-verifier/wasm-multisig-view/Cargo.lock index 93d97a39..6c70bd0b 100644 --- a/header-verifier/wasm-multisig-view/Cargo.lock +++ b/header-verifier/wasm-multisig-view/Cargo.lock @@ -63,14 +63,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.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", @@ -102,9 +113,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", @@ -115,9 +126,9 @@ dependencies = [ [[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/header-verifier/wasm-multisig-view/Cargo.toml b/header-verifier/wasm-multisig-view/Cargo.toml index 640694e4..a8715457 100644 --- a/header-verifier/wasm-multisig-view/Cargo.toml +++ b/header-verifier/wasm-multisig-view/Cargo.toml @@ -28,7 +28,7 @@ panic = "abort" path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.53.2" +version = "0.54.0" [workspace] members = ["."] diff --git a/header-verifier/wasm/Cargo.lock b/header-verifier/wasm/Cargo.lock index 6dd608cb..8a04f786 100644 --- a/header-verifier/wasm/Cargo.lock +++ b/header-verifier/wasm/Cargo.lock @@ -63,14 +63,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", @@ -102,9 +113,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", @@ -115,9 +126,9 @@ dependencies = [ [[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/header-verifier/wasm/Cargo.toml b/header-verifier/wasm/Cargo.toml index 0ea44624..b543f73d 100644 --- a/header-verifier/wasm/Cargo.toml +++ b/header-verifier/wasm/Cargo.toml @@ -28,7 +28,7 @@ panic = "abort" path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.53.2" +version = "0.54.0" [workspace] members = ["."] From d59f7c6702d55fa65e03e679c0787e18f83f4905 Mon Sep 17 00:00:00 2001 From: Andrei Baltariu Date: Wed, 13 Nov 2024 11:15:46 +0200 Subject: [PATCH 10/15] Removed token-whitelist commented code Signed-off-by: Andrei Baltariu --- common/token-whitelist/src/lib.rs | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/common/token-whitelist/src/lib.rs b/common/token-whitelist/src/lib.rs index 56524102..90745a58 100644 --- a/common/token-whitelist/src/lib.rs +++ b/common/token-whitelist/src/lib.rs @@ -8,11 +8,7 @@ pub trait TokenWhitelistModule: { /// Tokens in the whitelist can be transferred without fees #[endpoint(addTokensToWhitelist)] - fn add_tokens_to_whitelist( - &self, - // opt_signature: Option>, - tokens: MultiValueEncoded, - ) { + fn add_tokens_to_whitelist(&self, tokens: MultiValueEncoded) { if !self.is_setup_phase_complete() { self.require_caller_initiator(); self.token_whitelist().extend(tokens); @@ -20,16 +16,11 @@ pub trait TokenWhitelistModule: return; } - // let token_list = self.verify_items_signature(opt_signature, tokens); self.token_whitelist().extend(tokens); } #[endpoint(removeTokensFromWhitelist)] - fn remove_tokens_from_whitelist( - &self, - // opt_signature: Option>, - tokens: MultiValueEncoded, - ) { + fn remove_tokens_from_whitelist(&self, tokens: MultiValueEncoded) { if !self.is_setup_phase_complete() { self.require_caller_initiator(); self.remove_items(&mut self.token_whitelist(), tokens); @@ -37,7 +28,6 @@ pub trait TokenWhitelistModule: return; } - // let token_list = self.verify_items_signature(opt_signature, tokens); self.remove_items(&mut self.token_whitelist(), tokens); } @@ -50,11 +40,7 @@ pub trait TokenWhitelistModule: /// Tokens in blacklist cannot be transferred #[endpoint(addTokensToBlacklist)] - fn add_tokens_to_blacklist( - &self, - // opt_signature: Option>, - tokens: MultiValueEncoded, - ) { + fn add_tokens_to_blacklist(&self, tokens: MultiValueEncoded) { if !self.is_setup_phase_complete() { self.require_caller_initiator(); self.token_blacklist().extend(tokens); @@ -62,7 +48,6 @@ pub trait TokenWhitelistModule: return; } - // let token_list = self.verify_items_signature(opt_signature, tokens); self.token_blacklist().extend(tokens); } From f2c31cdb2992aa5b532a7d612a6f36682ae7a9ea Mon Sep 17 00:00:00 2001 From: Andrei Baltariu Date: Wed, 13 Nov 2024 12:44:51 +0200 Subject: [PATCH 11/15] Added interactor files Signed-off-by: Andrei Baltariu --- esdt-safe/interactor/src/interactor_main.rs | 422 ++++++++++------ .../src/proxies/fee_market_proxy.rs | 278 +++++++++++ .../src/proxies/header_verifier_proxy.rs | 174 +++++++ esdt-safe/interactor/src/proxies/mod.rs | 5 + .../src/proxies/price_aggregator_proxy.rs | 416 ++++++++++++++++ esdt-safe/interactor/src/proxies/proxy.rs | 458 ++++++++++++++++++ .../src/proxies/testing_sc_proxy.rs | 95 ++++ esdt-safe/interactor/state.toml | 9 +- 8 files changed, 1712 insertions(+), 145 deletions(-) create mode 100644 esdt-safe/interactor/src/proxies/fee_market_proxy.rs create mode 100644 esdt-safe/interactor/src/proxies/header_verifier_proxy.rs create mode 100644 esdt-safe/interactor/src/proxies/mod.rs create mode 100644 esdt-safe/interactor/src/proxies/price_aggregator_proxy.rs create mode 100644 esdt-safe/interactor/src/proxies/proxy.rs create mode 100644 esdt-safe/interactor/src/proxies/testing_sc_proxy.rs diff --git a/esdt-safe/interactor/src/interactor_main.rs b/esdt-safe/interactor/src/interactor_main.rs index 536cb988..74dc900c 100644 --- a/esdt-safe/interactor/src/interactor_main.rs +++ b/esdt-safe/interactor/src/interactor_main.rs @@ -2,26 +2,31 @@ // TODO: Remove this when interactor setup is complete #![allow(dead_code)] -mod price_aggregator_proxy; -mod proxy; +mod proxies; use fee_market::fee_market_proxy::FeeMarketProxy; use fee_market::fee_market_proxy::{self, FeeStruct, FeeType}; -use multiversx_sc_scenario::multiversx_chain_vm::crypto_functions::sha256; +use header_verifier_proxy::HeaderverifierProxy; +use multiversx_sc_scenario::meta::tools::find_current_workspace; +use multiversx_sc_scenario::multiversx_chain_vm::crypto_functions::{sha256, SHA256_RESULT_LEN}; +use multiversx_sc_scenario::scenario_model::TxResponseStatus; use multiversx_sc_snippets::imports::*; -use multiversx_sc_snippets::sdk; +use multiversx_sc_snippets::sdk::{self}; +use proxies::*; use serde::{Deserialize, Serialize}; use std::{ io::{Read, Write}, path::Path, }; -use transaction::OperationEsdtPayment; +use testing_sc_proxy::TestingScProxy; use transaction::{GasLimit, Operation, OperationData, PaymentsVec}; - +use transaction::{OperationEsdtPayment, TransferData}; const GATEWAY: &str = sdk::gateway::DEVNET_GATEWAY; const STATE_FILE: &str = "state.toml"; -const TOKEN_ID: &[u8] = b"SVT-805b28"; +const TOKEN_ID: &[u8] = b"SOV-101252"; +const TOKEN_ID_FOR_EXECUTE: &[u8] = b"x-SOV-101252"; const WHITELISTED_TOKEN_ID: &[u8] = b"CHOCOLATE-daf625"; +const INTERACTOR_SCENARIO_TRACE_PATH: &str = "interactor_trace.scen.json"; type OptionalTransferData = OptionalValue, ManagedVec>>>; @@ -44,7 +49,7 @@ async fn main() { "addSigners" => interact.add_signers().await, "removeSigners" => interact.remove_signers().await, "registerToken" => interact.register_token().await, - "executeBridgeOps" => interact.execute_operations().await, + // "executeBridgeOps" => interact.execute_operations().await, "setMaxTxBatchSize" => interact.set_max_tx_batch_size().await, "setMaxTxBatchBlockDuration" => interact.set_max_tx_batch_block_duration().await, "getCurrentTxBatch" => interact.get_current_tx_batch().await, @@ -75,6 +80,7 @@ struct State { fee_market_address: Option, price_aggregator_address: Option, header_verifier_address: Option, + testing_sc_address: Option, } impl State { @@ -107,12 +113,28 @@ impl State { self.header_verifier_address = Some(address); } + pub fn set_testing_sc_address(&mut self, address: Bech32Address) { + self.testing_sc_address = Some(address); + } + /// Returns the contract address pub fn current_address(&self) -> &Bech32Address { self.contract_address .as_ref() .expect("no known contract, deploy first") } + + pub fn get_header_verifier_address(&self) -> Address { + self.header_verifier_address.clone().unwrap().to_address() + } + + pub fn get_fee_market_address(&self) -> Address { + self.fee_market_address.clone().unwrap().to_address() + } + + pub fn get_testing_sc_address(&self) -> Address { + self.testing_sc_address.clone().unwrap().to_address() + } } impl Drop for State { @@ -127,62 +149,70 @@ impl Drop for State { struct ContractInteract { interactor: Interactor, wallet_address: Address, - bob_address: Address, + frank_address: Address, alice_address: Address, mike_address: Address, judy_address: Address, - contract_code: BytesValue, - fee_market_code: BytesValue, - price_aggregator_code: BytesValue, - header_verifier_code: BytesValue, + esdt_safe_code: String, + fee_market_code: String, + price_aggregator_code: String, + header_verifier_code: String, + testing_sc_code: String, state: State, } impl ContractInteract { async fn new() -> Self { - let mut interactor = Interactor::new(GATEWAY).await; - let wallet_address = interactor.register_wallet(test_wallets::frank()); - let bob_address = interactor.register_wallet(test_wallets::bob()); - let alice_address = interactor.register_wallet(test_wallets::alice()); - let mike_address = interactor.register_wallet(test_wallets::mike()); - let judy_address = interactor.register_wallet(test_wallets::judy()); - - let contract_code = BytesValue::interpret_from( - "mxsc:../output/esdt-safe.mxsc.json", - &InterpreterContext::default(), - ); - - let fee_market_code = BytesValue::interpret_from( - "mxsc:contract-codes/fee-market.mxsc.json", - &InterpreterContext::default(), - ); - - let price_aggregator_code = BytesValue::interpret_from( - "mxsc:contract-codes/multiversx-price-aggregator-sc.mxsc.json", - &InterpreterContext::default(), - ); - - let header_verifier_code = BytesValue::interpret_from( - "mxsc:contract-codes/header-verifier.mxsc.json", - &InterpreterContext::default(), - ); + let mut interactor = Interactor::new(GATEWAY, false).await; + + interactor.set_current_dir_from_workspace("esdt-safe/interactor"); + + let wallet_address = interactor.register_wallet(test_wallets::bob()).await; + let frank_address = interactor.register_wallet(test_wallets::frank()).await; + let alice_address = interactor.register_wallet(test_wallets::alice()).await; + let mike_address = interactor.register_wallet(test_wallets::mike()).await; + let judy_address = interactor.register_wallet(test_wallets::judy()).await; + + let current_dir = find_current_workspace().unwrap(); + println!("Current directory is: {}", current_dir.display()); + + let repo_dir = current_dir + .ancestors() + .nth(2) + .expect("Failed to go up 2 levels"); + println!("Repo directory is: {}", repo_dir.display()); + + let fee_market_code = "../../fee-market/output/fee-market.mxsc.json".to_owned(); + + let header_verifier_code = + "../../header-verifier/output/header-verifier.mxsc.json".to_owned(); + + let esdt_safe_code = "../output/esdt-safe.mxsc.json".to_owned(); + + let price_aggregator_code = + "contract-codes/multiversx-price-aggregator-sc.mxsc.json".to_owned(); + + let testing_sc_code = "../../testing-sc/output/testing-sc.mxsc.json".to_owned(); ContractInteract { interactor, wallet_address, - bob_address, + frank_address, alice_address, mike_address, judy_address, - contract_code, + esdt_safe_code, fee_market_code, price_aggregator_code, header_verifier_code, + testing_sc_code, state: State::load_state(), } } async fn deploy(&mut self, is_sov_chain: bool) { + let code_path = MxscPath::new(self.esdt_safe_code.as_ref()); + let new_address = self .interactor .tx() @@ -190,11 +220,11 @@ impl ContractInteract { .gas(110_000_000u64) .typed(proxy::EsdtSafeProxy) .init(is_sov_chain) - .code(&self.contract_code) + .code(code_path) .returns(ReturnsNewAddress) - .prepare_async() .run() .await; + let new_address_bech32 = bech32::encode(&new_address); self.state.set_address(Bech32Address::from_bech32_string( new_address_bech32.clone(), @@ -213,6 +243,7 @@ impl ContractInteract { }, }; + let fee_market_code_path = MxscPath::new(&self.fee_market_code); let new_address = self .interactor .tx() @@ -220,11 +251,11 @@ impl ContractInteract { .gas(100_000_000u64) .typed(fee_market_proxy::FeeMarketProxy) .init(self.state.current_address(), Option::Some(fee)) - .code(&self.fee_market_code) + .code(fee_market_code_path) .returns(ReturnsNewAddress) - .prepare_async() .run() .await; + let new_address_bech32 = bech32::encode(&new_address); self.state .set_fee_market_address(Bech32Address::from_bech32_string( @@ -234,8 +265,9 @@ impl ContractInteract { } async fn deploy_price_aggregator(&mut self) { + let price_agggregator_code_path = MxscPath::new(&self.price_aggregator_code); let mut oracles = MultiValueEncoded::new(); - let first_oracle_adress = managed_address!(&self.bob_address.clone()); + let first_oracle_adress = managed_address!(&self.frank_address.clone()); let second_oracle_adress = managed_address!(&self.alice_address.clone()); let third_oracle_adress = managed_address!(&self.mike_address.clone()); let forth_oracle_address = managed_address!(&self.judy_address.clone()); @@ -258,11 +290,11 @@ impl ContractInteract { 3u8, oracles, ) - .code(&self.price_aggregator_code) + .code(price_agggregator_code_path) .returns(ReturnsNewAddress) - .prepare_async() .run() .await; + let new_address_bech32 = bech32::encode(&new_address); self.state .set_price_aggregator_address(Bech32Address::from_bech32_string( @@ -272,18 +304,20 @@ impl ContractInteract { } async fn deploy_header_verifier_contract(&mut self) { + let header_verifier_code_path = MxscPath::new(&self.header_verifier_code); + let new_address = self .interactor .tx() .from(&self.wallet_address) .gas(100_000_000u64) - .typed(proxy::EsdtSafeProxy) - .init(false) - .code(&self.header_verifier_code) + .typed(header_verifier_proxy::HeaderverifierProxy) + .init(MultiValueEncoded::new()) + .code(header_verifier_code_path) .returns(ReturnsNewAddress) - .prepare_async() .run() .await; + let new_address_bech32 = bech32::encode(&new_address); self.state .set_header_verifier_address(Bech32Address::from_bech32_string( @@ -293,7 +327,49 @@ impl ContractInteract { println!("new header_verifier_address: {new_address_bech32}"); } + async fn deploy_testing_contract(&mut self) { + let testing_sc_code_path = MxscPath::new(&self.testing_sc_code); + + let new_address = self + .interactor + .tx() + .from(&self.wallet_address) + .gas(100_000_000u64) + .typed(TestingScProxy) + .init() + .code(testing_sc_code_path) + .returns(ReturnsNewAddress) + .run() + .await; + + let new_address_bech32 = bech32::encode(&new_address); + self.state + .set_testing_sc_address(Bech32Address::from_bech32_string( + new_address_bech32.clone(), + )); + + println!("new testing_sc_address: {new_address_bech32}"); + } + + async fn call_hello_endpoint(&mut self, value: u64) { + let response = self + .interactor + .tx() + .from(&self.wallet_address) + .to(&self.state.get_testing_sc_address()) + .gas(50_000_000u64) + .typed(TestingScProxy) + .hello(value) + .returns(ReturnsResultUnmanaged) + .run() + .await; + + println!("Result: {response:?}"); + } + async fn upgrade(&mut self) { + let code_path = MxscPath::new(&self.esdt_safe_code); + let response = self .interactor .tx() @@ -302,10 +378,9 @@ impl ContractInteract { .gas(30_000_000u64) .typed(proxy::EsdtSafeProxy) .upgrade() - .code(&self.contract_code) + .code(code_path) .code_metadata(CodeMetadata::UPGRADEABLE) .returns(ReturnsNewAddress) - .prepare_async() .run() .await; @@ -323,7 +398,6 @@ impl ContractInteract { .typed(proxy::EsdtSafeProxy) .set_fee_market_address(fee_market_address) .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; @@ -342,7 +416,6 @@ impl ContractInteract { .typed(proxy::EsdtSafeProxy) .set_header_verifier_address(header_verifier_address) .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; @@ -358,7 +431,7 @@ impl ContractInteract { let token_nonce = 0u64; let token_amount = BigUint::::from(20u64); - let to = &self.bob_address; + let to = &self.frank_address; let mut payments = PaymentsVec::new(); payments.push(EsdtTokenPayment::new( TokenIdentifier::from(token_id), @@ -377,7 +450,6 @@ impl ContractInteract { .deposit(to, transfer_data) .payment(payments) .returns(error) - .prepare_async() .run() .await; } @@ -391,7 +463,6 @@ impl ContractInteract { .deposit(to, transfer_data) .payment(payments) .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; } @@ -410,7 +481,6 @@ impl ContractInteract { .typed(proxy::EsdtSafeProxy) .set_min_valid_signers(new_value) .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; @@ -429,7 +499,6 @@ impl ContractInteract { .typed(proxy::EsdtSafeProxy) .add_signers(signers) .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; @@ -448,7 +517,6 @@ impl ContractInteract { .typed(proxy::EsdtSafeProxy) .remove_signers(signers) .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; @@ -458,10 +526,10 @@ impl ContractInteract { async fn register_token(&mut self) { let egld_amount = BigUint::::from(50_000_000_000_000_000u64); - let sov_token_id = TokenIdentifier::from_esdt_bytes(&b"SOV"[..]); + let sov_token_id = TokenIdentifier::from_esdt_bytes(b"x-SOV-101252"); let token_type = EsdtTokenType::Fungible; - let token_display_name = ManagedBuffer::new_from_bytes(&b"SOVEREIGN"[..]); - let token_ticker = ManagedBuffer::new_from_bytes(&b"SVCT"[..]); + let token_display_name = ManagedBuffer::new_from_bytes(b"TESDT"); + let token_ticker = ManagedBuffer::new_from_bytes(b"TEST"); let num_decimals = 18u32; let response = self @@ -480,40 +548,42 @@ impl ContractInteract { ) .egld(egld_amount) .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; println!("Result: {response:?}"); } - async fn execute_operations(&mut self) { - let (tokens, data) = self.setup_payments().await; - let to = managed_address!(&self.bob_address); - let operation = Operation::new(to, tokens, data); - let operation_hash = self.get_operation_hash(&operation).await; + async fn execute_operations( + &mut self, + operation: &Operation, + expect_error: Option, + ) { + let hash_of_hashes = sha256(&self.get_operation_hash(operation)); let response = self .interactor .tx() .from(&self.wallet_address) .to(self.state.current_address()) - .gas(30_000_000u64) + .gas(70_000_000u64) .typed(proxy::EsdtSafeProxy) - .execute_operations(operation_hash, operation) - .returns(ReturnsResultUnmanaged) - .prepare_async() + .execute_operations(&hash_of_hashes, operation) + .returns(ReturnsHandledOrError::new().returns(ReturnsResultUnmanaged)) .run() .await; - println!("Result: {response:?}"); + if let Err(err) = response { + assert!(err == expect_error.unwrap()); + } } async fn execute_operations_with_error(&mut self, error_msg: ExpectError<'_>) { - let (tokens, data) = self.setup_payments().await; - let to = managed_address!(&self.bob_address); - let operation = Operation::new(to, tokens, data); - let operation_hash = self.get_operation_hash(&operation).await; + let tokens = self.setup_payments().await; + let operation_data = self.setup_operation_data(false).await; + let to = managed_address!(&self.frank_address); + let operation = Operation::new(to, tokens, operation_data); + let operation_hash = self.get_operation_hash(&operation); let response = self .interactor @@ -522,9 +592,8 @@ impl ContractInteract { .to(self.state.current_address()) .gas(30_000_000u64) .typed(proxy::EsdtSafeProxy) - .execute_operations(operation_hash, operation) + .execute_operations(&operation_hash, operation) .returns(error_msg) - .prepare_async() .run() .await; @@ -543,7 +612,6 @@ impl ContractInteract { .typed(proxy::EsdtSafeProxy) .set_max_tx_batch_size(new_max_tx_batch_size) .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; @@ -562,7 +630,6 @@ impl ContractInteract { .typed(proxy::EsdtSafeProxy) .set_max_tx_batch_block_duration(new_max_tx_batch_block_duration) .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; @@ -577,7 +644,6 @@ impl ContractInteract { .typed(proxy::EsdtSafeProxy) .get_current_tx_batch() .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; } @@ -590,7 +656,6 @@ impl ContractInteract { .typed(proxy::EsdtSafeProxy) .get_first_batch_any_status() .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; } @@ -605,7 +670,6 @@ impl ContractInteract { .typed(proxy::EsdtSafeProxy) .get_batch(batch_id) .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; } @@ -619,7 +683,6 @@ impl ContractInteract { .typed(proxy::EsdtSafeProxy) .get_batch_status(batch_id) .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; } @@ -632,7 +695,6 @@ impl ContractInteract { .typed(proxy::EsdtSafeProxy) .first_batch_id() .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; @@ -647,7 +709,6 @@ impl ContractInteract { .typed(proxy::EsdtSafeProxy) .last_batch_id() .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; @@ -667,7 +728,6 @@ impl ContractInteract { .typed(proxy::EsdtSafeProxy) .set_max_bridged_amount(token_id, max_amount) .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; @@ -684,7 +744,6 @@ impl ContractInteract { .typed(proxy::EsdtSafeProxy) .max_bridged_amount(token_id) .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; @@ -701,7 +760,6 @@ impl ContractInteract { .typed(proxy::EsdtSafeProxy) .end_setup_phase() .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; @@ -720,7 +778,6 @@ impl ContractInteract { .typed(proxy::EsdtSafeProxy) .add_tokens_to_whitelist(tokens) .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; @@ -739,7 +796,6 @@ impl ContractInteract { .typed(proxy::EsdtSafeProxy) .remove_tokens_from_whitelist(tokens) .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; @@ -758,7 +814,6 @@ impl ContractInteract { .typed(proxy::EsdtSafeProxy) .add_tokens_to_blacklist(tokens) .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; @@ -777,7 +832,6 @@ impl ContractInteract { .typed(proxy::EsdtSafeProxy) .remove_tokens_from_blacklist(tokens) .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; @@ -792,7 +846,6 @@ impl ContractInteract { .typed(proxy::EsdtSafeProxy) .token_whitelist() .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; @@ -807,7 +860,6 @@ impl ContractInteract { .typed(proxy::EsdtSafeProxy) .token_blacklist() .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; @@ -824,7 +876,6 @@ impl ContractInteract { .typed(proxy::EsdtSafeProxy) .pause_endpoint() .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; @@ -841,7 +892,6 @@ impl ContractInteract { .typed(proxy::EsdtSafeProxy) .unpause_endpoint() .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; @@ -856,7 +906,6 @@ impl ContractInteract { .typed(proxy::EsdtSafeProxy) .paused_status() .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; @@ -868,81 +917,172 @@ impl ContractInteract { .interactor .tx() .from(&self.wallet_address) - .to(self.state.fee_market_address.clone().unwrap().as_address()) + .to(self.state.get_fee_market_address()) .gas(30_000_000u64) .typed(FeeMarketProxy) .remove_fee(TOKEN_ID) .returns(ReturnsResultUnmanaged) - .prepare_async() .run() .await; println!("Result: {response:?}"); } - async fn setup_payments( - &mut self, - ) -> ( - ManagedVec>, - OperationData, - ) { + async fn header_verifier_set_esdt_address(&mut self) { + let response = self + .interactor + .tx() + .from(&self.wallet_address) + .to(self.state.get_header_verifier_address()) + .gas(30_000_000u64) + .typed(HeaderverifierProxy) + .set_esdt_safe_address(self.state.current_address()) + .run() + .await; + + println!("Result: {response:?}"); + } + + async fn setup_operation(&mut self, has_transfer_data: bool) -> Operation { + let to = managed_address!(&self.state.get_testing_sc_address()); + let payments = self.setup_payments().await; + + let operation_data = self.setup_operation_data(has_transfer_data).await; + + Operation::new(to, payments, operation_data) + } + + async fn setup_operation_data(&mut self, has_transfer_data: bool) -> OperationData { + let op_sender = managed_address!(&self.wallet_address); + + let transfer_data = if has_transfer_data { + let mut args = ManagedVec::new(); + let value = BigUint::::from(0u64); + args.push(ManagedBuffer::from(value.to_bytes_be())); + + Some(TransferData::new( + 30_000_000u64, + ManagedBuffer::from("hello"), + args, + )) + } else { + None + }; + + let operation_data: OperationData = OperationData { + op_nonce: 1, + op_sender, + opt_transfer_data: transfer_data, + }; + + operation_data + } + + async fn register_operations(&mut self, operation: &Operation) { + let bls_signature = ManagedByteArray::default(); + let operation_hash = self.get_operation_hash(operation); + let hash_of_hashes = sha256(&operation_hash); + + let mut managed_operation_hashes = + MultiValueEncoded::>::new(); + + let managed_operation_hash = ManagedBuffer::::from(&operation_hash); + let managed_hash_of_hashes = ManagedBuffer::::from(&hash_of_hashes); + + managed_operation_hashes.push(managed_operation_hash); + + let header_verifier_address = self.state.get_header_verifier_address(); + + let response = self + .interactor + .tx() + .from(&self.wallet_address) + .to(header_verifier_address) + .typed(header_verifier_proxy::HeaderverifierProxy) + .register_bridge_operations( + bls_signature, + managed_hash_of_hashes, + managed_operation_hashes, + ) + .returns(ReturnsResult) + .run() + .await; + + println!("Result: {response:?}"); + } + + async fn setup_payments(&mut self) -> ManagedVec> { let mut tokens: ManagedVec> = ManagedVec::new(); - let token_ids = vec![TOKEN_ID]; + let token_ids = vec![TOKEN_ID_FOR_EXECUTE]; for token_id in token_ids { let payment: OperationEsdtPayment = OperationEsdtPayment { token_identifier: token_id.into(), - token_nonce: 1, - token_data: EsdtTokenData::default(), + token_nonce: 0, + token_data: EsdtTokenData { + token_type: EsdtTokenType::Fungible, + amount: BigUint::from(10_000u64), + frozen: false, + hash: ManagedBuffer::new(), + name: ManagedBuffer::from("SovToken"), + attributes: ManagedBuffer::new(), + creator: managed_address!(&self.frank_address), + royalties: BigUint::zero(), + uris: ManagedVec::new(), + }, }; tokens.push(payment); } - let op_sender = managed_address!(&self.wallet_address); - let data: OperationData = OperationData { - op_nonce: 1, - op_sender, - opt_transfer_data: Option::None, - }; - - (tokens, data) + tokens } - async fn get_operation_hash( - &mut self, - operation: &Operation, - ) -> ManagedBuffer { + fn get_operation_hash(&mut self, operation: &Operation) -> [u8; SHA256_RESULT_LEN] { let mut serialized_operation: ManagedBuffer = ManagedBuffer::new(); let _ = operation.top_encode(&mut serialized_operation); - let sha256 = sha256(&serialized_operation.to_vec()); - - ManagedBuffer::new_from_bytes(&sha256) + sha256(&serialized_operation.to_vec()) } -} -#[tokio::test] -#[ignore] -async fn test_deploy() { - let mut interact = ContractInteract::new().await; - interact.deploy(false).await; - interact.deploy_price_aggregator().await; - interact.deploy_fee_market().await; - interact.set_fee_market_address().await; - interact.remove_fee().await; - interact.unpause_endpoint().await; + fn get_hash(&mut self, operation: &ManagedBuffer) -> ManagedBuffer { + let mut array = [0; 1024]; + + let len = { + let byte_array = operation.load_to_byte_array(&mut array); + byte_array.len() + }; + + let trimmed_slice = &array[..len]; + let hash = sha256(trimmed_slice); + + ManagedBuffer::from(&hash) + } } #[tokio::test] #[ignore] async fn test_deploy_sov() { let mut interact = ContractInteract::new().await; - interact.deploy(true).await; - interact.deploy_price_aggregator().await; + interact.deploy(false).await; interact.deploy_fee_market().await; interact.set_fee_market_address().await; interact.remove_fee().await; interact.deploy_header_verifier_contract().await; interact.set_header_verifier_address().await; interact.unpause_endpoint().await; + interact.header_verifier_set_esdt_address().await; + interact.deploy_testing_contract().await; + interact.register_token().await; + + let operation = interact.setup_operation(true).await; + interact.register_operations(&operation).await; + interact + .execute_operations( + &operation, + Some(TxResponseStatus::new( + ReturnCode::UserError, + "Value should be greater than 0", + )), + ) + .await; } diff --git a/esdt-safe/interactor/src/proxies/fee_market_proxy.rs b/esdt-safe/interactor/src/proxies/fee_market_proxy.rs new file mode 100644 index 00000000..b595c0f6 --- /dev/null +++ b/esdt-safe/interactor/src/proxies/fee_market_proxy.rs @@ -0,0 +1,278 @@ +// 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 FeeMarketProxy; + +impl TxProxyTrait for FeeMarketProxy +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + type TxProxyMethods = FeeMarketProxyMethods; + + fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { + FeeMarketProxyMethods { wrapped_tx: tx } + } +} + +pub struct FeeMarketProxyMethods +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + wrapped_tx: Tx, +} + +#[rustfmt::skip] +impl FeeMarketProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + Gas: TxGas, +{ + pub fn init< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + Arg2: ProxyArg>>, + >( + self, + esdt_safe_address: Arg0, + price_aggregator_address: Arg1, + fee: Arg2, + ) -> TxTypedDeploy { + self.wrapped_tx + .payment(NotPayable) + .raw_deploy() + .argument(&esdt_safe_address) + .argument(&price_aggregator_address) + .argument(&fee) + .original_result() + } +} + +#[rustfmt::skip] +impl FeeMarketProxyMethods +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 FeeMarketProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn set_fee< + Arg0: ProxyArg>, + >( + self, + fee_struct: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("addFee") + .argument(&fee_struct) + .original_result() + } + + pub fn disable_fee< + Arg0: ProxyArg>, + >( + self, + base_token: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("removeFee") + .argument(&base_token) + .original_result() + } + + pub fn token_fee< + Arg0: ProxyArg>, + >( + self, + token_id: Arg0, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getTokenFee") + .argument(&token_id) + .original_result() + } + + 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() + } + + /// Percentages have to be between 0 and 10_000, and must all add up to 100% (i.e. 10_000) + pub fn distribute_fees< + Arg0: ProxyArg, usize>>>, + >( + self, + address_percentage_pairs: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("distributeFees") + .argument(&address_percentage_pairs) + .original_result() + } + + pub fn subtract_fee< + Arg0: ProxyArg>, + Arg1: ProxyArg, + Arg2: ProxyArg>, + >( + self, + original_caller: Arg0, + total_transfers: Arg1, + opt_gas_limit: Arg2, + ) -> TxTypedCall> { + self.wrapped_tx + .raw_call("subtractFee") + .argument(&original_caller) + .argument(&total_transfers) + .argument(&opt_gas_limit) + .original_result() + } + + pub fn users_whitelist( + self, + ) -> TxTypedCall>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getUsersWhitelist") + .original_result() + } + + pub fn set_min_valid_signers< + Arg0: ProxyArg, + >( + self, + new_value: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setMinValidSigners") + .argument(&new_value) + .original_result() + } + + pub fn add_signers< + Arg0: ProxyArg>>, + >( + self, + signers: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("addSigners") + .argument(&signers) + .original_result() + } + + pub fn remove_signers< + Arg0: ProxyArg>>, + >( + self, + signers: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("removeSigners") + .argument(&signers) + .original_result() + } +} + +#[type_abi] +#[derive(TopDecode, TopEncode, NestedEncode, NestedDecode, Clone)] +pub struct FeeStruct +where + Api: ManagedTypeApi, +{ + pub base_token: TokenIdentifier, + pub fee_type: FeeType, +} + +#[rustfmt::skip] +#[type_abi] +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, Clone)] +pub enum FeeType +where + Api: ManagedTypeApi, +{ + None, + Fixed { + token: TokenIdentifier, + per_transfer: BigUint, + per_gas: BigUint, + }, + AnyToken { + base_fee_token: TokenIdentifier, + per_transfer: BigUint, + per_gas: BigUint, + }, +} + +#[type_abi] +#[derive(TopEncode, TopDecode)] +pub struct FinalPayment +where + Api: ManagedTypeApi, +{ + pub fee: EsdtTokenPayment, + pub remaining_tokens: EsdtTokenPayment, +} diff --git a/esdt-safe/interactor/src/proxies/header_verifier_proxy.rs b/esdt-safe/interactor/src/proxies/header_verifier_proxy.rs new file mode 100644 index 00000000..4f57c709 --- /dev/null +++ b/esdt-safe/interactor/src/proxies/header_verifier_proxy.rs @@ -0,0 +1,174 @@ +// 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 HeaderverifierProxy; + +impl TxProxyTrait for HeaderverifierProxy +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + type TxProxyMethods = HeaderverifierProxyMethods; + + fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { + HeaderverifierProxyMethods { wrapped_tx: tx } + } +} + +pub struct HeaderverifierProxyMethods +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + wrapped_tx: Tx, +} + +#[rustfmt::skip] +impl HeaderverifierProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + Gas: TxGas, +{ + pub fn init< + Arg0: ProxyArg>>, + >( + self, + bls_pub_keys: Arg0, + ) -> TxTypedDeploy { + self.wrapped_tx + .payment(NotPayable) + .raw_deploy() + .argument(&bls_pub_keys) + .original_result() + } +} + +#[rustfmt::skip] +impl HeaderverifierProxyMethods +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 HeaderverifierProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn register_bridge_operations< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + Arg2: ProxyArg>>, + >( + self, + signature: Arg0, + bridge_operations_hash: Arg1, + operations_hashes: Arg2, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("registerBridgeOps") + .argument(&signature) + .argument(&bridge_operations_hash) + .argument(&operations_hashes) + .original_result() + } + + pub fn set_esdt_safe_address< + Arg0: ProxyArg>, + >( + self, + esdt_safe_address: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setEsdtSafeAddress") + .argument(&esdt_safe_address) + .original_result() + } + + pub fn remove_executed_hash< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + >( + self, + hash_of_hashes: Arg0, + operation_hash: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("removeExecutedHash") + .argument(&hash_of_hashes) + .argument(&operation_hash) + .original_result() + } + + pub fn set_min_valid_signers< + Arg0: ProxyArg, + >( + self, + new_value: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setMinValidSigners") + .argument(&new_value) + .original_result() + } + + pub fn add_signers< + Arg0: ProxyArg>>, + >( + self, + signers: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("addSigners") + .argument(&signers) + .original_result() + } + + pub fn remove_signers< + Arg0: ProxyArg>>, + >( + self, + signers: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("removeSigners") + .argument(&signers) + .original_result() + } +} diff --git a/esdt-safe/interactor/src/proxies/mod.rs b/esdt-safe/interactor/src/proxies/mod.rs new file mode 100644 index 00000000..171e160b --- /dev/null +++ b/esdt-safe/interactor/src/proxies/mod.rs @@ -0,0 +1,5 @@ +pub mod fee_market_proxy; +pub mod header_verifier_proxy; +pub mod price_aggregator_proxy; +pub mod proxy; +pub mod testing_sc_proxy; diff --git a/esdt-safe/interactor/src/proxies/price_aggregator_proxy.rs b/esdt-safe/interactor/src/proxies/price_aggregator_proxy.rs new file mode 100644 index 00000000..7a7e2aaa --- /dev/null +++ b/esdt-safe/interactor/src/proxies/price_aggregator_proxy.rs @@ -0,0 +1,416 @@ +// 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 PriceAggregatorProxy; + +impl TxProxyTrait for PriceAggregatorProxy +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + type TxProxyMethods = PriceAggregatorProxyMethods; + + fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { + PriceAggregatorProxyMethods { wrapped_tx: tx } + } +} + +pub struct PriceAggregatorProxyMethods +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + wrapped_tx: Tx, +} + +#[rustfmt::skip] +impl PriceAggregatorProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + Gas: TxGas, +{ + pub fn init< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + Arg2: ProxyArg>, + Arg3: ProxyArg, + Arg4: ProxyArg, + Arg5: ProxyArg>>, + >( + self, + staking_token: Arg0, + staking_amount: Arg1, + slash_amount: Arg2, + slash_quorum: Arg3, + submission_count: Arg4, + oracles: Arg5, + ) -> TxTypedDeploy { + self.wrapped_tx + .payment(NotPayable) + .raw_deploy() + .argument(&staking_token) + .argument(&staking_amount) + .argument(&slash_amount) + .argument(&slash_quorum) + .argument(&submission_count) + .argument(&oracles) + .original_result() + } +} + +#[rustfmt::skip] +impl PriceAggregatorProxyMethods +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 PriceAggregatorProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn change_amounts< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + >( + self, + staking_amount: Arg0, + slash_amount: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("changeAmounts") + .argument(&staking_amount) + .argument(&slash_amount) + .original_result() + } + + pub fn add_oracles< + Arg0: ProxyArg>>, + >( + self, + oracles: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("addOracles") + .argument(&oracles) + .original_result() + } + + /// Also receives submission count, + /// so the owner does not have to update it manually with setSubmissionCount before this call + pub fn remove_oracles< + Arg0: ProxyArg, + Arg1: ProxyArg>>, + >( + self, + submission_count: Arg0, + oracles: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("removeOracles") + .argument(&submission_count) + .argument(&oracles) + .original_result() + } + + pub fn submit< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + Arg2: ProxyArg, + Arg3: ProxyArg>, + Arg4: ProxyArg, + >( + self, + from: Arg0, + to: Arg1, + submission_timestamp: Arg2, + price: Arg3, + decimals: Arg4, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("submit") + .argument(&from) + .argument(&to) + .argument(&submission_timestamp) + .argument(&price) + .argument(&decimals) + .original_result() + } + + pub fn submit_batch< + Arg0: ProxyArg, ManagedBuffer, u64, BigUint, u8>>>, + >( + self, + submissions: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("submitBatch") + .argument(&submissions) + .original_result() + } + + pub fn latest_round_data( + self, + ) -> TxTypedCall>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("latestRoundData") + .original_result() + } + + pub fn latest_price_feed< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + >( + self, + from: Arg0, + to: Arg1, + ) -> TxTypedCall, ManagedBuffer, u64, BigUint, u8>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("latestPriceFeed") + .argument(&from) + .argument(&to) + .original_result() + } + + pub fn latest_price_feed_optional< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + >( + self, + from: Arg0, + to: Arg1, + ) -> TxTypedCall, ManagedBuffer, u64, BigUint, u8>>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("latestPriceFeedOptional") + .argument(&from) + .argument(&to) + .original_result() + } + + pub fn set_submission_count< + Arg0: ProxyArg, + >( + self, + submission_count: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setSubmissionCount") + .argument(&submission_count) + .original_result() + } + + pub fn get_oracles( + self, + ) -> TxTypedCall>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getOracles") + .original_result() + } + + pub fn set_pair_decimals< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + Arg2: ProxyArg, + >( + self, + from: Arg0, + to: Arg1, + decimals: Arg2, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setPairDecimals") + .argument(&from) + .argument(&to) + .argument(&decimals) + .original_result() + } + + pub fn get_pair_decimals< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + >( + self, + from: Arg0, + to: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getPairDecimals") + .argument(&from) + .argument(&to) + .original_result() + } + + pub fn submission_count( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("submission_count") + .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() + } + + pub fn stake( + self, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("stake") + .original_result() + } + + pub fn unstake< + Arg0: ProxyArg>, + >( + self, + unstake_amount: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("unstake") + .argument(&unstake_amount) + .original_result() + } + + pub fn vote_slash_member< + Arg0: ProxyArg>, + >( + self, + member_to_slash: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("voteSlashMember") + .argument(&member_to_slash) + .original_result() + } + + pub fn cancel_vote_slash_member< + Arg0: ProxyArg>, + >( + self, + member_to_slash: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("cancelVoteSlashMember") + .argument(&member_to_slash) + .original_result() + } + + pub fn slash_member< + Arg0: ProxyArg>, + >( + self, + member_to_slash: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("slashMember") + .argument(&member_to_slash) + .original_result() + } +} + +#[type_abi] +#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode)] +pub struct PriceFeed +where + Api: ManagedTypeApi, +{ + pub round_id: u32, + pub from: ManagedBuffer, + pub to: ManagedBuffer, + pub timestamp: u64, + pub price: BigUint, + pub decimals: u8, +} + +#[type_abi] +#[derive(TopEncode)] +pub struct NewRoundEvent +where + Api: ManagedTypeApi, +{ + pub price: BigUint, + pub timestamp: u64, + pub decimals: u8, + pub block: u64, + pub epoch: u64, +} + +#[type_abi] +#[derive(TopEncode)] +pub struct DiscardSubmissionEvent { + pub submission_timestamp: u64, + pub first_submission_timestamp: u64, + pub has_caller_already_submitted: bool, +} diff --git a/esdt-safe/interactor/src/proxies/proxy.rs b/esdt-safe/interactor/src/proxies/proxy.rs new file mode 100644 index 00000000..81e2e31d --- /dev/null +++ b/esdt-safe/interactor/src/proxies/proxy.rs @@ -0,0 +1,458 @@ +// 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 EsdtSafeProxy; + +impl TxProxyTrait for EsdtSafeProxy +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + type TxProxyMethods = EsdtSafeProxyMethods; + + fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { + EsdtSafeProxyMethods { wrapped_tx: tx } + } +} + +pub struct EsdtSafeProxyMethods +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + wrapped_tx: Tx, +} + +#[rustfmt::skip] +impl EsdtSafeProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + Gas: TxGas, +{ + pub fn init< + Arg0: ProxyArg, + >( + self, + is_sovereign_chain: Arg0, + ) -> TxTypedDeploy { + self.wrapped_tx + .payment(NotPayable) + .raw_deploy() + .argument(&is_sovereign_chain) + .original_result() + } +} + +#[rustfmt::skip] +impl EsdtSafeProxyMethods +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 EsdtSafeProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn set_fee_market_address< + Arg0: ProxyArg>, + >( + self, + fee_market_address: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setFeeMarketAddress") + .argument(&fee_market_address) + .original_result() + } + + pub fn set_header_verifier_address< + Arg0: ProxyArg>, + >( + self, + header_verifier_address: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setHeaderVerifierAddress") + .argument(&header_verifier_address) + .original_result() + } + + pub fn set_max_user_tx_gas_limit< + Arg0: ProxyArg, + >( + self, + max_user_tx_gas_limit: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setMaxTxGasLimit") + .argument(&max_user_tx_gas_limit) + .original_result() + } + + pub fn set_banned_endpoint< + Arg0: ProxyArg>, + >( + self, + endpoint_name: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setBannedEndpoint") + .argument(&endpoint_name) + .original_result() + } + + pub fn deposit< + Arg0: ProxyArg>, + Arg1: ProxyArg, ManagedVec>>>>, + >( + self, + to: Arg0, + optional_transfer_data: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("deposit") + .argument(&to) + .argument(&optional_transfer_data) + .original_result() + } + + pub fn set_min_valid_signers< + Arg0: ProxyArg, + >( + self, + new_value: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setMinValidSigners") + .argument(&new_value) + .original_result() + } + + pub fn add_signers< + Arg0: ProxyArg>>, + >( + self, + signers: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("addSigners") + .argument(&signers) + .original_result() + } + + pub fn remove_signers< + Arg0: ProxyArg>>, + >( + self, + signers: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("removeSigners") + .argument(&signers) + .original_result() + } + + pub fn register_token< + Arg0: ProxyArg>, + Arg1: ProxyArg, + Arg2: ProxyArg>, + Arg3: ProxyArg>, + Arg4: ProxyArg, + >( + self, + sov_token_id: Arg0, + token_type: Arg1, + token_display_name: Arg2, + token_ticker: Arg3, + num_decimals: Arg4, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("registerToken") + .argument(&sov_token_id) + .argument(&token_type) + .argument(&token_display_name) + .argument(&token_ticker) + .argument(&num_decimals) + .original_result() + } + + pub fn execute_operations< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + >( + self, + hash_of_hashes: Arg0, + operation: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("executeBridgeOps") + .argument(&hash_of_hashes) + .argument(&operation) + .original_result() + } + + pub fn set_max_tx_batch_size< + Arg0: ProxyArg, + >( + self, + new_max_tx_batch_size: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setMaxTxBatchSize") + .argument(&new_max_tx_batch_size) + .original_result() + } + + pub fn set_max_tx_batch_block_duration< + Arg0: ProxyArg, + >( + self, + new_max_tx_batch_block_duration: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setMaxTxBatchBlockDuration") + .argument(&new_max_tx_batch_block_duration) + .original_result() + } + + pub fn get_current_tx_batch( + self, + ) -> TxTypedCall, ManagedAddress, ManagedVec>, ManagedVec>, Option>>>>>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getCurrentTxBatch") + .original_result() + } + + pub fn get_first_batch_any_status( + self, + ) -> TxTypedCall, ManagedAddress, ManagedVec>, ManagedVec>, Option>>>>>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getFirstBatchAnyStatus") + .original_result() + } + + pub fn get_batch< + Arg0: ProxyArg, + >( + self, + batch_id: Arg0, + ) -> TxTypedCall, ManagedAddress, ManagedVec>, ManagedVec>, Option>>>>>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getBatch") + .argument(&batch_id) + .original_result() + } + + pub fn get_batch_status< + Arg0: ProxyArg, + >( + self, + batch_id: Arg0, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getBatchStatus") + .argument(&batch_id) + .original_result() + } + + pub fn first_batch_id( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getFirstBatchId") + .original_result() + } + + pub fn last_batch_id( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getLastBatchId") + .original_result() + } + + pub fn set_max_bridged_amount< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + >( + self, + token_id: Arg0, + max_amount: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setMaxBridgedAmount") + .argument(&token_id) + .argument(&max_amount) + .original_result() + } + + pub fn max_bridged_amount< + Arg0: ProxyArg>, + >( + self, + token_id: Arg0, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getMaxBridgedAmount") + .argument(&token_id) + .original_result() + } + + pub fn end_setup_phase( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("endSetupPhase") + .original_result() + } + + /// Tokens in the whitelist can be transferred without fees + pub fn add_tokens_to_whitelist< + Arg0: ProxyArg>>, + >( + self, + tokens: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("addTokensToWhitelist") + .argument(&tokens) + .original_result() + } + + pub fn remove_tokens_from_whitelist< + Arg0: ProxyArg>>, + >( + self, + tokens: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("removeTokensFromWhitelist") + .argument(&tokens) + .original_result() + } + + /// Tokens in blacklist cannot be transferred + pub fn add_tokens_to_blacklist< + Arg0: ProxyArg>>, + >( + self, + tokens: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("addTokensToBlacklist") + .argument(&tokens) + .original_result() + } + + pub fn remove_tokens_from_blacklist< + Arg0: ProxyArg>>, + >( + self, + tokens: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("removeTokensFromBlacklist") + .argument(&tokens) + .original_result() + } + + pub fn token_whitelist( + self, + ) -> TxTypedCall>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getTokenWhitelist") + .original_result() + } + + pub fn token_blacklist( + self, + ) -> TxTypedCall>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getTokenBlacklist") + .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/esdt-safe/interactor/src/proxies/testing_sc_proxy.rs b/esdt-safe/interactor/src/proxies/testing_sc_proxy.rs new file mode 100644 index 00000000..ecfec395 --- /dev/null +++ b/esdt-safe/interactor/src/proxies/testing_sc_proxy.rs @@ -0,0 +1,95 @@ +// 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 TestingScProxy; + +impl TxProxyTrait for TestingScProxy +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + type TxProxyMethods = TestingScProxyMethods; + + fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { + TestingScProxyMethods { wrapped_tx: tx } + } +} + +pub struct TestingScProxyMethods +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + wrapped_tx: Tx, +} + +#[rustfmt::skip] +impl TestingScProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + Gas: TxGas, +{ + pub fn init( + self, + ) -> TxTypedDeploy { + self.wrapped_tx + .payment(NotPayable) + .raw_deploy() + .original_result() + } +} + +#[rustfmt::skip] +impl TestingScProxyMethods +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 TestingScProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn hello< + Arg0: ProxyArg>, + >( + self, + value: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("hello") + .argument(&value) + .original_result() + } +} diff --git a/esdt-safe/interactor/state.toml b/esdt-safe/interactor/state.toml index 76c22a65..203020a1 100644 --- a/esdt-safe/interactor/state.toml +++ b/esdt-safe/interactor/state.toml @@ -1,4 +1,5 @@ -contract_address = "erd1qqqqqqqqqqqqqpgqyczw89pfr8aj54j4crvr7z700duqge4xt7asyhkfsm" -fee_market_address = "erd1qqqqqqqqqqqqqpgq0r6lzfdz4uhqar7kmspxhg0kr8ezmw64t7aswthejh" -price_aggregator_address = "erd1qqqqqqqqqqqqqpgqxutn5wwtjesh73fl3pz0ua9p9tqsys8vt7as36y3vf" -header_verifier_address = "erd1qqqqqqqqqqqqqpgqzt6lf09qhz8fdq4k67mz3e8h8yjmmlcvt7asftyk47" +contract_address = "erd1qqqqqqqqqqqqqpgqx6td5ezm7f2kynjsdg9u54lwwyhr0e8srruqazhkq2" +fee_market_address = "erd1qqqqqqqqqqqqqpgqqa6f8u9mzqwft2v9lgwhyjfehuhmylegrruq8mrtuw" +price_aggregator_address = "erd1qqqqqqqqqqqqqpgq4sshr5wx4ch5gd8847dsavahytt732kut7as6z3mv6" +header_verifier_address = "erd1qqqqqqqqqqqqqpgqqyhlhxwke87nwyvxafg5r6q9wfgyh2chrruq7qjcnj" +testing_sc_address = "erd1qqqqqqqqqqqqqpgqmsd3tr2e3t863dp8kc4y9sdu0fdfzcc0rruq872jth" From 387907219c8765d4fd3b2bf51696d9728292b3b7 Mon Sep 17 00:00:00 2001 From: Andrei Baltariu Date: Wed, 13 Nov 2024 13:01:09 +0200 Subject: [PATCH 12/15] Fixed interactor Signed-off-by: Andrei Baltariu --- Cargo.lock | 1558 ++++++++++++++++++- Cargo.toml | 1 + esdt-safe/interactor/src/interactor_main.rs | 20 +- 3 files changed, 1519 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8f9d906f..89e6cf9a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,32 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aes" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", +] + [[package]] name = "ahash" version = "0.8.11" @@ -14,6 +40,15 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + [[package]] name = "anstream" version = "0.6.13" @@ -80,6 +115,21 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" +[[package]] +name = "backtrace" +version = "0.3.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "base64" version = "0.22.0" @@ -98,6 +148,35 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d" +[[package]] +name = "bip39" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33415e24172c1b7d6066f6d999545375ab8e1d95421d6784bdfff9496f292387" +dependencies = [ + "bitcoin_hashes", + "rand", + "rand_core", + "serde", + "unicode-normalization", +] + +[[package]] +name = "bitcoin-internals" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9425c3bf7089c983facbae04de54513cce73b41c7f9ff8c845b54e7bc64ebbfb" + +[[package]] +name = "bitcoin_hashes" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1930a4dabfebb8d7d9992db18ebe3ae2876f0a305fab206fd168df931ede293b" +dependencies = [ + "bitcoin-internals", + "hex-conservative", +] + [[package]] name = "bitflags" version = "2.6.0" @@ -128,6 +207,21 @@ version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +[[package]] +name = "bytes" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" + +[[package]] +name = "cc" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aeb932158bd710538c73702db6945cb68a8fb08c519e6e12706b94263b36db8" +dependencies = [ + "shlex", +] + [[package]] name = "cfg-if" version = "1.0.0" @@ -172,6 +266,16 @@ dependencies = [ "multiversx-sc-meta-lib", ] +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", +] + [[package]] name = "clap" version = "4.5.4" @@ -243,6 +347,22 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + [[package]] name = "cpufeatures" version = "0.2.12" @@ -262,6 +382,15 @@ dependencies = [ "typenum", ] +[[package]] +name = "ctr" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" +dependencies = [ + "cipher", +] + [[package]] name = "curve25519-dalek" version = "4.1.3" @@ -307,6 +436,18 @@ checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", "crypto-common", + "subtle", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -345,12 +486,45 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" +[[package]] +name = "env_filter" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "env_logger" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "humantime", + "log", +] + [[package]] name = "equivalent" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "esdt-safe" version = "0.0.0" @@ -380,6 +554,12 @@ dependencies = [ "multiversx-sc-meta-lib", ] +[[package]] +name = "fastrand" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" + [[package]] name = "fee-market" version = "0.0.0" @@ -406,6 +586,125 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-executor" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" + +[[package]] +name = "futures-macro" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + +[[package]] +name = "futures-task" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" + +[[package]] +name = "futures-util" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -427,6 +726,12 @@ dependencies = [ "wasi", ] +[[package]] +name = "gimli" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" + [[package]] name = "hashbrown" version = "0.14.3" @@ -462,12 +767,24 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + [[package]] name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hex-conservative" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "212ab92002354b4819390025006c897e8140934349e8635c9b077f47b4dcbd20" + [[package]] name = "hex-literal" version = "0.4.1" @@ -475,108 +792,429 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] -name = "indexmap" -version = "2.2.6" +name = "hmac" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "equivalent", - "hashbrown", - "serde", + "digest", ] [[package]] -name = "itertools" -version = "0.13.0" +name = "http" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" dependencies = [ - "either", + "bytes", + "fnv", + "itoa", ] [[package]] -name = "itoa" -version = "1.0.11" +name = "http-body" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] [[package]] -name = "keccak" -version = "0.1.5" +name = "http-body-util" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ - "cpufeatures", + "bytes", + "futures-util", + "http", + "http-body", + "pin-project-lite", ] [[package]] -name = "lazy_static" -version = "1.4.0" +name = "httparse" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" [[package]] -name = "leb128" -version = "0.2.5" +name = "humantime" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] -name = "libc" -version = "0.2.153" +name = "hyper" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] [[package]] -name = "log" -version = "0.4.21" +name = "hyper-tls" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] [[package]] -name = "max-bridged-amount-module" -version = "0.0.0" +name = "hyper-util" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", ] [[package]] -name = "memchr" -version = "2.7.2" +name = "icu_collections" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] [[package]] -name = "multiversx-chain-core" -version = "0.11.0" +name = "icu_locid" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1088b268cad0d8c1146df9ca71a1f2baaee78267ab75e2202c0c0c71cc4b6e" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" dependencies = [ - "bitflags", - "multiversx-sc-codec", + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", ] [[package]] -name = "multiversx-chain-scenario-format" -version = "0.23.0" +name = "icu_locid_transform" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcca77966bf5eb9c9f96d0597f17a4fa7b64681cc7b83e39bdf31f8c6ca04d44" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" dependencies = [ - "bech32", - "hex", - "num-bigint", - "num-traits", - "serde", - "serde_json", - "sha3", + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", ] [[package]] -name = "multiversx-chain-vm" -version = "0.11.0" +name = "icu_locid_transform_data" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d885c04e117cf5ca37303825a578385dbc880ee89890b0649dbbb22ad19dc59" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "idna" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown", + "serde", +] + +[[package]] +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +dependencies = [ + "generic-array", +] + +[[package]] +name = "ipnet" +version = "2.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" + +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "js-sys" +version = "0.3.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "keccak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "leb128" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" + +[[package]] +name = "libc" +version = "0.2.153" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "litemap" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" + +[[package]] +name = "max-bridged-amount-module" +version = "0.0.0" +dependencies = [ + "multiversx-sc", + "multiversx-sc-scenario", +] + +[[package]] +name = "memchr" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "miniz_oxide" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +dependencies = [ + "hermit-abi", + "libc", + "wasi", + "windows-sys 0.52.0", +] + +[[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-chain-scenario-format" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcca77966bf5eb9c9f96d0597f17a4fa7b64681cc7b83e39bdf31f8c6ca04d44" +dependencies = [ + "bech32", + "hex", + "num-bigint", + "num-traits", + "serde", + "serde_json", + "sha3", +] + +[[package]] +name = "multiversx-chain-vm" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d885c04e117cf5ca37303825a578385dbc880ee89890b0649dbbb22ad19dc59" dependencies = [ "bitflags", "colored", @@ -709,6 +1347,87 @@ dependencies = [ "unwrap-infallible", ] +[[package]] +name = "multiversx-sc-snippets" +version = "0.54.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83eec6ebd7efc32eb77d19ea29f3f13d42b7d848662b173c920201741ec3897e" +dependencies = [ + "anyhow", + "base64", + "env_logger", + "futures", + "hex", + "log", + "multiversx-chain-scenario-format", + "multiversx-sc-scenario", + "multiversx-sdk", + "multiversx-sdk-http", + "tokio", +] + +[[package]] +name = "multiversx-sdk" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c393e7b58c5eafcfc814bb13efe2a09f20fa0dbfee93bc501ca4236135a7647" +dependencies = [ + "aes", + "anyhow", + "base64", + "bech32", + "bip39", + "ctr", + "hex", + "hmac", + "itertools", + "log", + "multiversx-chain-core", + "pbkdf2", + "pem", + "rand", + "scrypt", + "serde", + "serde_json", + "serde_repr", + "sha2", + "sha3", + "uuid", + "zeroize", +] + +[[package]] +name = "multiversx-sdk-http" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0727639c2b44d21d024f8134231c37d50ad76788675c77bee342016a63e226" +dependencies = [ + "anyhow", + "hex", + "itertools", + "log", + "multiversx-sdk", + "reqwest", + "tokio", +] + +[[package]] +name = "native-tls" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "nibble_vec" version = "0.1.0" @@ -746,18 +1465,143 @@ dependencies = [ "autocfg", ] +[[package]] +name = "object" +version = "0.36.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "openssl" +version = "0.10.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.52.4", +] + +[[package]] +name = "password-hash" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "346f04948ba92c43e8469c1ee6736c7563d71012b17d40745260fe106aac2166" +dependencies = [ + "base64ct", + "rand_core", + "subtle", +] + [[package]] name = "pathdiff" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" +[[package]] +name = "pbkdf2" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" +dependencies = [ + "digest", + "hmac", +] + +[[package]] +name = "pem" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" +dependencies = [ + "base64", + "serde", +] + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pin-project-lite" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + [[package]] name = "pkcs8" version = "0.10.2" @@ -768,6 +1612,12 @@ dependencies = [ "spki", ] +[[package]] +name = "pkg-config" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -841,6 +1691,106 @@ dependencies = [ "rand_core", ] +[[package]] +name = "redox_syscall" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "reqwest" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" +dependencies = [ + "base64", + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-tls", + "hyper-util", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + +[[package]] +name = "rust-interact" +version = "0.0.0" +dependencies = [ + "clap", + "esdt-safe", + "fee-market", + "multiversx-sc", + "multiversx-sc-scenario", + "multiversx-sc-snippets", + "serde", + "toml", + "transaction", + "tx-batch-module", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + [[package]] name = "rustc_version" version = "0.4.0" @@ -850,11 +1800,98 @@ dependencies = [ "semver", ] +[[package]] +name = "rustix" +version = "0.38.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustls-pemfile" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" + [[package]] name = "ryu" version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" + +[[package]] +name = "salsa20" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213" +dependencies = [ + "cipher", +] + +[[package]] +name = "schannel" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "scrypt" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0516a385866c09368f0b5bcd1caff3366aace790fcd46e2bb032697bb172fd1f" +dependencies = [ + "password-hash", + "pbkdf2", + "salsa20", + "sha2", +] + +[[package]] +name = "security-framework" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa39c7303dc58b5543c94d22c1766b0d31f2ee58306363ea622b10bbc075eaa2" +dependencies = [ + "core-foundation-sys", + "libc", +] [[package]] name = "semver" @@ -888,11 +1925,23 @@ version = "1.0.115" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" dependencies = [ + "indexmap", "itoa", "ryu", "serde", ] +[[package]] +name = "serde_repr" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "serde_spanned" version = "0.6.5" @@ -902,6 +1951,18 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + [[package]] name = "setup-phase" version = "0.0.0" @@ -931,6 +1992,21 @@ dependencies = [ "keccak", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook-registry" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +dependencies = [ + "libc", +] + [[package]] name = "signature" version = "2.2.0" @@ -940,12 +2016,31 @@ dependencies = [ "rand_core", ] +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + [[package]] name = "smallvec" version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +[[package]] +name = "socket2" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "spki" version = "0.7.3" @@ -956,6 +2051,12 @@ dependencies = [ "der", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "strsim" version = "0.11.1" @@ -979,6 +2080,36 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" + +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tempfile" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fcd239983515c23a32fb82099f97d0b11b8c72f654ed659363a95c3dad7a53" +dependencies = [ + "cfg-if", + "fastrand", + "once_cell", + "rustix", + "windows-sys 0.52.0", +] + [[package]] name = "termcolor" version = "1.4.1" @@ -988,6 +2119,31 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinyvec" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + [[package]] name = "token-whitelist" version = "0.0.0" @@ -999,6 +2155,45 @@ dependencies = [ "utils", ] +[[package]] +name = "tokio" +version = "1.41.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.52.0", +] + +[[package]] +name = "tokio-macros" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + [[package]] name = "toml" version = "0.8.12" @@ -1034,6 +2229,31 @@ dependencies = [ "winnow", ] +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + [[package]] name = "transaction" version = "0.0.0" @@ -1041,6 +2261,12 @@ dependencies = [ "multiversx-sc", ] +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + [[package]] name = "tx-batch-module" version = "0.0.0" @@ -1062,6 +2288,15 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + [[package]] name = "unicode-segmentation" version = "1.11.0" @@ -1080,6 +2315,29 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "151ac09978d3c2862c4e39b557f4eceee2cc72150bc4cb4f16abf061b6e381fb" +[[package]] +name = "url" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" version = "0.2.1" @@ -1094,18 +2352,109 @@ dependencies = [ "multiversx-sc", ] +[[package]] +name = "uuid" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" +dependencies = [ + "getrandom", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version_check" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasm-bindgen" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" +dependencies = [ + "cfg-if", + "once_cell", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" + [[package]] name = "wasm-encoder" version = "0.220.0" @@ -1173,6 +2522,16 @@ dependencies = [ "wast", ] +[[package]] +name = "web-sys" +version = "0.3.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "winapi" version = "0.3.9" @@ -1345,6 +2704,52 @@ dependencies = [ "memchr", ] +[[package]] +name = "winreg" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + +[[package]] +name = "yoke" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + [[package]] name = "zerocopy" version = "0.7.34" @@ -1365,8 +2770,51 @@ dependencies = [ "syn", ] +[[package]] +name = "zerofrom" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + [[package]] name = "zeroize" version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml index 709827ac..f73bdeaa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ members = [ "chain-factory", "chain-factory/meta", "esdt-safe", + "esdt-safe/interactor", "esdt-safe/meta", "fee-market", "fee-market/meta", diff --git a/esdt-safe/interactor/src/interactor_main.rs b/esdt-safe/interactor/src/interactor_main.rs index 74dc900c..b6debec7 100644 --- a/esdt-safe/interactor/src/interactor_main.rs +++ b/esdt-safe/interactor/src/interactor_main.rs @@ -4,8 +4,7 @@ mod proxies; -use fee_market::fee_market_proxy::FeeMarketProxy; -use fee_market::fee_market_proxy::{self, FeeStruct, FeeType}; +use fee_market_proxy::{FeeStruct, FeeType}; use header_verifier_proxy::HeaderverifierProxy; use multiversx_sc_scenario::meta::tools::find_current_workspace; use multiversx_sc_scenario::multiversx_chain_vm::crypto_functions::{sha256, SHA256_RESULT_LEN}; @@ -135,6 +134,10 @@ impl State { pub fn get_testing_sc_address(&self) -> Address { self.testing_sc_address.clone().unwrap().to_address() } + + pub fn get_price_aggregator_address(&self) -> Address { + self.price_aggregator_address.clone().unwrap().to_address() + } } impl Drop for State { @@ -250,7 +253,11 @@ impl ContractInteract { .from(&self.wallet_address) .gas(100_000_000u64) .typed(fee_market_proxy::FeeMarketProxy) - .init(self.state.current_address(), Option::Some(fee)) + .init( + self.state.current_address(), + self.state.get_price_aggregator_address(), + Option::Some(fee), + ) .code(fee_market_code_path) .returns(ReturnsNewAddress) .run() @@ -919,8 +926,8 @@ impl ContractInteract { .from(&self.wallet_address) .to(self.state.get_fee_market_address()) .gas(30_000_000u64) - .typed(FeeMarketProxy) - .remove_fee(TOKEN_ID) + .typed(fee_market_proxy::FeeMarketProxy) + .disable_fee(TOKEN_ID) .returns(ReturnsResultUnmanaged) .run() .await; @@ -1059,6 +1066,9 @@ impl ContractInteract { } } +// NOTE: +// All interactor tests should only be ignored when pushed to Github +// Those System Tests are intended to run locally since they won't work on Github Actions #[tokio::test] #[ignore] async fn test_deploy_sov() { From 14c569ff2383c0b36885b6b65dd1b426e7a068a9 Mon Sep 17 00:00:00 2001 From: Andrei Baltariu Date: Wed, 13 Nov 2024 13:20:37 +0200 Subject: [PATCH 13/15] Removed proxies from src/ folder Signed-off-by: Andrei Baltariu --- esdt-safe/interactor/src/fee_market_proxy.rs | 278 ------------ .../interactor/src/header_verifier_proxy.rs | 174 -------- esdt-safe/interactor/src/interactor_main.rs | 10 +- .../interactor/src/price_aggregator_proxy.rs | 416 ------------------ .../src/proxies/fee_market_proxy.rs | 22 +- 5 files changed, 19 insertions(+), 881 deletions(-) delete mode 100644 esdt-safe/interactor/src/fee_market_proxy.rs delete mode 100644 esdt-safe/interactor/src/header_verifier_proxy.rs delete mode 100644 esdt-safe/interactor/src/price_aggregator_proxy.rs diff --git a/esdt-safe/interactor/src/fee_market_proxy.rs b/esdt-safe/interactor/src/fee_market_proxy.rs deleted file mode 100644 index b595c0f6..00000000 --- a/esdt-safe/interactor/src/fee_market_proxy.rs +++ /dev/null @@ -1,278 +0,0 @@ -// 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 FeeMarketProxy; - -impl TxProxyTrait for FeeMarketProxy -where - Env: TxEnv, - From: TxFrom, - To: TxTo, - Gas: TxGas, -{ - type TxProxyMethods = FeeMarketProxyMethods; - - fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { - FeeMarketProxyMethods { wrapped_tx: tx } - } -} - -pub struct FeeMarketProxyMethods -where - Env: TxEnv, - From: TxFrom, - To: TxTo, - Gas: TxGas, -{ - wrapped_tx: Tx, -} - -#[rustfmt::skip] -impl FeeMarketProxyMethods -where - Env: TxEnv, - Env::Api: VMApi, - From: TxFrom, - Gas: TxGas, -{ - pub fn init< - Arg0: ProxyArg>, - Arg1: ProxyArg>, - Arg2: ProxyArg>>, - >( - self, - esdt_safe_address: Arg0, - price_aggregator_address: Arg1, - fee: Arg2, - ) -> TxTypedDeploy { - self.wrapped_tx - .payment(NotPayable) - .raw_deploy() - .argument(&esdt_safe_address) - .argument(&price_aggregator_address) - .argument(&fee) - .original_result() - } -} - -#[rustfmt::skip] -impl FeeMarketProxyMethods -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 FeeMarketProxyMethods -where - Env: TxEnv, - Env::Api: VMApi, - From: TxFrom, - To: TxTo, - Gas: TxGas, -{ - pub fn set_fee< - Arg0: ProxyArg>, - >( - self, - fee_struct: Arg0, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("addFee") - .argument(&fee_struct) - .original_result() - } - - pub fn disable_fee< - Arg0: ProxyArg>, - >( - self, - base_token: Arg0, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("removeFee") - .argument(&base_token) - .original_result() - } - - pub fn token_fee< - Arg0: ProxyArg>, - >( - self, - token_id: Arg0, - ) -> TxTypedCall> { - self.wrapped_tx - .payment(NotPayable) - .raw_call("getTokenFee") - .argument(&token_id) - .original_result() - } - - 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() - } - - /// Percentages have to be between 0 and 10_000, and must all add up to 100% (i.e. 10_000) - pub fn distribute_fees< - Arg0: ProxyArg, usize>>>, - >( - self, - address_percentage_pairs: Arg0, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("distributeFees") - .argument(&address_percentage_pairs) - .original_result() - } - - pub fn subtract_fee< - Arg0: ProxyArg>, - Arg1: ProxyArg, - Arg2: ProxyArg>, - >( - self, - original_caller: Arg0, - total_transfers: Arg1, - opt_gas_limit: Arg2, - ) -> TxTypedCall> { - self.wrapped_tx - .raw_call("subtractFee") - .argument(&original_caller) - .argument(&total_transfers) - .argument(&opt_gas_limit) - .original_result() - } - - pub fn users_whitelist( - self, - ) -> TxTypedCall>> { - self.wrapped_tx - .payment(NotPayable) - .raw_call("getUsersWhitelist") - .original_result() - } - - pub fn set_min_valid_signers< - Arg0: ProxyArg, - >( - self, - new_value: Arg0, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("setMinValidSigners") - .argument(&new_value) - .original_result() - } - - pub fn add_signers< - Arg0: ProxyArg>>, - >( - self, - signers: Arg0, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("addSigners") - .argument(&signers) - .original_result() - } - - pub fn remove_signers< - Arg0: ProxyArg>>, - >( - self, - signers: Arg0, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("removeSigners") - .argument(&signers) - .original_result() - } -} - -#[type_abi] -#[derive(TopDecode, TopEncode, NestedEncode, NestedDecode, Clone)] -pub struct FeeStruct -where - Api: ManagedTypeApi, -{ - pub base_token: TokenIdentifier, - pub fee_type: FeeType, -} - -#[rustfmt::skip] -#[type_abi] -#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, Clone)] -pub enum FeeType -where - Api: ManagedTypeApi, -{ - None, - Fixed { - token: TokenIdentifier, - per_transfer: BigUint, - per_gas: BigUint, - }, - AnyToken { - base_fee_token: TokenIdentifier, - per_transfer: BigUint, - per_gas: BigUint, - }, -} - -#[type_abi] -#[derive(TopEncode, TopDecode)] -pub struct FinalPayment -where - Api: ManagedTypeApi, -{ - pub fee: EsdtTokenPayment, - pub remaining_tokens: EsdtTokenPayment, -} diff --git a/esdt-safe/interactor/src/header_verifier_proxy.rs b/esdt-safe/interactor/src/header_verifier_proxy.rs deleted file mode 100644 index 4f57c709..00000000 --- a/esdt-safe/interactor/src/header_verifier_proxy.rs +++ /dev/null @@ -1,174 +0,0 @@ -// 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 HeaderverifierProxy; - -impl TxProxyTrait for HeaderverifierProxy -where - Env: TxEnv, - From: TxFrom, - To: TxTo, - Gas: TxGas, -{ - type TxProxyMethods = HeaderverifierProxyMethods; - - fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { - HeaderverifierProxyMethods { wrapped_tx: tx } - } -} - -pub struct HeaderverifierProxyMethods -where - Env: TxEnv, - From: TxFrom, - To: TxTo, - Gas: TxGas, -{ - wrapped_tx: Tx, -} - -#[rustfmt::skip] -impl HeaderverifierProxyMethods -where - Env: TxEnv, - Env::Api: VMApi, - From: TxFrom, - Gas: TxGas, -{ - pub fn init< - Arg0: ProxyArg>>, - >( - self, - bls_pub_keys: Arg0, - ) -> TxTypedDeploy { - self.wrapped_tx - .payment(NotPayable) - .raw_deploy() - .argument(&bls_pub_keys) - .original_result() - } -} - -#[rustfmt::skip] -impl HeaderverifierProxyMethods -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 HeaderverifierProxyMethods -where - Env: TxEnv, - Env::Api: VMApi, - From: TxFrom, - To: TxTo, - Gas: TxGas, -{ - pub fn register_bridge_operations< - Arg0: ProxyArg>, - Arg1: ProxyArg>, - Arg2: ProxyArg>>, - >( - self, - signature: Arg0, - bridge_operations_hash: Arg1, - operations_hashes: Arg2, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("registerBridgeOps") - .argument(&signature) - .argument(&bridge_operations_hash) - .argument(&operations_hashes) - .original_result() - } - - pub fn set_esdt_safe_address< - Arg0: ProxyArg>, - >( - self, - esdt_safe_address: Arg0, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("setEsdtSafeAddress") - .argument(&esdt_safe_address) - .original_result() - } - - pub fn remove_executed_hash< - Arg0: ProxyArg>, - Arg1: ProxyArg>, - >( - self, - hash_of_hashes: Arg0, - operation_hash: Arg1, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("removeExecutedHash") - .argument(&hash_of_hashes) - .argument(&operation_hash) - .original_result() - } - - pub fn set_min_valid_signers< - Arg0: ProxyArg, - >( - self, - new_value: Arg0, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("setMinValidSigners") - .argument(&new_value) - .original_result() - } - - pub fn add_signers< - Arg0: ProxyArg>>, - >( - self, - signers: Arg0, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("addSigners") - .argument(&signers) - .original_result() - } - - pub fn remove_signers< - Arg0: ProxyArg>>, - >( - self, - signers: Arg0, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("removeSigners") - .argument(&signers) - .original_result() - } -} diff --git a/esdt-safe/interactor/src/interactor_main.rs b/esdt-safe/interactor/src/interactor_main.rs index b6debec7..1b340aa7 100644 --- a/esdt-safe/interactor/src/interactor_main.rs +++ b/esdt-safe/interactor/src/interactor_main.rs @@ -2,7 +2,7 @@ // TODO: Remove this when interactor setup is complete #![allow(dead_code)] -mod proxies; +pub mod proxies; use fee_market_proxy::{FeeStruct, FeeType}; use header_verifier_proxy::HeaderverifierProxy; @@ -253,11 +253,7 @@ impl ContractInteract { .from(&self.wallet_address) .gas(100_000_000u64) .typed(fee_market_proxy::FeeMarketProxy) - .init( - self.state.current_address(), - self.state.get_price_aggregator_address(), - Option::Some(fee), - ) + .init(self.state.current_address(), Option::Some(fee)) .code(fee_market_code_path) .returns(ReturnsNewAddress) .run() @@ -927,7 +923,7 @@ impl ContractInteract { .to(self.state.get_fee_market_address()) .gas(30_000_000u64) .typed(fee_market_proxy::FeeMarketProxy) - .disable_fee(TOKEN_ID) + .remove_fee(TOKEN_ID) .returns(ReturnsResultUnmanaged) .run() .await; diff --git a/esdt-safe/interactor/src/price_aggregator_proxy.rs b/esdt-safe/interactor/src/price_aggregator_proxy.rs deleted file mode 100644 index 7a7e2aaa..00000000 --- a/esdt-safe/interactor/src/price_aggregator_proxy.rs +++ /dev/null @@ -1,416 +0,0 @@ -// 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 PriceAggregatorProxy; - -impl TxProxyTrait for PriceAggregatorProxy -where - Env: TxEnv, - From: TxFrom, - To: TxTo, - Gas: TxGas, -{ - type TxProxyMethods = PriceAggregatorProxyMethods; - - fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { - PriceAggregatorProxyMethods { wrapped_tx: tx } - } -} - -pub struct PriceAggregatorProxyMethods -where - Env: TxEnv, - From: TxFrom, - To: TxTo, - Gas: TxGas, -{ - wrapped_tx: Tx, -} - -#[rustfmt::skip] -impl PriceAggregatorProxyMethods -where - Env: TxEnv, - Env::Api: VMApi, - From: TxFrom, - Gas: TxGas, -{ - pub fn init< - Arg0: ProxyArg>, - Arg1: ProxyArg>, - Arg2: ProxyArg>, - Arg3: ProxyArg, - Arg4: ProxyArg, - Arg5: ProxyArg>>, - >( - self, - staking_token: Arg0, - staking_amount: Arg1, - slash_amount: Arg2, - slash_quorum: Arg3, - submission_count: Arg4, - oracles: Arg5, - ) -> TxTypedDeploy { - self.wrapped_tx - .payment(NotPayable) - .raw_deploy() - .argument(&staking_token) - .argument(&staking_amount) - .argument(&slash_amount) - .argument(&slash_quorum) - .argument(&submission_count) - .argument(&oracles) - .original_result() - } -} - -#[rustfmt::skip] -impl PriceAggregatorProxyMethods -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 PriceAggregatorProxyMethods -where - Env: TxEnv, - Env::Api: VMApi, - From: TxFrom, - To: TxTo, - Gas: TxGas, -{ - pub fn change_amounts< - Arg0: ProxyArg>, - Arg1: ProxyArg>, - >( - self, - staking_amount: Arg0, - slash_amount: Arg1, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("changeAmounts") - .argument(&staking_amount) - .argument(&slash_amount) - .original_result() - } - - pub fn add_oracles< - Arg0: ProxyArg>>, - >( - self, - oracles: Arg0, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("addOracles") - .argument(&oracles) - .original_result() - } - - /// Also receives submission count, - /// so the owner does not have to update it manually with setSubmissionCount before this call - pub fn remove_oracles< - Arg0: ProxyArg, - Arg1: ProxyArg>>, - >( - self, - submission_count: Arg0, - oracles: Arg1, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("removeOracles") - .argument(&submission_count) - .argument(&oracles) - .original_result() - } - - pub fn submit< - Arg0: ProxyArg>, - Arg1: ProxyArg>, - Arg2: ProxyArg, - Arg3: ProxyArg>, - Arg4: ProxyArg, - >( - self, - from: Arg0, - to: Arg1, - submission_timestamp: Arg2, - price: Arg3, - decimals: Arg4, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("submit") - .argument(&from) - .argument(&to) - .argument(&submission_timestamp) - .argument(&price) - .argument(&decimals) - .original_result() - } - - pub fn submit_batch< - Arg0: ProxyArg, ManagedBuffer, u64, BigUint, u8>>>, - >( - self, - submissions: Arg0, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("submitBatch") - .argument(&submissions) - .original_result() - } - - pub fn latest_round_data( - self, - ) -> TxTypedCall>> { - self.wrapped_tx - .payment(NotPayable) - .raw_call("latestRoundData") - .original_result() - } - - pub fn latest_price_feed< - Arg0: ProxyArg>, - Arg1: ProxyArg>, - >( - self, - from: Arg0, - to: Arg1, - ) -> TxTypedCall, ManagedBuffer, u64, BigUint, u8>> { - self.wrapped_tx - .payment(NotPayable) - .raw_call("latestPriceFeed") - .argument(&from) - .argument(&to) - .original_result() - } - - pub fn latest_price_feed_optional< - Arg0: ProxyArg>, - Arg1: ProxyArg>, - >( - self, - from: Arg0, - to: Arg1, - ) -> TxTypedCall, ManagedBuffer, u64, BigUint, u8>>> { - self.wrapped_tx - .payment(NotPayable) - .raw_call("latestPriceFeedOptional") - .argument(&from) - .argument(&to) - .original_result() - } - - pub fn set_submission_count< - Arg0: ProxyArg, - >( - self, - submission_count: Arg0, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("setSubmissionCount") - .argument(&submission_count) - .original_result() - } - - pub fn get_oracles( - self, - ) -> TxTypedCall>> { - self.wrapped_tx - .payment(NotPayable) - .raw_call("getOracles") - .original_result() - } - - pub fn set_pair_decimals< - Arg0: ProxyArg>, - Arg1: ProxyArg>, - Arg2: ProxyArg, - >( - self, - from: Arg0, - to: Arg1, - decimals: Arg2, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("setPairDecimals") - .argument(&from) - .argument(&to) - .argument(&decimals) - .original_result() - } - - pub fn get_pair_decimals< - Arg0: ProxyArg>, - Arg1: ProxyArg>, - >( - self, - from: Arg0, - to: Arg1, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("getPairDecimals") - .argument(&from) - .argument(&to) - .original_result() - } - - pub fn submission_count( - self, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("submission_count") - .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() - } - - pub fn stake( - self, - ) -> TxTypedCall { - self.wrapped_tx - .raw_call("stake") - .original_result() - } - - pub fn unstake< - Arg0: ProxyArg>, - >( - self, - unstake_amount: Arg0, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("unstake") - .argument(&unstake_amount) - .original_result() - } - - pub fn vote_slash_member< - Arg0: ProxyArg>, - >( - self, - member_to_slash: Arg0, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("voteSlashMember") - .argument(&member_to_slash) - .original_result() - } - - pub fn cancel_vote_slash_member< - Arg0: ProxyArg>, - >( - self, - member_to_slash: Arg0, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("cancelVoteSlashMember") - .argument(&member_to_slash) - .original_result() - } - - pub fn slash_member< - Arg0: ProxyArg>, - >( - self, - member_to_slash: Arg0, - ) -> TxTypedCall { - self.wrapped_tx - .payment(NotPayable) - .raw_call("slashMember") - .argument(&member_to_slash) - .original_result() - } -} - -#[type_abi] -#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode)] -pub struct PriceFeed -where - Api: ManagedTypeApi, -{ - pub round_id: u32, - pub from: ManagedBuffer, - pub to: ManagedBuffer, - pub timestamp: u64, - pub price: BigUint, - pub decimals: u8, -} - -#[type_abi] -#[derive(TopEncode)] -pub struct NewRoundEvent -where - Api: ManagedTypeApi, -{ - pub price: BigUint, - pub timestamp: u64, - pub decimals: u8, - pub block: u64, - pub epoch: u64, -} - -#[type_abi] -#[derive(TopEncode)] -pub struct DiscardSubmissionEvent { - pub submission_timestamp: u64, - pub first_submission_timestamp: u64, - pub has_caller_already_submitted: bool, -} diff --git a/esdt-safe/interactor/src/proxies/fee_market_proxy.rs b/esdt-safe/interactor/src/proxies/fee_market_proxy.rs index b595c0f6..d65c1106 100644 --- a/esdt-safe/interactor/src/proxies/fee_market_proxy.rs +++ b/esdt-safe/interactor/src/proxies/fee_market_proxy.rs @@ -45,19 +45,16 @@ where { pub fn init< Arg0: ProxyArg>, - Arg1: ProxyArg>, - Arg2: ProxyArg>>, + Arg1: ProxyArg>>, >( self, esdt_safe_address: Arg0, - price_aggregator_address: Arg1, - fee: Arg2, + fee: Arg1, ) -> TxTypedDeploy { self.wrapped_tx .payment(NotPayable) .raw_deploy() .argument(&esdt_safe_address) - .argument(&price_aggregator_address) .argument(&fee) .original_result() } @@ -91,6 +88,19 @@ where To: TxTo, Gas: TxGas, { + pub fn set_price_aggregator_address< + Arg0: ProxyArg>, + >( + self, + price_aggregator_address: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setPriceAggregatorAddress") + .argument(&price_aggregator_address) + .original_result() + } + pub fn set_fee< Arg0: ProxyArg>, >( @@ -104,7 +114,7 @@ where .original_result() } - pub fn disable_fee< + pub fn remove_fee< Arg0: ProxyArg>, >( self, From 93663a19686902f5f3e183f4d99120acf43a164f Mon Sep 17 00:00:00 2001 From: Andrei Baltariu Date: Wed, 13 Nov 2024 13:20:47 +0200 Subject: [PATCH 14/15] Updated fee-market to create proxy in interactor Signed-off-by: Andrei Baltariu --- fee-market/sc-config.toml | 3 +++ fee-market/src/fee_market_proxy.rs | 2 +- fee-market/src/fee_type.rs | 2 +- fee-market/wasm-fee-marker-full/src/lib.rs | 2 +- fee-market/wasm/src/lib.rs | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/fee-market/sc-config.toml b/fee-market/sc-config.toml index 78a84c24..a53b25d4 100644 --- a/fee-market/sc-config.toml +++ b/fee-market/sc-config.toml @@ -17,3 +17,6 @@ add-labels = ["fee-market-external-view"] [[proxy]] path = "src/fee_market_proxy.rs" + +[[proxy]] +path = "../esdt-safe/interactor/src/proxies/fee_market_proxy.rs" diff --git a/fee-market/src/fee_market_proxy.rs b/fee-market/src/fee_market_proxy.rs index 36ed1bc8..d65c1106 100644 --- a/fee-market/src/fee_market_proxy.rs +++ b/fee-market/src/fee_market_proxy.rs @@ -114,7 +114,7 @@ where .original_result() } - pub fn disable_fee< + pub fn remove_fee< Arg0: ProxyArg>, >( self, diff --git a/fee-market/src/fee_type.rs b/fee-market/src/fee_type.rs index 9621d436..50e7d4f9 100644 --- a/fee-market/src/fee_type.rs +++ b/fee-market/src/fee_type.rs @@ -61,7 +61,7 @@ pub trait FeeTypeModule: utils::UtilsModule + bls_signature::BlsSignatureModule #[only_owner] #[endpoint(removeFee)] - fn disable_fee(&self, base_token: TokenIdentifier) { + fn remove_fee(&self, base_token: TokenIdentifier) { self.token_fee(&base_token).clear(); self.fee_enabled().set(false); } diff --git a/fee-market/wasm-fee-marker-full/src/lib.rs b/fee-market/wasm-fee-marker-full/src/lib.rs index a07b92d6..7e1433a9 100644 --- a/fee-market/wasm-fee-marker-full/src/lib.rs +++ b/fee-market/wasm-fee-marker-full/src/lib.rs @@ -22,7 +22,7 @@ multiversx_sc_wasm_adapter::endpoints! { upgrade => upgrade setPriceAggregatorAddress => set_price_aggregator_address addFee => set_fee - removeFee => disable_fee + removeFee => remove_fee getTokenFee => token_fee addUsersToWhitelist => add_users_to_whitelist removeUsersFromWhitelist => remove_users_from_whitelist diff --git a/fee-market/wasm/src/lib.rs b/fee-market/wasm/src/lib.rs index a07b92d6..7e1433a9 100644 --- a/fee-market/wasm/src/lib.rs +++ b/fee-market/wasm/src/lib.rs @@ -22,7 +22,7 @@ multiversx_sc_wasm_adapter::endpoints! { upgrade => upgrade setPriceAggregatorAddress => set_price_aggregator_address addFee => set_fee - removeFee => disable_fee + removeFee => remove_fee getTokenFee => token_fee addUsersToWhitelist => add_users_to_whitelist removeUsersFromWhitelist => remove_users_from_whitelist From 5ea20683b86bc52fe3949ba509e7125b191b8426 Mon Sep 17 00:00:00 2001 From: Andrei Baltariu Date: Wed, 13 Nov 2024 13:22:58 +0200 Subject: [PATCH 15/15] Used correct endpoint name in tests Signed-off-by: Andrei Baltariu --- fee-market/tests/fee_market_blackbox_test.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fee-market/tests/fee_market_blackbox_test.rs b/fee-market/tests/fee_market_blackbox_test.rs index f7d43b25..c4baf4d0 100644 --- a/fee-market/tests/fee_market_blackbox_test.rs +++ b/fee-market/tests/fee_market_blackbox_test.rs @@ -133,13 +133,13 @@ impl FeeMarketTestState { } } - fn disable_fee(&mut self) { + fn remove_fee(&mut self) { self.world .tx() .from(OWNER_ADDRESS) .to(FEE_MARKET_ADDRESS) .typed(fee_market_proxy::FeeMarketProxy) - .disable_fee(TOKEN_ID) + .remove_fee(TOKEN_ID) .run(); } @@ -283,7 +283,7 @@ fn test_substract_fee_no_fee() { let mut state = FeeMarketTestState::new(); state.deploy_fee_market(); - state.disable_fee(); + state.remove_fee(); state.substract_fee("Correct", None);