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

Commit

Permalink
Add documentation to transaction/mod module (#761)
Browse files Browse the repository at this point in the history
* Add documentation to transaction/mod module

* Fix typo

* Delete white space

* Add markdown parameter

* Fix typos

* Fix typo

* Fix comments

* Apply suggestion

Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 5, 2023
1 parent 384f459 commit 29b828f
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ use crate::{
};
use error::TransactionError;

/// Represents a transaction inside the starknet network.
/// The transaction are actions that may modified the state of the network.
/// it can be one of:
/// - Declare
/// - DeclareV2
/// - Deploy
/// - DeployAccount
/// - InvokeFunction
/// - L1Handler
pub enum Transaction {
/// A declare transaction.
Declare(Declare),
Expand All @@ -38,6 +47,7 @@ pub enum Transaction {
}

impl Transaction {
/// returns the contract address of the transaction.
pub fn contract_address(&self) -> Address {
match self {
Transaction::Deploy(tx) => tx.contract_address.clone(),
Expand All @@ -49,6 +59,11 @@ impl Transaction {
}
}

/// execute the transaction in cairo-vm and returns a TransactionExecutionInfo structure.
///## Parameters:
///- state: a structure that implements State and StateReader traits.
///- block_context: The block context of the transaction that is about to be executed.
///- remaining_gas: The gas supplied to execute the transaction.
pub fn execute<S: State + StateReader>(
&self,
state: &mut S,
Expand All @@ -64,7 +79,11 @@ impl Transaction {
Transaction::L1Handler(tx) => tx.execute(state, block_context, remaining_gas),
}
}

/// It creates a new transaction structure modificating the skip flags. It is meant to be used only to run a simulation
///## Parameters:
///- skip_validate: the transaction will not be verified.
///- skip_execute: the transaction will not be executed in the cairo vm.
///- skip_fee_transfer: the transaction will not pay the fee.
pub fn create_for_simulation(
&self,
skip_validate: bool,
Expand Down

0 comments on commit 29b828f

Please sign in to comment.