pub enum JsonStorageKey {
Hash(B256),
Number(U256),
}Expand description
A storage key type that can be serialized to and from a hex string up to 32 bytes. Used for
eth_getStorageAt and eth_getProof RPCs.
This is a wrapper type meant to mirror geth’s serialization and deserialization behavior for storage keys.
In eth_getStorageAt, this is used for deserialization of the index field. Internally, the
index is a B256, but in eth_getStorageAt requests, its serialization can be up to 32
bytes. To support this, the storage key is deserialized first as a U256, and converted to a
B256 for use internally.
eth_getProof also takes storage keys up to 32 bytes as input, so the keys field is
similarly deserialized. However, geth populates the storage proof key fields in the response
by mirroring the key field used in the input.
See how storageKeys (the input) are populated in the StorageResult (the output):
https://github.com/ethereum/go-ethereum/blob/00a73fbcce3250b87fc4160f3deddc44390848f4/internal/ethapi/api.go#L658-L690
The contained B256 and From implementation for String are used to preserve the input and implement this behavior from geth.
Variants§
Hash(B256)
A full 32-byte key (tried first during deserialization)
Number(U256)
A number (fallback if B256 deserialization fails)
Implementations§
Trait Implementations§
Source§impl Clone for JsonStorageKey
impl Clone for JsonStorageKey
Source§fn clone(&self) -> JsonStorageKey
fn clone(&self) -> JsonStorageKey
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more