Skip to content

Commit

Permalink
feat(network): add state diff part struct identical to protobuf
Browse files Browse the repository at this point in the history
  • Loading branch information
ShahakShama committed May 28, 2024
1 parent 76dec5d commit 4d0b9c0
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions crates/papyrus_protobuf/src/sync.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
use indexmap::IndexMap;
use starknet_api::block::{BlockHash, BlockHeader, BlockNumber, BlockSignature};
use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce};
use starknet_api::hash::StarkFelt;
use starknet_api::state::StorageKey;

#[derive(Debug, PartialEq, Eq, Clone, Copy, Default, Hash)]
pub enum Direction {
Expand Down Expand Up @@ -33,3 +37,27 @@ pub struct SignedBlockHeader {
pub block_header: BlockHeader,
pub signatures: Vec<BlockSignature>,
}

// TODO(shahak): Implement conversion to/from Vec<u8>.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct StateDiffsResponse(pub Option<StateDiffChunk>);

// TODO(shahak): Implement conversion to/from protobuf.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum StateDiffChunk {
ContractDiff {
contract_address: ContractAddress,
// Has value only if the contract was deployed or replaced in this block.
class_hash: Option<ClassHash>,
// Has value only if the nonce was updated in this block.
nonce: Option<Nonce>,
storage_diffs: IndexMap<StorageKey, StarkFelt>,
},
DeclaredClass {
class_hash: ClassHash,
compiled_class_hash: CompiledClassHash,
},
DeprecatedDeclaredClass {
class_hash: ClassHash,
},
}

0 comments on commit 4d0b9c0

Please sign in to comment.