-
Notifications
You must be signed in to change notification settings - Fork 14
/
test.html
67 lines (58 loc) · 1.91 KB
/
test.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
<!DOCTYPE html>
<head>
<script type="text/javascript" src="umd/akashjs.js"></script>
</head>
<body>
<textarea id="csr"></textarea><br />
<textarea id="publicKey"></textarea><br />
<textarea id="privateKey"></textarea>
<br /><br />
<button id="signBroadcast">Sign and Broadcast Certificate</button>
<button id="getCerts">Get Certs</button>
<script type="text/javascript">
console.log(akjs);
const fn = async () => {
const certs = await akjs.certificate.createCertificate("akash12345");
let chain;
let signer;
let client;
let accounts;
let myAddress;
document.querySelector("#csr").value = certs.csr;
document.querySelector("#publicKey").value = certs.publicKey;
document.querySelector("#privateKey").value = certs.privateKey;
window.addEventListener("DOMContentLoaded", async (event) => {
console.log("DOM fully loaded and parsed");
chain = akjs.keplr.getChains().testnet;
signer = await akjs.keplr.getSigner(chain);
client = await akjs.keplr.get(chain, signer);
accounts = await signer.getAccounts();
myAddress = accounts[0].address;
});
document
.querySelector("#signBroadcast")
.addEventListener("click", async () => {
try {
akjs.certificate.broadcastCertificate(
{ csr: certs.csr, publicKey: certs.publicKey },
myAddress,
client
);
} catch (error) {
console.log(`Akash Transport : ${error.message}`);
}
});
document
.querySelector("#getCerts")
.addEventListener("click", async () => {
const certs = await akjs.certificate.queryCertificates(
akjs.certProto.CertificateFilter.fromJSON({
owner: myAddress,
})
);
console.log(certs);
});
};
fn();
</script>
</body>