vapjson/
state.rs

1// Copyright 2015-2020 Parity Technologies (UK) Ltd.
2// This file is part of Tetsy Vapory.
3
4// Tetsy Vapory is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// Tetsy Vapory is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with Tetsy Vapory.  If not, see <http://www.gnu.org/licenses/>.
16
17//! State deserialization types
18
19use crate::{
20	bytes::Bytes,
21	hash::{Address, H256, Bloom},
22};
23use serde::Deserialize;
24
25/// State log deserialization.
26#[derive(Debug, PartialEq, Deserialize)]
27pub struct Log {
28	/// Address.
29	pub address: Address,
30	/// Topics.
31	pub topics: Vec<H256>,
32	/// Data.
33	pub data: Bytes,
34	/// Bloom.
35	pub bloom: Bloom,
36}
37
38#[cfg(test)]
39mod tests {
40	use super::Log;
41
42	#[test]
43	fn log_deserialization() {
44		let s = r#"{
45			"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
46			"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008800000000000000000020000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000",
47			"data" : "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
48			"topics" : [
49				"0000000000000000000000000000000000000000000000000000000000000000"
50			]
51		}"#;
52		let _deserialized: Log = serde_json::from_str(s).unwrap();
53		// TODO: validate all fields
54	}
55}