Skip to content

Commit

Permalink
multisig: EthTransaction to EthTxAsMultiValue
Browse files Browse the repository at this point in the history
  • Loading branch information
CostinCarabas committed Aug 14, 2024
1 parent aedf519 commit 5ad062d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion multisig/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ pub trait Multisig:
fn propose_multi_transfer_esdt_batch(
&self,
eth_batch_id: u64,
transfers: MultiValueEncoded<EthTransaction<Self::Api>>,
transfers: MultiValueEncoded<EthTxAsMultiValue<Self::Api>>,
) -> usize {
let next_eth_batch_id = self.last_executed_eth_batch_id().get() + 1;
require!(
Expand Down
10 changes: 5 additions & 5 deletions multisig/src/queries.rs
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -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<EthTransaction<Self::Api>>,
transfers: MultiValueEncoded<EthTxAsMultiValue<Self::Api>>,
) -> bool {
let action_id = self.get_action_id_for_transfer_batch(eth_batch_id, transfers);

Expand All @@ -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<EthTransaction<Self::Api>>,
transfers: MultiValueEncoded<EthTxAsMultiValue<Self::Api>>,
) -> 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)
Expand Down
18 changes: 15 additions & 3 deletions multisig/src/util.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use multiversx_sc::imports::*;

use transaction::EthTransaction;
use transaction::{EthTransaction, EthTxAsMultiValue};

use crate::storage::EthBatchHash;
use crate::user_role::UserRole;
Expand Down Expand Up @@ -45,11 +45,23 @@ pub trait UtilModule: crate::storage::StorageModule {

fn transfers_multi_value_to_eth_tx_vec(
&self,
transfers: MultiValueEncoded<EthTransaction<Self::Api>>,
transfers: MultiValueEncoded<EthTxAsMultiValue<Self::Api>>,
) -> ManagedVec<EthTransaction<Self::Api>> {
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
Expand Down

0 comments on commit 5ad062d

Please sign in to comment.