@@ -14,6 +14,10 @@ use cairo_vm::felt::Felt252;
1414use getset:: { Getters , MutGetters } ;
1515use std:: collections:: HashMap ;
1616
17+ /// A [StateReader] that holds all the data in memory.
18+ ///
19+ /// This implementation is used for testing and debugging.
20+ /// It uses HashMaps to store the data.
1721#[ derive( Debug , MutGetters , Getters , PartialEq , Clone , Default ) ]
1822pub struct InMemoryStateReader {
1923 #[ getset( get_mut = "pub" ) ]
@@ -31,6 +35,15 @@ pub struct InMemoryStateReader {
3135}
3236
3337impl InMemoryStateReader {
38+ /// Creates a new InMemoryStateReader.
39+ ///
40+ /// # Parameters
41+ /// - `address_to_class_hash` - A HashMap from contract addresses to their class hashes.
42+ /// - `address_to_nonce` - A HashMap from contract addresses to their nonces.
43+ /// - `address_to_storage` - A HashMap from storage entries to their values.
44+ /// - `class_hash_to_contract_class` - A HashMap from class hashes to their contract classes.
45+ /// - `casm_contract_classes` - A [CasmClassCache].
46+ /// - `class_hash_to_compiled_class_hash` - A HashMap from class hashes to their compiled class hashes.
3447 pub fn new (
3548 address_to_class_hash : HashMap < Address , ClassHash > ,
3649 address_to_nonce : HashMap < Address , Felt252 > ,
@@ -49,6 +62,18 @@ impl InMemoryStateReader {
4962 }
5063 }
5164
65+ /// Gets the [CompiledClass] with the given [CompiledClassHash].
66+ ///
67+ /// It looks for the [CompiledClass] both in the cache and the storage.
68+ ///
69+ /// # Parameters
70+ /// - `compiled_class_hash` - The [CompiledClassHash] of the [CompiledClass] to get.
71+ ///
72+ /// # Errors
73+ /// - [StateError::NoneCompiledClass] - If the [CompiledClass] is not found.
74+ ///
75+ /// # Returns
76+ /// The [CompiledClass] with the given [CompiledClassHash].
5277 fn get_compiled_class (
5378 & mut self ,
5479 compiled_class_hash : & CompiledClassHash ,
0 commit comments