aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2016-11-11 13:19:34 +0800
committerkumavis <aaron@kumavis.me>2016-11-11 13:19:34 +0800
commit536cab0687b6eb652401859cb41ae90dd7a62c1f (patch)
treee8021eadbff3d2c249deb453da8e21b2d729f0dd
parent3775a4bf799efc99cfe3d46b35fc0b39a82c94c2 (diff)
downloadtangerine-wallet-browser-536cab0687b6eb652401859cb41ae90dd7a62c1f.tar
tangerine-wallet-browser-536cab0687b6eb652401859cb41ae90dd7a62c1f.tar.gz
tangerine-wallet-browser-536cab0687b6eb652401859cb41ae90dd7a62c1f.tar.bz2
tangerine-wallet-browser-536cab0687b6eb652401859cb41ae90dd7a62c1f.tar.lz
tangerine-wallet-browser-536cab0687b6eb652401859cb41ae90dd7a62c1f.tar.xz
tangerine-wallet-browser-536cab0687b6eb652401859cb41ae90dd7a62c1f.tar.zst
tangerine-wallet-browser-536cab0687b6eb652401859cb41ae90dd7a62c1f.zip
detect tx error - show warning and fix gasLimit
-rw-r--r--app/scripts/lib/idStore.js18
-rw-r--r--ui/app/components/pending-tx.js9
2 files changed, 25 insertions, 2 deletions
diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js
index dd895a6c0..cd717df28 100644
--- a/app/scripts/lib/idStore.js
+++ b/app/scripts/lib/idStore.js
@@ -259,10 +259,24 @@ IdentityStore.prototype.addUnconfirmedTransaction = function (txParams, onTxDone
}
function estimateGas(cb){
- query.estimateGas(txParams, function(err, result){
+ var estimationParams = extend(txParams)
+ // 1 billion gas for estimation
+ var gasLimit = '0x3b9aca00'
+ estimationParams.gas = gasLimit
+ query.estimateGas(estimationParams, function(err, result){
if (err) return cb(err)
+ if (result === estimationParams.gas) {
+ txData.simulationFails = true
+ query.getBlockByNumber('latest', true, function(err, block){
+ if (err) return cb(err)
+ txData.estimatedGas = block.gasLimit
+ txData.txParams.gas = block.gasLimit
+ cb()
+ })
+ return
+ }
txData.estimatedGas = self.addGasBuffer(result)
- txData.txParams.gasLimit = txData.estimatedGas
+ txData.txParams.gas = txData.estimatedGas
cb()
})
}
diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js
index 4c27a8092..b619020d1 100644
--- a/ui/app/components/pending-tx.js
+++ b/ui/app/components/pending-tx.js
@@ -30,6 +30,15 @@ PendingTx.prototype.render = function () {
}
`),
+ txData.simulationFails ?
+ h('span.error', {
+ style: {
+ marginLeft: 50,
+ fontSize: '0.9em',
+ },
+ }, 'Transaction Error. Exception thrown in contract code.')
+ : null,
+
state.insufficientBalance ?
h('span.error', {
style: {