@sofaws/dapp-core
Version:
A library to hold the main logic for a dapp on the Elrond Network
14 lines (13 loc) • 28.7 kB
JavaScript
"use strict";var Nr=Object.create;var _=Object.defineProperty;var Mr=Object.getOwnPropertyDescriptor;var Pr=Object.getOwnPropertyNames;var _r=Object.getPrototypeOf,Vr=Object.prototype.hasOwnProperty;var Hr=(t,r)=>()=>(t&&(r=t(t=0)),r);var V=(t,r)=>()=>(r||t((r={exports:{}}).exports,r),r.exports),Wr=(t,r)=>{for(var e in r)_(t,e,{get:r[e],enumerable:!0})},nr=(t,r,e,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of Pr(r))!Vr.call(t,n)&&n!==e&&_(t,n,{get:()=>r[n],enumerable:!(i=Mr(r,n))||i.enumerable});return t};var Q=(t,r,e)=>(e=t!=null?Nr(_r(t)):{},nr(r||!t||!t.__esModule?_(e,"default",{value:t,enumerable:!0}):e,t)),qr=t=>nr(_({},"__esModule",{value:!0}),t);var ur=V(H=>{"use strict";c();H.byteLength=zr;H.toByteArray=Xr;H.fromByteArray=Jr;var k=[],v=[],Yr=typeof Uint8Array!="undefined"?Uint8Array:Array,X="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(R=0,or=X.length;R<or;++R)k[R]=X[R],v[X.charCodeAt(R)]=R;var R,or;v["-".charCodeAt(0)]=62;v["_".charCodeAt(0)]=63;function ar(t){var r=t.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=t.indexOf("=");e===-1&&(e=r);var i=e===r?0:4-e%4;return[e,i]}function zr(t){var r=ar(t),e=r[0],i=r[1];return(e+i)*3/4-i}function Qr(t,r,e){return(r+e)*3/4-e}function Xr(t){var r,e=ar(t),i=e[0],n=e[1],o=new Yr(Qr(t,i,n)),a=0,s=n>0?i-4:i,f;for(f=0;f<s;f+=4)r=v[t.charCodeAt(f)]<<18|v[t.charCodeAt(f+1)]<<12|v[t.charCodeAt(f+2)]<<6|v[t.charCodeAt(f+3)],o[a++]=r>>16&255,o[a++]=r>>8&255,o[a++]=r&255;return n===2&&(r=v[t.charCodeAt(f)]<<2|v[t.charCodeAt(f+1)]>>4,o[a++]=r&255),n===1&&(r=v[t.charCodeAt(f)]<<10|v[t.charCodeAt(f+1)]<<4|v[t.charCodeAt(f+2)]>>2,o[a++]=r>>8&255,o[a++]=r&255),o}function Gr(t){return k[t>>18&63]+k[t>>12&63]+k[t>>6&63]+k[t&63]}function $r(t,r,e){for(var i,n=[],o=r;o<e;o+=3)i=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(t[o+2]&255),n.push(Gr(i));return n.join("")}function Jr(t){for(var r,e=t.length,i=e%3,n=[],o=16383,a=0,s=e-i;a<s;a+=o)n.push($r(t,a,a+o>s?s:a+o));return i===1?(r=t[e-1],n.push(k[r>>2]+k[r<<4&63]+"==")):i===2&&(r=(t[e-2]<<8)+t[e-1],n.push(k[r>>10]+k[r>>4&63]+k[r<<2&63]+"=")),n.join("")}});var sr=V(G=>{c();G.read=function(t,r,e,i,n){var o,a,s=n*8-i-1,f=(1<<s)-1,p=f>>1,h=-7,l=e?n-1:0,B=e?-1:1,m=t[r+l];for(l+=B,o=m&(1<<-h)-1,m>>=-h,h+=s;h>0;o=o*256+t[r+l],l+=B,h-=8);for(a=o&(1<<-h)-1,o>>=-h,h+=i;h>0;a=a*256+t[r+l],l+=B,h-=8);if(o===0)o=1-p;else{if(o===f)return a?NaN:(m?-1:1)*(1/0);a=a+Math.pow(2,i),o=o-p}return(m?-1:1)*a*Math.pow(2,o-i)};G.write=function(t,r,e,i,n,o){var a,s,f,p=o*8-n-1,h=(1<<p)-1,l=h>>1,B=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,m=i?0:o-1,C=i?1:-1,Cr=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(s=isNaN(r)?1:0,a=h):(a=Math.floor(Math.log(r)/Math.LN2),r*(f=Math.pow(2,-a))<1&&(a--,f*=2),a+l>=1?r+=B/f:r+=B*Math.pow(2,1-l),r*f>=2&&(a++,f/=2),a+l>=h?(s=0,a=h):a+l>=1?(s=(r*f-1)*Math.pow(2,n),a=a+l):(s=r*Math.pow(2,l-1)*Math.pow(2,n),a=0));n>=8;t[e+m]=s&255,m+=C,s/=256,n-=8);for(a=a<<n|s,p+=n;p>0;t[e+m]=a&255,m+=C,a/=256,p-=8);t[e+m-C]|=Cr*128}});var vr=V(M=>{"use strict";c();var $=ur(),N=sr(),fr=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;M.Buffer=u;M.SlowBuffer=ee;M.INSPECT_MAX_BYTES=50;var W=2147483647;M.kMaxLength=W;u.TYPED_ARRAY_SUPPORT=Kr();!u.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Kr(){try{var t=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(t,r),t.foo()===42}catch(e){return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(!!u.isBuffer(this))return this.buffer}});Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(!!u.isBuffer(this))return this.byteOffset}});function E(t){if(t>W)throw new RangeError('The value "'+t+'" is invalid for option "size"');var r=new Uint8Array(t);return Object.setPrototypeOf(r,u.prototype),r}function u(t,r,e){if(typeof t=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return j(t)}return hr(t,r,e)}u.poolSize=8192;function hr(t,r,e){if(typeof t=="string")return jr(t,r);if(ArrayBuffer.isView(t))return Or(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(I(t,ArrayBuffer)||t&&I(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer!="undefined"&&(I(t,SharedArrayBuffer)||t&&I(t.buffer,SharedArrayBuffer)))return K(t,r,e);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var i=t.valueOf&&t.valueOf();if(i!=null&&i!==t)return u.from(i,r,e);var n=re(t);if(n)return n;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return u.from(t[Symbol.toPrimitive]("string"),r,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}u.from=function(t,r,e){return hr(t,r,e)};Object.setPrototypeOf(u.prototype,Uint8Array.prototype);Object.setPrototypeOf(u,Uint8Array);function cr(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function Zr(t,r,e){return cr(t),t<=0?E(t):r!==void 0?typeof e=="string"?E(t).fill(r,e):E(t).fill(r):E(t)}u.alloc=function(t,r,e){return Zr(t,r,e)};function j(t){return cr(t),E(t<0?0:O(t)|0)}u.allocUnsafe=function(t){return j(t)};u.allocUnsafeSlow=function(t){return j(t)};function jr(t,r){if((typeof r!="string"||r==="")&&(r="utf8"),!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r);var e=xr(t,r)|0,i=E(e),n=i.write(t,r);return n!==e&&(i=i.slice(0,n)),i}function J(t){for(var r=t.length<0?0:O(t.length)|0,e=E(r),i=0;i<r;i+=1)e[i]=t[i]&255;return e}function Or(t){if(I(t,Uint8Array)){var r=new Uint8Array(t);return K(r.buffer,r.byteOffset,r.byteLength)}return J(t)}function K(t,r,e){if(r<0||t.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<r+(e||0))throw new RangeError('"length" is outside of buffer bounds');var i;return r===void 0&&e===void 0?i=new Uint8Array(t):e===void 0?i=new Uint8Array(t,r):i=new Uint8Array(t,r,e),Object.setPrototypeOf(i,u.prototype),i}function re(t){if(u.isBuffer(t)){var r=O(t.length)|0,e=E(r);return e.length===0||t.copy(e,0,0,r),e}if(t.length!==void 0)return typeof t.length!="number"||rr(t.length)?E(0):J(t);if(t.type==="Buffer"&&Array.isArray(t.data))return J(t.data)}function O(t){if(t>=W)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+W.toString(16)+" bytes");return t|0}function ee(t){return+t!=t&&(t=0),u.alloc(+t)}u.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==u.prototype};u.compare=function(r,e){if(I(r,Uint8Array)&&(r=u.from(r,r.offset,r.byteLength)),I(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(r)||!u.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===e)return 0;for(var i=r.length,n=e.length,o=0,a=Math.min(i,n);o<a;++o)if(r[o]!==e[o]){i=r[o],n=e[o];break}return i<n?-1:n<i?1:0};u.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};u.concat=function(r,e){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return u.alloc(0);var i;if(e===void 0)for(e=0,i=0;i<r.length;++i)e+=r[i].length;var n=u.allocUnsafe(e),o=0;for(i=0;i<r.length;++i){var a=r[i];if(I(a,Uint8Array))o+a.length>n.length?u.from(a).copy(n,o):Uint8Array.prototype.set.call(n,a,o);else if(u.isBuffer(a))a.copy(n,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=a.length}return n};function xr(t,r){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||I(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var e=t.length,i=arguments.length>2&&arguments[2]===!0;if(!i&&e===0)return 0;for(var n=!1;;)switch(r){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return Z(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Fr(t).length;default:if(n)return i?-1:Z(t).length;r=(""+r).toLowerCase(),n=!0}}u.byteLength=xr;function te(t,r,e){var i=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,r>>>=0,e<=r))return"";for(t||(t="utf8");;)switch(t){case"hex":return he(this,r,e);case"utf8":case"utf-8":return dr(this,r,e);case"ascii":return le(this,r,e);case"latin1":case"binary":return pe(this,r,e);case"base64":return se(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ce(this,r,e);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}u.prototype._isBuffer=!0;function S(t,r,e){var i=t[r];t[r]=t[e],t[e]=i}u.prototype.swap16=function(){var r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<r;e+=2)S(this,e,e+1);return this};u.prototype.swap32=function(){var r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<r;e+=4)S(this,e,e+3),S(this,e+1,e+2);return this};u.prototype.swap64=function(){var r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<r;e+=8)S(this,e,e+7),S(this,e+1,e+6),S(this,e+2,e+5),S(this,e+3,e+4);return this};u.prototype.toString=function(){var r=this.length;return r===0?"":arguments.length===0?dr(this,0,r):te.apply(this,arguments)};u.prototype.toLocaleString=u.prototype.toString;u.prototype.equals=function(r){if(!u.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:u.compare(this,r)===0};u.prototype.inspect=function(){var r="",e=M.INSPECT_MAX_BYTES;return r=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(r+=" ... "),"<Buffer "+r+">"};fr&&(u.prototype[fr]=u.prototype.inspect);u.prototype.compare=function(r,e,i,n,o){if(I(r,Uint8Array)&&(r=u.from(r,r.offset,r.byteLength)),!u.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(e===void 0&&(e=0),i===void 0&&(i=r?r.length:0),n===void 0&&(n=0),o===void 0&&(o=this.length),e<0||i>r.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=i)return 0;if(n>=o)return-1;if(e>=i)return 1;if(e>>>=0,i>>>=0,n>>>=0,o>>>=0,this===r)return 0;for(var a=o-n,s=i-e,f=Math.min(a,s),p=this.slice(n,o),h=r.slice(e,i),l=0;l<f;++l)if(p[l]!==h[l]){a=p[l],s=h[l];break}return a<s?-1:s<a?1:0};function gr(t,r,e,i,n){if(t.length===0)return-1;if(typeof e=="string"?(i=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,rr(e)&&(e=n?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(n)return-1;e=t.length-1}else if(e<0)if(n)e=0;else return-1;if(typeof r=="string"&&(r=u.from(r,i)),u.isBuffer(r))return r.length===0?-1:lr(t,r,e,i,n);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):lr(t,[r],e,i,n);throw new TypeError("val must be string, number or Buffer")}function lr(t,r,e,i,n){var o=1,a=t.length,s=r.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(t.length<2||r.length<2)return-1;o=2,a/=2,s/=2,e/=2}function f(m,C){return o===1?m[C]:m.readUInt16BE(C*o)}var p;if(n){var h=-1;for(p=e;p<a;p++)if(f(t,p)===f(r,h===-1?0:p-h)){if(h===-1&&(h=p),p-h+1===s)return h*o}else h!==-1&&(p-=p-h),h=-1}else for(e+s>a&&(e=a-s),p=e;p>=0;p--){for(var l=!0,B=0;B<s;B++)if(f(t,p+B)!==f(r,B)){l=!1;break}if(l)return p}return-1}u.prototype.includes=function(r,e,i){return this.indexOf(r,e,i)!==-1};u.prototype.indexOf=function(r,e,i){return gr(this,r,e,i,!0)};u.prototype.lastIndexOf=function(r,e,i){return gr(this,r,e,i,!1)};function ie(t,r,e,i){e=Number(e)||0;var n=t.length-e;i?(i=Number(i),i>n&&(i=n)):i=n;var o=r.length;i>o/2&&(i=o/2);for(var a=0;a<i;++a){var s=parseInt(r.substr(a*2,2),16);if(rr(s))return a;t[e+a]=s}return a}function ne(t,r,e,i){return q(Z(r,t.length-e),t,e,i)}function oe(t,r,e,i){return q(de(r),t,e,i)}function ae(t,r,e,i){return q(Fr(r),t,e,i)}function ue(t,r,e,i){return q(ye(r,t.length-e),t,e,i)}u.prototype.write=function(r,e,i,n){if(e===void 0)n="utf8",i=this.length,e=0;else if(i===void 0&&typeof e=="string")n=e,i=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(i)?(i=i>>>0,n===void 0&&(n="utf8")):(n=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var o=this.length-e;if((i===void 0||i>o)&&(i=o),r.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var a=!1;;)switch(n){case"hex":return ie(this,r,e,i);case"utf8":case"utf-8":return ne(this,r,e,i);case"ascii":case"latin1":case"binary":return oe(this,r,e,i);case"base64":return ae(this,r,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(this,r,e,i);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}};u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function se(t,r,e){return r===0&&e===t.length?$.fromByteArray(t):$.fromByteArray(t.slice(r,e))}function dr(t,r,e){e=Math.min(t.length,e);for(var i=[],n=r;n<e;){var o=t[n],a=null,s=o>239?4:o>223?3:o>191?2:1;if(n+s<=e){var f,p,h,l;switch(s){case 1:o<128&&(a=o);break;case 2:f=t[n+1],(f&192)===128&&(l=(o&31)<<6|f&63,l>127&&(a=l));break;case 3:f=t[n+1],p=t[n+2],(f&192)===128&&(p&192)===128&&(l=(o&15)<<12|(f&63)<<6|p&63,l>2047&&(l<55296||l>57343)&&(a=l));break;case 4:f=t[n+1],p=t[n+2],h=t[n+3],(f&192)===128&&(p&192)===128&&(h&192)===128&&(l=(o&15)<<18|(f&63)<<12|(p&63)<<6|h&63,l>65535&&l<1114112&&(a=l))}}a===null?(a=65533,s=1):a>65535&&(a-=65536,i.push(a>>>10&1023|55296),a=56320|a&1023),i.push(a),n+=s}return fe(i)}var pr=4096;function fe(t){var r=t.length;if(r<=pr)return String.fromCharCode.apply(String,t);for(var e="",i=0;i<r;)e+=String.fromCharCode.apply(String,t.slice(i,i+=pr));return e}function le(t,r,e){var i="";e=Math.min(t.length,e);for(var n=r;n<e;++n)i+=String.fromCharCode(t[n]&127);return i}function pe(t,r,e){var i="";e=Math.min(t.length,e);for(var n=r;n<e;++n)i+=String.fromCharCode(t[n]);return i}function he(t,r,e){var i=t.length;(!r||r<0)&&(r=0),(!e||e<0||e>i)&&(e=i);for(var n="",o=r;o<e;++o)n+=we[t[o]];return n}function ce(t,r,e){for(var i=t.slice(r,e),n="",o=0;o<i.length-1;o+=2)n+=String.fromCharCode(i[o]+i[o+1]*256);return n}u.prototype.slice=function(r,e){var i=this.length;r=~~r,e=e===void 0?i:~~e,r<0?(r+=i,r<0&&(r=0)):r>i&&(r=i),e<0?(e+=i,e<0&&(e=0)):e>i&&(e=i),e<r&&(e=r);var n=this.subarray(r,e);return Object.setPrototypeOf(n,u.prototype),n};function d(t,r,e){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+r>e)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(r,e,i){r=r>>>0,e=e>>>0,i||d(r,e,this.length);for(var n=this[r],o=1,a=0;++a<e&&(o*=256);)n+=this[r+a]*o;return n};u.prototype.readUintBE=u.prototype.readUIntBE=function(r,e,i){r=r>>>0,e=e>>>0,i||d(r,e,this.length);for(var n=this[r+--e],o=1;e>0&&(o*=256);)n+=this[r+--e]*o;return n};u.prototype.readUint8=u.prototype.readUInt8=function(r,e){return r=r>>>0,e||d(r,1,this.length),this[r]};u.prototype.readUint16LE=u.prototype.readUInt16LE=function(r,e){return r=r>>>0,e||d(r,2,this.length),this[r]|this[r+1]<<8};u.prototype.readUint16BE=u.prototype.readUInt16BE=function(r,e){return r=r>>>0,e||d(r,2,this.length),this[r]<<8|this[r+1]};u.prototype.readUint32LE=u.prototype.readUInt32LE=function(r,e){return r=r>>>0,e||d(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216};u.prototype.readUint32BE=u.prototype.readUInt32BE=function(r,e){return r=r>>>0,e||d(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])};u.prototype.readIntLE=function(r,e,i){r=r>>>0,e=e>>>0,i||d(r,e,this.length);for(var n=this[r],o=1,a=0;++a<e&&(o*=256);)n+=this[r+a]*o;return o*=128,n>=o&&(n-=Math.pow(2,8*e)),n};u.prototype.readIntBE=function(r,e,i){r=r>>>0,e=e>>>0,i||d(r,e,this.length);for(var n=e,o=1,a=this[r+--n];n>0&&(o*=256);)a+=this[r+--n]*o;return o*=128,a>=o&&(a-=Math.pow(2,8*e)),a};u.prototype.readInt8=function(r,e){return r=r>>>0,e||d(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]};u.prototype.readInt16LE=function(r,e){r=r>>>0,e||d(r,2,this.length);var i=this[r]|this[r+1]<<8;return i&32768?i|4294901760:i};u.prototype.readInt16BE=function(r,e){r=r>>>0,e||d(r,2,this.length);var i=this[r+1]|this[r]<<8;return i&32768?i|4294901760:i};u.prototype.readInt32LE=function(r,e){return r=r>>>0,e||d(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24};u.prototype.readInt32BE=function(r,e){return r=r>>>0,e||d(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]};u.prototype.readFloatLE=function(r,e){return r=r>>>0,e||d(r,4,this.length),N.read(this,r,!0,23,4)};u.prototype.readFloatBE=function(r,e){return r=r>>>0,e||d(r,4,this.length),N.read(this,r,!1,23,4)};u.prototype.readDoubleLE=function(r,e){return r=r>>>0,e||d(r,8,this.length),N.read(this,r,!0,52,8)};u.prototype.readDoubleBE=function(r,e){return r=r>>>0,e||d(r,8,this.length),N.read(this,r,!1,52,8)};function w(t,r,e,i,n,o){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>n||r<o)throw new RangeError('"value" argument is out of bounds');if(e+i>t.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(r,e,i,n){if(r=+r,e=e>>>0,i=i>>>0,!n){var o=Math.pow(2,8*i)-1;w(this,r,e,i,o,0)}var a=1,s=0;for(this[e]=r&255;++s<i&&(a*=256);)this[e+s]=r/a&255;return e+i};u.prototype.writeUintBE=u.prototype.writeUIntBE=function(r,e,i,n){if(r=+r,e=e>>>0,i=i>>>0,!n){var o=Math.pow(2,8*i)-1;w(this,r,e,i,o,0)}var a=i-1,s=1;for(this[e+a]=r&255;--a>=0&&(s*=256);)this[e+a]=r/s&255;return e+i};u.prototype.writeUint8=u.prototype.writeUInt8=function(r,e,i){return r=+r,e=e>>>0,i||w(this,r,e,1,255,0),this[e]=r&255,e+1};u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(r,e,i){return r=+r,e=e>>>0,i||w(this,r,e,2,65535,0),this[e]=r&255,this[e+1]=r>>>8,e+2};u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(r,e,i){return r=+r,e=e>>>0,i||w(this,r,e,2,65535,0),this[e]=r>>>8,this[e+1]=r&255,e+2};u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(r,e,i){return r=+r,e=e>>>0,i||w(this,r,e,4,4294967295,0),this[e+3]=r>>>24,this[e+2]=r>>>16,this[e+1]=r>>>8,this[e]=r&255,e+4};u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(r,e,i){return r=+r,e=e>>>0,i||w(this,r,e,4,4294967295,0),this[e]=r>>>24,this[e+1]=r>>>16,this[e+2]=r>>>8,this[e+3]=r&255,e+4};u.prototype.writeIntLE=function(r,e,i,n){if(r=+r,e=e>>>0,!n){var o=Math.pow(2,8*i-1);w(this,r,e,i,o-1,-o)}var a=0,s=1,f=0;for(this[e]=r&255;++a<i&&(s*=256);)r<0&&f===0&&this[e+a-1]!==0&&(f=1),this[e+a]=(r/s>>0)-f&255;return e+i};u.prototype.writeIntBE=function(r,e,i,n){if(r=+r,e=e>>>0,!n){var o=Math.pow(2,8*i-1);w(this,r,e,i,o-1,-o)}var a=i-1,s=1,f=0;for(this[e+a]=r&255;--a>=0&&(s*=256);)r<0&&f===0&&this[e+a+1]!==0&&(f=1),this[e+a]=(r/s>>0)-f&255;return e+i};u.prototype.writeInt8=function(r,e,i){return r=+r,e=e>>>0,i||w(this,r,e,1,127,-128),r<0&&(r=255+r+1),this[e]=r&255,e+1};u.prototype.writeInt16LE=function(r,e,i){return r=+r,e=e>>>0,i||w(this,r,e,2,32767,-32768),this[e]=r&255,this[e+1]=r>>>8,e+2};u.prototype.writeInt16BE=function(r,e,i){return r=+r,e=e>>>0,i||w(this,r,e,2,32767,-32768),this[e]=r>>>8,this[e+1]=r&255,e+2};u.prototype.writeInt32LE=function(r,e,i){return r=+r,e=e>>>0,i||w(this,r,e,4,2147483647,-2147483648),this[e]=r&255,this[e+1]=r>>>8,this[e+2]=r>>>16,this[e+3]=r>>>24,e+4};u.prototype.writeInt32BE=function(r,e,i){return r=+r,e=e>>>0,i||w(this,r,e,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[e]=r>>>24,this[e+1]=r>>>16,this[e+2]=r>>>8,this[e+3]=r&255,e+4};function yr(t,r,e,i,n,o){if(e+i>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function wr(t,r,e,i,n){return r=+r,e=e>>>0,n||yr(t,r,e,4,34028234663852886e22,-34028234663852886e22),N.write(t,r,e,i,23,4),e+4}u.prototype.writeFloatLE=function(r,e,i){return wr(this,r,e,!0,i)};u.prototype.writeFloatBE=function(r,e,i){return wr(this,r,e,!1,i)};function mr(t,r,e,i,n){return r=+r,e=e>>>0,n||yr(t,r,e,8,17976931348623157e292,-17976931348623157e292),N.write(t,r,e,i,52,8),e+8}u.prototype.writeDoubleLE=function(r,e,i){return mr(this,r,e,!0,i)};u.prototype.writeDoubleBE=function(r,e,i){return mr(this,r,e,!1,i)};u.prototype.copy=function(r,e,i,n){if(!u.isBuffer(r))throw new TypeError("argument should be a Buffer");if(i||(i=0),!n&&n!==0&&(n=this.length),e>=r.length&&(e=r.length),e||(e=0),n>0&&n<i&&(n=i),n===i||r.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),r.length-e<n-i&&(n=r.length-e+i);var o=n-i;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,i,n):Uint8Array.prototype.set.call(r,this.subarray(i,n),e),o};u.prototype.fill=function(r,e,i,n){if(typeof r=="string"){if(typeof e=="string"?(n=e,e=0,i=this.length):typeof i=="string"&&(n=i,i=this.length),n!==void 0&&typeof n!="string")throw new TypeError("encoding must be a string");if(typeof n=="string"&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(r.length===1){var o=r.charCodeAt(0);(n==="utf8"&&o<128||n==="latin1")&&(r=o)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(e<0||this.length<e||this.length<i)throw new RangeError("Out of range index");if(i<=e)return this;e=e>>>0,i=i===void 0?this.length:i>>>0,r||(r=0);var a;if(typeof r=="number")for(a=e;a<i;++a)this[a]=r;else{var s=u.isBuffer(r)?r:u.from(r,n),f=s.length;if(f===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(a=0;a<i-e;++a)this[a+e]=s[a%f]}return this};var xe=/[^+/0-9A-Za-z-_]/g;function ge(t){if(t=t.split("=")[0],t=t.trim().replace(xe,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function Z(t,r){r=r||1/0;for(var e,i=t.length,n=null,o=[],a=0;a<i;++a){if(e=t.charCodeAt(a),e>55295&&e<57344){if(!n){if(e>56319){(r-=3)>-1&&o.push(239,191,189);continue}else if(a+1===i){(r-=3)>-1&&o.push(239,191,189);continue}n=e;continue}if(e<56320){(r-=3)>-1&&o.push(239,191,189),n=e;continue}e=(n-55296<<10|e-56320)+65536}else n&&(r-=3)>-1&&o.push(239,191,189);if(n=null,e<128){if((r-=1)<0)break;o.push(e)}else if(e<2048){if((r-=2)<0)break;o.push(e>>6|192,e&63|128)}else if(e<65536){if((r-=3)<0)break;o.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((r-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return o}function de(t){for(var r=[],e=0;e<t.length;++e)r.push(t.charCodeAt(e)&255);return r}function ye(t,r){for(var e,i,n,o=[],a=0;a<t.length&&!((r-=2)<0);++a)e=t.charCodeAt(a),i=e>>8,n=e%256,o.push(n),o.push(i);return o}function Fr(t){return $.toByteArray(ge(t))}function q(t,r,e,i){for(var n=0;n<i&&!(n+e>=r.length||n>=t.length);++n)r[n+e]=t[n];return n}function I(t,r){return t instanceof r||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===r.name}function rr(t){return t!==t}var we=function(){for(var t="0123456789abcdef",r=new Array(256),e=0;e<16;++e)for(var i=e*16,n=0;n<16;++n)r[i+n]=t[e]+t[n];return r}()});var Tr=V((be,Ur)=>{c();var x=Ur.exports={},U,T;function er(){throw new Error("setTimeout has not been defined")}function tr(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?U=setTimeout:U=er}catch(t){U=er}try{typeof clearTimeout=="function"?T=clearTimeout:T=tr}catch(t){T=tr}})();function Br(t){if(U===setTimeout)return setTimeout(t,0);if((U===er||!U)&&setTimeout)return U=setTimeout,setTimeout(t,0);try{return U(t,0)}catch(r){try{return U.call(null,t,0)}catch(e){return U.call(this,t,0)}}}function me(t){if(T===clearTimeout)return clearTimeout(t);if((T===tr||!T)&&clearTimeout)return T=clearTimeout,clearTimeout(t);try{return T(t)}catch(r){try{return T.call(null,t)}catch(e){return T.call(this,t)}}}var L=[],P=!1,D,Y=-1;function Fe(){!P||!D||(P=!1,D.length?L=D.concat(L):Y=-1,L.length&&kr())}function kr(){if(!P){var t=Br(Fe);P=!0;for(var r=L.length;r;){for(D=L,L=[];++Y<r;)D&&D[Y].run();Y=-1,r=L.length}D=null,P=!1,me(t)}}x.nextTick=function(t){var r=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)r[e-1]=arguments[e];L.push(new Ir(t,r)),L.length===1&&!P&&Br(kr)};function Ir(t,r){this.fun=t,this.array=r}Ir.prototype.run=function(){this.fun.apply(null,this.array)};x.title="browser";x.browser=!0;x.env={};x.argv=[];x.version="";x.versions={};function A(){}x.on=A;x.addListener=A;x.once=A;x.off=A;x.removeListener=A;x.removeAllListeners=A;x.emit=A;x.prependListener=A;x.prependOnceListener=A;x.listeners=function(t){return[]};x.binding=function(t){throw new Error("process.binding is not supported")};x.cwd=function(){return"/"};x.chdir=function(t){throw new Error("process.chdir is not supported")};x.umask=function(){return 0}});var g,y,Re,c=Hr(()=>{g=Q(vr()),y=Q(Tr()),Re=function(t){function r(){var i=this||self;return delete t.prototype.__magic__,i}if(typeof globalThis=="object")return globalThis;if(this)return r();t.defineProperty(t.prototype,"__magic__",{configurable:!0,get:r});var e=__magic__;return e}(Object)});var Ue={};Wr(Ue,{decodeForDisplay:()=>Ie});module.exports=qr(Ue);c();c();c();c();var Rr=require("@elrondnetwork/erdjs/out"),ir=Q(require("bignumber.js"));c();var Er=require("@elrondnetwork/erdjs");function ve(t){try{let r=new Er.Address(t);return Boolean(r.bech32())}catch(r){return!1}}function Lr(t){return(t==null?void 0:t.startsWith("erd"))&&t.length===62&&/^\w+$/.test(t)&&ve(t)}c();function Ar(t){for(let r=0;r<t.length;r++)if(t.charCodeAt(r)>127)return!1;return!0}var b=(t,r,e)=>{switch(r){case"text":try{return g.Buffer.from(String(t),"hex").toString("utf8")}catch(n){}return t;case"decimal":return new ir.default(t,16).toString(10);case"smart":try{let n=Rr.Address.fromHex(t).toString();if(Lr(n))return n}catch(n){}try{let n=g.Buffer.from(String(t),"hex").toString("utf8");return Ar(n)||e&&[...e.esdts,...e.nfts].some(s=>n.includes(s))?n:new ir.default(t,16).toString(10)}catch(n){}return t;case"raw":default:return t}};c();c();var Be=t=>t.toLowerCase().match(/[0-9a-f]/g),ke=t=>t.length%2===0,Sr=t=>{let r=[];return t&&!Be(t)&&r.push(`Invalid Hex characters on argument @${t}`),t&&!ke(t)&&r.push(`Odd number of Hex characters on argument @${t}`),r};c();c();var z=({parts:t,decodedParts:r,identifier:e})=>{let i=[...r];if(t[0]==="ESDTNFTTransfer"&&t[2]&&(i[2]=b(t[2],"decimal")),e==="ESDTNFTTransfer"&&t[1]){let n=g.Buffer.from(String(t[1]),"base64");i[1]=b(n.toString("hex"),"decimal")}return i};var Dr=({parts:t,decodeMethod:r,identifier:e})=>{let i=[],n=t.map((a,s)=>{if(t.length>=2&&(s===0&&a.length<64||s===1&&!t[0]))return/[^a-z0-9]/gi.test(a)?b(a,r):a;{let f=Sr(a);return f.length&&(i=f),b(a,r)}});return{displayValue:(r==="smart"?z({parts:t,decodedParts:n,identifier:e}):n).join("@"),validationWarnings:i}};var Ie=({input:t,decodeMethod:r,identifier:e})=>{let i={displayValue:"",validationWarnings:[]};if(!(t.includes("@")||t.includes(`
`)))return i.displayValue=b(t,r),i;if(t.includes("@")){let o=t.split("@");i=Dr({parts:o,decodeMethod:r,identifier:e})}if(t.includes(`
`)){let o=t.split(`
`),a=o.map(f=>{let p=g.Buffer.from(String(f),"base64");return r==="raw"?f:b(p.toString("hex"),r)}),s=r==="smart"?z({parts:o,decodedParts:a,identifier:e}):a;i.displayValue=s.join(`
`)}return i};0&&(module.exports={decodeForDisplay});
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
//# sourceMappingURL=index.js.map