miden_objects/decoded/account/
storage.rs1pub use proto::account::DecodedStorageSlotId as StorageSlotId;
2
3use crate::decoded::VerificationError;
4use crate::{Verify, proto};
5
6#[cfg(test)]
7mod tests;
8
9impl Verify for StorageSlotId {
10 type Verified = miden_protocol::account::StorageSlotId;
11 type Error = core::convert::Infallible;
12 fn verify(self) -> Result<Self::Verified, Self::Error> {
13 Ok(Self::Verified::new(self.suffix, self.prefix))
14 }
15}
16
17pub use proto::account::DecodedStorageMapEntry as StorageMapEntry;
18
19impl Verify for StorageMapEntry {
20 type Verified = (miden_protocol::account::StorageMapKey, miden_protocol::Word);
21 type Error = core::convert::Infallible;
22 fn verify(self) -> Result<Self::Verified, Self::Error> {
23 Ok((miden_protocol::account::StorageMapKey::from_raw(self.key), self.value))
24 }
25}
26
27pub use proto::account::account_storage_header::DecodedStorageSlot as AccountStorageHeaderStorageSlot;
28
29impl Verify for AccountStorageHeaderStorageSlot {
30 type Verified = miden_protocol::account::StorageSlotHeader;
31 type Error = miden_protocol::errors::StorageSlotNameError;
32 fn verify(self) -> Result<Self::Verified, Self::Error> {
33 use miden_protocol::account::StorageSlotType;
34 use proto::account::account_storage_header::storage_slot::DecodedContent;
35
36 let name = miden_protocol::account::StorageSlotName::new(self.slot_name)?;
37 let (slot_type, value) = match self.content {
38 DecodedContent::Value(value) => (StorageSlotType::Value, value),
39 DecodedContent::MapRoot(root) => (StorageSlotType::Map, root),
40 };
41 Ok(Self::Verified::new(name, slot_type, value))
42 }
43}
44
45pub use proto::account::DecodedAccountStorageHeader as AccountStorageHeader;
46
47impl Verify for AccountStorageHeader {
48 type Verified = miden_protocol::account::AccountStorageHeader;
49 type Error = VerificationError;
50 fn verify(self) -> Result<Self::Verified, Self::Error> {
51 let slots = self.slots.into_iter().map(Verify::verify).collect::<Result<_, _>>()?;
52 Ok(Self::Verified::new(slots)?)
53 }
54}