Skip to content

Commit

Permalink
Merge pull request #3 from paritytech/master
Browse files Browse the repository at this point in the history
Update from parity
  • Loading branch information
EighteenZi authored Apr 13, 2018
2 parents 23947c3 + bc2f558 commit 92ecda6
Show file tree
Hide file tree
Showing 215 changed files with 13,709 additions and 1,286 deletions.
522 changes: 256 additions & 266 deletions Cargo.lock

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ semver = "0.9"
ansi_term = "0.10"
parking_lot = "0.5"
regex = "0.2"
isatty = "0.1"
atty = "0.2.8"
toml = "0.4"
serde = "1.0"
serde_json = "1.0"
Expand All @@ -30,10 +30,8 @@ app_dirs = "1.2.1"
futures = "0.1"
futures-cpupool = "0.1"
fdlimit = "0.1"
ws2_32-sys = "0.2"
ctrlc = { git = "https://github.com/paritytech/rust-ctrlc.git" }
jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.11" }
ethsync = { path = "sync" }
ethcore = { path = "ethcore" }
ethcore-bytes = { path = "util/bytes" }
ethcore-io = { path = "util/io" }
Expand All @@ -42,8 +40,10 @@ ethcore-logger = { path = "logger" }
ethcore-migrations = { path = "ethcore/migrations" }
ethcore-miner = { path = "miner" }
ethcore-network = { path = "util/network" }
ethcore-private-tx = { path = "ethcore/private-tx" }
ethcore-service = { path = "ethcore/service" }
ethcore-stratum = { path = "stratum" }
ethcore-stratum = { path = "ethcore/stratum" }
ethcore-sync = { path = "ethcore/sync" }
ethcore-transaction = { path = "ethcore/transaction" }
ethereum-types = "0.3"
node-filter = { path = "ethcore/node_filter" }
Expand All @@ -68,6 +68,7 @@ migration = { path = "util/migration" }
kvdb = { path = "util/kvdb" }
kvdb-rocksdb = { path = "util/kvdb-rocksdb" }
journaldb = { path = "util/journaldb" }
mem = { path = "util/mem" }

parity-dapps = { path = "dapps", optional = true }
ethcore-secretstore = { path = "secret_store", optional = true }
Expand All @@ -81,9 +82,10 @@ rustc_version = "0.2"
pretty_assertions = "0.1"
ipnetwork = "0.12.6"
tempdir = "0.3"
fake-fetch = { path = "util/fake-fetch" }

[target.'cfg(windows)'.dependencies]
winapi = "0.2"
winapi = { version = "0.3.4", features = ["winsock2", "winuser", "shellapi"] }

[target.'cfg(not(windows))'.dependencies]
daemonize = { git = "https://github.com/paritytech/daemonize" }
Expand Down Expand Up @@ -131,7 +133,8 @@ members = [
"evmbin",
"miner",
"transaction-pool",
"whisper"
"whisper",
"whisper/cli",
]

