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

Commit 35538bc

Browse files
authored
Deploy Doc (#804)
1 parent 39585de commit 35538bc

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/transaction/deploy.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use num_traits::Zero;
3030

3131
use super::Transaction;
3232

33+
/// Represents a Deploy Transaction in the starknet network
3334
#[derive(Debug, Clone)]
3435
pub struct Deploy {
3536
pub hash_value: Felt252,
@@ -116,6 +117,7 @@ impl Deploy {
116117
})
117118
}
118119

120+
/// Returns the class hash of the deployed contract
119121
pub fn class_hash(&self) -> ClassHash {
120122
self.contract_hash
121123
}
@@ -133,7 +135,10 @@ impl Deploy {
133135
CompiledClass::Casm(class) => Ok(class.entry_points_by_type.constructor.is_empty()),
134136
}
135137
}
136-
138+
/// Deploys the contract in the starknet network and calls its constructor if it has one.
139+
/// ## Parameters
140+
/// - state: A state that implements the [`State`] and [`StateReader`] traits.
141+
/// - block_context: The block's execution context.
137142
pub fn apply<S: State + StateReader>(
138143
&self,
139144
state: &mut S,
@@ -150,6 +155,9 @@ impl Deploy {
150155
self.invoke_constructor(state, block_context)
151156
}
152157
}
158+
/// Executes the contract without constructor
159+
/// ## Parameters
160+
/// - state: A state that implements the [`State`] and [`StateReader`] traits.
153161
154162
pub fn handle_empty_constructor<S: State + StateReader>(
155163
&self,
@@ -185,6 +193,10 @@ impl Deploy {
185193
))
186194
}
187195

196+
/// Execute the contract using its constructor
197+
/// ## Parameters
198+
/// - state: A state that implements the [`State`] and [`StateReader`] traits.
199+
/// - block_context: The block's execution context.
188200
pub fn invoke_constructor<S: State + StateReader>(
189201
&self,
190202
state: &mut S,
@@ -239,6 +251,9 @@ impl Deploy {
239251

240252
/// Calculates actual fee used by the transaction using the execution
241253
/// info returned by apply(), then updates the transaction execution info with the data of the fee.
254+
/// ## Parameters
255+
/// - state: A state that implements the [`State`] and [`StateReader`] traits.
256+
/// - block_context: The block's execution context.
242257
pub fn execute<S: State + StateReader>(
243258
&self,
244259
state: &mut S,
@@ -254,6 +269,8 @@ impl Deploy {
254269
// ---------------
255270
// Simulation
256271
// ---------------
272+
273+
/// Creates a Deploy transaction for simulate a deploy
257274
pub(crate) fn create_for_simulation(
258275
&self,
259276
skip_validate: bool,

0 commit comments

Comments
 (0)