@ -13,7 +13,6 @@ module.exports = class TransactionManager extends EventEmitter {
super ( )
super ( )
this . store = new ObservableStore ( extend ( {
this . store = new ObservableStore ( extend ( {
transactions : [ ] ,
transactions : [ ] ,
gasMultiplier : 1 ,
} , opts . initState ) )
} , opts . initState ) )
this . memStore = new ObservableStore ( { } )
this . memStore = new ObservableStore ( { } )
this . networkStore = opts . networkStore || 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 )
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
// Adds a tx to the txlist
addTx ( txMeta ) {
addTx ( txMeta ) {
var txList = this . getTxList ( )
var txList = this . getTxList ( )
@ -129,7 +120,6 @@ module.exports = class TransactionManager extends EventEmitter {
id : txId ,
id : txId ,
time : time ,
time : time ,
status : 'unapproved' ,
status : 'unapproved' ,
gasMultiplier : this . getGasMultiplier ( ) ,
metamaskNetworkId : this . getNetwork ( ) ,
metamaskNetworkId : this . getNetwork ( ) ,
txParams : txParams ,
txParams : txParams ,
}
}
@ -147,10 +137,8 @@ module.exports = class TransactionManager extends EventEmitter {
setMaxTxCostAndFee ( txMeta ) {
setMaxTxCostAndFee ( txMeta ) {
var txParams = txMeta . txParams
var txParams = txMeta . txParams
var gasMultiplier = txMeta . gasMultiplier
var gasCost = new BN ( ethUtil . stripHexPrefix ( txParams . gas || txMeta . estimatedGas ) , 16 )
var gasCost = new BN ( ethUtil . stripHexPrefix ( txParams . gas || txMeta . estimatedGas ) , 16 )
var gasPrice = new BN ( ethUtil . stripHexPrefix ( txParams . gasPrice || '0x4a817c800' ) , 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 txFee = gasCost . mul ( gasPrice )
var txValue = new BN ( ethUtil . stripHexPrefix ( txParams . value || '0x0' ) , 16 )
var txValue = new BN ( ethUtil . stripHexPrefix ( txParams . value || '0x0' ) , 16 )
var maxCost = txValue . add ( txFee )
var maxCost = txValue . add ( txFee )
@ -210,7 +198,7 @@ module.exports = class TransactionManager extends EventEmitter {
let txMeta = this . getTx ( txId )
let txMeta = this . getTx ( txId )
let txParams = txMeta . txParams
let txParams = txMeta . txParams
let fromAddress = txParams . from
let fromAddress = txParams . from
let ethTx = this . txProviderUtils . buildEthTxFromParams ( txParams , txMeta . gasMultiplier )
let ethTx = this . txProviderUtils . buildEthTxFromParams ( txParams )
this . signEthTx ( ethTx , fromAddress ) . then ( ( ) => {
this . signEthTx ( ethTx , fromAddress ) . then ( ( ) => {
this . setTxStatusSigned ( txMeta . id )
this . setTxStatusSigned ( txMeta . id )
cb ( null , ethUtil . bufferToHex ( ethTx . serialize ( ) ) )
cb ( null , ethUtil . bufferToHex ( ethTx . serialize ( ) ) )