[patch.crates-io]
Expand Down
1 change: 1 addition & 0 deletions dapps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ node-health = { path = "./node-health" }
parity-hash-fetch = { path = "../hash-fetch" }
parity-reactor = { path = "../util/reactor" }
parity-ui = { path = "./ui" }
parity-ui-deprecation = { path = "./ui-deprecation" }
keccak-hash = { path = "../util/hash" }
parity-version = { path = "../util/version" }
registrar = { path = "../registrar" }
Expand Down
2 changes: 1 addition & 1 deletion dapps/node-health/src/health.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl NodeHealth {
let tx = Arc::new(Mutex::new(Some(tx)));
let tx2 = tx.clone();
self.remote.spawn_with_timeout(
move || time.then(move |result| {
move |_| time.then(move |result| {
let _ = tx.lock().take().expect(PROOF).send(Ok(result));
Ok(())
}),
Expand Down
13 changes: 8 additions & 5 deletions dapps/src/apps/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use page;
use proxypac::ProxyPac;
use web::Web;
use fetch::Fetch;
use parity_ui;
use {WebProxyTokens, ParentFrameSettings};

mod app;
Expand All @@ -43,11 +42,15 @@ pub const WEB_PATH: &'static str = "web";
pub const URL_REFERER: &'static str = "__referer=";

pub fn utils(pool: CpuPool) -> Box<Endpoint> {
Box::new(page::builtin::Dapp::new(pool, parity_ui::App::default()))
Box::new(page::builtin::Dapp::new(pool, ::parity_ui::App::default()))
}

pub fn ui(pool: CpuPool) -> Box<Endpoint> {
Box::new(page::builtin::Dapp::with_fallback_to_index(pool, parity_ui::App::default()))
Box::new(page::builtin::Dapp::with_fallback_to_index(pool, ::parity_ui::App::default()))
}

pub fn ui_deprecation(pool: CpuPool) -> Box<Endpoint> {
Box::new(page::builtin::Dapp::with_fallback_to_index(pool, ::parity_ui_deprecation::App::default()))
}

pub fn ui_redirection(embeddable: Option<ParentFrameSettings>) -> Box<Endpoint> {
Expand Down Expand Up @@ -77,13 +80,13 @@ pub fn all_endpoints<F: Fetch>(
// NOTE [ToDr] Dapps will be currently embeded on 8180
pages.insert(
"ui".into(),
Box::new(page::builtin::Dapp::new_safe_to_embed(pool.clone(), parity_ui::App::default(), embeddable.clone()))
Box::new(page::builtin::Dapp::new_safe_to_embed(pool.clone(), ::parity_ui::App::default(), embeddable.clone()))
);
// old version
pages.insert(
"v1".into(),
Box::new({
let mut page = page::builtin::Dapp::new_safe_to_embed(pool.clone(), parity_ui::old::App::default(), embeddable.clone());
let mut page = page::builtin::Dapp::new_safe_to_embed(pool.clone(), ::parity_ui::old::App::default(), embeddable.clone());
// allow JS eval on old Wallet
page.allow_js_eval();
page
Expand Down
6 changes: 3 additions & 3 deletions dapps/src/handlers/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use fetch::{self, Fetch};
use futures::sync::oneshot;
use futures::{self, Future};
use futures_cpupool::CpuPool;
use hyper::{self, Method, StatusCode};
use hyper::{self, StatusCode};
use parking_lot::Mutex;

use endpoint::{self, EndpointPath};
Expand Down Expand Up @@ -261,7 +261,7 @@ impl ContentFetcherHandler {
// Validation of method
let status = match *method {
// Start fetching content
Method::Get => {
hyper::Method::Get => {
trace!(target: "dapps", "Fetching content from: {:?}", url);
FetchState::InProgress(Self::fetch_content(
pool,
Expand Down Expand Up @@ -295,7 +295,7 @@ impl ContentFetcherHandler {
) -> Box<Future<Item=FetchState, Error=()> + Send> {
// Start fetching the content
let pool2 = pool.clone();
let future = fetch.fetch(url, abort.into()).then(move |result| {
let future = fetch.get(url, abort.into()).then(move |result| {
trace!(target: "dapps", "Fetching content finished. Starting validation: {:?}", result);
Ok(match result {
Ok(response) => match installer.validate_and_install(response) {
Expand Down
19 changes: 19 additions & 0 deletions dapps/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ extern crate node_health;
extern crate parity_dapps_glue as parity_dapps;
extern crate parity_hash_fetch as hash_fetch;
extern crate parity_ui;
extern crate parity_ui_deprecation;
extern crate keccak_hash as hash;
extern crate parity_version;
extern crate registrar;
Expand Down Expand Up @@ -159,13 +160,31 @@ impl Middleware {
registrar: Arc<RegistrarClient<Call=Asynchronous>>,
sync_status: Arc<SyncStatus>,
fetch: F,
info_page_only: bool,
) -> Self {
let content_fetcher = Arc::new(apps::fetcher::ContentFetcher::new(
hash_fetch::urlhint::URLHintContract::new(registrar),
sync_status.clone(),
fetch.clone(),
pool.clone(),
).embeddable_on(None).allow_dapps(false));

if info_page_only {
let mut special = HashMap::default();
special.insert(router::SpecialEndpoint::Home, Some(apps::ui_deprecation(pool.clone())));

return Middleware {
endpoints: Default::default(),
router: router::Router::new(
content_fetcher,
None,
special,
None,
dapps_domain.to_owned(),
),
}
}

let special = {
let mut special = special_endpoints(
pool.clone(),
Expand Down
14 changes: 12 additions & 2 deletions dapps/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,20 @@ impl Router {
}
},
// RPC by default
_ => {
_ if self.special.contains_key(&SpecialEndpoint::Rpc) => {
trace!(target: "dapps", "Resolving to RPC call.");
Response::None(req)
}
},
// 404 otherwise
_ => {
Response::Some(Box::new(future::ok(handlers::ContentHandler::error(
hyper::StatusCode::NotFound,
"404 Not Found",
"Requested content was not found.",
None,
self.embeddable_on.clone(),
).into())))
},
})
}
}
Expand Down
26 changes: 21 additions & 5 deletions dapps/src/tests/helpers/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use std::sync::{atomic, mpsc, Arc};
use parking_lot::Mutex;
use hyper;

use futures::{self, Future};
use fetch::{self, Fetch, Url};
use futures::{self, future, Future};
use fetch::{self, Fetch, Url, Request, Abort};

pub struct FetchControl {
sender: mpsc::Sender<()>,
Expand Down Expand Up @@ -97,9 +97,9 @@ impl FakeFetch {
impl Fetch for FakeFetch {
type Result = Box<Future<Item = fetch::Response, Error = fetch::Error> + Send>;

fn fetch(&self, url: &str, abort: fetch::Abort) -> Self::Result {
let u = Url::parse(url).unwrap();
self.requested.lock().push(url.into());
fn fetch(&self, request: Request, abort: fetch::Abort) -> Self::Result {
let u = request.url().clone();
self.requested.lock().push(u.as_str().into());
let manual = self.manual.clone();
let response = self.response.clone();

Expand All @@ -115,4 +115,20 @@ impl Fetch for FakeFetch {

Box::new(rx.map_err(|_| fetch::Error::Aborted))
}

fn get(&self, url: &str, abort: Abort) -> Self::Result {
let url: Url = match url.parse() {
Ok(u) => u,
Err(e) => return Box::new(future::err(e.into()))
};
self.fetch(Request::get(url), abort)
}

fn post(&self, url: &str, abort: Abort) -> Self::Result {
let url: Url = match url.parse() {
Ok(u) => u,
Err(e) => return Box::new(future::err(e.into()))
};
self.fetch(Request::post(url), abort)
}
}
1 change: 1 addition & 0 deletions dapps/src/tests/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ impl Server {
registrar,
sync_status,
fetch,
false,
)
} else {
Middleware::dapps(
Expand Down
18 changes: 18 additions & 0 deletions dapps/ui-deprecation/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
description = "Parity UI deprecation notice."
name = "parity-ui-deprecation"
version = "1.10.0"
license = "GPL-3.0"
authors = ["Parity Technologies <admin@parity.io>"]
build = "build.rs"

[features]
default = ["with-syntex", "use-precompiled-js"]
use-precompiled-js = ["parity-dapps-glue/use-precompiled-js"]
with-syntex = ["parity-dapps-glue/with-syntex"]

[build-dependencies]
parity-dapps-glue = "1.9"

[dependencies]
parity-dapps-glue = "1.9"
21 changes: 21 additions & 0 deletions dapps/ui-deprecation/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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/>.

extern crate parity_dapps_glue;

fn main() {
parity_dapps_glue::generate();
}
Loading

0 comments on commit 92ecda6

Please sign in to comment.