1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 01:47:00 +01:00

Increase send value precision

This commit is contained in:
Dan Finlay 2016-05-19 14:21:35 -07:00
parent 43a948e94b
commit 22a77b8041
3 changed files with 11 additions and 3 deletions

View File

@ -61,6 +61,7 @@ describe('util', function() {
var result = util.isValidAddress(address)
assert.ok(!result)
})
})
describe('numericBalance', function() {
@ -160,6 +161,13 @@ describe('util', function() {
describe('#normalizeNumberToWei', function() {
it('should handle a simple use case', function() {
var input = 0.0002
var output = util.normalizeNumberToWei(input, 'ether')
var str = output.toString(10)
assert.equal(str, '200000000000000')
})
it('should convert a kwei number to the appropriate equivalent wei', function() {
var result = util.normalizeNumberToWei(1.111, 'kwei')
assert.equal(result.toString(10), '1111', 'accepts decimals')

View File

@ -219,7 +219,7 @@ SendTransactionScreen.prototype.onSubmit = function() {
return this.props.dispatch(actions.displayWarning(message))
}
if ((util.isValidAddress(recipient) && !txData) || (!recipient && !txData)) {
if ((!util.isValidAddress(recipient) && !txData) || (!recipient && !txData)) {
var message = 'Recipient address is invalid.'
return this.props.dispatch(actions.displayWarning(message))
}

View File

@ -120,9 +120,9 @@ function normalizeToWei(amount, currency) {
return amount
}
var multiple = new ethUtil.BN('1000', 10)
var multiple = new ethUtil.BN('10000', 10)
function normalizeNumberToWei(n, currency) {
var enlarged = n * 1000
var enlarged = n * 10000
var amount = new ethUtil.BN(String(enlarged), 10)
return normalizeToWei(amount, currency).div(multiple)
}