Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
[beta] Backports (#8346)
Browse files Browse the repository at this point in the history
* Warp-only sync with warp-barrier [blocknumber] flag. (#8228)

* Warp-only sync with warp-after [blocknumber] flag.

* Fix tests.

* Fix configuration tests.

* Rename to warp barrier.

* Allow unsafe js eval on Parity Wallet. (#8204)

* Update musicoin spec in line with gmc v2.6.2 (#8242)

* Supress TemporaryInvalid verification failures. (#8256)

* Include suicided accounts in state diff (#8297)

* Include suicided accounts in state diff

* Shorten form match -> if let

* Test suicide trace diff in State

* replace_home for password_files, reserved_peers and log_file (#8324)

* replace_home for password_files, reserved_peers and log_file

* typo: arg_log_file is Option

* Enable UI by default, but only display info page.

* Fix test.

* Fix naming and remove old todo.

* Change "wallet" with "browser UI"
  • Loading branch information
tomusdrw authored and 5chdn committed Apr 10, 2018
1 parent 68320e8 commit fc652db
Show file tree
Hide file tree
Showing 25 changed files with 561 additions and 104 deletions.
8 changes: 8 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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" }

Expand Down
49 changes: 27 additions & 22 deletions dapps/src/apps/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ use page;
use proxypac::ProxyPac;
use web::Web;
use fetch::Fetch;
use parity_dapps::WebApp;
use parity_ui;
use {WebProxyTokens, ParentFrameSettings};

mod app;
Expand All @@ -44,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 @@ -76,25 +78,28 @@ pub fn all_endpoints<F: Fetch>(
}

// NOTE [ToDr] Dapps will be currently embeded on 8180
insert::<parity_ui::App>(&mut pages, "ui", Embeddable::Yes(embeddable.clone()), pool.clone());
pages.insert(
"ui".into(),
Box::new(page::builtin::Dapp::new_safe_to_embed(pool.clone(), ::parity_ui::App::default(), embeddable.clone()))
);
// old version
insert::<parity_ui::old::App>(&mut pages, "v1", Embeddable::Yes(embeddable.clone()), pool.clone());

pages.insert("proxy".into(), ProxyPac::boxed(embeddable.clone(), dapps_domain.to_owned()));
pages.insert(WEB_PATH.into(), Web::boxed(embeddable.clone(), web_proxy_tokens.clone(), fetch.clone(), pool.clone()));
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());
// allow JS eval on old Wallet
page.allow_js_eval();
page
})
);
pages.insert(
"proxy".into(),
ProxyPac::boxed(embeddable.clone(), dapps_domain.to_owned())
);
pages.insert(
WEB_PATH.into(),
Web::boxed(embeddable.clone(), web_proxy_tokens.clone(), fetch.clone(), pool.clone())
);

(local_endpoints, pages)
}

fn insert<T : WebApp + Default + 'static>(pages: &mut Endpoints, id: &str, embed_at: Embeddable, pool: CpuPool) {
pages.insert(id.to_owned(), Box::new(match embed_at {
Embeddable::Yes(address) => page::builtin::Dapp::new_safe_to_embed(pool, T::default(), address),
Embeddable::No => page::builtin::Dapp::new(pool, T::default()),
}));
}

enum Embeddable {
Yes(Option<ParentFrameSettings>),
#[allow(dead_code)]
No,
}
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;

Expand Down Expand Up @@ -158,13 +159,31 @@ impl Middleware {
registrar: Arc<ContractClient>,
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
5 changes: 5 additions & 0 deletions dapps/src/page/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ impl<T: WebApp + 'static> Dapp<T> {
fallback_to_index_html: false,
}
}

/// Allow the dapp to use `unsafe-eval` to run JS.
pub fn allow_js_eval(&mut self) {
self.info.allow_js_eval = Some(true);
}
}

impl<T: WebApp> Endpoint for Dapp<T> {
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
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 <[email protected]>"]
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();
}
119 changes: 119 additions & 0 deletions dapps/ui-deprecation/build/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Parity</title>
<style>
/* Copyright 2015-2017 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/>.
*/
:root, :root body {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
background: rgb(95, 95, 95);
color: rgba(255, 255, 255, 0.75);
font-size: 16px;
font-family: 'Roboto', sans-serif;
font-weight: 300;
}

:root a, :root a:visited {
text-decoration: none;
cursor: pointer;
color: rgb(0, 151, 167); /* #f80 */
}

:root a:hover {
color: rgb(0, 174, 193);
}

h1,h2,h3,h4,h5,h6 {
font-weight: 300;
text-transform: uppercase;
text-decoration: none;
}

h1 {
font-size: 24px;
line-height: 36px;
color: rgb(0, 151, 167);
}

h2 {
font-size: 20px;
line-height: 34px;
}

code,kbd,pre,samp {
font-family: 'Roboto Mono', monospace;
}

.parity-navbar {
background: rgb(65, 65, 65);
height: 72px;
padding: 0 1rem;
display: flex;
justify-content: space-between;
}

.parity-status {
clear: both;
padding: 1rem;
margin: 1rem 0;
text-align: right;
opacity: 0.75;
}

.parity-box {
margin: 1rem;
padding: 1rem;
background-color: rgb(48, 48, 48);
box-sizing: border-box;
box-shadow: rgba(0, 0, 0, 0.117647) 0px 1px 6px, rgba(0, 0, 0, 0.117647) 0px 1px 4px;
border-radius: 2px;
z-index: 1;
color: #aaa;
}

.parity-box h1,
.parity-box h2,
.parity-box h3,
.parity-box h4,
.parity-box h5,
.parity-box h6 {
margin: 0;
}
</style>
</head>
<body>
<div class="parity-navbar">
</div>
<div class="parity-box">
<h1>Parity browser UI is deprecated.</h1>
<h3>Get a standalone Parity UI from <a href="https://github.com/Parity-JS/shell/releases">here</a></h3>
<p>

</p>
</div>
<div class="parity-status">
</div>
</body>
</html>
21 changes: 21 additions & 0 deletions dapps/ui-deprecation/src/lib.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/>.

#[cfg(feature = "with-syntex")]
include!(concat!(env!("OUT_DIR"), "/lib.rs"));

#[cfg(not(feature = "with-syntex"))]
include!("lib.rs.in");
Loading

0 comments on commit fc652db

Please sign in to comment.