Add StorageKey impls for all primitive integer types and bool#1431
Open
cburgdorf wants to merge 1 commit into
Open
Add StorageKey impls for all primitive integer types and bool#1431cburgdorf wants to merge 1 commit into
cburgdorf wants to merge 1 commit into
Conversation
cburgdorf
added a commit
to cburgdorf/fe
that referenced
this pull request
May 7, 2026
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 31c506e823
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Previously only `u256` and `Address` could be used as `StorageMap` keys. With these impls, `StorageMap<K, V>` accepts any of u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, i256, isize, and bool — matching Solidity's `mapping(intN/uintN/bool => V)` slot derivation, since each `write_key` left-pads to 32 bytes via `WordRepr::to_word()` (zero-extending unsigned, sign-extending signed, encoding `bool` as 0/1). Notable consumer: containers like `DoubleEndedQueue` that want to pack their indices into a single storage slot via `u128` keys — previously forced to `u256` keys for lack of this impl. The new test fixture `storage_map_key_types.fe` exercises each key type by storing and reading values back through a contract method. Note: `test_signed_keys` constructs negative i8/i32/i256 keys *inside* the contract instead of decoding them from calldata, sidestepping an unrelated Sonatina calldata-decoder bug for negative `intN` values where N < 256.
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.
Previously only
u256andAddresscould be used asStorageMapkeys. With these impls,StorageMap<K, V>accepts any of u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, i256, isize, and bool — matching Solidity'smapping(intN/uintN/bool => V)slot derivation, since eachwrite_keyleft-pads to 32 bytes viaWordRepr::to_word()(zero-extending unsigned, sign-extending signed, encodingboolas 0/1).Notable consumer: containers like
DoubleEndedQueuethat want to pack their indices into a single storage slot viau128keys — previously forced tou256keys for lack of this impl.The new test fixture
storage_map_key_types.feexercises each key type by storing and reading values back through a contract method.Note:
test_signed_keysconstructs negative i8/i32/i256 keys inside the contract instead of decoding them from calldata, sidestepping an unrelated Sonatina calldata-decoder bug for negativeintNvalues where N < 256.