miden_protocol/block/
block_account_update.rs1use crate::Word;
2use crate::account::{AccountId, AccountUpdateDetails};
3use crate::utils::serde::{
4 ByteReader,
5 ByteWriter,
6 Deserializable,
7 DeserializationError,
8 Serializable,
9};
10
11#[derive(Debug, Clone, PartialEq, Eq)]
17pub struct BlockAccountUpdate {
18 account_id: AccountId,
20
21 final_state_commitment: Word,
23
24 details: AccountUpdateDetails,
28}
29
30impl BlockAccountUpdate {
31 pub const fn new(
33 account_id: AccountId,
34 final_state_commitment: Word,
35 details: AccountUpdateDetails,
36 ) -> Self {
37 Self {
38 account_id,
39 final_state_commitment,
40 details,
41 }
42 }
43
44 pub fn account_id(&self) -> AccountId {
46 self.account_id
47 }
48
49 pub fn final_state_commitment(&self) -> Word {
51 self.final_state_commitment
52 }
53
54 pub fn details(&self) -> &AccountUpdateDetails {
58 &self.details
59 }
60
61 pub fn is_private(&self) -> bool {
63 self.details.is_private()
64 }
65}
66
67impl Serializable for BlockAccountUpdate {
68 fn write_into<W: ByteWriter>(&self, target: &mut W) {
69 self.account_id.write_into(target);
70 self.final_state_commitment.write_into(target);
71 self.details.write_into(target);
72 }
73}
74
75impl Deserializable for BlockAccountUpdate {
76 fn read_from<R: ByteReader>(source: &mut R) -> Result<Self, DeserializationError> {
77 Ok(Self {
78 account_id: AccountId::read_from(source)?,
79 final_state_commitment: Word::read_from(source)?,
80 details: AccountUpdateDetails::read_from(source)?,
81 })
82 }
83}