miden_objects/block/
block_account_update.rs1use alloc::vec::Vec;
2
3use crate::{
4 Digest,
5 account::{AccountId, delta::AccountUpdateDetails},
6 transaction::TransactionId,
7 utils::{ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable},
8};
9
10#[derive(Debug, Clone, PartialEq, Eq)]
16pub struct BlockAccountUpdate {
17 account_id: AccountId,
19
20 final_state_commitment: Digest,
22
23 details: AccountUpdateDetails,
27
28 transactions: Vec<TransactionId>,
30}
31
32impl BlockAccountUpdate {
33 pub const fn new(
35 account_id: AccountId,
36 final_state_commitment: Digest,
37 details: AccountUpdateDetails,
38 transactions: Vec<TransactionId>,
39 ) -> Self {
40 Self {
41 account_id,
42 final_state_commitment,
43 details,
44 transactions,
45 }
46 }
47
48 pub fn account_id(&self) -> AccountId {
50 self.account_id
51 }
52
53 pub fn final_state_commitment(&self) -> Digest {
55 self.final_state_commitment
56 }
57
58 pub fn details(&self) -> &AccountUpdateDetails {
63 &self.details
64 }
65
66 pub fn transactions(&self) -> &[TransactionId] {
68 &self.transactions
69 }
70
71 pub fn is_private(&self) -> bool {
73 self.details.is_private()
74 }
75}
76
77impl Serializable for BlockAccountUpdate {
78 fn write_into<W: ByteWriter>(&self, target: &mut W) {
79 self.account_id.write_into(target);
80 self.final_state_commitment.write_into(target);
81 self.details.write_into(target);
82 self.transactions.write_into(target);
83 }
84}
85
86impl Deserializable for BlockAccountUpdate {
87 fn read_from<R: ByteReader>(source: &mut R) -> Result<Self, DeserializationError> {
88 Ok(Self {
89 account_id: AccountId::read_from(source)?,
90 final_state_commitment: Digest::read_from(source)?,
91 details: AccountUpdateDetails::read_from(source)?,
92 transactions: Vec::<TransactionId>::read_from(source)?,
93 })
94 }
95}