Exposing types from RPC
This commit is contained in:
parent
d0ae713b29
commit
6f93ecf1d2
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -331,7 +331,6 @@ dependencies = [
|
|||||||
"clippy 0.0.69 (registry+https://github.com/rust-lang/crates.io-index)",
|
"clippy 0.0.69 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ethash 1.2.0",
|
"ethash 1.2.0",
|
||||||
"ethcore 1.2.0",
|
"ethcore 1.2.0",
|
||||||
"ethcore-signer 1.2.0",
|
|
||||||
"ethcore-util 1.2.0",
|
"ethcore-util 1.2.0",
|
||||||
"ethminer 1.2.0",
|
"ethminer 1.2.0",
|
||||||
"ethsync 1.2.0",
|
"ethsync 1.2.0",
|
||||||
@ -353,6 +352,7 @@ version = "1.2.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"clippy 0.0.69 (registry+https://github.com/rust-lang/crates.io-index)",
|
"clippy 0.0.69 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"ethcore-rpc 1.2.0",
|
||||||
"ethcore-util 1.2.0",
|
"ethcore-util 1.2.0",
|
||||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -54,7 +54,7 @@ pub fn start(conf: Configuration, deps: Dependencies) -> Option<SignerServer> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "ethcore-signer"))]
|
#[cfg(not(feature = "ethcore-signer"))]
|
||||||
pub fn start(conf: Configuration) -> !{
|
pub fn start(conf: Configuration) -> Option<SignerServer> {
|
||||||
if !conf.enabled {
|
if !conf.enabled {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ ethcore = { path = "../ethcore" }
|
|||||||
ethash = { path = "../ethash" }
|
ethash = { path = "../ethash" }
|
||||||
ethsync = { path = "../sync" }
|
ethsync = { path = "../sync" }
|
||||||
ethminer = { path = "../miner" }
|
ethminer = { path = "../miner" }
|
||||||
ethcore-signer = { path = "../signer" }
|
|
||||||
rustc-serialize = "0.3"
|
rustc-serialize = "0.3"
|
||||||
transient-hashmap = "0.1"
|
transient-hashmap = "0.1"
|
||||||
serde_macros = { version = "0.7.0", optional = true }
|
serde_macros = { version = "0.7.0", optional = true }
|
||||||
|
@ -27,7 +27,6 @@ extern crate serde_json;
|
|||||||
extern crate jsonrpc_core;
|
extern crate jsonrpc_core;
|
||||||
extern crate jsonrpc_http_server;
|
extern crate jsonrpc_http_server;
|
||||||
extern crate ethcore_util as util;
|
extern crate ethcore_util as util;
|
||||||
extern crate ethcore_signer as signer;
|
|
||||||
extern crate ethcore;
|
extern crate ethcore;
|
||||||
extern crate ethsync;
|
extern crate ethsync;
|
||||||
extern crate ethminer;
|
extern crate ethminer;
|
||||||
|
@ -18,12 +18,12 @@
|
|||||||
//!
|
//!
|
||||||
//! Compliant with ethereum rpc.
|
//! Compliant with ethereum rpc.
|
||||||
|
|
||||||
pub mod traits;
|
|
||||||
mod impls;
|
mod impls;
|
||||||
mod types;
|
|
||||||
mod helpers;
|
mod helpers;
|
||||||
|
|
||||||
|
pub mod traits;
|
||||||
pub mod tests;
|
pub mod tests;
|
||||||
|
pub mod types;
|
||||||
|
|
||||||
pub use self::traits::{Web3, Eth, EthFilter, Personal, Net, Ethcore, Traces, Rpc};
|
pub use self::traits::{Web3, Eth, EthFilter, Personal, Net, Ethcore, Traces, Rpc};
|
||||||
pub use self::impls::*;
|
pub use self::impls::*;
|
||||||
|
@ -18,9 +18,12 @@ use serde::{Serialize, Serializer};
|
|||||||
use util::numbers::*;
|
use util::numbers::*;
|
||||||
use v1::types::{Bytes, Transaction, OptionalValue};
|
use v1::types::{Bytes, Transaction, OptionalValue};
|
||||||
|
|
||||||
|
/// Block Transactions
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum BlockTransactions {
|
pub enum BlockTransactions {
|
||||||
|
/// Only hashes
|
||||||
Hashes(Vec<H256>),
|
Hashes(Vec<H256>),
|
||||||
|
/// Full transactions
|
||||||
Full(Vec<Transaction>)
|
Full(Vec<Transaction>)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,38 +37,58 @@ impl Serialize for BlockTransactions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Block representation
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
pub struct Block {
|
pub struct Block {
|
||||||
|
/// Hash of the block
|
||||||
pub hash: OptionalValue<H256>,
|
pub hash: OptionalValue<H256>,
|
||||||
|
/// Hash of the parent
|
||||||
#[serde(rename="parentHash")]
|
#[serde(rename="parentHash")]
|
||||||
pub parent_hash: H256,
|
pub parent_hash: H256,
|
||||||
|
/// Hash of the uncles
|
||||||
#[serde(rename="sha3Uncles")]
|
#[serde(rename="sha3Uncles")]
|
||||||
pub uncles_hash: H256,
|
pub uncles_hash: H256,
|
||||||
|
/// Authors address
|
||||||
pub author: Address,
|
pub author: Address,
|
||||||
// TODO: get rid of this one
|
// TODO: get rid of this one
|
||||||
|
/// ?
|
||||||
pub miner: Address,
|
pub miner: Address,
|
||||||
|
/// State root hash
|
||||||
#[serde(rename="stateRoot")]
|
#[serde(rename="stateRoot")]
|
||||||
pub state_root: H256,
|
pub state_root: H256,
|
||||||
|
/// Transactions root hash
|
||||||
#[serde(rename="transactionsRoot")]
|
#[serde(rename="transactionsRoot")]
|
||||||
pub transactions_root: H256,
|
pub transactions_root: H256,
|
||||||
|
/// Transactions receipts root hash
|
||||||
#[serde(rename="receiptsRoot")]
|
#[serde(rename="receiptsRoot")]
|
||||||
pub receipts_root: H256,
|
pub receipts_root: H256,
|
||||||
|
/// Block number
|
||||||
pub number: OptionalValue<U256>,
|
pub number: OptionalValue<U256>,
|
||||||
|
/// Gas Used
|
||||||
#[serde(rename="gasUsed")]
|
#[serde(rename="gasUsed")]
|
||||||
pub gas_used: U256,
|
pub gas_used: U256,
|
||||||
|
/// Gas Limit
|
||||||
#[serde(rename="gasLimit")]
|
#[serde(rename="gasLimit")]
|
||||||
pub gas_limit: U256,
|
pub gas_limit: U256,
|
||||||
|
/// Extra data
|
||||||
#[serde(rename="extraData")]
|
#[serde(rename="extraData")]
|
||||||
pub extra_data: Bytes,
|
pub extra_data: Bytes,
|
||||||
|
/// Logs bloom
|
||||||
#[serde(rename="logsBloom")]
|
#[serde(rename="logsBloom")]
|
||||||
pub logs_bloom: H2048,
|
pub logs_bloom: H2048,
|
||||||
|
/// Timestamp
|
||||||
pub timestamp: U256,
|
pub timestamp: U256,
|
||||||
|
/// Difficulty
|
||||||
pub difficulty: U256,
|
pub difficulty: U256,
|
||||||
|
/// Total difficulty
|
||||||
#[serde(rename="totalDifficulty")]
|
#[serde(rename="totalDifficulty")]
|
||||||
pub total_difficulty: U256,
|
pub total_difficulty: U256,
|
||||||
|
/// Seal fields
|
||||||
#[serde(rename="sealFields")]
|
#[serde(rename="sealFields")]
|
||||||
pub seal_fields: Vec<Bytes>,
|
pub seal_fields: Vec<Bytes>,
|
||||||
|
/// Uncles' hashes
|
||||||
pub uncles: Vec<H256>,
|
pub uncles: Vec<H256>,
|
||||||
|
/// Transactions
|
||||||
pub transactions: BlockTransactions
|
pub transactions: BlockTransactions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,9 +21,13 @@ use ethcore::client::BlockID;
|
|||||||
/// Represents rpc api block number param.
|
/// Represents rpc api block number param.
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
pub enum BlockNumber {
|
pub enum BlockNumber {
|
||||||
|
/// Number
|
||||||
Num(u64),
|
Num(u64),
|
||||||
|
/// Latest block
|
||||||
Latest,
|
Latest,
|
||||||
|
/// Earliest block (genesis)
|
||||||
Earliest,
|
Earliest,
|
||||||
|
/// Pending block (being mined)
|
||||||
Pending
|
Pending
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,15 +18,23 @@ use util::hash::Address;
|
|||||||
use util::numbers::U256;
|
use util::numbers::U256;
|
||||||
use v1::types::Bytes;
|
use v1::types::Bytes;
|
||||||
|
|
||||||
|
/// Call request
|
||||||
#[derive(Debug, Default, PartialEq, Deserialize)]
|
#[derive(Debug, Default, PartialEq, Deserialize)]
|
||||||
pub struct CallRequest {
|
pub struct CallRequest {
|
||||||
|
/// From
|
||||||
pub from: Option<Address>,
|
pub from: Option<Address>,
|
||||||
|
/// To
|
||||||
pub to: Option<Address>,
|
pub to: Option<Address>,
|
||||||
|
/// Gas Price
|
||||||
#[serde(rename="gasPrice")]
|
#[serde(rename="gasPrice")]
|
||||||
pub gas_price: Option<U256>,
|
pub gas_price: Option<U256>,
|
||||||
|
/// Gas
|
||||||
pub gas: Option<U256>,
|
pub gas: Option<U256>,
|
||||||
|
/// Value
|
||||||
pub value: Option<U256>,
|
pub value: Option<U256>,
|
||||||
|
/// Data
|
||||||
pub data: Option<Bytes>,
|
pub data: Option<Bytes>,
|
||||||
|
/// Nonce
|
||||||
pub nonce: Option<U256>,
|
pub nonce: Option<U256>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,10 +22,14 @@ use v1::types::BlockNumber;
|
|||||||
use ethcore::filter::Filter as EthFilter;
|
use ethcore::filter::Filter as EthFilter;
|
||||||
use ethcore::client::BlockID;
|
use ethcore::client::BlockID;
|
||||||
|
|
||||||
|
/// Variadic value
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
pub enum VariadicValue<T> where T: Deserialize {
|
pub enum VariadicValue<T> where T: Deserialize {
|
||||||
|
/// Single
|
||||||
Single(T),
|
Single(T),
|
||||||
|
/// List
|
||||||
Multiple(Vec<T>),
|
Multiple(Vec<T>),
|
||||||
|
/// None
|
||||||
Null,
|
Null,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,17 +48,24 @@ impl<T> Deserialize for VariadicValue<T> where T: Deserialize {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Filter Address
|
||||||
pub type FilterAddress = VariadicValue<Address>;
|
pub type FilterAddress = VariadicValue<Address>;
|
||||||
|
/// Topic
|
||||||
pub type Topic = VariadicValue<H256>;
|
pub type Topic = VariadicValue<H256>;
|
||||||
|
|
||||||
|
/// Filter
|
||||||
#[derive(Debug, PartialEq, Clone, Deserialize)]
|
#[derive(Debug, PartialEq, Clone, Deserialize)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct Filter {
|
pub struct Filter {
|
||||||
|
/// From Block
|
||||||
#[serde(rename="fromBlock")]
|
#[serde(rename="fromBlock")]
|
||||||
pub from_block: Option<BlockNumber>,
|
pub from_block: Option<BlockNumber>,
|
||||||
|
/// To Block
|
||||||
#[serde(rename="toBlock")]
|
#[serde(rename="toBlock")]
|
||||||
pub to_block: Option<BlockNumber>,
|
pub to_block: Option<BlockNumber>,
|
||||||
|
/// Address
|
||||||
pub address: Option<FilterAddress>,
|
pub address: Option<FilterAddress>,
|
||||||
|
/// Topics
|
||||||
pub topics: Option<Vec<Topic>>,
|
pub topics: Option<Vec<Topic>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ use serde::de::Visitor;
|
|||||||
pub struct Index(usize);
|
pub struct Index(usize);
|
||||||
|
|
||||||
impl Index {
|
impl Index {
|
||||||
|
/// Convert to usize
|
||||||
pub fn value(&self) -> usize {
|
pub fn value(&self) -> usize {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
|
@ -18,21 +18,31 @@ use util::numbers::*;
|
|||||||
use ethcore::log_entry::{LocalizedLogEntry, LogEntry};
|
use ethcore::log_entry::{LocalizedLogEntry, LogEntry};
|
||||||
use v1::types::Bytes;
|
use v1::types::Bytes;
|
||||||
|
|
||||||
|
/// Log
|
||||||
#[derive(Debug, Serialize, PartialEq, Eq, Hash, Clone)]
|
#[derive(Debug, Serialize, PartialEq, Eq, Hash, Clone)]
|
||||||
pub struct Log {
|
pub struct Log {
|
||||||
|
/// Address
|
||||||
pub address: Address,
|
pub address: Address,
|
||||||
|
/// Topics
|
||||||
pub topics: Vec<H256>,
|
pub topics: Vec<H256>,
|
||||||
|
/// Data
|
||||||
pub data: Bytes,
|
pub data: Bytes,
|
||||||
|
/// Block Hash
|
||||||
#[serde(rename="blockHash")]
|
#[serde(rename="blockHash")]
|
||||||
pub block_hash: Option<H256>,
|
pub block_hash: Option<H256>,
|
||||||
|
/// Block Number
|
||||||
#[serde(rename="blockNumber")]
|
#[serde(rename="blockNumber")]
|
||||||
pub block_number: Option<U256>,
|
pub block_number: Option<U256>,
|
||||||
|
/// Transaction Hash
|
||||||
#[serde(rename="transactionHash")]
|
#[serde(rename="transactionHash")]
|
||||||
pub transaction_hash: Option<H256>,
|
pub transaction_hash: Option<H256>,
|
||||||
|
/// Transaction Index
|
||||||
#[serde(rename="transactionIndex")]
|
#[serde(rename="transactionIndex")]
|
||||||
pub transaction_index: Option<U256>,
|
pub transaction_index: Option<U256>,
|
||||||
|
/// Log Index
|
||||||
#[serde(rename="logIndex")]
|
#[serde(rename="logIndex")]
|
||||||
pub log_index: Option<U256>,
|
pub log_index: Option<U256>,
|
||||||
|
/// Log Type
|
||||||
#[serde(rename="type")]
|
#[serde(rename="type")]
|
||||||
pub log_type: String,
|
pub log_type: String,
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! Structures used in RPC communication
|
||||||
|
|
||||||
#[cfg(feature = "serde_macros")]
|
#[cfg(feature = "serde_macros")]
|
||||||
include!("mod.rs.in");
|
include!("mod.rs.in");
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
mod bytes;
|
||||||
mod block;
|
mod block;
|
||||||
mod block_number;
|
mod block_number;
|
||||||
mod filter;
|
mod filter;
|
||||||
@ -22,13 +23,13 @@ mod log;
|
|||||||
mod optionals;
|
mod optionals;
|
||||||
mod sync;
|
mod sync;
|
||||||
mod transaction;
|
mod transaction;
|
||||||
|
mod transaction_request;
|
||||||
mod call_request;
|
mod call_request;
|
||||||
mod receipt;
|
mod receipt;
|
||||||
mod trace;
|
mod trace;
|
||||||
mod trace_filter;
|
mod trace_filter;
|
||||||
|
|
||||||
pub use signer::types::bytes::Bytes;
|
pub use self::bytes::Bytes;
|
||||||
pub use signer::types::transaction_request::TransactionRequest;
|
|
||||||
pub use self::block::{Block, BlockTransactions};
|
pub use self::block::{Block, BlockTransactions};
|
||||||
pub use self::block_number::BlockNumber;
|
pub use self::block_number::BlockNumber;
|
||||||
pub use self::filter::Filter;
|
pub use self::filter::Filter;
|
||||||
@ -37,6 +38,7 @@ pub use self::log::Log;
|
|||||||
pub use self::optionals::OptionalValue;
|
pub use self::optionals::OptionalValue;
|
||||||
pub use self::sync::{SyncStatus, SyncInfo};
|
pub use self::sync::{SyncStatus, SyncInfo};
|
||||||
pub use self::transaction::Transaction;
|
pub use self::transaction::Transaction;
|
||||||
|
pub use self::transaction_request::TransactionRequest;
|
||||||
pub use self::call_request::CallRequest;
|
pub use self::call_request::CallRequest;
|
||||||
pub use self::receipt::Receipt;
|
pub use self::receipt::Receipt;
|
||||||
pub use self::trace::Trace;
|
pub use self::trace::Trace;
|
||||||
|
@ -17,9 +17,12 @@
|
|||||||
use serde::{Serialize, Serializer};
|
use serde::{Serialize, Serializer};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
|
/// Optional value
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum OptionalValue<T> where T: Serialize {
|
pub enum OptionalValue<T> where T: Serialize {
|
||||||
|
/// Some
|
||||||
Value(T),
|
Value(T),
|
||||||
|
/// None
|
||||||
Null
|
Null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,22 +19,31 @@ use util::hash::{Address, H256};
|
|||||||
use v1::types::Log;
|
use v1::types::Log;
|
||||||
use ethcore::receipt::LocalizedReceipt;
|
use ethcore::receipt::LocalizedReceipt;
|
||||||
|
|
||||||
|
/// Receipt
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
pub struct Receipt {
|
pub struct Receipt {
|
||||||
|
/// Transaction Hash
|
||||||
#[serde(rename="transactionHash")]
|
#[serde(rename="transactionHash")]
|
||||||
pub transaction_hash: H256,
|
pub transaction_hash: H256,
|
||||||
|
/// Transaction index
|
||||||
#[serde(rename="transactionIndex")]
|
#[serde(rename="transactionIndex")]
|
||||||
pub transaction_index: U256,
|
pub transaction_index: U256,
|
||||||
|
/// Block hash
|
||||||
#[serde(rename="blockHash")]
|
#[serde(rename="blockHash")]
|
||||||
pub block_hash: H256,
|
pub block_hash: H256,
|
||||||
|
/// Block number
|
||||||
#[serde(rename="blockNumber")]
|
#[serde(rename="blockNumber")]
|
||||||
pub block_number: U256,
|
pub block_number: U256,
|
||||||
|
/// Cumulative gas used
|
||||||
#[serde(rename="cumulativeGasUsed")]
|
#[serde(rename="cumulativeGasUsed")]
|
||||||
pub cumulative_gas_used: U256,
|
pub cumulative_gas_used: U256,
|
||||||
|
/// Gas used
|
||||||
#[serde(rename="gasUsed")]
|
#[serde(rename="gasUsed")]
|
||||||
pub gas_used: U256,
|
pub gas_used: U256,
|
||||||
|
/// Contract address
|
||||||
#[serde(rename="contractAddress")]
|
#[serde(rename="contractAddress")]
|
||||||
pub contract_address: Option<Address>,
|
pub contract_address: Option<Address>,
|
||||||
|
/// Logs
|
||||||
pub logs: Vec<Log>,
|
pub logs: Vec<Log>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,19 +17,26 @@
|
|||||||
use serde::{Serialize, Serializer};
|
use serde::{Serialize, Serializer};
|
||||||
use util::numbers::*;
|
use util::numbers::*;
|
||||||
|
|
||||||
|
/// Sync info
|
||||||
#[derive(Default, Debug, Serialize, PartialEq)]
|
#[derive(Default, Debug, Serialize, PartialEq)]
|
||||||
pub struct SyncInfo {
|
pub struct SyncInfo {
|
||||||
|
/// Starting block
|
||||||
#[serde(rename="startingBlock")]
|
#[serde(rename="startingBlock")]
|
||||||
pub starting_block: U256,
|
pub starting_block: U256,
|
||||||
|
/// Current block
|
||||||
#[serde(rename="currentBlock")]
|
#[serde(rename="currentBlock")]
|
||||||
pub current_block: U256,
|
pub current_block: U256,
|
||||||
|
/// Highest block seen so far
|
||||||
#[serde(rename="highestBlock")]
|
#[serde(rename="highestBlock")]
|
||||||
pub highest_block: U256,
|
pub highest_block: U256,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sync status
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum SyncStatus {
|
pub enum SyncStatus {
|
||||||
|
/// Info when syncing
|
||||||
Info(SyncInfo),
|
Info(SyncInfo),
|
||||||
|
/// Not syncing
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,11 +19,16 @@ use ethcore::trace::trace;
|
|||||||
use ethcore::trace::LocalizedTrace;
|
use ethcore::trace::LocalizedTrace;
|
||||||
use v1::types::Bytes;
|
use v1::types::Bytes;
|
||||||
|
|
||||||
|
/// Create response
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
pub struct Create {
|
pub struct Create {
|
||||||
|
/// Sender
|
||||||
from: Address,
|
from: Address,
|
||||||
|
/// Value
|
||||||
value: U256,
|
value: U256,
|
||||||
|
/// Gas
|
||||||
gas: U256,
|
gas: U256,
|
||||||
|
/// Initialization code
|
||||||
init: Bytes,
|
init: Bytes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,12 +43,18 @@ impl From<trace::Create> for Create {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Call response
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
pub struct Call {
|
pub struct Call {
|
||||||
|
/// Sender
|
||||||
from: Address,
|
from: Address,
|
||||||
|
/// Recipient
|
||||||
to: Address,
|
to: Address,
|
||||||
|
/// Transfered Value
|
||||||
value: U256,
|
value: U256,
|
||||||
|
/// Gas
|
||||||
gas: U256,
|
gas: U256,
|
||||||
|
/// Input data
|
||||||
input: Bytes,
|
input: Bytes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,10 +70,13 @@ impl From<trace::Call> for Call {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Action
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
pub enum Action {
|
pub enum Action {
|
||||||
|
/// Call
|
||||||
#[serde(rename="call")]
|
#[serde(rename="call")]
|
||||||
Call(Call),
|
Call(Call),
|
||||||
|
/// Create
|
||||||
#[serde(rename="create")]
|
#[serde(rename="create")]
|
||||||
Create(Create),
|
Create(Create),
|
||||||
}
|
}
|
||||||
@ -76,10 +90,13 @@ impl From<trace::Action> for Action {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Call Result
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
pub struct CallResult {
|
pub struct CallResult {
|
||||||
|
/// Gas used
|
||||||
#[serde(rename="gasUsed")]
|
#[serde(rename="gasUsed")]
|
||||||
gas_used: U256,
|
gas_used: U256,
|
||||||
|
/// Output bytes
|
||||||
output: Bytes,
|
output: Bytes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,11 +109,15 @@ impl From<trace::CallResult> for CallResult {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Craete Result
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
pub struct CreateResult {
|
pub struct CreateResult {
|
||||||
|
/// Gas used
|
||||||
#[serde(rename="gasUsed")]
|
#[serde(rename="gasUsed")]
|
||||||
gas_used: U256,
|
gas_used: U256,
|
||||||
|
/// Code
|
||||||
code: Bytes,
|
code: Bytes,
|
||||||
|
/// Assigned address
|
||||||
address: Address,
|
address: Address,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,14 +131,19 @@ impl From<trace::CreateResult> for CreateResult {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Response
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
pub enum Res {
|
pub enum Res {
|
||||||
|
/// Call
|
||||||
#[serde(rename="call")]
|
#[serde(rename="call")]
|
||||||
Call(CallResult),
|
Call(CallResult),
|
||||||
|
/// Create
|
||||||
#[serde(rename="create")]
|
#[serde(rename="create")]
|
||||||
Create(CreateResult),
|
Create(CreateResult),
|
||||||
|
/// Call failure
|
||||||
#[serde(rename="failedCall")]
|
#[serde(rename="failedCall")]
|
||||||
FailedCall,
|
FailedCall,
|
||||||
|
/// Creation failure
|
||||||
#[serde(rename="failedCreate")]
|
#[serde(rename="failedCreate")]
|
||||||
FailedCreate,
|
FailedCreate,
|
||||||
}
|
}
|
||||||
@ -133,19 +159,28 @@ impl From<trace::Res> for Res {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Trace
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
pub struct Trace {
|
pub struct Trace {
|
||||||
|
/// Action
|
||||||
action: Action,
|
action: Action,
|
||||||
|
/// Result
|
||||||
result: Res,
|
result: Res,
|
||||||
|
/// Trace address
|
||||||
#[serde(rename="traceAddress")]
|
#[serde(rename="traceAddress")]
|
||||||
trace_address: Vec<U256>,
|
trace_address: Vec<U256>,
|
||||||
|
/// Subtraces
|
||||||
subtraces: U256,
|
subtraces: U256,
|
||||||
|
/// Transaction position
|
||||||
#[serde(rename="transactionPosition")]
|
#[serde(rename="transactionPosition")]
|
||||||
transaction_position: U256,
|
transaction_position: U256,
|
||||||
|
/// Transaction hash
|
||||||
#[serde(rename="transactionHash")]
|
#[serde(rename="transactionHash")]
|
||||||
transaction_hash: H256,
|
transaction_hash: H256,
|
||||||
|
/// Block Number
|
||||||
#[serde(rename="blockNumber")]
|
#[serde(rename="blockNumber")]
|
||||||
block_number: U256,
|
block_number: U256,
|
||||||
|
/// Block Hash
|
||||||
#[serde(rename="blockHash")]
|
#[serde(rename="blockHash")]
|
||||||
block_hash: H256,
|
block_hash: H256,
|
||||||
}
|
}
|
||||||
|
@ -21,14 +21,19 @@ use ethcore::client::BlockID;
|
|||||||
use ethcore::client;
|
use ethcore::client;
|
||||||
use super::BlockNumber;
|
use super::BlockNumber;
|
||||||
|
|
||||||
|
/// Trace filter
|
||||||
#[derive(Debug, PartialEq, Deserialize)]
|
#[derive(Debug, PartialEq, Deserialize)]
|
||||||
pub struct TraceFilter {
|
pub struct TraceFilter {
|
||||||
|
/// From block
|
||||||
#[serde(rename="fromBlock")]
|
#[serde(rename="fromBlock")]
|
||||||
pub from_block: Option<BlockNumber>,
|
pub from_block: Option<BlockNumber>,
|
||||||
|
/// To block
|
||||||
#[serde(rename="toBlock")]
|
#[serde(rename="toBlock")]
|
||||||
pub to_block: Option<BlockNumber>,
|
pub to_block: Option<BlockNumber>,
|
||||||
|
/// From address
|
||||||
#[serde(rename="fromAddress")]
|
#[serde(rename="fromAddress")]
|
||||||
pub from_address: Option<Vec<Address>>,
|
pub from_address: Option<Vec<Address>>,
|
||||||
|
/// To address
|
||||||
#[serde(rename="toAddress")]
|
#[serde(rename="toAddress")]
|
||||||
pub to_address: Option<Vec<Address>>,
|
pub to_address: Option<Vec<Address>>,
|
||||||
}
|
}
|
||||||
|
@ -18,22 +18,34 @@ use util::numbers::*;
|
|||||||
use ethcore::transaction::{LocalizedTransaction, Action, SignedTransaction};
|
use ethcore::transaction::{LocalizedTransaction, Action, SignedTransaction};
|
||||||
use v1::types::{Bytes, OptionalValue};
|
use v1::types::{Bytes, OptionalValue};
|
||||||
|
|
||||||
|
/// Transaction
|
||||||
#[derive(Debug, Default, Serialize)]
|
#[derive(Debug, Default, Serialize)]
|
||||||
pub struct Transaction {
|
pub struct Transaction {
|
||||||
|
/// Hash
|
||||||
pub hash: H256,
|
pub hash: H256,
|
||||||
|
/// Nonce
|
||||||
pub nonce: U256,
|
pub nonce: U256,
|
||||||
|
/// Block hash
|
||||||
#[serde(rename="blockHash")]
|
#[serde(rename="blockHash")]
|
||||||
pub block_hash: OptionalValue<H256>,
|
pub block_hash: OptionalValue<H256>,
|
||||||
|
/// Block number
|
||||||
#[serde(rename="blockNumber")]
|
#[serde(rename="blockNumber")]
|
||||||
pub block_number: OptionalValue<U256>,
|
pub block_number: OptionalValue<U256>,
|
||||||
|
/// Transaction Index
|
||||||
#[serde(rename="transactionIndex")]
|
#[serde(rename="transactionIndex")]
|
||||||
pub transaction_index: OptionalValue<U256>,
|
pub transaction_index: OptionalValue<U256>,
|
||||||
|
/// Sender
|
||||||
pub from: Address,
|
pub from: Address,
|
||||||
|
/// Recipient
|
||||||
pub to: OptionalValue<Address>,
|
pub to: OptionalValue<Address>,
|
||||||
|
/// Transfered value
|
||||||
pub value: U256,
|
pub value: U256,
|
||||||
|
/// Gas Price
|
||||||
#[serde(rename="gasPrice")]
|
#[serde(rename="gasPrice")]
|
||||||
pub gas_price: U256,
|
pub gas_price: U256,
|
||||||
|
/// Gas
|
||||||
pub gas: U256,
|
pub gas: U256,
|
||||||
|
/// Data
|
||||||
pub input: Bytes
|
pub input: Bytes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
use util::hash::Address;
|
use util::hash::Address;
|
||||||
use util::numbers::U256;
|
use util::numbers::U256;
|
||||||
use types::bytes::Bytes;
|
use v1::types::bytes::Bytes;
|
||||||
|
|
||||||
/// Transaction request coming from RPC
|
/// Transaction request coming from RPC
|
||||||
#[derive(Debug, Clone, Default, Eq, PartialEq, Hash, Deserialize)]
|
#[derive(Debug, Clone, Default, Eq, PartialEq, Hash, Deserialize)]
|
||||||
@ -47,7 +47,7 @@ mod tests {
|
|||||||
use serde_json;
|
use serde_json;
|
||||||
use util::numbers::{U256};
|
use util::numbers::{U256};
|
||||||
use util::hash::Address;
|
use util::hash::Address;
|
||||||
use types::bytes::Bytes;
|
use v1::types::bytes::Bytes;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
@ -16,10 +16,11 @@ syntex = "^0.32.0"
|
|||||||
serde = "0.7.0"
|
serde = "0.7.0"
|
||||||
serde_json = "0.7.0"
|
serde_json = "0.7.0"
|
||||||
rustc-serialize = "0.3"
|
rustc-serialize = "0.3"
|
||||||
ethcore-util = { path = "../util" }
|
|
||||||
log = "0.3"
|
log = "0.3"
|
||||||
env_logger = "0.3"
|
env_logger = "0.3"
|
||||||
ws = "0.4.7"
|
ws = "0.4.7"
|
||||||
|
ethcore-util = { path = "../util" }
|
||||||
|
ethcore-rpc = { path = "../rpc" }
|
||||||
|
|
||||||
serde_macros = { version = "0.7.0", optional = true }
|
serde_macros = { version = "0.7.0", optional = true }
|
||||||
clippy = { version = "0.0.69", optional = true}
|
clippy = { version = "0.0.69", optional = true}
|
||||||
|
@ -49,11 +49,11 @@ extern crate serde_json;
|
|||||||
extern crate rustc_serialize;
|
extern crate rustc_serialize;
|
||||||
|
|
||||||
extern crate ethcore_util as util;
|
extern crate ethcore_util as util;
|
||||||
|
extern crate ethcore_rpc as rpc;
|
||||||
extern crate ws;
|
extern crate ws;
|
||||||
|
|
||||||
mod signing_queue;
|
mod signing_queue;
|
||||||
mod ws_server;
|
mod ws_server;
|
||||||
pub mod types;
|
|
||||||
|
|
||||||
pub use ws_server::*;
|
pub use ws_server::*;
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use types::transaction_request::TransactionRequest;
|
use rpc::v1::types::TransactionRequest;
|
||||||
|
|
||||||
pub trait SigningQueue {
|
pub trait SigningQueue {
|
||||||
fn add_request(&mut self, transaction: TransactionRequest);
|
fn add_request(&mut self, transaction: TransactionRequest);
|
||||||
@ -45,7 +45,7 @@ mod test {
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use util::hash::Address;
|
use util::hash::Address;
|
||||||
use util::numbers::U256;
|
use util::numbers::U256;
|
||||||
use types::transaction_request::TransactionRequest;
|
use rpc::v1::types::TransactionRequest;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -14,5 +14,12 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pub mod transaction_request;
|
|
||||||
pub mod bytes;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// TODO [ToDr] Types are empty for now. But they are about to come.
|
||||||
|
@ -31,14 +31,14 @@ pub enum ServerError {
|
|||||||
/// Wrapped `std::io::Error`
|
/// Wrapped `std::io::Error`
|
||||||
IoError(std::io::Error),
|
IoError(std::io::Error),
|
||||||
/// Other `ws-rs` error
|
/// Other `ws-rs` error
|
||||||
Other(ws::Error)
|
WebSocket(ws::Error)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ws::Error> for ServerError {
|
impl From<ws::Error> for ServerError {
|
||||||
fn from(err: ws::Error) -> Self {
|
fn from(err: ws::Error) -> Self {
|
||||||
match err.kind {
|
match err.kind {
|
||||||
ws::ErrorKind::Io(e) => ServerError::IoError(e),
|
ws::ErrorKind::Io(e) => ServerError::IoError(e),
|
||||||
_ => ServerError::Other(err),
|
_ => ServerError::WebSocket(err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user