@heliofi/common 0.1.340-alpha.0 → 0.1.340

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.
@@ -0,0 +1,6 @@
1
+ import BigNumber from 'bignumber.js';
2
+ import { Currency } from '../model';
3
+ export declare class CommonCurrencyService {
4
+ static fromMinimalUnits(decimals: number, amount: number): number;
5
+ static minValueFromCurrencyMinDecimals(currency?: Pick<Currency, 'decimals' | 'minDecimals'>): BigNumber | undefined;
6
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CommonCurrencyService = void 0;
7
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
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
+ 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
+ }
26
+ exports.CommonCurrencyService = CommonCurrencyService;
27
+ //# sourceMappingURL=CommonCurrencyService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommonCurrencyService.js","sourceRoot":"","sources":["../../../../src/domain/services/CommonCurrencyService.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AAGrC,MAAa,qBAAqB;IAChC,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;IAED,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;YAAE,OAAO,SAAS,CAAC;QAEvC,OAAO,IAAA,sBAAS,EAAC,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC5C,CAAC;CACF;AAlBD,sDAkBC"}
@@ -1,5 +1,6 @@
1
+ import BigNumber from 'bignumber.js';
1
2
  import { Currency } from '../model';
2
3
  export declare class CurrencyService {
3
4
  static fromMinimalUnits(decimals: number, amount: number): number;
4
- static minValueFromCurrencyMinDecimals(currency?: Pick<Currency, 'decimals' | 'minDecimals'>): number | undefined;
5
+ static minValueFromCurrencyMinDecimals(currency?: Pick<Currency, 'decimals' | 'minDecimals'>): BigNumber | undefined;
5
6
  }
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.CurrencyService = void 0;
7
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
4
8
  class CurrencyService {
5
9
  static fromMinimalUnits(decimals, amount) {
6
10
  const decimalsValue = Number.isNaN(decimals) ? 0 : decimals;
@@ -16,7 +20,7 @@ class CurrencyService {
16
20
  const numDecimals = currency.decimals - currency.minDecimals;
17
21
  if (numDecimals <= 0)
18
22
  return undefined;
19
- return 1 / 10 ** numDecimals;
23
+ return (0, bignumber_js_1.default)(1 / 10).pow(numDecimals);
20
24
  }
21
25
  }
22
26
  exports.CurrencyService = CurrencyService;
@@ -1 +1 @@
1
- {"version":3,"file":"CurrencyService.js","sourceRoot":"","sources":["../../../../src/domain/services/CurrencyService.ts"],"names":[],"mappings":";;;AAEA,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;IAED,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;YAAE,OAAO,SAAS,CAAC;QAEvC,OAAO,CAAC,GAAG,EAAE,IAAI,WAAW,CAAC;IAC/B,CAAC;CACF;AAlBD,0CAkBC"}
1
+ {"version":3,"file":"CurrencyService.js","sourceRoot":"","sources":["../../../../src/domain/services/CurrencyService.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AAGrC,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;IAED,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;YAAE,OAAO,SAAS,CAAC;QAEvC,OAAO,IAAA,sBAAS,EAAC,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC5C,CAAC;CACF;AAlBD,0CAkBC"}
@@ -1,5 +1,5 @@
1
1
  export * from './BigIntCalculatorService';
2
- export * from './CurrencyService';
2
+ export * from './CommonCurrencyService';
3
3
  export * from './SolscanService';
4
4
  export * from './HelioUIService';
5
5
  export * from './FeeService';
@@ -15,7 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./BigIntCalculatorService"), exports);
18
- __exportStar(require("./CurrencyService"), exports);
18
+ __exportStar(require("./CommonCurrencyService"), exports);
19
19
  __exportStar(require("./SolscanService"), exports);
20
20
  __exportStar(require("./HelioUIService"), exports);
21
21
  __exportStar(require("./FeeService"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/domain/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C;AAC1C,oDAAkC;AAClC,mDAAiC;AACjC,mDAAiC;AACjC,+CAA6B;AAC7B,iEAA+C;AAC/C,2DAAyC;AACzC,uDAAqC;AACrC,2DAAyC;AACzC,6DAA2C;AAC3C,mDAAiC;AACjC,kDAAgC;AAChC,mDAAiC;AACjC,qDAAmC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/domain/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C;AAC1C,0DAAwC;AACxC,mDAAiC;AACjC,mDAAiC;AACjC,+CAA6B;AAC7B,iEAA+C;AAC/C,2DAAyC;AACzC,uDAAqC;AACrC,2DAAyC;AACzC,6DAA2C;AAC3C,mDAAiC;AACjC,kDAAgC;AAChC,mDAAiC;AACjC,qDAAmC"}