Skip to content

Commit

Permalink
Boost minimum gas (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
floating committed Sep 12, 2019
1 parent bc77e66 commit 476c7c2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
15 changes: 12 additions & 3 deletions main/provider/index.js
Expand Up @@ -237,10 +237,19 @@ class Provider extends EventEmitter {
}
}

fillDone (fullTx, res) {
this.getGasPrice(fullTx, response => {
if (response.error) return res({ need: 'gasPrice', message: response.error.message })
const minGas = '0x' + (Math.floor(response.result * 1.2)).toString(16)
if (!fullTx.gasPrice || fullTx.gasPrice < minGas) fullTx.gasPrice = minGas
res(null, fullTx)
})
}

fillTx (rawTx, cb) {
const needs = {}
// if (!rawTx.nonce) needs.nonce = this.getNonce
if (!rawTx.gasPrice) needs.gasPrice = this.getGasPrice
// if (!rawTx.gasPrice) needs.gasPrice = this.getGasPrice
if (!rawTx.gas) needs.gas = this.getGasEstimate
let count = 0
const list = Object.keys(needs)
Expand All @@ -253,11 +262,11 @@ class Provider extends EventEmitter {
} else {
rawTx[need] = response.result
}
if (++count === list.length) errors.length > 0 ? cb(errors[0]) : cb(null, rawTx)
if (++count === list.length) errors.length > 0 ? cb(errors[0]) : this.fillDone(rawTx, cb)
})
})
} else {
cb(null, rawTx)
this.fillDone(rawTx, cb)
}
}

Expand Down
3 changes: 1 addition & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "frame",
"version": "0.2.2",
"version": "0.2.3",
"description": "An Ethereum Interface",
"main": "main",
"build": {
Expand Down

0 comments on commit 476c7c2

Please sign in to comment.