mirror of
https://github.com/trezor/trezor-wallet
synced 2025-05-28 19:58:45 +00:00
formatUtils: conversion from/to decimal amount
This commit is contained in:
parent
a94095d527
commit
8bc2ec4206
@ -1,6 +1,7 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
|
|
||||||
// TODO: chagne currency units
|
import BigNumber from 'bignumber.js';
|
||||||
|
|
||||||
const currencyUnitsConstant: string = 'mbtc2';
|
const currencyUnitsConstant: string = 'mbtc2';
|
||||||
|
|
||||||
export const formatAmount = (n: number, coinInfo: any, currencyUnits: string = currencyUnitsConstant): string => {
|
export const formatAmount = (n: number, coinInfo: any, currencyUnits: string = currencyUnitsConstant): string => {
|
||||||
@ -52,3 +53,7 @@ export const hexToString = (hex: string): string => {
|
|||||||
}
|
}
|
||||||
return str;
|
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