aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/tx-utils.js
diff options
context:
space:
mode:
authorFrankie <frankie.diamond@gmail.com>2017-07-14 03:48:50 +0800
committerGitHub <noreply@github.com>2017-07-14 03:48:50 +0800
commit9d3207fb7302e74d3d2f8ffad12d50dfd3885fdc (patch)
tree7fcde7cce82116803a9df3586ad5d91fe812d870 /app/scripts/lib/tx-utils.js
parent43b7d5f0ebd420d39eb9257b1edc235d58b0099d (diff)
parent7eccf5905a830853bbb1932dde9a7f4536d43f55 (diff)
downloadtangerine-wallet-browser-9d3207fb7302e74d3d2f8ffad12d50dfd3885fdc.tar
tangerine-wallet-browser-9d3207fb7302e74d3d2f8ffad12d50dfd3885fdc.tar.gz
tangerine-wallet-browser-9d3207fb7302e74d3d2f8ffad12d50dfd3885fdc.tar.bz2
tangerine-wallet-browser-9d3207fb7302e74d3d2f8ffad12d50dfd3885fdc.tar.lz
tangerine-wallet-browser-9d3207fb7302e74d3d2f8ffad12d50dfd3885fdc.tar.xz
tangerine-wallet-browser-9d3207fb7302e74d3d2f8ffad12d50dfd3885fdc.tar.zst
tangerine-wallet-browser-9d3207fb7302e74d3d2f8ffad12d50dfd3885fdc.zip
Merge pull request #1617 from MetaMask/nonce-tracker
transaction controller - use nonce-tracker
Diffstat (limited to 'app/scripts/lib/tx-utils.js')
-rw-r--r--app/scripts/lib/tx-utils.js17
1 files changed, 11 insertions, 6 deletions
diff --git a/app/scripts/lib/tx-utils.js b/app/scripts/lib/tx-utils.js
index 4e780fcc0..8f6943937 100644
--- a/app/scripts/lib/tx-utils.js
+++ b/app/scripts/lib/tx-utils.js
@@ -106,8 +106,13 @@ module.exports = class txProviderUtils {
return ethTx
}
- publishTransaction (rawTx, cb) {
- this.query.sendRawTransaction(rawTx, cb)
+ publishTransaction (rawTx) {
+ return new Promise((resolve, reject) => {
+ this.query.sendRawTransaction(rawTx, (err, ress) => {
+ if (err) reject(err)
+ else resolve(ress)
+ })
+ })
}
validateTxParams (txParams, cb) {
@@ -118,11 +123,11 @@ module.exports = class txProviderUtils {
}
}
- sufficientBalance (tx, hexBalance) {
+ sufficientBalance (txParams, hexBalance) {
const balance = hexToBn(hexBalance)
- const value = hexToBn(tx.value)
- const gasLimit = hexToBn(tx.gas)
- const gasPrice = hexToBn(tx.gasPrice)
+ const value = hexToBn(txParams.value)
+ const gasLimit = hexToBn(txParams.gas)
+ const gasPrice = hexToBn(txParams.gasPrice)
const maxCost = value.add(gasLimit.mul(gasPrice))
return balance.gte(maxCost)