@helium/currency
Advanced tools
Comparing version 3.0.0 to 3.16.0
import BigNumber from 'bignumber.js'; | ||
import { AnyCurrencyType } from './CurrencyType'; | ||
import { NetworkTokens, USDollars, DataCredits, BaseCurrencyType } from './currency_types'; | ||
@@ -10,2 +11,3 @@ export default class Balance<T extends BaseCurrencyType> { | ||
constructor(integerBalance: number | undefined, type: T); | ||
static fromFloat(float: number, currencyType: AnyCurrencyType): Balance<AnyCurrencyType>; | ||
toString(maxDecimalPlaces?: number): string; | ||
@@ -12,0 +14,0 @@ plus(balance: Balance<T>): Balance<T>; |
@@ -31,2 +31,7 @@ "use strict"; | ||
} | ||
static fromFloat(float, currencyType) { | ||
const bigFloat = new bignumber_js_1.default(float); | ||
const integerBalance = bigFloat.dividedBy(currencyType.coefficient).toNumber(); | ||
return new Balance(integerBalance, currencyType); | ||
} | ||
toString(maxDecimalPlaces) { | ||
@@ -33,0 +38,0 @@ let numberString = this.bigBalance.toFormat(maxDecimalPlaces); |
{ | ||
"name": "@helium/currency", | ||
"version": "3.0.0", | ||
"version": "3.16.0", | ||
"description": "Utilities for handling different currency types on the Helium blockchain", | ||
@@ -31,3 +31,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "0a68af326f693378fdd687e8c809486a2efa6762" | ||
"gitHead": "e764bb372ca18d2709ea22d0b8c84d77d35739aa" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40500
304