UNPKG

@sofaws/dapp-core

Version:

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

10 lines (9 loc) 35 kB
"use strict";var br=Object.create;var z=Object.defineProperty,vr=Object.defineProperties,kr=Object.getOwnPropertyDescriptor,Ir=Object.getOwnPropertyDescriptors,Er=Object.getOwnPropertyNames,Ee=Object.getOwnPropertySymbols,Sr=Object.getPrototypeOf,Ae=Object.prototype.hasOwnProperty,Ar=Object.prototype.propertyIsEnumerable;var Se=(t,e,r)=>e in t?z(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,te=(t,e)=>{for(var r in e||(e={}))Ae.call(e,r)&&Se(t,r,e[r]);if(Ee)for(var r of Ee(e))Ar.call(e,r)&&Se(t,r,e[r]);return t},ne=(t,e)=>vr(t,Ir(e));var Dr=(t,e)=>()=>(t&&(e=t(t=0)),e);var W=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Nr=(t,e)=>{for(var r in e)z(t,r,{get:e[r],enumerable:!0})},De=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Er(e))!Ae.call(t,i)&&i!==r&&z(t,i,{get:()=>e[i],enumerable:!(n=kr(e,i))||n.enumerable});return t};var A=(t,e,r)=>(r=t!=null?br(Sr(t)):{},De(e||!t||!t.__esModule?z(r,"default",{value:t,enumerable:!0}):r,t)),_r=t=>De(z({},"__esModule",{value:!0}),t);var Fe=W(Y=>{"use strict";s();Y.byteLength=Rr;Y.toByteArray=Cr;Y.fromByteArray=Pr;var k=[],v=[],Fr=typeof Uint8Array!="undefined"?Uint8Array:Array,ie="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(B=0,Ne=ie.length;B<Ne;++B)k[B]=ie[B],v[ie.charCodeAt(B)]=B;var B,Ne;v["-".charCodeAt(0)]=62;v["_".charCodeAt(0)]=63;function _e(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 Rr(t){var e=_e(t),r=e[0],n=e[1];return(r+n)*3/4-n}function Lr(t,e,r){return(e+r)*3/4-r}function Cr(t){var e,r=_e(t),n=r[0],i=r[1],o=new Fr(Lr(t,n,i)),a=0,m=i>0?n-4:n,d;for(d=0;d<m;d+=4)e=v[t.charCodeAt(d)]<<18|v[t.charCodeAt(d+1)]<<12|v[t.charCodeAt(d+2)]<<6|v[t.charCodeAt(d+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=e&255;return i===2&&(e=v[t.charCodeAt(d)]<<2|v[t.charCodeAt(d+1)]>>4,o[a++]=e&255),i===1&&(e=v[t.charCodeAt(d)]<<10|v[t.charCodeAt(d+1)]<<4|v[t.charCodeAt(d+2)]>>2,o[a++]=e>>8&255,o[a++]=e&255),o}function Br(t){return k[t>>18&63]+k[t>>12&63]+k[t>>6&63]+k[t&63]}function Or(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(t[o+2]&255),i.push(Br(n));return i.join("")}function Pr(t){for(var e,r=t.length,n=r%3,i=[],o=16383,a=0,m=r-n;a<m;a+=o)i.push(Or(t,a,a+o>m?m:a+o));return n===1?(e=t[r-1],i.push(k[e>>2]+k[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(k[e>>10]+k[e>>4&63]+k[e<<2&63]+"=")),i.join("")}});var Re=W(oe=>{s();oe.read=function(t,e,r,n,i){var o,a,m=i*8-n-1,d=(1<<m)-1,f=d>>1,h=-7,g=r?i-1:0,b=r?-1:1,x=t[e+g];for(g+=b,o=x&(1<<-h)-1,x>>=-h,h+=m;h>0;o=o*256+t[e+g],g+=b,h-=8);for(a=o&(1<<-h)-1,o>>=-h,h+=n;h>0;a=a*256+t[e+g],g+=b,h-=8);if(o===0)o=1-f;else{if(o===d)return a?NaN:(x?-1:1)*(1/0);a=a+Math.pow(2,n),o=o-f}return(x?-1:1)*a*Math.pow(2,o-n)};oe.write=function(t,e,r,n,i,o){var a,m,d,f=o*8-i-1,h=(1<<f)-1,g=h>>1,b=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=n?0:o-1,F=n?1:-1,j=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(m=isNaN(e)?1:0,a=h):(a=Math.floor(Math.log(e)/Math.LN2),e*(d=Math.pow(2,-a))<1&&(a--,d*=2),a+g>=1?e+=b/d:e+=b*Math.pow(2,1-g),e*d>=2&&(a++,d/=2),a+g>=h?(m=0,a=h):a+g>=1?(m=(e*d-1)*Math.pow(2,i),a=a+g):(m=e*Math.pow(2,g-1)*Math.pow(2,i),a=0));i>=8;t[r+x]=m&255,x+=F,m/=256,i-=8);for(a=a<<i|m,f+=i;f>0;t[r+x]=a&255,x+=F,a/=256,f-=8);t[r+x-F]|=j*128}});var qe=W($=>{"use strict";s();var ae=Fe(),M=Re(),Le=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;$.Buffer=c;$.SlowBuffer=Hr;$.INSPECT_MAX_BYTES=50;var Z=2147483647;$.kMaxLength=Z;c.TYPED_ARRAY_SUPPORT=Ur();!c.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 Ur(){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(c.prototype,"parent",{enumerable:!0,get:function(){if(!!c.isBuffer(this))return this.buffer}});Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(!!c.isBuffer(this))return this.byteOffset}});function D(t){if(t>Z)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,c.prototype),e}function c(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 ue(t)}return Oe(t,e,r)}c.poolSize=8192;function Oe(t,e,r){if(typeof t=="string")return $r(t,e);if(ArrayBuffer.isView(t))return Vr(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 ce(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 c.from(n,e,r);var i=Gr(t);if(i)return i;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return c.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)}c.from=function(t,e,r){return Oe(t,e,r)};Object.setPrototypeOf(c.prototype,Uint8Array.prototype);Object.setPrototypeOf(c,Uint8Array);function Pe(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 Mr(t,e,r){return Pe(t),t<=0?D(t):e!==void 0?typeof r=="string"?D(t).fill(e,r):D(t).fill(e):D(t)}c.alloc=function(t,e,r){return Mr(t,e,r)};function ue(t){return Pe(t),D(t<0?0:pe(t)|0)}c.allocUnsafe=function(t){return ue(t)};c.allocUnsafeSlow=function(t){return ue(t)};function $r(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!c.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=Ue(t,e)|0,n=D(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function se(t){for(var e=t.length<0?0:pe(t.length)|0,r=D(e),n=0;n<e;n+=1)r[n]=t[n]&255;return r}function Vr(t){if(I(t,Uint8Array)){var e=new Uint8Array(t);return ce(e.buffer,e.byteOffset,e.byteLength)}return se(t)}function ce(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,c.prototype),n}function Gr(t){if(c.isBuffer(t)){var e=pe(t.length)|0,r=D(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||me(t.length)?D(0):se(t);if(t.type==="Buffer"&&Array.isArray(t.data))return se(t.data)}function pe(t){if(t>=Z)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Z.toString(16)+" bytes");return t|0}function Hr(t){return+t!=t&&(t=0),c.alloc(+t)}c.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==c.prototype};c.compare=function(e,r){if(I(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),I(r,Uint8Array)&&(r=c.from(r,r.offset,r.byteLength)),!c.isBuffer(e)||!c.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,o=0,a=Math.min(n,i);o<a;++o)if(e[o]!==r[o]){n=e[o],i=r[o];break}return n<i?-1:i<n?1:0};c.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}};c.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return c.alloc(0);var n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;var i=c.allocUnsafe(r),o=0;for(n=0;n<e.length;++n){var a=e[n];if(I(a,Uint8Array))o+a.length>i.length?c.from(a).copy(i,o):Uint8Array.prototype.set.call(i,a,o);else if(c.isBuffer(a))a.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=a.length}return i};function Ue(t,e){if(c.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 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 le(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return ze(t).length;default:if(i)return n?-1:le(t).length;e=(""+e).toLowerCase(),i=!0}}c.byteLength=Ue;function zr(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 et(this,e,r);case"utf8":case"utf-8":return $e(this,e,r);case"ascii":return Qr(this,e,r);case"latin1":case"binary":return Jr(this,e,r);case"base64":return Kr(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return rt(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}c.prototype._isBuffer=!0;function O(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}c.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)O(this,r,r+1);return this};c.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)O(this,r,r+3),O(this,r+1,r+2);return this};c.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)O(this,r,r+7),O(this,r+1,r+6),O(this,r+2,r+5),O(this,r+3,r+4);return this};c.prototype.toString=function(){var e=this.length;return e===0?"":arguments.length===0?$e(this,0,e):zr.apply(this,arguments)};c.prototype.toLocaleString=c.prototype.toString;c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:c.compare(this,e)===0};c.prototype.inspect=function(){var e="",r=$.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};Le&&(c.prototype[Le]=c.prototype.inspect);c.prototype.compare=function(e,r,n,i,o){if(I(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.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),o===void 0&&(o=this.length),r<0||n>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===e)return 0;for(var a=o-i,m=n-r,d=Math.min(a,m),f=this.slice(i,o),h=e.slice(r,n),g=0;g<d;++g)if(f[g]!==h[g]){a=f[g],m=h[g];break}return a<m?-1:m<a?1:0};function Me(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,me(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=c.from(e,n)),c.isBuffer(e))return e.length===0?-1:Ce(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):Ce(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Ce(t,e,r,n,i){var o=1,a=t.length,m=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;o=2,a/=2,m/=2,r/=2}function d(x,F){return o===1?x[F]:x.readUInt16BE(F*o)}var f;if(i){var h=-1;for(f=r;f<a;f++)if(d(t,f)===d(e,h===-1?0:f-h)){if(h===-1&&(h=f),f-h+1===m)return h*o}else h!==-1&&(f-=f-h),h=-1}else for(r+m>a&&(r=a-m),f=r;f>=0;f--){for(var g=!0,b=0;b<m;b++)if(d(t,f+b)!==d(e,b)){g=!1;break}if(g)return f}return-1}c.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};c.prototype.indexOf=function(e,r,n){return Me(this,e,r,n,!0)};c.prototype.lastIndexOf=function(e,r,n){return Me(this,e,r,n,!1)};function qr(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var o=e.length;n>o/2&&(n=o/2);for(var a=0;a<n;++a){var m=parseInt(e.substr(a*2,2),16);if(me(m))return a;t[r+a]=m}return a}function jr(t,e,r,n){return K(le(e,t.length-r),t,r,n)}function Wr(t,e,r,n){return K(it(e),t,r,n)}function Yr(t,e,r,n){return K(ze(e),t,r,n)}function Zr(t,e,r,n){return K(ot(e,t.length-r),t,r,n)}c.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 o=this.length-r;if((n===void 0||n>o)&&(n=o),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var a=!1;;)switch(i){case"hex":return qr(this,e,r,n);case"utf8":case"utf-8":return jr(this,e,r,n);case"ascii":case"latin1":case"binary":return Wr(this,e,r,n);case"base64":return Yr(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Zr(this,e,r,n);default:if(a)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),a=!0}};c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Kr(t,e,r){return e===0&&r===t.length?ae.fromByteArray(t):ae.fromByteArray(t.slice(e,r))}function $e(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i<r;){var o=t[i],a=null,m=o>239?4:o>223?3:o>191?2:1;if(i+m<=r){var d,f,h,g;switch(m){case 1:o<128&&(a=o);break;case 2:d=t[i+1],(d&192)===128&&(g=(o&31)<<6|d&63,g>127&&(a=g));break;case 3:d=t[i+1],f=t[i+2],(d&192)===128&&(f&192)===128&&(g=(o&15)<<12|(d&63)<<6|f&63,g>2047&&(g<55296||g>57343)&&(a=g));break;case 4:d=t[i+1],f=t[i+2],h=t[i+3],(d&192)===128&&(f&192)===128&&(h&192)===128&&(g=(o&15)<<18|(d&63)<<12|(f&63)<<6|h&63,g>65535&&g<1114112&&(a=g))}}a===null?(a=65533,m=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|a&1023),n.push(a),i+=m}return Xr(n)}var Be=4096;function Xr(t){var e=t.length;if(e<=Be)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Be));return r}function Qr(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 Jr(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 et(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=e;o<r;++o)i+=at[t[o]];return i}function rt(t,e,r){for(var n=t.slice(e,r),i="",o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}c.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,c.prototype),i};function T(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")}c.prototype.readUintLE=c.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||T(e,r,this.length);for(var i=this[e],o=1,a=0;++a<r&&(o*=256);)i+=this[e+a]*o;return i};c.prototype.readUintBE=c.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||T(e,r,this.length);for(var i=this[e+--r],o=1;r>0&&(o*=256);)i+=this[e+--r]*o;return i};c.prototype.readUint8=c.prototype.readUInt8=function(e,r){return e=e>>>0,r||T(e,1,this.length),this[e]};c.prototype.readUint16LE=c.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||T(e,2,this.length),this[e]|this[e+1]<<8};c.prototype.readUint16BE=c.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||T(e,2,this.length),this[e]<<8|this[e+1]};c.prototype.readUint32LE=c.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||T(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};c.prototype.readUint32BE=c.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||T(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};c.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||T(e,r,this.length);for(var i=this[e],o=1,a=0;++a<r&&(o*=256);)i+=this[e+a]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*r)),i};c.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||T(e,r,this.length);for(var i=r,o=1,a=this[e+--i];i>0&&(o*=256);)a+=this[e+--i]*o;return o*=128,a>=o&&(a-=Math.pow(2,8*r)),a};c.prototype.readInt8=function(e,r){return e=e>>>0,r||T(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};c.prototype.readInt16LE=function(e,r){e=e>>>0,r||T(e,2,this.length);var n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};c.prototype.readInt16BE=function(e,r){e=e>>>0,r||T(e,2,this.length);var n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};c.prototype.readInt32LE=function(e,r){return e=e>>>0,r||T(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};c.prototype.readInt32BE=function(e,r){return e=e>>>0,r||T(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};c.prototype.readFloatLE=function(e,r){return e=e>>>0,r||T(e,4,this.length),M.read(this,e,!0,23,4)};c.prototype.readFloatBE=function(e,r){return e=e>>>0,r||T(e,4,this.length),M.read(this,e,!1,23,4)};c.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||T(e,8,this.length),M.read(this,e,!0,52,8)};c.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||T(e,8,this.length),M.read(this,e,!1,52,8)};function w(t,e,r,n,i,o){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){var o=Math.pow(2,8*n)-1;w(this,e,r,n,o,0)}var a=1,m=0;for(this[r]=e&255;++m<n&&(a*=256);)this[r+m]=e/a&255;return r+n};c.prototype.writeUintBE=c.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){var o=Math.pow(2,8*n)-1;w(this,e,r,n,o,0)}var a=n-1,m=1;for(this[r+a]=e&255;--a>=0&&(m*=256);)this[r+a]=e/m&255;return r+n};c.prototype.writeUint8=c.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||w(this,e,r,1,255,0),this[r]=e&255,r+1};c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||w(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||w(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||w(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};c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||w(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};c.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){var o=Math.pow(2,8*n-1);w(this,e,r,n,o-1,-o)}var a=0,m=1,d=0;for(this[r]=e&255;++a<n&&(m*=256);)e<0&&d===0&&this[r+a-1]!==0&&(d=1),this[r+a]=(e/m>>0)-d&255;return r+n};c.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){var o=Math.pow(2,8*n-1);w(this,e,r,n,o-1,-o)}var a=n-1,m=1,d=0;for(this[r+a]=e&255;--a>=0&&(m*=256);)e<0&&d===0&&this[r+a+1]!==0&&(d=1),this[r+a]=(e/m>>0)-d&255;return r+n};c.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||w(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};c.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||w(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};c.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||w(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};c.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||w(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};c.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||w(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,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Ge(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}c.prototype.writeFloatLE=function(e,r,n){return Ge(this,e,r,!0,n)};c.prototype.writeFloatBE=function(e,r,n){return Ge(this,e,r,!1,n)};function He(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}c.prototype.writeDoubleLE=function(e,r,n){return He(this,e,r,!0,n)};c.prototype.writeDoubleBE=function(e,r,n){return He(this,e,r,!1,n)};c.prototype.copy=function(e,r,n,i){if(!c.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 o=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),o};c.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"&&!c.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){var o=e.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(e=o)}}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 a;if(typeof e=="number")for(a=r;a<n;++a)this[a]=e;else{var m=c.isBuffer(e)?e:c.from(e,i),d=m.length;if(d===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(a=0;a<n-r;++a)this[a+r]=m[a%d]}return this};var tt=/[^+/0-9A-Za-z-_]/g;function nt(t){if(t=t.split("=")[0],t=t.trim().replace(tt,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function le(t,e){e=e||1/0;for(var r,n=t.length,i=null,o=[],a=0;a<n;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function it(t){for(var e=[],r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function ot(t,e){for(var r,n,i,o=[],a=0;a<t.length&&!((e-=2)<0);++a)r=t.charCodeAt(a),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function ze(t){return ae.toByteArray(nt(t))}function K(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 I(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function me(t){return t!==t}var at=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 Ke=W((Gt,Ze)=>{s();var y=Ze.exports={},E,S;function de(){throw new Error("setTimeout has not been defined")}function ge(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?E=setTimeout:E=de}catch(t){E=de}try{typeof clearTimeout=="function"?S=clearTimeout:S=ge}catch(t){S=ge}})();function je(t){if(E===setTimeout)return setTimeout(t,0);if((E===de||!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 st(t){if(S===clearTimeout)return clearTimeout(t);if((S===ge||!S)&&clearTimeout)return S=clearTimeout,clearTimeout(t);try{return S(t)}catch(e){try{return S.call(null,t)}catch(r){return S.call(this,t)}}}var N=[],V=!1,P,X=-1;function ct(){!V||!P||(V=!1,P.length?N=P.concat(N):X=-1,N.length&&We())}function We(){if(!V){var t=je(ct);V=!0;for(var e=N.length;e;){for(P=N,N=[];++X<e;)P&&P[X].run();X=-1,e=N.length}P=null,V=!1,st(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];N.push(new Ye(t,e)),N.length===1&&!V&&je(We)};function Ye(t,e){this.fun=t,this.array=e}Ye.prototype.run=function(){this.fun.apply(null,this.array)};y.title="browser";y.browser=!0;y.env={};y.argv=[];y.version="";y.versions={};function _(){}y.on=_;y.addListener=_;y.once=_;y.off=_;y.removeListener=_;y.removeAllListeners=_;y.emit=_;y.prependListener=_;y.prependOnceListener=_;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 l,u,Ht,s=Dr(()=>{l=A(qe()),u=A(Ke()),Ht=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 Pt={};Nr(Pt,{getInterpretedTransaction:()=>Ot});module.exports=_r(Pt);s();s();var q=require("@elrondnetwork/erdjs");s();s();s();s();s();s();s();s();s();var Xe=require("@elrondnetwork/erdjs");function lt(t){try{let e=new Xe.Address(t);return Boolean(e.bech32())}catch(e){return!1}}function Q(t){return(t==null?void 0:t.startsWith("erd"))&&t.length===62&&/^\w+$/.test(t)&&lt(t)}s();function Qe(t){try{return l.Buffer.from(t,"base64").toString()===atob(t)}catch(e){return!1}}var ut=["ESDTNFTTransfer","ESDTNFTBurn","ESDTNFTAddQuantity","ESDTNFTCreate","MultiESDTNFTTransfer","ESDTTransfer","ESDTBurn","ESDTLocalMint","ESDTLocalBurn","ESDTWipe","ESDTFreeze"];function Je(t,e,r=""){if(!Q(t))return!1;if(new q.Address(t).isContractAddress())return!0;let o=gt({receiver:t,data:r});return o?new q.Address(o).isContractAddress()||dt(t,e,r):!1}var pt=t=>t.toLowerCase().match(/[0-9a-f]/g),mt=t=>t.length%2===0;function dt(t,e,r){let n=r==null?void 0:r.split("@");if(n==null)return!1;let[i,...o]=n,a=e!=null&&t!=null&&t===e,m=ut.includes(i),d=o.every(f=>pt(f)&&mt(f));return a&&m&&d}function gt({receiver:t,data:e}){try{if(!e)return t;let r=Qe(e)?q.TransactionPayload.fromEncoded(e).toString():e,n=ft(r),i=r.split("@");return n>-1?i[n]:t}catch(r){console.log(r);return}}function ft(t){return t.includes("MultiESDTNFTTransfer")?1:t.includes("ESDTNFTTransfer")?4:-1}s();var he=require("@elrondnetwork/erdjs"),ye=A(require("bignumber.js"));s();s();function er(t){for(let e=0;e<t.length;e++)if(t.charCodeAt(e)>127)return!1;return!0}function rr(t){let e=t;try{let r=l.Buffer.from(t,"hex").toString();er(r)&&r.length>1&&(e=r)}catch(r){}return e}var fe={tokenId:"",amount:""},ht=t=>t.split("@").map((o,a)=>[2,3].includes(a)?o:rr(o));function tr(t){if(!t)return fe;let e=t.startsWith("ESDTTransfer"),r=t.startsWith("ESDTNFTTransfer")&&t.includes("@");if(e){let[,n,i]=t.split("@");try{let o=l.Buffer.from(n,"hex").toString("ascii");if(!o)return fe;let a=new ye.default("0x"+i.replace("0x","")).toString(10);return{tokenId:o,amount:a}}catch(o){console.error("Error getting token from transaction data",o)}}if(r)try{let[,n,i,o,a]=ht(t);if([n,i,o,a].every(m=>Boolean(m))&&Q(new he.Address(a).bech32()))return{tokenId:`${n}-${i}`,amount:new ye.default(o,16).toString(10),collection:n,nonce:i,receiver:new he.Address(a).bech32()}}catch(n){}return fe}s();s();s();var R="accounts",U="transactions";var G="tokens",nr="blocks";var ir="nodes",or="identities",ar="collections",Te="nfts",xe="providers",we="sc-results",sr="contracts",cr="logs",lr="code",ur="locked-accounts",pr="roles";var L={shard:t=>`/${nr}?shard=${t}`,receiverShard:t=>`/${U}?receivershard=${t}`,senderShard:t=>`/${U}?sendershard=${t}`,transactionDetails:t=>`/${U}/${t}`,transactionDetailsScResults:t=>`/${U}/${t}/${we}`,transactionDetailsLogs:t=>`/${U}/${t}/${cr}`,nodeDetails:t=>`/${ir}/${t}`,accountDetails:t=>`/${R}/${t}`,accountDetailsContractCode:t=>`/${R}/${t}/${lr}`,accountDetailsTokens:t=>`/${R}/${t}/${G}`,accountDetailsNfts:t=>`/${R}/${t}/${Te}`,accountDetailsScResults:t=>`/${R}/${t}/${we}`,accountDetailsContracts:t=>`/${R}/${t}/${sr}`,identityDetails:t=>`/${or}/${t}`,tokenDetails:t=>`/${G}/${t}`,tokenDetailsAccounts:t=>`/${G}/${t}/${R}`,tokenDetailsLockedAccounts:t=>`/${G}/${t}/${ur}`,tokenDetailsRoles:t=>`/${G}/${t}/${pr}`,collectionDetails:t=>`/${ar}/${t}`,nftDetails:t=>`/${Te}/${t}`,providerDetails:t=>`/${xe}/${t}`,providerDetailsTransactions:t=>`/${xe}/${t}/${U}`};s();var be=t=>{var e,r,n,i;if(t.action){let o=[(e=t.action.arguments)==null?void 0:e.token,(r=t.action.arguments)==null?void 0:r.token1,(n=t.action.arguments)==null?void 0:n.token2,(i=t.action.arguments)==null?void 0:i.transfers].filter(m=>m!=null);return[].concat(...o)}return[]};s();s();function J(t){var r,n;let e=t.receiver;return(n=(r=t.action)==null?void 0:r.arguments)!=null&&n.receiver&&(e=t.action.arguments.receiver),e}function mr(t){let e=J(t);return t.receiver===e?t.receiverAssets:void 0}s();var dr=t=>{var n,i,o,a,m,d;let e="Transaction";return((n=t.action)==null?void 0:n.name)&&((i=t.action)==null?void 0:i.category)&&(((o=t.action)==null?void 0:o.category)==="esdtNft"&&((a=t.action)==null?void 0:a.name)==="transfer"?e="Transaction":t.action&&(e=t.action.name),(d=(m=t.action)==null?void 0:m.arguments)!=null&&d.functionName&&(e=t.action.arguments.functionName)),e};s();var gr=!1;function Tt(t){gr||(console.error(t),gr=!0)}function H({explorerAddress:t,to:e}){try{return new URL(e).href}catch(r){return e.startsWith("/")||(Tt(`Link not prepended by / : ${e}`),e=`/${e}`),t?`${t}${e}`:e}}s();function fr(t,e,r){let n=t===e.sender,i=t===r,o=n&&i,a=(e==null?void 0:e.type)==="SmartContractResult";switch(!0){case a:return"Internal";case o:return"Self";case i:return"In";case n:default:return"Out"}}s();s();s();var vt=A(require("bignumber.js"));s();s();s();var ve={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:hr,egldLabel:$n}=ve["devnet"],{chainId:yr,egldLabel:Vn}=ve["testnet"],{chainId:Tr,egldLabel:Gn}=ve["mainnet"];var Hn={["devnet"]:hr,["testnet"]:yr,["mainnet"]:Tr},zn={[hr]:"devnet",[yr]:"testnet",[Tr]:"mainnet"};s();s();s();s();var bt=require("@elrondnetwork/erdjs"),ke=A(require("bignumber.js"));s();var xt=A(require("bignumber.js"));s();ke.default.config({ROUNDING_MODE:ke.default.ROUND_FLOOR});s();s();s();s();s();s();s();s();s();var kt=require("@elrondnetwork/erdjs");s();var re=require("@elrondnetwork/erdjs"),Et=require("@elrondnetwork/erdjs"),St=require("@elrondnetwork/erdjs-network-providers");s();s();var It=A(require("bignumber.js"));s();s();s();s();s();s();s();var Dt=["reDelegateRewards","claimRewards","unBond"],Nt=["wrapEgld","unwrapEgld"],_t=["unStake"],Ft=["unDelegate"];s();s();s();s();var Ct=A(require("bignumber.js"));s();s();s();s();var Bt=A(require("bignumber.js"));function Ot({transaction:t,address:e,explorerAddress:r}){var j;let n=(j=t.tokenIdentifier)!=null?j:tr(t.data).tokenId,i=J(t),o=mr(t),a=fr(e,t,i),m=dr(t),d=be(t),f=H({explorerAddress:r,to:L.accountDetails(t.sender)}),h=H({explorerAddress:r,to:L.accountDetails(i)}),g=H({explorerAddress:r,to:L.senderShard(t.senderShard)}),b=H({explorerAddress:r,to:L.receiverShard(t.receiverShard)}),x=t.originalTxHash?`${t.originalTxHash}#${t.txHash}`:t.txHash,F=H({explorerAddress:r,to:L.transactionDetails(x)});return ne(te({},t),{tokenIdentifier:n,receiver:i,receiverAssets:o,transactionDetails:{direction:a,method:m,transactionTokens:d,isContract:Je(t.sender)},links:{senderLink:f,receiverLink:h,senderShardLink:g,receiverShardLink:b,transactionLink:F}})}0&&(module.exports={getInterpretedTransaction}); /*! * 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=getInterpretedTransaction.js.map