@@ -6,29 +6,43 @@ use super::super::strings::replace_last;
6
6
/// Has several helper functions to add different types of traces.
7
7
#[ derive( Clone , Debug ) ]
8
8
pub struct TraceFactory {
9
+ /// The level of the trace. Higher numbers mean more verbose output.
9
10
pub level : i8 ,
11
+ /// The collection of traces gathered during execution.
10
12
pub traces : Vec < Trace > ,
11
13
}
12
14
13
15
/// The trace category is used to determine how the trace is formatted.
14
16
#[ derive( Clone , Debug ) ]
15
17
pub enum TraceCategory {
18
+ /// Standard log message.
16
19
Log ,
20
+ /// Log message with unknown source.
17
21
LogUnknown ,
22
+ /// General message.
18
23
Message ,
24
+ /// Function call trace.
19
25
Call ,
26
+ /// Contract creation trace.
20
27
Create ,
28
+ /// Empty trace (placeholder).
21
29
Empty ,
30
+ /// Contract self-destruct trace.
22
31
Suicide ,
23
32
}
24
33
25
34
/// Individual trace, which is added to the trace factory.
26
35
#[ derive( Clone , Debug ) ]
27
36
pub struct Trace {
37
+ /// The category of the trace, determining its formatting and interpretation.
28
38
pub category : TraceCategory ,
39
+ /// The instruction number or identifier for this trace.
29
40
pub instruction : u32 ,
41
+ /// The message content of the trace, potentially multiple lines.
30
42
pub message : Vec < String > ,
43
+ /// The parent trace identifier (if this is a child trace).
31
44
pub parent : u32 ,
45
+ /// Child trace identifiers that are nested under this trace.
32
46
pub children : Vec < u32 > ,
33
47
}
34
48
@@ -246,6 +260,24 @@ impl TraceFactory {
246
260
self . add ( "call" , parent_index, instruction, vec ! [ title, returns] )
247
261
}
248
262
263
+ /// Adds a function call trace with extra information.
264
+ ///
265
+ /// This method creates a trace entry for a function call and includes additional context
266
+ /// information.
267
+ ///
268
+ /// # Arguments
269
+ ///
270
+ /// * `parent_index` - The index of the parent trace
271
+ /// * `instruction` - The instruction identifier
272
+ /// * `origin` - The origin context (e.g., contract name)
273
+ /// * `function_name` - The name of the function being called
274
+ /// * `args` - The arguments passed to the function
275
+ /// * `returns` - The return value(s) of the function
276
+ /// * `extra` - Additional context information to display
277
+ ///
278
+ /// # Returns
279
+ ///
280
+ /// * `u32` - The index of the newly added trace
249
281
#[ allow( clippy:: too_many_arguments) ]
250
282
pub fn add_call_with_extra (
251
283
& mut self ,
0 commit comments