From 96a8b26d1ccbe88735c019edb6ae9f6e2acf3f54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Mon, 10 Jul 2023 09:09:15 +0300 Subject: [PATCH 01/50] Add data and gasLimit data is the SC call to be executed on MultiversX side --- common/transaction/src/lib.rs | 4 +++- multisig/src/util.rs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/common/transaction/src/lib.rs b/common/transaction/src/lib.rs index c2050a82..89ec1753 100644 --- a/common/transaction/src/lib.rs +++ b/common/transaction/src/lib.rs @@ -33,10 +33,12 @@ pub struct EthTransaction { pub token_id: TokenIdentifier, pub amount: BigUint, pub tx_nonce: TxNonce, + pub data: ManagedBuffer, + pub gas_limit: u64, } pub type EthTxAsMultiValue = - MultiValue5, ManagedAddress, TokenIdentifier, BigUint, TxNonce>; + MultiValue7, ManagedAddress, TokenIdentifier, BigUint, TxNonce, ManagedBuffer, u64>; #[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, ManagedVecItem, Clone)] pub struct Transaction { diff --git a/multisig/src/util.rs b/multisig/src/util.rs index 96fc007b..d47450b3 100644 --- a/multisig/src/util.rs +++ b/multisig/src/util.rs @@ -49,7 +49,7 @@ pub trait UtilModule: crate::storage::StorageModule { ) -> ManagedVec> { let mut transfers_as_eth_tx = ManagedVec::new(); for transfer in transfers { - let (from, to, token_id, amount, tx_nonce) = transfer.into_tuple(); + let (from, to, token_id, amount, tx_nonce, data, gas_limit) = transfer.into_tuple(); transfers_as_eth_tx.push(EthTransaction { from, @@ -57,6 +57,8 @@ pub trait UtilModule: crate::storage::StorageModule { token_id, amount, tx_nonce, + data, + gas_limit }); } From 95161114e927074131614558878414c8d5fe259b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Tue, 11 Jul 2023 09:53:14 +0300 Subject: [PATCH 02/50] Add bridge proxy to execute SC calls from Eth --- bridge-proxy/.gitignore | 7 + bridge-proxy/Cargo.toml | 21 ++ bridge-proxy/meta/Cargo.toml | 14 ++ bridge-proxy/meta/src/main.rs | 3 + bridge-proxy/multiversx.json | 3 + bridge-proxy/scenarios/bridge-proxy.scen.json | 45 ++++ bridge-proxy/src/bridge-proxy.rs | 70 ++++++ bridge-proxy/src/config.rs | 38 ++++ bridge-proxy/tests/bridge_proxy_rust_test.rs | 64 ++++++ .../tests/bridge_proxy_scenario_go_test.rs | 4 + .../tests/bridge_proxy_scenario_rs_test.rs | 16 ++ bridge-proxy/wasm/Cargo.lock | 209 ++++++++++++++++++ bridge-proxy/wasm/Cargo.toml | 27 +++ bridge-proxy/wasm/src/lib.rs | 24 ++ 14 files changed, 545 insertions(+) create mode 100644 bridge-proxy/.gitignore create mode 100644 bridge-proxy/Cargo.toml create mode 100644 bridge-proxy/meta/Cargo.toml create mode 100644 bridge-proxy/meta/src/main.rs create mode 100644 bridge-proxy/multiversx.json create mode 100644 bridge-proxy/scenarios/bridge-proxy.scen.json create mode 100644 bridge-proxy/src/bridge-proxy.rs create mode 100644 bridge-proxy/src/config.rs create mode 100644 bridge-proxy/tests/bridge_proxy_rust_test.rs create mode 100644 bridge-proxy/tests/bridge_proxy_scenario_go_test.rs create mode 100644 bridge-proxy/tests/bridge_proxy_scenario_rs_test.rs create mode 100644 bridge-proxy/wasm/Cargo.lock create mode 100644 bridge-proxy/wasm/Cargo.toml create mode 100644 bridge-proxy/wasm/src/lib.rs diff --git a/bridge-proxy/.gitignore b/bridge-proxy/.gitignore new file mode 100644 index 00000000..2c76bc98 --- /dev/null +++ b/bridge-proxy/.gitignore @@ -0,0 +1,7 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +*/target/ + +# The mxpy output +/output*/ diff --git a/bridge-proxy/Cargo.toml b/bridge-proxy/Cargo.toml new file mode 100644 index 00000000..196c14f8 --- /dev/null +++ b/bridge-proxy/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "bridge-proxy" +version = "0.0.0" +authors = ["Costin CarabaČ™ "] +edition = "2018" +publish = false + +[lib] +path = "src/bridge-proxy.rs" + +[dependencies.transaction] +path = "../common/transaction" + +[dev-dependencies] +num-bigint = "0.4.2" + +[dependencies.multiversx-sc] +version = "0.41.3" + +[dev-dependencies.multiversx-sc-scenario] +version = "0.41.3" diff --git a/bridge-proxy/meta/Cargo.toml b/bridge-proxy/meta/Cargo.toml new file mode 100644 index 00000000..fa6f2db7 --- /dev/null +++ b/bridge-proxy/meta/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "bridge-proxy-meta" +version = "0.0.0" +edition = "2018" +publish = false +authors = [ "you",] + +[dev-dependencies] + +[dependencies.bridge-proxy] +path = ".." + +[dependencies.multiversx-sc-meta] +version = "0.41.3" diff --git a/bridge-proxy/meta/src/main.rs b/bridge-proxy/meta/src/main.rs new file mode 100644 index 00000000..97b4754a --- /dev/null +++ b/bridge-proxy/meta/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + multiversx_sc_meta::cli_main::(); +} diff --git a/bridge-proxy/multiversx.json b/bridge-proxy/multiversx.json new file mode 100644 index 00000000..73655396 --- /dev/null +++ b/bridge-proxy/multiversx.json @@ -0,0 +1,3 @@ +{ + "language": "rust" +} \ No newline at end of file diff --git a/bridge-proxy/scenarios/bridge-proxy.scen.json b/bridge-proxy/scenarios/bridge-proxy.scen.json new file mode 100644 index 00000000..7161bd2c --- /dev/null +++ b/bridge-proxy/scenarios/bridge-proxy.scen.json @@ -0,0 +1,45 @@ +{ + "name": "bridge-proxy", + "steps": [ + { + "step": "setState", + "accounts": { + "address:owner": { + "nonce": "1", + "balance": "0" + } + }, + "newAddresses": [ + { + "creatorAddress": "address:owner", + "creatorNonce": "1", + "newAddress": "sc:bridge-proxy" + }, + { + "creatorAddress": "address:owner", + "creatorNonce": "0", + "newAddress": "sc:multi_transfer_esdt" + } + + ] + }, + { + "step": "scDeploy", + "id": "deploy", + "tx": { + "from": "address:owner", + "contractCode": "file:../output/bridge-proxy.wasm", + "arguments": ["sc:multi_transfer_esdt"], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "out": [], + "status": "", + "logs": [], + "gas": "*", + "refund": "*" + } + } + ] +} \ No newline at end of file diff --git a/bridge-proxy/src/bridge-proxy.rs b/bridge-proxy/src/bridge-proxy.rs new file mode 100644 index 00000000..6edaa9c6 --- /dev/null +++ b/bridge-proxy/src/bridge-proxy.rs @@ -0,0 +1,70 @@ +#![no_std] + +multiversx_sc::imports!(); +multiversx_sc::derive_imports!(); + +mod config; + +use config::EthTransactionPayment; +use transaction::EthTransaction; + +/// An empty contract. To be used as a template when starting a new contract from scratch. +#[multiversx_sc::contract] +pub trait BridgeProxyContract: config::ConfigModule { + #[init] + fn init(&self, multi_transfer_address: ManagedAddress) { + self.multi_transfer_address() + .set_if_empty(&multi_transfer_address); + } + + #[endpoint] + fn deposit(&self, eth_tx: EthTransaction) { + let (token_id, nonce, amount) = self.call_value().single_esdt().into_tuple(); + self.eth_transaction_list() + .push_back(EthTransactionPayment { + token_id, + nonce, + amount, + eth_tx, + }); + } + + #[endpoint] + fn execute(&self) { + for loop_tx in self.eth_transaction_list().iter() { + let tx = loop_tx.get_value_as_ref(); + self.send() + .contract_call::(tx.eth_tx.to.clone(), tx.eth_tx.data.clone()) + .with_esdt_transfer((tx.token_id.clone(), tx.nonce, tx.amount.clone())) + .with_gas_limit(tx.eth_tx.gas_limit) + .transfer_execute(); + + //TODO Check if transaction failed, add it to `eth_failed_transaction_list` + } + } + + #[endpoint(executeWithAsnyc)] + fn execute_with_async(&self) { + let tx_node = self + .eth_transaction_list() + .front() + .unwrap_or_else(|| sc_panic!("No more ETH transactions!")); + let tx = tx_node.get_value_as_ref(); + + self.send() + .contract_call::(tx.eth_tx.to.clone(), tx.eth_tx.data.clone()) + .with_esdt_transfer((tx.token_id.clone(), tx.nonce, tx.amount.clone())) + .with_gas_limit(tx.eth_tx.gas_limit) + .async_call() + .with_callback(self.callbacks().failed_execution_callback(tx)) + .call_and_exit(); + } + + #[callback] + fn failed_execution_callback(&self, tx: &EthTransactionPayment) { + self.eth_failed_transaction_list().push_back(tx.clone()); + } + + #[endpoint(refundTransactions)] + fn refund_transactions(&self) {} +} diff --git a/bridge-proxy/src/config.rs b/bridge-proxy/src/config.rs new file mode 100644 index 00000000..bf9e6f43 --- /dev/null +++ b/bridge-proxy/src/config.rs @@ -0,0 +1,38 @@ +multiversx_sc::imports!(); +multiversx_sc::derive_imports!(); + +use transaction::EthTransaction; + +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, Clone)] +pub struct EthTransactionPayment { + pub token_id: TokenIdentifier, + pub nonce: u64, + pub amount: BigUint, + pub eth_tx: EthTransaction, +} + +#[multiversx_sc::module] +pub trait ConfigModule { + #[only_owner] + #[endpoint(setupMultiTransfer)] + fn setup_multi_transfer(&self, multi_transfer_address: ManagedAddress) { + require!( + self.blockchain().is_smart_contract(&multi_transfer_address), + "Invalid multi-transfer address" + ); + + self.multi_transfer_address().set(&multi_transfer_address); + } + + #[view(getMultiTransferAddress)] + #[storage_mapper("multiTransferAddress")] + fn multi_transfer_address(&self) -> SingleValueMapper; + + #[view(getEthTransactionList)] + #[storage_mapper("eth_transaction_list")] + fn eth_transaction_list(&self) -> LinkedListMapper>; + + #[view(getEthFailedTransactionList)] + #[storage_mapper("eth_failed_transaction_list")] + fn eth_failed_transaction_list(&self) -> LinkedListMapper>; +} diff --git a/bridge-proxy/tests/bridge_proxy_rust_test.rs b/bridge-proxy/tests/bridge_proxy_rust_test.rs new file mode 100644 index 00000000..28227ca6 --- /dev/null +++ b/bridge-proxy/tests/bridge_proxy_rust_test.rs @@ -0,0 +1,64 @@ +use bridge_proxy::*; +use multiversx_sc::types::Address; +use multiversx_sc_scenario::{managed_address, rust_biguint, testing_framework::*, DebugApi}; + +const BRIDGE_PROXY_PATH: &str = "output/bridge-proxy.wasm"; + +struct ContractSetup +where + BridgeProxyObjBuilder: 'static + Copy + Fn() -> bridge_proxy::ContractObj, +{ + pub blockchain_wrapper: BlockchainStateWrapper, + pub owner_address: Address, + pub bridge_proxy_wrapper: + ContractObjWrapper, BridgeProxyObjBuilder>, +} + +fn setup_contract( + bridge_proxy_builder: BridgeProxyObjBuilder, +) -> ContractSetup +where + BridgeProxyObjBuilder: 'static + Copy + Fn() -> bridge_proxy::ContractObj, +{ + let rust_zero = rust_biguint!(0u64); + let mut blockchain_wrapper = BlockchainStateWrapper::new(); + let owner_address = blockchain_wrapper.create_user_account(&rust_zero); + let bridge_proxy_wrapper = blockchain_wrapper.create_sc_account( + &rust_zero, + Some(&owner_address), + bridge_proxy_builder, + BRIDGE_PROXY_PATH, + ); + + blockchain_wrapper + .execute_tx(&owner_address, &bridge_proxy_wrapper, &rust_zero, |sc| { + sc.init(managed_address!(&Address::zero())); + }) + .assert_ok(); + + blockchain_wrapper.add_mandos_set_account(bridge_proxy_wrapper.address_ref()); + + ContractSetup { + blockchain_wrapper, + owner_address, + bridge_proxy_wrapper, + } +} + +#[test] +fn deploy_test() { + let mut setup = setup_contract(bridge_proxy::contract_obj); + + // simulate deploy + setup + .blockchain_wrapper + .execute_tx( + &setup.owner_address, + &setup.bridge_proxy_wrapper, + &rust_biguint!(0u64), + |sc| { + sc.init(managed_address!(&Address::zero())); + }, + ) + .assert_ok(); +} diff --git a/bridge-proxy/tests/bridge_proxy_scenario_go_test.rs b/bridge-proxy/tests/bridge_proxy_scenario_go_test.rs new file mode 100644 index 00000000..b869f3ed --- /dev/null +++ b/bridge-proxy/tests/bridge_proxy_scenario_go_test.rs @@ -0,0 +1,4 @@ +#[test] +fn bridge_proxy_go() { + multiversx_sc_scenario::run_go("scenarios/bridge-proxy.scen.json"); +} diff --git a/bridge-proxy/tests/bridge_proxy_scenario_rs_test.rs b/bridge-proxy/tests/bridge_proxy_scenario_rs_test.rs new file mode 100644 index 00000000..9d1df981 --- /dev/null +++ b/bridge-proxy/tests/bridge_proxy_scenario_rs_test.rs @@ -0,0 +1,16 @@ +use multiversx_sc_scenario::*; + +fn world() -> ScenarioWorld { + let mut blockchain = ScenarioWorld::new(); + + blockchain.register_contract( + "file:output/bridge-proxy.wasm", + bridge_proxy::ContractBuilder, + ); + blockchain +} + +#[test] +fn empty_rs() { + multiversx_sc_scenario::run_rs("scenarios/bridge-proxy.scen.json", world()); +} diff --git a/bridge-proxy/wasm/Cargo.lock b/bridge-proxy/wasm/Cargo.lock new file mode 100644 index 00000000..2c8edf0a --- /dev/null +++ b/bridge-proxy/wasm/Cargo.lock @@ -0,0 +1,209 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ahash" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", +] + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "empty" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "empty-wasm" +version = "0.0.0" +dependencies = [ + "empty", + "multiversx-sc-wasm-adapter", +] + +[[package]] +name = "endian-type" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", +] + +[[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.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" + +[[package]] +name = "multiversx-sc" +version = "0.41.3" +dependencies = [ + "bitflags", + "hashbrown", + "hex-literal", + "multiversx-sc-codec", + "multiversx-sc-derive", + "num-traits", +] + +[[package]] +name = "multiversx-sc-codec" +version = "0.17.2" +dependencies = [ + "arrayvec", + "multiversx-sc-codec-derive", +] + +[[package]] +name = "multiversx-sc-codec-derive" +version = "0.17.2" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "multiversx-sc-derive" +version = "0.41.3" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "radix_trie", + "syn", +] + +[[package]] +name = "multiversx-sc-wasm-adapter" +version = "0.41.3" +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.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + +[[package]] +name = "proc-macro2" +version = "1.0.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dec2b086b7a862cf4de201096214fa870344cf922b2b30c167badb3af3195406" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +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.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" diff --git a/bridge-proxy/wasm/Cargo.toml b/bridge-proxy/wasm/Cargo.toml new file mode 100644 index 00000000..cbe13baa --- /dev/null +++ b/bridge-proxy/wasm/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "bridge-proxy-wasm" +version = "0.0.0" +edition = "2018" +publish = false +authors = [ "you",] + +[lib] +crate-type = [ "cdylib",] + +[workspace] +members = [ ".",] + +[dev-dependencies] + +[profile.release] +codegen-units = 1 +opt-level = "z" +lto = true +debug = false +panic = "abort" + +[dependencies.bridge-proxy] +path = ".." + +[dependencies.multiversx-sc-wasm-adapter] +version = "0.41.3" diff --git a/bridge-proxy/wasm/src/lib.rs b/bridge-proxy/wasm/src/lib.rs new file mode 100644 index 00000000..89ef4fc9 --- /dev/null +++ b/bridge-proxy/wasm/src/lib.rs @@ -0,0 +1,24 @@ +// Code generated by the multiversx-sc multi-contract system. DO NOT EDIT. + +//////////////////////////////////////////////////// +////////////////// AUTO-GENERATED ////////////////// +//////////////////////////////////////////////////// + +// Init: 1 +// Endpoints: 0 +// Async Callback (empty): 1 +// Total number of exported functions: 2 + +#![no_std] +#![feature(lang_items)] + +multiversx_sc_wasm_adapter::allocator!(); +multiversx_sc_wasm_adapter::panic_handler!(); + +multiversx_sc_wasm_adapter::endpoints! { + empty + ( + ) +} + +multiversx_sc_wasm_adapter::empty_callback! {} From e373415e405c93c7d05106e98c9b5ebce4035a3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Tue, 11 Jul 2023 09:53:58 +0300 Subject: [PATCH 03/50] MultiTransfer: deposit funds and tx from Eth --- Cargo.toml | 1 + common/transaction/src/lib.rs | 11 +++++++++-- multi-transfer-esdt/Cargo.toml | 3 +++ multi-transfer-esdt/src/lib.rs | 22 +++++++++++++++++++--- multisig/src/util.rs | 2 +- 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f9432301..3edcae35 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,6 @@ [workspace] members = [ + "bridge-proxy", "esdt-safe", "esdt-safe/meta", "multi-transfer-esdt", diff --git a/common/transaction/src/lib.rs b/common/transaction/src/lib.rs index 89ec1753..d6e9bac3 100644 --- a/common/transaction/src/lib.rs +++ b/common/transaction/src/lib.rs @@ -37,8 +37,15 @@ pub struct EthTransaction { pub gas_limit: u64, } -pub type EthTxAsMultiValue = - MultiValue7, ManagedAddress, TokenIdentifier, BigUint, TxNonce, ManagedBuffer, u64>; +pub type EthTxAsMultiValue = MultiValue7< + EthAddress, + ManagedAddress, + TokenIdentifier, + BigUint, + TxNonce, + ManagedBuffer, + u64, +>; #[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, ManagedVecItem, Clone)] pub struct Transaction { diff --git a/multi-transfer-esdt/Cargo.toml b/multi-transfer-esdt/Cargo.toml index 18c9455e..8ed5ccac 100644 --- a/multi-transfer-esdt/Cargo.toml +++ b/multi-transfer-esdt/Cargo.toml @@ -19,6 +19,9 @@ path = "../common/max-bridged-amount-module" [dependencies.bridged-tokens-wrapper] path = "../bridged-tokens-wrapper" +[dependencies.bridge-proxy] +path = "../bridge-proxy" + [dependencies.multiversx-sc] version = "0.41.3" [dev-dependencies.multiversx-sc-scenario] diff --git a/multi-transfer-esdt/src/lib.rs b/multi-transfer-esdt/src/lib.rs index 015d9e42..de386226 100644 --- a/multi-transfer-esdt/src/lib.rs +++ b/multi-transfer-esdt/src/lib.rs @@ -6,6 +6,7 @@ use transaction::{EthTransaction, PaymentsVec, Transaction, TxBatchSplitInFields const DEFAULT_MAX_TX_BATCH_SIZE: usize = 10; const DEFAULT_MAX_TX_BATCH_BLOCK_DURATION: u64 = u64::MAX; +const MIN_GAS_LIMIT_FOR_SC_CALL: u64 = 10_000_000; #[multiversx_sc::contract] pub trait MultiTransferEsdt: @@ -41,7 +42,7 @@ pub trait MultiTransferEsdt: for eth_tx in transfers { let mut must_refund = false; - if eth_tx.to.is_zero() || self.blockchain().is_smart_contract(ð_tx.to) { + if eth_tx.to.is_zero() { self.transfer_failed_invalid_destination(batch_id, eth_tx.tx_nonce); must_refund = true; } else if !self.is_local_role_set(ð_tx.token_id, &EsdtLocalRole::Mint) { @@ -53,6 +54,10 @@ pub trait MultiTransferEsdt: } else if self.is_account_same_shard_frozen(sc_shard, ð_tx.to, ð_tx.token_id) { self.transfer_failed_frozen_destination_account(batch_id, eth_tx.tx_nonce); must_refund = true; + } else if self.blockchain().is_smart_contract(ð_tx.to) + && (eth_tx.data.is_empty() || eth_tx.gas_limit < MIN_GAS_LIMIT_FOR_SC_CALL) + { + must_refund = true; } if must_refund { @@ -68,8 +73,16 @@ pub trait MultiTransferEsdt: // emit event before the actual transfer so we don't have to save the tx_nonces as well self.transfer_performed_event(batch_id, eth_tx.tx_nonce); - valid_dest_addresses_list.push(eth_tx.to); - valid_payments_list.push(EsdtTokenPayment::new(eth_tx.token_id, 0, eth_tx.amount)); + if self.blockchain().is_smart_contract(ð_tx.to) { + let _: IgnoreValue = self + .bridge_proxy() + .deposit(ð_tx) + .with_esdt_transfer((eth_tx.token_id.clone(), 0, eth_tx.amount.clone())) + .execute_on_dest_context(); + } else { + valid_dest_addresses_list.push(eth_tx.to); + valid_payments_list.push(EsdtTokenPayment::new(eth_tx.token_id, 0, eth_tx.amount)); + } } let payments_after_wrapping = self.wrap_tokens(valid_payments_list); @@ -179,6 +192,9 @@ pub trait MultiTransferEsdt: self.wrapping_contract_proxy(self.wrapping_contract_address().get()) } + #[proxy] + fn bridge_proxy(&self) -> bridge_proxy::Proxy; + // storage #[view(getWrappingContractAddress)] diff --git a/multisig/src/util.rs b/multisig/src/util.rs index d47450b3..e4552e2c 100644 --- a/multisig/src/util.rs +++ b/multisig/src/util.rs @@ -58,7 +58,7 @@ pub trait UtilModule: crate::storage::StorageModule { amount, tx_nonce, data, - gas_limit + gas_limit, }); } From b3453404ca4042dc945ac0a14e2f63ceb575fa9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Tue, 11 Jul 2023 12:20:39 +0300 Subject: [PATCH 04/50] Framework update --- Cargo.toml | 1 + bridge-proxy/wasm/Cargo.lock | 60 ++++++++++---- bridge-proxy/wasm/src/lib.rs | 19 +++-- bridged-tokens-wrapper/wasm/Cargo.lock | 104 ++++++------------------ bridged-tokens-wrapper/wasm/src/lib.rs | 2 +- esdt-safe/wasm/src/lib.rs | 2 +- multi-transfer-esdt/wasm/Cargo.lock | 105 +++++++------------------ multi-transfer-esdt/wasm/src/lib.rs | 2 +- multisig/wasm/Cargo.lock | 105 +++++++------------------ multisig/wasm/src/lib.rs | 2 +- 10 files changed, 146 insertions(+), 256 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3edcae35..7720c88c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,7 @@ [workspace] members = [ "bridge-proxy", + "bridge-proxy/meta", "esdt-safe", "esdt-safe/meta", "multi-transfer-esdt", diff --git a/bridge-proxy/wasm/Cargo.lock b/bridge-proxy/wasm/Cargo.lock index 2c8edf0a..c5bac434 100644 --- a/bridge-proxy/wasm/Cargo.lock +++ b/bridge-proxy/wasm/Cargo.lock @@ -32,32 +32,40 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "empty" +name = "bridge-proxy" version = "0.0.0" dependencies = [ "multiversx-sc", + "transaction", ] [[package]] -name = "empty-wasm" +name = "bridge-proxy-wasm" version = "0.0.0" dependencies = [ - "empty", + "bridge-proxy", "multiversx-sc-wasm-adapter", ] +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + [[package]] name = "endian-type" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" +[[package]] +name = "eth-address" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + [[package]] name = "hashbrown" version = "0.13.2" @@ -82,6 +90,8 @@ checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" [[package]] name = "multiversx-sc" version = "0.41.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfbe80ec68fedf299dd65469f8999cf3c0f884ffa497122428f08303bcb8b884" dependencies = [ "bitflags", "hashbrown", @@ -94,6 +104,8 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d70ea458247d263b7e9fdfb207530b6a530546247139c162450e515c013a18" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -102,6 +114,8 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ad6920f80fda67fc60fd51aaa9f83ec7e069470f60a068c81205f9da5d05a30" dependencies = [ "hex", "proc-macro2", @@ -112,6 +126,8 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" version = "0.41.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c2b87d817f2176bf1830bef938884f24267516c334a377e71a96bc18ebb09c1" dependencies = [ "hex", "proc-macro2", @@ -123,6 +139,8 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" version = "0.41.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "932327626de71eeb1dbe86b863cc70cc532f8ceba8e73a059410f6aa56b22a77" dependencies = [ "multiversx-sc", ] @@ -153,18 +171,18 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "proc-macro2" -version = "1.0.60" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dec2b086b7a862cf4de201096214fa870344cf922b2b30c167badb3af3195406" +checksum = "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.28" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" dependencies = [ "proc-macro2", ] @@ -181,9 +199,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" [[package]] name = "syn" @@ -196,11 +214,19 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "transaction" +version = "0.0.0" +dependencies = [ + "eth-address", + "multiversx-sc", +] + [[package]] name = "unicode-ident" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" +checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" [[package]] name = "version_check" diff --git a/bridge-proxy/wasm/src/lib.rs b/bridge-proxy/wasm/src/lib.rs index 89ef4fc9..b2232364 100644 --- a/bridge-proxy/wasm/src/lib.rs +++ b/bridge-proxy/wasm/src/lib.rs @@ -5,9 +5,9 @@ //////////////////////////////////////////////////// // Init: 1 -// Endpoints: 0 -// Async Callback (empty): 1 -// Total number of exported functions: 2 +// Endpoints: 8 +// Async Callback: 1 +// Total number of exported functions: 10 #![no_std] #![feature(lang_items)] @@ -16,9 +16,16 @@ multiversx_sc_wasm_adapter::allocator!(); multiversx_sc_wasm_adapter::panic_handler!(); multiversx_sc_wasm_adapter::endpoints! { - empty + bridge_proxy ( + deposit + execute + executeWithAsnyc + refundTransactions + setupMultiTransfer + getMultiTransferAddress + getEthTransactionList + getEthFailedTransactionList + callBack ) } - -multiversx_sc_wasm_adapter::empty_callback! {} diff --git a/bridged-tokens-wrapper/wasm/Cargo.lock b/bridged-tokens-wrapper/wasm/Cargo.lock index f3a582a2..3e6072c5 100644 --- a/bridged-tokens-wrapper/wasm/Cargo.lock +++ b/bridged-tokens-wrapper/wasm/Cargo.lock @@ -8,16 +8,16 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "once_cell", "version_check", ] [[package]] name = "arrayvec" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "autocfg" @@ -48,12 +48,6 @@ dependencies = [ "multiversx-sc-wasm-adapter", ] -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - [[package]] name = "cfg-if" version = "1.0.0" @@ -94,23 +88,11 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" -[[package]] -name = "libc" -version = "0.2.139" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" - -[[package]] -name = "memory_units" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" - [[package]] name = "multiversx-sc" -version = "0.39.8" +version = "0.41.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31561133b64837f1a7835ae4ba96383ab07d9ce401e703ad2a37aef45789a1e7" +checksum = "bfbe80ec68fedf299dd65469f8999cf3c0f884ffa497122428f08303bcb8b884" dependencies = [ "bitflags", "hashbrown", @@ -122,20 +104,19 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.17.1" +version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7638cb46a0e99c636fd55443ac534ff0a5fad0bd772e1037fbac9a75e04c3c9" +checksum = "71d70ea458247d263b7e9fdfb207530b6a530546247139c162450e515c013a18" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", - "wee_alloc", ] [[package]] name = "multiversx-sc-codec-derive" -version = "0.17.1" +version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e976002d51367f16140929c10ee695f95dd8d34c150a45db60d3fcd1328a267a" +checksum = "3ad6920f80fda67fc60fd51aaa9f83ec7e069470f60a068c81205f9da5d05a30" dependencies = [ "hex", "proc-macro2", @@ -145,9 +126,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.39.8" +version = "0.41.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23187464277575f8055c92cffbd664592825591f5cebb8dae038d2af04c5e639" +checksum = "1c2b87d817f2176bf1830bef938884f24267516c334a377e71a96bc18ebb09c1" dependencies = [ "hex", "proc-macro2", @@ -158,21 +139,20 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.39.8" +version = "0.41.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbcb0b06f37396484f01d89295091db401b8b515ab781e3580a6bb333e912591" +checksum = "704825223788bfdfd622980cae8feedae82609fded5ef5f53af31661d5e02312" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.39.8" +version = "0.41.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af5fee54f1498ec8181593cd54a96ef7436543ad78848e2e805b9b62c27c4095" +checksum = "932327626de71eeb1dbe86b863cc70cc532f8ceba8e73a059410f6aa56b22a77" dependencies = [ "multiversx-sc", - "wee_alloc", ] [[package]] @@ -195,24 +175,24 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.1" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "proc-macro2" -version = "1.0.51" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" +checksum = "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.23" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" dependencies = [ "proc-macro2", ] @@ -229,9 +209,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" [[package]] name = "syn" @@ -254,46 +234,12 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.8" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" [[package]] name = "version_check" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "wee_alloc" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e" -dependencies = [ - "cfg-if 0.1.10", - "libc", - "memory_units", - "winapi", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/bridged-tokens-wrapper/wasm/src/lib.rs b/bridged-tokens-wrapper/wasm/src/lib.rs index ca27291f..99d29ded 100644 --- a/bridged-tokens-wrapper/wasm/src/lib.rs +++ b/bridged-tokens-wrapper/wasm/src/lib.rs @@ -10,7 +10,7 @@ // Total number of exported functions: 18 #![no_std] -#![feature(alloc_error_handler, lang_items)] +#![feature(lang_items)] multiversx_sc_wasm_adapter::allocator!(); multiversx_sc_wasm_adapter::panic_handler!(); diff --git a/esdt-safe/wasm/src/lib.rs b/esdt-safe/wasm/src/lib.rs index bb0d544d..2377e18f 100644 --- a/esdt-safe/wasm/src/lib.rs +++ b/esdt-safe/wasm/src/lib.rs @@ -10,7 +10,7 @@ // Total number of exported functions: 33 #![no_std] -#![feature(alloc_error_handler, lang_items)] +#![feature(lang_items)] multiversx_sc_wasm_adapter::allocator!(); multiversx_sc_wasm_adapter::panic_handler!(); diff --git a/multi-transfer-esdt/wasm/Cargo.lock b/multi-transfer-esdt/wasm/Cargo.lock index fa0324f9..148d8db4 100644 --- a/multi-transfer-esdt/wasm/Cargo.lock +++ b/multi-transfer-esdt/wasm/Cargo.lock @@ -8,7 +8,7 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "once_cell", "version_check", ] @@ -32,19 +32,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] -name = "bridged-tokens-wrapper" +name = "bridge-proxy" version = "0.0.0" dependencies = [ "multiversx-sc", - "multiversx-sc-modules", "transaction", ] [[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +name = "bridged-tokens-wrapper" +version = "0.0.0" +dependencies = [ + "multiversx-sc", + "multiversx-sc-modules", + "transaction", +] [[package]] name = "cfg-if" @@ -86,12 +88,6 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" -[[package]] -name = "libc" -version = "0.2.147" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" - [[package]] name = "max-bridged-amount-module" version = "0.0.0" @@ -99,16 +95,11 @@ dependencies = [ "multiversx-sc", ] -[[package]] -name = "memory_units" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" - [[package]] name = "multi-transfer-esdt" version = "0.0.0" dependencies = [ + "bridge-proxy", "bridged-tokens-wrapper", "max-bridged-amount-module", "multiversx-sc", @@ -126,9 +117,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.39.8" +version = "0.41.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31561133b64837f1a7835ae4ba96383ab07d9ce401e703ad2a37aef45789a1e7" +checksum = "bfbe80ec68fedf299dd65469f8999cf3c0f884ffa497122428f08303bcb8b884" dependencies = [ "bitflags", "hashbrown", @@ -140,20 +131,19 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.17.1" +version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7638cb46a0e99c636fd55443ac534ff0a5fad0bd772e1037fbac9a75e04c3c9" +checksum = "71d70ea458247d263b7e9fdfb207530b6a530546247139c162450e515c013a18" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", - "wee_alloc", ] [[package]] name = "multiversx-sc-codec-derive" -version = "0.17.1" +version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e976002d51367f16140929c10ee695f95dd8d34c150a45db60d3fcd1328a267a" +checksum = "3ad6920f80fda67fc60fd51aaa9f83ec7e069470f60a068c81205f9da5d05a30" dependencies = [ "hex", "proc-macro2", @@ -163,9 +153,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.39.8" +version = "0.41.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23187464277575f8055c92cffbd664592825591f5cebb8dae038d2af04c5e639" +checksum = "1c2b87d817f2176bf1830bef938884f24267516c334a377e71a96bc18ebb09c1" dependencies = [ "hex", "proc-macro2", @@ -176,21 +166,20 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.39.8" +version = "0.41.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbcb0b06f37396484f01d89295091db401b8b515ab781e3580a6bb333e912591" +checksum = "704825223788bfdfd622980cae8feedae82609fded5ef5f53af31661d5e02312" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.39.8" +version = "0.41.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af5fee54f1498ec8181593cd54a96ef7436543ad78848e2e805b9b62c27c4095" +checksum = "932327626de71eeb1dbe86b863cc70cc532f8ceba8e73a059410f6aa56b22a77" dependencies = [ "multiversx-sc", - "wee_alloc", ] [[package]] @@ -219,18 +208,18 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "proc-macro2" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb" +checksum = "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.28" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" dependencies = [ "proc-macro2", ] @@ -247,9 +236,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" [[package]] name = "syn" @@ -280,46 +269,12 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" +checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" [[package]] name = "version_check" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "wee_alloc" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e" -dependencies = [ - "cfg-if 0.1.10", - "libc", - "memory_units", - "winapi", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/multi-transfer-esdt/wasm/src/lib.rs b/multi-transfer-esdt/wasm/src/lib.rs index 86ea70f1..fb1d87df 100644 --- a/multi-transfer-esdt/wasm/src/lib.rs +++ b/multi-transfer-esdt/wasm/src/lib.rs @@ -10,7 +10,7 @@ // Total number of exported functions: 16 #![no_std] -#![feature(alloc_error_handler, lang_items)] +#![feature(lang_items)] multiversx_sc_wasm_adapter::allocator!(); multiversx_sc_wasm_adapter::panic_handler!(); diff --git a/multisig/wasm/Cargo.lock b/multisig/wasm/Cargo.lock index deda533d..885193d3 100644 --- a/multisig/wasm/Cargo.lock +++ b/multisig/wasm/Cargo.lock @@ -8,7 +8,7 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "once_cell", "version_check", ] @@ -32,19 +32,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] -name = "bridged-tokens-wrapper" +name = "bridge-proxy" version = "0.0.0" dependencies = [ "multiversx-sc", - "multiversx-sc-modules", "transaction", ] [[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +name = "bridged-tokens-wrapper" +version = "0.0.0" +dependencies = [ + "multiversx-sc", + "multiversx-sc-modules", + "transaction", +] [[package]] name = "cfg-if" @@ -107,12 +109,6 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" -[[package]] -name = "libc" -version = "0.2.147" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" - [[package]] name = "max-bridged-amount-module" version = "0.0.0" @@ -120,16 +116,11 @@ dependencies = [ "multiversx-sc", ] -[[package]] -name = "memory_units" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" - [[package]] name = "multi-transfer-esdt" version = "0.0.0" dependencies = [ + "bridge-proxy", "bridged-tokens-wrapper", "max-bridged-amount-module", "multiversx-sc", @@ -163,9 +154,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.39.8" +version = "0.41.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31561133b64837f1a7835ae4ba96383ab07d9ce401e703ad2a37aef45789a1e7" +checksum = "bfbe80ec68fedf299dd65469f8999cf3c0f884ffa497122428f08303bcb8b884" dependencies = [ "bitflags", "hashbrown", @@ -177,20 +168,19 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.17.1" +version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7638cb46a0e99c636fd55443ac534ff0a5fad0bd772e1037fbac9a75e04c3c9" +checksum = "71d70ea458247d263b7e9fdfb207530b6a530546247139c162450e515c013a18" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", - "wee_alloc", ] [[package]] name = "multiversx-sc-codec-derive" -version = "0.17.1" +version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e976002d51367f16140929c10ee695f95dd8d34c150a45db60d3fcd1328a267a" +checksum = "3ad6920f80fda67fc60fd51aaa9f83ec7e069470f60a068c81205f9da5d05a30" dependencies = [ "hex", "proc-macro2", @@ -200,9 +190,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.39.8" +version = "0.41.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23187464277575f8055c92cffbd664592825591f5cebb8dae038d2af04c5e639" +checksum = "1c2b87d817f2176bf1830bef938884f24267516c334a377e71a96bc18ebb09c1" dependencies = [ "hex", "proc-macro2", @@ -213,21 +203,20 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.39.8" +version = "0.41.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbcb0b06f37396484f01d89295091db401b8b515ab781e3580a6bb333e912591" +checksum = "704825223788bfdfd622980cae8feedae82609fded5ef5f53af31661d5e02312" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.39.8" +version = "0.41.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af5fee54f1498ec8181593cd54a96ef7436543ad78848e2e805b9b62c27c4095" +checksum = "932327626de71eeb1dbe86b863cc70cc532f8ceba8e73a059410f6aa56b22a77" dependencies = [ "multiversx-sc", - "wee_alloc", ] [[package]] @@ -256,18 +245,18 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "proc-macro2" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb" +checksum = "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.28" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" dependencies = [ "proc-macro2", ] @@ -284,9 +273,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" [[package]] name = "syn" @@ -325,46 +314,12 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" +checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" [[package]] name = "version_check" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "wee_alloc" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e" -dependencies = [ - "cfg-if 0.1.10", - "libc", - "memory_units", - "winapi", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/multisig/wasm/src/lib.rs b/multisig/wasm/src/lib.rs index 4cf423c2..ea52cff9 100644 --- a/multisig/wasm/src/lib.rs +++ b/multisig/wasm/src/lib.rs @@ -10,7 +10,7 @@ // Total number of exported functions: 63 #![no_std] -#![feature(alloc_error_handler, lang_items)] +#![feature(lang_items)] multiversx_sc_wasm_adapter::allocator!(); multiversx_sc_wasm_adapter::panic_handler!(); From e92448692d234d0aa1b758278bd9bec2174bfc13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Wed, 12 Jul 2023 09:29:13 +0300 Subject: [PATCH 05/50] Bridge-proxy & Multi-Transfer Send failed transactions from Bridge-Proxy to Multi-Transfer-Esdt --- bridge-proxy/src/bridge-proxy.rs | 43 +++++++++++++++-------------- bridge-proxy/src/config.rs | 10 +------ bridge-proxy/wasm/src/lib.rs | 5 ++-- common/transaction/src/lib.rs | 8 ++++++ multi-transfer-esdt/src/lib.rs | 18 +++++++++++- multi-transfer-esdt/wasm/src/lib.rs | 5 ++-- 6 files changed, 54 insertions(+), 35 deletions(-) diff --git a/bridge-proxy/src/bridge-proxy.rs b/bridge-proxy/src/bridge-proxy.rs index 6edaa9c6..35404f06 100644 --- a/bridge-proxy/src/bridge-proxy.rs +++ b/bridge-proxy/src/bridge-proxy.rs @@ -5,8 +5,7 @@ multiversx_sc::derive_imports!(); mod config; -use config::EthTransactionPayment; -use transaction::EthTransaction; +use transaction::{EthTransaction, EthTransactionPayment}; /// An empty contract. To be used as a template when starting a new contract from scratch. #[multiversx_sc::contract] @@ -29,28 +28,14 @@ pub trait BridgeProxyContract: config::ConfigModule { }); } - #[endpoint] - fn execute(&self) { - for loop_tx in self.eth_transaction_list().iter() { - let tx = loop_tx.get_value_as_ref(); - self.send() - .contract_call::(tx.eth_tx.to.clone(), tx.eth_tx.data.clone()) - .with_esdt_transfer((tx.token_id.clone(), tx.nonce, tx.amount.clone())) - .with_gas_limit(tx.eth_tx.gas_limit) - .transfer_execute(); - - //TODO Check if transaction failed, add it to `eth_failed_transaction_list` - } - } - #[endpoint(executeWithAsnyc)] - fn execute_with_async(&self) { + fn execute_with_async(&self, tx_id: u32) { let tx_node = self .eth_transaction_list() - .front() + .remove_node_by_id(tx_id) .unwrap_or_else(|| sc_panic!("No more ETH transactions!")); let tx = tx_node.get_value_as_ref(); - + self.send() .contract_call::(tx.eth_tx.to.clone(), tx.eth_tx.data.clone()) .with_esdt_transfer((tx.token_id.clone(), tx.nonce, tx.amount.clone())) @@ -66,5 +51,23 @@ pub trait BridgeProxyContract: config::ConfigModule { } #[endpoint(refundTransactions)] - fn refund_transactions(&self) {} + fn refund_transactions(&self) -> MultiValueEncoded> { + // Send Failed Tx Structure + let mut result = MultiValueEncoded::new(); + for tx_loop in self.eth_failed_transaction_list().iter() { + let tx = tx_loop.get_value_cloned(); + result.push(tx); + } + + // Send Funds + let mut all_payments = ManagedVec::new(); + for failed_tx_loop in self.eth_failed_transaction_list().into_iter() { + let failed_tx = failed_tx_loop.get_value_as_ref(); + + all_payments.push(EsdtTokenPayment::new(failed_tx.token_id.clone(), failed_tx.nonce, failed_tx.amount.clone())); + } + self.send().direct_multi(&self.multi_transfer_address().get(), &all_payments); + + result + } } diff --git a/bridge-proxy/src/config.rs b/bridge-proxy/src/config.rs index bf9e6f43..2f035cdd 100644 --- a/bridge-proxy/src/config.rs +++ b/bridge-proxy/src/config.rs @@ -1,15 +1,7 @@ multiversx_sc::imports!(); multiversx_sc::derive_imports!(); -use transaction::EthTransaction; - -#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, Clone)] -pub struct EthTransactionPayment { - pub token_id: TokenIdentifier, - pub nonce: u64, - pub amount: BigUint, - pub eth_tx: EthTransaction, -} +use transaction::EthTransactionPayment; #[multiversx_sc::module] pub trait ConfigModule { diff --git a/bridge-proxy/wasm/src/lib.rs b/bridge-proxy/wasm/src/lib.rs index b2232364..540a82e4 100644 --- a/bridge-proxy/wasm/src/lib.rs +++ b/bridge-proxy/wasm/src/lib.rs @@ -5,9 +5,9 @@ //////////////////////////////////////////////////// // Init: 1 -// Endpoints: 8 +// Endpoints: 7 // Async Callback: 1 -// Total number of exported functions: 10 +// Total number of exported functions: 9 #![no_std] #![feature(lang_items)] @@ -19,7 +19,6 @@ multiversx_sc_wasm_adapter::endpoints! { bridge_proxy ( deposit - execute executeWithAsnyc refundTransactions setupMultiTransfer diff --git a/common/transaction/src/lib.rs b/common/transaction/src/lib.rs index d6e9bac3..c2098019 100644 --- a/common/transaction/src/lib.rs +++ b/common/transaction/src/lib.rs @@ -47,6 +47,14 @@ pub type EthTxAsMultiValue = MultiValue7< u64, >; +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, ManagedVecItem, Clone)] +pub struct EthTransactionPayment { + pub token_id: TokenIdentifier, + pub nonce: u64, + pub amount: BigUint, + pub eth_tx: EthTransaction, +} + #[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, ManagedVecItem, Clone)] pub struct Transaction { pub block_nonce: BlockNonce, diff --git a/multi-transfer-esdt/src/lib.rs b/multi-transfer-esdt/src/lib.rs index de386226..065743f8 100644 --- a/multi-transfer-esdt/src/lib.rs +++ b/multi-transfer-esdt/src/lib.rs @@ -2,7 +2,7 @@ multiversx_sc::imports!(); -use transaction::{EthTransaction, PaymentsVec, Transaction, TxBatchSplitInFields}; +use transaction::{EthTransaction, PaymentsVec, Transaction, TxBatchSplitInFields, EthTransactionPayment}; const DEFAULT_MAX_TX_BATCH_SIZE: usize = 10; const DEFAULT_MAX_TX_BATCH_BLOCK_DURATION: u64 = u64::MAX; @@ -121,6 +121,22 @@ pub trait MultiTransferEsdt: } } + #[endpoint(getFailedTxFromBridgeProxy)] + fn get_failed_tx_from_bridge_proxy(&self) { + let mut refund_tx_list = ManagedVec::new(); + + let failed_txs: MultiValueEncoded> = self + .bridge_proxy() + .refund_transactions() + .execute_on_dest_context(); + + for failed_tx in failed_txs { + let refund_tx = self.convert_to_refund_tx(failed_tx.eth_tx); + refund_tx_list.push(refund_tx); + } + + self.add_multiple_tx_to_batch(&refund_tx_list); + } // private fn convert_to_refund_tx(&self, eth_tx: EthTransaction) -> Transaction { diff --git a/multi-transfer-esdt/wasm/src/lib.rs b/multi-transfer-esdt/wasm/src/lib.rs index fb1d87df..adeca473 100644 --- a/multi-transfer-esdt/wasm/src/lib.rs +++ b/multi-transfer-esdt/wasm/src/lib.rs @@ -5,9 +5,9 @@ //////////////////////////////////////////////////// // Init: 1 -// Endpoints: 14 +// Endpoints: 15 // Async Callback (empty): 1 -// Total number of exported functions: 16 +// Total number of exported functions: 17 #![no_std] #![feature(lang_items)] @@ -21,6 +21,7 @@ multiversx_sc_wasm_adapter::endpoints! { batchTransferEsdtToken getAndClearFirstRefundBatch setWrappingContractAddress + getFailedTxFromBridgeProxy getWrappingContractAddress setMaxTxBatchSize setMaxTxBatchBlockDuration From 76a97e65e06d0821a267c1734cc6e87a1375b63f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Wed, 9 Aug 2023 15:57:15 +0300 Subject: [PATCH 06/50] Tests fix --- bridge-proxy/src/bridge-proxy.rs | 1 - .../batch_transfer_both_executed.scen.json | 4 +- .../batch_transfer_both_failed.scen.json | 68 +-------------- ...transfer_one_executed_one_failed.scen.json | 15 +--- ...batch_transfer_to_frozen_account.scen.json | 4 +- .../batch_transfer_with_wrapping.scen.json | 9 +- .../mandos/setup_accounts.scen.json | 84 ++++++++++++++++++- .../mandos/transfer_ok.scen.json | 2 +- .../mandos/two_transfers_same_token.scen.json | 4 +- multi-transfer-esdt/src/lib.rs | 51 +++++++++-- multi-transfer-esdt/wasm/src/lib.rs | 6 +- 11 files changed, 146 insertions(+), 102 deletions(-) diff --git a/bridge-proxy/src/bridge-proxy.rs b/bridge-proxy/src/bridge-proxy.rs index 35404f06..df5f6447 100644 --- a/bridge-proxy/src/bridge-proxy.rs +++ b/bridge-proxy/src/bridge-proxy.rs @@ -7,7 +7,6 @@ mod config; use transaction::{EthTransaction, EthTransactionPayment}; -/// An empty contract. To be used as a template when starting a new contract from scratch. #[multiversx_sc::contract] pub trait BridgeProxyContract: config::ConfigModule { #[init] diff --git a/multi-transfer-esdt/mandos/batch_transfer_both_executed.scen.json b/multi-transfer-esdt/mandos/batch_transfer_both_executed.scen.json index e64ad857..b4417975 100644 --- a/multi-transfer-esdt/mandos/batch_transfer_both_executed.scen.json +++ b/multi-transfer-esdt/mandos/batch_transfer_both_executed.scen.json @@ -15,8 +15,8 @@ "function": "batchTransferEsdtToken", "arguments": [ "1", - "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1", - "0x0102030405060708091011121314151617181920|address:user2|nested:str:WRAPPED-123456|biguint:500|u64:2" + "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:10000000", + "0x0102030405060708091011121314151617181920|address:user2|nested:str:WRAPPED-123456|biguint:500|u64:2|nested:str:data|u64:10000000" ], "gasLimit": "50,000,000", "gasPrice": "0" diff --git a/multi-transfer-esdt/mandos/batch_transfer_both_failed.scen.json b/multi-transfer-esdt/mandos/batch_transfer_both_failed.scen.json index a9b34ac0..aab426d6 100644 --- a/multi-transfer-esdt/mandos/batch_transfer_both_failed.scen.json +++ b/multi-transfer-esdt/mandos/batch_transfer_both_failed.scen.json @@ -15,8 +15,8 @@ "function": "batchTransferEsdtToken", "arguments": [ "1", - "0x0102030405060708091011121314151617181920|sc:multi_transfer_esdt|nested:str:BRIDGE-123456|biguint:100,200|u64:1", - "0x0102030405060708091011121314151617181920|sc:multi_transfer_esdt|nested:str:WRAPPED-123456|biguint:100,500|u64:2" + "0x0102030405060708091011121314151617181920|sc:multi_transfer_esdt|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:20000000", + "0x0102030405060708091011121314151617181920|sc:multi_transfer_esdt|nested:str:WRAPPED-123456|biguint:100,500|u64:2|nested:str:data|u64:20000000" ], "gasLimit": "50,000,000", "gasPrice": "0" @@ -37,70 +37,6 @@ "function": "getFirstBatchAnyStatus", "arguments": [] }, - "expect": { - "out": [ - "1", - - "0", - "1", - "0x0102030405060708091011121314151617181920", - "sc:multi_transfer_esdt", - "str:BRIDGE-123456", - "100,200", - - "0", - "2", - "0x0102030405060708091011121314151617181920", - "sc:multi_transfer_esdt", - "str:WRAPPED-123456", - "100,500" - ] - } - }, - { - "step": "scCall", - "txId": "clear-refund-batch", - "tx": { - "from": "address:owner", - "to": "sc:multi_transfer_esdt", - "value": "0", - "function": "getAndClearFirstRefundBatch", - "arguments": [], - "gasLimit": "50,000,000", - "gasPrice": "0" - }, - "expect": { - "status": "0", - "message": "", - "out": [ - "1", - - "0", - "1", - "0x0102030405060708091011121314151617181920", - "sc:multi_transfer_esdt", - "str:BRIDGE-123456", - "100,200", - - "0", - "2", - "0x0102030405060708091011121314151617181920", - "sc:multi_transfer_esdt", - "str:WRAPPED-123456", - "100,500" - ], - "gas": "*", - "refund": "*" - } - }, - { - "step": "scQuery", - "txId": "get-current-refund-tx-batch-after-clear", - "tx": { - "to": "sc:multi_transfer_esdt", - "function": "getFirstBatchAnyStatus", - "arguments": [] - }, "expect": { "out": [] } diff --git a/multi-transfer-esdt/mandos/batch_transfer_one_executed_one_failed.scen.json b/multi-transfer-esdt/mandos/batch_transfer_one_executed_one_failed.scen.json index 7ee4cb31..94771439 100644 --- a/multi-transfer-esdt/mandos/batch_transfer_one_executed_one_failed.scen.json +++ b/multi-transfer-esdt/mandos/batch_transfer_one_executed_one_failed.scen.json @@ -15,8 +15,8 @@ "function": "batchTransferEsdtToken", "arguments": [ "1", - "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1", - "0x0102030405060708091011121314151617181920|sc:multi_transfer_esdt|nested:str:WRAPPED-123456|biguint:500|u64:2" + "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:10000000", + "0x0102030405060708091011121314151617181920|sc:multi_transfer_esdt|nested:str:WRAPPED-123456|biguint:500|u64:2|nested:str:getWrappingContractAddress|u64:10000000" ], "gasLimit": "50,000,000", "gasPrice": "0" @@ -52,16 +52,7 @@ "arguments": [] }, "expect": { - "out": [ - "1", - - "0", - "2", - "0x0102030405060708091011121314151617181920", - "sc:multi_transfer_esdt", - "str:WRAPPED-123456", - "500" - ] + "out": [] } } ] diff --git a/multi-transfer-esdt/mandos/batch_transfer_to_frozen_account.scen.json b/multi-transfer-esdt/mandos/batch_transfer_to_frozen_account.scen.json index 53ffbc12..dcf91222 100644 --- a/multi-transfer-esdt/mandos/batch_transfer_to_frozen_account.scen.json +++ b/multi-transfer-esdt/mandos/batch_transfer_to_frozen_account.scen.json @@ -35,8 +35,8 @@ "function": "batchTransferEsdtToken", "arguments": [ "1", - "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1", - "0x0102030405060708091011121314151617181920|address:frozen_user|nested:str:BRIDGE-123456|biguint:500|u64:2" + "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:10000000", + "0x0102030405060708091011121314151617181920|address:frozen_user|nested:str:BRIDGE-123456|biguint:500|u64:2|nested:str:data|u64:10000000" ], "gasLimit": "50,000,000", "gasPrice": "0" diff --git a/multi-transfer-esdt/mandos/batch_transfer_with_wrapping.scen.json b/multi-transfer-esdt/mandos/batch_transfer_with_wrapping.scen.json index 07bb451c..c24baa4c 100644 --- a/multi-transfer-esdt/mandos/batch_transfer_with_wrapping.scen.json +++ b/multi-transfer-esdt/mandos/batch_transfer_with_wrapping.scen.json @@ -82,7 +82,8 @@ "str:maxTxBatchBlockDuration": "3,600", "str:firstBatchId": "1", "str:lastBatchId": "1", - "str:wrappingContractAddress": "sc:bridged_tokens_wrapper" + "str:wrappingContractAddress": "sc:bridged_tokens_wrapper", + "str:bridgeProxyContractAddress": "sc:bridge-proxy" }, "code": "file:../output/multi-transfer-esdt.wasm", "owner": "address:owner" @@ -99,9 +100,9 @@ "function": "batchTransferEsdtToken", "arguments": [ "1", - "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1", - "0x0102030405060708091011121314151617181920|address:user2|nested:str:USDC-aaaaaa|biguint:500|u64:2", - "0x0102030405060708091011121314151617181920|address:user1|nested:str:USDC-cccccc|biguint:1000|u64:3" + "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:20000000", + "0x0102030405060708091011121314151617181920|address:user2|nested:str:USDC-aaaaaa|biguint:500|u64:2|nested:str:data|u64:20000000", + "0x0102030405060708091011121314151617181920|address:user1|nested:str:USDC-cccccc|biguint:1000|u64:3|nested:str:data|u64:20000000" ], "gasLimit": "50,000,000", "gasPrice": "0" diff --git a/multi-transfer-esdt/mandos/setup_accounts.scen.json b/multi-transfer-esdt/mandos/setup_accounts.scen.json index 37240de8..31310507 100644 --- a/multi-transfer-esdt/mandos/setup_accounts.scen.json +++ b/multi-transfer-esdt/mandos/setup_accounts.scen.json @@ -25,6 +25,11 @@ "creatorAddress": "address:owner", "creatorNonce": "0", "newAddress": "sc:multi_transfer_esdt" + }, + { + "creatorAddress": "address:owner", + "creatorNonce": "1", + "newAddress": "sc:bridge-proxy" } ] }, @@ -46,6 +51,82 @@ "refund": "*" } }, + { + "step": "scDeploy", + "txId": "deploy", + "tx": { + "from": "address:owner", + "contractCode": "file:../../bridge-proxy/output/bridge-proxy.wasm", + "value": "0", + "arguments": ["sc:multi_transfer_esdt"], + "gasLimit": "20,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "txId": "add-bridge-proxy-to-multi-transfer", + "tx": { + "from": "address:owner", + "to": "sc:multi_transfer_esdt", + "function": "setBridgeProxyContractAddress", + "arguments": [ + "sc:bridge-proxy" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, + { + "step": "checkState", + "accounts": { + "address:owner": { + "nonce": "3", + "balance": "0", + "storage": {} + }, + "address:user1": { + "nonce": "0", + "balance": "0", + "storage": {} + }, + "address:user2": { + "nonce": "0", + "balance": "0", + "storage": {} + }, + "sc:multi_transfer_esdt": { + "code":"file:../output/multi-transfer-esdt.wasm", + "nonce": "0", + "balance": "0", + "storage": { + "str:firstBatchId": "1", + "str:lastBatchId": "1", + "str:bridgeProxyContractAddress": "sc:bridge-proxy", + "str:maxTxBatchSize": "10", + "str:maxTxBatchBlockDuration": "0xffffffffffffffff" + } + }, + "sc:bridge-proxy": { + "code":"file:../../bridge-proxy/output/bridge-proxy.wasm", + "nonce": "0", + "balance": "0", + "storage": "*" + } + } + }, { "step": "setState", "comment": "setting local mint role", @@ -71,7 +152,8 @@ "str:maxTxBatchSize": "10", "str:maxTxBatchBlockDuration": "3,600", "str:firstBatchId": "1", - "str:lastBatchId": "1" + "str:lastBatchId": "1", + "str:bridgeProxyContractAddress": "sc:bridge-proxy" }, "code": "file:../output/multi-transfer-esdt.wasm", "owner": "address:owner" diff --git a/multi-transfer-esdt/mandos/transfer_ok.scen.json b/multi-transfer-esdt/mandos/transfer_ok.scen.json index 85911b69..4768ca5e 100644 --- a/multi-transfer-esdt/mandos/transfer_ok.scen.json +++ b/multi-transfer-esdt/mandos/transfer_ok.scen.json @@ -15,7 +15,7 @@ "function": "batchTransferEsdtToken", "arguments": [ "1", - "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1" + "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:10000000" ], "gasLimit": "50,000,000", "gasPrice": "0" diff --git a/multi-transfer-esdt/mandos/two_transfers_same_token.scen.json b/multi-transfer-esdt/mandos/two_transfers_same_token.scen.json index 4799f41f..02d29c99 100644 --- a/multi-transfer-esdt/mandos/two_transfers_same_token.scen.json +++ b/multi-transfer-esdt/mandos/two_transfers_same_token.scen.json @@ -15,8 +15,8 @@ "function": "batchTransferEsdtToken", "arguments": [ "1", - "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1", - "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:2" + "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:10000000", + "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:2|nested:str:data|u64:10000000" ], "gasLimit": "50,000,000", "gasPrice": "0" diff --git a/multi-transfer-esdt/src/lib.rs b/multi-transfer-esdt/src/lib.rs index 065743f8..df937aa4 100644 --- a/multi-transfer-esdt/src/lib.rs +++ b/multi-transfer-esdt/src/lib.rs @@ -2,7 +2,9 @@ multiversx_sc::imports!(); -use transaction::{EthTransaction, PaymentsVec, Transaction, TxBatchSplitInFields, EthTransactionPayment}; +use transaction::{ + EthTransaction, EthTransactionPayment, PaymentsVec, Transaction, TxBatchSplitInFields, +}; const DEFAULT_MAX_TX_BATCH_SIZE: usize = 10; const DEFAULT_MAX_TX_BATCH_BLOCK_DURATION: u64 = u64::MAX; @@ -13,13 +15,18 @@ pub trait MultiTransferEsdt: tx_batch_module::TxBatchModule + max_bridged_amount_module::MaxBridgedAmountModule { #[init] - fn init(&self, opt_wrapping_contract_address: OptionalValue) { + fn init( + &self, + opt_bridge_proxy_contract_address: OptionalValue, + opt_wrapping_contract_address: OptionalValue, + ) { self.max_tx_batch_size() .set_if_empty(DEFAULT_MAX_TX_BATCH_SIZE); self.max_tx_batch_block_duration() .set_if_empty(DEFAULT_MAX_TX_BATCH_BLOCK_DURATION); self.set_wrapping_contract_address(opt_wrapping_contract_address); + self.set_bridge_proxy_contract_address(opt_bridge_proxy_contract_address); // batch ID 0 is considered invalid self.first_batch_id().set_if_empty(1); @@ -73,15 +80,17 @@ pub trait MultiTransferEsdt: // emit event before the actual transfer so we don't have to save the tx_nonces as well self.transfer_performed_event(batch_id, eth_tx.tx_nonce); - if self.blockchain().is_smart_contract(ð_tx.to) { + + if self.blockchain().is_smart_contract(ð_tx.to.clone()) { + let bridge_proxy_addr = self.bridge_proxy_contract_address().get(); let _: IgnoreValue = self - .bridge_proxy() + .bridge_proxy(bridge_proxy_addr) .deposit(ð_tx) .with_esdt_transfer((eth_tx.token_id.clone(), 0, eth_tx.amount.clone())) .execute_on_dest_context(); } else { valid_dest_addresses_list.push(eth_tx.to); - valid_payments_list.push(EsdtTokenPayment::new(eth_tx.token_id, 0, eth_tx.amount)); + // valid_payments_list.push(EsdtTokenPayment::new(eth_tx.token_id, 0, eth_tx.amount)); } } @@ -121,18 +130,35 @@ pub trait MultiTransferEsdt: } } + #[only_owner] + #[endpoint(setBridgeProxyContractAddress)] + fn set_bridge_proxy_contract_address(&self, opt_new_address: OptionalValue) { + match opt_new_address { + OptionalValue::Some(sc_addr) => { + require!( + self.blockchain().is_smart_contract(&sc_addr), + "Invalid bridge proxy contract address" + ); + + self.bridge_proxy_contract_address().set(&sc_addr); + } + OptionalValue::None => self.bridge_proxy_contract_address().clear(), + } + } + #[endpoint(getFailedTxFromBridgeProxy)] fn get_failed_tx_from_bridge_proxy(&self) { let mut refund_tx_list = ManagedVec::new(); + let bridge_proxy_addr = self.bridge_proxy_contract_address().get(); let failed_txs: MultiValueEncoded> = self - .bridge_proxy() + .bridge_proxy(bridge_proxy_addr) .refund_transactions() .execute_on_dest_context(); for failed_tx in failed_txs { let refund_tx = self.convert_to_refund_tx(failed_tx.eth_tx); - refund_tx_list.push(refund_tx); + refund_tx_list.push(refund_tx); } self.add_multiple_tx_to_batch(&refund_tx_list); @@ -209,14 +235,21 @@ pub trait MultiTransferEsdt: } #[proxy] - fn bridge_proxy(&self) -> bridge_proxy::Proxy; + fn bridge_proxy(&self, sc_address: ManagedAddress) -> bridge_proxy::Proxy; - // storage + fn get_bridge_proxy_contract_proxy_instance(&self) -> bridge_proxy::Proxy { + self.bridge_proxy(self.bridge_proxy_contract_address().get()) + } + // storage #[view(getWrappingContractAddress)] #[storage_mapper("wrappingContractAddress")] fn wrapping_contract_address(&self) -> SingleValueMapper; + #[view(getBridgeProxyContractAddress)] + #[storage_mapper("bridgeProxyContractAddress")] + fn bridge_proxy_contract_address(&self) -> SingleValueMapper; + // events #[event("transferPerformedEvent")] diff --git a/multi-transfer-esdt/wasm/src/lib.rs b/multi-transfer-esdt/wasm/src/lib.rs index adeca473..68f1f328 100644 --- a/multi-transfer-esdt/wasm/src/lib.rs +++ b/multi-transfer-esdt/wasm/src/lib.rs @@ -5,9 +5,9 @@ //////////////////////////////////////////////////// // Init: 1 -// Endpoints: 15 +// Endpoints: 17 // Async Callback (empty): 1 -// Total number of exported functions: 17 +// Total number of exported functions: 19 #![no_std] #![feature(lang_items)] @@ -21,8 +21,10 @@ multiversx_sc_wasm_adapter::endpoints! { batchTransferEsdtToken getAndClearFirstRefundBatch setWrappingContractAddress + setBridgeProxyContractAddress getFailedTxFromBridgeProxy getWrappingContractAddress + getBridgeProxyContractAddress setMaxTxBatchSize setMaxTxBatchBlockDuration getCurrentTxBatch From e70cd371aa3bd8ce20e5954a4d402be2fc2d0aa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Wed, 9 Aug 2023 16:57:12 +0300 Subject: [PATCH 07/50] Test fix --- multi-transfer-esdt/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multi-transfer-esdt/src/lib.rs b/multi-transfer-esdt/src/lib.rs index df937aa4..63989ac1 100644 --- a/multi-transfer-esdt/src/lib.rs +++ b/multi-transfer-esdt/src/lib.rs @@ -90,7 +90,7 @@ pub trait MultiTransferEsdt: .execute_on_dest_context(); } else { valid_dest_addresses_list.push(eth_tx.to); - // valid_payments_list.push(EsdtTokenPayment::new(eth_tx.token_id, 0, eth_tx.amount)); + valid_payments_list.push(EsdtTokenPayment::new(eth_tx.token_id, 0, eth_tx.amount)); } } From 492ee3a520510d78019e8ba66c8ac46571ed8f4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Wed, 9 Aug 2023 18:21:34 +0300 Subject: [PATCH 08/50] Fix tests --- .../batch_transfer_both_failed.scen.json | 68 ++++++++++++++++++- ...transfer_one_executed_one_failed.scen.json | 16 +++-- multi-transfer-esdt/src/lib.rs | 4 +- 3 files changed, 79 insertions(+), 9 deletions(-) diff --git a/multi-transfer-esdt/mandos/batch_transfer_both_failed.scen.json b/multi-transfer-esdt/mandos/batch_transfer_both_failed.scen.json index aab426d6..9b6d48e1 100644 --- a/multi-transfer-esdt/mandos/batch_transfer_both_failed.scen.json +++ b/multi-transfer-esdt/mandos/batch_transfer_both_failed.scen.json @@ -15,8 +15,8 @@ "function": "batchTransferEsdtToken", "arguments": [ "1", - "0x0102030405060708091011121314151617181920|sc:multi_transfer_esdt|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:20000000", - "0x0102030405060708091011121314151617181920|sc:multi_transfer_esdt|nested:str:WRAPPED-123456|biguint:100,500|u64:2|nested:str:data|u64:20000000" + "0x0102030405060708091011121314151617181920|sc:multi_transfer_esdt|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:2000000", + "0x0102030405060708091011121314151617181920|sc:multi_transfer_esdt|nested:str:WRAPPED-123456|biguint:100,500|u64:2|nested:str:data|u64:2000000" ], "gasLimit": "50,000,000", "gasPrice": "0" @@ -37,6 +37,70 @@ "function": "getFirstBatchAnyStatus", "arguments": [] }, + "expect": { + "out": [ + "1", + + "0", + "1", + "0x0102030405060708091011121314151617181920", + "sc:multi_transfer_esdt", + "str:BRIDGE-123456", + "100,200", + + "0", + "2", + "0x0102030405060708091011121314151617181920", + "sc:multi_transfer_esdt", + "str:WRAPPED-123456", + "100,500" + ] + } + }, + { + "step": "scCall", + "txId": "clear-refund-batch", + "tx": { + "from": "address:owner", + "to": "sc:multi_transfer_esdt", + "value": "0", + "function": "getAndClearFirstRefundBatch", + "arguments": [], + "gasLimit": "50,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "out": [ + "1", + + "0", + "1", + "0x0102030405060708091011121314151617181920", + "sc:multi_transfer_esdt", + "str:BRIDGE-123456", + "100,200", + + "0", + "2", + "0x0102030405060708091011121314151617181920", + "sc:multi_transfer_esdt", + "str:WRAPPED-123456", + "100,500" + ], + "gas": "*", + "refund": "*" + } + }, + { + "step": "scQuery", + "txId": "get-current-refund-tx-batch-after-clear", + "tx": { + "to": "sc:multi_transfer_esdt", + "function": "getFirstBatchAnyStatus", + "arguments": [] + }, "expect": { "out": [] } diff --git a/multi-transfer-esdt/mandos/batch_transfer_one_executed_one_failed.scen.json b/multi-transfer-esdt/mandos/batch_transfer_one_executed_one_failed.scen.json index 94771439..b6420639 100644 --- a/multi-transfer-esdt/mandos/batch_transfer_one_executed_one_failed.scen.json +++ b/multi-transfer-esdt/mandos/batch_transfer_one_executed_one_failed.scen.json @@ -15,8 +15,8 @@ "function": "batchTransferEsdtToken", "arguments": [ "1", - "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:10000000", - "0x0102030405060708091011121314151617181920|sc:multi_transfer_esdt|nested:str:WRAPPED-123456|biguint:500|u64:2|nested:str:getWrappingContractAddress|u64:10000000" + "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:1000000", + "0x0102030405060708091011121314151617181920|sc:multi_transfer_esdt|nested:str:WRAPPED-123456|biguint:500|u64:2|nested:str:data|u64:1000000" ], "gasLimit": "50,000,000", "gasPrice": "0" @@ -52,8 +52,16 @@ "arguments": [] }, "expect": { - "out": [] + "out": [ + "1", + "0", + "2", + "0x0102030405060708091011121314151617181920", + "sc:multi_transfer_esdt", + "str:WRAPPED-123456", + "500" + ] } } ] -} +} \ No newline at end of file diff --git a/multi-transfer-esdt/src/lib.rs b/multi-transfer-esdt/src/lib.rs index 63989ac1..38a653fd 100644 --- a/multi-transfer-esdt/src/lib.rs +++ b/multi-transfer-esdt/src/lib.rs @@ -80,11 +80,9 @@ pub trait MultiTransferEsdt: // emit event before the actual transfer so we don't have to save the tx_nonces as well self.transfer_performed_event(batch_id, eth_tx.tx_nonce); - if self.blockchain().is_smart_contract(ð_tx.to.clone()) { - let bridge_proxy_addr = self.bridge_proxy_contract_address().get(); let _: IgnoreValue = self - .bridge_proxy(bridge_proxy_addr) + .get_bridge_proxy_contract_proxy_instance() .deposit(ð_tx) .with_esdt_transfer((eth_tx.token_id.clone(), 0, eth_tx.amount.clone())) .execute_on_dest_context(); From f29acbfcdaefa242a6a37f76c449fdeac96e90ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Thu, 10 Aug 2023 10:27:51 +0300 Subject: [PATCH 09/50] Fix tests --- .../ethereum_to_elrond_tx_batch_ok.scen.json | 12 ++++--- ...reum_to_elrond_tx_batch_rejected.scen.json | 32 +++++++++++++++---- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/multisig/mandos/ethereum_to_elrond_tx_batch_ok.scen.json b/multisig/mandos/ethereum_to_elrond_tx_batch_ok.scen.json index 86fe3a03..93bacdb6 100644 --- a/multisig/mandos/ethereum_to_elrond_tx_batch_ok.scen.json +++ b/multisig/mandos/ethereum_to_elrond_tx_batch_ok.scen.json @@ -15,8 +15,8 @@ "function": "proposeMultiTransferEsdtBatch", "arguments": [ "1", - "0x0102030405060708091011121314151617181920", "address:user", "str:EGLD-123456", "500,000", "1", - "0x0102030405060708091011121314151617181920", "address:user", "str:ETH-123456", "500,000", "2" + "0x0102030405060708091011121314151617181920", "address:user", "str:EGLD-123456", "500,000", "1", "str:data", "u64:20000000", + "0x0102030405060708091011121314151617181920", "address:user", "str:ETH-123456", "500,000", "2", "str:data", "u64:20000000" ], "gasLimit": "50,000,000", "gasPrice": "0" @@ -48,14 +48,18 @@ "2-to": "address:user", "3-token_id": "nested:str:EGLD-123456", "4-amount": "biguint:500,000", - "5-tx_nonce": "u64:1" + "5-tx_nonce": "u64:1", + "6-data": "nested:str:data", + "7-gas_limit": "u64:20000000" }, { "1-from": "0x0102030405060708091011121314151617181920", "2-to": "address:user", "3-token_id": "nested:str:ETH-123456", "4-amount": "biguint:500,000", - "5-tx_nonce": "u64:2" + "5-tx_nonce": "u64:2", + "6-data": "nested:str:data", + "7-gas_limit": "u64:20000000" } ] }, diff --git a/multisig/mandos/ethereum_to_elrond_tx_batch_rejected.scen.json b/multisig/mandos/ethereum_to_elrond_tx_batch_rejected.scen.json index f3d8f739..d9c1f630 100644 --- a/multisig/mandos/ethereum_to_elrond_tx_batch_rejected.scen.json +++ b/multisig/mandos/ethereum_to_elrond_tx_batch_rejected.scen.json @@ -19,12 +19,16 @@ "sc:egld_esdt_swap", "str:EGLD-123456", "2,000,000", + "str:data", + "u64:20,000,000", "u64:1", "0x0102030405060708091011121314151617181920", "sc:egld_esdt_swap", "str:ETH-123456", "2,000,000", - "u64:2" + "u64:2", + "str:data", + "u64:20,000,000" ], "gasLimit": "50,000,000", "gasPrice": "0" @@ -52,11 +56,15 @@ "str:EGLD-123456", "2,000,000", "u64:2", + "str:data", + "u64:20,000,000", "0x0102030405060708091011121314151617181920", "sc:egld_esdt_swap", "str:ETH-123456", "2,000,000", - "u64:3" + "u64:3", + "str:data", + "u64:20,000,000" ], "gasLimit": "50,000,000", "gasPrice": "0" @@ -84,11 +92,15 @@ "str:EGLD-123456", "2,000,000", "u64:1", + "str:data", + "u64:20,000,000", "0x0102030405060708091011121314151617181920", "sc:egld_esdt_swap", "str:ETH-123456", "2,000,000", - "u64:2" + "u64:2", + "str:data", + "u64:20,000,000" ], "gasLimit": "50,000,000", "gasPrice": "0" @@ -120,14 +132,18 @@ "2-to": "sc:egld_esdt_swap", "3-token_id": "nested:str:EGLD-123456", "4-amount": "biguint:2,000,000", - "5-tx_id": "u64:1" + "5-tx_id": "u64:1", + "6-data": "nested:str:data", + "7-gas_limit": "u64:20,000,000" }, { "1-from": "0x0102030405060708091011121314151617181920", "2-to": "sc:egld_esdt_swap", "3-token_id": "nested:str:ETH-123456", "4-amount": "biguint:2,000,000", - "5-tx_id": "u64:2" + "5-tx_id": "u64:2", + "6-data": "nested:str:data", + "7-gas_limit": "u64:20,000,000" } ] }, @@ -200,12 +216,16 @@ "sc:egld_esdt_swap", "str:EGLD-123456", "2,000,000", + "str:data", + "u64:20,000,000", "0", "2", "0x0102030405060708091011121314151617181920", "sc:egld_esdt_swap", "str:ETH-123456", - "2,000,000" + "2,000,000", + "str:data", + "u64:20,000,000" ] } }, From 32224fcfd7953fccff3a4a88da3ae883900ee75d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Thu, 10 Aug 2023 10:33:49 +0300 Subject: [PATCH 10/50] Test fix --- ...reum_to_elrond_tx_batch_rejected.scen.json | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/multisig/mandos/ethereum_to_elrond_tx_batch_rejected.scen.json b/multisig/mandos/ethereum_to_elrond_tx_batch_rejected.scen.json index d9c1f630..a084ebfa 100644 --- a/multisig/mandos/ethereum_to_elrond_tx_batch_rejected.scen.json +++ b/multisig/mandos/ethereum_to_elrond_tx_batch_rejected.scen.json @@ -20,7 +20,7 @@ "str:EGLD-123456", "2,000,000", "str:data", - "u64:20,000,000", + "u64:2,000,000", "u64:1", "0x0102030405060708091011121314151617181920", "sc:egld_esdt_swap", @@ -28,7 +28,7 @@ "2,000,000", "u64:2", "str:data", - "u64:20,000,000" + "u64:2,000,000" ], "gasLimit": "50,000,000", "gasPrice": "0" @@ -57,14 +57,14 @@ "2,000,000", "u64:2", "str:data", - "u64:20,000,000", + "u64:2,000,000", "0x0102030405060708091011121314151617181920", "sc:egld_esdt_swap", "str:ETH-123456", "2,000,000", "u64:3", "str:data", - "u64:20,000,000" + "u64:2,000,000" ], "gasLimit": "50,000,000", "gasPrice": "0" @@ -93,14 +93,14 @@ "2,000,000", "u64:1", "str:data", - "u64:20,000,000", + "u64:2,000,000", "0x0102030405060708091011121314151617181920", "sc:egld_esdt_swap", "str:ETH-123456", "2,000,000", "u64:2", "str:data", - "u64:20,000,000" + "u64:2,000,000" ], "gasLimit": "50,000,000", "gasPrice": "0" @@ -134,7 +134,7 @@ "4-amount": "biguint:2,000,000", "5-tx_id": "u64:1", "6-data": "nested:str:data", - "7-gas_limit": "u64:20,000,000" + "7-gas_limit": "u64:2,000,000" }, { "1-from": "0x0102030405060708091011121314151617181920", @@ -143,7 +143,7 @@ "4-amount": "biguint:2,000,000", "5-tx_id": "u64:2", "6-data": "nested:str:data", - "7-gas_limit": "u64:20,000,000" + "7-gas_limit": "u64:2,000,000" } ] }, @@ -217,7 +217,7 @@ "str:EGLD-123456", "2,000,000", "str:data", - "u64:20,000,000", + "u64:2,000,000", "0", "2", "0x0102030405060708091011121314151617181920", @@ -225,7 +225,7 @@ "str:ETH-123456", "2,000,000", "str:data", - "u64:20,000,000" + "u64:2,000,000" ] } }, From 3a42445fb9aaab6584806bd2a3e5841d3422b7fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Fri, 11 Aug 2023 09:45:11 +0300 Subject: [PATCH 11/50] Tests fix --- .../mandos/ethereum_to_elrond_tx_batch_rejected.scen.json | 6 +----- multisig/mandos/setup.scen.json | 5 +++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/multisig/mandos/ethereum_to_elrond_tx_batch_rejected.scen.json b/multisig/mandos/ethereum_to_elrond_tx_batch_rejected.scen.json index a084ebfa..e3ca3858 100644 --- a/multisig/mandos/ethereum_to_elrond_tx_batch_rejected.scen.json +++ b/multisig/mandos/ethereum_to_elrond_tx_batch_rejected.scen.json @@ -216,16 +216,12 @@ "sc:egld_esdt_swap", "str:EGLD-123456", "2,000,000", - "str:data", - "u64:2,000,000", "0", "2", "0x0102030405060708091011121314151617181920", "sc:egld_esdt_swap", "str:ETH-123456", - "2,000,000", - "str:data", - "u64:2,000,000" + "2,000,000" ] } }, diff --git a/multisig/mandos/setup.scen.json b/multisig/mandos/setup.scen.json index 9739684e..6b7ebe5b 100644 --- a/multisig/mandos/setup.scen.json +++ b/multisig/mandos/setup.scen.json @@ -103,6 +103,11 @@ "str:ETH-123456": "1,000,000" }, "storage": {} + }, + "sc:egld_esdt_swap": { + "nonce": "0", + "balance": "0", + "code": "sc:egld_esdt_swap" } }, "newAddresses": [ From 07fb46636c72320796a2077a7f4f6b79dccac6c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Fri, 11 Aug 2023 21:44:47 +0300 Subject: [PATCH 12/50] Framework upgrade 0.42 --- bridge-proxy/Cargo.toml | 9 +- bridge-proxy/meta/Cargo.toml | 5 +- .../tests/bridge_proxy_scenario_go_test.rs | 8 +- .../tests/bridge_proxy_scenario_rs_test.rs | 4 +- bridge-proxy/wasm/Cargo.lock | 36 ++--- bridge-proxy/wasm/Cargo.toml | 10 +- bridge-proxy/wasm/src/lib.rs | 18 +-- bridged-tokens-wrapper/Cargo.toml | 6 +- bridged-tokens-wrapper/meta/Cargo.toml | 2 +- bridged-tokens-wrapper/wasm/Cargo.lock | 40 +++--- bridged-tokens-wrapper/wasm/Cargo.toml | 2 +- bridged-tokens-wrapper/wasm/src/lib.rs | 35 ++--- common/eth-address/Cargo.toml | 2 +- common/fee-estimator-module/Cargo.toml | 4 +- common/max-bridged-amount-module/Cargo.toml | 4 +- common/token-module/Cargo.toml | 4 +- common/transaction/Cargo.toml | 2 +- common/tx-batch-module/Cargo.toml | 4 +- esdt-safe/Cargo.toml | 6 +- esdt-safe/meta/Cargo.toml | 2 +- esdt-safe/wasm/Cargo.toml | 2 +- esdt-safe/wasm/src/lib.rs | 65 ++++----- multi-transfer-esdt/Cargo.toml | 4 +- .../batch_transfer_with_wrapping.scen.json | 6 +- multi-transfer-esdt/meta/Cargo.toml | 2 +- multi-transfer-esdt/wasm/Cargo.lock | 40 +++--- multi-transfer-esdt/wasm/Cargo.toml | 2 +- multi-transfer-esdt/wasm/src/lib.rs | 37 +++--- multisig/Cargo.toml | 6 +- multisig/meta/Cargo.toml | 2 +- multisig/src/setup.rs | 2 +- multisig/wasm/Cargo.lock | 40 +++--- multisig/wasm/Cargo.toml | 2 +- multisig/wasm/src/lib.rs | 125 +++++++++--------- 34 files changed, 273 insertions(+), 265 deletions(-) diff --git a/bridge-proxy/Cargo.toml b/bridge-proxy/Cargo.toml index 196c14f8..4d5c3413 100644 --- a/bridge-proxy/Cargo.toml +++ b/bridge-proxy/Cargo.toml @@ -7,15 +7,14 @@ publish = false [lib] path = "src/bridge-proxy.rs" - [dependencies.transaction] path = "../common/transaction" +[dependencies.multiversx-sc] +version = "0.42.0" + [dev-dependencies] num-bigint = "0.4.2" -[dependencies.multiversx-sc] -version = "0.41.3" - [dev-dependencies.multiversx-sc-scenario] -version = "0.41.3" +version = "0.42.0" diff --git a/bridge-proxy/meta/Cargo.toml b/bridge-proxy/meta/Cargo.toml index fa6f2db7..2d75f6e4 100644 --- a/bridge-proxy/meta/Cargo.toml +++ b/bridge-proxy/meta/Cargo.toml @@ -3,12 +3,11 @@ name = "bridge-proxy-meta" version = "0.0.0" edition = "2018" publish = false -authors = [ "you",] +authors = ["you"] [dev-dependencies] - [dependencies.bridge-proxy] path = ".." [dependencies.multiversx-sc-meta] -version = "0.41.3" +version = "0.42.0" diff --git a/bridge-proxy/tests/bridge_proxy_scenario_go_test.rs b/bridge-proxy/tests/bridge_proxy_scenario_go_test.rs index b869f3ed..2fca5f45 100644 --- a/bridge-proxy/tests/bridge_proxy_scenario_go_test.rs +++ b/bridge-proxy/tests/bridge_proxy_scenario_go_test.rs @@ -1,4 +1,10 @@ +use multiversx_sc_scenario::*; + +fn world() -> ScenarioWorld { + ScenarioWorld::vm_go() +} + #[test] fn bridge_proxy_go() { - multiversx_sc_scenario::run_go("scenarios/bridge-proxy.scen.json"); + world().run("scenarios/bridge-proxy.scen.json"); } diff --git a/bridge-proxy/tests/bridge_proxy_scenario_rs_test.rs b/bridge-proxy/tests/bridge_proxy_scenario_rs_test.rs index 9d1df981..9f8940b6 100644 --- a/bridge-proxy/tests/bridge_proxy_scenario_rs_test.rs +++ b/bridge-proxy/tests/bridge_proxy_scenario_rs_test.rs @@ -11,6 +11,6 @@ fn world() -> ScenarioWorld { } #[test] -fn empty_rs() { - multiversx_sc_scenario::run_rs("scenarios/bridge-proxy.scen.json", world()); +fn bridge_proxy_rs() { + world().run("scenarios/bridge-proxy.scen.json"); } diff --git a/bridge-proxy/wasm/Cargo.lock b/bridge-proxy/wasm/Cargo.lock index c5bac434..0b278dad 100644 --- a/bridge-proxy/wasm/Cargo.lock +++ b/bridge-proxy/wasm/Cargo.lock @@ -89,9 +89,9 @@ checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" [[package]] name = "multiversx-sc" -version = "0.41.3" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfbe80ec68fedf299dd65469f8999cf3c0f884ffa497122428f08303bcb8b884" +checksum = "c22c2d1e82a357b6f397f87d475314628473b8a88882aa407234197f596786aa" dependencies = [ "bitflags", "hashbrown", @@ -103,9 +103,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.17.2" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d70ea458247d263b7e9fdfb207530b6a530546247139c162450e515c013a18" +checksum = "e9c97dc9e9f34f836de6a56386ddbe1b9e87e20916ff86b1ea728c08e1871ac2" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -113,9 +113,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.17.2" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ad6920f80fda67fc60fd51aaa9f83ec7e069470f60a068c81205f9da5d05a30" +checksum = "12ab795364fcf0452a953e33eae7e0c22d1a6374ffeb0724d24a42727e099c6e" dependencies = [ "hex", "proc-macro2", @@ -125,9 +125,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.41.3" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c2b87d817f2176bf1830bef938884f24267516c334a377e71a96bc18ebb09c1" +checksum = "b6d77a125ea6985b2fa5cf1a297cdb9202c5a528eebb22652cc68ab1a9305e11" dependencies = [ "hex", "proc-macro2", @@ -138,9 +138,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.41.3" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "932327626de71eeb1dbe86b863cc70cc532f8ceba8e73a059410f6aa56b22a77" +checksum = "951b0137614c8412554ccd086967c565af38b91b77a66b5d9f433801ff24e501" dependencies = [ "multiversx-sc", ] @@ -156,9 +156,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" dependencies = [ "autocfg", ] @@ -171,18 +171,18 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "proc-macro2" -version = "1.0.64" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.29" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" +checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" dependencies = [ "proc-macro2", ] @@ -224,9 +224,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "version_check" diff --git a/bridge-proxy/wasm/Cargo.toml b/bridge-proxy/wasm/Cargo.toml index cbe13baa..8d6d744a 100644 --- a/bridge-proxy/wasm/Cargo.toml +++ b/bridge-proxy/wasm/Cargo.toml @@ -3,25 +3,23 @@ name = "bridge-proxy-wasm" version = "0.0.0" edition = "2018" publish = false -authors = [ "you",] +authors = ["you"] [lib] -crate-type = [ "cdylib",] +crate-type = ["cdylib"] [workspace] -members = [ ".",] +members = ["."] [dev-dependencies] - [profile.release] codegen-units = 1 opt-level = "z" lto = true debug = false panic = "abort" - [dependencies.bridge-proxy] path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.41.3" +version = "0.42.0" diff --git a/bridge-proxy/wasm/src/lib.rs b/bridge-proxy/wasm/src/lib.rs index 540a82e4..89af2cdb 100644 --- a/bridge-proxy/wasm/src/lib.rs +++ b/bridge-proxy/wasm/src/lib.rs @@ -18,13 +18,15 @@ multiversx_sc_wasm_adapter::panic_handler!(); multiversx_sc_wasm_adapter::endpoints! { bridge_proxy ( - deposit - executeWithAsnyc - refundTransactions - setupMultiTransfer - getMultiTransferAddress - getEthTransactionList - getEthFailedTransactionList - callBack + init => init + deposit => deposit + executeWithAsnyc => execute_with_async + refundTransactions => refund_transactions + setupMultiTransfer => setup_multi_transfer + getMultiTransferAddress => multi_transfer_address + getEthTransactionList => eth_transaction_list + getEthFailedTransactionList => eth_failed_transaction_list ) } + +multiversx_sc_wasm_adapter::async_callback! { bridge_proxy } diff --git a/bridged-tokens-wrapper/Cargo.toml b/bridged-tokens-wrapper/Cargo.toml index dc1bbfd7..f3015025 100644 --- a/bridged-tokens-wrapper/Cargo.toml +++ b/bridged-tokens-wrapper/Cargo.toml @@ -11,9 +11,9 @@ path = "src/lib.rs" path = "../common/transaction" [dependencies.multiversx-sc] -version = "0.41.3" +version = "0.42.0" [dependencies.multiversx-sc-modules] -version = "0.41.3" +version = "0.42.0" [dev-dependencies.multiversx-sc-scenario] -version = "0.41.3" +version = "0.42.0" diff --git a/bridged-tokens-wrapper/meta/Cargo.toml b/bridged-tokens-wrapper/meta/Cargo.toml index 55bf3058..887076ac 100644 --- a/bridged-tokens-wrapper/meta/Cargo.toml +++ b/bridged-tokens-wrapper/meta/Cargo.toml @@ -7,4 +7,4 @@ publish = false path = ".." [dependencies.multiversx-sc-meta] -version = "0.41.3" +version = "0.42.0" diff --git a/bridged-tokens-wrapper/wasm/Cargo.lock b/bridged-tokens-wrapper/wasm/Cargo.lock index 3e6072c5..75724ebc 100644 --- a/bridged-tokens-wrapper/wasm/Cargo.lock +++ b/bridged-tokens-wrapper/wasm/Cargo.lock @@ -90,9 +90,9 @@ checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" [[package]] name = "multiversx-sc" -version = "0.41.3" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfbe80ec68fedf299dd65469f8999cf3c0f884ffa497122428f08303bcb8b884" +checksum = "c22c2d1e82a357b6f397f87d475314628473b8a88882aa407234197f596786aa" dependencies = [ "bitflags", "hashbrown", @@ -104,9 +104,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.17.2" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d70ea458247d263b7e9fdfb207530b6a530546247139c162450e515c013a18" +checksum = "e9c97dc9e9f34f836de6a56386ddbe1b9e87e20916ff86b1ea728c08e1871ac2" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -114,9 +114,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.17.2" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ad6920f80fda67fc60fd51aaa9f83ec7e069470f60a068c81205f9da5d05a30" +checksum = "12ab795364fcf0452a953e33eae7e0c22d1a6374ffeb0724d24a42727e099c6e" dependencies = [ "hex", "proc-macro2", @@ -126,9 +126,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.41.3" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c2b87d817f2176bf1830bef938884f24267516c334a377e71a96bc18ebb09c1" +checksum = "b6d77a125ea6985b2fa5cf1a297cdb9202c5a528eebb22652cc68ab1a9305e11" dependencies = [ "hex", "proc-macro2", @@ -139,18 +139,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.41.3" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "704825223788bfdfd622980cae8feedae82609fded5ef5f53af31661d5e02312" +checksum = "087a8ea95fac541128600a51c3c4ef7329642d5a1a397b4c6a65eb3ee621a282" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.41.3" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "932327626de71eeb1dbe86b863cc70cc532f8ceba8e73a059410f6aa56b22a77" +checksum = "951b0137614c8412554ccd086967c565af38b91b77a66b5d9f433801ff24e501" dependencies = [ "multiversx-sc", ] @@ -166,9 +166,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" dependencies = [ "autocfg", ] @@ -181,18 +181,18 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "proc-macro2" -version = "1.0.64" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.29" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" +checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" dependencies = [ "proc-macro2", ] @@ -234,9 +234,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "version_check" diff --git a/bridged-tokens-wrapper/wasm/Cargo.toml b/bridged-tokens-wrapper/wasm/Cargo.toml index 05ea6ac7..3a2a2f7a 100644 --- a/bridged-tokens-wrapper/wasm/Cargo.toml +++ b/bridged-tokens-wrapper/wasm/Cargo.toml @@ -17,7 +17,7 @@ panic = "abort" path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.41.3" +version = "0.42.0" [workspace] members = ["."] diff --git a/bridged-tokens-wrapper/wasm/src/lib.rs b/bridged-tokens-wrapper/wasm/src/lib.rs index 99d29ded..a03ebc18 100644 --- a/bridged-tokens-wrapper/wasm/src/lib.rs +++ b/bridged-tokens-wrapper/wasm/src/lib.rs @@ -18,23 +18,24 @@ multiversx_sc_wasm_adapter::panic_handler!(); multiversx_sc_wasm_adapter::endpoints! { bridged_tokens_wrapper ( - addWrappedToken - updateWrappedToken - removeWrappedToken - whitelistToken - updateWhitelistedToken - blacklistToken - depositLiquidity - wrapTokens - unwrapToken - getUniversalBridgedTokenIds - getTokenLiquidity - getChainSpecificToUniversalMapping - getchainSpecificTokenIds - pause - unpause - isPaused + init => init + addWrappedToken => add_wrapped_token + updateWrappedToken => update_wrapped_token + removeWrappedToken => remove_wrapped_token + whitelistToken => whitelist_token + updateWhitelistedToken => update_whitelisted_token + blacklistToken => blacklist_token + depositLiquidity => deposit_liquidity + wrapTokens => wrap_tokens + unwrapToken => unwrap_token + getUniversalBridgedTokenIds => universal_bridged_token_ids + getTokenLiquidity => token_liquidity + getChainSpecificToUniversalMapping => chain_specific_to_universal_mapping + getchainSpecificTokenIds => chain_specific_token_ids + pause => pause_endpoint + unpause => unpause_endpoint + isPaused => paused_status ) } -multiversx_sc_wasm_adapter::empty_callback! {} +multiversx_sc_wasm_adapter::async_callback_empty! {} diff --git a/common/eth-address/Cargo.toml b/common/eth-address/Cargo.toml index b0f24f38..773d2522 100644 --- a/common/eth-address/Cargo.toml +++ b/common/eth-address/Cargo.toml @@ -7,4 +7,4 @@ edition = "2018" [lib] path = "src/lib.rs" [dependencies.multiversx-sc] -version = "0.41.3" +version = "0.42.0" diff --git a/common/fee-estimator-module/Cargo.toml b/common/fee-estimator-module/Cargo.toml index 5ae1347c..4c745cc6 100644 --- a/common/fee-estimator-module/Cargo.toml +++ b/common/fee-estimator-module/Cargo.toml @@ -4,6 +4,6 @@ version = "0.0.0" authors = ["dorin-iancu "] edition = "2018" [dependencies.multiversx-sc] -version = "0.41.3" +version = "0.42.0" [dev-dependencies.multiversx-sc-scenario] -version = "0.41.3" +version = "0.42.0" diff --git a/common/max-bridged-amount-module/Cargo.toml b/common/max-bridged-amount-module/Cargo.toml index 8c9527b9..64cf2a04 100644 --- a/common/max-bridged-amount-module/Cargo.toml +++ b/common/max-bridged-amount-module/Cargo.toml @@ -4,6 +4,6 @@ version = "0.0.0" authors = ["dorin-iancu "] edition = "2018" [dependencies.multiversx-sc] -version = "0.41.3" +version = "0.42.0" [dev-dependencies.multiversx-sc-scenario] -version = "0.41.3" +version = "0.42.0" diff --git a/common/token-module/Cargo.toml b/common/token-module/Cargo.toml index 04386c99..c5201dc8 100644 --- a/common/token-module/Cargo.toml +++ b/common/token-module/Cargo.toml @@ -7,6 +7,6 @@ edition = "2018" path = "../fee-estimator-module" [dependencies.multiversx-sc] -version = "0.41.3" +version = "0.42.0" [dev-dependencies.multiversx-sc-scenario] -version = "0.41.3" +version = "0.42.0" diff --git a/common/transaction/Cargo.toml b/common/transaction/Cargo.toml index a3c78a10..a0e402cc 100644 --- a/common/transaction/Cargo.toml +++ b/common/transaction/Cargo.toml @@ -10,4 +10,4 @@ path = "src/lib.rs" path = "../eth-address" [dependencies.multiversx-sc] -version = "0.41.3" +version = "0.42.0" diff --git a/common/tx-batch-module/Cargo.toml b/common/tx-batch-module/Cargo.toml index 45b50869..4983bb4f 100644 --- a/common/tx-batch-module/Cargo.toml +++ b/common/tx-batch-module/Cargo.toml @@ -4,9 +4,9 @@ version = "0.0.0" authors = ["dorin-iancu "] edition = "2018" [dependencies.multiversx-sc] -version = "0.41.3" +version = "0.42.0" [dependencies.transaction] path = "../transaction" [dev-dependencies.multiversx-sc-scenario] -version = "0.41.3" +version = "0.42.0" diff --git a/esdt-safe/Cargo.toml b/esdt-safe/Cargo.toml index d3c4062d..752ce19f 100644 --- a/esdt-safe/Cargo.toml +++ b/esdt-safe/Cargo.toml @@ -26,9 +26,9 @@ path = "../common/tx-batch-module" path = "../common/max-bridged-amount-module" [dependencies.multiversx-sc] -version = "0.41.3" +version = "0.42.0" [dependencies.multiversx-sc-modules] -version = "0.41.3" +version = "0.42.0" [dev-dependencies.multiversx-sc-scenario] -version = "0.41.3" +version = "0.42.0" diff --git a/esdt-safe/meta/Cargo.toml b/esdt-safe/meta/Cargo.toml index a16eeefd..47db7b79 100644 --- a/esdt-safe/meta/Cargo.toml +++ b/esdt-safe/meta/Cargo.toml @@ -10,4 +10,4 @@ publish = false path = ".." [dependencies.multiversx-sc-meta] -version = "0.41.3" +version = "0.42.0" diff --git a/esdt-safe/wasm/Cargo.toml b/esdt-safe/wasm/Cargo.toml index d49dabc8..7270e4e2 100644 --- a/esdt-safe/wasm/Cargo.toml +++ b/esdt-safe/wasm/Cargo.toml @@ -22,4 +22,4 @@ panic = "abort" path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.41.3" +version = "0.42.0" diff --git a/esdt-safe/wasm/src/lib.rs b/esdt-safe/wasm/src/lib.rs index 2377e18f..061228d4 100644 --- a/esdt-safe/wasm/src/lib.rs +++ b/esdt-safe/wasm/src/lib.rs @@ -18,38 +18,39 @@ multiversx_sc_wasm_adapter::panic_handler!(); multiversx_sc_wasm_adapter::endpoints! { esdt_safe ( - setTransactionBatchStatus - addRefundBatch - createTransaction - claimRefund - getRefundAmounts - setFeeEstimatorContractAddress - setEthTxGasLimit - setDefaultPricePerGasUnit - setTokenTicker - calculateRequiredFee - getFeeEstimatorContractAddress - getDefaultPricePerGasUnit - getEthTxGasLimit - distributeFees - addTokenToWhitelist - removeTokenFromWhitelist - getAllKnownTokens - getAccumulatedTransactionFees - setMaxTxBatchSize - setMaxTxBatchBlockDuration - getCurrentTxBatch - getFirstBatchAnyStatus - getBatch - getBatchStatus - getFirstBatchId - getLastBatchId - setMaxBridgedAmount - getMaxBridgedAmount - pause - unpause - isPaused + init => init + setTransactionBatchStatus => set_transaction_batch_status + addRefundBatch => add_refund_batch + createTransaction => create_transaction + claimRefund => claim_refund + getRefundAmounts => get_refund_amounts + setFeeEstimatorContractAddress => set_fee_estimator_contract_address + setEthTxGasLimit => set_eth_tx_gas_limit + setDefaultPricePerGasUnit => set_default_price_per_gas_unit + setTokenTicker => set_token_ticker + calculateRequiredFee => calculate_required_fee + getFeeEstimatorContractAddress => fee_estimator_contract_address + getDefaultPricePerGasUnit => default_price_per_gas_unit + getEthTxGasLimit => eth_tx_gas_limit + distributeFees => distribute_fees + addTokenToWhitelist => add_token_to_whitelist + removeTokenFromWhitelist => remove_token_from_whitelist + getAllKnownTokens => token_whitelist + getAccumulatedTransactionFees => accumulated_transaction_fees + setMaxTxBatchSize => set_max_tx_batch_size + setMaxTxBatchBlockDuration => set_max_tx_batch_block_duration + getCurrentTxBatch => get_current_tx_batch + getFirstBatchAnyStatus => get_first_batch_any_status + getBatch => get_batch + getBatchStatus => get_batch_status + getFirstBatchId => first_batch_id + getLastBatchId => last_batch_id + setMaxBridgedAmount => set_max_bridged_amount + getMaxBridgedAmount => max_bridged_amount + pause => pause_endpoint + unpause => unpause_endpoint + isPaused => paused_status ) } -multiversx_sc_wasm_adapter::empty_callback! {} +multiversx_sc_wasm_adapter::async_callback_empty! {} diff --git a/multi-transfer-esdt/Cargo.toml b/multi-transfer-esdt/Cargo.toml index 8ed5ccac..680fdc75 100644 --- a/multi-transfer-esdt/Cargo.toml +++ b/multi-transfer-esdt/Cargo.toml @@ -23,6 +23,6 @@ path = "../bridged-tokens-wrapper" path = "../bridge-proxy" [dependencies.multiversx-sc] -version = "0.41.3" +version = "0.42.0" [dev-dependencies.multiversx-sc-scenario] -version = "0.41.3" +version = "0.42.0" diff --git a/multi-transfer-esdt/mandos/batch_transfer_with_wrapping.scen.json b/multi-transfer-esdt/mandos/batch_transfer_with_wrapping.scen.json index c24baa4c..7a2c6c12 100644 --- a/multi-transfer-esdt/mandos/batch_transfer_with_wrapping.scen.json +++ b/multi-transfer-esdt/mandos/batch_transfer_with_wrapping.scen.json @@ -100,9 +100,9 @@ "function": "batchTransferEsdtToken", "arguments": [ "1", - "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:20000000", - "0x0102030405060708091011121314151617181920|address:user2|nested:str:USDC-aaaaaa|biguint:500|u64:2|nested:str:data|u64:20000000", - "0x0102030405060708091011121314151617181920|address:user1|nested:str:USDC-cccccc|biguint:1000|u64:3|nested:str:data|u64:20000000" + "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:2000000", + "0x0102030405060708091011121314151617181920|address:user2|nested:str:USDC-aaaaaa|biguint:500|u64:2|nested:str:data|u64:2000000", + "0x0102030405060708091011121314151617181920|address:user1|nested:str:USDC-cccccc|biguint:1000|u64:3|nested:str:data|u64:2000000" ], "gasLimit": "50,000,000", "gasPrice": "0" diff --git a/multi-transfer-esdt/meta/Cargo.toml b/multi-transfer-esdt/meta/Cargo.toml index 9a489dd5..46997942 100644 --- a/multi-transfer-esdt/meta/Cargo.toml +++ b/multi-transfer-esdt/meta/Cargo.toml @@ -10,4 +10,4 @@ publish = false path = ".." [dependencies.multiversx-sc-meta] -version = "0.41.3" +version = "0.42.0" diff --git a/multi-transfer-esdt/wasm/Cargo.lock b/multi-transfer-esdt/wasm/Cargo.lock index 148d8db4..58967f4e 100644 --- a/multi-transfer-esdt/wasm/Cargo.lock +++ b/multi-transfer-esdt/wasm/Cargo.lock @@ -117,9 +117,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.41.3" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfbe80ec68fedf299dd65469f8999cf3c0f884ffa497122428f08303bcb8b884" +checksum = "c22c2d1e82a357b6f397f87d475314628473b8a88882aa407234197f596786aa" dependencies = [ "bitflags", "hashbrown", @@ -131,9 +131,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.17.2" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d70ea458247d263b7e9fdfb207530b6a530546247139c162450e515c013a18" +checksum = "e9c97dc9e9f34f836de6a56386ddbe1b9e87e20916ff86b1ea728c08e1871ac2" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -141,9 +141,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.17.2" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ad6920f80fda67fc60fd51aaa9f83ec7e069470f60a068c81205f9da5d05a30" +checksum = "12ab795364fcf0452a953e33eae7e0c22d1a6374ffeb0724d24a42727e099c6e" dependencies = [ "hex", "proc-macro2", @@ -153,9 +153,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.41.3" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c2b87d817f2176bf1830bef938884f24267516c334a377e71a96bc18ebb09c1" +checksum = "b6d77a125ea6985b2fa5cf1a297cdb9202c5a528eebb22652cc68ab1a9305e11" dependencies = [ "hex", "proc-macro2", @@ -166,18 +166,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.41.3" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "704825223788bfdfd622980cae8feedae82609fded5ef5f53af31661d5e02312" +checksum = "087a8ea95fac541128600a51c3c4ef7329642d5a1a397b4c6a65eb3ee621a282" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.41.3" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "932327626de71eeb1dbe86b863cc70cc532f8ceba8e73a059410f6aa56b22a77" +checksum = "951b0137614c8412554ccd086967c565af38b91b77a66b5d9f433801ff24e501" dependencies = [ "multiversx-sc", ] @@ -193,9 +193,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" dependencies = [ "autocfg", ] @@ -208,18 +208,18 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "proc-macro2" -version = "1.0.64" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.29" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" +checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" dependencies = [ "proc-macro2", ] @@ -269,9 +269,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "version_check" diff --git a/multi-transfer-esdt/wasm/Cargo.toml b/multi-transfer-esdt/wasm/Cargo.toml index 8dcc8c0f..860fc15b 100644 --- a/multi-transfer-esdt/wasm/Cargo.toml +++ b/multi-transfer-esdt/wasm/Cargo.toml @@ -22,4 +22,4 @@ panic = "abort" path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.41.3" +version = "0.42.0" diff --git a/multi-transfer-esdt/wasm/src/lib.rs b/multi-transfer-esdt/wasm/src/lib.rs index 68f1f328..cfe77698 100644 --- a/multi-transfer-esdt/wasm/src/lib.rs +++ b/multi-transfer-esdt/wasm/src/lib.rs @@ -18,24 +18,25 @@ multiversx_sc_wasm_adapter::panic_handler!(); multiversx_sc_wasm_adapter::endpoints! { multi_transfer_esdt ( - batchTransferEsdtToken - getAndClearFirstRefundBatch - setWrappingContractAddress - setBridgeProxyContractAddress - getFailedTxFromBridgeProxy - getWrappingContractAddress - getBridgeProxyContractAddress - setMaxTxBatchSize - setMaxTxBatchBlockDuration - getCurrentTxBatch - getFirstBatchAnyStatus - getBatch - getBatchStatus - getFirstBatchId - getLastBatchId - setMaxBridgedAmount - getMaxBridgedAmount + init => init + batchTransferEsdtToken => batch_transfer_esdt_token + getAndClearFirstRefundBatch => get_and_clear_first_refund_batch + setWrappingContractAddress => set_wrapping_contract_address + setBridgeProxyContractAddress => set_bridge_proxy_contract_address + getFailedTxFromBridgeProxy => get_failed_tx_from_bridge_proxy + getWrappingContractAddress => wrapping_contract_address + getBridgeProxyContractAddress => bridge_proxy_contract_address + setMaxTxBatchSize => set_max_tx_batch_size + setMaxTxBatchBlockDuration => set_max_tx_batch_block_duration + getCurrentTxBatch => get_current_tx_batch + getFirstBatchAnyStatus => get_first_batch_any_status + getBatch => get_batch + getBatchStatus => get_batch_status + getFirstBatchId => first_batch_id + getLastBatchId => last_batch_id + setMaxBridgedAmount => set_max_bridged_amount + getMaxBridgedAmount => max_bridged_amount ) } -multiversx_sc_wasm_adapter::empty_callback! {} +multiversx_sc_wasm_adapter::async_callback_empty! {} diff --git a/multisig/Cargo.toml b/multisig/Cargo.toml index 6a8ff88d..abf4d18d 100644 --- a/multisig/Cargo.toml +++ b/multisig/Cargo.toml @@ -32,9 +32,9 @@ path = "../esdt-safe" path = "../multi-transfer-esdt" [dependencies.multiversx-sc] -version = "0.41.3" +version = "0.42.0" [dependencies.multiversx-sc-modules] -version = "0.41.3" +version = "0.42.0" [dev-dependencies.multiversx-sc-scenario] -version = "0.41.3" +version = "0.42.0" diff --git a/multisig/meta/Cargo.toml b/multisig/meta/Cargo.toml index d57b4414..e5de4243 100644 --- a/multisig/meta/Cargo.toml +++ b/multisig/meta/Cargo.toml @@ -8,4 +8,4 @@ publish = false path = ".." [dependencies.multiversx-sc-meta] -version = "0.41.3" +version = "0.42.0" diff --git a/multisig/src/setup.rs b/multisig/src/setup.rs index 4fa369b0..624b1c98 100644 --- a/multisig/src/setup.rs +++ b/multisig/src/setup.rs @@ -33,7 +33,7 @@ pub trait SetupModule: } let gas = self.blockchain().get_gas_left(); - Self::Api::send_api_impl().upgrade_from_source_contract( + self.send_raw().upgrade_from_source_contract( &child_sc_address, gas, &BigUint::zero(), diff --git a/multisig/wasm/Cargo.lock b/multisig/wasm/Cargo.lock index 885193d3..036c6f9c 100644 --- a/multisig/wasm/Cargo.lock +++ b/multisig/wasm/Cargo.lock @@ -154,9 +154,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.41.3" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfbe80ec68fedf299dd65469f8999cf3c0f884ffa497122428f08303bcb8b884" +checksum = "c22c2d1e82a357b6f397f87d475314628473b8a88882aa407234197f596786aa" dependencies = [ "bitflags", "hashbrown", @@ -168,9 +168,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.17.2" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d70ea458247d263b7e9fdfb207530b6a530546247139c162450e515c013a18" +checksum = "e9c97dc9e9f34f836de6a56386ddbe1b9e87e20916ff86b1ea728c08e1871ac2" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -178,9 +178,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.17.2" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ad6920f80fda67fc60fd51aaa9f83ec7e069470f60a068c81205f9da5d05a30" +checksum = "12ab795364fcf0452a953e33eae7e0c22d1a6374ffeb0724d24a42727e099c6e" dependencies = [ "hex", "proc-macro2", @@ -190,9 +190,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.41.3" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c2b87d817f2176bf1830bef938884f24267516c334a377e71a96bc18ebb09c1" +checksum = "b6d77a125ea6985b2fa5cf1a297cdb9202c5a528eebb22652cc68ab1a9305e11" dependencies = [ "hex", "proc-macro2", @@ -203,18 +203,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.41.3" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "704825223788bfdfd622980cae8feedae82609fded5ef5f53af31661d5e02312" +checksum = "087a8ea95fac541128600a51c3c4ef7329642d5a1a397b4c6a65eb3ee621a282" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.41.3" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "932327626de71eeb1dbe86b863cc70cc532f8ceba8e73a059410f6aa56b22a77" +checksum = "951b0137614c8412554ccd086967c565af38b91b77a66b5d9f433801ff24e501" dependencies = [ "multiversx-sc", ] @@ -230,9 +230,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" dependencies = [ "autocfg", ] @@ -245,18 +245,18 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "proc-macro2" -version = "1.0.64" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.29" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" +checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" dependencies = [ "proc-macro2", ] @@ -314,9 +314,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "version_check" diff --git a/multisig/wasm/Cargo.toml b/multisig/wasm/Cargo.toml index cbe703b5..24ae2cfd 100644 --- a/multisig/wasm/Cargo.toml +++ b/multisig/wasm/Cargo.toml @@ -17,7 +17,7 @@ panic = "abort" path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.41.3" +version = "0.42.0" [workspace] members = ["."] diff --git a/multisig/wasm/src/lib.rs b/multisig/wasm/src/lib.rs index ea52cff9..4b535cfd 100644 --- a/multisig/wasm/src/lib.rs +++ b/multisig/wasm/src/lib.rs @@ -18,68 +18,69 @@ multiversx_sc_wasm_adapter::panic_handler!(); multiversx_sc_wasm_adapter::endpoints! { multisig ( - distributeFeesFromChildContracts - stake - unstake - proposeEsdtSafeSetCurrentTransactionBatchStatus - proposeMultiTransferEsdtBatch - moveRefundBatchToSafe - performAction - sign - upgradeChildContractFromSource - addBoardMember - removeUser - slashBoardMember - changeQuorum - addMapping - clearMapping - pauseEsdtSafe - unpauseEsdtSafe - changeFeeEstimatorContractAddress - changeElrondToEthGasLimit - changeDefaultPricePerGasUnit - changeTokenTicker - esdtSafeAddTokenToWhitelist - esdtSafeRemoveTokenFromWhitelist - esdtSafeSetMaxTxBatchSize - esdtSafeSetMaxTxBatchBlockDuration - esdtSafeSetMaxBridgedAmountForToken - multiTransferEsdtSetMaxBridgedAmountForToken - multiTransferEsdtSetMaxRefundTxBatchSize - multiTransferEsdtSetMaxRefundTxBatchBlockDuration - multiTransferEsdtSetWrappingContractAddress - getQuorum - getNumBoardMembers - getRequiredStakeAmount - getAmountStaked - getSlashAmount - getSlashedTokensAmount - getLastExecutedEthBatchId - getLastExecutedEthTxId - getErc20AddressForTokenId - getTokenIdForErc20Address - getEsdtSafeAddress - getMultiTransferEsdtAddress - getCurrentTxBatch - getCurrentRefundBatch - wasActionExecuted - wasTransferActionProposed - getActionIdForTransferBatch - wasSetCurrentTransactionBatchStatusActionProposed - getActionIdForSetCurrentTransactionBatchStatus - signed - userRole - getAllBoardMembers - getAllStakedRelayers - getActionSignerCount - getActionValidSignerCount - quorumReached - getActionLastIndex - getActionData - pause - unpause - isPaused + init => init + distributeFeesFromChildContracts => distribute_fees_from_child_contracts + stake => stake + unstake => unstake + proposeEsdtSafeSetCurrentTransactionBatchStatus => propose_esdt_safe_set_current_transaction_batch_status + proposeMultiTransferEsdtBatch => propose_multi_transfer_esdt_batch + moveRefundBatchToSafe => move_refund_batch_to_safe + performAction => perform_action_endpoint + sign => sign + upgradeChildContractFromSource => upgrade_child_contract_from_source + addBoardMember => add_board_member_endpoint + removeUser => remove_user + slashBoardMember => slash_board_member + changeQuorum => change_quorum + addMapping => add_mapping + clearMapping => clear_mapping + pauseEsdtSafe => pause_esdt_safe + unpauseEsdtSafe => unpause_esdt_safe + changeFeeEstimatorContractAddress => change_fee_estimator_contract_address + changeElrondToEthGasLimit => change_elrond_to_eth_gas_limit + changeDefaultPricePerGasUnit => change_default_price_per_gas_unit + changeTokenTicker => change_token_ticker + esdtSafeAddTokenToWhitelist => esdt_safe_add_token_to_whitelist + esdtSafeRemoveTokenFromWhitelist => esdt_safe_remove_token_from_whitelist + esdtSafeSetMaxTxBatchSize => esdt_safe_set_max_tx_batch_size + esdtSafeSetMaxTxBatchBlockDuration => esdt_safe_set_max_tx_batch_block_duration + esdtSafeSetMaxBridgedAmountForToken => esdt_safe_set_max_bridged_amount_for_token + multiTransferEsdtSetMaxBridgedAmountForToken => multi_transfer_esdt_set_max_bridged_amount_for_token + multiTransferEsdtSetMaxRefundTxBatchSize => multi_transfer_esdt_set_max_refund_tx_batch_size + multiTransferEsdtSetMaxRefundTxBatchBlockDuration => multi_transfer_esdt_set_max_refund_tx_batch_block_duration + multiTransferEsdtSetWrappingContractAddress => multi_transfer_esdt_set_wrapping_contract_address + getQuorum => quorum + getNumBoardMembers => num_board_members + getRequiredStakeAmount => required_stake_amount + getAmountStaked => amount_staked + getSlashAmount => slash_amount + getSlashedTokensAmount => slashed_tokens_amount + getLastExecutedEthBatchId => last_executed_eth_batch_id + getLastExecutedEthTxId => last_executed_eth_tx_id + getErc20AddressForTokenId => erc20_address_for_token_id + getTokenIdForErc20Address => token_id_for_erc20_address + getEsdtSafeAddress => esdt_safe_address + getMultiTransferEsdtAddress => multi_transfer_esdt_address + getCurrentTxBatch => get_current_tx_batch + getCurrentRefundBatch => get_current_refund_batch + wasActionExecuted => was_action_executed + wasTransferActionProposed => was_transfer_action_proposed + getActionIdForTransferBatch => get_action_id_for_transfer_batch + wasSetCurrentTransactionBatchStatusActionProposed => was_set_current_transaction_batch_status_action_proposed + getActionIdForSetCurrentTransactionBatchStatus => get_action_id_for_set_current_transaction_batch_status + signed => signed + userRole => user_role + getAllBoardMembers => get_all_board_members + getAllStakedRelayers => get_all_staked_relayers + getActionSignerCount => get_action_signer_count + getActionValidSignerCount => get_action_valid_signer_count + quorumReached => quorum_reached + getActionLastIndex => get_action_last_index + getActionData => get_action_data + pause => pause_endpoint + unpause => unpause_endpoint + isPaused => paused_status ) } -multiversx_sc_wasm_adapter::empty_callback! {} +multiversx_sc_wasm_adapter::async_callback_empty! {} From 864bcf0122aa1114043a21ad2a3de53e475b40f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Mon, 14 Aug 2023 00:29:29 +0300 Subject: [PATCH 13/50] bridge-proxy: Add tests --- bridge-proxy/Cargo.toml | 3 + bridge-proxy/scenarios/bridge-proxy.scen.json | 45 ------ bridge-proxy/src/bridge-proxy.rs | 8 +- bridge-proxy/src/config.rs | 25 ++- .../tests/bridge-proxy-blackbox-setup/mod.rs | 56 +++++++ .../tests/bridge_proxy_blackbox_test.rs | 148 ++++++++++++++++++ bridge-proxy/tests/bridge_proxy_rust_test.rs | 64 -------- .../tests/bridge_proxy_scenario_go_test.rs | 10 -- .../tests/bridge_proxy_scenario_rs_test.rs | 16 -- bridge-proxy/wasm/Cargo.lock | 1 + bridge-proxy/wasm/src/lib.rs | 2 +- 11 files changed, 232 insertions(+), 146 deletions(-) delete mode 100644 bridge-proxy/scenarios/bridge-proxy.scen.json create mode 100644 bridge-proxy/tests/bridge-proxy-blackbox-setup/mod.rs create mode 100644 bridge-proxy/tests/bridge_proxy_blackbox_test.rs delete mode 100644 bridge-proxy/tests/bridge_proxy_rust_test.rs delete mode 100644 bridge-proxy/tests/bridge_proxy_scenario_go_test.rs delete mode 100644 bridge-proxy/tests/bridge_proxy_scenario_rs_test.rs diff --git a/bridge-proxy/Cargo.toml b/bridge-proxy/Cargo.toml index 4d5c3413..b9b4542d 100644 --- a/bridge-proxy/Cargo.toml +++ b/bridge-proxy/Cargo.toml @@ -10,6 +10,9 @@ path = "src/bridge-proxy.rs" [dependencies.transaction] path = "../common/transaction" +[dependencies.eth-address] +path = "../common/eth-address" + [dependencies.multiversx-sc] version = "0.42.0" diff --git a/bridge-proxy/scenarios/bridge-proxy.scen.json b/bridge-proxy/scenarios/bridge-proxy.scen.json deleted file mode 100644 index 7161bd2c..00000000 --- a/bridge-proxy/scenarios/bridge-proxy.scen.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "name": "bridge-proxy", - "steps": [ - { - "step": "setState", - "accounts": { - "address:owner": { - "nonce": "1", - "balance": "0" - } - }, - "newAddresses": [ - { - "creatorAddress": "address:owner", - "creatorNonce": "1", - "newAddress": "sc:bridge-proxy" - }, - { - "creatorAddress": "address:owner", - "creatorNonce": "0", - "newAddress": "sc:multi_transfer_esdt" - } - - ] - }, - { - "step": "scDeploy", - "id": "deploy", - "tx": { - "from": "address:owner", - "contractCode": "file:../output/bridge-proxy.wasm", - "arguments": ["sc:multi_transfer_esdt"], - "gasLimit": "5,000,000", - "gasPrice": "0" - }, - "expect": { - "out": [], - "status": "", - "logs": [], - "gas": "*", - "refund": "*" - } - } - ] -} \ No newline at end of file diff --git a/bridge-proxy/src/bridge-proxy.rs b/bridge-proxy/src/bridge-proxy.rs index df5f6447..c86e809e 100644 --- a/bridge-proxy/src/bridge-proxy.rs +++ b/bridge-proxy/src/bridge-proxy.rs @@ -3,18 +3,18 @@ multiversx_sc::imports!(); multiversx_sc::derive_imports!(); -mod config; +pub mod config; use transaction::{EthTransaction, EthTransactionPayment}; #[multiversx_sc::contract] pub trait BridgeProxyContract: config::ConfigModule { #[init] - fn init(&self, multi_transfer_address: ManagedAddress) { - self.multi_transfer_address() - .set_if_empty(&multi_transfer_address); + fn init(&self, opt_multi_transfer_address: OptionalValue) { + self.set_multi_transfer_contract_address(opt_multi_transfer_address); } + #[payable("*")] #[endpoint] fn deposit(&self, eth_tx: EthTransaction) { let (token_id, nonce, amount) = self.call_value().single_esdt().into_tuple(); diff --git a/bridge-proxy/src/config.rs b/bridge-proxy/src/config.rs index 2f035cdd..f2c002e9 100644 --- a/bridge-proxy/src/config.rs +++ b/bridge-proxy/src/config.rs @@ -7,13 +7,26 @@ use transaction::EthTransactionPayment; pub trait ConfigModule { #[only_owner] #[endpoint(setupMultiTransfer)] - fn setup_multi_transfer(&self, multi_transfer_address: ManagedAddress) { - require!( - self.blockchain().is_smart_contract(&multi_transfer_address), - "Invalid multi-transfer address" - ); + fn set_multi_transfer_contract_address(&self, opt_multi_transfer_address: OptionalValue) { + match opt_multi_transfer_address { + OptionalValue::Some(sc_addr) => { + require!( + self.blockchain().is_smart_contract(&sc_addr), + "Invalid multi-transfer address" + ); + self.multi_transfer_address().set(&sc_addr); + } + OptionalValue::None => self.multi_transfer_address().clear(), + } + } - self.multi_transfer_address().set(&multi_transfer_address); + #[view(getEthTransactionById)] + fn get_eth_transaction_by_id(&self, id: u32) -> ManagedBuffer { + let eth_tx_list = self.eth_transaction_list(); + match eth_tx_list.get_node_by_id(id) { + Some(tx) => tx.get_value_cloned().eth_tx.data, + None => sc_panic!("No transaction with this id!") + } } #[view(getMultiTransferAddress)] diff --git a/bridge-proxy/tests/bridge-proxy-blackbox-setup/mod.rs b/bridge-proxy/tests/bridge-proxy-blackbox-setup/mod.rs new file mode 100644 index 00000000..c2404b1f --- /dev/null +++ b/bridge-proxy/tests/bridge-proxy-blackbox-setup/mod.rs @@ -0,0 +1,56 @@ + +use bridge_proxy::bridge_proxy::ConfigModule; + +use multiversx_sc::{ + api::ManagedTypeApi, + codec::multi_types::OptionalValue, + types::{Address, BigUint, BoxedBytes, CodeMetadata, ManagedBuffer, ManagedVec}, +}; +use multiversx_sc_scenario::{managed_address, rust_biguint, testing_framework::*, DebugApi}; + + +const BRIDGE_PROXY_WASM_PATH: &str = "bridge-proxy/output/bridge-proxy.wasm"; +const BRIDGE_TOKEN_ID: &[u8] = b"BRIDGE-123456"; + + +pub struct BridgeProxySetup +where + BridgeProxyObjBuilder: 'static + Copy + Fn() -> bridge_proxy::ContractObj, +{ + pub b_mock: BlockchainStateWrapper, + pub owner_address: Address, + pub bp_wrapper: ContractObjWrapper, BridgeProxyObjBuilder>, +} + +impl BridgeProxySetup +where + BridgeProxyObjBuilder: 'static + Copy + Fn() -> bridge_proxy::ContractObj, +{ + pub fn new(bp_builder: BridgeProxyObjBuilder) -> Self { + let rust_zero = rust_biguint!(0u64); + let mut b_mock = BlockchainStateWrapper::new(); + let owner_address = b_mock.create_user_account(&rust_zero); + + let bp_wrapper = b_mock.create_sc_account( + &rust_zero, + Some(&owner_address), + bp_builder, + BRIDGE_PROXY_PATH, + ); + b_mock + .execute_tx(&owner_address, &ms_wrapper, &rust_zero, |sc| { + let mut board_members = ManagedVec::new(); + board_members.push(managed_address!(&board_member_address)); + + sc.init(QUORUM_SIZE, board_members.into()); + sc.change_user_role(0, managed_address!(&proposer_address), UserRole::Proposer); + }) + .assert_ok(); + + Self { + b_mock, + owner_address, + bp_wrapper, + } + } +} \ No newline at end of file diff --git a/bridge-proxy/tests/bridge_proxy_blackbox_test.rs b/bridge-proxy/tests/bridge_proxy_blackbox_test.rs new file mode 100644 index 00000000..8a4e0f0d --- /dev/null +++ b/bridge-proxy/tests/bridge_proxy_blackbox_test.rs @@ -0,0 +1,148 @@ +#![allow(unused)] + +use std::collections::LinkedList; + +use bridge_proxy::config::ProxyTrait as _; +use bridge_proxy::ProxyTrait; + +use multiversx_sc::{ + api::ManagedTypeApi, + codec::multi_types::{MultiValueVec, OptionalValue}, + storage::mappers::SingleValue, + types::{ + Address, BigUint, CodeMetadata, ManagedAddress, ManagedBuffer, ManagedByteArray, + TokenIdentifier, + }, +}; +use multiversx_sc_scenario::{ + api::StaticApi, + scenario_format::interpret_trait::{InterpretableFrom, InterpreterContext}, + scenario_model::*, + ContractInfo, ScenarioWorld, +}; + +use eth_address::*; +use transaction::{EthTransaction, EthTransactionPayment}; + +const BRIDGE_TOKEN_ID: &[u8] = b"BRIDGE-123456"; +const MULTI_TRANSFER_CONTRACT_ADDRESS: &str = + "0x0000000000000000000000000000000000000000000000000000000000000000"; + +const USER_ETHEREUM_ADDRESS: &[u8] = b"0x0102030405060708091011121314151617181920"; + +const GAS_LIMIT: u64 = 1_000_000; + +const BRIDGE_PROXY_PATH_EXPR: &str = "file:output/bridge-proxy.wasm"; +// const MULTI_TRANSFER_PATH_EXPR: &str = "file:../multi-transfer-esdt/output/multi-transfer-esdt.wasm"; +// const ADDER_PATH_EXPR: &str = "file:test-contracts/adder.wasm"; + +fn world() -> ScenarioWorld { + let mut blockchain = ScenarioWorld::new(); + + blockchain.register_contract(BRIDGE_PROXY_PATH_EXPR, bridge_proxy::ContractBuilder); + blockchain +} + +#[test] +fn basic_setup_test() { + let mut test = BridgeProxyTestState::setup(); + let bridge_token_id_expr = "str:BRIDGE-123456"; // when specifying the token transfer + + test.bridge_proxy_deploy(); + + let eth_tx = EthTransaction { + from: test.eth_user, + to: ManagedAddress::from_address(&test.user.value), + token_id: TokenIdentifier::from_esdt_bytes(BRIDGE_TOKEN_ID), + amount: BigUint::from(500u64), + tx_nonce: 1u64, + data: ManagedBuffer::from("data"), + gas_limit: GAS_LIMIT, + }; + + test.world.set_state_step(SetStateStep::new().put_account( + &test.owner, + Account::new().esdt_balance(bridge_token_id_expr, 1_000u64), + )); + + test.world.sc_call( + ScCallStep::new() + .from(&test.owner) + .to(&test.bridge_proxy) + .call(test.bridge_proxy.deposit(ð_tx)) + .esdt_transfer(bridge_token_id_expr, 0u64, 500u64), + ); + + test.world.sc_query( + ScQueryStep::new() + .to(&test.bridge_proxy) + .call(test.bridge_proxy.get_eth_transaction_by_id(1u32)) + .expect_value(eth_tx.data)); + // |tr| { + // let respose: LinkedList> = tr.result.unwrap(); + // let reponse_eth_tx = respose.pop_front(); + + // let eth_tx_payment = EthTransactionPayment { + // token_id: TokenIdentifier::from_esdt_bytes(BRIDGE_TOKEN_ID), + // nonce: 0u64, + // amount: BigUint::from(500u64), + // eth_tx, + // }; + // match reponse_eth_tx { + // Some(tx) => assert!(tx.eq(ð_tx_payment), "Transactions not equal!"), + // None => panic!("No transaction registered!"), + // } + // }, + // ); +} + +type BridgeProxyContract = ContractInfo>; + +struct BridgeProxyTestState { + world: ScenarioWorld, + owner: AddressValue, + user: AddressValue, + eth_user: EthAddress, + bridge_proxy: BridgeProxyContract, +} + +impl BridgeProxyTestState { + fn setup() -> Self { + let world = world(); + let ic = &world.interpreter_context(); + + let mut state = BridgeProxyTestState { + world, + owner: "address:owner".into(), + user: "address:user".into(), + eth_user: EthAddress { + raw_addr: ManagedByteArray::default(), + }, + bridge_proxy: BridgeProxyContract::new("sc:bridge_proxy"), + }; + + state + .world + .set_state_step(SetStateStep::new().put_account(&state.owner, Account::new().nonce(1))); + + state + } + + fn bridge_proxy_deploy(&mut self) -> &mut Self { + self.world.set_state_step( + SetStateStep::new() + .put_account(&self.owner, Account::new().nonce(1)) + .new_address(&self.owner, 1, &self.bridge_proxy), + ); + + let ic = &self.world.interpreter_context(); + self.world.sc_deploy( + ScDeployStep::new() + .from(self.owner.clone()) + .code(self.world.code_expression(BRIDGE_PROXY_PATH_EXPR)) + .call(self.bridge_proxy.init(ManagedAddress::zero())), + ); + + self + } +} diff --git a/bridge-proxy/tests/bridge_proxy_rust_test.rs b/bridge-proxy/tests/bridge_proxy_rust_test.rs deleted file mode 100644 index 28227ca6..00000000 --- a/bridge-proxy/tests/bridge_proxy_rust_test.rs +++ /dev/null @@ -1,64 +0,0 @@ -use bridge_proxy::*; -use multiversx_sc::types::Address; -use multiversx_sc_scenario::{managed_address, rust_biguint, testing_framework::*, DebugApi}; - -const BRIDGE_PROXY_PATH: &str = "output/bridge-proxy.wasm"; - -struct ContractSetup -where - BridgeProxyObjBuilder: 'static + Copy + Fn() -> bridge_proxy::ContractObj, -{ - pub blockchain_wrapper: BlockchainStateWrapper, - pub owner_address: Address, - pub bridge_proxy_wrapper: - ContractObjWrapper, BridgeProxyObjBuilder>, -} - -fn setup_contract( - bridge_proxy_builder: BridgeProxyObjBuilder, -) -> ContractSetup -where - BridgeProxyObjBuilder: 'static + Copy + Fn() -> bridge_proxy::ContractObj, -{ - let rust_zero = rust_biguint!(0u64); - let mut blockchain_wrapper = BlockchainStateWrapper::new(); - let owner_address = blockchain_wrapper.create_user_account(&rust_zero); - let bridge_proxy_wrapper = blockchain_wrapper.create_sc_account( - &rust_zero, - Some(&owner_address), - bridge_proxy_builder, - BRIDGE_PROXY_PATH, - ); - - blockchain_wrapper - .execute_tx(&owner_address, &bridge_proxy_wrapper, &rust_zero, |sc| { - sc.init(managed_address!(&Address::zero())); - }) - .assert_ok(); - - blockchain_wrapper.add_mandos_set_account(bridge_proxy_wrapper.address_ref()); - - ContractSetup { - blockchain_wrapper, - owner_address, - bridge_proxy_wrapper, - } -} - -#[test] -fn deploy_test() { - let mut setup = setup_contract(bridge_proxy::contract_obj); - - // simulate deploy - setup - .blockchain_wrapper - .execute_tx( - &setup.owner_address, - &setup.bridge_proxy_wrapper, - &rust_biguint!(0u64), - |sc| { - sc.init(managed_address!(&Address::zero())); - }, - ) - .assert_ok(); -} diff --git a/bridge-proxy/tests/bridge_proxy_scenario_go_test.rs b/bridge-proxy/tests/bridge_proxy_scenario_go_test.rs deleted file mode 100644 index 2fca5f45..00000000 --- a/bridge-proxy/tests/bridge_proxy_scenario_go_test.rs +++ /dev/null @@ -1,10 +0,0 @@ -use multiversx_sc_scenario::*; - -fn world() -> ScenarioWorld { - ScenarioWorld::vm_go() -} - -#[test] -fn bridge_proxy_go() { - world().run("scenarios/bridge-proxy.scen.json"); -} diff --git a/bridge-proxy/tests/bridge_proxy_scenario_rs_test.rs b/bridge-proxy/tests/bridge_proxy_scenario_rs_test.rs deleted file mode 100644 index 9f8940b6..00000000 --- a/bridge-proxy/tests/bridge_proxy_scenario_rs_test.rs +++ /dev/null @@ -1,16 +0,0 @@ -use multiversx_sc_scenario::*; - -fn world() -> ScenarioWorld { - let mut blockchain = ScenarioWorld::new(); - - blockchain.register_contract( - "file:output/bridge-proxy.wasm", - bridge_proxy::ContractBuilder, - ); - blockchain -} - -#[test] -fn bridge_proxy_rs() { - world().run("scenarios/bridge-proxy.scen.json"); -} diff --git a/bridge-proxy/wasm/Cargo.lock b/bridge-proxy/wasm/Cargo.lock index 0b278dad..c43b87e1 100644 --- a/bridge-proxy/wasm/Cargo.lock +++ b/bridge-proxy/wasm/Cargo.lock @@ -35,6 +35,7 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" name = "bridge-proxy" version = "0.0.0" dependencies = [ + "eth-address", "multiversx-sc", "transaction", ] diff --git a/bridge-proxy/wasm/src/lib.rs b/bridge-proxy/wasm/src/lib.rs index 89af2cdb..757dc9cd 100644 --- a/bridge-proxy/wasm/src/lib.rs +++ b/bridge-proxy/wasm/src/lib.rs @@ -22,7 +22,7 @@ multiversx_sc_wasm_adapter::endpoints! { deposit => deposit executeWithAsnyc => execute_with_async refundTransactions => refund_transactions - setupMultiTransfer => setup_multi_transfer + setupMultiTransfer => set_multi_transfer_contract_address getMultiTransferAddress => multi_transfer_address getEthTransactionList => eth_transaction_list getEthFailedTransactionList => eth_failed_transaction_list From b22ab53198ffab3829e2c711264ca305028e529a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Mon, 14 Aug 2023 00:30:01 +0300 Subject: [PATCH 14/50] Rename mandos -> scenarios --- .../add_wrapped_token.scen.json | 0 .../blacklist_token.scen.json | 0 .../remove_wrapped_token.scen.json | 0 .../{mandos => scenarios}/setup.scen.json | 0 .../unwrap_token.scen.json | 0 .../whitelist_token.scen.json | 0 .../wrap_token.scen.json | 0 .../tests/scenario_go_test.rs | 35 +++++++++----- common/eth-address/src/lib.rs | 5 +- common/transaction/src/lib.rs | 4 +- .../add_refund_batch.scen.json | 0 .../create_another_tx_ok.scen.json | 0 ...te_another_tx_too_late_for_batch.scen.json | 0 .../create_transaction_ok.scen.json | 0 ...eate_transaction_over_max_amount.scen.json | 0 .../distribute_fees.scen.json | 0 .../execute_batch_both_rejected.scen.json | 0 .../execute_batch_both_success.scen.json | 0 ...e_batch_one_success_one_rejected.scen.json | 0 .../execute_transaction_rejected.scen.json | 0 .../execute_transaction_success.scen.json | 0 .../get_next_pending_tx.scen.json | 0 .../get_next_tx_batch.scen.json | 0 .../get_next_tx_batch_too_early.scen.json | 0 .../setup_accounts.scen.json | 0 .../{mandos => scenarios}/zero_fees.scen.json | 0 esdt-safe/tests/scenario_go_test.rs | 46 +++++++++++++------ .../batch_transfer_both_executed.scen.json | 0 .../batch_transfer_both_failed.scen.json | 0 ...transfer_one_executed_one_failed.scen.json | 0 ...batch_transfer_to_frozen_account.scen.json | 0 .../batch_transfer_with_wrapping.scen.json | 0 .../setup_accounts.scen.json | 0 .../transfer_ok.scen.json | 0 .../two_transfers_same_token.scen.json | 0 multi-transfer-esdt/tests/scenario_go_test.rs | 25 +++++++--- multi-transfer-esdt/wasm/Cargo.lock | 1 + .../change_token_config.scen.json | 0 ...eate_elrond_to_ethereum_tx_batch.scen.json | 0 .../ethereum_to_elrond_tx_batch_ok.scen.json | 0 ...reum_to_elrond_tx_batch_rejected.scen.json | 0 ...cute_elrond_to_ethereum_tx_batch.scen.json | 0 .../get_empty_batch.scen.json | 0 ...ject_elrond_to_ethereum_tx_batch.scen.json | 0 .../{mandos => scenarios}/setup.scen.json | 0 .../{mandos => scenarios}/unstake.scen.json | 0 multisig/tests/scenario_go_test.rs | 37 +++++++++------ multisig/wasm/Cargo.lock | 1 + .../{mandos => scenarios}/deploy.scen.json | 0 .../get_latest_price_feed.scen.json | 0 ...acle_gwei_in_eth_and_egld_submit.scen.json | 0 .../oracle_submit.scen.json | 0 52 files changed, 101 insertions(+), 53 deletions(-) rename bridged-tokens-wrapper/{mandos => scenarios}/add_wrapped_token.scen.json (100%) rename bridged-tokens-wrapper/{mandos => scenarios}/blacklist_token.scen.json (100%) rename bridged-tokens-wrapper/{mandos => scenarios}/remove_wrapped_token.scen.json (100%) rename bridged-tokens-wrapper/{mandos => scenarios}/setup.scen.json (100%) rename bridged-tokens-wrapper/{mandos => scenarios}/unwrap_token.scen.json (100%) rename bridged-tokens-wrapper/{mandos => scenarios}/whitelist_token.scen.json (100%) rename bridged-tokens-wrapper/{mandos => scenarios}/wrap_token.scen.json (100%) rename esdt-safe/{mandos => scenarios}/add_refund_batch.scen.json (100%) rename esdt-safe/{mandos => scenarios}/create_another_tx_ok.scen.json (100%) rename esdt-safe/{mandos => scenarios}/create_another_tx_too_late_for_batch.scen.json (100%) rename esdt-safe/{mandos => scenarios}/create_transaction_ok.scen.json (100%) rename esdt-safe/{mandos => scenarios}/create_transaction_over_max_amount.scen.json (100%) rename esdt-safe/{mandos => scenarios}/distribute_fees.scen.json (100%) rename esdt-safe/{mandos => scenarios}/execute_batch_both_rejected.scen.json (100%) rename esdt-safe/{mandos => scenarios}/execute_batch_both_success.scen.json (100%) rename esdt-safe/{mandos => scenarios}/execute_batch_one_success_one_rejected.scen.json (100%) rename esdt-safe/{mandos => scenarios}/execute_transaction_rejected.scen.json (100%) rename esdt-safe/{mandos => scenarios}/execute_transaction_success.scen.json (100%) rename esdt-safe/{mandos => scenarios}/get_next_pending_tx.scen.json (100%) rename esdt-safe/{mandos => scenarios}/get_next_tx_batch.scen.json (100%) rename esdt-safe/{mandos => scenarios}/get_next_tx_batch_too_early.scen.json (100%) rename esdt-safe/{mandos => scenarios}/setup_accounts.scen.json (100%) rename esdt-safe/{mandos => scenarios}/zero_fees.scen.json (100%) rename multi-transfer-esdt/{mandos => scenarios}/batch_transfer_both_executed.scen.json (100%) rename multi-transfer-esdt/{mandos => scenarios}/batch_transfer_both_failed.scen.json (100%) rename multi-transfer-esdt/{mandos => scenarios}/batch_transfer_one_executed_one_failed.scen.json (100%) rename multi-transfer-esdt/{mandos => scenarios}/batch_transfer_to_frozen_account.scen.json (100%) rename multi-transfer-esdt/{mandos => scenarios}/batch_transfer_with_wrapping.scen.json (100%) rename multi-transfer-esdt/{mandos => scenarios}/setup_accounts.scen.json (100%) rename multi-transfer-esdt/{mandos => scenarios}/transfer_ok.scen.json (100%) rename multi-transfer-esdt/{mandos => scenarios}/two_transfers_same_token.scen.json (100%) rename multisig/{mandos => scenarios}/change_token_config.scen.json (100%) rename multisig/{mandos => scenarios}/create_elrond_to_ethereum_tx_batch.scen.json (100%) rename multisig/{mandos => scenarios}/ethereum_to_elrond_tx_batch_ok.scen.json (100%) rename multisig/{mandos => scenarios}/ethereum_to_elrond_tx_batch_rejected.scen.json (100%) rename multisig/{mandos => scenarios}/execute_elrond_to_ethereum_tx_batch.scen.json (100%) rename multisig/{mandos => scenarios}/get_empty_batch.scen.json (100%) rename multisig/{mandos => scenarios}/reject_elrond_to_ethereum_tx_batch.scen.json (100%) rename multisig/{mandos => scenarios}/setup.scen.json (100%) rename multisig/{mandos => scenarios}/unstake.scen.json (100%) rename price-aggregator/{mandos => scenarios}/deploy.scen.json (100%) rename price-aggregator/{mandos => scenarios}/get_latest_price_feed.scen.json (100%) rename price-aggregator/{mandos => scenarios}/oracle_gwei_in_eth_and_egld_submit.scen.json (100%) rename price-aggregator/{mandos => scenarios}/oracle_submit.scen.json (100%) diff --git a/bridged-tokens-wrapper/mandos/add_wrapped_token.scen.json b/bridged-tokens-wrapper/scenarios/add_wrapped_token.scen.json similarity index 100% rename from bridged-tokens-wrapper/mandos/add_wrapped_token.scen.json rename to bridged-tokens-wrapper/scenarios/add_wrapped_token.scen.json diff --git a/bridged-tokens-wrapper/mandos/blacklist_token.scen.json b/bridged-tokens-wrapper/scenarios/blacklist_token.scen.json similarity index 100% rename from bridged-tokens-wrapper/mandos/blacklist_token.scen.json rename to bridged-tokens-wrapper/scenarios/blacklist_token.scen.json diff --git a/bridged-tokens-wrapper/mandos/remove_wrapped_token.scen.json b/bridged-tokens-wrapper/scenarios/remove_wrapped_token.scen.json similarity index 100% rename from bridged-tokens-wrapper/mandos/remove_wrapped_token.scen.json rename to bridged-tokens-wrapper/scenarios/remove_wrapped_token.scen.json diff --git a/bridged-tokens-wrapper/mandos/setup.scen.json b/bridged-tokens-wrapper/scenarios/setup.scen.json similarity index 100% rename from bridged-tokens-wrapper/mandos/setup.scen.json rename to bridged-tokens-wrapper/scenarios/setup.scen.json diff --git a/bridged-tokens-wrapper/mandos/unwrap_token.scen.json b/bridged-tokens-wrapper/scenarios/unwrap_token.scen.json similarity index 100% rename from bridged-tokens-wrapper/mandos/unwrap_token.scen.json rename to bridged-tokens-wrapper/scenarios/unwrap_token.scen.json diff --git a/bridged-tokens-wrapper/mandos/whitelist_token.scen.json b/bridged-tokens-wrapper/scenarios/whitelist_token.scen.json similarity index 100% rename from bridged-tokens-wrapper/mandos/whitelist_token.scen.json rename to bridged-tokens-wrapper/scenarios/whitelist_token.scen.json diff --git a/bridged-tokens-wrapper/mandos/wrap_token.scen.json b/bridged-tokens-wrapper/scenarios/wrap_token.scen.json similarity index 100% rename from bridged-tokens-wrapper/mandos/wrap_token.scen.json rename to bridged-tokens-wrapper/scenarios/wrap_token.scen.json diff --git a/bridged-tokens-wrapper/tests/scenario_go_test.rs b/bridged-tokens-wrapper/tests/scenario_go_test.rs index 4bbc4b02..a3d6e919 100644 --- a/bridged-tokens-wrapper/tests/scenario_go_test.rs +++ b/bridged-tokens-wrapper/tests/scenario_go_test.rs @@ -1,29 +1,40 @@ +use multiversx_sc_scenario::*; + +fn world() -> ScenarioWorld { + ScenarioWorld::vm_go() +} + #[test] -fn unwrap_token_go() { - multiversx_sc_scenario::run_go("mandos/unwrap_token.scen.json"); +fn add_wrapped_token_go() { + world().run("scenarios/add_wrapped_token.scen.json"); } #[test] -fn wrap_token_go() { - multiversx_sc_scenario::run_go("mandos/wrap_token.scen.json"); +fn blacklist_token_go() { + world().run("scenarios/blacklist_token.scen.json"); } #[test] -fn whitelist_token_go() { - multiversx_sc_scenario::run_go("mandos/whitelist_token.scen.json"); +fn remove_wrapped_token_go() { + world().run("scenarios/remove_wrapped_token.scen.json"); } #[test] -fn blacklist_token_go() { - multiversx_sc_scenario::run_go("mandos/blacklist_token.scen.json"); +fn setup_go() { + world().run("scenarios/setup.scen.json"); } #[test] -fn add_wrapped_token_go() { - multiversx_sc_scenario::run_go("mandos/add_wrapped_token.scen.json"); +fn unwrap_token_go() { + world().run("scenarios/unwrap_token.scen.json"); } #[test] -fn remove_wrapped_token_go() { - multiversx_sc_scenario::run_go("mandos/remove_wrapped_token.scen.json"); +fn whitelist_token_go() { + world().run("scenarios/whitelist_token.scen.json"); +} + +#[test] +fn wrap_token_go() { + world().run("scenarios/wrap_token.scen.json"); } diff --git a/common/eth-address/src/lib.rs b/common/eth-address/src/lib.rs index 0e4e6a53..878d94ab 100644 --- a/common/eth-address/src/lib.rs +++ b/common/eth-address/src/lib.rs @@ -9,7 +9,7 @@ use multiversx_sc::{ pub const ETH_ADDRESS_LEN: usize = 20; /// Wrapper over a 20-byte array -#[derive(TypeAbi, TopEncode, TopDecode, NestedEncode, NestedDecode, Clone, ManagedVecItem)] +#[derive(TypeAbi, TopEncode, TopDecode, NestedEncode, NestedDecode, Clone, ManagedVecItem, PartialEq)] pub struct EthAddress { pub raw_addr: ManagedByteArray, } @@ -24,4 +24,5 @@ impl EthAddress { pub fn as_managed_buffer(&self) -> &ManagedBuffer { self.raw_addr.as_managed_buffer() } -} + +} \ No newline at end of file diff --git a/common/transaction/src/lib.rs b/common/transaction/src/lib.rs index c2098019..68d3a2a8 100644 --- a/common/transaction/src/lib.rs +++ b/common/transaction/src/lib.rs @@ -26,7 +26,7 @@ pub type TxAsMultiValue = MultiValue6< pub type PaymentsVec = ManagedVec>; pub type TxBatchSplitInFields = MultiValue2>>; -#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, ManagedVecItem, Clone)] +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, ManagedVecItem, Clone, PartialEq)] pub struct EthTransaction { pub from: EthAddress, pub to: ManagedAddress, @@ -47,7 +47,7 @@ pub type EthTxAsMultiValue = MultiValue7< u64, >; -#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, ManagedVecItem, Clone)] +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, ManagedVecItem, Clone, PartialEq)] pub struct EthTransactionPayment { pub token_id: TokenIdentifier, pub nonce: u64, diff --git a/esdt-safe/mandos/add_refund_batch.scen.json b/esdt-safe/scenarios/add_refund_batch.scen.json similarity index 100% rename from esdt-safe/mandos/add_refund_batch.scen.json rename to esdt-safe/scenarios/add_refund_batch.scen.json diff --git a/esdt-safe/mandos/create_another_tx_ok.scen.json b/esdt-safe/scenarios/create_another_tx_ok.scen.json similarity index 100% rename from esdt-safe/mandos/create_another_tx_ok.scen.json rename to esdt-safe/scenarios/create_another_tx_ok.scen.json diff --git a/esdt-safe/mandos/create_another_tx_too_late_for_batch.scen.json b/esdt-safe/scenarios/create_another_tx_too_late_for_batch.scen.json similarity index 100% rename from esdt-safe/mandos/create_another_tx_too_late_for_batch.scen.json rename to esdt-safe/scenarios/create_another_tx_too_late_for_batch.scen.json diff --git a/esdt-safe/mandos/create_transaction_ok.scen.json b/esdt-safe/scenarios/create_transaction_ok.scen.json similarity index 100% rename from esdt-safe/mandos/create_transaction_ok.scen.json rename to esdt-safe/scenarios/create_transaction_ok.scen.json diff --git a/esdt-safe/mandos/create_transaction_over_max_amount.scen.json b/esdt-safe/scenarios/create_transaction_over_max_amount.scen.json similarity index 100% rename from esdt-safe/mandos/create_transaction_over_max_amount.scen.json rename to esdt-safe/scenarios/create_transaction_over_max_amount.scen.json diff --git a/esdt-safe/mandos/distribute_fees.scen.json b/esdt-safe/scenarios/distribute_fees.scen.json similarity index 100% rename from esdt-safe/mandos/distribute_fees.scen.json rename to esdt-safe/scenarios/distribute_fees.scen.json diff --git a/esdt-safe/mandos/execute_batch_both_rejected.scen.json b/esdt-safe/scenarios/execute_batch_both_rejected.scen.json similarity index 100% rename from esdt-safe/mandos/execute_batch_both_rejected.scen.json rename to esdt-safe/scenarios/execute_batch_both_rejected.scen.json diff --git a/esdt-safe/mandos/execute_batch_both_success.scen.json b/esdt-safe/scenarios/execute_batch_both_success.scen.json similarity index 100% rename from esdt-safe/mandos/execute_batch_both_success.scen.json rename to esdt-safe/scenarios/execute_batch_both_success.scen.json diff --git a/esdt-safe/mandos/execute_batch_one_success_one_rejected.scen.json b/esdt-safe/scenarios/execute_batch_one_success_one_rejected.scen.json similarity index 100% rename from esdt-safe/mandos/execute_batch_one_success_one_rejected.scen.json rename to esdt-safe/scenarios/execute_batch_one_success_one_rejected.scen.json diff --git a/esdt-safe/mandos/execute_transaction_rejected.scen.json b/esdt-safe/scenarios/execute_transaction_rejected.scen.json similarity index 100% rename from esdt-safe/mandos/execute_transaction_rejected.scen.json rename to esdt-safe/scenarios/execute_transaction_rejected.scen.json diff --git a/esdt-safe/mandos/execute_transaction_success.scen.json b/esdt-safe/scenarios/execute_transaction_success.scen.json similarity index 100% rename from esdt-safe/mandos/execute_transaction_success.scen.json rename to esdt-safe/scenarios/execute_transaction_success.scen.json diff --git a/esdt-safe/mandos/get_next_pending_tx.scen.json b/esdt-safe/scenarios/get_next_pending_tx.scen.json similarity index 100% rename from esdt-safe/mandos/get_next_pending_tx.scen.json rename to esdt-safe/scenarios/get_next_pending_tx.scen.json diff --git a/esdt-safe/mandos/get_next_tx_batch.scen.json b/esdt-safe/scenarios/get_next_tx_batch.scen.json similarity index 100% rename from esdt-safe/mandos/get_next_tx_batch.scen.json rename to esdt-safe/scenarios/get_next_tx_batch.scen.json diff --git a/esdt-safe/mandos/get_next_tx_batch_too_early.scen.json b/esdt-safe/scenarios/get_next_tx_batch_too_early.scen.json similarity index 100% rename from esdt-safe/mandos/get_next_tx_batch_too_early.scen.json rename to esdt-safe/scenarios/get_next_tx_batch_too_early.scen.json diff --git a/esdt-safe/mandos/setup_accounts.scen.json b/esdt-safe/scenarios/setup_accounts.scen.json similarity index 100% rename from esdt-safe/mandos/setup_accounts.scen.json rename to esdt-safe/scenarios/setup_accounts.scen.json diff --git a/esdt-safe/mandos/zero_fees.scen.json b/esdt-safe/scenarios/zero_fees.scen.json similarity index 100% rename from esdt-safe/mandos/zero_fees.scen.json rename to esdt-safe/scenarios/zero_fees.scen.json diff --git a/esdt-safe/tests/scenario_go_test.rs b/esdt-safe/tests/scenario_go_test.rs index 205306a5..7dcd7957 100644 --- a/esdt-safe/tests/scenario_go_test.rs +++ b/esdt-safe/tests/scenario_go_test.rs @@ -1,69 +1,85 @@ +use multiversx_sc_scenario::*; + +fn world() -> ScenarioWorld { + ScenarioWorld::vm_go() +} + #[test] -fn claim_fees_go() { - multiversx_sc_scenario::run_go("mandos/distribute_fees.scen.json"); +fn add_refund_batch_go() { + world().run("scenarios/add_refund_batch.scen.json"); } #[test] fn create_another_tx_ok_go() { - multiversx_sc_scenario::run_go("mandos/create_another_tx_ok.scen.json"); + world().run("scenarios/create_another_tx_ok.scen.json"); } #[test] fn create_another_tx_too_late_for_batch_go() { - multiversx_sc_scenario::run_go("mandos/create_another_tx_too_late_for_batch.scen.json"); + world().run("scenarios/create_another_tx_too_late_for_batch.scen.json"); } #[test] fn create_transaction_ok_go() { - multiversx_sc_scenario::run_go("mandos/create_transaction_ok.scen.json"); + world().run("scenarios/create_transaction_ok.scen.json"); +} + +#[test] +fn create_transaction_over_max_amount_go() { + world().run("scenarios/create_transaction_over_max_amount.scen.json"); +} + +#[test] +fn distribute_fees_go() { + world().run("scenarios/distribute_fees.scen.json"); } #[test] fn execute_batch_both_rejected_go() { - multiversx_sc_scenario::run_go("mandos/execute_batch_both_rejected.scen.json"); + world().run("scenarios/execute_batch_both_rejected.scen.json"); } #[test] fn execute_batch_both_success_go() { - multiversx_sc_scenario::run_go("mandos/execute_batch_both_success.scen.json"); + world().run("scenarios/execute_batch_both_success.scen.json"); } #[test] fn execute_batch_one_success_one_rejected_go() { - multiversx_sc_scenario::run_go("mandos/execute_batch_one_success_one_rejected.scen.json"); + world().run("scenarios/execute_batch_one_success_one_rejected.scen.json"); } #[test] fn execute_transaction_rejected_go() { - multiversx_sc_scenario::run_go("mandos/execute_transaction_rejected.scen.json"); + world().run("scenarios/execute_transaction_rejected.scen.json"); } #[test] fn execute_transaction_success_go() { - multiversx_sc_scenario::run_go("mandos/execute_transaction_success.scen.json"); + world().run("scenarios/execute_transaction_success.scen.json"); } #[test] fn get_next_pending_tx_go() { - multiversx_sc_scenario::run_go("mandos/get_next_pending_tx.scen.json"); + world().run("scenarios/get_next_pending_tx.scen.json"); } #[test] fn get_next_tx_batch_go() { - multiversx_sc_scenario::run_go("mandos/get_next_tx_batch.scen.json"); + world().run("scenarios/get_next_tx_batch.scen.json"); } #[test] fn get_next_tx_batch_too_early_go() { - multiversx_sc_scenario::run_go("mandos/get_next_tx_batch_too_early.scen.json"); + world().run("scenarios/get_next_tx_batch_too_early.scen.json"); } #[test] fn setup_accounts_go() { - multiversx_sc_scenario::run_go("mandos/setup_accounts.scen.json"); + world().run("scenarios/setup_accounts.scen.json"); } #[test] fn zero_fees_go() { - multiversx_sc_scenario::run_go("mandos/zero_fees.scen.json"); + world().run("scenarios/zero_fees.scen.json"); } diff --git a/multi-transfer-esdt/mandos/batch_transfer_both_executed.scen.json b/multi-transfer-esdt/scenarios/batch_transfer_both_executed.scen.json similarity index 100% rename from multi-transfer-esdt/mandos/batch_transfer_both_executed.scen.json rename to multi-transfer-esdt/scenarios/batch_transfer_both_executed.scen.json diff --git a/multi-transfer-esdt/mandos/batch_transfer_both_failed.scen.json b/multi-transfer-esdt/scenarios/batch_transfer_both_failed.scen.json similarity index 100% rename from multi-transfer-esdt/mandos/batch_transfer_both_failed.scen.json rename to multi-transfer-esdt/scenarios/batch_transfer_both_failed.scen.json diff --git a/multi-transfer-esdt/mandos/batch_transfer_one_executed_one_failed.scen.json b/multi-transfer-esdt/scenarios/batch_transfer_one_executed_one_failed.scen.json similarity index 100% rename from multi-transfer-esdt/mandos/batch_transfer_one_executed_one_failed.scen.json rename to multi-transfer-esdt/scenarios/batch_transfer_one_executed_one_failed.scen.json diff --git a/multi-transfer-esdt/mandos/batch_transfer_to_frozen_account.scen.json b/multi-transfer-esdt/scenarios/batch_transfer_to_frozen_account.scen.json similarity index 100% rename from multi-transfer-esdt/mandos/batch_transfer_to_frozen_account.scen.json rename to multi-transfer-esdt/scenarios/batch_transfer_to_frozen_account.scen.json diff --git a/multi-transfer-esdt/mandos/batch_transfer_with_wrapping.scen.json b/multi-transfer-esdt/scenarios/batch_transfer_with_wrapping.scen.json similarity index 100% rename from multi-transfer-esdt/mandos/batch_transfer_with_wrapping.scen.json rename to multi-transfer-esdt/scenarios/batch_transfer_with_wrapping.scen.json diff --git a/multi-transfer-esdt/mandos/setup_accounts.scen.json b/multi-transfer-esdt/scenarios/setup_accounts.scen.json similarity index 100% rename from multi-transfer-esdt/mandos/setup_accounts.scen.json rename to multi-transfer-esdt/scenarios/setup_accounts.scen.json diff --git a/multi-transfer-esdt/mandos/transfer_ok.scen.json b/multi-transfer-esdt/scenarios/transfer_ok.scen.json similarity index 100% rename from multi-transfer-esdt/mandos/transfer_ok.scen.json rename to multi-transfer-esdt/scenarios/transfer_ok.scen.json diff --git a/multi-transfer-esdt/mandos/two_transfers_same_token.scen.json b/multi-transfer-esdt/scenarios/two_transfers_same_token.scen.json similarity index 100% rename from multi-transfer-esdt/mandos/two_transfers_same_token.scen.json rename to multi-transfer-esdt/scenarios/two_transfers_same_token.scen.json diff --git a/multi-transfer-esdt/tests/scenario_go_test.rs b/multi-transfer-esdt/tests/scenario_go_test.rs index cdda9c2b..099736dd 100644 --- a/multi-transfer-esdt/tests/scenario_go_test.rs +++ b/multi-transfer-esdt/tests/scenario_go_test.rs @@ -1,34 +1,45 @@ +use multiversx_sc_scenario::*; + +fn world() -> ScenarioWorld { + ScenarioWorld::vm_go() +} + #[test] fn batch_transfer_both_executed_go() { - multiversx_sc_scenario::run_go("mandos/batch_transfer_both_executed.scen.json"); + world().run("scenarios/batch_transfer_both_executed.scen.json"); } #[test] fn batch_transfer_both_failed_go() { - multiversx_sc_scenario::run_go("mandos/batch_transfer_both_failed.scen.json"); + world().run("scenarios/batch_transfer_both_failed.scen.json"); } #[test] fn batch_transfer_one_executed_one_failed_go() { - multiversx_sc_scenario::run_go("mandos/batch_transfer_one_executed_one_failed.scen.json"); + world().run("scenarios/batch_transfer_one_executed_one_failed.scen.json"); } #[test] fn batch_transfer_to_frozen_account_go() { - multiversx_sc_scenario::run_go("mandos/batch_transfer_to_frozen_account.scen.json"); + world().run("scenarios/batch_transfer_to_frozen_account.scen.json"); +} + +#[test] +fn batch_transfer_with_wrapping_go() { + world().run("scenarios/batch_transfer_with_wrapping.scen.json"); } #[test] fn setup_accounts_go() { - multiversx_sc_scenario::run_go("mandos/setup_accounts.scen.json"); + world().run("scenarios/setup_accounts.scen.json"); } #[test] fn transfer_ok_go() { - multiversx_sc_scenario::run_go("mandos/transfer_ok.scen.json"); + world().run("scenarios/transfer_ok.scen.json"); } #[test] fn two_transfers_same_token_go() { - multiversx_sc_scenario::run_go("mandos/two_transfers_same_token.scen.json"); + world().run("scenarios/two_transfers_same_token.scen.json"); } diff --git a/multi-transfer-esdt/wasm/Cargo.lock b/multi-transfer-esdt/wasm/Cargo.lock index 58967f4e..e4dc86a0 100644 --- a/multi-transfer-esdt/wasm/Cargo.lock +++ b/multi-transfer-esdt/wasm/Cargo.lock @@ -35,6 +35,7 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" name = "bridge-proxy" version = "0.0.0" dependencies = [ + "eth-address", "multiversx-sc", "transaction", ] diff --git a/multisig/mandos/change_token_config.scen.json b/multisig/scenarios/change_token_config.scen.json similarity index 100% rename from multisig/mandos/change_token_config.scen.json rename to multisig/scenarios/change_token_config.scen.json diff --git a/multisig/mandos/create_elrond_to_ethereum_tx_batch.scen.json b/multisig/scenarios/create_elrond_to_ethereum_tx_batch.scen.json similarity index 100% rename from multisig/mandos/create_elrond_to_ethereum_tx_batch.scen.json rename to multisig/scenarios/create_elrond_to_ethereum_tx_batch.scen.json diff --git a/multisig/mandos/ethereum_to_elrond_tx_batch_ok.scen.json b/multisig/scenarios/ethereum_to_elrond_tx_batch_ok.scen.json similarity index 100% rename from multisig/mandos/ethereum_to_elrond_tx_batch_ok.scen.json rename to multisig/scenarios/ethereum_to_elrond_tx_batch_ok.scen.json diff --git a/multisig/mandos/ethereum_to_elrond_tx_batch_rejected.scen.json b/multisig/scenarios/ethereum_to_elrond_tx_batch_rejected.scen.json similarity index 100% rename from multisig/mandos/ethereum_to_elrond_tx_batch_rejected.scen.json rename to multisig/scenarios/ethereum_to_elrond_tx_batch_rejected.scen.json diff --git a/multisig/mandos/execute_elrond_to_ethereum_tx_batch.scen.json b/multisig/scenarios/execute_elrond_to_ethereum_tx_batch.scen.json similarity index 100% rename from multisig/mandos/execute_elrond_to_ethereum_tx_batch.scen.json rename to multisig/scenarios/execute_elrond_to_ethereum_tx_batch.scen.json diff --git a/multisig/mandos/get_empty_batch.scen.json b/multisig/scenarios/get_empty_batch.scen.json similarity index 100% rename from multisig/mandos/get_empty_batch.scen.json rename to multisig/scenarios/get_empty_batch.scen.json diff --git a/multisig/mandos/reject_elrond_to_ethereum_tx_batch.scen.json b/multisig/scenarios/reject_elrond_to_ethereum_tx_batch.scen.json similarity index 100% rename from multisig/mandos/reject_elrond_to_ethereum_tx_batch.scen.json rename to multisig/scenarios/reject_elrond_to_ethereum_tx_batch.scen.json diff --git a/multisig/mandos/setup.scen.json b/multisig/scenarios/setup.scen.json similarity index 100% rename from multisig/mandos/setup.scen.json rename to multisig/scenarios/setup.scen.json diff --git a/multisig/mandos/unstake.scen.json b/multisig/scenarios/unstake.scen.json similarity index 100% rename from multisig/mandos/unstake.scen.json rename to multisig/scenarios/unstake.scen.json diff --git a/multisig/tests/scenario_go_test.rs b/multisig/tests/scenario_go_test.rs index 9605e9d4..f8cd6f03 100644 --- a/multisig/tests/scenario_go_test.rs +++ b/multisig/tests/scenario_go_test.rs @@ -1,46 +1,53 @@ +use multiversx_sc_scenario::*; + +fn world() -> ScenarioWorld { + ScenarioWorld::vm_go() +} + +*/ + + +#[test] +fn change_token_config_go() { + world().run("scenarios/change_token_config.scen.json"); +} + #[test] fn create_elrond_to_ethereum_tx_batch_go() { - multiversx_sc_scenario::run_go("mandos/create_elrond_to_ethereum_tx_batch.scen.json"); + world().run("scenarios/create_elrond_to_ethereum_tx_batch.scen.json"); } #[test] fn ethereum_to_elrond_tx_batch_ok_go() { - multiversx_sc_scenario::run_go("mandos/ethereum_to_elrond_tx_batch_ok.scen.json"); + world().run("scenarios/ethereum_to_elrond_tx_batch_ok.scen.json"); } #[test] fn ethereum_to_elrond_tx_batch_rejected_go() { - multiversx_sc_scenario::run_go("mandos/ethereum_to_elrond_tx_batch_rejected.scen.json"); + world().run("scenarios/ethereum_to_elrond_tx_batch_rejected.scen.json"); } #[test] fn execute_elrond_to_ethereum_tx_batch_go() { - multiversx_sc_scenario::run_go("mandos/execute_elrond_to_ethereum_tx_batch.scen.json"); + world().run("scenarios/execute_elrond_to_ethereum_tx_batch.scen.json"); } #[test] fn get_empty_batch_go() { - multiversx_sc_scenario::run_go("mandos/get_empty_batch.scen.json"); + world().run("scenarios/get_empty_batch.scen.json"); } #[test] fn reject_elrond_to_ethereum_tx_batch_go() { - multiversx_sc_scenario::run_go("mandos/reject_elrond_to_ethereum_tx_batch.scen.json"); + world().run("scenarios/reject_elrond_to_ethereum_tx_batch.scen.json"); } #[test] fn setup_go() { - multiversx_sc_scenario::run_go("mandos/setup.scen.json"); + world().run("scenarios/setup.scen.json"); } #[test] fn unstake_go() { - multiversx_sc_scenario::run_go("mandos/unstake.scen.json"); -} - -/* -#[test] -fn upgrade_child_sc_go() { - multiversx_sc_scenario::run_go("mandos/upgrade_child_sc.scen.json"); + world().run("scenarios/unstake.scen.json"); } -*/ diff --git a/multisig/wasm/Cargo.lock b/multisig/wasm/Cargo.lock index 036c6f9c..80816d3f 100644 --- a/multisig/wasm/Cargo.lock +++ b/multisig/wasm/Cargo.lock @@ -35,6 +35,7 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" name = "bridge-proxy" version = "0.0.0" dependencies = [ + "eth-address", "multiversx-sc", "transaction", ] diff --git a/price-aggregator/mandos/deploy.scen.json b/price-aggregator/scenarios/deploy.scen.json similarity index 100% rename from price-aggregator/mandos/deploy.scen.json rename to price-aggregator/scenarios/deploy.scen.json diff --git a/price-aggregator/mandos/get_latest_price_feed.scen.json b/price-aggregator/scenarios/get_latest_price_feed.scen.json similarity index 100% rename from price-aggregator/mandos/get_latest_price_feed.scen.json rename to price-aggregator/scenarios/get_latest_price_feed.scen.json diff --git a/price-aggregator/mandos/oracle_gwei_in_eth_and_egld_submit.scen.json b/price-aggregator/scenarios/oracle_gwei_in_eth_and_egld_submit.scen.json similarity index 100% rename from price-aggregator/mandos/oracle_gwei_in_eth_and_egld_submit.scen.json rename to price-aggregator/scenarios/oracle_gwei_in_eth_and_egld_submit.scen.json diff --git a/price-aggregator/mandos/oracle_submit.scen.json b/price-aggregator/scenarios/oracle_submit.scen.json similarity index 100% rename from price-aggregator/mandos/oracle_submit.scen.json rename to price-aggregator/scenarios/oracle_submit.scen.json From b8e9086874a5776bb29852e56660a89bc1210743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Mon, 14 Aug 2023 15:10:07 +0300 Subject: [PATCH 15/50] Refactor bridge-proxy deposit test --- bridge-proxy/src/config.rs | 6 +- .../tests/bridge-proxy-blackbox-setup/mod.rs | 56 ------------------- .../tests/bridge_proxy_blackbox_test.rs | 29 +--------- 3 files changed, 6 insertions(+), 85 deletions(-) delete mode 100644 bridge-proxy/tests/bridge-proxy-blackbox-setup/mod.rs diff --git a/bridge-proxy/src/config.rs b/bridge-proxy/src/config.rs index f2c002e9..1cedabe2 100644 --- a/bridge-proxy/src/config.rs +++ b/bridge-proxy/src/config.rs @@ -1,7 +1,7 @@ multiversx_sc::imports!(); multiversx_sc::derive_imports!(); -use transaction::EthTransactionPayment; +use transaction::{EthTransactionPayment, EthTransaction}; #[multiversx_sc::module] pub trait ConfigModule { @@ -21,10 +21,10 @@ pub trait ConfigModule { } #[view(getEthTransactionById)] - fn get_eth_transaction_by_id(&self, id: u32) -> ManagedBuffer { + fn get_eth_transaction_by_id(&self, id: u32) -> EthTransaction { let eth_tx_list = self.eth_transaction_list(); match eth_tx_list.get_node_by_id(id) { - Some(tx) => tx.get_value_cloned().eth_tx.data, + Some(tx) => tx.get_value_cloned().eth_tx, None => sc_panic!("No transaction with this id!") } } diff --git a/bridge-proxy/tests/bridge-proxy-blackbox-setup/mod.rs b/bridge-proxy/tests/bridge-proxy-blackbox-setup/mod.rs deleted file mode 100644 index c2404b1f..00000000 --- a/bridge-proxy/tests/bridge-proxy-blackbox-setup/mod.rs +++ /dev/null @@ -1,56 +0,0 @@ - -use bridge_proxy::bridge_proxy::ConfigModule; - -use multiversx_sc::{ - api::ManagedTypeApi, - codec::multi_types::OptionalValue, - types::{Address, BigUint, BoxedBytes, CodeMetadata, ManagedBuffer, ManagedVec}, -}; -use multiversx_sc_scenario::{managed_address, rust_biguint, testing_framework::*, DebugApi}; - - -const BRIDGE_PROXY_WASM_PATH: &str = "bridge-proxy/output/bridge-proxy.wasm"; -const BRIDGE_TOKEN_ID: &[u8] = b"BRIDGE-123456"; - - -pub struct BridgeProxySetup -where - BridgeProxyObjBuilder: 'static + Copy + Fn() -> bridge_proxy::ContractObj, -{ - pub b_mock: BlockchainStateWrapper, - pub owner_address: Address, - pub bp_wrapper: ContractObjWrapper, BridgeProxyObjBuilder>, -} - -impl BridgeProxySetup -where - BridgeProxyObjBuilder: 'static + Copy + Fn() -> bridge_proxy::ContractObj, -{ - pub fn new(bp_builder: BridgeProxyObjBuilder) -> Self { - let rust_zero = rust_biguint!(0u64); - let mut b_mock = BlockchainStateWrapper::new(); - let owner_address = b_mock.create_user_account(&rust_zero); - - let bp_wrapper = b_mock.create_sc_account( - &rust_zero, - Some(&owner_address), - bp_builder, - BRIDGE_PROXY_PATH, - ); - b_mock - .execute_tx(&owner_address, &ms_wrapper, &rust_zero, |sc| { - let mut board_members = ManagedVec::new(); - board_members.push(managed_address!(&board_member_address)); - - sc.init(QUORUM_SIZE, board_members.into()); - sc.change_user_role(0, managed_address!(&proposer_address), UserRole::Proposer); - }) - .assert_ok(); - - Self { - b_mock, - owner_address, - bp_wrapper, - } - } -} \ No newline at end of file diff --git a/bridge-proxy/tests/bridge_proxy_blackbox_test.rs b/bridge-proxy/tests/bridge_proxy_blackbox_test.rs index 8a4e0f0d..1902f57f 100644 --- a/bridge-proxy/tests/bridge_proxy_blackbox_test.rs +++ b/bridge-proxy/tests/bridge_proxy_blackbox_test.rs @@ -25,16 +25,8 @@ use eth_address::*; use transaction::{EthTransaction, EthTransactionPayment}; const BRIDGE_TOKEN_ID: &[u8] = b"BRIDGE-123456"; -const MULTI_TRANSFER_CONTRACT_ADDRESS: &str = - "0x0000000000000000000000000000000000000000000000000000000000000000"; - -const USER_ETHEREUM_ADDRESS: &[u8] = b"0x0102030405060708091011121314151617181920"; - const GAS_LIMIT: u64 = 1_000_000; - const BRIDGE_PROXY_PATH_EXPR: &str = "file:output/bridge-proxy.wasm"; -// const MULTI_TRANSFER_PATH_EXPR: &str = "file:../multi-transfer-esdt/output/multi-transfer-esdt.wasm"; -// const ADDER_PATH_EXPR: &str = "file:test-contracts/adder.wasm"; fn world() -> ScenarioWorld { let mut blockchain = ScenarioWorld::new(); @@ -44,7 +36,7 @@ fn world() -> ScenarioWorld { } #[test] -fn basic_setup_test() { +fn deploy_deposit_test() { let mut test = BridgeProxyTestState::setup(); let bridge_token_id_expr = "str:BRIDGE-123456"; // when specifying the token transfer @@ -77,23 +69,8 @@ fn basic_setup_test() { ScQueryStep::new() .to(&test.bridge_proxy) .call(test.bridge_proxy.get_eth_transaction_by_id(1u32)) - .expect_value(eth_tx.data)); - // |tr| { - // let respose: LinkedList> = tr.result.unwrap(); - // let reponse_eth_tx = respose.pop_front(); - - // let eth_tx_payment = EthTransactionPayment { - // token_id: TokenIdentifier::from_esdt_bytes(BRIDGE_TOKEN_ID), - // nonce: 0u64, - // amount: BigUint::from(500u64), - // eth_tx, - // }; - // match reponse_eth_tx { - // Some(tx) => assert!(tx.eq(ð_tx_payment), "Transactions not equal!"), - // None => panic!("No transaction registered!"), - // } - // }, - // ); + .expect_value(eth_tx), + ); } type BridgeProxyContract = ContractInfo>; From 4c8596aaa58dc4a1813eaac94b5b7e47c2b6b367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Mon, 14 Aug 2023 20:12:19 +0300 Subject: [PATCH 16/50] Add MultiTransferEsdt rust test --- bridge-proxy/wasm/src/lib.rs | 5 +- multi-transfer-esdt/Cargo.toml | 3 + .../tests/multi_transfer_blackbox_test.rs | 172 ++++++++++++++++++ multi-transfer-esdt/wasm/Cargo.lock | 1 + multisig/tests/scenario_go_test.rs | 4 - multisig/wasm/Cargo.lock | 1 + 6 files changed, 180 insertions(+), 6 deletions(-) create mode 100644 multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs diff --git a/bridge-proxy/wasm/src/lib.rs b/bridge-proxy/wasm/src/lib.rs index 757dc9cd..4cde9d5d 100644 --- a/bridge-proxy/wasm/src/lib.rs +++ b/bridge-proxy/wasm/src/lib.rs @@ -5,9 +5,9 @@ //////////////////////////////////////////////////// // Init: 1 -// Endpoints: 7 +// Endpoints: 8 // Async Callback: 1 -// Total number of exported functions: 9 +// Total number of exported functions: 10 #![no_std] #![feature(lang_items)] @@ -23,6 +23,7 @@ multiversx_sc_wasm_adapter::endpoints! { executeWithAsnyc => execute_with_async refundTransactions => refund_transactions setupMultiTransfer => set_multi_transfer_contract_address + getEthTransactionById => get_eth_transaction_by_id getMultiTransferAddress => multi_transfer_address getEthTransactionList => eth_transaction_list getEthFailedTransactionList => eth_failed_transaction_list diff --git a/multi-transfer-esdt/Cargo.toml b/multi-transfer-esdt/Cargo.toml index 680fdc75..d8daabe6 100644 --- a/multi-transfer-esdt/Cargo.toml +++ b/multi-transfer-esdt/Cargo.toml @@ -13,6 +13,9 @@ path = "../common/transaction" [dependencies.tx-batch-module] path = "../common/tx-batch-module" +[dependencies.eth-address] +path = "../common/eth-address" + [dependencies.max-bridged-amount-module] path = "../common/max-bridged-amount-module" diff --git a/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs b/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs new file mode 100644 index 00000000..edbbf58d --- /dev/null +++ b/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs @@ -0,0 +1,172 @@ +#![allow(unused)] + +use bridge_proxy::ProxyTrait as _; +use multi_transfer_esdt::ProxyTrait as _; + +use multiversx_sc::{ + api::ManagedTypeApi, + codec::multi_types::{MultiValueVec, OptionalValue}, + storage::mappers::SingleValue, + types::{ + Address, BigUint, CodeMetadata, ManagedAddress, ManagedBuffer, ManagedByteArray, + MultiValueEncoded, TokenIdentifier, + }, +}; +use multiversx_sc_scenario::{ + api::StaticApi, + scenario_format::interpret_trait::{InterpretableFrom, InterpreterContext}, + scenario_model::*, + ContractInfo, ScenarioWorld, +}; + +use eth_address::*; +use transaction::{EthTransaction, EthTransactionPayment}; + +const BRIDGE_TOKEN_ID: &[u8] = b"BRIDGE-123456"; +const USER_ETHEREUM_ADDRESS: &[u8] = b"0x0102030405060708091011121314151617181920"; + +const GAS_LIMIT: u64 = 1_000_000; + +const MULTI_TRANSFER_PATH_EXPR: &str = "file:output/multi-transfer-esdt.wasm"; +const BRIDGE_PROXY_PATH_EXPR: &str = "file:../bridge-proxy/output/bridge-proxy.wasm"; + +fn world() -> ScenarioWorld { + let mut blockchain = ScenarioWorld::new(); + + blockchain.register_contract( + MULTI_TRANSFER_PATH_EXPR, + multi_transfer_esdt::ContractBuilder, + ); + blockchain +} + +#[test] +fn basic_setup_test() { + let mut test = MultiTransferTestState::setup(); + let bridge_token_id_expr = "str:BRIDGE-123456"; // when specifying the token transfer + + test.multi_transfer_deploy(); + test.bridge_proxy_deploy(); + + test.world.set_state_step(SetStateStep::new().put_account( + &test.owner, + Account::new().esdt_balance(bridge_token_id_expr, 1_000u64), + )); + + let eth_tx = EthTransaction { + from: test.eth_user, + to: ManagedAddress::from_address(&test.user1.value), + token_id: TokenIdentifier::from_esdt_bytes(BRIDGE_TOKEN_ID), + amount: BigUint::from(500u64), + tx_nonce: 1u64, + data: ManagedBuffer::from("data"), + gas_limit: GAS_LIMIT, + }; + + test.world + .check_state_step(CheckStateStep::new().put_account( + &test.multi_transfer, + CheckAccount::new().check_storage("bridgeProxyContractAddress", "sc:bridge-proxy"), + )); + + let mut transfers = MultiValueEncoded::new(); + transfers.push(eth_tx); + + test.world.sc_call( + ScCallStep::new() + .from(&test.owner) + .to(&test.multi_transfer) + .call(test.multi_transfer.batch_transfer_esdt_token(1u32, transfers)) + // .esdt_transfer(bridge_token_id_expr, 0u64, 500u64), + ); + + // test.world.sc_query( + // ScQueryStep::new() + // .to(&test.multi_transfer) + // .call(test.multi_transfer.get_eth_transaction_by_id(1u32)) + // .expect_value(eth_tx), + // ); +} + +type MultiTransferContract = ContractInfo>; +type BridgeProxyContract = ContractInfo>; + +struct MultiTransferTestState { + world: ScenarioWorld, + owner: AddressValue, + user1: AddressValue, + user2: AddressValue, + eth_user: EthAddress, + multi_transfer: MultiTransferContract, + bridge_proxy: BridgeProxyContract, +} + +impl MultiTransferTestState { + fn setup() -> Self { + let world = world(); + let ic = &world.interpreter_context(); + + let mut state: MultiTransferTestState = MultiTransferTestState { + world, + owner: "address:owner".into(), + user1: "address:user1".into(), + user2: "address:user2".into(), + eth_user: EthAddress { + raw_addr: ManagedByteArray::default(), + }, + multi_transfer: MultiTransferContract::new("sc:multi_transfer"), + bridge_proxy: BridgeProxyContract::new("sc:bridge_proxy"), + }; + + state + .world + .set_state_step(SetStateStep::new().put_account(&state.owner, Account::new().nonce(1))); + + state + } + + fn multi_transfer_deploy(&mut self) -> &mut Self { + self.world.set_state_step( + SetStateStep::new() + .put_account(&self.owner, Account::new().nonce(1)) + .new_address(&self.owner, 1, &self.multi_transfer), + ); + + let ic = &self.world.interpreter_context(); + let bridge_proxy_addr = self + .bridge_proxy + .address + .clone() + .unwrap_or_sc_panic("Cannot get Bridge Proxy Contract address!"); + + self.world.sc_deploy( + ScDeployStep::new() + .from(self.owner.clone()) + .code(self.world.code_expression(MULTI_TRANSFER_PATH_EXPR)) + .call( + self.multi_transfer + .init(bridge_proxy_addr, ManagedAddress::zero()), + ), + ); + + self + } + + fn bridge_proxy_deploy(&mut self) -> &mut Self { + self.world.set_state_step( + SetStateStep::new() + .put_account(&self.owner, Account::new().nonce(1)) + .new_address(&self.owner, 1, &self.bridge_proxy), + ); + + let ic = &self.world.interpreter_context(); + self.world.sc_deploy( + ScDeployStep::new() + .from(self.owner.clone()) + .code(self.world.code_expression(BRIDGE_PROXY_PATH_EXPR)) + .call(self.bridge_proxy.init(ManagedAddress::zero())), + ); + + self + } +} diff --git a/multi-transfer-esdt/wasm/Cargo.lock b/multi-transfer-esdt/wasm/Cargo.lock index e4dc86a0..11823bb6 100644 --- a/multi-transfer-esdt/wasm/Cargo.lock +++ b/multi-transfer-esdt/wasm/Cargo.lock @@ -102,6 +102,7 @@ version = "0.0.0" dependencies = [ "bridge-proxy", "bridged-tokens-wrapper", + "eth-address", "max-bridged-amount-module", "multiversx-sc", "transaction", diff --git a/multisig/tests/scenario_go_test.rs b/multisig/tests/scenario_go_test.rs index f8cd6f03..0fc3e199 100644 --- a/multisig/tests/scenario_go_test.rs +++ b/multisig/tests/scenario_go_test.rs @@ -3,10 +3,6 @@ use multiversx_sc_scenario::*; fn world() -> ScenarioWorld { ScenarioWorld::vm_go() } - -*/ - - #[test] fn change_token_config_go() { world().run("scenarios/change_token_config.scen.json"); diff --git a/multisig/wasm/Cargo.lock b/multisig/wasm/Cargo.lock index 80816d3f..09074be0 100644 --- a/multisig/wasm/Cargo.lock +++ b/multisig/wasm/Cargo.lock @@ -123,6 +123,7 @@ version = "0.0.0" dependencies = [ "bridge-proxy", "bridged-tokens-wrapper", + "eth-address", "max-bridged-amount-module", "multiversx-sc", "transaction", From 2bc968bfd700ba48f13105f5d2e9453ea1080c2f Mon Sep 17 00:00:00 2001 From: Rebegea Dragos-Alexandru Date: Mon, 16 Oct 2023 11:37:27 +0300 Subject: [PATCH 17/50] fix MultiTransferEsdt init arguments --- multi-transfer-esdt/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/multi-transfer-esdt/src/lib.rs b/multi-transfer-esdt/src/lib.rs index 38a653fd..cf0a19bb 100644 --- a/multi-transfer-esdt/src/lib.rs +++ b/multi-transfer-esdt/src/lib.rs @@ -17,15 +17,15 @@ pub trait MultiTransferEsdt: #[init] fn init( &self, + wrapping_contract_address: ManagedAddress, opt_bridge_proxy_contract_address: OptionalValue, - opt_wrapping_contract_address: OptionalValue, ) { self.max_tx_batch_size() .set_if_empty(DEFAULT_MAX_TX_BATCH_SIZE); self.max_tx_batch_block_duration() .set_if_empty(DEFAULT_MAX_TX_BATCH_BLOCK_DURATION); - self.set_wrapping_contract_address(opt_wrapping_contract_address); + self.set_wrapping_contract_address(Some(wrapping_contract_address).into()); self.set_bridge_proxy_contract_address(opt_bridge_proxy_contract_address); // batch ID 0 is considered invalid From 55142c7d2b4d0e47eb44698c6758ee84d3fba15e Mon Sep 17 00:00:00 2001 From: Rebegea Dragos-Alexandru Date: Mon, 16 Oct 2023 11:56:27 +0300 Subject: [PATCH 18/50] remove MultiTransferEsdt init arguments --- multi-transfer-esdt/src/lib.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/multi-transfer-esdt/src/lib.rs b/multi-transfer-esdt/src/lib.rs index cf0a19bb..b6a54e29 100644 --- a/multi-transfer-esdt/src/lib.rs +++ b/multi-transfer-esdt/src/lib.rs @@ -15,19 +15,11 @@ pub trait MultiTransferEsdt: tx_batch_module::TxBatchModule + max_bridged_amount_module::MaxBridgedAmountModule { #[init] - fn init( - &self, - wrapping_contract_address: ManagedAddress, - opt_bridge_proxy_contract_address: OptionalValue, - ) { + fn init(&self) { self.max_tx_batch_size() .set_if_empty(DEFAULT_MAX_TX_BATCH_SIZE); self.max_tx_batch_block_duration() .set_if_empty(DEFAULT_MAX_TX_BATCH_BLOCK_DURATION); - - self.set_wrapping_contract_address(Some(wrapping_contract_address).into()); - self.set_bridge_proxy_contract_address(opt_bridge_proxy_contract_address); - // batch ID 0 is considered invalid self.first_batch_id().set_if_empty(1); self.last_batch_id().set_if_empty(1); From 743facdc0aea06affc110e6131543856ea300424 Mon Sep 17 00:00:00 2001 From: Rebegea Dragos-Alexandru Date: Wed, 25 Oct 2023 18:09:03 +0300 Subject: [PATCH 19/50] add mintBurn or locking functionality --- common/token-module/src/lib.rs | 49 ++++++++++++++++++++++++++++++++++ esdt-safe/src/lib.rs | 10 +++---- multi-transfer-esdt/Cargo.toml | 3 +++ multi-transfer-esdt/src/lib.rs | 34 +++++++++++++++++++++-- multisig/src/setup.rs | 21 ++++++++++++++- 5 files changed, 108 insertions(+), 9 deletions(-) diff --git a/common/token-module/src/lib.rs b/common/token-module/src/lib.rs index b1b5e3f3..ccec954d 100644 --- a/common/token-module/src/lib.rs +++ b/common/token-module/src/lib.rs @@ -67,6 +67,7 @@ pub trait TokenModule: fee_estimator_module::FeeEstimatorModule { &self, token_id: TokenIdentifier, ticker: ManagedBuffer, + mint_burn_allowed: bool, opt_default_price_per_gas_unit: OptionalValue, ) { self.token_ticker(&token_id).set(&ticker); @@ -76,6 +77,7 @@ pub trait TokenModule: fee_estimator_module::FeeEstimatorModule { .set(&default_price_per_gas_unit); } + self.whitelisted_token_mint_burn(&token_id).set(mint_burn_allowed); let _ = self.token_whitelist().insert(token_id); } @@ -88,8 +90,32 @@ pub trait TokenModule: fee_estimator_module::FeeEstimatorModule { let _ = self.token_whitelist().swap_remove(&token_id); } + #[endpoint(getToken)] + fn get_token(&self, token_id: &TokenIdentifier, amount: &BigUint) { + let caller = self.blockchain().get_caller(); + require!(caller == self.multi_transfer_contract_address().get(), "Only MultiTransfer can get tokens"); + if self.whitelisted_token_mint_burn(token_id).get() == true { + self.mint_esdt_token(token_id, amount); + } + + self.send().direct_esdt( + &self.blockchain().get_caller(), + token_id, + 0, + amount, + ); + } + // private + fn burn_esdt_token(&self, token_id: &TokenIdentifier, amount: &BigUint) { + self.send().esdt_local_burn(token_id, 0, amount); + } + + fn mint_esdt_token(&self, token_id: &TokenIdentifier, amount: &BigUint) { + self.send().esdt_local_mint(token_id, 0, amount); + } + fn require_token_in_whitelist(&self, token_id: &TokenIdentifier) { require!( self.token_whitelist().contains(token_id), @@ -110,12 +136,35 @@ pub trait TokenModule: fee_estimator_module::FeeEstimatorModule { roles.has_role(role) } + #[only_owner] + #[endpoint(setMultiTransferContractAddress)] + fn set_multi_transfer_contract_address(&self, opt_new_address: OptionalValue) { + match opt_new_address { + OptionalValue::Some(sc_addr) => { + require!( + self.blockchain().is_smart_contract(&sc_addr), + "Invalid multi transfer contract address" + ); + + self.multi_transfer_contract_address().set(&sc_addr); + } + OptionalValue::None => self.multi_transfer_contract_address().clear(), + } + } + // storage #[view(getAllKnownTokens)] #[storage_mapper("tokenWhitelist")] fn token_whitelist(&self) -> UnorderedSetMapper; + #[storage_mapper("whitelistedTokenMintBurn")] + fn whitelisted_token_mint_burn(&self, token: &TokenIdentifier) -> SingleValueMapper; + + #[view(getMultiTransferContractAddress)] + #[storage_mapper("multiTransferContractAddress")] + fn multi_transfer_contract_address(&self) -> SingleValueMapper; + #[view(getAccumulatedTransactionFees)] #[storage_mapper("accumulatedTransactionFees")] fn accumulated_transaction_fees( diff --git a/esdt-safe/src/lib.rs b/esdt-safe/src/lib.rs index 30269c30..30770924 100644 --- a/esdt-safe/src/lib.rs +++ b/esdt-safe/src/lib.rs @@ -84,8 +84,10 @@ pub trait EsdtSafe: // local burn role might be removed while tx is executed // tokens will remain locked forever in that case // otherwise, the whole batch would fail - if self.is_local_role_set(&tx.token_identifier, &EsdtLocalRole::Burn) { - self.burn_esdt_token(&tx.token_identifier, &tx.amount); + if self.whitelisted_token_mint_burn(&tx.token_identifier).get() == true { + if self.is_local_role_set(&tx.token_identifier, &EsdtLocalRole::Burn) { + self.burn_esdt_token(&tx.token_identifier, &tx.amount); + } } } TransactionStatus::Rejected => { @@ -243,10 +245,6 @@ pub trait EsdtSafe: // private - fn burn_esdt_token(&self, token_id: &TokenIdentifier, amount: &BigUint) { - self.send().esdt_local_burn(token_id, 0, amount); - } - fn mark_refund(&self, to: &ManagedAddress, token_id: &TokenIdentifier, amount: &BigUint) { self.refund_amount(to, token_id) .update(|refund| *refund += amount); diff --git a/multi-transfer-esdt/Cargo.toml b/multi-transfer-esdt/Cargo.toml index 680fdc75..3dcc5fd5 100644 --- a/multi-transfer-esdt/Cargo.toml +++ b/multi-transfer-esdt/Cargo.toml @@ -22,6 +22,9 @@ path = "../bridged-tokens-wrapper" [dependencies.bridge-proxy] path = "../bridge-proxy" +[dependencies.esdt-safe] +path = "../esdt-safe" + [dependencies.multiversx-sc] version = "0.42.0" [dev-dependencies.multiversx-sc-scenario] diff --git a/multi-transfer-esdt/src/lib.rs b/multi-transfer-esdt/src/lib.rs index b6a54e29..c40e3ae2 100644 --- a/multi-transfer-esdt/src/lib.rs +++ b/multi-transfer-esdt/src/lib.rs @@ -66,8 +66,11 @@ pub trait MultiTransferEsdt: continue; } - self.send() - .esdt_local_mint(ð_tx.token_id, 0, ð_tx.amount); + let _: IgnoreValue = self + .get_esdt_safe_contract_proxy_instance() + .get_token(ð_tx.token_id, ð_tx.amount) + .with_esdt_transfer((eth_tx.token_id.clone(), 0, eth_tx.amount.clone())) + .execute_on_dest_context(); // emit event before the actual transfer so we don't have to save the tx_nonces as well self.transfer_performed_event(batch_id, eth_tx.tx_nonce); @@ -136,6 +139,22 @@ pub trait MultiTransferEsdt: } } + #[only_owner] + #[endpoint(setEsdtSafeContractAddress)] + fn set_esdt_safe_contract_address(&self, opt_new_address: OptionalValue) { + match opt_new_address { + OptionalValue::Some(sc_addr) => { + require!( + self.blockchain().is_smart_contract(&sc_addr), + "Invalid esdt safe contract address" + ); + + self.esdt_safe_contract_address().set(&sc_addr); + } + OptionalValue::None => self.esdt_safe_contract_address().clear(), + } + } + #[endpoint(getFailedTxFromBridgeProxy)] fn get_failed_tx_from_bridge_proxy(&self) { let mut refund_tx_list = ManagedVec::new(); @@ -231,6 +250,13 @@ pub trait MultiTransferEsdt: self.bridge_proxy(self.bridge_proxy_contract_address().get()) } + #[proxy] + fn esdt_safe(&self, sc_address: ManagedAddress) -> esdt_safe::Proxy; + + fn get_esdt_safe_contract_proxy_instance(&self) -> esdt_safe::Proxy { + self.esdt_safe(self.esdt_safe_contract_address().get()) + } + // storage #[view(getWrappingContractAddress)] #[storage_mapper("wrappingContractAddress")] @@ -240,6 +266,10 @@ pub trait MultiTransferEsdt: #[storage_mapper("bridgeProxyContractAddress")] fn bridge_proxy_contract_address(&self) -> SingleValueMapper; + #[view(getEsdtSafeContractAddress)] + #[storage_mapper("esdtSafeContractAddress")] + fn esdt_safe_contract_address(&self) -> SingleValueMapper; + // events #[event("transferPerformedEvent")] diff --git a/multisig/src/setup.rs b/multisig/src/setup.rs index 624b1c98..6b601025 100644 --- a/multisig/src/setup.rs +++ b/multisig/src/setup.rs @@ -205,11 +205,30 @@ pub trait SetupModule: &self, token_id: TokenIdentifier, ticker: ManagedBuffer, + mintBurnAllowed: bool, opt_default_price_per_gas_unit: OptionalValue, ) { let _: IgnoreValue = self .get_esdt_safe_proxy_instance() - .add_token_to_whitelist(token_id, ticker, opt_default_price_per_gas_unit) + .add_token_to_whitelist(token_id, ticker, mintBurnAllowed, opt_default_price_per_gas_unit) + .execute_on_dest_context(); + } + + #[only_owner] + #[endpoint(setMultiTransferOnEsdtSafe)] + fn set_multi_transfer_on_esdt_safe(&self) { + let _: IgnoreValue = self + .get_esdt_safe_proxy_instance() + .set_multi_transfer_contract_address(Some(self.multi_transfer_esdt_address().get())) + .execute_on_dest_context(); + } + + #[only_owner] + #[endpoint(setEsdtSafeOnMultiTransfer)] + fn set_multi_transfer_on_esdt_safe(&self) { + let _: IgnoreValue = self + .get_multi_transfer_esdt_proxy_instance() + .set_esdt_safe_contract_address(Some(self.esdt_safe_address().get())) .execute_on_dest_context(); } From fc41c0dd204ccd5ee6507abf3f8e5f2bbd23d9e1 Mon Sep 17 00:00:00 2001 From: Rebegea Dragos-Alexandru Date: Thu, 26 Oct 2023 15:25:11 +0300 Subject: [PATCH 20/50] fix proxytrait and always wrap tokens --- multi-transfer-esdt/Cargo.toml | 3 +++ multi-transfer-esdt/src/lib.rs | 34 +++++++++++++++-------------- multi-transfer-esdt/wasm/Cargo.lock | 31 ++++++++++++++++++++++++++ multi-transfer-esdt/wasm/src/lib.rs | 6 +++-- 4 files changed, 56 insertions(+), 18 deletions(-) diff --git a/multi-transfer-esdt/Cargo.toml b/multi-transfer-esdt/Cargo.toml index 3dcc5fd5..5d0a66d7 100644 --- a/multi-transfer-esdt/Cargo.toml +++ b/multi-transfer-esdt/Cargo.toml @@ -25,6 +25,9 @@ path = "../bridge-proxy" [dependencies.esdt-safe] path = "../esdt-safe" +[dependencies.token-module] +path = "../common/token-module" + [dependencies.multiversx-sc] version = "0.42.0" [dev-dependencies.multiversx-sc-scenario] diff --git a/multi-transfer-esdt/src/lib.rs b/multi-transfer-esdt/src/lib.rs index c40e3ae2..d95846b8 100644 --- a/multi-transfer-esdt/src/lib.rs +++ b/multi-transfer-esdt/src/lib.rs @@ -5,6 +5,7 @@ multiversx_sc::imports!(); use transaction::{ EthTransaction, EthTransactionPayment, PaymentsVec, Transaction, TxBatchSplitInFields, }; +use token_module::ProxyTrait as OtherProxyTrait; const DEFAULT_MAX_TX_BATCH_SIZE: usize = 10; const DEFAULT_MAX_TX_BATCH_BLOCK_DURATION: u64 = u64::MAX; @@ -33,7 +34,7 @@ pub trait MultiTransferEsdt: transfers: MultiValueEncoded>, ) { let mut valid_payments_list = ManagedVec::new(); - let mut valid_dest_addresses_list = ManagedVec::new(); + let mut valid_tx_list = ManagedVec::new(); let mut refund_tx_list = ManagedVec::new(); let own_sc_address = self.blockchain().get_sc_address(); @@ -75,20 +76,12 @@ pub trait MultiTransferEsdt: // emit event before the actual transfer so we don't have to save the tx_nonces as well self.transfer_performed_event(batch_id, eth_tx.tx_nonce); - if self.blockchain().is_smart_contract(ð_tx.to.clone()) { - let _: IgnoreValue = self - .get_bridge_proxy_contract_proxy_instance() - .deposit(ð_tx) - .with_esdt_transfer((eth_tx.token_id.clone(), 0, eth_tx.amount.clone())) - .execute_on_dest_context(); - } else { - valid_dest_addresses_list.push(eth_tx.to); - valid_payments_list.push(EsdtTokenPayment::new(eth_tx.token_id, 0, eth_tx.amount)); - } + valid_tx_list.push(eth_tx.clone()); + valid_payments_list.push(EsdtTokenPayment::new(eth_tx.token_id, 0, eth_tx.amount)); } let payments_after_wrapping = self.wrap_tokens(valid_payments_list); - self.distribute_payments(valid_dest_addresses_list, payments_after_wrapping); + self.distribute_payments(valid_tx_list, payments_after_wrapping); self.add_multiple_tx_to_batch(&refund_tx_list); } @@ -222,12 +215,21 @@ pub trait MultiTransferEsdt: fn distribute_payments( &self, - dest_addresses: ManagedVec, + transfers: ManagedVec>, payments: PaymentsVec, ) { - for (dest, p) in dest_addresses.iter().zip(payments.iter()) { - self.send() - .direct_esdt(&dest, &p.token_identifier, 0, &p.amount); + for (eth_tx, p) in transfers.iter().zip(payments.iter()) { + if self.blockchain().is_smart_contract(ð_tx.to.clone()) { + let _: IgnoreValue = self + .get_bridge_proxy_contract_proxy_instance() + .deposit(ð_tx) + .with_esdt_transfer((eth_tx.token_id.clone(), 0, eth_tx.amount.clone())) + .execute_on_dest_context(); + } else { + self.send() + .direct_esdt(ð_tx.to, &p.token_identifier, 0, &p.amount); + } + } } diff --git a/multi-transfer-esdt/wasm/Cargo.lock b/multi-transfer-esdt/wasm/Cargo.lock index 58967f4e..16b3b71c 100644 --- a/multi-transfer-esdt/wasm/Cargo.lock +++ b/multi-transfer-esdt/wasm/Cargo.lock @@ -60,6 +60,20 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" +[[package]] +name = "esdt-safe" +version = "0.0.0" +dependencies = [ + "eth-address", + "fee-estimator-module", + "max-bridged-amount-module", + "multiversx-sc", + "multiversx-sc-modules", + "token-module", + "transaction", + "tx-batch-module", +] + [[package]] name = "eth-address" version = "0.0.0" @@ -67,6 +81,13 @@ dependencies = [ "multiversx-sc", ] +[[package]] +name = "fee-estimator-module" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + [[package]] name = "hashbrown" version = "0.13.2" @@ -101,8 +122,10 @@ version = "0.0.0" dependencies = [ "bridge-proxy", "bridged-tokens-wrapper", + "esdt-safe", "max-bridged-amount-module", "multiversx-sc", + "token-module", "transaction", "tx-batch-module", ] @@ -251,6 +274,14 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "token-module" +version = "0.0.0" +dependencies = [ + "fee-estimator-module", + "multiversx-sc", +] + [[package]] name = "transaction" version = "0.0.0" diff --git a/multi-transfer-esdt/wasm/src/lib.rs b/multi-transfer-esdt/wasm/src/lib.rs index cfe77698..09f1636a 100644 --- a/multi-transfer-esdt/wasm/src/lib.rs +++ b/multi-transfer-esdt/wasm/src/lib.rs @@ -5,9 +5,9 @@ //////////////////////////////////////////////////// // Init: 1 -// Endpoints: 17 +// Endpoints: 19 // Async Callback (empty): 1 -// Total number of exported functions: 19 +// Total number of exported functions: 21 #![no_std] #![feature(lang_items)] @@ -23,9 +23,11 @@ multiversx_sc_wasm_adapter::endpoints! { getAndClearFirstRefundBatch => get_and_clear_first_refund_batch setWrappingContractAddress => set_wrapping_contract_address setBridgeProxyContractAddress => set_bridge_proxy_contract_address + setEsdtSafeContractAddress => set_esdt_safe_contract_address getFailedTxFromBridgeProxy => get_failed_tx_from_bridge_proxy getWrappingContractAddress => wrapping_contract_address getBridgeProxyContractAddress => bridge_proxy_contract_address + getEsdtSafeContractAddress => esdt_safe_contract_address setMaxTxBatchSize => set_max_tx_batch_size setMaxTxBatchBlockDuration => set_max_tx_batch_block_duration getCurrentTxBatch => get_current_tx_batch From dc4f12d5da1bbcb8167047e53a867103397ec87b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Fri, 27 Oct 2023 07:53:53 +0300 Subject: [PATCH 21/50] Fix compiling issues --- esdt-safe/wasm/src/lib.rs | 7 +++++-- multisig/src/setup.rs | 10 +++++----- multisig/wasm/Cargo.lock | 2 ++ multisig/wasm/src/lib.rs | 6 ++++-- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/esdt-safe/wasm/src/lib.rs b/esdt-safe/wasm/src/lib.rs index 061228d4..b81d3b08 100644 --- a/esdt-safe/wasm/src/lib.rs +++ b/esdt-safe/wasm/src/lib.rs @@ -5,9 +5,9 @@ //////////////////////////////////////////////////// // Init: 1 -// Endpoints: 31 +// Endpoints: 34 // Async Callback (empty): 1 -// Total number of exported functions: 33 +// Total number of exported functions: 36 #![no_std] #![feature(lang_items)] @@ -35,7 +35,10 @@ multiversx_sc_wasm_adapter::endpoints! { distributeFees => distribute_fees addTokenToWhitelist => add_token_to_whitelist removeTokenFromWhitelist => remove_token_from_whitelist + getToken => get_token + setMultiTransferContractAddress => set_multi_transfer_contract_address getAllKnownTokens => token_whitelist + getMultiTransferContractAddress => multi_transfer_contract_address getAccumulatedTransactionFees => accumulated_transaction_fees setMaxTxBatchSize => set_max_tx_batch_size setMaxTxBatchBlockDuration => set_max_tx_batch_block_duration diff --git a/multisig/src/setup.rs b/multisig/src/setup.rs index 6b601025..b4119271 100644 --- a/multisig/src/setup.rs +++ b/multisig/src/setup.rs @@ -205,12 +205,12 @@ pub trait SetupModule: &self, token_id: TokenIdentifier, ticker: ManagedBuffer, - mintBurnAllowed: bool, + mint_burn_allowed: bool, opt_default_price_per_gas_unit: OptionalValue, ) { let _: IgnoreValue = self .get_esdt_safe_proxy_instance() - .add_token_to_whitelist(token_id, ticker, mintBurnAllowed, opt_default_price_per_gas_unit) + .add_token_to_whitelist(token_id, ticker, mint_burn_allowed, opt_default_price_per_gas_unit) .execute_on_dest_context(); } @@ -219,16 +219,16 @@ pub trait SetupModule: fn set_multi_transfer_on_esdt_safe(&self) { let _: IgnoreValue = self .get_esdt_safe_proxy_instance() - .set_multi_transfer_contract_address(Some(self.multi_transfer_esdt_address().get())) + .set_multi_transfer_contract_address(self.multi_transfer_esdt_address().get()) .execute_on_dest_context(); } #[only_owner] #[endpoint(setEsdtSafeOnMultiTransfer)] - fn set_multi_transfer_on_esdt_safe(&self) { + fn set_esdt_safe_on_multi_transfer(&self) { let _: IgnoreValue = self .get_multi_transfer_esdt_proxy_instance() - .set_esdt_safe_contract_address(Some(self.esdt_safe_address().get())) + .set_esdt_safe_contract_address(self.esdt_safe_address().get()) .execute_on_dest_context(); } diff --git a/multisig/wasm/Cargo.lock b/multisig/wasm/Cargo.lock index 09074be0..b8d97890 100644 --- a/multisig/wasm/Cargo.lock +++ b/multisig/wasm/Cargo.lock @@ -124,8 +124,10 @@ dependencies = [ "bridge-proxy", "bridged-tokens-wrapper", "eth-address", + "esdt-safe", "max-bridged-amount-module", "multiversx-sc", + "token-module", "transaction", "tx-batch-module", ] diff --git a/multisig/wasm/src/lib.rs b/multisig/wasm/src/lib.rs index 4b535cfd..d72c0159 100644 --- a/multisig/wasm/src/lib.rs +++ b/multisig/wasm/src/lib.rs @@ -5,9 +5,9 @@ //////////////////////////////////////////////////// // Init: 1 -// Endpoints: 61 +// Endpoints: 63 // Async Callback (empty): 1 -// Total number of exported functions: 63 +// Total number of exported functions: 65 #![no_std] #![feature(lang_items)] @@ -41,6 +41,8 @@ multiversx_sc_wasm_adapter::endpoints! { changeDefaultPricePerGasUnit => change_default_price_per_gas_unit changeTokenTicker => change_token_ticker esdtSafeAddTokenToWhitelist => esdt_safe_add_token_to_whitelist + setMultiTransferOnEsdtSafe => set_multi_transfer_on_esdt_safe + setEsdtSafeOnMultiTransfer => set_esdt_safe_on_multi_transfer esdtSafeRemoveTokenFromWhitelist => esdt_safe_remove_token_from_whitelist esdtSafeSetMaxTxBatchSize => esdt_safe_set_max_tx_batch_size esdtSafeSetMaxTxBatchBlockDuration => esdt_safe_set_max_tx_batch_block_duration From f85a3db83ecfba57a72dae028a0b5c216cd0b425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Fri, 27 Oct 2023 07:55:57 +0300 Subject: [PATCH 22/50] Fix clippy --- common/token-module/src/lib.rs | 2 +- esdt-safe/src/lib.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/token-module/src/lib.rs b/common/token-module/src/lib.rs index ccec954d..b81bfa54 100644 --- a/common/token-module/src/lib.rs +++ b/common/token-module/src/lib.rs @@ -94,7 +94,7 @@ pub trait TokenModule: fee_estimator_module::FeeEstimatorModule { fn get_token(&self, token_id: &TokenIdentifier, amount: &BigUint) { let caller = self.blockchain().get_caller(); require!(caller == self.multi_transfer_contract_address().get(), "Only MultiTransfer can get tokens"); - if self.whitelisted_token_mint_burn(token_id).get() == true { + if self.whitelisted_token_mint_burn(token_id).get() { self.mint_esdt_token(token_id, amount); } diff --git a/esdt-safe/src/lib.rs b/esdt-safe/src/lib.rs index 30770924..29f4b236 100644 --- a/esdt-safe/src/lib.rs +++ b/esdt-safe/src/lib.rs @@ -84,10 +84,10 @@ pub trait EsdtSafe: // local burn role might be removed while tx is executed // tokens will remain locked forever in that case // otherwise, the whole batch would fail - if self.whitelisted_token_mint_burn(&tx.token_identifier).get() == true { - if self.is_local_role_set(&tx.token_identifier, &EsdtLocalRole::Burn) { - self.burn_esdt_token(&tx.token_identifier, &tx.amount); - } + if self.whitelisted_token_mint_burn(&tx.token_identifier).get() + && self.is_local_role_set(&tx.token_identifier, &EsdtLocalRole::Burn) + { + self.burn_esdt_token(&tx.token_identifier, &tx.amount); } } TransactionStatus::Rejected => { From c6079b6b54f07bd81f241b2e2992d839e25a617f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Fri, 27 Oct 2023 07:57:50 +0300 Subject: [PATCH 23/50] Fix dependencies --- multisig/wasm/Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multisig/wasm/Cargo.lock b/multisig/wasm/Cargo.lock index b8d97890..c4db0688 100644 --- a/multisig/wasm/Cargo.lock +++ b/multisig/wasm/Cargo.lock @@ -123,8 +123,8 @@ version = "0.0.0" dependencies = [ "bridge-proxy", "bridged-tokens-wrapper", - "eth-address", "esdt-safe", + "eth-address", "max-bridged-amount-module", "multiversx-sc", "token-module", From ea878b33fd8b0c2c2e8806c71b82d6704722d174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Mon, 30 Oct 2023 08:29:59 +0200 Subject: [PATCH 24/50] Add blackbox test for Multi Transfer SC --- multi-transfer-esdt/Cargo.toml | 4 + .../tests/multi_transfer_blackbox_test.rs | 237 +++++++++++++----- 2 files changed, 183 insertions(+), 58 deletions(-) diff --git a/multi-transfer-esdt/Cargo.toml b/multi-transfer-esdt/Cargo.toml index 54833af3..2dd0b0ee 100644 --- a/multi-transfer-esdt/Cargo.toml +++ b/multi-transfer-esdt/Cargo.toml @@ -31,6 +31,10 @@ path = "../esdt-safe" [dependencies.token-module] path = "../common/token-module" + +[dependencies.price-aggregator] +path = "../price-aggregator" + [dependencies.multiversx-sc] version = "0.42.0" [dev-dependencies.multiversx-sc-scenario] diff --git a/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs b/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs index edbbf58d..9e953c71 100644 --- a/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs +++ b/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs @@ -1,6 +1,7 @@ #![allow(unused)] use bridge_proxy::ProxyTrait as _; +use esdt_safe::{EsdtSafe, ProxyTrait}; use multi_transfer_esdt::ProxyTrait as _; use multiversx_sc::{ @@ -29,6 +30,23 @@ const GAS_LIMIT: u64 = 1_000_000; const MULTI_TRANSFER_PATH_EXPR: &str = "file:output/multi-transfer-esdt.wasm"; const BRIDGE_PROXY_PATH_EXPR: &str = "file:../bridge-proxy/output/bridge-proxy.wasm"; +const ESDT_SAFE_PATH_EXPR: &str = "file:../esdt-safe/output/esdt-safe.wasm"; +const BRIDGED_TOKENS_WRAPPER_PATH_EXPR: &str = + "file:../bridged-tokens-wrapper/output/bridged-tokens-wrapper.wasm"; +const PRICE_AGGREGATOR_PATH_EXPR: &str = "file:../price-aggregator/price-aggregator.wasm"; + +const MULTI_TRANSFER_ADDRESS_EXPR: &str = "sc:multi_transfer"; +const BRIDGE_PROXY_ADDRESS_EXPR: &str = "sc_bridge_proxy"; +const ESDT_SAFE_ADDRESS_EXPR: &str = "sc:esdt_safe"; +const BRIDGED_TOKENS_WRAPPER_ADDRESS_EXPR: &str = "sc:bridged_tokens_wrapper"; +const PRICE_AGGREGATOR_ADDRESS_EXPR: &str = "sc:price_aggregator"; + +const ORACLE_ADDRESS_EXPR: &str = "address:oracle"; + +const ESDT_SAFE_ETH_TX_GAS_LIMIT: u64 = 150_000; + +const BALANCE: &str = "2,000,000"; +const WEGLD_TOKEN_ID_EXPR: &str = "str:BRIDGE-123456"; fn world() -> ScenarioWorld { let mut blockchain = ScenarioWorld::new(); @@ -40,56 +58,11 @@ fn world() -> ScenarioWorld { blockchain } -#[test] -fn basic_setup_test() { - let mut test = MultiTransferTestState::setup(); - let bridge_token_id_expr = "str:BRIDGE-123456"; // when specifying the token transfer - - test.multi_transfer_deploy(); - test.bridge_proxy_deploy(); - - test.world.set_state_step(SetStateStep::new().put_account( - &test.owner, - Account::new().esdt_balance(bridge_token_id_expr, 1_000u64), - )); - - let eth_tx = EthTransaction { - from: test.eth_user, - to: ManagedAddress::from_address(&test.user1.value), - token_id: TokenIdentifier::from_esdt_bytes(BRIDGE_TOKEN_ID), - amount: BigUint::from(500u64), - tx_nonce: 1u64, - data: ManagedBuffer::from("data"), - gas_limit: GAS_LIMIT, - }; - - test.world - .check_state_step(CheckStateStep::new().put_account( - &test.multi_transfer, - CheckAccount::new().check_storage("bridgeProxyContractAddress", "sc:bridge-proxy"), - )); - - let mut transfers = MultiValueEncoded::new(); - transfers.push(eth_tx); - - test.world.sc_call( - ScCallStep::new() - .from(&test.owner) - .to(&test.multi_transfer) - .call(test.multi_transfer.batch_transfer_esdt_token(1u32, transfers)) - // .esdt_transfer(bridge_token_id_expr, 0u64, 500u64), - ); - - // test.world.sc_query( - // ScQueryStep::new() - // .to(&test.multi_transfer) - // .call(test.multi_transfer.get_eth_transaction_by_id(1u32)) - // .expect_value(eth_tx), - // ); -} - type MultiTransferContract = ContractInfo>; type BridgeProxyContract = ContractInfo>; +type EsdtSafeContract = ContractInfo>; +type BridgedTokensWrapperContract = ContractInfo>; +type PriceAggregatorContract = ContractInfo>; struct MultiTransferTestState { world: ScenarioWorld, @@ -99,6 +72,9 @@ struct MultiTransferTestState { eth_user: EthAddress, multi_transfer: MultiTransferContract, bridge_proxy: BridgeProxyContract, + esdt_safe: EsdtSafeContract, + bridged_tokens_wrapper: BridgedTokensWrapperContract, + price_aggregator: PriceAggregatorContract, } impl MultiTransferTestState { @@ -116,11 +92,20 @@ impl MultiTransferTestState { }, multi_transfer: MultiTransferContract::new("sc:multi_transfer"), bridge_proxy: BridgeProxyContract::new("sc:bridge_proxy"), + esdt_safe: EsdtSafeContract::new("sc:esdt_safe"), + bridged_tokens_wrapper: BridgedTokensWrapperContract::new("sc:bridged_tokens_wrapper"), + price_aggregator: PriceAggregatorContract::new("sc:price_aggregator"), }; - state - .world - .set_state_step(SetStateStep::new().put_account(&state.owner, Account::new().nonce(1))); + state.world.set_state_step( + SetStateStep::new().put_account( + &state.owner, + Account::new() + .nonce(1) + .balance(BALANCE) + .esdt_balance(WEGLD_TOKEN_ID_EXPR, BALANCE), + ), + ); state } @@ -129,7 +114,7 @@ impl MultiTransferTestState { self.world.set_state_step( SetStateStep::new() .put_account(&self.owner, Account::new().nonce(1)) - .new_address(&self.owner, 1, &self.multi_transfer), + .new_address(&self.owner, 1, MULTI_TRANSFER_ADDRESS_EXPR), ); let ic = &self.world.interpreter_context(); @@ -143,10 +128,7 @@ impl MultiTransferTestState { ScDeployStep::new() .from(self.owner.clone()) .code(self.world.code_expression(MULTI_TRANSFER_PATH_EXPR)) - .call( - self.multi_transfer - .init(bridge_proxy_addr, ManagedAddress::zero()), - ), + .call(self.multi_transfer.init()), ); self @@ -156,7 +138,7 @@ impl MultiTransferTestState { self.world.set_state_step( SetStateStep::new() .put_account(&self.owner, Account::new().nonce(1)) - .new_address(&self.owner, 1, &self.bridge_proxy), + .new_address(&self.owner, 2, BRIDGE_PROXY_ADDRESS_EXPR), ); let ic = &self.world.interpreter_context(); @@ -164,9 +146,148 @@ impl MultiTransferTestState { ScDeployStep::new() .from(self.owner.clone()) .code(self.world.code_expression(BRIDGE_PROXY_PATH_EXPR)) - .call(self.bridge_proxy.init(ManagedAddress::zero())), + .call(self.bridge_proxy.init(self.multi_transfer.address)), ); self } + + fn price_aggregator_deploy(&mut self) -> &mut Self { + self.world.set_state_step( + SetStateStep::new() + .put_account(&self.owner, Account::new().nonce(1)) + .new_address(&self.owner, 3, PRICE_AGGREGATOR_ADDRESS_EXPR), + ); + + let ic = &self.world.interpreter_context(); + self.world.sc_deploy( + ScDeployStep::new() + .from(self.owner.clone()) + .code(self.world.code_expression(PRICE_AGGREGATOR_PATH_EXPR)) + .call(self.price_aggregator.init(1, 0, ORACLE_ADDRESS_EXPR)), + ); + + self + } + + fn safe_deploy(&mut self, price_aggregator_contract_address: Address) -> &mut Self { + self.world.set_state_step( + SetStateStep::new() + .put_account(&self.owner, Account::new().nonce(1)) + .new_address(&self.owner, 4, ESDT_SAFE_ADDRESS_EXPR), + ); + + let ic = &self.world.interpreter_context(); + self.world.sc_deploy( + ScDeployStep::new() + .from(self.owner.clone()) + .code(self.world.code_expression(ESDT_SAFE_PATH_EXPR)) + .call(self.esdt_safe.init( + price_aggregator_contract_address, + ESDT_SAFE_ETH_TX_GAS_LIMIT, + )), + ); + + self + } + + fn bridged_tokens_wrapper_deploy(&mut self) -> &mut Self { + self.world.set_state_step( + SetStateStep::new() + .put_account(&self.owner, Account::new().nonce(1)) + .new_address(&self.owner, 5, &self.bridged_tokens_wrapper), + ); + + let ic = &self.world.interpreter_context(); + self.world.sc_deploy( + ScDeployStep::new() + .from(self.owner.clone()) + .code(self.world.code_expression(BRIDGED_TOKENS_WRAPPER_PATH_EXPR)) + .call(self.bridged_tokens_wrapper.init()), + ); + + self + } + + fn config_multi_transfer( + &mut self, + bridged_tokens_wrapper_contract_address: Address, + bridge_proxy_contract_address: Address, + ) { + self.world.sc_call( + ScCallStep::new() + .from(self.owner.clone()) + .to(&self.multi_transfer) + .call( + self.multi_transfer + .set_wrapping_contract_address(bridged_tokens_wrapper_contract_address), + ), + ); + + self.world.sc_call( + ScCallStep::new() + .from(self.owner.clone()) + .to(&self.multi_transfer) + .call( + self.multi_transfer + .set_bridge_proxy_contract_address(bridge_proxy_contract_address), + ), + ); + } +} + +#[test] +fn basic_setup_test() { + let mut test = MultiTransferTestState::setup(); + let bridge_token_id_expr = "str:BRIDGE-123456"; // when specifying the token transfer + + test.multi_transfer_deploy(); + test.bridge_proxy_deploy(); + test.price_aggregator_deploy(); + test.safe_deploy(test.price_aggregator.to_address()); + test.config_multi_transfer( + test.bridged_tokens_wrapper.to_address(), + test.bridge_proxy.to_address(), + ); + + test.world.set_state_step(SetStateStep::new().put_account( + &test.owner, + Account::new().esdt_balance(bridge_token_id_expr, 1_000u64), + )); + + let eth_tx = EthTransaction { + from: test.eth_user, + to: ManagedAddress::from_address(&test.user1.value), + token_id: TokenIdentifier::from_esdt_bytes(BRIDGE_TOKEN_ID), + amount: BigUint::from(500u64), + tx_nonce: 1u64, + data: ManagedBuffer::from("data"), + gas_limit: GAS_LIMIT, + }; + + test.world + .check_state_step(CheckStateStep::new().put_account( + &test.multi_transfer, + CheckAccount::new().check_storage("bridgeProxyContractAddress", "sc:bridge-proxy"), + )); + + let mut transfers = MultiValueEncoded::new(); + transfers.push(eth_tx); + + test.world.sc_call( + ScCallStep::new() + .from(&test.owner) + .to(&test.multi_transfer) + .call( + test.multi_transfer + .batch_transfer_esdt_token(1u32, transfers), + ), // .esdt_transfer(bridge_token_id_expr, 0u64, 500u64), + ); + + // test.world.sc_query( + // ScQueryStep::new() + // .to(&test.multi_transfer) + // .call(test.multi_transfer.get_eth_transaction_by_id(1u32)) + // .expect_value(eth_tx), + // ); } From f90ac87e068536c62e66b9f8906efb3b1bab7d62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Mon, 30 Oct 2023 10:23:33 +0200 Subject: [PATCH 25/50] Add check storage for test --- multi-transfer-esdt/Cargo.toml | 3 - .../tests/multi_transfer_blackbox_test.rs | 120 ++++++++++-------- 2 files changed, 70 insertions(+), 53 deletions(-) diff --git a/multi-transfer-esdt/Cargo.toml b/multi-transfer-esdt/Cargo.toml index 2dd0b0ee..3932fe4b 100644 --- a/multi-transfer-esdt/Cargo.toml +++ b/multi-transfer-esdt/Cargo.toml @@ -32,9 +32,6 @@ path = "../esdt-safe" path = "../common/token-module" -[dependencies.price-aggregator] -path = "../price-aggregator" - [dependencies.multiversx-sc] version = "0.42.0" [dev-dependencies.multiversx-sc-scenario] diff --git a/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs b/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs index 9e953c71..5b1ad70f 100644 --- a/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs +++ b/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs @@ -1,11 +1,12 @@ #![allow(unused)] use bridge_proxy::ProxyTrait as _; -use esdt_safe::{EsdtSafe, ProxyTrait}; +use bridged_tokens_wrapper::ProxyTrait as _; +use esdt_safe::{EsdtSafe, ProxyTrait as _}; use multi_transfer_esdt::ProxyTrait as _; use multiversx_sc::{ - api::ManagedTypeApi, + api::{HandleConstraints, ManagedTypeApi}, codec::multi_types::{MultiValueVec, OptionalValue}, storage::mappers::SingleValue, types::{ @@ -14,16 +15,18 @@ use multiversx_sc::{ }, }; use multiversx_sc_scenario::{ - api::StaticApi, + api::{StaticApi, VMHooksApi}, scenario_format::interpret_trait::{InterpretableFrom, InterpreterContext}, scenario_model::*, - ContractInfo, ScenarioWorld, + ContractInfo, DebugApi, ScenarioWorld, }; use eth_address::*; use transaction::{EthTransaction, EthTransactionPayment}; const BRIDGE_TOKEN_ID: &[u8] = b"BRIDGE-123456"; +const BRIDGE_TOKEN_ID_EXPR: &str = "str:BRIDGE-123456"; + const USER_ETHEREUM_ADDRESS: &[u8] = b"0x0102030405060708091011121314151617181920"; const GAS_LIMIT: u64 = 1_000_000; @@ -36,12 +39,13 @@ const BRIDGED_TOKENS_WRAPPER_PATH_EXPR: &str = const PRICE_AGGREGATOR_PATH_EXPR: &str = "file:../price-aggregator/price-aggregator.wasm"; const MULTI_TRANSFER_ADDRESS_EXPR: &str = "sc:multi_transfer"; -const BRIDGE_PROXY_ADDRESS_EXPR: &str = "sc_bridge_proxy"; +const BRIDGE_PROXY_ADDRESS_EXPR: &str = "sc:bridge_proxy"; const ESDT_SAFE_ADDRESS_EXPR: &str = "sc:esdt_safe"; const BRIDGED_TOKENS_WRAPPER_ADDRESS_EXPR: &str = "sc:bridged_tokens_wrapper"; const PRICE_AGGREGATOR_ADDRESS_EXPR: &str = "sc:price_aggregator"; const ORACLE_ADDRESS_EXPR: &str = "address:oracle"; +const OWNER_ADDRESS_EXPR: &str = "address:owner"; const ESDT_SAFE_ETH_TX_GAS_LIMIT: u64 = 150_000; @@ -55,6 +59,15 @@ fn world() -> ScenarioWorld { MULTI_TRANSFER_PATH_EXPR, multi_transfer_esdt::ContractBuilder, ); + blockchain.register_contract(BRIDGE_PROXY_PATH_EXPR, bridge_proxy::ContractBuilder); + + blockchain.register_contract(ESDT_SAFE_PATH_EXPR, esdt_safe::ContractBuilder); + + blockchain.register_contract( + BRIDGED_TOKENS_WRAPPER_PATH_EXPR, + bridged_tokens_wrapper::ContractBuilder, + ); + blockchain } @@ -62,7 +75,7 @@ type MultiTransferContract = ContractInfo> type BridgeProxyContract = ContractInfo>; type EsdtSafeContract = ContractInfo>; type BridgedTokensWrapperContract = ContractInfo>; -type PriceAggregatorContract = ContractInfo>; +// type PriceAggregatorContract = ContractInfo>; struct MultiTransferTestState { world: ScenarioWorld, @@ -74,7 +87,7 @@ struct MultiTransferTestState { bridge_proxy: BridgeProxyContract, esdt_safe: EsdtSafeContract, bridged_tokens_wrapper: BridgedTokensWrapperContract, - price_aggregator: PriceAggregatorContract, + // price_aggregator: PriceAggregatorContract, } impl MultiTransferTestState { @@ -94,7 +107,7 @@ impl MultiTransferTestState { bridge_proxy: BridgeProxyContract::new("sc:bridge_proxy"), esdt_safe: EsdtSafeContract::new("sc:esdt_safe"), bridged_tokens_wrapper: BridgedTokensWrapperContract::new("sc:bridged_tokens_wrapper"), - price_aggregator: PriceAggregatorContract::new("sc:price_aggregator"), + // price_aggregator: PriceAggregatorContract::new("sc:price_aggregator"), }; state.world.set_state_step( @@ -113,7 +126,7 @@ impl MultiTransferTestState { fn multi_transfer_deploy(&mut self) -> &mut Self { self.world.set_state_step( SetStateStep::new() - .put_account(&self.owner, Account::new().nonce(1)) + .put_account(OWNER_ADDRESS_EXPR, Account::new().nonce(1)) .new_address(&self.owner, 1, MULTI_TRANSFER_ADDRESS_EXPR), ); @@ -135,68 +148,68 @@ impl MultiTransferTestState { } fn bridge_proxy_deploy(&mut self) -> &mut Self { - self.world.set_state_step( - SetStateStep::new() - .put_account(&self.owner, Account::new().nonce(1)) - .new_address(&self.owner, 2, BRIDGE_PROXY_ADDRESS_EXPR), - ); + self.world.set_state_step(SetStateStep::new().new_address( + &self.owner, + 2, + BRIDGE_PROXY_ADDRESS_EXPR, + )); let ic = &self.world.interpreter_context(); self.world.sc_deploy( ScDeployStep::new() .from(self.owner.clone()) .code(self.world.code_expression(BRIDGE_PROXY_PATH_EXPR)) - .call(self.bridge_proxy.init(self.multi_transfer.address)), + .call(self.bridge_proxy.init(self.multi_transfer.to_address())), ); self } - fn price_aggregator_deploy(&mut self) -> &mut Self { - self.world.set_state_step( - SetStateStep::new() - .put_account(&self.owner, Account::new().nonce(1)) - .new_address(&self.owner, 3, PRICE_AGGREGATOR_ADDRESS_EXPR), - ); + // fn price_aggregator_deploy(&mut self) -> &mut Self { + // self.world.set_state_step( + // SetStateStep::new() + // .put_account(&self.owner, Account::new().nonce(1)) + // .new_address(&self.owner, 3, PRICE_AGGREGATOR_ADDRESS_EXPR), + // ); - let ic = &self.world.interpreter_context(); - self.world.sc_deploy( - ScDeployStep::new() - .from(self.owner.clone()) - .code(self.world.code_expression(PRICE_AGGREGATOR_PATH_EXPR)) - .call(self.price_aggregator.init(1, 0, ORACLE_ADDRESS_EXPR)), - ); + // let ic = &self.world.interpreter_context(); + // self.world.sc_deploy( + // ScDeployStep::new() + // .from(self.owner.clone()) + // .code(self.world.code_expression(PRICE_AGGREGATOR_PATH_EXPR)) + // .call(self.price_aggregator.init(1, 0, ORACLE_ADDRESS_EXPR)), + // ); - self - } + // self + // } fn safe_deploy(&mut self, price_aggregator_contract_address: Address) -> &mut Self { - self.world.set_state_step( - SetStateStep::new() - .put_account(&self.owner, Account::new().nonce(1)) - .new_address(&self.owner, 4, ESDT_SAFE_ADDRESS_EXPR), - ); + self.world.set_state_step(SetStateStep::new().new_address( + &self.owner, + 3, + ESDT_SAFE_ADDRESS_EXPR, + )); let ic = &self.world.interpreter_context(); self.world.sc_deploy( ScDeployStep::new() .from(self.owner.clone()) .code(self.world.code_expression(ESDT_SAFE_PATH_EXPR)) - .call(self.esdt_safe.init( - price_aggregator_contract_address, - ESDT_SAFE_ETH_TX_GAS_LIMIT, - )), + .call( + self.esdt_safe + .init(ManagedAddress::zero(), ESDT_SAFE_ETH_TX_GAS_LIMIT), + ), ); self } fn bridged_tokens_wrapper_deploy(&mut self) -> &mut Self { - self.world.set_state_step( - SetStateStep::new() - .put_account(&self.owner, Account::new().nonce(1)) - .new_address(&self.owner, 5, &self.bridged_tokens_wrapper), - ); + self.world.set_state_step(SetStateStep::new().new_address( + &self.owner, + 4, + &self.bridged_tokens_wrapper, + )); let ic = &self.world.interpreter_context(); self.world.sc_deploy( @@ -243,8 +256,8 @@ fn basic_setup_test() { test.multi_transfer_deploy(); test.bridge_proxy_deploy(); - test.price_aggregator_deploy(); - test.safe_deploy(test.price_aggregator.to_address()); + // test.price_aggregator_deploy(); + test.safe_deploy(Address::zero()); test.config_multi_transfer( test.bridged_tokens_wrapper.to_address(), test.bridge_proxy.to_address(), @@ -265,11 +278,18 @@ fn basic_setup_test() { gas_limit: GAS_LIMIT, }; - test.world - .check_state_step(CheckStateStep::new().put_account( + test.world.check_state_step( + CheckStateStep::new().put_account( &test.multi_transfer, - CheckAccount::new().check_storage("bridgeProxyContractAddress", "sc:bridge-proxy"), - )); + CheckAccount::new() + .check_storage("str:bridgeProxyContractAddress", "sc:bridge_proxy") + .check_storage("str:lastBatchId", "0x01") + .check_storage("str:wrappingContractAddress", "sc:bridged_tokens_wrapper") + .check_storage("str:maxTxBatchBlockDuration", "0xffffffffffffffff") + .check_storage("str:maxTxBatchSize", "10") + .check_storage("str:firstBatchId", "0x01"), + ), + ); let mut transfers = MultiValueEncoded::new(); transfers.push(eth_tx); From 23260b3f8bbaa33b09102a9dae2948a5dec2f91f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Thu, 9 Nov 2023 14:15:55 +0200 Subject: [PATCH 26/50] Fix compilation issues --- bridge-proxy/Cargo.toml | 4 +- bridge-proxy/meta/Cargo.toml | 2 +- bridge-proxy/wasm/Cargo.lock | 80 ++++++--- bridge-proxy/wasm/Cargo.toml | 2 +- bridge-proxy/wasm/src/lib.rs | 3 + bridged-tokens-wrapper/Cargo.toml | 6 +- bridged-tokens-wrapper/meta/Cargo.toml | 2 +- bridged-tokens-wrapper/wasm/Cargo.lock | 84 +++++++--- bridged-tokens-wrapper/wasm/Cargo.toml | 2 +- bridged-tokens-wrapper/wasm/src/lib.rs | 3 + common/eth-address/Cargo.toml | 2 +- common/fee-estimator-module/Cargo.toml | 4 +- common/max-bridged-amount-module/Cargo.toml | 4 +- common/token-module/Cargo.toml | 4 +- common/transaction/Cargo.toml | 2 +- common/tx-batch-module/Cargo.toml | 4 +- esdt-safe/Cargo.toml | 6 +- esdt-safe/meta/Cargo.toml | 2 +- esdt-safe/wasm/Cargo.toml | 2 +- esdt-safe/wasm/src/lib.rs | 3 + multi-transfer-esdt/Cargo.toml | 6 +- multi-transfer-esdt/meta/Cargo.toml | 2 +- .../tests/multi_transfer_blackbox_test.rs | 154 ++++++++++-------- multi-transfer-esdt/wasm/Cargo.lock | 84 +++++++--- multi-transfer-esdt/wasm/Cargo.toml | 2 +- multi-transfer-esdt/wasm/src/lib.rs | 3 + multisig/Cargo.toml | 6 +- multisig/meta/Cargo.toml | 2 +- multisig/wasm/Cargo.lock | 84 +++++++--- multisig/wasm/Cargo.toml | 2 +- multisig/wasm/src/lib.rs | 3 + 31 files changed, 368 insertions(+), 201 deletions(-) diff --git a/bridge-proxy/Cargo.toml b/bridge-proxy/Cargo.toml index b9b4542d..4e637f19 100644 --- a/bridge-proxy/Cargo.toml +++ b/bridge-proxy/Cargo.toml @@ -14,10 +14,10 @@ path = "../common/transaction" path = "../common/eth-address" [dependencies.multiversx-sc] -version = "0.42.0" +version = "0.43.5" [dev-dependencies] num-bigint = "0.4.2" [dev-dependencies.multiversx-sc-scenario] -version = "0.42.0" +version = "0.43.5" diff --git a/bridge-proxy/meta/Cargo.toml b/bridge-proxy/meta/Cargo.toml index 2d75f6e4..b24ed1ab 100644 --- a/bridge-proxy/meta/Cargo.toml +++ b/bridge-proxy/meta/Cargo.toml @@ -10,4 +10,4 @@ authors = ["you"] path = ".." [dependencies.multiversx-sc-meta] -version = "0.42.0" +version = "0.43.5" diff --git a/bridge-proxy/wasm/Cargo.lock b/bridge-proxy/wasm/Cargo.lock index c43b87e1..0f8e9a10 100644 --- a/bridge-proxy/wasm/Cargo.lock +++ b/bridge-proxy/wasm/Cargo.lock @@ -4,13 +4,14 @@ version = 3 [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" dependencies = [ "cfg-if", "once_cell", "version_check", + "zerocopy", ] [[package]] @@ -90,9 +91,9 @@ checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" [[package]] name = "multiversx-sc" -version = "0.42.0" +version = "0.43.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c22c2d1e82a357b6f397f87d475314628473b8a88882aa407234197f596786aa" +checksum = "adbdd41a744caa562646c6d593df35caed84889e0d35df8b9ad8efc45457b5bd" dependencies = [ "bitflags", "hashbrown", @@ -104,9 +105,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9c97dc9e9f34f836de6a56386ddbe1b9e87e20916ff86b1ea728c08e1871ac2" +checksum = "0f1e15b46c17b87c0c7cdd79b041a4abd7f3a2b45f3c993f6ce38c0f233e82b6" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -114,34 +115,34 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ab795364fcf0452a953e33eae7e0c22d1a6374ffeb0724d24a42727e099c6e" +checksum = "9a7bc0762cd6d88f8bc54805bc652b042a61cd7fbc2d0a325010f088b78fb2ac" dependencies = [ "hex", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "multiversx-sc-derive" -version = "0.42.0" +version = "0.43.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6d77a125ea6985b2fa5cf1a297cdb9202c5a528eebb22652cc68ab1a9305e11" +checksum = "ebdaec412a272d8fd6668bc0b4b8674a5e03148aa72041a4705d502b86f4d9ce" dependencies = [ "hex", "proc-macro2", "quote", "radix_trie", - "syn", + "syn 1.0.109", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.42.0" +version = "0.43.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "951b0137614c8412554ccd086967c565af38b91b77a66b5d9f433801ff24e501" +checksum = "2befd4545b5b47adf1df89313b76a2282873fd9163b70badd727d8dfce83c588" dependencies = [ "multiversx-sc", ] @@ -157,9 +158,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] @@ -172,18 +173,18 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.32" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -200,9 +201,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "syn" @@ -215,6 +216,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "transaction" version = "0.0.0" @@ -225,12 +237,32 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "version_check" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "zerocopy" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd66a62464e3ffd4e37bd09950c2b9dd6c4f8767380fabba0d523f9a775bc85a" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "255c4596d41e6916ced49cfafea18727b24d67878fa180ddfd69b9df34fd1726" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] diff --git a/bridge-proxy/wasm/Cargo.toml b/bridge-proxy/wasm/Cargo.toml index 8d6d744a..ed28ebcd 100644 --- a/bridge-proxy/wasm/Cargo.toml +++ b/bridge-proxy/wasm/Cargo.toml @@ -22,4 +22,4 @@ panic = "abort" path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.42.0" +version = "0.43.5" diff --git a/bridge-proxy/wasm/src/lib.rs b/bridge-proxy/wasm/src/lib.rs index 4cde9d5d..21d44fe5 100644 --- a/bridge-proxy/wasm/src/lib.rs +++ b/bridge-proxy/wasm/src/lib.rs @@ -10,6 +10,9 @@ // Total number of exported functions: 10 #![no_std] + +// Configuration that works with rustc < 1.73.0. +// TODO: Recommended rustc version: 1.73.0 or newer. #![feature(lang_items)] multiversx_sc_wasm_adapter::allocator!(); diff --git a/bridged-tokens-wrapper/Cargo.toml b/bridged-tokens-wrapper/Cargo.toml index f3015025..86f7dbb2 100644 --- a/bridged-tokens-wrapper/Cargo.toml +++ b/bridged-tokens-wrapper/Cargo.toml @@ -11,9 +11,9 @@ path = "src/lib.rs" path = "../common/transaction" [dependencies.multiversx-sc] -version = "0.42.0" +version = "0.43.5" [dependencies.multiversx-sc-modules] -version = "0.42.0" +version = "0.43.5" [dev-dependencies.multiversx-sc-scenario] -version = "0.42.0" +version = "0.43.5" diff --git a/bridged-tokens-wrapper/meta/Cargo.toml b/bridged-tokens-wrapper/meta/Cargo.toml index 887076ac..30a5a635 100644 --- a/bridged-tokens-wrapper/meta/Cargo.toml +++ b/bridged-tokens-wrapper/meta/Cargo.toml @@ -7,4 +7,4 @@ publish = false path = ".." [dependencies.multiversx-sc-meta] -version = "0.42.0" +version = "0.43.5" diff --git a/bridged-tokens-wrapper/wasm/Cargo.lock b/bridged-tokens-wrapper/wasm/Cargo.lock index 75724ebc..281803ef 100644 --- a/bridged-tokens-wrapper/wasm/Cargo.lock +++ b/bridged-tokens-wrapper/wasm/Cargo.lock @@ -4,13 +4,14 @@ version = 3 [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" dependencies = [ "cfg-if", "once_cell", "version_check", + "zerocopy", ] [[package]] @@ -90,9 +91,9 @@ checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" [[package]] name = "multiversx-sc" -version = "0.42.0" +version = "0.43.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c22c2d1e82a357b6f397f87d475314628473b8a88882aa407234197f596786aa" +checksum = "adbdd41a744caa562646c6d593df35caed84889e0d35df8b9ad8efc45457b5bd" dependencies = [ "bitflags", "hashbrown", @@ -104,9 +105,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9c97dc9e9f34f836de6a56386ddbe1b9e87e20916ff86b1ea728c08e1871ac2" +checksum = "0f1e15b46c17b87c0c7cdd79b041a4abd7f3a2b45f3c993f6ce38c0f233e82b6" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -114,43 +115,43 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ab795364fcf0452a953e33eae7e0c22d1a6374ffeb0724d24a42727e099c6e" +checksum = "9a7bc0762cd6d88f8bc54805bc652b042a61cd7fbc2d0a325010f088b78fb2ac" dependencies = [ "hex", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "multiversx-sc-derive" -version = "0.42.0" +version = "0.43.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6d77a125ea6985b2fa5cf1a297cdb9202c5a528eebb22652cc68ab1a9305e11" +checksum = "ebdaec412a272d8fd6668bc0b4b8674a5e03148aa72041a4705d502b86f4d9ce" dependencies = [ "hex", "proc-macro2", "quote", "radix_trie", - "syn", + "syn 1.0.109", ] [[package]] name = "multiversx-sc-modules" -version = "0.42.0" +version = "0.43.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "087a8ea95fac541128600a51c3c4ef7329642d5a1a397b4c6a65eb3ee621a282" +checksum = "45a02a1c14d05986661eff35beab26f5e72cdc44753b1f415eff64d6c4e4bc98" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.42.0" +version = "0.43.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "951b0137614c8412554ccd086967c565af38b91b77a66b5d9f433801ff24e501" +checksum = "2befd4545b5b47adf1df89313b76a2282873fd9163b70badd727d8dfce83c588" dependencies = [ "multiversx-sc", ] @@ -166,9 +167,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] @@ -181,18 +182,18 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.32" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -209,9 +210,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "syn" @@ -224,6 +225,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "transaction" version = "0.0.0" @@ -234,12 +246,32 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "version_check" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "zerocopy" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd66a62464e3ffd4e37bd09950c2b9dd6c4f8767380fabba0d523f9a775bc85a" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "255c4596d41e6916ced49cfafea18727b24d67878fa180ddfd69b9df34fd1726" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] diff --git a/bridged-tokens-wrapper/wasm/Cargo.toml b/bridged-tokens-wrapper/wasm/Cargo.toml index 3a2a2f7a..98ff330b 100644 --- a/bridged-tokens-wrapper/wasm/Cargo.toml +++ b/bridged-tokens-wrapper/wasm/Cargo.toml @@ -17,7 +17,7 @@ panic = "abort" path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.42.0" +version = "0.43.5" [workspace] members = ["."] diff --git a/bridged-tokens-wrapper/wasm/src/lib.rs b/bridged-tokens-wrapper/wasm/src/lib.rs index a03ebc18..a9cc42de 100644 --- a/bridged-tokens-wrapper/wasm/src/lib.rs +++ b/bridged-tokens-wrapper/wasm/src/lib.rs @@ -10,6 +10,9 @@ // Total number of exported functions: 18 #![no_std] + +// Configuration that works with rustc < 1.73.0. +// TODO: Recommended rustc version: 1.73.0 or newer. #![feature(lang_items)] multiversx_sc_wasm_adapter::allocator!(); diff --git a/common/eth-address/Cargo.toml b/common/eth-address/Cargo.toml index 773d2522..11a4a52f 100644 --- a/common/eth-address/Cargo.toml +++ b/common/eth-address/Cargo.toml @@ -7,4 +7,4 @@ edition = "2018" [lib] path = "src/lib.rs" [dependencies.multiversx-sc] -version = "0.42.0" +version = "0.43.5" diff --git a/common/fee-estimator-module/Cargo.toml b/common/fee-estimator-module/Cargo.toml index 4c745cc6..f00ad30c 100644 --- a/common/fee-estimator-module/Cargo.toml +++ b/common/fee-estimator-module/Cargo.toml @@ -4,6 +4,6 @@ version = "0.0.0" authors = ["dorin-iancu "] edition = "2018" [dependencies.multiversx-sc] -version = "0.42.0" +version = "0.43.5" [dev-dependencies.multiversx-sc-scenario] -version = "0.42.0" +version = "0.43.5" diff --git a/common/max-bridged-amount-module/Cargo.toml b/common/max-bridged-amount-module/Cargo.toml index 64cf2a04..63f52559 100644 --- a/common/max-bridged-amount-module/Cargo.toml +++ b/common/max-bridged-amount-module/Cargo.toml @@ -4,6 +4,6 @@ version = "0.0.0" authors = ["dorin-iancu "] edition = "2018" [dependencies.multiversx-sc] -version = "0.42.0" +version = "0.43.5" [dev-dependencies.multiversx-sc-scenario] -version = "0.42.0" +version = "0.43.5" diff --git a/common/token-module/Cargo.toml b/common/token-module/Cargo.toml index c5201dc8..e9cb929c 100644 --- a/common/token-module/Cargo.toml +++ b/common/token-module/Cargo.toml @@ -7,6 +7,6 @@ edition = "2018" path = "../fee-estimator-module" [dependencies.multiversx-sc] -version = "0.42.0" +version = "0.43.5" [dev-dependencies.multiversx-sc-scenario] -version = "0.42.0" +version = "0.43.5" diff --git a/common/transaction/Cargo.toml b/common/transaction/Cargo.toml index a0e402cc..89135caa 100644 --- a/common/transaction/Cargo.toml +++ b/common/transaction/Cargo.toml @@ -10,4 +10,4 @@ path = "src/lib.rs" path = "../eth-address" [dependencies.multiversx-sc] -version = "0.42.0" +version = "0.43.5" diff --git a/common/tx-batch-module/Cargo.toml b/common/tx-batch-module/Cargo.toml index 4983bb4f..1a1a98ce 100644 --- a/common/tx-batch-module/Cargo.toml +++ b/common/tx-batch-module/Cargo.toml @@ -4,9 +4,9 @@ version = "0.0.0" authors = ["dorin-iancu "] edition = "2018" [dependencies.multiversx-sc] -version = "0.42.0" +version = "0.43.5" [dependencies.transaction] path = "../transaction" [dev-dependencies.multiversx-sc-scenario] -version = "0.42.0" +version = "0.43.5" diff --git a/esdt-safe/Cargo.toml b/esdt-safe/Cargo.toml index 752ce19f..1c2a0ad3 100644 --- a/esdt-safe/Cargo.toml +++ b/esdt-safe/Cargo.toml @@ -26,9 +26,9 @@ path = "../common/tx-batch-module" path = "../common/max-bridged-amount-module" [dependencies.multiversx-sc] -version = "0.42.0" +version = "0.43.5" [dependencies.multiversx-sc-modules] -version = "0.42.0" +version = "0.43.5" [dev-dependencies.multiversx-sc-scenario] -version = "0.42.0" +version = "0.43.5" diff --git a/esdt-safe/meta/Cargo.toml b/esdt-safe/meta/Cargo.toml index 47db7b79..743b0cec 100644 --- a/esdt-safe/meta/Cargo.toml +++ b/esdt-safe/meta/Cargo.toml @@ -10,4 +10,4 @@ publish = false path = ".." [dependencies.multiversx-sc-meta] -version = "0.42.0" +version = "0.43.5" diff --git a/esdt-safe/wasm/Cargo.toml b/esdt-safe/wasm/Cargo.toml index 7270e4e2..14ba001e 100644 --- a/esdt-safe/wasm/Cargo.toml +++ b/esdt-safe/wasm/Cargo.toml @@ -22,4 +22,4 @@ panic = "abort" path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.42.0" +version = "0.43.5" diff --git a/esdt-safe/wasm/src/lib.rs b/esdt-safe/wasm/src/lib.rs index b81d3b08..8565d921 100644 --- a/esdt-safe/wasm/src/lib.rs +++ b/esdt-safe/wasm/src/lib.rs @@ -10,6 +10,9 @@ // Total number of exported functions: 36 #![no_std] + +// Configuration that works with rustc < 1.73.0. +// TODO: Recommended rustc version: 1.73.0 or newer. #![feature(lang_items)] multiversx_sc_wasm_adapter::allocator!(); diff --git a/multi-transfer-esdt/Cargo.toml b/multi-transfer-esdt/Cargo.toml index 3932fe4b..38e5b5c8 100644 --- a/multi-transfer-esdt/Cargo.toml +++ b/multi-transfer-esdt/Cargo.toml @@ -33,6 +33,8 @@ path = "../common/token-module" [dependencies.multiversx-sc] -version = "0.42.0" +version = "0.43.5" [dev-dependencies.multiversx-sc-scenario] -version = "0.42.0" +version = "0.43.5" +[dependencies.multiversx-sc-modules] +version = "0.43.5" diff --git a/multi-transfer-esdt/meta/Cargo.toml b/multi-transfer-esdt/meta/Cargo.toml index 46997942..ad6a0ab8 100644 --- a/multi-transfer-esdt/meta/Cargo.toml +++ b/multi-transfer-esdt/meta/Cargo.toml @@ -10,4 +10,4 @@ publish = false path = ".." [dependencies.multiversx-sc-meta] -version = "0.42.0" +version = "0.43.5" diff --git a/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs b/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs index 5b1ad70f..ded40d99 100644 --- a/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs +++ b/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs @@ -7,13 +7,17 @@ use multi_transfer_esdt::ProxyTrait as _; use multiversx_sc::{ api::{HandleConstraints, ManagedTypeApi}, - codec::multi_types::{MultiValueVec, OptionalValue}, + codec::{ + multi_types::{MultiValueVec, OptionalValue}, + Empty, + }, storage::mappers::SingleValue, types::{ Address, BigUint, CodeMetadata, ManagedAddress, ManagedBuffer, ManagedByteArray, MultiValueEncoded, TokenIdentifier, }, }; +use multiversx_sc_modules::pause::ProxyTrait; use multiversx_sc_scenario::{ api::{StaticApi, VMHooksApi}, scenario_format::interpret_trait::{InterpretableFrom, InterpreterContext}, @@ -50,7 +54,6 @@ const OWNER_ADDRESS_EXPR: &str = "address:owner"; const ESDT_SAFE_ETH_TX_GAS_LIMIT: u64 = 150_000; const BALANCE: &str = "2,000,000"; -const WEGLD_TOKEN_ID_EXPR: &str = "str:BRIDGE-123456"; fn world() -> ScenarioWorld { let mut blockchain = ScenarioWorld::new(); @@ -75,7 +78,6 @@ type MultiTransferContract = ContractInfo> type BridgeProxyContract = ContractInfo>; type EsdtSafeContract = ContractInfo>; type BridgedTokensWrapperContract = ContractInfo>; -// type PriceAggregatorContract = ContractInfo>; struct MultiTransferTestState { world: ScenarioWorld, @@ -87,7 +89,6 @@ struct MultiTransferTestState { bridge_proxy: BridgeProxyContract, esdt_safe: EsdtSafeContract, bridged_tokens_wrapper: BridgedTokensWrapperContract, - // price_aggregator: PriceAggregatorContract, } impl MultiTransferTestState { @@ -107,35 +108,33 @@ impl MultiTransferTestState { bridge_proxy: BridgeProxyContract::new("sc:bridge_proxy"), esdt_safe: EsdtSafeContract::new("sc:esdt_safe"), bridged_tokens_wrapper: BridgedTokensWrapperContract::new("sc:bridged_tokens_wrapper"), - // price_aggregator: PriceAggregatorContract::new("sc:price_aggregator"), }; state.world.set_state_step( - SetStateStep::new().put_account( - &state.owner, - Account::new() - .nonce(1) - .balance(BALANCE) - .esdt_balance(WEGLD_TOKEN_ID_EXPR, BALANCE), - ), + SetStateStep::new() + .put_account( + &state.owner, + Account::new() + .nonce(1) + .balance(BALANCE) + .esdt_balance(BRIDGE_TOKEN_ID_EXPR, BALANCE), + ) + .put_account(&state.user1, Account::new().nonce(1)) + .new_address(&state.owner, 1, MULTI_TRANSFER_ADDRESS_EXPR) + .new_address(&state.owner, 2, BRIDGE_PROXY_ADDRESS_EXPR) + .new_address(&state.owner, 3, ESDT_SAFE_ADDRESS_EXPR) + .new_address(&state.owner, 4, BRIDGED_TOKENS_WRAPPER_ADDRESS_EXPR), ); state } fn multi_transfer_deploy(&mut self) -> &mut Self { - self.world.set_state_step( - SetStateStep::new() - .put_account(OWNER_ADDRESS_EXPR, Account::new().nonce(1)) - .new_address(&self.owner, 1, MULTI_TRANSFER_ADDRESS_EXPR), - ); - - let ic = &self.world.interpreter_context(); - let bridge_proxy_addr = self - .bridge_proxy - .address - .clone() - .unwrap_or_sc_panic("Cannot get Bridge Proxy Contract address!"); + // let bridge_proxy_addr = self + // .bridge_proxy + // .address + // .clone() + // .unwrap_or_sc_panic("Cannot get Bridge Proxy Contract address!"); self.world.sc_deploy( ScDeployStep::new() @@ -148,13 +147,6 @@ impl MultiTransferTestState { } fn bridge_proxy_deploy(&mut self) -> &mut Self { - self.world.set_state_step(SetStateStep::new().new_address( - &self.owner, - 2, - BRIDGE_PROXY_ADDRESS_EXPR, - )); - - let ic = &self.world.interpreter_context(); self.world.sc_deploy( ScDeployStep::new() .from(self.owner.clone()) @@ -165,32 +157,7 @@ impl MultiTransferTestState { self } - // fn price_aggregator_deploy(&mut self) -> &mut Self { - // self.world.set_state_step( - // SetStateStep::new() - // .put_account(&self.owner, Account::new().nonce(1)) - // .new_address(&self.owner, 3, PRICE_AGGREGATOR_ADDRESS_EXPR), - // ); - - // let ic = &self.world.interpreter_context(); - // self.world.sc_deploy( - // ScDeployStep::new() - // .from(self.owner.clone()) - // .code(self.world.code_expression(PRICE_AGGREGATOR_PATH_EXPR)) - // .call(self.price_aggregator.init(1, 0, ORACLE_ADDRESS_EXPR)), - // ); - - // self - // } - fn safe_deploy(&mut self, price_aggregator_contract_address: Address) -> &mut Self { - self.world.set_state_step(SetStateStep::new().new_address( - &self.owner, - 3, - ESDT_SAFE_ADDRESS_EXPR, - )); - - let ic = &self.world.interpreter_context(); self.world.sc_deploy( ScDeployStep::new() .from(self.owner.clone()) @@ -205,13 +172,6 @@ impl MultiTransferTestState { } fn bridged_tokens_wrapper_deploy(&mut self) -> &mut Self { - self.world.set_state_step(SetStateStep::new().new_address( - &self.owner, - 4, - &self.bridged_tokens_wrapper, - )); - - let ic = &self.world.interpreter_context(); self.world.sc_deploy( ScDeployStep::new() .from(self.owner.clone()) @@ -251,13 +211,14 @@ impl MultiTransferTestState { #[test] fn basic_setup_test() { - let mut test = MultiTransferTestState::setup(); + let mut test: MultiTransferTestState = MultiTransferTestState::setup(); let bridge_token_id_expr = "str:BRIDGE-123456"; // when specifying the token transfer test.multi_transfer_deploy(); test.bridge_proxy_deploy(); // test.price_aggregator_deploy(); test.safe_deploy(Address::zero()); + test.bridged_tokens_wrapper_deploy(); test.config_multi_transfer( test.bridged_tokens_wrapper.to_address(), test.bridge_proxy.to_address(), @@ -290,9 +251,63 @@ fn basic_setup_test() { .check_storage("str:firstBatchId", "0x01"), ), ); +} + +#[test] +fn basic_transfer_test() { + let mut test: MultiTransferTestState = MultiTransferTestState::setup(); + let token_amount = BigUint::from(500u64); + + test.multi_transfer_deploy(); + test.bridge_proxy_deploy(); + // test.price_aggregator_deploy(); + test.safe_deploy(Address::zero()); + test.bridged_tokens_wrapper_deploy(); + test.config_multi_transfer( + test.bridged_tokens_wrapper.to_address(), + test.bridge_proxy.to_address(), + ); + + let eth_tx = EthTransaction { + from: test.eth_user, + to: ManagedAddress::from_address(&test.user1.value), + token_id: TokenIdentifier::from_esdt_bytes(BRIDGE_TOKEN_ID), + amount: token_amount.clone(), + tx_nonce: 1u64, + data: ManagedBuffer::from("data"), + gas_limit: GAS_LIMIT, + }; + + test.world.check_state_step( + CheckStateStep::new().put_account( + &test.multi_transfer, + CheckAccount::new() + .check_storage("str:bridgeProxyContractAddress", "sc:bridge_proxy") + .check_storage("str:lastBatchId", "0x01") + .check_storage("str:wrappingContractAddress", "sc:bridged_tokens_wrapper") + .check_storage("str:maxTxBatchBlockDuration", "0xffffffffffffffff") + .check_storage("str:maxTxBatchSize", "10") + .check_storage("str:firstBatchId", "0x01"), + ), + ); let mut transfers = MultiValueEncoded::new(); - transfers.push(eth_tx); + // transfers.push(eth_tx); + + test.world.sc_call( + ScCallStep::new() + .from(&test.owner) + .to(&test.esdt_safe) + .call(test.esdt_safe.unpause_endpoint()), // .esdt_transfer(bridge_token_id_expr, 0u64, 500u64), + ); + + test.world.sc_call( + ScCallStep::new() + .from(&test.owner) + .to(&test.bridged_tokens_wrapper) + .call(test.bridged_tokens_wrapper.unpause_endpoint()), // .esdt_transfer(bridge_token_id_expr, 0u64, 500u64), + ); + test.world.dump_state_step(); test.world.sc_call( ScCallStep::new() @@ -301,9 +316,16 @@ fn basic_setup_test() { .call( test.multi_transfer .batch_transfer_esdt_token(1u32, transfers), - ), // .esdt_transfer(bridge_token_id_expr, 0u64, 500u64), + ) + // .esdt_transfer(BRIDGE_TOKEN_ID_EXPR, 0u64, BALANCE), ); + test.world + .check_state_step(CheckStateStep::new().put_account( + test.user1, + CheckAccount::new().esdt_balance(BRIDGE_TOKEN_ID_EXPR, token_amount), + )); + // test.world.sc_query( // ScQueryStep::new() // .to(&test.multi_transfer) diff --git a/multi-transfer-esdt/wasm/Cargo.lock b/multi-transfer-esdt/wasm/Cargo.lock index c34f6a19..5a273c3f 100644 --- a/multi-transfer-esdt/wasm/Cargo.lock +++ b/multi-transfer-esdt/wasm/Cargo.lock @@ -4,13 +4,14 @@ version = 3 [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" dependencies = [ "cfg-if", "once_cell", "version_check", + "zerocopy", ] [[package]] @@ -142,9 +143,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.42.0" +version = "0.43.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c22c2d1e82a357b6f397f87d475314628473b8a88882aa407234197f596786aa" +checksum = "adbdd41a744caa562646c6d593df35caed84889e0d35df8b9ad8efc45457b5bd" dependencies = [ "bitflags", "hashbrown", @@ -156,9 +157,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9c97dc9e9f34f836de6a56386ddbe1b9e87e20916ff86b1ea728c08e1871ac2" +checksum = "0f1e15b46c17b87c0c7cdd79b041a4abd7f3a2b45f3c993f6ce38c0f233e82b6" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -166,43 +167,43 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ab795364fcf0452a953e33eae7e0c22d1a6374ffeb0724d24a42727e099c6e" +checksum = "9a7bc0762cd6d88f8bc54805bc652b042a61cd7fbc2d0a325010f088b78fb2ac" dependencies = [ "hex", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "multiversx-sc-derive" -version = "0.42.0" +version = "0.43.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6d77a125ea6985b2fa5cf1a297cdb9202c5a528eebb22652cc68ab1a9305e11" +checksum = "ebdaec412a272d8fd6668bc0b4b8674a5e03148aa72041a4705d502b86f4d9ce" dependencies = [ "hex", "proc-macro2", "quote", "radix_trie", - "syn", + "syn 1.0.109", ] [[package]] name = "multiversx-sc-modules" -version = "0.42.0" +version = "0.43.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "087a8ea95fac541128600a51c3c4ef7329642d5a1a397b4c6a65eb3ee621a282" +checksum = "45a02a1c14d05986661eff35beab26f5e72cdc44753b1f415eff64d6c4e4bc98" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.42.0" +version = "0.43.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "951b0137614c8412554ccd086967c565af38b91b77a66b5d9f433801ff24e501" +checksum = "2befd4545b5b47adf1df89313b76a2282873fd9163b70badd727d8dfce83c588" dependencies = [ "multiversx-sc", ] @@ -218,9 +219,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] @@ -233,18 +234,18 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.32" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -261,9 +262,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "syn" @@ -276,6 +277,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "token-module" version = "0.0.0" @@ -302,12 +314,32 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "version_check" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "zerocopy" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd66a62464e3ffd4e37bd09950c2b9dd6c4f8767380fabba0d523f9a775bc85a" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "255c4596d41e6916ced49cfafea18727b24d67878fa180ddfd69b9df34fd1726" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] diff --git a/multi-transfer-esdt/wasm/Cargo.toml b/multi-transfer-esdt/wasm/Cargo.toml index 860fc15b..bac96b63 100644 --- a/multi-transfer-esdt/wasm/Cargo.toml +++ b/multi-transfer-esdt/wasm/Cargo.toml @@ -22,4 +22,4 @@ panic = "abort" path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.42.0" +version = "0.43.5" diff --git a/multi-transfer-esdt/wasm/src/lib.rs b/multi-transfer-esdt/wasm/src/lib.rs index 09f1636a..d4561b72 100644 --- a/multi-transfer-esdt/wasm/src/lib.rs +++ b/multi-transfer-esdt/wasm/src/lib.rs @@ -10,6 +10,9 @@ // Total number of exported functions: 21 #![no_std] + +// Configuration that works with rustc < 1.73.0. +// TODO: Recommended rustc version: 1.73.0 or newer. #![feature(lang_items)] multiversx_sc_wasm_adapter::allocator!(); diff --git a/multisig/Cargo.toml b/multisig/Cargo.toml index abf4d18d..e089c334 100644 --- a/multisig/Cargo.toml +++ b/multisig/Cargo.toml @@ -32,9 +32,9 @@ path = "../esdt-safe" path = "../multi-transfer-esdt" [dependencies.multiversx-sc] -version = "0.42.0" +version = "0.43.5" [dependencies.multiversx-sc-modules] -version = "0.42.0" +version = "0.43.5" [dev-dependencies.multiversx-sc-scenario] -version = "0.42.0" +version = "0.43.5" diff --git a/multisig/meta/Cargo.toml b/multisig/meta/Cargo.toml index e5de4243..e3c5503e 100644 --- a/multisig/meta/Cargo.toml +++ b/multisig/meta/Cargo.toml @@ -8,4 +8,4 @@ publish = false path = ".." [dependencies.multiversx-sc-meta] -version = "0.42.0" +version = "0.43.5" diff --git a/multisig/wasm/Cargo.lock b/multisig/wasm/Cargo.lock index c4db0688..be83d566 100644 --- a/multisig/wasm/Cargo.lock +++ b/multisig/wasm/Cargo.lock @@ -4,13 +4,14 @@ version = 3 [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" dependencies = [ "cfg-if", "once_cell", "version_check", + "zerocopy", ] [[package]] @@ -158,9 +159,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.42.0" +version = "0.43.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c22c2d1e82a357b6f397f87d475314628473b8a88882aa407234197f596786aa" +checksum = "adbdd41a744caa562646c6d593df35caed84889e0d35df8b9ad8efc45457b5bd" dependencies = [ "bitflags", "hashbrown", @@ -172,9 +173,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9c97dc9e9f34f836de6a56386ddbe1b9e87e20916ff86b1ea728c08e1871ac2" +checksum = "0f1e15b46c17b87c0c7cdd79b041a4abd7f3a2b45f3c993f6ce38c0f233e82b6" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -182,43 +183,43 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ab795364fcf0452a953e33eae7e0c22d1a6374ffeb0724d24a42727e099c6e" +checksum = "9a7bc0762cd6d88f8bc54805bc652b042a61cd7fbc2d0a325010f088b78fb2ac" dependencies = [ "hex", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "multiversx-sc-derive" -version = "0.42.0" +version = "0.43.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6d77a125ea6985b2fa5cf1a297cdb9202c5a528eebb22652cc68ab1a9305e11" +checksum = "ebdaec412a272d8fd6668bc0b4b8674a5e03148aa72041a4705d502b86f4d9ce" dependencies = [ "hex", "proc-macro2", "quote", "radix_trie", - "syn", + "syn 1.0.109", ] [[package]] name = "multiversx-sc-modules" -version = "0.42.0" +version = "0.43.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "087a8ea95fac541128600a51c3c4ef7329642d5a1a397b4c6a65eb3ee621a282" +checksum = "45a02a1c14d05986661eff35beab26f5e72cdc44753b1f415eff64d6c4e4bc98" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.42.0" +version = "0.43.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "951b0137614c8412554ccd086967c565af38b91b77a66b5d9f433801ff24e501" +checksum = "2befd4545b5b47adf1df89313b76a2282873fd9163b70badd727d8dfce83c588" dependencies = [ "multiversx-sc", ] @@ -234,9 +235,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] @@ -249,18 +250,18 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.32" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -277,9 +278,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "syn" @@ -292,6 +293,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "token-module" version = "0.0.0" @@ -318,12 +330,32 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "version_check" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "zerocopy" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd66a62464e3ffd4e37bd09950c2b9dd6c4f8767380fabba0d523f9a775bc85a" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "255c4596d41e6916ced49cfafea18727b24d67878fa180ddfd69b9df34fd1726" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] diff --git a/multisig/wasm/Cargo.toml b/multisig/wasm/Cargo.toml index 24ae2cfd..39a74438 100644 --- a/multisig/wasm/Cargo.toml +++ b/multisig/wasm/Cargo.toml @@ -17,7 +17,7 @@ panic = "abort" path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.42.0" +version = "0.43.5" [workspace] members = ["."] diff --git a/multisig/wasm/src/lib.rs b/multisig/wasm/src/lib.rs index d72c0159..32c45b7c 100644 --- a/multisig/wasm/src/lib.rs +++ b/multisig/wasm/src/lib.rs @@ -10,6 +10,9 @@ // Total number of exported functions: 65 #![no_std] + +// Configuration that works with rustc < 1.73.0. +// TODO: Recommended rustc version: 1.73.0 or newer. #![feature(lang_items)] multiversx_sc_wasm_adapter::allocator!(); From 13c90347c72fcab577924c059cd52f2e8e0b6208 Mon Sep 17 00:00:00 2001 From: Rebegea Dragos-Alexandru Date: Mon, 27 Nov 2023 13:16:45 +0200 Subject: [PATCH 27/50] add accumulated burned tokens --- common/token-module/src/lib.rs | 22 ++++++++++++++++------ esdt-safe/src/lib.rs | 4 +++- esdt-safe/wasm/src/lib.rs | 8 +++++--- multi-transfer-esdt/src/lib.rs | 2 +- multi-transfer-esdt/wasm/Cargo.lock | 1 + multi-transfer-esdt/wasm/src/lib.rs | 4 +--- multisig/wasm/Cargo.lock | 1 + multisig/wasm/src/lib.rs | 4 +--- 8 files changed, 29 insertions(+), 17 deletions(-) diff --git a/common/token-module/src/lib.rs b/common/token-module/src/lib.rs index b81bfa54..9b6a582f 100644 --- a/common/token-module/src/lib.rs +++ b/common/token-module/src/lib.rs @@ -77,7 +77,7 @@ pub trait TokenModule: fee_estimator_module::FeeEstimatorModule { .set(&default_price_per_gas_unit); } - self.whitelisted_token_mint_burn(&token_id).set(mint_burn_allowed); + self.mint_burn_allowed(&token_id).set(mint_burn_allowed); let _ = self.token_whitelist().insert(token_id); } @@ -90,11 +90,13 @@ pub trait TokenModule: fee_estimator_module::FeeEstimatorModule { let _ = self.token_whitelist().swap_remove(&token_id); } - #[endpoint(getToken)] - fn get_token(&self, token_id: &TokenIdentifier, amount: &BigUint) { + #[endpoint(mintToken)] + fn mint_token(&self, token_id: &TokenIdentifier, amount: &BigUint) { let caller = self.blockchain().get_caller(); require!(caller == self.multi_transfer_contract_address().get(), "Only MultiTransfer can get tokens"); - if self.whitelisted_token_mint_burn(token_id).get() { + if self.mint_burn_allowed(token_id).get() { + self.accumulated_burned_tokens(token_id) + .update(|burned| *burned -= amount); self.mint_esdt_token(token_id, amount); } @@ -158,8 +160,9 @@ pub trait TokenModule: fee_estimator_module::FeeEstimatorModule { #[storage_mapper("tokenWhitelist")] fn token_whitelist(&self) -> UnorderedSetMapper; - #[storage_mapper("whitelistedTokenMintBurn")] - fn whitelisted_token_mint_burn(&self, token: &TokenIdentifier) -> SingleValueMapper; + #[view(isMintBurnAllowed)] + #[storage_mapper("mintBurnAllowed")] + fn mint_burn_allowed(&self, token: &TokenIdentifier) -> SingleValueMapper; #[view(getMultiTransferContractAddress)] #[storage_mapper("multiTransferContractAddress")] @@ -171,4 +174,11 @@ pub trait TokenModule: fee_estimator_module::FeeEstimatorModule { &self, token_id: &TokenIdentifier, ) -> SingleValueMapper; + + #[view(getAccumulatedBurnedTokens)] + #[storage_mapper("accumulatedBurnedTokens")] + fn accumulated_burned_tokens( + &self, + token_id: &TokenIdentifier, + ) -> SingleValueMapper; } diff --git a/esdt-safe/src/lib.rs b/esdt-safe/src/lib.rs index 29f4b236..99dfa7f8 100644 --- a/esdt-safe/src/lib.rs +++ b/esdt-safe/src/lib.rs @@ -84,10 +84,12 @@ pub trait EsdtSafe: // local burn role might be removed while tx is executed // tokens will remain locked forever in that case // otherwise, the whole batch would fail - if self.whitelisted_token_mint_burn(&tx.token_identifier).get() + if self.mint_burn_allowed(&tx.token_identifier).get() && self.is_local_role_set(&tx.token_identifier, &EsdtLocalRole::Burn) { self.burn_esdt_token(&tx.token_identifier, &tx.amount); + self.accumulated_burned_tokens(&tx.token_identifier) + .update(|burned| *burned += &tx.amount); } } TransactionStatus::Rejected => { diff --git a/esdt-safe/wasm/src/lib.rs b/esdt-safe/wasm/src/lib.rs index 8565d921..6ff155ee 100644 --- a/esdt-safe/wasm/src/lib.rs +++ b/esdt-safe/wasm/src/lib.rs @@ -5,9 +5,9 @@ //////////////////////////////////////////////////// // Init: 1 -// Endpoints: 34 +// Endpoints: 36 // Async Callback (empty): 1 -// Total number of exported functions: 36 +// Total number of exported functions: 38 #![no_std] @@ -38,11 +38,13 @@ multiversx_sc_wasm_adapter::endpoints! { distributeFees => distribute_fees addTokenToWhitelist => add_token_to_whitelist removeTokenFromWhitelist => remove_token_from_whitelist - getToken => get_token + mintToken => mint_token setMultiTransferContractAddress => set_multi_transfer_contract_address getAllKnownTokens => token_whitelist + isWhitelistedTokenMintBurn => mint_burn_allowed getMultiTransferContractAddress => multi_transfer_contract_address getAccumulatedTransactionFees => accumulated_transaction_fees + getAccumulatedBurnedTokens => accumulated_burned_tokens setMaxTxBatchSize => set_max_tx_batch_size setMaxTxBatchBlockDuration => set_max_tx_batch_block_duration getCurrentTxBatch => get_current_tx_batch diff --git a/multi-transfer-esdt/src/lib.rs b/multi-transfer-esdt/src/lib.rs index d95846b8..659c0af6 100644 --- a/multi-transfer-esdt/src/lib.rs +++ b/multi-transfer-esdt/src/lib.rs @@ -69,7 +69,7 @@ pub trait MultiTransferEsdt: let _: IgnoreValue = self .get_esdt_safe_contract_proxy_instance() - .get_token(ð_tx.token_id, ð_tx.amount) + .mint_token(ð_tx.token_id, ð_tx.amount) .with_esdt_transfer((eth_tx.token_id.clone(), 0, eth_tx.amount.clone())) .execute_on_dest_context(); diff --git a/multi-transfer-esdt/wasm/Cargo.lock b/multi-transfer-esdt/wasm/Cargo.lock index 5a273c3f..8da56ed3 100644 --- a/multi-transfer-esdt/wasm/Cargo.lock +++ b/multi-transfer-esdt/wasm/Cargo.lock @@ -128,6 +128,7 @@ dependencies = [ "eth-address", "max-bridged-amount-module", "multiversx-sc", + "multiversx-sc-modules", "token-module", "transaction", "tx-batch-module", diff --git a/multi-transfer-esdt/wasm/src/lib.rs b/multi-transfer-esdt/wasm/src/lib.rs index d4561b72..dcce9996 100644 --- a/multi-transfer-esdt/wasm/src/lib.rs +++ b/multi-transfer-esdt/wasm/src/lib.rs @@ -10,9 +10,7 @@ // Total number of exported functions: 21 #![no_std] - -// Configuration that works with rustc < 1.73.0. -// TODO: Recommended rustc version: 1.73.0 or newer. +#![allow(internal_features)] #![feature(lang_items)] multiversx_sc_wasm_adapter::allocator!(); diff --git a/multisig/wasm/Cargo.lock b/multisig/wasm/Cargo.lock index be83d566..c1170ed7 100644 --- a/multisig/wasm/Cargo.lock +++ b/multisig/wasm/Cargo.lock @@ -128,6 +128,7 @@ dependencies = [ "eth-address", "max-bridged-amount-module", "multiversx-sc", + "multiversx-sc-modules", "token-module", "transaction", "tx-batch-module", diff --git a/multisig/wasm/src/lib.rs b/multisig/wasm/src/lib.rs index 32c45b7c..d0ac1324 100644 --- a/multisig/wasm/src/lib.rs +++ b/multisig/wasm/src/lib.rs @@ -10,9 +10,7 @@ // Total number of exported functions: 65 #![no_std] - -// Configuration that works with rustc < 1.73.0. -// TODO: Recommended rustc version: 1.73.0 or newer. +#![allow(internal_features)] #![feature(lang_items)] multiversx_sc_wasm_adapter::allocator!(); From 32286289825214359e9af8a28e8a7e78ac45f016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Tue, 5 Dec 2023 10:00:14 +0200 Subject: [PATCH 28/50] Framework upgrade 0.45.1 --- bridge-proxy/Cargo.toml | 5 +- bridge-proxy/meta/Cargo.toml | 4 +- bridge-proxy/wasm/Cargo.lock | 57 ++++++++++--------- bridge-proxy/wasm/Cargo.toml | 17 ++++-- bridge-proxy/wasm/src/lib.rs | 2 +- bridged-tokens-wrapper/Cargo.toml | 8 ++- bridged-tokens-wrapper/meta/Cargo.toml | 4 +- bridged-tokens-wrapper/wasm/Cargo.lock | 61 ++++++++++++--------- bridged-tokens-wrapper/wasm/Cargo.toml | 11 +++- bridged-tokens-wrapper/wasm/src/lib.rs | 2 +- common/eth-address/Cargo.toml | 3 +- common/fee-estimator-module/Cargo.toml | 6 +- common/max-bridged-amount-module/Cargo.toml | 6 +- common/token-module/Cargo.toml | 6 +- common/transaction/Cargo.toml | 3 +- common/tx-batch-module/Cargo.toml | 6 +- esdt-safe/Cargo.toml | 8 ++- esdt-safe/meta/Cargo.toml | 4 +- esdt-safe/wasm/Cargo.toml | 17 ++++-- esdt-safe/wasm/src/lib.rs | 2 +- multi-transfer-esdt/Cargo.toml | 12 ++-- multi-transfer-esdt/meta/Cargo.toml | 4 +- multi-transfer-esdt/wasm/Cargo.lock | 61 ++++++++++++--------- multi-transfer-esdt/wasm/Cargo.toml | 17 ++++-- multi-transfer-esdt/wasm/src/lib.rs | 2 +- multisig/Cargo.toml | 8 ++- multisig/meta/Cargo.toml | 4 +- multisig/wasm/Cargo.lock | 61 ++++++++++++--------- multisig/wasm/Cargo.toml | 11 +++- multisig/wasm/src/lib.rs | 2 +- 30 files changed, 250 insertions(+), 164 deletions(-) diff --git a/bridge-proxy/Cargo.toml b/bridge-proxy/Cargo.toml index 4e637f19..9f4481fb 100644 --- a/bridge-proxy/Cargo.toml +++ b/bridge-proxy/Cargo.toml @@ -7,6 +7,7 @@ publish = false [lib] path = "src/bridge-proxy.rs" + [dependencies.transaction] path = "../common/transaction" @@ -14,10 +15,10 @@ path = "../common/transaction" path = "../common/eth-address" [dependencies.multiversx-sc] -version = "0.43.5" +version = "0.45.1" [dev-dependencies] num-bigint = "0.4.2" [dev-dependencies.multiversx-sc-scenario] -version = "0.43.5" +version = "0.45.1" diff --git a/bridge-proxy/meta/Cargo.toml b/bridge-proxy/meta/Cargo.toml index b24ed1ab..788c3de3 100644 --- a/bridge-proxy/meta/Cargo.toml +++ b/bridge-proxy/meta/Cargo.toml @@ -6,8 +6,10 @@ publish = false authors = ["you"] [dev-dependencies] + [dependencies.bridge-proxy] path = ".." [dependencies.multiversx-sc-meta] -version = "0.43.5" +version = "0.45.1" +default-features = false diff --git a/bridge-proxy/wasm/Cargo.lock b/bridge-proxy/wasm/Cargo.lock index 0f8e9a10..44fa826c 100644 --- a/bridge-proxy/wasm/Cargo.lock +++ b/bridge-proxy/wasm/Cargo.lock @@ -14,6 +14,12 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + [[package]] name = "arrayvec" version = "0.7.4" @@ -70,11 +76,12 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.13.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ "ahash", + "allocator-api2", ] [[package]] @@ -85,15 +92,15 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hex-literal" -version = "0.3.4" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "multiversx-sc" -version = "0.43.5" +version = "0.45.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adbdd41a744caa562646c6d593df35caed84889e0d35df8b9ad8efc45457b5bd" +checksum = "f11b51d6a2ab0218585ed58e100c5ac2218de09490fbfc4243b5ecd0ca7f5cbc" dependencies = [ "bitflags", "hashbrown", @@ -105,9 +112,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.18.1" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f1e15b46c17b87c0c7cdd79b041a4abd7f3a2b45f3c993f6ce38c0f233e82b6" +checksum = "327b0ad1c3477cab0d7c84391439ba302238f738ef3c6e1fcd18e247fba84875" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -115,9 +122,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.18.1" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a7bc0762cd6d88f8bc54805bc652b042a61cd7fbc2d0a325010f088b78fb2ac" +checksum = "f444038e0043b8eda816b26952479c2aca3c4a643580f4337f71fb362a586db5" dependencies = [ "hex", "proc-macro2", @@ -127,9 +134,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.43.5" +version = "0.45.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebdaec412a272d8fd6668bc0b4b8674a5e03148aa72041a4705d502b86f4d9ce" +checksum = "784f0fc505806102fe6f808b368e12fcb13096dd73c5678f09c5663230724d6f" dependencies = [ "hex", "proc-macro2", @@ -140,9 +147,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.43.5" +version = "0.45.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2befd4545b5b47adf1df89313b76a2282873fd9163b70badd727d8dfce83c588" +checksum = "5afb8b8cc380eabd82dc8f9b02afbab3dce16fc2b5de1dbc601fcfcf261278ba" dependencies = [ "multiversx-sc", ] @@ -173,9 +180,9 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" dependencies = [ "unicode-ident", ] @@ -201,9 +208,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.1" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "syn" @@ -218,9 +225,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.38" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ "proc-macro2", "quote", @@ -249,20 +256,20 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "zerocopy" -version = "0.7.20" +version = "0.7.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd66a62464e3ffd4e37bd09950c2b9dd6c4f8767380fabba0d523f9a775bc85a" +checksum = "7d6f15f7ade05d2a4935e34a457b936c23dc70a05cc1d97133dc99e7a3fe0f0e" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.20" +version = "0.7.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "255c4596d41e6916ced49cfafea18727b24d67878fa180ddfd69b9df34fd1726" +checksum = "dbbad221e3f78500350ecbd7dfa4e63ef945c05f4c61cb7f4d3f84cd0bba649b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] diff --git a/bridge-proxy/wasm/Cargo.toml b/bridge-proxy/wasm/Cargo.toml index ed28ebcd..91ff88f5 100644 --- a/bridge-proxy/wasm/Cargo.toml +++ b/bridge-proxy/wasm/Cargo.toml @@ -1,25 +1,30 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "bridge-proxy-wasm" version = "0.0.0" edition = "2018" publish = false -authors = ["you"] [lib] crate-type = ["cdylib"] -[workspace] -members = ["."] - -[dev-dependencies] [profile.release] codegen-units = 1 opt-level = "z" lto = true debug = false panic = "abort" + [dependencies.bridge-proxy] path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.43.5" +version = "0.45.1" + +[workspace] +members = ["."] diff --git a/bridge-proxy/wasm/src/lib.rs b/bridge-proxy/wasm/src/lib.rs index 21d44fe5..abe47c04 100644 --- a/bridge-proxy/wasm/src/lib.rs +++ b/bridge-proxy/wasm/src/lib.rs @@ -1,4 +1,4 @@ -// Code generated by the multiversx-sc multi-contract system. DO NOT EDIT. +// Code generated by the multiversx-sc build system. DO NOT EDIT. //////////////////////////////////////////////////// ////////////////// AUTO-GENERATED ////////////////// diff --git a/bridged-tokens-wrapper/Cargo.toml b/bridged-tokens-wrapper/Cargo.toml index 86f7dbb2..7a56d549 100644 --- a/bridged-tokens-wrapper/Cargo.toml +++ b/bridged-tokens-wrapper/Cargo.toml @@ -7,13 +7,15 @@ publish = false [lib] path = "src/lib.rs" + [dependencies.transaction] path = "../common/transaction" [dependencies.multiversx-sc] -version = "0.43.5" +version = "0.45.1" [dependencies.multiversx-sc-modules] -version = "0.43.5" +version = "0.45.1" + [dev-dependencies.multiversx-sc-scenario] -version = "0.43.5" +version = "0.45.1" diff --git a/bridged-tokens-wrapper/meta/Cargo.toml b/bridged-tokens-wrapper/meta/Cargo.toml index 30a5a635..4b9d3b50 100644 --- a/bridged-tokens-wrapper/meta/Cargo.toml +++ b/bridged-tokens-wrapper/meta/Cargo.toml @@ -3,8 +3,10 @@ name = "bridged-tokens-wrapper-meta" version = "0.0.0" edition = "2018" publish = false + [dependencies.bridged-tokens-wrapper] path = ".." [dependencies.multiversx-sc-meta] -version = "0.43.5" +version = "0.45.1" +default-features = false diff --git a/bridged-tokens-wrapper/wasm/Cargo.lock b/bridged-tokens-wrapper/wasm/Cargo.lock index 281803ef..fea5f091 100644 --- a/bridged-tokens-wrapper/wasm/Cargo.lock +++ b/bridged-tokens-wrapper/wasm/Cargo.lock @@ -14,6 +14,12 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + [[package]] name = "arrayvec" version = "0.7.4" @@ -70,11 +76,12 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.13.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ "ahash", + "allocator-api2", ] [[package]] @@ -85,15 +92,15 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hex-literal" -version = "0.3.4" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "multiversx-sc" -version = "0.43.5" +version = "0.45.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adbdd41a744caa562646c6d593df35caed84889e0d35df8b9ad8efc45457b5bd" +checksum = "f11b51d6a2ab0218585ed58e100c5ac2218de09490fbfc4243b5ecd0ca7f5cbc" dependencies = [ "bitflags", "hashbrown", @@ -105,9 +112,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.18.1" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f1e15b46c17b87c0c7cdd79b041a4abd7f3a2b45f3c993f6ce38c0f233e82b6" +checksum = "327b0ad1c3477cab0d7c84391439ba302238f738ef3c6e1fcd18e247fba84875" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -115,9 +122,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.18.1" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a7bc0762cd6d88f8bc54805bc652b042a61cd7fbc2d0a325010f088b78fb2ac" +checksum = "f444038e0043b8eda816b26952479c2aca3c4a643580f4337f71fb362a586db5" dependencies = [ "hex", "proc-macro2", @@ -127,9 +134,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.43.5" +version = "0.45.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebdaec412a272d8fd6668bc0b4b8674a5e03148aa72041a4705d502b86f4d9ce" +checksum = "784f0fc505806102fe6f808b368e12fcb13096dd73c5678f09c5663230724d6f" dependencies = [ "hex", "proc-macro2", @@ -140,18 +147,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.43.5" +version = "0.45.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45a02a1c14d05986661eff35beab26f5e72cdc44753b1f415eff64d6c4e4bc98" +checksum = "75cc759dda52661f2fc776dfd810a6e90e681d4697a8c866d0f23f3e068f1b29" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.43.5" +version = "0.45.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2befd4545b5b47adf1df89313b76a2282873fd9163b70badd727d8dfce83c588" +checksum = "5afb8b8cc380eabd82dc8f9b02afbab3dce16fc2b5de1dbc601fcfcf261278ba" dependencies = [ "multiversx-sc", ] @@ -182,9 +189,9 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" dependencies = [ "unicode-ident", ] @@ -210,9 +217,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.1" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "syn" @@ -227,9 +234,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.38" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ "proc-macro2", "quote", @@ -258,20 +265,20 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "zerocopy" -version = "0.7.20" +version = "0.7.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd66a62464e3ffd4e37bd09950c2b9dd6c4f8767380fabba0d523f9a775bc85a" +checksum = "7d6f15f7ade05d2a4935e34a457b936c23dc70a05cc1d97133dc99e7a3fe0f0e" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.20" +version = "0.7.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "255c4596d41e6916ced49cfafea18727b24d67878fa180ddfd69b9df34fd1726" +checksum = "dbbad221e3f78500350ecbd7dfa4e63ef945c05f4c61cb7f4d3f84cd0bba649b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] diff --git a/bridged-tokens-wrapper/wasm/Cargo.toml b/bridged-tokens-wrapper/wasm/Cargo.toml index 98ff330b..2c6f92a5 100644 --- a/bridged-tokens-wrapper/wasm/Cargo.toml +++ b/bridged-tokens-wrapper/wasm/Cargo.toml @@ -1,23 +1,30 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "bridged-tokens-wrapper-wasm" version = "0.0.0" -authors = ["Alin Cruceat "] edition = "2018" publish = false [lib] crate-type = ["cdylib"] + [profile.release] codegen-units = 1 opt-level = "z" lto = true debug = false panic = "abort" + [dependencies.bridged-tokens-wrapper] path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.43.5" +version = "0.45.1" [workspace] members = ["."] diff --git a/bridged-tokens-wrapper/wasm/src/lib.rs b/bridged-tokens-wrapper/wasm/src/lib.rs index a9cc42de..eb736854 100644 --- a/bridged-tokens-wrapper/wasm/src/lib.rs +++ b/bridged-tokens-wrapper/wasm/src/lib.rs @@ -1,4 +1,4 @@ -// Code generated by the multiversx-sc multi-contract system. DO NOT EDIT. +// Code generated by the multiversx-sc build system. DO NOT EDIT. //////////////////////////////////////////////////// ////////////////// AUTO-GENERATED ////////////////// diff --git a/common/eth-address/Cargo.toml b/common/eth-address/Cargo.toml index 11a4a52f..7e502562 100644 --- a/common/eth-address/Cargo.toml +++ b/common/eth-address/Cargo.toml @@ -6,5 +6,6 @@ edition = "2018" [lib] path = "src/lib.rs" + [dependencies.multiversx-sc] -version = "0.43.5" +version = "0.45.1" diff --git a/common/fee-estimator-module/Cargo.toml b/common/fee-estimator-module/Cargo.toml index f00ad30c..1c5dbe7d 100644 --- a/common/fee-estimator-module/Cargo.toml +++ b/common/fee-estimator-module/Cargo.toml @@ -3,7 +3,9 @@ name = "fee-estimator-module" version = "0.0.0" authors = ["dorin-iancu "] edition = "2018" + [dependencies.multiversx-sc] -version = "0.43.5" +version = "0.45.1" + [dev-dependencies.multiversx-sc-scenario] -version = "0.43.5" +version = "0.45.1" diff --git a/common/max-bridged-amount-module/Cargo.toml b/common/max-bridged-amount-module/Cargo.toml index 63f52559..f5862ce7 100644 --- a/common/max-bridged-amount-module/Cargo.toml +++ b/common/max-bridged-amount-module/Cargo.toml @@ -3,7 +3,9 @@ name = "max-bridged-amount-module" version = "0.0.0" authors = ["dorin-iancu "] edition = "2018" + [dependencies.multiversx-sc] -version = "0.43.5" +version = "0.45.1" + [dev-dependencies.multiversx-sc-scenario] -version = "0.43.5" +version = "0.45.1" diff --git a/common/token-module/Cargo.toml b/common/token-module/Cargo.toml index e9cb929c..52ef40f1 100644 --- a/common/token-module/Cargo.toml +++ b/common/token-module/Cargo.toml @@ -3,10 +3,12 @@ name = "token-module" version = "0.0.0" authors = ["dorin-iancu "] edition = "2018" + [dependencies.fee-estimator-module] path = "../fee-estimator-module" [dependencies.multiversx-sc] -version = "0.43.5" +version = "0.45.1" + [dev-dependencies.multiversx-sc-scenario] -version = "0.43.5" +version = "0.45.1" diff --git a/common/transaction/Cargo.toml b/common/transaction/Cargo.toml index 89135caa..4d55c716 100644 --- a/common/transaction/Cargo.toml +++ b/common/transaction/Cargo.toml @@ -6,8 +6,9 @@ edition = "2018" [lib] path = "src/lib.rs" + [dependencies.eth-address] path = "../eth-address" [dependencies.multiversx-sc] -version = "0.43.5" +version = "0.45.1" diff --git a/common/tx-batch-module/Cargo.toml b/common/tx-batch-module/Cargo.toml index 1a1a98ce..60f22af4 100644 --- a/common/tx-batch-module/Cargo.toml +++ b/common/tx-batch-module/Cargo.toml @@ -3,10 +3,12 @@ name = "tx-batch-module" version = "0.0.0" authors = ["dorin-iancu "] edition = "2018" + [dependencies.multiversx-sc] -version = "0.43.5" +version = "0.45.1" [dependencies.transaction] path = "../transaction" + [dev-dependencies.multiversx-sc-scenario] -version = "0.43.5" +version = "0.45.1" diff --git a/esdt-safe/Cargo.toml b/esdt-safe/Cargo.toml index 1c2a0ad3..6404f5a8 100644 --- a/esdt-safe/Cargo.toml +++ b/esdt-safe/Cargo.toml @@ -7,6 +7,7 @@ publish = false [lib] path = "src/lib.rs" + [dependencies.transaction] path = "../common/transaction" @@ -26,9 +27,10 @@ path = "../common/tx-batch-module" path = "../common/max-bridged-amount-module" [dependencies.multiversx-sc] -version = "0.43.5" +version = "0.45.1" [dependencies.multiversx-sc-modules] -version = "0.43.5" +version = "0.45.1" + [dev-dependencies.multiversx-sc-scenario] -version = "0.43.5" +version = "0.45.1" diff --git a/esdt-safe/meta/Cargo.toml b/esdt-safe/meta/Cargo.toml index 743b0cec..4a931828 100644 --- a/esdt-safe/meta/Cargo.toml +++ b/esdt-safe/meta/Cargo.toml @@ -6,8 +6,10 @@ edition = "2018" publish = false [dev-dependencies] + [dependencies.esdt-safe] path = ".." [dependencies.multiversx-sc-meta] -version = "0.43.5" +version = "0.45.1" +default-features = false diff --git a/esdt-safe/wasm/Cargo.toml b/esdt-safe/wasm/Cargo.toml index 14ba001e..42193d74 100644 --- a/esdt-safe/wasm/Cargo.toml +++ b/esdt-safe/wasm/Cargo.toml @@ -1,25 +1,30 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "esdt-safe-wasm" version = "0.0.0" -authors = ["you"] edition = "2018" publish = false [lib] crate-type = ["cdylib"] -[workspace] -members = ["."] - -[dev-dependencies] [profile.release] codegen-units = 1 opt-level = "z" lto = true debug = false panic = "abort" + [dependencies.esdt-safe] path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.43.5" +version = "0.45.1" + +[workspace] +members = ["."] diff --git a/esdt-safe/wasm/src/lib.rs b/esdt-safe/wasm/src/lib.rs index 6ff155ee..5f3dc08b 100644 --- a/esdt-safe/wasm/src/lib.rs +++ b/esdt-safe/wasm/src/lib.rs @@ -1,4 +1,4 @@ -// Code generated by the multiversx-sc multi-contract system. DO NOT EDIT. +// Code generated by the multiversx-sc build system. DO NOT EDIT. //////////////////////////////////////////////////// ////////////////// AUTO-GENERATED ////////////////// diff --git a/multi-transfer-esdt/Cargo.toml b/multi-transfer-esdt/Cargo.toml index 38e5b5c8..86d8bf41 100644 --- a/multi-transfer-esdt/Cargo.toml +++ b/multi-transfer-esdt/Cargo.toml @@ -7,6 +7,7 @@ publish = false [lib] path = "src/lib.rs" + [dependencies.transaction] path = "../common/transaction" @@ -31,10 +32,11 @@ path = "../esdt-safe" [dependencies.token-module] path = "../common/token-module" - [dependencies.multiversx-sc] -version = "0.43.5" -[dev-dependencies.multiversx-sc-scenario] -version = "0.43.5" +version = "0.45.1" + [dependencies.multiversx-sc-modules] -version = "0.43.5" +version = "0.45.1" + +[dev-dependencies.multiversx-sc-scenario] +version = "0.45.1" diff --git a/multi-transfer-esdt/meta/Cargo.toml b/multi-transfer-esdt/meta/Cargo.toml index ad6a0ab8..ce5168c7 100644 --- a/multi-transfer-esdt/meta/Cargo.toml +++ b/multi-transfer-esdt/meta/Cargo.toml @@ -6,8 +6,10 @@ edition = "2018" publish = false [dev-dependencies] + [dependencies.multi-transfer-esdt] path = ".." [dependencies.multiversx-sc-meta] -version = "0.43.5" +version = "0.45.1" +default-features = false diff --git a/multi-transfer-esdt/wasm/Cargo.lock b/multi-transfer-esdt/wasm/Cargo.lock index 8da56ed3..b0c56fbf 100644 --- a/multi-transfer-esdt/wasm/Cargo.lock +++ b/multi-transfer-esdt/wasm/Cargo.lock @@ -14,6 +14,12 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + [[package]] name = "arrayvec" version = "0.7.4" @@ -92,11 +98,12 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.13.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ "ahash", + "allocator-api2", ] [[package]] @@ -107,9 +114,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hex-literal" -version = "0.3.4" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "max-bridged-amount-module" @@ -144,9 +151,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.43.5" +version = "0.45.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adbdd41a744caa562646c6d593df35caed84889e0d35df8b9ad8efc45457b5bd" +checksum = "f11b51d6a2ab0218585ed58e100c5ac2218de09490fbfc4243b5ecd0ca7f5cbc" dependencies = [ "bitflags", "hashbrown", @@ -158,9 +165,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.18.1" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f1e15b46c17b87c0c7cdd79b041a4abd7f3a2b45f3c993f6ce38c0f233e82b6" +checksum = "327b0ad1c3477cab0d7c84391439ba302238f738ef3c6e1fcd18e247fba84875" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -168,9 +175,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.18.1" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a7bc0762cd6d88f8bc54805bc652b042a61cd7fbc2d0a325010f088b78fb2ac" +checksum = "f444038e0043b8eda816b26952479c2aca3c4a643580f4337f71fb362a586db5" dependencies = [ "hex", "proc-macro2", @@ -180,9 +187,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.43.5" +version = "0.45.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebdaec412a272d8fd6668bc0b4b8674a5e03148aa72041a4705d502b86f4d9ce" +checksum = "784f0fc505806102fe6f808b368e12fcb13096dd73c5678f09c5663230724d6f" dependencies = [ "hex", "proc-macro2", @@ -193,18 +200,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.43.5" +version = "0.45.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45a02a1c14d05986661eff35beab26f5e72cdc44753b1f415eff64d6c4e4bc98" +checksum = "75cc759dda52661f2fc776dfd810a6e90e681d4697a8c866d0f23f3e068f1b29" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.43.5" +version = "0.45.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2befd4545b5b47adf1df89313b76a2282873fd9163b70badd727d8dfce83c588" +checksum = "5afb8b8cc380eabd82dc8f9b02afbab3dce16fc2b5de1dbc601fcfcf261278ba" dependencies = [ "multiversx-sc", ] @@ -235,9 +242,9 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" dependencies = [ "unicode-ident", ] @@ -263,9 +270,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.1" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "syn" @@ -280,9 +287,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.38" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ "proc-macro2", "quote", @@ -327,20 +334,20 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "zerocopy" -version = "0.7.20" +version = "0.7.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd66a62464e3ffd4e37bd09950c2b9dd6c4f8767380fabba0d523f9a775bc85a" +checksum = "7d6f15f7ade05d2a4935e34a457b936c23dc70a05cc1d97133dc99e7a3fe0f0e" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.20" +version = "0.7.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "255c4596d41e6916ced49cfafea18727b24d67878fa180ddfd69b9df34fd1726" +checksum = "dbbad221e3f78500350ecbd7dfa4e63ef945c05f4c61cb7f4d3f84cd0bba649b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] diff --git a/multi-transfer-esdt/wasm/Cargo.toml b/multi-transfer-esdt/wasm/Cargo.toml index bac96b63..ff8c18a0 100644 --- a/multi-transfer-esdt/wasm/Cargo.toml +++ b/multi-transfer-esdt/wasm/Cargo.toml @@ -1,25 +1,30 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "multi-transfer-esdt-wasm" version = "0.0.0" -authors = ["you"] edition = "2018" publish = false [lib] crate-type = ["cdylib"] -[workspace] -members = ["."] - -[dev-dependencies] [profile.release] codegen-units = 1 opt-level = "z" lto = true debug = false panic = "abort" + [dependencies.multi-transfer-esdt] path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.43.5" +version = "0.45.1" + +[workspace] +members = ["."] diff --git a/multi-transfer-esdt/wasm/src/lib.rs b/multi-transfer-esdt/wasm/src/lib.rs index dcce9996..1afddf8e 100644 --- a/multi-transfer-esdt/wasm/src/lib.rs +++ b/multi-transfer-esdt/wasm/src/lib.rs @@ -1,4 +1,4 @@ -// Code generated by the multiversx-sc multi-contract system. DO NOT EDIT. +// Code generated by the multiversx-sc build system. DO NOT EDIT. //////////////////////////////////////////////////// ////////////////// AUTO-GENERATED ////////////////// diff --git a/multisig/Cargo.toml b/multisig/Cargo.toml index e089c334..68a91a7c 100644 --- a/multisig/Cargo.toml +++ b/multisig/Cargo.toml @@ -7,6 +7,7 @@ publish = false [lib] path = "src/lib.rs" + [dependencies.transaction] path = "../common/transaction" @@ -32,9 +33,10 @@ path = "../esdt-safe" path = "../multi-transfer-esdt" [dependencies.multiversx-sc] -version = "0.43.5" +version = "0.45.1" [dependencies.multiversx-sc-modules] -version = "0.43.5" +version = "0.45.1" + [dev-dependencies.multiversx-sc-scenario] -version = "0.43.5" +version = "0.45.1" diff --git a/multisig/meta/Cargo.toml b/multisig/meta/Cargo.toml index e3c5503e..21096849 100644 --- a/multisig/meta/Cargo.toml +++ b/multisig/meta/Cargo.toml @@ -4,8 +4,10 @@ version = "0.0.0" authors = ["Andrei Marinica , Dorin Iancu "] edition = "2018" publish = false + [dependencies.multisig] path = ".." [dependencies.multiversx-sc-meta] -version = "0.43.5" +version = "0.45.1" +default-features = false diff --git a/multisig/wasm/Cargo.lock b/multisig/wasm/Cargo.lock index c1170ed7..d51710ff 100644 --- a/multisig/wasm/Cargo.lock +++ b/multisig/wasm/Cargo.lock @@ -14,6 +14,12 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + [[package]] name = "arrayvec" version = "0.7.4" @@ -92,11 +98,12 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.13.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ "ahash", + "allocator-api2", ] [[package]] @@ -107,9 +114,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hex-literal" -version = "0.3.4" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "max-bridged-amount-module" @@ -160,9 +167,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.43.5" +version = "0.45.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adbdd41a744caa562646c6d593df35caed84889e0d35df8b9ad8efc45457b5bd" +checksum = "f11b51d6a2ab0218585ed58e100c5ac2218de09490fbfc4243b5ecd0ca7f5cbc" dependencies = [ "bitflags", "hashbrown", @@ -174,9 +181,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.18.1" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f1e15b46c17b87c0c7cdd79b041a4abd7f3a2b45f3c993f6ce38c0f233e82b6" +checksum = "327b0ad1c3477cab0d7c84391439ba302238f738ef3c6e1fcd18e247fba84875" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -184,9 +191,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.18.1" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a7bc0762cd6d88f8bc54805bc652b042a61cd7fbc2d0a325010f088b78fb2ac" +checksum = "f444038e0043b8eda816b26952479c2aca3c4a643580f4337f71fb362a586db5" dependencies = [ "hex", "proc-macro2", @@ -196,9 +203,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.43.5" +version = "0.45.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebdaec412a272d8fd6668bc0b4b8674a5e03148aa72041a4705d502b86f4d9ce" +checksum = "784f0fc505806102fe6f808b368e12fcb13096dd73c5678f09c5663230724d6f" dependencies = [ "hex", "proc-macro2", @@ -209,18 +216,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.43.5" +version = "0.45.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45a02a1c14d05986661eff35beab26f5e72cdc44753b1f415eff64d6c4e4bc98" +checksum = "75cc759dda52661f2fc776dfd810a6e90e681d4697a8c866d0f23f3e068f1b29" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.43.5" +version = "0.45.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2befd4545b5b47adf1df89313b76a2282873fd9163b70badd727d8dfce83c588" +checksum = "5afb8b8cc380eabd82dc8f9b02afbab3dce16fc2b5de1dbc601fcfcf261278ba" dependencies = [ "multiversx-sc", ] @@ -251,9 +258,9 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" dependencies = [ "unicode-ident", ] @@ -279,9 +286,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.1" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "syn" @@ -296,9 +303,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.38" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ "proc-macro2", "quote", @@ -343,20 +350,20 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "zerocopy" -version = "0.7.20" +version = "0.7.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd66a62464e3ffd4e37bd09950c2b9dd6c4f8767380fabba0d523f9a775bc85a" +checksum = "7d6f15f7ade05d2a4935e34a457b936c23dc70a05cc1d97133dc99e7a3fe0f0e" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.20" +version = "0.7.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "255c4596d41e6916ced49cfafea18727b24d67878fa180ddfd69b9df34fd1726" +checksum = "dbbad221e3f78500350ecbd7dfa4e63ef945c05f4c61cb7f4d3f84cd0bba649b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] diff --git a/multisig/wasm/Cargo.toml b/multisig/wasm/Cargo.toml index 39a74438..4866e47c 100644 --- a/multisig/wasm/Cargo.toml +++ b/multisig/wasm/Cargo.toml @@ -1,23 +1,30 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "multisig-wasm" version = "0.0.0" -authors = ["Andrei Marinica , Dorin Iancu "] edition = "2018" publish = false [lib] crate-type = ["cdylib"] + [profile.release] codegen-units = 1 opt-level = "z" lto = true debug = false panic = "abort" + [dependencies.multisig] path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.43.5" +version = "0.45.1" [workspace] members = ["."] diff --git a/multisig/wasm/src/lib.rs b/multisig/wasm/src/lib.rs index d0ac1324..7b00f1d3 100644 --- a/multisig/wasm/src/lib.rs +++ b/multisig/wasm/src/lib.rs @@ -1,4 +1,4 @@ -// Code generated by the multiversx-sc multi-contract system. DO NOT EDIT. +// Code generated by the multiversx-sc build system. DO NOT EDIT. //////////////////////////////////////////////////// ////////////////// AUTO-GENERATED ////////////////// From da8fcec137c7654b5af9188cfac290f0aefc8f93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Wed, 20 Dec 2023 09:46:54 +0200 Subject: [PATCH 29/50] Fixed after reviews --- common/token-module/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common/token-module/src/lib.rs b/common/token-module/src/lib.rs index 9b6a582f..61133d5d 100644 --- a/common/token-module/src/lib.rs +++ b/common/token-module/src/lib.rs @@ -87,7 +87,8 @@ pub trait TokenModule: fee_estimator_module::FeeEstimatorModule { self.token_ticker(&token_id).clear(); self.default_price_per_gas_unit(&token_id).clear(); - let _ = self.token_whitelist().swap_remove(&token_id); + self.mint_burn_allowed(&token_id).clear(); + self.token_whitelist().swap_remove(&token_id); } #[endpoint(mintToken)] @@ -101,7 +102,7 @@ pub trait TokenModule: fee_estimator_module::FeeEstimatorModule { } self.send().direct_esdt( - &self.blockchain().get_caller(), + &caller, token_id, 0, amount, From b10b80c489f5a3a7c7de964fde0905130413e91f Mon Sep 17 00:00:00 2001 From: dragosrebegea Date: Wed, 27 Dec 2023 12:32:05 +0200 Subject: [PATCH 30/50] add snippets for tx-with-SC-call --- multisig/interaction/config/configs.cfg | 9 +++--- .../interaction/config/menu_functions.cfg | 28 ++++++++++++++--- .../interaction/config/multisig-snippets.sh | 31 +++++++++++++++++-- .../config/multitransfer-snippets.sh | 26 ++++++++-------- multisig/interaction/config/safe-snippets.sh | 5 +-- .../interaction/config/upgrade-snippets.sh | 26 ++++++++++------ .../interaction/config/wrapped-snippets.sh | 2 +- multisig/interaction/script.sh | 8 +++++ 8 files changed, 99 insertions(+), 36 deletions(-) diff --git a/multisig/interaction/config/configs.cfg b/multisig/interaction/config/configs.cfg index 9b58c555..d72fa513 100644 --- a/multisig/interaction/config/configs.cfg +++ b/multisig/interaction/config/configs.cfg @@ -17,6 +17,7 @@ SAFE_WASM="./esdt-safe.wasm" BRIDGED_TOKENS_WRAPPER_WASM="./bridged-tokens-wrapper.wasm" MULTI_TRANSFER_WASM="./multi-transfer-esdt.wasm" MULTISIG_WASM="./multisig.wasm" +PROXY_WASM="./bridge-proxy.wasm" #============CONTRACT ADDRESSES============== @@ -38,10 +39,10 @@ CHAIN_SPECIFIC_TOKEN_DISPLAY_NAME=EthereumWrappedUSDC UNIVERSAL_TOKENS_ALREADY_MINTED=0 #============TOKENS TO BE WHITELISTED============== -UNIVERSAL_TOKEN=USDT-92ae4e -CHAIN_SPECIFIC_TOKEN=ETHUSDT-41b065 -ERC20_TOKEN=0xbe388e5276035575e672ce795a87d16976ecaacb - +UNIVERSAL_TOKEN= +CHAIN_SPECIFIC_TOKEN=MEX-a659d0 +ERC20_TOKEN=0x2E8e0BBe20Ecd819c721D164fb91F7c33BDFC756 +MINTBURN_WHITELIST=true #============BRIDGE SETTINGS============== FEE_AMOUNT=50 # value without decimals diff --git a/multisig/interaction/config/menu_functions.cfg b/multisig/interaction/config/menu_functions.cfg index e7585ccf..90fd5da7 100644 --- a/multisig/interaction/config/menu_functions.cfg +++ b/multisig/interaction/config/menu_functions.cfg @@ -5,6 +5,7 @@ source $SCRIPTPATH/config/aggregator-snippets.sh source $SCRIPTPATH/config/issue-tokens-snippets.sh source $SCRIPTPATH/config/multisig-snippets.sh source $SCRIPTPATH/config/multitransfer-snippets.sh +source $SCRIPTPATH/config/proxy-snippets.sh source $SCRIPTPATH/config/relayers-snippets.sh source $SCRIPTPATH/config/upgrade-snippets.sh source $SCRIPTPATH/config/wrapped-snippets.sh @@ -39,14 +40,17 @@ function upgrade-wrapper-chain-specific-token { } function deploy-bridge-contracts { - deploySafe - update-config SAFE ${ADDRESS} + confirmation-with-skip deploySafe confirmation-with-skip deployMultiTransfer - update-config MULTI_TRANSFER ${ADDRESS} confirmation-with-skip deployMultisig - update-config MULTISIG ${ADDRESS} + confirmation-with-skip deployBridgeProxy + confirmation-with-skip setBridgeProxyContractAddress + confirmation-with-skip setWrappingContractAddress confirmation-with-skip changeChildContractsOwnershipSafe confirmation-with-skip changeChildContractsOwnershipMultiTransfer + confirmation-with-skip changeChildContractsOwnershipProxy + confirmation-with-skip setMultiTransferOnEsdtSafe + confirmation-with-skip setEsdtSafeOnMultiTransfer } function remove-whitelist-token { @@ -84,7 +88,21 @@ function whitelist-token { confirmation-with-skip addWrappedToken confirmation-with-skip wrapper-whitelistToken confirmation-with-skip setLocalRolesEsdtSafe - confirmation-with-skip setLocalRolesMultiTransferEsdt + confirmation-with-skip addMapping + confirmation-with-skip addTokenToWhitelist + echo -e + echo "Update FEE_AMOUNT and MAX_AMOUNT in BRIDGE SETTINGS section in configs.cfg" + echo -e + confirmation-with-skip manual-update-config-file + + confirmation-with-skip submitAggregatorBatch + + confirmation-with-skip esdtSafeSetMaxBridgedAmountForToken + confirmation-with-skip multiTransferEsdtSetMaxBridgedAmountForToken +} + +function whitelist-native-token { + confirmation-with-skip setLocalRolesEsdtSafe confirmation-with-skip addMapping confirmation-with-skip addTokenToWhitelist echo -e diff --git a/multisig/interaction/config/multisig-snippets.sh b/multisig/interaction/config/multisig-snippets.sh index 2037bfc1..2cc6db27 100644 --- a/multisig/interaction/config/multisig-snippets.sh +++ b/multisig/interaction/config/multisig-snippets.sh @@ -19,6 +19,7 @@ deployMultisig() { echo "" echo "Multisig contract address: ${ADDRESS}" + update-config MULTISIG ${ADDRESS} } changeChildContractsOwnershipSafe() { @@ -30,6 +31,15 @@ changeChildContractsOwnershipSafe() { --send --proxy=${PROXY} --chain=${CHAIN_ID} } +changeChildContractsOwnershipProxy() { + CHECK_VARIABLES BRIDGE_PROXY MULTISIG + + mxpy --verbose contract call ${BRIDGE_PROXY} --recall-nonce --pem=${ALICE} \ + --gas-limit=10000000 --function="ChangeOwnerAddress" \ + --arguments ${MULTISIG} \ + --send --proxy=${PROXY} --chain=${CHAIN_ID} +} + changeChildContractsOwnershipMultiTransfer() { CHECK_VARIABLES MULTI_TRANSFER MULTISIG @@ -58,11 +68,11 @@ addMapping() { } addTokenToWhitelist() { - CHECK_VARIABLES CHAIN_SPECIFIC_TOKEN CHAIN_SPECIFIC_TOKEN_TICKER MULTISIG + CHECK_VARIABLES CHAIN_SPECIFIC_TOKEN CHAIN_SPECIFIC_TOKEN_TICKER MULTISIG MINTBURN_WHITELIST mxpy --verbose contract call ${MULTISIG} --recall-nonce --pem=${ALICE} \ --gas-limit=60000000 --function="esdtSafeAddTokenToWhitelist" \ - --arguments str:${CHAIN_SPECIFIC_TOKEN} str:${CHAIN_SPECIFIC_TOKEN_TICKER} \ + --arguments str:${CHAIN_SPECIFIC_TOKEN} str:${CHAIN_SPECIFIC_TOKEN_TICKER} ${MINTBURN_WHITELIST} \ --send --proxy=${PROXY} --chain=${CHAIN_ID} } @@ -162,3 +172,20 @@ multiTransferEsdtSetMaxBridgedAmountForToken() { --arguments str:${CHAIN_SPECIFIC_TOKEN} ${MAX} \ --send --proxy=${PROXY} --chain=${CHAIN_ID} } + + +setMultiTransferOnEsdtSafe() { + CHECK_VARIABLES MULTISIG + + mxpy --verbose contract call ${MULTISIG} --recall-nonce --pem=${ALICE} \ + --gas-limit=60000000 --function="setMultiTransferOnEsdtSafe" \ + --send --proxy=${PROXY} --chain=${CHAIN_ID} +} + +setEsdtSafeOnMultiTransfer() { + CHECK_VARIABLES MULTISIG + + mxpy --verbose contract call ${MULTISIG} --recall-nonce --pem=${ALICE} \ + --gas-limit=60000000 --function="setEsdtSafeOnMultiTransfer" \ + --send --proxy=${PROXY} --chain=${CHAIN_ID} +} \ No newline at end of file diff --git a/multisig/interaction/config/multitransfer-snippets.sh b/multisig/interaction/config/multitransfer-snippets.sh index 38304735..72a5a8cc 100644 --- a/multisig/interaction/config/multitransfer-snippets.sh +++ b/multisig/interaction/config/multitransfer-snippets.sh @@ -1,9 +1,8 @@ deployMultiTransfer() { - CHECK_VARIABLES MULTI_TRANSFER_WASM BRIDGED_TOKENS_WRAPPER + CHECK_VARIABLES MULTI_TRANSFER_WASM mxpy --verbose contract deploy --bytecode=${MULTI_TRANSFER_WASM} --recall-nonce --pem=${ALICE} \ - --gas-limit=100000000 \ - --arguments ${BRIDGED_TOKENS_WRAPPER} --metadata-payable \ + --gas-limit=100000000 --metadata-payable \ --send --outfile="deploy-multitransfer-testnet.interaction.json" --proxy=${PROXY} --chain=${CHAIN_ID} || return ADDRESS=$(mxpy data parse --file="./deploy-multitransfer-testnet.interaction.json" --expression="data['contractAddress']") @@ -11,22 +10,23 @@ deployMultiTransfer() { echo "" echo "Multi transfer contract address: ${ADDRESS}" + update-config MULTI_TRANSFER ${ADDRESS} } -setLocalRolesMultiTransferEsdt() { - CHECK_VARIABLES ESDT_SYSTEM_SC_ADDRESS CHAIN_SPECIFIC_TOKEN MULTI_TRANSFER +setBridgeProxyContractAddress() { + CHECK_VARIABLES MULTI_TRANSFER BRIDGE_PROXY - mxpy --verbose contract call ${ESDT_SYSTEM_SC_ADDRESS} --recall-nonce --pem=${ALICE} \ - --gas-limit=60000000 --function="setSpecialRole" \ - --arguments str:${CHAIN_SPECIFIC_TOKEN} ${MULTI_TRANSFER} str:ESDTRoleLocalMint \ + mxpy --verbose contract call ${MULTI_TRANSFER} --recall-nonce --pem=${ALICE} \ + --gas-limit=60000000 --function="setBridgeProxyContractAddress" \ + --arguments ${BRIDGE_PROXY} \ --send --proxy=${PROXY} --chain=${CHAIN_ID} } -unsetLocalRolesMultiTransferEsdt() { - CHECK_VARIABLES ESDT_SYSTEM_SC_ADDRESS CHAIN_SPECIFIC_TOKEN MULTI_TRANSFER +setWrappingContractAddress() { + CHECK_VARIABLES MULTI_TRANSFER BRIDGED_TOKENS_WRAPPER - mxpy --verbose contract call ${ESDT_SYSTEM_SC_ADDRESS} --recall-nonce --pem=${ALICE} \ - --gas-limit=60000000 --function="unSetSpecialRole" \ - --arguments str:${CHAIN_SPECIFIC_TOKEN} ${MULTI_TRANSFER} str:ESDTRoleLocalMint \ + mxpy --verbose contract call ${MULTI_TRANSFER} --recall-nonce --pem=${ALICE} \ + --gas-limit=60000000 --function="setWrappingContractAddress" \ + --arguments ${BRIDGED_TOKENS_WRAPPER} \ --send --proxy=${PROXY} --chain=${CHAIN_ID} } \ No newline at end of file diff --git a/multisig/interaction/config/safe-snippets.sh b/multisig/interaction/config/safe-snippets.sh index 636c5cbc..57e6ad6d 100644 --- a/multisig/interaction/config/safe-snippets.sh +++ b/multisig/interaction/config/safe-snippets.sh @@ -14,6 +14,7 @@ deploySafe() { echo "" echo "Safe contract address: ${ADDRESS}" + update-config SAFE ${ADDRESS} } setLocalRolesEsdtSafe() { @@ -21,7 +22,7 @@ setLocalRolesEsdtSafe() { mxpy --verbose contract call ${ESDT_SYSTEM_SC_ADDRESS} --recall-nonce --pem=${ALICE} \ --gas-limit=60000000 --function="setSpecialRole" \ - --arguments str:${CHAIN_SPECIFIC_TOKEN} ${SAFE} str:ESDTRoleLocalBurn \ + --arguments str:${CHAIN_SPECIFIC_TOKEN} ${SAFE} str:ESDTRoleLocalBurn str:ESDTRoleLocalMint \ --send --proxy=${PROXY} --chain=${CHAIN_ID} } @@ -30,6 +31,6 @@ unsetLocalRolesEsdtSafe() { mxpy --verbose contract call ${ESDT_SYSTEM_SC_ADDRESS} --recall-nonce --pem=${ALICE} \ --gas-limit=60000000 --function="unSetSpecialRole" \ - --arguments str:${CHAIN_SPECIFIC_TOKEN} ${SAFE} str:ESDTRoleLocalBurn \ + --arguments str:${CHAIN_SPECIFIC_TOKEN} ${SAFE} str:ESDTRoleLocalBurn str:ESDTRoleLocalMint \ --send --proxy=${PROXY} --chain=${CHAIN_ID} } \ No newline at end of file diff --git a/multisig/interaction/config/upgrade-snippets.sh b/multisig/interaction/config/upgrade-snippets.sh index 5eeb077f..f2a6090d 100644 --- a/multisig/interaction/config/upgrade-snippets.sh +++ b/multisig/interaction/config/upgrade-snippets.sh @@ -39,15 +39,23 @@ upgrade() { } upgradeMultisig() { - getMultiTransferEsdtAddressHex - getEsdtSafeAddressHex - getMultiTransferEsdtAddressHex + CHECK_VARIABLES RELAYER_ADDR_0 RELAYER_ADDR_1 RELAYER_ADDR_2 RELAYER_ADDR_3 \ + RELAYER_ADDR_4 RELAYER_ADDR_5 RELAYER_ADDR_6 RELAYER_ADDR_7 RELAYER_ADDR_8 \ + RELAYER_ADDR_9 SAFE MULTI_TRANSFER RELAYER_REQUIRED_STAKE SLASH_AMOUNT QUORUM MULTISIG MULTISIG_WASM - local SLASH_AMOUNT=0x00 # 0 MIN_STAKE=$(echo "$RELAYER_REQUIRED_STAKE*10^18" | bc) - mxpy --verbose contract upgrade ${ADDRESS} --bytecode=../output/multisig.wasm --recall-nonce --pem=${ALICE} \ - --arguments 0x${ESDT_SAFE_ADDRESS_HEX} 0x${MULTI_TRANSFER_ESDT_ADDRESS_HEX} \ - ${local} ${SLASH_AMOUNT} 0x07 \ - --gas-limit=200000000 --send --outfile="upgrade-multisig.json" --proxy=${PROXY} --chain=${CHAIN_ID} || return - + mxpy --verbose contract upgrade ${MULTISIG} --bytecode=${MULTISIG_WASM} --recall-nonce --pem=${ALICE} \ + --gas-limit=200000000 \ + --arguments ${SAFE} ${MULTI_TRANSFER} \ + ${MIN_STAKE} ${SLASH_AMOUNT} ${QUORUM} \ + --send --outfile="deploy-testnet.interaction.json" --proxy=${PROXY} --chain=${CHAIN_ID} || return + + TRANSACTION=$(mxpy data parse --file="./deploy-testnet.interaction.json" --expression="data['emitted_tx']['hash']") + ADDRESS=$(mxpy data parse --file="./deploy-testnet.interaction.json" --expression="data['contractAddress']") + + mxpy data store --key=address-testnet-multisig --value=${ADDRESS} + mxpy data store --key=deployTransaction-testnet --value=${TRANSACTION} + + echo "" + echo "Multisig contract address: ${ADDRESS}" } \ No newline at end of file diff --git a/multisig/interaction/config/wrapped-snippets.sh b/multisig/interaction/config/wrapped-snippets.sh index 4985d888..ca1d7919 100644 --- a/multisig/interaction/config/wrapped-snippets.sh +++ b/multisig/interaction/config/wrapped-snippets.sh @@ -9,7 +9,7 @@ deployBridgedTokensWrapper() { CHECK_VARIABLES BRIDGED_TOKENS_WRAPPER_WASM mxpy --verbose contract deploy --bytecode=${BRIDGED_TOKENS_WRAPPER_WASM} --recall-nonce --pem=${ALICE} \ - --gas-limit=30000000 \ + --gas-limit=40000000 \ --send --outfile="deploy-bridged-tokens-wrapper-testnet.interaction.json" --proxy=${PROXY} --chain=${CHAIN_ID} || return TRANSACTION=$(mxpy data parse --file="./deploy-bridged-tokens-wrapper-testnet.interaction.json" --expression="data['emittedTransactionHash']") diff --git a/multisig/interaction/script.sh b/multisig/interaction/script.sh index ed684a2a..2f74347e 100755 --- a/multisig/interaction/script.sh +++ b/multisig/interaction/script.sh @@ -45,6 +45,14 @@ case "$1" in confirmation whitelist-token ;; +'whitelist-native-token') + echo -e + echo "Check and update TOKENS SETTINGS section in configs.cfg" + source $SCRIPTPATH/config/configs.cfg + echo -e + confirmation whitelist-native-token + ;; + 'remove-whitelist-token') echo -e echo "PREREQUIREMENTS: BRIDGED_TOKENS_WRAPPER needs to have MINT+BURN role for the UNIVERSAL TOKEN" From 6c43b9d6ed8c348296554c1b1256ec21d0949035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Wed, 27 Dec 2023 13:12:08 +0200 Subject: [PATCH 31/50] Fixes after review --- bridge-proxy/src/bridge-proxy.rs | 9 +++-- bridge-proxy/src/config.rs | 9 +++-- bridge-proxy/wasm/Cargo.toml | 1 + bridged-tokens-wrapper/wasm/Cargo.toml | 1 + common/eth-address/src/lib.rs | 7 ++-- common/token-module/src/lib.rs | 36 +++++++++---------- common/transaction/src/lib.rs | 8 +++-- esdt-safe/wasm/Cargo.toml | 1 + esdt-safe/wasm/src/lib.rs | 2 +- multi-transfer-esdt/src/lib.rs | 14 +++----- .../tests/multi_transfer_blackbox_test.rs | 3 +- multi-transfer-esdt/wasm/Cargo.toml | 1 + multi-transfer-esdt/wasm/src/lib.rs | 4 ++- multisig/src/setup.rs | 7 +++- multisig/wasm/Cargo.toml | 1 + multisig/wasm/src/lib.rs | 4 ++- 16 files changed, 63 insertions(+), 45 deletions(-) diff --git a/bridge-proxy/src/bridge-proxy.rs b/bridge-proxy/src/bridge-proxy.rs index c86e809e..5742fcbf 100644 --- a/bridge-proxy/src/bridge-proxy.rs +++ b/bridge-proxy/src/bridge-proxy.rs @@ -63,9 +63,14 @@ pub trait BridgeProxyContract: config::ConfigModule { for failed_tx_loop in self.eth_failed_transaction_list().into_iter() { let failed_tx = failed_tx_loop.get_value_as_ref(); - all_payments.push(EsdtTokenPayment::new(failed_tx.token_id.clone(), failed_tx.nonce, failed_tx.amount.clone())); + all_payments.push(EsdtTokenPayment::new( + failed_tx.token_id.clone(), + failed_tx.nonce, + failed_tx.amount.clone(), + )); } - self.send().direct_multi(&self.multi_transfer_address().get(), &all_payments); + self.send() + .direct_multi(&self.multi_transfer_address().get(), &all_payments); result } diff --git a/bridge-proxy/src/config.rs b/bridge-proxy/src/config.rs index 1cedabe2..ad6f69bc 100644 --- a/bridge-proxy/src/config.rs +++ b/bridge-proxy/src/config.rs @@ -1,13 +1,16 @@ multiversx_sc::imports!(); multiversx_sc::derive_imports!(); -use transaction::{EthTransactionPayment, EthTransaction}; +use transaction::{EthTransaction, EthTransactionPayment}; #[multiversx_sc::module] pub trait ConfigModule { #[only_owner] #[endpoint(setupMultiTransfer)] - fn set_multi_transfer_contract_address(&self, opt_multi_transfer_address: OptionalValue) { + fn set_multi_transfer_contract_address( + &self, + opt_multi_transfer_address: OptionalValue, + ) { match opt_multi_transfer_address { OptionalValue::Some(sc_addr) => { require!( @@ -25,7 +28,7 @@ pub trait ConfigModule { let eth_tx_list = self.eth_transaction_list(); match eth_tx_list.get_node_by_id(id) { Some(tx) => tx.get_value_cloned().eth_tx, - None => sc_panic!("No transaction with this id!") + None => sc_panic!("No transaction with this id!"), } } diff --git a/bridge-proxy/wasm/Cargo.toml b/bridge-proxy/wasm/Cargo.toml index 91ff88f5..d9712db0 100644 --- a/bridge-proxy/wasm/Cargo.toml +++ b/bridge-proxy/wasm/Cargo.toml @@ -19,6 +19,7 @@ opt-level = "z" lto = true debug = false panic = "abort" +overflow-checks = false [dependencies.bridge-proxy] path = ".." diff --git a/bridged-tokens-wrapper/wasm/Cargo.toml b/bridged-tokens-wrapper/wasm/Cargo.toml index 2c6f92a5..5b34a7c3 100644 --- a/bridged-tokens-wrapper/wasm/Cargo.toml +++ b/bridged-tokens-wrapper/wasm/Cargo.toml @@ -19,6 +19,7 @@ opt-level = "z" lto = true debug = false panic = "abort" +overflow-checks = false [dependencies.bridged-tokens-wrapper] path = ".." diff --git a/common/eth-address/src/lib.rs b/common/eth-address/src/lib.rs index 878d94ab..a20ec78f 100644 --- a/common/eth-address/src/lib.rs +++ b/common/eth-address/src/lib.rs @@ -9,7 +9,9 @@ use multiversx_sc::{ pub const ETH_ADDRESS_LEN: usize = 20; /// Wrapper over a 20-byte array -#[derive(TypeAbi, TopEncode, TopDecode, NestedEncode, NestedDecode, Clone, ManagedVecItem, PartialEq)] +#[derive( + TypeAbi, TopEncode, TopDecode, NestedEncode, NestedDecode, Clone, ManagedVecItem, PartialEq, +)] pub struct EthAddress { pub raw_addr: ManagedByteArray, } @@ -24,5 +26,4 @@ impl EthAddress { pub fn as_managed_buffer(&self) -> &ManagedBuffer { self.raw_addr.as_managed_buffer() } - -} \ No newline at end of file +} diff --git a/common/token-module/src/lib.rs b/common/token-module/src/lib.rs index 61133d5d..78f19203 100644 --- a/common/token-module/src/lib.rs +++ b/common/token-module/src/lib.rs @@ -92,21 +92,27 @@ pub trait TokenModule: fee_estimator_module::FeeEstimatorModule { } #[endpoint(mintToken)] - fn mint_token(&self, token_id: &TokenIdentifier, amount: &BigUint) { + fn mint_token(&self, token_id: &TokenIdentifier, amount: &BigUint) -> EsdtTokenPayment { let caller = self.blockchain().get_caller(); - require!(caller == self.multi_transfer_contract_address().get(), "Only MultiTransfer can get tokens"); + require!( + caller == self.multi_transfer_contract_address().get(), + "Only MultiTransfer can get tokens" + ); if self.mint_burn_allowed(token_id).get() { - self.accumulated_burned_tokens(token_id) - .update(|burned| *burned -= amount); + let accumulated_burned_tokens_mapper = self.accumulated_burned_tokens(token_id); + require!( + !accumulated_burned_tokens_mapper.is_empty(), + "Accumulated burned tokens storage is not initialized!" + ); + accumulated_burned_tokens_mapper.update(|burned| { + require!(*burned >= *amount, "Not enough accumulated burned tokens!"); + *burned -= amount; + }); self.mint_esdt_token(token_id, amount); } - self.send().direct_esdt( - &caller, - token_id, - 0, - amount, - ); + self.send().direct_esdt(&caller, token_id, 0, amount); + EsdtTokenPayment::new(token_id.clone(), 0, amount.clone()) } // private @@ -144,11 +150,6 @@ pub trait TokenModule: fee_estimator_module::FeeEstimatorModule { fn set_multi_transfer_contract_address(&self, opt_new_address: OptionalValue) { match opt_new_address { OptionalValue::Some(sc_addr) => { - require!( - self.blockchain().is_smart_contract(&sc_addr), - "Invalid multi transfer contract address" - ); - self.multi_transfer_contract_address().set(&sc_addr); } OptionalValue::None => self.multi_transfer_contract_address().clear(), @@ -178,8 +179,5 @@ pub trait TokenModule: fee_estimator_module::FeeEstimatorModule { #[view(getAccumulatedBurnedTokens)] #[storage_mapper("accumulatedBurnedTokens")] - fn accumulated_burned_tokens( - &self, - token_id: &TokenIdentifier, - ) -> SingleValueMapper; + fn accumulated_burned_tokens(&self, token_id: &TokenIdentifier) -> SingleValueMapper; } diff --git a/common/transaction/src/lib.rs b/common/transaction/src/lib.rs index 68d3a2a8..6e7e3028 100644 --- a/common/transaction/src/lib.rs +++ b/common/transaction/src/lib.rs @@ -26,7 +26,9 @@ pub type TxAsMultiValue = MultiValue6< pub type PaymentsVec = ManagedVec>; pub type TxBatchSplitInFields = MultiValue2>>; -#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, ManagedVecItem, Clone, PartialEq)] +#[derive( + TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, ManagedVecItem, Clone, PartialEq, +)] pub struct EthTransaction { pub from: EthAddress, pub to: ManagedAddress, @@ -47,7 +49,9 @@ pub type EthTxAsMultiValue = MultiValue7< u64, >; -#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, ManagedVecItem, Clone, PartialEq)] +#[derive( + TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, ManagedVecItem, Clone, PartialEq, +)] pub struct EthTransactionPayment { pub token_id: TokenIdentifier, pub nonce: u64, diff --git a/esdt-safe/wasm/Cargo.toml b/esdt-safe/wasm/Cargo.toml index 42193d74..82102221 100644 --- a/esdt-safe/wasm/Cargo.toml +++ b/esdt-safe/wasm/Cargo.toml @@ -19,6 +19,7 @@ opt-level = "z" lto = true debug = false panic = "abort" +overflow-checks = false [dependencies.esdt-safe] path = ".." diff --git a/esdt-safe/wasm/src/lib.rs b/esdt-safe/wasm/src/lib.rs index 5f3dc08b..ee3e2fbc 100644 --- a/esdt-safe/wasm/src/lib.rs +++ b/esdt-safe/wasm/src/lib.rs @@ -41,7 +41,7 @@ multiversx_sc_wasm_adapter::endpoints! { mintToken => mint_token setMultiTransferContractAddress => set_multi_transfer_contract_address getAllKnownTokens => token_whitelist - isWhitelistedTokenMintBurn => mint_burn_allowed + isMintBurnAllowed => mint_burn_allowed getMultiTransferContractAddress => multi_transfer_contract_address getAccumulatedTransactionFees => accumulated_transaction_fees getAccumulatedBurnedTokens => accumulated_burned_tokens diff --git a/multi-transfer-esdt/src/lib.rs b/multi-transfer-esdt/src/lib.rs index 659c0af6..dcc6f456 100644 --- a/multi-transfer-esdt/src/lib.rs +++ b/multi-transfer-esdt/src/lib.rs @@ -2,10 +2,10 @@ multiversx_sc::imports!(); +use token_module::ProxyTrait as OtherProxyTrait; use transaction::{ EthTransaction, EthTransactionPayment, PaymentsVec, Transaction, TxBatchSplitInFields, }; -use token_module::ProxyTrait as OtherProxyTrait; const DEFAULT_MAX_TX_BATCH_SIZE: usize = 10; const DEFAULT_MAX_TX_BATCH_BLOCK_DURATION: u64 = u64::MAX; @@ -67,7 +67,7 @@ pub trait MultiTransferEsdt: continue; } - let _: IgnoreValue = self + let minted_token = self .get_esdt_safe_contract_proxy_instance() .mint_token(ð_tx.token_id, ð_tx.amount) .with_esdt_transfer((eth_tx.token_id.clone(), 0, eth_tx.amount.clone())) @@ -77,7 +77,7 @@ pub trait MultiTransferEsdt: self.transfer_performed_event(batch_id, eth_tx.tx_nonce); valid_tx_list.push(eth_tx.clone()); - valid_payments_list.push(EsdtTokenPayment::new(eth_tx.token_id, 0, eth_tx.amount)); + valid_payments_list.push(minted_token); } let payments_after_wrapping = self.wrap_tokens(valid_payments_list); @@ -137,11 +137,6 @@ pub trait MultiTransferEsdt: fn set_esdt_safe_contract_address(&self, opt_new_address: OptionalValue) { match opt_new_address { OptionalValue::Some(sc_addr) => { - require!( - self.blockchain().is_smart_contract(&sc_addr), - "Invalid esdt safe contract address" - ); - self.esdt_safe_contract_address().set(&sc_addr); } OptionalValue::None => self.esdt_safe_contract_address().clear(), @@ -219,7 +214,7 @@ pub trait MultiTransferEsdt: payments: PaymentsVec, ) { for (eth_tx, p) in transfers.iter().zip(payments.iter()) { - if self.blockchain().is_smart_contract(ð_tx.to.clone()) { + if self.blockchain().is_smart_contract(ð_tx.to) { let _: IgnoreValue = self .get_bridge_proxy_contract_proxy_instance() .deposit(ð_tx) @@ -229,7 +224,6 @@ pub trait MultiTransferEsdt: self.send() .direct_esdt(ð_tx.to, &p.token_identifier, 0, &p.amount); } - } } diff --git a/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs b/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs index ded40d99..cb29c397 100644 --- a/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs +++ b/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs @@ -316,8 +316,7 @@ fn basic_transfer_test() { .call( test.multi_transfer .batch_transfer_esdt_token(1u32, transfers), - ) - // .esdt_transfer(BRIDGE_TOKEN_ID_EXPR, 0u64, BALANCE), + ), // .esdt_transfer(BRIDGE_TOKEN_ID_EXPR, 0u64, BALANCE), ); test.world diff --git a/multi-transfer-esdt/wasm/Cargo.toml b/multi-transfer-esdt/wasm/Cargo.toml index ff8c18a0..3ae8aa59 100644 --- a/multi-transfer-esdt/wasm/Cargo.toml +++ b/multi-transfer-esdt/wasm/Cargo.toml @@ -19,6 +19,7 @@ opt-level = "z" lto = true debug = false panic = "abort" +overflow-checks = false [dependencies.multi-transfer-esdt] path = ".." diff --git a/multi-transfer-esdt/wasm/src/lib.rs b/multi-transfer-esdt/wasm/src/lib.rs index 1afddf8e..d77e27f2 100644 --- a/multi-transfer-esdt/wasm/src/lib.rs +++ b/multi-transfer-esdt/wasm/src/lib.rs @@ -10,7 +10,9 @@ // Total number of exported functions: 21 #![no_std] -#![allow(internal_features)] + +// Configuration that works with rustc < 1.73.0. +// TODO: Recommended rustc version: 1.73.0 or newer. #![feature(lang_items)] multiversx_sc_wasm_adapter::allocator!(); diff --git a/multisig/src/setup.rs b/multisig/src/setup.rs index b4119271..2dd9b0bf 100644 --- a/multisig/src/setup.rs +++ b/multisig/src/setup.rs @@ -210,7 +210,12 @@ pub trait SetupModule: ) { let _: IgnoreValue = self .get_esdt_safe_proxy_instance() - .add_token_to_whitelist(token_id, ticker, mint_burn_allowed, opt_default_price_per_gas_unit) + .add_token_to_whitelist( + token_id, + ticker, + mint_burn_allowed, + opt_default_price_per_gas_unit, + ) .execute_on_dest_context(); } diff --git a/multisig/wasm/Cargo.toml b/multisig/wasm/Cargo.toml index 4866e47c..8f4f7999 100644 --- a/multisig/wasm/Cargo.toml +++ b/multisig/wasm/Cargo.toml @@ -19,6 +19,7 @@ opt-level = "z" lto = true debug = false panic = "abort" +overflow-checks = false [dependencies.multisig] path = ".." diff --git a/multisig/wasm/src/lib.rs b/multisig/wasm/src/lib.rs index 7b00f1d3..c781b716 100644 --- a/multisig/wasm/src/lib.rs +++ b/multisig/wasm/src/lib.rs @@ -10,7 +10,9 @@ // Total number of exported functions: 65 #![no_std] -#![allow(internal_features)] + +// Configuration that works with rustc < 1.73.0. +// TODO: Recommended rustc version: 1.73.0 or newer. #![feature(lang_items)] multiversx_sc_wasm_adapter::allocator!(); From dbf666851018fbe8a0856b48958b92244e054fe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Wed, 27 Dec 2023 13:14:18 +0200 Subject: [PATCH 32/50] Framework upgrade bridge-proxy to 0.45.2 --- bridge-proxy/Cargo.toml | 5 +- bridge-proxy/meta/Cargo.toml | 3 +- bridge-proxy/wasm/Cargo.lock | 76 ++++++++++++++++++++--------- bridge-proxy/wasm/Cargo.toml | 18 ++++--- bridge-proxy/wasm/src/lib.rs | 5 +- multi-transfer-esdt/wasm/Cargo.lock | 11 +++++ multi-transfer-esdt/wasm/src/lib.rs | 4 +- multisig/wasm/Cargo.lock | 11 +++++ 8 files changed, 97 insertions(+), 36 deletions(-) diff --git a/bridge-proxy/Cargo.toml b/bridge-proxy/Cargo.toml index b9b4542d..6ef84c1f 100644 --- a/bridge-proxy/Cargo.toml +++ b/bridge-proxy/Cargo.toml @@ -7,6 +7,7 @@ publish = false [lib] path = "src/bridge-proxy.rs" + [dependencies.transaction] path = "../common/transaction" @@ -14,10 +15,10 @@ path = "../common/transaction" path = "../common/eth-address" [dependencies.multiversx-sc] -version = "0.42.0" +version = "0.45.2" [dev-dependencies] num-bigint = "0.4.2" [dev-dependencies.multiversx-sc-scenario] -version = "0.42.0" +version = "0.45.2" diff --git a/bridge-proxy/meta/Cargo.toml b/bridge-proxy/meta/Cargo.toml index 2d75f6e4..6ad8ed05 100644 --- a/bridge-proxy/meta/Cargo.toml +++ b/bridge-proxy/meta/Cargo.toml @@ -6,8 +6,9 @@ publish = false authors = ["you"] [dev-dependencies] + [dependencies.bridge-proxy] path = ".." [dependencies.multiversx-sc-meta] -version = "0.42.0" +version = "0.45.2" diff --git a/bridge-proxy/wasm/Cargo.lock b/bridge-proxy/wasm/Cargo.lock index c43b87e1..8453a20a 100644 --- a/bridge-proxy/wasm/Cargo.lock +++ b/bridge-proxy/wasm/Cargo.lock @@ -4,15 +4,22 @@ version = 3 [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" dependencies = [ "cfg-if", "once_cell", "version_check", + "zerocopy", ] +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + [[package]] name = "arrayvec" version = "0.7.4" @@ -27,9 +34,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "bitflags" -version = "1.3.2" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" [[package]] name = "bridge-proxy" @@ -69,11 +76,12 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.13.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ "ahash", + "allocator-api2", ] [[package]] @@ -84,15 +92,15 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hex-literal" -version = "0.3.4" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "multiversx-sc" -version = "0.42.0" +version = "0.45.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c22c2d1e82a357b6f397f87d475314628473b8a88882aa407234197f596786aa" +checksum = "9b2bdb196b3ff2b9f8c744ec2e026c22c8e02bc91e5c6ed09951415c47fef6b8" dependencies = [ "bitflags", "hashbrown", @@ -104,9 +112,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.18.0" +version = "0.18.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9c97dc9e9f34f836de6a56386ddbe1b9e87e20916ff86b1ea728c08e1871ac2" +checksum = "19908153158c03df4582af08f47c0eb39fb52a7dff4736b301a66acbbb9955d3" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -114,9 +122,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.18.0" +version = "0.18.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ab795364fcf0452a953e33eae7e0c22d1a6374ffeb0724d24a42727e099c6e" +checksum = "d3b03b43f9cad320992f54ed162de2ed63e3ec83ed01361e57ee9c1865fba5a2" dependencies = [ "hex", "proc-macro2", @@ -126,9 +134,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.42.0" +version = "0.45.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6d77a125ea6985b2fa5cf1a297cdb9202c5a528eebb22652cc68ab1a9305e11" +checksum = "2e60b5dce707f61376f74d713218f75326121d9f6a5f09a3a63de7aea2a92be9" dependencies = [ "hex", "proc-macro2", @@ -139,9 +147,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.42.0" +version = "0.45.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "951b0137614c8412554ccd086967c565af38b91b77a66b5d9f433801ff24e501" +checksum = "c4299660d5413d9f120bfddda8105b1f9d28f0345a72f53e5dc90732c4983e45" dependencies = [ "multiversx-sc", ] @@ -172,18 +180,18 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.32" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -206,9 +214,9 @@ checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" [[package]] name = "syn" -version = "1.0.109" +version = "2.0.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +checksum = "ee659fb5f3d355364e1f3e5bc10fb82068efbf824a1e9d1c9504244a6469ad53" dependencies = [ "proc-macro2", "quote", @@ -234,3 +242,23 @@ name = "version_check" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "zerocopy" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/bridge-proxy/wasm/Cargo.toml b/bridge-proxy/wasm/Cargo.toml index 8d6d744a..e342ed42 100644 --- a/bridge-proxy/wasm/Cargo.toml +++ b/bridge-proxy/wasm/Cargo.toml @@ -1,25 +1,31 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + [package] name = "bridge-proxy-wasm" version = "0.0.0" edition = "2018" publish = false -authors = ["you"] [lib] crate-type = ["cdylib"] -[workspace] -members = ["."] - -[dev-dependencies] [profile.release] codegen-units = 1 opt-level = "z" lto = true debug = false panic = "abort" +overflow-checks = false + [dependencies.bridge-proxy] path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.42.0" +version = "0.45.2" + +[workspace] +members = ["."] diff --git a/bridge-proxy/wasm/src/lib.rs b/bridge-proxy/wasm/src/lib.rs index 4cde9d5d..abe47c04 100644 --- a/bridge-proxy/wasm/src/lib.rs +++ b/bridge-proxy/wasm/src/lib.rs @@ -1,4 +1,4 @@ -// Code generated by the multiversx-sc multi-contract system. DO NOT EDIT. +// Code generated by the multiversx-sc build system. DO NOT EDIT. //////////////////////////////////////////////////// ////////////////// AUTO-GENERATED ////////////////// @@ -10,6 +10,9 @@ // Total number of exported functions: 10 #![no_std] + +// Configuration that works with rustc < 1.73.0. +// TODO: Recommended rustc version: 1.73.0 or newer. #![feature(lang_items)] multiversx_sc_wasm_adapter::allocator!(); diff --git a/multi-transfer-esdt/wasm/Cargo.lock b/multi-transfer-esdt/wasm/Cargo.lock index a6f561a9..27f04b9d 100644 --- a/multi-transfer-esdt/wasm/Cargo.lock +++ b/multi-transfer-esdt/wasm/Cargo.lock @@ -38,6 +38,15 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +[[package]] +name = "bridge-proxy" +version = "0.0.0" +dependencies = [ + "eth-address", + "multiversx-sc", + "transaction", +] + [[package]] name = "bridged-tokens-wrapper" version = "0.0.0" @@ -99,7 +108,9 @@ dependencies = [ name = "multi-transfer-esdt" version = "0.0.0" dependencies = [ + "bridge-proxy", "bridged-tokens-wrapper", + "eth-address", "max-bridged-amount-module", "multiversx-sc", "transaction", diff --git a/multi-transfer-esdt/wasm/src/lib.rs b/multi-transfer-esdt/wasm/src/lib.rs index 10c770ae..c7d33eb7 100644 --- a/multi-transfer-esdt/wasm/src/lib.rs +++ b/multi-transfer-esdt/wasm/src/lib.rs @@ -5,9 +5,9 @@ //////////////////////////////////////////////////// // Init: 1 -// Endpoints: 17 +// Endpoints: 18 // Async Callback (empty): 1 -// Total number of exported functions: 19 +// Total number of exported functions: 20 #![no_std] diff --git a/multisig/wasm/Cargo.lock b/multisig/wasm/Cargo.lock index b114b035..fdbb3e19 100644 --- a/multisig/wasm/Cargo.lock +++ b/multisig/wasm/Cargo.lock @@ -38,6 +38,15 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +[[package]] +name = "bridge-proxy" +version = "0.0.0" +dependencies = [ + "eth-address", + "multiversx-sc", + "transaction", +] + [[package]] name = "bridged-tokens-wrapper" version = "0.0.0" @@ -120,7 +129,9 @@ dependencies = [ name = "multi-transfer-esdt" version = "0.0.0" dependencies = [ + "bridge-proxy", "bridged-tokens-wrapper", + "eth-address", "max-bridged-amount-module", "multiversx-sc", "transaction", From a93762f9dcdc2093cf6cf73def20e8c4fd7b6f33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Wed, 27 Dec 2023 14:03:27 +0200 Subject: [PATCH 33/50] Comiling fixes --- bridge-proxy/wasm/Cargo.lock | 15 +------ multi-transfer-esdt/wasm/Cargo.lock | 68 ++++++++++++++--------------- multi-transfer-esdt/wasm/src/lib.rs | 6 +-- multisig/wasm/Cargo.lock | 3 ++ 4 files changed, 40 insertions(+), 52 deletions(-) diff --git a/bridge-proxy/wasm/Cargo.lock b/bridge-proxy/wasm/Cargo.lock index ef9e2b07..db1fc988 100644 --- a/bridge-proxy/wasm/Cargo.lock +++ b/bridge-proxy/wasm/Cargo.lock @@ -129,7 +129,7 @@ dependencies = [ "hex", "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] @@ -142,7 +142,7 @@ dependencies = [ "proc-macro2", "quote", "radix_trie", - "syn 1.0.109", + "syn", ] [[package]] @@ -212,17 +212,6 @@ version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" -[[package]] -name = "syn" -version = "2.0.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee659fb5f3d355364e1f3e5bc10fb82068efbf824a1e9d1c9504244a6469ad53" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "syn" version = "2.0.39" diff --git a/multi-transfer-esdt/wasm/Cargo.lock b/multi-transfer-esdt/wasm/Cargo.lock index f64879dc..e8fc44b3 100644 --- a/multi-transfer-esdt/wasm/Cargo.lock +++ b/multi-transfer-esdt/wasm/Cargo.lock @@ -68,6 +68,20 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" +[[package]] +name = "esdt-safe" +version = "0.0.0" +dependencies = [ + "eth-address", + "fee-estimator-module", + "max-bridged-amount-module", + "multiversx-sc", + "multiversx-sc-modules", + "token-module", + "transaction", + "tx-batch-module", +] + [[package]] name = "eth-address" version = "0.0.0" @@ -75,6 +89,13 @@ dependencies = [ "multiversx-sc", ] +[[package]] +name = "fee-estimator-module" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + [[package]] name = "hashbrown" version = "0.14.3" @@ -110,9 +131,12 @@ version = "0.0.0" dependencies = [ "bridge-proxy", "bridged-tokens-wrapper", + "esdt-safe", "eth-address", "max-bridged-amount-module", "multiversx-sc", + "multiversx-sc-modules", + "token-module", "transaction", "tx-batch-module", ] @@ -127,15 +151,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -<<<<<<< HEAD -version = "0.45.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f11b51d6a2ab0218585ed58e100c5ac2218de09490fbfc4243b5ecd0ca7f5cbc" -======= version = "0.45.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b2bdb196b3ff2b9f8c744ec2e026c22c8e02bc91e5c6ed09951415c47fef6b8" ->>>>>>> origin/mintBurn-or-locking dependencies = [ "bitflags", "hashbrown", @@ -147,15 +165,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -<<<<<<< HEAD -version = "0.18.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327b0ad1c3477cab0d7c84391439ba302238f738ef3c6e1fcd18e247fba84875" -======= version = "0.18.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19908153158c03df4582af08f47c0eb39fb52a7dff4736b301a66acbbb9955d3" ->>>>>>> origin/mintBurn-or-locking dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -163,15 +175,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -<<<<<<< HEAD -version = "0.18.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f444038e0043b8eda816b26952479c2aca3c4a643580f4337f71fb362a586db5" -======= version = "0.18.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3b03b43f9cad320992f54ed162de2ed63e3ec83ed01361e57ee9c1865fba5a2" ->>>>>>> origin/mintBurn-or-locking dependencies = [ "hex", "proc-macro2", @@ -181,15 +187,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -<<<<<<< HEAD -version = "0.45.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784f0fc505806102fe6f808b368e12fcb13096dd73c5678f09c5663230724d6f" -======= version = "0.45.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e60b5dce707f61376f74d713218f75326121d9f6a5f09a3a63de7aea2a92be9" ->>>>>>> origin/mintBurn-or-locking dependencies = [ "hex", "proc-macro2", @@ -200,30 +200,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -<<<<<<< HEAD -version = "0.45.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75cc759dda52661f2fc776dfd810a6e90e681d4697a8c866d0f23f3e068f1b29" -======= version = "0.45.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a5833f8bc88104357d38a8952d2a16c3e66080e2e512c0e7001c0c003006c475" ->>>>>>> origin/mintBurn-or-locking dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -<<<<<<< HEAD -version = "0.45.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5afb8b8cc380eabd82dc8f9b02afbab3dce16fc2b5de1dbc601fcfcf261278ba" -======= version = "0.45.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4299660d5413d9f120bfddda8105b1f9d28f0345a72f53e5dc90732c4983e45" ->>>>>>> origin/mintBurn-or-locking dependencies = [ "multiversx-sc", ] @@ -297,6 +285,14 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "token-module" +version = "0.0.0" +dependencies = [ + "fee-estimator-module", + "multiversx-sc", +] + [[package]] name = "transaction" version = "0.0.0" diff --git a/multi-transfer-esdt/wasm/src/lib.rs b/multi-transfer-esdt/wasm/src/lib.rs index 3d0b6ff9..6f0baa97 100644 --- a/multi-transfer-esdt/wasm/src/lib.rs +++ b/multi-transfer-esdt/wasm/src/lib.rs @@ -5,12 +5,12 @@ //////////////////////////////////////////////////// // Init: 1 -// Endpoints: 18 +// Endpoints: 20 // Async Callback (empty): 1 -// Total number of exported functions: 20 +// Total number of exported functions: 22 #![no_std] -#![allow(internal_features)] + // Configuration that works with rustc < 1.73.0. // TODO: Recommended rustc version: 1.73.0 or newer. #![feature(lang_items)] diff --git a/multisig/wasm/Cargo.lock b/multisig/wasm/Cargo.lock index fdbb3e19..28af16f8 100644 --- a/multisig/wasm/Cargo.lock +++ b/multisig/wasm/Cargo.lock @@ -131,9 +131,12 @@ version = "0.0.0" dependencies = [ "bridge-proxy", "bridged-tokens-wrapper", + "esdt-safe", "eth-address", "max-bridged-amount-module", "multiversx-sc", + "multiversx-sc-modules", + "token-module", "transaction", "tx-batch-module", ] From a9b512c975203ab8c73a0ac463107d575bfeb0b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Wed, 27 Dec 2023 15:03:50 +0200 Subject: [PATCH 34/50] Actions: checks trigger also on feat branches --- .github/workflows/actions.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 202f45a8..2f7c9f82 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -4,8 +4,11 @@ on: push: branches: - main + - feat/* pull_request: - branches: [ main ] + branches: + - main + - feat/* permissions: checks: write From d1767c54539c6020a56d176628b0ceffea2991a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Fri, 29 Dec 2023 14:35:44 +0200 Subject: [PATCH 35/50] Multi transfer: Batch Transfer blackbox test --- .../tests/dfp_big_uint_test.rs | 6 +- common/token-module/src/lib.rs | 10 +- esdt-safe/src/lib.rs | 22 ++- multi-transfer-esdt/src/lib.rs | 15 +- .../tests/multi_transfer_blackbox_test.rs | 177 +++++++++++------- 5 files changed, 153 insertions(+), 77 deletions(-) diff --git a/bridged-tokens-wrapper/tests/dfp_big_uint_test.rs b/bridged-tokens-wrapper/tests/dfp_big_uint_test.rs index 31a2c9b5..add8399b 100644 --- a/bridged-tokens-wrapper/tests/dfp_big_uint_test.rs +++ b/bridged-tokens-wrapper/tests/dfp_big_uint_test.rs @@ -4,7 +4,7 @@ use multiversx_sc_scenario::DebugApi; #[test] fn test_biguint() { - let _ = DebugApi::dummy(); + DebugApi::dummy(); let raw = 123456u64; let dfp = DFPBigUint::::from_raw(raw.into(), 6); let converted = dfp.clone().convert(9); @@ -12,12 +12,12 @@ fn test_biguint() { assert!(converted.clone().convert(9).to_raw() == 123456000u64); assert!(converted.clone().convert(1).to_raw() == 1u64); assert!(converted.clone().convert(3).to_raw() == 123u64); - assert!(converted.clone().convert(5).to_raw() == 12345u64); + assert!(converted.convert(5).to_raw() == 12345u64); } #[test] fn test_mandos_scenario_values() { - let _ = DebugApi::dummy(); + DebugApi::dummy(); let raw = 300000000000000u64; let dfp = DFPBigUint::::from_raw(raw.into(), 18); assert!(dfp.convert(6).to_raw() == 300u64); diff --git a/common/token-module/src/lib.rs b/common/token-module/src/lib.rs index 78f19203..b1e668b6 100644 --- a/common/token-module/src/lib.rs +++ b/common/token-module/src/lib.rs @@ -100,10 +100,6 @@ pub trait TokenModule: fee_estimator_module::FeeEstimatorModule { ); if self.mint_burn_allowed(token_id).get() { let accumulated_burned_tokens_mapper = self.accumulated_burned_tokens(token_id); - require!( - !accumulated_burned_tokens_mapper.is_empty(), - "Accumulated burned tokens storage is not initialized!" - ); accumulated_burned_tokens_mapper.update(|burned| { require!(*burned >= *amount, "Not enough accumulated burned tokens!"); *burned -= amount; @@ -156,6 +152,12 @@ pub trait TokenModule: fee_estimator_module::FeeEstimatorModule { } } + #[only_owner] + #[endpoint(setAccumulatedBurnedTokens)] + fn set_accumulated_burned_tokens(&self, token_id: &TokenIdentifier, value: BigUint) { + self.accumulated_burned_tokens(token_id).set_if_empty(value); + } + // storage #[view(getAllKnownTokens)] diff --git a/esdt-safe/src/lib.rs b/esdt-safe/src/lib.rs index 14c040b7..3adf6ae8 100644 --- a/esdt-safe/src/lib.rs +++ b/esdt-safe/src/lib.rs @@ -50,7 +50,27 @@ pub trait EsdtSafe: } #[upgrade] - fn upgrade(&self) {} + fn upgrade(&self, fee_estimator_contract_address: ManagedAddress, eth_tx_gas_limit: BigUint) { + self.fee_estimator_contract_address() + .set(&fee_estimator_contract_address); + self.eth_tx_gas_limit().set(ð_tx_gas_limit); + + self.max_tx_batch_size() + .set_if_empty(DEFAULT_MAX_TX_BATCH_SIZE); + self.max_tx_batch_block_duration() + .set_if_empty(DEFAULT_MAX_TX_BATCH_BLOCK_DURATION); + + // batch ID 0 is considered invalid + self.first_batch_id().set_if_empty(1); + self.last_batch_id().set_if_empty(1); + + // set ticker for "GWEI" + let gwei_token_id = TokenIdentifier::from(GWEI_STRING); + self.token_ticker(&gwei_token_id) + .set(gwei_token_id.as_managed_buffer()); + + self.set_paused(true); + } /// Sets the statuses for the transactions, after they were executed on the Ethereum side. /// diff --git a/multi-transfer-esdt/src/lib.rs b/multi-transfer-esdt/src/lib.rs index f2c289ea..dfa75acf 100644 --- a/multi-transfer-esdt/src/lib.rs +++ b/multi-transfer-esdt/src/lib.rs @@ -27,7 +27,15 @@ pub trait MultiTransferEsdt: } #[upgrade] - fn upgrade(&self) {} + fn upgrade(&self) { + self.max_tx_batch_size() + .set_if_empty(DEFAULT_MAX_TX_BATCH_SIZE); + self.max_tx_batch_block_duration() + .set_if_empty(DEFAULT_MAX_TX_BATCH_BLOCK_DURATION); + // batch ID 0 is considered invalid + self.first_batch_id().set_if_empty(1); + self.last_batch_id().set_if_empty(1); + } #[only_owner] #[endpoint(batchTransferEsdtToken)] @@ -48,9 +56,6 @@ pub trait MultiTransferEsdt: if eth_tx.to.is_zero() { self.transfer_failed_invalid_destination(batch_id, eth_tx.tx_nonce); must_refund = true; - } else if !self.is_local_role_set(ð_tx.token_id, &EsdtLocalRole::Mint) { - self.transfer_failed_invalid_token(batch_id, eth_tx.tx_nonce); - must_refund = true; } else if self.is_above_max_amount(ð_tx.token_id, ð_tx.amount) { self.transfer_over_max_amount(batch_id, eth_tx.tx_nonce); must_refund = true; @@ -73,7 +78,7 @@ pub trait MultiTransferEsdt: let minted_token = self .get_esdt_safe_contract_proxy_instance() .mint_token(ð_tx.token_id, ð_tx.amount) - .with_esdt_transfer((eth_tx.token_id.clone(), 0, eth_tx.amount.clone())) + // .with_esdt_transfer((eth_tx.token_id.clone(), 0, eth_tx.amount.clone())) .execute_on_dest_context(); // emit event before the actual transfer so we don't have to save the tx_nonces as well diff --git a/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs b/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs index cb29c397..fc2c2eec 100644 --- a/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs +++ b/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs @@ -1,6 +1,6 @@ #![allow(unused)] -use bridge_proxy::ProxyTrait as _; +use bridge_proxy::{config::ProxyTrait as _, ProxyTrait as _}; use bridged_tokens_wrapper::ProxyTrait as _; use esdt_safe::{EsdtSafe, ProxyTrait as _}; use multi_transfer_esdt::ProxyTrait as _; @@ -26,6 +26,7 @@ use multiversx_sc_scenario::{ }; use eth_address::*; +use token_module::ProxyTrait as _; use transaction::{EthTransaction, EthTransactionPayment}; const BRIDGE_TOKEN_ID: &[u8] = b"BRIDGE-123456"; @@ -33,7 +34,7 @@ const BRIDGE_TOKEN_ID_EXPR: &str = "str:BRIDGE-123456"; const USER_ETHEREUM_ADDRESS: &[u8] = b"0x0102030405060708091011121314151617181920"; -const GAS_LIMIT: u64 = 1_000_000; +const GAS_LIMIT: u64 = 100_000_000; const MULTI_TRANSFER_PATH_EXPR: &str = "file:output/multi-transfer-esdt.wasm"; const BRIDGE_PROXY_PATH_EXPR: &str = "file:../bridge-proxy/output/bridge-proxy.wasm"; @@ -110,6 +111,18 @@ impl MultiTransferTestState { bridged_tokens_wrapper: BridgedTokensWrapperContract::new("sc:bridged_tokens_wrapper"), }; + let multi_transfer_code = state.world.code_expression(MULTI_TRANSFER_PATH_EXPR); + let bridge_proxy_code = state.world.code_expression(BRIDGE_PROXY_PATH_EXPR); + let esdt_safe_code = state.world.code_expression(ESDT_SAFE_PATH_EXPR); + let bridged_tokens_wrapper_code = state + .world + .code_expression(BRIDGED_TOKENS_WRAPPER_PATH_EXPR); + + let roles = vec![ + "ESDTRoleLocalMint".to_string(), + "ESDTRoleLocalBurn".to_string(), + ]; + state.world.set_state_step( SetStateStep::new() .put_account( @@ -123,19 +136,20 @@ impl MultiTransferTestState { .new_address(&state.owner, 1, MULTI_TRANSFER_ADDRESS_EXPR) .new_address(&state.owner, 2, BRIDGE_PROXY_ADDRESS_EXPR) .new_address(&state.owner, 3, ESDT_SAFE_ADDRESS_EXPR) + .put_account( + ESDT_SAFE_ADDRESS_EXPR, + Account::new() + .code(&esdt_safe_code) + .owner(&state.owner) + .esdt_roles(BRIDGE_TOKEN_ID_EXPR, roles) + .esdt_balance(BRIDGE_TOKEN_ID_EXPR, "1_000"), + ) .new_address(&state.owner, 4, BRIDGED_TOKENS_WRAPPER_ADDRESS_EXPR), ); - state } fn multi_transfer_deploy(&mut self) -> &mut Self { - // let bridge_proxy_addr = self - // .bridge_proxy - // .address - // .clone() - // .unwrap_or_sc_panic("Cannot get Bridge Proxy Contract address!"); - self.world.sc_deploy( ScDeployStep::new() .from(self.owner.clone()) @@ -158,14 +172,11 @@ impl MultiTransferTestState { } fn safe_deploy(&mut self, price_aggregator_contract_address: Address) -> &mut Self { - self.world.sc_deploy( - ScDeployStep::new() - .from(self.owner.clone()) - .code(self.world.code_expression(ESDT_SAFE_PATH_EXPR)) - .call( - self.esdt_safe - .init(ManagedAddress::zero(), ESDT_SAFE_ETH_TX_GAS_LIMIT), - ), + self.world.sc_call( + ScCallStep::new().from(self.owner.clone()).call( + self.esdt_safe + .upgrade(ManagedAddress::zero(), ESDT_SAFE_ETH_TX_GAS_LIMIT), + ), ); self @@ -182,30 +193,77 @@ impl MultiTransferTestState { self } - fn config_multi_transfer( - &mut self, - bridged_tokens_wrapper_contract_address: Address, - bridge_proxy_contract_address: Address, - ) { - self.world.sc_call( - ScCallStep::new() - .from(self.owner.clone()) - .to(&self.multi_transfer) - .call( - self.multi_transfer - .set_wrapping_contract_address(bridged_tokens_wrapper_contract_address), - ), - ); - - self.world.sc_call( - ScCallStep::new() - .from(self.owner.clone()) - .to(&self.multi_transfer) - .call( - self.multi_transfer - .set_bridge_proxy_contract_address(bridge_proxy_contract_address), - ), - ); + fn config_multi_transfer(&mut self) { + self.world + .sc_call( + ScCallStep::new() + .from(self.owner.clone()) + .to(&self.multi_transfer) + .call( + self.multi_transfer.set_wrapping_contract_address( + self.bridged_tokens_wrapper.to_address(), + ), + ), + ) + .sc_call( + ScCallStep::new() + .from(self.owner.clone()) + .to(&self.multi_transfer) + .call( + self.multi_transfer + .set_bridge_proxy_contract_address(self.bridge_proxy.to_address()), + ), + ) + .sc_call( + ScCallStep::new() + .from(self.owner.clone()) + .to(&self.multi_transfer) + .call( + self.multi_transfer + .set_esdt_safe_contract_address(self.esdt_safe.to_address()), + ), + ) + .sc_call( + ScCallStep::new() + .from(self.owner.clone()) + .to(&self.esdt_safe) + .call( + self.esdt_safe + .set_multi_transfer_contract_address(self.multi_transfer.to_address()), + ), + ) + .sc_call( + ScCallStep::new() + .from(self.owner.clone()) + .to(&self.esdt_safe) + .call(self.esdt_safe.add_token_to_whitelist( + TokenIdentifier::from_esdt_bytes("BRIDGE-123456"), + "BRIDGE", + true, + BigUint::from(ESDT_SAFE_ETH_TX_GAS_LIMIT), + )), + ) + .sc_call( + ScCallStep::new() + .from(self.owner.clone()) + .to(&self.esdt_safe) + .call(self.esdt_safe.set_accumulated_burned_tokens( + TokenIdentifier::from_esdt_bytes("BRIDGE-123456"), + BigUint::from(1_000u64), + )), + ); + + //mint_burn_allowed + + // .sc_call( + // ScCallStep::new() + // .from(self.owner.clone()) + // .to(&self.bridge_proxy) + // .call( + // self.bridge_proxy + // .set_multi_transfer_contract_address(self.multi_transfer.to_address()), + // ), + // ); } } @@ -216,13 +274,9 @@ fn basic_setup_test() { test.multi_transfer_deploy(); test.bridge_proxy_deploy(); - // test.price_aggregator_deploy(); test.safe_deploy(Address::zero()); test.bridged_tokens_wrapper_deploy(); - test.config_multi_transfer( - test.bridged_tokens_wrapper.to_address(), - test.bridge_proxy.to_address(), - ); + test.config_multi_transfer(); test.world.set_state_step(SetStateStep::new().put_account( &test.owner, @@ -248,7 +302,8 @@ fn basic_setup_test() { .check_storage("str:wrappingContractAddress", "sc:bridged_tokens_wrapper") .check_storage("str:maxTxBatchBlockDuration", "0xffffffffffffffff") .check_storage("str:maxTxBatchSize", "10") - .check_storage("str:firstBatchId", "0x01"), + .check_storage("str:firstBatchId", "0x01") + .check_storage("str:esdtSafeContractAddress", "sc:esdt_safe"), ), ); } @@ -260,13 +315,9 @@ fn basic_transfer_test() { test.multi_transfer_deploy(); test.bridge_proxy_deploy(); - // test.price_aggregator_deploy(); test.safe_deploy(Address::zero()); test.bridged_tokens_wrapper_deploy(); - test.config_multi_transfer( - test.bridged_tokens_wrapper.to_address(), - test.bridge_proxy.to_address(), - ); + test.config_multi_transfer(); let eth_tx = EthTransaction { from: test.eth_user, @@ -287,27 +338,32 @@ fn basic_transfer_test() { .check_storage("str:wrappingContractAddress", "sc:bridged_tokens_wrapper") .check_storage("str:maxTxBatchBlockDuration", "0xffffffffffffffff") .check_storage("str:maxTxBatchSize", "10") - .check_storage("str:firstBatchId", "0x01"), + .check_storage("str:firstBatchId", "0x01") + .check_storage("str:esdtSafeContractAddress", "sc:esdt_safe"), ), ); let mut transfers = MultiValueEncoded::new(); - // transfers.push(eth_tx); + transfers.push(eth_tx); test.world.sc_call( ScCallStep::new() .from(&test.owner) .to(&test.esdt_safe) - .call(test.esdt_safe.unpause_endpoint()), // .esdt_transfer(bridge_token_id_expr, 0u64, 500u64), + .call(test.esdt_safe.unpause_endpoint()), ); test.world.sc_call( ScCallStep::new() .from(&test.owner) .to(&test.bridged_tokens_wrapper) - .call(test.bridged_tokens_wrapper.unpause_endpoint()), // .esdt_transfer(bridge_token_id_expr, 0u64, 500u64), + .call(test.bridged_tokens_wrapper.unpause_endpoint()), ); test.world.dump_state_step(); + let roles = vec![ + "ESDTRoleLocalMint".to_string(), + "ESDTRoleLocalBurn".to_string(), + ]; test.world.sc_call( ScCallStep::new() @@ -316,7 +372,7 @@ fn basic_transfer_test() { .call( test.multi_transfer .batch_transfer_esdt_token(1u32, transfers), - ), // .esdt_transfer(BRIDGE_TOKEN_ID_EXPR, 0u64, BALANCE), + ), ); test.world @@ -324,11 +380,4 @@ fn basic_transfer_test() { test.user1, CheckAccount::new().esdt_balance(BRIDGE_TOKEN_ID_EXPR, token_amount), )); - - // test.world.sc_query( - // ScQueryStep::new() - // .to(&test.multi_transfer) - // .call(test.multi_transfer.get_eth_transaction_by_id(1u32)) - // .expect_value(eth_tx), - // ); } From 1185594b8c4dc03192e9263270e6a8e92e931933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Fri, 29 Dec 2023 17:12:24 +0200 Subject: [PATCH 36/50] Fix go tests - replace mandos -> scenarios --- esdt-safe/scenarios/setup_accounts.scen.json | 2 +- .../scenarios/batch_transfer_with_wrapping.scen.json | 2 +- multisig/scenarios/setup.scen.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/esdt-safe/scenarios/setup_accounts.scen.json b/esdt-safe/scenarios/setup_accounts.scen.json index c6e77b27..1c2822c3 100644 --- a/esdt-safe/scenarios/setup_accounts.scen.json +++ b/esdt-safe/scenarios/setup_accounts.scen.json @@ -3,7 +3,7 @@ "steps": [ { "step": "externalSteps", - "path": "../../price-aggregator/mandos/get_latest_price_feed.scen.json" + "path": "../../price-aggregator/scenarios/get_latest_price_feed.scen.json" }, { "step": "setState", diff --git a/multi-transfer-esdt/scenarios/batch_transfer_with_wrapping.scen.json b/multi-transfer-esdt/scenarios/batch_transfer_with_wrapping.scen.json index 7a2c6c12..1a739235 100644 --- a/multi-transfer-esdt/scenarios/batch_transfer_with_wrapping.scen.json +++ b/multi-transfer-esdt/scenarios/batch_transfer_with_wrapping.scen.json @@ -3,7 +3,7 @@ "steps": [ { "step": "externalSteps", - "path": "../../bridged-tokens-wrapper/mandos/whitelist_token.scen.json" + "path": "../../bridged-tokens-wrapper/scenarios/whitelist_token.scen.json" }, { "step": "setState", diff --git a/multisig/scenarios/setup.scen.json b/multisig/scenarios/setup.scen.json index 6b7ebe5b..a57d872f 100644 --- a/multisig/scenarios/setup.scen.json +++ b/multisig/scenarios/setup.scen.json @@ -3,7 +3,7 @@ "steps": [ { "step": "externalSteps", - "path": "../../price-aggregator/mandos/oracle_gwei_in_eth_and_egld_submit.scen.json" + "path": "../../price-aggregator/scenarios/oracle_gwei_in_eth_and_egld_submit.scen.json" }, { "step": "setState", From 37772a6494dbe7e0bc95002fe5a030279cecbd32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Fri, 29 Dec 2023 20:08:39 +0200 Subject: [PATCH 37/50] Fix mandos tests --- esdt-safe/scenarios/distribute_fees.scen.json | 2 +- .../execute_batch_both_success.scen.json | 2 +- ...e_batch_one_success_one_rejected.scen.json | 2 +- .../execute_transaction_success.scen.json | 2 +- esdt-safe/scenarios/setup_accounts.scen.json | 3 +- esdt-safe/wasm/src/lib.rs | 5 +- .../batch_transfer_with_wrapping.scen.json | 248 ++++++++++++++++-- .../scenarios/setup_accounts.scen.json | 230 ++++++++++++++-- .../tests/multi_transfer_blackbox_test.rs | 5 - 9 files changed, 445 insertions(+), 54 deletions(-) diff --git a/esdt-safe/scenarios/distribute_fees.scen.json b/esdt-safe/scenarios/distribute_fees.scen.json index 30469112..fee008ef 100644 --- a/esdt-safe/scenarios/distribute_fees.scen.json +++ b/esdt-safe/scenarios/distribute_fees.scen.json @@ -43,7 +43,7 @@ "balance": "0", "esdt": { "str:BRIDGE-123456": { - "balance": "0", + "balance": "400", "roles": [ "ESDTRoleLocalBurn" ] diff --git a/esdt-safe/scenarios/execute_batch_both_success.scen.json b/esdt-safe/scenarios/execute_batch_both_success.scen.json index d8d3bdcb..ec05db60 100644 --- a/esdt-safe/scenarios/execute_batch_both_success.scen.json +++ b/esdt-safe/scenarios/execute_batch_both_success.scen.json @@ -93,7 +93,7 @@ "balance": "0", "esdt": { "str:BRIDGE-123456": { - "balance": "3,000,000", + "balance": "3,001,300", "roles": [ "ESDTRoleLocalBurn" ] diff --git a/esdt-safe/scenarios/execute_batch_one_success_one_rejected.scen.json b/esdt-safe/scenarios/execute_batch_one_success_one_rejected.scen.json index 757f5141..d94de8e8 100644 --- a/esdt-safe/scenarios/execute_batch_one_success_one_rejected.scen.json +++ b/esdt-safe/scenarios/execute_batch_one_success_one_rejected.scen.json @@ -94,7 +94,7 @@ "balance": "0", "esdt": { "str:BRIDGE-123456": { - "balance": "3,000,000", + "balance": "3,000,400", "roles": [ "ESDTRoleLocalBurn" ] diff --git a/esdt-safe/scenarios/execute_transaction_success.scen.json b/esdt-safe/scenarios/execute_transaction_success.scen.json index 71fbb4c3..7616dff9 100644 --- a/esdt-safe/scenarios/execute_transaction_success.scen.json +++ b/esdt-safe/scenarios/execute_transaction_success.scen.json @@ -64,7 +64,7 @@ "balance": "0", "esdt": { "str:BRIDGE-123456": { - "balance": "1,500,000", + "balance": "1,500,400", "roles": [ "ESDTRoleLocalBurn" ] diff --git a/esdt-safe/scenarios/setup_accounts.scen.json b/esdt-safe/scenarios/setup_accounts.scen.json index 1c2822c3..a34c4c58 100644 --- a/esdt-safe/scenarios/setup_accounts.scen.json +++ b/esdt-safe/scenarios/setup_accounts.scen.json @@ -69,7 +69,8 @@ "function": "addTokenToWhitelist", "arguments": [ "str:BRIDGE-123456", - "str:BRIDGE" + "str:BRIDGE", + "true" ], "gasLimit": "50,000,000", "gasPrice": "0" diff --git a/esdt-safe/wasm/src/lib.rs b/esdt-safe/wasm/src/lib.rs index 219cddc5..d37244cc 100644 --- a/esdt-safe/wasm/src/lib.rs +++ b/esdt-safe/wasm/src/lib.rs @@ -5,9 +5,9 @@ //////////////////////////////////////////////////// // Init: 1 -// Endpoints: 37 +// Endpoints: 38 // Async Callback (empty): 1 -// Total number of exported functions: 39 +// Total number of exported functions: 40 #![no_std] @@ -41,6 +41,7 @@ multiversx_sc_wasm_adapter::endpoints! { removeTokenFromWhitelist => remove_token_from_whitelist mintToken => mint_token setMultiTransferContractAddress => set_multi_transfer_contract_address + setAccumulatedBurnedTokens => set_accumulated_burned_tokens getAllKnownTokens => token_whitelist isMintBurnAllowed => mint_burn_allowed getMultiTransferContractAddress => multi_transfer_contract_address diff --git a/multi-transfer-esdt/scenarios/batch_transfer_with_wrapping.scen.json b/multi-transfer-esdt/scenarios/batch_transfer_with_wrapping.scen.json index 1a739235..cfde499a 100644 --- a/multi-transfer-esdt/scenarios/batch_transfer_with_wrapping.scen.json +++ b/multi-transfer-esdt/scenarios/batch_transfer_with_wrapping.scen.json @@ -22,6 +22,34 @@ "nonce": "0", "balance": "0", "storage": {} + }, + "sc:esdt-safe": { + "nonce": "0", + "esdt": { + "str:BRIDGE-123456": { + "balance": "2,000,000", + "roles": [ + "ESDTRoleLocalMint", + "ESDTRoleLocalBurn" + ] + }, + "str:USDC-aaaaaa": { + "balance": "2,000,000", + "roles": [ + "ESDTRoleLocalMint", + "ESDTRoleLocalBurn" + ] + }, + "str:USDC-cccccc": { + "balance": "2,000,000", + "roles": [ + "ESDTRoleLocalMint", + "ESDTRoleLocalBurn" + ] + } + }, + "code": "file:../../esdt-safe/output/esdt-safe.wasm", + "owner": "address:owner" } }, "newAddresses": [ @@ -50,6 +78,27 @@ "refund": "*" } }, + { + "step": "scDeploy", + "txId": "deploy-esdt-safe", + "tx": { + "from": "address:owner", + "contractCode": "file:../../esdt-safe/output/esdt-safe.wasm", + "value": "0", + "arguments": [ + "sc:price_aggregator", + "150,000" + ], + "gasLimit": "20,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, { "step": "setState", "comment": "setting local mint role", @@ -57,26 +106,6 @@ "sc:multi_transfer_esdt": { "nonce": "0", "balance": "0", - "esdt": { - "str:BRIDGE-123456": { - "balance": "0", - "roles": [ - "ESDTRoleLocalMint" - ] - }, - "str:USDC-aaaaaa": { - "balance": "0", - "roles": [ - "ESDTRoleLocalMint" - ] - }, - "str:USDC-cccccc": { - "balance": "0", - "roles": [ - "ESDTRoleLocalMint" - ] - } - }, "storage": { "str:maxTxBatchSize": "10", "str:maxTxBatchBlockDuration": "3,600", @@ -90,6 +119,182 @@ } } }, + { + "step": "scCall", + "txId": "add-token-1", + "tx": { + "from": "address:owner", + "to": "sc:esdt-safe", + "value": "0", + "function": "addTokenToWhitelist", + "arguments": [ + "str:BRIDGE-123456", + "str:BRIDGE", + "true", + "2,000,000" + ], + "gasLimit": "50,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "txId": "add-token-1", + "tx": { + "from": "address:owner", + "to": "sc:esdt-safe", + "value": "0", + "function": "addTokenToWhitelist", + "arguments": [ + "str:USDC-aaaaaa", + "str:USDC", + "true", + "2,000,000" + ], + "gasLimit": "50,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "txId": "add-token-1", + "tx": { + "from": "address:owner", + "to": "sc:esdt-safe", + "value": "0", + "function": "addTokenToWhitelist", + "arguments": [ + "str:USDC-cccccc", + "str:USDC", + "true", + "2,000,000" + ], + "gasLimit": "50,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "txId": "set-multi-transfer-contract-address", + "tx": { + "from": "address:owner", + "to": "sc:esdt-safe", + "value": "0", + "function": "setMultiTransferContractAddress", + "arguments": [ + "sc:multi_transfer_esdt" + ], + "gasLimit": "50,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "txId": "add-bridge-proxy-to-multi-transfer", + "tx": { + "from": "address:owner", + "to": "sc:multi_transfer_esdt", + "function": "setEsdtSafeContractAddress", + "arguments": [ + "sc:esdt-safe" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "txId": "set-accumulated-burned-tokens", + "tx": { + "from": "address:owner", + "to": "sc:esdt-safe", + "function": "setAccumulatedBurnedTokens", + "arguments": [ + "str:BRIDGE-123456", + "2,000,000" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "txId": "set-accumulated-burned-tokens", + "tx": { + "from": "address:owner", + "to": "sc:esdt-safe", + "function": "setAccumulatedBurnedTokens", + "arguments": [ + "str:USDC-aaaaaa", + "500" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "txId": "set-accumulated-burned-tokens", + "tx": { + "from": "address:owner", + "to": "sc:esdt-safe", + "function": "setAccumulatedBurnedTokens", + "arguments": [ + "str:USDC-cccccc", + "1,000" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, { "step": "scCall", "txId": "batch-transfer-both-executed", @@ -100,7 +305,6 @@ "function": "batchTransferEsdtToken", "arguments": [ "1", - "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:2000000", "0x0102030405060708091011121314151617181920|address:user2|nested:str:USDC-aaaaaa|biguint:500|u64:2|nested:str:data|u64:2000000", "0x0102030405060708091011121314151617181920|address:user1|nested:str:USDC-cccccc|biguint:1000|u64:3|nested:str:data|u64:2000000" ], @@ -162,4 +366,4 @@ } } ] -} +} \ No newline at end of file diff --git a/multi-transfer-esdt/scenarios/setup_accounts.scen.json b/multi-transfer-esdt/scenarios/setup_accounts.scen.json index 31310507..b968c990 100644 --- a/multi-transfer-esdt/scenarios/setup_accounts.scen.json +++ b/multi-transfer-esdt/scenarios/setup_accounts.scen.json @@ -18,6 +18,27 @@ "nonce": "0", "balance": "0", "storage": {} + }, + "sc:esdt-safe": { + "nonce": "0", + "esdt": { + "str:BRIDGE-123456": { + "balance": "1,000,000", + "roles": [ + "ESDTRoleLocalMint", + "ESDTRoleLocalBurn" + ] + }, + "str:WRAPPED-123456": { + "balance": "1,000,000", + "roles": [ + "ESDTRoleLocalMint", + "ESDTRoleLocalBurn" + ] + } + }, + "code": "file:../../esdt-safe/output/esdt-safe.wasm", + "owner": "address:owner" } }, "newAddresses": [ @@ -30,6 +51,11 @@ "creatorAddress": "address:owner", "creatorNonce": "1", "newAddress": "sc:bridge-proxy" + }, + { + "creatorAddress": "address:owner", + "creatorNonce": "2", + "newAddress": "sc:esdt-safe" } ] }, @@ -53,12 +79,35 @@ }, { "step": "scDeploy", - "txId": "deploy", + "txId": "deploy-bridge-proxy", "tx": { "from": "address:owner", "contractCode": "file:../../bridge-proxy/output/bridge-proxy.wasm", "value": "0", - "arguments": ["sc:multi_transfer_esdt"], + "arguments": [ + "sc:multi_transfer_esdt" + ], + "gasLimit": "20,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scDeploy", + "txId": "deploy-esdt-safe", + "tx": { + "from": "address:owner", + "contractCode": "file:../../esdt-safe/output/esdt-safe.wasm", + "value": "0", + "arguments": [ + "sc:price_aggregator", + "150,000" + ], "gasLimit": "20,000,000", "gasPrice": "0" }, @@ -89,11 +138,142 @@ "refund": "*" } }, + { + "step": "scCall", + "txId": "add-token-1", + "tx": { + "from": "address:owner", + "to": "sc:esdt-safe", + "value": "0", + "function": "addTokenToWhitelist", + "arguments": [ + "str:BRIDGE-123456", + "str:BRIDGE", + "true", + "150,000" + ], + "gasLimit": "50,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "txId": "add-token-1", + "tx": { + "from": "address:owner", + "to": "sc:esdt-safe", + "value": "0", + "function": "addTokenToWhitelist", + "arguments": [ + "str:WRAPPED-123456", + "str:WRAPPED", + "true", + "1,000" + ], + "gasLimit": "50,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "txId": "set-multi-transfer-contract-address", + "tx": { + "from": "address:owner", + "to": "sc:esdt-safe", + "value": "0", + "function": "setMultiTransferContractAddress", + "arguments": [ + "sc:multi_transfer_esdt" + ], + "gasLimit": "50,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "txId": "add-bridge-proxy-to-multi-transfer", + "tx": { + "from": "address:owner", + "to": "sc:multi_transfer_esdt", + "function": "setEsdtSafeContractAddress", + "arguments": [ + "sc:esdt-safe" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "txId": "set-accumulated-burned-tokens", + "tx": { + "from": "address:owner", + "to": "sc:esdt-safe", + "function": "setAccumulatedBurnedTokens", + "arguments": [ + "str:BRIDGE-123456", + "1_000_000" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "txId": "set-accumulated-burned-tokens", + "tx": { + "from": "address:owner", + "to": "sc:esdt-safe", + "function": "setAccumulatedBurnedTokens", + "arguments": [ + "str:WRAPPED-123456", + "1_000" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, { "step": "checkState", "accounts": { "address:owner": { - "nonce": "3", + "nonce": "10", "balance": "0", "storage": {} }, @@ -108,7 +288,7 @@ "storage": {} }, "sc:multi_transfer_esdt": { - "code":"file:../output/multi-transfer-esdt.wasm", + "code": "file:../output/multi-transfer-esdt.wasm", "nonce": "0", "balance": "0", "storage": { @@ -116,44 +296,54 @@ "str:lastBatchId": "1", "str:bridgeProxyContractAddress": "sc:bridge-proxy", "str:maxTxBatchSize": "10", - "str:maxTxBatchBlockDuration": "0xffffffffffffffff" + "str:maxTxBatchBlockDuration": "0xffffffffffffffff", + "str:esdtSafeContractAddress": "sc:esdt-safe" } }, "sc:bridge-proxy": { - "code":"file:../../bridge-proxy/output/bridge-proxy.wasm", + "code": "file:../../bridge-proxy/output/bridge-proxy.wasm", "nonce": "0", "balance": "0", "storage": "*" - } - } - }, - { - "step": "setState", - "comment": "setting local mint role", - "accounts": { - "sc:multi_transfer_esdt": { + }, + "sc:esdt-safe": { + "code": "file:../../esdt-safe/output/esdt-safe.wasm", "nonce": "0", "balance": "0", "esdt": { "str:BRIDGE-123456": { - "balance": "0", + "balance": "1,000,000", "roles": [ - "ESDTRoleLocalMint" + "ESDTRoleLocalMint", + "ESDTRoleLocalBurn" ] }, "str:WRAPPED-123456": { - "balance": "0", + "balance": "1,000,000", "roles": [ - "ESDTRoleLocalMint" + "ESDTRoleLocalMint", + "ESDTRoleLocalBurn" ] } }, + "storage": "*" + } + } + }, + { + "step": "setState", + "comment": "setting local mint role", + "accounts": { + "sc:multi_transfer_esdt": { + "nonce": "0", + "balance": "0", "storage": { "str:maxTxBatchSize": "10", "str:maxTxBatchBlockDuration": "3,600", "str:firstBatchId": "1", "str:lastBatchId": "1", - "str:bridgeProxyContractAddress": "sc:bridge-proxy" + "str:bridgeProxyContractAddress": "sc:bridge-proxy", + "str:esdtSafeContractAddress": "sc:esdt-safe" }, "code": "file:../output/multi-transfer-esdt.wasm", "owner": "address:owner" @@ -161,4 +351,4 @@ } } ] -} +} \ No newline at end of file diff --git a/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs b/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs index fc2c2eec..afcaf3ff 100644 --- a/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs +++ b/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs @@ -359,11 +359,6 @@ fn basic_transfer_test() { .to(&test.bridged_tokens_wrapper) .call(test.bridged_tokens_wrapper.unpause_endpoint()), ); - test.world.dump_state_step(); - let roles = vec![ - "ESDTRoleLocalMint".to_string(), - "ESDTRoleLocalBurn".to_string(), - ]; test.world.sc_call( ScCallStep::new() From a40c1c02050843105ebf5cb6fedd29a10e048cf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Wed, 3 Jan 2024 18:50:44 +0200 Subject: [PATCH 38/50] Update price-aggregator to 0.45.2 --- .../multiversx-price-aggregator-sc.abi.json | 440 ++++++++++++++++++ .../multiversx-price-aggregator-sc.wasm | Bin 0 -> 20831 bytes price-aggregator/scenarios/deploy.scen.json | 89 +++- ...acle_gwei_in_eth_and_egld_submit.scen.json | 10 +- .../scenarios/oracle_stake.scen.json | 28 ++ .../scenarios/oracle_submit.scen.json | 6 +- 6 files changed, 560 insertions(+), 13 deletions(-) create mode 100644 price-aggregator/multiversx-price-aggregator-sc.abi.json create mode 100755 price-aggregator/multiversx-price-aggregator-sc.wasm create mode 100644 price-aggregator/scenarios/oracle_stake.scen.json diff --git a/price-aggregator/multiversx-price-aggregator-sc.abi.json b/price-aggregator/multiversx-price-aggregator-sc.abi.json new file mode 100644 index 00000000..32b96429 --- /dev/null +++ b/price-aggregator/multiversx-price-aggregator-sc.abi.json @@ -0,0 +1,440 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.71.0-nightly", + "commitHash": "a2b1646c597329d0a25efa3889b66650f65de1de", + "commitDate": "2023-05-25", + "channel": "Nightly", + "short": "rustc 1.71.0-nightly (a2b1646c5 2023-05-25)" + }, + "contractCrate": { + "name": "multiversx-price-aggregator-sc", + "version": "0.45.2", + "gitVersion": "v0.45.2-2-g3aa173014" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.45.2" + } + }, + "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": [] + }, + "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": "new_round", + "inputs": [ + { + "name": "from", + "type": "bytes", + "indexed": true + }, + { + "name": "to", + "type": "bytes", + "indexed": true + }, + { + "name": "epoch", + "type": "u64", + "indexed": true + }, + { + "name": "new_round_event", + "type": "NewRoundEvent" + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": { + "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" + } + ] + } + } +} diff --git a/price-aggregator/multiversx-price-aggregator-sc.wasm b/price-aggregator/multiversx-price-aggregator-sc.wasm new file mode 100755 index 0000000000000000000000000000000000000000..5b6b425309b0bf957ec421737e6a240f3a551f96 GIT binary patch literal 20831 zcmcJXdz@WYb>GiE=e}mnotZ6ZY|D}e=Ux;%BDRnnBN@e*Ib%z*Y|9q-MM$u8J#!_^ zTe@>c!eBH4JI1^m7l#BI3Ix))Bsf5tXG>EPLUttPs^tzO+Qh; zzqQZ3Gb4)_{;0>g_ndw9UVFXQ+H3E7qSn&9i=xQA$z6IhURjBbx)rx_G>UY?MY0mw zqN5RaCGO}_))(J;*lXpRk!R_4mZ4{X!#_HnwJ!15V%S+)1^Fznc+~4cBTwRwRIf6Le$&>AcsVFfpMcckp;eJzbe`j~G(>mVPS35lM#ghZ=?rrUb2CYB#p6LEhbK?8 zCueV8JluM~Bp+*z(e-pl&h4qlsMuCOL4t>t=epDT?!4(P>DfK4x#f1DPys`FT=1Y- zjJ1Jxby^Ecn1TS@zW=U$uWe5*ciYj3=HFU$?Da9=>v|Mi5N3gsJtJY(wHomm_i5)U zQ7x{OToNU4EHYmbRbp37crxI4UM`p8sKgb|2M2LAW!HYnYPE=g=uJ{mLsdguIf}}qXroU{n_N^WGh4-#lXAI~)JDtBT~eu) zqofpU_w-x>SUenze+P^M;v$ zIWlQ*zV6B=TgyxB=o_xOybvz`v#U)n9aig9^p~!T@yxcPZ|Zrt{3|zddQo1ZwRGZ8 zd;WfWCR>=w+&vdO_%Co{O}}rs+9cXO(VCo%{>BX+IWh%9j^MfzmmWECqTM=q z9rHvT)fECKIpcl~I==@KoKjo5@7eu+AZ6@34WnfDyS(4Xg3{bNaK>auq zBx7-1V2Y+|8_WnwX&_(~eMbA4?NR!A7YlY4U<+gu?D8kxRLfJad%b^YR`Rc4v>tI0 z+YI`s?T7P8zIo=VC@PKT-}-7Tmyq&r>tb&dog^H3AN$E*Q0bp0Bx${H*Lw{^e501KOtp8BN{Fl&%g6kSy1L~L0EjDe$7M# zp_l#!e`A(3TpitI?4|4iw?D|~hNx@}c2QGtp!Qk!A zorU_LW-@V(|NN^#M#2c1@N!foc`|)LualcN7tXutMEwm&t(s>C znEsQG)bf%1Pf$qkbFme-kmaV?`NW20(VK2$2ofI zf3z8Gg$Ka7eQUZGU7$_2YuXU|q><>dCgGz-8zAzJfiWUm3^T~%Wl8$uu@(YB@M3h2 zzsB8Wgay4HpnUz3E7&6 zoTS|Mq$5xu1R3x`y7YX0X^Z&)8|+pM=Mw4Zy?u{hdT~{R@yLWrrW`fQS^fz_@IPhD zkW$o4Gr;L$t}7@>dQB9M3oi>Y`Qu-TzF(Me`BxsRS-jW^_PCP18U+P14yQGH=6@0; zG=n%ox0c`pT{NomkI#Y`3bY z03d%aR&WNTiDkAIL~~|2VR3w>QD%P7ooQ5ls5o9R<;%)@5~$BFjN{i_=q?InHQ|A1 zEx3!?8U?&<&5)8@IlM^xTp|^NISU%N-mGi-seO!VhI4h@qYpp)utX)r#p~7lstU8tD=C)m z3Yngen#1HwAJLyPs5433HYEt9-SM`VCu6a1R;*7()2Iwu+9Oeo#haUDuY?ng63r$5 zI=mWOAldY;_-N#i>f>rS(o?}yd`~JidriKtAUH) zN4Y@FLrYmc6ITlp4-BcFCDi+dR(;^QjJj-zju@*%VU0R7@yy!BLN5iO^JsIkVnVN|ABrA?UPho2dPzdBXc*ingkDDI zC9H>u%zC!#%B&|t4kd8LdLBe4^vQ!v{kCI0rHoKOMD=t+ODctyFuJED{tXN|DiK0f zH!GW(l!BTRIYjKc{yw>dyZf>=P891KRvqh*tM`#pjwG_1j`)V7=hG+#Ihl6hcvu^n zD@IwA+|V)dZ$fd>kGsBaDa`zbU84NFlU8L8rXeq_a7xNQiZrH~%-$+xVa6mY3Cmw# zTH?OqwLVJzZp&+I^-_;9O+ASGy;4p`xa!^a1M{YWmi(8orm|U6s)f;-^gp z?fs`rx@O8LTFp{qe@Msqqeb#2(QN5W@K|pGMhAB7TR#t!{18$4&fcuHoD2(BEhpO- zt}olRzFI?%F##hF99xYHJ%EQni-)))wB!L++!O#X`49Kp4b9NF%)gyvWM8DYWPFpk zXc4cmKn>wX5ocyiR#(KF9{@Hh14S98c@%d`C~UB-(aN-#qq=9!9KATRS-7ikVX1ha z%?b-e4!U2=I7_}Tju4cGx>w12k$X~Y8H%?kv-)39v{8!#3KYs+C9jvHMYMf~^T$_R z@W<&|S?hwIa;|E?!5q~i7C8U2t{IocnNdp}i;T^Zzpt5u5>B$eSw*L5$&!OZn39Gm z!MvJeMXj+~F--qPmsR{RFqC2!{lQHdp778gM=k{YS%1!Da>~Rgh4IHxeWCGo^Uu)% z)@r}NQr8x6t3=%w!h-Yfz`mrnx7a$WAVaR;olY=&6vX~MoViVoq-RL{LC+E96lFkw z5zKv`W-pdG@IfwVDDo2_ciZW2OmA3k0!*hBg-jk`e*_4EL<1sqQCromo~nL~0xI&( z5?c;a4H>!BaE!8OHcw79%QGNZrYTlcK#F-)q#_Nr>}CYlP|r#ShghzOeOZ}2A%E~x zvoh0&Ok`yOx9T0|of#ek76wxv}w<4F4T|piz7$Ywhc~Un? zCUZvKh*b&Cx&BIooIW0h#>kxQS~pvomDVXA!Tyw)f^Q^WYdH@eR#fuua`MZWkd;cB zGDzyF%m_7j_1Y$(ZeH@`eUaOuLQ^oPCw70OCJ8dvY-?m*jDKSsg3L3~Y|}Cp#Yw3p zE54sW2Q#-L8QUXi1G+|jRvJ+mVVh)V-u?p>58ZsibQu4vBhE# zR6?bcjJOl8t`6h=>X0X_4jZvbwJrn3nrKmo;|=|gFJZu&8tRFqTf!DFh*dnZ`qbTW zA!3C2XPgz84zBGv=Jz`pFWtd)eM3 z^R@mrH&1qW4t2By6{+2f;!C5LQ6D8r8T1x-eBD1*G^HMvXZy*41C?uva28R608}rH zdqGa4k~J}SU21Ids!{pRqL;)qf0?9H_nYy)WV`lFb{U#S{pDG7b+p-EmVSA?a?zIs zsT>8kYgvkmDd?{e$EwYWJO^o6QPJQ+PN9O~_UjsG9vrWzoKecrNpV0bNVWz@Dj%MF zEW^{5ibU^LtVd3+MBxfk3FgX(5h3t$aLYczZ+kr@r@F^538@BohVGd)c3-^ z-zjp_z0rt9=OZ(@qc$F!ilx^oKR`+>MWibG0F4^WO8u{n;HZ|Rg=;M=mm>0+3t|8N zUEcPQJ-Q~dGW{<~5QwFyl?6>&tvHJsd8Hq)Vz#$W*s8P6m5dOZ&56JkU0lRZzcY?Y z6!Vk`h#QprdW(Hk|BA)FE>{=(Zp~ufty%25{$d|cTI@G#d!k5EI!yLPt*wDtH4-#K zZ4)c6K*{2*Xer;dC-W+Cm|S31CFDj$`jg~UlqGk?n0Opfv+miCu&EFc?oje(RY`@C zn?{K-N)M_6RX!kS@hoYF=_7MpU#VpTPP^vXUvObwyISH%Bmb+;zZETAN?+QK?o2>)h$E_uL{H^G_FBH+ zewbDEG}W7JFv|bWTWk3yKb~%k{68bz!Fb;HkP^k8P%3Oy6atRmKIK$jB6|J0F0>l> zsKHdF_MJ+UR4M%!j!hv=jvEsJ{%^j$mN$Vv3Ss#t-&V`FQZolLs(8-I-}(QhaT~S4 ze-iEie3yil#|P8LTnIGdEc*Z`E%v`5iiq2hKV)vTk(eYytAB5xQx=R4LM%DV90f>6 z!k`UG*#Ya=iD)A73#c?S#5DXPz6yG-WEK5amZs%@04FXLCm1(AOB7ZmGat(T?(H@I z--wRff$eWPp_|3}4BH~V_U2l?S>t}!1#uQ-6k;s1Gvr@WEQ!bUryvw6A`C^J<>~a* zdn$^5#U>bzV|H}&zabV5g@sB3q{DOV_4ENzTH!9#R)Bet@~k$E~teoJ9>NBnbcPeR2t z|9Yg-(C<1{e^vi`u2J<{8a=pxm?O(fjbEACXIov(*0!xv$ip&C;}4pLlfm z!F$mC+CKb|^7EocIsaBP(<9e|@6@uK2O6{_2iqIl%;TxRz7RL5aJp z6g9LPAx+z7t@wEaUtFH>FDW{JE~8Jv2O(9?&%qmY>Jgos*ps|Ah~(`msq#Q;{jvB# zf0|8~f9d>vXcqV+`8BMTF$R(XrIue&ZD4$skMF^*N?z(Ha~B_z@jc0Rcq-jM0w#|} z1@~UguM^iL?`wiIuFIV~ycHRk^Lueqt2dmyE!~C2^^nC^ZOGLtsj0ozTS3Oc1Ym5j zWm$53)_(#ole^Q}VaVMn^EuReXPZ^6NNq^725b&xFp0mSsS;L&+stP3S9q6qCSr;? zJjgqKYduNxkG`drUt;d}n;7G;xt~JA`hXfqiiU_%SRt{N^G8|rRZt-+0u@w-va* zXUg(^pDR@~`Phys-={@r4WGdC%`?3ng>8Ey*^WAG-i^HxFm^NcK@_jThJs2TPZ}Hv z^D6pMe#GvmO!#fs1AZHqt3pqekyrTVHR^tXBGs2TVK6`dxiNF}d4dRl6+OY08NJy) z3A#Z@%J8gAL@1=4Y*-(o+WgnB8~p@nb>#PeOyobP5FhyuxD1!0JI&6Qdj3eAj1%SD zPrhnK&mj~5N(Jn|0eXsZvh8F`y!=y0u^}nii5&PLZTt;~(M3Te@jC)L*HalL0WtJA zVowI;e%u{Kv$%M-Rt@F+18zq9MScGufb`u7;)72;n57f$LBF7<=Mq~!Szcn1E6pE$ zONd+w#=j2Rw)kMu`UU<{NtE>j@qZB~Xi#yW zT7hR9Fx~!ic9P;$qn58Um{KUr9zPAQ2ODL>BIdY60E7+0;~|RiOJs!`$Px8j4)!R06zz_$SGV1< z2+Rg{$A74A*5ps?yP99mYWfS|@@e!BP-5KGoWkPaIPs6KT{HgQpg~+++rPTbuHeu( z_6R2O5qi!Ck3Me!ObompqUzd!j})B9qF}NF(@bGQ8aRDrqpq%F>|s`M2lUWGNbAbx zVpYm|T{GC0mu4HdMLb1g$b?S(nrV(GXRBoOnSDcp*-$nDi_D9nn~f2W@5PW>rn4k4 z3lpO?0P9OMtq&k90lzk1S(<4K<+gUzePbvq?@P0drxel#G)~%Bfv`HFt>@*i5IfiY>QW>;n!Hcs8?mB=D-49a0p2ND6IaVQB4 zWJAI!P(!Z)mgMx3!bRCoa0HlwH8}qnI5~#V>>ENk$1oMC@fg^1!{K^Skj#Vtx zc$#Im>lkE)+-DF(1^!q;8CY+f2tSNT`^5J~}Czm=?~k_{j1G)K3B$0#Umlmc%BMmgJ{ ziw(-GQ2;r)jkApnDPS3SfD#?*0ZmHj@T^!DCQ;5d%5N}2TMU8c+{xICGP39y)F{Zr zG6KMX0pQSM7*I2))m+}Y(ik?78w7HA9mqbwY9X3vt+q%o z|HZ9Xu4q}mD#FCOGtIgrJIax{I{d1rb!DmlKq^-wdeo&JBSNkU!z-<+NUvIXjxP)Mgbjz#?f71j_hAc~&uklg5&k zB|mroIntcCBkTy^gcupz)3N1<{>O^qMkW93J1j-iS#WrR&FYzE+Yy&oWv5MLhL4gN z4v`s>q|%An2?tAh7jgPWE|fiX+4-Az+$u}t#}waLj@aQF4#cns5DA_|1lJLqQI9~C z;+5*hwEN$3P1}JCaOGf7PgU!xj!V#p#-wXpZv79;Hx8Hm`jF z^(0D4S!Lx>zR{`)s(G#UQFgxzwy;rY2gV7t5e2a88z4gF9*+m29fykGrt=@ceF<=} zTk%_D!lO#~S2w+!A~ikO?9~93u%OVNW;>A9Yi{kRxi|hBy-Zp_!x>ltJOw%kQ*F%6 z^vYv81z=4omz{U}ITPJG#Gs=eI@FPCZ7D8asY4xMi%q9Hj1^&np*Y~N8!=`HnI16L zp0x?v?^(i+3~V}>gAajiVQ+Cllre!!4MDOeAblxxCN{4k%|KI}09%7}CP1@o`hD8k z;2EuK287Vgy|!m?-D^WV>u-%?H&0*2MZ^j+Y>?&94l}jO%0RB_>|g3i)PIikoVDsh z>&|rzp$8Cp;x1~hbZ#a%58JN-cg<8UG(LnX9sed-&SDc@`lmVx5Rx;inQ3mu!yEh& z*IF{F^ng@oS3wf={EL(y)WWK~-mDpm68w801T&az$_ZMSM5gVK)#a0`mtWT>u=&6lY=|EL|$wgaQ+0QKbo@UmUE^z$W`N>Wre zF;4${e;WsZZe_7}gWpeX;rxLH*zuXkeQM=9&t>{0$rHuVzt&Tou3eI|cZ zhI607!J$v#ThQ<+u~#tj&p0TrgdZR%Y2k*0yXaW{&Y!8}S6lTe%Kz?-8!Vy4hA(9 z?`zM=D%JT136X^P{5-{dFZ@=^{Q1v5T+3f{zT&XuK0ggeEF=lhqTIk%uo(jjS5Vmu3c#6*mbd>1?fYv|E-3JeJ+Y~*8*%5KVU z__y8hc2T`M&XA}>l8Rw`aBg&$de-(KGmFG^+nmAZm8!tpLpp4-Ru*}mnvBPoEb;)2 zw>bm?VsAr$7WydYe4F2dyj*ne?z_c;I&3BKx6%`d)cL{%=E9@y4@!z55T@@bxdCzI zagwjqflfx&H=+uiq3a}H)W@+RMvuiOv7(3!TX8b7;=5z7hX*%fb$s0vx{Wt#g&jpI z^IA{s|Ip()*%IoY@r}Tn796A3){#P}xS=Dz zJXR4j_OG*iL4}toC9AP@Bpng^)KRGzUAOl-5<*YN2#=C~jG<%k z!>E&7ZmiOZ&8ij0%wfkRm z#af>zQOTX=yJSl!T z5cG15I-@gyz!>wOA2n3Em`nLIvOW}#OY6iDZ*0+aunkK5zjYb~09{FgINt`(GB2NZR#ipDR#UumF7U`T2t z0u~HnBF3a$2Q>+XnR}hpf(rQoM;0Y^=oUA?)phCxuDaNfa0*BTeVT6KYL8~WnTrp| z$xsu?@4?B}EA2yvJZgVuWJ&W*vux<)-$Ld7Js7@S56( zV;Mbri1N`HcKZXvTGAB`)$fgjpk^kd^C-iABkw1rdbR_`Bih4n0}Qw{5a62w+H758 zEm(~{&~eCrvr&@SwA!nU@++k(O7HpG5pNG?BZ;Z+HmULB1s668UDzyKRn$j&haPTP zANPx#1|JP{v~$%Pb6>b!&O$sjao#LXKTb}Y+`nF{4ITQhl$BVy}{Lk!H^Q2__0`|NP@2Dl$S~Z{bjeNGD(vtp^ zisz-%!?9zrm_LaPHuZbb{FwlN(;ET6idynz0a*6Ue3|?=^;b0Fkm4!{P!1o=z|L#J z-yG?XOKRg?Rg%MY4it-RKGz{fT%a<4(Eo>j1dw7$&p7`U*GyD=j*5JnHJj~M?eAF9 zp7Q zYuJi@KUYn8uV3O_8N~{hMKZF*;Nx+GasY*5uSk=WG)Y(<@XK)Xr?>Zx4}}vq^44X; z3uOY4kFiR%AOD4fTtB3=D;}0uCm87s&X6}sicJz`ARK1UKp-l1hOcP2EJikzdx#0o z!BiOs{8z8%_?b5+>cNL}pU^x3N?`l~JMK*IDekv#VQ~{w{+0d1vBAw5hy2a(=ObD% zU5~3%#YmJptaKaUN190aQ89uFUTqIzp^&bcOA=tEe?5#f z5;oJ%4^JuHapCw?7; zD41%$Hd};PPzUMb?R^JsyJ_cqi?>5f?OcG?Bhynmd411(xS5+?m|fa=TCd*OIlXXf zaVKc&6;a#(sJK~2?A~nWTzldE))aJgS`TF0@Y<-;t&ZqinqC0b^i*aL1Db1*xp8qJ zP&mDmiDG-(%GBD{(DI7q#m@4)b?LNQykKbRt{ykGNk=Xov8JXo!Tyo8KS zEl=|%9A0{5_|EgD8eSJOjig%(Q<=T`C2QF$bh1LuNOG6GI_BB!Yf&m714FN$VTu+A ztW%)%n9MIPNp-U0u&mps>qNW2;gs?8U?HHB;cZROJ=_;EfJ%I+FV=Ychs`9D6U`)dfidRD|;5tw5Rq@cbI#1 z9;0hP4l^x}sVeO;A2bet{nO~e*o@?(7#w~S5IeLvo zc=3*@i#!Rodf^yZ#MH$H1sHcpuP+!SKXGqQ%P)9l_HRb{ec<-2@lH*B@tO6OCkQ*- zS;UXD>_t$Wr6BnuOxImDtvu4x3A%TWtZKxOZtpd1$E0KzeG(LNp?&6vT^(CqIBxDL z1Sye>Ih-VbwWsziOr2bu#wp2$O_gyCh2ZW-uk{wcXGe=Dif+dw+6#-z$4>;qJlR^9 bp3D{}CzlD0Q<2^{mDb;@y!ZV175)2v@`1ei literal 0 HcmV?d00001 diff --git a/price-aggregator/scenarios/deploy.scen.json b/price-aggregator/scenarios/deploy.scen.json index c7474748..fe2afaa0 100644 --- a/price-aggregator/scenarios/deploy.scen.json +++ b/price-aggregator/scenarios/deploy.scen.json @@ -10,6 +10,26 @@ "storage": {} }, "address:oracle": { + "nonce": "0", + "balance": "100", + "storage": {} + }, + "address:oracle2": { + "nonce": "0", + "balance": "0", + "storage": {} + }, + "address:oracle3": { + "nonce": "0", + "balance": "0", + "storage": {} + }, + "address:oracle4": { + "nonce": "0", + "balance": "0", + "storage": {} + }, + "address:oracle5": { "nonce": "0", "balance": "0", "storage": {} @@ -28,12 +48,19 @@ "txId": "deploy", "tx": { "from": "address:aggregator-owner", - "contractCode": "file:../price-aggregator.wasm", + "contractCode": "file:../multiversx-price-aggregator-sc.wasm", "value": "0", "arguments": [ - "1", - "0", - "address:oracle" + "str:EGLD", + "20", + "10", + "3", + "3", + "address:oracle", + "address:oracle2", + "address:oracle3", + "address:oracle4", + "address:oracle5" ], "gasLimit": "20,000,000", "gasPrice": "0" @@ -45,6 +72,52 @@ "refund": "*" } }, + { + "step": "scCall", + "txId": "oracle-set-pair", + "tx": { + "from": "address:aggregator-owner", + "to": "sc:price_aggregator", + "value": "0", + "function": "setPairDecimals", + "arguments": [ + "str:GWEI", + "str:BRIDGE", + "u8:0" + ], + "gasLimit": "40,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "txId": "oracle-set-pair", + "tx": { + "from": "address:aggregator-owner", + "to": "sc:price_aggregator", + "value": "0", + "function": "setPairDecimals", + "arguments": [ + "str:GWEI", + "str:EGLD", + "u8:0" + ], + "gasLimit": "40,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, { "step": "scCall", "txId": "unpause", @@ -69,7 +142,7 @@ "step": "checkState", "accounts": { "address:aggregator-owner": { - "nonce": "2", + "nonce": "4", "balance": "0", "storage": {} }, @@ -77,7 +150,7 @@ "nonce": "0", "balance": "0", "storage": { - "str:submission_count": "1", + "str:submission_count": "3", "str:decimals": "0", "str:oracle_status.mapped|address:oracle": { "0-total_submissions": "u64:0", @@ -85,10 +158,10 @@ }, "+": "" }, - "code": "file:../price-aggregator.wasm" + "code": "file:../multiversx-price-aggregator-sc.wasm" }, "+": {} } } ] -} +} \ No newline at end of file diff --git a/price-aggregator/scenarios/oracle_gwei_in_eth_and_egld_submit.scen.json b/price-aggregator/scenarios/oracle_gwei_in_eth_and_egld_submit.scen.json index b8bf80d3..cbf2f46c 100644 --- a/price-aggregator/scenarios/oracle_gwei_in_eth_and_egld_submit.scen.json +++ b/price-aggregator/scenarios/oracle_gwei_in_eth_and_egld_submit.scen.json @@ -15,8 +15,10 @@ "function": "submit", "arguments": [ "str:GWEI", - "str:ETH", - "1" + "str:BRIDGE", + "u64:0", + "1", + "0" ], "gasLimit": "40,000,000", "gasPrice": "0" @@ -39,7 +41,9 @@ "arguments": [ "str:GWEI", "str:EGLD", - "10" + "u64:0", + "10", + "0" ], "gasLimit": "40,000,000", "gasPrice": "0" diff --git a/price-aggregator/scenarios/oracle_stake.scen.json b/price-aggregator/scenarios/oracle_stake.scen.json new file mode 100644 index 00000000..e6efbb1e --- /dev/null +++ b/price-aggregator/scenarios/oracle_stake.scen.json @@ -0,0 +1,28 @@ +{ + "name": "oracle stake", + "steps": [ + { + "step": "externalSteps", + "path": "deploy.scen.json" + }, + { + "step": "scCall", + "txId": "oracle-stake", + "tx": { + "from": "address:oracle", + "to": "sc:price_aggregator", + "value": "100", + "function": "stake", + "arguments": [], + "gasLimit": "40,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + } + ] +} diff --git a/price-aggregator/scenarios/oracle_submit.scen.json b/price-aggregator/scenarios/oracle_submit.scen.json index 02dd2172..d791fe2e 100644 --- a/price-aggregator/scenarios/oracle_submit.scen.json +++ b/price-aggregator/scenarios/oracle_submit.scen.json @@ -3,7 +3,7 @@ "steps": [ { "step": "externalSteps", - "path": "deploy.scen.json" + "path": "oracle_stake.scen.json" }, { "step": "scCall", @@ -16,7 +16,9 @@ "arguments": [ "str:GWEI", "str:BRIDGE", - "10" + "u64:0", + "10", + "0" ], "gasLimit": "40,000,000", "gasPrice": "0" From b9958ac21ecaa657fc0a9adf33b301e6e481f45b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Thu, 4 Jan 2024 10:56:04 +0200 Subject: [PATCH 39/50] price-aggregator scenarios:Submit correctly prices --- price-aggregator/scenarios/deploy.scen.json | 10 ++-- .../scenarios/get_latest_price_feed.scen.json | 8 +-- ...acle_gwei_in_eth_and_egld_submit.scen.json | 6 +-- .../scenarios/oracle_stake.scen.json | 40 +++++++++++++- .../scenarios/oracle_submit.scen.json | 52 ++++++++++++++++++- 5 files changed, 103 insertions(+), 13 deletions(-) diff --git a/price-aggregator/scenarios/deploy.scen.json b/price-aggregator/scenarios/deploy.scen.json index fe2afaa0..78d381a0 100644 --- a/price-aggregator/scenarios/deploy.scen.json +++ b/price-aggregator/scenarios/deploy.scen.json @@ -16,12 +16,12 @@ }, "address:oracle2": { "nonce": "0", - "balance": "0", + "balance": "100", "storage": {} }, "address:oracle3": { "nonce": "0", - "balance": "0", + "balance": "100", "storage": {} }, "address:oracle4": { @@ -83,7 +83,7 @@ "arguments": [ "str:GWEI", "str:BRIDGE", - "u8:0" + "u8:6" ], "gasLimit": "40,000,000", "gasPrice": "0" @@ -105,8 +105,8 @@ "function": "setPairDecimals", "arguments": [ "str:GWEI", - "str:EGLD", - "u8:0" + "str:WEGLD-123456", + "u8:6" ], "gasLimit": "40,000,000", "gasPrice": "0" diff --git a/price-aggregator/scenarios/get_latest_price_feed.scen.json b/price-aggregator/scenarios/get_latest_price_feed.scen.json index 27ccdaa8..3b616063 100644 --- a/price-aggregator/scenarios/get_latest_price_feed.scen.json +++ b/price-aggregator/scenarios/get_latest_price_feed.scen.json @@ -22,8 +22,9 @@ "1", "str:GWEI", "str:BRIDGE", + "0", "10", - "0" + "6" ] } }, @@ -47,8 +48,9 @@ "1", "str:GWEI", "str:BRIDGE", + "0", "10", - "0" + "6" ], "status": "0", "message": "", @@ -66,7 +68,7 @@ "function": "latestPriceFeedOptional", "arguments": [ "str:RAND-TOKEN", - "str:EGLD" + "str:WEGLD-123456" ], "gasLimit": "40,000,000", "gasPrice": "0" diff --git a/price-aggregator/scenarios/oracle_gwei_in_eth_and_egld_submit.scen.json b/price-aggregator/scenarios/oracle_gwei_in_eth_and_egld_submit.scen.json index cbf2f46c..9c8c3599 100644 --- a/price-aggregator/scenarios/oracle_gwei_in_eth_and_egld_submit.scen.json +++ b/price-aggregator/scenarios/oracle_gwei_in_eth_and_egld_submit.scen.json @@ -18,7 +18,7 @@ "str:BRIDGE", "u64:0", "1", - "0" + "6" ], "gasLimit": "40,000,000", "gasPrice": "0" @@ -40,10 +40,10 @@ "function": "submit", "arguments": [ "str:GWEI", - "str:EGLD", + "str:WEGLD-123456", "u64:0", "10", - "0" + "6" ], "gasLimit": "40,000,000", "gasPrice": "0" diff --git a/price-aggregator/scenarios/oracle_stake.scen.json b/price-aggregator/scenarios/oracle_stake.scen.json index e6efbb1e..0c7c402b 100644 --- a/price-aggregator/scenarios/oracle_stake.scen.json +++ b/price-aggregator/scenarios/oracle_stake.scen.json @@ -23,6 +23,44 @@ "gas": "*", "refund": "*" } + }, + { + "step": "scCall", + "txId": "oracle-stake", + "tx": { + "from": "address:oracle2", + "to": "sc:price_aggregator", + "value": "100", + "function": "stake", + "arguments": [], + "gasLimit": "40,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "txId": "oracle-stake", + "tx": { + "from": "address:oracle3", + "to": "sc:price_aggregator", + "value": "100", + "function": "stake", + "arguments": [], + "gasLimit": "40,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } } ] -} +} \ No newline at end of file diff --git a/price-aggregator/scenarios/oracle_submit.scen.json b/price-aggregator/scenarios/oracle_submit.scen.json index d791fe2e..53d53c45 100644 --- a/price-aggregator/scenarios/oracle_submit.scen.json +++ b/price-aggregator/scenarios/oracle_submit.scen.json @@ -18,7 +18,57 @@ "str:BRIDGE", "u64:0", "10", - "0" + "6" + ], + "gasLimit": "40,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "txId": "oracle-submit", + "tx": { + "from": "address:oracle2", + "to": "sc:price_aggregator", + "value": "0", + "function": "submit", + "arguments": [ + "str:GWEI", + "str:BRIDGE", + "u64:0", + "10", + "6" + ], + "gasLimit": "40,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "txId": "oracle-submit", + "tx": { + "from": "address:oracle3", + "to": "sc:price_aggregator", + "value": "0", + "function": "submit", + "arguments": [ + "str:GWEI", + "str:BRIDGE", + "u64:0", + "10", + "6" ], "gasLimit": "40,000,000", "gasPrice": "0" From 455aaebac7dda66741e4b1d9863b65aab71b680e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Fri, 5 Jan 2024 14:56:20 +0200 Subject: [PATCH 40/50] Fix tests --- bridge-proxy/wasm/Cargo.lock | 20 ++-- bridge-proxy/wasm/src/lib.rs | 4 +- bridged-tokens-wrapper/wasm/Cargo.lock | 44 +++---- bridged-tokens-wrapper/wasm/src/lib.rs | 4 +- .../src/aggregator_proxy.rs | 6 +- common/token-module/src/lib.rs | 16 ++- esdt-safe/Cargo.toml | 3 + .../scenarios/create_another_tx_ok.scen.json | 19 +-- ...te_another_tx_too_late_for_batch.scen.json | 30 ++--- .../scenarios/create_transaction_ok.scen.json | 15 ++- ...eate_transaction_over_max_amount.scen.json | 26 ++-- esdt-safe/scenarios/setup_accounts.scen.json | 3 +- esdt-safe/scenarios/zero_fees.scen.json | 18 +-- esdt-safe/tests/esdt_safe_scenario_rs_test.rs | 92 +++++++++++++++ esdt-safe/wasm/src/lib.rs | 4 +- .../batch_transfer_with_wrapping.scen.json | 34 ++---- .../scenarios/setup_accounts.scen.json | 23 +--- multi-transfer-esdt/src/lib.rs | 10 +- .../multi_transfer_esdt_scenario_rs_test.rs | 53 +++++++++ multi-transfer-esdt/wasm/Cargo.lock | 40 +++---- multi-transfer-esdt/wasm/src/lib.rs | 4 +- multisig/Cargo.toml | 5 +- .../scenarios/change_token_config.scen.json | 10 +- ...eate_elrond_to_ethereum_tx_batch.scen.json | 67 ++++++----- .../ethereum_to_elrond_tx_batch_ok.scen.json | 14 +-- ...reum_to_elrond_tx_batch_rejected.scen.json | 42 +++---- ...cute_elrond_to_ethereum_tx_batch.scen.json | 32 ++--- ...ject_elrond_to_ethereum_tx_batch.scen.json | 42 ++++--- multisig/scenarios/setup.scen.json | 111 ++++++++++++++++-- multisig/tests/multisig_scenario_rs_test.rs | 58 +++++++++ multisig/wasm/Cargo.lock | 40 +++---- multisig/wasm/src/lib.rs | 4 +- 32 files changed, 599 insertions(+), 294 deletions(-) create mode 100644 esdt-safe/tests/esdt_safe_scenario_rs_test.rs create mode 100644 multi-transfer-esdt/tests/multi_transfer_esdt_scenario_rs_test.rs create mode 100644 multisig/tests/multisig_scenario_rs_test.rs diff --git a/bridge-proxy/wasm/Cargo.lock b/bridge-proxy/wasm/Cargo.lock index db1fc988..a29bf138 100644 --- a/bridge-proxy/wasm/Cargo.lock +++ b/bridge-proxy/wasm/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "ahash" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" +checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" dependencies = [ "cfg-if", "once_cell", @@ -174,24 +174,24 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "proc-macro2" -version = "1.0.71" +version = "1.0.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8" +checksum = "2de98502f212cfcea8d0bb305bd0f49d7ebdd75b64ba0a68f937d888f4e0d6db" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -214,9 +214,9 @@ checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "syn" -version = "2.0.39" +version = "2.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +checksum = "89456b690ff72fddcecf231caedbe615c59480c93358a93dfae7fc29e3ebbf0e" dependencies = [ "proc-macro2", "quote", diff --git a/bridge-proxy/wasm/src/lib.rs b/bridge-proxy/wasm/src/lib.rs index abe47c04..2cb3f686 100644 --- a/bridge-proxy/wasm/src/lib.rs +++ b/bridge-proxy/wasm/src/lib.rs @@ -10,9 +10,7 @@ // Total number of exported functions: 10 #![no_std] - -// Configuration that works with rustc < 1.73.0. -// TODO: Recommended rustc version: 1.73.0 or newer. +#![allow(internal_features)] #![feature(lang_items)] multiversx_sc_wasm_adapter::allocator!(); diff --git a/bridged-tokens-wrapper/wasm/Cargo.lock b/bridged-tokens-wrapper/wasm/Cargo.lock index 26ce41ff..f1d8e3cb 100644 --- a/bridged-tokens-wrapper/wasm/Cargo.lock +++ b/bridged-tokens-wrapper/wasm/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "ahash" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" +checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" dependencies = [ "cfg-if", "once_cell", @@ -22,9 +22,9 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "arrayvec" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "autocfg" @@ -174,33 +174,33 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] [[package]] name = "once_cell" -version = "1.17.1" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "proc-macro2" -version = "1.0.70" +version = "1.0.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" +checksum = "2de98502f212cfcea8d0bb305bd0f49d7ebdd75b64ba0a68f937d888f4e0d6db" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -217,15 +217,15 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.10.0" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "syn" -version = "2.0.41" +version = "2.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c8b28c477cc3bf0e7966561e3460130e1255f7a1cf71931075f1c5e7a7e269" +checksum = "89456b690ff72fddcecf231caedbe615c59480c93358a93dfae7fc29e3ebbf0e" dependencies = [ "proc-macro2", "quote", @@ -242,9 +242,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.8" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "version_check" @@ -254,18 +254,18 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "zerocopy" -version = "0.7.31" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c4061bedbb353041c12f413700357bec76df2c7e2ca8e4df8bac24c6bf68e3d" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.31" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3c129550b3e6de3fd0ba67ba5c81818f9805e58b8d7fee80a3a59d2c9fc601a" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", diff --git a/bridged-tokens-wrapper/wasm/src/lib.rs b/bridged-tokens-wrapper/wasm/src/lib.rs index 61e709b7..5377fa9a 100644 --- a/bridged-tokens-wrapper/wasm/src/lib.rs +++ b/bridged-tokens-wrapper/wasm/src/lib.rs @@ -10,9 +10,7 @@ // Total number of exported functions: 19 #![no_std] - -// Configuration that works with rustc < 1.73.0. -// TODO: Recommended rustc version: 1.73.0 or newer. +#![allow(internal_features)] #![feature(lang_items)] multiversx_sc_wasm_adapter::allocator!(); diff --git a/common/fee-estimator-module/src/aggregator_proxy.rs b/common/fee-estimator-module/src/aggregator_proxy.rs index 123254ae..d31ba305 100644 --- a/common/fee-estimator-module/src/aggregator_proxy.rs +++ b/common/fee-estimator-module/src/aggregator_proxy.rs @@ -3,7 +3,7 @@ multiversx_sc::imports!(); pub const GWEI_STRING: &[u8] = b"GWEI"; pub type AggregatorResultAsMultiValue = - MultiValue5, ManagedBuffer, BigUint, u8>; + MultiValue6, ManagedBuffer, u64, BigUint, u8>; #[multiversx_sc::proxy] pub trait Aggregator { @@ -19,18 +19,20 @@ pub struct AggregatorResult { pub round_id: u32, pub from_token_name: ManagedBuffer, pub to_token_name: ManagedBuffer, + pub timestamp: u64, pub price: BigUint, pub decimals: u8, } impl From> for AggregatorResult { fn from(multi_result: AggregatorResultAsMultiValue) -> Self { - let (round_id, from_token_name, to_token_name, price, decimals) = multi_result.into_tuple(); + let (round_id, from_token_name, to_token_name, timestamp, price, decimals) = multi_result.into_tuple(); AggregatorResult { round_id, from_token_name, to_token_name, + timestamp, price, decimals, } diff --git a/common/token-module/src/lib.rs b/common/token-module/src/lib.rs index b1e668b6..35e8d9ce 100644 --- a/common/token-module/src/lib.rs +++ b/common/token-module/src/lib.rs @@ -98,7 +98,16 @@ pub trait TokenModule: fee_estimator_module::FeeEstimatorModule { caller == self.multi_transfer_contract_address().get(), "Only MultiTransfer can get tokens" ); + if self.mint_burn_allowed(token_id).get() { + if !self + .blockchain() + .get_esdt_local_roles(token_id) + .has_role(&EsdtLocalRole::Mint) + { + return EsdtTokenPayment::new(token_id.clone(), 0, BigUint::zero()); + } + let accumulated_burned_tokens_mapper = self.accumulated_burned_tokens(token_id); accumulated_burned_tokens_mapper.update(|burned| { require!(*burned >= *amount, "Not enough accumulated burned tokens!"); @@ -107,7 +116,12 @@ pub trait TokenModule: fee_estimator_module::FeeEstimatorModule { self.mint_esdt_token(token_id, amount); } - self.send().direct_esdt(&caller, token_id, 0, amount); + let current_balance = + self.blockchain() + .get_esdt_balance(&self.blockchain().get_sc_address(), token_id, 0); + if ¤t_balance >= amount { + self.send().direct_esdt(&caller, token_id, 0, amount); + } EsdtTokenPayment::new(token_id.clone(), 0, amount.clone()) } diff --git a/esdt-safe/Cargo.toml b/esdt-safe/Cargo.toml index a7ce3334..bdbc3284 100644 --- a/esdt-safe/Cargo.toml +++ b/esdt-safe/Cargo.toml @@ -26,6 +26,9 @@ path = "../common/tx-batch-module" [dependencies.max-bridged-amount-module] path = "../common/max-bridged-amount-module" +[dependencies.multiversx-price-aggregator-sc] +version = "0.45.2" + [dependencies.multiversx-sc] version = "0.45.2" diff --git a/esdt-safe/scenarios/create_another_tx_ok.scen.json b/esdt-safe/scenarios/create_another_tx_ok.scen.json index 224c9e7a..653c581b 100644 --- a/esdt-safe/scenarios/create_another_tx_ok.scen.json +++ b/esdt-safe/scenarios/create_another_tx_ok.scen.json @@ -11,10 +11,12 @@ "tx": { "from": "address:user2", "to": "sc:esdt_safe", - "esdt": { - "tokenIdentifier": "str:BRIDGE-123456", - "value": "1,500,900" - }, + "esdtValue": [ + { + "tokenIdentifier": "str:BRIDGE-123456", + "value": "1,500,900" + } + ], "function": "createTransaction", "arguments": [ "0x0102030405060708091011121314151617181920" @@ -24,9 +26,7 @@ }, "expect": { "status": "0", - "out": [ - - ], + "out": [], "message": "", "gas": "*", "refund": "*" @@ -71,7 +71,8 @@ "str:BRIDGE-123456": { "balance": "3,001,300", "roles": [ - "ESDTRoleLocalBurn" + "ESDTRoleLocalBurn", + "ESDTRoleLocalMint" ] } }, @@ -105,4 +106,4 @@ } } ] -} +} \ No newline at end of file diff --git a/esdt-safe/scenarios/create_another_tx_too_late_for_batch.scen.json b/esdt-safe/scenarios/create_another_tx_too_late_for_batch.scen.json index c9584de9..e00dbcbb 100644 --- a/esdt-safe/scenarios/create_another_tx_too_late_for_batch.scen.json +++ b/esdt-safe/scenarios/create_another_tx_too_late_for_batch.scen.json @@ -45,10 +45,12 @@ "tx": { "from": "address:user2", "to": "sc:esdt_safe", - "esdt": { - "tokenIdentifier": "str:BRIDGE-123456", - "value": "1,500,100" - }, + "esdtValue": [ + { + "tokenIdentifier": "str:BRIDGE-123456", + "value": "1,500,100" + } + ], "function": "createTransaction", "arguments": [ "0x0102030405060708091011121314151617181920" @@ -58,9 +60,7 @@ }, "expect": { "status": "0", - "out": [ - - ], + "out": [], "message": "", "gas": "*", "refund": "*" @@ -176,10 +176,12 @@ "tx": { "from": "address:user3", "to": "sc:esdt_safe", - "esdt": { - "tokenIdentifier": "str:BRIDGE-123456", - "value": "1,500,100" - }, + "esdtValue": [ + { + "tokenIdentifier": "str:BRIDGE-123456", + "value": "1,500,100" + } + ], "function": "createTransaction", "arguments": [ "0x0102030405060708091011121314151617181920" @@ -189,9 +191,7 @@ }, "expect": { "status": "0", - "out": [ - - ], + "out": [], "message": "", "gas": "*", "refund": "*" @@ -289,4 +289,4 @@ } } ] -} +} \ No newline at end of file diff --git a/esdt-safe/scenarios/create_transaction_ok.scen.json b/esdt-safe/scenarios/create_transaction_ok.scen.json index d3e159cb..22bacf7d 100644 --- a/esdt-safe/scenarios/create_transaction_ok.scen.json +++ b/esdt-safe/scenarios/create_transaction_ok.scen.json @@ -29,10 +29,12 @@ "tx": { "from": "address:user1", "to": "sc:esdt_safe", - "esdt": { - "tokenIdentifier": "str:BRIDGE-123456", - "value": "1,500,400" - }, + "esdtValue": [ + { + "tokenIdentifier": "str:BRIDGE-123456", + "value": "1,500,400" + } + ], "function": "createTransaction", "arguments": [ "0x0102030405060708091011121314151617181920" @@ -87,7 +89,8 @@ "str:BRIDGE-123456": { "balance": "1,500,400", "roles": [ - "ESDTRoleLocalBurn" + "ESDTRoleLocalBurn", + "ESDTRoleLocalMint" ] } }, @@ -112,4 +115,4 @@ } } ] -} +} \ No newline at end of file diff --git a/esdt-safe/scenarios/create_transaction_over_max_amount.scen.json b/esdt-safe/scenarios/create_transaction_over_max_amount.scen.json index c76faa7f..44418d98 100644 --- a/esdt-safe/scenarios/create_transaction_over_max_amount.scen.json +++ b/esdt-safe/scenarios/create_transaction_over_max_amount.scen.json @@ -33,10 +33,12 @@ "tx": { "from": "address:user1", "to": "sc:esdt_safe", - "esdt": { - "tokenIdentifier": "str:BRIDGE-123456", - "value": "1,800,000" - }, + "esdtValue": [ + { + "tokenIdentifier": "str:BRIDGE-123456", + "value": "1,800,000" + } + ], "function": "createTransaction", "arguments": [ "0x0102030405060708091011121314151617181920" @@ -57,10 +59,12 @@ "tx": { "from": "address:user1", "to": "sc:esdt_safe", - "esdt": { - "tokenIdentifier": "str:BRIDGE-123456", - "value": "1,600,000" - }, + "esdtValue": [ + { + "tokenIdentifier": "str:BRIDGE-123456", + "value": "1,600,000" + } + ], "function": "createTransaction", "arguments": [ "0x0102030405060708091011121314151617181920" @@ -70,13 +74,11 @@ }, "expect": { "status": "0", - "out": [ - - ], + "out": [], "message": "", "gas": "*", "refund": "*" } } ] -} +} \ No newline at end of file diff --git a/esdt-safe/scenarios/setup_accounts.scen.json b/esdt-safe/scenarios/setup_accounts.scen.json index a34c4c58..2070b41a 100644 --- a/esdt-safe/scenarios/setup_accounts.scen.json +++ b/esdt-safe/scenarios/setup_accounts.scen.json @@ -136,7 +136,8 @@ "str:BRIDGE-123456": { "balance": "0", "roles": [ - "ESDTRoleLocalBurn" + "ESDTRoleLocalBurn", + "ESDTRoleLocalMint" ] } }, diff --git a/esdt-safe/scenarios/zero_fees.scen.json b/esdt-safe/scenarios/zero_fees.scen.json index f5d6d36d..5e573a8c 100644 --- a/esdt-safe/scenarios/zero_fees.scen.json +++ b/esdt-safe/scenarios/zero_fees.scen.json @@ -37,7 +37,8 @@ "str:BRIDGE-123456": { "balance": "0", "roles": [ - "ESDTRoleLocalBurn" + "ESDTRoleLocalBurn", + "ESDTRoleLocalMint" ] } }, @@ -56,10 +57,12 @@ "tx": { "from": "address:user1", "to": "sc:esdt_safe", - "esdt": { - "tokenIdentifier": "str:BRIDGE-123456", - "value": "1,500,400" - }, + "esdtValue": [ + { + "tokenIdentifier": "str:BRIDGE-123456", + "value": "1,500,400" + } + ], "function": "createTransaction", "arguments": [ "0x0102030405060708091011121314151617181920" @@ -93,7 +96,8 @@ "str:BRIDGE-123456": { "balance": "1,500,400", "roles": [ - "ESDTRoleLocalBurn" + "ESDTRoleLocalBurn", + "ESDTRoleLocalMint" ] } }, @@ -118,4 +122,4 @@ } } ] -} +} \ No newline at end of file diff --git a/esdt-safe/tests/esdt_safe_scenario_rs_test.rs b/esdt-safe/tests/esdt_safe_scenario_rs_test.rs new file mode 100644 index 00000000..b6a97cb3 --- /dev/null +++ b/esdt-safe/tests/esdt_safe_scenario_rs_test.rs @@ -0,0 +1,92 @@ +use multiversx_sc_scenario::*; + +fn world() -> ScenarioWorld { + let mut blockchain = ScenarioWorld::new(); + blockchain.set_current_dir_from_workspace("esdt-safe/"); + + blockchain.register_contract("file:output/esdt-safe.wasm", esdt_safe::ContractBuilder); + blockchain.register_contract("file:../price-aggregator/multiversx-price-aggregator-sc.wasm", multiversx_price_aggregator_sc::ContractBuilder); + + blockchain + +} + +#[test] +fn add_refund_batch_rs() { + world().run("scenarios/add_refund_batch.scen.json"); +} + +#[test] +fn create_another_tx_ok_rs() { + world().run("scenarios/create_another_tx_ok.scen.json"); +} + +#[test] +fn create_another_tx_too_late_for_batch_rs() { + world().run("scenarios/create_another_tx_too_late_for_batch.scen.json"); +} + +#[test] +fn create_transaction_ok_rs() { + world().run("scenarios/create_transaction_ok.scen.json"); +} + +#[test] +fn create_transaction_over_max_amount_rs() { + world().run("scenarios/create_transaction_over_max_amount.scen.json"); +} + +#[test] +fn distribute_fees_rs() { + world().run("scenarios/distribute_fees.scen.json"); +} + +#[test] +fn execute_batch_both_rejected_rs() { + world().run("scenarios/execute_batch_both_rejected.scen.json"); +} + +#[test] +fn execute_batch_both_success_rs() { + world().run("scenarios/execute_batch_both_success.scen.json"); +} + +#[test] +fn execute_batch_one_success_one_rejected_rs() { + world().run("scenarios/execute_batch_one_success_one_rejected.scen.json"); +} + +#[test] +fn execute_transaction_rejected_rs() { + world().run("scenarios/execute_transaction_rejected.scen.json"); +} + +#[test] +fn execute_transaction_success_rs() { + world().run("scenarios/execute_transaction_success.scen.json"); +} + +#[test] +fn get_next_pending_tx_rs() { + world().run("scenarios/get_next_pending_tx.scen.json"); +} + +#[test] +fn get_next_tx_batch_rs() { + world().run("scenarios/get_next_tx_batch.scen.json"); +} + +#[test] +fn get_next_tx_batch_too_early_rs() { + world().run("scenarios/get_next_tx_batch_too_early.scen.json"); +} + +#[test] +fn setup_accounts_rs() { + world().run("scenarios/setup_accounts.scen.json"); +} + +#[test] +fn zero_fees_rs() { + world().run("scenarios/zero_fees.scen.json"); +} diff --git a/esdt-safe/wasm/src/lib.rs b/esdt-safe/wasm/src/lib.rs index d37244cc..b3bc1203 100644 --- a/esdt-safe/wasm/src/lib.rs +++ b/esdt-safe/wasm/src/lib.rs @@ -10,9 +10,7 @@ // Total number of exported functions: 40 #![no_std] - -// Configuration that works with rustc < 1.73.0. -// TODO: Recommended rustc version: 1.73.0 or newer. +#![allow(internal_features)] #![feature(lang_items)] multiversx_sc_wasm_adapter::allocator!(); diff --git a/multi-transfer-esdt/scenarios/batch_transfer_with_wrapping.scen.json b/multi-transfer-esdt/scenarios/batch_transfer_with_wrapping.scen.json index cfde499a..c08275c1 100644 --- a/multi-transfer-esdt/scenarios/batch_transfer_with_wrapping.scen.json +++ b/multi-transfer-esdt/scenarios/batch_transfer_with_wrapping.scen.json @@ -78,27 +78,6 @@ "refund": "*" } }, - { - "step": "scDeploy", - "txId": "deploy-esdt-safe", - "tx": { - "from": "address:owner", - "contractCode": "file:../../esdt-safe/output/esdt-safe.wasm", - "value": "0", - "arguments": [ - "sc:price_aggregator", - "150,000" - ], - "gasLimit": "20,000,000", - "gasPrice": "0" - }, - "expect": { - "status": "0", - "message": "", - "gas": "*", - "refund": "*" - } - }, { "step": "setState", "comment": "setting local mint role", @@ -262,7 +241,7 @@ "function": "setAccumulatedBurnedTokens", "arguments": [ "str:USDC-aaaaaa", - "500" + "500,000,000,000,000" ], "gasLimit": "5,000,000", "gasPrice": "0" @@ -283,7 +262,7 @@ "function": "setAccumulatedBurnedTokens", "arguments": [ "str:USDC-cccccc", - "1,000" + "1,000,000,000,000,000" ], "gasLimit": "5,000,000", "gasPrice": "0" @@ -305,8 +284,9 @@ "function": "batchTransferEsdtToken", "arguments": [ "1", - "0x0102030405060708091011121314151617181920|address:user2|nested:str:USDC-aaaaaa|biguint:500|u64:2|nested:str:data|u64:2000000", - "0x0102030405060708091011121314151617181920|address:user1|nested:str:USDC-cccccc|biguint:1000|u64:3|nested:str:data|u64:2000000" + "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:2000000", + "0x0102030405060708091011121314151617181920|address:user2|nested:str:USDC-aaaaaa|biguint:500,000,000,000,000|u64:2|nested:str:data|u64:2000000", + "0x0102030405060708091011121314151617181920|address:user1|nested:str:USDC-cccccc|biguint:1,000,000,000,000,000|u64:3|nested:str:data|u64:2000000" ], "gasLimit": "50,000,000", "gasPrice": "0" @@ -356,8 +336,8 @@ "ESDTRoleLocalBurn" ] }, - "str:USDC-aaaaaa": "500", - "str:USDC-cccccc": "1,000" + "str:USDC-aaaaaa": "500,000,000,000,000", + "str:USDC-cccccc": "1,000,000,000,000,000" }, "storage": "*", "code": "*" diff --git a/multi-transfer-esdt/scenarios/setup_accounts.scen.json b/multi-transfer-esdt/scenarios/setup_accounts.scen.json index b968c990..f893a190 100644 --- a/multi-transfer-esdt/scenarios/setup_accounts.scen.json +++ b/multi-transfer-esdt/scenarios/setup_accounts.scen.json @@ -97,27 +97,6 @@ "refund": "*" } }, - { - "step": "scDeploy", - "txId": "deploy-esdt-safe", - "tx": { - "from": "address:owner", - "contractCode": "file:../../esdt-safe/output/esdt-safe.wasm", - "value": "0", - "arguments": [ - "sc:price_aggregator", - "150,000" - ], - "gasLimit": "20,000,000", - "gasPrice": "0" - }, - "expect": { - "status": "0", - "message": "", - "gas": "*", - "refund": "*" - } - }, { "step": "scCall", "txId": "add-bridge-proxy-to-multi-transfer", @@ -273,7 +252,7 @@ "step": "checkState", "accounts": { "address:owner": { - "nonce": "10", + "nonce": "9", "balance": "0", "storage": {} }, diff --git a/multi-transfer-esdt/src/lib.rs b/multi-transfer-esdt/src/lib.rs index dfa75acf..5b362caf 100644 --- a/multi-transfer-esdt/src/lib.rs +++ b/multi-transfer-esdt/src/lib.rs @@ -75,12 +75,18 @@ pub trait MultiTransferEsdt: continue; } - let minted_token = self + let minted_token: EsdtTokenPayment = self .get_esdt_safe_contract_proxy_instance() .mint_token(ð_tx.token_id, ð_tx.amount) - // .with_esdt_transfer((eth_tx.token_id.clone(), 0, eth_tx.amount.clone())) .execute_on_dest_context(); + if minted_token.amount == BigUint::zero() { + let refund_tx = self.convert_to_refund_tx(eth_tx); + refund_tx_list.push(refund_tx); + + continue; + } + // emit event before the actual transfer so we don't have to save the tx_nonces as well self.transfer_performed_event(batch_id, eth_tx.tx_nonce); diff --git a/multi-transfer-esdt/tests/multi_transfer_esdt_scenario_rs_test.rs b/multi-transfer-esdt/tests/multi_transfer_esdt_scenario_rs_test.rs new file mode 100644 index 00000000..cd92e808 --- /dev/null +++ b/multi-transfer-esdt/tests/multi_transfer_esdt_scenario_rs_test.rs @@ -0,0 +1,53 @@ +use multiversx_sc_scenario::*; + +fn world() -> ScenarioWorld { + let mut blockchain = ScenarioWorld::new(); + blockchain.set_current_dir_from_workspace("multi-transfer-esdt/"); + + blockchain.register_contract("file:output/multi-transfer-esdt.wasm", multi_transfer_esdt::ContractBuilder); + blockchain.register_contract("file:../esdt-safe/output/esdt-safe.wasm", esdt_safe::ContractBuilder); + blockchain.register_contract("file:../bridge-proxy/output/bridge-proxy.wasm", bridge_proxy::ContractBuilder); + blockchain.register_contract("file:../bridged-tokens-wrapper/output/bridged-tokens-wrapper.wasm", bridged_tokens_wrapper::ContractBuilder); + + blockchain +} + +#[test] +fn batch_transfer_both_executed_rs() { + world().run("scenarios/batch_transfer_both_executed.scen.json"); +} + +#[test] +fn batch_transfer_both_failed_rs() { + world().run("scenarios/batch_transfer_both_failed.scen.json"); +} + +#[test] +fn batch_transfer_one_executed_one_failed_rs() { + world().run("scenarios/batch_transfer_one_executed_one_failed.scen.json"); +} + +#[test] +fn batch_transfer_to_frozen_account_rs() { + world().run("scenarios/batch_transfer_to_frozen_account.scen.json"); +} + +#[test] +fn batch_transfer_with_wrapping_rs() { + world().run("scenarios/batch_transfer_with_wrapping.scen.json"); +} + +#[test] +fn setup_accounts_rs() { + world().run("scenarios/setup_accounts.scen.json"); +} + +#[test] +fn transfer_ok_rs() { + world().run("scenarios/transfer_ok.scen.json"); +} + +#[test] +fn two_transfers_same_token_rs() { + world().run("scenarios/two_transfers_same_token.scen.json"); +} diff --git a/multi-transfer-esdt/wasm/Cargo.lock b/multi-transfer-esdt/wasm/Cargo.lock index e8fc44b3..6abca25d 100644 --- a/multi-transfer-esdt/wasm/Cargo.lock +++ b/multi-transfer-esdt/wasm/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "ahash" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" +checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" dependencies = [ "cfg-if", "once_cell", @@ -227,33 +227,33 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "proc-macro2" -version = "1.0.70" +version = "1.0.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" +checksum = "2de98502f212cfcea8d0bb305bd0f49d7ebdd75b64ba0a68f937d888f4e0d6db" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -270,15 +270,15 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.10.0" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "syn" -version = "2.0.41" +version = "2.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c8b28c477cc3bf0e7966561e3460130e1255f7a1cf71931075f1c5e7a7e269" +checksum = "89456b690ff72fddcecf231caedbe615c59480c93358a93dfae7fc29e3ebbf0e" dependencies = [ "proc-macro2", "quote", @@ -311,9 +311,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.9" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "version_check" @@ -323,18 +323,18 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "zerocopy" -version = "0.7.31" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c4061bedbb353041c12f413700357bec76df2c7e2ca8e4df8bac24c6bf68e3d" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.31" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3c129550b3e6de3fd0ba67ba5c81818f9805e58b8d7fee80a3a59d2c9fc601a" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", diff --git a/multi-transfer-esdt/wasm/src/lib.rs b/multi-transfer-esdt/wasm/src/lib.rs index 6f0baa97..bec1d596 100644 --- a/multi-transfer-esdt/wasm/src/lib.rs +++ b/multi-transfer-esdt/wasm/src/lib.rs @@ -10,9 +10,7 @@ // Total number of exported functions: 22 #![no_std] - -// Configuration that works with rustc < 1.73.0. -// TODO: Recommended rustc version: 1.73.0 or newer. +#![allow(internal_features)] #![feature(lang_items)] multiversx_sc_wasm_adapter::allocator!(); diff --git a/multisig/Cargo.toml b/multisig/Cargo.toml index d6f77141..67819826 100644 --- a/multisig/Cargo.toml +++ b/multisig/Cargo.toml @@ -35,8 +35,11 @@ path = "../multi-transfer-esdt" [dependencies.multiversx-sc] version = "0.45.2" +[dependencies.multiversx-price-aggregator-sc] +version = "0.45.2" + [dependencies.multiversx-sc-modules] version = "0.45.2" [dev-dependencies.multiversx-sc-scenario] -version = "0.45.2" +version = "0.45.2" \ No newline at end of file diff --git a/multisig/scenarios/change_token_config.scen.json b/multisig/scenarios/change_token_config.scen.json index 8a9d0c73..75610ded 100644 --- a/multisig/scenarios/change_token_config.scen.json +++ b/multisig/scenarios/change_token_config.scen.json @@ -154,7 +154,7 @@ "function": "addMapping", "arguments": [ "0x0102030405060708091011121314151617181999", - "str:EGLD-123456" + "str:WEGLD-123456" ], "gasLimit": "50,000,000", "gasPrice": "0" @@ -177,7 +177,7 @@ "function": "addMapping", "arguments": [ "0x0000030405060708091011121314151617181999", - "str:EGLD-123456" + "str:WEGLD-123456" ], "gasLimit": "50,000,000", "gasPrice": "0" @@ -202,7 +202,7 @@ }, "expect": { "out": [ - "str:EGLD-123456" + "str:WEGLD-123456" ] } }, @@ -213,7 +213,7 @@ "to": "sc:multisig", "function": "getErc20AddressForTokenId", "arguments": [ - "str:EGLD-123456" + "str:WEGLD-123456" ] }, "expect": { @@ -232,7 +232,7 @@ "function": "clearMapping", "arguments": [ "0x0102030405060708091011121314151617181920", - "str:EGLD-123456" + "str:WEGLD-123456" ], "gasLimit": "50,000,000", "gasPrice": "0" diff --git a/multisig/scenarios/create_elrond_to_ethereum_tx_batch.scen.json b/multisig/scenarios/create_elrond_to_ethereum_tx_batch.scen.json index 1cd5744f..405d8d55 100644 --- a/multisig/scenarios/create_elrond_to_ethereum_tx_batch.scen.json +++ b/multisig/scenarios/create_elrond_to_ethereum_tx_batch.scen.json @@ -11,10 +11,13 @@ "tx": { "from": "address:user", "to": "sc:esdt_safe", - "esdt": { - "tokenIdentifier": "str:EGLD-123456", - "value": "1,500,400" - }, + "value": "0", + "esdtValue": [ + { + "tokenIdentifier": "str:WEGLD-123456", + "value": "85,000,000,000" + } + ], "function": "createTransaction", "arguments": [ "0x0102030405060708091011121314151617181920" @@ -37,8 +40,8 @@ "nonce": "*", "balance": "0", "esdt": { - "str:EGLD-123456": "499,600", - "str:ETH-123456": "1,000,000" + "str:WEGLD-123456": "15,000,000,000", + "str:ETH-123456": "200,000,000,000" }, "storage": {} }, @@ -46,15 +49,17 @@ "nonce": "0", "balance": "0", "esdt": { - "str:EGLD-123456": { - "balance": "1,500,400", + "str:WEGLD-123456": { + "balance": "85,000,000,000", "roles": [ + "ESDTRoleLocalMint", "ESDTRoleLocalBurn" ] }, "str:ETH-123456": { "balance": "0", "roles": [ + "ESDTRoleLocalMint", "ESDTRoleLocalBurn" ] } @@ -65,13 +70,13 @@ "2-nonce": "u64:1", "3-from": "u32:32|address:user", "4-to": "u32:20|0x0102030405060708091011121314151617181920", - "5-token_identifier": "nested:str:EGLD-123456", - "6-amount": "biguint:400", + "5-token_identifier": "nested:str:WEGLD-123456", + "6-amount": "biguint:10,000,000,000", "7-is_refund_tx": "u8:0" }, "str:firstBatchId": "1", "str:lastBatchId": "1", - "str:accumulatedTransactionFees|nested:str:EGLD-123456": "1,500,000", + "str:accumulatedTransactionFees|nested:str:WEGLD-123456": "75,000,000,000", "+": "" }, "code": "*" @@ -85,10 +90,12 @@ "tx": { "from": "address:user", "to": "sc:esdt_safe", - "esdt": { - "tokenIdentifier": "str:ETH-123456", - "value": "500,000" - }, + "esdtValue": [ + { + "tokenIdentifier": "str:ETH-123456", + "value": "95,000,000,000" + } + ], "function": "createTransaction", "arguments": [ "0x0102030405060708091011121314151617181920" @@ -111,8 +118,8 @@ "nonce": "*", "balance": "0", "esdt": { - "str:EGLD-123456": "499,600", - "str:ETH-123456": "500,000" + "str:WEGLD-123456": "15,000,000,000", + "str:ETH-123456": "105,000,000,000" }, "storage": {} }, @@ -120,15 +127,17 @@ "nonce": "0", "balance": "0", "esdt": { - "str:EGLD-123456": { - "balance": "1,500,400", + "str:WEGLD-123456": { + "balance": "85,000,000,000", "roles": [ + "ESDTRoleLocalMint", "ESDTRoleLocalBurn" ] }, "str:ETH-123456": { - "balance": "500,000", + "balance": "95,000,000,000", "roles": [ + "ESDTRoleLocalMint", "ESDTRoleLocalBurn" ] } @@ -139,8 +148,8 @@ "2-nonce": "u64:1", "3-from": "u32:32|address:user", "4-to": "u32:20|0x0102030405060708091011121314151617181920", - "5-token_identifier": "nested:str:EGLD-123456", - "6-amount": "biguint:400", + "5-token_identifier": "nested:str:WEGLD-123456", + "6-amount": "biguint:10,000,000,000", "7-is_refund_tx": "u8:0" }, "str:pendingBatches|u64:1|str:.item|u32:2": { @@ -149,13 +158,13 @@ "3-from": "u32:32|address:user", "4-to": "u32:20|0x0102030405060708091011121314151617181920", "5-token_identifier": "nested:str:ETH-123456", - "6-amount": "biguint:350,000", + "6-amount": "biguint:20,000,000,000", "7-is_refund_tx": "u8:0" }, "str:firstBatchId": "1", "str:lastBatchId": "1", - "str:accumulatedTransactionFees|nested:str:EGLD-123456": "1,500,000", - "str:accumulatedTransactionFees|nested:str:ETH-123456": "150,000", + "str:accumulatedTransactionFees|nested:str:WEGLD-123456": "75,000,000,000", + "str:accumulatedTransactionFees|nested:str:ETH-123456": "75,000,000,000", "+": "" }, "code": "*" @@ -184,16 +193,16 @@ "1", "address:user", "0x0102030405060708091011121314151617181920", - "str:EGLD-123456", - "400", + "str:WEGLD-123456", + "10,000,000,000", "0", "2", "address:user", "0x0102030405060708091011121314151617181920", "str:ETH-123456", - "350,000" + "20,000,000,000" ] } } ] -} +} \ No newline at end of file diff --git a/multisig/scenarios/ethereum_to_elrond_tx_batch_ok.scen.json b/multisig/scenarios/ethereum_to_elrond_tx_batch_ok.scen.json index 93bacdb6..0d0b629f 100644 --- a/multisig/scenarios/ethereum_to_elrond_tx_batch_ok.scen.json +++ b/multisig/scenarios/ethereum_to_elrond_tx_batch_ok.scen.json @@ -15,8 +15,8 @@ "function": "proposeMultiTransferEsdtBatch", "arguments": [ "1", - "0x0102030405060708091011121314151617181920", "address:user", "str:EGLD-123456", "500,000", "1", "str:data", "u64:20000000", - "0x0102030405060708091011121314151617181920", "address:user", "str:ETH-123456", "500,000", "2", "str:data", "u64:20000000" + "0x0102030405060708091011121314151617181920", "address:user", "str:WEGLD-123456", "76,000,000,000", "1", "str:data", "u64:20000000", + "0x0102030405060708091011121314151617181920", "address:user", "str:ETH-123456", "76,000,000,000", "2", "str:data", "u64:20000000" ], "gasLimit": "50,000,000", "gasPrice": "0" @@ -46,8 +46,8 @@ { "1-from": "0x0102030405060708091011121314151617181920", "2-to": "address:user", - "3-token_id": "nested:str:EGLD-123456", - "4-amount": "biguint:500,000", + "3-token_id": "nested:str:WEGLD-123456", + "4-amount": "biguint:76,000,000,000", "5-tx_nonce": "u64:1", "6-data": "nested:str:data", "7-gas_limit": "u64:20000000" @@ -56,7 +56,7 @@ "1-from": "0x0102030405060708091011121314151617181920", "2-to": "address:user", "3-token_id": "nested:str:ETH-123456", - "4-amount": "biguint:500,000", + "4-amount": "biguint:76,000,000,000", "5-tx_nonce": "u64:2", "6-data": "nested:str:data", "7-gas_limit": "u64:20000000" @@ -121,8 +121,8 @@ "nonce": "*", "balance": "0", "esdt": { - "str:EGLD-123456": "2,500,000", - "str:ETH-123456": "1,500,000" + "str:WEGLD-123456": "176,000,000,000", + "str:ETH-123456": "276,000,000,000" }, "storage": {} }, diff --git a/multisig/scenarios/ethereum_to_elrond_tx_batch_rejected.scen.json b/multisig/scenarios/ethereum_to_elrond_tx_batch_rejected.scen.json index e3ca3858..c54c0375 100644 --- a/multisig/scenarios/ethereum_to_elrond_tx_batch_rejected.scen.json +++ b/multisig/scenarios/ethereum_to_elrond_tx_batch_rejected.scen.json @@ -17,15 +17,15 @@ "2", "0x0102030405060708091011121314151617181920", "sc:egld_esdt_swap", - "str:EGLD-123456", - "2,000,000", + "str:WEGLD-123456", + "76,000,000,000", "str:data", "u64:2,000,000", "u64:1", "0x0102030405060708091011121314151617181920", "sc:egld_esdt_swap", "str:ETH-123456", - "2,000,000", + "76,000,000,000", "u64:2", "str:data", "u64:2,000,000" @@ -53,15 +53,15 @@ "1", "0x0102030405060708091011121314151617181920", "sc:egld_esdt_swap", - "str:EGLD-123456", - "2,000,000", + "str:WEGLD-123456", + "76,000,000,000", "u64:2", "str:data", "u64:2,000,000", "0x0102030405060708091011121314151617181920", "sc:egld_esdt_swap", "str:ETH-123456", - "2,000,000", + "76,000,000,000", "u64:3", "str:data", "u64:2,000,000" @@ -89,15 +89,15 @@ "1", "0x0102030405060708091011121314151617181920", "sc:egld_esdt_swap", - "str:EGLD-123456", - "2,000,000", + "str:WEGLD-123456", + "76,000,000,000", "u64:1", "str:data", "u64:2,000,000", "0x0102030405060708091011121314151617181920", "sc:egld_esdt_swap", "str:ETH-123456", - "2,000,000", + "76,000,000,000", "u64:2", "str:data", "u64:2,000,000" @@ -130,8 +130,8 @@ { "1-from": "0x0102030405060708091011121314151617181920", "2-to": "sc:egld_esdt_swap", - "3-token_id": "nested:str:EGLD-123456", - "4-amount": "biguint:2,000,000", + "3-token_id": "nested:str:WEGLD-123456", + "4-amount": "biguint:76,000,000,000", "5-tx_id": "u64:1", "6-data": "nested:str:data", "7-gas_limit": "u64:2,000,000" @@ -140,7 +140,7 @@ "1-from": "0x0102030405060708091011121314151617181920", "2-to": "sc:egld_esdt_swap", "3-token_id": "nested:str:ETH-123456", - "4-amount": "biguint:2,000,000", + "4-amount": "biguint:76,000,000,000", "5-tx_id": "u64:2", "6-data": "nested:str:data", "7-gas_limit": "u64:2,000,000" @@ -214,14 +214,14 @@ "1", "0x0102030405060708091011121314151617181920", "sc:egld_esdt_swap", - "str:EGLD-123456", - "2,000,000", + "str:WEGLD-123456", + "76,000,000,000", "0", "2", "0x0102030405060708091011121314151617181920", "sc:egld_esdt_swap", "str:ETH-123456", - "2,000,000" + "76,000,000,000" ] } }, @@ -264,15 +264,17 @@ "nonce": "0", "balance": "0", "esdt": { - "str:EGLD-123456": { + "str:WEGLD-123456": { "balance": "0", "roles": [ + "ESDTRoleLocalMint", "ESDTRoleLocalBurn" ] }, "str:ETH-123456": { "balance": "0", "roles": [ + "ESDTRoleLocalMint", "ESDTRoleLocalBurn" ] } @@ -283,8 +285,8 @@ "2-nonce": "u64:1", "3-from": "u32:32|sc:egld_esdt_swap", "4-to": "u32:20|0x0102030405060708091011121314151617181920", - "5-token_identifier": "nested:str:EGLD-123456", - "6-amount": "biguint:500,000", + "5-token_identifier": "nested:str:WEGLD-123456", + "6-amount": "biguint:1,000,000,000", "7-is_refund_tx": "u8:1" }, "str:pendingBatches|u64:1|str:.item|u32:2": { @@ -293,12 +295,12 @@ "3-from": "u32:32|sc:egld_esdt_swap", "4-to": "u32:20|0x0102030405060708091011121314151617181920", "5-token_identifier": "nested:str:ETH-123456", - "6-amount": "biguint:1,850,000", + "6-amount": "biguint:1,000,000,000", "7-is_refund_tx": "u8:1" }, "str:firstBatchId": "1", "str:lastBatchId": "1", - "str:accumulatedTransactionFees|nested:str:EGLD-123456": "0", + "str:accumulatedTransactionFees|nested:str:WEGLD-123456": "0", "str:accumulatedTransactionFees|nested:str:ETH-123456": "0", "+": "" }, diff --git a/multisig/scenarios/execute_elrond_to_ethereum_tx_batch.scen.json b/multisig/scenarios/execute_elrond_to_ethereum_tx_batch.scen.json index 77368000..8215bfb1 100644 --- a/multisig/scenarios/execute_elrond_to_ethereum_tx_batch.scen.json +++ b/multisig/scenarios/execute_elrond_to_ethereum_tx_batch.scen.json @@ -103,7 +103,7 @@ "value": "0", "function": "claimRefund", "arguments": [ - "str:EGLD-123456" + "str:WEGLD-123456" ], "gasLimit": "50,000,000", "gasPrice": "0" @@ -144,15 +144,17 @@ "nonce": "0", "balance": "0", "esdt": { - "str:EGLD-123456": { - "balance": "1,500,000", + "str:WEGLD-123456": { + "balance": "75,000,000,000", "roles": [ + "ESDTRoleLocalMint", "ESDTRoleLocalBurn" ] }, "str:ETH-123456": { - "balance": "150,000", + "balance": "75,000,000,000", "roles": [ + "ESDTRoleLocalMint", "ESDTRoleLocalBurn" ] } @@ -162,8 +164,8 @@ "str:transactionsByNonce|address:user|str:.item|u32:1": "", "str:transactionStatus|address:user|u32:2": "", "str:transactionsByNonce|address:user|str:.item|u32:2": "", - "str:accumulatedTransactionFees|nested:str:EGLD-123456": "1,500,000", - "str:accumulatedTransactionFees|nested:str:ETH-123456": "150,000", + "str:accumulatedTransactionFees|nested:str:WEGLD-123456": "75,000,000,000", + "str:accumulatedTransactionFees|nested:str:ETH-123456": "75,000,000,000", "+": "" }, "code": "*" @@ -202,11 +204,11 @@ "nonce": "*", "balance": "0", "esdt": { - "str:EGLD-123456": { - "balance": "600,000" + "str:WEGLD-123456": { + "balance": "30,000,000,000" }, "str:ETH-123456": { - "balance": "60,000" + "balance": "30,000,000,000" } }, "storage": {} @@ -215,11 +217,11 @@ "nonce": "*", "balance": "0", "esdt": { - "str:EGLD-123456": { - "balance": "900,000" + "str:WEGLD-123456": { + "balance": "45,000,000,000" }, "str:ETH-123456": { - "balance": "90,000" + "balance": "45,000,000,000" } }, "storage": {} @@ -228,21 +230,23 @@ "nonce": "0", "balance": "0", "esdt": { - "str:EGLD-123456": { + "str:WEGLD-123456": { "balance": "0", "roles": [ + "ESDTRoleLocalMint", "ESDTRoleLocalBurn" ] }, "str:ETH-123456": { "balance": "0", "roles": [ + "ESDTRoleLocalMint", "ESDTRoleLocalBurn" ] } }, "storage": { - "str:accumulatedTransactionFees|nested:str:EGLD-123456": "0", + "str:accumulatedTransactionFees|nested:str:WEGLD-123456": "0", "str:accumulatedTransactionFees|nested:str:ETH-123456": "0", "+": "" }, diff --git a/multisig/scenarios/reject_elrond_to_ethereum_tx_batch.scen.json b/multisig/scenarios/reject_elrond_to_ethereum_tx_batch.scen.json index 1150e544..4d59d262 100644 --- a/multisig/scenarios/reject_elrond_to_ethereum_tx_batch.scen.json +++ b/multisig/scenarios/reject_elrond_to_ethereum_tx_batch.scen.json @@ -106,10 +106,10 @@ }, "expect": { "out": [ - "str:EGLD-123456", - "400", + "str:WEGLD-123456", + "10,000,000,000", "str:ETH-123456", - "350,000" + "20,000,000,000" ] } }, @@ -122,7 +122,7 @@ "value": "0", "function": "claimRefund", "arguments": [ - "str:EGLD-123456" + "str:WEGLD-123456" ], "gasLimit": "50,000,000", "gasPrice": "0" @@ -165,8 +165,8 @@ "nonce": "*", "balance": "0", "esdt": { - "str:EGLD-123456": "500,000", - "str:ETH-123456": "850,000" + "str:WEGLD-123456": "25,000,000,000", + "str:ETH-123456": "125,000,000,000" }, "storage": {} }, @@ -174,15 +174,17 @@ "nonce": "0", "balance": "0", "esdt": { - "str:EGLD-123456": { - "balance": "1,500,000", + "str:WEGLD-123456": { + "balance": "75,000,000,000", "roles": [ + "ESDTRoleLocalMint", "ESDTRoleLocalBurn" ] }, "str:ETH-123456": { - "balance": "150,000", + "balance": "75,000,000,000", "roles": [ + "ESDTRoleLocalMint", "ESDTRoleLocalBurn" ] } @@ -192,8 +194,8 @@ "str:transactionsByNonce|address:user|str:.item|u32:1": "", "str:transactionStatus|address:user|u32:2": "", "str:transactionsByNonce|address:user|str:.item|u32:2": "", - "str:accumulatedTransactionFees|nested:str:EGLD-123456": "1,500,000", - "str:accumulatedTransactionFees|nested:str:ETH-123456": "150,000", + "str:accumulatedTransactionFees|nested:str:WEGLD-123456": "75,000,000,000", + "str:accumulatedTransactionFees|nested:str:ETH-123456": "75,000,000,000", "+": "" }, "code": "*" @@ -232,11 +234,11 @@ "nonce": "*", "balance": "0", "esdt": { - "str:EGLD-123456": { - "balance": "600,000" + "str:WEGLD-123456": { + "balance": "30,000,000,000" }, "str:ETH-123456": { - "balance": "60,000" + "balance": "30,000,000,000" } }, "storage": {} @@ -245,11 +247,11 @@ "nonce": "*", "balance": "0", "esdt": { - "str:EGLD-123456": { - "balance": "900,000" + "str:WEGLD-123456": { + "balance": "45,000,000,000" }, "str:ETH-123456": { - "balance": "90,000" + "balance": "45,000,000,000" } }, "storage": {} @@ -258,21 +260,23 @@ "nonce": "0", "balance": "0", "esdt": { - "str:EGLD-123456": { + "str:WEGLD-123456": { "balance": "0", "roles": [ + "ESDTRoleLocalMint", "ESDTRoleLocalBurn" ] }, "str:ETH-123456": { "balance": "0", "roles": [ + "ESDTRoleLocalMint", "ESDTRoleLocalBurn" ] } }, "storage": { - "str:accumulatedTransactionFees|nested:str:EGLD-123456": "0", + "str:accumulatedTransactionFees|nested:str:WEGLD-123456": "0", "str:accumulatedTransactionFees|nested:str:ETH-123456": "0", "+": "" }, diff --git a/multisig/scenarios/setup.scen.json b/multisig/scenarios/setup.scen.json index a57d872f..2be0fe38 100644 --- a/multisig/scenarios/setup.scen.json +++ b/multisig/scenarios/setup.scen.json @@ -13,7 +13,7 @@ "nonce": "0", "balance": "0", "esdt": { - "str:EGLD-123456": { + "str:WEGLD-123456": { "balance": "0", "roles": [ "ESDTRoleLocalMint" @@ -27,6 +27,8 @@ } }, "storage": { + "str:esdtSafeContractAddress": "sc:esdt_safe", + "str:maxTxBatchSize": "10", "str:maxTxBatchBlockDuration": "3,600", @@ -40,20 +42,23 @@ "nonce": "0", "balance": "0", "esdt": { - "str:EGLD-123456": { + "str:WEGLD-123456": { "balance": "0", "roles": [ + "ESDTRoleLocalMint", "ESDTRoleLocalBurn" ] }, "str:ETH-123456": { "balance": "0", "roles": [ + "ESDTRoleLocalMint", "ESDTRoleLocalBurn" ] } }, "storage": { + "str:multiTransferContractAddress": "sc:multi_transfer", "str:feeEstimatorContractAddress": "sc:price_aggregator", "str:maxTxBatchSize": "10", "str:maxTxBatchBlockDuration": "100", @@ -63,11 +68,11 @@ "str:lastBatchId": "1", "str:tokenTicker|nested:str:GWEI": "str:GWEI", - "str:tokenTicker|nested:str:EGLD-123456": "str:EGLD", + "str:tokenTicker|nested:str:WEGLD-123456": "str:WEGLD", "str:tokenTicker|nested:str:ETH-123456": "str:ETH", - "str:tokenWhitelist.index|nested:str:EGLD-123456": "1", - "str:tokenWhitelist.item|u32:1": "str:EGLD-123456", + "str:tokenWhitelist.index|nested:str:WEGLD-123456": "1", + "str:tokenWhitelist.item|u32:1": "str:WEGLD-123456", "str:tokenWhitelist.index|nested:str:ETH-123456": "2", "str:tokenWhitelist.item|u32:2": "str:ETH-123456", "str:tokenWhitelist.len": "2" @@ -99,8 +104,8 @@ "nonce": "0", "balance": "0", "esdt": { - "str:EGLD-123456": "2,000,000", - "str:ETH-123456": "1,000,000" + "str:WEGLD-123456": "100,000,000,000", + "str:ETH-123456": "200,000,000,000" }, "storage": {} }, @@ -282,7 +287,7 @@ }, "expect": { "out": [ - "str:EGLD-123456", + "str:WEGLD-123456", "str:ETH-123456" ] } @@ -305,6 +310,96 @@ "gas": "*", "refund": "*" } + }, + { + "step": "scCall", + "txId": "add-token-1", + "tx": { + "from": "sc:multisig", + "to": "sc:esdt_safe", + "value": "0", + "function": "addTokenToWhitelist", + "arguments": [ + "str:WEGLD-123456", + "str:WEGLD", + "true", + "500,000" + ], + "gasLimit": "50,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "txId": "add-token-1", + "tx": { + "from": "sc:multisig", + "to": "sc:esdt_safe", + "value": "0", + "function": "addTokenToWhitelist", + "arguments": [ + "str:ETH-123456", + "str:ETH", + "true", + "500,000" + ], + "gasLimit": "50,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "txId": "set-accumulated-burned-tokens", + "tx": { + "from": "sc:multisig", + "to": "sc:esdt_safe", + "function": "setAccumulatedBurnedTokens", + "arguments": [ + "str:WEGLD-123456", + "500,000,000,000" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "txId": "set-accumulated-burned-tokens", + "tx": { + "from": "sc:multisig", + "to": "sc:esdt_safe", + "function": "setAccumulatedBurnedTokens", + "arguments": [ + "str:ETH-123456", + "500,000,000,000" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } } ] } diff --git a/multisig/tests/multisig_scenario_rs_test.rs b/multisig/tests/multisig_scenario_rs_test.rs new file mode 100644 index 00000000..72b0bd82 --- /dev/null +++ b/multisig/tests/multisig_scenario_rs_test.rs @@ -0,0 +1,58 @@ +use multiversx_sc_scenario::*; + +fn world() -> ScenarioWorld { + let mut blockchain = ScenarioWorld::new(); + blockchain.set_current_dir_from_workspace("multisig/"); + + blockchain.register_contract("file:output/multisig.wasm", multisig::ContractBuilder); + blockchain.register_contract("file:../multi-transfer-esdt/output/multi-transfer-esdt.wasm", multi_transfer_esdt::ContractBuilder); + blockchain.register_contract("file:../esdt-safe/output/esdt-safe.wasm", esdt_safe::ContractBuilder); + blockchain.register_contract("file:../price-aggregator/multiversx-price-aggregator-sc.wasm", multiversx_price_aggregator_sc::ContractBuilder); + + blockchain +} + +#[test] +fn change_token_config_rs() { + world().run("scenarios/change_token_config.scen.json"); +} + +#[test] +fn create_elrond_to_ethereum_tx_batch_rs() { + world().run("scenarios/create_elrond_to_ethereum_tx_batch.scen.json"); +} + +#[test] +fn ethereum_to_elrond_tx_batch_ok_rs() { + world().run("scenarios/ethereum_to_elrond_tx_batch_ok.scen.json"); +} + +#[test] +fn ethereum_to_elrond_tx_batch_rejected_rs() { + world().run("scenarios/ethereum_to_elrond_tx_batch_rejected.scen.json"); +} + +#[test] +fn execute_elrond_to_ethereum_tx_batch_rs() { + world().run("scenarios/execute_elrond_to_ethereum_tx_batch.scen.json"); +} + +#[test] +fn get_empty_batch_rs() { + world().run("scenarios/get_empty_batch.scen.json"); +} + +#[test] +fn reject_elrond_to_ethereum_tx_batch_rs() { + world().run("scenarios/reject_elrond_to_ethereum_tx_batch.scen.json"); +} + +#[test] +fn setup_rs() { + world().run("scenarios/setup.scen.json"); +} + +#[test] +fn unstake_rs() { + world().run("scenarios/unstake.scen.json"); +} diff --git a/multisig/wasm/Cargo.lock b/multisig/wasm/Cargo.lock index 28af16f8..f0556566 100644 --- a/multisig/wasm/Cargo.lock +++ b/multisig/wasm/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "ahash" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" +checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" dependencies = [ "cfg-if", "once_cell", @@ -243,33 +243,33 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "proc-macro2" -version = "1.0.70" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" +checksum = "907a61bd0f64c2f29cd1cf1dc34d05176426a3f504a78010f08416ddb7b13708" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -286,15 +286,15 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.10.0" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "syn" -version = "2.0.41" +version = "2.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c8b28c477cc3bf0e7966561e3460130e1255f7a1cf71931075f1c5e7a7e269" +checksum = "1726efe18f42ae774cc644f330953a5e7b3c3003d3edcecf18850fe9d4dd9afb" dependencies = [ "proc-macro2", "quote", @@ -327,9 +327,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.9" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "version_check" @@ -339,18 +339,18 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "zerocopy" -version = "0.7.31" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c4061bedbb353041c12f413700357bec76df2c7e2ca8e4df8bac24c6bf68e3d" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.31" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3c129550b3e6de3fd0ba67ba5c81818f9805e58b8d7fee80a3a59d2c9fc601a" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", diff --git a/multisig/wasm/src/lib.rs b/multisig/wasm/src/lib.rs index d8045a40..6e2ab6ea 100644 --- a/multisig/wasm/src/lib.rs +++ b/multisig/wasm/src/lib.rs @@ -10,9 +10,7 @@ // Total number of exported functions: 66 #![no_std] - -// Configuration that works with rustc < 1.73.0. -// TODO: Recommended rustc version: 1.73.0 or newer. +#![allow(internal_features)] #![feature(lang_items)] multiversx_sc_wasm_adapter::allocator!(); From 40d718977d952f69c462a79ffc0aff3032ee2303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Fri, 5 Jan 2024 15:06:55 +0200 Subject: [PATCH 41/50] Update Rust toolchain --- .github/workflows/actions.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 202f45a8..06e71cb3 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -14,9 +14,9 @@ permissions: jobs: contracts: name: Contracts - uses: multiversx/mx-sc-actions/.github/workflows/contracts.yml@v2.3.0 + uses: multiversx/mx-sc-actions/.github/workflows/contracts.yml@v2.3.5 with: - rust-toolchain: nightly-2023-04-24 - vmtools-version: v1.4.60 + rust-toolchain: nightly-2023-12-11 + vmtools-version: v1.5.19 secrets: token: ${{ secrets.GITHUB_TOKEN }} From b7717ae00cf453116c5b0f982c2ce1849bcb49ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Fri, 5 Jan 2024 15:07:20 +0200 Subject: [PATCH 42/50] Rebranding elrond -> MultiversX --- docs/setup.md | 4 ++-- esdt-safe/interaction/snippets.sh | 6 +++--- multi-transfer-esdt/README.md | 4 ++-- multi-transfer-esdt/interaction/snippets.sh | 6 +++--- ...multiversx_to_ethereum_tx_batch.scen.json} | 0 ...ereum_to_multiversx_tx_batch_ok.scen.json} | 2 +- ...to_multiversx_tx_batch_rejected.scen.json} | 2 +- ...multiversx_to_ethereum_tx_batch.scen.json} | 2 +- ...multiversx_to_ethereum_tx_batch.scen.json} | 2 +- multisig/tests/multisig_scenario_rs_test.rs | 20 +++++++++--------- multisig/tests/scenario_go_test.rs | 20 +++++++++--------- ...n => price-aggregator-deprecated.abi.json} | 0 ....wasm => price-aggregator-deprecated.wasm} | Bin 13 files changed, 34 insertions(+), 34 deletions(-) rename multisig/scenarios/{create_elrond_to_ethereum_tx_batch.scen.json => create_multiversx_to_ethereum_tx_batch.scen.json} (100%) rename multisig/scenarios/{ethereum_to_elrond_tx_batch_ok.scen.json => ethereum_to_multiversx_tx_batch_ok.scen.json} (98%) rename multisig/scenarios/{ethereum_to_elrond_tx_batch_rejected.scen.json => ethereum_to_multiversx_tx_batch_rejected.scen.json} (99%) rename multisig/scenarios/{execute_elrond_to_ethereum_tx_batch.scen.json => execute_multiversx_to_ethereum_tx_batch.scen.json} (99%) rename multisig/scenarios/{reject_elrond_to_ethereum_tx_batch.scen.json => reject_multiversx_to_ethereum_tx_batch.scen.json} (99%) rename price-aggregator/{price-aggregator.abi.json => price-aggregator-deprecated.abi.json} (100%) rename price-aggregator/{price-aggregator.wasm => price-aggregator-deprecated.wasm} (100%) diff --git a/docs/setup.md b/docs/setup.md index 01186a22..dd44c29b 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -8,7 +8,7 @@ Additionally, you will have to issue at least two ESDT tokens (suggested paramet IMPORTANT: Ticker should always be chosen so that the aggregator has a mapping for it. "WEGLD" would not work at all, since the aggregator wouldn't know about the token, but "EGLD" works perfectly) -You can find more about how to issue an ESDT token here: https://docs.elrond.com/developers/esdt-tokens/#issuance-of-fungible-esdt-tokens +You can find more about how to issue an ESDT token here: https://docs.multiversx.com/tokens/esdt-tokens/#issuance-of-fungible-esdt-tokens Next, we're going to setup the main "controller" contract, which will be a multisig-style SC. You can find more details about this type of smart contract here: https://github.com/multiversx/mx-sdk-rs/blob/master/contracts/examples/multisig/README.md @@ -35,7 +35,7 @@ The `_code` arguments are the compiled wasm bytecode of the respective contracts `esdt_safe_eth_tx_gas_limit` and `multi_transfer_esdt_eth_tx_gas_limit` are gas limits used for MultiversX -> Ethereum tx, and Ethereum -> MultiversX tx respectively. This is the gas limit used for processing on the Ethereum side (briding over to MultiversX or from MultiversX). This cost is used to calculate the fees taken from the bridged token, to be then used as payment/incentive for the relayers. -`wrapped_egld_token_id` is the token identifier of the previously issued "WrappedEgld" token (Note: identifier format is ticker + '-' + 6 random characters). For WrappedEgld, it might look something like "EGLD-123456". +`wrapped_egld_token_id` is the token identifier of the previously issued "WrappedEgld" token (Note: identifier format is ticker + '-' + 6 random characters). For WrappedEgld, it might look something like "WEGLD-123456". `token_whitelist` is a list of tokens already issued that will be used by the bridge, in our case, that will be only one: The "WrappedEth" token. diff --git a/esdt-safe/interaction/snippets.sh b/esdt-safe/interaction/snippets.sh index 8a46ca3a..ec1c5148 100644 --- a/esdt-safe/interaction/snippets.sh +++ b/esdt-safe/interaction/snippets.sh @@ -1,8 +1,8 @@ -ALICE="/home/elrond/elrond-sdk/mxpy/testnet/wallets/users/alice.pem" -BOB="/home/elrond/elrond-sdk/mxpy/testnet/wallets/users/bob.pem" +ALICE="/home/multiversx/multiversx-sdk/mxpy/testnet/wallets/users/alice.pem" +BOB="/home/multiversx/multiversx-sdk/mxpy/testnet/wallets/users/bob.pem" ADDRESS=$(mxpy data load --key=address-testnet-esdt-safe) DEPLOY_TRANSACTION=$(mxpy data load --key=deployTransaction-testnet) -PROXY=https://testnet-gateway.elrond.com +PROXY=https://testnet-gateway.multiversx.com CHAIN_ID=T BOB_ADDRESS=0x8049d639e5a6980d1cd2392abcce41029cda74a1563523a202f09641cc2618f8 # 32 bytes diff --git a/multi-transfer-esdt/README.md b/multi-transfer-esdt/README.md index 821c7653..9a3c4fb6 100644 --- a/multi-transfer-esdt/README.md +++ b/multi-transfer-esdt/README.md @@ -19,11 +19,11 @@ python3 ./interaction/playground.py --pem=./testnet/wallets/users/alice.pem --pr Deploy & interact with contract: ``` -python3 ./interaction/playground.py --pem=my.pem --proxy=https://testnet-gateway.elrond.com +python3 ./interaction/playground.py --pem=my.pem --proxy=https://testnet-gateway.multiversx.com ``` Interact with existing contract: ``` -python3 ./interaction/playground.py --pem=my.pem --proxy=https://testnet-gateway.elrond.com --contract=erd1... +python3 ./interaction/playground.py --pem=my.pem --proxy=https://testnet-gateway.multiversx.com --contract=erd1... ``` diff --git a/multi-transfer-esdt/interaction/snippets.sh b/multi-transfer-esdt/interaction/snippets.sh index 32996d89..d387f47b 100644 --- a/multi-transfer-esdt/interaction/snippets.sh +++ b/multi-transfer-esdt/interaction/snippets.sh @@ -1,8 +1,8 @@ -ALICE="/home/elrond/elrond-sdk/mxpy/testnet/wallets/users/alice.pem" -BOB="/home/elrond/elrond-sdk/mxpy/testnet/wallets/users/bob.pem" +ALICE="/home/multiversx/multiversx-sdk/mxpy/testnet/wallets/users/alice.pem" +BOB="/home/multiversx/multiversx-sdk/mxpy/testnet/wallets/users/bob.pem" ADDRESS=$(mxpy data load --key=address-testnet-multi-transfer-esdt) DEPLOY_TRANSACTION=$(mxpy data load --key=deployTransaction-testnet) -PROXY=https://testnet-gateway.elrond.com +PROXY=https://testnet-gateway.multiversx.com CHAIN_ID=T ALICE_ADDRESS=0x0139472eff6886771a982f3083da5d421f24c29181e63888228dc81ca60d69e1 diff --git a/multisig/scenarios/create_elrond_to_ethereum_tx_batch.scen.json b/multisig/scenarios/create_multiversx_to_ethereum_tx_batch.scen.json similarity index 100% rename from multisig/scenarios/create_elrond_to_ethereum_tx_batch.scen.json rename to multisig/scenarios/create_multiversx_to_ethereum_tx_batch.scen.json diff --git a/multisig/scenarios/ethereum_to_elrond_tx_batch_ok.scen.json b/multisig/scenarios/ethereum_to_multiversx_tx_batch_ok.scen.json similarity index 98% rename from multisig/scenarios/ethereum_to_elrond_tx_batch_ok.scen.json rename to multisig/scenarios/ethereum_to_multiversx_tx_batch_ok.scen.json index 0d0b629f..661f068a 100644 --- a/multisig/scenarios/ethereum_to_elrond_tx_batch_ok.scen.json +++ b/multisig/scenarios/ethereum_to_multiversx_tx_batch_ok.scen.json @@ -1,5 +1,5 @@ { - "name": "create ethereum to elrond tx batch", + "name": "create ethereum to MultiversX tx batch", "steps": [ { "step": "externalSteps", diff --git a/multisig/scenarios/ethereum_to_elrond_tx_batch_rejected.scen.json b/multisig/scenarios/ethereum_to_multiversx_tx_batch_rejected.scen.json similarity index 99% rename from multisig/scenarios/ethereum_to_elrond_tx_batch_rejected.scen.json rename to multisig/scenarios/ethereum_to_multiversx_tx_batch_rejected.scen.json index c54c0375..78396eba 100644 --- a/multisig/scenarios/ethereum_to_elrond_tx_batch_rejected.scen.json +++ b/multisig/scenarios/ethereum_to_multiversx_tx_batch_rejected.scen.json @@ -1,5 +1,5 @@ { - "name": "create ethereum to elrond tx batch - rejected", + "name": "create ethereum to MultiversX tx batch - rejected", "steps": [ { "step": "externalSteps", diff --git a/multisig/scenarios/execute_elrond_to_ethereum_tx_batch.scen.json b/multisig/scenarios/execute_multiversx_to_ethereum_tx_batch.scen.json similarity index 99% rename from multisig/scenarios/execute_elrond_to_ethereum_tx_batch.scen.json rename to multisig/scenarios/execute_multiversx_to_ethereum_tx_batch.scen.json index 8215bfb1..6a7acfa9 100644 --- a/multisig/scenarios/execute_elrond_to_ethereum_tx_batch.scen.json +++ b/multisig/scenarios/execute_multiversx_to_ethereum_tx_batch.scen.json @@ -3,7 +3,7 @@ "steps": [ { "step": "externalSteps", - "path": "create_elrond_to_ethereum_tx_batch.scen.json" + "path": "create_multiversx_to_ethereum_tx_batch.scen.json" }, { "step": "scCall", diff --git a/multisig/scenarios/reject_elrond_to_ethereum_tx_batch.scen.json b/multisig/scenarios/reject_multiversx_to_ethereum_tx_batch.scen.json similarity index 99% rename from multisig/scenarios/reject_elrond_to_ethereum_tx_batch.scen.json rename to multisig/scenarios/reject_multiversx_to_ethereum_tx_batch.scen.json index 4d59d262..bea7cd56 100644 --- a/multisig/scenarios/reject_elrond_to_ethereum_tx_batch.scen.json +++ b/multisig/scenarios/reject_multiversx_to_ethereum_tx_batch.scen.json @@ -3,7 +3,7 @@ "steps": [ { "step": "externalSteps", - "path": "create_elrond_to_ethereum_tx_batch.scen.json" + "path": "create_multiversx_to_ethereum_tx_batch.scen.json" }, { "step": "scCall", diff --git a/multisig/tests/multisig_scenario_rs_test.rs b/multisig/tests/multisig_scenario_rs_test.rs index 72b0bd82..a615f95e 100644 --- a/multisig/tests/multisig_scenario_rs_test.rs +++ b/multisig/tests/multisig_scenario_rs_test.rs @@ -18,23 +18,23 @@ fn change_token_config_rs() { } #[test] -fn create_elrond_to_ethereum_tx_batch_rs() { - world().run("scenarios/create_elrond_to_ethereum_tx_batch.scen.json"); +fn create_multiversx_to_ethereum_tx_batch_rs() { + world().run("scenarios/create_multiversx_to_ethereum_tx_batch.scen.json"); } #[test] -fn ethereum_to_elrond_tx_batch_ok_rs() { - world().run("scenarios/ethereum_to_elrond_tx_batch_ok.scen.json"); +fn ethereum_to_multiversx_tx_batch_ok_rs() { + world().run("scenarios/ethereum_to_multiversx_tx_batch_ok.scen.json"); } #[test] -fn ethereum_to_elrond_tx_batch_rejected_rs() { - world().run("scenarios/ethereum_to_elrond_tx_batch_rejected.scen.json"); +fn ethereum_to_multiversx_tx_batch_rejected_rs() { + world().run("scenarios/ethereum_to_multiversx_tx_batch_rejected.scen.json"); } #[test] -fn execute_elrond_to_ethereum_tx_batch_rs() { - world().run("scenarios/execute_elrond_to_ethereum_tx_batch.scen.json"); +fn execute_multiversx_to_ethereum_tx_batch_rs() { + world().run("scenarios/execute_multiversx_to_ethereum_tx_batch.scen.json"); } #[test] @@ -43,8 +43,8 @@ fn get_empty_batch_rs() { } #[test] -fn reject_elrond_to_ethereum_tx_batch_rs() { - world().run("scenarios/reject_elrond_to_ethereum_tx_batch.scen.json"); +fn reject_multiversx_to_ethereum_tx_batch_rs() { + world().run("scenarios/reject_multiversx_to_ethereum_tx_batch.scen.json"); } #[test] diff --git a/multisig/tests/scenario_go_test.rs b/multisig/tests/scenario_go_test.rs index 0fc3e199..aed76ed9 100644 --- a/multisig/tests/scenario_go_test.rs +++ b/multisig/tests/scenario_go_test.rs @@ -9,23 +9,23 @@ fn change_token_config_go() { } #[test] -fn create_elrond_to_ethereum_tx_batch_go() { - world().run("scenarios/create_elrond_to_ethereum_tx_batch.scen.json"); +fn create_multiversx_to_ethereum_tx_batch_go() { + world().run("scenarios/create_multiversx_to_ethereum_tx_batch.scen.json"); } #[test] -fn ethereum_to_elrond_tx_batch_ok_go() { - world().run("scenarios/ethereum_to_elrond_tx_batch_ok.scen.json"); +fn ethereum_to_multiversx_tx_batch_ok_go() { + world().run("scenarios/ethereum_to_multiversx_tx_batch_ok.scen.json"); } #[test] -fn ethereum_to_elrond_tx_batch_rejected_go() { - world().run("scenarios/ethereum_to_elrond_tx_batch_rejected.scen.json"); +fn ethereum_to_multiversx_tx_batch_rejected_go() { + world().run("scenarios/ethereum_to_multiversx_tx_batch_rejected.scen.json"); } #[test] -fn execute_elrond_to_ethereum_tx_batch_go() { - world().run("scenarios/execute_elrond_to_ethereum_tx_batch.scen.json"); +fn execute_multiversx_to_ethereum_tx_batch_go() { + world().run("scenarios/execute_multiversx_to_ethereum_tx_batch.scen.json"); } #[test] @@ -34,8 +34,8 @@ fn get_empty_batch_go() { } #[test] -fn reject_elrond_to_ethereum_tx_batch_go() { - world().run("scenarios/reject_elrond_to_ethereum_tx_batch.scen.json"); +fn reject_multiversx_to_ethereum_tx_batch_go() { + world().run("scenarios/reject_multiversx_to_ethereum_tx_batch.scen.json"); } #[test] diff --git a/price-aggregator/price-aggregator.abi.json b/price-aggregator/price-aggregator-deprecated.abi.json similarity index 100% rename from price-aggregator/price-aggregator.abi.json rename to price-aggregator/price-aggregator-deprecated.abi.json diff --git a/price-aggregator/price-aggregator.wasm b/price-aggregator/price-aggregator-deprecated.wasm similarity index 100% rename from price-aggregator/price-aggregator.wasm rename to price-aggregator/price-aggregator-deprecated.wasm From d6d2ff2a1b4b69baeb32be3adeb8b6bbffa9ace2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Fri, 5 Jan 2024 19:04:15 +0200 Subject: [PATCH 43/50] Framework upgrade 0.46 --- bridge-proxy/Cargo.toml | 4 +- bridge-proxy/meta/Cargo.toml | 2 +- bridge-proxy/wasm/Cargo.lock | 79 +-------- bridge-proxy/wasm/Cargo.toml | 2 +- bridged-tokens-wrapper/Cargo.toml | 6 +- bridged-tokens-wrapper/meta/Cargo.toml | 2 +- bridged-tokens-wrapper/wasm/Cargo.lock | 83 +-------- bridged-tokens-wrapper/wasm/Cargo.toml | 2 +- common/eth-address/Cargo.toml | 2 +- common/fee-estimator-module/Cargo.toml | 4 +- common/max-bridged-amount-module/Cargo.toml | 4 +- common/token-module/Cargo.toml | 4 +- common/transaction/Cargo.toml | 2 +- common/tx-batch-module/Cargo.toml | 4 +- esdt-safe/Cargo.toml | 8 +- esdt-safe/meta/Cargo.toml | 2 +- esdt-safe/wasm/Cargo.toml | 2 +- multi-transfer-esdt/Cargo.toml | 10 +- multi-transfer-esdt/meta/Cargo.toml | 2 +- multi-transfer-esdt/wasm/Cargo.lock | 179 ++++++++++++++----- multi-transfer-esdt/wasm/Cargo.toml | 2 +- multisig/Cargo.toml | 8 +- multisig/meta/Cargo.toml | 2 +- multisig/wasm/Cargo.lock | 180 +++++++++++++++----- multisig/wasm/Cargo.toml | 2 +- 25 files changed, 327 insertions(+), 270 deletions(-) diff --git a/bridge-proxy/Cargo.toml b/bridge-proxy/Cargo.toml index 6ef84c1f..4b04e1c1 100644 --- a/bridge-proxy/Cargo.toml +++ b/bridge-proxy/Cargo.toml @@ -15,10 +15,10 @@ path = "../common/transaction" path = "../common/eth-address" [dependencies.multiversx-sc] -version = "0.45.2" +version = "0.46.0" [dev-dependencies] num-bigint = "0.4.2" [dev-dependencies.multiversx-sc-scenario] -version = "0.45.2" +version = "0.46.0" diff --git a/bridge-proxy/meta/Cargo.toml b/bridge-proxy/meta/Cargo.toml index 6ad8ed05..6c870ea7 100644 --- a/bridge-proxy/meta/Cargo.toml +++ b/bridge-proxy/meta/Cargo.toml @@ -11,4 +11,4 @@ authors = ["you"] path = ".." [dependencies.multiversx-sc-meta] -version = "0.45.2" +version = "0.46.0" diff --git a/bridge-proxy/wasm/Cargo.lock b/bridge-proxy/wasm/Cargo.lock index a29bf138..0a24845e 100644 --- a/bridge-proxy/wasm/Cargo.lock +++ b/bridge-proxy/wasm/Cargo.lock @@ -2,24 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "ahash" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] -name = "allocator-api2" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" - [[package]] name = "arrayvec" version = "0.7.4" @@ -55,12 +37,6 @@ dependencies = [ "multiversx-sc-wasm-adapter", ] -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - [[package]] name = "endian-type" version = "0.1.2" @@ -74,16 +50,6 @@ dependencies = [ "multiversx-sc", ] -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" -dependencies = [ - "ahash", - "allocator-api2", -] - [[package]] name = "hex" version = "0.4.3" @@ -98,12 +64,11 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "multiversx-sc" -version = "0.45.2" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2bdb196b3ff2b9f8c744ec2e026c22c8e02bc91e5c6ed09951415c47fef6b8" +checksum = "9fff591179642ac99baad6050ff73ec98f0be45e4f2043ec2a9c222dcef94194" dependencies = [ "bitflags", - "hashbrown", "hex-literal", "multiversx-sc-codec", "multiversx-sc-derive", @@ -134,9 +99,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.45.2" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e60b5dce707f61376f74d713218f75326121d9f6a5f09a3a63de7aea2a92be9" +checksum = "f24329c73b4bfd9fae9186a397a358b26deaeac14e10234bb27838fc618cad8b" dependencies = [ "hex", "proc-macro2", @@ -147,9 +112,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.45.2" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4299660d5413d9f120bfddda8105b1f9d28f0345a72f53e5dc90732c4983e45" +checksum = "ace7a78b860a27b1bf2b6f2840d1cf40516b85c44e80ba34663b3388079afba8" dependencies = [ "multiversx-sc", ] @@ -172,12 +137,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - [[package]] name = "proc-macro2" version = "1.0.74" @@ -236,29 +195,3 @@ name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "zerocopy" -version = "0.7.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] diff --git a/bridge-proxy/wasm/Cargo.toml b/bridge-proxy/wasm/Cargo.toml index e342ed42..d4febb9c 100644 --- a/bridge-proxy/wasm/Cargo.toml +++ b/bridge-proxy/wasm/Cargo.toml @@ -25,7 +25,7 @@ overflow-checks = false path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.45.2" +version = "0.46.0" [workspace] members = ["."] diff --git a/bridged-tokens-wrapper/Cargo.toml b/bridged-tokens-wrapper/Cargo.toml index 94e3a1f4..f3550d62 100644 --- a/bridged-tokens-wrapper/Cargo.toml +++ b/bridged-tokens-wrapper/Cargo.toml @@ -12,10 +12,10 @@ path = "src/lib.rs" path = "../common/transaction" [dependencies.multiversx-sc] -version = "0.45.2" +version = "0.46.0" [dependencies.multiversx-sc-modules] -version = "0.45.2" +version = "0.46.0" [dev-dependencies.multiversx-sc-scenario] -version = "0.45.2" +version = "0.46.0" diff --git a/bridged-tokens-wrapper/meta/Cargo.toml b/bridged-tokens-wrapper/meta/Cargo.toml index 0c7eaff8..26774878 100644 --- a/bridged-tokens-wrapper/meta/Cargo.toml +++ b/bridged-tokens-wrapper/meta/Cargo.toml @@ -8,5 +8,5 @@ publish = false path = ".." [dependencies.multiversx-sc-meta] -version = "0.45.2" +version = "0.46.0" default-features = false diff --git a/bridged-tokens-wrapper/wasm/Cargo.lock b/bridged-tokens-wrapper/wasm/Cargo.lock index f1d8e3cb..8ba6ac3c 100644 --- a/bridged-tokens-wrapper/wasm/Cargo.lock +++ b/bridged-tokens-wrapper/wasm/Cargo.lock @@ -2,24 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "ahash" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] -name = "allocator-api2" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" - [[package]] name = "arrayvec" version = "0.7.4" @@ -55,12 +37,6 @@ dependencies = [ "multiversx-sc-wasm-adapter", ] -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - [[package]] name = "endian-type" version = "0.1.2" @@ -74,16 +50,6 @@ dependencies = [ "multiversx-sc", ] -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" -dependencies = [ - "ahash", - "allocator-api2", -] - [[package]] name = "hex" version = "0.4.3" @@ -98,12 +64,11 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "multiversx-sc" -version = "0.45.2" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2bdb196b3ff2b9f8c744ec2e026c22c8e02bc91e5c6ed09951415c47fef6b8" +checksum = "9fff591179642ac99baad6050ff73ec98f0be45e4f2043ec2a9c222dcef94194" dependencies = [ "bitflags", - "hashbrown", "hex-literal", "multiversx-sc-codec", "multiversx-sc-derive", @@ -134,9 +99,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.45.2" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e60b5dce707f61376f74d713218f75326121d9f6a5f09a3a63de7aea2a92be9" +checksum = "f24329c73b4bfd9fae9186a397a358b26deaeac14e10234bb27838fc618cad8b" dependencies = [ "hex", "proc-macro2", @@ -147,18 +112,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.45.2" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5833f8bc88104357d38a8952d2a16c3e66080e2e512c0e7001c0c003006c475" +checksum = "4088eb7642032b69f7b9961b505c2bffce852f795c60dc490e22a6037124f0c0" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.45.2" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4299660d5413d9f120bfddda8105b1f9d28f0345a72f53e5dc90732c4983e45" +checksum = "ace7a78b860a27b1bf2b6f2840d1cf40516b85c44e80ba34663b3388079afba8" dependencies = [ "multiversx-sc", ] @@ -181,12 +146,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - [[package]] name = "proc-macro2" version = "1.0.74" @@ -245,29 +204,3 @@ name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "zerocopy" -version = "0.7.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] diff --git a/bridged-tokens-wrapper/wasm/Cargo.toml b/bridged-tokens-wrapper/wasm/Cargo.toml index 304c40a8..84ddb624 100644 --- a/bridged-tokens-wrapper/wasm/Cargo.toml +++ b/bridged-tokens-wrapper/wasm/Cargo.toml @@ -25,7 +25,7 @@ overflow-checks = false path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.45.2" +version = "0.46.0" [workspace] members = ["."] diff --git a/common/eth-address/Cargo.toml b/common/eth-address/Cargo.toml index e4b8dadc..6f612e83 100644 --- a/common/eth-address/Cargo.toml +++ b/common/eth-address/Cargo.toml @@ -8,4 +8,4 @@ edition = "2018" path = "src/lib.rs" [dependencies.multiversx-sc] -version = "0.45.2" +version = "0.46.0" diff --git a/common/fee-estimator-module/Cargo.toml b/common/fee-estimator-module/Cargo.toml index 88663e5d..4338c3bf 100644 --- a/common/fee-estimator-module/Cargo.toml +++ b/common/fee-estimator-module/Cargo.toml @@ -5,7 +5,7 @@ authors = ["dorin-iancu "] edition = "2018" [dependencies.multiversx-sc] -version = "0.45.2" +version = "0.46.0" [dev-dependencies.multiversx-sc-scenario] -version = "0.45.2" +version = "0.46.0" diff --git a/common/max-bridged-amount-module/Cargo.toml b/common/max-bridged-amount-module/Cargo.toml index 010ce5a2..5e9c56b7 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.45.2" +version = "0.46.0" [dev-dependencies.multiversx-sc-scenario] -version = "0.45.2" +version = "0.46.0" diff --git a/common/token-module/Cargo.toml b/common/token-module/Cargo.toml index 207621c7..7362cd18 100644 --- a/common/token-module/Cargo.toml +++ b/common/token-module/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" path = "../fee-estimator-module" [dependencies.multiversx-sc] -version = "0.45.2" +version = "0.46.0" [dev-dependencies.multiversx-sc-scenario] -version = "0.45.2" +version = "0.46.0" diff --git a/common/transaction/Cargo.toml b/common/transaction/Cargo.toml index c1f3d18c..e5fb3913 100644 --- a/common/transaction/Cargo.toml +++ b/common/transaction/Cargo.toml @@ -11,4 +11,4 @@ path = "src/lib.rs" path = "../eth-address" [dependencies.multiversx-sc] -version = "0.45.2" +version = "0.46.0" diff --git a/common/tx-batch-module/Cargo.toml b/common/tx-batch-module/Cargo.toml index 3d58cda8..8dbd6559 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.45.2" +version = "0.46.0" [dependencies.transaction] path = "../transaction" [dev-dependencies.multiversx-sc-scenario] -version = "0.45.2" +version = "0.46.0" diff --git a/esdt-safe/Cargo.toml b/esdt-safe/Cargo.toml index bdbc3284..5a9aa27b 100644 --- a/esdt-safe/Cargo.toml +++ b/esdt-safe/Cargo.toml @@ -27,13 +27,13 @@ path = "../common/tx-batch-module" path = "../common/max-bridged-amount-module" [dependencies.multiversx-price-aggregator-sc] -version = "0.45.2" +version = "0.46.0" [dependencies.multiversx-sc] -version = "0.45.2" +version = "0.46.0" [dependencies.multiversx-sc-modules] -version = "0.45.2" +version = "0.46.0" [dev-dependencies.multiversx-sc-scenario] -version = "0.45.2" +version = "0.46.0" diff --git a/esdt-safe/meta/Cargo.toml b/esdt-safe/meta/Cargo.toml index 00e7a9e7..68ca15bb 100644 --- a/esdt-safe/meta/Cargo.toml +++ b/esdt-safe/meta/Cargo.toml @@ -11,5 +11,5 @@ publish = false path = ".." [dependencies.multiversx-sc-meta] -version = "0.45.2" +version = "0.46.0" default-features = false diff --git a/esdt-safe/wasm/Cargo.toml b/esdt-safe/wasm/Cargo.toml index 196a688a..071b7ec4 100644 --- a/esdt-safe/wasm/Cargo.toml +++ b/esdt-safe/wasm/Cargo.toml @@ -25,7 +25,7 @@ overflow-checks = false path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.45.2" +version = "0.46.0" [workspace] members = ["."] diff --git a/multi-transfer-esdt/Cargo.toml b/multi-transfer-esdt/Cargo.toml index a22e4093..2bf1d2f4 100644 --- a/multi-transfer-esdt/Cargo.toml +++ b/multi-transfer-esdt/Cargo.toml @@ -33,10 +33,10 @@ path = "../esdt-safe" path = "../common/token-module" [dependencies.multiversx-sc] -version = "0.45.2" - -[dev-dependencies.multiversx-sc-scenario] -version = "0.45.2" +version = "0.46.0" [dependencies.multiversx-sc-modules] -version = "0.45.2" +version = "0.46.0" + +[dev-dependencies.multiversx-sc-scenario] +version = "0.46.0" diff --git a/multi-transfer-esdt/meta/Cargo.toml b/multi-transfer-esdt/meta/Cargo.toml index 7582654f..16530d42 100644 --- a/multi-transfer-esdt/meta/Cargo.toml +++ b/multi-transfer-esdt/meta/Cargo.toml @@ -11,5 +11,5 @@ publish = false path = ".." [dependencies.multiversx-sc-meta] -version = "0.45.2" +version = "0.46.0" default-features = false diff --git a/multi-transfer-esdt/wasm/Cargo.lock b/multi-transfer-esdt/wasm/Cargo.lock index 6abca25d..5ff0f22f 100644 --- a/multi-transfer-esdt/wasm/Cargo.lock +++ b/multi-transfer-esdt/wasm/Cargo.lock @@ -2,24 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "ahash" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] -name = "allocator-api2" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" - [[package]] name = "arrayvec" version = "0.7.4" @@ -56,6 +38,12 @@ dependencies = [ "transaction", ] +[[package]] +name = "bumpalo" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" + [[package]] name = "cfg-if" version = "1.0.0" @@ -75,6 +63,7 @@ dependencies = [ "eth-address", "fee-estimator-module", "max-bridged-amount-module", + "multiversx-price-aggregator-sc", "multiversx-sc", "multiversx-sc-modules", "token-module", @@ -97,13 +86,16 @@ dependencies = [ ] [[package]] -name = "hashbrown" -version = "0.14.3" +name = "getrandom" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ - "ahash", - "allocator-api2", + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", ] [[package]] @@ -118,6 +110,27 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "js-sys" +version = "0.3.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.151" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + [[package]] name = "max-bridged-amount-module" version = "0.0.0" @@ -149,14 +162,26 @@ dependencies = [ "multiversx-sc-wasm-adapter", ] +[[package]] +name = "multiversx-price-aggregator-sc" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd93dff2ebf61fe728609ef3fdeb451852524ad4eb559ba45bc2194d801edf17" +dependencies = [ + "arrayvec", + "getrandom", + "multiversx-sc", + "multiversx-sc-modules", + "rand", +] + [[package]] name = "multiversx-sc" -version = "0.45.2" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2bdb196b3ff2b9f8c744ec2e026c22c8e02bc91e5c6ed09951415c47fef6b8" +checksum = "9fff591179642ac99baad6050ff73ec98f0be45e4f2043ec2a9c222dcef94194" dependencies = [ "bitflags", - "hashbrown", "hex-literal", "multiversx-sc-codec", "multiversx-sc-derive", @@ -187,9 +212,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.45.2" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e60b5dce707f61376f74d713218f75326121d9f6a5f09a3a63de7aea2a92be9" +checksum = "f24329c73b4bfd9fae9186a397a358b26deaeac14e10234bb27838fc618cad8b" dependencies = [ "hex", "proc-macro2", @@ -200,18 +225,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.45.2" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5833f8bc88104357d38a8952d2a16c3e66080e2e512c0e7001c0c003006c475" +checksum = "4088eb7642032b69f7b9961b505c2bffce852f795c60dc490e22a6037124f0c0" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.45.2" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4299660d5413d9f120bfddda8105b1f9d28f0345a72f53e5dc90732c4983e45" +checksum = "ace7a78b860a27b1bf2b6f2840d1cf40516b85c44e80ba34663b3388079afba8" dependencies = [ "multiversx-sc", ] @@ -240,6 +265,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + [[package]] name = "proc-macro2" version = "1.0.74" @@ -268,6 +299,36 @@ dependencies = [ "nibble_vec", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + [[package]] name = "smallvec" version = "1.11.2" @@ -316,27 +377,61 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] -name = "version_check" -version = "0.9.4" +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "zerocopy" -version = "0.7.32" +name = "wasm-bindgen" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" dependencies = [ - "zerocopy-derive", + "cfg-if", + "wasm-bindgen-macro", ] [[package]] -name = "zerocopy-derive" -version = "0.7.32" +name = "wasm-bindgen-backend" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" dependencies = [ + "bumpalo", + "log", + "once_cell", "proc-macro2", "quote", "syn", + "wasm-bindgen-shared", ] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" diff --git a/multi-transfer-esdt/wasm/Cargo.toml b/multi-transfer-esdt/wasm/Cargo.toml index 69f59530..d2d9e843 100644 --- a/multi-transfer-esdt/wasm/Cargo.toml +++ b/multi-transfer-esdt/wasm/Cargo.toml @@ -25,7 +25,7 @@ overflow-checks = false path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.45.2" +version = "0.46.0" [workspace] members = ["."] diff --git a/multisig/Cargo.toml b/multisig/Cargo.toml index 67819826..44609f03 100644 --- a/multisig/Cargo.toml +++ b/multisig/Cargo.toml @@ -33,13 +33,13 @@ path = "../esdt-safe" path = "../multi-transfer-esdt" [dependencies.multiversx-sc] -version = "0.45.2" +version = "0.46.0" [dependencies.multiversx-price-aggregator-sc] -version = "0.45.2" +version = "0.46.0" [dependencies.multiversx-sc-modules] -version = "0.45.2" +version = "0.46.0" [dev-dependencies.multiversx-sc-scenario] -version = "0.45.2" \ No newline at end of file +version = "0.46.0" diff --git a/multisig/meta/Cargo.toml b/multisig/meta/Cargo.toml index ec3e8100..3c938171 100644 --- a/multisig/meta/Cargo.toml +++ b/multisig/meta/Cargo.toml @@ -9,5 +9,5 @@ publish = false path = ".." [dependencies.multiversx-sc-meta] -version = "0.45.2" +version = "0.46.0" default-features = false diff --git a/multisig/wasm/Cargo.lock b/multisig/wasm/Cargo.lock index f0556566..2807d24c 100644 --- a/multisig/wasm/Cargo.lock +++ b/multisig/wasm/Cargo.lock @@ -2,24 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "ahash" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] -name = "allocator-api2" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" - [[package]] name = "arrayvec" version = "0.7.4" @@ -56,6 +38,12 @@ dependencies = [ "transaction", ] +[[package]] +name = "bumpalo" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" + [[package]] name = "cfg-if" version = "1.0.0" @@ -75,6 +63,7 @@ dependencies = [ "eth-address", "fee-estimator-module", "max-bridged-amount-module", + "multiversx-price-aggregator-sc", "multiversx-sc", "multiversx-sc-modules", "token-module", @@ -97,13 +86,16 @@ dependencies = [ ] [[package]] -name = "hashbrown" -version = "0.14.3" +name = "getrandom" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ - "ahash", - "allocator-api2", + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", ] [[package]] @@ -118,6 +110,27 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "js-sys" +version = "0.3.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.151" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + [[package]] name = "max-bridged-amount-module" version = "0.0.0" @@ -150,6 +163,7 @@ dependencies = [ "fee-estimator-module", "max-bridged-amount-module", "multi-transfer-esdt", + "multiversx-price-aggregator-sc", "multiversx-sc", "multiversx-sc-modules", "token-module", @@ -165,14 +179,26 @@ dependencies = [ "multiversx-sc-wasm-adapter", ] +[[package]] +name = "multiversx-price-aggregator-sc" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd93dff2ebf61fe728609ef3fdeb451852524ad4eb559ba45bc2194d801edf17" +dependencies = [ + "arrayvec", + "getrandom", + "multiversx-sc", + "multiversx-sc-modules", + "rand", +] + [[package]] name = "multiversx-sc" -version = "0.45.2" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2bdb196b3ff2b9f8c744ec2e026c22c8e02bc91e5c6ed09951415c47fef6b8" +checksum = "9fff591179642ac99baad6050ff73ec98f0be45e4f2043ec2a9c222dcef94194" dependencies = [ "bitflags", - "hashbrown", "hex-literal", "multiversx-sc-codec", "multiversx-sc-derive", @@ -203,9 +229,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.45.2" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e60b5dce707f61376f74d713218f75326121d9f6a5f09a3a63de7aea2a92be9" +checksum = "f24329c73b4bfd9fae9186a397a358b26deaeac14e10234bb27838fc618cad8b" dependencies = [ "hex", "proc-macro2", @@ -216,18 +242,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.45.2" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5833f8bc88104357d38a8952d2a16c3e66080e2e512c0e7001c0c003006c475" +checksum = "4088eb7642032b69f7b9961b505c2bffce852f795c60dc490e22a6037124f0c0" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.45.2" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4299660d5413d9f120bfddda8105b1f9d28f0345a72f53e5dc90732c4983e45" +checksum = "ace7a78b860a27b1bf2b6f2840d1cf40516b85c44e80ba34663b3388079afba8" dependencies = [ "multiversx-sc", ] @@ -256,6 +282,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + [[package]] name = "proc-macro2" version = "1.0.75" @@ -284,6 +316,36 @@ dependencies = [ "nibble_vec", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + [[package]] name = "smallvec" version = "1.11.2" @@ -332,27 +394,61 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] -name = "version_check" -version = "0.9.4" +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "zerocopy" -version = "0.7.32" +name = "wasm-bindgen" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" dependencies = [ - "zerocopy-derive", + "cfg-if", + "wasm-bindgen-macro", ] [[package]] -name = "zerocopy-derive" -version = "0.7.32" +name = "wasm-bindgen-backend" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" dependencies = [ + "bumpalo", + "log", + "once_cell", "proc-macro2", "quote", "syn", + "wasm-bindgen-shared", ] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" diff --git a/multisig/wasm/Cargo.toml b/multisig/wasm/Cargo.toml index b6d0ab00..467bf3bf 100644 --- a/multisig/wasm/Cargo.toml +++ b/multisig/wasm/Cargo.toml @@ -25,7 +25,7 @@ overflow-checks = false path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.45.2" +version = "0.46.0" [workspace] members = ["."] From fb20be976bebc05814bb5d9250aee1fb844a2679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Fri, 5 Jan 2024 19:35:16 +0200 Subject: [PATCH 44/50] esdt-safe: tests: ix roles --- esdt-safe/scenarios/add_refund_batch.scen.json | 2 +- .../create_another_tx_too_late_for_batch.scen.json | 6 ++++-- esdt-safe/scenarios/distribute_fees.scen.json | 2 +- .../scenarios/execute_batch_both_rejected.scen.json | 3 ++- .../scenarios/execute_batch_both_success.scen.json | 10 +++++----- .../execute_batch_one_success_one_rejected.scen.json | 10 +++++----- .../scenarios/execute_transaction_rejected.scen.json | 3 ++- .../scenarios/execute_transaction_success.scen.json | 3 ++- multisig/interaction/config/upgrade-snippets.sh | 2 +- multisig/src/setup.rs | 2 +- multisig/wasm/src/lib.rs | 2 +- 11 files changed, 25 insertions(+), 20 deletions(-) diff --git a/esdt-safe/scenarios/add_refund_batch.scen.json b/esdt-safe/scenarios/add_refund_batch.scen.json index c88b0013..4e749d92 100644 --- a/esdt-safe/scenarios/add_refund_batch.scen.json +++ b/esdt-safe/scenarios/add_refund_batch.scen.json @@ -59,7 +59,7 @@ "str:BRIDGE-123456": { "balance": "3,001,300", "roles": [ - "ESDTRoleLocalBurn" + "ESDTRoleLocalBurn","ESDTRoleLocalMint" ] } }, diff --git a/esdt-safe/scenarios/create_another_tx_too_late_for_batch.scen.json b/esdt-safe/scenarios/create_another_tx_too_late_for_batch.scen.json index e00dbcbb..811c9c0a 100644 --- a/esdt-safe/scenarios/create_another_tx_too_late_for_batch.scen.json +++ b/esdt-safe/scenarios/create_another_tx_too_late_for_batch.scen.json @@ -84,7 +84,8 @@ "str:BRIDGE-123456": { "balance": "4,501,400", "roles": [ - "ESDTRoleLocalBurn" + "ESDTRoleLocalBurn", + "ESDTRoleLocalMint" ] } }, @@ -215,7 +216,8 @@ "str:BRIDGE-123456": { "balance": "6,001,500", "roles": [ - "ESDTRoleLocalBurn" + "ESDTRoleLocalBurn", + "ESDTRoleLocalMint" ] } }, diff --git a/esdt-safe/scenarios/distribute_fees.scen.json b/esdt-safe/scenarios/distribute_fees.scen.json index fee008ef..ff0fed43 100644 --- a/esdt-safe/scenarios/distribute_fees.scen.json +++ b/esdt-safe/scenarios/distribute_fees.scen.json @@ -45,7 +45,7 @@ "str:BRIDGE-123456": { "balance": "400", "roles": [ - "ESDTRoleLocalBurn" + "ESDTRoleLocalBurn","ESDTRoleLocalMint" ] } }, diff --git a/esdt-safe/scenarios/execute_batch_both_rejected.scen.json b/esdt-safe/scenarios/execute_batch_both_rejected.scen.json index 55d42cc2..ab8b3056 100644 --- a/esdt-safe/scenarios/execute_batch_both_rejected.scen.json +++ b/esdt-safe/scenarios/execute_batch_both_rejected.scen.json @@ -97,7 +97,8 @@ "str:BRIDGE-123456": { "balance": "3,000,000", "roles": [ - "ESDTRoleLocalBurn" + "ESDTRoleLocalBurn", + "ESDTRoleLocalMint" ] } }, diff --git a/esdt-safe/scenarios/execute_batch_both_success.scen.json b/esdt-safe/scenarios/execute_batch_both_success.scen.json index ec05db60..f4bcfdef 100644 --- a/esdt-safe/scenarios/execute_batch_both_success.scen.json +++ b/esdt-safe/scenarios/execute_batch_both_success.scen.json @@ -15,7 +15,8 @@ "function": "setTransactionBatchStatus", "arguments": [ "1", - "3", "3" + "3", + "3" ], "gasLimit": "50,000,000", "gasPrice": "0" @@ -95,7 +96,8 @@ "str:BRIDGE-123456": { "balance": "3,001,300", "roles": [ - "ESDTRoleLocalBurn" + "ESDTRoleLocalBurn", + "ESDTRoleLocalMint" ] } }, @@ -103,9 +105,7 @@ "str:pendingBatches|u64:1": "", "str:firstBatchId": "2", "str:lastBatchId": "2", - "str:accumulatedTransactionFees|nested:str:BRIDGE-123456": "3,000,000", - "+": "" }, "code": "file:../output/esdt-safe.wasm" @@ -114,4 +114,4 @@ } } ] -} +} \ No newline at end of file diff --git a/esdt-safe/scenarios/execute_batch_one_success_one_rejected.scen.json b/esdt-safe/scenarios/execute_batch_one_success_one_rejected.scen.json index d94de8e8..2244cbe0 100644 --- a/esdt-safe/scenarios/execute_batch_one_success_one_rejected.scen.json +++ b/esdt-safe/scenarios/execute_batch_one_success_one_rejected.scen.json @@ -15,7 +15,8 @@ "function": "setTransactionBatchStatus", "arguments": [ "1", - "3", "4" + "3", + "4" ], "gasLimit": "50,000,000", "gasPrice": "0" @@ -96,7 +97,8 @@ "str:BRIDGE-123456": { "balance": "3,000,400", "roles": [ - "ESDTRoleLocalBurn" + "ESDTRoleLocalBurn", + "ESDTRoleLocalMint" ] } }, @@ -104,9 +106,7 @@ "str:pendingBatches|u64:1": "", "str:firstBatchId": "2", "str:lastBatchId": "2", - "str:accumulatedTransactionFees|nested:str:BRIDGE-123456": "3,000,000", - "+": "" }, "code": "file:../output/esdt-safe.wasm" @@ -115,4 +115,4 @@ } } ] -} +} \ No newline at end of file diff --git a/esdt-safe/scenarios/execute_transaction_rejected.scen.json b/esdt-safe/scenarios/execute_transaction_rejected.scen.json index 52a289ac..1d61d733 100644 --- a/esdt-safe/scenarios/execute_transaction_rejected.scen.json +++ b/esdt-safe/scenarios/execute_transaction_rejected.scen.json @@ -67,7 +67,8 @@ "str:BRIDGE-123456": { "balance": "1,500,000", "roles": [ - "ESDTRoleLocalBurn" + "ESDTRoleLocalBurn", + "ESDTRoleLocalMint" ] } }, diff --git a/esdt-safe/scenarios/execute_transaction_success.scen.json b/esdt-safe/scenarios/execute_transaction_success.scen.json index 7616dff9..1731749b 100644 --- a/esdt-safe/scenarios/execute_transaction_success.scen.json +++ b/esdt-safe/scenarios/execute_transaction_success.scen.json @@ -66,7 +66,8 @@ "str:BRIDGE-123456": { "balance": "1,500,400", "roles": [ - "ESDTRoleLocalBurn" + "ESDTRoleLocalBurn", + "ESDTRoleLocalMint" ] } }, diff --git a/multisig/interaction/config/upgrade-snippets.sh b/multisig/interaction/config/upgrade-snippets.sh index f2a6090d..a612104a 100644 --- a/multisig/interaction/config/upgrade-snippets.sh +++ b/multisig/interaction/config/upgrade-snippets.sh @@ -2,7 +2,7 @@ deploySafeForUpgrade() { getAggregatorAddressHex - local ESDT_SAFE_ETH_TX_GAS_LIMIT=20000 # gives us 200$ for elrond->eth + local ESDT_SAFE_ETH_TX_GAS_LIMIT=20000 # gives us 200$ for multiversx->eth mxpy --verbose contract deploy --project=${PROJECT_SAFE} --recall-nonce --pem=${ALICE} \ --gas-limit=150000000 \ diff --git a/multisig/src/setup.rs b/multisig/src/setup.rs index 2dd9b0bf..85abd174 100644 --- a/multisig/src/setup.rs +++ b/multisig/src/setup.rs @@ -171,7 +171,7 @@ pub trait SetupModule: /// where price_per_gas_unit is queried from the aggregator (fee estimator SC) #[only_owner] #[endpoint(changeElrondToEthGasLimit)] - fn change_elrond_to_eth_gas_limit(&self, new_gas_limit: BigUint) { + fn change_multiversx_to_eth_gas_limit(&self, new_gas_limit: BigUint) { let _: IgnoreValue = self .get_esdt_safe_proxy_instance() .set_eth_tx_gas_limit(new_gas_limit) diff --git a/multisig/wasm/src/lib.rs b/multisig/wasm/src/lib.rs index 6e2ab6ea..f5203310 100644 --- a/multisig/wasm/src/lib.rs +++ b/multisig/wasm/src/lib.rs @@ -39,7 +39,7 @@ multiversx_sc_wasm_adapter::endpoints! { pauseEsdtSafe => pause_esdt_safe unpauseEsdtSafe => unpause_esdt_safe changeFeeEstimatorContractAddress => change_fee_estimator_contract_address - changeElrondToEthGasLimit => change_elrond_to_eth_gas_limit + changeElrondToEthGasLimit => change_multiversx_to_eth_gas_limit changeDefaultPricePerGasUnit => change_default_price_per_gas_unit changeTokenTicker => change_token_ticker esdtSafeAddTokenToWhitelist => esdt_safe_add_token_to_whitelist From ba6292bb6c25c2d58269c849aaacc17f104d70e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Tue, 9 Jan 2024 15:40:16 +0200 Subject: [PATCH 45/50] Bridge-proxy: Add option for args + tests --- bridge-proxy/Cargo.toml | 4 + bridge-proxy/src/bridge-proxy.rs | 3 +- .../tests/bridge_proxy_blackbox_test.rs | 241 ++++++++++++++---- bridge-proxy/wasm/Cargo.lock | 9 + common/transaction/src/lib.rs | 12 +- .../tests/multi_transfer_blackbox_test.rs | 12 - multi-transfer-esdt/wasm/Cargo.lock | 9 + multisig/src/util.rs | 3 +- multisig/wasm/Cargo.lock | 9 + 9 files changed, 235 insertions(+), 67 deletions(-) diff --git a/bridge-proxy/Cargo.toml b/bridge-proxy/Cargo.toml index 4b04e1c1..a321b276 100644 --- a/bridge-proxy/Cargo.toml +++ b/bridge-proxy/Cargo.toml @@ -22,3 +22,7 @@ num-bigint = "0.4.2" [dev-dependencies.multiversx-sc-scenario] version = "0.46.0" + +[dependencies.adder] +git = "https://github.com/multiversx/mx-contracts-rs" +rev = "64e8926" \ No newline at end of file diff --git a/bridge-proxy/src/bridge-proxy.rs b/bridge-proxy/src/bridge-proxy.rs index 5742fcbf..b058bacd 100644 --- a/bridge-proxy/src/bridge-proxy.rs +++ b/bridge-proxy/src/bridge-proxy.rs @@ -32,11 +32,12 @@ pub trait BridgeProxyContract: config::ConfigModule { let tx_node = self .eth_transaction_list() .remove_node_by_id(tx_id) - .unwrap_or_else(|| sc_panic!("No more ETH transactions!")); + .unwrap_or_else(|| sc_panic!("Invalid ETH transaction!")); let tx = tx_node.get_value_as_ref(); self.send() .contract_call::(tx.eth_tx.to.clone(), tx.eth_tx.data.clone()) + .with_raw_arguments(tx.eth_tx.args.clone().into()) .with_esdt_transfer((tx.token_id.clone(), tx.nonce, tx.amount.clone())) .with_gas_limit(tx.eth_tx.gas_limit) .async_call() diff --git a/bridge-proxy/tests/bridge_proxy_blackbox_test.rs b/bridge-proxy/tests/bridge_proxy_blackbox_test.rs index 1902f57f..9a3e1002 100644 --- a/bridge-proxy/tests/bridge_proxy_blackbox_test.rs +++ b/bridge-proxy/tests/bridge_proxy_blackbox_test.rs @@ -2,20 +2,25 @@ use std::collections::LinkedList; +use adder::{Adder, ProxyTrait as _}; use bridge_proxy::config::ProxyTrait as _; use bridge_proxy::ProxyTrait; use multiversx_sc::{ - api::ManagedTypeApi, - codec::multi_types::{MultiValueVec, OptionalValue}, + api::{HandleConstraints, ManagedTypeApi}, + codec::{ + multi_types::{MultiValueVec, OptionalValue}, + TopEncodeMultiOutput, + }, storage::mappers::SingleValue, types::{ - Address, BigUint, CodeMetadata, ManagedAddress, ManagedBuffer, ManagedByteArray, - TokenIdentifier, + Address, BigUint, CodeMetadata, ManagedAddress, ManagedArgBuffer, ManagedBuffer, + ManagedByteArray, ManagedVec, TokenIdentifier, }, }; use multiversx_sc_scenario::{ api::StaticApi, + rust_biguint, scenario_format::interpret_trait::{InterpretableFrom, InterpreterContext}, scenario_model::*, ContractInfo, ScenarioWorld, @@ -27,60 +32,27 @@ use transaction::{EthTransaction, EthTransactionPayment}; const BRIDGE_TOKEN_ID: &[u8] = b"BRIDGE-123456"; const GAS_LIMIT: u64 = 1_000_000; const BRIDGE_PROXY_PATH_EXPR: &str = "file:output/bridge-proxy.wasm"; +const ADDER_BOGUS_PATH_EXPR: &str = "file:bogus-path.wasm"; fn world() -> ScenarioWorld { let mut blockchain = ScenarioWorld::new(); blockchain.register_contract(BRIDGE_PROXY_PATH_EXPR, bridge_proxy::ContractBuilder); - blockchain -} - -#[test] -fn deploy_deposit_test() { - let mut test = BridgeProxyTestState::setup(); - let bridge_token_id_expr = "str:BRIDGE-123456"; // when specifying the token transfer - - test.bridge_proxy_deploy(); + blockchain.register_contract(ADDER_BOGUS_PATH_EXPR, adder::ContractBuilder); - let eth_tx = EthTransaction { - from: test.eth_user, - to: ManagedAddress::from_address(&test.user.value), - token_id: TokenIdentifier::from_esdt_bytes(BRIDGE_TOKEN_ID), - amount: BigUint::from(500u64), - tx_nonce: 1u64, - data: ManagedBuffer::from("data"), - gas_limit: GAS_LIMIT, - }; - - test.world.set_state_step(SetStateStep::new().put_account( - &test.owner, - Account::new().esdt_balance(bridge_token_id_expr, 1_000u64), - )); - - test.world.sc_call( - ScCallStep::new() - .from(&test.owner) - .to(&test.bridge_proxy) - .call(test.bridge_proxy.deposit(ð_tx)) - .esdt_transfer(bridge_token_id_expr, 0u64, 500u64), - ); - - test.world.sc_query( - ScQueryStep::new() - .to(&test.bridge_proxy) - .call(test.bridge_proxy.get_eth_transaction_by_id(1u32)) - .expect_value(eth_tx), - ); + blockchain } type BridgeProxyContract = ContractInfo>; +type AdderContract = ContractInfo>; struct BridgeProxyTestState { world: ScenarioWorld, owner: AddressValue, user: AddressValue, eth_user: EthAddress, - bridge_proxy: BridgeProxyContract, + bridge_proxy_contract: BridgeProxyContract, + adder_contract: AdderContract, } impl BridgeProxyTestState { @@ -95,7 +67,8 @@ impl BridgeProxyTestState { eth_user: EthAddress { raw_addr: ManagedByteArray::default(), }, - bridge_proxy: BridgeProxyContract::new("sc:bridge_proxy"), + bridge_proxy_contract: BridgeProxyContract::new("sc:bridge_proxy"), + adder_contract: AdderContract::new("sc:adder"), }; state @@ -109,7 +82,7 @@ impl BridgeProxyTestState { self.world.set_state_step( SetStateStep::new() .put_account(&self.owner, Account::new().nonce(1)) - .new_address(&self.owner, 1, &self.bridge_proxy), + .new_address(&self.owner, 1, &self.bridge_proxy_contract), ); let ic = &self.world.interpreter_context(); @@ -117,9 +90,185 @@ impl BridgeProxyTestState { ScDeployStep::new() .from(self.owner.clone()) .code(self.world.code_expression(BRIDGE_PROXY_PATH_EXPR)) - .call(self.bridge_proxy.init(ManagedAddress::zero())), + .call(self.bridge_proxy_contract.init(ManagedAddress::zero())), + ); + + self + } + + fn deploy_adder(&mut self) -> &mut Self { + self.world.set_state_step(SetStateStep::new().new_address( + &self.owner, + 2, + &self.adder_contract, + )); + + self.world.sc_deploy( + ScDeployStep::new() + .from(self.owner.clone()) + .code(self.world.code_expression(ADDER_BOGUS_PATH_EXPR)) + .call(self.adder_contract.init(BigUint::zero())), ); self } } + +#[test] +fn deploy_deposit_test() { + let mut test = BridgeProxyTestState::setup(); + let bridge_token_id_expr = "str:BRIDGE-123456"; // when specifying the token transfer + + test.bridge_proxy_deploy(); + test.deploy_adder(); + + let mut args = ManagedVec::new(); + args.push(ManagedBuffer::from(&[5u8])); + + let eth_tx = EthTransaction { + from: test.eth_user.clone(), + to: ManagedAddress::from_address(&test.adder_contract.to_address()), + token_id: TokenIdentifier::from_esdt_bytes(BRIDGE_TOKEN_ID), + amount: BigUint::from(500u64), + tx_nonce: 1u64, + data: ManagedBuffer::from(b"add"), + gas_limit: GAS_LIMIT, + args, + }; + + test.world.set_state_step(SetStateStep::new().put_account( + &test.owner, + Account::new().esdt_balance(bridge_token_id_expr, 1_000u64), + )); + + test.world.sc_call( + ScCallStep::new() + .from(&test.owner) + .to(&test.bridge_proxy_contract) + .call(test.bridge_proxy_contract.deposit(ð_tx)) + .esdt_transfer(bridge_token_id_expr, 0u64, 500u64), + ); + + test.world.sc_query( + ScQueryStep::new() + .to(&test.bridge_proxy_contract) + .call(test.bridge_proxy_contract.get_eth_transaction_by_id(1u32)) + .expect_value(eth_tx), + ); + + test.world.sc_call( + ScCallStep::new() + .from(&test.owner) + .to(&test.bridge_proxy_contract) + .call(test.bridge_proxy_contract.execute_with_async(1u32)), + ); + + test.world.sc_query( + ScQueryStep::new() + .to(&test.adder_contract) + .call(test.adder_contract.sum()) + .expect_value(SingleValue::from(BigUint::from(5u32))), + ); +} + + +#[test] +fn multiple_deposit_test() { + let mut test = BridgeProxyTestState::setup(); + let bridge_token_id_expr = "str:BRIDGE-123456"; // when specifying the token transfer + + test.bridge_proxy_deploy(); + test.deploy_adder(); + + let mut args1 = ManagedVec::new(); + args1.push(ManagedBuffer::from(&[5u8])); + + let eth_tx1 = EthTransaction { + from: test.eth_user.clone(), + to: ManagedAddress::from_address(&test.adder_contract.to_address()), + token_id: TokenIdentifier::from_esdt_bytes(BRIDGE_TOKEN_ID), + amount: BigUint::from(500u64), + tx_nonce: 1u64, + data: ManagedBuffer::from(b"add"), + gas_limit: GAS_LIMIT, + args: args1, + }; + + let mut args2 = ManagedVec::new(); + args2.push(ManagedBuffer::from(&[15u8])); + + let eth_tx2 = EthTransaction { + from: test.eth_user.clone(), + to: ManagedAddress::from_address(&test.adder_contract.to_address()), + token_id: TokenIdentifier::from_esdt_bytes(BRIDGE_TOKEN_ID), + amount: BigUint::zero(), + tx_nonce: 1u64, + data: ManagedBuffer::from(b"add"), + gas_limit: GAS_LIMIT, + args: args2, + }; + + test.world.set_state_step(SetStateStep::new().put_account( + &test.owner, + Account::new().esdt_balance(bridge_token_id_expr, 1_000u64), + )); + + test.world.sc_call( + ScCallStep::new() + .from(&test.owner) + .to(&test.bridge_proxy_contract) + .call(test.bridge_proxy_contract.deposit(ð_tx1)) + .esdt_transfer(bridge_token_id_expr, 0u64, 500u64), + ); + + test.world.sc_call( + ScCallStep::new() + .from(&test.owner) + .to(&test.bridge_proxy_contract) + .call(test.bridge_proxy_contract.deposit(ð_tx2)) + .esdt_transfer(bridge_token_id_expr, 0u64, 0u64), + ); + + test.world.sc_query( + ScQueryStep::new() + .to(&test.bridge_proxy_contract) + .call(test.bridge_proxy_contract.get_eth_transaction_by_id(1u32)) + .expect_value(eth_tx1), + ); + + test.world.sc_query( + ScQueryStep::new() + .to(&test.bridge_proxy_contract) + .call(test.bridge_proxy_contract.get_eth_transaction_by_id(2u32)) + .expect_value(eth_tx2), + ); + + test.world.sc_call( + ScCallStep::new() + .from(&test.owner) + .to(&test.bridge_proxy_contract) + .call(test.bridge_proxy_contract.execute_with_async(1u32)), + ); + + test.world.sc_query( + ScQueryStep::new() + .to(&test.adder_contract) + .call(test.adder_contract.sum()) + .expect_value(SingleValue::from(BigUint::from(5u32))), + ); + + test.world.sc_call( + ScCallStep::new() + .from(&test.owner) + .to(&test.bridge_proxy_contract) + .call(test.bridge_proxy_contract.execute_with_async(2u32)), + ); + + test.world.sc_query( + ScQueryStep::new() + .to(&test.adder_contract) + .call(test.adder_contract.sum()) + .expect_value(SingleValue::from(BigUint::from(20u32))), + ); + +} diff --git a/bridge-proxy/wasm/Cargo.lock b/bridge-proxy/wasm/Cargo.lock index 0a24845e..bfe79a1e 100644 --- a/bridge-proxy/wasm/Cargo.lock +++ b/bridge-proxy/wasm/Cargo.lock @@ -2,6 +2,14 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "adder" +version = "0.0.0" +source = "git+https://github.com/multiversx/mx-contracts-rs?rev=64e8926#64e892655f9c59b2aafe07800af61d0fa41c6ddc" +dependencies = [ + "multiversx-sc", +] + [[package]] name = "arrayvec" version = "0.7.4" @@ -24,6 +32,7 @@ checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" name = "bridge-proxy" version = "0.0.0" dependencies = [ + "adder", "eth-address", "multiversx-sc", "transaction", diff --git a/common/transaction/src/lib.rs b/common/transaction/src/lib.rs index 6e7e3028..75e7892b 100644 --- a/common/transaction/src/lib.rs +++ b/common/transaction/src/lib.rs @@ -26,9 +26,7 @@ pub type TxAsMultiValue = MultiValue6< pub type PaymentsVec = ManagedVec>; pub type TxBatchSplitInFields = MultiValue2>>; -#[derive( - TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, ManagedVecItem, Clone, PartialEq, -)] +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, Clone, ManagedVecItem)] pub struct EthTransaction { pub from: EthAddress, pub to: ManagedAddress, @@ -37,9 +35,10 @@ pub struct EthTransaction { pub tx_nonce: TxNonce, pub data: ManagedBuffer, pub gas_limit: u64, + pub args: ManagedVec>, } -pub type EthTxAsMultiValue = MultiValue7< +pub type EthTxAsMultiValue = MultiValue8< EthAddress, ManagedAddress, TokenIdentifier, @@ -47,11 +46,10 @@ pub type EthTxAsMultiValue = MultiValue7< TxNonce, ManagedBuffer, u64, + ManagedVec>, >; -#[derive( - TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, ManagedVecItem, Clone, PartialEq, -)] +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, Clone)] pub struct EthTransactionPayment { pub token_id: TokenIdentifier, pub nonce: u64, diff --git a/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs b/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs index afcaf3ff..f3bc4471 100644 --- a/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs +++ b/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs @@ -252,18 +252,6 @@ impl MultiTransferTestState { BigUint::from(1_000u64), )), ); - - //mint_burn_allowed - - // .sc_call( - // ScCallStep::new() - // .from(self.owner.clone()) - // .to(&self.bridge_proxy) - // .call( - // self.bridge_proxy - // .set_multi_transfer_contract_address(self.multi_transfer.to_address()), - // ), - // ); } } diff --git a/multi-transfer-esdt/wasm/Cargo.lock b/multi-transfer-esdt/wasm/Cargo.lock index 5ff0f22f..30127ce3 100644 --- a/multi-transfer-esdt/wasm/Cargo.lock +++ b/multi-transfer-esdt/wasm/Cargo.lock @@ -2,6 +2,14 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "adder" +version = "0.0.0" +source = "git+https://github.com/multiversx/mx-contracts-rs?rev=64e8926#64e892655f9c59b2aafe07800af61d0fa41c6ddc" +dependencies = [ + "multiversx-sc", +] + [[package]] name = "arrayvec" version = "0.7.4" @@ -24,6 +32,7 @@ checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" name = "bridge-proxy" version = "0.0.0" dependencies = [ + "adder", "eth-address", "multiversx-sc", "transaction", diff --git a/multisig/src/util.rs b/multisig/src/util.rs index e4552e2c..df489c64 100644 --- a/multisig/src/util.rs +++ b/multisig/src/util.rs @@ -49,7 +49,7 @@ pub trait UtilModule: crate::storage::StorageModule { ) -> ManagedVec> { let mut transfers_as_eth_tx = ManagedVec::new(); for transfer in transfers { - let (from, to, token_id, amount, tx_nonce, data, gas_limit) = transfer.into_tuple(); + let (from, to, token_id, amount, tx_nonce, data, gas_limit, args) = transfer.into_tuple(); transfers_as_eth_tx.push(EthTransaction { from, @@ -59,6 +59,7 @@ pub trait UtilModule: crate::storage::StorageModule { tx_nonce, data, gas_limit, + args }); } diff --git a/multisig/wasm/Cargo.lock b/multisig/wasm/Cargo.lock index 2807d24c..15d83057 100644 --- a/multisig/wasm/Cargo.lock +++ b/multisig/wasm/Cargo.lock @@ -2,6 +2,14 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "adder" +version = "0.0.0" +source = "git+https://github.com/multiversx/mx-contracts-rs?rev=64e8926#64e892655f9c59b2aafe07800af61d0fa41c6ddc" +dependencies = [ + "multiversx-sc", +] + [[package]] name = "arrayvec" version = "0.7.4" @@ -24,6 +32,7 @@ checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" name = "bridge-proxy" version = "0.0.0" dependencies = [ + "adder", "eth-address", "multiversx-sc", "transaction", From 8c54750e21fc5ef847dc06674f7056a2ee02fef4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Wed, 10 Jan 2024 09:59:21 +0200 Subject: [PATCH 46/50] Bridge-proxy: transform args to ManagedVec Adjust tests --- .../batch_transfer_both_executed.scen.json | 4 ++-- .../batch_transfer_both_failed.scen.json | 4 ++-- ..._transfer_one_executed_one_failed.scen.json | 4 ++-- .../batch_transfer_to_frozen_account.scen.json | 4 ++-- .../batch_transfer_with_wrapping.scen.json | 6 +++--- .../scenarios/transfer_ok.scen.json | 2 +- .../two_transfers_same_token.scen.json | 4 ++-- .../tests/multi_transfer_blackbox_test.rs | 4 +++- ...thereum_to_multiversx_tx_batch_ok.scen.json | 10 ++++++---- ...m_to_multiversx_tx_batch_rejected.scen.json | 18 +++++++++++++----- 10 files changed, 36 insertions(+), 24 deletions(-) diff --git a/multi-transfer-esdt/scenarios/batch_transfer_both_executed.scen.json b/multi-transfer-esdt/scenarios/batch_transfer_both_executed.scen.json index b4417975..c708c2bd 100644 --- a/multi-transfer-esdt/scenarios/batch_transfer_both_executed.scen.json +++ b/multi-transfer-esdt/scenarios/batch_transfer_both_executed.scen.json @@ -15,8 +15,8 @@ "function": "batchTransferEsdtToken", "arguments": [ "1", - "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:10000000", - "0x0102030405060708091011121314151617181920|address:user2|nested:str:WRAPPED-123456|biguint:500|u64:2|nested:str:data|u64:10000000" + "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:10000000|nested:0", + "0x0102030405060708091011121314151617181920|address:user2|nested:str:WRAPPED-123456|biguint:500|u64:2|nested:str:data|u64:10000000|nested:0" ], "gasLimit": "50,000,000", "gasPrice": "0" diff --git a/multi-transfer-esdt/scenarios/batch_transfer_both_failed.scen.json b/multi-transfer-esdt/scenarios/batch_transfer_both_failed.scen.json index 9b6d48e1..1329c6f4 100644 --- a/multi-transfer-esdt/scenarios/batch_transfer_both_failed.scen.json +++ b/multi-transfer-esdt/scenarios/batch_transfer_both_failed.scen.json @@ -15,8 +15,8 @@ "function": "batchTransferEsdtToken", "arguments": [ "1", - "0x0102030405060708091011121314151617181920|sc:multi_transfer_esdt|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:2000000", - "0x0102030405060708091011121314151617181920|sc:multi_transfer_esdt|nested:str:WRAPPED-123456|biguint:100,500|u64:2|nested:str:data|u64:2000000" + "0x0102030405060708091011121314151617181920|sc:multi_transfer_esdt|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:2000000|nested:0", + "0x0102030405060708091011121314151617181920|sc:multi_transfer_esdt|nested:str:WRAPPED-123456|biguint:100,500|u64:2|nested:str:data|u64:2000000|nested:0" ], "gasLimit": "50,000,000", "gasPrice": "0" diff --git a/multi-transfer-esdt/scenarios/batch_transfer_one_executed_one_failed.scen.json b/multi-transfer-esdt/scenarios/batch_transfer_one_executed_one_failed.scen.json index b6420639..562c799e 100644 --- a/multi-transfer-esdt/scenarios/batch_transfer_one_executed_one_failed.scen.json +++ b/multi-transfer-esdt/scenarios/batch_transfer_one_executed_one_failed.scen.json @@ -15,8 +15,8 @@ "function": "batchTransferEsdtToken", "arguments": [ "1", - "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:1000000", - "0x0102030405060708091011121314151617181920|sc:multi_transfer_esdt|nested:str:WRAPPED-123456|biguint:500|u64:2|nested:str:data|u64:1000000" + "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:1000000|nested:0", + "0x0102030405060708091011121314151617181920|sc:multi_transfer_esdt|nested:str:WRAPPED-123456|biguint:500|u64:2|nested:str:data|u64:1000000|nested:0" ], "gasLimit": "50,000,000", "gasPrice": "0" diff --git a/multi-transfer-esdt/scenarios/batch_transfer_to_frozen_account.scen.json b/multi-transfer-esdt/scenarios/batch_transfer_to_frozen_account.scen.json index dcf91222..9735e012 100644 --- a/multi-transfer-esdt/scenarios/batch_transfer_to_frozen_account.scen.json +++ b/multi-transfer-esdt/scenarios/batch_transfer_to_frozen_account.scen.json @@ -35,8 +35,8 @@ "function": "batchTransferEsdtToken", "arguments": [ "1", - "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:10000000", - "0x0102030405060708091011121314151617181920|address:frozen_user|nested:str:BRIDGE-123456|biguint:500|u64:2|nested:str:data|u64:10000000" + "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:10000000|nested:0", + "0x0102030405060708091011121314151617181920|address:frozen_user|nested:str:BRIDGE-123456|biguint:500|u64:2|nested:str:data|u64:10000000|nested:0" ], "gasLimit": "50,000,000", "gasPrice": "0" diff --git a/multi-transfer-esdt/scenarios/batch_transfer_with_wrapping.scen.json b/multi-transfer-esdt/scenarios/batch_transfer_with_wrapping.scen.json index c08275c1..22d53384 100644 --- a/multi-transfer-esdt/scenarios/batch_transfer_with_wrapping.scen.json +++ b/multi-transfer-esdt/scenarios/batch_transfer_with_wrapping.scen.json @@ -284,9 +284,9 @@ "function": "batchTransferEsdtToken", "arguments": [ "1", - "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:2000000", - "0x0102030405060708091011121314151617181920|address:user2|nested:str:USDC-aaaaaa|biguint:500,000,000,000,000|u64:2|nested:str:data|u64:2000000", - "0x0102030405060708091011121314151617181920|address:user1|nested:str:USDC-cccccc|biguint:1,000,000,000,000,000|u64:3|nested:str:data|u64:2000000" + "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:2000000|nested:0", + "0x0102030405060708091011121314151617181920|address:user2|nested:str:USDC-aaaaaa|biguint:500,000,000,000,000|u64:2|nested:str:data|u64:2000000|nested:0", + "0x0102030405060708091011121314151617181920|address:user1|nested:str:USDC-cccccc|biguint:1,000,000,000,000,000|u64:3|nested:str:data|u64:2000000|nested:0" ], "gasLimit": "50,000,000", "gasPrice": "0" diff --git a/multi-transfer-esdt/scenarios/transfer_ok.scen.json b/multi-transfer-esdt/scenarios/transfer_ok.scen.json index 4768ca5e..2277c198 100644 --- a/multi-transfer-esdt/scenarios/transfer_ok.scen.json +++ b/multi-transfer-esdt/scenarios/transfer_ok.scen.json @@ -15,7 +15,7 @@ "function": "batchTransferEsdtToken", "arguments": [ "1", - "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:10000000" + "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:10000000|nested:0" ], "gasLimit": "50,000,000", "gasPrice": "0" diff --git a/multi-transfer-esdt/scenarios/two_transfers_same_token.scen.json b/multi-transfer-esdt/scenarios/two_transfers_same_token.scen.json index 02d29c99..d58f4972 100644 --- a/multi-transfer-esdt/scenarios/two_transfers_same_token.scen.json +++ b/multi-transfer-esdt/scenarios/two_transfers_same_token.scen.json @@ -15,8 +15,8 @@ "function": "batchTransferEsdtToken", "arguments": [ "1", - "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:10000000", - "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:2|nested:str:data|u64:10000000" + "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:10000000|nested:0", + "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:2|nested:str:data|u64:10000000|nested:0" ], "gasLimit": "50,000,000", "gasPrice": "0" diff --git a/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs b/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs index f3bc4471..65e94c94 100644 --- a/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs +++ b/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs @@ -14,7 +14,7 @@ use multiversx_sc::{ storage::mappers::SingleValue, types::{ Address, BigUint, CodeMetadata, ManagedAddress, ManagedBuffer, ManagedByteArray, - MultiValueEncoded, TokenIdentifier, + MultiValueEncoded, TokenIdentifier, ManagedVec, }, }; use multiversx_sc_modules::pause::ProxyTrait; @@ -279,6 +279,7 @@ fn basic_setup_test() { tx_nonce: 1u64, data: ManagedBuffer::from("data"), gas_limit: GAS_LIMIT, + args: ManagedVec::new() }; test.world.check_state_step( @@ -315,6 +316,7 @@ fn basic_transfer_test() { tx_nonce: 1u64, data: ManagedBuffer::from("data"), gas_limit: GAS_LIMIT, + args: ManagedVec::new() }; test.world.check_state_step( diff --git a/multisig/scenarios/ethereum_to_multiversx_tx_batch_ok.scen.json b/multisig/scenarios/ethereum_to_multiversx_tx_batch_ok.scen.json index 661f068a..81310661 100644 --- a/multisig/scenarios/ethereum_to_multiversx_tx_batch_ok.scen.json +++ b/multisig/scenarios/ethereum_to_multiversx_tx_batch_ok.scen.json @@ -15,8 +15,8 @@ "function": "proposeMultiTransferEsdtBatch", "arguments": [ "1", - "0x0102030405060708091011121314151617181920", "address:user", "str:WEGLD-123456", "76,000,000,000", "1", "str:data", "u64:20000000", - "0x0102030405060708091011121314151617181920", "address:user", "str:ETH-123456", "76,000,000,000", "2", "str:data", "u64:20000000" + "0x0102030405060708091011121314151617181920", "address:user", "str:WEGLD-123456", "76,000,000,000", "1", "str:data", "u64:20000000", "0", + "0x0102030405060708091011121314151617181920", "address:user", "str:ETH-123456", "76,000,000,000", "2", "str:data", "u64:20000000", "0" ], "gasLimit": "50,000,000", "gasPrice": "0" @@ -50,7 +50,8 @@ "4-amount": "biguint:76,000,000,000", "5-tx_nonce": "u64:1", "6-data": "nested:str:data", - "7-gas_limit": "u64:20000000" + "7-gas_limit": "u64:20000000", + "8-args": "nested:0" }, { "1-from": "0x0102030405060708091011121314151617181920", @@ -59,7 +60,8 @@ "4-amount": "biguint:76,000,000,000", "5-tx_nonce": "u64:2", "6-data": "nested:str:data", - "7-gas_limit": "u64:20000000" + "7-gas_limit": "u64:20000000", + "8-args": "nested:0" } ] }, diff --git a/multisig/scenarios/ethereum_to_multiversx_tx_batch_rejected.scen.json b/multisig/scenarios/ethereum_to_multiversx_tx_batch_rejected.scen.json index 78396eba..1c1076c6 100644 --- a/multisig/scenarios/ethereum_to_multiversx_tx_batch_rejected.scen.json +++ b/multisig/scenarios/ethereum_to_multiversx_tx_batch_rejected.scen.json @@ -22,13 +22,15 @@ "str:data", "u64:2,000,000", "u64:1", + "0", "0x0102030405060708091011121314151617181920", "sc:egld_esdt_swap", "str:ETH-123456", "76,000,000,000", "u64:2", "str:data", - "u64:2,000,000" + "u64:2,000,000", + "0" ], "gasLimit": "50,000,000", "gasPrice": "0" @@ -58,13 +60,15 @@ "u64:2", "str:data", "u64:2,000,000", + "0", "0x0102030405060708091011121314151617181920", "sc:egld_esdt_swap", "str:ETH-123456", "76,000,000,000", "u64:3", "str:data", - "u64:2,000,000" + "u64:2,000,000", + "0" ], "gasLimit": "50,000,000", "gasPrice": "0" @@ -94,13 +98,15 @@ "u64:1", "str:data", "u64:2,000,000", + "0", "0x0102030405060708091011121314151617181920", "sc:egld_esdt_swap", "str:ETH-123456", "76,000,000,000", "u64:2", "str:data", - "u64:2,000,000" + "u64:2,000,000", + "0" ], "gasLimit": "50,000,000", "gasPrice": "0" @@ -134,7 +140,8 @@ "4-amount": "biguint:76,000,000,000", "5-tx_id": "u64:1", "6-data": "nested:str:data", - "7-gas_limit": "u64:2,000,000" + "7-gas_limit": "u64:2,000,000", + "8-args": "nested:0" }, { "1-from": "0x0102030405060708091011121314151617181920", @@ -143,7 +150,8 @@ "4-amount": "biguint:76,000,000,000", "5-tx_id": "u64:2", "6-data": "nested:str:data", - "7-gas_limit": "u64:2,000,000" + "7-gas_limit": "u64:2,000,000", + "8-args": "nested:0" } ] }, From a6c8ae16a3ad8b62e9ade77fbbdde0266f46647c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Fri, 12 Jan 2024 16:17:43 +0200 Subject: [PATCH 47/50] Update common/token-module/src/lib.rs Co-authored-by: Rebegea Dragos-Alexandru <42241923+dragos-rebegea@users.noreply.github.com> --- common/token-module/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/token-module/src/lib.rs b/common/token-module/src/lib.rs index 35e8d9ce..3460c8bc 100644 --- a/common/token-module/src/lib.rs +++ b/common/token-module/src/lib.rs @@ -121,6 +121,8 @@ pub trait TokenModule: fee_estimator_module::FeeEstimatorModule { .get_esdt_balance(&self.blockchain().get_sc_address(), token_id, 0); if ¤t_balance >= amount { self.send().direct_esdt(&caller, token_id, 0, amount); + } else { + return EsdtTokenPayment::new(token_id.clone(), 0, BigUint::zero()); } EsdtTokenPayment::new(token_id.clone(), 0, amount.clone()) } From 58546e3dc353fb5b4ab641569ce3d507a7c4f3c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Fri, 12 Jan 2024 17:01:07 +0200 Subject: [PATCH 48/50] Multi-transfer: Add new test Check tx fail if token is not whitelist or mintBurnAllowed = False --- ...nsfer_fail_mint_burn_not_allowed.scen.json | 73 +++++++++++++++++++ .../multi_transfer_esdt_scenario_rs_test.rs | 5 ++ multi-transfer-esdt/tests/scenario_go_test.rs | 5 ++ 3 files changed, 83 insertions(+) create mode 100644 multi-transfer-esdt/scenarios/transfer_fail_mint_burn_not_allowed.scen.json diff --git a/multi-transfer-esdt/scenarios/transfer_fail_mint_burn_not_allowed.scen.json b/multi-transfer-esdt/scenarios/transfer_fail_mint_burn_not_allowed.scen.json new file mode 100644 index 00000000..99085379 --- /dev/null +++ b/multi-transfer-esdt/scenarios/transfer_fail_mint_burn_not_allowed.scen.json @@ -0,0 +1,73 @@ +{ + "name": "transfer ok", + "steps": [ + { + "step": "externalSteps", + "path": "setup_accounts.scen.json" + }, + { + "step": "scCall", + "txId": "add-token-1", + "tx": { + "from": "address:owner", + "to": "sc:esdt-safe", + "value": "0", + "function": "removeTokenFromWhitelist", + "arguments": [ + "str:BRIDGE-123456" + ], + "gasLimit": "50,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "txId": "transfer-ok", + "tx": { + "from": "address:owner", + "to": "sc:multi_transfer_esdt", + "value": "0", + "function": "batchTransferEsdtToken", + "arguments": [ + "1", + "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:1|nested:str:data|u64:10000000|nested:0" + ], + "gasLimit": "50,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "out": [], + "gas": "*", + "refund": "*" + } + }, + { + "step": "scQuery", + "txId": "get-current-refund-tx-batch", + "tx": { + "to": "sc:multi_transfer_esdt", + "function": "getFirstBatchAnyStatus", + "arguments": [] + }, + "expect": { + "out": [ + "1", + "0", + "1", + "0x0102030405060708091011121314151617181920", + "address:user1", + "str:BRIDGE-123456", + "100,200" + ] + } + } + ] +} \ No newline at end of file diff --git a/multi-transfer-esdt/tests/multi_transfer_esdt_scenario_rs_test.rs b/multi-transfer-esdt/tests/multi_transfer_esdt_scenario_rs_test.rs index cd92e808..602df64f 100644 --- a/multi-transfer-esdt/tests/multi_transfer_esdt_scenario_rs_test.rs +++ b/multi-transfer-esdt/tests/multi_transfer_esdt_scenario_rs_test.rs @@ -42,6 +42,11 @@ fn setup_accounts_rs() { world().run("scenarios/setup_accounts.scen.json"); } +#[test] +fn transfer_fail_mint_burn_not_allowed_rs() { + world().run("scenarios/transfer_fail_mint_burn_not_allowed.scen.json"); +} + #[test] fn transfer_ok_rs() { world().run("scenarios/transfer_ok.scen.json"); diff --git a/multi-transfer-esdt/tests/scenario_go_test.rs b/multi-transfer-esdt/tests/scenario_go_test.rs index 099736dd..b58db004 100644 --- a/multi-transfer-esdt/tests/scenario_go_test.rs +++ b/multi-transfer-esdt/tests/scenario_go_test.rs @@ -34,6 +34,11 @@ fn setup_accounts_go() { world().run("scenarios/setup_accounts.scen.json"); } +#[test] +fn transfer_fail_mint_burn_not_allowed_go() { + world().run("scenarios/transfer_fail_mint_burn_not_allowed.scen.json"); +} + #[test] fn transfer_ok_go() { world().run("scenarios/transfer_ok.scen.json"); From 40dc6ead3ae597ab4396585f4e21be0ba06e80e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Fri, 19 Jan 2024 15:26:28 +0200 Subject: [PATCH 49/50] Framework upgrade 0.46.1 --- bridge-proxy/Cargo.toml | 12 +-- bridge-proxy/meta/Cargo.toml | 2 +- bridge-proxy/wasm/Cargo.lock | 12 +-- bridge-proxy/wasm/Cargo.toml | 2 +- bridged-tokens-wrapper/Cargo.toml | 6 +- bridged-tokens-wrapper/meta/Cargo.toml | 2 +- bridged-tokens-wrapper/wasm/Cargo.lock | 32 +++---- bridged-tokens-wrapper/wasm/Cargo.toml | 2 +- common/eth-address/Cargo.toml | 2 +- common/fee-estimator-module/Cargo.toml | 4 +- common/max-bridged-amount-module/Cargo.toml | 4 +- common/token-module/Cargo.toml | 4 +- common/transaction/Cargo.toml | 2 +- common/tx-batch-module/Cargo.toml | 4 +- esdt-safe/Cargo.toml | 8 +- esdt-safe/meta/Cargo.toml | 2 +- esdt-safe/wasm/Cargo.toml | 2 +- multi-transfer-esdt/Cargo.toml | 6 +- multi-transfer-esdt/meta/Cargo.toml | 2 +- ...nsfer_fail_mint_burn_not_allowed.scen.json | 84 +++++++++++++++---- multi-transfer-esdt/wasm/Cargo.lock | 68 +++++++-------- multi-transfer-esdt/wasm/Cargo.toml | 2 +- multisig/Cargo.toml | 8 +- multisig/meta/Cargo.toml | 2 +- multisig/wasm/Cargo.lock | 68 +++++++-------- multisig/wasm/Cargo.toml | 2 +- 26 files changed, 197 insertions(+), 147 deletions(-) diff --git a/bridge-proxy/Cargo.toml b/bridge-proxy/Cargo.toml index a321b276..ef15b6ad 100644 --- a/bridge-proxy/Cargo.toml +++ b/bridge-proxy/Cargo.toml @@ -15,14 +15,14 @@ path = "../common/transaction" path = "../common/eth-address" [dependencies.multiversx-sc] -version = "0.46.0" +version = "0.46.1" + +[dependencies.adder] +git = "https://github.com/multiversx/mx-contracts-rs" +rev = "64e8926" [dev-dependencies] num-bigint = "0.4.2" [dev-dependencies.multiversx-sc-scenario] -version = "0.46.0" - -[dependencies.adder] -git = "https://github.com/multiversx/mx-contracts-rs" -rev = "64e8926" \ No newline at end of file +version = "0.46.1" diff --git a/bridge-proxy/meta/Cargo.toml b/bridge-proxy/meta/Cargo.toml index 6c870ea7..a8b29fd6 100644 --- a/bridge-proxy/meta/Cargo.toml +++ b/bridge-proxy/meta/Cargo.toml @@ -11,4 +11,4 @@ authors = ["you"] path = ".." [dependencies.multiversx-sc-meta] -version = "0.46.0" +version = "0.46.1" diff --git a/bridge-proxy/wasm/Cargo.lock b/bridge-proxy/wasm/Cargo.lock index bfe79a1e..c088f7e9 100644 --- a/bridge-proxy/wasm/Cargo.lock +++ b/bridge-proxy/wasm/Cargo.lock @@ -73,9 +73,9 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "multiversx-sc" -version = "0.46.0" +version = "0.46.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fff591179642ac99baad6050ff73ec98f0be45e4f2043ec2a9c222dcef94194" +checksum = "6c94b173dc5ff0e157f767275fe6b7a1b4d2ad343bef7b66cd22a6353e016b93" dependencies = [ "bitflags", "hex-literal", @@ -108,9 +108,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.46.0" +version = "0.46.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f24329c73b4bfd9fae9186a397a358b26deaeac14e10234bb27838fc618cad8b" +checksum = "3b78945957036c281ad6ee21bb5120dcefa2017688adf43ec94e3e7c982efb09" dependencies = [ "hex", "proc-macro2", @@ -121,9 +121,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.46.0" +version = "0.46.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace7a78b860a27b1bf2b6f2840d1cf40516b85c44e80ba34663b3388079afba8" +checksum = "9579f40c00da56a5a68e010ff851fa48ac7b9c6a16ad4314795cb32d889d9e78" dependencies = [ "multiversx-sc", ] diff --git a/bridge-proxy/wasm/Cargo.toml b/bridge-proxy/wasm/Cargo.toml index d4febb9c..dc23e0bb 100644 --- a/bridge-proxy/wasm/Cargo.toml +++ b/bridge-proxy/wasm/Cargo.toml @@ -25,7 +25,7 @@ overflow-checks = false path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.46.0" +version = "0.46.1" [workspace] members = ["."] diff --git a/bridged-tokens-wrapper/Cargo.toml b/bridged-tokens-wrapper/Cargo.toml index f3550d62..e2c728b2 100644 --- a/bridged-tokens-wrapper/Cargo.toml +++ b/bridged-tokens-wrapper/Cargo.toml @@ -12,10 +12,10 @@ path = "src/lib.rs" path = "../common/transaction" [dependencies.multiversx-sc] -version = "0.46.0" +version = "0.46.1" [dependencies.multiversx-sc-modules] -version = "0.46.0" +version = "0.46.1" [dev-dependencies.multiversx-sc-scenario] -version = "0.46.0" +version = "0.46.1" diff --git a/bridged-tokens-wrapper/meta/Cargo.toml b/bridged-tokens-wrapper/meta/Cargo.toml index 26774878..94dedaf9 100644 --- a/bridged-tokens-wrapper/meta/Cargo.toml +++ b/bridged-tokens-wrapper/meta/Cargo.toml @@ -8,5 +8,5 @@ publish = false path = ".." [dependencies.multiversx-sc-meta] -version = "0.46.0" +version = "0.46.1" default-features = false diff --git a/bridged-tokens-wrapper/wasm/Cargo.lock b/bridged-tokens-wrapper/wasm/Cargo.lock index 8ba6ac3c..5cf7dda8 100644 --- a/bridged-tokens-wrapper/wasm/Cargo.lock +++ b/bridged-tokens-wrapper/wasm/Cargo.lock @@ -16,9 +16,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "bitflags" -version = "2.4.1" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "bridged-tokens-wrapper" @@ -64,9 +64,9 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "multiversx-sc" -version = "0.46.0" +version = "0.46.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fff591179642ac99baad6050ff73ec98f0be45e4f2043ec2a9c222dcef94194" +checksum = "6c94b173dc5ff0e157f767275fe6b7a1b4d2ad343bef7b66cd22a6353e016b93" dependencies = [ "bitflags", "hex-literal", @@ -99,9 +99,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.46.0" +version = "0.46.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f24329c73b4bfd9fae9186a397a358b26deaeac14e10234bb27838fc618cad8b" +checksum = "3b78945957036c281ad6ee21bb5120dcefa2017688adf43ec94e3e7c982efb09" dependencies = [ "hex", "proc-macro2", @@ -112,18 +112,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.46.0" +version = "0.46.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4088eb7642032b69f7b9961b505c2bffce852f795c60dc490e22a6037124f0c0" +checksum = "c63ffaba95e630ff75981e2f5f50da64f523219b52f484234c66f3adc248885f" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.46.0" +version = "0.46.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace7a78b860a27b1bf2b6f2840d1cf40516b85c44e80ba34663b3388079afba8" +checksum = "9579f40c00da56a5a68e010ff851fa48ac7b9c6a16ad4314795cb32d889d9e78" dependencies = [ "multiversx-sc", ] @@ -148,9 +148,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.74" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2de98502f212cfcea8d0bb305bd0f49d7ebdd75b64ba0a68f937d888f4e0d6db" +checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" dependencies = [ "unicode-ident", ] @@ -176,15 +176,15 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.2" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" +checksum = "2593d31f82ead8df961d8bd23a64c2ccf2eb5dd34b0a34bfb4dd54011c72009e" [[package]] name = "syn" -version = "2.0.46" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89456b690ff72fddcecf231caedbe615c59480c93358a93dfae7fc29e3ebbf0e" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", diff --git a/bridged-tokens-wrapper/wasm/Cargo.toml b/bridged-tokens-wrapper/wasm/Cargo.toml index 84ddb624..c587d37a 100644 --- a/bridged-tokens-wrapper/wasm/Cargo.toml +++ b/bridged-tokens-wrapper/wasm/Cargo.toml @@ -25,7 +25,7 @@ overflow-checks = false path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.46.0" +version = "0.46.1" [workspace] members = ["."] diff --git a/common/eth-address/Cargo.toml b/common/eth-address/Cargo.toml index 6f612e83..7cf6ff45 100644 --- a/common/eth-address/Cargo.toml +++ b/common/eth-address/Cargo.toml @@ -8,4 +8,4 @@ edition = "2018" path = "src/lib.rs" [dependencies.multiversx-sc] -version = "0.46.0" +version = "0.46.1" diff --git a/common/fee-estimator-module/Cargo.toml b/common/fee-estimator-module/Cargo.toml index 4338c3bf..54226945 100644 --- a/common/fee-estimator-module/Cargo.toml +++ b/common/fee-estimator-module/Cargo.toml @@ -5,7 +5,7 @@ authors = ["dorin-iancu "] edition = "2018" [dependencies.multiversx-sc] -version = "0.46.0" +version = "0.46.1" [dev-dependencies.multiversx-sc-scenario] -version = "0.46.0" +version = "0.46.1" diff --git a/common/max-bridged-amount-module/Cargo.toml b/common/max-bridged-amount-module/Cargo.toml index 5e9c56b7..a79eb730 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.46.0" +version = "0.46.1" [dev-dependencies.multiversx-sc-scenario] -version = "0.46.0" +version = "0.46.1" diff --git a/common/token-module/Cargo.toml b/common/token-module/Cargo.toml index 7362cd18..3b85c7ce 100644 --- a/common/token-module/Cargo.toml +++ b/common/token-module/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" path = "../fee-estimator-module" [dependencies.multiversx-sc] -version = "0.46.0" +version = "0.46.1" [dev-dependencies.multiversx-sc-scenario] -version = "0.46.0" +version = "0.46.1" diff --git a/common/transaction/Cargo.toml b/common/transaction/Cargo.toml index e5fb3913..53bc3118 100644 --- a/common/transaction/Cargo.toml +++ b/common/transaction/Cargo.toml @@ -11,4 +11,4 @@ path = "src/lib.rs" path = "../eth-address" [dependencies.multiversx-sc] -version = "0.46.0" +version = "0.46.1" diff --git a/common/tx-batch-module/Cargo.toml b/common/tx-batch-module/Cargo.toml index 8dbd6559..b8a95dac 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.46.0" +version = "0.46.1" [dependencies.transaction] path = "../transaction" [dev-dependencies.multiversx-sc-scenario] -version = "0.46.0" +version = "0.46.1" diff --git a/esdt-safe/Cargo.toml b/esdt-safe/Cargo.toml index 5a9aa27b..62ac7441 100644 --- a/esdt-safe/Cargo.toml +++ b/esdt-safe/Cargo.toml @@ -27,13 +27,13 @@ path = "../common/tx-batch-module" path = "../common/max-bridged-amount-module" [dependencies.multiversx-price-aggregator-sc] -version = "0.46.0" +version = "0.46.1" [dependencies.multiversx-sc] -version = "0.46.0" +version = "0.46.1" [dependencies.multiversx-sc-modules] -version = "0.46.0" +version = "0.46.1" [dev-dependencies.multiversx-sc-scenario] -version = "0.46.0" +version = "0.46.1" diff --git a/esdt-safe/meta/Cargo.toml b/esdt-safe/meta/Cargo.toml index 68ca15bb..a69035ab 100644 --- a/esdt-safe/meta/Cargo.toml +++ b/esdt-safe/meta/Cargo.toml @@ -11,5 +11,5 @@ publish = false path = ".." [dependencies.multiversx-sc-meta] -version = "0.46.0" +version = "0.46.1" default-features = false diff --git a/esdt-safe/wasm/Cargo.toml b/esdt-safe/wasm/Cargo.toml index 071b7ec4..4c66c1a8 100644 --- a/esdt-safe/wasm/Cargo.toml +++ b/esdt-safe/wasm/Cargo.toml @@ -25,7 +25,7 @@ overflow-checks = false path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.46.0" +version = "0.46.1" [workspace] members = ["."] diff --git a/multi-transfer-esdt/Cargo.toml b/multi-transfer-esdt/Cargo.toml index 2bf1d2f4..3239d8a9 100644 --- a/multi-transfer-esdt/Cargo.toml +++ b/multi-transfer-esdt/Cargo.toml @@ -33,10 +33,10 @@ path = "../esdt-safe" path = "../common/token-module" [dependencies.multiversx-sc] -version = "0.46.0" +version = "0.46.1" [dependencies.multiversx-sc-modules] -version = "0.46.0" +version = "0.46.1" [dev-dependencies.multiversx-sc-scenario] -version = "0.46.0" +version = "0.46.1" diff --git a/multi-transfer-esdt/meta/Cargo.toml b/multi-transfer-esdt/meta/Cargo.toml index 16530d42..65941801 100644 --- a/multi-transfer-esdt/meta/Cargo.toml +++ b/multi-transfer-esdt/meta/Cargo.toml @@ -11,5 +11,5 @@ publish = false path = ".." [dependencies.multiversx-sc-meta] -version = "0.46.0" +version = "0.46.1" default-features = false diff --git a/multi-transfer-esdt/scenarios/transfer_fail_mint_burn_not_allowed.scen.json b/multi-transfer-esdt/scenarios/transfer_fail_mint_burn_not_allowed.scen.json index 99085379..831c3e52 100644 --- a/multi-transfer-esdt/scenarios/transfer_fail_mint_burn_not_allowed.scen.json +++ b/multi-transfer-esdt/scenarios/transfer_fail_mint_burn_not_allowed.scen.json @@ -26,6 +26,10 @@ "refund": "*" } }, + { + "step": "dumpState", + "comment": "all accounts beginning" + }, { "step": "scCall", "txId": "transfer-ok", @@ -50,23 +54,69 @@ } }, { - "step": "scQuery", - "txId": "get-current-refund-tx-batch", - "tx": { - "to": "sc:multi_transfer_esdt", - "function": "getFirstBatchAnyStatus", - "arguments": [] - }, - "expect": { - "out": [ - "1", - "0", - "1", - "0x0102030405060708091011121314151617181920", - "address:user1", - "str:BRIDGE-123456", - "100,200" - ] + "step": "checkState", + "accounts": { + "address:owner": { + "nonce": "11", + "balance": "0", + "storage": {} + }, + "address:user1": { + "nonce": "0", + "balance": "0", + "esdt": { + "str:BRIDGE-123456": { + "balance": "100,200" + } + }, + "storage": {} + }, + "address:user2": { + "nonce": "0", + "balance": "0", + "storage": {} + }, + "sc:multi_transfer_esdt": { + "code": "file:../output/multi-transfer-esdt.wasm", + "nonce": "0", + "balance": "0", + "storage": { + "str:firstBatchId": "1", + "str:lastBatchId": "1", + "str:bridgeProxyContractAddress": "sc:bridge-proxy", + "str:maxTxBatchSize": "10", + "str:maxTxBatchBlockDuration": "3600", + "str:esdtSafeContractAddress": "sc:esdt-safe" + } + }, + "sc:bridge-proxy": { + "code": "file:../../bridge-proxy/output/bridge-proxy.wasm", + "nonce": "0", + "balance": "0", + "storage": "*" + }, + "sc:esdt-safe": { + "code": "file:../../esdt-safe/output/esdt-safe.wasm", + "nonce": "0", + "balance": "0", + "esdt": { + "str:BRIDGE-123456": { + "balance": "899,800", + "roles": [ + "ESDTRoleLocalMint", + "ESDTRoleLocalBurn" + ] + }, + "str:WRAPPED-123456": { + "balance": "1,000,000", + "roles": [ + "ESDTRoleLocalMint", + "ESDTRoleLocalBurn" + ] + } + }, + "storage": "*" + } } } ] diff --git a/multi-transfer-esdt/wasm/Cargo.lock b/multi-transfer-esdt/wasm/Cargo.lock index 30127ce3..1dfb2b05 100644 --- a/multi-transfer-esdt/wasm/Cargo.lock +++ b/multi-transfer-esdt/wasm/Cargo.lock @@ -24,9 +24,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "bitflags" -version = "2.4.1" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "bridge-proxy" @@ -96,9 +96,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", "js-sys", @@ -121,18 +121,18 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "js-sys" -version = "0.3.66" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" +checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" dependencies = [ "wasm-bindgen", ] [[package]] name = "libc" -version = "0.2.151" +version = "0.2.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" [[package]] name = "log" @@ -173,9 +173,9 @@ dependencies = [ [[package]] name = "multiversx-price-aggregator-sc" -version = "0.46.0" +version = "0.46.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd93dff2ebf61fe728609ef3fdeb451852524ad4eb559ba45bc2194d801edf17" +checksum = "b8de03c6796bd16c39cafafd13da688d9f64d30965866d1c0d0badd2071235f9" dependencies = [ "arrayvec", "getrandom", @@ -186,9 +186,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.46.0" +version = "0.46.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fff591179642ac99baad6050ff73ec98f0be45e4f2043ec2a9c222dcef94194" +checksum = "6c94b173dc5ff0e157f767275fe6b7a1b4d2ad343bef7b66cd22a6353e016b93" dependencies = [ "bitflags", "hex-literal", @@ -221,9 +221,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.46.0" +version = "0.46.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f24329c73b4bfd9fae9186a397a358b26deaeac14e10234bb27838fc618cad8b" +checksum = "3b78945957036c281ad6ee21bb5120dcefa2017688adf43ec94e3e7c982efb09" dependencies = [ "hex", "proc-macro2", @@ -234,18 +234,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.46.0" +version = "0.46.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4088eb7642032b69f7b9961b505c2bffce852f795c60dc490e22a6037124f0c0" +checksum = "c63ffaba95e630ff75981e2f5f50da64f523219b52f484234c66f3adc248885f" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.46.0" +version = "0.46.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace7a78b860a27b1bf2b6f2840d1cf40516b85c44e80ba34663b3388079afba8" +checksum = "9579f40c00da56a5a68e010ff851fa48ac7b9c6a16ad4314795cb32d889d9e78" dependencies = [ "multiversx-sc", ] @@ -282,9 +282,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.74" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2de98502f212cfcea8d0bb305bd0f49d7ebdd75b64ba0a68f937d888f4e0d6db" +checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" dependencies = [ "unicode-ident", ] @@ -340,15 +340,15 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.2" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" +checksum = "2593d31f82ead8df961d8bd23a64c2ccf2eb5dd34b0a34bfb4dd54011c72009e" [[package]] name = "syn" -version = "2.0.46" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89456b690ff72fddcecf231caedbe615c59480c93358a93dfae7fc29e3ebbf0e" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", @@ -393,9 +393,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" +checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -403,9 +403,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" +checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" dependencies = [ "bumpalo", "log", @@ -418,9 +418,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" +checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -428,9 +428,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" +checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" dependencies = [ "proc-macro2", "quote", @@ -441,6 +441,6 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" +checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" diff --git a/multi-transfer-esdt/wasm/Cargo.toml b/multi-transfer-esdt/wasm/Cargo.toml index d2d9e843..66b222ea 100644 --- a/multi-transfer-esdt/wasm/Cargo.toml +++ b/multi-transfer-esdt/wasm/Cargo.toml @@ -25,7 +25,7 @@ overflow-checks = false path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.46.0" +version = "0.46.1" [workspace] members = ["."] diff --git a/multisig/Cargo.toml b/multisig/Cargo.toml index 44609f03..c2d6287d 100644 --- a/multisig/Cargo.toml +++ b/multisig/Cargo.toml @@ -33,13 +33,13 @@ path = "../esdt-safe" path = "../multi-transfer-esdt" [dependencies.multiversx-sc] -version = "0.46.0" +version = "0.46.1" [dependencies.multiversx-price-aggregator-sc] -version = "0.46.0" +version = "0.46.1" [dependencies.multiversx-sc-modules] -version = "0.46.0" +version = "0.46.1" [dev-dependencies.multiversx-sc-scenario] -version = "0.46.0" +version = "0.46.1" diff --git a/multisig/meta/Cargo.toml b/multisig/meta/Cargo.toml index 3c938171..e64607f0 100644 --- a/multisig/meta/Cargo.toml +++ b/multisig/meta/Cargo.toml @@ -9,5 +9,5 @@ publish = false path = ".." [dependencies.multiversx-sc-meta] -version = "0.46.0" +version = "0.46.1" default-features = false diff --git a/multisig/wasm/Cargo.lock b/multisig/wasm/Cargo.lock index 15d83057..e7801f46 100644 --- a/multisig/wasm/Cargo.lock +++ b/multisig/wasm/Cargo.lock @@ -24,9 +24,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "bitflags" -version = "2.4.1" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "bridge-proxy" @@ -96,9 +96,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", "js-sys", @@ -121,18 +121,18 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "js-sys" -version = "0.3.66" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" +checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" dependencies = [ "wasm-bindgen", ] [[package]] name = "libc" -version = "0.2.151" +version = "0.2.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" [[package]] name = "log" @@ -190,9 +190,9 @@ dependencies = [ [[package]] name = "multiversx-price-aggregator-sc" -version = "0.46.0" +version = "0.46.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd93dff2ebf61fe728609ef3fdeb451852524ad4eb559ba45bc2194d801edf17" +checksum = "b8de03c6796bd16c39cafafd13da688d9f64d30965866d1c0d0badd2071235f9" dependencies = [ "arrayvec", "getrandom", @@ -203,9 +203,9 @@ dependencies = [ [[package]] name = "multiversx-sc" -version = "0.46.0" +version = "0.46.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fff591179642ac99baad6050ff73ec98f0be45e4f2043ec2a9c222dcef94194" +checksum = "6c94b173dc5ff0e157f767275fe6b7a1b4d2ad343bef7b66cd22a6353e016b93" dependencies = [ "bitflags", "hex-literal", @@ -238,9 +238,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.46.0" +version = "0.46.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f24329c73b4bfd9fae9186a397a358b26deaeac14e10234bb27838fc618cad8b" +checksum = "3b78945957036c281ad6ee21bb5120dcefa2017688adf43ec94e3e7c982efb09" dependencies = [ "hex", "proc-macro2", @@ -251,18 +251,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.46.0" +version = "0.46.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4088eb7642032b69f7b9961b505c2bffce852f795c60dc490e22a6037124f0c0" +checksum = "c63ffaba95e630ff75981e2f5f50da64f523219b52f484234c66f3adc248885f" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.46.0" +version = "0.46.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace7a78b860a27b1bf2b6f2840d1cf40516b85c44e80ba34663b3388079afba8" +checksum = "9579f40c00da56a5a68e010ff851fa48ac7b9c6a16ad4314795cb32d889d9e78" dependencies = [ "multiversx-sc", ] @@ -299,9 +299,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.75" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "907a61bd0f64c2f29cd1cf1dc34d05176426a3f504a78010f08416ddb7b13708" +checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" dependencies = [ "unicode-ident", ] @@ -357,15 +357,15 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.2" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" +checksum = "2593d31f82ead8df961d8bd23a64c2ccf2eb5dd34b0a34bfb4dd54011c72009e" [[package]] name = "syn" -version = "2.0.47" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1726efe18f42ae774cc644f330953a5e7b3c3003d3edcecf18850fe9d4dd9afb" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", @@ -410,9 +410,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" +checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -420,9 +420,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" +checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" dependencies = [ "bumpalo", "log", @@ -435,9 +435,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" +checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -445,9 +445,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" +checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" dependencies = [ "proc-macro2", "quote", @@ -458,6 +458,6 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" +checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" diff --git a/multisig/wasm/Cargo.toml b/multisig/wasm/Cargo.toml index 467bf3bf..50d26db2 100644 --- a/multisig/wasm/Cargo.toml +++ b/multisig/wasm/Cargo.toml @@ -25,7 +25,7 @@ overflow-checks = false path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.46.0" +version = "0.46.1" [workspace] members = ["."] From 12ea6db66e0e39a2e29b29ea5c8983c340ffb5b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Fri, 19 Jan 2024 16:26:14 +0200 Subject: [PATCH 50/50] Test fix --- ...nsfer_fail_mint_burn_not_allowed.scen.json | 76 +++---------------- 1 file changed, 9 insertions(+), 67 deletions(-) diff --git a/multi-transfer-esdt/scenarios/transfer_fail_mint_burn_not_allowed.scen.json b/multi-transfer-esdt/scenarios/transfer_fail_mint_burn_not_allowed.scen.json index 831c3e52..a4db0d9f 100644 --- a/multi-transfer-esdt/scenarios/transfer_fail_mint_burn_not_allowed.scen.json +++ b/multi-transfer-esdt/scenarios/transfer_fail_mint_burn_not_allowed.scen.json @@ -26,10 +26,6 @@ "refund": "*" } }, - { - "step": "dumpState", - "comment": "all accounts beginning" - }, { "step": "scCall", "txId": "transfer-ok", @@ -54,69 +50,15 @@ } }, { - "step": "checkState", - "accounts": { - "address:owner": { - "nonce": "11", - "balance": "0", - "storage": {} - }, - "address:user1": { - "nonce": "0", - "balance": "0", - "esdt": { - "str:BRIDGE-123456": { - "balance": "100,200" - } - }, - "storage": {} - }, - "address:user2": { - "nonce": "0", - "balance": "0", - "storage": {} - }, - "sc:multi_transfer_esdt": { - "code": "file:../output/multi-transfer-esdt.wasm", - "nonce": "0", - "balance": "0", - "storage": { - "str:firstBatchId": "1", - "str:lastBatchId": "1", - "str:bridgeProxyContractAddress": "sc:bridge-proxy", - "str:maxTxBatchSize": "10", - "str:maxTxBatchBlockDuration": "3600", - "str:esdtSafeContractAddress": "sc:esdt-safe" - } - }, - "sc:bridge-proxy": { - "code": "file:../../bridge-proxy/output/bridge-proxy.wasm", - "nonce": "0", - "balance": "0", - "storage": "*" - }, - "sc:esdt-safe": { - "code": "file:../../esdt-safe/output/esdt-safe.wasm", - "nonce": "0", - "balance": "0", - "esdt": { - "str:BRIDGE-123456": { - "balance": "899,800", - "roles": [ - "ESDTRoleLocalMint", - "ESDTRoleLocalBurn" - ] - }, - "str:WRAPPED-123456": { - "balance": "1,000,000", - "roles": [ - "ESDTRoleLocalMint", - "ESDTRoleLocalBurn" - ] - } - }, - "storage": "*" - } + "step": "scQuery", + "txId": "get-current-refund-tx-batch", + "tx": { + "to": "sc:multi_transfer_esdt", + "function": "getFirstBatchAnyStatus", + "arguments": [] + }, + "expect": { + "out": "*" } } ]