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