Skip to content

Commit

Permalink
Upgrade to substrate 2.0-alpha-4
Browse files Browse the repository at this point in the history
  • Loading branch information
akru committed Mar 18, 2020
1 parent de07000 commit 4d5fd84
Show file tree
Hide file tree
Showing 15 changed files with 2,314 additions and 2,374 deletions.
3,727 changes: 1,856 additions & 1,871 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions bin/node/browser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
<title>Robonomics Web Node</title>
<title>Robonomics Browser Node</title>
<link rel="shortcut icon" href="/favicon.ico" />
<script type="module">
import { start_client, default as init } from './pkg/node_cli.js';
import ws from './ws.js';

function log(msg) {
document.getElementsByTagName('body')[0].innerHTML += msg + '\n';
Expand All @@ -20,7 +19,7 @@
const chain_spec_text = await chain_spec_response.text();

// Build our client.
let client = await start_client(chain_spec_text, 'debug', ws());
let client = await start_client(chain_spec_text, 'debug');
log('Client started');

client.rpcSubscribe('{"method":"chain_subscribeNewHead","params":[],"id":1,"jsonrpc":"2.0"}',
Expand Down
148 changes: 0 additions & 148 deletions bin/node/browser/ws.js

This file was deleted.

4 changes: 4 additions & 0 deletions bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,7 @@ ros = [
"substrate-ros-api",
"robonomics-ros-api",
]
runtime-benchmarks = [
"robonomics-runtime/runtime-benchmarks",
"ipci-runtime/runtime-benchmarks",
]
29 changes: 15 additions & 14 deletions bin/node/cli/src/browser.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
///////////////////////////////////////////////////////////////////////////////
//
// Copyright 2018-2020 Airalab <[email protected]>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -12,43 +15,41 @@
// limitations under the License.
//
///////////////////////////////////////////////////////////////////////////////
use log::info;
use std::str::FromStr;

use crate::{IsIpci, chain_spec::ChainSpec};
use wasm_bindgen::prelude::*;
use sc_service::Configuration;
use browser_utils::{
Transport, Client,
Client,
browser_configuration, set_console_error_panic_hook, init_console_log,
};
use crate::{IsIpci, chain_spec::ChainSpec};
use std::str::FromStr;
use log::info;

/// Starts the client.
#[wasm_bindgen]
pub async fn start_client(chain_spec: String, log_level: String, wasm_ext: Transport) -> Result<Client, JsValue> {
start_inner(chain_spec, log_level, wasm_ext)
pub async fn start_client(chain_spec: String, log_level: String) -> Result<Client, JsValue> {
start_inner(chain_spec, log_level)
.await
.map_err(|err| JsValue::from_str(&err.to_string()))
}

async fn start_inner(chain_spec: String, log_level: String, wasm_ext: Transport) -> Result<Client, Box<dyn std::error::Error>> {
async fn start_inner(chain_spec: String, log_level: String) -> Result<Client, Box<dyn std::error::Error>> {
set_console_error_panic_hook();
init_console_log(log::Level::from_str(&log_level)?)?;
let chain_spec = ChainSpec::from_json_bytes(chain_spec.as_bytes().to_vec())
.map_err(|e| format!("{:?}", e))?;

let config: Configuration<_, _> = browser_configuration(wasm_ext, chain_spec)
.await?;
let config = browser_configuration(chain_spec).await?;

info!("Robonomics Web Node");
info!("Robonomics browser node");
info!(" version {}", config.full_version());
info!(" by Airalab <[email protected]>, 2018-2020");
info!(" by Airalab, 2018-2020");
info!("Chain specification: {}", config.expect_chain_spec().name());
info!("Node name: {}", config.name);
info!("Roles: {:?}", config.roles);

let is_ipci = config.chain_spec.as_ref().map_or(false, |s| s.is_ipci());
// Create the service. This is the most heavy initialization step.
if is_ipci {
if config.expect_chain_spec().is_ipci() {
let service = crate::service::new_ipci_light(config)
.map_err(|e| format!("{:?}", e))?;
Ok(browser_utils::start_client(service))
Expand Down
Loading

0 comments on commit 4d5fd84

Please sign in to comment.