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