11use cairo_vm:: felt:: Felt252 ;
22use cairo_vm:: types:: relocatable:: { MaybeRelocatable , Relocatable } ;
33
4+ /// Abstracts every response variant body for each syscall.
45pub ( crate ) enum ResponseBody {
56 StorageReadResponse { value : Option < Felt252 > } ,
67 GetBlockNumber { number : Felt252 } ,
@@ -11,6 +12,7 @@ pub(crate) enum ResponseBody {
1112 GetExecutionInfo { exec_info_ptr : Relocatable } ,
1213 GetBlockHash ( GetBlockHashResponse ) ,
1314}
15+ /// Wraps around any response body. It also contains the remaining gas after the execution.
1416#[ allow( unused) ]
1517pub ( crate ) struct SyscallResponse {
1618 /// The amount of gas left after the syscall execution.
@@ -20,6 +22,7 @@ pub(crate) struct SyscallResponse {
2022}
2123
2224impl SyscallResponse {
25+ /// Converts a response into cairo args for writing in memory.
2326 pub ( crate ) fn to_cairo_compatible_args ( & self ) -> Vec < MaybeRelocatable > {
2427 let mut cairo_args = Vec :: < MaybeRelocatable > :: with_capacity ( 5 ) ;
2528 cairo_args. push ( Felt252 :: from ( self . gas ) . into ( ) ) ;
@@ -64,32 +67,46 @@ impl SyscallResponse {
6467// Response objects
6568// ----------------------
6669
70+ /// Represents the response of get_block_timestamp syscall.
6771#[ derive( Clone , Debug , PartialEq ) ]
6872pub struct GetBlockTimestampResponse {
73+ /// The block timestamp.
6974 pub timestamp : Felt252 ,
7075}
7176
77+ /// Represents the response of deploy syscall.
7278pub struct DeployResponse {
79+ /// Address of the deployed contract.
7380 pub contract_address : Felt252 ,
81+ /// The retdata segment start.
7482 pub retdata_start : Relocatable ,
83+ /// The retdata segment end.
7584 pub retdata_end : Relocatable ,
7685}
7786
87+ /// Represents error data of any syscall response.
7888pub struct FailureReason {
89+ /// The retdata segment start.
7990 pub retdata_start : Relocatable ,
91+ /// The retdata segment end.
8092 pub retdata_end : Relocatable ,
8193 // Syscall specific response fields.
8294 // TODO: this cause circular dependency
8395 //pub(crate) body: Option<ResponseBody>,
8496}
8597
98+ /// Represents the response of call_contract syscall
8699#[ derive( Clone , Debug , PartialEq ) ]
87100pub struct CallContractResponse {
101+ /// The retdata segment start.
88102 pub retdata_start : Relocatable ,
103+ /// The retdata segment end.
89104 pub retdata_end : Relocatable ,
90105}
91106
107+ /// Represents the response of get_block_hash syscall
92108#[ derive( Clone , Debug , PartialEq ) ]
93109pub struct GetBlockHashResponse {
110+ /// The returned hash.
94111 pub block_hash : Felt252 ,
95112}
0 commit comments