mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-23 02:10:12 +01:00
Merge pull request #4654 from TrejGun/bignumber
fixes #4307 BigNumber casting issue
This commit is contained in:
commit
8def5281b4
@ -140,7 +140,7 @@ const addCurrencies = (a, b, options = {}) => {
|
||||
bBase,
|
||||
...conversionOptions
|
||||
} = options
|
||||
const value = (new BigNumber(a, aBase)).add(b, bBase)
|
||||
const value = (new BigNumber(a.toString(), aBase)).add(b.toString(), bBase)
|
||||
|
||||
return converter({
|
||||
value,
|
||||
|
22
ui/app/conversion-util.test.js
Normal file
22
ui/app/conversion-util.test.js
Normal file
@ -0,0 +1,22 @@
|
||||
import assert from 'assert'
|
||||
import {addCurrencies} from './conversion-util'
|
||||
|
||||
|
||||
describe('conversion utils', () => {
|
||||
describe('addCurrencies()', () => {
|
||||
it('add whole numbers', () => {
|
||||
const result = addCurrencies(3, 9)
|
||||
assert.equal(result.toNumber(), 12)
|
||||
})
|
||||
|
||||
it('add decimals', () => {
|
||||
const result = addCurrencies(1.3, 1.9)
|
||||
assert.equal(result.toNumber(), 3.2)
|
||||
})
|
||||
|
||||
it('add repeating decimals', () => {
|
||||
const result = addCurrencies(1 / 3, 1 / 9)
|
||||
assert.equal(result.toNumber(), 0.4444444444444444)
|
||||
})
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue
Block a user