-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathvalidator.html
103 lines (96 loc) · 4.31 KB
/
validator.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">
<title>Pundi AIFX validator</title>
<link rel="icon" type="image/svg+xml" href="favicon.svg">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
</head>
<body>
<div class="container-fluid text-center">
<div class="row">
<table class="table table-striped table-hover">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col" style="text-align: left">Validator</th>
<th scope="col" style="text-align: left">Bonded Tokens</th>
<th scope="col" style="text-align: left">Status</th>
<th scope="col" style="text-align: left">Commission Rates</th>
<th scope="col" style="text-align: left">Missed Blocks</th>
</tr>
</thead>
<tbody id="isSign">
</tbody>
</table>
</div>
</div>
<script src="./js/bech32.js"></script>
<script src="./js/index.js"></script>
<script type="text/javascript">
const validators = getValidators()
const signBody = document.getElementById("isSign")
function update() {
const blockSignatures = getBlockSignatures()
const signInfos = getSigningInfos()
signBody.innerHTML = ''
validators.sort((val1, val2) => {
const a = BigInt(val1.tokens)
const b = BigInt(val2.tokens)
if (a > b) {
return -1;
}
if (a < b) {
return 1;
}
return 0;
}).forEach((validator, index) => {
const signature = blockSignatures[index]
let signInfo = signInfos.find((sign) => {
const address = toHexString(fromWords(getLibraryFromEncoding('bech32').decode(sign.address).words))
return address === signature?.validator_address
})
if (!signInfo && !signature) {
signInfo = {missed_blocks_counter: 0}
}
let color = "text-success"
if (signInfo?.missed_blocks_counter > 10 && signInfo?.missed_blocks_counter < 100) {
color = "text-warning"
} else if (signInfo?.missed_blocks_counter > 100) {
color = "text-danger"
}
if (!signInfo && signature) {
color = "text-danger"
signInfo = {missed_blocks_counter: "No signature block"}
}
const tokens = Number(BigInt(validator.tokens) / BigInt(1e16))
let website = validator.description.website
if (website !== "" && !website.startsWith("http")) {
website = "https://" + website
}
let para = document.createElement('tr');
para.innerHTML = `
<th scope="row">${index + 1}</th>
<td style="text-align: left"><a target="_blank" href="${website}">${validator.description.moniker}</a></td>
<td style="text-align: left">${(tokens / 100).toLocaleString()} FX</td>
<td style="text-align: left">${validator.status === "BOND_STATUS_BONDED" ? "✅" : "❌"} ${validator.jailed ? "(jailed)" : ""}</td>
<td style="text-align: left">${(validator.commission.commission_rates.rate * 100).toFixed(2)}%</td>
<td style="text-align: left"><a target="_blank" href="${getPundiscanUrl()}/fxcore/validator/${validator.operator_address}"><span class="${color}">${signInfo?.missed_blocks_counter}</span></a></td>`
signBody.appendChild(para)
})
}
update()
window.setInterval(function () {
update()
}, 7000);
</script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"
integrity="sha384-Xe+8cL9oJa6tN/veChSP7q+mnSPaj5Bcu9mPX5F5xIGE0DVittaqT5lorf0EI7Vk"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"
integrity="sha384-ODmDIVzN+pFdexxHEHFBQH3/9/vQ9uori45z4JjnFsRydbmQbmL5t1tQ0culUzyK"
crossorigin="anonymous"></script>
</body>
</html>