UNPKG

@sofaws/dapp-core

Version:

A library to hold the main logic for a dapp on the Elrond Network

148 lines (147 loc) 37.1 kB
"use strict";var Xe=Object.create;var V=Object.defineProperty;var Ke=Object.getOwnPropertyDescriptor;var Qe=Object.getOwnPropertyNames;var Ze=Object.getPrototypeOf,$e=Object.prototype.hasOwnProperty;var Je=(t,e)=>()=>(t&&(e=t(t=0)),e);var q=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),er=(t,e)=>{for(var r in e)V(t,r,{get:e[r],enumerable:!0})},le=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Qe(e))!$e.call(t,i)&&i!==r&&V(t,i,{get:()=>e[i],enumerable:!(n=Ke(e,i))||n.enumerable});return t};var z=(t,e,r)=>(r=t!=null?Xe(Ze(t)):{},le(e||!t||!t.__esModule?V(r,"default",{value:t,enumerable:!0}):r,t)),rr=t=>le(V({},"__esModule",{value:!0}),t);var de=q(H=>{"use strict";l();H.byteLength=nr;H.toByteArray=ar;H.fromByteArray=cr;var T=[],_=[],tr=typeof Uint8Array!="undefined"?Uint8Array:Array,Q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(N=0,pe=Q.length;N<pe;++N)T[N]=Q[N],_[Q.charCodeAt(N)]=N;var N,pe;_["-".charCodeAt(0)]=62;_["_".charCodeAt(0)]=63;function ue(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function nr(t){var e=ue(t),r=e[0],n=e[1];return(r+n)*3/4-n}function ir(t,e,r){return(e+r)*3/4-r}function ar(t){var e,r=ue(t),n=r[0],i=r[1],a=new tr(ir(t,n,i)),o=0,c=i>0?n-4:n,p;for(p=0;p<c;p+=4)e=_[t.charCodeAt(p)]<<18|_[t.charCodeAt(p+1)]<<12|_[t.charCodeAt(p+2)]<<6|_[t.charCodeAt(p+3)],a[o++]=e>>16&255,a[o++]=e>>8&255,a[o++]=e&255;return i===2&&(e=_[t.charCodeAt(p)]<<2|_[t.charCodeAt(p+1)]>>4,a[o++]=e&255),i===1&&(e=_[t.charCodeAt(p)]<<10|_[t.charCodeAt(p+1)]<<4|_[t.charCodeAt(p+2)]>>2,a[o++]=e>>8&255,a[o++]=e&255),a}function or(t){return T[t>>18&63]+T[t>>12&63]+T[t>>6&63]+T[t&63]}function sr(t,e,r){for(var n,i=[],a=e;a<r;a+=3)n=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(t[a+2]&255),i.push(or(n));return i.join("")}function cr(t){for(var e,r=t.length,n=r%3,i=[],a=16383,o=0,c=r-n;o<c;o+=a)i.push(sr(t,o,o+a>c?c:o+a));return n===1?(e=t[r-1],i.push(T[e>>2]+T[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(T[e>>10]+T[e>>4&63]+T[e<<2&63]+"=")),i.join("")}});var me=q(Z=>{l();Z.read=function(t,e,r,n,i){var a,o,c=i*8-n-1,p=(1<<c)-1,u=p>>1,m=-7,d=r?i-1:0,v=r?-1:1,b=t[e+d];for(d+=v,a=b&(1<<-m)-1,b>>=-m,m+=c;m>0;a=a*256+t[e+d],d+=v,m-=8);for(o=a&(1<<-m)-1,a>>=-m,m+=n;m>0;o=o*256+t[e+d],d+=v,m-=8);if(a===0)a=1-u;else{if(a===p)return o?NaN:(b?-1:1)*(1/0);o=o+Math.pow(2,n),a=a-u}return(b?-1:1)*o*Math.pow(2,a-n)};Z.write=function(t,e,r,n,i,a){var o,c,p,u=a*8-i-1,m=(1<<u)-1,d=m>>1,v=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,b=n?0:a-1,P=n?1:-1,Ye=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(c=isNaN(e)?1:0,o=m):(o=Math.floor(Math.log(e)/Math.LN2),e*(p=Math.pow(2,-o))<1&&(o--,p*=2),o+d>=1?e+=v/p:e+=v*Math.pow(2,1-d),e*p>=2&&(o++,p/=2),o+d>=m?(c=0,o=m):o+d>=1?(c=(e*p-1)*Math.pow(2,i),o=o+d):(c=e*Math.pow(2,d-1)*Math.pow(2,i),o=0));i>=8;t[r+b]=c&255,b+=P,c/=256,i-=8);for(o=o<<i|c,u+=i;u>0;t[r+b]=o&255,b+=P,o/=256,u-=8);t[r+b-P]|=Ye*128}});var Ie=q(O=>{"use strict";l();var $=de(),M=me(),ge=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;O.Buffer=s;O.SlowBuffer=gr;O.INSPECT_MAX_BYTES=50;var j=2147483647;O.kMaxLength=j;s.TYPED_ARRAY_SUPPORT=lr();!s.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 lr(){try{var t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch(r){return!1}}Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(!!s.isBuffer(this))return this.buffer}});Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(!!s.isBuffer(this))return this.byteOffset}});function A(t){if(t>j)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,s.prototype),e}function s(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return te(t)}return ye(t,e,r)}s.poolSize=8192;function ye(t,e,r){if(typeof t=="string")return ur(t,e);if(ArrayBuffer.isView(t))return dr(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(k(t,ArrayBuffer)||t&&k(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer!="undefined"&&(k(t,SharedArrayBuffer)||t&&k(t.buffer,SharedArrayBuffer)))return ee(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return s.from(n,e,r);var i=mr(t);if(i)return i;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return s.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}s.from=function(t,e,r){return ye(t,e,r)};Object.setPrototypeOf(s.prototype,Uint8Array.prototype);Object.setPrototypeOf(s,Uint8Array);function we(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 pr(t,e,r){return we(t),t<=0?A(t):e!==void 0?typeof r=="string"?A(t).fill(e,r):A(t).fill(e):A(t)}s.alloc=function(t,e,r){return pr(t,e,r)};function te(t){return we(t),A(t<0?0:ne(t)|0)}s.allocUnsafe=function(t){return te(t)};s.allocUnsafeSlow=function(t){return te(t)};function ur(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=xe(t,e)|0,n=A(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function J(t){for(var e=t.length<0?0:ne(t.length)|0,r=A(e),n=0;n<e;n+=1)r[n]=t[n]&255;return r}function dr(t){if(k(t,Uint8Array)){var e=new Uint8Array(t);return ee(e.buffer,e.byteOffset,e.byteLength)}return J(t)}function ee(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');var n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,s.prototype),n}function mr(t){if(s.isBuffer(t)){var e=ne(t.length)|0,r=A(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||ie(t.length)?A(0):J(t);if(t.type==="Buffer"&&Array.isArray(t.data))return J(t.data)}function ne(t){if(t>=j)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+j.toString(16)+" bytes");return t|0}function gr(t){return+t!=t&&(t=0),s.alloc(+t)}s.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==s.prototype};s.compare=function(e,r){if(k(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),k(r,Uint8Array)&&(r=s.from(r,r.offset,r.byteLength)),!s.isBuffer(e)||!s.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;for(var n=e.length,i=r.length,a=0,o=Math.min(n,i);a<o;++a)if(e[a]!==r[a]){n=e[a],i=r[a];break}return n<i?-1:i<n?1:0};s.isEncoding=function(e){switch(String(e).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}};s.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return s.alloc(0);var n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;var i=s.allocUnsafe(r),a=0;for(n=0;n<e.length;++n){var o=e[n];if(k(o,Uint8Array))a+o.length>i.length?s.from(o).copy(i,a):Uint8Array.prototype.set.call(i,o,a);else if(s.isBuffer(o))o.copy(i,a);else throw new TypeError('"list" argument must be an Array of Buffers');a+=o.length}return i};function xe(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||k(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 r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return re(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Ee(t).length;default:if(i)return n?-1:re(t).length;e=(""+e).toLowerCase(),i=!0}}s.byteLength=xe;function fr(t,e,r){var n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return Er(this,e,r);case"utf8":case"utf-8":return _e(this,e,r);case"ascii":return Tr(this,e,r);case"latin1":case"binary":return kr(this,e,r);case"base64":return _r(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ir(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}s.prototype._isBuffer=!0;function B(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}s.prototype.swap16=function(){var e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;r<e;r+=2)B(this,r,r+1);return this};s.prototype.swap32=function(){var e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<e;r+=4)B(this,r,r+3),B(this,r+1,r+2);return this};s.prototype.swap64=function(){var e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<e;r+=8)B(this,r,r+7),B(this,r+1,r+6),B(this,r+2,r+5),B(this,r+3,r+4);return this};s.prototype.toString=function(){var e=this.length;return e===0?"":arguments.length===0?_e(this,0,e):fr.apply(this,arguments)};s.prototype.toLocaleString=s.prototype.toString;s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:s.compare(this,e)===0};s.prototype.inspect=function(){var e="",r=O.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};ge&&(s.prototype[ge]=s.prototype.inspect);s.prototype.compare=function(e,r,n,i,a){if(k(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),a===void 0&&(a=this.length),r<0||n>e.length||i<0||a>this.length)throw new RangeError("out of range index");if(i>=a&&r>=n)return 0;if(i>=a)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,a>>>=0,this===e)return 0;for(var o=a-i,c=n-r,p=Math.min(o,c),u=this.slice(i,a),m=e.slice(r,n),d=0;d<p;++d)if(u[d]!==m[d]){o=u[d],c=m[d];break}return o<c?-1:c<o?1:0};function be(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,ie(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=s.from(e,n)),s.isBuffer(e))return e.length===0?-1:fe(t,e,r,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):fe(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function fe(t,e,r,n,i){var a=1,o=t.length,c=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;a=2,o/=2,c/=2,r/=2}function p(b,P){return a===1?b[P]:b.readUInt16BE(P*a)}var u;if(i){var m=-1;for(u=r;u<o;u++)if(p(t,u)===p(e,m===-1?0:u-m)){if(m===-1&&(m=u),u-m+1===c)return m*a}else m!==-1&&(u-=u-m),m=-1}else for(r+c>o&&(r=o-c),u=r;u>=0;u--){for(var d=!0,v=0;v<c;v++)if(p(t,u+v)!==p(e,v)){d=!1;break}if(d)return u}return-1}s.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};s.prototype.indexOf=function(e,r,n){return be(this,e,r,n,!0)};s.prototype.lastIndexOf=function(e,r,n){return be(this,e,r,n,!1)};function hr(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var a=e.length;n>a/2&&(n=a/2);for(var o=0;o<n;++o){var c=parseInt(e.substr(o*2,2),16);if(ie(c))return o;t[r+o]=c}return o}function yr(t,e,r,n){return W(re(e,t.length-r),t,r,n)}function wr(t,e,r,n){return W(Sr(e),t,r,n)}function xr(t,e,r,n){return W(Ee(e),t,r,n)}function br(t,e,r,n){return W(Fr(e,t.length-r),t,r,n)}s.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var a=this.length-r;if((n===void 0||n>a)&&(n=a),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return hr(this,e,r,n);case"utf8":case"utf-8":return yr(this,e,r,n);case"ascii":case"latin1":case"binary":return wr(this,e,r,n);case"base64":return xr(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return br(this,e,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function _r(t,e,r){return e===0&&r===t.length?$.fromByteArray(t):$.fromByteArray(t.slice(e,r))}function _e(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i<r;){var a=t[i],o=null,c=a>239?4:a>223?3:a>191?2:1;if(i+c<=r){var p,u,m,d;switch(c){case 1:a<128&&(o=a);break;case 2:p=t[i+1],(p&192)===128&&(d=(a&31)<<6|p&63,d>127&&(o=d));break;case 3:p=t[i+1],u=t[i+2],(p&192)===128&&(u&192)===128&&(d=(a&15)<<12|(p&63)<<6|u&63,d>2047&&(d<55296||d>57343)&&(o=d));break;case 4:p=t[i+1],u=t[i+2],m=t[i+3],(p&192)===128&&(u&192)===128&&(m&192)===128&&(d=(a&15)<<18|(p&63)<<12|(u&63)<<6|m&63,d>65535&&d<1114112&&(o=d))}}o===null?(o=65533,c=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=c}return vr(n)}var he=4096;function vr(t){var e=t.length;if(e<=he)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=he));return r}function Tr(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function kr(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function Er(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var i="",a=e;a<r;++a)i+=Dr[t[a]];return i}function Ir(t,e,r){for(var n=t.slice(e,r),i="",a=0;a<n.length-1;a+=2)i+=String.fromCharCode(n[a]+n[a+1]*256);return i}s.prototype.slice=function(e,r){var n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);var i=this.subarray(e,r);return Object.setPrototypeOf(i,s.prototype),i};function w(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUintLE=s.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||w(e,r,this.length);for(var i=this[e],a=1,o=0;++o<r&&(a*=256);)i+=this[e+o]*a;return i};s.prototype.readUintBE=s.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||w(e,r,this.length);for(var i=this[e+--r],a=1;r>0&&(a*=256);)i+=this[e+--r]*a;return i};s.prototype.readUint8=s.prototype.readUInt8=function(e,r){return e=e>>>0,r||w(e,1,this.length),this[e]};s.prototype.readUint16LE=s.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||w(e,2,this.length),this[e]|this[e+1]<<8};s.prototype.readUint16BE=s.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||w(e,2,this.length),this[e]<<8|this[e+1]};s.prototype.readUint32LE=s.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||w(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};s.prototype.readUint32BE=s.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||w(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};s.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||w(e,r,this.length);for(var i=this[e],a=1,o=0;++o<r&&(a*=256);)i+=this[e+o]*a;return a*=128,i>=a&&(i-=Math.pow(2,8*r)),i};s.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||w(e,r,this.length);for(var i=r,a=1,o=this[e+--i];i>0&&(a*=256);)o+=this[e+--i]*a;return a*=128,o>=a&&(o-=Math.pow(2,8*r)),o};s.prototype.readInt8=function(e,r){return e=e>>>0,r||w(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};s.prototype.readInt16LE=function(e,r){e=e>>>0,r||w(e,2,this.length);var n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};s.prototype.readInt16BE=function(e,r){e=e>>>0,r||w(e,2,this.length);var n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};s.prototype.readInt32LE=function(e,r){return e=e>>>0,r||w(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};s.prototype.readInt32BE=function(e,r){return e=e>>>0,r||w(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};s.prototype.readFloatLE=function(e,r){return e=e>>>0,r||w(e,4,this.length),M.read(this,e,!0,23,4)};s.prototype.readFloatBE=function(e,r){return e=e>>>0,r||w(e,4,this.length),M.read(this,e,!1,23,4)};s.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||w(e,8,this.length),M.read(this,e,!0,52,8)};s.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||w(e,8,this.length),M.read(this,e,!1,52,8)};function x(t,e,r,n,i,a){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<a)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){var a=Math.pow(2,8*n)-1;x(this,e,r,n,a,0)}var o=1,c=0;for(this[r]=e&255;++c<n&&(o*=256);)this[r+c]=e/o&255;return r+n};s.prototype.writeUintBE=s.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){var a=Math.pow(2,8*n)-1;x(this,e,r,n,a,0)}var o=n-1,c=1;for(this[r+o]=e&255;--o>=0&&(c*=256);)this[r+o]=e/c&255;return r+n};s.prototype.writeUint8=s.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||x(this,e,r,1,255,0),this[r]=e&255,r+1};s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||x(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||x(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||x(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||x(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};s.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){var a=Math.pow(2,8*n-1);x(this,e,r,n,a-1,-a)}var o=0,c=1,p=0;for(this[r]=e&255;++o<n&&(c*=256);)e<0&&p===0&&this[r+o-1]!==0&&(p=1),this[r+o]=(e/c>>0)-p&255;return r+n};s.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){var a=Math.pow(2,8*n-1);x(this,e,r,n,a-1,-a)}var o=n-1,c=1,p=0;for(this[r+o]=e&255;--o>=0&&(c*=256);)e<0&&p===0&&this[r+o+1]!==0&&(p=1),this[r+o]=(e/c>>0)-p&255;return r+n};s.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||x(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};s.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||x(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};s.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||x(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};s.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||x(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};s.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||x(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function ve(t,e,r,n,i,a){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Te(t,e,r,n,i){return e=+e,r=r>>>0,i||ve(t,e,r,4,34028234663852886e22,-34028234663852886e22),M.write(t,e,r,n,23,4),r+4}s.prototype.writeFloatLE=function(e,r,n){return Te(this,e,r,!0,n)};s.prototype.writeFloatBE=function(e,r,n){return Te(this,e,r,!1,n)};function ke(t,e,r,n,i){return e=+e,r=r>>>0,i||ve(t,e,r,8,17976931348623157e292,-17976931348623157e292),M.write(t,e,r,n,52,8),r+8}s.prototype.writeDoubleLE=function(e,r,n){return ke(this,e,r,!0,n)};s.prototype.writeDoubleBE=function(e,r,n){return ke(this,e,r,!1,n)};s.prototype.copy=function(e,r,n,i){if(!s.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);var a=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),a};s.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!s.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){var a=e.charCodeAt(0);(i==="utf8"&&a<128||i==="latin1")&&(e=a)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);var o;if(typeof e=="number")for(o=r;o<n;++o)this[o]=e;else{var c=s.isBuffer(e)?e:s.from(e,i),p=c.length;if(p===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<n-r;++o)this[o+r]=c[o%p]}return this};var Ar=/[^+/0-9A-Za-z-_]/g;function Rr(t){if(t=t.split("=")[0],t=t.trim().replace(Ar,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function re(t,e){e=e||1/0;for(var r,n=t.length,i=null,a=[],o=0;o<n;++o){if(r=t.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&a.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&a.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&a.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;a.push(r)}else if(r<2048){if((e-=2)<0)break;a.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;a.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return a}function Sr(t){for(var e=[],r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function Fr(t,e){for(var r,n,i,a=[],o=0;o<t.length&&!((e-=2)<0);++o)r=t.charCodeAt(o),n=r>>8,i=r%256,a.push(i),a.push(n);return a}function Ee(t){return $.toByteArray(Rr(t))}function W(t,e,r,n){for(var i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function k(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function ie(t){return t!==t}var Dr=function(){for(var t="0123456789abcdef",e=new Array(256),r=0;r<16;++r)for(var n=r*16,i=0;i<16;++i)e[n+i]=t[r]+t[i];return e}()});var De=q((jr,Fe)=>{l();var y=Fe.exports={},E,I;function ae(){throw new Error("setTimeout has not been defined")}function oe(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?E=setTimeout:E=ae}catch(t){E=ae}try{typeof clearTimeout=="function"?I=clearTimeout:I=oe}catch(t){I=oe}})();function Ae(t){if(E===setTimeout)return setTimeout(t,0);if((E===ae||!E)&&setTimeout)return E=setTimeout,setTimeout(t,0);try{return E(t,0)}catch(e){try{return E.call(null,t,0)}catch(r){return E.call(this,t,0)}}}function Lr(t){if(I===clearTimeout)return clearTimeout(t);if((I===oe||!I)&&clearTimeout)return I=clearTimeout,clearTimeout(t);try{return I(t)}catch(e){try{return I.call(null,t)}catch(r){return I.call(this,t)}}}var R=[],G=!1,C,Y=-1;function Nr(){!G||!C||(G=!1,C.length?R=C.concat(R):Y=-1,R.length&&Re())}function Re(){if(!G){var t=Ae(Nr);G=!0;for(var e=R.length;e;){for(C=R,R=[];++Y<e;)C&&C[Y].run();Y=-1,e=R.length}C=null,G=!1,Lr(t)}}y.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];R.push(new Se(t,e)),R.length===1&&!G&&Ae(Re)};function Se(t,e){this.fun=t,this.array=e}Se.prototype.run=function(){this.fun.apply(null,this.array)};y.title="browser";y.browser=!0;y.env={};y.argv=[];y.version="";y.versions={};function S(){}y.on=S;y.addListener=S;y.once=S;y.off=S;y.removeListener=S;y.removeAllListeners=S;y.emit=S;y.prependListener=S;y.prependOnceListener=S;y.listeners=function(t){return[]};y.binding=function(t){throw new Error("process.binding is not supported")};y.cwd=function(){return"/"};y.chdir=function(t){throw new Error("process.chdir is not supported")};y.umask=function(){return 0}});var g,f,Wr,l=Je(()=>{g=z(Ie()),f=z(De()),Wr=function(t){function e(){var n=this||self;return delete t.prototype.__magic__,n}if(typeof globalThis=="object")return globalThis;if(this)return e();t.defineProperty(t.prototype,"__magic__",{configurable:!0,get:e});var r=__magic__;return r}(Object)});var Gr={};er(Gr,{DataDecode:()=>Or});module.exports=rr(Gr);l();l();var D=z(require("react")),He=require("@fortawesome/free-solid-svg-icons"),je=require("@fortawesome/react-fontawesome"),We=z(require("classnames"));l();l();l();l();l();l();var U=(i=>(i.raw="raw",i.text="text",i.decimal="decimal",i.smart="smart",i))(U||{});l();l();l();l();l();var se={devnet:{id:"devnet",chainId:"D",name:"Devnet",egldLabel:"xEGLD",decimals:"18",digits:"4",gasPerDataByte:"1500",walletConnectDeepLink:"https://maiar.page.link/?apn=com.elrond.maiar.wallet&isi=1519405832&ibi=com.elrond.maiar.wallet&link=https://maiar.com/",walletConnectBridgeAddresses:["https://bridge.walletconnect.org"],walletConnectV2RelayAddresses:["wss://relay.walletconnect.com"],walletAddress:"https://devnet-wallet.elrond.com",apiAddress:"https://devnet-api.elrond.com",explorerAddress:"http://devnet-explorer.elrond.com",apiTimeout:"4000"},testnet:{id:"testnet",chainId:"T",name:"Testnet",egldLabel:"xEGLD",decimals:"18",digits:"4",gasPerDataByte:"1500",walletConnectDeepLink:"https://maiar.page.link/?apn=com.elrond.maiar.wallet&isi=1519405832&ibi=com.elrond.maiar.wallet&link=https://maiar.com/",walletConnectBridgeAddresses:["https://bridge.walletconnect.org"],walletConnectV2RelayAddresses:["wss://relay.walletconnect.com"],walletAddress:"https://testnet-wallet.elrond.com",apiAddress:"https://testnet-api.elrond.com",explorerAddress:"http://testnet-explorer.elrond.com",apiTimeout:"4000"},mainnet:{id:"mainnet",chainId:"1",name:"Mainnet",egldLabel:"xEGLD",decimals:"18",digits:"4",gasPerDataByte:"1500",walletConnectDeepLink:"https://maiar.page.link/?apn=com.elrond.maiar.wallet&isi=1519405832&ibi=com.elrond.maiar.wallet&link=https://maiar.com/",walletConnectBridgeAddresses:["https://bridge.walletconnect.org"],walletConnectV2RelayAddresses:["wss://relay.walletconnect.com"],walletAddress:"https://wallet.elrond.com",apiAddress:"https://api.elrond.com",explorerAddress:"https://explorer.elrond.com",apiTimeout:"4000"}},{chainId:Le,egldLabel:ct}=se["devnet"],{chainId:Ne,egldLabel:lt}=se["testnet"],{chainId:Be,egldLabel:pt}=se["mainnet"];var ut={["devnet"]:Le,["testnet"]:Ne,["mainnet"]:Be},dt={[Le]:"devnet",[Ne]:"testnet",[Be]:"mainnet"};l();l();l();var Ce="N/A";l();var K=require("react");l();l();l();var Oe=require("@elrondnetwork/erdjs/out"),ce=z(require("bignumber.js"));l();var Ue=require("@elrondnetwork/erdjs");function Br(t){try{let e=new Ue.Address(t);return Boolean(e.bech32())}catch(e){return!1}}function Pe(t){return(t==null?void 0:t.startsWith("erd"))&&t.length===62&&/^\w+$/.test(t)&&Br(t)}l();function Me(t){for(let e=0;e<t.length;e++)if(t.charCodeAt(e)>127)return!1;return!0}var F=(t,e,r)=>{switch(e){case"text":try{return g.Buffer.from(String(t),"hex").toString("utf8")}catch(i){}return t;case"decimal":return new ce.default(t,16).toString(10);case"smart":try{let i=Oe.Address.fromHex(t).toString();if(Pe(i))return i}catch(i){}try{let i=g.Buffer.from(String(t),"hex").toString("utf8");return Me(i)||r&&[...r.esdts,...r.nfts].some(c=>i.includes(c))?i:new ce.default(t,16).toString(10)}catch(i){}return t;case"raw":default:return t}};l();l();var Cr=t=>t.toLowerCase().match(/[0-9a-f]/g),Ur=t=>t.length%2===0,Ge=t=>{let e=[];return t&&!Cr(t)&&e.push(`Invalid Hex characters on argument @${t}`),t&&!Ur(t)&&e.push(`Odd number of Hex characters on argument @${t}`),e};l();var X=({parts:t,decodedParts:e,identifier:r})=>{let n=[...e];if(t[0]==="ESDTNFTTransfer"&&t[2]&&(n[2]=F(t[2],"decimal")),r==="ESDTNFTTransfer"&&t[1]){let i=g.Buffer.from(String(t[1]),"base64");n[1]=F(i.toString("hex"),"decimal")}return n};var ze=({parts:t,decodeMethod:e,identifier:r})=>{let n=[],i=t.map((o,c)=>{if(t.length>=2&&(c===0&&o.length<64||c===1&&!t[0]))return/[^a-z0-9]/gi.test(o)?F(o,e):o;{let p=Ge(o);return p.length&&(n=p),F(o,e)}});return{displayValue:(e==="smart"?X({parts:t,decodedParts:i,identifier:r}):i).join("@"),validationWarnings:n}};var Ve=({input:t,decodeMethod:e,identifier:r})=>{let n={displayValue:"",validationWarnings:[]};if(!(t.includes("@")||t.includes(` `)))return n.displayValue=F(t,e),n;if(t.includes("@")){let a=t.split("@");n=ze({parts:a,decodeMethod:e,identifier:r})}if(t.includes(` `)){let a=t.split(` `),o=a.map(p=>{let u=g.Buffer.from(String(p),"base64");return e==="raw"?p:F(u.toString("hex"),e)}),c=e==="smart"?X({parts:a,decodedParts:o,identifier:r}):o;n.displayValue=c.join(` `)}return n};var Pr=[{label:"Raw",value:"raw"},{label:"Text",value:"text"},{label:"Decimal",value:"decimal"},{label:"Smart",value:"smart"}],qe=({value:t,initialDecodeMethod:e,setDecodeMethod:r,identifier:n})=>{let[i,a]=(0,K.useState)(e&&Object.values(U).includes(e)?e:"raw"),{displayValue:o,validationWarnings:c}=Ve({input:t,decodeMethod:i,identifier:n});return(0,K.useEffect)(()=>{r&&r(i)},[i]),{displayValue:o,validationWarnings:c,setActiveKey:a,decodeOptions:Pr}};l();var Mr=`.dapp-core-component__styles__decode { margin-top: 0.25rem; position: relative; max-width: 100%; flex: 1; } .dapp-core-component__styles__decode .dapp-core-component__styles__textarea { -moz-appearance: textfield-multiline; -webkit-appearance: textarea; border: 1px solid #dee2e6; background-color: #fafafa; font-size: 0.8125rem; min-height: 3.125rem; height: 4.5rem; overflow: auto; padding: 0.375rem 6rem 0.375rem 0.75rem; word-wrap: break-word; white-space: pre-wrap; resize: vertical; scrollbar-width: thin; overflow-x: hidden; width: 100%; } .dapp-core-component__styles__decode .dapp-core-component__styles__textarea:hover { border: 1px solid #dee2e6; } @media screen and (-webkit-min-device-pixel-ratio: 0) { .dapp-core-component__styles__decode .dapp-core-component__styles__textarea:before { background: #fafafa; content: ""; bottom: 1px; right: 1px; width: 16px; height: 16px; position: absolute; cursor: ns-resize; } } @media screen and (-webkit-min-device-pixel-ratio: 0) { .dapp-core-component__styles__decode .dapp-core-component__styles__textarea:after { content: ""; bottom: 0; right: 0; width: 16px; height: 16px; position: absolute; -webkit-clip-path: polygon(80% 0, 80% 80%, 0 80%); clip-path: polygon(80% 0, 80% 80%, 0 80%); cursor: ns-resize; background: repeating-linear-gradient(135deg, #dee2e6, #dee2e6 1px, transparent 0, transparent 3px); } } .dapp-core-component__styles__decode .dapp-core-component__styles__textarea::-webkit-scrollbar { background-color: #fafafa; width: 1rem; } .dapp-core-component__styles__decode .dapp-core-component__styles__textarea::-webkit-scrollbar-track { background-color: #fafafa; } .dapp-core-component__styles__decode .dapp-core-component__styles__textarea::-webkit-scrollbar-track:hover { background-color: #fafafa; } .dapp-core-component__styles__decode .dapp-core-component__styles__textarea::-webkit-scrollbar-thumb { background-color: #dee2e6; border-radius: 1rem; border: 5px solid #fafafa; } .dapp-core-component__styles__decode .dapp-core-component__styles__textarea::-webkit-scrollbar-thumb:hover { background-color: #a0a0a5; border: 4px solid #fafafa; } .dapp-core-component__styles__decode .dapp-core-component__styles__textarea::-webkit-scrollbar-button { display: none; } .dapp-core-component__styles__decode .dapp-core-component__styles__textarea::-webkit-resizer { background-color: transparent; } @-moz-document url-prefix() { .dapp-core-component__styles__decode:before, .dapp-core-component__styles__decode:after { display: none; } } .dapp-core-component__styles__decode .dapp-core-component__styles__select { right: 0.313rem; top: 0.313rem; position: absolute; } .dapp-core-component__styles__decode .dapp-core-component__styles__select:after { content: ""; position: absolute; width: 5px; height: 5px; top: calc(50% + 1px); transform: translateY(-50%); left: calc(50% + 0.5rem); border-top: 0.25rem solid; border-right: 0.25rem solid transparent; border-bottom: 0; border-left: 0.25rem solid transparent; } .dapp-core-component__styles__decode .dapp-core-component__styles__select .dapp-core-component__styles__dropdown { appearance: none; text-align: center; padding: 0.25rem 0.5rem; text-indent: -10px; font-size: 0.6875rem; line-height: 1.5; border-radius: 0.25rem; background-color: transparent; border: 1px solid #e4e5e5 !important; transition: all 400ms ease; cursor: pointer; } .dapp-core-component__styles__decode .dapp-core-component__styles__select .dapp-core-component__styles__dropdown:hover { background-color: #eeeeee; } .dapp-core-component__styles__decode .dapp-core-component__styles__select .dapp-core-component__styles__dropdown:active { box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.13) !important; background-color: #eeeeee; } .dapp-core-component__styles__decode .dapp-core-component__styles__select .dapp-core-component__styles__dropdown:focus { outline: none; } .dapp-core-component__styles__decode .dapp-core-component__styles__warnings { display: flex; align-items: center; margin-right: 0.25rem; } .dapp-core-component__styles__decode .dapp-core-component__styles__warnings .dapp-core-component__styles__icon { margin-right: 0.25rem; color: #f0ad4e; } .dapp-core-component__styles__decode .dapp-core-component__styles__warnings .dapp-core-component__styles__warning { color: #f0ad4e; }`;document.head.appendChild(document.createElement("style")).appendChild(document.createTextNode(Mr));var L={decode:"dapp-core-component__styles__decode",textarea:"dapp-core-component__styles__textarea",select:"dapp-core-component__styles__select",dropdown:"dapp-core-component__styles__dropdown",warnings:"dapp-core-component__styles__warnings",icon:"dapp-core-component__styles__icon",warning:"dapp-core-component__styles__warning"};var Or=t=>{let{className:e,value:r}=t,{displayValue:n,validationWarnings:i,setActiveKey:a,decodeOptions:o}=qe(t),c=r&&r!==Ce,p=u=>u?a(u.target.value):"raw";return D.default.createElement("div",{className:L.decode},D.default.createElement("div",{className:(0,We.default)(L.textarea,e)},n),c&&D.default.createElement("div",{className:L.select},D.default.createElement("select",{className:L.dropdown,onChange:p},o.map(u=>D.default.createElement("option",{key:u.value,value:u.value},u.label)))),i.map((u,m)=>D.default.createElement("div",{key:m,className:L.warnings},D.default.createElement(je.FontAwesomeIcon,{icon:He.faExclamationTriangle,className:L.icon,size:"xs"}),D.default.createElement("small",{className:L.warning},u))))};0&&(module.exports={DataDecode}); /*! * 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