-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlight.html
103 lines (83 loc) · 3.06 KB
/
light.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Test Page for Polkadot JS Bundle with Light Client</title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<!-- Custom styles for this template -->
<style>
/* Sticky footer styles
-------------------------------------------------- */
html {
position: relative;
min-height: 100%;
}
body {
/* Margin bottom by footer height */
margin-bottom: 60px;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
/* Set the fixed height of the footer here */
height: 60px;
/* Vertically center the text there */
line-height: 60px;
background-color: #f5f5f5;
}
/* Custom page CSS
-------------------------------------------------- */
/* Not required for template or sticky footer method. */
.container {
width: auto;
max-width: 680px;
padding: 0 15px;
}
</style>
</head>
<body>
<!-- Begin page content -->
<main role="main" class="container">
<h1 class="mt-5">Test Page for Polkadot JS Bundle with Light Client</h1>
<p class="lead">This page simply tests that the <code>polkadot{JS}</code> bundles are working with a light
client.</p>
<p class="lead">Swith to a <a href="./index.html">regular RPC node.</a></p>
<p></p><code id="code"></code></p>
<p id="version"></p>
<p>Polkadot Block: <span id="polkadot-block">Not Connected</span></p>
</main>
<footer class="footer">
<div class="container">
<span class="text-center text-muted">Created by <a href="http://shawntabrizi.com">Shawn Tabrizi</a> - Source
on <a href="https://github.com/shawntabrizi/polkadot-js-bundle">GitHub</a> - <a
href="http://shawntabrizi.com/substrate/porting-web3-js-to-polkadot-js/">Blog Post</a> - Using <a
href="https://github.com/polkadot-js/api/">Polkadot.js</a>
</span>
</div>
</footer>
<script src="//unpkg.com/@polkadot/util/bundle-polkadot-util.js"></script>
<script src="//unpkg.com/@polkadot/util-crypto/bundle-polkadot-util-crypto.js"></script>
<script src="//unpkg.com/@polkadot/types/bundle-polkadot-types.js"></script>
<script src="//unpkg.com/@polkadot/api/bundle-polkadot-api.js"></script>
<script>
async function testConnect() {
const { ApiPromise, ScProvider } = polkadotApi;
const { WellKnownChain } = ScProvider;
const provider = new ScProvider(WellKnownChain.polkadot);
provider.connect()
const polkadotLight = await ApiPromise.create({ provider });
document.getElementById("version").innerText = polkadotLight.libraryInfo;
let polkadotLightBlock = document.getElementById("polkadot-block");
polkadotLight.derive.chain.subscribeNewHeads((header) => {
polkadotLightBlock.innerText = header.number;
});
}
testConnect();
document.getElementById("code").innerText = testConnect.toString()
</script>
</body>
</html>