From 5ad062d0ff3eb9a396998c059d2940fbd996c923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Wed, 14 Aug 2024 12:35:08 +0300 Subject: [PATCH] multisig: EthTransaction to EthTxAsMultiValue --- multisig/src/lib.rs | 2 +- multisig/src/queries.rs | 10 +++++----- multisig/src/util.rs | 18 +++++++++++++++--- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/multisig/src/lib.rs b/multisig/src/lib.rs index 5e3e5cf6..2c866839 100644 --- a/multisig/src/lib.rs +++ b/multisig/src/lib.rs @@ -267,7 +267,7 @@ pub trait Multisig: fn propose_multi_transfer_esdt_batch( &self, eth_batch_id: u64, - transfers: MultiValueEncoded>, + transfers: MultiValueEncoded>, ) -> usize { let next_eth_batch_id = self.last_executed_eth_batch_id().get() + 1; require!( diff --git a/multisig/src/queries.rs b/multisig/src/queries.rs index 93a6b594..4bb93210 100644 --- a/multisig/src/queries.rs +++ b/multisig/src/queries.rs @@ -1,7 +1,7 @@ use multiversx_sc::imports::*; use crate::{action::Action, esdt_safe_proxy, multi_transfer_esdt_proxy, user_role::UserRole}; -use transaction::{transaction_status::TransactionStatus, EthTransaction, TxBatchSplitInFields}; +use transaction::{transaction_status::TransactionStatus, EthTxAsMultiValue, TxBatchSplitInFields}; /// Note: Additional queries can be found in the Storage module #[multiversx_sc::module] @@ -73,7 +73,7 @@ pub trait QueriesModule: crate::storage::StorageModule + crate::util::UtilModule fn was_transfer_action_proposed( &self, eth_batch_id: u64, - transfers: MultiValueEncoded>, + transfers: MultiValueEncoded>, ) -> bool { let action_id = self.get_action_id_for_transfer_batch(eth_batch_id, transfers); @@ -87,10 +87,10 @@ pub trait QueriesModule: crate::storage::StorageModule + crate::util::UtilModule fn get_action_id_for_transfer_batch( &self, eth_batch_id: u64, - transfers: MultiValueEncoded>, + transfers: MultiValueEncoded>, ) -> usize { - let transfers_as_eth_tx = self.transfers_multi_value_to_eth_tx_vec(transfers); - let batch_hash = self.hash_eth_tx_batch(&transfers_as_eth_tx); + let transfers_as_struct = self.transfers_multi_value_to_eth_tx_vec(transfers); + let batch_hash = self.hash_eth_tx_batch(&transfers_as_struct); self.batch_id_to_action_id_mapping(eth_batch_id) .get(&batch_hash) diff --git a/multisig/src/util.rs b/multisig/src/util.rs index 36e9eff0..36661a1c 100644 --- a/multisig/src/util.rs +++ b/multisig/src/util.rs @@ -1,6 +1,6 @@ use multiversx_sc::imports::*; -use transaction::EthTransaction; +use transaction::{EthTransaction, EthTxAsMultiValue}; use crate::storage::EthBatchHash; use crate::user_role::UserRole; @@ -45,11 +45,23 @@ pub trait UtilModule: crate::storage::StorageModule { fn transfers_multi_value_to_eth_tx_vec( &self, - transfers: MultiValueEncoded>, + transfers: MultiValueEncoded>, ) -> ManagedVec> { let mut transfers_as_eth_tx = ManagedVec::new(); + // for transfer in transfers { + // transfers_as_eth_tx.push(transfer); + // } for transfer in transfers { - transfers_as_eth_tx.push(transfer); + let (from, to, token_id, amount, tx_nonce, call_data) = transfer.into_tuple(); + + transfers_as_eth_tx.push(EthTransaction { + from, + to, + token_id, + amount, + tx_nonce, + call_data, + }); } transfers_as_eth_tx