Skip to content

Instantly share code, notes, and snippets.

@stephancill
Last active January 25, 2023 15:54
Show Gist options
  • Save stephancill/50bff860b683ade0c90d9f5529355d13 to your computer and use it in GitHub Desktop.
Save stephancill/50bff860b683ade0c90d9f5529355d13 to your computer and use it in GitHub Desktop.
Ethereum KZG Ceremony Lobby Size Scriptable Widget
// 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