fc_rpc_core/types/account_info.rs
1// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
2// This file is part of Frontier.
3//
4// Copyright (c) 2015-2020 Parity Technologies (UK) Ltd.
5//
6// This program is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with this program. If not, see <https://www.gnu.org/licenses/>.
18
19//! Return types for RPC calls
20
21use serde::Serialize;
22use ethereum_types::{Public, Address, H160, H256, U256};
23use crate::types::Bytes;
24
25/// Account information.
26#[derive(Debug, Default, Clone, PartialEq, Serialize)]
27pub struct AccountInfo {
28 /// Account name
29 pub name: String,
30}
31
32/// Data structure with proof for one single storage-entry
33#[derive(Debug, Default, Clone, PartialEq, Serialize)]
34#[serde(rename_all = "camelCase")]
35pub struct StorageProof {
36 pub key: U256,
37 pub value: U256,
38 pub proof: Vec<Bytes>
39}
40
41/// Account information.
42#[derive(Debug, Default, Clone, PartialEq, Serialize)]
43#[serde(rename_all = "camelCase")]
44pub struct EthAccount {
45 pub address: H160,
46 pub balance: U256,
47 pub nonce: U256,
48 pub code_hash: H256,
49 pub storage_hash: H256,
50 pub account_proof: Vec<Bytes>,
51 pub storage_proof: Vec<StorageProof>,
52}
53
54/// Extended account information (used by `parity_allAccountInfo`).
55#[derive(Debug, Default, Clone, PartialEq, Serialize)]
56pub struct ExtAccountInfo {
57 /// Account name
58 pub name: String,
59 /// Account meta JSON
60 pub meta: String,
61 /// Account UUID (`None` for address book entries)
62 #[serde(skip_serializing_if = "Option::is_none")]
63 pub uuid: Option<String>,
64}
65
66/// account derived from a signature
67/// as well as information that tells if it is valid for
68/// the current chain
69#[derive(Debug, Clone, Serialize)]
70#[serde(rename_all="camelCase")]
71pub struct RecoveredAccount {
72 /// address of the recovered account
73 pub address: Address,
74 /// public key of the recovered account
75 pub public_key: Public,
76 /// If the signature contains chain replay protection,
77 /// And the chain_id encoded within the signature
78 /// matches the current chain this would be true, otherwise false.
79 pub is_valid_for_current_chain: bool
80}