From 40d1d0ca305cd6f8f4f37f582b04bc429943543b Mon Sep 17 00:00:00 2001 From: Bobbin Threadbare Date: Tue, 19 Dec 2023 10:16:28 -0800 Subject: [PATCH] feat: implement Serializable and Deserializable on Account --- objects/src/accounts/mod.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/objects/src/accounts/mod.rs b/objects/src/accounts/mod.rs index acf9139ec..92de60f33 100644 --- a/objects/src/accounts/mod.rs +++ b/objects/src/accounts/mod.rs @@ -232,6 +232,28 @@ impl ToAdviceInputs for Account { // SERIALIZATION // ================================================================================================ +impl Serializable for Account { + fn write_into(&self, target: &mut W) { + self.id.write_into(target); + self.vault.write_into(target); + self.storage.write_into(target); + self.code.write_into(target); + self.nonce.write_into(target); + } +} + +impl Deserializable for Account { + fn read_from(source: &mut R) -> Result { + let id = AccountId::read_from(source)?; + let vault = AccountVault::read_from(source)?; + let storage = AccountStorage::read_from(source)?; + let code = AccountCode::read_from(source)?; + let nonce = Felt::read_from(source)?; + + Ok(Self::new(id, vault, storage, code, nonce)) + } +} + #[cfg(feature = "serde")] mod vault_serialization { use super::AccountVault;