@heliofi/common 0.1.340-alpha.0 → 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.
@@ -0,0 +1,5 @@
1
+ import BigNumber from 'bignumber.js';
2
+ import { Currency } from '../model';
3
+ export declare class CommonCurrencyService {
4
+ static minValueFromCurrencyMinDecimals(currency?: Pick<Currency, 'decimals' | 'minDecimals'>): BigNumber | undefined;
5
+ }
@@ -0,0 +1,24 @@
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 minValueFromCurrencyMinDecimals(currency) {
10
+ if (!currency)
11
+ return undefined;
12
+ if (!currency.minDecimals)
13
+ return undefined;
14
+ if (!currency.decimals)
15
+ return undefined;
16
+ const numDecimals = currency.decimals - currency.minDecimals;
17
+ if (numDecimals <= 0) {
18
+ throw new Error('Unable to get min value from currency when decimals - minDecimals is <= 0');
19
+ }
20
+ return (0, bignumber_js_1.default)(1 / 10).pow(numDecimals);
21
+ }
22
+ }
23
+ exports.CommonCurrencyService = CommonCurrencyService;
24
+ //# 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,+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,5 +1,3 @@
1
- import { Currency } from '../model';
2
1
  export declare class CurrencyService {
3
2
  static fromMinimalUnits(decimals: number, amount: number): number;
4
- static minValueFromCurrencyMinDecimals(currency?: Pick<Currency, 'decimals' | 'minDecimals'>): number | undefined;
5
3
  }
@@ -6,18 +6,6 @@ class CurrencyService {
6
6
  const decimalsValue = Number.isNaN(decimals) ? 0 : decimals;
7
7
  return parseFloat((amount / 10 ** decimalsValue).toFixed(3));
8
8
  }
9
- static minValueFromCurrencyMinDecimals(currency) {
10
- if (!currency)
11
- return undefined;
12
- if (!currency.minDecimals)
13
- return undefined;
14
- if (!currency.decimals)
15
- return undefined;
16
- const numDecimals = currency.decimals - currency.minDecimals;
17
- if (numDecimals <= 0)
18
- return undefined;
19
- return 1 / 10 ** numDecimals;
20
- }
21
9
  }
22
10
  exports.CurrencyService = CurrencyService;
23
11
  //# sourceMappingURL=CurrencyService.js.map
@@ -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":";;;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"}
@@ -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"}