From 0ceebe662598a9b505c8024e2a9f056596b1a978 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= <tomusdrw@users.noreply.github.com>
Date: Mon, 13 Nov 2017 20:51:30 +0100
Subject: [PATCH] camel case and deny (#20)

---
 substrate/primitives/src/block.rs     | 7 ++++---
 substrate/primitives/src/parachain.rs | 3 ++-
 substrate/primitives/src/validator.rs | 4 ++--
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/substrate/primitives/src/block.rs b/substrate/primitives/src/block.rs
index 41d684f70dd..41844b5d732 100644
--- a/substrate/primitives/src/block.rs
+++ b/substrate/primitives/src/block.rs
@@ -24,12 +24,12 @@ pub type HeaderHash = H256;
 
 /// A relay chain block header.
 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+#[serde(deny_unknown_fields)]
 pub struct Header {
 	/// Block parent's hash.
-	#[serde(rename="parentHash")]
 	pub parent_hash: HeaderHash,
 	/// State root after this transition.
-	#[serde(rename="stateRoot")]
 	pub state_root: H256,
 	/// Unix time at which this header was produced.
 	pub timestamp: u64,
@@ -42,9 +42,10 @@ pub struct Header {
 /// Included candidates should be sorted by parachain ID, and without duplicate
 /// IDs.
 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+#[serde(deny_unknown_fields)]
 pub struct Body {
 	/// Parachain proposal blocks.
-	#[serde(rename="paraBlocks")]
 	pub para_blocks: Vec<parachain::Proposal>,
 }
 
diff --git a/substrate/primitives/src/parachain.rs b/substrate/primitives/src/parachain.rs
index 567225acfee..5d80ffcf1f7 100644
--- a/substrate/primitives/src/parachain.rs
+++ b/substrate/primitives/src/parachain.rs
@@ -32,13 +32,14 @@ impl From<u64> for Id {
 
 /// A parachain block proposal.
 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+#[serde(deny_unknown_fields)]
 pub struct Proposal {
 	/// The ID of the parachain this is a proposal for.
 	pub parachain: Id,
 	/// Parachain block header bytes.
 	pub header: Header,
 	/// Hash of data necessary to prove validity of the header.
-	#[serde(rename="proofHash")]
 	pub proof_hash: ProofHash,
 }
 
diff --git a/substrate/primitives/src/validator.rs b/substrate/primitives/src/validator.rs
index 3ae18fe2709..afdff7e20f3 100644
--- a/substrate/primitives/src/validator.rs
+++ b/substrate/primitives/src/validator.rs
@@ -33,11 +33,11 @@ pub struct EgressPosts(#[serde(with="bytes")] pub Vec<u8>);
 /// Validity result of particular proof and ingress queue.
 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
 #[serde(tag="type", content="data")]
+#[serde(rename_all = "camelCase")]
+#[serde(deny_unknown_fields)]
 pub enum ProofValidity {
 	/// The proof is invalid.
-	#[serde(rename="invalid")]
 	Invalid,
-	#[serde(rename="valid")]
 	/// The proof is processed and new egress queue is created.
 	/// Also includes current ingress queue delta.
 	Valid(IngressPostsDelta, EgressPosts),
-- 
GitLab