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

Add comments to origin/Document-transactionl1_handler module #888

Merged
merged 12 commits into from
Oct 5, 2023
9 changes: 8 additions & 1 deletion src/transaction/l1_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use super::Transaction;

#[allow(dead_code)]
#[derive(Debug, Getters, Clone)]
/// Represents an L1Handler transaction in the StarkNet network.
pub struct L1Handler {
#[getset(get = "pub")]
hash_value: Felt252,
Expand All @@ -43,6 +44,7 @@ pub struct L1Handler {
}

impl L1Handler {
/// Constructor creates a new [L1Handler] instance.
pub fn new(
contract_address: Address,
entry_point_selector: Felt252,
Expand Down Expand Up @@ -71,7 +73,7 @@ impl L1Handler {
hash_value,
)
}

/// Creates a new [L1Handler] instance with a specified transaction hash.
fguthmann marked this conversation as resolved.
Show resolved Hide resolved
pub fn new_with_tx_hash(
contract_address: Address,
entry_point_selector: Felt252,
Expand Down Expand Up @@ -189,6 +191,8 @@ impl L1Handler {
L1_HANDLER_VERSION.into(),
))
}

/// Creates a L1Handler for simulation purposes.
pub(crate) fn create_for_simulation(
&self,
skip_validate: bool,
Expand Down Expand Up @@ -230,6 +234,7 @@ mod test {
utils::Address,
};

/// Test the correct execution of the L1Handler.
#[test]
fn test_execute_l1_handler() {
let l1_handler = L1Handler::new(
Expand Down Expand Up @@ -286,6 +291,8 @@ mod test {
assert_eq!(tx_exec, expected_tx_exec)
}

/// Helper function to construct the expected transaction execution info.
/// Expected output of the L1Handler's execution.
fn expected_tx_exec_info() -> TransactionExecutionInfo {
TransactionExecutionInfo {
validate_info: None,
Expand Down