Added mini gerty api support to front end
This commit is contained in:
parent
592a52e9a2
commit
b2e2c11af8
3 changed files with 137 additions and 99 deletions
|
|
@ -13,7 +13,7 @@ def get_percent_difference(current, previous, precision=4):
|
||||||
|
|
||||||
|
|
||||||
# A helper function get a nicely formated dict for the text
|
# A helper function get a nicely formated dict for the text
|
||||||
def get_text_item_dict(text: str, font_size: int, x_pos: int = None, y_pos: int = None):
|
def get_text_item_dict(text: str, font_size: int, x_pos: int = None, y_pos: int = None, gerty_type: str = 'Gerty'):
|
||||||
# Get line size by font size
|
# Get line size by font size
|
||||||
line_width = 20
|
line_width = 20
|
||||||
if font_size <= 12:
|
if font_size <= 12:
|
||||||
|
|
@ -25,6 +25,19 @@ def get_text_item_dict(text: str, font_size: int, x_pos: int = None, y_pos: int
|
||||||
elif font_size <= 40:
|
elif font_size <= 40:
|
||||||
line_width = 25
|
line_width = 25
|
||||||
|
|
||||||
|
# Get font sizes for Gerty mini
|
||||||
|
if(gerty_type.lower() == 'mini gerty'):
|
||||||
|
if font_size <= 15:
|
||||||
|
font_size = 2
|
||||||
|
elif font_size <= 20:
|
||||||
|
font_size = 3
|
||||||
|
elif font_size <= 40:
|
||||||
|
font_size = 4
|
||||||
|
else:
|
||||||
|
font_size = 5
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# wrap the text
|
# wrap the text
|
||||||
wrapper = textwrap.TextWrapper(width=line_width)
|
wrapper = textwrap.TextWrapper(width=line_width)
|
||||||
word_list = wrapper.wrap(text=text)
|
word_list = wrapper.wrap(text=text)
|
||||||
|
|
@ -68,18 +81,18 @@ async def get_mining_dashboard(gerty):
|
||||||
hashrateOneWeekAgo = data["hashrates"][6]["avgHashrate"]
|
hashrateOneWeekAgo = data["hashrates"][6]["avgHashrate"]
|
||||||
|
|
||||||
text = []
|
text = []
|
||||||
text.append(get_text_item_dict("Current mining hashrate", 12))
|
text.append(get_text_item_dict(text="Current mining hashrate", font_size=12,gerty_type=gerty.type))
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict(
|
get_text_item_dict(
|
||||||
"{0}hash".format(si_format(hashrateNow, 6, True, " ")), 20
|
text="{0}hash".format(si_format(hashrateNow, 6, True, " ")), font_size=20,gerty_type=gerty.type
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict(
|
get_text_item_dict(
|
||||||
"{0} vs 7 days ago".format(
|
text="{0} vs 7 days ago".format(
|
||||||
get_percent_difference(hashrateNow, hashrateOneWeekAgo, 3)
|
get_percent_difference(hashrateNow, hashrateOneWeekAgo, 3)
|
||||||
),
|
),
|
||||||
12,
|
font_size=12,gerty_type=gerty.type
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
@ -91,27 +104,27 @@ async def get_mining_dashboard(gerty):
|
||||||
# timeAvg
|
# timeAvg
|
||||||
text = []
|
text = []
|
||||||
progress = "{0}%".format(round(r.json()["progressPercent"], 2))
|
progress = "{0}%".format(round(r.json()["progressPercent"], 2))
|
||||||
text.append(get_text_item_dict("Progress through current epoch", 12))
|
text.append(get_text_item_dict(text="Progress through current epoch", font_size=12,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict(progress, 60))
|
text.append(get_text_item_dict(text=progress, font_size=60,gerty_type=gerty.type))
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
||||||
# difficulty adjustment
|
# difficulty adjustment
|
||||||
text = []
|
text = []
|
||||||
stat = r.json()["remainingTime"]
|
stat = r.json()["remainingTime"]
|
||||||
text.append(get_text_item_dict("Time to next difficulty adjustment", 12))
|
text.append(get_text_item_dict(text="Time to next difficulty adjustment", font_size=12,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict(get_time_remaining(stat / 1000, 3), 12))
|
text.append(get_text_item_dict(text=get_time_remaining(stat / 1000, 3), font_size=12,gerty_type=gerty.type))
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
||||||
# difficultyChange
|
# difficultyChange
|
||||||
text = []
|
text = []
|
||||||
difficultyChange = round(r.json()["difficultyChange"], 2)
|
difficultyChange = round(r.json()["difficultyChange"], 2)
|
||||||
text.append(get_text_item_dict("Estimated difficulty change", 12))
|
text.append(get_text_item_dict(text="Estimated difficulty change", font_size=12,gerty_type=gerty.type))
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict(
|
get_text_item_dict(
|
||||||
"{0}{1}%".format(
|
text="{0}{1}%".format(
|
||||||
"+" if difficultyChange > 0 else "", round(difficultyChange, 2)
|
"+" if difficultyChange > 0 else "", round(difficultyChange, 2)
|
||||||
),
|
),
|
||||||
60,
|
font_size=60,gerty_type=gerty.type
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
@ -142,49 +155,49 @@ async def get_lightning_stats(gerty):
|
||||||
areas = []
|
areas = []
|
||||||
|
|
||||||
text = []
|
text = []
|
||||||
text.append(get_text_item_dict("Channel Count", 12))
|
text.append(get_text_item_dict(text="Channel Count", font_size=12, gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict(format_number(data["latest"]["channel_count"]), 20))
|
text.append(get_text_item_dict(text=format_number(data["latest"]["channel_count"]), font_size=20, gerty_type=gerty.type))
|
||||||
difference = get_percent_difference(
|
difference = get_percent_difference(
|
||||||
current=data["latest"]["channel_count"],
|
current=data["latest"]["channel_count"],
|
||||||
previous=data["previous"]["channel_count"],
|
previous=data["previous"]["channel_count"],
|
||||||
)
|
)
|
||||||
text.append(get_text_item_dict("{0} in last 7 days".format(difference), 12))
|
text.append(get_text_item_dict(text="{0} in last 7 days".format(difference), font_size=12, gerty_type=gerty.type))
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
||||||
text = []
|
text = []
|
||||||
text.append(get_text_item_dict("Number of Nodes", 12))
|
text.append(get_text_item_dict(text="Number of Nodes", font_size=12,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict(format_number(data["latest"]["node_count"]), 20))
|
text.append(get_text_item_dict(text=format_number(data["latest"]["node_count"]), font_size=20,gerty_type=gerty.type))
|
||||||
difference = get_percent_difference(
|
difference = get_percent_difference(
|
||||||
current=data["latest"]["node_count"], previous=data["previous"]["node_count"]
|
current=data["latest"]["node_count"], previous=data["previous"]["node_count"]
|
||||||
)
|
)
|
||||||
text.append(get_text_item_dict("{0} in last 7 days".format(difference), 12))
|
text.append(get_text_item_dict(text="{0} in last 7 days".format(difference), font_size=12,gerty_type=gerty.type))
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
||||||
text = []
|
text = []
|
||||||
text.append(get_text_item_dict("Total Capacity", 12))
|
text.append(get_text_item_dict(text="Total Capacity", font_size=12,gerty_type=gerty.type))
|
||||||
avg_capacity = float(data["latest"]["total_capacity"]) / float(100000000)
|
avg_capacity = float(data["latest"]["total_capacity"]) / float(100000000)
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict("{0} BTC".format(format_number(avg_capacity, 2)), 20)
|
get_text_item_dict(text="{0} BTC".format(format_number(avg_capacity, 2)), font_size=20,gerty_type=gerty.type)
|
||||||
)
|
)
|
||||||
difference = get_percent_difference(
|
difference = get_percent_difference(
|
||||||
current=data["latest"]["total_capacity"],
|
current=data["latest"]["total_capacity"],
|
||||||
previous=data["previous"]["total_capacity"],
|
previous=data["previous"]["total_capacity"],
|
||||||
)
|
)
|
||||||
text.append(get_text_item_dict("{0} in last 7 days".format(difference), 12))
|
text.append(get_text_item_dict(text="{0} in last 7 days".format(difference), font_size=12,gerty_type=gerty.type))
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
||||||
text = []
|
text = []
|
||||||
text.append(get_text_item_dict("Average Channel Capacity", 12))
|
text.append(get_text_item_dict(text="Average Channel Capacity", font_size=12,gerty_type=gerty.type))
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict(
|
get_text_item_dict(
|
||||||
"{0} sats".format(format_number(data["latest"]["avg_capacity"])), 20
|
text="{0} sats".format(format_number(data["latest"]["avg_capacity"])), font_size=20,gerty_type=gerty.type
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
difference = get_percent_difference(
|
difference = get_percent_difference(
|
||||||
current=data["latest"]["avg_capacity"],
|
current=data["latest"]["avg_capacity"],
|
||||||
previous=data["previous"]["avg_capacity"],
|
previous=data["previous"]["avg_capacity"],
|
||||||
)
|
)
|
||||||
text.append(get_text_item_dict("{0} in last 7 days".format(difference), 12))
|
text.append(get_text_item_dict(text="{0} in last 7 days".format(difference), font_size=12, gerty_type=gerty.type))
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
||||||
return areas
|
return areas
|
||||||
|
|
@ -247,17 +260,17 @@ async def get_mining_stat(stat_slug: str, gerty):
|
||||||
stat = await api_get_mining_stat(stat_slug, gerty)
|
stat = await api_get_mining_stat(stat_slug, gerty)
|
||||||
logger.debug(stat)
|
logger.debug(stat)
|
||||||
current = "{0}hash".format(si_format(stat['current'], 6, True, " "))
|
current = "{0}hash".format(si_format(stat['current'], 6, True, " "))
|
||||||
text.append(get_text_item_dict("Current Mining Hashrate", 20))
|
text.append(get_text_item_dict(text="Current Mining Hashrate", font_size=20,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict(current, 40))
|
text.append(get_text_item_dict(text=current, font_size=40,gerty_type=gerty.type))
|
||||||
# compare vs previous time period
|
# compare vs previous time period
|
||||||
difference = get_percent_difference(current=stat['current'], previous=stat['1w'])
|
difference = get_percent_difference(current=stat['current'], previous=stat['1w'])
|
||||||
text.append(get_text_item_dict("{0} in last 7 days".format(difference), 12))
|
text.append(get_text_item_dict(text="{0} in last 7 days".format(difference), font_size=12,gerty_type=gerty.type))
|
||||||
elif stat_slug == "mining_current_difficulty":
|
elif stat_slug == "mining_current_difficulty":
|
||||||
stat = await api_get_mining_stat(stat_slug, gerty)
|
stat = await api_get_mining_stat(stat_slug, gerty)
|
||||||
text.append(get_text_item_dict("Current Mining Difficulty", 20))
|
text.append(get_text_item_dict(text="Current Mining Difficulty", font_size=20,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict(format_number(stat['current']), 40))
|
text.append(get_text_item_dict(text=format_number(stat['current']), font_size=40,gerty_type=gerty.type))
|
||||||
difference = get_percent_difference(current=stat['current'], previous=stat['previous'])
|
difference = get_percent_difference(current=stat['current'], previous=stat['previous'])
|
||||||
text.append(get_text_item_dict("{0} since last adjustment".format(difference), 12))
|
text.append(get_text_item_dict(text="{0} since last adjustment".format(difference), font_size=12,gerty_type=gerty.type))
|
||||||
# text.append(get_text_item_dict("Required threshold for mining proof-of-work", 12))
|
# text.append(get_text_item_dict("Required threshold for mining proof-of-work", 12))
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -198,7 +198,9 @@
|
||||||
|
|
||||||
<p>Use the toggles below to control what your Gerty will display</p>
|
<p>Use the toggles below to control what your Gerty will display</p>
|
||||||
|
|
||||||
|
|
||||||
<q-expansion-item
|
<q-expansion-item
|
||||||
|
v-if="!isMiniGerty"
|
||||||
expand-separator
|
expand-separator
|
||||||
icon="grid_view"
|
icon="grid_view"
|
||||||
label="Dashboards"
|
label="Dashboards"
|
||||||
|
|
@ -208,17 +210,6 @@
|
||||||
label="LNbits Dashboard"
|
label="LNbits Dashboard"
|
||||||
></q-toggle>
|
></q-toggle>
|
||||||
|
|
||||||
<q-toggle
|
|
||||||
v-model="formDialog.data.display_preferences.fun_satoshi_quotes"
|
|
||||||
label="Satoshi Quotes"
|
|
||||||
>
|
|
||||||
<q-tooltip>Displays random quotes from Satoshi</q-tooltip>
|
|
||||||
</q-toggle>
|
|
||||||
<q-toggle
|
|
||||||
v-model="formDialog.data.display_preferences.fun_exchange_market_rate"
|
|
||||||
label="Fiat to BTC price"
|
|
||||||
></q-toggle>
|
|
||||||
|
|
||||||
<q-toggle
|
<q-toggle
|
||||||
v-model="formDialog.data.display_preferences.dashboard_onchain"
|
v-model="formDialog.data.display_preferences.dashboard_onchain"
|
||||||
label="Onchain Dashboard"
|
label="Onchain Dashboard"
|
||||||
|
|
@ -241,8 +232,20 @@
|
||||||
expand-separator
|
expand-separator
|
||||||
icon="pin"
|
icon="pin"
|
||||||
label="Single Data Points"
|
label="Single Data Points"
|
||||||
|
ref="single-data-points-expansion"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
<q-toggle
|
||||||
|
v-model="formDialog.data.display_preferences.fun_exchange_market_rate"
|
||||||
|
label="Fiat to BTC price"
|
||||||
|
></q-toggle>
|
||||||
|
<q-toggle
|
||||||
|
v-if="!isMiniGerty"
|
||||||
|
v-model="formDialog.data.display_preferences.fun_satoshi_quotes"
|
||||||
|
label="Satoshi Quotes"
|
||||||
|
>
|
||||||
|
<q-tooltip>Displays random quotes from Satoshi</q-tooltip>
|
||||||
|
</q-toggle>
|
||||||
<q-expansion-item
|
<q-expansion-item
|
||||||
expand-separator
|
expand-separator
|
||||||
icon="perm_identity"
|
icon="perm_identity"
|
||||||
|
|
@ -757,12 +760,30 @@
|
||||||
LNbits.utils.exportCSV(this.gertysTable.columns, this.gertys)
|
LNbits.utils.exportCSV(this.gertysTable.columns, this.gertys)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
isMiniGerty() {
|
||||||
|
return (this.formDialog.data.type == 'Mini Gerty')
|
||||||
|
}
|
||||||
|
},
|
||||||
created: function () {
|
created: function () {
|
||||||
if (this.g.user.wallets.length) {
|
if (this.g.user.wallets.length) {
|
||||||
this.getGertys()
|
this.getGertys()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
'formDialog.data.type': {
|
||||||
|
handler(value) {
|
||||||
|
if (value == 'Mini Gerty') {
|
||||||
|
this.formDialog.data.display_preferences.dashboard = false;
|
||||||
|
this.formDialog.data.display_preferences.dashboard_onchain = false;
|
||||||
|
this.formDialog.data.display_preferences.dashboard_mining = false;
|
||||||
|
this.formDialog.data.display_preferences.lightning_dashboard = false;
|
||||||
|
this.formDialog.data.display_preferences.fun_satoshi_quotes = false;
|
||||||
|
this.formDialog.data.display_preferences.mempool_recommended_fees = false;
|
||||||
|
this.formDialog.data.display_preferences.onchain = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
toggleStates: {
|
toggleStates: {
|
||||||
handler(toggleStatesValue) {
|
handler(toggleStatesValue) {
|
||||||
// Switch all the toggles in each section to the relevant state
|
// Switch all the toggles in each section to the relevant state
|
||||||
|
|
|
||||||
|
|
@ -177,11 +177,11 @@ async def get_screen_data(screen_num: int, screens_list: dict, gerty):
|
||||||
wallets = await get_lnbits_wallet_balances(gerty)
|
wallets = await get_lnbits_wallet_balances(gerty)
|
||||||
text = []
|
text = []
|
||||||
for wallet in wallets:
|
for wallet in wallets:
|
||||||
text.append(get_text_item_dict("{0}'s Wallet".format(wallet['name']), 20))
|
text.append(get_text_item_dict(text="{0}'s Wallet".format(wallet['name']), font_size=20,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict("{0} sats".format(format_number(wallet['balance'])), 40))
|
text.append(get_text_item_dict(text="{0} sats".format(format_number(wallet['balance'])), font_size=40,gerty_type=gerty.type))
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
elif screen_slug == "fun_satoshi_quotes":
|
elif screen_slug == "fun_satoshi_quotes":
|
||||||
areas.append(await get_satoshi_quotes())
|
areas.append(await get_satoshi_quotes(gerty))
|
||||||
elif screen_slug == "fun_exchange_market_rate":
|
elif screen_slug == "fun_exchange_market_rate":
|
||||||
areas.append(await get_exchange_rate(gerty))
|
areas.append(await get_exchange_rate(gerty))
|
||||||
elif screen_slug == "onchain_difficulty_epoch_progress":
|
elif screen_slug == "onchain_difficulty_epoch_progress":
|
||||||
|
|
@ -223,34 +223,34 @@ async def get_dashboard(gerty):
|
||||||
# XC rate
|
# XC rate
|
||||||
text = []
|
text = []
|
||||||
amount = await satoshis_amount_as_fiat(100000000, gerty.exchange)
|
amount = await satoshis_amount_as_fiat(100000000, gerty.exchange)
|
||||||
text.append(get_text_item_dict(format_number(amount), 40))
|
text.append(get_text_item_dict(text=format_number(amount), font_size=40,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict("BTC{0} price".format(gerty.exchange), 15))
|
text.append(get_text_item_dict(text="BTC{0} price".format(gerty.exchange), font_size=15,gerty_type=gerty.type))
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
# balance
|
# balance
|
||||||
text = []
|
text = []
|
||||||
wallets = await get_lnbits_wallet_balances(gerty)
|
wallets = await get_lnbits_wallet_balances(gerty)
|
||||||
text = []
|
text = []
|
||||||
for wallet in wallets:
|
for wallet in wallets:
|
||||||
text.append(get_text_item_dict("{0}".format(wallet["name"]), 15))
|
text.append(get_text_item_dict(text="{0}".format(wallet["name"]), font_size=15,gerty_type=gerty.type))
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict("{0} sats".format(format_number(wallet["balance"])), 20)
|
get_text_item_dict(text="{0} sats".format(format_number(wallet["balance"])), font_size=20,gerty_type=gerty.type)
|
||||||
)
|
)
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
||||||
# Mempool fees
|
# Mempool fees
|
||||||
text = []
|
text = []
|
||||||
text.append(get_text_item_dict(format_number(await get_block_height(gerty)), 40))
|
text.append(get_text_item_dict(text=format_number(await get_block_height(gerty)), font_size=40,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict("Current block height", 15))
|
text.append(get_text_item_dict(text="Current block height", font_size=15,gerty_type=gerty.type))
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
||||||
# difficulty adjustment time
|
# difficulty adjustment time
|
||||||
text = []
|
text = []
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict(
|
get_text_item_dict(
|
||||||
await get_time_remaining_next_difficulty_adjustment(gerty), 15
|
text=await get_time_remaining_next_difficulty_adjustment(gerty), font_size=15,gerty_type=gerty.type
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
text.append(get_text_item_dict("until next difficulty adjustment", 12))
|
text.append(get_text_item_dict(text="until next difficulty adjustment", font_size=12,gerty_type=gerty.type))
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
||||||
return areas
|
return areas
|
||||||
|
|
@ -276,21 +276,21 @@ async def get_lnbits_wallet_balances(gerty):
|
||||||
|
|
||||||
async def get_placeholder_text():
|
async def get_placeholder_text():
|
||||||
return [
|
return [
|
||||||
get_text_item_dict("Some placeholder text", 15, 10, 50),
|
get_text_item_dict(text="Some placeholder text", x_pos=15, y_pos=10, font_size=50,gerty_type=gerty.type),
|
||||||
get_text_item_dict("Some placeholder text", 15, 10, 50),
|
get_text_item_dict(text="Some placeholder text", x_pos=15, y_pos=10, font_size=50,gerty_type=gerty.type),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
async def get_satoshi_quotes():
|
async def get_satoshi_quotes(gerty):
|
||||||
# Get Satoshi quotes
|
# Get Satoshi quotes
|
||||||
text = []
|
text = []
|
||||||
quote = await api_gerty_satoshi()
|
quote = await api_gerty_satoshi()
|
||||||
if quote:
|
if quote:
|
||||||
if quote["text"]:
|
if quote["text"]:
|
||||||
text.append(get_text_item_dict(quote["text"], 15))
|
text.append(get_text_item_dict(text=quote["text"], font_size=15,gerty_type=gerty.type))
|
||||||
if quote["date"]:
|
if quote["date"]:
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict("Satoshi Nakamoto - {0}".format(quote["date"]), 15)
|
get_text_item_dict(text="Satoshi Nakamoto - {0}".format(quote["date"]), font_size=15,gerty_type=gerty.type)
|
||||||
)
|
)
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
@ -305,10 +305,10 @@ async def get_exchange_rate(gerty):
|
||||||
price = format_number(amount)
|
price = format_number(amount)
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict(
|
get_text_item_dict(
|
||||||
"Current {0}/BTC price".format(gerty.exchange), 15
|
text="Current {0}/BTC price".format(gerty.exchange), font_size=15,gerty_type=gerty.type
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
text.append(get_text_item_dict(price, 80))
|
text.append(get_text_item_dict(text=price, font_size=80,gerty_type=gerty.type))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
return text
|
return text
|
||||||
|
|
@ -325,21 +325,21 @@ async def get_onchain_stat(stat_slug: str, gerty):
|
||||||
r = await client.get(gerty.mempool_endpoint + "/api/v1/difficulty-adjustment")
|
r = await client.get(gerty.mempool_endpoint + "/api/v1/difficulty-adjustment")
|
||||||
if stat_slug == "onchain_difficulty_epoch_progress":
|
if stat_slug == "onchain_difficulty_epoch_progress":
|
||||||
stat = round(r.json()['progressPercent'])
|
stat = round(r.json()['progressPercent'])
|
||||||
text.append(get_text_item_dict("Progress through current difficulty epoch", 15))
|
text.append(get_text_item_dict(text="Progress through current difficulty epoch", font_size=15,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict("{0}%".format(stat), 80))
|
text.append(get_text_item_dict(text="{0}%".format(stat), font_size=80,gerty_type=gerty.type))
|
||||||
elif stat_slug == "onchain_difficulty_retarget_date":
|
elif stat_slug == "onchain_difficulty_retarget_date":
|
||||||
stat = r.json()['estimatedRetargetDate']
|
stat = r.json()['estimatedRetargetDate']
|
||||||
dt = datetime.fromtimestamp(stat / 1000).strftime("%e %b %Y at %H:%M")
|
dt = datetime.fromtimestamp(stat / 1000).strftime("%e %b %Y at %H:%M")
|
||||||
text.append(get_text_item_dict("Estimated date of next difficulty adjustment", 15))
|
text.append(get_text_item_dict(text="Estimated date of next difficulty adjustment", font_size=15,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict(dt, 40))
|
text.append(get_text_item_dict(text=dt, font_size=40,gerty_type=gerty.type))
|
||||||
elif stat_slug == "onchain_difficulty_blocks_remaining":
|
elif stat_slug == "onchain_difficulty_blocks_remaining":
|
||||||
stat = r.json()['remainingBlocks']
|
stat = r.json()['remainingBlocks']
|
||||||
text.append(get_text_item_dict("Blocks remaining until next difficulty adjustment", 15))
|
text.append(get_text_item_dict(text="Blocks remaining until next difficulty adjustment", font_size=15,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict("{0}".format(format_number(stat)), 80))
|
text.append(get_text_item_dict(text="{0}".format(format_number(stat)), font_size=80,gerty_type=gerty.type))
|
||||||
elif stat_slug == "onchain_difficulty_epoch_time_remaining":
|
elif stat_slug == "onchain_difficulty_epoch_time_remaining":
|
||||||
stat = r.json()['remainingTime']
|
stat = r.json()['remainingTime']
|
||||||
text.append(get_text_item_dict("Blocks remaining until next difficulty adjustment", 15))
|
text.append(get_text_item_dict(text="Blocks remaining until next difficulty adjustment", font_size=15,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict(get_time_remaining(stat / 1000, 4), 20))
|
text.append(get_text_item_dict(text=get_time_remaining(stat / 1000, 4), font_size=20,gerty_type=gerty.type))
|
||||||
return text
|
return text
|
||||||
|
|
||||||
async def get_onchain_dashboard(gerty):
|
async def get_onchain_dashboard(gerty):
|
||||||
|
|
@ -351,27 +351,27 @@ async def get_onchain_dashboard(gerty):
|
||||||
)
|
)
|
||||||
text = []
|
text = []
|
||||||
stat = round(r.json()["progressPercent"])
|
stat = round(r.json()["progressPercent"])
|
||||||
text.append(get_text_item_dict("Progress through epoch", 12))
|
text.append(get_text_item_dict(text="Progress through epoch", font_size=12,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict("{0}%".format(stat), 60))
|
text.append(get_text_item_dict(text="{0}%".format(stat), font_size=60,gerty_type=gerty.type))
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
||||||
text = []
|
text = []
|
||||||
stat = r.json()["estimatedRetargetDate"]
|
stat = r.json()["estimatedRetargetDate"]
|
||||||
dt = datetime.fromtimestamp(stat / 1000).strftime("%e %b %Y at %H:%M")
|
dt = datetime.fromtimestamp(stat / 1000).strftime("%e %b %Y at %H:%M")
|
||||||
text.append(get_text_item_dict("Date of next adjustment", 12))
|
text.append(get_text_item_dict(text="Date of next adjustment", font_size=12,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict(dt, 20))
|
text.append(get_text_item_dict(text=dt, font_size=20,gerty_type=gerty.type))
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
||||||
text = []
|
text = []
|
||||||
stat = r.json()["remainingBlocks"]
|
stat = r.json()["remainingBlocks"]
|
||||||
text.append(get_text_item_dict("Blocks until adjustment", 12))
|
text.append(get_text_item_dict(text="Blocks until adjustment", font_size=12,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict("{0}".format(format_number(stat)), 60))
|
text.append(get_text_item_dict(text="{0}".format(format_number(stat)), font_size=60,gerty_type=gerty.type))
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
||||||
text = []
|
text = []
|
||||||
stat = r.json()["remainingTime"]
|
stat = r.json()["remainingTime"]
|
||||||
text.append(get_text_item_dict("Time until adjustment", 12))
|
text.append(get_text_item_dict(text="Time until adjustment", font_size=12,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict(get_time_remaining(stat / 1000, 4), 20))
|
text.append(get_text_item_dict(text=get_time_remaining(stat / 1000, 4), font_size=20,gerty_type=gerty.type))
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
||||||
return areas
|
return areas
|
||||||
|
|
@ -404,30 +404,30 @@ async def get_mempool_stat(stat_slug: str, gerty):
|
||||||
r = await client.get(gerty.mempool_endpoint + "/api/mempool")
|
r = await client.get(gerty.mempool_endpoint + "/api/mempool")
|
||||||
if stat_slug == "mempool_tx_count":
|
if stat_slug == "mempool_tx_count":
|
||||||
stat = round(r.json()["count"])
|
stat = round(r.json()["count"])
|
||||||
text.append(get_text_item_dict("Transactions in the mempool", 15))
|
text.append(get_text_item_dict(text="Transactions in the mempool", font_size=15,gerty_type=gerty.type))
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict("{0}".format(format_number(stat)), 80)
|
get_text_item_dict(text="{0}".format(format_number(stat)), font_size=80,gerty_type=gerty.type)
|
||||||
)
|
)
|
||||||
elif stat_slug == "mempool_recommended_fees":
|
elif stat_slug == "mempool_recommended_fees":
|
||||||
y_offset = 60
|
y_offset = 60
|
||||||
fees = await get_mempool_recommended_fees(gerty)
|
fees = await get_mempool_recommended_fees(gerty)
|
||||||
pos_y = 80 + y_offset
|
pos_y = 80 + y_offset
|
||||||
text.append(get_text_item_dict("mempool.space", 40, 160, pos_y))
|
text.append(get_text_item_dict("mempool.space", 40, 160, pos_y, gerty.type))
|
||||||
pos_y = 180 + y_offset
|
pos_y = 180 + y_offset
|
||||||
text.append(get_text_item_dict("Recommended Tx Fees", 20, 240, pos_y))
|
text.append(get_text_item_dict("Recommended Tx Fees", 20, 240, pos_y, gerty.type))
|
||||||
|
|
||||||
pos_y = 280 + y_offset
|
pos_y = 280 + y_offset
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict("{0}".format("None"), 15, 30, pos_y)
|
get_text_item_dict("{0}".format("None"), 15, 30, pos_y, gerty.type)
|
||||||
)
|
)
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict("{0}".format("Low"), 15, 235, pos_y)
|
get_text_item_dict("{0}".format("Low"), 15, 235, pos_y, gerty.type)
|
||||||
)
|
)
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict("{0}".format("Medium"), 15, 460, pos_y)
|
get_text_item_dict("{0}".format("Medium"), 15, 460, pos_y, gerty.type)
|
||||||
)
|
)
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict("{0}".format("High"), 15, 750, pos_y)
|
get_text_item_dict("{0}".format("High"), 15, 750, pos_y, gerty.type)
|
||||||
)
|
)
|
||||||
|
|
||||||
pos_y = 340 + y_offset
|
pos_y = 340 + y_offset
|
||||||
|
|
@ -436,56 +436,60 @@ async def get_mempool_stat(stat_slug: str, gerty):
|
||||||
fee_rate = fees["economyFee"]
|
fee_rate = fees["economyFee"]
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict(
|
get_text_item_dict(
|
||||||
"{0} {1}{2}".format(
|
text="{0} {1}{2}".format(
|
||||||
format_number(fee_rate),
|
format_number(fee_rate),
|
||||||
("sat" if fee_rate == 1 else "sats"),
|
("sat" if fee_rate == 1 else "sats"),
|
||||||
fee_append,
|
fee_append,
|
||||||
),
|
),
|
||||||
font_size,
|
font_size=font_size,
|
||||||
30,
|
x_pos=30,
|
||||||
pos_y,
|
y_pos=pos_y,
|
||||||
|
gerty_type=gerty.type
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
fee_rate = fees["hourFee"]
|
fee_rate = fees["hourFee"]
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict(
|
get_text_item_dict(
|
||||||
"{0} {1}{2}".format(
|
text="{0} {1}{2}".format(
|
||||||
format_number(fee_rate),
|
format_number(fee_rate),
|
||||||
("sat" if fee_rate == 1 else "sats"),
|
("sat" if fee_rate == 1 else "sats"),
|
||||||
fee_append,
|
fee_append,
|
||||||
),
|
),
|
||||||
font_size,
|
font_size=font_size,
|
||||||
235,
|
x_pos=235,
|
||||||
pos_y,
|
y_pos=pos_y,
|
||||||
|
gerty_type=gerty.type
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
fee_rate = fees["halfHourFee"]
|
fee_rate = fees["halfHourFee"]
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict(
|
get_text_item_dict(
|
||||||
"{0} {1}{2}".format(
|
text="{0} {1}{2}".format(
|
||||||
format_number(fee_rate),
|
format_number(fee_rate),
|
||||||
("sat" if fee_rate == 1 else "sats"),
|
("sat" if fee_rate == 1 else "sats"),
|
||||||
fee_append,
|
fee_append,
|
||||||
),
|
),
|
||||||
font_size,
|
font_size=font_size,
|
||||||
460,
|
x_pos=460,
|
||||||
pos_y,
|
y_pos=pos_y,
|
||||||
|
gerty_type=gerty.type
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
fee_rate = fees["fastestFee"]
|
fee_rate = fees["fastestFee"]
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict(
|
get_text_item_dict(
|
||||||
"{0} {1}{2}".format(
|
text="{0} {1}{2}".format(
|
||||||
format_number(fee_rate),
|
format_number(fee_rate),
|
||||||
("sat" if fee_rate == 1 else "sats"),
|
("sat" if fee_rate == 1 else "sats"),
|
||||||
fee_append,
|
fee_append,
|
||||||
),
|
),
|
||||||
font_size,
|
font_size=font_size,
|
||||||
750,
|
x_pos=750,
|
||||||
pos_y,
|
y_pos=pos_y,
|
||||||
|
gerty_type=gerty.type
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return text
|
return text
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue