Repository navigation
chore: tag all storage keys as named constants - #73
Merged
codemagician1949 merged 1 commit intoAug 29, 2026
Merged
Conversation
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.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
No inline string storage keys — all moved to named constants.
What this does
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 namedADMINconstant and replaced all 4 call sites. (Test-code uses ofsymbol_short!("admin")as an identity value passed intoinitialize(..., admin, ...)are untouched — those aren't storage keys, just test data.)mod storage { ... }block inlib.rs, and invoice-registry additionally had two keys (QUEUED_UPGRADE,UPGRADE_PAUSED) as loose top-level consts outside that module.#[contracttype] enum DataKey(arguably the strongest form of this — a typo is a compile error, not a silent new slot) but had it inline inlib.rsrather than its own module.Consolidated all four into a
keys.rsmodule per crate, as the issue asks, and renamed every reference (storage::X/ bareX/DataKeyimport) accordingly. governance'sDataKeyalso gainedDebug, PartialEqderives so its test can assert on it.Testing
Each new
keys.rshas a#[cfg(test)] mod testsasserting every key's underlyingSymbol(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, andcargo test --workspaceare all clean.Closes #6.