mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 20:27:58 +00:00
40 lines
1.1 KiB
HTML
40 lines
1.1 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
|
|
<title>Substrate node</title>
|
|
<link rel="shortcut icon" href="/favicon.png" />
|
|
<script type="module">
|
|
import { start_client, default as init } from './pkg/node_cli.js';
|
|
|
|
function log(msg) {
|
|
document.getElementsByTagName('body')[0].innerHTML += msg + '\n';
|
|
}
|
|
|
|
async function start() {
|
|
log('Loading WASM');
|
|
await init('./pkg/node_cli_bg.wasm');
|
|
log('Fetching chain spec');
|
|
const chain_spec_response = await fetch("https://raw.githubusercontent.com/paritytech/substrate/master/bin/node/cli/res/flaming-fir.json");
|
|
const chain_spec_text = await chain_spec_response.text();
|
|
|
|
// Build our client.
|
|
let client = await start_client(chain_spec_text, 'info');
|
|
log('Client started');
|
|
|
|
client.rpcSubscribe('{"method":"chain_subscribeNewHead","params":[],"id":1,"jsonrpc":"2.0"}',
|
|
(r) => log("New chain head: " + r));
|
|
|
|
setInterval(() => {
|
|
client
|
|
.rpcSend('{"method":"system_localPeerId","params":[],"id":1,"jsonrpc":"2.0"}')
|
|
.then((r) => log("Local PeerId: " + r));
|
|
}, 20000);
|
|
}
|
|
|
|
start();
|
|
</script>
|
|
</head>
|
|
<body style="white-space: pre"></body>
|
|
</html>
|