From 7ba569ccd25d4be9e7e06758e7ab183b2ae0cfb7 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Mon, 4 Mar 2024 17:36:48 +0400 Subject: [PATCH] some docs --- crates/forge/bin/cmd/script/states.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/crates/forge/bin/cmd/script/states.rs b/crates/forge/bin/cmd/script/states.rs index c32b5f5c058e0..d2a7e8fc9327a 100644 --- a/crates/forge/bin/cmd/script/states.rs +++ b/crates/forge/bin/cmd/script/states.rs @@ -10,12 +10,14 @@ use super::{ ScriptArgs, ScriptConfig, ScriptResult, }; +/// First state basically containing only inputs of the user. pub struct PreprocessedState { pub args: ScriptArgs, pub script_config: ScriptConfig, pub script_wallets: ScriptWallets, } +/// State after we have determined and compiled target contract to be executed. pub struct CompiledState { pub args: ScriptArgs, pub script_config: ScriptConfig, @@ -23,6 +25,8 @@ pub struct CompiledState { pub build_data: BuildData, } +/// State after linking, contains the linked build data along with library addresses and optional +/// array of libraries that need to be predeployed. pub struct LinkedState { pub args: ScriptArgs, pub script_config: ScriptConfig, @@ -30,6 +34,7 @@ pub struct LinkedState { pub build_data: LinkedBuildData, } +/// Same as [LinkedState], but also contains [ExecutionData]. pub struct PreExecutionState { pub args: ScriptArgs, pub script_config: ScriptConfig, @@ -38,6 +43,7 @@ pub struct PreExecutionState { pub execution_data: ExecutionData, } +/// State after the script has been executed. pub struct ExecutedState { pub args: ScriptArgs, pub script_config: ScriptConfig, @@ -47,6 +53,11 @@ pub struct ExecutedState { pub execution_result: ScriptResult, } +/// Same as [ExecutedState], but also contains [ExecutionArtifacts] which are obtained from +/// [ScriptResult]. +/// +/// Can be either converted directly to [BundledState] via [PreSimulationState::resume] or driven to +/// it through [FilledTransactionsState]. pub struct PreSimulationState { pub args: ScriptArgs, pub script_config: ScriptConfig, @@ -57,6 +68,9 @@ pub struct PreSimulationState { pub execution_artifacts: ExecutionArtifacts, } +/// At this point we have converted transactions collected during script execution to +/// [TransactionWithMetadata] objects which contain additional metadata needed for broadcasting and +/// verification. pub struct FilledTransactionsState { pub args: ScriptArgs, pub script_config: ScriptConfig, @@ -67,6 +81,8 @@ pub struct FilledTransactionsState { pub transactions: VecDeque, } +/// State after we have bundled all [TransactionWithMetadata] objects into a single +/// [ScriptSequenceKind] object containing one or more script sequences. pub struct BundledState { pub args: ScriptArgs, pub script_config: ScriptConfig, @@ -77,6 +93,9 @@ pub struct BundledState { pub sequence: ScriptSequenceKind, } +/// State after we have broadcasted the script. +/// It is assumed that at this point [BroadcastedState::sequence] contains receipts for all +/// broadcasted transactions. pub struct BroadcastedState { pub args: ScriptArgs, pub script_config: ScriptConfig,