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 25.0.0 to 25.0.77

2

dist/utils.cjs.development.js

@@ -152,3 +152,3 @@ 'use strict';

if (littleEndian === void 0) {
littleEndian = true;
littleEndian = false;
}

@@ -155,0 +155,0 @@

@@ -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=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),_=0;_<=12;_++)m=c[f.and(0===_?l:d)]+m,f=f.shiftRight(0===_?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 _(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(_({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(_({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 p(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=_({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 x(t){return a({},t,{account_ram_deltas:[],receiver:"",act_digest:"",traces:[]})}function g(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(g)),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(g(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,O=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,_=t.collection,p=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=_,this.mint=p,this.edition_size=v};function T(t){return t?("Qm"===t.substring(0,2)&&(t="https://ipfs.io/ipfs/"+t),t):t}(w=exports.DbopOp||(exports.DbopOp={})).Ins="INS",w.Rem="REM",w.Upd="UPD",exports.Nft=O,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.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,_=0,p=i(d.execution_trace.action_traces);!(f=p()).done;){var v=f.value;if(v.inline_traces||(v.inline_traces=[]),v.act.account===r.EOSIO&&"claimrewards"===v.act.name){for(var h,x=0,g="",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(" "),O=w[1];x+=Number(w[0]),g=O}}v.act.data.quantity=x.toFixed(r.CORE_PRECISION)+" "+g,delete v.inline_traces,c.push({action_trace:v})}else if(v.act.account===r.EOSIO&&"sellrex"===v.act.name){for(var T,S=i(v.inline_traces);!(T=S()).done;){var E=T.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=[];_=l(e,v,A,m,_),c=c.concat(A.reverse())}_++}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=_,exports.dfuseTransformTransaction=p,exports.dfuseTransformTransactionResult=function(t){return t.execution_trace?p(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 _=Number(d.value).toString(16);m+=(1===_.length?"0":"")+_}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=x,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 x(t)}))}},exports.historyTransformFlatTraces=y,exports.historyTransformRecursiveTrace=g,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(g),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 g(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 g(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 p(t);var _=t.traces.map((function(t){return g(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:_,traces:_}},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=T(t.data.img||t.data.image),r=T(t.data.video),n=T(t.data.audio),i=T(t.data.model),o=T(t.data.stage),c=T(t.data.skybox),s=t.immutable_data;return t.template&&t.template.immutable_data&&(s=a({},s,t.template.immutable_data)),new O({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=T(t.idata&&(t.idata.img||t.idata.image)||t.mdata&&(t.mdata.img||t.mdata.img)),a=T(t.idata&&t.idata.video||t.mdata&&t.mdata.video),n=T(t.idata&&t.idata.audio||t.mdata&&t.mdata.audio),i=T(t.idata&&t.idata.model||t.mdata&&t.mdata.model),o=T(t.idata&&t.idata.stage||t.mdata&&t.mdata.stage),c=T(t.idata&&t.idata.skybox||t.mdata&&t.mdata.skybox);return new O({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)}};
"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),_=0;_<=12;_++)m=c[f.and(0===_?l:d)]+m,f=f.shiftRight(0===_?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 _(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(_({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(_({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 p(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=_({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 x(t){return a({},t,{account_ram_deltas:[],receiver:"",act_digest:"",traces:[]})}function g(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(g)),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(g(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,O=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,_=t.collection,p=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=_,this.mint=p,this.edition_size=v};function T(t){return t?("Qm"===t.substring(0,2)&&(t="https://ipfs.io/ipfs/"+t),t):t}(w=exports.DbopOp||(exports.DbopOp={})).Ins="INS",w.Rem="REM",w.Upd="UPD",exports.Nft=O,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.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,_=0,p=i(d.execution_trace.action_traces);!(f=p()).done;){var v=f.value;if(v.inline_traces||(v.inline_traces=[]),v.act.account===r.EOSIO&&"claimrewards"===v.act.name){for(var h,x=0,g="",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(" "),O=w[1];x+=Number(w[0]),g=O}}v.act.data.quantity=x.toFixed(r.CORE_PRECISION)+" "+g,delete v.inline_traces,c.push({action_trace:v})}else if(v.act.account===r.EOSIO&&"sellrex"===v.act.name){for(var T,S=i(v.inline_traces);!(T=S()).done;){var E=T.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=[];_=l(e,v,A,m,_),c=c.concat(A.reverse())}_++}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=_,exports.dfuseTransformTransaction=p,exports.dfuseTransformTransactionResult=function(t){return t.execution_trace?p(t):h(t)},exports.encodeName=function(t,r){if(void 0===r&&(r=!1),"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 _=Number(d.value).toString(16);m+=(1===_.length?"0":"")+_}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=x,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 x(t)}))}},exports.historyTransformFlatTraces=y,exports.historyTransformRecursiveTrace=g,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(g),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 g(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 g(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 p(t);var _=t.traces.map((function(t){return g(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:_,traces:_}},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=T(t.data.img||t.data.image),r=T(t.data.video),n=T(t.data.audio),i=T(t.data.model),o=T(t.data.stage),c=T(t.data.skybox),s=t.immutable_data;return t.template&&t.template.immutable_data&&(s=a({},s,t.template.immutable_data)),new O({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=T(t.idata&&(t.idata.img||t.idata.image)||t.mdata&&(t.mdata.img||t.mdata.img)),a=T(t.idata&&t.idata.video||t.mdata&&t.mdata.video),n=T(t.idata&&t.idata.audio||t.mdata&&t.mdata.audio),i=T(t.idata&&t.idata.model||t.mdata&&t.mdata.model),o=T(t.idata&&t.idata.stage||t.mdata&&t.mdata.stage),c=T(t.idata&&t.idata.skybox||t.mdata&&t.mdata.skybox);return new O({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

@@ -146,3 +146,3 @@ import Long from 'long';

if (littleEndian === void 0) {
littleEndian = true;
littleEndian = false;
}

@@ -149,0 +149,0 @@

{
"name": "@bloks/utils",
"version": "25.0.0",
"version": "25.0.77",
"author": "jafri",

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

},
"gitHead": "596b74b381b45a8b1ed1ec64033cf0baaa801374"
"gitHead": "b6c058f0c6ef99999db765224459c45c58318018"
}

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