Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bloks/utils

Package Overview
Dependencies
Maintainers
1
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bloks/utils - npm Package Compare versions

Comparing version 22.0.89 to 23.0.0

2

dist/index.d.ts
export * from './arrays';
export * from './encoding';
export * from './historyApiTransformer';
export * from './numbers';
export * from './serialization';
export * from './time';
export * from './url';

@@ -8,0 +6,0 @@ export * from './dom';

export * from './nft';
export * from './asset';

@@ -9,10 +9,2 @@ 'use strict';

require('fast-text-encoding');
var BN = require('bignumber.js');
var BN__default = _interopDefault(BN);
var numbro = _interopDefault(require('@jafri/numbro'));
var dayjs = _interopDefault(require('dayjs'));
var relativeTimePlugin = _interopDefault(require('dayjs/plugin/relativeTime'));
var utcPlugin = _interopDefault(require('dayjs/plugin/utc'));
var timezonePlugin = _interopDefault(require('dayjs/plugin/timezone'));
var advancedFormatPlugin = _interopDefault(require('dayjs/plugin/advancedFormat'));
var query = _interopDefault(require('qs'));

@@ -926,358 +918,2 @@

var currencyMap = {
GBP: {
symbol: '£',
precision: 2
},
EUR: {
symbol: '€',
precision: 2
},
JPY: {
symbol: '¥',
precision: 0
},
CAD: {
symbol: 'CA$',
precision: 2
},
USD: {
symbol: '$',
precision: 2
},
INR: {
symbol: '₹',
precision: 2
},
CNY: {
symbol: 'CN¥',
precision: 2
},
HKD: {
symbol: 'HK$',
precision: 2
},
KRW: {
symbol: '₩',
precision: 0
},
AUD: {
symbol: 'AUD$',
precision: 2
},
SAR: {
symbol: 'SR',
precision: 2
},
ETH: {
symbol: 'Ξ',
precision: 4
},
BTC: {
symbol: '₿',
precision: 8
},
EOS: {
symbol: 'EOS',
precision: 4
}
};
var eosFmt = {
decimalSeparator: '.',
groupSeparator: ',',
groupSize: 3
};
BN.BigNumber.set({
ROUNDING_MODE: 1
});
function toBigNumber(number) {
return new BN.BigNumber(number);
}
function numberToAmount(number, precision, round) {
if (round === void 0) {
round = BN.BigNumber.ROUND_DOWN;
}
return new BN.BigNumber(number).toFixed(precision, round);
}
function numberToAmountFormatted(number, precision, round) {
if (round === void 0) {
round = BN.BigNumber.ROUND_DOWN;
}
return new BN.BigNumber(number).toFormat(precision, round, eosFmt);
}
function calculatePercentage(balance, percentage, precision) {
var _final = new BN.BigNumber(balance).multipliedBy(percentage);
return numberToAmount(_final, precision, BN.BigNumber.ROUND_DOWN);
}
function eosDisplayFormatting(value, symbol, precision) {
return numberToAmountFormatted(value, precision) + " " + symbol;
}
function numberToRex(number, precision) {
return numberToAmount(number, precision) + " REX";
}
function numberToEos(number, symbol, precision) {
return numberToAmount(number, precision) + " " + symbol;
}
function numberToEosRoundUp(number, symbol, precision) {
return numberToAmount(number, precision, BN.BigNumber.ROUND_UP) + " " + symbol;
}
function parseRex(rex) {
return new BN.BigNumber(rex).dividedBy(10000);
}
function add() {
var start = new BN.BigNumber(0);
for (var _len = arguments.length, numbers = new Array(_len), _key = 0; _key < _len; _key++) {
numbers[_key] = arguments[_key];
}
if (numbers.length) {
for (var _iterator = _createForOfIteratorHelperLoose(numbers), _step; !(_step = _iterator()).done;) {
var number = _step.value;
start = start.plus(number);
}
}
return start;
}
function substract(a, b) {
return new BN.BigNumber(a).minus(b);
}
function multiply(a, b) {
return new BN.BigNumber(a).multipliedBy(b);
}
function divide(a, b) {
return new BN.BigNumber(a).dividedBy(b);
}
/**
* Converts USD to { symbol: "USD", precision: 4 }
* @param {*} currency
*/
function currencyToSymbol(currency) {
return currencyMap[currency];
}
/**
* Converts "1000.0000 EOS" to { amount: 1000, symbol: { code: "EOS", precision: 4 }}
* @param {*} quantity
*/
function split(quantity) {
var _quantity$split = quantity.split(' '),
amount = _quantity$split[0],
code = _quantity$split[1];
var precision = (amount.split('.')[1] || []).length;
return {
amount: +amount,
symbol: {
code: code,
precision: precision
}
};
}
function toNumbro(number) {
return numbro(number);
}
/**
* Converts 1000 to "1000.0000 EOS"
* @param {*} asset
*/
function numberToAsset(number, symbol, precision, trimMantissa) {
if (trimMantissa === void 0) {
trimMantissa = false;
}
var amount = numbro(number).format({
thousandSeparated: false,
mantissa: precision,
trimMantissa: trimMantissa
});
return amount + " " + symbol;
}
/**
* DISPLAY FUNCTIONS
*/
/**
* Converts (1, 2) to "0.5000 EOS"
*/
function displayUsdAsEos(usd, eosPrice, symbol, precision, trimMantissa) {
if (trimMantissa === void 0) {
trimMantissa = false;
}
var eos = usd / eosPrice || 0;
var amount = numbro(eos).format({
thousandSeparated: true,
mantissa: precision,
trimMantissa: trimMantissa
});
return amount + " " + symbol;
}
/**
* Converts 1000 to 1,000
* @param {*} number
*/
function displayNumber(number) {
return numbro(number).format({
thousandSeparated: true
});
}
/**
* Converts 1000 to $1,000 USD
* @param {*} number
*/
function displayNumberAsCurrency(number, currency, precision) {
if (currency === void 0) {
currency = 'USD';
}
var _currencyMap$currency = currencyMap[currency],
symbol = _currencyMap$currency.symbol,
defaultPrecision = _currencyMap$currency.precision;
var formattedNumber = numbro(number).format({
thousandSeparated: true,
mantissa: precision !== undefined ? precision : defaultPrecision
});
return "" + symbol + formattedNumber;
}
/**
* Converts "1000.0000 EOS" to "1,000.0000 EOS"
* @param {*} asset
*/
function displayAsset(asset) {
var _split = split(asset),
amount = _split.amount,
code = _split.symbol.code;
return displayNumber(amount) + " " + code;
}
/**
* Converts 1000 to 1,000.0000
* @param {*} number
*/
function displayNumberAsAmount(number, precision, trimMantissa) {
if (trimMantissa === void 0) {
trimMantissa = false;
}
return numbro(number).format({
thousandSeparated: true,
mantissa: precision,
trimMantissa: trimMantissa
});
}
function displayNumberAsAmountUnboundPrecision(number, trimMantissa) {
if (trimMantissa === void 0) {
trimMantissa = false;
}
return numbro(number).format({
thousandSeparated: true,
trimMantissa: trimMantissa
});
}
/**
* Converts 1000 to "1,000.0000 EOS"
* @param {*} number
*/
function displayNumberAsAsset(number, symbol, precision, trimMantissa) {
if (trimMantissa === void 0) {
trimMantissa = false;
}
var amount = numbro(number).format({
thousandSeparated: true,
mantissa: precision,
trimMantissa: trimMantissa
});
return amount + " " + symbol;
}
/**
* Converts 10000000 to "1,000.0000 EOS"
* @param {*} number
*/
function displayRawNumberAsAsset(number, symbol, precision, trimMantissa) {
if (trimMantissa === void 0) {
trimMantissa = false;
}
return displayNumberAsAsset(number / Math.pow(10, precision), symbol, precision, trimMantissa);
}
/**
* Resource utilities
*/
function bytesToKB(bytes) {
if (bytes === void 0) {
bytes = 0;
}
return numbro(bytes / 1024).format({
thousandSeparated: false,
mantissa: 2
});
}
function parseNetAndRam(bytes) {
var parsedValue = 0;
var parsedText = '';
if (bytes < 1024) {
parsedValue = bytes;
parsedText = 'Bytes';
} else if (bytes < 1048576) {
parsedValue = bytes / 1024;
parsedText = 'KB';
} else if (bytes < 1073741824) {
parsedValue = bytes / 1048576;
parsedText = 'MB';
} else if (bytes < 1099511627776) {
parsedValue = bytes / 1073741824;
parsedText = 'GB';
} else if (bytes < 1125899906842624) {
parsedValue = bytes / 1099511627776;
parsedText = 'TB';
}
return displayNumberAsAmount(parsedValue, 2, true) + " " + parsedText;
}
function parseCpu(us) {
var parsedValue = 0;
var parsedText = '';
if (us < 1000) {
parsedValue = us;
parsedText = 'µs';
} else if (us < 1000000) {
parsedValue = us / 1000;
parsedText = 'ms';
} else if (us < 60000000) {
parsedValue = us / 1000000;
parsedText = 's';
} else if (us < 3600000000) {
parsedValue = us / 60000000;
parsedText = 'min';
} else if (us < 3600000000000) {
parsedValue = us / 3600000000;
parsedText = 'hours';
} else {
parsedValue = us / 86400000000;
parsedText = 'days';
}
return displayNumberAsAmount(parsedValue, 2, true) + " " + parsedText;
}
function hexToUint8Array(hex) {

@@ -1308,167 +944,2 @@ if (typeof hex !== 'string') {

dayjs.extend(relativeTimePlugin);
dayjs.extend(utcPlugin);
dayjs.extend(timezonePlugin);
dayjs.extend(advancedFormatPlugin);
var COMMON_DATE_FORMAT = 'MMM-DD-YYYY, hh:mm:ss A';
/**
* Time utilities
*/
function time(date) {
return dayjs(date);
}
function utcTime(date) {
return dayjs(date).utc();
}
function utcTimeToLocal(date) {
return dayjs(date).local();
}
function unixTime(unixTimestamp) {
return dayjs.unix(unixTimestamp);
}
function formatDate(date, format) {
if (format === void 0) {
format = COMMON_DATE_FORMAT;
}
return dayjs(date).format(format);
}
function formatDateLocal(date, format) {
if (format === void 0) {
format = COMMON_DATE_FORMAT;
}
return dayjs(date).utc().format(format);
}
function timestampToDate(timestamp) {
return new Date(timestamp);
}
function utcTimestampToDate(timestamp) {
timestamp = timestamp.slice(-1) === 'Z' ? timestamp : timestamp + 'Z';
return new Date(timestamp);
}
function timestampFromNow(timestamp) {
return time(timestamp).fromNow();
}
function utcTimestampFromNow(timestamp) {
timestamp = timestamp.slice(-1) === 'Z' ? timestamp : timestamp + 'Z';
return time(timestamp).fromNow();
}
function parseTimestamp(timestamp, format) {
if (format === void 0) {
format = COMMON_DATE_FORMAT;
}
return formatDate(timestampToDate(timestamp), format);
}
function parseUtcTimestamp(timestamp, format) {
if (format === void 0) {
format = COMMON_DATE_FORMAT;
}
return formatDate(utcTimestampToDate(timestamp), format);
}
function inFuture(date, utc) {
if (utc === void 0) {
utc = false;
}
return utc ? utcTime(date).isAfter(utcTime()) : time(date).isAfter(time());
}
function inPast(date, utc) {
if (utc === void 0) {
utc = false;
}
return utc ? utcTime(date).isBefore(utcTime()) : time(date).isBefore(time());
}
function isSameDay(start, end) {
if (end === void 0) {
end = time();
}
return dayjs(start).isSame(dayjs(end), 'day');
} // Seconds till now if second param empty
function secondsFrom(start, end) {
if (end === void 0) {
end = time();
}
return dayjs(start).diff(dayjs(end), 'second');
}
function millisecondsFrom(start, end) {
if (end === void 0) {
end = time();
}
return dayjs(start).diff(dayjs(end));
}
/**
* Specific to EOS
*/
function startDate(startDate, days) {
if (days === void 0) {
days = 3;
}
return dayjs(startDate).clone().subtract(days, 'days');
}
function formatStartDate(startTimestamp) {
return startDate(startTimestamp).format('MMM-DD-YYYY, hh:mm:ss A');
}
function endDate(endDate, days) {
if (days === void 0) {
days = 3;
}
return dayjs(endDate).clone().add(days, 'days');
}
function formatEndDate(endTimestamp) {
return endDate(endTimestamp).format('MMM-DD-YYYY, hh:mm:ss A');
}
function dateToUtcTimePoint(date) {
if (date === void 0) {
date = time();
}
return dayjs(date).utc().format('YYYY-MM-DDTHH:mm:ss.SSS');
}
var emptyTimePoint = '1970-01-01T00:00:00.000';
function parseSeconds(seconds) {
var days = 0;
var hours = 0;
var minutes = 0;
var parsedDate = ''; // Days
if (seconds > 86400) {
days += Math.floor(seconds / 86400);
seconds -= days * 86400;
parsedDate += days.toFixed(0) + " " + (days === 1 ? 'Day' : 'Days') + " ";
} // Hours
if (seconds > 3600) {
hours += Math.floor(seconds / 3600);
seconds -= hours * 3600;
parsedDate += hours.toFixed(0) + " " + (hours === 1 ? 'Hour' : 'Hours') + " ";
} // Minutes
if (seconds > 60) {
minutes += Math.floor(seconds / 60);
seconds -= minutes * 60;
parsedDate += minutes.toFixed(0) + " " + (minutes === 1 ? 'Minute' : 'Minutes') + " ";
} // Seconds
if (seconds > 0) {
parsedDate += seconds.toFixed(0) + " Seconds ";
}
return parsedDate;
}
function urlBuilder(url, id, params) {

@@ -1550,87 +1021,2 @@ params = params || {};

var Asset = function Asset(asset) {
var _this = this;
this.isEqualSymbol = function (_ref) {
var symbol_code = _ref.symbol_code,
precision = _ref.precision;
return _this.symbol_code === symbol_code && _this.precision === precision;
};
this.toString = function () {
return new BN__default(_this.amount).toFixed(_this.precision, BN__default.ROUND_DOWN) + " " + _this.symbol_code;
};
if (typeof asset === 'string') {
var _asset$split = asset.split(' '),
amount = _asset$split[0],
symbol_code = _asset$split[1];
var _amount$split = amount.split('.'),
afterPeriod = _amount$split[1];
var precision = (afterPeriod || '').length;
this.symbol_code = symbol_code;
this.amount = +amount;
this.precision = precision;
} else {
this.symbol_code = asset.symbol_code;
this.amount = +asset.amount;
this.precision = asset.precision;
}
this.amountBN = new BN__default(this.amount);
this.integerQuantityBN = this.amountBN.multipliedBy(Math.pow(10, this.precision));
};
var ExtendedAsset = function ExtendedAsset(quantity, contract) {
var _this2 = this;
this.isEqualExtendedSymbol = function (_ref2) {
var contract = _ref2.contract,
symbol_code = _ref2.symbol_code,
precision = _ref2.precision;
return _this2.contract === contract && _this2.quantity.isEqualSymbol({
symbol_code: symbol_code,
precision: precision
});
};
this.toString = function () {
return _this2.quantity.toString() + "@" + _this2.contract;
};
this.quantity = quantity;
this.contract = contract;
};
var Symbol$1 = function Symbol(symbol) {
var _this3 = this;
this.isEqualSymbol = function (_ref3) {
var symbol_code = _ref3.symbol_code,
precision = _ref3.precision;
return _this3.symbol_code === symbol_code && _this3.precision === precision;
};
this.toString = function () {
return _this3.precision + "," + _this3.symbol_code;
};
var _symbol$split = symbol.split(','),
precision = _symbol$split[0],
symbol_code = _symbol$split[1];
this.precision = +precision;
this.symbol_code = symbol_code;
};
var ExtendedSymbol = function ExtendedSymbol(sym, contract) {
var _this4 = this;
this.toString = function () {
return _this4.sym.toString() + "@" + _this4.contract;
};
this.sym = sym;
this.contract = contract;
};
function parseIpfs(imageUrl) {

@@ -1801,11 +1187,4 @@ if (!imageUrl) {

exports.Asset = Asset;
exports.ExtendedAsset = ExtendedAsset;
exports.ExtendedSymbol = ExtendedSymbol;
exports.Nft = Nft;
exports.Symbol = Symbol$1;
exports.add = add;
exports.bytesToKB = bytesToKB;
exports.bytesToString = bytesToString;
exports.calculatePercentage = calculatePercentage;
exports.charidx = charidx;

@@ -1815,4 +1194,2 @@ exports.cloneDeepArrayOfObj = cloneDeepArrayOfObj;

exports.createQrCode = createQrCode;
exports.currencyToSymbol = currencyToSymbol;
exports.dateToUtcTimePoint = dateToUtcTimePoint;
exports.decodeName = decodeName;

@@ -1826,20 +1203,4 @@ exports.dfuseDepthFirstExtract = dfuseDepthFirstExtract;

exports.dfuseTransformTransactionResult = dfuseTransformTransactionResult;
exports.displayAsset = displayAsset;
exports.displayNumber = displayNumber;
exports.displayNumberAsAmount = displayNumberAsAmount;
exports.displayNumberAsAmountUnboundPrecision = displayNumberAsAmountUnboundPrecision;
exports.displayNumberAsAsset = displayNumberAsAsset;
exports.displayNumberAsCurrency = displayNumberAsCurrency;
exports.displayRawNumberAsAsset = displayRawNumberAsAsset;
exports.displayUsdAsEos = displayUsdAsEos;
exports.divide = divide;
exports.emptyTimePoint = emptyTimePoint;
exports.encodeName = encodeName;
exports.endDate = endDate;
exports.eosDisplayFormatting = eosDisplayFormatting;
exports.fioKeyToActor = fioKeyToActor;
exports.formatDate = formatDate;
exports.formatDateLocal = formatDateLocal;
exports.formatEndDate = formatEndDate;
exports.formatStartDate = formatStartDate;
exports.hexToUint8Array = hexToUint8Array;

@@ -1854,41 +1215,10 @@ exports.historyTransformDeferredAction = historyTransformDeferredAction;

exports.hyperionTransformTransaction = hyperionTransformTransaction;
exports.inFuture = inFuture;
exports.inPast = inPast;
exports.isSameDay = isSameDay;
exports.isString = isString;
exports.millisecondsFrom = millisecondsFrom;
exports.multiply = multiply;
exports.nativeTransformGetActions = nativeTransformGetActions;
exports.numberToAmount = numberToAmount;
exports.numberToAmountFormatted = numberToAmountFormatted;
exports.numberToAsset = numberToAsset;
exports.numberToEos = numberToEos;
exports.numberToEosRoundUp = numberToEosRoundUp;
exports.numberToRex = numberToRex;
exports.parseAaNft = parseAaNft;
exports.parseCpu = parseCpu;
exports.parseNetAndRam = parseNetAndRam;
exports.parseRex = parseRex;
exports.parseSaNft = parseSaNft;
exports.parseSeconds = parseSeconds;
exports.parseTimestamp = parseTimestamp;
exports.parseUtcTimestamp = parseUtcTimestamp;
exports.secondsFrom = secondsFrom;
exports.sha = sha;
exports.split = split;
exports.startDate = startDate;
exports.string_to_uint128_hash = string_to_uint128_hash;
exports.substract = substract;
exports.time = time;
exports.timestampFromNow = timestampFromNow;
exports.timestampToDate = timestampToDate;
exports.toBigNumber = toBigNumber;
exports.toNumbro = toNumbro;
exports.unixTime = unixTime;
exports.urlBuilder = urlBuilder;
exports.utcTime = utcTime;
exports.utcTimeToLocal = utcTimeToLocal;
exports.utcTimestampFromNow = utcTimestampFromNow;
exports.utcTimestampToDate = utcTimestampToDate;
exports.wait = wait;
//# sourceMappingURL=utils.cjs.development.js.map

2

dist/utils.cjs.production.min.js

@@ -1,2 +0,2 @@

"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=t(require("long"));require("fast-text-encoding");var r=require("bignumber.js"),n=t(r),a=t(require("@jafri/numbro")),o=t(require("dayjs")),i=t(require("dayjs/plugin/relativeTime")),s=t(require("dayjs/plugin/utc")),c=t(require("dayjs/plugin/timezone")),u=t(require("dayjs/plugin/advancedFormat")),d=t(require("qs"));function m(){return(m=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function l(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function p(t,e){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return l(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?l(t,void 0):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=t[Symbol.iterator]()).next.bind(r)}var f=function(t,e,r){void 0===e&&(e=!1),void 0===r&&(r="SHA-256");try{var n;if(e){var a=t.match(/[\da-f]{2}/gi);if(!a)throw Error("Empty message");var o=a.map((function(t){return parseInt(t,16)}));n=new Uint8Array(o)}else n=(new TextEncoder).encode(t);return Promise.resolve(crypto.subtle.digest(r,n)).then((function(t){return Array.from(new Uint8Array(t)).map((function(t){return t.toString(16).padStart(2,"0")})).join("")}))}catch(t){return Promise.reject(t)}},_=".12345abcdefghijklmnopqrstuvwxyz";function v(t){var e=_.indexOf(t);if(-1===e)throw new TypeError("Invalid character: '"+t+"'");return e}function h(t,r){void 0===r&&(r=!0);for(var n,a=e.fromString(t),o="",i=p(r?a.toBytesLE():a.toBytesBE());!(n=i()).done;){var s=Number(n.value).toString(16);o+=(1===s.length?"0":"")+s}o+="0".repeat(16-o.length);for(var c=e.fromNumber(31,!0),u=e.fromNumber(15,!0),d="",m=e.fromString(o,!0,16),l=0;l<=12;l++)d=_[m.and(0===l?u:c)]+d,m=m.shiftRight(0===l?4:5);return d.replace(/\.+$/,"")}function y(t,e){return t*Math.pow(2,e)}function x(t,e,r,n,a){if(n.includes(a)&&r.push({action_trace:e}),e.inline_traces){for(var o,i=p(e.inline_traces);!(o=i()).done;)a=x(t,o.value,r,n,++a);delete e.inline_traces}return a}function b(t,e,r,n,a){if(n&&n.includes(a)&&r.push({action_trace:t,dbops:e.filter((function(t){return t.action_idx===a}))}),t.inline_traces)for(var o,i=p(t.inline_traces);!(o=i()).done;)a=b(o.value,e,r,n,++a);return a}function g(t){for(var e,r=t.reduce((function(t,e){return t[e.action_ordinal]=m({},e,{traces:[],account_ram_deltas:e.account_ram_deltas,receivers:e.notified}),t}),{}),n=p(t.sort((function(t,e){return e.action_ordinal-t.action_ordinal})));!(e=n()).done;){var a=e.value;if(0!==a.creator_action_ordinal&&r[a.creator_action_ordinal]){var o=r[a.creator_action_ordinal].traces||[],i=[r[a.action_ordinal]];delete r[a.action_ordinal],r[a.creator_action_ordinal].traces=i.concat(o)}}return Object.values(r)}function S(t){var e=t.trace,r=t.dbops,n=void 0===r?[]:r,a=t.ramops,o=void 0===a?[]:a,i=t.index,s=void 0===i?0:i,c={act:e.act,account_ram_deltas:e.account_ram_deltas,receivers:[e.receipt.receiver],act_digest:e.receipt.act_digest,dbops:(n||[]).filter((function(t){return t.action_idx===s})),ramops:(o||[]).filter((function(t){return t.action_idx===s})),traces:[]};return e.inline_traces&&e.inline_traces.length&&e.inline_traces.map((function(t){if(s++,t.act.hex_data!==c.act.hex_data||t.act.name!==c.act.name||t.act.account!==c.act.account)c.traces.push(S({trace:t,index:s,ramops:o,dbops:n}));else{if(t.inline_traces&&t.inline_traces.length)for(var e,r=p(t.inline_traces);!(e=r()).done;)s++,c.traces.push(S({trace:e.value,index:s,ramops:o,dbops:n}));c.receivers.includes(t.receipt.receiver)||c.receivers.push(t.receipt.receiver),c.dbops=c.dbops.concat((n||[]).filter((function(t){return t.action_idx===s}))),c.ramops=c.ramops.concat((o||[]).filter((function(t){return t.action_idx===s})))}})),c}function w(t){var e=t.execution_trace,r=t.transaction,n=t.ramops,a=t.dbops,o=t.created_by,i=0,s=(e.action_traces||[]).map((function(t){var e=S({trace:t,ramops:n,dbops:a,index:i}),r=E([t]);return i+=r,e}));return{status:e.receipt.status,cpu_usage:e.receipt.cpu_usage_us,net_usage:8*e.receipt.net_usage_words,id:e.id,block_time:e.block_time,block_num:e.block_num,delay_sec:r.delay_sec,expiration:r.expiration,created_by:o,actions:s,traces:s}}function N(t){return{act:m({},t),account_ram_deltas:[],receivers:[],act_digest:"",traces:[]}}function T(t){var e=t.transaction.actions.map(N);return{id:t.id,status:"deferred",dfuse_status:t.transaction_status,sender:t.created_by.sender,payer:t.created_by.payer,published:t.created_by.published_at,delay_until:t.created_by.delay_until,expiration:t.transaction.expiration,delay_sec:t.transaction.delay_sec,actions:e,traces:e}}function A(t){return m({},t,{account_ram_deltas:[],receiver:"",act_digest:"",traces:[]})}function D(t){var e={act:t.act,account_ram_deltas:t.account_ram_deltas||[],receivers:[t.receipt.receiver],act_digest:t.receipt.act_digest,traces:[]};return t.inline_traces&&t.inline_traces.length&&t.inline_traces.forEach((function(r){var n=r.receipt.act_digest===t.receipt.act_digest;n&&r.inline_traces&&r.inline_traces.length?(e.traces=e.traces.concat(r.inline_traces.map(D)),e.receivers.includes(r.receipt.receiver)||e.receivers.push(r.receipt.receiver)):n?e.receivers.includes(r.receipt.receiver)||e.receivers.push(r.receipt.receiver):e.traces.push(D(r))})),e}function O(t){for(var e,r=t.reduce((function(t,e){return t[e.action_ordinal]=e,t}),{}),n=p(t.sort((function(t,e){return e.action_ordinal-t.action_ordinal})));!(e=n()).done;){var a=e.value;0!==a.creator_action_ordinal&&(r[a.creator_action_ordinal].inline_traces=[r[a.action_ordinal]].concat(r[a.creator_action_ordinal].inline_traces||[]))}return Object.values(r).filter((function(t){return 0===t.creator_action_ordinal})).map((function(t){return m({},t,{receivers:[t.receipt.receiver],act_digest:t.receipt.act_digest})}))}function E(t){return t.reduce((function(t,e){return t+1+E(e.inline_traces||[])}),0)}var B={GBP:{symbol:"£",precision:2},EUR:{symbol:"€",precision:2},JPY:{symbol:"¥",precision:0},CAD:{symbol:"CA$",precision:2},USD:{symbol:"$",precision:2},INR:{symbol:"₹",precision:2},CNY:{symbol:"CN¥",precision:2},HKD:{symbol:"HK$",precision:2},KRW:{symbol:"₩",precision:0},AUD:{symbol:"AUD$",precision:2},SAR:{symbol:"SR",precision:2},ETH:{symbol:"Ξ",precision:4},BTC:{symbol:"₿",precision:8},EOS:{symbol:"EOS",precision:4}},M={decimalSeparator:".",groupSeparator:",",groupSize:3};function I(t,e,n){return void 0===n&&(n=r.BigNumber.ROUND_DOWN),new r.BigNumber(t).toFixed(e,n)}function Y(t,e,n){return void 0===n&&(n=r.BigNumber.ROUND_DOWN),new r.BigNumber(t).toFormat(e,n,M)}function R(t){var e=t.split(" "),r=e[0],n=e[1],a=(r.split(".")[1]||[]).length;return{amount:+r,symbol:{code:n,precision:a}}}function k(t){return a(t).format({thousandSeparated:!0})}function q(t,e,r){return void 0===r&&(r=!1),a(t).format({thousandSeparated:!0,mantissa:e,trimMantissa:r})}function P(t,e,r,n){return void 0===n&&(n=!1),a(t).format({thousandSeparated:!0,mantissa:r,trimMantissa:n})+" "+e}function j(t){return o(t)}function U(t){return o(t).utc()}function C(t,e){return void 0===e&&(e="MMM-DD-YYYY, hh:mm:ss A"),o(t).format(e)}function F(t){return new Date(t)}function L(t){return t="Z"===t.slice(-1)?t:t+"Z",new Date(t)}function H(t,e){return void 0===e&&(e=3),o(t).clone().subtract(e,"days")}function z(t,e){return void 0===e&&(e=3),o(t).clone().add(e,"days")}r.BigNumber.set({ROUNDING_MODE:1}),o.extend(i),o.extend(s),o.extend(c),o.extend(u);var G=function(t){var e=t.mdata,r=t.name,n=t.image,a=t.video,o=t.model,i=t.audio,s=t.stage,c=t.skybox,u=t.id,d=t.contract,m=t.link,l=t.owner,p=t.author,f=t.collection,_=t.mint,v=t.edition_size;this.idata=t.idata,this.mdata=e,this.name=r,this.image=n,this.video=a,this.model=o,this.audio=i,this.stage=s,this.skybox=c,this.id=u,this.contract=d,this.link=m,this.owner=l,this.author=p,this.collection=f,this.mint=_,this.edition_size=v};function K(t){return t?("Qm"===t.substring(0,2)&&(t="https://ipfs.io/ipfs/"+t),t):t}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var $,W=require("qrcode");($=exports.DbopOp||(exports.DbopOp={})).Ins="INS",$.Rem="REM",$.Upd="UPD",exports.Asset=function(t){var e=this;if(this.isEqualSymbol=function(t){return e.symbol_code===t.symbol_code&&e.precision===t.precision},this.toString=function(){return new n(e.amount).toFixed(e.precision,n.ROUND_DOWN)+" "+e.symbol_code},"string"==typeof t){var r=t.split(" "),a=r[0],o=r[1],i=(a.split(".")[1]||"").length;this.symbol_code=o,this.amount=+a,this.precision=i}else this.symbol_code=t.symbol_code,this.amount=+t.amount,this.precision=t.precision;this.amountBN=new n(this.amount),this.integerQuantityBN=this.amountBN.multipliedBy(Math.pow(10,this.precision))},exports.ExtendedAsset=function(t,e){var r=this;this.isEqualExtendedSymbol=function(t){return r.contract===t.contract&&r.quantity.isEqualSymbol({symbol_code:t.symbol_code,precision:t.precision})},this.toString=function(){return r.quantity.toString()+"@"+r.contract},this.quantity=t,this.contract=e},exports.ExtendedSymbol=function(t,e){var r=this;this.toString=function(){return r.sym.toString()+"@"+r.contract},this.sym=t,this.contract=e},exports.Nft=G,exports.Symbol=function(t){var e=this;this.isEqualSymbol=function(t){return e.symbol_code===t.symbol_code&&e.precision===t.precision},this.toString=function(){return e.precision+","+e.symbol_code};var r=t.split(","),n=r[1];this.precision=+r[0],this.symbol_code=n},exports.add=function(){for(var t=new r.BigNumber(0),e=arguments.length,n=new Array(e),a=0;a<e;a++)n[a]=arguments[a];if(n.length)for(var o,i=p(n);!(o=i()).done;){var s=o.value;t=t.plus(s)}return t},exports.bytesToKB=function(t){return void 0===t&&(t=0),a(t/1024).format({thousandSeparated:!1,mantissa:2})},exports.bytesToString=function(t){return"string"==typeof t?t:t.reduce((function(t,e){return t+String.fromCharCode(e)}),"")},exports.calculatePercentage=function(t,e,n){return I(new r.BigNumber(t).multipliedBy(e),n,r.BigNumber.ROUND_DOWN)},exports.charidx=v,exports.cloneDeepArrayOfObj=function(t){return[].concat(t).map((function(t){return m({},t)}))},exports.copy=function(t){var e=!1,r=document.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="absolute",r.style.left="-9999px",document.body.appendChild(r);var n=document.getSelection();n&&n.rangeCount>0&&(e=n.getRangeAt(0)),r.select(),document.execCommand("copy"),document.body.removeChild(r),n&&e&&(n.removeAllRanges(),n.addRange(e))},exports.createQrCode=function(t,e){void 0===e&&(e={});try{return Promise.resolve(function(r,n){try{var a=Promise.resolve(W.toCanvas(t,{errorCorrectLevel:"max",width:e.width||350})).then((function(t){return(e.r||e.g||e.b)&&(t=function(t,e,r,n){for(var a=n.getContext("2d"),o=a.getImageData(0,0,n.width,n.height),i=0,s=o.data.length;i<s;i+=4)o.data[i]=t|o.data[i],o.data[i+1]=e|o.data[i+1],o.data[i+2]=r|o.data[i+2];return a.putImageData(o,0,0),n}(e.r,e.g,e.b,t)),e.logoPath&&function(t,e){var r=document.createElement("img");r.src=t,r.width=.21*e.width,r.height=.21*e.height,e.getContext("2d").drawImage(r,(e.width-r.width)/2,(e.height-r.height)/2,r.width,r.height)}(e.logoPath,t),t.toDataURL()}))}catch(t){return n(t)}return a&&a.then?a.then(void 0,n):a}(0,(function(t){console.log(t)})))}catch(t){return Promise.reject(t)}},exports.currencyToSymbol=function(t){return B[t]},exports.dateToUtcTimePoint=function(t){return void 0===t&&(t=j()),o(t).utc().format("YYYY-MM-DDTHH:mm:ss.SSS")},exports.decodeName=h,exports.dfuseDepthFirstExtract=function(t){var e=t.transactions,r=t.cursor,n=[];if(e)for(var a,o=p(e);!(a=o()).done;)for(var i,s=a.value,c=s.lifecycle,u=s.action_idx,d=0,m=p(c.execution_trace.action_traces);!(i=m()).done;)d=b(i.value,c.dbops,n,u,d),d++;return{actions:n,cursor:r}},exports.dfuseTransformDeferredAction=N,exports.dfuseTransformDeferredTransaction=T,exports.dfuseTransformGetActions=function(t,e,r){var n=t.transactions,a=t.cursor;if(!n)return{cursor:a,actions:[],numOfTxLoaded:0};for(var o,i=[],s=p(n);!(o=s()).done;){var c=o.value,u=c.lifecycle,d=c.action_idx;if(d)for(var m,l=0,f=p(u.execution_trace.action_traces);!(m=f()).done;){var _=m.value;if(_.inline_traces||(_.inline_traces=[]),_.act.account===r.EOSIO&&"claimrewards"===_.act.name){for(var v,h=0,y="",b=p(_.inline_traces);!(v=b()).done;){var g=v.value;if(g.act.data.from===r.EOSIO_VPAY||g.act.data.from===r.EOSIO_BPAY){i.push({action_trace:g});var S=g.act.data.quantity.split(" "),w=S[1];h+=Number(S[0]),y=w}}_.act.data.quantity=h.toFixed(r.CORE_PRECISION)+" "+y,delete _.inline_traces,i.push({action_trace:_})}else if(_.act.account===r.EOSIO&&"sellrex"===_.act.name){for(var N,T=p(_.inline_traces);!(N=T()).done;){var A=N.value;A.act.account!==r.EOSIO_REX&&"sellresult"!==A.act.name||i.push({action_trace:A})}delete _.inline_traces,i.push({action_trace:_})}else{var D=[];l=x(e,_,D,d,l),i=i.concat(D.reverse())}l++}else i=i.concat(u.execution_trace.action_traces.map((function(t){return{action_trace:t}})).reverse())}return{cursor:a,actions:i,numOfTxLoaded:n.length}},exports.dfuseTransformTrace=S,exports.dfuseTransformTransaction=w,exports.dfuseTransformTransactionResult=function(t){return t.execution_trace?w(t):T(t)},exports.displayAsset=function(t){var e=R(t),r=e.symbol.code;return k(e.amount)+" "+r},exports.displayNumber=k,exports.displayNumberAsAmount=q,exports.displayNumberAsAmountUnboundPrecision=function(t,e){return void 0===e&&(e=!1),a(t).format({thousandSeparated:!0,trimMantissa:e})},exports.displayNumberAsAsset=P,exports.displayNumberAsCurrency=function(t,e,r){void 0===e&&(e="USD");var n=B[e],o=n.precision;return""+n.symbol+a(t).format({thousandSeparated:!0,mantissa:void 0!==r?r:o})},exports.displayRawNumberAsAsset=function(t,e,r,n){return void 0===n&&(n=!1),P(t/Math.pow(10,r),e,r,n)},exports.displayUsdAsEos=function(t,e,r,n,o){return void 0===o&&(o=!1),a(t/e||0).format({thousandSeparated:!0,mantissa:n,trimMantissa:o})+" "+r},exports.divide=function(t,e){return new r.BigNumber(t).dividedBy(e)},exports.emptyTimePoint="1970-01-01T00:00:00.000",exports.encodeName=function(t,r){if(void 0===r&&(r=!0),"string"!=typeof t)throw new TypeError("name parameter is a required string");if(t.length>12)throw new TypeError("A name can be up to 12 characters long");for(var n="",a=0;a<=12;a++){var o=a<t.length?v(t[a]):0,i=a<12?5:4,s=Number(o).toString(2);if(s.length>i)throw new TypeError("Invalid name "+t);n+=s="0".repeat(i-s.length)+s}for(var c,u=e.fromString(n,!0,2),d="",m=p(r?u.toBytesLE():u.toBytesBE());!(c=m()).done;){var l=Number(c.value).toString(16);d+=(1===l.length?"0":"")+l}return e.fromString(d,!0,16).toString().toString()},exports.endDate=z,exports.eosDisplayFormatting=function(t,e,r){return Y(t,r)+" "+e},exports.fioKeyToActor=function(t,r){return h(function(t){for(var r=new e(0,0,!0),n=1,a=0;a<=12;){if(n>=33)throw new Error("FIO: i too large");var o=t[n]&(12==a?15:31);0!=o?(r=r.or(e.fromNumber(y(o,12==a?0:5*(12-a)-1),!0)),a++,n++):n++}return r}(r(t,"FIO").data).toString(),!1).substr(0,12)},exports.formatDate=C,exports.formatDateLocal=function(t,e){return void 0===e&&(e="MMM-DD-YYYY, hh:mm:ss A"),o(t).utc().format(e)},exports.formatEndDate=function(t){return z(t).format("MMM-DD-YYYY, hh:mm:ss A")},exports.formatStartDate=function(t){return H(t).format("MMM-DD-YYYY, hh:mm:ss A")},exports.hexToUint8Array=function(t){if("string"!=typeof t)throw new Error("Expected string containing hex digits");if(t.length%2)throw new Error("Odd number of hex digits");for(var e=t.length/2,r=new Uint8Array(e),n=0;n<e;++n){var a=parseInt(t.substr(2*n,2),16);if(Number.isNaN(a))throw new Error("Expected hex string");r[n]=a}return r},exports.historyTransformDeferredAction=A,exports.historyTransformDeferredTransaction=function(t){return{id:t.trx_id,status:"deferred",sender:t.sender,payer:t.payer,published:t.published,expiration:t.expiration,delay_until:t.delay_until,delay_sec:t.transaction.delay_sec,actions:t.transaction.actions,traces:t.transaction.actions.map((function(t){return A(t)}))}},exports.historyTransformFlatTraces=O,exports.historyTransformRecursiveTrace=D,exports.historyTransformTransaction=function(t){if(t.trx){var e,r,n,a=[];if(t.traces&&t.traces.length&&"creator_action_ordinal"in t.traces[0])n=O(t.traces).map(D),a=t.traces.filter((function(t){return 0===t.creator_action_ordinal}));else{for(var o,i=function(){var e=o.value,r=e[0],n=e[1],i=t.traces.slice();i.splice(r,r+1),i.find((function(t){return function t(e,r){for(var n,a=p(e);!(n=a()).done;){var o=n.value;if(o.act.hex_data===r.hex_data&&o.act.name===r.name&&o.act.account===r.account||t(o.inline_traces,r))return!0}return!1}(t.inline_traces.slice(),n.act)}))||a.push(n)},s=p(t.traces.entries());!(o=s()).done;)i();if(n=a.map((function(t){return D(t)})),t.trx.trx?(e=t.trx.trx.delay_sec,r=t.trx.trx.expiration):(e="N/A",r="N/A"),t.traces.length>0&&0===a.length){a=[];for(var c,u=0,d=0,m=p(t.traces);!(c=m()).done;){var l=c.value;d>=u&&a.push(l),u+=E(l.inline_traces),d++}n=a.map((function(t){return D(t)}))}0===t.traces.length&&0===a.length&&t.trx.trx&&t.trx.trx.actions&&t.trx.trx.actions.length&&(n=t.trx.trx.actions.map((function(t){return{act:t,account_ram_deltas:[],receivers:t.authorization.map((function(t){return t.actor})),act_digest:"",traces:[]}})),a=n)}return{status:t.trx.receipt.status,cpu_usage:t.trx.receipt.cpu_usage_us,net_usage:8*t.trx.receipt.net_usage_words,id:t.id,block_time:t.block_time,block_num:t.block_num,delay_sec:e,expiration:r,actions:a,traces:n}}if(t.action_traces)return w(t);var f=t.traces.map((function(t){return D(t)}));return{status:"executed",cpu_usage:0,net_usage:0,id:t.id,block_time:t.block_time,block_num:t.block_num,delay_sec:0,expiration:0,actions:f,traces:f}},exports.hyperionTransformFlatTraces=g,exports.hyperionTransformGetActions=function(t){for(var e,r=t.query_time,n=t.lib,a=t.actions,o=t.total,i=o.relation,s=o.value,c=[],u=0,d=p(a);!(e=d()).done;){var m=e.value;m.receipt={act_digest:u++},m.block_time=m["@timestamp"],m.act.data&&m.act.data.amount&&m.act.data.symbol&&(m.act.data.quantity=m.act.data.amount+" "+m.act.data.symbol),c.push({action_trace:m})}return{lib:n,actions:c,query_time:r,numOfTxLoaded:a.length,total:{relation:i,value:s}}},exports.hyperionTransformTransaction=function(t){var e=t.actions,r=t.lib,n=t.trx_id,a=e[0],o=a.parent?e.filter((function(t){return 0===t.parent})):e,i=g(e);return{status:"Executed",cpu_usage:a.cpu_usage_us,net_usage:8*a.net_usage_words,id:n,block_time:a["@timestamp"],block_num:a.block_num,delay_sec:"N/A",expiration:"N/A",lib:r,actions:o,traces:i}},exports.inFuture=function(t,e){return void 0===e&&(e=!1),e?U(t).isAfter(U()):j(t).isAfter(j())},exports.inPast=function(t,e){return void 0===e&&(e=!1),e?U(t).isBefore(U()):j(t).isBefore(j())},exports.isSameDay=function(t,e){return void 0===e&&(e=j()),o(t).isSame(o(e),"day")},exports.isString=function(t){return"[object String]"===Object.prototype.toString.call(t)},exports.millisecondsFrom=function(t,e){return void 0===e&&(e=j()),o(t).diff(o(e))},exports.multiply=function(t,e){return new r.BigNumber(t).multipliedBy(e)},exports.nativeTransformGetActions=function(t,e){return t.actions=t.actions.map((function(t){if(t.action_trace.act.account===e.EOSIO&&"claimrewards"===t.action_trace.act.name&&t.action_trace.inline_traces){for(var r,n=0,a="",o=p(t.action_trace.inline_traces);!(r=o()).done;){var i=r.value;if(i.act.data.from===e.EOSIO_VPAY||i.act.data.from===e.EOSIO_BPAY){var s=i.act.data.quantity.split(" "),c=s[1];n+=Number(s[0]),a=c}}t.action_trace.act.data.quantity=n.toFixed(e.CORE_PRECISION)+" "+a}return t})).reverse(),t.numOfTxLoaded=t.actions.length,t},exports.numberToAmount=I,exports.numberToAmountFormatted=Y,exports.numberToAsset=function(t,e,r,n){return void 0===n&&(n=!1),a(t).format({thousandSeparated:!1,mantissa:r,trimMantissa:n})+" "+e},exports.numberToEos=function(t,e,r){return I(t,r)+" "+e},exports.numberToEosRoundUp=function(t,e,n){return I(t,n,r.BigNumber.ROUND_UP)+" "+e},exports.numberToRex=function(t,e){return I(t,e)+" REX"},exports.parseAaNft=function(t){var e=K(t.data.img||t.data.image),r=K(t.data.video),n=K(t.data.audio),a=K(t.data.model),o=K(t.data.stage),i=K(t.data.skybox),s=t.immutable_data;return t.template&&t.template.immutable_data&&(s=m({},s,t.template.immutable_data)),new G({idata:s,mdata:t.mutable_data,name:t.name||t.data.name||t.asset_id,image:e,video:r,model:a,audio:n,stage:o,skybox:i,id:t.asset_id,contract:"atomicassets",link:"/nft/"+t.asset_id,owner:t.owner,author:t.collection.author,collection:t.collection.collection_name,mint:t.template_mint?+t.template_mint:void 0,edition_size:t.template?+t.template.max_supply||+t.template.issued_supply:void 0})},exports.parseCpu=function(t){var e=0,r="";return t<1e3?(e=t,r="µs"):t<1e6?(e=t/1e3,r="ms"):t<6e7?(e=t/1e6,r="s"):t<36e8?(e=t/6e7,r="min"):t<36e11?(e=t/36e8,r="hours"):(e=t/864e8,r="days"),q(e,2,!0)+" "+r},exports.parseNetAndRam=function(t){var e=0,r="";return t<1024?(e=t,r="Bytes"):t<1048576?(e=t/1024,r="KB"):t<1073741824?(e=t/1048576,r="MB"):t<1099511627776?(e=t/1073741824,r="GB"):t<0x4000000000000&&(e=t/1099511627776,r="TB"),q(e,2,!0)+" "+r},exports.parseRex=function(t){return new r.BigNumber(t).dividedBy(1e4)},exports.parseSaNft=function(t){var e=t.idata&&t.idata.name||t.mdata&&t.mdata.name,r=K(t.idata&&(t.idata.img||t.idata.image)||t.mdata&&(t.mdata.img||t.mdata.img)),n=K(t.idata&&t.idata.video||t.mdata&&t.mdata.video),a=K(t.idata&&t.idata.audio||t.mdata&&t.mdata.audio),o=K(t.idata&&t.idata.model||t.mdata&&t.mdata.model),i=K(t.idata&&t.idata.stage||t.mdata&&t.mdata.stage),s=K(t.idata&&t.idata.skybox||t.mdata&&t.mdata.skybox);return new G({idata:t.idata,mdata:t.mdata,name:e,image:r,video:n,model:o,audio:a,stage:i,skybox:s,id:t.assetId,contract:"simpleassets",link:"/nft/"+t.assetId,owner:t.owner,author:t.author,mint:t.extra&&t.extra.mintNumber,collection:t.category,edition_size:t.extra&&t.extra.totalMinted})},exports.parseSeconds=function(t){var e=0,r=0,n=0,a="";return t>86400&&(t-=86400*(e+=Math.floor(t/86400)),a+=e.toFixed(0)+" "+(1===e?"Day":"Days")+" "),t>3600&&(t-=3600*(r+=Math.floor(t/3600)),a+=r.toFixed(0)+" "+(1===r?"Hour":"Hours")+" "),t>60&&(t-=60*(n+=Math.floor(t/60)),a+=n.toFixed(0)+" "+(1===n?"Minute":"Minutes")+" "),t>0&&(a+=t.toFixed(0)+" Seconds "),a},exports.parseTimestamp=function(t,e){return void 0===e&&(e="MMM-DD-YYYY, hh:mm:ss A"),C(F(t),e)},exports.parseUtcTimestamp=function(t,e){return void 0===e&&(e="MMM-DD-YYYY, hh:mm:ss A"),C(L(t),e)},exports.secondsFrom=function(t,e){return void 0===e&&(e=j()),o(t).diff(o(e),"second")},exports.sha=f,exports.split=R,exports.startDate=H,exports.string_to_uint128_hash=function(t){try{return Promise.resolve(f(t,!1,"SHA-1")).then((function(t){var e=t.match(/../g);return e?e.slice(0,-4).reverse().join(""):0}))}catch(t){return Promise.reject(t)}},exports.substract=function(t,e){return new r.BigNumber(t).minus(e)},exports.time=j,exports.timestampFromNow=function(t){return j(t).fromNow()},exports.timestampToDate=F,exports.toBigNumber=function(t){return new r.BigNumber(t)},exports.toNumbro=function(t){return a(t)},exports.unixTime=function(t){return o.unix(t)},exports.urlBuilder=function(t,e,r){return r=r||{},null!=e&&(t+="/"+encodeURIComponent(e)),0!==Object.keys(r).length&&(t+="?"+d.stringify(r)),t},exports.utcTime=U,exports.utcTimeToLocal=function(t){return o(t).local()},exports.utcTimestampFromNow=function(t){return j(t="Z"===t.slice(-1)?t:t+"Z").fromNow()},exports.utcTimestampToDate=L,exports.wait=function(t){try{return Promise.resolve(new Promise((function(e){setTimeout(e,t)})))}catch(t){return Promise.reject(t)}};
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=t(require("long"));require("fast-text-encoding");var r=t(require("qs"));function a(){return(a=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a])}return t}).apply(this,arguments)}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,a=new Array(e);r<e;r++)a[r]=t[r];return a}function i(t,e){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return n(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,void 0):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var a=0;return function(){return a>=t.length?{done:!0}:{done:!1,value:t[a++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=t[Symbol.iterator]()).next.bind(r)}var o=function(t,e,r){void 0===e&&(e=!1),void 0===r&&(r="SHA-256");try{var a;if(e){var n=t.match(/[\da-f]{2}/gi);if(!n)throw Error("Empty message");var i=n.map((function(t){return parseInt(t,16)}));a=new Uint8Array(i)}else a=(new TextEncoder).encode(t);return Promise.resolve(crypto.subtle.digest(r,a)).then((function(t){return Array.from(new Uint8Array(t)).map((function(t){return t.toString(16).padStart(2,"0")})).join("")}))}catch(t){return Promise.reject(t)}},c=".12345abcdefghijklmnopqrstuvwxyz";function s(t){var e=c.indexOf(t);if(-1===e)throw new TypeError("Invalid character: '"+t+"'");return e}function u(t,r){void 0===r&&(r=!0);for(var a,n=e.fromString(t),o="",s=i(r?n.toBytesLE():n.toBytesBE());!(a=s()).done;){var u=Number(a.value).toString(16);o+=(1===u.length?"0":"")+u}o+="0".repeat(16-o.length);for(var d=e.fromNumber(31,!0),l=e.fromNumber(15,!0),m="",f=e.fromString(o,!0,16),p=0;p<=12;p++)m=c[f.and(0===p?l:d)]+m,f=f.shiftRight(0===p?4:5);return m.replace(/\.+$/,"")}function d(t,e){return t*Math.pow(2,e)}function l(t,e,r,a,n){if(a.includes(n)&&r.push({action_trace:e}),e.inline_traces){for(var o,c=i(e.inline_traces);!(o=c()).done;)n=l(t,o.value,r,a,++n);delete e.inline_traces}return n}function m(t,e,r,a,n){if(a&&a.includes(n)&&r.push({action_trace:t,dbops:e.filter((function(t){return t.action_idx===n}))}),t.inline_traces)for(var o,c=i(t.inline_traces);!(o=c()).done;)n=m(o.value,e,r,a,++n);return n}function f(t){for(var e,r=t.reduce((function(t,e){return t[e.action_ordinal]=a({},e,{traces:[],account_ram_deltas:e.account_ram_deltas,receivers:e.notified}),t}),{}),n=i(t.sort((function(t,e){return e.action_ordinal-t.action_ordinal})));!(e=n()).done;){var o=e.value;if(0!==o.creator_action_ordinal&&r[o.creator_action_ordinal]){var c=r[o.creator_action_ordinal].traces||[],s=[r[o.action_ordinal]];delete r[o.action_ordinal],r[o.creator_action_ordinal].traces=s.concat(c)}}return Object.values(r)}function p(t){var e=t.trace,r=t.dbops,a=void 0===r?[]:r,n=t.ramops,o=void 0===n?[]:n,c=t.index,s=void 0===c?0:c,u={act:e.act,account_ram_deltas:e.account_ram_deltas,receivers:[e.receipt.receiver],act_digest:e.receipt.act_digest,dbops:(a||[]).filter((function(t){return t.action_idx===s})),ramops:(o||[]).filter((function(t){return t.action_idx===s})),traces:[]};return e.inline_traces&&e.inline_traces.length&&e.inline_traces.map((function(t){if(s++,t.act.hex_data!==u.act.hex_data||t.act.name!==u.act.name||t.act.account!==u.act.account)u.traces.push(p({trace:t,index:s,ramops:o,dbops:a}));else{if(t.inline_traces&&t.inline_traces.length)for(var e,r=i(t.inline_traces);!(e=r()).done;)s++,u.traces.push(p({trace:e.value,index:s,ramops:o,dbops:a}));u.receivers.includes(t.receipt.receiver)||u.receivers.push(t.receipt.receiver),u.dbops=u.dbops.concat((a||[]).filter((function(t){return t.action_idx===s}))),u.ramops=u.ramops.concat((o||[]).filter((function(t){return t.action_idx===s})))}})),u}function _(t){var e=t.execution_trace,r=t.transaction,a=t.ramops,n=t.dbops,i=t.created_by,o=0,c=(e.action_traces||[]).map((function(t){var e=p({trace:t,ramops:a,dbops:n,index:o}),r=b([t]);return o+=r,e}));return{status:e.receipt.status,cpu_usage:e.receipt.cpu_usage_us,net_usage:8*e.receipt.net_usage_words,id:e.id,block_time:e.block_time,block_num:e.block_num,delay_sec:r.delay_sec,expiration:r.expiration,created_by:i,actions:c,traces:c}}function v(t){return{act:a({},t),account_ram_deltas:[],receivers:[],act_digest:"",traces:[]}}function h(t){var e=t.transaction.actions.map(v);return{id:t.id,status:"deferred",dfuse_status:t.transaction_status,sender:t.created_by.sender,payer:t.created_by.payer,published:t.created_by.published_at,delay_until:t.created_by.delay_until,expiration:t.transaction.expiration,delay_sec:t.transaction.delay_sec,actions:e,traces:e}}function g(t){return a({},t,{account_ram_deltas:[],receiver:"",act_digest:"",traces:[]})}function x(t){var e={act:t.act,account_ram_deltas:t.account_ram_deltas||[],receivers:[t.receipt.receiver],act_digest:t.receipt.act_digest,traces:[]};return t.inline_traces&&t.inline_traces.length&&t.inline_traces.forEach((function(r){var a=r.receipt.act_digest===t.receipt.act_digest;a&&r.inline_traces&&r.inline_traces.length?(e.traces=e.traces.concat(r.inline_traces.map(x)),e.receivers.includes(r.receipt.receiver)||e.receivers.push(r.receipt.receiver)):a?e.receivers.includes(r.receipt.receiver)||e.receivers.push(r.receipt.receiver):e.traces.push(x(r))})),e}function y(t){for(var e,r=t.reduce((function(t,e){return t[e.action_ordinal]=e,t}),{}),n=i(t.sort((function(t,e){return e.action_ordinal-t.action_ordinal})));!(e=n()).done;){var o=e.value;0!==o.creator_action_ordinal&&(r[o.creator_action_ordinal].inline_traces=[r[o.action_ordinal]].concat(r[o.creator_action_ordinal].inline_traces||[]))}return Object.values(r).filter((function(t){return 0===t.creator_action_ordinal})).map((function(t){return a({},t,{receivers:[t.receipt.receiver],act_digest:t.receipt.act_digest})}))}function b(t){return t.reduce((function(t,e){return t+1+b(e.inline_traces||[])}),0)}var w=function(t){var e=t.mdata,r=t.name,a=t.image,n=t.video,i=t.model,o=t.audio,c=t.stage,s=t.skybox,u=t.id,d=t.contract,l=t.link,m=t.owner,f=t.author,p=t.collection,_=t.mint,v=t.edition_size;this.idata=t.idata,this.mdata=e,this.name=r,this.image=a,this.video=n,this.model=i,this.audio=o,this.stage=c,this.skybox=s,this.id=u,this.contract=d,this.link=l,this.owner=m,this.author=f,this.collection=p,this.mint=_,this.edition_size=v};function S(t){return t?("Qm"===t.substring(0,2)&&(t="https://ipfs.io/ipfs/"+t),t):t}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var O,T=require("qrcode");(O=exports.DbopOp||(exports.DbopOp={})).Ins="INS",O.Rem="REM",O.Upd="UPD",exports.Nft=w,exports.bytesToString=function(t){return"string"==typeof t?t:t.reduce((function(t,e){return t+String.fromCharCode(e)}),"")},exports.charidx=s,exports.cloneDeepArrayOfObj=function(t){return[].concat(t).map((function(t){return a({},t)}))},exports.copy=function(t){var e=!1,r=document.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="absolute",r.style.left="-9999px",document.body.appendChild(r);var a=document.getSelection();a&&a.rangeCount>0&&(e=a.getRangeAt(0)),r.select(),document.execCommand("copy"),document.body.removeChild(r),a&&e&&(a.removeAllRanges(),a.addRange(e))},exports.createQrCode=function(t,e){void 0===e&&(e={});try{return Promise.resolve(function(r,a){try{var n=Promise.resolve(T.toCanvas(t,{errorCorrectLevel:"max",width:e.width||350})).then((function(t){return(e.r||e.g||e.b)&&(t=function(t,e,r,a){for(var n=a.getContext("2d"),i=n.getImageData(0,0,a.width,a.height),o=0,c=i.data.length;o<c;o+=4)i.data[o]=t|i.data[o],i.data[o+1]=e|i.data[o+1],i.data[o+2]=r|i.data[o+2];return n.putImageData(i,0,0),a}(e.r,e.g,e.b,t)),e.logoPath&&function(t,e){var r=document.createElement("img");r.src=t,r.width=.21*e.width,r.height=.21*e.height,e.getContext("2d").drawImage(r,(e.width-r.width)/2,(e.height-r.height)/2,r.width,r.height)}(e.logoPath,t),t.toDataURL()}))}catch(t){return a(t)}return n&&n.then?n.then(void 0,a):n}(0,(function(t){console.log(t)})))}catch(t){return Promise.reject(t)}},exports.decodeName=u,exports.dfuseDepthFirstExtract=function(t){var e=t.transactions,r=t.cursor,a=[];if(e)for(var n,o=i(e);!(n=o()).done;)for(var c,s=n.value,u=s.lifecycle,d=s.action_idx,l=0,f=i(u.execution_trace.action_traces);!(c=f()).done;)l=m(c.value,u.dbops,a,d,l),l++;return{actions:a,cursor:r}},exports.dfuseTransformDeferredAction=v,exports.dfuseTransformDeferredTransaction=h,exports.dfuseTransformGetActions=function(t,e,r){var a=t.transactions,n=t.cursor;if(!a)return{cursor:n,actions:[],numOfTxLoaded:0};for(var o,c=[],s=i(a);!(o=s()).done;){var u=o.value,d=u.lifecycle,m=u.action_idx;if(m)for(var f,p=0,_=i(d.execution_trace.action_traces);!(f=_()).done;){var v=f.value;if(v.inline_traces||(v.inline_traces=[]),v.act.account===r.EOSIO&&"claimrewards"===v.act.name){for(var h,g=0,x="",y=i(v.inline_traces);!(h=y()).done;){var b=h.value;if(b.act.data.from===r.EOSIO_VPAY||b.act.data.from===r.EOSIO_BPAY){c.push({action_trace:b});var w=b.act.data.quantity.split(" "),S=w[1];g+=Number(w[0]),x=S}}v.act.data.quantity=g.toFixed(r.CORE_PRECISION)+" "+x,delete v.inline_traces,c.push({action_trace:v})}else if(v.act.account===r.EOSIO&&"sellrex"===v.act.name){for(var O,T=i(v.inline_traces);!(O=T()).done;){var E=O.value;E.act.account!==r.EOSIO_REX&&"sellresult"!==E.act.name||c.push({action_trace:E})}delete v.inline_traces,c.push({action_trace:v})}else{var A=[];p=l(e,v,A,m,p),c=c.concat(A.reverse())}p++}else c=c.concat(d.execution_trace.action_traces.map((function(t){return{action_trace:t}})).reverse())}return{cursor:n,actions:c,numOfTxLoaded:a.length}},exports.dfuseTransformTrace=p,exports.dfuseTransformTransaction=_,exports.dfuseTransformTransactionResult=function(t){return t.execution_trace?_(t):h(t)},exports.encodeName=function(t,r){if(void 0===r&&(r=!0),"string"!=typeof t)throw new TypeError("name parameter is a required string");if(t.length>12)throw new TypeError("A name can be up to 12 characters long");for(var a="",n=0;n<=12;n++){var o=n<t.length?s(t[n]):0,c=n<12?5:4,u=Number(o).toString(2);if(u.length>c)throw new TypeError("Invalid name "+t);a+=u="0".repeat(c-u.length)+u}for(var d,l=e.fromString(a,!0,2),m="",f=i(r?l.toBytesLE():l.toBytesBE());!(d=f()).done;){var p=Number(d.value).toString(16);m+=(1===p.length?"0":"")+p}return e.fromString(m,!0,16).toString().toString()},exports.fioKeyToActor=function(t,r){return u(function(t){for(var r=new e(0,0,!0),a=1,n=0;n<=12;){if(a>=33)throw new Error("FIO: i too large");var i=t[a]&(12==n?15:31);0!=i?(r=r.or(e.fromNumber(d(i,12==n?0:5*(12-n)-1),!0)),n++,a++):a++}return r}(r(t,"FIO").data).toString(),!1).substr(0,12)},exports.hexToUint8Array=function(t){if("string"!=typeof t)throw new Error("Expected string containing hex digits");if(t.length%2)throw new Error("Odd number of hex digits");for(var e=t.length/2,r=new Uint8Array(e),a=0;a<e;++a){var n=parseInt(t.substr(2*a,2),16);if(Number.isNaN(n))throw new Error("Expected hex string");r[a]=n}return r},exports.historyTransformDeferredAction=g,exports.historyTransformDeferredTransaction=function(t){return{id:t.trx_id,status:"deferred",sender:t.sender,payer:t.payer,published:t.published,expiration:t.expiration,delay_until:t.delay_until,delay_sec:t.transaction.delay_sec,actions:t.transaction.actions,traces:t.transaction.actions.map((function(t){return g(t)}))}},exports.historyTransformFlatTraces=y,exports.historyTransformRecursiveTrace=x,exports.historyTransformTransaction=function(t){if(t.trx){var e,r,a,n=[];if(t.traces&&t.traces.length&&"creator_action_ordinal"in t.traces[0])a=y(t.traces).map(x),n=t.traces.filter((function(t){return 0===t.creator_action_ordinal}));else{for(var o,c=function(){var e=o.value,r=e[0],a=e[1],c=t.traces.slice();c.splice(r,r+1),c.find((function(t){return function t(e,r){for(var a,n=i(e);!(a=n()).done;){var o=a.value;if(o.act.hex_data===r.hex_data&&o.act.name===r.name&&o.act.account===r.account||t(o.inline_traces,r))return!0}return!1}(t.inline_traces.slice(),a.act)}))||n.push(a)},s=i(t.traces.entries());!(o=s()).done;)c();if(a=n.map((function(t){return x(t)})),t.trx.trx?(e=t.trx.trx.delay_sec,r=t.trx.trx.expiration):(e="N/A",r="N/A"),t.traces.length>0&&0===n.length){n=[];for(var u,d=0,l=0,m=i(t.traces);!(u=m()).done;){var f=u.value;l>=d&&n.push(f),d+=b(f.inline_traces),l++}a=n.map((function(t){return x(t)}))}0===t.traces.length&&0===n.length&&t.trx.trx&&t.trx.trx.actions&&t.trx.trx.actions.length&&(a=t.trx.trx.actions.map((function(t){return{act:t,account_ram_deltas:[],receivers:t.authorization.map((function(t){return t.actor})),act_digest:"",traces:[]}})),n=a)}return{status:t.trx.receipt.status,cpu_usage:t.trx.receipt.cpu_usage_us,net_usage:8*t.trx.receipt.net_usage_words,id:t.id,block_time:t.block_time,block_num:t.block_num,delay_sec:e,expiration:r,actions:n,traces:a}}if(t.action_traces)return _(t);var p=t.traces.map((function(t){return x(t)}));return{status:"executed",cpu_usage:0,net_usage:0,id:t.id,block_time:t.block_time,block_num:t.block_num,delay_sec:0,expiration:0,actions:p,traces:p}},exports.hyperionTransformFlatTraces=f,exports.hyperionTransformGetActions=function(t){for(var e,r=t.query_time,a=t.lib,n=t.actions,o=t.total,c=o.relation,s=o.value,u=[],d=0,l=i(n);!(e=l()).done;){var m=e.value;m.receipt={act_digest:d++},m.block_time=m["@timestamp"],m.act.data&&m.act.data.amount&&m.act.data.symbol&&(m.act.data.quantity=m.act.data.amount+" "+m.act.data.symbol),u.push({action_trace:m})}return{lib:a,actions:u,query_time:r,numOfTxLoaded:n.length,total:{relation:c,value:s}}},exports.hyperionTransformTransaction=function(t){var e=t.actions,r=t.lib,a=t.trx_id,n=e[0],i=n.parent?e.filter((function(t){return 0===t.parent})):e,o=f(e);return{status:"Executed",cpu_usage:n.cpu_usage_us,net_usage:8*n.net_usage_words,id:a,block_time:n["@timestamp"],block_num:n.block_num,delay_sec:"N/A",expiration:"N/A",lib:r,actions:i,traces:o}},exports.isString=function(t){return"[object String]"===Object.prototype.toString.call(t)},exports.nativeTransformGetActions=function(t,e){return t.actions=t.actions.map((function(t){if(t.action_trace.act.account===e.EOSIO&&"claimrewards"===t.action_trace.act.name&&t.action_trace.inline_traces){for(var r,a=0,n="",o=i(t.action_trace.inline_traces);!(r=o()).done;){var c=r.value;if(c.act.data.from===e.EOSIO_VPAY||c.act.data.from===e.EOSIO_BPAY){var s=c.act.data.quantity.split(" "),u=s[1];a+=Number(s[0]),n=u}}t.action_trace.act.data.quantity=a.toFixed(e.CORE_PRECISION)+" "+n}return t})).reverse(),t.numOfTxLoaded=t.actions.length,t},exports.parseAaNft=function(t){var e=S(t.data.img||t.data.image),r=S(t.data.video),n=S(t.data.audio),i=S(t.data.model),o=S(t.data.stage),c=S(t.data.skybox),s=t.immutable_data;return t.template&&t.template.immutable_data&&(s=a({},s,t.template.immutable_data)),new w({idata:s,mdata:t.mutable_data,name:t.name||t.data.name||t.asset_id,image:e,video:r,model:i,audio:n,stage:o,skybox:c,id:t.asset_id,contract:"atomicassets",link:"/nft/"+t.asset_id,owner:t.owner,author:t.collection.author,collection:t.collection.collection_name,mint:t.template_mint?+t.template_mint:void 0,edition_size:t.template?+t.template.max_supply||+t.template.issued_supply:void 0})},exports.parseSaNft=function(t){var e=t.idata&&t.idata.name||t.mdata&&t.mdata.name,r=S(t.idata&&(t.idata.img||t.idata.image)||t.mdata&&(t.mdata.img||t.mdata.img)),a=S(t.idata&&t.idata.video||t.mdata&&t.mdata.video),n=S(t.idata&&t.idata.audio||t.mdata&&t.mdata.audio),i=S(t.idata&&t.idata.model||t.mdata&&t.mdata.model),o=S(t.idata&&t.idata.stage||t.mdata&&t.mdata.stage),c=S(t.idata&&t.idata.skybox||t.mdata&&t.mdata.skybox);return new w({idata:t.idata,mdata:t.mdata,name:e,image:r,video:a,model:i,audio:n,stage:o,skybox:c,id:t.assetId,contract:"simpleassets",link:"/nft/"+t.assetId,owner:t.owner,author:t.author,mint:t.extra&&t.extra.mintNumber,collection:t.category,edition_size:t.extra&&t.extra.totalMinted})},exports.sha=o,exports.string_to_uint128_hash=function(t){try{return Promise.resolve(o(t,!1,"SHA-1")).then((function(t){var e=t.match(/../g);return e?e.slice(0,-4).reverse().join(""):0}))}catch(t){return Promise.reject(t)}},exports.urlBuilder=function(t,e,a){return a=a||{},null!=e&&(t+="/"+encodeURIComponent(e)),0!==Object.keys(a).length&&(t+="?"+r.stringify(a)),t},exports.wait=function(t){try{return Promise.resolve(new Promise((function(e){setTimeout(e,t)})))}catch(t){return Promise.reject(t)}};
//# sourceMappingURL=utils.cjs.production.min.js.map
import Long from 'long';
import 'fast-text-encoding';
import BN, { BigNumber } from 'bignumber.js';
import numbro from '@jafri/numbro';
import dayjs from 'dayjs';
import relativeTimePlugin from 'dayjs/plugin/relativeTime';
import utcPlugin from 'dayjs/plugin/utc';
import timezonePlugin from 'dayjs/plugin/timezone';
import advancedFormatPlugin from 'dayjs/plugin/advancedFormat';
import query from 'qs';

@@ -918,358 +911,2 @@

var currencyMap = {
GBP: {
symbol: '£',
precision: 2
},
EUR: {
symbol: '€',
precision: 2
},
JPY: {
symbol: '¥',
precision: 0
},
CAD: {
symbol: 'CA$',
precision: 2
},
USD: {
symbol: '$',
precision: 2
},
INR: {
symbol: '₹',
precision: 2
},
CNY: {
symbol: 'CN¥',
precision: 2
},
HKD: {
symbol: 'HK$',
precision: 2
},
KRW: {
symbol: '₩',
precision: 0
},
AUD: {
symbol: 'AUD$',
precision: 2
},
SAR: {
symbol: 'SR',
precision: 2
},
ETH: {
symbol: 'Ξ',
precision: 4
},
BTC: {
symbol: '₿',
precision: 8
},
EOS: {
symbol: 'EOS',
precision: 4
}
};
var eosFmt = {
decimalSeparator: '.',
groupSeparator: ',',
groupSize: 3
};
BigNumber.set({
ROUNDING_MODE: 1
});
function toBigNumber(number) {
return new BigNumber(number);
}
function numberToAmount(number, precision, round) {
if (round === void 0) {
round = BigNumber.ROUND_DOWN;
}
return new BigNumber(number).toFixed(precision, round);
}
function numberToAmountFormatted(number, precision, round) {
if (round === void 0) {
round = BigNumber.ROUND_DOWN;
}
return new BigNumber(number).toFormat(precision, round, eosFmt);
}
function calculatePercentage(balance, percentage, precision) {
var _final = new BigNumber(balance).multipliedBy(percentage);
return numberToAmount(_final, precision, BigNumber.ROUND_DOWN);
}
function eosDisplayFormatting(value, symbol, precision) {
return numberToAmountFormatted(value, precision) + " " + symbol;
}
function numberToRex(number, precision) {
return numberToAmount(number, precision) + " REX";
}
function numberToEos(number, symbol, precision) {
return numberToAmount(number, precision) + " " + symbol;
}
function numberToEosRoundUp(number, symbol, precision) {
return numberToAmount(number, precision, BigNumber.ROUND_UP) + " " + symbol;
}
function parseRex(rex) {
return new BigNumber(rex).dividedBy(10000);
}
function add() {
var start = new BigNumber(0);
for (var _len = arguments.length, numbers = new Array(_len), _key = 0; _key < _len; _key++) {
numbers[_key] = arguments[_key];
}
if (numbers.length) {
for (var _iterator = _createForOfIteratorHelperLoose(numbers), _step; !(_step = _iterator()).done;) {
var number = _step.value;
start = start.plus(number);
}
}
return start;
}
function substract(a, b) {
return new BigNumber(a).minus(b);
}
function multiply(a, b) {
return new BigNumber(a).multipliedBy(b);
}
function divide(a, b) {
return new BigNumber(a).dividedBy(b);
}
/**
* Converts USD to { symbol: "USD", precision: 4 }
* @param {*} currency
*/
function currencyToSymbol(currency) {
return currencyMap[currency];
}
/**
* Converts "1000.0000 EOS" to { amount: 1000, symbol: { code: "EOS", precision: 4 }}
* @param {*} quantity
*/
function split(quantity) {
var _quantity$split = quantity.split(' '),
amount = _quantity$split[0],
code = _quantity$split[1];
var precision = (amount.split('.')[1] || []).length;
return {
amount: +amount,
symbol: {
code: code,
precision: precision
}
};
}
function toNumbro(number) {
return numbro(number);
}
/**
* Converts 1000 to "1000.0000 EOS"
* @param {*} asset
*/
function numberToAsset(number, symbol, precision, trimMantissa) {
if (trimMantissa === void 0) {
trimMantissa = false;
}
var amount = numbro(number).format({
thousandSeparated: false,
mantissa: precision,
trimMantissa: trimMantissa
});
return amount + " " + symbol;
}
/**
* DISPLAY FUNCTIONS
*/
/**
* Converts (1, 2) to "0.5000 EOS"
*/
function displayUsdAsEos(usd, eosPrice, symbol, precision, trimMantissa) {
if (trimMantissa === void 0) {
trimMantissa = false;
}
var eos = usd / eosPrice || 0;
var amount = numbro(eos).format({
thousandSeparated: true,
mantissa: precision,
trimMantissa: trimMantissa
});
return amount + " " + symbol;
}
/**
* Converts 1000 to 1,000
* @param {*} number
*/
function displayNumber(number) {
return numbro(number).format({
thousandSeparated: true
});
}
/**
* Converts 1000 to $1,000 USD
* @param {*} number
*/
function displayNumberAsCurrency(number, currency, precision) {
if (currency === void 0) {
currency = 'USD';
}
var _currencyMap$currency = currencyMap[currency],
symbol = _currencyMap$currency.symbol,
defaultPrecision = _currencyMap$currency.precision;
var formattedNumber = numbro(number).format({
thousandSeparated: true,
mantissa: precision !== undefined ? precision : defaultPrecision
});
return "" + symbol + formattedNumber;
}
/**
* Converts "1000.0000 EOS" to "1,000.0000 EOS"
* @param {*} asset
*/
function displayAsset(asset) {
var _split = split(asset),
amount = _split.amount,
code = _split.symbol.code;
return displayNumber(amount) + " " + code;
}
/**
* Converts 1000 to 1,000.0000
* @param {*} number
*/
function displayNumberAsAmount(number, precision, trimMantissa) {
if (trimMantissa === void 0) {
trimMantissa = false;
}
return numbro(number).format({
thousandSeparated: true,
mantissa: precision,
trimMantissa: trimMantissa
});
}
function displayNumberAsAmountUnboundPrecision(number, trimMantissa) {
if (trimMantissa === void 0) {
trimMantissa = false;
}
return numbro(number).format({
thousandSeparated: true,
trimMantissa: trimMantissa
});
}
/**
* Converts 1000 to "1,000.0000 EOS"
* @param {*} number
*/
function displayNumberAsAsset(number, symbol, precision, trimMantissa) {
if (trimMantissa === void 0) {
trimMantissa = false;
}
var amount = numbro(number).format({
thousandSeparated: true,
mantissa: precision,
trimMantissa: trimMantissa
});
return amount + " " + symbol;
}
/**
* Converts 10000000 to "1,000.0000 EOS"
* @param {*} number
*/
function displayRawNumberAsAsset(number, symbol, precision, trimMantissa) {
if (trimMantissa === void 0) {
trimMantissa = false;
}
return displayNumberAsAsset(number / Math.pow(10, precision), symbol, precision, trimMantissa);
}
/**
* Resource utilities
*/
function bytesToKB(bytes) {
if (bytes === void 0) {
bytes = 0;
}
return numbro(bytes / 1024).format({
thousandSeparated: false,
mantissa: 2
});
}
function parseNetAndRam(bytes) {
var parsedValue = 0;
var parsedText = '';
if (bytes < 1024) {
parsedValue = bytes;
parsedText = 'Bytes';
} else if (bytes < 1048576) {
parsedValue = bytes / 1024;
parsedText = 'KB';
} else if (bytes < 1073741824) {
parsedValue = bytes / 1048576;
parsedText = 'MB';
} else if (bytes < 1099511627776) {
parsedValue = bytes / 1073741824;
parsedText = 'GB';
} else if (bytes < 1125899906842624) {
parsedValue = bytes / 1099511627776;
parsedText = 'TB';
}
return displayNumberAsAmount(parsedValue, 2, true) + " " + parsedText;
}
function parseCpu(us) {
var parsedValue = 0;
var parsedText = '';
if (us < 1000) {
parsedValue = us;
parsedText = 'µs';
} else if (us < 1000000) {
parsedValue = us / 1000;
parsedText = 'ms';
} else if (us < 60000000) {
parsedValue = us / 1000000;
parsedText = 's';
} else if (us < 3600000000) {
parsedValue = us / 60000000;
parsedText = 'min';
} else if (us < 3600000000000) {
parsedValue = us / 3600000000;
parsedText = 'hours';
} else {
parsedValue = us / 86400000000;
parsedText = 'days';
}
return displayNumberAsAmount(parsedValue, 2, true) + " " + parsedText;
}
function hexToUint8Array(hex) {

@@ -1300,167 +937,2 @@ if (typeof hex !== 'string') {

dayjs.extend(relativeTimePlugin);
dayjs.extend(utcPlugin);
dayjs.extend(timezonePlugin);
dayjs.extend(advancedFormatPlugin);
var COMMON_DATE_FORMAT = 'MMM-DD-YYYY, hh:mm:ss A';
/**
* Time utilities
*/
function time(date) {
return dayjs(date);
}
function utcTime(date) {
return dayjs(date).utc();
}
function utcTimeToLocal(date) {
return dayjs(date).local();
}
function unixTime(unixTimestamp) {
return dayjs.unix(unixTimestamp);
}
function formatDate(date, format) {
if (format === void 0) {
format = COMMON_DATE_FORMAT;
}
return dayjs(date).format(format);
}
function formatDateLocal(date, format) {
if (format === void 0) {
format = COMMON_DATE_FORMAT;
}
return dayjs(date).utc().format(format);
}
function timestampToDate(timestamp) {
return new Date(timestamp);
}
function utcTimestampToDate(timestamp) {
timestamp = timestamp.slice(-1) === 'Z' ? timestamp : timestamp + 'Z';
return new Date(timestamp);
}
function timestampFromNow(timestamp) {
return time(timestamp).fromNow();
}
function utcTimestampFromNow(timestamp) {
timestamp = timestamp.slice(-1) === 'Z' ? timestamp : timestamp + 'Z';
return time(timestamp).fromNow();
}
function parseTimestamp(timestamp, format) {
if (format === void 0) {
format = COMMON_DATE_FORMAT;
}
return formatDate(timestampToDate(timestamp), format);
}
function parseUtcTimestamp(timestamp, format) {
if (format === void 0) {
format = COMMON_DATE_FORMAT;
}
return formatDate(utcTimestampToDate(timestamp), format);
}
function inFuture(date, utc) {
if (utc === void 0) {
utc = false;
}
return utc ? utcTime(date).isAfter(utcTime()) : time(date).isAfter(time());
}
function inPast(date, utc) {
if (utc === void 0) {
utc = false;
}
return utc ? utcTime(date).isBefore(utcTime()) : time(date).isBefore(time());
}
function isSameDay(start, end) {
if (end === void 0) {
end = time();
}
return dayjs(start).isSame(dayjs(end), 'day');
} // Seconds till now if second param empty
function secondsFrom(start, end) {
if (end === void 0) {
end = time();
}
return dayjs(start).diff(dayjs(end), 'second');
}
function millisecondsFrom(start, end) {
if (end === void 0) {
end = time();
}
return dayjs(start).diff(dayjs(end));
}
/**
* Specific to EOS
*/
function startDate(startDate, days) {
if (days === void 0) {
days = 3;
}
return dayjs(startDate).clone().subtract(days, 'days');
}
function formatStartDate(startTimestamp) {
return startDate(startTimestamp).format('MMM-DD-YYYY, hh:mm:ss A');
}
function endDate(endDate, days) {
if (days === void 0) {
days = 3;
}
return dayjs(endDate).clone().add(days, 'days');
}
function formatEndDate(endTimestamp) {
return endDate(endTimestamp).format('MMM-DD-YYYY, hh:mm:ss A');
}
function dateToUtcTimePoint(date) {
if (date === void 0) {
date = time();
}
return dayjs(date).utc().format('YYYY-MM-DDTHH:mm:ss.SSS');
}
var emptyTimePoint = '1970-01-01T00:00:00.000';
function parseSeconds(seconds) {
var days = 0;
var hours = 0;
var minutes = 0;
var parsedDate = ''; // Days
if (seconds > 86400) {
days += Math.floor(seconds / 86400);
seconds -= days * 86400;
parsedDate += days.toFixed(0) + " " + (days === 1 ? 'Day' : 'Days') + " ";
} // Hours
if (seconds > 3600) {
hours += Math.floor(seconds / 3600);
seconds -= hours * 3600;
parsedDate += hours.toFixed(0) + " " + (hours === 1 ? 'Hour' : 'Hours') + " ";
} // Minutes
if (seconds > 60) {
minutes += Math.floor(seconds / 60);
seconds -= minutes * 60;
parsedDate += minutes.toFixed(0) + " " + (minutes === 1 ? 'Minute' : 'Minutes') + " ";
} // Seconds
if (seconds > 0) {
parsedDate += seconds.toFixed(0) + " Seconds ";
}
return parsedDate;
}
function urlBuilder(url, id, params) {

@@ -1542,87 +1014,2 @@ params = params || {};

var Asset = function Asset(asset) {
var _this = this;
this.isEqualSymbol = function (_ref) {
var symbol_code = _ref.symbol_code,
precision = _ref.precision;
return _this.symbol_code === symbol_code && _this.precision === precision;
};
this.toString = function () {
return new BN(_this.amount).toFixed(_this.precision, BN.ROUND_DOWN) + " " + _this.symbol_code;
};
if (typeof asset === 'string') {
var _asset$split = asset.split(' '),
amount = _asset$split[0],
symbol_code = _asset$split[1];
var _amount$split = amount.split('.'),
afterPeriod = _amount$split[1];
var precision = (afterPeriod || '').length;
this.symbol_code = symbol_code;
this.amount = +amount;
this.precision = precision;
} else {
this.symbol_code = asset.symbol_code;
this.amount = +asset.amount;
this.precision = asset.precision;
}
this.amountBN = new BN(this.amount);
this.integerQuantityBN = this.amountBN.multipliedBy(Math.pow(10, this.precision));
};
var ExtendedAsset = function ExtendedAsset(quantity, contract) {
var _this2 = this;
this.isEqualExtendedSymbol = function (_ref2) {
var contract = _ref2.contract,
symbol_code = _ref2.symbol_code,
precision = _ref2.precision;
return _this2.contract === contract && _this2.quantity.isEqualSymbol({
symbol_code: symbol_code,
precision: precision
});
};
this.toString = function () {
return _this2.quantity.toString() + "@" + _this2.contract;
};
this.quantity = quantity;
this.contract = contract;
};
var Symbol$1 = function Symbol(symbol) {
var _this3 = this;
this.isEqualSymbol = function (_ref3) {
var symbol_code = _ref3.symbol_code,
precision = _ref3.precision;
return _this3.symbol_code === symbol_code && _this3.precision === precision;
};
this.toString = function () {
return _this3.precision + "," + _this3.symbol_code;
};
var _symbol$split = symbol.split(','),
precision = _symbol$split[0],
symbol_code = _symbol$split[1];
this.precision = +precision;
this.symbol_code = symbol_code;
};
var ExtendedSymbol = function ExtendedSymbol(sym, contract) {
var _this4 = this;
this.toString = function () {
return _this4.sym.toString() + "@" + _this4.contract;
};
this.sym = sym;
this.contract = contract;
};
function parseIpfs(imageUrl) {

@@ -1794,3 +1181,3 @@ if (!imageUrl) {

export { Asset, DbopOp, ExtendedAsset, ExtendedSymbol, Nft, Symbol$1 as Symbol, add, bytesToKB, bytesToString, calculatePercentage, charidx, cloneDeepArrayOfObj, copy, createQrCode, currencyToSymbol, dateToUtcTimePoint, decodeName, dfuseDepthFirstExtract, dfuseTransformDeferredAction, dfuseTransformDeferredTransaction, dfuseTransformGetActions, dfuseTransformTrace, dfuseTransformTransaction, dfuseTransformTransactionResult, displayAsset, displayNumber, displayNumberAsAmount, displayNumberAsAmountUnboundPrecision, displayNumberAsAsset, displayNumberAsCurrency, displayRawNumberAsAsset, displayUsdAsEos, divide, emptyTimePoint, encodeName, endDate, eosDisplayFormatting, fioKeyToActor, formatDate, formatDateLocal, formatEndDate, formatStartDate, hexToUint8Array, historyTransformDeferredAction, historyTransformDeferredTransaction, historyTransformFlatTraces, historyTransformRecursiveTrace, historyTransformTransaction, hyperionTransformFlatTraces, hyperionTransformGetActions, hyperionTransformTransaction, inFuture, inPast, isSameDay, isString, millisecondsFrom, multiply, nativeTransformGetActions, numberToAmount, numberToAmountFormatted, numberToAsset, numberToEos, numberToEosRoundUp, numberToRex, parseAaNft, parseCpu, parseNetAndRam, parseRex, parseSaNft, parseSeconds, parseTimestamp, parseUtcTimestamp, secondsFrom, sha, split, startDate, string_to_uint128_hash, substract, time, timestampFromNow, timestampToDate, toBigNumber, toNumbro, unixTime, urlBuilder, utcTime, utcTimeToLocal, utcTimestampFromNow, utcTimestampToDate, wait };
export { DbopOp, Nft, bytesToString, charidx, cloneDeepArrayOfObj, copy, createQrCode, decodeName, dfuseDepthFirstExtract, dfuseTransformDeferredAction, dfuseTransformDeferredTransaction, dfuseTransformGetActions, dfuseTransformTrace, dfuseTransformTransaction, dfuseTransformTransactionResult, encodeName, fioKeyToActor, hexToUint8Array, historyTransformDeferredAction, historyTransformDeferredTransaction, historyTransformFlatTraces, historyTransformRecursiveTrace, historyTransformTransaction, hyperionTransformFlatTraces, hyperionTransformGetActions, hyperionTransformTransaction, isString, nativeTransformGetActions, parseAaNft, parseSaNft, sha, string_to_uint128_hash, urlBuilder, wait };
//# sourceMappingURL=utils.esm.js.map
{
"name": "@bloks/utils",
"version": "22.0.89",
"version": "23.0.0",
"author": "jafri",

@@ -35,3 +35,3 @@ "module": "dist/utils.esm.js",

},
"gitHead": "d9e9782e375de19495fb257271ed39a2a91e95b5"
"gitHead": "930969bd16b4900ce03f3420df4e6cff6aed58ae"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc