mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge pull request #4852 from keyiiiii/fix-token-amount
Fix token amount
This commit is contained in:
commit
78a1bcfdec
@ -1,5 +1,6 @@
|
|||||||
const log = require('loglevel')
|
const log = require('loglevel')
|
||||||
const util = require('./util')
|
const util = require('./util')
|
||||||
|
const BigNumber = require('bignumber.js')
|
||||||
|
|
||||||
function tokenInfoGetter () {
|
function tokenInfoGetter () {
|
||||||
const tokens = {}
|
const tokens = {}
|
||||||
@ -43,9 +44,7 @@ async function getSymbolAndDecimals (tokenAddress, existingTokens = []) {
|
|||||||
|
|
||||||
function calcTokenAmount (value, decimals) {
|
function calcTokenAmount (value, decimals) {
|
||||||
const multiplier = Math.pow(10, Number(decimals || 0))
|
const multiplier = Math.pow(10, Number(decimals || 0))
|
||||||
const amount = Number(value / multiplier)
|
return new BigNumber(value).div(multiplier).toNumber()
|
||||||
|
|
||||||
return amount
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user