From 10b8301f1cf97f87881ae9b4d0036b94ba732567 Mon Sep 17 00:00:00 2001 From: MarcusDavidG Date: Fri, 19 Jun 2026 07:31:37 +0100 Subject: [PATCH] fix: extend storage TTL on every invoice save Soroban persistent storage entries expire if TTL is not extended. Recurring and long-lived invoices risk becoming inaccessible. Set min_ttl=100_000 ledgers, max_ttl=6_307_200 (~1 year at 5s/ledger) on every save_invoice call. Closes #5 --- .gitignore | 4 ++-- contracts/sharpy/src/lib.rs | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 5554c2e..3ef2fcf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ # Rust target -sharpy -test_snapshots// +/sharpy +test_snapshots/ Cargo.lock *.rlib *.so diff --git a/contracts/sharpy/src/lib.rs b/contracts/sharpy/src/lib.rs index d2a077e..54e4e87 100644 --- a/contracts/sharpy/src/lib.rs +++ b/contracts/sharpy/src/lib.rs @@ -43,6 +43,8 @@ fn load_invoice(env: &Env, id: u64) -> Invoice { fn save_invoice(env: &Env, id: u64, invoice: &Invoice) { env.storage().persistent().set(&invoice_key(id), invoice); + // Extend TTL to ~1 year (in ledgers at ~5s each: 365*24*3600/5 = 6_307_200) + env.storage().persistent().extend_ttl(&invoice_key(id), 100_000, 6_307_200); } fn append_audit(env: &Env, id: u64, action: Symbol, actor: &Address) {