Skip to content

Commit

Permalink
[contract: multisig, bugfix] fixed issue in signing and performing ba…
Browse files Browse the repository at this point in the history
…tches in one go
  • Loading branch information
ccorcoveanu committed Jul 12, 2024
1 parent f54b696 commit afa4fc8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
17 changes: 13 additions & 4 deletions contracts/multisig/src/multisig_sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,19 @@ pub trait MultisigSignModule:
}
}

if quorums_reached {
for action_id in self.action_groups(group_id).iter() {
let _ = self.perform_action(action_id);
}
if !quorums_reached {
return;
}

// Copy action_ids before executing them since perform_action does a swap_remove
// clearing the last item
let mut action_ids = ManagedVec::<Self::Api, _>::new();
for action_id in self.action_groups(group_id).iter() {
action_ids.push(action_id);
}

for action_id in &action_ids {
let _ = self.perform_action(action_id);
}
}

Expand Down
9 changes: 4 additions & 5 deletions contracts/multisig/tests/multisig_blackbox_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use multiversx_sc::{codec::top_encode_to_vec_u8_or_panic, types::BigUint};
use multiversx_sc_scenario::imports::*;

use adder::adder_proxy;
use multisig::{action::{Action, CallActionData, GasLimit}, multisig_proxy};
use num_bigint::BigUint;
use multisig::{action::GasLimit, multisig_proxy};

const ADDER_ADDRESS: TestSCAddress = TestSCAddress::new("adder");
const ADDER_OWNER_ADDRESS: TestAddress = TestAddress::new("adder-owner");
Expand Down Expand Up @@ -497,8 +496,8 @@ fn test_transfer_execute_sc_all() {
fn test_transfer_execute_batch() {
let mut state = MultisigTestState::new();
state.deploy_multisig_contract().deploy_adder_contract();
let call_data = CallActionData {

let call_data = multisig_proxy::CallActionData {
to: ManagedAddress::from_address(&ADDER_ADDRESS.to_address()),
egld_amount: BigUint::default(),
endpoint_name: ManagedBuffer::new_from_bytes(BoxedBytes::from(&b"add"[..]).as_slice()),
Expand All @@ -507,7 +506,7 @@ fn test_transfer_execute_batch() {
};

let mut actions = MultiValueEncoded::new();
let action_id = Action::SendTransferExecuteEgld(call_data);
let action_id = multisig_proxy::Action::SendTransferExecuteEgld(call_data);
actions.push(action_id.clone());
actions.push(action_id.clone());

Expand Down

0 comments on commit afa4fc8

Please sign in to comment.