From e2ac2db0cd7481d968640eaef09fedccf3c87f95 Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Mon, 16 Jul 2018 19:42:59 +0800 Subject: [PATCH] Completely remove all dapps struct from rpc (#9107) * Completely remove all dapps struct from rpc * Remove unused pub use --- parity/rpc_apis.rs | 1 - rpc/src/lib.rs | 2 +- rpc/src/v1/helpers/dapps.rs | 27 ------------ rpc/src/v1/helpers/errors.rs | 8 ---- rpc/src/v1/helpers/mod.rs | 1 - rpc/src/v1/impls/light/parity.rs | 4 -- rpc/src/v1/impls/light/parity_set.rs | 10 +---- rpc/src/v1/impls/parity.rs | 8 +--- rpc/src/v1/impls/parity_set.rs | 10 +---- rpc/src/v1/mod.rs | 6 --- rpc/src/v1/tests/mocked/parity.rs | 14 ------ rpc/src/v1/tests/mocked/parity_set.rs | 15 ------- rpc/src/v1/traits/parity.rs | 5 --- rpc/src/v1/traits/parity_set.rs | 11 +---- rpc/src/v1/types/dapps.rs | 61 --------------------------- rpc/src/v1/types/mod.rs | 2 - 16 files changed, 6 insertions(+), 179 deletions(-) delete mode 100644 rpc/src/v1/helpers/dapps.rs delete mode 100644 rpc/src/v1/types/dapps.rs diff --git a/parity/rpc_apis.rs b/parity/rpc_apis.rs index ade6c696946..cf9f6d2dd59 100644 --- a/parity/rpc_apis.rs +++ b/parity/rpc_apis.rs @@ -20,7 +20,6 @@ use std::str::FromStr; use std::sync::{Arc, Weak}; pub use parity_rpc::signer::SignerService; -pub use parity_rpc::dapps::LocalDapp; use ethcore_service::PrivateTxService; use ethcore::account_provider::AccountProvider; diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 98d743881ed..bef7d9effb4 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -118,7 +118,7 @@ pub use http::{ AccessControlAllowOrigin, Host, DomainsValidation }; -pub use v1::{NetworkSettings, Metadata, Origin, informant, dispatch, signer, dapps}; +pub use v1::{NetworkSettings, Metadata, Origin, informant, dispatch, signer}; pub use v1::block_import::is_major_importing; pub use v1::extractors::{RpcExtractor, WsExtractor, WsStats, WsDispatcher}; pub use authcodes::{AuthCodes, TimeProvider}; diff --git a/rpc/src/v1/helpers/dapps.rs b/rpc/src/v1/helpers/dapps.rs deleted file mode 100644 index 88a9cce6fbc..00000000000 --- a/rpc/src/v1/helpers/dapps.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2015-2018 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -//! Dapps Service - -use v1::types::LocalDapp; - -/// Dapps Server service. -pub trait DappsService: Send + Sync + 'static { - /// List available local dapps. - fn list_dapps(&self) -> Vec; - /// Refresh local dapps list - fn refresh_local_dapps(&self) -> bool; -} diff --git a/rpc/src/v1/helpers/errors.rs b/rpc/src/v1/helpers/errors.rs index 6207d4542fc..710f7d7497a 100644 --- a/rpc/src/v1/helpers/errors.rs +++ b/rpc/src/v1/helpers/errors.rs @@ -211,14 +211,6 @@ pub fn signer_disabled() -> Error { } } -pub fn dapps_disabled() -> Error { - Error { - code: ErrorCode::ServerError(codes::UNSUPPORTED_REQUEST), - message: "Dapps Server is disabled. This API is not available.".into(), - data: None, - } -} - pub fn ws_disabled() -> Error { Error { code: ErrorCode::ServerError(codes::UNSUPPORTED_REQUEST), diff --git a/rpc/src/v1/helpers/mod.rs b/rpc/src/v1/helpers/mod.rs index 5b62087ab38..ba8356334b3 100644 --- a/rpc/src/v1/helpers/mod.rs +++ b/rpc/src/v1/helpers/mod.rs @@ -18,7 +18,6 @@ pub mod errors; pub mod block_import; -pub mod dapps; pub mod dispatch; pub mod fake_sign; pub mod ipfs; diff --git a/rpc/src/v1/impls/light/parity.rs b/rpc/src/v1/impls/light/parity.rs index f722781111e..f9ec03cd378 100644 --- a/rpc/src/v1/impls/light/parity.rs +++ b/rpc/src/v1/impls/light/parity.rs @@ -326,10 +326,6 @@ impl Parity for ParityClient { Ok(map) } - fn dapps_url(&self) -> Result { - Err(errors::dapps_disabled()) - } - fn ws_url(&self) -> Result { helpers::to_url(&self.ws_address) .ok_or_else(|| errors::ws_disabled()) diff --git a/rpc/src/v1/impls/light/parity_set.rs b/rpc/src/v1/impls/light/parity_set.rs index dfe90a8ac8d..6eadea43ab5 100644 --- a/rpc/src/v1/impls/light/parity_set.rs +++ b/rpc/src/v1/impls/light/parity_set.rs @@ -29,7 +29,7 @@ use jsonrpc_core::{Result, BoxFuture}; use jsonrpc_core::futures::Future; use v1::helpers::errors; use v1::traits::ParitySet; -use v1::types::{Bytes, H160, H256, U256, ReleaseInfo, Transaction, LocalDapp}; +use v1::types::{Bytes, H160, H256, U256, ReleaseInfo, Transaction}; /// Parity-specific rpc interface for operations altering the settings. pub struct ParitySetClient { @@ -137,14 +137,6 @@ impl ParitySet for ParitySetClient { Box::new(self.pool.spawn(future)) } - fn dapps_refresh(&self) -> Result { - Err(errors::dapps_disabled()) - } - - fn dapps_list(&self) -> Result> { - Err(errors::dapps_disabled()) - } - fn upgrade_ready(&self) -> Result> { Err(errors::light_unimplemented(None)) } diff --git a/rpc/src/v1/impls/parity.rs b/rpc/src/v1/impls/parity.rs index ac4bb11525b..93560836f9c 100644 --- a/rpc/src/v1/impls/parity.rs +++ b/rpc/src/v1/impls/parity.rs @@ -139,11 +139,11 @@ impl Parity for ParityClient where .collect() ) } - + fn locked_hardware_accounts_info(&self) -> Result> { self.accounts.locked_hardware_accounts().map_err(|e| errors::account("Error communicating with hardware wallet.", e)) } - + fn default_account(&self, meta: Self::Metadata) -> Result { let dapp_id = meta.dapp_id(); @@ -347,10 +347,6 @@ impl Parity for ParityClient where ) } - fn dapps_url(&self) -> Result { - Err(errors::dapps_disabled()) - } - fn ws_url(&self) -> Result { helpers::to_url(&self.ws_address) .ok_or_else(|| errors::ws_disabled()) diff --git a/rpc/src/v1/impls/parity_set.rs b/rpc/src/v1/impls/parity_set.rs index 82880f7207d..c811b3e5daf 100644 --- a/rpc/src/v1/impls/parity_set.rs +++ b/rpc/src/v1/impls/parity_set.rs @@ -31,7 +31,7 @@ use jsonrpc_core::{BoxFuture, Result}; use jsonrpc_core::futures::Future; use v1::helpers::errors; use v1::traits::ParitySet; -use v1::types::{Bytes, H160, H256, U256, ReleaseInfo, Transaction, LocalDapp}; +use v1::types::{Bytes, H160, H256, U256, ReleaseInfo, Transaction}; /// Parity-specific rpc interface for operations altering the settings. pub struct ParitySetClient { @@ -182,14 +182,6 @@ impl ParitySet for ParitySetClient where Box::new(self.pool.spawn(future)) } - fn dapps_refresh(&self) -> Result { - Err(errors::dapps_disabled()) - } - - fn dapps_list(&self) -> Result> { - Err(errors::dapps_disabled()) - } - fn upgrade_ready(&self) -> Result> { Ok(self.updater.upgrade_ready().map(Into::into)) } diff --git a/rpc/src/v1/mod.rs b/rpc/src/v1/mod.rs index cb510ae2941..a0b74aa5aa4 100644 --- a/rpc/src/v1/mod.rs +++ b/rpc/src/v1/mod.rs @@ -53,9 +53,3 @@ pub mod signer { pub use super::helpers::{SigningQueue, SignerService, ConfirmationsQueue}; pub use super::types::{ConfirmationRequest, TransactionModification, U256, TransactionCondition}; } - -/// Dapps integration utilities -pub mod dapps { - pub use super::helpers::dapps::DappsService; - pub use super::types::LocalDapp; -} diff --git a/rpc/src/v1/tests/mocked/parity.rs b/rpc/src/v1/tests/mocked/parity.rs index f8322f8fe79..ca241140640 100644 --- a/rpc/src/v1/tests/mocked/parity.rs +++ b/rpc/src/v1/tests/mocked/parity.rs @@ -425,20 +425,6 @@ fn rpc_parity_ws_address() { assert_eq!(io2.handle_request_sync(request), Some(response2.to_owned())); } -#[test] -fn rpc_parity_dapps_address() { - // given - let deps = Dependencies::new(); - let io1 = deps.default_client(); - - // when - let request = r#"{"jsonrpc": "2.0", "method": "parity_dappsUrl", "params": [], "id": 1}"#; - let response = r#"{"jsonrpc":"2.0","error":{"code":-32000,"message":"Dapps Server is disabled. This API is not available."},"id":1}"#; - - // then - assert_eq!(io1.handle_request_sync(request), Some(response.to_owned())); -} - #[test] fn rpc_parity_next_nonce() { let deps = Dependencies::new(); diff --git a/rpc/src/v1/tests/mocked/parity_set.rs b/rpc/src/v1/tests/mocked/parity_set.rs index 0347da39ad6..5aca2827e12 100644 --- a/rpc/src/v1/tests/mocked/parity_set.rs +++ b/rpc/src/v1/tests/mocked/parity_set.rs @@ -238,18 +238,3 @@ fn rpc_parity_remove_transaction() { miner.pending_transactions.lock().insert(hash, signed); assert_eq!(io.handle_request_sync(&request), Some(response.to_owned())); } - -#[test] -fn rpc_parity_set_dapps_list() { - let miner = miner_service(); - let client = client_service(); - let network = network_service(); - let updater = updater_service(); - let mut io = IoHandler::new(); - io.extend_with(parity_set_client(&client, &miner, &updater, &network).to_delegate()); - - let request = r#"{"jsonrpc": "2.0", "method": "parity_dappsList", "params":[], "id": 1}"#; - let response = r#"{"jsonrpc":"2.0","error":{"code":-32000,"message":"Dapps Server is disabled. This API is not available."},"id":1}"#; - - assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); -} diff --git a/rpc/src/v1/traits/parity.rs b/rpc/src/v1/traits/parity.rs index 56634cc158c..2f2eef90741 100644 --- a/rpc/src/v1/traits/parity.rs +++ b/rpc/src/v1/traits/parity.rs @@ -161,11 +161,6 @@ build_rpc_trait! { #[rpc(name = "parity_localTransactions")] fn local_transactions(&self) -> Result>; - /// Returns current Dapps Server interface and port or an error if dapps server is disabled. - /// (deprecated, should always return an error now). - #[rpc(name = "parity_dappsUrl")] - fn dapps_url(&self) -> Result; - /// Returns current WS Server interface and port or an error if ws server is disabled. #[rpc(name = "parity_wsUrl")] fn ws_url(&self) -> Result; diff --git a/rpc/src/v1/traits/parity_set.rs b/rpc/src/v1/traits/parity_set.rs index dfd0ad5541f..707758920f6 100644 --- a/rpc/src/v1/traits/parity_set.rs +++ b/rpc/src/v1/traits/parity_set.rs @@ -18,7 +18,7 @@ use jsonrpc_core::{BoxFuture, Result}; -use v1::types::{Bytes, H160, H256, U256, ReleaseInfo, Transaction, LocalDapp}; +use v1::types::{Bytes, H160, H256, U256, ReleaseInfo, Transaction}; build_rpc_trait! { /// Parity-specific rpc interface for operations altering the settings. @@ -95,15 +95,6 @@ build_rpc_trait! { #[rpc(name = "parity_hashContent")] fn hash_content(&self, String) -> BoxFuture; - /// Returns true if refresh successful, error if unsuccessful or server is disabled - /// (deprecated, should always return an error now). - #[rpc(name = "parity_dappsRefresh")] - fn dapps_refresh(&self) -> Result; - - /// Returns a list of local dapps (deprecated, should always return an error now). - #[rpc(name = "parity_dappsList")] - fn dapps_list(&self) -> Result>; - /// Is there a release ready for install? #[rpc(name = "parity_upgradeReady")] fn upgrade_ready(&self) -> Result>; diff --git a/rpc/src/v1/types/dapps.rs b/rpc/src/v1/types/dapps.rs deleted file mode 100644 index 81339fb1dc2..00000000000 --- a/rpc/src/v1/types/dapps.rs +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2015-2018 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -/// Local Dapp -#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct LocalDapp { - /// ID of local dapp - pub id: String, - /// Dapp name - pub name: String, - /// Dapp description - pub description: String, - /// Dapp version string - pub version: String, - /// Dapp author - pub author: String, - /// Dapp icon - #[serde(rename="iconUrl")] - pub icon_url: String, - /// Local development Url - #[serde(rename="localUrl")] - pub local_url: Option, -} - -#[cfg(test)] -mod tests { - use serde_json; - use super::LocalDapp; - - #[test] - fn dapp_serialization() { - let s = r#"{"id":"skeleton","name":"Skeleton","description":"A skeleton dapp","version":"0.1","author":"Parity Technologies Ltd","iconUrl":"title.png","localUrl":"http://localhost:5000"}"#; - - let dapp = LocalDapp { - id: "skeleton".into(), - name: "Skeleton".into(), - description: "A skeleton dapp".into(), - version: "0.1".into(), - author: "Parity Technologies Ltd".into(), - icon_url: "title.png".into(), - local_url: Some("http://localhost:5000".into()), - }; - - let serialized = serde_json::to_string(&dapp).unwrap(); - assert_eq!(serialized, s); - } -} diff --git a/rpc/src/v1/types/mod.rs b/rpc/src/v1/types/mod.rs index 7bf72d9c739..0f21e2f7b5b 100644 --- a/rpc/src/v1/types/mod.rs +++ b/rpc/src/v1/types/mod.rs @@ -23,7 +23,6 @@ mod bytes; mod call_request; mod confirmations; mod consensus_status; -mod dapps; mod derivation; mod filter; mod hash; @@ -57,7 +56,6 @@ pub use self::confirmations::{ TransactionModification, SignRequest, DecryptRequest, Either }; pub use self::consensus_status::*; -pub use self::dapps::LocalDapp; pub use self::derivation::{DeriveHash, DeriveHierarchical, Derive}; pub use self::filter::{Filter, FilterChanges}; pub use self::hash::{H64, H160, H256, H512, H520, H2048};