@heliofi/common 0.1.340 → 0.1.341
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/domain/services/CommonCurrencyService.d.ts +0 -1
- package/dist/src/domain/services/CommonCurrencyService.js +3 -6
- package/dist/src/domain/services/CommonCurrencyService.js.map +1 -1
- package/dist/src/domain/services/CurrencyService.d.ts +0 -3
- package/dist/src/domain/services/CurrencyService.js +0 -16
- package/dist/src/domain/services/CurrencyService.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
2
|
import { Currency } from '../model';
|
|
3
3
|
export declare class CommonCurrencyService {
|
|
4
|
-
static fromMinimalUnits(decimals: number, amount: number): number;
|
|
5
4
|
static minValueFromCurrencyMinDecimals(currency?: Pick<Currency, 'decimals' | 'minDecimals'>): BigNumber | undefined;
|
|
6
5
|
}
|
|
@@ -6,10 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.CommonCurrencyService = void 0;
|
|
7
7
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
8
|
class CommonCurrencyService {
|
|
9
|
-
static fromMinimalUnits(decimals, amount) {
|
|
10
|
-
const decimalsValue = Number.isNaN(decimals) ? 0 : decimals;
|
|
11
|
-
return parseFloat((amount / 10 ** decimalsValue).toFixed(3));
|
|
12
|
-
}
|
|
13
9
|
static minValueFromCurrencyMinDecimals(currency) {
|
|
14
10
|
if (!currency)
|
|
15
11
|
return undefined;
|
|
@@ -18,8 +14,9 @@ class CommonCurrencyService {
|
|
|
18
14
|
if (!currency.decimals)
|
|
19
15
|
return undefined;
|
|
20
16
|
const numDecimals = currency.decimals - currency.minDecimals;
|
|
21
|
-
if (numDecimals <= 0)
|
|
22
|
-
|
|
17
|
+
if (numDecimals <= 0) {
|
|
18
|
+
throw new Error('Unable to get min value from currency when decimals - minDecimals is <= 0');
|
|
19
|
+
}
|
|
23
20
|
return (0, bignumber_js_1.default)(1 / 10).pow(numDecimals);
|
|
24
21
|
}
|
|
25
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommonCurrencyService.js","sourceRoot":"","sources":["../../../../src/domain/services/CommonCurrencyService.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AAGrC,MAAa,qBAAqB;IAChC,MAAM,CAAC
|
|
1
|
+
{"version":3,"file":"CommonCurrencyService.js","sourceRoot":"","sources":["../../../../src/domain/services/CommonCurrencyService.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AAGrC,MAAa,qBAAqB;IAChC,MAAM,CAAC,+BAA+B,CACpC,QAAqD;QAErD,IAAI,CAAC,QAAQ;YAAE,OAAO,SAAS,CAAC;QAChC,IAAI,CAAC,QAAQ,CAAC,WAAW;YAAE,OAAO,SAAS,CAAC;QAC5C,IAAI,CAAC,QAAQ,CAAC,QAAQ;YAAE,OAAO,SAAS,CAAC;QAEzC,MAAM,WAAW,GAAG,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC;QAC7D,IAAI,WAAW,IAAI,CAAC,EAAE;YACpB,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAA;SAC7F;QAED,OAAO,IAAA,sBAAS,EAAC,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC5C,CAAC;CACF;AAfD,sDAeC"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import BigNumber from 'bignumber.js';
|
|
2
|
-
import { Currency } from '../model';
|
|
3
1
|
export declare class CurrencyService {
|
|
4
2
|
static fromMinimalUnits(decimals: number, amount: number): number;
|
|
5
|
-
static minValueFromCurrencyMinDecimals(currency?: Pick<Currency, 'decimals' | 'minDecimals'>): BigNumber | undefined;
|
|
6
3
|
}
|
|
@@ -1,27 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.CurrencyService = void 0;
|
|
7
|
-
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
4
|
class CurrencyService {
|
|
9
5
|
static fromMinimalUnits(decimals, amount) {
|
|
10
6
|
const decimalsValue = Number.isNaN(decimals) ? 0 : decimals;
|
|
11
7
|
return parseFloat((amount / 10 ** decimalsValue).toFixed(3));
|
|
12
8
|
}
|
|
13
|
-
static minValueFromCurrencyMinDecimals(currency) {
|
|
14
|
-
if (!currency)
|
|
15
|
-
return undefined;
|
|
16
|
-
if (!currency.minDecimals)
|
|
17
|
-
return undefined;
|
|
18
|
-
if (!currency.decimals)
|
|
19
|
-
return undefined;
|
|
20
|
-
const numDecimals = currency.decimals - currency.minDecimals;
|
|
21
|
-
if (numDecimals <= 0)
|
|
22
|
-
return undefined;
|
|
23
|
-
return (0, bignumber_js_1.default)(1 / 10).pow(numDecimals);
|
|
24
|
-
}
|
|
25
9
|
}
|
|
26
10
|
exports.CurrencyService = CurrencyService;
|
|
27
11
|
//# sourceMappingURL=CurrencyService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurrencyService.js","sourceRoot":"","sources":["../../../../src/domain/services/CurrencyService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CurrencyService.js","sourceRoot":"","sources":["../../../../src/domain/services/CurrencyService.ts"],"names":[],"mappings":";;;AAGA,MAAa,eAAe;IAC1B,MAAM,CAAC,gBAAgB,CAAC,QAAgB,EAAE,MAAc;QACtD,MAAM,aAAa,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QAC5D,OAAO,UAAU,CAAC,CAAC,MAAM,GAAG,EAAE,IAAI,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/D,CAAC;CACF;AALD,0CAKC"}
|