diff options
author | Kevin Serrano <kevgagser@gmail.com> | 2016-10-20 05:57:30 +0800 |
---|---|---|
committer | Kevin Serrano <kevgagser@gmail.com> | 2016-10-20 05:57:30 +0800 |
commit | afbc4c832ba86fcb94b612c93796a5ffa422b457 (patch) | |
tree | dbdaa16920fd175171603b182d332dbf87655bd4 /app/scripts/lib | |
parent | ad3fa24a28c0ec45dca43a257005626a4027487a (diff) | |
parent | a88a48ba14a213920ce1becb0b70cf10192ad3e5 (diff) | |
download | tangerine-wallet-browser-afbc4c832ba86fcb94b612c93796a5ffa422b457.tar tangerine-wallet-browser-afbc4c832ba86fcb94b612c93796a5ffa422b457.tar.gz tangerine-wallet-browser-afbc4c832ba86fcb94b612c93796a5ffa422b457.tar.bz2 tangerine-wallet-browser-afbc4c832ba86fcb94b612c93796a5ffa422b457.tar.lz tangerine-wallet-browser-afbc4c832ba86fcb94b612c93796a5ffa422b457.tar.xz tangerine-wallet-browser-afbc4c832ba86fcb94b612c93796a5ffa422b457.tar.zst tangerine-wallet-browser-afbc4c832ba86fcb94b612c93796a5ffa422b457.zip |
Git merge resolution.
Diffstat (limited to 'app/scripts/lib')
-rw-r--r-- | app/scripts/lib/config-manager.js | 12 | ||||
-rw-r--r-- | app/scripts/lib/id-management.js | 7 | ||||
-rw-r--r-- | app/scripts/lib/idStore.js | 14 |
3 files changed, 32 insertions, 1 deletions
diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js index 1c0e3b696..d12304c46 100644 --- a/app/scripts/lib/config-manager.js +++ b/app/scripts/lib/config-manager.js @@ -416,3 +416,15 @@ ConfigManager.prototype.createShapeShiftTx = function (depositAddress, depositTy } this.setData(data) } + +ConfigManager.prototype.getGasMultiplier = function () { + var data = this.getData() + return ('gasMultiplier' in data) && data.gasMultiplier +} + +ConfigManager.prototype.setGasMultiplier = function (gasMultiplier) { + var data = this.getData() + + data.gasMultiplier = gasMultiplier + this.setData(data) +} diff --git a/app/scripts/lib/id-management.js b/app/scripts/lib/id-management.js index 2d42e1e30..421f2105f 100644 --- a/app/scripts/lib/id-management.js +++ b/app/scripts/lib/id-management.js @@ -7,6 +7,7 @@ */ const ethUtil = require('ethereumjs-util') +const BN = ethUtil.BN const Transaction = require('ethereumjs-tx') module.exports = IdManagement @@ -24,7 +25,13 @@ function IdManagement (opts) { } this.signTx = function (txParams) { + // calculate gas with custom gas multiplier + var gasMultiplier = this.configManager.getGasMultiplier() || 1 + var gasPrice = new BN(ethUtil.stripHexPrefix(txParams.gasPrice), 16) + gasPrice = gasPrice.mul(new BN(gasMultiplier * 100, 10)).div(new BN(100, 10)) + txParams.gasPrice = ethUtil.intToHex(gasPrice.toNumber()) // normalize values + txParams.to = ethUtil.addHexPrefix(txParams.to) txParams.from = ethUtil.addHexPrefix(txParams.from.toLowerCase()) txParams.value = ethUtil.addHexPrefix(txParams.value) diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js index 6837a1e8d..9d0ca7f19 100644 --- a/app/scripts/lib/idStore.js +++ b/app/scripts/lib/idStore.js @@ -2,6 +2,7 @@ const EventEmitter = require('events').EventEmitter const inherits = require('util').inherits const async = require('async') const ethUtil = require('ethereumjs-util') +const BN = ethUtil.BN const EthQuery = require('eth-query') const KeyStore = require('eth-lightwallet').keystore const clone = require('clone') @@ -112,6 +113,8 @@ IdentityStore.prototype.getState = function () { currentFiat: configManager.getCurrentFiat(), conversionRate: configManager.getConversionRate(), conversionDate: configManager.getConversionDate(), + gasMultiplier: configManager.getGasMultiplier(), + })) } @@ -211,6 +214,7 @@ IdentityStore.prototype.exportAccount = function (address, cb) { // comes from dapp via zero-client hooked-wallet provider IdentityStore.prototype.addUnconfirmedTransaction = function (txParams, onTxDoneCb, cb) { const configManager = this.configManager + var self = this // create txData obj with parameters and meta data var time = (new Date()).getTime() @@ -222,6 +226,7 @@ IdentityStore.prototype.addUnconfirmedTransaction = function (txParams, onTxDone txParams: txParams, time: time, status: 'unconfirmed', + gasMultiplier: configManager.getGasMultiplier() || 1, } console.log('addUnconfirmedTransaction:', txData) @@ -262,7 +267,7 @@ IdentityStore.prototype.addUnconfirmedTransaction = function (txParams, onTxDone function estimateGas(cb){ query.estimateGas(txParams, function(err, result){ if (err) return cb(err) - txData.estimatedGas = result + txData.estimatedGas = self.addGasBuffer(result) cb() }) } @@ -277,6 +282,13 @@ IdentityStore.prototype.addUnconfirmedTransaction = function (txParams, onTxDone } } +IdentityStore.prototype.addGasBuffer = function (gasHex) { + var gas = new BN(gasHex, 16) + var buffer = new BN('100000', 10) + var result = gas.add(buffer) + return ethUtil.addHexPrefix(result.toString(16)) +} + // comes from metamask ui IdentityStore.prototype.approveTransaction = function (txId, cb) { const configManager = this.configManager |