Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions contracts/split/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3934,6 +3934,15 @@ impl SplitContract {
.persistent()
.set(&recipient_whitelist_key(invoice_id), &whitelist);
events::recipient_whitelisted(&env, invoice_id, &address);
let mut added: Vec<Address> = Vec::new(&env);
added.push_back(address.clone());
events::recipient_whitelist_updated(
&env,
invoice_id,
invoice.recipient_whitelist_enabled,
&added,
&Vec::new(&env),
);
}
}

Expand Down Expand Up @@ -3974,6 +3983,15 @@ impl SplitContract {
.persistent()
.set(&recipient_whitelist_key(invoice_id), &new_wl);
events::recipient_removed_from_whitelist(&env, invoice_id, &address);
let mut removed: Vec<Address> = Vec::new(&env);
removed.push_back(address.clone());
events::recipient_whitelist_updated(
&env,
invoice_id,
invoice.recipient_whitelist_enabled,
&Vec::new(&env),
&removed,
);
}
}

Expand Down Expand Up @@ -7346,6 +7364,36 @@ impl SplitContract {
}
}

// Issue #686: announce when the overfunding policy actually changes the
// outcome of this payment, i.e. it would push `funded` past `total`.
// `Cap` has its own `overflow_behavior` events, so it is excluded here.
match invoice.overfunding_policy {
OverfundingPolicy::AcceptAll => {
let surplus = (invoice.funded + credited_amount - total).max(0);
if surplus > 0 {
events::overfunding_triggered(
env,
invoice_id,
payer,
&invoice.overfunding_policy,
surplus,
);
}
}
OverfundingPolicy::ReturnSurplus => {
if excess > 0 {
events::overfunding_triggered(
env,
invoice_id,
payer,
&invoice.overfunding_policy,
excess,
);
}
}
OverfundingPolicy::Cap => {}
}

invoice.insurance_fund += premium;

// Penalty for late payment (issues #42, #211).
Expand Down Expand Up @@ -7381,6 +7429,14 @@ impl SplitContract {
token_client.transfer(payer, &recipient, &share);
}
}
// Issue #687: surface the late-payment penalty deduction.
events::penalty_applied(
env,
invoice_id,
payer,
penalty_amount,
penalty_bps,
);
}
}
}
Expand Down Expand Up @@ -11875,9 +11931,11 @@ impl SplitContract {
assert!(is_creator_or_co || is_delegate, "not authorized");
}

let old_deadline = invoice.deadline;
invoice.deadline = new_deadline;
save_invoice(&env, invoice_id, &invoice);
append_audit_entry(&env, invoice_id, symbol_short!("extend"), &caller);
events::deadline_extended(&env, invoice_id, old_deadline, new_deadline);
}

/// Roll over a partially funded invoice to a new invoice with the same recipients,
Expand Down