Skip to content

Commit

Permalink
feat: implement Serializable and Deserializable on Account
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbinth committed Dec 19, 2023
1 parent a365f31 commit 40d1d0c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions objects/src/accounts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,28 @@ impl ToAdviceInputs for Account {
// SERIALIZATION
// ================================================================================================

impl Serializable for Account {
fn write_into<W: ByteWriter>(&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<R: ByteReader>(source: &mut R) -> Result<Self, DeserializationError> {
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;
Expand Down

0 comments on commit 40d1d0c

Please sign in to comment.