Storage inspection command
Created by: ascjones
Contract metadata describes the storage in the layout
section. A storage
command should be introduced which utilizes this to allow inspection of a contract's storage from the command line.
So for the flipper
:
#[ink::contract]
pub mod flipper {
#[ink(storage)]
pub struct Flipper {
value: bool,
}
}
Calling cargo contract storage --contract <contract_account>
would result in the following:
Flipper { value: false }
This would work by using the metadata to generate keys and query the get_storage
rpc: https://github.com/paritytech/substrate/blob/30ecb9b259140a860b20c662fda01b5b2c33e5fa/frame/contracts/rpc/runtime-api/src/lib.rs#L54.
The metadata would then be used to decode the results into human readable form, building on the "SCON" work done in #79.
For an initial implementation I think we don't need to do everything in a single PR, we can define a basic implementation that is useful and then add features as follow up PRs.
Lazy and Collections
We would need to consider how to handle the built-in lazy and collection types, they would probably require some custom display code.
Keys
It might be useful to be able to augment the data with the actual storage keys, and also query individual storage keys either by the raw key or by name.
Raw Storage
For debugging of corrupt storage it would be useful to be able to inspect the raw contract storage (without decoding).