Skip to content

Commit 4a748f0

Browse files
siroukReginald PianoBea Hobby
authored andcommitted
[framework] CW advance direct (#422)
Co-authored-by: Reginald Piano <[email protected]> Co-authored-by: Bea Hobby <[email protected]>
1 parent 1882c6a commit 4a748f0

File tree

2 files changed

+20
-23
lines changed

2 files changed

+20
-23
lines changed

framework/libra-framework/sources/ol_sources/donor_voice_txs.move

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,20 @@ module ol_framework::donor_voice_txs {
280280
let tx: Payment = multi_action::extract_proposal_data(multisig_address, &uid);
281281

282282
if (passed && option::is_some(&withdraw_cap_opt)) {
283-
schedule(option::borrow(&withdraw_cap_opt), tx, &uid);
283+
// else large payments to slow wallets take longer to review
284+
if (slow_wallet::is_slow(payee)) {
285+
let deadline = epoch_helper::get_current_epoch() + DEFAULT_PAYMENT_DURATION;
286+
schedule(option::borrow(&withdraw_cap_opt), tx, &uid, deadline);
287+
288+
} else {
289+
// transfer happens immediately after multisig threshold is reached
290+
let can_withdraw = community_wallet_advance::can_withdraw_amount(multisig_address, tx.value);
291+
292+
if (can_withdraw) {
293+
community_wallet_advance::transfer_credit(option::borrow(&withdraw_cap_opt), tx.payee, tx.value);
294+
}
295+
}
296+
284297
};
285298

286299
multi_action::maybe_restore_withdraw_cap(withdraw_cap_opt);
@@ -302,13 +315,11 @@ module ol_framework::donor_voice_txs {
302315
// the rejected list.
303316

304317
fun schedule(
305-
withdraw_capability: &WithdrawCapability, tx: Payment, uid: &guid::ID
318+
withdraw_capability: &WithdrawCapability, tx: Payment, uid: &guid::ID, deadline: u64
306319
) acquires TxSchedule {
307320
let multisig_address = account::get_withdraw_cap_address(withdraw_capability);
308321
let transfers = borrow_global_mut<TxSchedule>(multisig_address);
309322

310-
let deadline = epoch_helper::get_current_epoch() + DEFAULT_PAYMENT_DURATION;
311-
312323
let t = TimedTransfer {
313324
uid: *uid,
314325
deadline, // pays automatically at the end of seventh epoch. Unless there is a veto by a Donor. In that case a day is added for every day there is a veto. This deduplicates vetoes.
@@ -404,7 +415,7 @@ module ol_framework::donor_voice_txs {
404415
let is_slow = slow_wallet::is_slow(t.tx.payee);
405416

406417

407-
let this_transfer_value =if (!is_slow) {
418+
let this_transfer_value = if (!is_slow) {
408419
let can_withdraw = community_wallet_advance::can_withdraw_amount(multisig_address, t.tx.value);
409420

410421
if (can_withdraw) {
@@ -1000,21 +1011,9 @@ module ol_framework::donor_voice_txs {
10001011
ids
10011012
}
10021013

1003-
// // Helper function to list proposals by status in the multisig system
1004-
// fun list_multisig_proposals_by_status(multisig_address: address, status_enum: u8): vector<u64> {
1005-
// // Check if we have access to the multi_action module for the Payment type
1006-
// if (!multi_action::has_action<Payment>(multisig_address)) {
1007-
// return vector::empty<u64>()
1008-
// };
1009-
1010-
// // Use the new get_proposals_by_status function to fetch IDs directly
1011-
// multi_action::get_proposals_by_status<Payment>(multisig_address, status_enum)
1012-
// }
1013-
10141014
//////// TRANSACTIONS ////////
10151015

1016-
// /// A signer of the multisig can propose a payment
1017-
// }
1016+
/// A signer of the multisig can propose a payment
10181017

10191018
public entry fun propose_payment_tx(
10201019
auth: signer,

framework/libra-framework/sources/ol_sources/tests/donor_voice.test.move

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -540,12 +540,10 @@ module ol_framework::test_donor_voice {
540540
donor_voice_txs::propose_payment_tx(carol, donor_voice_address, marlon_addr, 100, b"thanks marlon", is_unlocked_advance);
541541

542542
// PROCESS THE PAYMENT
543-
// process epoch 3 accounts
544543

545-
mock::trigger_epoch(root); // into epoch 1
546-
mock::trigger_epoch(root); // into epoch 2
547-
mock::trigger_epoch(root); // into epoch 3, processes at the end of this epoch.
548-
mock::trigger_epoch(root); // epoch 4 should include the payment
544+
// COMMIT NOTE: No need to advance epoch here, since we are testing the unlocked payment, which is processed immediately.
545+
// mock::trigger_epoch(root); // into epoch 1
546+
549547

550548
let (marlon_unlocked_post, marlon_rando_balance_post) = ol_account::balance(marlon_addr);
551549

0 commit comments

Comments
 (0)