mirror of
https://github.com/trezor/trezor-wallet
synced 2024-12-30 19:00:53 +00:00
formatUtils: conversion from/to decimal amount
This commit is contained in:
parent
a94095d527
commit
8bc2ec4206
@ -1,6 +1,7 @@
|
||||
/* @flow */
|
||||
|
||||
// TODO: chagne currency units
|
||||
import BigNumber from 'bignumber.js';
|
||||
|
||||
const currencyUnitsConstant: string = 'mbtc2';
|
||||
|
||||
export const formatAmount = (n: number, coinInfo: any, currencyUnits: string = currencyUnitsConstant): string => {
|
||||
@ -52,3 +53,7 @@ export const hexToString = (hex: string): string => {
|
||||
}
|
||||
return str;
|
||||
};
|
||||
|
||||
export const toDecimalAmount = (amount: string, decimals: number): string => new BigNumber(amount).div(10 ** decimals).toString(10);
|
||||
|
||||
export const toAbsoluteAmount = (amount: string, decimals: number): string => new BigNumber(amount).times(10 ** decimals).toString(10);
|
||||
|
Loading…
Reference in New Issue
Block a user