UNPKG

@sofaws/dapp-core

Version:

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

10 lines (9 loc) 41.3 kB
"use strict";var Fr=Object.create;var H=Object.defineProperty,Nr=Object.defineProperties,Br=Object.getOwnPropertyDescriptor,Pr=Object.getOwnPropertyDescriptors,Mr=Object.getOwnPropertyNames,ve=Object.getOwnPropertySymbols,Dr=Object.getPrototypeOf,Ie=Object.prototype.hasOwnProperty,Ur=Object.prototype.propertyIsEnumerable;var Ae=(t,e,r)=>e in t?H(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,A=(t,e)=>{for(var r in e||(e={}))Ie.call(e,r)&&Ae(t,r,e[r]);if(ve)for(var r of ve(e))Ur.call(e,r)&&Ae(t,r,e[r]);return t},B=(t,e)=>Nr(t,Pr(e));var Or=(t,e)=>()=>(t&&(e=t(t=0)),e);var K=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),te=(t,e)=>{for(var r in e)H(t,r,{get:e[r],enumerable:!0})},ke=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Mr(e))!Ie.call(t,o)&&o!==r&&H(t,o,{get:()=>e[o],enumerable:!(n=Br(e,o))||n.enumerable});return t};var Y=(t,e,r)=>(r=t!=null?Fr(Dr(t)):{},ke(e||!t||!t.__esModule?H(r,"default",{value:t,enumerable:!0}):r,t)),Gr=t=>ke(H({},"__esModule",{value:!0}),t);var Ee=(t,e,r)=>new Promise((n,o)=>{var i=l=>{try{u(r.next(l))}catch(p){o(p)}},a=l=>{try{u(r.throw(l))}catch(p){o(p)}},u=l=>l.done?n(l.value):Promise.resolve(l.value).then(i,a);u((r=r.apply(t,e)).next())});var _e=K(X=>{"use strict";c();X.byteLength=qr;X.toByteArray=Wr;X.fromByteArray=Kr;var I=[],b=[],zr=typeof Uint8Array!="undefined"?Uint8Array:Array,ne="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(P=0,Le=ne.length;P<Le;++P)I[P]=ne[P],b[ne.charCodeAt(P)]=P;var P,Le;b["-".charCodeAt(0)]=62;b["_".charCodeAt(0)]=63;function Re(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 qr(t){var e=Re(t),r=e[0],n=e[1];return(r+n)*3/4-n}function Hr(t,e,r){return(e+r)*3/4-r}function Wr(t){var e,r=Re(t),n=r[0],o=r[1],i=new zr(Hr(t,n,o)),a=0,u=o>0?n-4:n,l;for(l=0;l<u;l+=4)e=b[t.charCodeAt(l)]<<18|b[t.charCodeAt(l+1)]<<12|b[t.charCodeAt(l+2)]<<6|b[t.charCodeAt(l+3)],i[a++]=e>>16&255,i[a++]=e>>8&255,i[a++]=e&255;return o===2&&(e=b[t.charCodeAt(l)]<<2|b[t.charCodeAt(l+1)]>>4,i[a++]=e&255),o===1&&(e=b[t.charCodeAt(l)]<<10|b[t.charCodeAt(l+1)]<<4|b[t.charCodeAt(l+2)]>>2,i[a++]=e>>8&255,i[a++]=e&255),i}function jr(t){return I[t>>18&63]+I[t>>12&63]+I[t>>6&63]+I[t&63]}function Vr(t,e,r){for(var n,o=[],i=e;i<r;i+=3)n=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(t[i+2]&255),o.push(jr(n));return o.join("")}function Kr(t){for(var e,r=t.length,n=r%3,o=[],i=16383,a=0,u=r-n;a<u;a+=i)o.push(Vr(t,a,a+i>u?u:a+i));return n===1?(e=t[r-1],o.push(I[e>>2]+I[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],o.push(I[e>>10]+I[e>>4&63]+I[e<<2&63]+"=")),o.join("")}});var Ce=K(oe=>{c();oe.read=function(t,e,r,n,o){var i,a,u=o*8-n-1,l=(1<<u)-1,p=l>>1,y=-7,d=r?o-1:0,x=r?-1:1,w=t[e+d];for(d+=x,i=w&(1<<-y)-1,w>>=-y,y+=u;y>0;i=i*256+t[e+d],d+=x,y-=8);for(a=i&(1<<-y)-1,i>>=-y,y+=n;y>0;a=a*256+t[e+d],d+=x,y-=8);if(i===0)i=1-p;else{if(i===l)return a?NaN:(w?-1:1)*(1/0);a=a+Math.pow(2,n),i=i-p}return(w?-1:1)*a*Math.pow(2,i-n)};oe.write=function(t,e,r,n,o,i){var a,u,l,p=i*8-o-1,y=(1<<p)-1,d=y>>1,x=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=n?0:i-1,N=n?1:-1,R=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,a=y):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),a+d>=1?e+=x/l:e+=x*Math.pow(2,1-d),e*l>=2&&(a++,l/=2),a+d>=y?(u=0,a=y):a+d>=1?(u=(e*l-1)*Math.pow(2,o),a=a+d):(u=e*Math.pow(2,d-1)*Math.pow(2,o),a=0));o>=8;t[r+w]=u&255,w+=N,u/=256,o-=8);for(a=a<<o|u,p+=o;p>0;t[r+w]=a&255,w+=N,a/=256,p-=8);t[r+w-N]|=R*128}});var We=K(G=>{"use strict";c();var ie=_e(),O=Ce(),Fe=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;G.Buffer=s;G.SlowBuffer=$r;G.INSPECT_MAX_BYTES=50;var J=2147483647;G.kMaxLength=J;s.TYPED_ARRAY_SUPPORT=Yr();!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 Yr(){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 _(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 le(t)}return Pe(t,e,r)}s.poolSize=8192;function Pe(t,e,r){if(typeof t=="string")return Jr(t,e);if(ArrayBuffer.isView(t))return Qr(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 se(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 o=Zr(t);if(o)return o;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 Pe(t,e,r)};Object.setPrototypeOf(s.prototype,Uint8Array.prototype);Object.setPrototypeOf(s,Uint8Array);function Me(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 Xr(t,e,r){return Me(t),t<=0?_(t):e!==void 0?typeof r=="string"?_(t).fill(e,r):_(t).fill(e):_(t)}s.alloc=function(t,e,r){return Xr(t,e,r)};function le(t){return Me(t),_(t<0?0:ue(t)|0)}s.allocUnsafe=function(t){return le(t)};s.allocUnsafeSlow=function(t){return le(t)};function Jr(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=De(t,e)|0,n=_(r),o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}function ae(t){for(var e=t.length<0?0:ue(t.length)|0,r=_(e),n=0;n<e;n+=1)r[n]=t[n]&255;return r}function Qr(t){if(k(t,Uint8Array)){var e=new Uint8Array(t);return se(e.buffer,e.byteOffset,e.byteLength)}return ae(t)}function se(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 Zr(t){if(s.isBuffer(t)){var e=ue(t.length)|0,r=_(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||pe(t.length)?_(0):ae(t);if(t.type==="Buffer"&&Array.isArray(t.data))return ae(t.data)}function ue(t){if(t>=J)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+J.toString(16)+" bytes");return t|0}function $r(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,o=r.length,i=0,a=Math.min(n,o);i<a;++i)if(e[i]!==r[i]){n=e[i],o=r[i];break}return n<o?-1:o<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 o=s.allocUnsafe(r),i=0;for(n=0;n<e.length;++n){var a=e[n];if(k(a,Uint8Array))i+a.length>o.length?s.from(a).copy(o,i):Uint8Array.prototype.set.call(o,a,i);else if(s.isBuffer(a))a.copy(o,i);else throw new TypeError('"list" argument must be an Array of Buffers');i+=a.length}return o};function De(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 o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return ce(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return He(t).length;default:if(o)return n?-1:ce(t).length;e=(""+e).toLowerCase(),o=!0}}s.byteLength=De;function et(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 ut(this,e,r);case"utf8":case"utf-8":return Oe(this,e,r);case"ascii":return ct(this,e,r);case"latin1":case"binary":return lt(this,e,r);case"base64":return at(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pt(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}s.prototype._isBuffer=!0;function M(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)M(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)M(this,r,r+3),M(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)M(this,r,r+7),M(this,r+1,r+6),M(this,r+2,r+5),M(this,r+3,r+4);return this};s.prototype.toString=function(){var e=this.length;return e===0?"":arguments.length===0?Oe(this,0,e):et.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=G.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};Fe&&(s.prototype[Fe]=s.prototype.inspect);s.prototype.compare=function(e,r,n,o,i){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),o===void 0&&(o=0),i===void 0&&(i=this.length),r<0||n>e.length||o<0||i>this.length)throw new RangeError("out of range index");if(o>=i&&r>=n)return 0;if(o>=i)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,o>>>=0,i>>>=0,this===e)return 0;for(var a=i-o,u=n-r,l=Math.min(a,u),p=this.slice(o,i),y=e.slice(r,n),d=0;d<l;++d)if(p[d]!==y[d]){a=p[d],u=y[d];break}return a<u?-1:u<a?1:0};function Ue(t,e,r,n,o){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,pe(r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0)if(o)r=0;else return-1;if(typeof e=="string"&&(e=s.from(e,n)),s.isBuffer(e))return e.length===0?-1:Ne(t,e,r,n,o);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):Ne(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function Ne(t,e,r,n,o){var i=1,a=t.length,u=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;i=2,a/=2,u/=2,r/=2}function l(w,N){return i===1?w[N]:w.readUInt16BE(N*i)}var p;if(o){var y=-1;for(p=r;p<a;p++)if(l(t,p)===l(e,y===-1?0:p-y)){if(y===-1&&(y=p),p-y+1===u)return y*i}else y!==-1&&(p-=p-y),y=-1}else for(r+u>a&&(r=a-u),p=r;p>=0;p--){for(var d=!0,x=0;x<u;x++)if(l(t,p+x)!==l(e,x)){d=!1;break}if(d)return p}return-1}s.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};s.prototype.indexOf=function(e,r,n){return Ue(this,e,r,n,!0)};s.prototype.lastIndexOf=function(e,r,n){return Ue(this,e,r,n,!1)};function rt(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n),n>o&&(n=o)):n=o;var i=e.length;n>i/2&&(n=i/2);for(var a=0;a<n;++a){var u=parseInt(e.substr(a*2,2),16);if(pe(u))return a;t[r+a]=u}return a}function tt(t,e,r,n){return Q(ce(e,t.length-r),t,r,n)}function nt(t,e,r,n){return Q(mt(e),t,r,n)}function ot(t,e,r,n){return Q(He(e),t,r,n)}function it(t,e,r,n){return Q(ft(e,t.length-r),t,r,n)}s.prototype.write=function(e,r,n,o){if(r===void 0)o="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")o=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,o===void 0&&(o="utf8")):(o=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var i=this.length-r;if((n===void 0||n>i)&&(n=i),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");for(var a=!1;;)switch(o){case"hex":return rt(this,e,r,n);case"utf8":case"utf-8":return tt(this,e,r,n);case"ascii":case"latin1":case"binary":return nt(this,e,r,n);case"base64":return ot(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return it(this,e,r,n);default:if(a)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),a=!0}};s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function at(t,e,r){return e===0&&r===t.length?ie.fromByteArray(t):ie.fromByteArray(t.slice(e,r))}function Oe(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o<r;){var i=t[o],a=null,u=i>239?4:i>223?3:i>191?2:1;if(o+u<=r){var l,p,y,d;switch(u){case 1:i<128&&(a=i);break;case 2:l=t[o+1],(l&192)===128&&(d=(i&31)<<6|l&63,d>127&&(a=d));break;case 3:l=t[o+1],p=t[o+2],(l&192)===128&&(p&192)===128&&(d=(i&15)<<12|(l&63)<<6|p&63,d>2047&&(d<55296||d>57343)&&(a=d));break;case 4:l=t[o+1],p=t[o+2],y=t[o+3],(l&192)===128&&(p&192)===128&&(y&192)===128&&(d=(i&15)<<18|(l&63)<<12|(p&63)<<6|y&63,d>65535&&d<1114112&&(a=d))}}a===null?(a=65533,u=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|a&1023),n.push(a),o+=u}return st(n)}var Be=4096;function st(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 ct(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]&127);return n}function lt(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function ut(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=e;i<r;++i)o+=yt[t[i]];return o}function pt(t,e,r){for(var n=t.slice(e,r),o="",i=0;i<n.length-1;i+=2)o+=String.fromCharCode(n[i]+n[i+1]*256);return o}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 o=this.subarray(e,r);return Object.setPrototypeOf(o,s.prototype),o};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")}s.prototype.readUintLE=s.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||T(e,r,this.length);for(var o=this[e],i=1,a=0;++a<r&&(i*=256);)o+=this[e+a]*i;return o};s.prototype.readUintBE=s.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||T(e,r,this.length);for(var o=this[e+--r],i=1;r>0&&(i*=256);)o+=this[e+--r]*i;return o};s.prototype.readUint8=s.prototype.readUInt8=function(e,r){return e=e>>>0,r||T(e,1,this.length),this[e]};s.prototype.readUint16LE=s.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||T(e,2,this.length),this[e]|this[e+1]<<8};s.prototype.readUint16BE=s.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||T(e,2,this.length),this[e]<<8|this[e+1]};s.prototype.readUint32LE=s.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};s.prototype.readUint32BE=s.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])};s.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||T(e,r,this.length);for(var o=this[e],i=1,a=0;++a<r&&(i*=256);)o+=this[e+a]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*r)),o};s.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||T(e,r,this.length);for(var o=r,i=1,a=this[e+--o];o>0&&(i*=256);)a+=this[e+--o]*i;return i*=128,a>=i&&(a-=Math.pow(2,8*r)),a};s.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]};s.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};s.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};s.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};s.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]};s.prototype.readFloatLE=function(e,r){return e=e>>>0,r||T(e,4,this.length),O.read(this,e,!0,23,4)};s.prototype.readFloatBE=function(e,r){return e=e>>>0,r||T(e,4,this.length),O.read(this,e,!1,23,4)};s.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||T(e,8,this.length),O.read(this,e,!0,52,8)};s.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||T(e,8,this.length),O.read(this,e,!1,52,8)};function S(t,e,r,n,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)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,o){if(e=+e,r=r>>>0,n=n>>>0,!o){var i=Math.pow(2,8*n)-1;S(this,e,r,n,i,0)}var a=1,u=0;for(this[r]=e&255;++u<n&&(a*=256);)this[r+u]=e/a&255;return r+n};s.prototype.writeUintBE=s.prototype.writeUIntBE=function(e,r,n,o){if(e=+e,r=r>>>0,n=n>>>0,!o){var i=Math.pow(2,8*n)-1;S(this,e,r,n,i,0)}var a=n-1,u=1;for(this[r+a]=e&255;--a>=0&&(u*=256);)this[r+a]=e/u&255;return r+n};s.prototype.writeUint8=s.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||S(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||S(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||S(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||S(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||S(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,o){if(e=+e,r=r>>>0,!o){var i=Math.pow(2,8*n-1);S(this,e,r,n,i-1,-i)}var a=0,u=1,l=0;for(this[r]=e&255;++a<n&&(u*=256);)e<0&&l===0&&this[r+a-1]!==0&&(l=1),this[r+a]=(e/u>>0)-l&255;return r+n};s.prototype.writeIntBE=function(e,r,n,o){if(e=+e,r=r>>>0,!o){var i=Math.pow(2,8*n-1);S(this,e,r,n,i-1,-i)}var a=n-1,u=1,l=0;for(this[r+a]=e&255;--a>=0&&(u*=256);)e<0&&l===0&&this[r+a+1]!==0&&(l=1),this[r+a]=(e/u>>0)-l&255;return r+n};s.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||S(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||S(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||S(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||S(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||S(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 Ge(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ze(t,e,r,n,o){return e=+e,r=r>>>0,o||Ge(t,e,r,4,34028234663852886e22,-34028234663852886e22),O.write(t,e,r,n,23,4),r+4}s.prototype.writeFloatLE=function(e,r,n){return ze(this,e,r,!0,n)};s.prototype.writeFloatBE=function(e,r,n){return ze(this,e,r,!1,n)};function qe(t,e,r,n,o){return e=+e,r=r>>>0,o||Ge(t,e,r,8,17976931348623157e292,-17976931348623157e292),O.write(t,e,r,n,52,8),r+8}s.prototype.writeDoubleLE=function(e,r,n){return qe(this,e,r,!0,n)};s.prototype.writeDoubleBE=function(e,r,n){return qe(this,e,r,!1,n)};s.prototype.copy=function(e,r,n,o){if(!s.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!o&&o!==0&&(o=this.length),r>=e.length&&(r=e.length),r||(r=0),o>0&&o<n&&(o=n),o===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(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-r<o-n&&(o=e.length-r+n);var i=o-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,o):Uint8Array.prototype.set.call(e,this.subarray(n,o),r),i};s.prototype.fill=function(e,r,n,o){if(typeof e=="string"){if(typeof r=="string"?(o=r,r=0,n=this.length):typeof n=="string"&&(o=n,n=this.length),o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!s.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(e.length===1){var i=e.charCodeAt(0);(o==="utf8"&&i<128||o==="latin1")&&(e=i)}}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 u=s.isBuffer(e)?e:s.from(e,o),l=u.length;if(l===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(a=0;a<n-r;++a)this[a+r]=u[a%l]}return this};var dt=/[^+/0-9A-Za-z-_]/g;function gt(t){if(t=t.split("=")[0],t=t.trim().replace(dt,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function ce(t,e){e=e||1/0;for(var r,n=t.length,o=null,i=[],a=0;a<n;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}else if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=(o-55296<<10|r-56320)+65536}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return i}function mt(t){for(var e=[],r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function ft(t,e){for(var r,n,o,i=[],a=0;a<t.length&&!((e-=2)<0);++a)r=t.charCodeAt(a),n=r>>8,o=r%256,i.push(o),i.push(n);return i}function He(t){return ie.toByteArray(gt(t))}function Q(t,e,r,n){for(var o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function k(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function pe(t){return t!==t}var yt=function(){for(var t="0123456789abcdef",e=new Array(256),r=0;r<16;++r)for(var n=r*16,o=0;o<16;++o)e[n+o]=t[r]+t[o];return e}()});var Xe=K((Kt,Ye)=>{c();var h=Ye.exports={},E,L;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"?L=clearTimeout:L=ge}catch(t){L=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 ht(t){if(L===clearTimeout)return clearTimeout(t);if((L===ge||!L)&&clearTimeout)return L=clearTimeout,clearTimeout(t);try{return L(t)}catch(e){try{return L.call(null,t)}catch(r){return L.call(this,t)}}}var C=[],z=!1,D,Z=-1;function Tt(){!z||!D||(z=!1,D.length?C=D.concat(C):Z=-1,C.length&&Ve())}function Ve(){if(!z){var t=je(Tt);z=!0;for(var e=C.length;e;){for(D=C,C=[];++Z<e;)D&&D[Z].run();Z=-1,e=C.length}D=null,z=!1,ht(t)}}h.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];C.push(new Ke(t,e)),C.length===1&&!z&&je(Ve)};function Ke(t,e){this.fun=t,this.array=e}Ke.prototype.run=function(){this.fun.apply(null,this.array)};h.title="browser";h.browser=!0;h.env={};h.argv=[];h.version="";h.versions={};function F(){}h.on=F;h.addListener=F;h.once=F;h.off=F;h.removeListener=F;h.removeAllListeners=F;h.emit=F;h.prependListener=F;h.prependOnceListener=F;h.listeners=function(t){return[]};h.binding=function(t){throw new Error("process.binding is not supported")};h.cwd=function(){return"/"};h.chdir=function(t){throw new Error("process.chdir is not supported")};h.umask=function(){return 0}});var g,m,Yt,c=Or(()=>{g=Y(We()),m=Y(Xe()),Yt=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 qt={};te(qt,{loginSessionMiddleware:()=>zt});module.exports=Gr(qt);c();var Cr=Y(require("lodash.throttle"));c();c();c();c();c();c();c();c();c();c();c();var me={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:Je,egldLabel:pn}=me["devnet"],{chainId:Qe,egldLabel:dn}=me["testnet"],{chainId:Ze,egldLabel:gn}=me["mainnet"];var mn={["devnet"]:Je,["testnet"]:Qe,["mainnet"]:Ze},fn={[Je]:"devnet",[Qe]:"testnet",[Ze]:"mainnet"};c();c();c();var $e="transaction-status-toast-id";var $="logout",er="login";var rr="0";c();c();var sr=require("@reduxjs/toolkit");c();c();var ye={};te(ye,{getItem:()=>wt,localStorageKeys:()=>U,removeItem:()=>St,setItem:()=>xt});c();c();c();var ee=()=>Date.now()/1e3;c();c();var U={loginExpiresAt:"dapp-core-login-expires-at",logoutEvent:"dapp-core-logout-event"},fe=typeof localStorage!="undefined",xt=({key:t,data:e,expires:r})=>{!fe||localStorage.setItem(String(t),JSON.stringify({expires:r,data:e}))},wt=t=>{if(!fe)return;let e=localStorage.getItem(String(t));if(!e)return null;let r=JSON.parse(e);return!r||!r.hasOwnProperty("expires")||!r.hasOwnProperty("data")?null:ee()>=r.expires?(localStorage.removeItem(String(t)),null):r.data},St=t=>{!fe||localStorage.removeItem(String(t))};var he={};te(he,{clear:()=>ir,getItem:()=>nr,removeItem:()=>or,setItem:()=>tr,storage:()=>bt});c();var tr=({key:t,data:e,expires:r})=>{sessionStorage.setItem(String(t),JSON.stringify({expires:r,data:e}))},nr=t=>{let e=sessionStorage.getItem(String(t));if(!e)return null;let r=JSON.parse(e);return!r||!r.hasOwnProperty("expires")||!r.hasOwnProperty("data")?null:Date.now()>=r.expires?(sessionStorage.removeItem(String(t)),null):r.data},or=t=>sessionStorage.removeItem(String(t)),ir=()=>sessionStorage.clear(),bt={setItem:tr,getItem:nr,removeItem:or,clear:ir};var q={session:he,local:ye};function W(){return new Date().setHours(new Date().getHours()+24)}function j(t){q.local.setItem({key:U.loginExpiresAt,data:t,expires:t})}c();var Te=require("@reduxjs/toolkit");var v=(0,Te.createAction)($),re=(0,Te.createAction)(er,t=>({payload:t}));var ar={loginMethod:"",walletConnectLogin:null,ledgerLogin:null,tokenLogin:null,walletLogin:null,extensionLogin:null,isLoginSessionInvalid:!1},cr=(0,sr.createSlice)({name:"loginInfoSlice",initialState:ar,reducers:{setLoginMethod:(t,e)=>{t.loginMethod=e.payload},setTokenLogin:(t,e)=>{t.tokenLogin=e.payload},setTokenLoginSignature:(t,e)=>{(t==null?void 0:t.tokenLogin)!=null&&(t.tokenLogin.signature=e.payload)},setWalletLogin:(t,e)=>{t.walletLogin=e.payload},setWalletConnectLogin:(t,e)=>{t.walletConnectLogin=e.payload},setLedgerLogin:(t,e)=>{t.ledgerLogin=e.payload},invalidateLoginSession:t=>{t.isLoginSessionInvalid=!0}},extraReducers:t=>{t.addCase(v,()=>ar),t.addCase(re,(e,r)=>{e.loginMethod=r.payload.loginMethod,j(W())})}}),{setLoginMethod:Vn,setWalletConnectLogin:Kn,setLedgerLogin:Yn,setTokenLogin:Xn,setTokenLoginSignature:Jn,setWalletLogin:Qn,invalidateLoginSession:lr}=cr.actions,Zn=cr.reducer;c();var ur=require("@reduxjs/toolkit"),pr=Y(require("lodash.omit"));c();c();c();c();function xe(t){return t[Math.floor(Math.random()*t.length)]}c();var vt={id:"not-configured",chainId:"",name:"NOT CONFIGURED",egldLabel:"",decimals:"18",digits:"4",gasPerDataByte:"1500",walletConnectDeepLink:"",walletConnectBridgeAddress:"",walletConnectV2RelayAddress:"",walletConnectV2ProjectId:"",walletAddress:"",apiAddress:"",explorerAddress:"",apiTimeout:"4000"},At={network:vt,chainID:"-1"},dr=(0,ur.createSlice)({name:"appConfig",initialState:At,reducers:{initializeNetworkConfig:(t,e)=>{let r=xe(e.payload.walletConnectBridgeAddresses),n=xe(e.payload.walletConnectV2RelayAddresses),o=(0,pr.default)(e.payload,"walletConnectBridgeAddresses","walletConnectV2RelayAddresses");t.network=B(A(A({},t.network),o),{walletConnectBridgeAddress:r,walletConnectV2RelayAddress:n})},setChainID:(t,e)=>{t.chainID=e.payload}}}),{initializeNetworkConfig:fo,setChainID:yo}=dr.actions,ho=dr.reducer;c();var Se=require("@elrondnetwork/erdjs"),gr=require("@reduxjs/toolkit"),mr=require("redux-persist");var fr={balance:"...",address:"",nonce:0,txCount:0,scrCount:0,claimableRewards:rr},we={address:"",websocketEvent:null,accounts:{"":fr},ledgerAccount:null,publicKey:"",walletConnectAccount:null,isAccountLoading:!0,accountLoadingError:null},yr=(0,gr.createSlice)({name:"accountInfoSlice",initialState:we,reducers:{setAddress:(t,e)=>{let r=e.payload;t.address=r,t.publicKey=new Se.Address(r).hex()},setAccount:(t,e)=>{let r=t.address===e.payload.address;t.accounts={[t.address]:r?e.payload:fr},t.isAccountLoading=!1,t.accountLoadingError=null},setAccountNonce:(t,e)=>{let{address:r}=t;t.accounts[r].nonce=e.payload},setAccountShard:(t,e)=>{t.shard=e.payload},setLedgerAccount:(t,e)=>{t.ledgerAccount=e.payload},updateLedgerAccount:(t,e)=>{t.ledgerAccount!=null&&(t.ledgerAccount.index=e.payload.index,t.ledgerAccount.address=e.payload.address)},setWalletConnectAccount:(t,e)=>{t.walletConnectAccount=e.payload},setIsAccountLoading:(t,e)=>{t.isAccountLoading=e.payload,t.accountLoadingError=null},setAccountLoadingError:(t,e)=>{t.accountLoadingError=e.payload,t.isAccountLoading=!1},setWebsocketEvent:(t,e)=>{t.websocketEvent={timestamp:Date.now(),message:e.payload}}},extraReducers:t=>{t.addCase(v,()=>(q.local.removeItem(U.loginExpiresAt),we)),t.addCase(re,(e,r)=>{let{address:n}=r.payload;e.address=n,e.publicKey=new Se.Address(n).hex()}),t.addCase(mr.REHYDRATE,(e,r)=>{var p;if(!((p=r.payload)!=null&&p.account))return;let{account:n}=r.payload,{address:o,shard:i,accounts:a,publicKey:u}=n;e.address=o,e.shard=i;let l=a&&o in a;e.accounts=l?a:we.accounts,e.publicKey=u})}}),{setAccount:Io,setAddress:ko,setAccountNonce:Eo,setAccountShard:Lo,setLedgerAccount:Ro,updateLedgerAccount:_o,setWalletConnectAccount:Co,setIsAccountLoading:Fo,setAccountLoadingError:No,setWebsocketEvent:Bo}=yr.actions,Po=yr.reducer;c();var xr=require("@reduxjs/toolkit"),wr=require("redux-persist");c();var Oo=["sent"],kt=["success"],Et=["fail","cancelled","timedOut"],Go=["timedOut"],zo=["pending"],Lt=["success"],Rt=["fail","invalid"];function hr(t){return t!=null&&(_t(t)||Ft(t))}function Tr(t){return t!=null&&(Ct(t)||Nt(t))}function _t(t){return t!=null&&kt.includes(t)}function Ct(t){return t!=null&&Et.includes(t)}function Ft(t){return t!=null&&Lt.includes(t)}function Nt(t){return t!=null&&Rt.includes(t)}var V={signedTransactions:{},transactionsToSign:null,signTransactionsError:null,signTransactionsCancelMessage:null,customTransactionInformationForSessionId:{}},Bt={signWithoutSending:!1,sessionInformation:null,redirectAfterSign:!1},Sr=(0,xr.createSlice)({name:"transactionsSlice",initialState:V,reducers:{moveTransactionsToSignedState:(t,e)=>{var l,p;let{sessionId:r,transactions:n,errorMessage:o,status:i,redirectRoute:a}=e.payload,u=((l=t.customTransactionInformationForSessionId)==null?void 0:l[r])||Bt;t.signedTransactions[r]={transactions:n,status:i,errorMessage:o,redirectRoute:a,customTransactionInformation:u},((p=t==null?void 0:t.transactionsToSign)==null?void 0:p.sessionId)===r&&(t.transactionsToSign=V.transactionsToSign)},clearSignedTransaction:(t,e)=>{t.signedTransactions[e.payload]&&delete t.signedTransactions[e.payload]},clearTransactionToSign:t=>{t!=null&&t.transactionsToSign&&(t.transactionsToSign=null)},updateSignedTransaction:(t,e)=>{t.signedTransactions=A(A({},t.signedTransactions),e.payload)},updateSignedTransactions:(t,e)=>{let{sessionId:r,status:n,errorMessage:o,transactions:i}=e.payload;t.signedTransactions[r]!=null&&(t.signedTransactions[r].status=n,o!=null&&(t.signedTransactions[r].errorMessage=o),i!=null&&(t.signedTransactions[r].transactions=i))},updateSignedTransactionStatus:(t,e)=>{var u,l,p,y,d,x;let{sessionId:r,status:n,errorMessage:o,transactionHash:i}=e.payload,a=(l=(u=t.signedTransactions)==null?void 0:u[r])==null?void 0:l.transactions;if(a!=null){t.signedTransactions[r].transactions=a.map(R=>R.hash===i?B(A({},R),{status:n,errorMessage:o}):R);let w=(y=(p=t.signedTransactions[r])==null?void 0:p.transactions)==null?void 0:y.every(R=>hr(R.status)),N=(x=(d=t.signedTransactions[r])==null?void 0:d.transactions)==null?void 0:x.every(R=>Tr(R.status));w&&(t.signedTransactions[r].status="success"),N&&(t.signedTransactions[r].status="fail")}},setTransactionsToSign:(t,e)=>{t.transactionsToSign=e.payload;let{sessionId:r,customTransactionInformation:n}=e.payload;t.customTransactionInformationForSessionId[r]=n,t.signTransactionsError=null},clearAllTransactionsToSign:t=>{t.transactionsToSign=V.transactionsToSign,t.signTransactionsError=null},clearAllSignedTransactions:t=>{t.signedTransactions=V.signedTransactions},setSignTransactionsError:(t,e)=>{t.signTransactionsError=e.payload},setSignTransactionsCancelMessage:(t,e)=>{t.signTransactionsCancelMessage=e.payload}},extraReducers:t=>{t.addCase(v,()=>V),t.addCase(wr.REHYDRATE,(e,r)=>{var a;if(e.signTransactionsCancelMessage=null,!((a=r.payload)!=null&&a.transactions))return;let{signedTransactions:n,customTransactionInformationForSessionId:o}=r.payload.transactions,i=Object.entries(n).reduce((u,[l,p])=>{let y=new Date(l),d=new Date;return d.setHours(d.getHours()+5),d-y>0||(u[l]=p),u},{});o!=null&&(e.customTransactionInformationForSessionId=o),n!=null&&(e.signedTransactions=i)})}}),{updateSignedTransactionStatus:Yo,updateSignedTransactions:Xo,setTransactionsToSign:Jo,clearAllTransactionsToSign:Qo,clearAllSignedTransactions:Zo,clearSignedTransaction:$o,clearTransactionToSign:ei,setSignTransactionsError:ri,setSignTransactionsCancelMessage:ti,moveTransactionsToSignedState:ni}=Sr.actions,oi=Sr.reducer;c();var br=require("@reduxjs/toolkit");var Pt="Transaction failed",Mt="Transaction successful",Dt="Processing transaction",Ut="Transaction submitted",be={},vr=(0,br.createSlice)({name:"transactionsInfo",initialState:be,reducers:{setTransactionsDisplayInfo(t,e){let{sessionId:r,transactionsDisplayInfo:n}=e.payload;r!=null&&(t[r]={errorMessage:(n==null?void 0:n.errorMessage)||Pt,successMessage:(n==null?void 0:n.successMessage)||Mt,processingMessage:(n==null?void 0:n.processingMessage)||Dt,submittedMessage:(n==null?void 0:n.submittedMessage)||Ut,transactionDuration:n==null?void 0:n.transactionDuration})},clearTransactionsInfoForSessionId(t,e){e.payload!=null&&delete t[e.payload]},clearTransactionsInfo:()=>be},extraReducers:t=>{t.addCase(v,()=>be)}}),{clearTransactionsInfo:ci,setTransactionsDisplayInfo:li,clearTransactionsInfoForSessionId:ui}=vr.actions,pi=vr.reducer;c();var Ir=require("@reduxjs/toolkit");var Ar={},kr=(0,Ir.createSlice)({name:"modalsSlice",initialState:Ar,reducers:{setTxSubmittedModal:(t,e)=>{t.txSubmittedModal=e.payload},setNotificationModal:(t,e)=>{t.notificationModal=e.payload},clearTxSubmittedModal:t=>{t.txSubmittedModal=void 0},clearNotificationModal:t=>{t.notificationModal=void 0}},extraReducers:t=>{t.addCase(v,()=>Ar)}}),{setTxSubmittedModal:fi,setNotificationModal:yi,clearTxSubmittedModal:hi,clearNotificationModal:Ti}=kr.actions,xi=kr.reducer;c();var Lr=require("@reduxjs/toolkit"),Rr=require("redux-persist");var Er={customToasts:[],transactionToasts:[],failTransactionToast:null},_r=(0,Lr.createSlice)({name:"toastsSlice",initialState:Er,reducers:{addCustomToast:(t,e)=>{t.customToasts.push(B(A({},e.payload),{type:"custom",toastId:e.payload.toastId||`custom-toast-${t.customToasts.length+1}`}))},removeCustomToast:(t,e)=>{t.customToasts=t.customToasts.filter(r=>r.toastId!==e.payload)},addTransactionToast:(t,e)=>{t.transactionToasts.push({type:"transaction",startTimestamp:ee(),toastId:e.payload||`custom-toast-${t.transactionToasts.length+1}`})},removeTransactionToast:(t,e)=>{t.transactionToasts=t.transactionToasts.filter(r=>r.toastId!==e.payload)},addFailTransactionToast:(t,e)=>{t.failTransactionToast=B(A({},e.payload),{toastId:$e})},removeFailTransactionToast:t=>{t.failTransactionToast=null}},extraReducers:t=>{t.addCase(v,()=>Er),t.addCase(Rr.REHYDRATE,(e,r)=>{var o,i;let n=(i=(o=r.customToasts)==null?void 0:o.filter(a=>!("component"in a)))!=null?i:[];e.customToasts=n})}}),{addCustomToast:Ei,removeCustomToast:Li,addTransactionToast:Ri,removeTransactionToast:_i,addFailTransactionToast:Ci,removeFailTransactionToast:Fi}=_r.actions,Ni=_r.reducer;var Ot=[$],Gt=(0,Cr.default)(()=>{j(W())},5e3),zt=t=>e=>r=>{var l;if(Ot.includes(r.type))return e(r);let n=t.getState(),o=q.local.getItem(U.loginExpiresAt);if(!((l=n==null?void 0:n.loginInfo)==null?void 0:l.isLoggedIn))return e(r);if(o==null)return j(W());let a=Date.now();return o-a<0?setTimeout(()=>Ee(void 0,null,function*(){console.log("session expired");try{t.dispatch(lr())}catch(p){console.error("error logging out",p)}}),1e3):(Gt(),e(r))};0&&(module.exports={loginSessionMiddleware}); /*! * 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=loginSessionMiddleware.js.map