Skip to content

chore: tag all storage keys as named constants - #73

Merged
codemagician1949 merged 1 commit into
IntensifierLab:mainfrom
Codeinx:issue-6-storage-key-constants
Aug 29, 2026
Merged

codemagician1949 merged 1 commit into
IntensifierLab:mainfrom
Codeinx:issue-6-storage-key-constants

Conversation

@Codeinx

@Codeinx Codeinx commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Overview

No inline string storage keys — all moved to named constants.

What this does

  • repayment-waterfall had 4 real inline-literal storage-key call sites (env.storage().instance().has/get/set(&symbol_short!("admin"))) — a typo in any of those silently creates a disconnected new storage slot instead of failing to compile. Added a named ADMIN constant and replaced all 4 call sites. (Test-code uses of symbol_short!("admin") as an identity value passed into initialize(..., admin, ...) are untouched — those aren't storage keys, just test data.)
  • pool-manager and invoice-registry already had their keys named, but inside an inline mod storage { ... } block in lib.rs, and invoice-registry additionally had two keys (QUEUED_UPGRADE, UPGRADE_PAUSED) as loose top-level consts outside that module.
  • governance already used a type-safe #[contracttype] enum DataKey (arguably the strongest form of this — a typo is a compile error, not a silent new slot) but had it inline in lib.rs rather than its own module.

Consolidated all four into a keys.rs module per crate, as the issue asks, and renamed every reference (storage::X / bare X / DataKey import) accordingly. governance's DataKey also gained Debug, PartialEq derives so its test can assert on it.

Testing

Each new keys.rs has a #[cfg(test)] mod tests asserting every key's underlying Symbol (or, for governance's enum, that its no-argument variants are pairwise distinct) — the acceptance criterion's "tests verify key names."

cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, cargo check --workspace, and cargo test --workspace are all clean.

Closes #6.

Storage keys were inline symbol_short!("...") literals at the call
site in three places, plus a repeated bare mod storage { ... } pattern
that wasn't consistently named or located:

- repayment-waterfall had 4 real inline-literal storage-key call sites
  (env.storage().instance().has/get/set(&symbol_short!("admin"))) —
  a typo in any of those silently creates a disconnected new storage
  slot instead of failing to compile. Added a named ADMIN constant and
  replaced all 4 call sites. (Test-code uses of symbol_short!("admin")
  as an *identity value* passed into initialize(..., admin, ...) are
  untouched — those aren't storage keys.)
- pool-manager and invoice-registry already had their keys named, but
  inside an inline `mod storage { ... }` block in lib.rs, and
  invoice-registry additionally had two keys (QUEUED_UPGRADE,
  UPGRADE_PAUSED) as loose top-level consts outside that module.
- governance already used a type-safe `#[contracttype] enum DataKey`
  (arguably the strongest form of this — a typo is a compile error,
  not a silent new slot) but had it inline in lib.rs rather than its
  own module.

Consolidated all four into a `keys.rs` module per crate, as the issue
asks, and renamed every reference (`storage::X` / bare `X` / `DataKey`
import) accordingly. governance's DataKey also gained `Debug,
PartialEq` derives so its test can assert on it.

## Testing

Each new keys.rs has a `#[cfg(test)] mod tests` asserting every key's
underlying Symbol (or, for governance's enum, that its no-argument
variants are pairwise distinct) — the acceptance criterion's tests
verifying key names.

`cargo fmt --all --check`, `cargo clippy --workspace --all-targets --
-D warnings`, `cargo check --workspace`, and `cargo test --workspace`
are all clean.

Closes IntensifierLab#6.
@codemagician1949
codemagician1949 merged commit f020a71 into IntensifierLab:main Aug 29, 2026
4 checks passed
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.

chore: tag all storage keys as named constants

2 participants