-
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
8dfd0d9
commit d49e50e
Showing
3 changed files
with
140 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
{{template "layout" .}} {{define "content"}} | ||
<div class="masthead mb-3"> | ||
<div class="container-xxl bd-gutter"> | ||
<div class="col-md-8 mx-auto text-center mt-5"> | ||
<h1 class="mb-3 fw-semibold"> | ||
<span class="d-inline-block blinking">👁</span> Panopticon <span class="d-inline-block blinking">👁</span> | ||
</h1> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="container w-95 border border-5 rounded pb-3"> | ||
<h3 class="text-center"> | ||
ggAVAX <i class="bi bi-info-square" data-bs-toggle="modal" data-bs-target="#infoModal"></i> | ||
</h3> | ||
<div id="ggavax" class="text-center"><div class="loader">Loading...</div></div> | ||
</div> | ||
|
||
<!-- Modal --> | ||
<div class="modal fade" id="infoModal" tabindex="-1"> | ||
<div class="modal-dialog"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h5 class="modal-title" id="exampleModalLabel">ggAVAX Info</h5> | ||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button> | ||
</div> | ||
<div class="modal-body"> | ||
<pre id="infoData"></pre> | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<style> | ||
.container, | ||
.container-lg, | ||
.container-md, | ||
.container-sm, | ||
.container-xl { | ||
max-width: 9140px; | ||
} | ||
</style> | ||
|
||
<script type="module"> | ||
import { DEPLOYMENT } from "/deployments/selected.js"; | ||
import { ggAVAX } from "/js/ggavax.js"; | ||
import { ggAVAXDef } from "/js/tabulator.js"; | ||
|
||
let GGAVAX; | ||
|
||
async function initData() { | ||
GGAVAX = new ggAVAX(DEPLOYMENT); | ||
await GGAVAX.fetchCurrentDelegations(); | ||
} | ||
|
||
await initData(); | ||
|
||
const tableCurrentDelegations = new Tabulator("#ggavax", ggAVAXDef); | ||
|
||
GGAVAX.refreshDataLoop(() => { | ||
tableCurrentDelegations.updateOrAddData(GGAVAX.currentDelegations); | ||
}); | ||
</script> | ||
{{end}} |
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,40 @@ | ||
// Etherjs read-only interface to Rialto Orchestrator | ||
import { formatters, pick } from "/js/utils.js"; | ||
import { DateTime, Interval } from "https://esm.sh/[email protected]"; | ||
|
||
class ggAVAX { | ||
currentDelegations; | ||
|
||
constructor() {} | ||
|
||
async fetchCurrentDelegations() { | ||
const timestamp = Math.floor(Date.now() / 1000); | ||
const response = await fetch( | ||
`https://glacier-api.avax.network/v1/networks/mainnet/blockchains/p-chain/transactions:listStaking?addresses=avax10f8305248c0wsfsdempdtpx7lpkc30vwzl9y9q&txTypes=AddDelegatorTx&startTimestamp=1&endTimestamp=${timestamp}&pageSize=100`, | ||
{ | ||
headers: { | ||
Accept: "application/json", | ||
"Content-Type": "application/json", | ||
"User-Agent": "panopticon.fly.dev", | ||
}, | ||
} | ||
).then((res) => res.json()); | ||
this.currentDelegations = response.transactions; | ||
return this.currentDelegations; | ||
} | ||
|
||
refreshDataLoop(fn) { | ||
const poll = async () => { | ||
await this.fetchCurrentDelegations(); | ||
fn(); | ||
setTimeout(poll, 30000); | ||
}; | ||
poll(); | ||
} | ||
|
||
required() { | ||
throw new Error("Missing argument."); | ||
} | ||
} | ||
|
||
export { ggAVAX }; |
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