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 | |
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')
-rw-r--r-- | app/scripts/contentscript.js | 16 | ||||
-rw-r--r-- | app/scripts/inpage.js | 2 | ||||
-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 | ||||
-rw-r--r-- | app/scripts/metamask-controller.js | 9 |
6 files changed, 56 insertions, 4 deletions
diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js index 3ad145e3e..e2a968ac9 100644 --- a/app/scripts/contentscript.js +++ b/app/scripts/contentscript.js @@ -69,6 +69,18 @@ function setupStreams(){ } function shouldInjectWeb3(){ - var shouldInject = (window.location.href.indexOf('.pdf') === -1) - return shouldInject + return isAllowedSuffix(window.location.href) +} + +function isAllowedSuffix(testCase) { + var prohibitedTypes = ['xml', 'pdf'] + var currentUrl = window.location.href + var currentRegex + for (let i = 0; i < prohibitedTypes.length; i++) { + currentRegex = new RegExp(`\.${prohibitedTypes[i]}$`) + if (currentRegex.test(currentUrl)) { + return false + } + } + return true } diff --git a/app/scripts/inpage.js b/app/scripts/inpage.js index ef199946c..85dd70b4d 100644 --- a/app/scripts/inpage.js +++ b/app/scripts/inpage.js @@ -43,7 +43,7 @@ reloadStream.once('data', triggerReload) var pingChannel = inpageProvider.multiStream.createStream('pingpong') var pingStream = new PingStream({ objectMode: true }) // wait for first successful reponse -metamaskStream.once('data', function(){ +metamaskStream.once('_data', function(){ pingStream.pipe(pingChannel).pipe(pingStream) }) endOfStream(pingStream, triggerReload) 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 diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 9f4fcfefb..92551d633 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -57,6 +57,7 @@ module.exports = class MetamaskController { agreeToEthWarning: this.agreeToEthWarning.bind(this), setTOSHash: this.setTOSHash.bind(this), checkTOSChange: this.checkTOSChange.bind(this), + setGasMultiplier: this.setGasMultiplier.bind(this), // forward directly to idStore createNewVault: idStore.createNewVault.bind(idStore), @@ -395,4 +396,12 @@ module.exports = class MetamaskController { }) } + setGasMultiplier (gasMultiplier, cb) { + try { + this.configManager.setGasMultiplier(gasMultiplier) + cb() + } catch (e) { + cb(e) + } + } } |