Beta backports (#4462)
* Support HTML5-routed dapps (#4173) * Fix compilation on latest nightly * Updating precompiled
This commit is contained in:
parent
8764563222
commit
449e85743d
6
Cargo.lock
generated
6
Cargo.lock
generated
@ -1533,7 +1533,7 @@ name = "parity-ui"
|
|||||||
version = "1.5.0"
|
version = "1.5.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"parity-ui-dev 1.4.0",
|
"parity-ui-dev 1.4.0",
|
||||||
"parity-ui-precompiled 1.4.0 (git+https://github.com/ethcore/js-precompiled.git)",
|
"parity-ui-precompiled 1.4.0 (git+https://github.com/ethcore/js-precompiled.git?branch=beta)",
|
||||||
"rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -1547,7 +1547,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "parity-ui-precompiled"
|
name = "parity-ui-precompiled"
|
||||||
version = "1.4.0"
|
version = "1.4.0"
|
||||||
source = "git+https://github.com/ethcore/js-precompiled.git#a590186c6acf75e31b7cff259721793960ded4e1"
|
source = "git+https://github.com/ethcore/js-precompiled.git?branch=beta#46942acf631743e844a4d8d051067c8e40534731"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"parity-dapps-glue 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parity-dapps-glue 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
@ -2534,7 +2534,7 @@ dependencies = [
|
|||||||
"checksum openssl-sys 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d2845e841700e7b04282ceaa115407ea84e0db918ae689ad9ceb6f06fa6046bd"
|
"checksum openssl-sys 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d2845e841700e7b04282ceaa115407ea84e0db918ae689ad9ceb6f06fa6046bd"
|
||||||
"checksum owning_ref 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8d91377085359426407a287ab16884a0111ba473aa6844ff01d4ec20ce3d75e7"
|
"checksum owning_ref 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8d91377085359426407a287ab16884a0111ba473aa6844ff01d4ec20ce3d75e7"
|
||||||
"checksum parity-dapps-glue 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "98378dec0a185da2b7180308752f0bad73aaa949c3e0a3b0528d0e067945f7ab"
|
"checksum parity-dapps-glue 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "98378dec0a185da2b7180308752f0bad73aaa949c3e0a3b0528d0e067945f7ab"
|
||||||
"checksum parity-ui-precompiled 1.4.0 (git+https://github.com/ethcore/js-precompiled.git)" = "<none>"
|
"checksum parity-ui-precompiled 1.4.0 (git+https://github.com/ethcore/js-precompiled.git?branch=beta)" = "<none>"
|
||||||
"checksum parking_lot 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "e1435e7a2a00dfebededd6c6bdbd54008001e94b4a2aadd6aef0dc4c56317621"
|
"checksum parking_lot 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "e1435e7a2a00dfebededd6c6bdbd54008001e94b4a2aadd6aef0dc4c56317621"
|
||||||
"checksum parking_lot_core 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fb1b97670a2ffadce7c397fb80a3d687c4f3060140b885621ef1653d0e5d5068"
|
"checksum parking_lot_core 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fb1b97670a2ffadce7c397fb80a3d687c4f3060140b885621ef1653d0e5d5068"
|
||||||
"checksum phf 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)" = "447d9d45f2e0b4a9b532e808365abf18fc211be6ca217202fcd45236ef12f026"
|
"checksum phf 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)" = "447d9d45f2e0b4a9b532e808365abf18fc211be6ca217202fcd45236ef12f026"
|
||||||
|
@ -38,6 +38,7 @@ pub const RPC_PATH: &'static str = "rpc";
|
|||||||
pub const API_PATH: &'static str = "api";
|
pub const API_PATH: &'static str = "api";
|
||||||
pub const UTILS_PATH: &'static str = "parity-utils";
|
pub const UTILS_PATH: &'static str = "parity-utils";
|
||||||
pub const WEB_PATH: &'static str = "web";
|
pub const WEB_PATH: &'static str = "web";
|
||||||
|
pub const URL_REFERER: &'static str = "__referer=";
|
||||||
|
|
||||||
pub fn utils() -> Box<Endpoint> {
|
pub fn utils() -> Box<Endpoint> {
|
||||||
Box::new(PageEndpoint::with_prefix(parity_ui::App::default(), UTILS_PATH.to_owned()))
|
Box::new(PageEndpoint::with_prefix(parity_ui::App::default(), UTILS_PATH.to_owned()))
|
||||||
|
@ -56,7 +56,6 @@ pub struct Router<A: Authorization + 'static> {
|
|||||||
impl<A: Authorization + 'static> server::Handler<HttpStream> for Router<A> {
|
impl<A: Authorization + 'static> server::Handler<HttpStream> for Router<A> {
|
||||||
|
|
||||||
fn on_request(&mut self, req: server::Request<HttpStream>) -> Next {
|
fn on_request(&mut self, req: server::Request<HttpStream>) -> Next {
|
||||||
|
|
||||||
// Choose proper handler depending on path / domain
|
// Choose proper handler depending on path / domain
|
||||||
let url = handlers::extract_url(&req);
|
let url = handlers::extract_url(&req);
|
||||||
let endpoint = extract_endpoint(&url);
|
let endpoint = extract_endpoint(&url);
|
||||||
@ -92,8 +91,7 @@ impl<A: Authorization + 'static> server::Handler<HttpStream> for Router<A> {
|
|||||||
self.handler = match (endpoint.0, endpoint.1, referer) {
|
self.handler = match (endpoint.0, endpoint.1, referer) {
|
||||||
// Handle invalid web requests that we can recover from
|
// Handle invalid web requests that we can recover from
|
||||||
(ref path, SpecialEndpoint::None, Some((ref referer, ref referer_url)))
|
(ref path, SpecialEndpoint::None, Some((ref referer, ref referer_url)))
|
||||||
if is_get_request
|
if referer.app_id == apps::WEB_PATH
|
||||||
&& referer.app_id == apps::WEB_PATH
|
|
||||||
&& self.endpoints.contains_key(apps::WEB_PATH)
|
&& self.endpoints.contains_key(apps::WEB_PATH)
|
||||||
&& !is_web_endpoint(path)
|
&& !is_web_endpoint(path)
|
||||||
=>
|
=>
|
||||||
@ -225,10 +223,28 @@ fn extract_referer_endpoint(req: &server::Request<HttpStream>) -> Option<(Endpoi
|
|||||||
let url = referer.and_then(|referer| Url::parse(&referer.0).ok());
|
let url = referer.and_then(|referer| Url::parse(&referer.0).ok());
|
||||||
url.and_then(|url| {
|
url.and_then(|url| {
|
||||||
let option = Some(url);
|
let option = Some(url);
|
||||||
extract_endpoint(&option).0.map(|endpoint| (endpoint, option.expect("Just wrapped; qed")))
|
extract_url_referer_endpoint(&option).or_else(|| {
|
||||||
|
extract_endpoint(&option).0.map(|endpoint| (endpoint, option.expect("Just wrapped; qed")))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn extract_url_referer_endpoint(url: &Option<Url>) -> Option<(EndpointPath, Url)> {
|
||||||
|
let query = url.as_ref().and_then(|url| url.query.as_ref());
|
||||||
|
match (url, query) {
|
||||||
|
(&Some(ref url), Some(ref query)) if query.starts_with(apps::URL_REFERER) => {
|
||||||
|
let referer_url = format!("http://{}:{}/{}", url.host, url.port, &query[apps::URL_REFERER.len()..]);
|
||||||
|
debug!(target: "dapps", "Recovering referer from query parameter: {}", referer_url);
|
||||||
|
|
||||||
|
let referer_url = Url::parse(&referer_url).ok();
|
||||||
|
extract_endpoint(&referer_url).0.map(|endpoint| {
|
||||||
|
(endpoint, referer_url.expect("Endpoint returned only when url `is_some`").clone())
|
||||||
|
})
|
||||||
|
},
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn extract_endpoint(url: &Option<Url>) -> (Option<EndpointPath>, SpecialEndpoint) {
|
fn extract_endpoint(url: &Option<Url>) -> (Option<EndpointPath>, SpecialEndpoint) {
|
||||||
fn special_endpoint(url: &Url) -> SpecialEndpoint {
|
fn special_endpoint(url: &Url) -> SpecialEndpoint {
|
||||||
if url.path.len() <= 1 {
|
if url.path.len() <= 1 {
|
||||||
|
@ -68,6 +68,7 @@ impl<F: Fetch> Endpoint for Web<F> {
|
|||||||
|
|
||||||
struct WebInstaller {
|
struct WebInstaller {
|
||||||
embeddable_on: Embeddable,
|
embeddable_on: Embeddable,
|
||||||
|
referer: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ContentValidator for WebInstaller {
|
impl ContentValidator for WebInstaller {
|
||||||
@ -84,7 +85,12 @@ impl ContentValidator for WebInstaller {
|
|||||||
self.embeddable_on.clone(),
|
self.embeddable_on.clone(),
|
||||||
);
|
);
|
||||||
if is_html {
|
if is_html {
|
||||||
handler.set_initial_content(&format!(r#"<script src="/{}/inject.js"></script>"#, apps::UTILS_PATH));
|
handler.set_initial_content(&format!(
|
||||||
|
r#"<script src="/{}/inject.js"></script><script>history.replaceState({{}}, "", "/?{}{}")</script>"#,
|
||||||
|
apps::UTILS_PATH,
|
||||||
|
apps::URL_REFERER,
|
||||||
|
&self.referer,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
Ok(ValidatorResponse::Streaming(handler))
|
Ok(ValidatorResponse::Streaming(handler))
|
||||||
}
|
}
|
||||||
@ -108,7 +114,7 @@ struct WebHandler<F: Fetch> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<F: Fetch> WebHandler<F> {
|
impl<F: Fetch> WebHandler<F> {
|
||||||
fn extract_target_url(&self, url: Option<Url>) -> Result<String, State<F>> {
|
fn extract_target_url(&self, url: Option<Url>) -> Result<(String, String), State<F>> {
|
||||||
let (path, query) = match url {
|
let (path, query) = match url {
|
||||||
Some(url) => (url.path, url.query),
|
Some(url) => (url.path, url.query),
|
||||||
None => {
|
None => {
|
||||||
@ -157,7 +163,7 @@ impl<F: Fetch> WebHandler<F> {
|
|||||||
None => "".into(),
|
None => "".into(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(format!("{}://{}{}", protocol, path[idx + 2..].join("/"), query))
|
Ok((format!("{}://{}{}", protocol, path[idx + 2..].join("/"), query), path[0..].join("/")))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +172,7 @@ impl<F: Fetch> server::Handler<net::HttpStream> for WebHandler<F> {
|
|||||||
let url = extract_url(&request);
|
let url = extract_url(&request);
|
||||||
|
|
||||||
// First extract the URL (reject invalid URLs)
|
// First extract the URL (reject invalid URLs)
|
||||||
let target_url = match self.extract_target_url(url) {
|
let (target_url, referer) = match self.extract_target_url(url) {
|
||||||
Ok(url) => url,
|
Ok(url) => url,
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
self.state = error;
|
self.state = error;
|
||||||
@ -180,6 +186,7 @@ impl<F: Fetch> server::Handler<net::HttpStream> for WebHandler<F> {
|
|||||||
self.control.clone(),
|
self.control.clone(),
|
||||||
WebInstaller {
|
WebInstaller {
|
||||||
embeddable_on: self.embeddable_on.clone(),
|
embeddable_on: self.embeddable_on.clone(),
|
||||||
|
referer: referer,
|
||||||
},
|
},
|
||||||
self.embeddable_on.clone(),
|
self.embeddable_on.clone(),
|
||||||
self.remote.clone(),
|
self.remote.clone(),
|
||||||
|
@ -11,7 +11,7 @@ rustc_version = "0.1"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
parity-ui-dev = { path = "../../js", optional = true }
|
parity-ui-dev = { path = "../../js", optional = true }
|
||||||
parity-ui-precompiled = { git = "https://github.com/ethcore/js-precompiled.git", optional = true }
|
parity-ui-precompiled = { git = "https://github.com/ethcore/js-precompiled.git", branch = "beta", optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
no-precompiled-js = ["parity-ui-dev"]
|
no-precompiled-js = ["parity-ui-dev"]
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
//! Trace database.
|
//! Trace database.
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::collections::HashMap;
|
use std::collections::{HashMap, VecDeque};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use bloomchain::{Number, Config as BloomConfig};
|
use bloomchain::{Number, Config as BloomConfig};
|
||||||
use bloomchain::group::{BloomGroupDatabase, BloomGroupChain, GroupPosition, BloomGroup};
|
use bloomchain::group::{BloomGroupDatabase, BloomGroupChain, GroupPosition, BloomGroup};
|
||||||
@ -305,7 +305,7 @@ impl<T> TraceDatabase for TraceDB<T> where T: DatabaseExtras {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn trace(&self, block_number: BlockNumber, tx_position: usize, trace_position: Vec<usize>) -> Option<LocalizedTrace> {
|
fn trace(&self, block_number: BlockNumber, tx_position: usize, trace_position: Vec<usize>) -> Option<LocalizedTrace> {
|
||||||
let trace_position_deq = trace_position.into_iter().collect();
|
let trace_position_deq = trace_position.into_iter().collect::<VecDeque<usize>>();
|
||||||
self.extras.block_hash(block_number)
|
self.extras.block_hash(block_number)
|
||||||
.and_then(|block_hash| self.transactions_traces(&block_hash)
|
.and_then(|block_hash| self.transactions_traces(&block_hash)
|
||||||
.and_then(|traces| traces.into_iter().nth(tx_position))
|
.and_then(|traces| traces.into_iter().nth(tx_position))
|
||||||
|
Loading…
Reference in New Issue
Block a user