aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'app/scripts')
-rw-r--r--app/scripts/lib/config-manager.js12
-rw-r--r--app/scripts/lib/id-management.js9
-rw-r--r--app/scripts/lib/idStore.js1
-rw-r--r--app/scripts/lib/tx-utils.js4
-rw-r--r--app/scripts/metamask-controller.js23
-rw-r--r--app/scripts/transaction-manager.js15
6 files changed, 17 insertions, 47 deletions
diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js
index ea5e49b19..6868637e5 100644
--- a/app/scripts/lib/config-manager.js
+++ b/app/scripts/lib/config-manager.js
@@ -228,18 +228,6 @@ ConfigManager.prototype._emitUpdates = function (state) {
})
}
-ConfigManager.prototype.getGasMultiplier = function () {
- var data = this.getData()
- return data.gasMultiplier
-}
-
-ConfigManager.prototype.setGasMultiplier = function (gasMultiplier) {
- var data = this.getData()
-
- data.gasMultiplier = gasMultiplier
- this.setData(data)
-}
-
ConfigManager.prototype.setLostAccounts = function (lostAccounts) {
var data = this.getData()
data.lostAccounts = lostAccounts
diff --git a/app/scripts/lib/id-management.js b/app/scripts/lib/id-management.js
index 421f2105f..90b3fdb13 100644
--- a/app/scripts/lib/id-management.js
+++ b/app/scripts/lib/id-management.js
@@ -7,7 +7,6 @@
*/
const ethUtil = require('ethereumjs-util')
-const BN = ethUtil.BN
const Transaction = require('ethereumjs-tx')
module.exports = IdManagement
@@ -25,13 +24,9 @@ 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
+ // normalize values
+ txParams.gasPrice = ethUtil.intToHex(txParams.gasPrice)
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 7a6968c6c..01474035e 100644
--- a/app/scripts/lib/idStore.js
+++ b/app/scripts/lib/idStore.js
@@ -95,7 +95,6 @@ IdentityStore.prototype.getState = function () {
isUnlocked: this._isUnlocked(),
seedWords: seedWords,
selectedAddress: configManager.getSelectedAccount(),
- gasMultiplier: configManager.getGasMultiplier(),
}))
}
diff --git a/app/scripts/lib/tx-utils.js b/app/scripts/lib/tx-utils.js
index 240a6ab47..19a2d430e 100644
--- a/app/scripts/lib/tx-utils.js
+++ b/app/scripts/lib/tx-utils.js
@@ -92,11 +92,10 @@ module.exports = class txProviderUtils {
}
// builds ethTx from txParams object
- buildEthTxFromParams (txParams, gasMultiplier = 1) {
+ buildEthTxFromParams (txParams) {
// apply gas multiplyer
let gasPrice = new BN(ethUtil.stripHexPrefix(txParams.gasPrice), 16)
// multiply and divide by 100 so as to add percision to integer mul
- gasPrice = gasPrice.mul(new BN(gasMultiplier * 100, 10)).div(new BN(100, 10))
txParams.gasPrice = ethUtil.intToHex(gasPrice.toNumber())
// normalize values
txParams.to = normalize(txParams.to)
@@ -106,6 +105,7 @@ module.exports = class txProviderUtils {
txParams.gasLimit = normalize(txParams.gasLimit || txParams.gas)
txParams.nonce = normalize(txParams.nonce)
// build ethTx
+ log.info(`Prepared tx for signing: ${JSON.stringify(txParams)}`)
const ethTx = new Transaction(txParams)
return ethTx
}
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index f172c67a8..bd01a260d 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -248,7 +248,6 @@ module.exports = class MetamaskController extends EventEmitter {
setProviderType: this.setProviderType.bind(this),
useEtherscanProvider: this.useEtherscanProvider.bind(this),
setCurrentCurrency: this.setCurrentCurrency.bind(this),
- setGasMultiplier: this.setGasMultiplier.bind(this),
markAccountsFound: this.markAccountsFound.bind(this),
// coinbase
buyEth: this.buyEth.bind(this),
@@ -276,8 +275,9 @@ module.exports = class MetamaskController extends EventEmitter {
exportAccount: nodeify(keyringController.exportAccount).bind(keyringController),
// txManager
- approveTransaction: txManager.approveTransaction.bind(txManager),
- cancelTransaction: txManager.cancelTransaction.bind(txManager),
+ approveTransaction: txManager.approveTransaction.bind(txManager),
+ cancelTransaction: txManager.cancelTransaction.bind(txManager),
+ updateAndApproveTransaction: this.updateAndApproveTx.bind(this),
// messageManager
signMessage: nodeify(this.signMessage).bind(this),
@@ -407,6 +407,7 @@ module.exports = class MetamaskController extends EventEmitter {
//
newUnapprovedTransaction (txParams, cb) {
+ log.debug(`MetaMaskController newUnapprovedTransaction ${JSON.stringify(txParams)}`)
const self = this
self.txManager.addUnapprovedTransaction(txParams, (err, txMeta) => {
if (err) return cb(err)
@@ -462,6 +463,13 @@ module.exports = class MetamaskController extends EventEmitter {
})
}
+ updateAndApproveTx(txMeta, cb) {
+ log.debug(`MetaMaskController - updateAndApproveTx: ${JSON.stringify(txMeta)}`)
+ const txManager = this.txManager
+ txManager.updateTx(txMeta)
+ txManager.approveTransaction(txMeta.id, cb)
+ }
+
signMessage (msgParams, cb) {
log.info('MetaMaskController - signMessage')
const msgId = msgParams.metamaskId
@@ -644,15 +652,6 @@ module.exports = class MetamaskController extends EventEmitter {
this.shapeshiftController.createShapeShiftTx(depositAddress, depositType)
}
- setGasMultiplier (gasMultiplier, cb) {
- try {
- this.txManager.setGasMultiplier(gasMultiplier)
- cb()
- } catch (err) {
- cb(err)
- }
- }
-
//
// network
//
diff --git a/app/scripts/transaction-manager.js b/app/scripts/transaction-manager.js
index 6299091f2..07c90af7e 100644
--- a/app/scripts/transaction-manager.js
+++ b/app/scripts/transaction-manager.js
@@ -13,7 +13,6 @@ module.exports = class TransactionManager extends EventEmitter {
super()
this.store = new ObservableStore(extend({
transactions: [],
- gasMultiplier: 1,
}, opts.initState))
this.memStore = new ObservableStore({})
this.networkStore = opts.networkStore || new ObservableStore({})
@@ -52,14 +51,6 @@ module.exports = class TransactionManager extends EventEmitter {
return fullTxList.filter(txMeta => txMeta.metamaskNetworkId === network)
}
- getGasMultiplier () {
- return this.store.getState().gasMultiplier
- }
-
- setGasMultiplier (gasMultiplier) {
- return this.store.updateState({ gasMultiplier })
- }
-
// Adds a tx to the txlist
addTx (txMeta) {
var txList = this.getTxList()
@@ -129,7 +120,6 @@ module.exports = class TransactionManager extends EventEmitter {
id: txId,
time: time,
status: 'unapproved',
- gasMultiplier: this.getGasMultiplier(),
metamaskNetworkId: this.getNetwork(),
txParams: txParams,
}
@@ -147,16 +137,15 @@ module.exports = class TransactionManager extends EventEmitter {
setMaxTxCostAndFee (txMeta) {
var txParams = txMeta.txParams
- var gasMultiplier = txMeta.gasMultiplier
var gasCost = new BN(ethUtil.stripHexPrefix(txParams.gas || txMeta.estimatedGas), 16)
var gasPrice = new BN(ethUtil.stripHexPrefix(txParams.gasPrice || '0x4a817c800'), 16)
- gasPrice = gasPrice.mul(new BN(gasMultiplier * 100), 10).div(new BN(100, 10))
var txFee = gasCost.mul(gasPrice)
var txValue = new BN(ethUtil.stripHexPrefix(txParams.value || '0x0'), 16)
var maxCost = txValue.add(txFee)
txMeta.txFee = txFee
txMeta.txValue = txValue
txMeta.maxCost = maxCost
+ txMeta.gasPrice = gasPrice
this.updateTx(txMeta)
}
@@ -209,7 +198,7 @@ module.exports = class TransactionManager extends EventEmitter {
let txMeta = this.getTx(txId)
let txParams = txMeta.txParams
let fromAddress = txParams.from
- let ethTx = this.txProviderUtils.buildEthTxFromParams(txParams, txMeta.gasMultiplier)
+ let ethTx = this.txProviderUtils.buildEthTxFromParams(txParams)
this.signEthTx(ethTx, fromAddress).then(() => {
this.setTxStatusSigned(txMeta.id)
cb(null, ethUtil.bufferToHex(ethTx.serialize()))