Struct miden_tx::TransactionCompiler
source · pub struct TransactionCompiler { /* private fields */ }Expand description
The transaction compiler is responsible for building executable programs for Miden rollup transactions.
The generated programs can then be executed on the Miden VM to update the states of accounts involved in these transactions.
In addition to transaction compilation, transaction compiler provides methods which can be used to compile Miden account code and note scripts.
Implementations§
source§impl TransactionCompiler
impl TransactionCompiler
sourcepub fn new() -> TransactionCompiler
pub fn new() -> TransactionCompiler
Returns a new TransactionCompiler.
sourcepub fn with_debug_mode(self, in_debug_mode: bool) -> Self
pub fn with_debug_mode(self, in_debug_mode: bool) -> Self
Puts the TransactionCompiler into debug mode.
When transaction compiler is in debug mode, all transaction-related code (note scripts, account code) will be compiled in debug mode which will preserve debug artifacts from the original source code.
sourcepub fn load_account(
&mut self,
account_id: AccountId,
account_code: ModuleAst,
) -> Result<AccountCode, TransactionCompilerError>
pub fn load_account( &mut self, account_id: AccountId, account_code: ModuleAst, ) -> Result<AccountCode, TransactionCompilerError>
Compiles the provided module into AccountCode and associates the resulting procedures with the specified account ID.
sourcepub fn load_account_interface(
&mut self,
account_id: AccountId,
procedures: Vec<Digest>,
) -> Option<Vec<Digest>>
pub fn load_account_interface( &mut self, account_id: AccountId, procedures: Vec<Digest>, ) -> Option<Vec<Digest>>
Loads the provided account interface (vector of procedure digests) into this compiler. Returns the old account interface if it previously existed.
sourcepub fn compile_note_script(
&self,
note_script_ast: ProgramAst,
target_account_proc: Vec<ScriptTarget>,
) -> Result<NoteScript, TransactionCompilerError>
pub fn compile_note_script( &self, note_script_ast: ProgramAst, target_account_proc: Vec<ScriptTarget>, ) -> Result<NoteScript, TransactionCompilerError>
Compiles the provided program into the NoteScript and checks (to the extent possible) if a note could be executed against all accounts with the specified interfaces.
sourcepub fn compile_tx_script<T>(
&self,
tx_script_ast: ProgramAst,
tx_script_inputs: T,
target_account_proc: Vec<ScriptTarget>,
) -> Result<TransactionScript, TransactionCompilerError>
pub fn compile_tx_script<T>( &self, tx_script_ast: ProgramAst, tx_script_inputs: T, target_account_proc: Vec<ScriptTarget>, ) -> Result<TransactionScript, TransactionCompilerError>
Constructs a TransactionScript by compiling the provided source code and checking the compatibility of the resulting program with the target account interfaces.
sourcepub fn compile_transaction(
&self,
account_id: AccountId,
notes: &InputNotes<InputNote>,
tx_script: Option<&ProgramAst>,
) -> Result<Program, TransactionCompilerError>
pub fn compile_transaction( &self, account_id: AccountId, notes: &InputNotes<InputNote>, tx_script: Option<&ProgramAst>, ) -> Result<Program, TransactionCompilerError>
Compiles a transaction which executes the provided notes and an optional tx script against the specified account. Returns the compiled transaction program.
The account is assumed to have been previously loaded into this compiler.