miden_objects/block/
block_account_update.rs1use crate::Word;
2use crate::account::AccountId;
3use crate::account::delta::AccountUpdateDetails;
4use crate::utils::{ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable};
5
6#[derive(Debug, Clone, PartialEq, Eq)]
12pub struct BlockAccountUpdate {
13 account_id: AccountId,
15
16 final_state_commitment: Word,
18
19 details: AccountUpdateDetails,
23}
24
25impl BlockAccountUpdate {
26 pub const fn new(
28 account_id: AccountId,
29 final_state_commitment: Word,
30 details: AccountUpdateDetails,
31 ) -> Self {
32 Self {
33 account_id,
34 final_state_commitment,
35 details,
36 }
37 }
38
39 pub fn account_id(&self) -> AccountId {
41 self.account_id
42 }
43
44 pub fn final_state_commitment(&self) -> Word {
46 self.final_state_commitment
47 }
48
49 pub fn details(&self) -> &AccountUpdateDetails {
54 &self.details
55 }
56
57 pub fn is_private(&self) -> bool {
59 self.details.is_private()
60 }
61}
62
63impl Serializable for BlockAccountUpdate {
64 fn write_into<W: ByteWriter>(&self, target: &mut W) {
65 self.account_id.write_into(target);
66 self.final_state_commitment.write_into(target);
67 self.details.write_into(target);
68 }
69}
70
71impl Deserializable for BlockAccountUpdate {
72 fn read_from<R: ByteReader>(source: &mut R) -> Result<Self, DeserializationError> {
73 Ok(Self {
74 account_id: AccountId::read_from(source)?,
75 final_state_commitment: Word::read_from(source)?,
76 details: AccountUpdateDetails::read_from(source)?,
77 })
78 }
79}