Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit 47bb93e

Browse files
xqftmatias-gonz
andauthored
Add syscall_reponse docs (#827)
* Add syscall_reponse docs * Typo * Update syscall_response docs --------- Co-authored-by: Matías Ignacio González <[email protected]>
1 parent ab70113 commit 47bb93e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/syscalls/syscall_response.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use cairo_vm::felt::Felt252;
22
use cairo_vm::types::relocatable::{MaybeRelocatable, Relocatable};
33

4+
/// Abstracts every response variant body for each syscall.
45
pub(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)]
1517
pub(crate) struct SyscallResponse {
1618
/// The amount of gas left after the syscall execution.
@@ -20,6 +22,7 @@ pub(crate) struct SyscallResponse {
2022
}
2123

2224
impl 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)]
6872
pub struct GetBlockTimestampResponse {
73+
/// The block timestamp.
6974
pub timestamp: Felt252,
7075
}
7176

77+
/// Represents the response of deploy syscall.
7278
pub 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.
7888
pub 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)]
87100
pub 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)]
93109
pub struct GetBlockHashResponse {
110+
/// The returned hash.
94111
pub block_hash: Felt252,
95112
}

0 commit comments

Comments
 (0)