@bloks/utils
Advanced tools
Comparing version 4.0.182 to 4.0.187
@@ -6,3 +6,3 @@ # Change Log | ||
## [4.0.182](https://github.com/jafri/bloks/compare/v4.0.181...v4.0.182) (2020-09-09) | ||
## [4.0.184](https://github.com/jafri/bloks/compare/v4.0.181...v4.0.184) (2020-09-10) | ||
@@ -15,3 +15,3 @@ **Note:** Version bump only for package @bloks/utils | ||
## [4.0.181](https://github.com/jafri/bloks/compare/v4.0.180...v4.0.181) (2020-09-03) | ||
## [4.0.183](https://github.com/jafri/bloks/compare/v4.0.183...v4.0.183) (2020-09-10) | ||
@@ -24,2 +24,10 @@ **Note:** Version bump only for package @bloks/utils | ||
## [4.0.183](https://github.com/jafri/bloks/compare/v4.0.180...v4.0.183) (2020-09-03) | ||
**Note:** Version bump only for package @bloks/utils | ||
## [4.0.180](https://github.com/jafri/bloks/compare/v4.0.179...v4.0.180) (2020-08-19) | ||
@@ -26,0 +34,0 @@ |
@@ -8,6 +8,5 @@ 'use strict'; | ||
var Long = _interopDefault(require('long')); | ||
var eosjs2 = require('@jafri/eosjs2'); | ||
var protonjs = require('@protonprotocol/protonjs'); | ||
var constants = require('@bloks/constants'); | ||
var bignumber_js = require('bignumber.js'); | ||
var eosjsSerialize = require('@jafri/eosjs2/dist/eosjs-serialize'); | ||
var dayjs = _interopDefault(require('dayjs')); | ||
@@ -365,3 +364,3 @@ var relativeTime = _interopDefault(require('dayjs/plugin/relativeTime')); | ||
var fioKeyToActor = function fioKeyToActor(key) { | ||
var pubKey = eosjs2.Numeric.stringToPublicKey(key, 'FIO').data; | ||
var pubKey = protonjs.Numeric.stringToPublicKey(key, 'FIO').data; | ||
var shortenedPubKey = shorten_key(pubKey); | ||
@@ -1614,4 +1613,4 @@ var decodedName = decodeName(shortenedPubKey.toString(), false); | ||
cursor = _ref.cursor; | ||
var eosioTypes = eosjsSerialize.getTypesFromAbi(eosjsSerialize.createInitialTypes(), eosioAbi); | ||
var namebidsType = eosjsSerialize.getType(eosioTypes, 'name_bid'); | ||
var eosioTypes = protonjs.Serialize.getTypesFromAbi(protonjs.Serialize.createInitialTypes(), eosioAbi); | ||
var namebidsType = protonjs.Serialize.getType(eosioTypes, 'name_bid'); | ||
var newActions = []; | ||
@@ -1629,6 +1628,6 @@ | ||
var arrayNew = hexToUint8Array(op['old']['hex']); | ||
var bufferNew = new eosjsSerialize.SerialBuffer({ | ||
var bufferNew = new protonjs.Serialize.SerialBuffer({ | ||
array: arrayNew | ||
}); | ||
action['newRow'] = namebidsType.deserialize(bufferNew, new eosjsSerialize.SerializerState({ | ||
action['newRow'] = namebidsType.deserialize(bufferNew, new protonjs.Serialize.SerializerState({ | ||
bytesAsUint8Array: false | ||
@@ -1635,0 +1634,0 @@ })); |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("long")),r=require("@jafri/eosjs2"),n=require("@bloks/constants"),o=require("bignumber.js"),a=require("@jafri/eosjs2/dist/eosjs-serialize"),i=e(require("dayjs")),s=e(require("dayjs/plugin/relativeTime")),c=e(require("dayjs/plugin/utc")),u=e(require("qs"));function d(){return(d=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function p(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return l(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?l(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[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=e[Symbol.iterator]()).next.bind(r)}var f=function(e,t,r){void 0===t&&(t=!1),void 0===r&&(r="SHA-256");try{var n;if(t){var o=e.match(/[\da-f]{2}/gi);if(!o)throw Error("Empty message");var a=o.map((function(e){return parseInt(e,16)}));n=new Uint8Array(a)}else n=(new m).encode(e);return Promise.resolve(crypto.subtle.digest(r,n)).then((function(e){return Array.from(new Uint8Array(e)).map((function(e){return e.toString(16).padStart(2,"0")})).join("")}))}catch(e){return Promise.reject(e)}},m=function(){function e(){}return e.prototype.encode=function(e){for(var t=[],r=e.length,n=0;n<r;){var o=e.codePointAt(n),a=0,i=0;for(o<=127?(a=0,i=0):o<=2047?(a=6,i=192):o<=65535?(a=12,i=224):o<=2097151&&(a=18,i=240),t.push(i|o>>a),a-=6;a>=0;)t.push(128|o>>a&63),a-=6;n+=o>=65536?2:1}return new Uint8Array(t)},e}(),_=function(){function e(){}return e.prototype.decode=function(e){for(var t="",r=0;r<e.length;){var n=e[r],o=0,a=0;if(n<=127?(o=0,a=255&n):n<=223?(o=1,a=31&n):n<=239?(o=2,a=15&n):n<=244&&(o=3,a=7&n),e.length-r-o>0)for(var i=0;i<o;)a=a<<6|63&(n=e[r+i+1]),i+=1;else a=65533,o=e.length-r;t+=String.fromCodePoint(a),r+=o+1}return t},e}(),v=".12345abcdefghijklmnopqrstuvwxyz";function x(e){var t=v.indexOf(e);if(-1===t)throw new TypeError("Invalid character: '"+e+"'");return t}function y(e,r){void 0===r&&(r=!0);for(var n,o=t.fromString(e),a="",i=p(r?o.toBytesLE():o.toBytesBE());!(n=i()).done;){var s=Number(n.value).toString(16);a+=(1===s.length?"0":"")+s}a+="0".repeat(16-a.length);for(var c=t.fromNumber(31,!0),u=t.fromNumber(15,!0),d="",l=t.fromString(a,!0,16),f=0;f<=12;f++)d=v[l.and(0===f?u:c)]+d,l=l.shiftRight(0===f?4:5);return d.replace(/\.+$/,"")}function g(e,t){return e*Math.pow(2,t)}function b(e,t,r,n,o){if(n.includes(o)&&r.push({action_trace:t}),t.inline_traces){for(var a,i=p(t.inline_traces);!(a=i()).done;)o=b(e,a.value,r,n,++o);delete t.inline_traces}return o}function h(e,t,r,n,o){if(n&&n.includes(o)&&r.push({action_trace:e,dbops:t.filter((function(e){return e.action_idx===o}))}),e.inline_traces)for(var a,i=p(e.inline_traces);!(a=i()).done;)o=h(a.value,t,r,n,++o);return o}function O(e){for(var t,r=e.reduce((function(e,t){return e[t.action_ordinal]=d({},t,{traces:[],account_ram_deltas:t.account_ram_deltas,receivers:t.notified}),e}),{}),n=p(e.reverse());!(t=n()).done;){var o=t.value;0!==o.creator_action_ordinal&&r[o.creator_action_ordinal]&&(r[o.creator_action_ordinal].traces=[r[o.action_ordinal]].concat(r[o.creator_action_ordinal].traces||[]))}return Object.values(r).filter((function(e){return 0===e.creator_action_ordinal}))}function S(e){var t=e.trace,r=e.dbops,n=void 0===r?[]:r,o=e.ramops,a=void 0===o?[]:o,i=e.index,s=void 0===i?0:i,c={act:t.act,account_ram_deltas:t.account_ram_deltas,receivers:[t.receipt.receiver],act_digest:t.receipt.act_digest,dbops:(n||[]).filter((function(e){return e.action_idx===s})),ramops:(a||[]).filter((function(e){return e.action_idx===s})),traces:[]};return t.inline_traces&&t.inline_traces.length&&t.inline_traces.map((function(e){if(s++,e.act.hex_data!==c.act.hex_data||e.act.name!==c.act.name||e.act.account!==c.act.account)c.traces.push(S({trace:e,index:s,ramops:a,dbops:n}));else{if(e.inline_traces&&e.inline_traces.length)for(var t,r=p(e.inline_traces);!(t=r()).done;)s++,c.traces.push(S({trace:t.value,index:s,ramops:a,dbops:n}));c.receivers.includes(e.receipt.receiver)||c.receivers.push(e.receipt.receiver),c.dbops=c.dbops.concat((n||[]).filter((function(e){return e.action_idx===s}))),c.ramops=c.ramops.concat((a||[]).filter((function(e){return e.action_idx===s})))}})),c}function E(e){var t=e.execution_trace,r=e.transaction,n=e.ramops,o=e.dbops,a=e.created_by,i=0,s=(t.action_traces||[]).map((function(e){var t=S({trace:e,ramops:n,dbops:o,index:i}),r=D([e]);return i+=r,t}));return{status:t.receipt.status,cpu_usage:t.receipt.cpu_usage_us,net_usage:8*t.receipt.net_usage_words,id:t.id,block_time:t.block_time,block_num:t.block_num,delay_sec:r.delay_sec,expiration:r.expiration,created_by:a,actions:s,traces:s}}function N(e){return{act:d({},e),account_ram_deltas:[],receivers:[],act_digest:"",traces:[]}}function T(e){var t=e.transaction.actions.map(N);return{id:e.id,status:"deferred",dfuse_status:e.transaction_status,sender:e.created_by.sender,payer:e.created_by.payer,published:e.created_by.published_at,delay_until:e.created_by.delay_until,expiration:e.transaction.expiration,delay_sec:e.transaction.delay_sec,actions:t,traces:t}}function R(e){return d({},e,{account_ram_deltas:[],receiver:"",act_digest:"",traces:[]})}function A(e){var t={act:e.act,account_ram_deltas:e.account_ram_deltas||[],receivers:[e.receipt.receiver],act_digest:e.receipt.act_digest,traces:[]};return e.inline_traces&&e.inline_traces.length&&e.inline_traces.forEach((function(r){r.receipt.act_digest!==e.receipt.act_digest?t.traces.push(A(r)):t.receivers.includes(r.receipt.receiver)||t.receivers.push(r.receipt.receiver)})),t}function w(e){for(var t,r=e.reduce((function(e,t){return e[t.action_ordinal]=t,e}),{}),n=p(e.reverse());!(t=n()).done;){var o=t.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(e){return 0===e.creator_action_ordinal})).map((function(e){return d({},e,{receivers:[e.receipt.receiver],act_digest:e.receipt.act_digest})}))}function D(e){return e.reduce((function(e,t){return e+1+D(t.inline_traces||[])}),0)}var I=require("numbro"),C={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}},B={decimalSeparator:".",groupSeparator:",",groupSize:3};function M(e,t,r){return void 0===t&&(t=n.constants.CORE_PRECISION),void 0===r&&(r=o.BigNumber.ROUND_DOWN),new o.BigNumber(e).toFixed(t,r)}function Y(e,t,r){return void 0===t&&(t=n.constants.CORE_PRECISION),void 0===r&&(r=o.BigNumber.ROUND_DOWN),new o.BigNumber(e).toFormat(t,r,B)}function P(e){var t=e.split(" "),r=t[0],n=t[1],o=(r.split(".")[1]||[]).length;return{amount:+r,symbol:{code:n,precision:o}}}function k(e){return I(e).format({thousandSeparated:!0})}function j(e,t,r){return void 0===t&&(t=n.constants.CORE_PRECISION),void 0===r&&(r=!1),I(e).format({thousandSeparated:!0,mantissa:t,trimMantissa:r})}function U(e,t,r,o){return void 0===t&&(t=n.constants.CORE_SYMBOL),void 0===r&&(r=n.constants.CORE_PRECISION),void 0===o&&(o=!1),I(e).format({thousandSeparated:!0,mantissa:r,trimMantissa:o})+" "+t}function q(e){return i(e)}function F(e){return i(e).utc()}function L(e,t){return void 0===t&&(t="MMM-DD-YYYY, hh:mm:ss A"),i(e).format(t)}function H(e){return new Date(e)}function z(e){return e="Z"===e.slice(-1)?e:e+"Z",new Date(e)}function K(e,t){return void 0===t&&(t=3),i(e).clone().subtract(t,"days")}function G(e,t){return void 0===t&&(t=3),i(e).clone().add(t,"days")}function $(e){if("string"!=typeof e)throw new Error("Expected string containing hex digits");if(e.length%2)throw new Error("Odd number of hex digits");for(var t=e.length/2,r=new Uint8Array(t),n=0;n<t;++n){var o=parseInt(e.substr(2*n,2),16);if(Number.isNaN(o))throw new Error("Expected hex string");r[n]=o}return r}function W(e){if(e.rowval&&(e=d({},e,e.rowval)),"token:simpleassets"===e.contract_type){var t={},r={};try{t=JSON.parse(e.idata)}catch(t){console.log("Error pasing idata",e),console.log(t)}try{r=JSON.parse(e.mdata)}catch(e){console.log("Error pasing mdata"),console.log(e)}var n=r.img||r.image||t.img||r.img||"/img/questionmark.png";return"Qm"===n.substring(0,2)&&(n="https://cloudflare-ipfs.com/ipfs/"+n),d({},e,{idata:t,mdata:r,metadata:{name:r.name||t.name||e.primary_key,image:n,id:e.id||e.assetid||e.primary_key,contract:e.code,link:"/nft/"+e.code+"/"+e.scope+"/"+e.tblname+"/"+e.primary_key,owner:e.owner,author:e.author,category:e.category}})}if("token:atomicassets"===e.contract_type);else if("token:dgoods"===e.contract_type){var o=e.imageSmall||e.imageMedium||e.imageLarge||"/img/questionmark.png";return"pixeos1dgdsa"===e.code&&(o="https://nftsvc.pixeos.art/thumb/"+e.relative_uri),d({},e,{metadata:{name:e.name||e.token_name+" "+e.serial_number,image:o,id:e.id||e.assetid||e.primary_key,contract:e.code,link:"/nft/"+e.code+"/"+e.scope+"/"+e.tblname+"/"+e.primary_key,owner:e.owner,author:e.creator,category:e.category}})}}o.BigNumber.set({ROUNDING_MODE:1}),i.extend(s),i.extend(c),exports.TextDecoder=_,exports.TextEncoder=m,exports.add=function(){for(var e=new o.BigNumber(0),t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];if(r.length)for(var a,i=p(r);!(a=i()).done;){var s=a.value;e=e.plus(s)}return e},exports.bytesToKB=function(e){return void 0===e&&(e=0),I(e/1024).format({thousandSeparated:!1,mantissa:2})},exports.bytesToString=function(e){return"string"==typeof e?e:e.reduce((function(e,t){return e+String.fromCharCode(t)}),"")},exports.calculatePercentage=function(e,t,r){return void 0===r&&(r=n.constants.CORE_PRECISION),M(new o.BigNumber(e).multipliedBy(t),r,o.BigNumber.ROUND_DOWN)},exports.charidx=x,exports.cloneDeepArrayOfObj=function(e){return[].concat(e).map((function(e){return d({},e)}))},exports.copy=function(e){var t=!1,r=document.createElement("textarea");r.value=e,r.setAttribute("readonly",""),r.style.position="absolute",r.style.left="-9999px",document.body.appendChild(r);var n=document.getSelection();n&&n.rangeCount>0&&(t=n.getRangeAt(0)),r.select(),document.execCommand("copy"),document.body.removeChild(r),n&&t&&(n.removeAllRanges(),n.addRange(t))},exports.currencyToSymbol=function(e){return C[e]},exports.dateToUtcTimePoint=function(e){return void 0===e&&(e=q()),i(e).utc().format("YYYY-MM-DDTHH:mm:ss.SSS")},exports.decodeName=y,exports.dfuseDepthFirstExtract=function(e){var t=e.transactions,r=e.cursor,n=[];if(t)for(var o,a=p(t);!(o=a()).done;)for(var i,s=o.value,c=s.lifecycle,u=s.action_idx,d=0,l=p(c.execution_trace.action_traces);!(i=l()).done;)d=h(i.value,c.dbops,n,u,d),d++;return{actions:n,cursor:r}},exports.dfuseTransformDeferredAction=N,exports.dfuseTransformDeferredTransaction=T,exports.dfuseTransformGetActions=function(e,t,r){var n=e.transactions,o=e.cursor;if(!n)return{cursor:o,actions:[],numOfTxLoaded:0};for(var a,i=[],s=p(n);!(a=s()).done;){var c=a.value,u=c.lifecycle,d=c.action_idx;if(d)for(var l,f=0,m=p(u.execution_trace.action_traces);!(l=m()).done;){var _=l.value;if(_.inline_traces||(_.inline_traces=[]),_.act.account===r.EOSIO&&"claimrewards"===_.act.name){for(var v,x=0,y="",g=p(_.inline_traces);!(v=g()).done;){var h=v.value;if(h.act.data.from===r.EOSIO_VPAY||h.act.data.from===r.EOSIO_BPAY){i.push({action_trace:h});var O=h.act.data.quantity.split(" "),S=O[1];x+=Number(O[0]),y=S}}_.act.data.quantity=x.toFixed(r.CORE_PRECISION)+" "+y,delete _.inline_traces,i.push({action_trace:_})}else if(_.act.account===r.EOSIO&&"sellrex"===_.act.name){for(var E,N=p(_.inline_traces);!(E=N()).done;){var T=E.value;T.act.account!==r.EOSIO_REX&&"sellresult"!==T.act.name||i.push({action_trace:T})}delete _.inline_traces,i.push({action_trace:_})}else{var R=[];f=b(t,_,R,d,f),i=i.concat(R.reverse())}f++}else i=i.concat(u.execution_trace.action_traces.map((function(e){return{action_trace:e}})).reverse())}return{cursor:o,actions:i,numOfTxLoaded:n.length}},exports.dfuseTransformTrace=S,exports.dfuseTransformTransaction=E,exports.dfuseTransformTransactionResult=function(e){return e.execution_trace?E(e):T(e)},exports.displayAsset=function(e){var t=P(e),r=t.symbol.code;return k(t.amount)+" "+r},exports.displayNumber=k,exports.displayNumberAsAmount=j,exports.displayNumberAsAsset=U,exports.displayNumberAsCurrency=function(e,t){void 0===t&&(t="USD");var r=C[t],n=r.precision;return""+r.symbol+I(e).format({thousandSeparated:!0,mantissa:n})},exports.displayRawNumberAsAsset=function(e,t,r,o){return void 0===t&&(t=n.constants.CORE_SYMBOL),void 0===r&&(r=n.constants.CORE_PRECISION),void 0===o&&(o=!1),U(e/Math.pow(10,r),t,r,o)},exports.displayUsdAsEos=function(e,t,r,o,a){return void 0===r&&(r=n.constants.CORE_SYMBOL),void 0===o&&(o=n.constants.CORE_PRECISION),void 0===a&&(a=!1),I(e/t||0).format({thousandSeparated:!0,mantissa:o,trimMantissa:a})+" "+r},exports.divide=function(e,t){return new o.BigNumber(e).dividedBy(t)},exports.emptyTimePoint="1970-01-01T00:00:00.000",exports.encodeName=function(e,r){if(void 0===r&&(r=!0),"string"!=typeof e)throw new TypeError("name parameter is a required string");if(e.length>12)throw new TypeError("A name can be up to 12 characters long");for(var n="",o=0;o<=12;o++){var a=o<e.length?x(e[o]):0,i=o<12?5:4,s=Number(a).toString(2);if(s.length>i)throw new TypeError("Invalid name "+e);n+=s="0".repeat(i-s.length)+s}for(var c,u=t.fromString(n,!0,2),d="",l=p(r?u.toBytesLE():u.toBytesBE());!(c=l()).done;){var f=Number(c.value).toString(16);d+=(1===f.length?"0":"")+f}return t.fromString(d,!0,16).toString().toString()},exports.endDate=G,exports.eosDisplayFormatting=function(e,t,r){return void 0===r&&(r=n.constants.CORE_PRECISION),Y(e,r)+" "+t},exports.fioKeyToActor=function(e){return y(function(e){for(var r=new t(0,0,!0),n=1,o=0;o<=12;){if(n>=33)throw new Error("FIO: i too large");var a=e[n]&(12==o?15:31);0!=a?(r=r.or(t.fromNumber(g(a,12==o?0:5*(12-o)-1),!0)),o++,n++):n++}return r}(r.Numeric.stringToPublicKey(e,"FIO").data).toString(),!1).substr(0,12)},exports.formatDate=L,exports.formatDateLocal=function(e,t){return void 0===t&&(t="MMM-DD-YYYY, hh:mm:ss A"),i(e).utc().format(t)},exports.formatEndDate=function(e){return G(e).format("MMM-DD-YYYY, hh:mm:ss A")},exports.formatReferendumProposalDate=function(e){return i().add(e,"days").format("YYYY-MM-DDTHH:mm:ss")},exports.formatStartDate=function(e){return K(e).format("MMM-DD-YYYY, hh:mm:ss A")},exports.hexToUint8Array=$,exports.historyTransformDeferredAction=R,exports.historyTransformDeferredTransaction=function(e){return{id:e.trx_id,status:"deferred",sender:e.sender,payer:e.payer,published:e.published,expiration:e.expiration,delay_until:e.delay_until,delay_sec:e.transaction.delay_sec,actions:e.transaction.actions,traces:e.transaction.actions.map((function(e){return R(e)}))}},exports.historyTransformFlatTraces=w,exports.historyTransformRecursiveTrace=A,exports.historyTransformTransaction=function(e){if(e.trx){var t,r,n,o=[];if(e.traces&&e.traces.length&&"creator_action_ordinal"in e.traces[0])n=w(e.traces).map((function(e){return A(e)})),o=e.traces.filter((function(e){return 0===e.creator_action_ordinal}));else{for(var a,i=function(){var t=a.value,r=t[0],n=t[1],i=e.traces.slice();i.splice(r,r+1),i.find((function(e){return function e(t,r){for(var n,o=p(t);!(n=o()).done;){var a=n.value;if(a.act.hex_data===r.hex_data&&a.act.name===r.name&&a.act.account===r.account||e(a.inline_traces,r))return!0}return!1}(e.inline_traces.slice(),n.act)}))||o.push(n)},s=p(e.traces.entries());!(a=s()).done;)i();if(n=o.map((function(e){return A(e)})),e.trx.trx?(t=e.trx.trx.delay_sec,r=e.trx.trx.expiration):(t="N/A",r="N/A"),e.traces.length>0&&0===o.length){o=[];for(var c,u=0,d=0,l=p(e.traces);!(c=l()).done;){var f=c.value;d>=u&&o.push(f),u+=D(f.inline_traces),d++}n=o.map((function(e){return A(e)}))}0===e.traces.length&&0===o.length&&e.trx.trx&&e.trx.trx.actions&&e.trx.trx.actions.length&&(n=e.trx.trx.actions.map((function(e){return{act:e,account_ram_deltas:[],receivers:e.authorization.map((function(e){return e.actor})),act_digest:"",traces:[]}})),o=n)}return{status:e.trx.receipt.status,cpu_usage:e.trx.receipt.cpu_usage_us,net_usage:8*e.trx.receipt.net_usage_words,id:e.id,block_time:e.block_time,block_num:e.block_num,delay_sec:t,expiration:r,actions:o,traces:n}}if(e.action_traces)return E(e);var m=e.traces.map((function(e){return A(e)}));return{status:"executed",cpu_usage:0,net_usage:0,id:e.id,block_time:e.block_time,block_num:e.block_num,delay_sec:0,expiration:0,actions:m,traces:m}},exports.hyperionTransformFlatTraces=O,exports.hyperionTransformGetActions=function(e){for(var t,r=e.query_time,n=e.lib,o=e.actions,a=e.total,i=a.relation,s=a.value,c=[],u=0,d=p(o);!(t=d()).done;){var l=t.value;l.receipt={act_digest:u++},l.block_time=l["@timestamp"],l.act.data&&l.act.data.amount&&l.act.data.symbol&&(l.act.data.quantity=l.act.data.amount+" "+l.act.data.symbol),c.push({action_trace:l})}return{lib:n,actions:c,query_time:r,numOfTxLoaded:o.length,total:{relation:i,value:s}}},exports.hyperionTransformTransaction=function(e){var t=e.actions,r=e.lib,n=e.trx_id,o=t[0],a=o.parent?t.filter((function(e){return 0===e.parent})):t,i=O(t);return{status:"Executed",cpu_usage:o.cpu_usage_us,net_usage:8*o.net_usage_words,id:n,block_time:o["@timestamp"],block_num:o.block_num,delay_sec:"N/A",expiration:"N/A",lib:r,actions:a,traces:i}},exports.inFuture=function(e,t){return void 0===t&&(t=!1),t?F(e).isAfter(F()):q(e).isAfter(q())},exports.inPast=function(e,t){return void 0===t&&(t=!1),t?F(e).isBefore(F()):q(e).isBefore(q())},exports.isSameDay=function(e,t){return void 0===t&&(t=q()),i(e).isSame(i(t),"day")},exports.isString=function(e){return"[object String]"===Object.prototype.toString.call(e)},exports.millisecondsFrom=function(e,t){return void 0===t&&(t=q()),i(e).diff(i(t))},exports.multiply=function(e,t){return new o.BigNumber(e).multipliedBy(t)},exports.namebidsDeserializer=function(e,t){var r=e.actions,n=e.cursor,o=a.getTypesFromAbi(a.createInitialTypes(),t),i=a.getType(o,"name_bid"),s=[];if(r)for(var c,u=p(r);!(c=u()).done;){var d=c.value;if(d.dbops){for(var l,f=p(d.dbops);!(l=f()).done;){var m=l.value;if("namebids"===m.table&&"REM"===m.op){var _=$(m.old.hex),v=new a.SerialBuffer({array:_});d.newRow=i.deserialize(v,new a.SerializerState({bytesAsUint8Array:!1}))}}d.time=z(d.action_trace.block_time).valueOf(),s.push(d)}}return{actions:s,cursor:n}},exports.nativeTransformGetActions=function(e){return e.actions=e.actions.map((function(e){if(e.action_trace.act.account===n.constants.EOSIO&&"claimrewards"===e.action_trace.act.name&&e.action_trace.inline_traces){for(var t,r=0,o="",a=p(e.action_trace.inline_traces);!(t=a()).done;){var i=t.value;if(i.act.data.from===n.constants.EOSIO_VPAY||i.act.data.from===n.constants.EOSIO_BPAY){var s=i.act.data.quantity.split(" "),c=s[1];r+=Number(s[0]),o=c}}e.action_trace.act.data.quantity=r.toFixed(n.constants.CORE_PRECISION)+" "+o}return e})).reverse(),e.numOfTxLoaded=e.actions.length,e},exports.numberToAmount=M,exports.numberToAmountFormatted=Y,exports.numberToAsset=function(e,t,r,o){return void 0===t&&(t=n.constants.CORE_SYMBOL),void 0===r&&(r=n.constants.CORE_PRECISION),void 0===o&&(o=!1),I(e).format({thousandSeparated:!1,mantissa:r,trimMantissa:o})+" "+t},exports.numberToEos=function(e,t,r){return void 0===r&&(r=n.constants.CORE_PRECISION),M(e,r)+" "+t},exports.numberToEosRoundUp=function(e,t,r){return void 0===r&&(r=n.constants.CORE_PRECISION),M(e,r,o.BigNumber.ROUND_UP)+" "+t},exports.numberToRex=function(e,t){return void 0===t&&(t=n.constants.CORE_PRECISION),M(e,t)+" REX"},exports.numberToRexRoundUp=function(e,t){return void 0===t&&(t=n.constants.CORE_PRECISION),M(e,t,o.BigNumber.ROUND_UP)+" REX"},exports.parseCpu=function(e){var t=0,r="";return e<1e3?(t=e,r="µs"):e<1e6?(t=e/1e3,r="ms"):e<6e7?(t=e/1e6,r="s"):e<36e8?(t=e/6e7,r="min"):e<36e11?(t=e/36e8,r="hours"):(t=e/864e8,r="days"),j(t,2,!0)+" "+r},exports.parseNetAndRam=function(e){var t=0,r="";return e<1024?(t=e,r="Bytes"):e<1048576?(t=e/1024,r="KB"):e<1073741824?(t=e/1048576,r="MB"):e<1099511627776?(t=e/1073741824,r="GB"):e<0x4000000000000&&(t=e/1099511627776,r="TB"),j(t,2,!0)+" "+r},exports.parseNft=W,exports.parseNfts=function(e){return e.reduce((function(e,t,r){var n=W(t);return n&&e.push(d({},n,{index:r})),e}),[])},exports.parseRex=function(e){return new o.BigNumber(e).dividedBy(1e4)},exports.parseSeconds=function(e){var t=0,r=0,n=0,o="";return e>86400&&(e-=86400*(t+=Math.floor(e/86400)),o+=t.toFixed(0)+" "+(1===t?"Day":"Days")+" "),e>3600&&(e-=3600*(r+=Math.floor(e/3600)),o+=r.toFixed(0)+" "+(1===r?"Hour":"Hours")+" "),e>60&&(e-=60*(n+=Math.floor(e/60)),o+=n.toFixed(0)+" "+(1===n?"Minute":"Minutes")+" "),e>0&&(o+=e.toFixed(0)+" Seconds "),o},exports.parseTimestamp=function(e,t){return void 0===t&&(t="MMM-DD-YYYY, hh:mm:ss A"),L(H(e),t)},exports.parseUtcTimestamp=function(e,t){return void 0===t&&(t="MMM-DD-YYYY, hh:mm:ss A"),L(z(e),t)},exports.secondsFrom=function(e,t){return void 0===t&&(t=q()),i(e).diff(i(t),"second")},exports.sha=f,exports.split=P,exports.startDate=K,exports.string_to_uint128_hash=function(e){try{return Promise.resolve(f(e,!1,"SHA-1")).then((function(e){var t=e.match(/../g);return t?t.slice(0,-4).reverse().join(""):0}))}catch(e){return Promise.reject(e)}},exports.substract=function(e,t){return new o.BigNumber(e).minus(t)},exports.time=q,exports.timestampFromNow=function(e){return q(e).fromNow()},exports.timestampToDate=H,exports.toBigNumber=function(e){return new o.BigNumber(e)},exports.toNumbro=function(e){return I(e)},exports.unixTime=function(e){return i.unix(e)},exports.urlBuilder=function(e,t,r){return r=r||{},null!=t&&(e+="/"+encodeURIComponent(t)),0!==Object.keys(r).length&&(e+="?"+u.stringify(r)),e},exports.utcTime=F,exports.utcTimeToLocal=function(e){return i(e).local()},exports.utcTimestampFromNow=function(e){return q(e="Z"===e.slice(-1)?e:e+"Z").fromNow()},exports.utcTimestampToDate=z; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("long")),r=require("@protonprotocol/protonjs"),n=require("@bloks/constants"),o=require("bignumber.js"),a=e(require("dayjs")),i=e(require("dayjs/plugin/relativeTime")),s=e(require("dayjs/plugin/utc")),c=e(require("qs"));function u(){return(u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function l(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return d(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?d(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[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=e[Symbol.iterator]()).next.bind(r)}var p=function(e,t,r){void 0===t&&(t=!1),void 0===r&&(r="SHA-256");try{var n;if(t){var o=e.match(/[\da-f]{2}/gi);if(!o)throw Error("Empty message");var a=o.map((function(e){return parseInt(e,16)}));n=new Uint8Array(a)}else n=(new m).encode(e);return Promise.resolve(crypto.subtle.digest(r,n)).then((function(e){return Array.from(new Uint8Array(e)).map((function(e){return e.toString(16).padStart(2,"0")})).join("")}))}catch(e){return Promise.reject(e)}},m=function(){function e(){}return e.prototype.encode=function(e){for(var t=[],r=e.length,n=0;n<r;){var o=e.codePointAt(n),a=0,i=0;for(o<=127?(a=0,i=0):o<=2047?(a=6,i=192):o<=65535?(a=12,i=224):o<=2097151&&(a=18,i=240),t.push(i|o>>a),a-=6;a>=0;)t.push(128|o>>a&63),a-=6;n+=o>=65536?2:1}return new Uint8Array(t)},e}(),f=function(){function e(){}return e.prototype.decode=function(e){for(var t="",r=0;r<e.length;){var n=e[r],o=0,a=0;if(n<=127?(o=0,a=255&n):n<=223?(o=1,a=31&n):n<=239?(o=2,a=15&n):n<=244&&(o=3,a=7&n),e.length-r-o>0)for(var i=0;i<o;)a=a<<6|63&(n=e[r+i+1]),i+=1;else a=65533,o=e.length-r;t+=String.fromCodePoint(a),r+=o+1}return t},e}(),_=".12345abcdefghijklmnopqrstuvwxyz";function v(e){var t=_.indexOf(e);if(-1===t)throw new TypeError("Invalid character: '"+e+"'");return t}function x(e,r){void 0===r&&(r=!0);for(var n,o=t.fromString(e),a="",i=l(r?o.toBytesLE():o.toBytesBE());!(n=i()).done;){var s=Number(n.value).toString(16);a+=(1===s.length?"0":"")+s}a+="0".repeat(16-a.length);for(var c=t.fromNumber(31,!0),u=t.fromNumber(15,!0),d="",p=t.fromString(a,!0,16),m=0;m<=12;m++)d=_[p.and(0===m?u:c)]+d,p=p.shiftRight(0===m?4:5);return d.replace(/\.+$/,"")}function y(e,t){return e*Math.pow(2,t)}function g(e,t,r,n,o){if(n.includes(o)&&r.push({action_trace:t}),t.inline_traces){for(var a,i=l(t.inline_traces);!(a=i()).done;)o=g(e,a.value,r,n,++o);delete t.inline_traces}return o}function b(e,t,r,n,o){if(n&&n.includes(o)&&r.push({action_trace:e,dbops:t.filter((function(e){return e.action_idx===o}))}),e.inline_traces)for(var a,i=l(e.inline_traces);!(a=i()).done;)o=b(a.value,t,r,n,++o);return o}function h(e){for(var t,r=e.reduce((function(e,t){return e[t.action_ordinal]=u({},t,{traces:[],account_ram_deltas:t.account_ram_deltas,receivers:t.notified}),e}),{}),n=l(e.reverse());!(t=n()).done;){var o=t.value;0!==o.creator_action_ordinal&&r[o.creator_action_ordinal]&&(r[o.creator_action_ordinal].traces=[r[o.action_ordinal]].concat(r[o.creator_action_ordinal].traces||[]))}return Object.values(r).filter((function(e){return 0===e.creator_action_ordinal}))}function S(e){var t=e.trace,r=e.dbops,n=void 0===r?[]:r,o=e.ramops,a=void 0===o?[]:o,i=e.index,s=void 0===i?0:i,c={act:t.act,account_ram_deltas:t.account_ram_deltas,receivers:[t.receipt.receiver],act_digest:t.receipt.act_digest,dbops:(n||[]).filter((function(e){return e.action_idx===s})),ramops:(a||[]).filter((function(e){return e.action_idx===s})),traces:[]};return t.inline_traces&&t.inline_traces.length&&t.inline_traces.map((function(e){if(s++,e.act.hex_data!==c.act.hex_data||e.act.name!==c.act.name||e.act.account!==c.act.account)c.traces.push(S({trace:e,index:s,ramops:a,dbops:n}));else{if(e.inline_traces&&e.inline_traces.length)for(var t,r=l(e.inline_traces);!(t=r()).done;)s++,c.traces.push(S({trace:t.value,index:s,ramops:a,dbops:n}));c.receivers.includes(e.receipt.receiver)||c.receivers.push(e.receipt.receiver),c.dbops=c.dbops.concat((n||[]).filter((function(e){return e.action_idx===s}))),c.ramops=c.ramops.concat((a||[]).filter((function(e){return e.action_idx===s})))}})),c}function O(e){var t=e.execution_trace,r=e.transaction,n=e.ramops,o=e.dbops,a=e.created_by,i=0,s=(t.action_traces||[]).map((function(e){var t=S({trace:e,ramops:n,dbops:o,index:i}),r=w([e]);return i+=r,t}));return{status:t.receipt.status,cpu_usage:t.receipt.cpu_usage_us,net_usage:8*t.receipt.net_usage_words,id:t.id,block_time:t.block_time,block_num:t.block_num,delay_sec:r.delay_sec,expiration:r.expiration,created_by:a,actions:s,traces:s}}function E(e){return{act:u({},e),account_ram_deltas:[],receivers:[],act_digest:"",traces:[]}}function N(e){var t=e.transaction.actions.map(E);return{id:e.id,status:"deferred",dfuse_status:e.transaction_status,sender:e.created_by.sender,payer:e.created_by.payer,published:e.created_by.published_at,delay_until:e.created_by.delay_until,expiration:e.transaction.expiration,delay_sec:e.transaction.delay_sec,actions:t,traces:t}}function T(e){return u({},e,{account_ram_deltas:[],receiver:"",act_digest:"",traces:[]})}function R(e){var t={act:e.act,account_ram_deltas:e.account_ram_deltas||[],receivers:[e.receipt.receiver],act_digest:e.receipt.act_digest,traces:[]};return e.inline_traces&&e.inline_traces.length&&e.inline_traces.forEach((function(r){r.receipt.act_digest!==e.receipt.act_digest?t.traces.push(R(r)):t.receivers.includes(r.receipt.receiver)||t.receivers.push(r.receipt.receiver)})),t}function A(e){for(var t,r=e.reduce((function(e,t){return e[t.action_ordinal]=t,e}),{}),n=l(e.reverse());!(t=n()).done;){var o=t.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(e){return 0===e.creator_action_ordinal})).map((function(e){return u({},e,{receivers:[e.receipt.receiver],act_digest:e.receipt.act_digest})}))}function w(e){return e.reduce((function(e,t){return e+1+w(t.inline_traces||[])}),0)}var D=require("numbro"),I={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}},C={decimalSeparator:".",groupSeparator:",",groupSize:3};function B(e,t,r){return void 0===t&&(t=n.constants.CORE_PRECISION),void 0===r&&(r=o.BigNumber.ROUND_DOWN),new o.BigNumber(e).toFixed(t,r)}function M(e,t,r){return void 0===t&&(t=n.constants.CORE_PRECISION),void 0===r&&(r=o.BigNumber.ROUND_DOWN),new o.BigNumber(e).toFormat(t,r,C)}function Y(e){var t=e.split(" "),r=t[0],n=t[1],o=(r.split(".")[1]||[]).length;return{amount:+r,symbol:{code:n,precision:o}}}function P(e){return D(e).format({thousandSeparated:!0})}function k(e,t,r){return void 0===t&&(t=n.constants.CORE_PRECISION),void 0===r&&(r=!1),D(e).format({thousandSeparated:!0,mantissa:t,trimMantissa:r})}function U(e,t,r,o){return void 0===t&&(t=n.constants.CORE_SYMBOL),void 0===r&&(r=n.constants.CORE_PRECISION),void 0===o&&(o=!1),D(e).format({thousandSeparated:!0,mantissa:r,trimMantissa:o})+" "+t}function j(e){return a(e)}function q(e){return a(e).utc()}function F(e,t){return void 0===t&&(t="MMM-DD-YYYY, hh:mm:ss A"),a(e).format(t)}function L(e){return new Date(e)}function z(e){return e="Z"===e.slice(-1)?e:e+"Z",new Date(e)}function H(e,t){return void 0===t&&(t=3),a(e).clone().subtract(t,"days")}function K(e,t){return void 0===t&&(t=3),a(e).clone().add(t,"days")}function G(e){if("string"!=typeof e)throw new Error("Expected string containing hex digits");if(e.length%2)throw new Error("Odd number of hex digits");for(var t=e.length/2,r=new Uint8Array(t),n=0;n<t;++n){var o=parseInt(e.substr(2*n,2),16);if(Number.isNaN(o))throw new Error("Expected hex string");r[n]=o}return r}function $(e){if(e.rowval&&(e=u({},e,e.rowval)),"token:simpleassets"===e.contract_type){var t={},r={};try{t=JSON.parse(e.idata)}catch(t){console.log("Error pasing idata",e),console.log(t)}try{r=JSON.parse(e.mdata)}catch(e){console.log("Error pasing mdata"),console.log(e)}var n=r.img||r.image||t.img||r.img||"/img/questionmark.png";return"Qm"===n.substring(0,2)&&(n="https://cloudflare-ipfs.com/ipfs/"+n),u({},e,{idata:t,mdata:r,metadata:{name:r.name||t.name||e.primary_key,image:n,id:e.id||e.assetid||e.primary_key,contract:e.code,link:"/nft/"+e.code+"/"+e.scope+"/"+e.tblname+"/"+e.primary_key,owner:e.owner,author:e.author,category:e.category}})}if("token:atomicassets"===e.contract_type);else if("token:dgoods"===e.contract_type){var o=e.imageSmall||e.imageMedium||e.imageLarge||"/img/questionmark.png";return"pixeos1dgdsa"===e.code&&(o="https://nftsvc.pixeos.art/thumb/"+e.relative_uri),u({},e,{metadata:{name:e.name||e.token_name+" "+e.serial_number,image:o,id:e.id||e.assetid||e.primary_key,contract:e.code,link:"/nft/"+e.code+"/"+e.scope+"/"+e.tblname+"/"+e.primary_key,owner:e.owner,author:e.creator,category:e.category}})}}o.BigNumber.set({ROUNDING_MODE:1}),a.extend(i),a.extend(s),exports.TextDecoder=f,exports.TextEncoder=m,exports.add=function(){for(var e=new o.BigNumber(0),t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];if(r.length)for(var a,i=l(r);!(a=i()).done;){var s=a.value;e=e.plus(s)}return e},exports.bytesToKB=function(e){return void 0===e&&(e=0),D(e/1024).format({thousandSeparated:!1,mantissa:2})},exports.bytesToString=function(e){return"string"==typeof e?e:e.reduce((function(e,t){return e+String.fromCharCode(t)}),"")},exports.calculatePercentage=function(e,t,r){return void 0===r&&(r=n.constants.CORE_PRECISION),B(new o.BigNumber(e).multipliedBy(t),r,o.BigNumber.ROUND_DOWN)},exports.charidx=v,exports.cloneDeepArrayOfObj=function(e){return[].concat(e).map((function(e){return u({},e)}))},exports.copy=function(e){var t=!1,r=document.createElement("textarea");r.value=e,r.setAttribute("readonly",""),r.style.position="absolute",r.style.left="-9999px",document.body.appendChild(r);var n=document.getSelection();n&&n.rangeCount>0&&(t=n.getRangeAt(0)),r.select(),document.execCommand("copy"),document.body.removeChild(r),n&&t&&(n.removeAllRanges(),n.addRange(t))},exports.currencyToSymbol=function(e){return I[e]},exports.dateToUtcTimePoint=function(e){return void 0===e&&(e=j()),a(e).utc().format("YYYY-MM-DDTHH:mm:ss.SSS")},exports.decodeName=x,exports.dfuseDepthFirstExtract=function(e){var t=e.transactions,r=e.cursor,n=[];if(t)for(var o,a=l(t);!(o=a()).done;)for(var i,s=o.value,c=s.lifecycle,u=s.action_idx,d=0,p=l(c.execution_trace.action_traces);!(i=p()).done;)d=b(i.value,c.dbops,n,u,d),d++;return{actions:n,cursor:r}},exports.dfuseTransformDeferredAction=E,exports.dfuseTransformDeferredTransaction=N,exports.dfuseTransformGetActions=function(e,t,r){var n=e.transactions,o=e.cursor;if(!n)return{cursor:o,actions:[],numOfTxLoaded:0};for(var a,i=[],s=l(n);!(a=s()).done;){var c=a.value,u=c.lifecycle,d=c.action_idx;if(d)for(var p,m=0,f=l(u.execution_trace.action_traces);!(p=f()).done;){var _=p.value;if(_.inline_traces||(_.inline_traces=[]),_.act.account===r.EOSIO&&"claimrewards"===_.act.name){for(var v,x=0,y="",b=l(_.inline_traces);!(v=b()).done;){var h=v.value;if(h.act.data.from===r.EOSIO_VPAY||h.act.data.from===r.EOSIO_BPAY){i.push({action_trace:h});var S=h.act.data.quantity.split(" "),O=S[1];x+=Number(S[0]),y=O}}_.act.data.quantity=x.toFixed(r.CORE_PRECISION)+" "+y,delete _.inline_traces,i.push({action_trace:_})}else if(_.act.account===r.EOSIO&&"sellrex"===_.act.name){for(var E,N=l(_.inline_traces);!(E=N()).done;){var T=E.value;T.act.account!==r.EOSIO_REX&&"sellresult"!==T.act.name||i.push({action_trace:T})}delete _.inline_traces,i.push({action_trace:_})}else{var R=[];m=g(t,_,R,d,m),i=i.concat(R.reverse())}m++}else i=i.concat(u.execution_trace.action_traces.map((function(e){return{action_trace:e}})).reverse())}return{cursor:o,actions:i,numOfTxLoaded:n.length}},exports.dfuseTransformTrace=S,exports.dfuseTransformTransaction=O,exports.dfuseTransformTransactionResult=function(e){return e.execution_trace?O(e):N(e)},exports.displayAsset=function(e){var t=Y(e),r=t.symbol.code;return P(t.amount)+" "+r},exports.displayNumber=P,exports.displayNumberAsAmount=k,exports.displayNumberAsAsset=U,exports.displayNumberAsCurrency=function(e,t){void 0===t&&(t="USD");var r=I[t],n=r.precision;return""+r.symbol+D(e).format({thousandSeparated:!0,mantissa:n})},exports.displayRawNumberAsAsset=function(e,t,r,o){return void 0===t&&(t=n.constants.CORE_SYMBOL),void 0===r&&(r=n.constants.CORE_PRECISION),void 0===o&&(o=!1),U(e/Math.pow(10,r),t,r,o)},exports.displayUsdAsEos=function(e,t,r,o,a){return void 0===r&&(r=n.constants.CORE_SYMBOL),void 0===o&&(o=n.constants.CORE_PRECISION),void 0===a&&(a=!1),D(e/t||0).format({thousandSeparated:!0,mantissa:o,trimMantissa:a})+" "+r},exports.divide=function(e,t){return new o.BigNumber(e).dividedBy(t)},exports.emptyTimePoint="1970-01-01T00:00:00.000",exports.encodeName=function(e,r){if(void 0===r&&(r=!0),"string"!=typeof e)throw new TypeError("name parameter is a required string");if(e.length>12)throw new TypeError("A name can be up to 12 characters long");for(var n="",o=0;o<=12;o++){var a=o<e.length?v(e[o]):0,i=o<12?5:4,s=Number(a).toString(2);if(s.length>i)throw new TypeError("Invalid name "+e);n+=s="0".repeat(i-s.length)+s}for(var c,u=t.fromString(n,!0,2),d="",p=l(r?u.toBytesLE():u.toBytesBE());!(c=p()).done;){var m=Number(c.value).toString(16);d+=(1===m.length?"0":"")+m}return t.fromString(d,!0,16).toString().toString()},exports.endDate=K,exports.eosDisplayFormatting=function(e,t,r){return void 0===r&&(r=n.constants.CORE_PRECISION),M(e,r)+" "+t},exports.fioKeyToActor=function(e){return x(function(e){for(var r=new t(0,0,!0),n=1,o=0;o<=12;){if(n>=33)throw new Error("FIO: i too large");var a=e[n]&(12==o?15:31);0!=a?(r=r.or(t.fromNumber(y(a,12==o?0:5*(12-o)-1),!0)),o++,n++):n++}return r}(r.Numeric.stringToPublicKey(e,"FIO").data).toString(),!1).substr(0,12)},exports.formatDate=F,exports.formatDateLocal=function(e,t){return void 0===t&&(t="MMM-DD-YYYY, hh:mm:ss A"),a(e).utc().format(t)},exports.formatEndDate=function(e){return K(e).format("MMM-DD-YYYY, hh:mm:ss A")},exports.formatReferendumProposalDate=function(e){return a().add(e,"days").format("YYYY-MM-DDTHH:mm:ss")},exports.formatStartDate=function(e){return H(e).format("MMM-DD-YYYY, hh:mm:ss A")},exports.hexToUint8Array=G,exports.historyTransformDeferredAction=T,exports.historyTransformDeferredTransaction=function(e){return{id:e.trx_id,status:"deferred",sender:e.sender,payer:e.payer,published:e.published,expiration:e.expiration,delay_until:e.delay_until,delay_sec:e.transaction.delay_sec,actions:e.transaction.actions,traces:e.transaction.actions.map((function(e){return T(e)}))}},exports.historyTransformFlatTraces=A,exports.historyTransformRecursiveTrace=R,exports.historyTransformTransaction=function(e){if(e.trx){var t,r,n,o=[];if(e.traces&&e.traces.length&&"creator_action_ordinal"in e.traces[0])n=A(e.traces).map((function(e){return R(e)})),o=e.traces.filter((function(e){return 0===e.creator_action_ordinal}));else{for(var a,i=function(){var t=a.value,r=t[0],n=t[1],i=e.traces.slice();i.splice(r,r+1),i.find((function(e){return function e(t,r){for(var n,o=l(t);!(n=o()).done;){var a=n.value;if(a.act.hex_data===r.hex_data&&a.act.name===r.name&&a.act.account===r.account||e(a.inline_traces,r))return!0}return!1}(e.inline_traces.slice(),n.act)}))||o.push(n)},s=l(e.traces.entries());!(a=s()).done;)i();if(n=o.map((function(e){return R(e)})),e.trx.trx?(t=e.trx.trx.delay_sec,r=e.trx.trx.expiration):(t="N/A",r="N/A"),e.traces.length>0&&0===o.length){o=[];for(var c,u=0,d=0,p=l(e.traces);!(c=p()).done;){var m=c.value;d>=u&&o.push(m),u+=w(m.inline_traces),d++}n=o.map((function(e){return R(e)}))}0===e.traces.length&&0===o.length&&e.trx.trx&&e.trx.trx.actions&&e.trx.trx.actions.length&&(n=e.trx.trx.actions.map((function(e){return{act:e,account_ram_deltas:[],receivers:e.authorization.map((function(e){return e.actor})),act_digest:"",traces:[]}})),o=n)}return{status:e.trx.receipt.status,cpu_usage:e.trx.receipt.cpu_usage_us,net_usage:8*e.trx.receipt.net_usage_words,id:e.id,block_time:e.block_time,block_num:e.block_num,delay_sec:t,expiration:r,actions:o,traces:n}}if(e.action_traces)return O(e);var f=e.traces.map((function(e){return R(e)}));return{status:"executed",cpu_usage:0,net_usage:0,id:e.id,block_time:e.block_time,block_num:e.block_num,delay_sec:0,expiration:0,actions:f,traces:f}},exports.hyperionTransformFlatTraces=h,exports.hyperionTransformGetActions=function(e){for(var t,r=e.query_time,n=e.lib,o=e.actions,a=e.total,i=a.relation,s=a.value,c=[],u=0,d=l(o);!(t=d()).done;){var p=t.value;p.receipt={act_digest:u++},p.block_time=p["@timestamp"],p.act.data&&p.act.data.amount&&p.act.data.symbol&&(p.act.data.quantity=p.act.data.amount+" "+p.act.data.symbol),c.push({action_trace:p})}return{lib:n,actions:c,query_time:r,numOfTxLoaded:o.length,total:{relation:i,value:s}}},exports.hyperionTransformTransaction=function(e){var t=e.actions,r=e.lib,n=e.trx_id,o=t[0],a=o.parent?t.filter((function(e){return 0===e.parent})):t,i=h(t);return{status:"Executed",cpu_usage:o.cpu_usage_us,net_usage:8*o.net_usage_words,id:n,block_time:o["@timestamp"],block_num:o.block_num,delay_sec:"N/A",expiration:"N/A",lib:r,actions:a,traces:i}},exports.inFuture=function(e,t){return void 0===t&&(t=!1),t?q(e).isAfter(q()):j(e).isAfter(j())},exports.inPast=function(e,t){return void 0===t&&(t=!1),t?q(e).isBefore(q()):j(e).isBefore(j())},exports.isSameDay=function(e,t){return void 0===t&&(t=j()),a(e).isSame(a(t),"day")},exports.isString=function(e){return"[object String]"===Object.prototype.toString.call(e)},exports.millisecondsFrom=function(e,t){return void 0===t&&(t=j()),a(e).diff(a(t))},exports.multiply=function(e,t){return new o.BigNumber(e).multipliedBy(t)},exports.namebidsDeserializer=function(e,t){var n=e.actions,o=e.cursor,a=r.Serialize.getTypesFromAbi(r.Serialize.createInitialTypes(),t),i=r.Serialize.getType(a,"name_bid"),s=[];if(n)for(var c,u=l(n);!(c=u()).done;){var d=c.value;if(d.dbops){for(var p,m=l(d.dbops);!(p=m()).done;){var f=p.value;if("namebids"===f.table&&"REM"===f.op){var _=G(f.old.hex),v=new r.Serialize.SerialBuffer({array:_});d.newRow=i.deserialize(v,new r.Serialize.SerializerState({bytesAsUint8Array:!1}))}}d.time=z(d.action_trace.block_time).valueOf(),s.push(d)}}return{actions:s,cursor:o}},exports.nativeTransformGetActions=function(e){return e.actions=e.actions.map((function(e){if(e.action_trace.act.account===n.constants.EOSIO&&"claimrewards"===e.action_trace.act.name&&e.action_trace.inline_traces){for(var t,r=0,o="",a=l(e.action_trace.inline_traces);!(t=a()).done;){var i=t.value;if(i.act.data.from===n.constants.EOSIO_VPAY||i.act.data.from===n.constants.EOSIO_BPAY){var s=i.act.data.quantity.split(" "),c=s[1];r+=Number(s[0]),o=c}}e.action_trace.act.data.quantity=r.toFixed(n.constants.CORE_PRECISION)+" "+o}return e})).reverse(),e.numOfTxLoaded=e.actions.length,e},exports.numberToAmount=B,exports.numberToAmountFormatted=M,exports.numberToAsset=function(e,t,r,o){return void 0===t&&(t=n.constants.CORE_SYMBOL),void 0===r&&(r=n.constants.CORE_PRECISION),void 0===o&&(o=!1),D(e).format({thousandSeparated:!1,mantissa:r,trimMantissa:o})+" "+t},exports.numberToEos=function(e,t,r){return void 0===r&&(r=n.constants.CORE_PRECISION),B(e,r)+" "+t},exports.numberToEosRoundUp=function(e,t,r){return void 0===r&&(r=n.constants.CORE_PRECISION),B(e,r,o.BigNumber.ROUND_UP)+" "+t},exports.numberToRex=function(e,t){return void 0===t&&(t=n.constants.CORE_PRECISION),B(e,t)+" REX"},exports.numberToRexRoundUp=function(e,t){return void 0===t&&(t=n.constants.CORE_PRECISION),B(e,t,o.BigNumber.ROUND_UP)+" REX"},exports.parseCpu=function(e){var t=0,r="";return e<1e3?(t=e,r="µs"):e<1e6?(t=e/1e3,r="ms"):e<6e7?(t=e/1e6,r="s"):e<36e8?(t=e/6e7,r="min"):e<36e11?(t=e/36e8,r="hours"):(t=e/864e8,r="days"),k(t,2,!0)+" "+r},exports.parseNetAndRam=function(e){var t=0,r="";return e<1024?(t=e,r="Bytes"):e<1048576?(t=e/1024,r="KB"):e<1073741824?(t=e/1048576,r="MB"):e<1099511627776?(t=e/1073741824,r="GB"):e<0x4000000000000&&(t=e/1099511627776,r="TB"),k(t,2,!0)+" "+r},exports.parseNft=$,exports.parseNfts=function(e){return e.reduce((function(e,t,r){var n=$(t);return n&&e.push(u({},n,{index:r})),e}),[])},exports.parseRex=function(e){return new o.BigNumber(e).dividedBy(1e4)},exports.parseSeconds=function(e){var t=0,r=0,n=0,o="";return e>86400&&(e-=86400*(t+=Math.floor(e/86400)),o+=t.toFixed(0)+" "+(1===t?"Day":"Days")+" "),e>3600&&(e-=3600*(r+=Math.floor(e/3600)),o+=r.toFixed(0)+" "+(1===r?"Hour":"Hours")+" "),e>60&&(e-=60*(n+=Math.floor(e/60)),o+=n.toFixed(0)+" "+(1===n?"Minute":"Minutes")+" "),e>0&&(o+=e.toFixed(0)+" Seconds "),o},exports.parseTimestamp=function(e,t){return void 0===t&&(t="MMM-DD-YYYY, hh:mm:ss A"),F(L(e),t)},exports.parseUtcTimestamp=function(e,t){return void 0===t&&(t="MMM-DD-YYYY, hh:mm:ss A"),F(z(e),t)},exports.secondsFrom=function(e,t){return void 0===t&&(t=j()),a(e).diff(a(t),"second")},exports.sha=p,exports.split=Y,exports.startDate=H,exports.string_to_uint128_hash=function(e){try{return Promise.resolve(p(e,!1,"SHA-1")).then((function(e){var t=e.match(/../g);return t?t.slice(0,-4).reverse().join(""):0}))}catch(e){return Promise.reject(e)}},exports.substract=function(e,t){return new o.BigNumber(e).minus(t)},exports.time=j,exports.timestampFromNow=function(e){return j(e).fromNow()},exports.timestampToDate=L,exports.toBigNumber=function(e){return new o.BigNumber(e)},exports.toNumbro=function(e){return D(e)},exports.unixTime=function(e){return a.unix(e)},exports.urlBuilder=function(e,t,r){return r=r||{},null!=t&&(e+="/"+encodeURIComponent(t)),0!==Object.keys(r).length&&(e+="?"+c.stringify(r)),e},exports.utcTime=q,exports.utcTimeToLocal=function(e){return a(e).local()},exports.utcTimestampFromNow=function(e){return j(e="Z"===e.slice(-1)?e:e+"Z").fromNow()},exports.utcTimestampToDate=z; | ||
//# sourceMappingURL=utils.cjs.production.min.js.map |
import Long from 'long'; | ||
import { Numeric } from '@jafri/eosjs2'; | ||
import { Numeric, Serialize } from '@protonprotocol/protonjs'; | ||
import { constants } from '@bloks/constants'; | ||
import { BigNumber } from 'bignumber.js'; | ||
import { getTypesFromAbi, createInitialTypes, getType, SerialBuffer, SerializerState } from '@jafri/eosjs2/dist/eosjs-serialize'; | ||
import dayjs from 'dayjs'; | ||
@@ -1606,4 +1605,4 @@ import relativeTime from 'dayjs/plugin/relativeTime'; | ||
cursor = _ref.cursor; | ||
var eosioTypes = getTypesFromAbi(createInitialTypes(), eosioAbi); | ||
var namebidsType = getType(eosioTypes, 'name_bid'); | ||
var eosioTypes = Serialize.getTypesFromAbi(Serialize.createInitialTypes(), eosioAbi); | ||
var namebidsType = Serialize.getType(eosioTypes, 'name_bid'); | ||
var newActions = []; | ||
@@ -1621,6 +1620,6 @@ | ||
var arrayNew = hexToUint8Array(op['old']['hex']); | ||
var bufferNew = new SerialBuffer({ | ||
var bufferNew = new Serialize.SerialBuffer({ | ||
array: arrayNew | ||
}); | ||
action['newRow'] = namebidsType.deserialize(bufferNew, new SerializerState({ | ||
action['newRow'] = namebidsType.deserialize(bufferNew, new Serialize.SerializerState({ | ||
bytesAsUint8Array: false | ||
@@ -1627,0 +1626,0 @@ })); |
{ | ||
"name": "@bloks/utils", | ||
"version": "4.0.182", | ||
"version": "4.0.187", | ||
"author": "jafri", | ||
@@ -34,4 +34,4 @@ "module": "dist/utils.esm.js", | ||
"dependencies": { | ||
"@bloks/constants": "^4.0.182", | ||
"@jafri/eosjs2": "^21.0.0-rc.15", | ||
"@bloks/constants": "^4.0.187", | ||
"@protonprotocol/protonjs": "^21.0.0-rc.19", | ||
"bignumber.js": "^9.0.0", | ||
@@ -45,3 +45,3 @@ "dayjs": "^1.8.18", | ||
}, | ||
"gitHead": "724d73dbb3ba776015f8b5e388b31d88582aaae5" | ||
"gitHead": "9c3c1d9f3373099394ab6d25d30ecb9ab83313d5" | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
404766
3730
+ Added@bloks/constants@26.4.0(transitive)
+ Added@protonprotocol/protonjs@21.0.38(transitive)
+ Addedabort-controller@3.0.0(transitive)
+ Addedbase64url@3.0.1(transitive)
+ Addedbn.js@4.12.1(transitive)
+ Addedbrorand@1.1.0(transitive)
+ Addedcross-fetch@3.1.8(transitive)
+ Addedelliptic@6.6.1(transitive)
+ Addedevent-target-shim@5.0.1(transitive)
+ Addedfast-text-encoding@1.0.6(transitive)
+ Addedhash.js@1.1.7(transitive)
+ Addedhmac-drbg@1.0.1(transitive)
+ Addedminimalistic-assert@1.0.1(transitive)
+ Addedminimalistic-crypto-utils@1.0.1(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addedpako@2.0.3(transitive)
+ Addedripemd-ts@0.0.2(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
- Removed@jafri/eosjs2@^21.0.0-rc.15
- Removed@jafri/eosjs2@21.0.0(transitive)
- Removedripemd-ts@0.0.1(transitive)
Updated@bloks/constants@^4.0.187