Skip to content

feat(#139): add TTL auto-renewal for active users#158

Open
kimmoris12345 wants to merge 1 commit into
zintarh:mainfrom
kimmoris12345:feat/ttl-auto-renewal
Open

feat(#139): add TTL auto-renewal for active users#158
kimmoris12345 wants to merge 1 commit into
zintarh:mainfrom
kimmoris12345:feat/ttl-auto-renewal

Conversation

@kimmoris12345

Copy link
Copy Markdown

Closes #139

Summary

Adds TTL auto-renewal for active users so that their metadata keys (WrapCount, LatestPeriod) stay alive when they mint new wraps. Historical wrap records are not auto-renewed — that requires period enumeration (Issue #90).

Changes

src/lib.rs

  • renew_all_ttls(user) (line 457): New admin-only function that extends TTL for WrapCount, LatestPeriod, and the contract instance. Documents dependency on Issue feat: Add multi-period wrap summary query (aggregate stats across months) #90 for full wrap enumeration.
  • extend_ttl doc comment (line 383): Comprehensive TTL lifecycle documentation covering automatic metadata renewal, manual wrap renewal, admin bulk renewal, and expiry risk.

src/test.rs — 5 new tests (line 1291)

Test Purpose
test_metadata_ttl_extended_on_new_mint Verifies WrapCount and LatestPeriod survive across multiple mints
test_old_wrap_preserved_on_new_mint Verifies old wraps are not corrupted/lost on new mint (not auto-extended)
test_renew_all_ttls_extends_metadata Verifies admin bulk-renewal works
test_renew_all_ttls_requires_admin_auth Verifies admin auth required
test_renew_all_ttls_before_init_fails Verifies fail before init

SECURITY_RECOMMENDATIONS.md

  • Added "TTL Lifecycle & Data Freshness" section with:
    • TTL strategy table per storage key
    • Design decision rationale (auto-renew metadata only)
    • Mitigation recommendations (off-chain bots, admin bulk renewal)
    • Gas analysis cost estimates
    • Test coverage table

Design Decision

Auto-renew metadata onlyWrapCount and LatestPeriod were already being extended on every mint_wrap. This PR documents that behavior and adds renew_all_ttls for admin bulk metadata renewal. Historical wraps are not auto-renewed because period enumeration (Issue #90) is required to iterate them on-chain.

Verification

All 54 tests pass (cargo test).

- Add renew_all_ttls(user) admin function that extends metadata TTLs
- Document TTL lifecycle in extend_ttl doc comment and SECURITY_RECOMMENDATIONS.md
- Add 5 unit tests covering metadata renewal, old wrap preservation, and admin auth
- All 54 tests pass
@drips-wave

drips-wave Bot commented Jun 26, 2026

Copy link
Copy Markdown

@kimmoris12345 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

enhancement: Add TTL auto-renewal for active users

1 participant