@ -10,7 +10,12 @@ import NonceTracker from 'nonce-tracker'
import log from 'loglevel'
import log from 'loglevel'
import BigNumber from 'bignumber.js'
import BigNumber from 'bignumber.js'
import cleanErrorStack from '../../lib/cleanErrorStack'
import cleanErrorStack from '../../lib/cleanErrorStack'
import { hexToBn , bnToHex , BnMultiplyByFraction } from '../../lib/util'
import {
hexToBn ,
bnToHex ,
BnMultiplyByFraction ,
addHexPrefix ,
} from '../../lib/util'
import { TRANSACTION _NO _CONTRACT _ERROR _KEY } from '../../../../ui/app/helpers/constants/error-keys'
import { TRANSACTION _NO _CONTRACT _ERROR _KEY } from '../../../../ui/app/helpers/constants/error-keys'
import { getSwapsTokensReceivedFromTxMeta } from '../../../../ui/app/pages/swaps/swaps.util'
import { getSwapsTokensReceivedFromTxMeta } from '../../../../ui/app/pages/swaps/swaps.util'
import {
import {
@ -264,7 +269,7 @@ export default class TransactionController extends EventEmitter {
// ensure value
// ensure value
txMeta . txParams . value = txMeta . txParams . value
txMeta . txParams . value = txMeta . txParams . value
? ethUtil . addHexPrefix ( txMeta . txParams . value )
? addHexPrefix ( txMeta . txParams . value )
: '0x0'
: '0x0'
this . addTx ( txMeta )
this . addTx ( txMeta )
@ -324,7 +329,7 @@ export default class TransactionController extends EventEmitter {
}
}
const gasPrice = await this . query . gasPrice ( )
const gasPrice = await this . query . gasPrice ( )
return ethUtil . addHexPrefix ( gasPrice . toString ( 16 ) )
return addHexPrefix ( gasPrice . toString ( 16 ) )
}
}
/ * *
/ * *
@ -365,7 +370,7 @@ export default class TransactionController extends EventEmitter {
// add additional gas buffer to our estimation for safety
// add additional gas buffer to our estimation for safety
const gasLimit = this . txGasUtil . addGasBuffer (
const gasLimit = this . txGasUtil . addGasBuffer (
ethUtil . addHexPrefix ( estimatedGasHex ) ,
addHexPrefix ( estimatedGasHex ) ,
blockGasLimit ,
blockGasLimit ,
)
)
return { gasLimit , simulationFails }
return { gasLimit , simulationFails }
@ -501,7 +506,7 @@ export default class TransactionController extends EventEmitter {
const customOrNonce =
const customOrNonce =
customNonceValue === 0 ? customNonceValue : customNonceValue || nonce
customNonceValue === 0 ? customNonceValue : customNonceValue || nonce
txMeta . txParams . nonce = ethUtil . addHexPrefix ( customOrNonce . toString ( 16 ) )
txMeta . txParams . nonce = addHexPrefix ( customOrNonce . toString ( 16 ) )
// add nonce debugging information to txMeta
// add nonce debugging information to txMeta
txMeta . nonceDetails = nonceLock . nonceDetails
txMeta . nonceDetails = nonceLock . nonceDetails
if ( customNonceValue ) {
if ( customNonceValue ) {
@ -582,8 +587,8 @@ export default class TransactionController extends EventEmitter {
txHash = await this . query . sendRawTransaction ( rawTx )
txHash = await this . query . sendRawTransaction ( rawTx )
} catch ( error ) {
} catch ( error ) {
if ( error . message . toLowerCase ( ) . includes ( 'known transaction' ) ) {
if ( error . message . toLowerCase ( ) . includes ( 'known transaction' ) ) {
txHash = ethUtil . sha3 ( ethUtil . addHexPrefix ( rawTx ) ) . toString ( 'hex' )
txHash = ethUtil . sha3 ( addHexPrefix ( rawTx ) ) . toString ( 'hex' )
txHash = ethUtil . addHexPrefix ( txHash )
txHash = addHexPrefix ( txHash )
} else {
} else {
throw error
throw error
}
}