diff --git a/Cargo.lock b/Cargo.lock index c194b594d..c6195fdb0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1017,7 +1017,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "jsonrpc-core" version = "7.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#87db29043826f152cce171351fa34fada287764d" +source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#d8dae528860d7fe976a8e3ec060a792e2496573b" dependencies = [ "futures 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1029,7 +1029,7 @@ dependencies = [ [[package]] name = "jsonrpc-http-server" version = "7.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#87db29043826f152cce171351fa34fada287764d" +source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#d8dae528860d7fe976a8e3ec060a792e2496573b" dependencies = [ "hyper 0.10.0-a.0 (git+https://github.com/paritytech/hyper)", "jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)", @@ -1042,7 +1042,7 @@ dependencies = [ [[package]] name = "jsonrpc-ipc-server" version = "7.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#87db29043826f152cce171351fa34fada287764d" +source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#d8dae528860d7fe976a8e3ec060a792e2496573b" dependencies = [ "bytes 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)", @@ -1055,7 +1055,7 @@ dependencies = [ [[package]] name = "jsonrpc-macros" version = "7.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#87db29043826f152cce171351fa34fada287764d" +source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#d8dae528860d7fe976a8e3ec060a792e2496573b" dependencies = [ "jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)", "jsonrpc-pubsub 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)", @@ -1065,7 +1065,7 @@ dependencies = [ [[package]] name = "jsonrpc-minihttp-server" version = "7.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#87db29043826f152cce171351fa34fada287764d" +source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#d8dae528860d7fe976a8e3ec060a792e2496573b" dependencies = [ "jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)", "jsonrpc-server-utils 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)", @@ -1079,7 +1079,7 @@ dependencies = [ [[package]] name = "jsonrpc-pubsub" version = "7.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#87db29043826f152cce171351fa34fada287764d" +source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#d8dae528860d7fe976a8e3ec060a792e2496573b" dependencies = [ "jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)", "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1089,7 +1089,7 @@ dependencies = [ [[package]] name = "jsonrpc-server-utils" version = "7.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#87db29043826f152cce171351fa34fada287764d" +source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#d8dae528860d7fe976a8e3ec060a792e2496573b" dependencies = [ "globset 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)", @@ -1101,7 +1101,7 @@ dependencies = [ [[package]] name = "jsonrpc-tcp-server" version = "7.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#87db29043826f152cce171351fa34fada287764d" +source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#d8dae528860d7fe976a8e3ec060a792e2496573b" dependencies = [ "bytes 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)", @@ -1115,7 +1115,7 @@ dependencies = [ [[package]] name = "jsonrpc-ws-server" version = "7.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#87db29043826f152cce171351fa34fada287764d" +source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7#d8dae528860d7fe976a8e3ec060a792e2496573b" dependencies = [ "jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)", "jsonrpc-server-utils 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)", diff --git a/rpc/src/v1/helpers/light_fetch.rs b/rpc/src/v1/helpers/light_fetch.rs index 6f8e29171..2655f7351 100644 --- a/rpc/src/v1/helpers/light_fetch.rs +++ b/rpc/src/v1/helpers/light_fetch.rs @@ -162,7 +162,7 @@ impl LightFetch { let (sync, on_demand, client) = (self.sync.clone(), self.on_demand.clone(), self.client.clone()); let req: CallRequestHelper = req.into(); - let id = num.0.into(); + let id = num.unwrap_or_default().into(); let from = req.from.unwrap_or(Address::zero()); let nonce_fut = match req.nonce { diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index dacae2e67..04c74434e 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -361,7 +361,7 @@ impl Eth for EthClient where fn balance(&self, address: RpcH160, num: Trailing) -> BoxFuture { let address = address.into(); - let res = match num.0.clone() { + let res = match num.unwrap_or_default() { BlockNumber::Pending => { match self.miner.balance(&*self.client, &address) { Some(balance) => Ok(balance.into()), @@ -384,7 +384,7 @@ impl Eth for EthClient where let address: Address = RpcH160::into(address); let position: U256 = RpcU256::into(pos); - let res = match num.0.clone() { + let res = match num.unwrap_or_default() { BlockNumber::Pending => { match self.miner.storage_at(&*self.client, &address, &H256::from(position)) { Some(s) => Ok(s.into()), @@ -406,7 +406,7 @@ impl Eth for EthClient where fn transaction_count(&self, address: RpcH160, num: Trailing) -> BoxFuture { let address: Address = RpcH160::into(address); - let res = match num.0.clone() { + let res = match num.unwrap_or_default() { BlockNumber::Pending if self.options.pending_nonce_from_queue => { let nonce = self.miner.last_nonce(&address) .map(|n| n + 1.into()) @@ -468,7 +468,7 @@ impl Eth for EthClient where fn code_at(&self, address: RpcH160, num: Trailing) -> BoxFuture { let address: Address = RpcH160::into(address); - let res = match num.0.clone() { + let res = match num.unwrap_or_default() { BlockNumber::Pending => { match self.miner.code(&*self.client, &address) { Some(code) => Ok(code.map_or_else(Bytes::default, Bytes::new)), @@ -553,7 +553,7 @@ impl Eth for EthClient where } fn work(&self, no_new_work_timeout: Trailing) -> Result { - let no_new_work_timeout = no_new_work_timeout.0; + let no_new_work_timeout = no_new_work_timeout.unwrap_or_default(); // check if we're still syncing and return empty strings in that case { @@ -638,7 +638,7 @@ impl Eth for EthClient where Err(e) => return future::err(e).boxed(), }; - let result = match num.0 { + let result = match num.unwrap_or_default() { BlockNumber::Pending => self.miner.call(&*self.client, &signed, Default::default()), num => self.client.call(&signed, num.into(), Default::default()), }; @@ -655,7 +655,7 @@ impl Eth for EthClient where Ok(signed) => signed, Err(e) => return future::err(e).boxed(), }; - future::done(self.client.estimate_gas(&signed, num.0.into()) + future::done(self.client.estimate_gas(&signed, num.unwrap_or_default().into()) .map(Into::into) .map_err(errors::from_call_error) ).boxed() diff --git a/rpc/src/v1/impls/eth_pubsub.rs b/rpc/src/v1/impls/eth_pubsub.rs index ce839428b..677e74868 100644 --- a/rpc/src/v1/impls/eth_pubsub.rs +++ b/rpc/src/v1/impls/eth_pubsub.rs @@ -136,8 +136,9 @@ impl EthPubSub for EthPubSubClient { kind: pubsub::Kind, params: Trailing, ) { - match (kind, params.0) { - (pubsub::Kind::NewHeads, pubsub::Params::None) => { + let params: Option = params.into(); + match (kind, params) { + (pubsub::Kind::NewHeads, None) => { self.heads_subscribers.lock().push(subscriber) }, _ => { diff --git a/rpc/src/v1/impls/light/eth.rs b/rpc/src/v1/impls/light/eth.rs index ca1157206..dac63005e 100644 --- a/rpc/src/v1/impls/light/eth.rs +++ b/rpc/src/v1/impls/light/eth.rs @@ -270,7 +270,7 @@ impl Eth for EthClient { } fn balance(&self, address: RpcH160, num: Trailing) -> BoxFuture { - self.fetcher().account(address.into(), num.0.into()) + self.fetcher().account(address.into(), num.unwrap_or_default().into()) .map(|acc| acc.map_or(0.into(), |a| a.balance).into()).boxed() } @@ -287,7 +287,7 @@ impl Eth for EthClient { } fn transaction_count(&self, address: RpcH160, num: Trailing) -> BoxFuture { - self.fetcher().account(address.into(), num.0.into()) + self.fetcher().account(address.into(), num.unwrap_or_default().into()) .map(|acc| acc.map_or(0.into(), |a| a.nonce).into()).boxed() } diff --git a/rpc/src/v1/impls/light/parity.rs b/rpc/src/v1/impls/light/parity.rs index f0cdb5236..273c958fe 100644 --- a/rpc/src/v1/impls/light/parity.rs +++ b/rpc/src/v1/impls/light/parity.rs @@ -98,7 +98,7 @@ impl Parity for ParityClient { type Metadata = Metadata; fn accounts_info(&self, dapp: Trailing) -> Result, Error> { - let dapp = dapp.0; + let dapp = dapp.unwrap_or_default(); let store = &self.accounts; let dapp_accounts = store @@ -383,7 +383,7 @@ impl Parity for ParityClient { } }; - self.fetcher().header(number.0.into()).map(from_encoded).boxed() + self.fetcher().header(number.unwrap_or_default().into()).map(from_encoded).boxed() } fn ipfs_cid(&self, content: Bytes) -> Result { diff --git a/rpc/src/v1/impls/parity.rs b/rpc/src/v1/impls/parity.rs index 2c5bcbef4..f782be982 100644 --- a/rpc/src/v1/impls/parity.rs +++ b/rpc/src/v1/impls/parity.rs @@ -124,7 +124,7 @@ impl Parity for ParityClient where type Metadata = Metadata; fn accounts_info(&self, dapp: Trailing) -> Result, Error> { - let dapp = dapp.0; + let dapp = dapp.unwrap_or_default(); let store = self.account_provider()?; let dapp_accounts = store @@ -272,13 +272,13 @@ impl Parity for ParityClient where fn list_accounts(&self, count: u64, after: Option, block_number: Trailing) -> Result>, Error> { Ok(self.client - .list_accounts(block_number.0.into(), after.map(Into::into).as_ref(), count) + .list_accounts(block_number.unwrap_or_default().into(), after.map(Into::into).as_ref(), count) .map(|a| a.into_iter().map(Into::into).collect())) } fn list_storage_keys(&self, address: H160, count: u64, after: Option, block_number: Trailing) -> Result>, Error> { Ok(self.client - .list_storage(block_number.0.into(), &address.into(), after.map(Into::into).as_ref(), count) + .list_storage(block_number.unwrap_or_default().into(), &address.into(), after.map(Into::into).as_ref(), count) .map(|a| a.into_iter().map(Into::into).collect())) } @@ -389,7 +389,7 @@ impl Parity for ParityClient where fn block_header(&self, number: Trailing) -> BoxFuture { const EXTRA_INFO_PROOF: &'static str = "Object exists in in blockchain (fetched earlier), extra_info is always available if object exists; qed"; - let id: BlockId = number.0.into(); + let id: BlockId = number.unwrap_or_default().into(); let encoded = match self.client.block_header(id.clone()) { Some(encoded) => encoded, None => return future::err(errors::unknown_block()).boxed(), diff --git a/rpc/src/v1/impls/pubsub.rs b/rpc/src/v1/impls/pubsub.rs index 215141e84..48b8b4401 100644 --- a/rpc/src/v1/impls/pubsub.rs +++ b/rpc/src/v1/impls/pubsub.rs @@ -22,6 +22,7 @@ use util::RwLock; use futures::{self, BoxFuture, Future, Stream, Sink}; use jsonrpc_core::{self as core, Error, MetaIoHandler}; +use jsonrpc_macros::Trailing; use jsonrpc_macros::pubsub::Subscriber; use jsonrpc_pubsub::SubscriptionId; use tokio_timer; @@ -64,7 +65,8 @@ impl> PubSubClient { impl> PubSub for PubSubClient { type Metadata = Metadata; - fn parity_subscribe(&self, mut meta: Metadata, subscriber: Subscriber, method: String, params: core::Params) { + fn parity_subscribe(&self, mut meta: Metadata, subscriber: Subscriber, method: String, params: Trailing) { + let params = params.unwrap_or(core::Params::Array(vec![])); // Make sure to get rid of PubSub session otherwise it will never be dropped. meta.session = None; diff --git a/rpc/src/v1/impls/traces.rs b/rpc/src/v1/impls/traces.rs index 46a2ce9fd..705ad9cab 100644 --- a/rpc/src/v1/impls/traces.rs +++ b/rpc/src/v1/impls/traces.rs @@ -80,7 +80,7 @@ impl Traces for TracesClient where C: MiningBlockChainClient + 'stat } fn call(&self, request: CallRequest, flags: Vec, block: Trailing) -> Result { - let block = block.0; + let block = block.unwrap_or_default(); let request = CallRequest::into(request); let signed = fake_sign::sign_call(&self.client, &self.miner, request)?; @@ -91,7 +91,7 @@ impl Traces for TracesClient where C: MiningBlockChainClient + 'stat } fn raw_transaction(&self, raw_transaction: Bytes, flags: Vec, block: Trailing) -> Result { - let block = block.0; + let block = block.unwrap_or_default(); let tx = UntrustedRlp::new(&raw_transaction.into_vec()).as_val().map_err(|e| errors::invalid_params("Transaction is not valid RLP", e))?; let signed = SignedTransaction::new(tx).map_err(errors::from_transaction_error)?; diff --git a/rpc/src/v1/tests/mocked/pubsub.rs b/rpc/src/v1/tests/mocked/pubsub.rs index b7c8963e5..0c1afa4b8 100644 --- a/rpc/src/v1/tests/mocked/pubsub.rs +++ b/rpc/src/v1/tests/mocked/pubsub.rs @@ -52,7 +52,7 @@ fn should_subscribe_to_a_method() { metadata.session = Some(Arc::new(Session::new(sender))); // Subscribe - let request = r#"{"jsonrpc": "2.0", "method": "parity_subscribe", "params": ["hello", []], "id": 1}"#; + let request = r#"{"jsonrpc": "2.0", "method": "parity_subscribe", "params": ["hello"], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":1,"id":1}"#; assert_eq!(io.handle_request_sync(request, metadata.clone()), Some(response.to_owned())); diff --git a/rpc/src/v1/traits/pubsub.rs b/rpc/src/v1/traits/pubsub.rs index a4672403a..7957a3875 100644 --- a/rpc/src/v1/traits/pubsub.rs +++ b/rpc/src/v1/traits/pubsub.rs @@ -18,6 +18,7 @@ use jsonrpc_core::{Error, Value, Params}; use jsonrpc_pubsub::SubscriptionId; +use jsonrpc_macros::Trailing; use jsonrpc_macros::pubsub::Subscriber; use futures::BoxFuture; @@ -29,7 +30,7 @@ build_rpc_trait! { #[pubsub(name = "parity_subscription")] { /// Subscribe to changes of any RPC method in Parity. #[rpc(name = "parity_subscribe")] - fn parity_subscribe(&self, Self::Metadata, Subscriber, String, Params); + fn parity_subscribe(&self, Self::Metadata, Subscriber, String, Trailing); /// Unsubscribe from existing Parity subscription. #[rpc(name = "parity_unsubscribe")]