Web Based Dapps (#3956)
* Dapps web Conflicts: dapps/src/apps/fetcher.rs dapps/src/handlers/fetch.rs * Rewriting fetch * Parity-wide fetch service * Obey the limits and support cancellation. * Removing temporary files. * Actually use Fetch for dapps * Re-implementing file fetching to avoid temporary files. * Serde to 0.8.19 * Fixing content & dapps fetch * Serving web content and injecting scripts * Don't wait for old content, start a new download * Supporting timeouts and query * Simple GUI for the browser * Proxy tokens validation * Recovering from invalid web-based requests * Remember last visisted URL * Removing unused variables * Addressing review comments * Setting default account in web3 * Adding WebBrowser dapp to the list * Actually prune old entries when generating new token
This commit is contained in:
@@ -21,6 +21,7 @@ use ethcore::client::Client;
|
||||
use ethsync::SyncProvider;
|
||||
use helpers::replace_home;
|
||||
use dir::default_data_path;
|
||||
use rpc_apis::SignerService;
|
||||
use hash_fetch::fetch::Client as FetchClient;
|
||||
use parity_reactor::Remote;
|
||||
|
||||
@@ -57,6 +58,7 @@ pub struct Dependencies {
|
||||
pub sync: Arc<SyncProvider>,
|
||||
pub remote: Remote,
|
||||
pub fetch: FetchClient,
|
||||
pub signer: Arc<SignerService>,
|
||||
}
|
||||
|
||||
pub fn new(configuration: Configuration, deps: Dependencies) -> Result<Option<WebappServer>, String> {
|
||||
@@ -64,7 +66,6 @@ pub fn new(configuration: Configuration, deps: Dependencies) -> Result<Option<We
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let signer_address = deps.apis.signer_service.address();
|
||||
let url = format!("{}:{}", configuration.interface, configuration.port);
|
||||
let addr = try!(url.parse().map_err(|_| format!("Invalid Webapps listen host/port given: {}", url)));
|
||||
|
||||
@@ -79,7 +80,7 @@ pub fn new(configuration: Configuration, deps: Dependencies) -> Result<Option<We
|
||||
(username.to_owned(), password)
|
||||
});
|
||||
|
||||
Ok(Some(try!(setup_dapps_server(deps, configuration.dapps_path, &addr, configuration.hosts, auth, signer_address))))
|
||||
Ok(Some(try!(setup_dapps_server(deps, configuration.dapps_path, &addr, configuration.hosts, auth))))
|
||||
}
|
||||
|
||||
pub use self::server::WebappServer;
|
||||
@@ -97,7 +98,6 @@ mod server {
|
||||
_url: &SocketAddr,
|
||||
_allowed_hosts: Option<Vec<String>>,
|
||||
_auth: Option<(String, String)>,
|
||||
_signer_address: Option<(String, u16)>,
|
||||
) -> Result<WebappServer, String> {
|
||||
Err("Your Parity version has been compiled without WebApps support.".into())
|
||||
}
|
||||
@@ -126,7 +126,6 @@ mod server {
|
||||
url: &SocketAddr,
|
||||
allowed_hosts: Option<Vec<String>>,
|
||||
auth: Option<(String, String)>,
|
||||
signer_address: Option<(String, u16)>,
|
||||
) -> Result<WebappServer, String> {
|
||||
use ethcore_dapps as dapps;
|
||||
|
||||
@@ -137,9 +136,12 @@ mod server {
|
||||
);
|
||||
let sync = deps.sync.clone();
|
||||
let client = deps.client.clone();
|
||||
let signer = deps.signer.clone();
|
||||
|
||||
server.with_fetch(deps.fetch.clone());
|
||||
server.with_sync_status(Arc::new(move || is_major_importing(Some(sync.status().state), client.queue_info())));
|
||||
server.with_signer_address(signer_address);
|
||||
server.with_web_proxy_tokens(Arc::new(move |token| signer.is_valid_web_proxy_access_token(&token)));
|
||||
server.with_signer_address(deps.signer.address());
|
||||
|
||||
let server = rpc_apis::setup_rpc(server, deps.apis.clone(), rpc_apis::ApiSet::UnsafeContext);
|
||||
let start_result = match auth {
|
||||
|
||||
@@ -370,6 +370,7 @@ pub fn execute(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger>) -> R
|
||||
sync: sync_provider.clone(),
|
||||
remote: event_loop.remote(),
|
||||
fetch: fetch.clone(),
|
||||
signer: deps_for_rpc_apis.signer_service.clone(),
|
||||
};
|
||||
let dapps_server = try!(dapps::new(cmd.dapps_conf.clone(), dapps_deps));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user