Description
Every invoice currently initialises all storage keys (payment map, contributor count, etc.) at creation, incurring rent for entries that may never be used. This issue converts those entries to lazily-initialised storage using env.storage().has() checks before reads, deferring rent until first write.
Technical Context
Audit all create_invoice storage writes in lib.rs and identify entries that are only populated after the first pay_invoice call (e.g. payment_map_key, contributor_count_key, payer_window_key). Replace unconditional writes with lazy get_or_default helpers. Update read paths to handle the absent case. Measure storage slot reduction using a test that compares slot counts before and after.
Acceptance Criteria
Description
Every invoice currently initialises all storage keys (payment map, contributor count, etc.) at creation, incurring rent for entries that may never be used. This issue converts those entries to lazily-initialised storage using
env.storage().has()checks before reads, deferring rent until first write.Technical Context
Audit all
create_invoicestorage writes inlib.rsand identify entries that are only populated after the firstpay_invoicecall (e.g.payment_map_key,contributor_count_key,payer_window_key). Replace unconditional writes with lazyget_or_defaulthelpers. Update read paths to handle the absent case. Measure storage slot reduction using a test that compares slot counts before and after.Acceptance Criteria
create_invoicewrites only the minimum required storage entries (invoice struct, status key)create_invoiceis ≤ N (document N)cargo test --test integrationruns without error on the refactored storage model