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

Commit 29b828f

Browse files
mmsc2juanbonoSantiagoPittella
authored
Add documentation to transaction/mod module (#761)
* 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 <[email protected]> * Apply suggestions from code review Co-authored-by: Santiago Pittella <[email protected]> --------- Co-authored-by: Juan Bono <[email protected]> Co-authored-by: Santiago Pittella <[email protected]>
1 parent 384f459 commit 29b828f

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/transaction/mod.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ use crate::{
2222
};
2323
use error::TransactionError;
2424

25+
/// Represents a transaction inside the starknet network.
26+
/// The transaction are actions that may modified the state of the network.
27+
/// it can be one of:
28+
/// - Declare
29+
/// - DeclareV2
30+
/// - Deploy
31+
/// - DeployAccount
32+
/// - InvokeFunction
33+
/// - L1Handler
2534
pub enum Transaction {
2635
/// A declare transaction.
2736
Declare(Declare),
@@ -38,6 +47,7 @@ pub enum Transaction {
3847
}
3948

4049
impl Transaction {
50+
/// returns the contract address of the transaction.
4151
pub fn contract_address(&self) -> Address {
4252
match self {
4353
Transaction::Deploy(tx) => tx.contract_address.clone(),
@@ -49,6 +59,11 @@ impl Transaction {
4959
}
5060
}
5161

62+
/// execute the transaction in cairo-vm and returns a TransactionExecutionInfo structure.
63+
///## Parameters:
64+
///- state: a structure that implements State and StateReader traits.
65+
///- block_context: The block context of the transaction that is about to be executed.
66+
///- remaining_gas: The gas supplied to execute the transaction.
5267
pub fn execute<S: State + StateReader>(
5368
&self,
5469
state: &mut S,
@@ -64,7 +79,11 @@ impl Transaction {
6479
Transaction::L1Handler(tx) => tx.execute(state, block_context, remaining_gas),
6580
}
6681
}
67-
82+
/// It creates a new transaction structure modificating the skip flags. It is meant to be used only to run a simulation
83+
///## Parameters:
84+
///- skip_validate: the transaction will not be verified.
85+
///- skip_execute: the transaction will not be executed in the cairo vm.
86+
///- skip_fee_transfer: the transaction will not pay the fee.
6887
pub fn create_for_simulation(
6988
&self,
7089
skip_validate: bool,

0 commit comments

Comments
 (0)