mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Modify test, replace clone package.
This commit is contained in:
parent
c6715dc2dd
commit
717db41d0b
@ -14,7 +14,7 @@ describe('BnInput', function () {
|
|||||||
const renderer = ReactTestUtils.createRenderer()
|
const renderer = ReactTestUtils.createRenderer()
|
||||||
|
|
||||||
let valueStr = '20'
|
let valueStr = '20'
|
||||||
while (valueStr.length < 20) {
|
while (valueStr.length < 15) {
|
||||||
valueStr += '0'
|
valueStr += '0'
|
||||||
}
|
}
|
||||||
const value = new BN(valueStr, 10)
|
const value = new BN(valueStr, 10)
|
||||||
@ -22,7 +22,7 @@ describe('BnInput', function () {
|
|||||||
let inputStr = '2.3'
|
let inputStr = '2.3'
|
||||||
|
|
||||||
let targetStr = '23'
|
let targetStr = '23'
|
||||||
while (targetStr.length < 19) {
|
while (targetStr.length < 14) {
|
||||||
targetStr += '0'
|
targetStr += '0'
|
||||||
}
|
}
|
||||||
const target = new BN(targetStr, 10)
|
const target = new BN(targetStr, 10)
|
||||||
|
@ -2,6 +2,7 @@ const Component = require('react').Component
|
|||||||
const h = require('react-hyperscript')
|
const h = require('react-hyperscript')
|
||||||
const inherits = require('util').inherits
|
const inherits = require('util').inherits
|
||||||
const actions = require('../actions')
|
const actions = require('../actions')
|
||||||
|
const clone = require('clone')
|
||||||
|
|
||||||
const ethUtil = require('ethereumjs-util')
|
const ethUtil = require('ethereumjs-util')
|
||||||
const BN = ethUtil.BN
|
const BN = ethUtil.BN
|
||||||
@ -347,14 +348,14 @@ PendingTx.prototype.gasPriceChanged = function (newBN) {
|
|||||||
log.info(`Gas price changed to: ${newBN.toString(10)}`)
|
log.info(`Gas price changed to: ${newBN.toString(10)}`)
|
||||||
const txMeta = this.gatherTxMeta()
|
const txMeta = this.gatherTxMeta()
|
||||||
txMeta.txParams.gasPrice = '0x' + newBN.toString('hex')
|
txMeta.txParams.gasPrice = '0x' + newBN.toString('hex')
|
||||||
this.setState({ txData: cloneObj(txMeta) })
|
this.setState({ txData: clone(txMeta) })
|
||||||
}
|
}
|
||||||
|
|
||||||
PendingTx.prototype.gasLimitChanged = function (newBN) {
|
PendingTx.prototype.gasLimitChanged = function (newBN) {
|
||||||
log.info(`Gas limit changed to ${newBN.toString(10)}`)
|
log.info(`Gas limit changed to ${newBN.toString(10)}`)
|
||||||
const txMeta = this.gatherTxMeta()
|
const txMeta = this.gatherTxMeta()
|
||||||
txMeta.txParams.gas = '0x' + newBN.toString('hex')
|
txMeta.txParams.gas = '0x' + newBN.toString('hex')
|
||||||
this.setState({ txData: cloneObj(txMeta) })
|
this.setState({ txData: clone(txMeta) })
|
||||||
}
|
}
|
||||||
|
|
||||||
PendingTx.prototype.resetGasFields = function () {
|
PendingTx.prototype.resetGasFields = function () {
|
||||||
@ -405,7 +406,7 @@ PendingTx.prototype.gatherTxMeta = function () {
|
|||||||
log.debug(`pending-tx gatherTxMeta`)
|
log.debug(`pending-tx gatherTxMeta`)
|
||||||
const props = this.props
|
const props = this.props
|
||||||
const state = this.state
|
const state = this.state
|
||||||
const txData = cloneObj(state.txData) || cloneObj(props.txData)
|
const txData = clone(state.txData) || clone(props.txData)
|
||||||
|
|
||||||
log.debug(`UI has defaulted to tx meta ${JSON.stringify(txData)}`)
|
log.debug(`UI has defaulted to tx meta ${JSON.stringify(txData)}`)
|
||||||
return txData
|
return txData
|
||||||
@ -435,7 +436,3 @@ function forwardCarrat () {
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function cloneObj (obj) {
|
|
||||||
return JSON.parse(JSON.stringify(obj))
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user