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 | const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
7 | const constants_1 = require("./constants");
|
8 | const managers_1 = require("./managers");
|
9 | class Bignum extends bignumber_js_1.default {
|
10 | }
|
11 | Bignum.ZERO = new bignumber_js_1.default(0);
|
12 | Bignum.ONE = new bignumber_js_1.default(1);
|
13 | exports.Bignum = Bignum;
|
14 | Bignum.config({ DECIMAL_PLACES: 0 });
|
15 |
|
16 |
|
17 |
|
18 | function formatSatoshi(amount) {
|
19 | const localeString = (+amount / constants_1.SATOSHI).toLocaleString("en", {
|
20 | minimumFractionDigits: 0,
|
21 | maximumFractionDigits: 8,
|
22 | });
|
23 | return `${localeString} ${managers_1.configManager.config.client.symbol}`;
|
24 | }
|
25 | exports.formatSatoshi = formatSatoshi;
|
26 |
|
27 |
|
28 |
|
29 | function isException(blockOrTransaction) {
|
30 | return ["blocks", "transactions"].some(key => {
|
31 | const exceptions = managers_1.configManager.get(`exceptions.${key}`);
|
32 | return Array.isArray(exceptions) && exceptions.includes(blockOrTransaction.id);
|
33 | });
|
34 | }
|
35 | exports.isException = isException;
|
36 |
|
37 |
|
38 |
|
39 | function sortTransactions(transactions) {
|
40 | return transactions.sort((a, b) => {
|
41 | if (a.type < b.type) {
|
42 | return -1;
|
43 | }
|
44 | if (a.type > b.type) {
|
45 | return 1;
|
46 | }
|
47 | if (a.id < b.id) {
|
48 | return -1;
|
49 | }
|
50 | if (a.id > b.id) {
|
51 | return 1;
|
52 | }
|
53 | return 0;
|
54 | });
|
55 | }
|
56 | exports.sortTransactions = sortTransactions;
|
57 |
|
\ | No newline at end of file |