Summary
Invoice due-date monitoring and default triggering currently requires manual admin intervention. If no admin calls `mark_defaulted()` after grace period expiry, the invoice stays in an ambiguous state indefinitely. Stellar Turrets (or a Soroban automation service) can automate this monitoring.
Desired Automation
A Turret function that runs on a schedule:
- Fetches all `Active` invoices past their grace period deadline
- For each, submits a `mark_defaulted(invoice_id)` transaction signed by the Turret's key
- Turret key is whitelisted as a "keeper" in the invoice contract
```rust
// New role: keeper (can only call mark_defaulted, not other admin functions)
pub fn add_keeper(env: Env, keeper: Address) {
admin::require_admin(&env);
// ...
}
pub fn mark_defaulted(env: Env, invoice_id: u64) {
require_admin_or_keeper(&env);
// ... existing default logic ...
}
```
Alternative: Soroban Custom Account
Use a Soroban custom account contract that automatically triggers default when called by anyone, but only if the grace period has verifiably expired.
Acceptance Criteria
References
- `contracts/invoice/src/lib.rs` — `mark_defaulted()`
- Stellar Turrets documentation
Summary
Invoice due-date monitoring and default triggering currently requires manual admin intervention. If no admin calls `mark_defaulted()` after grace period expiry, the invoice stays in an ambiguous state indefinitely. Stellar Turrets (or a Soroban automation service) can automate this monitoring.
Desired Automation
A Turret function that runs on a schedule:
```rust
// New role: keeper (can only call mark_defaulted, not other admin functions)
pub fn add_keeper(env: Env, keeper: Address) {
admin::require_admin(&env);
// ...
}
pub fn mark_defaulted(env: Env, invoice_id: u64) {
require_admin_or_keeper(&env);
// ... existing default logic ...
}
```
Alternative: Soroban Custom Account
Use a Soroban custom account contract that automatically triggers default when called by anyone, but only if the grace period has verifiably expired.
Acceptance Criteria
References