diff options
author | Frankie <frankie.pangilinan@consensys.net> | 2016-10-13 10:35:09 +0800 |
---|---|---|
committer | Frankie <frankie.pangilinan@consensys.net> | 2016-10-14 06:10:29 +0800 |
commit | c400f7c0f6bff13400eedcd80fdc83e572eb42a8 (patch) | |
tree | 2c7baacd4f7439488e53d412ef2daf8fde520878 /app/scripts/lib | |
parent | 229d95956bc36ec413533df00389f8c5127e050b (diff) | |
download | tangerine-wallet-browser-c400f7c0f6bff13400eedcd80fdc83e572eb42a8.tar tangerine-wallet-browser-c400f7c0f6bff13400eedcd80fdc83e572eb42a8.tar.gz tangerine-wallet-browser-c400f7c0f6bff13400eedcd80fdc83e572eb42a8.tar.bz2 tangerine-wallet-browser-c400f7c0f6bff13400eedcd80fdc83e572eb42a8.tar.lz tangerine-wallet-browser-c400f7c0f6bff13400eedcd80fdc83e572eb42a8.tar.xz tangerine-wallet-browser-c400f7c0f6bff13400eedcd80fdc83e572eb42a8.tar.zst tangerine-wallet-browser-c400f7c0f6bff13400eedcd80fdc83e572eb42a8.zip |
Fix gasPrice range
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 | 8 | ||||
-rw-r--r-- | app/scripts/lib/idStore.js | 4 |
3 files changed, 20 insertions, 4 deletions
diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js index ecc9bc5f7..cced32670 100644 --- a/app/scripts/lib/config-manager.js +++ b/app/scripts/lib/config-manager.js @@ -384,3 +384,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 2a985265c..002f03047 100644 --- a/app/scripts/lib/id-management.js +++ b/app/scripts/lib/id-management.js @@ -26,10 +26,10 @@ function IdManagement (opts) { this.signTx = function (txParams) { // calculate gas with custom gas multiplier - var gasMultiplier = txParams.gasMultiplier || 1 - delete txParams.gasMultiplier - var gasPrice = parseFloat(new BN(ethUtil.stripHexPrefix(txParams.gasPrice), 16).toString()) * gasMultiplier - txParams.gasPrice = ethUtil.intToHex(parseInt(gasPrice)) + var gasMultiplier = this.configManager.getGasMultiplier() || 1 + var gasPrice = new BN(ethUtil.stripHexPrefix(txParams.gasPrice), 16) + gasPrice = gasPrice.mul(new BN(gasMultiplier * 100)).div(new BN(100, 10)) + txParams.gasPrice = ethUtil.intToHex(gasPrice.toNumber()) // normalize values txParams.to = ethUtil.addHexPrefix(txParams.to) diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js index 6837a1e8d..aa77c3360 100644 --- a/app/scripts/lib/idStore.js +++ b/app/scripts/lib/idStore.js @@ -112,6 +112,8 @@ IdentityStore.prototype.getState = function () { currentFiat: configManager.getCurrentFiat(), conversionRate: configManager.getConversionRate(), conversionDate: configManager.getConversionDate(), + gasMultiplier: configManager.getGasMultiplier(), + })) } @@ -211,6 +213,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 +225,7 @@ IdentityStore.prototype.addUnconfirmedTransaction = function (txParams, onTxDone txParams: txParams, time: time, status: 'unconfirmed', + gasMultiplier: configManager.getGasMultiplier() || 1, } console.log('addUnconfirmedTransaction:', txData) |