Skip to content

Commit

Permalink
chore: add storage_slots helper (#1884)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Jan 4, 2025
1 parent 3539a02 commit c927bd8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/genesis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,14 @@ impl GenesisAccount {
self
}

/// Returns an iterator over the storage slots in (`B256`, `U256`) format.
pub fn storage_slots(&self) -> impl Iterator<Item = (B256, U256)> + '_ {
self.storage.as_ref().into_iter().flat_map(|storage| storage.iter()).map(|(key, value)| {
let value = U256::from_be_bytes(value.0);
(*key, value)
})
}

/// Convert the genesis account into the [`TrieAccount`] format.
pub fn into_trie_account(self) -> TrieAccount {
self.into()
Expand Down

0 comments on commit c927bd8

Please sign in to comment.