Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement CompiledTransaction #47

Merged
merged 1 commit into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions objects/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ pub mod notes;
mod errors;
pub use errors::{AccountError, AssetError, NoteError};

mod transaction;
pub use transaction::ProvenTransaction;
pub mod transaction;
57 changes: 57 additions & 0 deletions objects/src/transaction/compiled_tx.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
use super::{AccountId, Digest, Note, Vec};
use miden_core::Program;

/// Resultant object of compiling a set of note scripts in the context of an account.
/// The CompiledTransaction does not contain any account data, it is passed to a component
/// that will do the required data lookups before processing the transaction further.
/// Contains:
/// - account_id: the account that the transaction was executed against.
/// - consumed_notes: a list of consumed notes.
/// - tx_script_root: optional MAST root for the transaction script.
/// - tx_program: an executable program describing the transaction.
pub struct CompiledTransaction {
account_id: AccountId,
consumed_notes: Vec<Note>,
tx_script_root: Option<Digest>,
tx_program: Program,
}

impl CompiledTransaction {
/// Creates a new CompiledTransaction object.
pub fn new(
account_id: AccountId,
consumed_notes: Vec<Note>,
tx_script_root: Option<Digest>,
tx_program: Program,
) -> Self {
Self {
account_id,
consumed_notes,
tx_script_root,
tx_program,
}
}

// ACCESSORS
// --------------------------------------------------------------------------------------------

/// Returns the account id.
pub fn account_id(&self) -> AccountId {
self.account_id
}

/// Returns the consumed notes.
pub fn consumed_notes(&self) -> &[Note] {
&self.consumed_notes
}

/// Returns the transaction script root.
pub fn tx_script_root(&self) -> Option<Digest> {
self.tx_script_root
}

/// Returns the transaction program.
pub fn tx_program(&self) -> &Program {
&self.tx_program
}
}
4 changes: 3 additions & 1 deletion objects/src/transaction/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use super::{AccountId, Digest, Felt, Hasher, StarkField, Vec, Word};
use super::{notes::Note, AccountId, Digest, Felt, Hasher, StarkField, Vec, Word};

mod compiled_tx;
mod consumed_note;
mod created_note;
mod proven_tx;

pub use compiled_tx::CompiledTransaction;
pub use consumed_note::ConsumedNoteInfo;
pub use created_note::CreatedNoteInfo;
pub use proven_tx::ProvenTransaction;