Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add starknet version to header #175

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "starknet_api"
version = "0.7.0-dev.1"
version = "0.7.0-rc.0"
edition = "2021"
repository = "https://github.com/starkware-libs/starknet-api"
license = "Apache-2.0"
Expand Down
20 changes: 19 additions & 1 deletion src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#[path = "block_test.rs"]
mod block_test;

use std::fmt::Display;

use derive_more::Display;
use serde::{Deserialize, Serialize};

Expand All @@ -22,6 +24,22 @@ pub struct Block {
pub body: BlockBody,
}

/// A version of the Starknet protocol used when creating a block.
#[derive(Clone, Debug, Eq, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord)]
pub struct StarknetVersion(pub String);

impl Default for StarknetVersion {
fn default() -> Self {
Self("0.0.0".to_string())
}
}

impl Display for StarknetVersion {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}

/// The header of a [Block](`crate::block::Block`).
#[derive(Debug, Default, Clone, Eq, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord)]
pub struct BlockHeader {
Expand All @@ -41,7 +59,7 @@ pub struct BlockHeader {
pub n_transactions: usize,
pub n_events: usize,
// TODO: add missing state diff commitment.
// TODO: add protocol version (starknet version).
pub starknet_version: StarknetVersion,
}

/// The [transactions](`crate::transaction::Transaction`) and their
Expand Down
Loading