Skip to content
This repository was 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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/transaction/l1_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use num_traits::Zero;

#[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 @@ -38,6 +39,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 @@ -66,7 +68,12 @@ impl L1Handler {
hash_value,
)
}

/// Creates a new [L1Handler] instance with a specified transaction hash.
///
/// # Safety
///
/// `tx_hash` will be assumed to be the same as would result from calling
/// `calculate_transaction_hash_common`. Non-compliance will result in silent misbehavior.
pub fn new_with_tx_hash(
contract_address: Address,
entry_point_selector: Felt252,
Expand Down Expand Up @@ -191,6 +198,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 @@ -234,6 +243,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 @@ -293,6 +303,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