From 29679790a2a8843ba1f00e7a7bef7a81c0802f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Thu, 1 Feb 2024 16:46:12 +0200 Subject: [PATCH 1/2] EthTransaction: impl TopDecode/TopEncode TopEncode/TopDecode is needed to have optional args for EthTransaction --- Cargo.toml | 2 +- .../tests/bridge_proxy_blackbox_test.rs | 2 - .../src/aggregator_proxy.rs | 3 +- common/token-module/src/lib.rs | 4 +- common/transaction/src/lib.rs | 157 +++++++++++++++++- esdt-safe/tests/esdt_safe_scenario_rs_test.rs | 6 +- esdt-safe/wasm/src/lib.rs | 4 +- .../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 +- ...nsfer_fail_mint_burn_not_allowed.scen.json | 2 +- .../scenarios/transfer_ok.scen.json | 2 +- .../two_transfers_same_token.scen.json | 4 +- .../tests/multi_transfer_blackbox_test.rs | 6 +- .../multi_transfer_esdt_scenario_rs_test.rs | 20 ++- multisig/src/util.rs | 5 +- multisig/tests/multisig_scenario_rs_test.rs | 15 +- 19 files changed, 215 insertions(+), 39 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7720c88c..2d9d9bd7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [workspace] members = [ "bridge-proxy", - "bridge-proxy/meta", + "bridge-proxy/meta", "esdt-safe", "esdt-safe/meta", "multi-transfer-esdt", diff --git a/bridge-proxy/tests/bridge_proxy_blackbox_test.rs b/bridge-proxy/tests/bridge_proxy_blackbox_test.rs index 9a3e1002..c00ab5e4 100644 --- a/bridge-proxy/tests/bridge_proxy_blackbox_test.rs +++ b/bridge-proxy/tests/bridge_proxy_blackbox_test.rs @@ -171,7 +171,6 @@ fn deploy_deposit_test() { ); } - #[test] fn multiple_deposit_test() { let mut test = BridgeProxyTestState::setup(); @@ -270,5 +269,4 @@ fn multiple_deposit_test() { .call(test.adder_contract.sum()) .expect_value(SingleValue::from(BigUint::from(20u32))), ); - } diff --git a/common/fee-estimator-module/src/aggregator_proxy.rs b/common/fee-estimator-module/src/aggregator_proxy.rs index d31ba305..1b8d0511 100644 --- a/common/fee-estimator-module/src/aggregator_proxy.rs +++ b/common/fee-estimator-module/src/aggregator_proxy.rs @@ -26,7 +26,8 @@ pub struct AggregatorResult { impl From> for AggregatorResult { fn from(multi_result: AggregatorResultAsMultiValue) -> Self { - let (round_id, from_token_name, to_token_name, timestamp, 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, diff --git a/common/token-module/src/lib.rs b/common/token-module/src/lib.rs index 3460c8bc..51af8595 100644 --- a/common/token-module/src/lib.rs +++ b/common/token-module/src/lib.rs @@ -121,8 +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()); + } else { + return EsdtTokenPayment::new(token_id.clone(), 0, BigUint::zero()); } EsdtTokenPayment::new(token_id.clone(), 0, amount.clone()) } diff --git a/common/transaction/src/lib.rs b/common/transaction/src/lib.rs index 75e7892b..076998ec 100644 --- a/common/transaction/src/lib.rs +++ b/common/transaction/src/lib.rs @@ -4,6 +4,8 @@ multiversx_sc::imports!(); multiversx_sc::derive_imports!(); use eth_address::EthAddress; +use multiversx_sc::codec::{EncodeErrorHandler, NestedDecodeInput, TopEncodeOutput}; +// use multiversx_sc::codec::{DecodeErrorHandler, EncodeErrorHandler, NestedDecodeInput, TopDecodeInput, TopEncodeOutput}; pub mod transaction_status; @@ -26,7 +28,7 @@ pub type TxAsMultiValue = MultiValue6< pub type PaymentsVec = ManagedVec>; pub type TxBatchSplitInFields = MultiValue2>>; -#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, Clone, ManagedVecItem)] +#[derive(NestedEncode, NestedDecode, TypeAbi, Clone, ManagedVecItem)] pub struct EthTransaction { pub from: EthAddress, pub to: ManagedAddress, @@ -38,6 +40,159 @@ pub struct EthTransaction { pub args: ManagedVec>, } +impl TopEncode for EthTransaction { + fn top_encode_or_handle_err(&self, output: O, h: H) -> Result<(), H::HandledErr> + where + O: TopEncodeOutput, + H: EncodeErrorHandler, + { + let mut nested_buffer = output.start_nested_encode(); + self.from.dep_encode_or_handle_err(&mut nested_buffer, h)?; + self.to.dep_encode_or_handle_err(&mut nested_buffer, h)?; + self.token_id + .dep_encode_or_handle_err(&mut nested_buffer, h)?; + self.amount + .dep_encode_or_handle_err(&mut nested_buffer, h)?; + self.tx_nonce + .dep_encode_or_handle_err(&mut nested_buffer, h)?; + self.data.dep_encode_or_handle_err(&mut nested_buffer, h)?; + self.gas_limit + .dep_encode_or_handle_err(&mut nested_buffer, h)?; + for arg in &self.args { + arg.dep_encode_or_handle_err(&mut nested_buffer, h)?; + } + output.finalize_nested_encode(nested_buffer); + Result::Ok(()) + } +} + +impl TopDecode for EthTransaction { + fn top_decode_or_handle_err(input: I, h: H) -> Result + where + I: codec::TopDecodeInput, + H: codec::DecodeErrorHandler, + { + let mut nested_buffer = input.into_nested_buffer(); + let from = EthAddress::dep_decode_or_handle_err(&mut nested_buffer, h)?; + let to = ManagedAddress::dep_decode_or_handle_err(&mut nested_buffer, h)?; + let token_id = TokenIdentifier::dep_decode_or_handle_err(&mut nested_buffer, h)?; + let amount = BigUint::dep_decode_or_handle_err(&mut nested_buffer, h)?; + let tx_nonce = TxNonce::dep_decode_or_handle_err(&mut nested_buffer, h)?; + let data = ManagedBuffer::dep_decode_or_handle_err(&mut nested_buffer, h)?; + let gas_limit = u64::dep_decode_or_handle_err(&mut nested_buffer, h)?; + let mut args = ManagedVec::new(); + + while !nested_buffer.is_depleted() { + args.push(ManagedBuffer::dep_decode_or_handle_err( + &mut nested_buffer, + h, + )?); + } + + Result::Ok(EthTransaction { + from, + to, + token_id, + amount, + tx_nonce, + data, + gas_limit, + args, + }) + } +} + +// impl codec::TopEncode for EthTransaction { +// fn top_encode_or_handle_err( +// &self, +// output: O, +// h: H, +// ) -> core::result::Result<(), H::HandledErr> +// where +// O: codec::TopEncodeOutput, +// H: codec::EncodeErrorHandler, +// { +// self { + +// } +// match self.args. { +// TokenMapperState::NotSet => codec::TopEncode::top_encode_or_handle_err(&"", output, h), +// TokenMapperState::Pending => { +// codec::TopEncode::top_encode_or_handle_err(&"pending", output, h) +// }, +// TokenMapperState::Token(token) => { +// codec::TopEncode::top_encode_or_handle_err(&token, output, h) +// }, +// } +// } +// } + +// impl TopDecode for EthTransaction { +// fn top_decode_or_handle_err(top_input: I, h: H) -> Result +// where +// I: codec::TopDecodeInput, +// H: codec::DecodeErrorHandler, +// { +// let mut nested_buffer = top_input.into_nested_buffer(); +// let result = Self::dep_decode_or_handle_err(&mut nested_buffer, h)?; +// if !codec::NestedDecodeInput::is_depleted(&nested_buffer) { +// return Err(h.handle_error(codec::DecodeError::INPUT_TOO_LONG)); +// } +// Ok(result) +// } +// } + +// impl codec::TopDecode for EthTransaction { +// fn top_decode_or_handle_err(input: I, h: H) -> core::result::Result +// where +// I: codec::TopDecodeInput, +// H: codec::DecodeErrorHandler, +// { +// let decoded_input = ManagedBuffer::top_decode_or_handle_err(input, h)?; +// if decoded_input.is_empty() { +// Ok(TokenMapperState::NotSet) +// } else if decoded_input == PENDING_ENCODING { +// Ok(TokenMapperState::Pending) +// } else { +// let token_id = TokenIdentifier::from_esdt_bytes(decoded_input); +// Ok(TokenMapperState::Token(token_id)) +// } +// } +// } + +// impl TopDecode for EthTransaction { +// fn top_decode_or_handle_err(input: I, h: H) -> Result +// where +// I: codec::TopDecodeInput, +// H: codec::DecodeErrorHandler, +// { +// let mut result: EthTransaction = EthTransaction::new(); +// let mut nested_arg = input.into_nested_buffer(); +// while !nested_arg.is_depleted() { +// if let Err(capacity_error) = +// result.try_push(T::dep_decode_or_handle_err(&mut nested_arg, h)?) +// { +// return Err(h.handle_error(DecodeError::from(capacity_error))); +// } +// } +// if !nested_arg.is_depleted() { +// if let Err(capacity_error) = +// result.try_push(T::dep_decode_or_handle_err(&mut nested_arg, h)?) +// { +// return Err(h.handle_error(DecodeError::from(capacity_error))); +// } +// } +// Ok(result) +// } + +// fn top_decode(input: I) -> Result +// where +// I: TopDecodeInput, +// { +// Self::top_decode_or_handle_err(input, codec::DefaultErrorHandler) +// } +// } + pub type EthTxAsMultiValue = MultiValue8< EthAddress, ManagedAddress, diff --git a/esdt-safe/tests/esdt_safe_scenario_rs_test.rs b/esdt-safe/tests/esdt_safe_scenario_rs_test.rs index b6a97cb3..e20b0b79 100644 --- a/esdt-safe/tests/esdt_safe_scenario_rs_test.rs +++ b/esdt-safe/tests/esdt_safe_scenario_rs_test.rs @@ -5,10 +5,12 @@ fn world() -> ScenarioWorld { 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.register_contract( + "file:../price-aggregator/multiversx-price-aggregator-sc.wasm", + multiversx_price_aggregator_sc::ContractBuilder, + ); blockchain - } #[test] 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_both_executed.scen.json b/multi-transfer-esdt/scenarios/batch_transfer_both_executed.scen.json index c708c2bd..b4417975 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|nested:0", - "0x0102030405060708091011121314151617181920|address:user2|nested:str:WRAPPED-123456|biguint:500|u64:2|nested:str:data|u64:10000000|nested:0" + "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/scenarios/batch_transfer_both_failed.scen.json b/multi-transfer-esdt/scenarios/batch_transfer_both_failed.scen.json index 1329c6f4..9b6d48e1 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|nested:0", - "0x0102030405060708091011121314151617181920|sc:multi_transfer_esdt|nested:str:WRAPPED-123456|biguint:100,500|u64:2|nested:str:data|u64:2000000|nested:0" + "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" 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 562c799e..b6420639 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|nested:0", - "0x0102030405060708091011121314151617181920|sc:multi_transfer_esdt|nested:str:WRAPPED-123456|biguint:500|u64:2|nested:str:data|u64:1000000|nested:0" + "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" 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 9735e012..dcf91222 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|nested:0", - "0x0102030405060708091011121314151617181920|address:frozen_user|nested:str:BRIDGE-123456|biguint:500|u64:2|nested:str:data|u64:10000000|nested:0" + "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/scenarios/batch_transfer_with_wrapping.scen.json b/multi-transfer-esdt/scenarios/batch_transfer_with_wrapping.scen.json index 22d53384..c08275c1 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|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" + "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" 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 a4db0d9f..40b66ec5 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 @@ -36,7 +36,7 @@ "function": "batchTransferEsdtToken", "arguments": [ "1", - "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:1|nested:str:data|u64:10000000" ], "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 2277c198..4768ca5e 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|nested:0" + "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/scenarios/two_transfers_same_token.scen.json b/multi-transfer-esdt/scenarios/two_transfers_same_token.scen.json index d58f4972..02d29c99 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|nested:0", - "0x0102030405060708091011121314151617181920|address:user1|nested:str:BRIDGE-123456|biguint:100,200|u64:2|nested:str:data|u64:10000000|nested:0" + "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/tests/multi_transfer_blackbox_test.rs b/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs index 65e94c94..553f5ed8 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, ManagedVec, + ManagedVec, MultiValueEncoded, TokenIdentifier, }, }; use multiversx_sc_modules::pause::ProxyTrait; @@ -279,7 +279,7 @@ fn basic_setup_test() { tx_nonce: 1u64, data: ManagedBuffer::from("data"), gas_limit: GAS_LIMIT, - args: ManagedVec::new() + args: ManagedVec::new(), }; test.world.check_state_step( @@ -316,7 +316,7 @@ fn basic_transfer_test() { tx_nonce: 1u64, data: ManagedBuffer::from("data"), gas_limit: GAS_LIMIT, - args: ManagedVec::new() + args: ManagedVec::new(), }; test.world.check_state_step( 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 602df64f..9ea7fc2b 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 @@ -4,10 +4,22 @@ 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.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 } diff --git a/multisig/src/util.rs b/multisig/src/util.rs index df489c64..f44eba1d 100644 --- a/multisig/src/util.rs +++ b/multisig/src/util.rs @@ -49,7 +49,8 @@ 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, args) = 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,7 +60,7 @@ pub trait UtilModule: crate::storage::StorageModule { tx_nonce, data, gas_limit, - args + args, }); } diff --git a/multisig/tests/multisig_scenario_rs_test.rs b/multisig/tests/multisig_scenario_rs_test.rs index a615f95e..0a950c5a 100644 --- a/multisig/tests/multisig_scenario_rs_test.rs +++ b/multisig/tests/multisig_scenario_rs_test.rs @@ -5,9 +5,18 @@ fn world() -> ScenarioWorld { 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.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 } From 806a7693084d3a432379ef0dfd25938a010c4ea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Fri, 2 Feb 2024 09:57:44 +0200 Subject: [PATCH 2/2] Remove commented code --- common/transaction/src/lib.rs | 92 ----------------------------------- 1 file changed, 92 deletions(-) diff --git a/common/transaction/src/lib.rs b/common/transaction/src/lib.rs index 076998ec..fa45ce32 100644 --- a/common/transaction/src/lib.rs +++ b/common/transaction/src/lib.rs @@ -5,7 +5,6 @@ multiversx_sc::derive_imports!(); use eth_address::EthAddress; use multiversx_sc::codec::{EncodeErrorHandler, NestedDecodeInput, TopEncodeOutput}; -// use multiversx_sc::codec::{DecodeErrorHandler, EncodeErrorHandler, NestedDecodeInput, TopDecodeInput, TopEncodeOutput}; pub mod transaction_status; @@ -102,97 +101,6 @@ impl TopDecode for EthTransaction { } } -// impl codec::TopEncode for EthTransaction { -// fn top_encode_or_handle_err( -// &self, -// output: O, -// h: H, -// ) -> core::result::Result<(), H::HandledErr> -// where -// O: codec::TopEncodeOutput, -// H: codec::EncodeErrorHandler, -// { -// self { - -// } -// match self.args. { -// TokenMapperState::NotSet => codec::TopEncode::top_encode_or_handle_err(&"", output, h), -// TokenMapperState::Pending => { -// codec::TopEncode::top_encode_or_handle_err(&"pending", output, h) -// }, -// TokenMapperState::Token(token) => { -// codec::TopEncode::top_encode_or_handle_err(&token, output, h) -// }, -// } -// } -// } - -// impl TopDecode for EthTransaction { -// fn top_decode_or_handle_err(top_input: I, h: H) -> Result -// where -// I: codec::TopDecodeInput, -// H: codec::DecodeErrorHandler, -// { -// let mut nested_buffer = top_input.into_nested_buffer(); -// let result = Self::dep_decode_or_handle_err(&mut nested_buffer, h)?; -// if !codec::NestedDecodeInput::is_depleted(&nested_buffer) { -// return Err(h.handle_error(codec::DecodeError::INPUT_TOO_LONG)); -// } -// Ok(result) -// } -// } - -// impl codec::TopDecode for EthTransaction { -// fn top_decode_or_handle_err(input: I, h: H) -> core::result::Result -// where -// I: codec::TopDecodeInput, -// H: codec::DecodeErrorHandler, -// { -// let decoded_input = ManagedBuffer::top_decode_or_handle_err(input, h)?; -// if decoded_input.is_empty() { -// Ok(TokenMapperState::NotSet) -// } else if decoded_input == PENDING_ENCODING { -// Ok(TokenMapperState::Pending) -// } else { -// let token_id = TokenIdentifier::from_esdt_bytes(decoded_input); -// Ok(TokenMapperState::Token(token_id)) -// } -// } -// } - -// impl TopDecode for EthTransaction { -// fn top_decode_or_handle_err(input: I, h: H) -> Result -// where -// I: codec::TopDecodeInput, -// H: codec::DecodeErrorHandler, -// { -// let mut result: EthTransaction = EthTransaction::new(); -// let mut nested_arg = input.into_nested_buffer(); -// while !nested_arg.is_depleted() { -// if let Err(capacity_error) = -// result.try_push(T::dep_decode_or_handle_err(&mut nested_arg, h)?) -// { -// return Err(h.handle_error(DecodeError::from(capacity_error))); -// } -// } -// if !nested_arg.is_depleted() { -// if let Err(capacity_error) = -// result.try_push(T::dep_decode_or_handle_err(&mut nested_arg, h)?) -// { -// return Err(h.handle_error(DecodeError::from(capacity_error))); -// } -// } -// Ok(result) -// } - -// fn top_decode(input: I) -> Result -// where -// I: TopDecodeInput, -// { -// Self::top_decode_or_handle_err(input, codec::DefaultErrorHandler) -// } -// } - pub type EthTxAsMultiValue = MultiValue8< EthAddress, ManagedAddress,