-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
62f5b49
commit e3f1268
Showing
3 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Staking</title> | ||
<link rel="stylesheet" href="./main.css"> | ||
</head> | ||
<body> | ||
<div id="links" style="text-align: center;font-size: 20px;display: flex;justify-content: space-between;"> | ||
<span class="flexible-filler"></span> | ||
<a href="./index.html">Basics</a> <span class="flexible-filler"></span> | ||
<a href="./zevm.html">zEVM</a> <span class="flexible-filler"></span> | ||
<a href="./zetaclients.html">ZetaClients</a> <span class="flexible-filler"></span> | ||
<a href="./crosschain.html">Cross-Chain Module</a> <span class="flexible-filler"></span> | ||
<a href="./consensus.html">Consensus</a> <span class="flexible-filler"></span> | ||
<a href="./wallet.html">Wallet</a> <span class="flexible-filler"></span> | ||
<a href="./audit.html">Audit</a> | ||
</div> | ||
|
||
<div id="entry"></div> | ||
|
||
<script src="./tag.js"></script> | ||
<script type="module" src="./staking.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { | ||
AddressExplorerByChainID, | ||
bitcoinChainID, | ||
esploraAPIURL, | ||
evmURL, | ||
nodeURL, | ||
RPCByChainID, | ||
externalChainIDs, | ||
makeTableElement2, makeTableElement | ||
} from './common.js'; | ||
import './web3.min.js'; | ||
import {convertbits, decode, encode} from "./bech32.js"; | ||
|
||
|
||
class StakingPage { | ||
constructor() { | ||
} | ||
|
||
async initialize() { | ||
|
||
} | ||
|
||
async render() { | ||
const entry = document.getElementById("entry"); | ||
entry.appendChild(H1("Distribution params")); | ||
const res2 = await fetch(`${nodeURL}/cosmos/distribution/v1beta1/params`); | ||
const data2 = await res2.json(); | ||
console.log("data2", data2); | ||
entry.appendChild(makeTableElement(data2.params)); | ||
|
||
entry.appendChild(H1("Staking Info")); | ||
const res = await fetch(`${nodeURL}/zeta-chain/emissions/list_addresses`); | ||
const addresses = await res.json(); | ||
const rows = []; | ||
for (const name in addresses) { | ||
console.log(name, addresses[name]); | ||
const addr = addresses[name]; | ||
// const res2 = await fetch(`${nodeURL}/cosmos/emissions/show_available_emissions/${addr}`); | ||
const res2 = await fetch(`${nodeURL}/cosmos/bank/v1beta1/balances/${addr}/by_denom?denom=azeta`); | ||
const amount = await res2.json(); | ||
console.log("amount", amount); | ||
rows.push({ | ||
name: name, | ||
address: addr, | ||
amount: `${amount.balance.amount}` | ||
}); | ||
} | ||
entry.appendChild(makeTableElement2(rows, ["name", "address", "amount"])); | ||
|
||
entry.appendChild(H1("Validator Voting Power")); | ||
const res3 = await fetch(`${nodeURL}/cosmos/staking/v1beta1/validators`); | ||
const data = await res3.json(); | ||
console.log("data", data); | ||
const rows2 = []; | ||
for (let i=0; i<data.validators.length; i++) { | ||
const val = data.validators[i]; | ||
const d = decode(val.operator_address, "bech32"); | ||
const a = convertbits(d.data, 5, 8, false); | ||
const valAddress = encode("zeta", convertbits(a, 8, 5, true), "bech32"); | ||
const row = { | ||
"moniker": val.description.moniker, | ||
"address": valAddress, | ||
"jailed": val.jailed, | ||
"status": val.status, | ||
"tokens": parseFloat(val.tokens)/1e18, | ||
"delegator_share": parseFloat(val.delegator_shares)/parseFloat(val.tokens), | ||
"update_time": val.commission.update_time | ||
}; | ||
rows2.push( row); | ||
console.log("val", i, row); | ||
} | ||
rows2.sort((a,b)=>{return -a.tokens+b.tokens;}); | ||
console.log(rows2); | ||
entry.appendChild(makeTableElement2(rows2, ["moniker", "address", "jailed", "status", "tokens", "delegator_share", "update_time"])); | ||
} | ||
} | ||
|
||
|
||
const page = new StakingPage(); | ||
await page.initialize(); | ||
|
||
await page.render(); |