Skip to content

Commit

Permalink
Merge pull request #163 from thanhson1085/master
Browse files Browse the repository at this point in the history
 fix gasPrice for tomomaster
  • Loading branch information
thanhson1085 authored Aug 20, 2018
2 parents 27b4ea6 + ac46bd5 commit 9334d64
Show file tree
Hide file tree
Showing 11 changed files with 142 additions and 87 deletions.
26 changes: 26 additions & 0 deletions apis/grafana.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict'
const express = require('express')
const config = require('config')
const request = require('request')
const router = express.Router()

router.get('/', async function (req, res, next) {
let db = req.query.db
let query = req.query.q
query = encodeURI(query).replace('=', '%3D').replace(';', '%3B')
let epoch = req.query.epoch
let apiKey = config.get('grafanaApiKey')
let url = `${config.get('grafanaUrl')}/api/datasources/proxy/1/query?db=${db}&q=${query}&epoch=${epoch}`
request({
url: url,
json: true,
headers: { Authorization: `Bearer ${apiKey}` }
}, (error, response, body) => {
if (error) {
return res.json(error)
}
return res.json(body)
})
})

module.exports = router
1 change: 1 addition & 0 deletions apis/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ router.use('/api/config', require('./config'))
router.use('/api/signers', require('./signers'))
router.use('/api/blocksigners', require('./blocksigners'))
router.use('/api/transactions', require('./transactions'))
router.use('/api/monitor', require('./grafana'))

module.exports = router
6 changes: 1 addition & 5 deletions app/components/Chart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,10 @@ export default {
fetchData: async function (db, query, epoch) {
let chartData = []
try {
let apiKey = 'eyJrIjoiRE1TQ3lyZ1U2ZmJkdURNRkNVNjU0RnRiakh3UElhQ3IiLCJuIjoiVG9tb21hc3RlciIsImlkIjoxfQ=='
this.chartLoading = true
// eslint-disable-next-line max-len
let { data } = await axios.get(`${this.config.grafanaUrl}/api/datasources/proxy/1/query?db=${db}&q=${query}&epoch=${epoch}`, {
headers: { Authorization: `Bearer ${apiKey}` }
})
let { data } = await axios.get(`/api/monitor?db=${db}&q=${query}&epoch=${epoch}`)
this.chartLoading = false
chartData = data
Expand Down
3 changes: 2 additions & 1 deletion app/components/candidates/Apply.vue
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ export default {
let contract = await self.TomoValidator.deployed()
let rs = await contract.propose(coinbase, {
from : account,
value: parseFloat(value) * 10 ** 18
value: parseFloat(value) * 10 ** 18,
gasPrice: 1
})
let toastMessage = rs.tx ? 'You have successfully applied!'
: 'An error occurred while applying, please try again'
Expand Down
5 changes: 4 additions & 1 deletion app/components/candidates/Resign.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ export default {
let account = await self.getAccount()
let contract = await self.TomoValidator.deployed()
let coinbase = self.coinbase
let rs = await contract.resign(coinbase, { from: account })
let rs = await contract.resign(coinbase, {
from: account,
gasPrice: 1
})
let toastMessage = rs.tx ? 'You have successfully resigned!'
: 'An error occurred while retiring, please try again'
Expand Down
5 changes: 4 additions & 1 deletion app/components/candidates/Withdraw.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ export default {
let contract = await self.TomoValidator.deployed()
let coinbase = this.coinbase
let rs = await contract.withdraw(coinbase, { from: account })
let rs = await contract.withdraw(coinbase, {
from: account,
gasPrice: 1
})
let toastMessage = rs.tx ? 'You have successfully withdrawed!'
: 'An error occurred while withdrawing, please try again'
Expand Down
5 changes: 4 additions & 1 deletion app/components/voters/Unvoting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ export default {
let account = await self.getAccount()
let contract = await self.TomoValidator.deployed()
let rs = await contract.unvote(candidate, (parseFloat(value) * 10 ** 18), { from: account })
let rs = await contract.unvote(candidate, (parseFloat(value) * 10 ** 18), {
from: account,
gasPrice: 1
})
self.vote -= value
let toastMessage = rs.tx ? 'You have successfully unvoted!'
Expand Down
5 changes: 3 additions & 2 deletions app/components/voters/Voting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ export default {
let contract = await self.TomoValidator.deployed()
let rs = await contract.vote(self.candidate, {
from: account,
value: new BigNumber(this.voteValue).multipliedBy(10 ** 18).toNumber()
value: new BigNumber(this.voteValue).multipliedBy(10 ** 18).toNumber(),
gasPrice: 1
})
let toastMessage = rs.tx ? 'You have successfully voted!'
Expand All @@ -162,7 +163,7 @@ export default {
}, 2000)
} catch (e) {
self.loading = false
self.$toasted.show('An error occurred while voting, please try again', {
self.$toasted.show(`An error occurred while voting. ${String(e)}`, {
type : 'error'
})
console.log(e)
Expand Down
1 change: 1 addition & 0 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
},
"explorerUrl": "http://localhost:3003",
"grafanaUrl": "http://localhost:8000",
"grafanaApiKey": "eyJrIjoiRE1TQ3lyZ1U2ZmJkdURNRkNVNjU0RnRiakh3UElhQ3IiLCJuIjoiVG9tb21hc3RlciIsImlkIjoxfQ==",
"redis": {
"host": "redis",
"port": 6379,
Expand Down
Loading

0 comments on commit 9334d64

Please sign in to comment.