-
Notifications
You must be signed in to change notification settings - Fork 120
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
Basic storage inspection command #1395
Conversation
I think we should update the CHANGELOG.md and the usage section of README.md file |
Done, but only a basic entry in the README, can be updated once the command is more fleshed out. |
|
||
/// Represents the raw key/value storage for the contract. | ||
#[derive(Serialize)] | ||
pub struct ContractStorageData(BTreeMap<Bytes, Bytes>); |
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.
Why do you need a dedicated structure for this if it only contains a single field, and has no methods?
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.
Don't strictly need it, just using the newtype idiom for readability: it is a public API so for me it is nice to have types describing the data. So the BTreeMap
I have used internally just because it serializes the key/values nicely into json, but that could change if we want to add more information in there, or have a different layout.
} | ||
} | ||
Layout::Array(_) => { | ||
todo!("Figure out what to do with an array layout") |
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.
What's the context?
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.
The context is that once we merge this pull request, I will continue working on storage inspection command.
Also worth looking at https://docs.rs/csv/latest/csv/cookbook/index.html#writing-basic to display values in CSV format |
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.
LGTM
This provides a foundation for #101.
It queries all the storage entries for a contract, and then associates the entries with root keys from the contract metadata storage layout, printing the results as JSON for now:
Also can display the raw storage keys/values if specified or if no contract metadata available:
For now the structure of the cells is flat, and only the raw data for the cells is shown. To continue on from this we should: