Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cli/browser-demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<link rel="shortcut icon" href="/favicon.png" />
<script type="module">
import { start_client, default as init } from './pkg/polkadot_cli.js';
import ws from './ws.js';

function log(msg) {
document.getElementsByTagName('body')[0].innerHTML += msg + '\n';
Expand All @@ -19,7 +18,7 @@

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

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

This file was deleted.

8 changes: 4 additions & 4 deletions cli/src/browser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ use service::IsKusama;
///
/// You must pass a libp2p transport that supports .
#[wasm_bindgen]
pub async fn start_client(chain_spec: String, wasm_ext: browser_utils::Transport) -> Result<browser_utils::Client, JsValue> {
start_inner(chain_spec, wasm_ext)
pub async fn start_client(chain_spec: String) -> Result<browser_utils::Client, JsValue> {
start_inner(chain_spec)
.await
.map_err(|err| JsValue::from_str(&err.to_string()))
}

async fn start_inner(chain_spec: String, wasm_ext: browser_utils::Transport) -> Result<browser_utils::Client, Box<dyn std::error::Error>> {
async fn start_inner(chain_spec: String) -> Result<browser_utils::Client, Box<dyn std::error::Error>> {
browser_utils::set_console_error_panic_hook();
browser_utils::init_console_log(log::Level::Info)?;

let chain_spec = ChainSpec::from(&chain_spec)
.ok_or_else(|| format!("Chain spec: {:?} doesn't exist.", chain_spec))?
.load()
.map_err(|e| format!("{:?}", e))?;
let config = browser_utils::browser_configuration(wasm_ext, chain_spec)
let config = browser_utils::browser_configuration(chain_spec)
.await?;

info!("Polkadot browser node");
Expand Down