aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrankie <frankie.diamond@gmail.com>2017-08-09 12:16:49 +0800
committerGitHub <noreply@github.com>2017-08-09 12:16:49 +0800
commit57f6fce6b2524c4b36b591da5e600d0652f4077e (patch)
treec72727ee7c08fa080e8b764aee3b5ff36753b948
parentd40bd9a726b7bef900d36ed195e38e8537cc791d (diff)
parent25f9746dabb4ecc736a5cdd7b01b2d8a6c8151de (diff)
downloadtangerine-wallet-browser-57f6fce6b2524c4b36b591da5e600d0652f4077e.tar
tangerine-wallet-browser-57f6fce6b2524c4b36b591da5e600d0652f4077e.tar.gz
tangerine-wallet-browser-57f6fce6b2524c4b36b591da5e600d0652f4077e.tar.bz2
tangerine-wallet-browser-57f6fce6b2524c4b36b591da5e600d0652f4077e.tar.lz
tangerine-wallet-browser-57f6fce6b2524c4b36b591da5e600d0652f4077e.tar.xz
tangerine-wallet-browser-57f6fce6b2524c4b36b591da5e600d0652f4077e.tar.zst
tangerine-wallet-browser-57f6fce6b2524c4b36b591da5e600d0652f4077e.zip
Merge pull request #1882 from MetaMask/tx-cont-fixes
Tx cont fixes
-rw-r--r--app/scripts/controllers/transactions.js9
-rw-r--r--app/scripts/lib/util.js7
2 files changed, 12 insertions, 4 deletions
diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js
index 28130c164..58c468e22 100644
--- a/app/scripts/controllers/transactions.js
+++ b/app/scripts/controllers/transactions.js
@@ -40,7 +40,7 @@ module.exports = class TransactionController extends EventEmitter {
this.pendingTxTracker = new PendingTransactionTracker({
provider: this.provider,
nonceTracker: this.nonceTracker,
- getBalance: async (address) => {
+ getBalance: (address) => {
const account = this.ethStore.getState().accounts[address]
if (!account) return
return account.balance
@@ -382,9 +382,12 @@ module.exports = class TransactionController extends EventEmitter {
this._setTxStatus(txId, 'confirmed')
}
- setTxStatusFailed (txId, reason) {
+ setTxStatusFailed (txId, err) {
const txMeta = this.getTx(txId)
- txMeta.err = reason
+ txMeta.err = {
+ message: err.toString(),
+ stack: err.stack,
+ }
this.updateTx(txMeta)
this._setTxStatus(txId, 'failed')
}
diff --git a/app/scripts/lib/util.js b/app/scripts/lib/util.js
index 70390e95c..6dee9edf0 100644
--- a/app/scripts/lib/util.js
+++ b/app/scripts/lib/util.js
@@ -1,5 +1,6 @@
const ethUtil = require('ethereumjs-util')
-const BN = ethUtil.BN
+const assert = require('assert')
+const BN = require('bn.js')
module.exports = {
getStack,
@@ -15,6 +16,10 @@ function getStack () {
}
function sufficientBalance (txParams, hexBalance) {
+ // validate hexBalance is a hex string
+ assert.equal(typeof hexBalance, 'string', 'sufficientBalance - hexBalance is not a hex string')
+ assert.equal(hexBalance.slice(0, 2), '0x', 'sufficientBalance - hexBalance is not a hex string')
+
const balance = hexToBn(hexBalance)
const value = hexToBn(txParams.value)
const gasLimit = hexToBn(txParams.gas)