Last active
January 25, 2023 15:54
-
-
Save stephancill/50bff860b683ade0c90d9f5529355d13 to your computer and use it in GitHub Desktop.
Ethereum KZG Ceremony Lobby Size Scriptable Widget
This file contains hidden or 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
| // Displays the Ethereum KZG ceremony lobby size | |
| // For use in the Scriptable app | |
| // Author: @stephancill | |
| async function getStatus() { | |
| let url = "https://seq.ceremony.ethereum.org/info/status" | |
| let req = new Request(url) | |
| let data = await req.loadJSON() | |
| return data | |
| } | |
| async function createWidget() { | |
| let widget = new ListWidget() | |
| const {lobby_size: lobbySize} = await getStatus() | |
| let title = "♦ KZG Ceremony" | |
| title.textColor = Color.white() | |
| title.lineLimit = 2 | |
| widget.addText(title) | |
| widget.addSpacer() | |
| addText(`Lobby: ${lobbySize}`, widget) | |
| return widget | |
| } | |
| async function addText(text, listWidget) { | |
| let item = listWidget.addText(text) | |
| item.textColor = Color.white() | |
| item.textOpacity = 0.85 | |
| } | |
| async function main() { | |
| console.log(config) | |
| if (config && config.runsInWidget) { | |
| let widget = await createWidget() | |
| Script.setWidget(widget) | |
| Script.complete() | |
| } else { | |
| const json = await getStatus() | |
| console.log(json) | |
| } | |
| } | |
| main().then() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment