diff --git a/Cargo.lock b/Cargo.lock
index a346f1ab1..eb147e6c4 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -924,7 +924,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "parity-dapps"
version = "0.6.0"
-source = "git+https://github.com/ethcore/parity-ui.git#7120546d08d4d9eb648e255c04935002223d362f"
+source = "git+https://github.com/ethcore/parity-ui.git#697e860dedc45003909602a002e7743478ab173a"
dependencies = [
"aster 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
"glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -938,7 +938,7 @@ dependencies = [
[[package]]
name = "parity-dapps-home"
version = "0.6.0"
-source = "git+https://github.com/ethcore/parity-ui.git#7120546d08d4d9eb648e255c04935002223d362f"
+source = "git+https://github.com/ethcore/parity-ui.git#697e860dedc45003909602a002e7743478ab173a"
dependencies = [
"parity-dapps 0.6.0 (git+https://github.com/ethcore/parity-ui.git)",
]
@@ -946,7 +946,7 @@ dependencies = [
[[package]]
name = "parity-dapps-signer"
version = "0.6.0"
-source = "git+https://github.com/ethcore/parity-ui.git#7120546d08d4d9eb648e255c04935002223d362f"
+source = "git+https://github.com/ethcore/parity-ui.git#697e860dedc45003909602a002e7743478ab173a"
dependencies = [
"parity-dapps 0.6.0 (git+https://github.com/ethcore/parity-ui.git)",
]
@@ -954,7 +954,7 @@ dependencies = [
[[package]]
name = "parity-dapps-status"
version = "0.6.0"
-source = "git+https://github.com/ethcore/parity-ui.git#7120546d08d4d9eb648e255c04935002223d362f"
+source = "git+https://github.com/ethcore/parity-ui.git#697e860dedc45003909602a002e7743478ab173a"
dependencies = [
"parity-dapps 0.6.0 (git+https://github.com/ethcore/parity-ui.git)",
]
@@ -962,7 +962,7 @@ dependencies = [
[[package]]
name = "parity-dapps-wallet"
version = "0.6.0"
-source = "git+https://github.com/ethcore/parity-ui.git#7120546d08d4d9eb648e255c04935002223d362f"
+source = "git+https://github.com/ethcore/parity-ui.git#697e860dedc45003909602a002e7743478ab173a"
dependencies = [
"parity-dapps 0.6.0 (git+https://github.com/ethcore/parity-ui.git)",
]
diff --git a/rpc/src/v1/helpers/mod.rs b/rpc/src/v1/helpers/mod.rs
index e38a77a79..4d3bd1207 100644
--- a/rpc/src/v1/helpers/mod.rs
+++ b/rpc/src/v1/helpers/mod.rs
@@ -21,5 +21,5 @@ mod signing_queue;
pub use self::poll_manager::PollManager;
pub use self::poll_filter::PollFilter;
-pub use self::requests::{TransactionRequest, TransactionConfirmation, CallRequest};
+pub use self::requests::{TransactionRequest, FilledTransactionRequest, ConfirmationRequest, ConfirmationPayload, CallRequest};
pub use self::signing_queue::{ConfirmationsQueue, ConfirmationPromise, ConfirmationResult, SigningQueue, QueueEvent};
diff --git a/rpc/src/v1/helpers/requests.rs b/rpc/src/v1/helpers/requests.rs
index d162774d9..6a30d80bb 100644
--- a/rpc/src/v1/helpers/requests.rs
+++ b/rpc/src/v1/helpers/requests.rs
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see .
-use util::{Address, U256};
+use util::{Address, U256, Bytes, H256};
/// Transaction request coming from RPC
#[derive(Debug, Clone, Default, Eq, PartialEq, Hash)]
@@ -30,18 +30,42 @@ pub struct TransactionRequest {
/// Value of transaction in wei
pub value: Option,
/// Additional data sent with transaction
- pub data: Option>,
+ pub data: Option,
/// Transaction's nonce
pub nonce: Option,
}
-/// Transaction confirmation waiting in a queue
+/// Transaction request coming from RPC with default values filled in.
#[derive(Debug, Clone, Default, Eq, PartialEq, Hash)]
-pub struct TransactionConfirmation {
- /// Id of this confirmation
- pub id: U256,
- /// TransactionRequest
- pub transaction: TransactionRequest,
+pub struct FilledTransactionRequest {
+ /// Sender
+ pub from: Address,
+ /// Recipient
+ pub to: Option,
+ /// Gas Price
+ pub gas_price: U256,
+ /// Gas
+ pub gas: U256,
+ /// Value of transaction in wei
+ pub value: U256,
+ /// Additional data sent with transaction
+ pub data: Bytes,
+ /// Transaction's nonce
+ pub nonce: Option,
+}
+
+impl From for TransactionRequest {
+ fn from(r: FilledTransactionRequest) -> Self {
+ TransactionRequest {
+ from: r.from,
+ to: r.to,
+ gas_price: Some(r.gas_price),
+ gas: Some(r.gas),
+ value: Some(r.value),
+ data: Some(r.data),
+ nonce: r.nonce,
+ }
+ }
}
/// Call request
@@ -62,3 +86,21 @@ pub struct CallRequest {
/// Nonce
pub nonce: Option,
}
+
+/// Confirmation object
+#[derive(Debug, Clone, Eq, PartialEq, Hash)]
+pub struct ConfirmationRequest {
+ /// Id of this confirmation
+ pub id: U256,
+ /// Payload to confirm
+ pub payload: ConfirmationPayload,
+}
+
+/// Payload to confirm in Trusted Signer
+#[derive(Debug, Clone, Eq, PartialEq, Hash)]
+pub enum ConfirmationPayload {
+ /// Transaction
+ Transaction(FilledTransactionRequest),
+ /// Sign request
+ Sign(Address, H256),
+}
diff --git a/rpc/src/v1/helpers/signing_queue.rs b/rpc/src/v1/helpers/signing_queue.rs
index 96c546052..616d35364 100644
--- a/rpc/src/v1/helpers/signing_queue.rs
+++ b/rpc/src/v1/helpers/signing_queue.rs
@@ -17,10 +17,10 @@
use std::thread;
use std::time::{Instant, Duration};
use std::sync::{mpsc, Arc};
-use std::collections::HashMap;
+use std::collections::BTreeMap;
use jsonrpc_core;
use util::{Mutex, RwLock, U256};
-use v1::helpers::{TransactionRequest, TransactionConfirmation};
+use v1::helpers::{ConfirmationRequest, ConfirmationPayload};
/// Result that can be returned from JSON RPC.
pub type RpcResult = Result;
@@ -54,41 +54,41 @@ pub type QueueEventReceiver = mpsc::Receiver;
pub trait SigningQueue: Send + Sync {
/// Add new request to the queue.
/// Returns a `ConfirmationPromise` that can be used to await for resolution of given request.
- fn add_request(&self, transaction: TransactionRequest) -> ConfirmationPromise;
+ fn add_request(&self, request: ConfirmationPayload) -> ConfirmationPromise;
/// Removes a request from the queue.
- /// Notifies possible token holders that transaction was rejected.
- fn request_rejected(&self, id: U256) -> Option;
+ /// Notifies possible token holders that request was rejected.
+ fn request_rejected(&self, id: U256) -> Option;
/// Removes a request from the queue.
- /// Notifies possible token holders that transaction was confirmed and given hash was assigned.
- fn request_confirmed(&self, id: U256, result: RpcResult) -> Option;
+ /// Notifies possible token holders that request was confirmed and given hash was assigned.
+ fn request_confirmed(&self, id: U256, result: RpcResult) -> Option;
/// Returns a request if it is contained in the queue.
- fn peek(&self, id: &U256) -> Option;
+ fn peek(&self, id: &U256) -> Option;
/// Return copy of all the requests in the queue.
- fn requests(&self) -> Vec;
+ fn requests(&self) -> Vec;
- /// Returns number of transactions awaiting confirmation.
+ /// Returns number of requests awaiting confirmation.
fn len(&self) -> usize;
- /// Returns true if there are no transactions awaiting confirmation.
+ /// Returns true if there are no requests awaiting confirmation.
fn is_empty(&self) -> bool;
}
#[derive(Debug, Clone, PartialEq)]
-/// Result of a pending transaction.
+/// Result of a pending confirmation request.
pub enum ConfirmationResult {
- /// The transaction has not yet been confirmed nor rejected.
+ /// The request has not yet been confirmed nor rejected.
Waiting,
- /// The transaction has been rejected.
+ /// The request has been rejected.
Rejected,
- /// The transaction has been confirmed.
+ /// The request has been confirmed.
Confirmed(RpcResult),
}
-/// Time you need to confirm the transaction in UI.
+/// Time you need to confirm the request in UI.
/// This is the amount of time token holder will wait before
/// returning `None`.
/// Unless we have a multi-threaded RPC this will lock
@@ -100,12 +100,14 @@ const QUEUE_TIMEOUT_DURATION_SEC : u64 = 20;
pub struct ConfirmationToken {
result: Arc>,
handle: thread::Thread,
- request: TransactionConfirmation,
+ request: ConfirmationRequest,
+ timeout: Duration,
}
pub struct ConfirmationPromise {
id: U256,
result: Arc>,
+ timeout: Duration,
}
impl ConfirmationToken {
@@ -121,6 +123,7 @@ impl ConfirmationToken {
ConfirmationPromise {
id: self.request.id,
result: self.result.clone(),
+ timeout: self.timeout,
}
}
}
@@ -134,8 +137,7 @@ impl ConfirmationPromise {
/// Returns `None` if transaction was rejected or timeout reached.
/// Returns `Some(result)` if transaction was confirmed.
pub fn wait_with_timeout(&self) -> Option {
- let timeout = Duration::from_secs(QUEUE_TIMEOUT_DURATION_SEC);
- let res = self.wait_until(Instant::now() + timeout);
+ let res = self.wait_until(Instant::now() + self.timeout);
match res {
ConfirmationResult::Confirmed(h) => Some(h),
ConfirmationResult::Rejected | ConfirmationResult::Waiting => None,
@@ -146,16 +148,16 @@ impl ConfirmationPromise {
pub fn result(&self) -> ConfirmationResult { self.wait_until(Instant::now()) }
/// Blocks current thread and awaits for
- /// resolution of the transaction (rejected / confirmed)
- /// Returns `None` if transaction was rejected or timeout reached.
- /// Returns `Some(result)` if transaction was confirmed.
+ /// resolution of the request (rejected / confirmed)
+ /// Returns `None` if request was rejected or timeout reached.
+ /// Returns `Some(result)` if request was confirmed.
pub fn wait_until(&self, deadline: Instant) -> ConfirmationResult {
- trace!(target: "own_tx", "Signer: Awaiting transaction confirmation... ({:?}).", self.id);
+ trace!(target: "own_tx", "Signer: Awaiting confirmation... ({:?}).", self.id);
loop {
let now = Instant::now();
// Check the result...
match *self.result.lock() {
- // Waiting and deadline not yet passed continue looping.
+ // Waiting and deadline not yet passed continue looping.
ConfirmationResult::Waiting if now < deadline => {}
// Anything else - return.
ref a => return a.clone(),
@@ -166,12 +168,13 @@ impl ConfirmationPromise {
}
}
-/// Queue for all unconfirmed transactions.
+/// Queue for all unconfirmed requests.
pub struct ConfirmationsQueue {
id: Mutex,
- queue: RwLock>,
+ queue: RwLock>,
sender: Mutex>,
receiver: Mutex