Completely remove all dapps struct from rpc (#9107)

* Completely remove all dapps struct from rpc

* Remove unused pub use
This commit is contained in:
Wei Tang 2018-07-16 19:42:59 +08:00 committed by 5chdn
parent 984674f39e
commit e2ac2db0cd
No known key found for this signature in database
GPG Key ID: 1A40871B597F5F80
16 changed files with 6 additions and 179 deletions

View File

@ -20,7 +20,6 @@ use std::str::FromStr;
use std::sync::{Arc, Weak}; use std::sync::{Arc, Weak};
pub use parity_rpc::signer::SignerService; pub use parity_rpc::signer::SignerService;
pub use parity_rpc::dapps::LocalDapp;
use ethcore_service::PrivateTxService; use ethcore_service::PrivateTxService;
use ethcore::account_provider::AccountProvider; use ethcore::account_provider::AccountProvider;

View File

@ -118,7 +118,7 @@ pub use http::{
AccessControlAllowOrigin, Host, DomainsValidation 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::block_import::is_major_importing;
pub use v1::extractors::{RpcExtractor, WsExtractor, WsStats, WsDispatcher}; pub use v1::extractors::{RpcExtractor, WsExtractor, WsStats, WsDispatcher};
pub use authcodes::{AuthCodes, TimeProvider}; pub use authcodes::{AuthCodes, TimeProvider};

View File

@ -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 <http://www.gnu.org/licenses/>.
//! Dapps Service
use v1::types::LocalDapp;
/// Dapps Server service.
pub trait DappsService: Send + Sync + 'static {
/// List available local dapps.
fn list_dapps(&self) -> Vec<LocalDapp>;
/// Refresh local dapps list
fn refresh_local_dapps(&self) -> bool;
}

View File

@ -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 { pub fn ws_disabled() -> Error {
Error { Error {
code: ErrorCode::ServerError(codes::UNSUPPORTED_REQUEST), code: ErrorCode::ServerError(codes::UNSUPPORTED_REQUEST),

View File

@ -18,7 +18,6 @@
pub mod errors; pub mod errors;
pub mod block_import; pub mod block_import;
pub mod dapps;
pub mod dispatch; pub mod dispatch;
pub mod fake_sign; pub mod fake_sign;
pub mod ipfs; pub mod ipfs;

View File

@ -326,10 +326,6 @@ impl Parity for ParityClient {
Ok(map) Ok(map)
} }
fn dapps_url(&self) -> Result<String> {
Err(errors::dapps_disabled())
}
fn ws_url(&self) -> Result<String> { fn ws_url(&self) -> Result<String> {
helpers::to_url(&self.ws_address) helpers::to_url(&self.ws_address)
.ok_or_else(|| errors::ws_disabled()) .ok_or_else(|| errors::ws_disabled())

View File

@ -29,7 +29,7 @@ use jsonrpc_core::{Result, BoxFuture};
use jsonrpc_core::futures::Future; use jsonrpc_core::futures::Future;
use v1::helpers::errors; use v1::helpers::errors;
use v1::traits::ParitySet; 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. /// Parity-specific rpc interface for operations altering the settings.
pub struct ParitySetClient<F> { pub struct ParitySetClient<F> {
@ -137,14 +137,6 @@ impl<F: Fetch> ParitySet for ParitySetClient<F> {
Box::new(self.pool.spawn(future)) Box::new(self.pool.spawn(future))
} }
fn dapps_refresh(&self) -> Result<bool> {
Err(errors::dapps_disabled())
}
fn dapps_list(&self) -> Result<Vec<LocalDapp>> {
Err(errors::dapps_disabled())
}
fn upgrade_ready(&self) -> Result<Option<ReleaseInfo>> { fn upgrade_ready(&self) -> Result<Option<ReleaseInfo>> {
Err(errors::light_unimplemented(None)) Err(errors::light_unimplemented(None))
} }

View File

@ -347,10 +347,6 @@ impl<C, M, U, S> Parity for ParityClient<C, M, U> where
) )
} }
fn dapps_url(&self) -> Result<String> {
Err(errors::dapps_disabled())
}
fn ws_url(&self) -> Result<String> { fn ws_url(&self) -> Result<String> {
helpers::to_url(&self.ws_address) helpers::to_url(&self.ws_address)
.ok_or_else(|| errors::ws_disabled()) .ok_or_else(|| errors::ws_disabled())

View File

@ -31,7 +31,7 @@ use jsonrpc_core::{BoxFuture, Result};
use jsonrpc_core::futures::Future; use jsonrpc_core::futures::Future;
use v1::helpers::errors; use v1::helpers::errors;
use v1::traits::ParitySet; 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. /// Parity-specific rpc interface for operations altering the settings.
pub struct ParitySetClient<C, M, U, F = fetch::Client> { pub struct ParitySetClient<C, M, U, F = fetch::Client> {
@ -182,14 +182,6 @@ impl<C, M, U, F> ParitySet for ParitySetClient<C, M, U, F> where
Box::new(self.pool.spawn(future)) Box::new(self.pool.spawn(future))
} }
fn dapps_refresh(&self) -> Result<bool> {
Err(errors::dapps_disabled())
}
fn dapps_list(&self) -> Result<Vec<LocalDapp>> {
Err(errors::dapps_disabled())
}
fn upgrade_ready(&self) -> Result<Option<ReleaseInfo>> { fn upgrade_ready(&self) -> Result<Option<ReleaseInfo>> {
Ok(self.updater.upgrade_ready().map(Into::into)) Ok(self.updater.upgrade_ready().map(Into::into))
} }

View File

@ -53,9 +53,3 @@ pub mod signer {
pub use super::helpers::{SigningQueue, SignerService, ConfirmationsQueue}; pub use super::helpers::{SigningQueue, SignerService, ConfirmationsQueue};
pub use super::types::{ConfirmationRequest, TransactionModification, U256, TransactionCondition}; 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;
}

View File

@ -425,20 +425,6 @@ fn rpc_parity_ws_address() {
assert_eq!(io2.handle_request_sync(request), Some(response2.to_owned())); 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] #[test]
fn rpc_parity_next_nonce() { fn rpc_parity_next_nonce() {
let deps = Dependencies::new(); let deps = Dependencies::new();

View File

@ -238,18 +238,3 @@ fn rpc_parity_remove_transaction() {
miner.pending_transactions.lock().insert(hash, signed); miner.pending_transactions.lock().insert(hash, signed);
assert_eq!(io.handle_request_sync(&request), Some(response.to_owned())); 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()));
}

View File

@ -161,11 +161,6 @@ build_rpc_trait! {
#[rpc(name = "parity_localTransactions")] #[rpc(name = "parity_localTransactions")]
fn local_transactions(&self) -> Result<BTreeMap<H256, LocalTransactionStatus>>; fn local_transactions(&self) -> Result<BTreeMap<H256, LocalTransactionStatus>>;
/// 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<String>;
/// Returns current WS Server interface and port or an error if ws server is disabled. /// Returns current WS Server interface and port or an error if ws server is disabled.
#[rpc(name = "parity_wsUrl")] #[rpc(name = "parity_wsUrl")]
fn ws_url(&self) -> Result<String>; fn ws_url(&self) -> Result<String>;

View File

@ -18,7 +18,7 @@
use jsonrpc_core::{BoxFuture, Result}; 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! { build_rpc_trait! {
/// Parity-specific rpc interface for operations altering the settings. /// Parity-specific rpc interface for operations altering the settings.
@ -95,15 +95,6 @@ build_rpc_trait! {
#[rpc(name = "parity_hashContent")] #[rpc(name = "parity_hashContent")]
fn hash_content(&self, String) -> BoxFuture<H256>; fn hash_content(&self, String) -> BoxFuture<H256>;
/// 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<bool>;
/// Returns a list of local dapps (deprecated, should always return an error now).
#[rpc(name = "parity_dappsList")]
fn dapps_list(&self) -> Result<Vec<LocalDapp>>;
/// Is there a release ready for install? /// Is there a release ready for install?
#[rpc(name = "parity_upgradeReady")] #[rpc(name = "parity_upgradeReady")]
fn upgrade_ready(&self) -> Result<Option<ReleaseInfo>>; fn upgrade_ready(&self) -> Result<Option<ReleaseInfo>>;

View File

@ -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 <http://www.gnu.org/licenses/>.
/// 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<String>,
}
#[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);
}
}

View File

@ -23,7 +23,6 @@ mod bytes;
mod call_request; mod call_request;
mod confirmations; mod confirmations;
mod consensus_status; mod consensus_status;
mod dapps;
mod derivation; mod derivation;
mod filter; mod filter;
mod hash; mod hash;
@ -57,7 +56,6 @@ pub use self::confirmations::{
TransactionModification, SignRequest, DecryptRequest, Either TransactionModification, SignRequest, DecryptRequest, Either
}; };
pub use self::consensus_status::*; pub use self::consensus_status::*;
pub use self::dapps::LocalDapp;
pub use self::derivation::{DeriveHash, DeriveHierarchical, Derive}; pub use self::derivation::{DeriveHash, DeriveHierarchical, Derive};
pub use self::filter::{Filter, FilterChanges}; pub use self::filter::{Filter, FilterChanges};
pub use self::hash::{H64, H160, H256, H512, H520, H2048}; pub use self::hash::{H64, H160, H256, H512, H520, H2048};