-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(serde
): StorageKeyKind
#1597
Conversation
crates/serde/src/storage.rs
Outdated
#[serde(from = "U256", into = "String")] | ||
pub struct JsonStorageKey(pub B256); | ||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize)] | ||
#[serde(into = "String")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Rjected isn't all of this now just serde(untagged) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I think so
crates/serde/src/storage.rs
Outdated
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] | ||
pub enum StorageKeyKind { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is now just #[serde(untagged)] then we no longer need any serialization on JsonStorageKey
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I simplified this and converted the jsonstoragekey type to an enum instead
Motivation
Closes #1553
Solution
Introduce the enum
StorageKeyKind
with variantsHash(B256)
andNumber(U256)
. Used inJsonStorageKey
.Tries to deserialize a string into the
Hash
variant first.PR Checklist