@@ -14,6 +14,10 @@ use cairo_vm::felt::Felt252;
14
14
use getset:: { Getters , MutGetters } ;
15
15
use std:: collections:: HashMap ;
16
16
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.
17
21
#[ derive( Debug , MutGetters , Getters , PartialEq , Clone , Default ) ]
18
22
pub struct InMemoryStateReader {
19
23
#[ getset( get_mut = "pub" ) ]
@@ -31,6 +35,15 @@ pub struct InMemoryStateReader {
31
35
}
32
36
33
37
impl 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.
34
47
pub fn new (
35
48
address_to_class_hash : HashMap < Address , ClassHash > ,
36
49
address_to_nonce : HashMap < Address , Felt252 > ,
@@ -49,6 +62,18 @@ impl InMemoryStateReader {
49
62
}
50
63
}
51
64
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].
52
77
fn get_compiled_class (
53
78
& mut self ,
54
79
compiled_class_hash : & CompiledClassHash ,
0 commit comments