diff --git a/apis/candidates.js b/apis/candidates.js index 1c08db59..4432116a 100644 --- a/apis/candidates.js +++ b/apis/candidates.js @@ -741,13 +741,8 @@ router.put('/update', [ set['dataCenter.location'] = body.dcLocation } - if (body.website) { - set['socials.website'] = body.website - } - - if (body.telegram) { - set['socials.telegram'] = body.telegram - } + set['socials.website'] = body.website || '' + set['socials.telegram'] = body.telegram || '' const address = await web3.eth.accounts.recover(message, signedMessage) diff --git a/apis/voters.js b/apis/voters.js index 7c215708..1abd632c 100644 --- a/apis/voters.js +++ b/apis/voters.js @@ -373,17 +373,20 @@ router.get('/calculatingReward1Day', [], async (req, res, next) => { const capacity = new BigNumber(candidate.capacity).div(10 ** 18) const totalReward = new BigNumber(config.get('blockchain.reward')) // get total signers in latest epoch - const totalSigners = await axios.post( - urljoin(config.get('tomoscanUrl'), `api/expose/totalSignNumber/${epoch}`) - ) + let totalSigners + if (epoch) { + totalSigners = await axios.post( + urljoin(config.get('tomoscanUrl'), `api/expose/totalSignNumber/${epoch}`) + ) + } - if (totalSigners.data && totalSigners.data.totalSignNumber) { + if (totalSigners && totalSigners.data && totalSigners.data.totalSignNumber) { // calculate devided reward const masternodeReward = totalReward.multipliedBy(signNumber).dividedBy(totalSigners.data.totalSignNumber) // calculate voter reward 1 day - const estimateReward = masternodeReward - .multipliedBy((amount.div(0.5))).div(capacity.plus(amount)).multipliedBy(await epochIn1Day) || 'N/A' + const estimateReward = masternodeReward.multipliedBy(0.5) + .multipliedBy(amount).div(capacity.plus(amount)).multipliedBy(await epochIn1Day) || 'N/A' return res.send(estimateReward.toString(10)) } return res.send('N/A') diff --git a/app/components/candidates/Update.vue b/app/components/candidates/Update.vue index 1126a04c..46628adb 100644 --- a/app/components/candidates/Update.vue +++ b/app/components/candidates/Update.vue @@ -68,6 +68,9 @@ + Not an url + Not an url
@@ -157,7 +163,8 @@ import { validationMixin } from 'vuelidate' import { required, minLength, - maxLength + maxLength, + url } from 'vuelidate/lib/validators' import axios from 'axios' import VueQrcode from '@chenfengyuan/vue-qrcode' @@ -207,7 +214,9 @@ export default { dcLocation: { maxLength: maxLength(30), minLength: minLength(2) - } + }, + website: { url }, + telegram: { url } }, beforeDestroy () { if (this.interval) { @@ -240,8 +249,8 @@ export default { self.hardware = data.hardware || 'N/A' self.dcName = (data.dataCenter || {}).name || 'N/A' self.dcLocation = (data.dataCenter || {}).location || 'N/A' - self.website = data.website || '' - self.telegram = data.telegram || '' + self.website = (data.socials || {}).website || '' + self.telegram = (data.socials || {}).telegram || '' } } } catch (e) { @@ -356,13 +365,8 @@ export default { body.dcLocation = self.dcLocation } - if (self.website !== '') { - body.website = self.website - } - - if (self.telegram !== '') { - body.telegram = self.telegram - } + body.website = self.website + body.telegram = self.telegram const { data } = await axios.put( '/api/candidates/update', diff --git a/app/components/candidates/View.vue b/app/components/candidates/View.vue index 5be822ca..79e1b0af 100644 --- a/app/components/candidates/View.vue +++ b/app/components/candidates/View.vue @@ -31,7 +31,9 @@ :key="key" class="list-inline-item social-links__item"> diff --git a/app/components/voters/EstimateReward.vue b/app/components/voters/EstimateReward.vue index 9eb08417..9c299b38 100644 --- a/app/components/voters/EstimateReward.vue +++ b/app/components/voters/EstimateReward.vue @@ -2,7 +2,7 @@
- Est. Daily Reward: {{ estimatedReward }} + Est. Daily Reward: {{ estimatedReward }} TOMO