From 00eb59767eb4a73545952e05532096af5b688a17 Mon Sep 17 00:00:00 2001 From: Manuel Date: Wed, 2 Nov 2022 13:01:34 +0100 Subject: [PATCH] fixes for validators that have not yet been activated, loading screen fixes on block tab --- android/app/build.gradle | 4 ++-- src/app/controllers/OverviewController.ts | 17 +++++++++-------- src/app/tab-blocks/tab-blocks.page.html | 6 +++--- src/app/tab-blocks/tab-blocks.page.ts | 20 ++------------------ src/app/utils/BlockUtils.ts | 8 ++++---- 5 files changed, 20 insertions(+), 35 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 2ce15d89..faaf3a04 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -12,8 +12,8 @@ android { applicationId "in.beaconcha.mobile" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 81 - versionName "4.0.1" + versionCode 82 + versionName "4.0.2" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/src/app/controllers/OverviewController.ts b/src/app/controllers/OverviewController.ts index 4dc51624..bfddae6f 100644 --- a/src/app/controllers/OverviewController.ts +++ b/src/app/controllers/OverviewController.ts @@ -125,7 +125,7 @@ export default class OverviewController { return cur.data.activationepoch <= currentEpoch.epoch ? cur.data.effectivebalance : new BigNumber(0) }); const investedBalance = this.sumBigIntBalanceRpl(validators, cur => { - return cur.data.activationepoch <= currentEpoch.epoch ? new BigNumber(cur.data.effectivebalance.toString()) : new BigNumber(0) + return new BigNumber(cur.data.effectivebalance.toString()) }); const aprPerformance31dConsensus = sumBigInt(validators, cur => cur.data.performance31d); @@ -158,12 +158,13 @@ export default class OverviewController { total: consensusPerf.total.plus(executionPerf.total), } - var attrEffectiveness = -1 - attrEffectiveness = sumBigInt(validators, cur => cur.attrEffectiveness ? new BigNumber(cur.attrEffectiveness.toString()): new BigNumber(0)) + var attrEffectiveness = 0 + if (activeValidators.length > 0) { + attrEffectiveness = sumBigInt(validators, cur => cur.attrEffectiveness ? new BigNumber(cur.attrEffectiveness.toString()): new BigNumber(0)) .dividedBy(activeValidators.length) .decimalPlaces(1).toNumber(); + } - const bestRank = findLowest(validators, cur => cur.data.rank7d) const worstRank = findHighest(validators, cur => cur.data.rank7d) const rocketpoolValiCount = sumBigInt(validators, cur => cur.rocketpool ? new BigNumber(1) : new BigNumber(0)) @@ -296,7 +297,6 @@ export default class OverviewController { const aprConsensus = this.getAPRFromMonth(effectiveBalanceActive, aprPerformance31dConsensus) - console.log("stuff", performance365d.toString(), total.toString()) return { performance1d: performance1d, performance31d: performance31d, @@ -331,10 +331,11 @@ export default class OverviewController { sumBigIntBalanceRpl(validators: Validator[], field: (cur: Validator) => BigNumber): BigNumber { return sumBigInt(validators, cur => { - if (!cur.rocketpool) return field(cur).multipliedBy(new BigNumber(cur.share == null ? 1 : cur.share)) - if (!cur.rocketpool.node_address) return field(cur).multipliedBy(new BigNumber(cur.share == null ? 1 : cur.share)) + const fieldVal = field(cur) + if (!cur.rocketpool) return fieldVal.multipliedBy(new BigNumber(cur.share == null ? 1 : cur.share)) + if (!cur.rocketpool.node_address) return fieldVal.multipliedBy(new BigNumber(cur.share == null ? 1 : cur.share)) - const rewards = new BigNumber(field(cur).toString()).minus(cur.data.effectivebalance) + const rewards = new BigNumber(fieldVal.toString()).minus(cur.data.effectivebalance) const nodeOperatorRewards = new BigNumber(rewards).multipliedBy(new BigNumber("1").plus(new BigNumber(cur.rocketpool.minipool_node_fee.toString()))).dividedBy("2") const wholeBalance = new BigNumber("16000000000").plus(nodeOperatorRewards) return wholeBalance.multipliedBy(new BigNumber(cur.share == null ? 1 : cur.share)) diff --git a/src/app/tab-blocks/tab-blocks.page.html b/src/app/tab-blocks/tab-blocks.page.html index f2e6a12c..91dad874 100644 --- a/src/app/tab-blocks/tab-blocks.page.html +++ b/src/app/tab-blocks/tab-blocks.page.html @@ -26,8 +26,8 @@

- Next block estimated to arrive in - Next block was estimated to arrive + On average next block expected in + On average next block was expected
~{{ nextBlockEstimate | timeago }} @@ -58,7 +58,7 @@

No Blocks so far

Your proposed blocks will show up here. -
+
diff --git a/src/app/tab-blocks/tab-blocks.page.ts b/src/app/tab-blocks/tab-blocks.page.ts index 69e91229..6af3bccf 100644 --- a/src/app/tab-blocks/tab-blocks.page.ts +++ b/src/app/tab-blocks/tab-blocks.page.ts @@ -78,6 +78,7 @@ export class TabBlocksPage implements OnInit { let blocks = await this.blockUtils.getMyBlocks(initial ? 0 : this.items.length) if (initial) { this.items = blocks + this.initialized = true } else { this.items = this.items.concat(blocks) } @@ -104,24 +105,7 @@ export class TabBlocksPage implements OnInit { } private setLoading(loading: boolean) { - if (loading) { - // Reasoning: Don't show loading indicator if it takes less than 400ms (already cached locally but storage is slow-ish so we adjust for that) - setTimeout(() => { - if (!this.items || this.items.length <= 0) { - this.loading = true - } - }, 200) - } else { - if (this.loading) { - setTimeout(() => { - this.initialized = true - this.loading = false - }, 350) - } else { - this.initialized = true - this.loading = false - } - } + this.loading = loading } async clickBlock(item: BlockResponse) { diff --git a/src/app/utils/BlockUtils.ts b/src/app/utils/BlockUtils.ts index 5b9c28ac..66807469 100644 --- a/src/app/utils/BlockUtils.ts +++ b/src/app/utils/BlockUtils.ts @@ -181,13 +181,13 @@ export class BlockUtils extends CacheModule { return WEEK } else if (diff < MONTH) { return MONTH - } else if (diff < SIXWEEKS && blocksPer30d <= 2.2) { + } else if (diff < SIXWEEKS && blocksPer30d <= 2.25) { return SIXWEEKS - } else if (diff < TWOEMONTH && blocksPer30d <= 1.6) { + } else if (diff < TWOEMONTH && blocksPer30d <= 1.65) { return TWOEMONTH - } else if (diff < THREEMONTH && blocksPer30d <= 0.95) { + } else if (diff < THREEMONTH && blocksPer30d <= 0.97) { return THREEMONTH - } else if (diff < FOURMONTH && blocksPer30d <= 0.55) { + } else if (diff < FOURMONTH && blocksPer30d <= 0.60) { return FOURMONTH }