Skip to content

Commit

Permalink
feat: introduce TransactionResult
Browse files Browse the repository at this point in the history
  • Loading branch information
frisitano committed Jul 26, 2023
1 parent 69dcd95 commit 9073a4b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion miden-tx/src/executor/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::{
AccountCode, AccountId, DataStore, Digest, NoteOrigin, NoteScript, NoteTarget,
AccountCode, AccountId, DataStore, Digest, ModuleAst, NoteOrigin, NoteScript, NoteTarget,
PreparedTransaction, ProgramAst, RecAdviceProvider, TransactionComplier,
TransactionExecutorError, TransactionResult,
};
Expand Down
1 change: 1 addition & 0 deletions miden-tx/src/prover/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 1 addition & 1 deletion objects/src/accounts/account_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub enum AccountType {
/// - 0 - full account data is stored on-chain.
/// - 1 - only the account hash is stored on-chain which serves as a commitment to the account state.
/// As such the three most significant bits fully describes the type of the account.
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
#[derive(Debug, Default, Copy, Clone, Eq, PartialEq)]
pub struct AccountId(Felt);

impl AccountId {
Expand Down
22 changes: 20 additions & 2 deletions objects/src/accounts/code.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::{
AccountError, AccountId, Assembler, AssemblyContext, AssemblyContextType, Digest, LibraryPath,
Module, ModuleAst, Vec,
Module, ModuleAst, TryApplyDiff, Vec,
};
use crypto::merkle::SimpleSmt;
use crypto::merkle::{SimpleSmt, StoreNode};

// ACCOUNT CODE
// ================================================================================================
Expand Down Expand Up @@ -118,3 +118,21 @@ impl AccountCode {
self.procedures.binary_search_by(|x| x.as_bytes().cmp(&root_bytes)).ok()
}
}

// DIFF
// ================================================================================================
impl TryApplyDiff<Digest, StoreNode> for AccountCode {
type DiffType = Option<ModuleAst>;
type Error = AccountError;

fn try_apply(&mut self, diff: Option<ModuleAst>) -> Result<(), Self::Error> {
if let Some(module) = diff {
// TODO: Consider introducing a TryApplyDiff variant that returns Result<(), Error>
let code = AccountCode::new(AccountId::default(), module, &Assembler::default())?;
self.module = code.module;
self.procedures = code.procedures;
self.procedure_tree = code.procedure_tree;
}
Ok(())
}
}

0 comments on commit 9073a4b

Please sign in to comment.