diff --git a/README.md b/README.md index 3cecd1e..3c43b96 100644 --- a/README.md +++ b/README.md @@ -44,9 +44,7 @@ const snxjs = synthetix({ network: 'mainnet' }); // If you want to interact with a contract, simply follow the convention: // await snxjs[contractName].methodName(arguments) // many arguments require being formatted toBytes32, which we also provide with the library -// Note can optionally pass in a { blockTag: someBlockNumber } to get data from a specific block instead of {} -E.g: -const unformattedSnxPrice = await snxjs.contracts.ExchangeRates.rateForCurrency(snxjs.toBytes32('SNX'), {}); +const unformattedSnxPrice = await snxjs.contracts.ExchangeRates.rateForCurrency(snxjs.toBytes32('SNX')); const unformattedTotalSupply = await snxjs.contracts.SynthsUSD.totalSupply({}); // We also expose ethers utils which provides handy methods for formatting responses to queries. @@ -57,4 +55,25 @@ const totalSupply = formatEther(unformattedTotalSupply); ``` +###### Historic block data + +``` +// NOTE for historic block data you have two options: +// both of these options require an archive node as a provider to work properly + +// Option 1 (see either examples/node-example.js or examples/node-older-blocks-example.js): +const unformattedSnxPrice = await snxjs.contracts.ExchangeRates.rateForCurrency(snxjs.toBytes32('SNX'), { blockTag: 10000000 }); +const unformattedTotalSupply = await snxjs.contracts.SynthsUSD.totalSupply({ blockTag: 10000000 }); + +// Option 2 (see examples/node-older-blocks-example.js): +// we added a helper to make life easier if you are pulling a lot of data from the same older block\ +// so you don't have to add the blockTag every time. +// this will automatically pass the block 10290987 as the blockTag reference for every method called on olderContracts +const olderContracts = snxjs.contractsAtBlock(10290987); +const olderUnformattedSnxPrice = await olderContracts.ExchangeRates.rateForCurrency( + snxjs.toBytes32('SNX') +); + +``` + See the examples folder for more usage details diff --git a/build/index.js b/build/index.js index 29cbb6b..0f6131b 100644 --- a/build/index.js +++ b/build/index.js @@ -33,4 +33,4 @@ var f=t(5),n=f.Buffer;function b(e,a){for(var t in e)a[t]=e[t]}function d(e,a,t) * @copyright Chen, Yi-Cyuan 2015-2016 * @license MIT */ -!function(){var a="object"==typeof window?window:{};!a.JS_SHA3_NO_NODE_JS&&"object"==typeof t&&t.versions&&t.versions.node&&(a=n);for(var f=!a.JS_SHA3_NO_COMMON_JS&&e.exports,b="0123456789abcdef".split(""),d=[0,8,16,24],s=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],i=[224,256,384,512],c=["hex","buffer","arrayBuffer","array"],r=function(e,a,t){return function(f){return new T(e,a,e).update(f)[t]()}},u=function(e,a,t){return function(f,n){return new T(e,a,n).update(f)[t]()}},o=function(e,a){var t=r(e,a,"hex");t.create=function(){return new T(e,a,e)},t.update=function(e){return t.create().update(e)};for(var f=0;f>5,this.byteCount=this.blockCount<<2,this.outputBlocks=t>>5,this.extraBytes=(31&t)>>3;for(var f=0;f<50;++f)this.s[f]=0}T.prototype.update=function(e){var a="string"!=typeof e;a&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e));for(var t,f,n=e.length,b=this.blocks,s=this.byteCount,i=this.blockCount,c=0,r=this.s;c>2]|=e[c]<>2]|=f<>2]|=(192|f>>6)<>2]|=(128|63&f)<=57344?(b[t>>2]|=(224|f>>12)<>2]|=(128|f>>6&63)<>2]|=(128|63&f)<>2]|=(240|f>>18)<>2]|=(128|f>>12&63)<>2]|=(128|f>>6&63)<>2]|=(128|63&f)<=s){for(this.start=t-s,this.block=b[i],t=0;t>2]|=this.padding[3&a],this.lastByteIndex===this.byteCount)for(e[0]=e[t],a=1;a>4&15]+b[15&e]+b[e>>12&15]+b[e>>8&15]+b[e>>20&15]+b[e>>16&15]+b[e>>28&15]+b[e>>24&15];s%a==0&&(w(t),d=0)}return n&&(e=t[d],n>0&&(i+=b[e>>4&15]+b[15&e]),n>1&&(i+=b[e>>12&15]+b[e>>8&15]),n>2&&(i+=b[e>>20&15]+b[e>>16&15])),i},T.prototype.arrayBuffer=function(){this.finalize();var e,a=this.blockCount,t=this.s,f=this.outputBlocks,n=this.extraBytes,b=0,d=0,s=this.outputBits>>3;e=n?new ArrayBuffer(f+1<<2):new ArrayBuffer(s);for(var i=new Uint32Array(e);d>8&255,i[e+2]=a>>16&255,i[e+3]=a>>24&255;s%t==0&&w(f)}return b&&(e=s<<2,a=f[d],b>0&&(i[e]=255&a),b>1&&(i[e+1]=a>>8&255),b>2&&(i[e+2]=a>>16&255)),i};var w=function(e){var a,t,f,n,b,d,i,c,r,u,o,p,l,y,m,h,x,g,v,T,w,E,A,M,C,D,S,B,F,_,k,R,P,O,I,N,L,U,X,K,Z,V,q,H,z,j,G,W,$,J,Y,Q,ee,ae,te,fe,ne,be,de,se,ie,ce,re;for(f=0;f<48;f+=2)n=e[0]^e[10]^e[20]^e[30]^e[40],b=e[1]^e[11]^e[21]^e[31]^e[41],d=e[2]^e[12]^e[22]^e[32]^e[42],i=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],r=e[5]^e[15]^e[25]^e[35]^e[45],u=e[6]^e[16]^e[26]^e[36]^e[46],o=e[7]^e[17]^e[27]^e[37]^e[47],a=(p=e[8]^e[18]^e[28]^e[38]^e[48])^(d<<1|i>>>31),t=(l=e[9]^e[19]^e[29]^e[39]^e[49])^(i<<1|d>>>31),e[0]^=a,e[1]^=t,e[10]^=a,e[11]^=t,e[20]^=a,e[21]^=t,e[30]^=a,e[31]^=t,e[40]^=a,e[41]^=t,a=n^(c<<1|r>>>31),t=b^(r<<1|c>>>31),e[2]^=a,e[3]^=t,e[12]^=a,e[13]^=t,e[22]^=a,e[23]^=t,e[32]^=a,e[33]^=t,e[42]^=a,e[43]^=t,a=d^(u<<1|o>>>31),t=i^(o<<1|u>>>31),e[4]^=a,e[5]^=t,e[14]^=a,e[15]^=t,e[24]^=a,e[25]^=t,e[34]^=a,e[35]^=t,e[44]^=a,e[45]^=t,a=c^(p<<1|l>>>31),t=r^(l<<1|p>>>31),e[6]^=a,e[7]^=t,e[16]^=a,e[17]^=t,e[26]^=a,e[27]^=t,e[36]^=a,e[37]^=t,e[46]^=a,e[47]^=t,a=u^(n<<1|b>>>31),t=o^(b<<1|n>>>31),e[8]^=a,e[9]^=t,e[18]^=a,e[19]^=t,e[28]^=a,e[29]^=t,e[38]^=a,e[39]^=t,e[48]^=a,e[49]^=t,y=e[0],m=e[1],j=e[11]<<4|e[10]>>>28,G=e[10]<<4|e[11]>>>28,B=e[20]<<3|e[21]>>>29,F=e[21]<<3|e[20]>>>29,se=e[31]<<9|e[30]>>>23,ie=e[30]<<9|e[31]>>>23,V=e[40]<<18|e[41]>>>14,q=e[41]<<18|e[40]>>>14,O=e[2]<<1|e[3]>>>31,I=e[3]<<1|e[2]>>>31,h=e[13]<<12|e[12]>>>20,x=e[12]<<12|e[13]>>>20,W=e[22]<<10|e[23]>>>22,$=e[23]<<10|e[22]>>>22,_=e[33]<<13|e[32]>>>19,k=e[32]<<13|e[33]>>>19,ce=e[42]<<2|e[43]>>>30,re=e[43]<<2|e[42]>>>30,ae=e[5]<<30|e[4]>>>2,te=e[4]<<30|e[5]>>>2,N=e[14]<<6|e[15]>>>26,L=e[15]<<6|e[14]>>>26,g=e[25]<<11|e[24]>>>21,v=e[24]<<11|e[25]>>>21,J=e[34]<<15|e[35]>>>17,Y=e[35]<<15|e[34]>>>17,R=e[45]<<29|e[44]>>>3,P=e[44]<<29|e[45]>>>3,M=e[6]<<28|e[7]>>>4,C=e[7]<<28|e[6]>>>4,fe=e[17]<<23|e[16]>>>9,ne=e[16]<<23|e[17]>>>9,U=e[26]<<25|e[27]>>>7,X=e[27]<<25|e[26]>>>7,T=e[36]<<21|e[37]>>>11,w=e[37]<<21|e[36]>>>11,Q=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,H=e[8]<<27|e[9]>>>5,z=e[9]<<27|e[8]>>>5,D=e[18]<<20|e[19]>>>12,S=e[19]<<20|e[18]>>>12,be=e[29]<<7|e[28]>>>25,de=e[28]<<7|e[29]>>>25,K=e[38]<<8|e[39]>>>24,Z=e[39]<<8|e[38]>>>24,E=e[48]<<14|e[49]>>>18,A=e[49]<<14|e[48]>>>18,e[0]=y^~h&g,e[1]=m^~x&v,e[10]=M^~D&B,e[11]=C^~S&F,e[20]=O^~N&U,e[21]=I^~L&X,e[30]=H^~j&W,e[31]=z^~G&$,e[40]=ae^~fe&be,e[41]=te^~ne&de,e[2]=h^~g&T,e[3]=x^~v&w,e[12]=D^~B&_,e[13]=S^~F&k,e[22]=N^~U&K,e[23]=L^~X&Z,e[32]=j^~W&J,e[33]=G^~$&Y,e[42]=fe^~be&se,e[43]=ne^~de&ie,e[4]=g^~T&E,e[5]=v^~w&A,e[14]=B^~_&R,e[15]=F^~k&P,e[24]=U^~K&V,e[25]=X^~Z&q,e[34]=W^~J&Q,e[35]=$^~Y&ee,e[44]=be^~se&ce,e[45]=de^~ie&re,e[6]=T^~E&y,e[7]=w^~A&m,e[16]=_^~R&M,e[17]=k^~P&C,e[26]=K^~V&O,e[27]=Z^~q&I,e[36]=J^~Q&H,e[37]=Y^~ee&z,e[46]=se^~ce&ae,e[47]=ie^~re&te,e[8]=E^~y&h,e[9]=A^~m&x,e[18]=R^~M&D,e[19]=P^~C&S,e[28]=V^~O&N,e[29]=q^~I&L,e[38]=Q^~H&j,e[39]=ee^~z&G,e[48]=ce^~ae&fe,e[49]=re^~te&ne,e[0]^=s[f],e[1]^=s[f+1]};if(f)e.exports=l;else for(m=0;m>=8;return a}function n(e,a,t){for(var f=0,n=0;na+1+n&&t.throwError("child data too short",o.Logger.errors.BUFFER_OVERRUN,{})}return{consumed:1+n,result:b}}function d(e,a){if(0===e.length&&t.throwError("data too short",o.Logger.errors.BUFFER_OVERRUN,{}),e[a]>=248){a+1+(s=e[a]-247)>e.length&&t.throwError("data short segment too short",o.Logger.errors.BUFFER_OVERRUN,{});var f=n(e,a+1,s);return a+1+s+f>e.length&&t.throwError("data long segment too short",o.Logger.errors.BUFFER_OVERRUN,{}),b(e,a,a+1+s,s+f)}if(e[a]>=192){var d=e[a]-192;return a+1+d>e.length&&t.throwError("data array too short",o.Logger.errors.BUFFER_OVERRUN,{}),b(e,a,a+1,d)}if(e[a]>=184){var s;a+1+(s=e[a]-183)>e.length&&t.throwError("data array too short",o.Logger.errors.BUFFER_OVERRUN,{});var i=n(e,a+1,s);return a+1+s+i>e.length&&t.throwError("data array too short",o.Logger.errors.BUFFER_OVERRUN,{}),{consumed:1+s+i,result:l.hexlify(e.slice(a+1+s,a+1+s+i))}}if(e[a]>=128){var c=e[a]-128;return a+1+c>e.length&&t.throwError("data too short",o.Logger.errors.BUFFER_OVERRUN,{}),{consumed:1+c,result:l.hexlify(e.slice(a+1,a+1+c))}}return{consumed:1,result:l.hexlify(e[a])}}a.encode=function(e){return l.hexlify(function e(a){if(Array.isArray(a)){var n=[];if(a.forEach((function(a){n=n.concat(e(a))})),n.length<=55)return n.unshift(192+n.length),n;var b=f(n.length);return b.unshift(247+b.length),b.concat(n)}l.isBytesLike(a)||t.throwArgumentError("RLP object must be BytesLike","object",a);var d=Array.prototype.slice.call(l.arrayify(a));if(1===d.length&&d[0]<=127)return d;if(d.length<=55)return d.unshift(128+d.length),d;var s=f(d.length);return s.unshift(183+s.length),s.concat(d)}(e))},a.decode=function(e){var a=l.arrayify(e),f=d(a,0);return f.consumed!==a.length&&t.throwArgumentError("invalid rlp data","data",e),f.result}}))),S=(b(D),D.encode,D.decode,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.version="address/5.0.2"}))),B=(b(S),S.version,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0});var t=new o.Logger(S.version);function f(e){l.isHexString(e,20)||t.throwArgumentError("invalid address","address",e);for(var a=(e=e.toLowerCase()).substring(2).split(""),f=new Uint8Array(40),n=0;n<40;n++)f[n]=a[n].charCodeAt(0);var b=l.arrayify(M.keccak256(f));for(n=0;n<40;n+=2)b[n>>1]>>4>=8&&(a[n]=a[n].toUpperCase()),(15&b[n>>1])>=8&&(a[n+1]=a[n+1].toUpperCase());return"0x"+a.join("")}for(var n={},b=0;b<10;b++)n[String(b)]=String(b);for(b=0;b<26;b++)n[String.fromCharCode(65+b)]=String(10+b);var d,s=Math.floor((d=9007199254740991,Math.log10?Math.log10(d):Math.log(d)/Math.LN10));function i(e){for(var a=(e=(e=e.toUpperCase()).substring(4)+e.substring(0,2)+"00").split("").map((function(e){return n[e]})).join("");a.length>=s;){var t=a.substring(0,s);a=parseInt(t,10)%97+a.substring(t.length)}for(var f=String(98-parseInt(a,10)%97);f.length<2;)f="0"+f;return f}function c(e){var a=null;if("string"!=typeof e&&t.throwArgumentError("invalid address","address",e),e.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==e.substring(0,2)&&(e="0x"+e),a=f(e),e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&a!==e&&t.throwArgumentError("bad address checksum","address",e);else if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(e.substring(2,4)!==i(e)&&t.throwArgumentError("bad icap checksum","address",e),a=new r.BN(e.substring(4),36).toString(16);a.length<40;)a="0"+a;a=f("0x"+a)}else t.throwArgumentError("invalid address","address",e);return a}a.getAddress=c,a.isAddress=function(e){try{return c(e),!0}catch(e){}return!1},a.getIcapAddress=function(e){for(var a=new r.BN(c(e).substring(2),16).toString(36).toUpperCase();a.length<30;)a="0"+a;return"XE"+i("XE00"+a)+a},a.getContractAddress=function(e){var a=null;try{a=c(e.from)}catch(a){t.throwArgumentError("missing from address","transaction",e)}var f=l.stripZeros(l.arrayify(x.BigNumber.from(e.nonce).toHexString()));return c(l.hexDataSlice(M.keccak256(D.encode([a,f])),12))},a.getCreate2Address=function(e,a,f){return 32!==l.hexDataLength(a)&&t.throwArgumentError("salt must be 32 bytes","salt",a),32!==l.hexDataLength(f)&&t.throwArgumentError("initCodeHash must be 32 bytes","initCodeHash",f),c(l.hexDataSlice(M.keccak256(l.concat(["0xff",c(e),a,f])),12))}}))),F=(b(B),B.getAddress,B.isAddress,B.getIcapAddress,B.getContractAddress,B.getCreate2Address,d((function(e,a){var t,f=n&&n.__extends||(t=function(e,a){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,a){e.__proto__=a}||function(e,a){for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])})(e,a)},function(e,a){function f(){this.constructor=e}t(e,a),e.prototype=null===a?Object.create(a):(f.prototype=a.prototype,new f)});Object.defineProperty(a,"__esModule",{value:!0});var b=function(e){function a(a){return e.call(this,"address","address",a,!1)||this}return f(a,e),a.prototype.encode=function(e,a){try{B.getAddress(a)}catch(e){this._throwError(e.message,a)}return e.writeValue(a)},a.prototype.decode=function(e){return B.getAddress(l.hexZeroPad(e.readValue().toHexString(),20))},a}(E.Coder);a.AddressCoder=b}))),_=(b(F),F.AddressCoder,d((function(e,a){var t,f=n&&n.__extends||(t=function(e,a){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,a){e.__proto__=a}||function(e,a){for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])})(e,a)},function(e,a){function f(){this.constructor=e}t(e,a),e.prototype=null===a?Object.create(a):(f.prototype=a.prototype,new f)});Object.defineProperty(a,"__esModule",{value:!0});var b=function(e){function a(a){var t=e.call(this,a.name,a.type,void 0,a.dynamic)||this;return t.coder=a,t}return f(a,e),a.prototype.encode=function(e,a){return this.coder.encode(e,a)},a.prototype.decode=function(e){return this.coder.decode(e)},a}(E.Coder);a.AnonymousCoder=b}))),k=(b(_),_.AnonymousCoder,d((function(e,a){var t,f=n&&n.__extends||(t=function(e,a){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,a){e.__proto__=a}||function(e,a){for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])})(e,a)},function(e,a){function f(){this.constructor=e}t(e,a),e.prototype=null===a?Object.create(a):(f.prototype=a.prototype,new f)});Object.defineProperty(a,"__esModule",{value:!0});var b=new o.Logger(T.version);function d(e,a,t){var f=null;if(Array.isArray(t))f=t;else if(t&&"object"==typeof t){var n={};f=a.map((function(e){var a=e.localName;return a||b.throwError("cannot encode object for signature with missing names",o.Logger.errors.INVALID_ARGUMENT,{argument:"values",coder:e,value:t}),n[a]&&b.throwError("cannot encode object for signature with duplicate names",o.Logger.errors.INVALID_ARGUMENT,{argument:"values",coder:e,value:t}),n[a]=!0,t[a]}))}else b.throwArgumentError("invalid tuple value","tuple",t);a.length!==f.length&&b.throwArgumentError("types/value length mismatch","tuple",t);var d=new E.Writer(e.wordSize),s=new E.Writer(e.wordSize),i=[];a.forEach((function(e,a){var t=f[a];if(e.dynamic){var n=s.length;e.encode(s,t);var b=d.writeUpdatableValue();i.push((function(e){b(e+n)}))}else e.encode(d,t)})),i.forEach((function(e){e(d.length)}));var c=e.writeBytes(d.data);return c+=e.writeBytes(s.data)}function s(e,a){var t=[],f=e.subReader(0),n=0;a.forEach((function(a){var b=null;if(a.dynamic){var d=e.readValue(),s=f.subReader(d.toNumber());try{b=a.decode(s)}catch(e){if(e.code===o.Logger.errors.BUFFER_OVERRUN)throw e;(b=e).baseType=a.name,b.name=a.localName,b.type=a.type}n+=s.consumed}else try{b=a.decode(e)}catch(e){if(e.code===o.Logger.errors.BUFFER_OVERRUN)throw e;(b=e).baseType=a.name,b.name=a.localName,b.type=a.type}null!=b&&t.push(b)})),e.readBytes(n);var b=a.reduce((function(e,a){var t=a.localName;return t&&(e[t]||(e[t]=0),e[t]++),e}),{});a.forEach((function(e,a){var f=e.localName;if(f&&1===b[f]&&("length"===f&&(f="_length"),null==t[f])){var n=t[a];n instanceof Error?Object.defineProperty(t,f,{get:function(){throw n}}):t[f]=n}}));for(var d=function(e){var a=t[e];a instanceof Error&&Object.defineProperty(t,e,{get:function(){throw a}})},s=0;s=0?t:"")+"]",d=-1===t||a.dynamic;return(n=e.call(this,"array",b,f,d)||this).coder=a,n.length=t,n}return f(a,e),a.prototype.encode=function(e,a){Array.isArray(a)||this._throwError("expected array value",a);var t=this.length;-1===t&&(t=a.length,e.writeValue(a.length)),b.checkArgumentCount(t,a.length,"coder array"+(this.localName?" "+this.localName:""));for(var f=[],n=0;n>6==2;s++)d++;return d}return e===f.OVERRUN?t.length-a-1:0}function d(e,t){null==t&&(t=a.Utf8ErrorFuncs.error),e=l.arrayify(e);for(var n=[],b=0;b>7!=0){var s=null,i=null;if(192==(224&d))s=1,i=127;else if(224==(240&d))s=2,i=2047;else{if(240!=(248&d)){b+=t(128==(192&d)?f.UNEXPECTED_CONTINUE:f.BAD_PREFIX,b-1,e,n);continue}s=3,i=65535}if(b-1+s>=e.length)b+=t(f.OVERRUN,b-1,e,n);else{for(var c=d&(1<<8-s-1)-1,r=0;r1114111?b+=t(f.OUT_OF_RANGE,b-1-s,e,n,c):c>=55296&&c<=57343?b+=t(f.UTF16_SURROGATE,b-1-s,e,n,c):c<=i?b+=t(f.OVERLONG,b-1-s,e,n,c):n.push(c))}}else n.push(d)}return n}function s(e,a){void 0===a&&(a=t.current),a!=t.current&&(n.checkNormalize(),e=e.normalize(a));for(var f=[],b=0;b>6|192),f.push(63&d|128);else if(55296==(64512&d)){b++;var s=e.charCodeAt(b);if(b>=e.length||56320!=(64512&s))throw new Error("invalid utf-8 string");var i=65536+((1023&d)<<10)+(1023&s);f.push(i>>18|240),f.push(i>>12&63|128),f.push(i>>6&63|128),f.push(63&i|128)}else f.push(d>>12|224),f.push(d>>6&63|128),f.push(63&d|128)}return l.arrayify(f)}function i(e){var a="0000"+e.toString(16);return"\\u"+a.substring(a.length-4)}function c(e){return e.map((function(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10&1023),56320+(1023&e)))})).join("")}!function(e){e.current="",e.NFC="NFC",e.NFD="NFD",e.NFKC="NFKC",e.NFKD="NFKD"}(t=a.UnicodeNormalizationForm||(a.UnicodeNormalizationForm={})),function(e){e.UNEXPECTED_CONTINUE="unexpected continuation byte",e.BAD_PREFIX="bad codepoint prefix",e.OVERRUN="string overrun",e.MISSING_CONTINUE="missing continuation byte",e.OUT_OF_RANGE="out of UTF-8 range",e.UTF16_SURROGATE="UTF-16 surrogate",e.OVERLONG="overlong representation"}(f=a.Utf8ErrorReason||(a.Utf8ErrorReason={})),a.Utf8ErrorFuncs=Object.freeze({error:function(e,a,t,f,b){return n.throwArgumentError("invalid codepoint at offset "+a+"; "+e,"bytes",t)},ignore:b,replace:function(e,a,t,n,d){return e===f.OVERLONG?(n.push(d),0):(n.push(65533),b(e,a,t))}}),a.toUtf8Bytes=s,a._toEscapedUtf8String=function(e,a){return'"'+d(e,a).map((function(e){if(e<256){switch(e){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(e>=32&&e<127)return String.fromCharCode(e)}return e<=65535?i(e):i(55296+((e-=65536)>>10&1023))+i(56320+(1023&e))})).join("")+'"'},a._toUtf8String=c,a.toUtf8String=function(e,a){return c(d(e,a))},a.toUtf8CodePoints=function(e,a){return void 0===a&&(a=t.current),d(s(e,a))}}))),K=(b(X),X.UnicodeNormalizationForm,X.Utf8ErrorReason,X.Utf8ErrorFuncs,X.toUtf8Bytes,X._toEscapedUtf8String,X._toUtf8String,X.toUtf8String,X.toUtf8CodePoints,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.formatBytes32String=function(e){var a=X.toUtf8Bytes(e);if(a.length>31)throw new Error("bytes32 string must be less than 32 bytes");return l.hexlify(l.concat([a,N.HashZero]).slice(0,32))},a.parseBytes32String=function(e){var a=l.arrayify(e);if(32!==a.length)throw new Error("invalid bytes32 - not 32 bytes long");if(0!==a[31])throw new Error("invalid bytes32 string - no null terminator");for(var t=31;0===a[t-1];)t--;return X.toUtf8String(a.slice(0,t))}}))),Z=(b(K),K.formatBytes32String,K.parseBytes32String,d((function(e,a){function t(e,a){a||(a=function(e){return[parseInt(e,16)]});var t=0,f={};return e.split(",").forEach((function(e){var n=e.split(":");t+=parseInt(n[0],16),f[t]=a(n[1])})),f}function f(e){var a=0;return e.split(",").map((function(e){var t=e.split("-");return 1===t.length?t[1]="0":""===t[1]&&(t[1]="1"),{l:a+parseInt(t[0],16),h:a=parseInt(t[1],16)}}))}function n(e,a){for(var t=0,f=0;f=(t+=n.l)&&e<=t+n.h&&(e-t)%(n.d||1)==0){if(n.e&&-1!==n.e.indexOf(e-t))continue;return n}}return null}Object.defineProperty(a,"__esModule",{value:!0});var b=f("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),d="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map((function(e){return parseInt(e,16)})),s=[{h:25,s:32,l:65},{h:30,s:32,e:[23],l:127},{h:54,s:1,e:[48],l:64,d:2},{h:14,s:1,l:57,d:2},{h:44,s:1,l:17,d:2},{h:10,s:1,e:[2,6,8],l:61,d:2},{h:16,s:1,l:68,d:2},{h:84,s:1,e:[18,24,66],l:19,d:2},{h:26,s:32,e:[17],l:435},{h:22,s:1,l:71,d:2},{h:15,s:80,l:40},{h:31,s:32,l:16},{h:32,s:1,l:80,d:2},{h:52,s:1,l:42,d:2},{h:12,s:1,l:55,d:2},{h:40,s:1,e:[38],l:15,d:2},{h:14,s:1,l:48,d:2},{h:37,s:48,l:49},{h:148,s:1,l:6351,d:2},{h:88,s:1,l:160,d:2},{h:15,s:16,l:704},{h:25,s:26,l:854},{h:25,s:32,l:55915},{h:37,s:40,l:1247},{h:25,s:-119711,l:53248},{h:25,s:-119763,l:52},{h:25,s:-119815,l:52},{h:25,s:-119867,e:[1,4,5,7,8,11,12,17],l:52},{h:25,s:-119919,l:52},{h:24,s:-119971,e:[2,7,8,17],l:52},{h:24,s:-120023,e:[2,7,13,15,16,17],l:52},{h:25,s:-120075,l:52},{h:25,s:-120127,l:52},{h:25,s:-120179,l:52},{h:25,s:-120231,l:52},{h:25,s:-120283,l:52},{h:25,s:-120335,l:52},{h:24,s:-119543,e:[17],l:56},{h:24,s:-119601,e:[17],l:58},{h:24,s:-119659,e:[17],l:58},{h:24,s:-119717,e:[17],l:58},{h:24,s:-119775,e:[17],l:58}],i=t("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),c=t("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),r=t("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",(function(e){if(e.length%4!=0)throw new Error("bad data");for(var a=[],t=0;t=0)return[];if(e>=65024&&e<=65039)return[];var a=p(e);return a||[e]})),t=a.reduce((function(e,a){return a.forEach((function(a){e.push(a)})),e}),[]),(t=X.toUtf8CodePoints(X._toUtf8String(t),X.UnicodeNormalizationForm.NFKC)).forEach((function(e){if(l(e))throw new Error("STRINGPREP_CONTAINS_PROHIBITED")})),t.forEach((function(e){if(o(e))throw new Error("STRINGPREP_CONTAINS_UNASSIGNED")}));var f=X._toUtf8String(t);if("-"===f.substring(0,1)||"--"===f.substring(2,4)||"-"===f.substring(f.length-1))throw new Error("invalid hyphen");if(f.length>63)throw new Error("too long");return f}}))),V=(b(Z),Z._nameprepTableA1,Z._nameprepTableB2,Z._nameprepTableC,Z.nameprep,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.formatBytes32String=K.formatBytes32String,a.parseBytes32String=K.parseBytes32String,a.nameprep=Z.nameprep,a._toEscapedUtf8String=X._toEscapedUtf8String,a.toUtf8Bytes=X.toUtf8Bytes,a.toUtf8CodePoints=X.toUtf8CodePoints,a.toUtf8String=X.toUtf8String,a.UnicodeNormalizationForm=X.UnicodeNormalizationForm,a.Utf8ErrorFuncs=X.Utf8ErrorFuncs,a.Utf8ErrorReason=X.Utf8ErrorReason}))),q=(b(V),V.formatBytes32String,V.parseBytes32String,V.nameprep,V._toEscapedUtf8String,V.toUtf8Bytes,V.toUtf8CodePoints,V.toUtf8String,V.UnicodeNormalizationForm,V.Utf8ErrorFuncs,V.Utf8ErrorReason,d((function(e,a){var t,f=n&&n.__extends||(t=function(e,a){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,a){e.__proto__=a}||function(e,a){for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])})(e,a)},function(e,a){function f(){this.constructor=e}t(e,a),e.prototype=null===a?Object.create(a):(f.prototype=a.prototype,new f)});Object.defineProperty(a,"__esModule",{value:!0});var b=function(e){function a(a){return e.call(this,"string",a)||this}return f(a,e),a.prototype.encode=function(a,t){return e.prototype.encode.call(this,a,V.toUtf8Bytes(t))},a.prototype.decode=function(a){return V.toUtf8String(e.prototype.decode.call(this,a))},a}(P.DynamicBytesCoder);a.StringCoder=b}))),H=(b(q),q.StringCoder,d((function(e,a){var t,f=n&&n.__extends||(t=function(e,a){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,a){e.__proto__=a}||function(e,a){for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])})(e,a)},function(e,a){function f(){this.constructor=e}t(e,a),e.prototype=null===a?Object.create(a):(f.prototype=a.prototype,new f)});Object.defineProperty(a,"__esModule",{value:!0});var b=function(e){function a(a,t){var f=this,n=!1,b=[];a.forEach((function(e){e.dynamic&&(n=!0),b.push(e.type)}));var d="tuple("+b.join(",")+")";return(f=e.call(this,"tuple",d,t,n)||this).coders=a,f}return f(a,e),a.prototype.encode=function(e,a){return k.pack(e,this.coders,a)},a.prototype.decode=function(e){return e.coerce(this.name,k.unpack(e,this.coders))},a}(E.Coder);a.TupleCoder=b}))),z=(b(H),H.TupleCoder,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0});var t=new o.Logger(T.version),f=new RegExp(/^bytes([0-9]*)$/),n=new RegExp(/^(u?int)([0-9]*)$/),b=function(){function e(a){var f=this.constructor;t.checkNew(f,e),v.defineReadOnly(this,"coerceFunc",a||null)}return e.prototype._getCoder=function(e){var a=this;switch(e.baseType){case"address":return new F.AddressCoder(e.name);case"bool":return new R.BooleanCoder(e.name);case"string":return new q.StringCoder(e.name);case"bytes":return new P.BytesCoder(e.name);case"array":return new k.ArrayCoder(this._getCoder(e.arrayChildren),e.arrayLength,e.name);case"tuple":return new H.TupleCoder((e.components||[]).map((function(e){return a._getCoder(e)})),e.name);case"":return new I.NullCoder(e.name)}var b,d=e.type.match(n);return d?((0===(b=parseInt(d[2]||"256"))||b>256||b%8!=0)&&t.throwArgumentError("invalid "+d[1]+" bit length","param",e),new L.NumberCoder(b/8,"int"===d[1],e.name)):(d=e.type.match(f))?((0===(b=parseInt(d[1]))||b>32)&&t.throwArgumentError("invalid bytes length","param",e),new O.FixedBytesCoder(b,e.name)):t.throwArgumentError("invalid type","type",e.type)},e.prototype._getWordSize=function(){return 32},e.prototype._getReader=function(e){return new E.Reader(e,this._getWordSize(),this.coerceFunc)},e.prototype._getWriter=function(){return new E.Writer(this._getWordSize())},e.prototype.encode=function(e,a){var f=this;e.length!==a.length&&t.throwError("types/values length mismatch",o.Logger.errors.INVALID_ARGUMENT,{count:{types:e.length,values:a.length},value:{types:e,values:a}});var n=e.map((function(e){return f._getCoder(w.ParamType.from(e))})),b=new H.TupleCoder(n,"_"),d=this._getWriter();return b.encode(d,a),d.data},e.prototype.decode=function(e,a){var t=this,f=e.map((function(e){return t._getCoder(w.ParamType.from(e))}));return new H.TupleCoder(f,"_").decode(this._getReader(l.arrayify(a)))},e}();a.AbiCoder=b,a.defaultAbiCoder=new b}))),j=(b(z),z.AbiCoder,z.defaultAbiCoder,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.version="hash/5.0.2"}))),G=(b(j),j.version,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0});var t=new o.Logger(j.version),f=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),n=new RegExp("^((.*)\\.)?([^.]+)$");a.isValidName=function(e){try{for(var a=e.split("."),t=0;t1&&b.throwArgumentError("multiple matching functions","name",t),this.functions[f[0]]}var n=this.functions[w.FunctionFragment.fromString(e).format()];return n||b.throwArgumentError("no matching function","signature",e),n},e.prototype.getEvent=function(e){if(l.isHexString(e)){var a=e.toLowerCase();for(var t in this.events)if(a===this.getEventTopic(t))return this.events[t];b.throwArgumentError("no matching event","topichash",a)}if(-1===e.indexOf("(")){var f=e.trim(),n=Object.keys(this.events).filter((function(e){return e.split("(")[0]===f}));return 0===n.length?b.throwArgumentError("no matching event","name",f):n.length>1&&b.throwArgumentError("multiple matching events","name",f),this.events[n[0]]}var d=this.events[w.EventFragment.fromString(e).format()];return d||b.throwArgumentError("no matching event","signature",e),d},e.prototype.getSighash=function(e){return"string"==typeof e&&(e=this.getFunction(e)),v.getStatic(this.constructor,"getSighash")(e)},e.prototype.getEventTopic=function(e){return"string"==typeof e&&(e=this.getEvent(e)),v.getStatic(this.constructor,"getEventTopic")(e)},e.prototype._decodeParams=function(e,a){return this._abiCoder.decode(e,a)},e.prototype._encodeParams=function(e,a){return this._abiCoder.encode(e,a)},e.prototype.encodeDeploy=function(e){return this._encodeParams(this.deploy.inputs,e||[])},e.prototype.decodeFunctionData=function(e,a){"string"==typeof e&&(e=this.getFunction(e));var t=l.arrayify(a);return l.hexlify(t.slice(0,4))!==this.getSighash(e)&&b.throwArgumentError("data signature does not match function "+e.name+".","data",l.hexlify(t)),this._decodeParams(e.inputs,t.slice(4))},e.prototype.encodeFunctionData=function(e,a){return"string"==typeof e&&(e=this.getFunction(e)),l.hexlify(l.concat([this.getSighash(e),this._encodeParams(e.inputs,a||[])]))},e.prototype.decodeFunctionResult=function(e,a){"string"==typeof e&&(e=this.getFunction(e));var t=l.arrayify(a),f=null,n=null;switch(t.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(e.outputs,t)}catch(e){}break;case 4:"0x08c379a0"===l.hexlify(t.slice(0,4))&&(n="Error(string)",f=this._abiCoder.decode(["string"],t.slice(4))[0])}return b.throwError("call revert exception",o.Logger.errors.CALL_EXCEPTION,{method:e.format(),errorSignature:n,errorArgs:[f],reason:f})},e.prototype.encodeFunctionResult=function(e,a){return"string"==typeof e&&(e=this.getFunction(e)),l.hexlify(this._abiCoder.encode(e.outputs,a||[]))},e.prototype.encodeFilterTopics=function(e,a){var t=this;"string"==typeof e&&(e=this.getEvent(e)),a.length>e.inputs.length&&b.throwError("too many arguments for "+e.format(),o.Logger.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:a});var f=[];e.anonymous||f.push(this.getEventTopic(e));var n=function(e,a){return"string"===e.type?G.id(a):"bytes"===e.type?M.keccak256(l.hexlify(a)):("address"===e.type&&t._abiCoder.encode(["address"],[a]),l.hexZeroPad(l.hexlify(a),32))};for(a.forEach((function(a,t){var d=e.inputs[t];d.indexed?null==a?f.push(null):"array"===d.baseType||"tuple"===d.baseType?b.throwArgumentError("filtering with tuples or arrays not supported","contract."+d.name,a):Array.isArray(a)?f.push(a.map((function(e){return n(d,e)}))):f.push(n(d,a)):null!=a&&b.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+d.name,a)}));f.length&&null===f[f.length-1];)f.pop();return f},e.prototype.encodeEventLog=function(e,a){var t=this;"string"==typeof e&&(e=this.getEvent(e));var f=[],n=[],d=[];return e.anonymous||f.push(this.getEventTopic(e)),a.length!==e.inputs.length&&b.throwArgumentError("event arguments/values mismatch","values",a),e.inputs.forEach((function(e,b){var s=a[b];if(e.indexed)if("string"===e.type)f.push(G.id(s));else if("bytes"===e.type)f.push(M.keccak256(s));else{if("tuple"===e.baseType||"array"===e.baseType)throw new Error("not implemented");f.push(t._abiCoder.encode([e.type],[s]))}else n.push(e),d.push(s)})),{data:this._abiCoder.encode(n,d),topics:f}},e.prototype.decodeEventLog=function(e,a,t){if("string"==typeof e&&(e=this.getEvent(e)),null!=t&&!e.anonymous){var f=this.getEventTopic(e);l.isHexString(t[0],32)&&t[0].toLowerCase()===f||b.throwError("fragment/topic mismatch",o.Logger.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:f,value:t[0]}),t=t.slice(1)}var n=[],d=[],s=[];e.inputs.forEach((function(e,a){e.indexed?"string"===e.type||"bytes"===e.type||"tuple"===e.baseType||"array"===e.baseType?(n.push(w.ParamType.fromObject({type:"bytes32",name:e.name})),s.push(!0)):(n.push(e),s.push(!1)):(d.push(e),s.push(!1))}));var r=null!=t?this._abiCoder.decode(n,l.concat(t)):null,u=this._abiCoder.decode(d,a),p=[],y=0,m=0;e.inputs.forEach((function(e,a){if(e.indexed)if(null==r)p[a]=new i({_isIndexed:!0,hash:null});else if(s[a])p[a]=new i({_isIndexed:!0,hash:r[m++]});else try{p[a]=r[m++]}catch(e){p[a]=e}else try{p[a]=u[y++]}catch(e){p[a]=e}if(e.name&&null==p[e.name]){var t=p[a];t instanceof Error?Object.defineProperty(p,e.name,{get:function(){throw c("property "+JSON.stringify(e.name),t)}}):p[e.name]=t}}));for(var h=function(e){var a=p[e];a instanceof Error&&Object.defineProperty(p,e,{get:function(){throw c("index "+e,a)}})},x=0;x0&&n[n.length-1])||6!==b[0]&&2!==b[0])){d=0;continue}if(3===b[0]&&(!n||b[1]>n[0]&&b[1]0&&n[n.length-1])||6!==b[0]&&2!==b[0])){d=0;continue}if(3===b[0]&&(!n||b[1]>n[0]&&b[1]1)){var t=a[0];null==s[e]&&v.defineReadOnly(s,e,s[t]),null==s.functions[e]&&v.defineReadOnly(s.functions,e,s.functions[t]),null==s.callStatic[e]&&v.defineReadOnly(s.callStatic,e,s.callStatic[t]),null==s.populateTransaction[e]&&v.defineReadOnly(s.populateTransaction,e,s.populateTransaction[t]),null==s.estimateGas[e]&&v.defineReadOnly(s.estimateGas,e,s.estimateGas[t])}}))}return e.getContractAddress=function(e){return B.getContractAddress(e)},e.getInterface=function(e){return $.Interface.isInterface(e)?e:new $.Interface(e)},e.prototype.deployed=function(){return this._deployed()},e.prototype._deployed=function(e){var a=this;return this._deployedPromise||(this.deployTransaction?this._deployedPromise=this.deployTransaction.wait().then((function(){return a})):this._deployedPromise=this.provider.getCode(this.address,e).then((function(e){return"0x"===e&&i.throwError("contract not deployed",o.Logger.errors.UNSUPPORTED_OPERATION,{contractAddress:a.address,operation:"getDeployed"}),a}))),this._deployedPromise},e.prototype.fallback=function(e){var a=this;this.signer||i.throwError("sending a transactions require a signer",o.Logger.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction(fallback)"});var t=v.shallowCopy(e||{});return["from","to"].forEach((function(e){null!=t[e]&&i.throwError("cannot override "+e,o.Logger.errors.UNSUPPORTED_OPERATION,{operation:e})})),t.to=this.resolvedAddress,this.deployed().then((function(){return a.signer.sendTransaction(t)}))},e.prototype.connect=function(e){"string"==typeof e&&(e=new ee.VoidSigner(e,this.provider));var a=new this.constructor(this.address,this.interface,e);return this.deployTransaction&&v.defineReadOnly(a,"deployTransaction",this.deployTransaction),a},e.prototype.attach=function(e){return new this.constructor(e,this.interface,this.signer||this.provider)},e.isIndexed=function(e){return $.Indexed.isIndexed(e)},e.prototype._normalizeRunningEvent=function(e){return this._runningEvents[e.tag]?this._runningEvents[e.tag]:e},e.prototype._getRunningEvent=function(e){if("string"==typeof e){if("error"===e)return this._normalizeRunningEvent(new T);if("event"===e)return this._normalizeRunningEvent(new g("event",null));if("*"===e)return this._normalizeRunningEvent(new E(this.address,this.interface));var a=this.interface.getEvent(e);return this._normalizeRunningEvent(new w(this.address,this.interface,a))}if(e.topics&&e.topics.length>0){try{var t=e.topics[0];if("string"!=typeof t)throw new Error("invalid topic");return a=this.interface.getEvent(t),this._normalizeRunningEvent(new w(this.address,this.interface,a,e.topics))}catch(e){}var f={address:this.address,topics:e.topics};return this._normalizeRunningEvent(new g(h(f),f))}return this._normalizeRunningEvent(new E(this.address,this.interface))},e.prototype._checkRunningEvents=function(e){if(0===e.listenerCount()){delete this._runningEvents[e.tag];var a=this._wrappedEmits[e.tag];a&&(this.provider.off(e.filter,a),delete this._wrappedEmits[e.tag])}},e.prototype._wrapEvent=function(e,a,t){var f=this,n=v.deepCopy(a);return n.removeListener=function(){t&&(e.removeListener(t),f._checkRunningEvents(e))},n.getBlock=function(){return f.provider.getBlock(a.blockHash)},n.getTransaction=function(){return f.provider.getTransaction(a.transactionHash)},n.getTransactionReceipt=function(){return f.provider.getTransactionReceipt(a.transactionHash)},e.prepareEvent(n),n},e.prototype._addEventListener=function(e,a,t){var f=this;if(this.provider||i.throwError("events require a provider or a signer with a provider",o.Logger.errors.UNSUPPORTED_OPERATION,{operation:"once"}),e.addListener(a,t),this._runningEvents[e.tag]=e,!this._wrappedEmits[e.tag]){var n=function(t){var n=f._wrapEvent(e,t,a);if(null==n.decodeError)try{var b=e.getEmit(n);f.emit.apply(f,s([e.filter],b))}catch(e){n.decodeError=e.error}null!=e.filter&&f.emit("event",n),null!=n.decodeError&&f.emit("error",n.decodeError,n)};this._wrappedEmits[e.tag]=n,null!=e.filter&&this.provider.on(e.filter,n)}},e.prototype.queryFilter=function(e,a,t){var f=this,n=this._getRunningEvent(e),b=v.shallowCopy(n.filter);return"string"==typeof a&&l.isHexString(a,32)?(null!=t&&i.throwArgumentError("cannot specify toBlock with blockhash","toBlock",t),b.blockHash=a):(b.fromBlock=null!=a?a:0,b.toBlock=null!=t?t:"latest"),this.provider.getLogs(b).then((function(e){return e.map((function(e){return f._wrapEvent(n,e,null)}))}))},e.prototype.on=function(e,a){return this._addEventListener(this._getRunningEvent(e),a,!1),this},e.prototype.once=function(e,a){return this._addEventListener(this._getRunningEvent(e),a,!0),this},e.prototype.emit=function(e){for(var a=[],t=1;t0;return this._checkRunningEvents(f),n},e.prototype.listenerCount=function(e){return this.provider?this._getRunningEvent(e).listenerCount():0},e.prototype.listeners=function(e){if(!this.provider)return[];if(null==e){var a=[];for(var t in this._runningEvents)this._runningEvents[t].listeners().forEach((function(e){a.push(e)}));return a}return this._getRunningEvent(e).listeners()},e.prototype.removeAllListeners=function(e){if(!this.provider)return this;if(null==e){for(var a in this._runningEvents){var t=this._runningEvents[a];t.removeAllListeners(),this._checkRunningEvents(t)}return this}var f=this._getRunningEvent(e);return f.removeAllListeners(),this._checkRunningEvents(f),this},e.prototype.off=function(e,a){if(!this.provider)return this;var t=this._getRunningEvent(e);return t.removeListener(a),this._checkRunningEvents(t),this},e.prototype.removeListener=function(e,a){return this.off(e,a)},e}();a.Contract=A;var M=function(){function e(e,a,t){var f=this.constructor,n=null;"0x"!==(n="string"==typeof a?a:l.isBytes(a)?l.hexlify(a):a&&"string"==typeof a.object?a.object:"!").substring(0,2)&&(n="0x"+n),(!l.isHexString(n)||n.length%2)&&i.throwArgumentError("invalid bytecode","bytecode",a),t&&!ee.Signer.isSigner(t)&&i.throwArgumentError("invalid signer","signer",t),v.defineReadOnly(this,"bytecode",n),v.defineReadOnly(this,"interface",v.getStatic(f,"getInterface")(e)),v.defineReadOnly(this,"signer",t||null)}return e.prototype.getDeployTransaction=function(){for(var e=[],a=0;a0;)t.push(n%this.base),n=n/this.base|0}for(var d="",s=0;0===a[s]&&s=0;--i)d+=this.alphabet[t[i]];return d},e.prototype.decode=function(e){if("string"!=typeof e)throw new TypeError("Expected String");var a=[];if(0===e.length)return new Uint8Array(a);a.push(0);for(var t=0;t>=8;for(;n>0;)a.push(255&n),n>>=8}for(var d=0;e[d]===this._leader&&d>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function ie(e){return 1===e.length?"0"+e:e}function ce(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}var re={inherits:de,toArray:function(e,a){if(Array.isArray(e))return e.slice();if(!e)return[];var t=[];if("string"==typeof e)if(a){if("hex"===a)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),f=0;f>8,d=255&n;b?t.push(b,d):t.push(d)}else for(f=0;f>>0}return b},split32:function(e,a){for(var t=new Array(4*e.length),f=0,n=0;f>>24,t[n+1]=b>>>16&255,t[n+2]=b>>>8&255,t[n+3]=255&b):(t[n+3]=b>>>24,t[n+2]=b>>>16&255,t[n+1]=b>>>8&255,t[n]=255&b)}return t},rotr32:function(e,a){return e>>>a|e<<32-a},rotl32:function(e,a){return e<>>32-a},sum32:function(e,a){return e+a>>>0},sum32_3:function(e,a,t){return e+a+t>>>0},sum32_4:function(e,a,t,f){return e+a+t+f>>>0},sum32_5:function(e,a,t,f,n){return e+a+t+f+n>>>0},sum64:function(e,a,t,f){var n=e[a],b=f+e[a+1]>>>0,d=(b>>0,e[a+1]=b},sum64_hi:function(e,a,t,f){return(a+f>>>0>>0},sum64_lo:function(e,a,t,f){return a+f>>>0},sum64_4_hi:function(e,a,t,f,n,b,d,s){var i=0,c=a;return i+=(c=c+f>>>0)>>0)>>0)>>0},sum64_4_lo:function(e,a,t,f,n,b,d,s){return a+f+b+s>>>0},sum64_5_hi:function(e,a,t,f,n,b,d,s,i,c){var r=0,u=a;return r+=(u=u+f>>>0)>>0)>>0)>>0)>>0},sum64_5_lo:function(e,a,t,f,n,b,d,s,i,c){return a+f+b+s+c>>>0},rotr64_hi:function(e,a,t){return(a<<32-t|e>>>t)>>>0},rotr64_lo:function(e,a,t){return(e<<32-t|a>>>t)>>>0},shr64_hi:function(e,a,t){return e>>>t},shr64_lo:function(e,a,t){return(e<<32-t|a>>>t)>>>0}};function ue(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}var oe=ue;ue.prototype.update=function(e,a){if(e=re.toArray(e,a),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var t=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-t,e.length),0===this.pending.length&&(this.pending=null),e=re.join32(e,0,e.length-t,this.endian);for(var f=0;f>>24&255,f[n++]=e>>>16&255,f[n++]=e>>>8&255,f[n++]=255&e}else for(f[n++]=255&e,f[n++]=e>>>8&255,f[n++]=e>>>16&255,f[n++]=e>>>24&255,f[n++]=0,f[n++]=0,f[n++]=0,f[n++]=0,b=8;b>>3},g1_256:function(e){return le(e,17)^le(e,19)^e>>>10}},ge=re.sum32,ve=re.sum32_4,Te=re.sum32_5,we=xe.ch32,Ee=xe.maj32,Ae=xe.s0_256,Me=xe.s1_256,Ce=xe.g0_256,De=xe.g1_256,Se=pe.BlockHash,Be=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Fe(){if(!(this instanceof Fe))return new Fe;Se.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=Be,this.W=new Array(64)}re.inherits(Fe,Se);var _e=Fe;Fe.blockSize=512,Fe.outSize=256,Fe.hmacStrength=192,Fe.padLength=64,Fe.prototype._update=function(e,a){for(var t=this.W,f=0;f<16;f++)t[f]=e[a+f];for(;fthis.blockSize&&(e=(new this.Hash).update(e).digest()),ne(e.length<=this.blockSize);for(var a=e.length;a>24&255,r[a.length+1]=u>>16&255,r[a.length+2]=u>>8&255,r[a.length+3]=255&u;var o=l.arrayify(Ma.computeHmac(n,e,r));b||(b=o.length,s=new Uint8Array(b),d=f-((i=Math.ceil(f/b))-1)*b),s.set(o);for(var p=1;p=49&&d<=54?d-49+10:d>=17&&d<=22?d-17+10:15&d}return f}function s(e,a,t,f){for(var n=0,b=Math.min(e.length,t),d=a;d=49?s-49+10:s>=17?s-17+10:s}return n}n.isBN=function(e){return e instanceof n||null!==e&&"object"==typeof e&&e.constructor.wordSize===n.wordSize&&Array.isArray(e.words)},n.max=function(e,a){return e.cmp(a)>0?e:a},n.min=function(e,a){return e.cmp(a)<0?e:a},n.prototype._init=function(e,a,f){if("number"==typeof e)return this._initNumber(e,a,f);if("object"==typeof e)return this._initArray(e,a,f);"hex"===a&&(a=16),t(a===(0|a)&&a>=2&&a<=36);var n=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&n++,16===a?this._parseHex(e,n):this._parseBase(e,a,n),"-"===e[0]&&(this.negative=1),this.strip(),"le"===f&&this._initArray(this.toArray(),a,f)},n.prototype._initNumber=function(e,a,f){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(t(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===f&&this._initArray(this.toArray(),a,f)},n.prototype._initArray=function(e,a,f){if(t("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var n=0;n=0;n-=3)d=e[n]|e[n-1]<<8|e[n-2]<<16,this.words[b]|=d<>>26-s&67108863,(s+=24)>=26&&(s-=26,b++);else if("le"===f)for(n=0,b=0;n>>26-s&67108863,(s+=24)>=26&&(s-=26,b++);return this.strip()},n.prototype._parseHex=function(e,a){this.length=Math.ceil((e.length-a)/6),this.words=new Array(this.length);for(var t=0;t=a;t-=6)n=d(e,t,t+6),this.words[f]|=n<>>26-b&4194303,(b+=24)>=26&&(b-=26,f++);t+6!==a&&(n=d(e,a,t+6),this.words[f]|=n<>>26-b&4194303),this.strip()},n.prototype._parseBase=function(e,a,t){this.words=[0],this.length=1;for(var f=0,n=1;n<=67108863;n*=a)f++;f--,n=n/a|0;for(var b=e.length-t,d=b%f,i=Math.min(b,b-d)+t,c=0,r=t;r1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?""};var i=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],r=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],u=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function o(e,a,t){t.negative=a.negative^e.negative;var f=e.length+a.length|0;t.length=f,f=f-1|0;var n=0|e.words[0],b=0|a.words[0],d=n*b,s=67108863&d,i=d/67108864|0;t.words[0]=s;for(var c=1;c>>26,u=67108863&i,o=Math.min(c,a.length-1),p=Math.max(0,c-e.length+1);p<=o;p++){var l=c-p|0;r+=(d=(n=0|e.words[l])*(b=0|a.words[p])+u)/67108864|0,u=67108863&d}t.words[c]=0|u,i=0|r}return 0!==i?t.words[c]=0|i:t.length--,t.strip()}n.prototype.toString=function(e,a){var f;if(a=0|a||1,16===(e=e||10)||"hex"===e){f="";for(var n=0,b=0,d=0;d>>24-n&16777215)||d!==this.length-1?i[6-c.length]+c+f:c+f,(n+=2)>=26&&(n-=26,d--)}for(0!==b&&(f=b.toString(16)+f);f.length%a!=0;)f="0"+f;return 0!==this.negative&&(f="-"+f),f}if(e===(0|e)&&e>=2&&e<=36){var o=r[e],p=u[e];f="";var l=this.clone();for(l.negative=0;!l.isZero();){var y=l.modn(p).toString(e);f=(l=l.idivn(p)).isZero()?y+f:i[o-y.length]+y+f}for(this.isZero()&&(f="0"+f);f.length%a!=0;)f="0"+f;return 0!==this.negative&&(f="-"+f),f}t(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(e,a){return t(void 0!==b),this.toArrayLike(b,e,a)},n.prototype.toArray=function(e,a){return this.toArrayLike(Array,e,a)},n.prototype.toArrayLike=function(e,a,f){var n=this.byteLength(),b=f||Math.max(1,n);t(n<=b,"byte array longer than desired length"),t(b>0,"Requested array length <= 0"),this.strip();var d,s,i="le"===a,c=new e(b),r=this.clone();if(i){for(s=0;!r.isZero();s++)d=r.andln(255),r.iushrn(8),c[s]=d;for(;s=4096&&(t+=13,a>>>=13),a>=64&&(t+=7,a>>>=7),a>=8&&(t+=4,a>>>=4),a>=2&&(t+=2,a>>>=2),t+a},n.prototype._zeroBits=function(e){if(0===e)return 26;var a=e,t=0;return 0==(8191&a)&&(t+=13,a>>>=13),0==(127&a)&&(t+=7,a>>>=7),0==(15&a)&&(t+=4,a>>>=4),0==(3&a)&&(t+=2,a>>>=2),0==(1&a)&&t++,t},n.prototype.bitLength=function(){var e=this.words[this.length-1],a=this._countBits(e);return 26*(this.length-1)+a},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,a=0;ae.length?this.clone().ior(e):e.clone().ior(this)},n.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},n.prototype.iuand=function(e){var a;a=this.length>e.length?e:this;for(var t=0;te.length?this.clone().iand(e):e.clone().iand(this)},n.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},n.prototype.iuxor=function(e){var a,t;this.length>e.length?(a=this,t=e):(a=e,t=this);for(var f=0;fe.length?this.clone().ixor(e):e.clone().ixor(this)},n.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},n.prototype.inotn=function(e){t("number"==typeof e&&e>=0);var a=0|Math.ceil(e/26),f=e%26;this._expand(a),f>0&&a--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-f),this.strip()},n.prototype.notn=function(e){return this.clone().inotn(e)},n.prototype.setn=function(e,a){t("number"==typeof e&&e>=0);var f=e/26|0,n=e%26;return this._expand(f+1),this.words[f]=a?this.words[f]|1<e.length?(t=this,f=e):(t=e,f=this);for(var n=0,b=0;b>>26;for(;0!==n&&b>>26;if(this.length=t.length,0!==n)this.words[this.length]=n,this.length++;else if(t!==this)for(;be.length?this.clone().iadd(e):e.clone().iadd(this)},n.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var a=this.iadd(e);return e.negative=1,a._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var t,f,n=this.cmp(e);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(t=this,f=e):(t=e,f=this);for(var b=0,d=0;d>26,this.words[d]=67108863&a;for(;0!==b&&d>26,this.words[d]=67108863&a;if(0===b&&d>>13,p=0|d[1],l=8191&p,y=p>>>13,m=0|d[2],h=8191&m,x=m>>>13,g=0|d[3],v=8191&g,T=g>>>13,w=0|d[4],E=8191&w,A=w>>>13,M=0|d[5],C=8191&M,D=M>>>13,S=0|d[6],B=8191&S,F=S>>>13,_=0|d[7],k=8191&_,R=_>>>13,P=0|d[8],O=8191&P,I=P>>>13,N=0|d[9],L=8191&N,U=N>>>13,X=0|s[0],K=8191&X,Z=X>>>13,V=0|s[1],q=8191&V,H=V>>>13,z=0|s[2],j=8191&z,G=z>>>13,W=0|s[3],$=8191&W,J=W>>>13,Y=0|s[4],Q=8191&Y,ee=Y>>>13,ae=0|s[5],te=8191&ae,fe=ae>>>13,ne=0|s[6],be=8191&ne,de=ne>>>13,se=0|s[7],ie=8191&se,ce=se>>>13,re=0|s[8],ue=8191&re,oe=re>>>13,pe=0|s[9],le=8191&pe,ye=pe>>>13;t.negative=e.negative^a.negative,t.length=19;var me=(c+(f=Math.imul(u,K))|0)+((8191&(n=(n=Math.imul(u,Z))+Math.imul(o,K)|0))<<13)|0;c=((b=Math.imul(o,Z))+(n>>>13)|0)+(me>>>26)|0,me&=67108863,f=Math.imul(l,K),n=(n=Math.imul(l,Z))+Math.imul(y,K)|0,b=Math.imul(y,Z);var he=(c+(f=f+Math.imul(u,q)|0)|0)+((8191&(n=(n=n+Math.imul(u,H)|0)+Math.imul(o,q)|0))<<13)|0;c=((b=b+Math.imul(o,H)|0)+(n>>>13)|0)+(he>>>26)|0,he&=67108863,f=Math.imul(h,K),n=(n=Math.imul(h,Z))+Math.imul(x,K)|0,b=Math.imul(x,Z),f=f+Math.imul(l,q)|0,n=(n=n+Math.imul(l,H)|0)+Math.imul(y,q)|0,b=b+Math.imul(y,H)|0;var xe=(c+(f=f+Math.imul(u,j)|0)|0)+((8191&(n=(n=n+Math.imul(u,G)|0)+Math.imul(o,j)|0))<<13)|0;c=((b=b+Math.imul(o,G)|0)+(n>>>13)|0)+(xe>>>26)|0,xe&=67108863,f=Math.imul(v,K),n=(n=Math.imul(v,Z))+Math.imul(T,K)|0,b=Math.imul(T,Z),f=f+Math.imul(h,q)|0,n=(n=n+Math.imul(h,H)|0)+Math.imul(x,q)|0,b=b+Math.imul(x,H)|0,f=f+Math.imul(l,j)|0,n=(n=n+Math.imul(l,G)|0)+Math.imul(y,j)|0,b=b+Math.imul(y,G)|0;var ge=(c+(f=f+Math.imul(u,$)|0)|0)+((8191&(n=(n=n+Math.imul(u,J)|0)+Math.imul(o,$)|0))<<13)|0;c=((b=b+Math.imul(o,J)|0)+(n>>>13)|0)+(ge>>>26)|0,ge&=67108863,f=Math.imul(E,K),n=(n=Math.imul(E,Z))+Math.imul(A,K)|0,b=Math.imul(A,Z),f=f+Math.imul(v,q)|0,n=(n=n+Math.imul(v,H)|0)+Math.imul(T,q)|0,b=b+Math.imul(T,H)|0,f=f+Math.imul(h,j)|0,n=(n=n+Math.imul(h,G)|0)+Math.imul(x,j)|0,b=b+Math.imul(x,G)|0,f=f+Math.imul(l,$)|0,n=(n=n+Math.imul(l,J)|0)+Math.imul(y,$)|0,b=b+Math.imul(y,J)|0;var ve=(c+(f=f+Math.imul(u,Q)|0)|0)+((8191&(n=(n=n+Math.imul(u,ee)|0)+Math.imul(o,Q)|0))<<13)|0;c=((b=b+Math.imul(o,ee)|0)+(n>>>13)|0)+(ve>>>26)|0,ve&=67108863,f=Math.imul(C,K),n=(n=Math.imul(C,Z))+Math.imul(D,K)|0,b=Math.imul(D,Z),f=f+Math.imul(E,q)|0,n=(n=n+Math.imul(E,H)|0)+Math.imul(A,q)|0,b=b+Math.imul(A,H)|0,f=f+Math.imul(v,j)|0,n=(n=n+Math.imul(v,G)|0)+Math.imul(T,j)|0,b=b+Math.imul(T,G)|0,f=f+Math.imul(h,$)|0,n=(n=n+Math.imul(h,J)|0)+Math.imul(x,$)|0,b=b+Math.imul(x,J)|0,f=f+Math.imul(l,Q)|0,n=(n=n+Math.imul(l,ee)|0)+Math.imul(y,Q)|0,b=b+Math.imul(y,ee)|0;var Te=(c+(f=f+Math.imul(u,te)|0)|0)+((8191&(n=(n=n+Math.imul(u,fe)|0)+Math.imul(o,te)|0))<<13)|0;c=((b=b+Math.imul(o,fe)|0)+(n>>>13)|0)+(Te>>>26)|0,Te&=67108863,f=Math.imul(B,K),n=(n=Math.imul(B,Z))+Math.imul(F,K)|0,b=Math.imul(F,Z),f=f+Math.imul(C,q)|0,n=(n=n+Math.imul(C,H)|0)+Math.imul(D,q)|0,b=b+Math.imul(D,H)|0,f=f+Math.imul(E,j)|0,n=(n=n+Math.imul(E,G)|0)+Math.imul(A,j)|0,b=b+Math.imul(A,G)|0,f=f+Math.imul(v,$)|0,n=(n=n+Math.imul(v,J)|0)+Math.imul(T,$)|0,b=b+Math.imul(T,J)|0,f=f+Math.imul(h,Q)|0,n=(n=n+Math.imul(h,ee)|0)+Math.imul(x,Q)|0,b=b+Math.imul(x,ee)|0,f=f+Math.imul(l,te)|0,n=(n=n+Math.imul(l,fe)|0)+Math.imul(y,te)|0,b=b+Math.imul(y,fe)|0;var we=(c+(f=f+Math.imul(u,be)|0)|0)+((8191&(n=(n=n+Math.imul(u,de)|0)+Math.imul(o,be)|0))<<13)|0;c=((b=b+Math.imul(o,de)|0)+(n>>>13)|0)+(we>>>26)|0,we&=67108863,f=Math.imul(k,K),n=(n=Math.imul(k,Z))+Math.imul(R,K)|0,b=Math.imul(R,Z),f=f+Math.imul(B,q)|0,n=(n=n+Math.imul(B,H)|0)+Math.imul(F,q)|0,b=b+Math.imul(F,H)|0,f=f+Math.imul(C,j)|0,n=(n=n+Math.imul(C,G)|0)+Math.imul(D,j)|0,b=b+Math.imul(D,G)|0,f=f+Math.imul(E,$)|0,n=(n=n+Math.imul(E,J)|0)+Math.imul(A,$)|0,b=b+Math.imul(A,J)|0,f=f+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,ee)|0)+Math.imul(T,Q)|0,b=b+Math.imul(T,ee)|0,f=f+Math.imul(h,te)|0,n=(n=n+Math.imul(h,fe)|0)+Math.imul(x,te)|0,b=b+Math.imul(x,fe)|0,f=f+Math.imul(l,be)|0,n=(n=n+Math.imul(l,de)|0)+Math.imul(y,be)|0,b=b+Math.imul(y,de)|0;var Ee=(c+(f=f+Math.imul(u,ie)|0)|0)+((8191&(n=(n=n+Math.imul(u,ce)|0)+Math.imul(o,ie)|0))<<13)|0;c=((b=b+Math.imul(o,ce)|0)+(n>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,f=Math.imul(O,K),n=(n=Math.imul(O,Z))+Math.imul(I,K)|0,b=Math.imul(I,Z),f=f+Math.imul(k,q)|0,n=(n=n+Math.imul(k,H)|0)+Math.imul(R,q)|0,b=b+Math.imul(R,H)|0,f=f+Math.imul(B,j)|0,n=(n=n+Math.imul(B,G)|0)+Math.imul(F,j)|0,b=b+Math.imul(F,G)|0,f=f+Math.imul(C,$)|0,n=(n=n+Math.imul(C,J)|0)+Math.imul(D,$)|0,b=b+Math.imul(D,J)|0,f=f+Math.imul(E,Q)|0,n=(n=n+Math.imul(E,ee)|0)+Math.imul(A,Q)|0,b=b+Math.imul(A,ee)|0,f=f+Math.imul(v,te)|0,n=(n=n+Math.imul(v,fe)|0)+Math.imul(T,te)|0,b=b+Math.imul(T,fe)|0,f=f+Math.imul(h,be)|0,n=(n=n+Math.imul(h,de)|0)+Math.imul(x,be)|0,b=b+Math.imul(x,de)|0,f=f+Math.imul(l,ie)|0,n=(n=n+Math.imul(l,ce)|0)+Math.imul(y,ie)|0,b=b+Math.imul(y,ce)|0;var Ae=(c+(f=f+Math.imul(u,ue)|0)|0)+((8191&(n=(n=n+Math.imul(u,oe)|0)+Math.imul(o,ue)|0))<<13)|0;c=((b=b+Math.imul(o,oe)|0)+(n>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,f=Math.imul(L,K),n=(n=Math.imul(L,Z))+Math.imul(U,K)|0,b=Math.imul(U,Z),f=f+Math.imul(O,q)|0,n=(n=n+Math.imul(O,H)|0)+Math.imul(I,q)|0,b=b+Math.imul(I,H)|0,f=f+Math.imul(k,j)|0,n=(n=n+Math.imul(k,G)|0)+Math.imul(R,j)|0,b=b+Math.imul(R,G)|0,f=f+Math.imul(B,$)|0,n=(n=n+Math.imul(B,J)|0)+Math.imul(F,$)|0,b=b+Math.imul(F,J)|0,f=f+Math.imul(C,Q)|0,n=(n=n+Math.imul(C,ee)|0)+Math.imul(D,Q)|0,b=b+Math.imul(D,ee)|0,f=f+Math.imul(E,te)|0,n=(n=n+Math.imul(E,fe)|0)+Math.imul(A,te)|0,b=b+Math.imul(A,fe)|0,f=f+Math.imul(v,be)|0,n=(n=n+Math.imul(v,de)|0)+Math.imul(T,be)|0,b=b+Math.imul(T,de)|0,f=f+Math.imul(h,ie)|0,n=(n=n+Math.imul(h,ce)|0)+Math.imul(x,ie)|0,b=b+Math.imul(x,ce)|0,f=f+Math.imul(l,ue)|0,n=(n=n+Math.imul(l,oe)|0)+Math.imul(y,ue)|0,b=b+Math.imul(y,oe)|0;var Me=(c+(f=f+Math.imul(u,le)|0)|0)+((8191&(n=(n=n+Math.imul(u,ye)|0)+Math.imul(o,le)|0))<<13)|0;c=((b=b+Math.imul(o,ye)|0)+(n>>>13)|0)+(Me>>>26)|0,Me&=67108863,f=Math.imul(L,q),n=(n=Math.imul(L,H))+Math.imul(U,q)|0,b=Math.imul(U,H),f=f+Math.imul(O,j)|0,n=(n=n+Math.imul(O,G)|0)+Math.imul(I,j)|0,b=b+Math.imul(I,G)|0,f=f+Math.imul(k,$)|0,n=(n=n+Math.imul(k,J)|0)+Math.imul(R,$)|0,b=b+Math.imul(R,J)|0,f=f+Math.imul(B,Q)|0,n=(n=n+Math.imul(B,ee)|0)+Math.imul(F,Q)|0,b=b+Math.imul(F,ee)|0,f=f+Math.imul(C,te)|0,n=(n=n+Math.imul(C,fe)|0)+Math.imul(D,te)|0,b=b+Math.imul(D,fe)|0,f=f+Math.imul(E,be)|0,n=(n=n+Math.imul(E,de)|0)+Math.imul(A,be)|0,b=b+Math.imul(A,de)|0,f=f+Math.imul(v,ie)|0,n=(n=n+Math.imul(v,ce)|0)+Math.imul(T,ie)|0,b=b+Math.imul(T,ce)|0,f=f+Math.imul(h,ue)|0,n=(n=n+Math.imul(h,oe)|0)+Math.imul(x,ue)|0,b=b+Math.imul(x,oe)|0;var Ce=(c+(f=f+Math.imul(l,le)|0)|0)+((8191&(n=(n=n+Math.imul(l,ye)|0)+Math.imul(y,le)|0))<<13)|0;c=((b=b+Math.imul(y,ye)|0)+(n>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,f=Math.imul(L,j),n=(n=Math.imul(L,G))+Math.imul(U,j)|0,b=Math.imul(U,G),f=f+Math.imul(O,$)|0,n=(n=n+Math.imul(O,J)|0)+Math.imul(I,$)|0,b=b+Math.imul(I,J)|0,f=f+Math.imul(k,Q)|0,n=(n=n+Math.imul(k,ee)|0)+Math.imul(R,Q)|0,b=b+Math.imul(R,ee)|0,f=f+Math.imul(B,te)|0,n=(n=n+Math.imul(B,fe)|0)+Math.imul(F,te)|0,b=b+Math.imul(F,fe)|0,f=f+Math.imul(C,be)|0,n=(n=n+Math.imul(C,de)|0)+Math.imul(D,be)|0,b=b+Math.imul(D,de)|0,f=f+Math.imul(E,ie)|0,n=(n=n+Math.imul(E,ce)|0)+Math.imul(A,ie)|0,b=b+Math.imul(A,ce)|0,f=f+Math.imul(v,ue)|0,n=(n=n+Math.imul(v,oe)|0)+Math.imul(T,ue)|0,b=b+Math.imul(T,oe)|0;var De=(c+(f=f+Math.imul(h,le)|0)|0)+((8191&(n=(n=n+Math.imul(h,ye)|0)+Math.imul(x,le)|0))<<13)|0;c=((b=b+Math.imul(x,ye)|0)+(n>>>13)|0)+(De>>>26)|0,De&=67108863,f=Math.imul(L,$),n=(n=Math.imul(L,J))+Math.imul(U,$)|0,b=Math.imul(U,J),f=f+Math.imul(O,Q)|0,n=(n=n+Math.imul(O,ee)|0)+Math.imul(I,Q)|0,b=b+Math.imul(I,ee)|0,f=f+Math.imul(k,te)|0,n=(n=n+Math.imul(k,fe)|0)+Math.imul(R,te)|0,b=b+Math.imul(R,fe)|0,f=f+Math.imul(B,be)|0,n=(n=n+Math.imul(B,de)|0)+Math.imul(F,be)|0,b=b+Math.imul(F,de)|0,f=f+Math.imul(C,ie)|0,n=(n=n+Math.imul(C,ce)|0)+Math.imul(D,ie)|0,b=b+Math.imul(D,ce)|0,f=f+Math.imul(E,ue)|0,n=(n=n+Math.imul(E,oe)|0)+Math.imul(A,ue)|0,b=b+Math.imul(A,oe)|0;var Se=(c+(f=f+Math.imul(v,le)|0)|0)+((8191&(n=(n=n+Math.imul(v,ye)|0)+Math.imul(T,le)|0))<<13)|0;c=((b=b+Math.imul(T,ye)|0)+(n>>>13)|0)+(Se>>>26)|0,Se&=67108863,f=Math.imul(L,Q),n=(n=Math.imul(L,ee))+Math.imul(U,Q)|0,b=Math.imul(U,ee),f=f+Math.imul(O,te)|0,n=(n=n+Math.imul(O,fe)|0)+Math.imul(I,te)|0,b=b+Math.imul(I,fe)|0,f=f+Math.imul(k,be)|0,n=(n=n+Math.imul(k,de)|0)+Math.imul(R,be)|0,b=b+Math.imul(R,de)|0,f=f+Math.imul(B,ie)|0,n=(n=n+Math.imul(B,ce)|0)+Math.imul(F,ie)|0,b=b+Math.imul(F,ce)|0,f=f+Math.imul(C,ue)|0,n=(n=n+Math.imul(C,oe)|0)+Math.imul(D,ue)|0,b=b+Math.imul(D,oe)|0;var Be=(c+(f=f+Math.imul(E,le)|0)|0)+((8191&(n=(n=n+Math.imul(E,ye)|0)+Math.imul(A,le)|0))<<13)|0;c=((b=b+Math.imul(A,ye)|0)+(n>>>13)|0)+(Be>>>26)|0,Be&=67108863,f=Math.imul(L,te),n=(n=Math.imul(L,fe))+Math.imul(U,te)|0,b=Math.imul(U,fe),f=f+Math.imul(O,be)|0,n=(n=n+Math.imul(O,de)|0)+Math.imul(I,be)|0,b=b+Math.imul(I,de)|0,f=f+Math.imul(k,ie)|0,n=(n=n+Math.imul(k,ce)|0)+Math.imul(R,ie)|0,b=b+Math.imul(R,ce)|0,f=f+Math.imul(B,ue)|0,n=(n=n+Math.imul(B,oe)|0)+Math.imul(F,ue)|0,b=b+Math.imul(F,oe)|0;var Fe=(c+(f=f+Math.imul(C,le)|0)|0)+((8191&(n=(n=n+Math.imul(C,ye)|0)+Math.imul(D,le)|0))<<13)|0;c=((b=b+Math.imul(D,ye)|0)+(n>>>13)|0)+(Fe>>>26)|0,Fe&=67108863,f=Math.imul(L,be),n=(n=Math.imul(L,de))+Math.imul(U,be)|0,b=Math.imul(U,de),f=f+Math.imul(O,ie)|0,n=(n=n+Math.imul(O,ce)|0)+Math.imul(I,ie)|0,b=b+Math.imul(I,ce)|0,f=f+Math.imul(k,ue)|0,n=(n=n+Math.imul(k,oe)|0)+Math.imul(R,ue)|0,b=b+Math.imul(R,oe)|0;var _e=(c+(f=f+Math.imul(B,le)|0)|0)+((8191&(n=(n=n+Math.imul(B,ye)|0)+Math.imul(F,le)|0))<<13)|0;c=((b=b+Math.imul(F,ye)|0)+(n>>>13)|0)+(_e>>>26)|0,_e&=67108863,f=Math.imul(L,ie),n=(n=Math.imul(L,ce))+Math.imul(U,ie)|0,b=Math.imul(U,ce),f=f+Math.imul(O,ue)|0,n=(n=n+Math.imul(O,oe)|0)+Math.imul(I,ue)|0,b=b+Math.imul(I,oe)|0;var ke=(c+(f=f+Math.imul(k,le)|0)|0)+((8191&(n=(n=n+Math.imul(k,ye)|0)+Math.imul(R,le)|0))<<13)|0;c=((b=b+Math.imul(R,ye)|0)+(n>>>13)|0)+(ke>>>26)|0,ke&=67108863,f=Math.imul(L,ue),n=(n=Math.imul(L,oe))+Math.imul(U,ue)|0,b=Math.imul(U,oe);var Re=(c+(f=f+Math.imul(O,le)|0)|0)+((8191&(n=(n=n+Math.imul(O,ye)|0)+Math.imul(I,le)|0))<<13)|0;c=((b=b+Math.imul(I,ye)|0)+(n>>>13)|0)+(Re>>>26)|0,Re&=67108863;var Pe=(c+(f=Math.imul(L,le))|0)+((8191&(n=(n=Math.imul(L,ye))+Math.imul(U,le)|0))<<13)|0;return c=((b=Math.imul(U,ye))+(n>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,i[0]=me,i[1]=he,i[2]=xe,i[3]=ge,i[4]=ve,i[5]=Te,i[6]=we,i[7]=Ee,i[8]=Ae,i[9]=Me,i[10]=Ce,i[11]=De,i[12]=Se,i[13]=Be,i[14]=Fe,i[15]=_e,i[16]=ke,i[17]=Re,i[18]=Pe,0!==c&&(i[19]=c,t.length++),t};function l(e,a,t){return(new y).mulp(e,a,t)}function y(e,a){this.x=e,this.y=a}Math.imul||(p=o),n.prototype.mulTo=function(e,a){var t=this.length+e.length;return 10===this.length&&10===e.length?p(this,e,a):t<63?o(this,e,a):t<1024?function(e,a,t){t.negative=a.negative^e.negative,t.length=e.length+a.length;for(var f=0,n=0,b=0;b>>26)|0)>>>26,d&=67108863}t.words[b]=s,f=d,d=n}return 0!==f?t.words[b]=f:t.length--,t.strip()}(this,e,a):l(this,e,a)},y.prototype.makeRBT=function(e){for(var a=new Array(e),t=n.prototype._countBits(e)-1,f=0;f>=1;return f},y.prototype.permute=function(e,a,t,f,n,b){for(var d=0;d>>=1)n++;return 1<>>=13,f[2*d+1]=8191&b,b>>>=13;for(d=2*a;d>=26,a+=n/67108864|0,a+=b>>>26,this.words[f]=67108863&b}return 0!==a&&(this.words[f]=a,this.length++),this},n.prototype.muln=function(e){return this.clone().imuln(e)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(e){var a=function(e){for(var a=new Array(e.bitLength()),t=0;t>>n}return a}(e);if(0===a.length)return new n(1);for(var t=this,f=0;f=0);var a,f=e%26,n=(e-f)/26,b=67108863>>>26-f<<26-f;if(0!==f){var d=0;for(a=0;a>>26-f}d&&(this.words[a]=d,this.length++)}if(0!==n){for(a=this.length-1;a>=0;a--)this.words[a+n]=this.words[a];for(a=0;a=0),n=a?(a-a%26)/26:0;var b=e%26,d=Math.min((e-b)/26,this.length),s=67108863^67108863>>>b<d)for(this.length-=d,c=0;c=0&&(0!==r||c>=n);c--){var u=0|this.words[c];this.words[c]=r<<26-b|u>>>b,r=u&s}return i&&0!==r&&(i.words[i.length++]=r),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(e,a,f){return t(0===this.negative),this.iushrn(e,a,f)},n.prototype.shln=function(e){return this.clone().ishln(e)},n.prototype.ushln=function(e){return this.clone().iushln(e)},n.prototype.shrn=function(e){return this.clone().ishrn(e)},n.prototype.ushrn=function(e){return this.clone().iushrn(e)},n.prototype.testn=function(e){t("number"==typeof e&&e>=0);var a=e%26,f=(e-a)/26,n=1<=0);var a=e%26,f=(e-a)/26;if(t(0===this.negative,"imaskn works only with positive numbers"),this.length<=f)return this;if(0!==a&&f++,this.length=Math.min(f,this.length),0!==a){var n=67108863^67108863>>>a<=67108864;a++)this.words[a]-=67108864,a===this.length-1?this.words[a+1]=1:this.words[a+1]++;return this.length=Math.max(this.length,a+1),this},n.prototype.isubn=function(e){if(t("number"==typeof e),t(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var a=0;a>26)-(i/67108864|0),this.words[n+f]=67108863&b}for(;n>26,this.words[n+f]=67108863&b;if(0===s)return this.strip();for(t(-1===s),s=0,n=0;n>26,this.words[n]=67108863&b;return this.negative=1,this.strip()},n.prototype._wordDiv=function(e,a){var t=(this.length,e.length),f=this.clone(),b=e,d=0|b.words[b.length-1];0!=(t=26-this._countBits(d))&&(b=b.ushln(t),f.iushln(t),d=0|b.words[b.length-1]);var s,i=f.length-b.length;if("mod"!==a){(s=new n(null)).length=i+1,s.words=new Array(s.length);for(var c=0;c=0;u--){var o=67108864*(0|f.words[b.length+u])+(0|f.words[b.length+u-1]);for(o=Math.min(o/d|0,67108863),f._ishlnsubmul(b,o,u);0!==f.negative;)o--,f.negative=0,f._ishlnsubmul(b,1,u),f.isZero()||(f.negative^=1);s&&(s.words[u]=o)}return s&&s.strip(),f.strip(),"div"!==a&&0!==t&&f.iushrn(t),{div:s||null,mod:f}},n.prototype.divmod=function(e,a,f){return t(!e.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,a),"mod"!==a&&(b=s.div.neg()),"div"!==a&&(d=s.mod.neg(),f&&0!==d.negative&&d.iadd(e)),{div:b,mod:d}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),a),"mod"!==a&&(b=s.div.neg()),{div:b,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),a),"div"!==a&&(d=s.mod.neg(),f&&0!==d.negative&&d.isub(e)),{div:s.div,mod:d}):e.length>this.length||this.cmp(e)<0?{div:new n(0),mod:this}:1===e.length?"div"===a?{div:this.divn(e.words[0]),mod:null}:"mod"===a?{div:null,mod:new n(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new n(this.modn(e.words[0]))}:this._wordDiv(e,a);var b,d,s},n.prototype.div=function(e){return this.divmod(e,"div",!1).div},n.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},n.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},n.prototype.divRound=function(e){var a=this.divmod(e);if(a.mod.isZero())return a.div;var t=0!==a.div.negative?a.mod.isub(e):a.mod,f=e.ushrn(1),n=e.andln(1),b=t.cmp(f);return b<0||1===n&&0===b?a.div:0!==a.div.negative?a.div.isubn(1):a.div.iaddn(1)},n.prototype.modn=function(e){t(e<=67108863);for(var a=(1<<26)%e,f=0,n=this.length-1;n>=0;n--)f=(a*f+(0|this.words[n]))%e;return f},n.prototype.idivn=function(e){t(e<=67108863);for(var a=0,f=this.length-1;f>=0;f--){var n=(0|this.words[f])+67108864*a;this.words[f]=n/e|0,a=n%e}return this.strip()},n.prototype.divn=function(e){return this.clone().idivn(e)},n.prototype.egcd=function(e){t(0===e.negative),t(!e.isZero());var a=this,f=e.clone();a=0!==a.negative?a.umod(e):a.clone();for(var b=new n(1),d=new n(0),s=new n(0),i=new n(1),c=0;a.isEven()&&f.isEven();)a.iushrn(1),f.iushrn(1),++c;for(var r=f.clone(),u=a.clone();!a.isZero();){for(var o=0,p=1;0==(a.words[0]&p)&&o<26;++o,p<<=1);if(o>0)for(a.iushrn(o);o-- >0;)(b.isOdd()||d.isOdd())&&(b.iadd(r),d.isub(u)),b.iushrn(1),d.iushrn(1);for(var l=0,y=1;0==(f.words[0]&y)&&l<26;++l,y<<=1);if(l>0)for(f.iushrn(l);l-- >0;)(s.isOdd()||i.isOdd())&&(s.iadd(r),i.isub(u)),s.iushrn(1),i.iushrn(1);a.cmp(f)>=0?(a.isub(f),b.isub(s),d.isub(i)):(f.isub(a),s.isub(b),i.isub(d))}return{a:s,b:i,gcd:f.iushln(c)}},n.prototype._invmp=function(e){t(0===e.negative),t(!e.isZero());var a=this,f=e.clone();a=0!==a.negative?a.umod(e):a.clone();for(var b,d=new n(1),s=new n(0),i=f.clone();a.cmpn(1)>0&&f.cmpn(1)>0;){for(var c=0,r=1;0==(a.words[0]&r)&&c<26;++c,r<<=1);if(c>0)for(a.iushrn(c);c-- >0;)d.isOdd()&&d.iadd(i),d.iushrn(1);for(var u=0,o=1;0==(f.words[0]&o)&&u<26;++u,o<<=1);if(u>0)for(f.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(i),s.iushrn(1);a.cmp(f)>=0?(a.isub(f),d.isub(s)):(f.isub(a),s.isub(d))}return(b=0===a.cmpn(1)?d:s).cmpn(0)<0&&b.iadd(e),b},n.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var a=this.clone(),t=e.clone();a.negative=0,t.negative=0;for(var f=0;a.isEven()&&t.isEven();f++)a.iushrn(1),t.iushrn(1);for(;;){for(;a.isEven();)a.iushrn(1);for(;t.isEven();)t.iushrn(1);var n=a.cmp(t);if(n<0){var b=a;a=t,t=b}else if(0===n||0===t.cmpn(1))break;a.isub(t)}return t.iushln(f)},n.prototype.invm=function(e){return this.egcd(e).a.umod(e)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(e){return this.words[0]&e},n.prototype.bincn=function(e){t("number"==typeof e);var a=e%26,f=(e-a)/26,n=1<>>26,s&=67108863,this.words[d]=s}return 0!==b&&(this.words[d]=b,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(e){var a,f=e<0;if(0!==this.negative&&!f)return-1;if(0===this.negative&&f)return 1;if(this.strip(),this.length>1)a=1;else{f&&(e=-e),t(e<=67108863,"Number is too big");var n=0|this.words[0];a=n===e?0:ne.length)return 1;if(this.length=0;t--){var f=0|this.words[t],n=0|e.words[t];if(f!==n){fn&&(a=1);break}}return a},n.prototype.gtn=function(e){return 1===this.cmpn(e)},n.prototype.gt=function(e){return 1===this.cmp(e)},n.prototype.gten=function(e){return this.cmpn(e)>=0},n.prototype.gte=function(e){return this.cmp(e)>=0},n.prototype.ltn=function(e){return-1===this.cmpn(e)},n.prototype.lt=function(e){return-1===this.cmp(e)},n.prototype.lten=function(e){return this.cmpn(e)<=0},n.prototype.lte=function(e){return this.cmp(e)<=0},n.prototype.eqn=function(e){return 0===this.cmpn(e)},n.prototype.eq=function(e){return 0===this.cmp(e)},n.red=function(e){return new w(e)},n.prototype.toRed=function(e){return t(!this.red,"Already a number in reduction context"),t(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},n.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(e){return this.red=e,this},n.prototype.forceRed=function(e){return t(!this.red,"Already a number in reduction context"),this._forceRed(e)},n.prototype.redAdd=function(e){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},n.prototype.redIAdd=function(e){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},n.prototype.redSub=function(e){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},n.prototype.redISub=function(e){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},n.prototype.redShl=function(e){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},n.prototype.redMul=function(e){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},n.prototype.redIMul=function(e){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},n.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(e){return t(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var m={k256:null,p224:null,p192:null,p25519:null};function h(e,a){this.name=e,this.p=new n(a,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function x(){h.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function g(){h.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function v(){h.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function T(){h.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function w(e){if("string"==typeof e){var a=n._prime(e);this.m=a.p,this.prime=a}else t(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function E(e){w.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}h.prototype._tmp=function(){var e=new n(null);return e.words=new Array(Math.ceil(this.n/13)),e},h.prototype.ireduce=function(e){var a,t=e;do{this.split(t,this.tmp),a=(t=(t=this.imulK(t)).iadd(this.tmp)).bitLength()}while(a>this.n);var f=a0?t.isub(this.p):void 0!==t.strip?t.strip():t._strip(),t},h.prototype.split=function(e,a){e.iushrn(this.n,0,a)},h.prototype.imulK=function(e){return e.imul(this.k)},f(x,h),x.prototype.split=function(e,a){for(var t=Math.min(e.length,9),f=0;f>>22,n=b}n>>>=22,e.words[f-10]=n,0===n&&e.length>10?e.length-=10:e.length-=9},x.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var a=0,t=0;t>>=26,e.words[t]=n,a=f}return 0!==a&&(e.words[e.length++]=a),e},n._prime=function(e){if(m[e])return m[e];var a;if("k256"===e)a=new x;else if("p224"===e)a=new g;else if("p192"===e)a=new v;else{if("p25519"!==e)throw new Error("Unknown prime "+e);a=new T}return m[e]=a,a},w.prototype._verify1=function(e){t(0===e.negative,"red works only with positives"),t(e.red,"red works only with red numbers")},w.prototype._verify2=function(e,a){t(0==(e.negative|a.negative),"red works only with positives"),t(e.red&&e.red===a.red,"red works only with red numbers")},w.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},w.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},w.prototype.add=function(e,a){this._verify2(e,a);var t=e.add(a);return t.cmp(this.m)>=0&&t.isub(this.m),t._forceRed(this)},w.prototype.iadd=function(e,a){this._verify2(e,a);var t=e.iadd(a);return t.cmp(this.m)>=0&&t.isub(this.m),t},w.prototype.sub=function(e,a){this._verify2(e,a);var t=e.sub(a);return t.cmpn(0)<0&&t.iadd(this.m),t._forceRed(this)},w.prototype.isub=function(e,a){this._verify2(e,a);var t=e.isub(a);return t.cmpn(0)<0&&t.iadd(this.m),t},w.prototype.shl=function(e,a){return this._verify1(e),this.imod(e.ushln(a))},w.prototype.imul=function(e,a){return this._verify2(e,a),this.imod(e.imul(a))},w.prototype.mul=function(e,a){return this._verify2(e,a),this.imod(e.mul(a))},w.prototype.isqr=function(e){return this.imul(e,e.clone())},w.prototype.sqr=function(e){return this.mul(e,e)},w.prototype.sqrt=function(e){if(e.isZero())return e.clone();var a=this.m.andln(3);if(t(a%2==1),3===a){var f=this.m.add(new n(1)).iushrn(2);return this.pow(e,f)}for(var b=this.m.subn(1),d=0;!b.isZero()&&0===b.andln(1);)d++,b.iushrn(1);t(!b.isZero());var s=new n(1).toRed(this),i=s.redNeg(),c=this.m.subn(1).iushrn(1),r=this.m.bitLength();for(r=new n(2*r*r).toRed(this);0!==this.pow(r,c).cmp(i);)r.redIAdd(i);for(var u=this.pow(r,b),o=this.pow(e,b.addn(1).iushrn(1)),p=this.pow(e,b),l=d;0!==p.cmp(s);){for(var y=p,m=0;0!==y.cmp(s);m++)y=y.redSqr();t(m=0;f--){for(var c=a.words[f],r=i-1;r>=0;r--){var u=c>>r&1;b!==t[0]&&(b=this.sqr(b)),0!==u||0!==d?(d<<=1,d|=u,(4==++s||0===f&&0===r)&&(b=this.mul(b,t[d]),s=0,d=0)):s=0}i=26}return b},w.prototype.convertTo=function(e){var a=e.umod(this.m);return a===e?a.clone():a},w.prototype.convertFrom=function(e){var a=e.clone();return a.red=null,a},n.mont=function(e){return new E(e)},f(E,w),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var a=this.imod(e.mul(this.rinv));return a.red=null,a},E.prototype.imul=function(e,a){if(e.isZero()||a.isZero())return e.words[0]=0,e.length=1,e;var t=e.imul(a),f=t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=t.isub(f).iushrn(this.shift),b=n;return n.cmp(this.m)>=0?b=n.isub(this.m):n.cmpn(0)<0&&(b=n.iadd(this.m)),b._forceRed(this)},E.prototype.mul=function(e,a){if(e.isZero()||a.isZero())return new n(0)._forceRed(this);var t=e.mul(a),f=t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),b=t.isub(f).iushrn(this.shift),d=b;return b.cmp(this.m)>=0?d=b.isub(this.m):b.cmpn(0)<0&&(d=b.iadd(this.m)),d._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,n)})),Fa=d((function(e,a){var t=a;function f(e){return 1===e.length?"0"+e:e}function n(e){for(var a="",t=0;t>8,d=255&n;b?t.push(b,d):t.push(d)}return t},t.zero2=f,t.toHex=n,t.encode=function(e,a){return"hex"===a?n(e):e}})),_a=d((function(e,a){var t=a;t.assert=ne,t.toArray=Fa.toArray,t.zero2=Fa.zero2,t.toHex=Fa.toHex,t.encode=Fa.encode,t.getNAF=function(e,a,t){var f=new Array(Math.max(e.bitLength(),t)+1);f.fill(0);for(var n=1<(n>>1)-1?(n>>1)-i:i,b.isubn(s)):s=0,f[d]=s,b.iushrn(1)}return f},t.getJSF=function(e,a){var t=[[],[]];e=e.clone(),a=a.clone();for(var f=0,n=0;e.cmpn(-f)>0||a.cmpn(-n)>0;){var b,d,s,i=e.andln(3)+f&3,c=a.andln(3)+n&3;3===i&&(i=-1),3===c&&(c=-1),b=0==(1&i)?0:3!=(s=e.andln(7)+f&7)&&5!==s||2!==c?i:-i,t[0].push(b),d=0==(1&c)?0:3!=(s=a.andln(7)+n&7)&&5!==s||2!==i?c:-c,t[1].push(d),2*f===b+1&&(f=1-f),2*n===d+1&&(n=1-n),e.iushrn(1),a.iushrn(1)}return t},t.cachedProperty=function(e,a,t){var f="_"+a;e.prototype[a]=function(){return void 0!==this[f]?this[f]:this[f]=t.call(this)}},t.parseBytes=function(e){return"string"==typeof e?t.toArray(e,"hex"):e},t.intFromLE=function(e){return new Ba(e,"hex","le")}})),ka=function(e){var a=new Uint8Array(e);return(n.crypto||n.msCrypto).getRandomValues(a),a},Ra=_a.getNAF,Pa=_a.getJSF,Oa=_a.assert;function Ia(e,a){this.type=e,this.p=new Ba(a.p,16),this.red=a.prime?Ba.red(a.prime):Ba.mont(this.p),this.zero=new Ba(0).toRed(this.red),this.one=new Ba(1).toRed(this.red),this.two=new Ba(2).toRed(this.red),this.n=a.n&&new Ba(a.n,16),this.g=a.g&&this.pointFromJSON(a.g,a.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Na=Ia;function La(e,a){this.curve=e,this.type=a,this.precomputed=null}Ia.prototype.point=function(){throw new Error("Not implemented")},Ia.prototype.validate=function(){throw new Error("Not implemented")},Ia.prototype._fixedNafMul=function(e,a){Oa(e.precomputed);var t=e._getDoubles(),f=Ra(a,1,this._bitLength),n=(1<=d;a--)s=(s<<1)+f[a];b.push(s)}for(var i=this.jpoint(null,null,null),c=this.jpoint(null,null,null),r=n;r>0;r--){for(d=0;d=0;s--){for(a=0;s>=0&&0===b[s];s--)a++;if(s>=0&&a++,d=d.dblp(a),s<0)break;var i=b[s];Oa(0!==i),d="affine"===e.type?i>0?d.mixedAdd(n[i-1>>1]):d.mixedAdd(n[-i-1>>1].neg()):i>0?d.add(n[i-1>>1]):d.add(n[-i-1>>1].neg())}return"affine"===e.type?d.toP():d},Ia.prototype._wnafMulAdd=function(e,a,t,f,n){for(var b=this._wnafT1,d=this._wnafT2,s=this._wnafT3,i=0,c=0;c=1;c-=2){var u=c-1,o=c;if(1===b[u]&&1===b[o]){var p=[a[u],null,null,a[o]];0===a[u].y.cmp(a[o].y)?(p[1]=a[u].add(a[o]),p[2]=a[u].toJ().mixedAdd(a[o].neg())):0===a[u].y.cmp(a[o].y.redNeg())?(p[1]=a[u].toJ().mixedAdd(a[o]),p[2]=a[u].add(a[o].neg())):(p[1]=a[u].toJ().mixedAdd(a[o]),p[2]=a[u].toJ().mixedAdd(a[o].neg()));var l=[-3,-1,-5,-7,0,7,5,1,3],y=Pa(t[u],t[o]);i=Math.max(y[0].length,i),s[u]=new Array(i),s[o]=new Array(i);for(var m=0;m=0;c--){for(var T=0;c>=0;){var w=!0;for(m=0;m=0&&T++,g=g.dblp(T),c<0)break;for(m=0;m0?E=d[m][A-1>>1]:A<0&&(E=d[m][-A-1>>1].neg()),g="affine"===E.type?g.mixedAdd(E):g.add(E))}}for(c=0;c=Math.ceil((e.bitLength()+1)/a.step)},La.prototype._getDoubles=function(e,a){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var t=[this],f=this,n=0;n=0&&(b=a,d=t),f.negative&&(f=f.neg(),n=n.neg()),b.negative&&(b=b.neg(),d=d.neg()),[{a:f,b:n},{a:b,b:d}]},Xa.prototype._endoSplit=function(e){var a=this.endo.basis,t=a[0],f=a[1],n=f.b.mul(e).divRound(this.n),b=t.b.neg().mul(e).divRound(this.n),d=n.mul(t.a),s=b.mul(f.a),i=n.mul(t.b),c=b.mul(f.b);return{k1:e.sub(d).sub(s),k2:i.add(c).neg()}},Xa.prototype.pointFromX=function(e,a){(e=new Ba(e,16)).red||(e=e.toRed(this.red));var t=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),f=t.redSqrt();if(0!==f.redSqr().redSub(t).cmp(this.zero))throw new Error("invalid point");var n=f.fromRed().isOdd();return(a&&!n||!a&&n)&&(f=f.redNeg()),this.point(e,f)},Xa.prototype.validate=function(e){if(e.inf)return!0;var a=e.x,t=e.y,f=this.a.redMul(a),n=a.redSqr().redMul(a).redIAdd(f).redIAdd(this.b);return 0===t.redSqr().redISub(n).cmpn(0)},Xa.prototype._endoWnafMulAdd=function(e,a,t){for(var f=this._endoWnafT1,n=this._endoWnafT2,b=0;b":""},Za.prototype.isInfinity=function(){return this.inf},Za.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var a=this.y.redSub(e.y);0!==a.cmpn(0)&&(a=a.redMul(this.x.redSub(e.x).redInvm()));var t=a.redSqr().redISub(this.x).redISub(e.x),f=a.redMul(this.x.redSub(t)).redISub(this.y);return this.curve.point(t,f)},Za.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var a=this.curve.a,t=this.x.redSqr(),f=e.redInvm(),n=t.redAdd(t).redIAdd(t).redIAdd(a).redMul(f),b=n.redSqr().redISub(this.x.redAdd(this.x)),d=n.redMul(this.x.redSub(b)).redISub(this.y);return this.curve.point(b,d)},Za.prototype.getX=function(){return this.x.fromRed()},Za.prototype.getY=function(){return this.y.fromRed()},Za.prototype.mul=function(e){return e=new Ba(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},Za.prototype.mulAdd=function(e,a,t){var f=[this,a],n=[e,t];return this.curve.endo?this.curve._endoWnafMulAdd(f,n):this.curve._wnafMulAdd(1,f,n,2)},Za.prototype.jmulAdd=function(e,a,t){var f=[this,a],n=[e,t];return this.curve.endo?this.curve._endoWnafMulAdd(f,n,!0):this.curve._wnafMulAdd(1,f,n,2,!0)},Za.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},Za.prototype.neg=function(e){if(this.inf)return this;var a=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var t=this.precomputed,f=function(e){return e.neg()};a.precomputed={naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(f)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(f)}}}return a},Za.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},de(Va,Na.BasePoint),Xa.prototype.jpoint=function(e,a,t){return new Va(this,e,a,t)},Va.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),a=e.redSqr(),t=this.x.redMul(a),f=this.y.redMul(a).redMul(e);return this.curve.point(t,f)},Va.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Va.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var a=e.z.redSqr(),t=this.z.redSqr(),f=this.x.redMul(a),n=e.x.redMul(t),b=this.y.redMul(a.redMul(e.z)),d=e.y.redMul(t.redMul(this.z)),s=f.redSub(n),i=b.redSub(d);if(0===s.cmpn(0))return 0!==i.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),r=c.redMul(s),u=f.redMul(c),o=i.redSqr().redIAdd(r).redISub(u).redISub(u),p=i.redMul(u.redISub(o)).redISub(b.redMul(r)),l=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(o,p,l)},Va.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var a=this.z.redSqr(),t=this.x,f=e.x.redMul(a),n=this.y,b=e.y.redMul(a).redMul(this.z),d=t.redSub(f),s=n.redSub(b);if(0===d.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var i=d.redSqr(),c=i.redMul(d),r=t.redMul(i),u=s.redSqr().redIAdd(c).redISub(r).redISub(r),o=s.redMul(r.redISub(u)).redISub(n.redMul(c)),p=this.z.redMul(d);return this.curve.jpoint(u,o,p)},Va.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var a=this,t=0;t=0)return!1;if(t.redIAdd(n),0===this.x.cmp(t))return!0}},Va.prototype.inspect=function(){return this.isInfinity()?"":""},Va.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var qa={},Ha={},za=d((function(e,a){var t=a;t.base=Na,t.short=Ka,t.mont=qa,t.edwards=Ha})),ja=d((function(e,a){var t,f=a,n=_a.assert;function b(e){"short"===e.type?this.curve=new za.short(e):"edwards"===e.type?this.curve=new za.edwards(e):this.curve=new za.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,n(this.g.validate(),"Invalid curve"),n(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function d(e,a){Object.defineProperty(f,e,{configurable:!0,enumerable:!0,get:function(){var t=new b(a);return Object.defineProperty(f,e,{configurable:!0,enumerable:!0,value:t}),t}})}f.PresetCurve=b,d("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Ea.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),d("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Ea.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),d("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Ea.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),d("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Ea.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),d("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Ea.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),d("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Ea.sha256,gRed:!1,g:["9"]}),d("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Ea.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{t=void 0}catch(e){t=void 0}d("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Ea.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",t]})}));function Ga(e){if(!(this instanceof Ga))return new Ga(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var a=Fa.toArray(e.entropy,e.entropyEnc||"hex"),t=Fa.toArray(e.nonce,e.nonceEnc||"hex"),f=Fa.toArray(e.pers,e.persEnc||"hex");ne(a.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(a,t,f)}var Wa=Ga;Ga.prototype._init=function(e,a,t){var f=e.concat(a).concat(t);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var n=0;n=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(t||[])),this._reseed=1},Ga.prototype.generate=function(e,a,t,f){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof a&&(f=t,t=a,a=null),t&&(t=Fa.toArray(t,f||"hex"),this._update(t));for(var n=[];n.length"};var Qa=_a.assert;function et(e,a){if(e instanceof et)return e;this._importDER(e,a)||(Qa(e.r&&e.s,"Signature without r or s"),this.r=new Ba(e.r,16),this.s=new Ba(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}var at=et;function tt(){this.place=0}function ft(e,a){var t=e[a.place++];if(!(128&t))return t;var f=15&t;if(0===f||f>4)return!1;for(var n=0,b=0,d=a.place;b>>=0;return!(n<=127)&&(a.place=d,n)}function nt(e){for(var a=0,t=e.length-1;!e[a]&&!(128&e[a+1])&&a>>3);for(e.push(128|t);--t;)e.push(a>>>(t<<3)&255);e.push(a)}}et.prototype._importDER=function(e,a){e=_a.toArray(e,a);var t=new tt;if(48!==e[t.place++])return!1;var f=ft(e,t);if(!1===f)return!1;if(f+t.place!==e.length)return!1;if(2!==e[t.place++])return!1;var n=ft(e,t);if(!1===n)return!1;var b=e.slice(t.place,n+t.place);if(t.place+=n,2!==e[t.place++])return!1;var d=ft(e,t);if(!1===d)return!1;if(e.length!==d+t.place)return!1;var s=e.slice(t.place,d+t.place);if(0===b[0]){if(!(128&b[1]))return!1;b=b.slice(1)}if(0===s[0]){if(!(128&s[1]))return!1;s=s.slice(1)}return this.r=new Ba(b),this.s=new Ba(s),this.recoveryParam=null,!0},et.prototype.toDER=function(e){var a=this.r.toArray(),t=this.s.toArray();for(128&a[0]&&(a=[0].concat(a)),128&t[0]&&(t=[0].concat(t)),a=nt(a),t=nt(t);!(t[0]||128&t[1]);)t=t.slice(1);var f=[2];bt(f,a.length),(f=f.concat(a)).push(2),bt(f,t.length);var n=f.concat(t),b=[48];return bt(b,n.length),b=b.concat(n),_a.encode(b,e)};var dt=_a.assert;function st(e){if(!(this instanceof st))return new st(e);"string"==typeof e&&(dt(ja.hasOwnProperty(e),"Unknown curve "+e),e=ja[e]),e instanceof ja.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}var it=st;st.prototype.keyPair=function(e){return new Ya(this,e)},st.prototype.keyFromPrivate=function(e,a){return Ya.fromPrivate(this,e,a)},st.prototype.keyFromPublic=function(e,a){return Ya.fromPublic(this,e,a)},st.prototype.genKeyPair=function(e){e||(e={});for(var a=new Wa({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||ka(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),t=this.n.byteLength(),f=this.n.sub(new Ba(2));;){var n=new Ba(a.generate(t));if(!(n.cmp(f)>0))return n.iaddn(1),this.keyFromPrivate(n)}},st.prototype._truncateToN=function(e,a){var t=8*e.byteLength()-this.n.bitLength();return t>0&&(e=e.ushrn(t)),!a&&e.cmp(this.n)>=0?e.sub(this.n):e},st.prototype.sign=function(e,a,t,f){"object"==typeof t&&(f=t,t=null),f||(f={}),a=this.keyFromPrivate(a,t),e=this._truncateToN(new Ba(e,16));for(var n=this.n.byteLength(),b=a.getPrivate().toArray("be",n),d=e.toArray("be",n),s=new Wa({hash:this.hash,entropy:b,nonce:d,pers:f.pers,persEnc:f.persEnc||"utf8"}),i=this.n.sub(new Ba(1)),c=0;;c++){var r=f.k?f.k(c):new Ba(s.generate(this.n.byteLength()));if(!((r=this._truncateToN(r,!0)).cmpn(1)<=0||r.cmp(i)>=0)){var u=this.g.mul(r);if(!u.isInfinity()){var o=u.getX(),p=o.umod(this.n);if(0!==p.cmpn(0)){var l=r.invm(this.n).mul(p.mul(a.getPrivate()).iadd(e));if(0!==(l=l.umod(this.n)).cmpn(0)){var y=(u.getY().isOdd()?1:0)|(0!==o.cmp(p)?2:0);return f.canonical&&l.cmp(this.nh)>0&&(l=this.n.sub(l),y^=1),new at({r:p,s:l,recoveryParam:y})}}}}}},st.prototype.verify=function(e,a,t,f){e=this._truncateToN(new Ba(e,16)),t=this.keyFromPublic(t,f);var n=(a=new at(a,"hex")).r,b=a.s;if(n.cmpn(1)<0||n.cmp(this.n)>=0)return!1;if(b.cmpn(1)<0||b.cmp(this.n)>=0)return!1;var d,s=b.invm(this.n),i=s.mul(e).umod(this.n),c=s.mul(n).umod(this.n);return this.curve._maxwellTrick?!(d=this.g.jmulAdd(i,t.getPublic(),c)).isInfinity()&&d.eqXToP(n):!(d=this.g.mulAdd(i,t.getPublic(),c)).isInfinity()&&0===d.getX().umod(this.n).cmp(n)},st.prototype.recoverPubKey=function(e,a,t,f){dt((3&t)===t,"The recovery param is more than two bits"),a=new at(a,f);var n=this.n,b=new Ba(e),d=a.r,s=a.s,i=1&t,c=t>>1;if(d.cmp(this.curve.p.umod(this.curve.n))>=0&&c)throw new Error("Unable to find sencond key candinate");d=c?this.curve.pointFromX(d.add(this.curve.n),i):this.curve.pointFromX(d,i);var r=a.r.invm(n),u=n.sub(b).mul(r).umod(n),o=s.mul(r).umod(n);return this.g.mulAdd(u,d,o)},st.prototype.getKeyRecoveryParam=function(e,a,t,f){if(null!==(a=new at(a,f)).recoveryParam)return a.recoveryParam;for(var n=0;n<4;n++){var b;try{b=this.recoverPubKey(e,a,n)}catch(e){continue}if(b.eq(t))return n}throw new Error("Unable to find valid recovery factor")};var ct={},rt=s(Sa),ut=d((function(e,a){var t=a;t.version=rt.version,t.utils=_a,t.rand=ka,t.curve=za,t.curves=ja,t.ec=it,t.eddsa=ct})),ot=(ut.ec,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.version="signing-key/5.0.3"}))),pt=(b(ot),ot.version,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0});var t=new o.Logger(ot.version),f=null;function n(){return f||(f=new ut.ec("secp256k1")),f}var b=function(){function e(e){v.defineReadOnly(this,"curve","secp256k1"),v.defineReadOnly(this,"privateKey",l.hexlify(e));var a=n().keyFromPrivate(l.arrayify(this.privateKey));v.defineReadOnly(this,"publicKey","0x"+a.getPublic(!1,"hex")),v.defineReadOnly(this,"compressedPublicKey","0x"+a.getPublic(!0,"hex")),v.defineReadOnly(this,"_isSigningKey",!0)}return e.prototype._addPoint=function(e){var a=n().keyFromPublic(l.arrayify(this.publicKey)),t=n().keyFromPublic(l.arrayify(e));return"0x"+a.pub.add(t.pub).encodeCompressed("hex")},e.prototype.signDigest=function(e){var a=n().keyFromPrivate(l.arrayify(this.privateKey)).sign(l.arrayify(e),{canonical:!0});return l.splitSignature({recoveryParam:a.recoveryParam,r:l.hexZeroPad("0x"+a.r.toString(16),32),s:l.hexZeroPad("0x"+a.s.toString(16),32)})},e.prototype.computeSharedSecret=function(e){var a=n().keyFromPrivate(l.arrayify(this.privateKey)),t=n().keyFromPublic(l.arrayify(d(e)));return l.hexZeroPad("0x"+a.derive(t.getPublic()).toString(16),32)},e.isSigningKey=function(e){return!(!e||!e._isSigningKey)},e}();function d(e,a){var f=l.arrayify(e);if(32===f.length){var d=new b(f);return a?"0x"+n().keyFromPrivate(f).getPublic(!0,"hex"):d.publicKey}return 33===f.length?a?l.hexlify(f):"0x"+n().keyFromPublic(f).getPublic(!1,"hex"):65===f.length?a?"0x"+n().keyFromPublic(f).getPublic(!0,"hex"):l.hexlify(f):t.throwArgumentError("invalid public or private key","key","[REDACTED]")}a.SigningKey=b,a.recoverPublicKey=function(e,a){var t=l.splitSignature(a),f={r:l.arrayify(t.r),s:l.arrayify(t.s)};return"0x"+n().recoverPubKey(l.arrayify(e),f,t.recoveryParam).encode("hex",!1)},a.computePublicKey=d}))),lt=(b(pt),pt.SigningKey,pt.recoverPublicKey,pt.computePublicKey,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.version="transactions/5.0.2"}))),yt=(b(lt),lt.version,d((function(e,a){var t=n&&n.__importStar||function(e){if(e&&e.__esModule)return e;var a={};if(null!=e)for(var t in e)Object.hasOwnProperty.call(e,t)&&(a[t]=e[t]);return a.default=e,a};Object.defineProperty(a,"__esModule",{value:!0});var f=t(D),b=new o.Logger(lt.version);function d(e){return"0x"===e?N.Zero:x.BigNumber.from(e)}var s=[{name:"nonce",maxLength:32,numeric:!0},{name:"gasPrice",maxLength:32,numeric:!0},{name:"gasLimit",maxLength:32,numeric:!0},{name:"to",length:20},{name:"value",maxLength:32,numeric:!0},{name:"data"}],i={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function c(e){var a=pt.computePublicKey(e);return B.getAddress(l.hexDataSlice(M.keccak256(l.hexDataSlice(a,1)),12))}function r(e,a){return c(pt.recoverPublicKey(l.arrayify(e),a))}a.computeAddress=c,a.recoverAddress=r,a.serialize=function(e,a){v.checkProperties(e,i);var t=[];s.forEach((function(a){var f=e[a.name]||[],n={};a.numeric&&(n.hexPad="left"),f=l.arrayify(l.hexlify(f,n)),a.length&&f.length!==a.length&&f.length>0&&b.throwArgumentError("invalid length for "+a.name,"transaction:"+a.name,f),a.maxLength&&(f=l.stripZeros(f)).length>a.maxLength&&b.throwArgumentError("invalid length for "+a.name,"transaction:"+a.name,f),t.push(l.hexlify(f))}));var n=0;if(null!=e.chainId?"number"!=typeof(n=e.chainId)&&b.throwArgumentError("invalid transaction.chainId","transaction",e):a&&!l.isBytesLike(a)&&a.v>28&&(n=Math.floor((a.v-35)/2)),0!==n&&(t.push(l.hexlify(n)),t.push("0x"),t.push("0x")),!a)return f.encode(t);var d=l.splitSignature(a),c=27+d.recoveryParam;return 0!==n?(t.pop(),t.pop(),t.pop(),c+=2*n+8,d.v>28&&d.v!==c&&b.throwArgumentError("transaction.chainId/signature.v mismatch","signature",a)):d.v!==c&&b.throwArgumentError("transaction.chainId/signature.v mismatch","signature",a),t.push(l.hexlify(c)),t.push(l.stripZeros(l.arrayify(d.r))),t.push(l.stripZeros(l.arrayify(d.s))),f.encode(t)},a.parse=function(e){var a=f.decode(e);9!==a.length&&6!==a.length&&b.throwArgumentError("invalid raw transaction","rawTransaction",e);var t,n={nonce:d(a[0]).toNumber(),gasPrice:d(a[1]),gasLimit:d(a[2]),to:(t=a[3],"0x"===t?null:B.getAddress(t)),value:d(a[4]),data:a[5],chainId:0};if(6===a.length)return n;try{n.v=x.BigNumber.from(a[6]).toNumber()}catch(e){return console.log(e),n}if(n.r=l.hexZeroPad(a[7],32),n.s=l.hexZeroPad(a[8],32),x.BigNumber.from(n.r).isZero()&&x.BigNumber.from(n.s).isZero())n.chainId=n.v,n.v=0;else{n.chainId=Math.floor((n.v-35)/2),n.chainId<0&&(n.chainId=0);var s=n.v-27,i=a.slice(0,6);0!==n.chainId&&(i.push(l.hexlify(n.chainId)),i.push("0x"),i.push("0x"),s-=2*n.chainId+8);var c=M.keccak256(f.encode(i));try{n.from=r(c,{r:l.hexlify(n.r),s:l.hexlify(n.s),recoveryParam:s})}catch(e){console.log(e)}n.hash=M.keccak256(e)}return n}}))),mt=(b(yt),yt.computeAddress,yt.recoverAddress,yt.serialize,yt.parse,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.version="wordlists/5.0.2"}))),ht=(b(mt),mt.version,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.logger=new o.Logger(mt.version);var t=function(){function e(t){var f=this.constructor;a.logger.checkAbstract(f,e),v.defineReadOnly(this,"locale",t)}return e.prototype.split=function(e){return e.toLowerCase().split(/ +/g)},e.prototype.join=function(e){return e.join(" ")},e.check=function(e){for(var a=[],t=0;t<2048;t++){var f=e.getWord(t);if(t!==e.getWordIndex(f))return"0x";a.push(f)}return G.id(a.join("\n")+"\n")},e.register=function(e,a){a||(a=e.locale)},e}();a.Wordlist=t}))),xt=(b(ht),ht.logger,ht.Wordlist,d((function(e,a){var t,f=n&&n.__extends||(t=function(e,a){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,a){e.__proto__=a}||function(e,a){for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])})(e,a)},function(e,a){function f(){this.constructor=e}t(e,a),e.prototype=null===a?Object.create(a):(f.prototype=a.prototype,new f)});Object.defineProperty(a,"__esModule",{value:!0});var b=null;function d(e){if(null==b&&(b="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo".replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),"0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"!==ht.Wordlist.check(e)))throw b=null,new Error("BIP39 Wordlist for en (English) FAILED")}var s=new(function(e){function a(){return e.call(this,"en")||this}return f(a,e),a.prototype.getWord=function(e){return d(this),b[e]},a.prototype.getWordIndex=function(e){return d(this),b.indexOf(e)},a}(ht.Wordlist));a.langEn=s,ht.Wordlist.register(s)}))),gt=(b(xt),xt.langEn,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.Wordlist=ht.Wordlist;var t={en:xt.langEn};a.wordlists=t}))),vt=(b(gt),gt.Wordlist,gt.wordlists,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.version="hdnode/5.0.2"}))),Tt=(b(vt),vt.version,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0});var t=new o.Logger(vt.version),f=x.BigNumber.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),n=V.toUtf8Bytes("Bitcoin seed");function b(e){return(1<=256)throw new Error("Depth too large!");return s(l.concat([null!=this.privateKey?"0x0488ADE4":"0x0488B21E",l.hexlify(this.depth),this.parentFingerprint,l.hexZeroPad(l.hexlify(this.index),4),this.chainCode,null!=this.privateKey?l.concat(["0x00",this.privateKey]):this.publicKey]))},enumerable:!0,configurable:!0}),e.prototype.neuter=function(){return new e(c,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,this.path)},e.prototype._derive=function(a){if(a>4294967295)throw new Error("invalid index - "+String(a));var t=this.path;t&&(t+="/"+(2147483647&a));var n=new Uint8Array(37);if(2147483648&a){if(!this.privateKey)throw new Error("cannot derive child of neutered node");n.set(l.arrayify(this.privateKey),1),t&&(t+="'")}else n.set(l.arrayify(this.publicKey));for(var b=24;b>=0;b-=8)n[33+(b>>3)]=a>>24-b&255;var s=l.arrayify(Ma.computeHmac(Ma.SupportedAlgorithm.sha512,this.chainCode,n)),i=s.slice(0,32),r=s.slice(32),u=null,o=null;this.privateKey?u=d(x.BigNumber.from(i).add(this.privateKey).mod(f)):o=new pt.SigningKey(l.hexlify(i))._addPoint(this.publicKey);var p=t,y=this.mnemonic;return y&&(p=Object.freeze({phrase:y.phrase,path:t,locale:y.locale||"en"})),new e(c,u,o,this.fingerprint,d(r),a,this.depth+1,p)},e.prototype.derivePath=function(e){var a=e.split("/");if(0===a.length||"m"===a[0]&&0!==this.depth)throw new Error("invalid path - "+e);"m"===a[0]&&a.shift();for(var t=this,f=0;f=2147483648)throw new Error("invalid path index - "+n);t=t._derive(2147483648+b)}else{if(!n.match(/^[0-9]+$/))throw new Error("invalid path component - "+n);var b;if((b=parseInt(n))>=2147483648)throw new Error("invalid path index - "+n);t=t._derive(b)}}return t},e._fromSeed=function(a,t){var f=l.arrayify(a);if(f.length<16||f.length>64)throw new Error("invalid seed");var b=l.arrayify(Ma.computeHmac(Ma.SupportedAlgorithm.sha512,n,f));return new e(c,d(b.slice(0,32)),null,"0x00000000",d(b.slice(32)),0,0,t)},e.fromMnemonic=function(a,t,f){return a=y(p(a,f=i(f)),f),e._fromSeed(u(a,t),{phrase:a,path:"m",locale:f.locale})},e.fromSeed=function(a){return e._fromSeed(a,null)},e.fromExtendedKey=function(a){var f=fe.Base58.decode(a);82===f.length&&s(f.slice(0,78))===a||t.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");var n=f[4],b=l.hexlify(f.slice(5,9)),d=parseInt(l.hexlify(f.slice(9,13)).substring(2),16),i=l.hexlify(f.slice(13,45)),r=f.slice(45,78);switch(l.hexlify(f.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new e(c,null,l.hexlify(r),b,i,d,n,null);case"0x0488ade4":case"0x04358394 ":if(0!==r[0])break;return new e(c,l.hexlify(r.slice(1)),null,b,i,d,n,null)}return t.throwArgumentError("invalid extended key","extendedKey","[REDACTED]")},e}();function u(e,a){a||(a="");var t=V.toUtf8Bytes("mnemonic"+a,V.UnicodeNormalizationForm.NFKD);return Ca.pbkdf2(V.toUtf8Bytes(e,V.UnicodeNormalizationForm.NFKD),t,2048,64,"sha512")}function p(e,a){a=i(a),t.checkNormalize();var f=a.split(e);if(f.length%3!=0)throw new Error("invalid mnemonic");for(var n=l.arrayify(new Uint8Array(Math.ceil(11*f.length/8))),d=0,s=0;s>3]|=1<<7-d%8),d++}var u=32*f.length/3,o=b(f.length/3);if((l.arrayify(Ma.sha256(n.slice(0,u/8)))[0]&o)!=(n[n.length-1]&o))throw new Error("invalid checksum");return l.hexlify(n.slice(0,u/8))}function y(e,a){if(a=i(a),(e=l.arrayify(e)).length%4!=0||e.length<16||e.length>32)throw new Error("invalid entropy");for(var t=[0],f=11,n=0;n8?(t[t.length-1]<<=8,t[t.length-1]|=e[n],f-=8):(t[t.length-1]<<=f,t[t.length-1]|=e[n]>>8-f,t.push(e[n]&(1<<8-f)-1),f+=3);var d=e.length/4,s=l.arrayify(Ma.sha256(e))[0]&b(d);return t[t.length-1]<<=d,t[t.length-1]|=s>>8-d,a.join(t.map((function(e){return a.getWord(e)})))}a.HDNode=r,a.mnemonicToSeed=u,a.mnemonicToEntropy=p,a.entropyToMnemonic=y,a.isValidMnemonic=function(e,a){try{return p(e,a),!0}catch(e){}return!1}}))),wt=(b(Tt),Tt.defaultPath,Tt.HDNode,Tt.mnemonicToSeed,Tt.mnemonicToEntropy,Tt.entropyToMnemonic,Tt.isValidMnemonic,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.version="random/5.0.2"}))),Et=(b(wt),wt.version,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.shuffled=function(e){for(var a=(e=e.slice()).length-1;a>0;a--){var t=Math.floor(Math.random()*(a+1)),f=e[a];e[a]=e[t],e[t]=f}return e}}))),At=(b(Et),Et.shuffled,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0});var t=new o.Logger(wt.version);a.shuffled=Et.shuffled;var f=null;try{if(null==(f=window))throw new Error("try next")}catch(e){try{if(null==(f=n))throw new Error("try next")}catch(e){f={}}}var b=f.crypto||f.msCrypto;b&&b.getRandomValues||(t.warn("WARNING: Missing strong random number source"),b={getRandomValues:function(e){return t.throwError("no secure random source avaialble",o.Logger.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}}),a.randomBytes=function(e){(e<=0||e>1024||e%1)&&t.throwArgumentError("invalid length","length",e);var a=new Uint8Array(e);return b.getRandomValues(a),l.arrayify(a)}}))),Mt=(b(At),At.shuffled,At.randomBytes,d((function(e,a){!function(a){function t(e){return parseInt(e)===e}function f(e){if(!t(e.length))return!1;for(var a=0;a255)return!1;return!0}function n(e,a){if(e.buffer&&ArrayBuffer.isView(e)&&"Uint8Array"===e.name)return a&&(e=e.slice?e.slice():Array.prototype.slice.call(e)),e;if(Array.isArray(e)){if(!f(e))throw new Error("Array contains invalid value: "+e);return new Uint8Array(e)}if(t(e.length)&&f(e))return new Uint8Array(e);throw new Error("unsupported array-like object")}function b(e){return new Uint8Array(e)}function d(e,a,t,f,n){null==f&&null==n||(e=e.slice?e.slice(f,n):Array.prototype.slice.call(e,f,n)),a.set(e,t)}var s,i={toBytes:function(e){var a=[],t=0;for(e=encodeURI(e);t191&&f<224?(a.push(String.fromCharCode((31&f)<<6|63&e[t+1])),t+=2):(a.push(String.fromCharCode((15&f)<<12|(63&e[t+1])<<6|63&e[t+2])),t+=3)}return a.join("")}},c=(s="0123456789abcdef",{toBytes:function(e){for(var a=[],t=0;t>4]+s[15&f])}return a.join("")}}),r={16:10,24:12,32:14},u=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],o=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],p=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],l=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],y=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],m=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],h=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],x=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],g=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],v=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],T=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],w=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],E=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],A=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],M=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function C(e){for(var a=[],t=0;t>2,this._Ke[t][a%4]=b[a],this._Kd[e-t][a%4]=b[a];for(var d,s=0,i=n;i>16&255]<<24^o[d>>8&255]<<16^o[255&d]<<8^o[d>>24&255]^u[s]<<24,s+=1,8!=n)for(a=1;a>8&255]<<8^o[d>>16&255]<<16^o[d>>24&255]<<24,a=n/2+1;a>2,p=i%4,this._Ke[c][p]=b[a],this._Kd[e-c][p]=b[a++],i++}for(var c=1;c>24&255]^E[d>>16&255]^A[d>>8&255]^M[255&d]},D.prototype.encrypt=function(e){if(16!=e.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var a=this._Ke.length-1,t=[0,0,0,0],f=C(e),n=0;n<4;n++)f[n]^=this._Ke[0][n];for(var d=1;d>24&255]^y[f[(n+1)%4]>>16&255]^m[f[(n+2)%4]>>8&255]^h[255&f[(n+3)%4]]^this._Ke[d][n];f=t.slice()}var s,i=b(16);for(n=0;n<4;n++)s=this._Ke[a][n],i[4*n]=255&(o[f[n]>>24&255]^s>>24),i[4*n+1]=255&(o[f[(n+1)%4]>>16&255]^s>>16),i[4*n+2]=255&(o[f[(n+2)%4]>>8&255]^s>>8),i[4*n+3]=255&(o[255&f[(n+3)%4]]^s);return i},D.prototype.decrypt=function(e){if(16!=e.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var a=this._Kd.length-1,t=[0,0,0,0],f=C(e),n=0;n<4;n++)f[n]^=this._Kd[0][n];for(var d=1;d>24&255]^g[f[(n+3)%4]>>16&255]^v[f[(n+2)%4]>>8&255]^T[255&f[(n+1)%4]]^this._Kd[d][n];f=t.slice()}var s,i=b(16);for(n=0;n<4;n++)s=this._Kd[a][n],i[4*n]=255&(p[f[n]>>24&255]^s>>24),i[4*n+1]=255&(p[f[(n+3)%4]>>16&255]^s>>16),i[4*n+2]=255&(p[f[(n+2)%4]>>8&255]^s>>8),i[4*n+3]=255&(p[255&f[(n+1)%4]]^s);return i};var S=function(e){if(!(this instanceof S))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new D(e)};S.prototype.encrypt=function(e){if((e=n(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var a=b(e.length),t=b(16),f=0;f=0;--a)this._counter[a]=e%256,e>>=8},k.prototype.setBytes=function(e){if(16!=(e=n(e,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=e},k.prototype.increment=function(){for(var e=15;e>=0;e--){if(255!==this._counter[e]){this._counter[e]++;break}this._counter[e]=0}};var R=function(e,a){if(!(this instanceof R))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",a instanceof k||(a=new k(a)),this._counter=a,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new D(e)};R.prototype.encrypt=function(e){for(var a=n(e,!0),t=0;t16)throw new Error("PKCS#7 padding byte out of range");for(var t=e.length-a,f=0;f=64;){let p,l,y,m,h,x=t,g=f,v=n,T=b,w=d,E=s,A=i,M=c;for(l=0;l<16;l++)y=u+4*l,r[l]=(255&e[y])<<24|(255&e[y+1])<<16|(255&e[y+2])<<8|255&e[y+3];for(l=16;l<64;l++)p=r[l-2],m=(p>>>17|p<<15)^(p>>>19|p<<13)^p>>>10,p=r[l-15],h=(p>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,r[l]=(m+r[l-7]|0)+(h+r[l-16]|0)|0;for(l=0;l<64;l++)m=(((w>>>6|w<<26)^(w>>>11|w<<21)^(w>>>25|w<<7))+(w&E^~w&A)|0)+(M+(a[l]+r[l]|0)|0)|0,h=((x>>>2|x<<30)^(x>>>13|x<<19)^(x>>>22|x<<10))+(x&g^x&v^g&v)|0,M=A,A=E,E=w,w=T+m|0,T=v,v=g,g=x,x=m+h|0;t=t+x|0,f=f+g|0,n=n+v|0,b=b+T|0,d=d+w|0,s=s+E|0,i=i+A|0,c=c+M|0,u+=64,o-=64}}u(e);let o,p=e.length%64,l=e.length/536870912|0,y=e.length<<3,m=p<56?56:120,h=e.slice(e.length-p,e.length);for(h.push(128),o=p+1;o>>24&255),h.push(l>>>16&255),h.push(l>>>8&255),h.push(l>>>0&255),h.push(y>>>24&255),h.push(y>>>16&255),h.push(y>>>8&255),h.push(y>>>0&255),u(h),[t>>>24&255,t>>>16&255,t>>>8&255,t>>>0&255,f>>>24&255,f>>>16&255,f>>>8&255,f>>>0&255,n>>>24&255,n>>>16&255,n>>>8&255,n>>>0&255,b>>>24&255,b>>>16&255,b>>>8&255,b>>>0&255,d>>>24&255,d>>>16&255,d>>>8&255,d>>>0&255,s>>>24&255,s>>>16&255,s>>>8&255,s>>>0&255,i>>>24&255,i>>>16&255,i>>>8&255,i>>>0&255,c>>>24&255,c>>>16&255,c>>>8&255,c>>>0&255]}function n(e,a,f){e=e.length<=64?e:t(e);const n=64+a.length+4,b=new Array(n),d=new Array(64);let s,i=[];for(s=0;s<64;s++)b[s]=54;for(s=0;s=n-4;e--){if(b[e]++,b[e]<=255)return;b[e]=0}}for(;f>=32;)c(),i=i.concat(t(d.concat(t(b)))),f-=32;return f>0&&(c(),i=i.concat(t(d.concat(t(b))).slice(0,f))),i}function b(e,a,t,f,n){let b;for(c(e,16*(2*t-1),n,0,16),b=0;b<2*t;b++)i(e,16*b,n,16),s(n,f),c(n,0,e,a+16*b,16);for(b=0;b>>32-a}function s(e,a){c(e,0,a,0,16);for(let e=8;e>0;e-=2)a[4]^=d(a[0]+a[12],7),a[8]^=d(a[4]+a[0],9),a[12]^=d(a[8]+a[4],13),a[0]^=d(a[12]+a[8],18),a[9]^=d(a[5]+a[1],7),a[13]^=d(a[9]+a[5],9),a[1]^=d(a[13]+a[9],13),a[5]^=d(a[1]+a[13],18),a[14]^=d(a[10]+a[6],7),a[2]^=d(a[14]+a[10],9),a[6]^=d(a[2]+a[14],13),a[10]^=d(a[6]+a[2],18),a[3]^=d(a[15]+a[11],7),a[7]^=d(a[3]+a[15],9),a[11]^=d(a[7]+a[3],13),a[15]^=d(a[11]+a[7],18),a[1]^=d(a[0]+a[3],7),a[2]^=d(a[1]+a[0],9),a[3]^=d(a[2]+a[1],13),a[0]^=d(a[3]+a[2],18),a[6]^=d(a[5]+a[4],7),a[7]^=d(a[6]+a[5],9),a[4]^=d(a[7]+a[6],13),a[5]^=d(a[4]+a[7],18),a[11]^=d(a[10]+a[9],7),a[8]^=d(a[11]+a[10],9),a[9]^=d(a[8]+a[11],13),a[10]^=d(a[9]+a[8],18),a[12]^=d(a[15]+a[14],7),a[13]^=d(a[12]+a[15],9),a[14]^=d(a[13]+a[12],13),a[15]^=d(a[14]+a[13],18);for(let t=0;t<16;++t)e[t]+=a[t]}function i(e,a,t,f){for(let n=0;n=256)return!1}return!0}function u(e,a){if("number"!=typeof e||e%1)throw new Error("invalid "+a);return e}function o(e,a,t,d,s,o,p){if(t=u(t,"N"),d=u(d,"r"),s=u(s,"p"),o=u(o,"dkLen"),0===t||0!=(t&t-1))throw new Error("N must be power of 2");if(t>2147483647/128/d)throw new Error("N too large");if(d>2147483647/128/s)throw new Error("r too large");if(!r(e))throw new Error("password must be an array or buffer");if(e=Array.prototype.slice.call(e),!r(a))throw new Error("salt must be an array or buffer");a=Array.prototype.slice.call(a);let l=n(e,a,128*s*d);const y=new Uint32Array(32*s*d);for(let e=0;eB&&(a=B);for(let e=0;eB&&(a=B);for(let e=0;e>0&255),l.push(y[e]>>8&255),l.push(y[e]>>16&255),l.push(y[e]>>24&255);const f=n(e,l,o);return p&&p(null,1,f),f}p&&F(_)};if(!p)for(;;){const e=_();if(null!=e)return e}_()}const p={scrypt:function(e,a,t,f,n,b,d){return new Promise((function(s,i){let c=0;d&&d(0),o(e,a,t,f,n,b,(function(e,a,t){if(e)i(e);else if(t)d&&1!==c&&d(1),s(new Uint8Array(t));else if(d&&a!==c)return c=a,d(a)}))}))},syncScrypt:function(e,a,t,f,n,b){return new Uint8Array(o(e,a,t,f,n,b))}};e.exports=p}()}))),_t=(Ft.scrypt,Ft.syncScrypt,d((function(e,a){var t,f=n&&n.__extends||(t=function(e,a){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,a){e.__proto__=a}||function(e,a){for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])})(e,a)},function(e,a){function f(){this.constructor=e}t(e,a),e.prototype=null===a?Object.create(a):(f.prototype=a.prototype,new f)}),b=n&&n.__awaiter||function(e,a,t,f){return new(t||(t=Promise))((function(n,b){function d(e){try{i(f.next(e))}catch(e){b(e)}}function s(e){try{i(f.throw(e))}catch(e){b(e)}}function i(e){var a;e.done?n(e.value):(a=e.value,a instanceof t?a:new t((function(e){e(a)}))).then(d,s)}i((f=f.apply(e,a||[])).next())}))},d=n&&n.__generator||function(e,a){var t,f,n,b,d={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return b={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(b[Symbol.iterator]=function(){return this}),b;function s(b){return function(s){return function(b){if(t)throw new TypeError("Generator is already executing.");for(;d;)try{if(t=1,f&&(n=2&b[0]?f.return:b[0]?f.throw||((n=f.return)&&n.call(f),0):f.next)&&!(n=n.call(f,b[1])).done)return n;switch(f=0,n&&(b=[2&b[0],n.value]),b[0]){case 0:case 1:n=b;break;case 4:return d.label++,{value:b[1],done:!1};case 5:d.label++,f=b[1],b=[0];continue;case 7:b=d.ops.pop(),d.trys.pop();continue;default:if(!((n=(n=d.trys).length>0&&n[n.length-1])||6!==b[0]&&2!==b[0])){d=0;continue}if(3===b[0]&&(!n||b[1]>n[0]&&b[1]0&&n[n.length-1])||6!==b[0]&&2!==b[0])){d=0;continue}if(3===b[0]&&(!n||b[1]>n[0]&&b[1]0&&n[n.length-1])||6!==b[0]&&2!==b[0])){d=0;continue}if(3===b[0]&&(!n||b[1]>n[0]&&b[1]0&&s%1==0,"invalid connection throttle limit","connection.throttleLimit",s);var i="object"==typeof e?e.throttleCallback:null,c="object"==typeof e&&"number"==typeof e.throttleSlotInterval?e.throttleSlotInterval:100;b.assertArgument(c>0&&c%1==0,"invalid connection throttle slot interval","connection.throttleSlotInterval",c);var r={},u=null,p={method:"GET"},l=!1,y=12e4;if("string"==typeof e)u=e;else if("object"==typeof e){if(null!=e&&null!=e.url||b.throwArgumentError("missing URL","connection.url",e),u=e.url,"number"==typeof e.timeout&&e.timeout>0&&(y=e.timeout),e.headers)for(var m in e.headers)r[m.toLowerCase()]={key:m,value:String(e.headers[m])},["if-none-match","if-modified-since"].indexOf(m.toLowerCase())>=0&&(l=!0);if(null!=e.user&&null!=e.password){"https:"!==u.substring(0,6)&&!0!==e.allowInsecureAuthentication&&b.throwError("basic authentication requires a secure https url",o.Logger.errors.INVALID_ARGUMENT,{argument:"url",url:u,user:e.user,password:"[REDACTED]"});var h=e.user+":"+e.password;r.authorization={key:"Authorization",value:"Basic "+Nt.encode(V.toUtf8Bytes(h))}}}a&&(p.method="POST",p.body=a,r["content-type"]={key:"Content-Type",value:"application/json"});var x={};Object.keys(r).forEach((function(e){var a=r[e];x[a.key]=a.value})),p.headers=x;var g,v=(g=null,{promise:new Promise((function(e,a){y&&(g=setTimeout((function(){null!=g&&(g=null,a(b.makeError("timeout",o.Logger.errors.TIMEOUT,{requestBody:p.body||null,requestMethod:p.method,timeout:y,url:u})))}),y))})),cancel:function(){null!=g&&(clearTimeout(g),g=null)}}),T=function(){return t(this,void 0,void 0,(function(){var e,a,t,r,y,m,h,x;return f(this,(function(f){switch(f.label){case 0:e=0,f.label=1;case 1:if(!(e=300)&&(v.cancel(),b.throwError("bad response",o.Logger.errors.SERVER_ERROR,{status:a.statusCode,headers:a.headers,body:y,requestBody:p.body||null,requestMethod:p.method,url:u})),m=null,null!=y)try{m=JSON.parse(y)}catch(e){v.cancel(),b.throwError("invalid JSON",o.Logger.errors.SERVER_ERROR,{body:y,error:e,requestBody:p.body||null,requestMethod:p.method,url:u})}if(!n)return[3,17];f.label=10;case 10:return f.trys.push([10,12,,17]),[4,n(m,a)];case 11:return m=f.sent(),[3,17];case 12:return(h=f.sent()).throttleRetry&&es)return void(d()&&f(new Error("retry limit reached")));var c=a.interval*parseInt(String(Math.random()*Math.pow(2,i)));ca.ceiling&&(c=a.ceiling),setTimeout(n,c)}return null}),(function(e){d()&&f(e)}))}()}))}}))),Kt=(b(Xt),Xt.fetchJson,Xt.poll,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.version="providers/5.0.5"}))),Zt=(b(Kt),Kt.version,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0});var t=new o.Logger(Kt.version),f=function(){function e(){var a=this.constructor;t.checkNew(a,e),this.formats=this.getDefaultFormats()}return e.prototype.getDefaultFormats=function(){var a=this,t={},f=this.address.bind(this),n=this.bigNumber.bind(this),b=this.blockTag.bind(this),d=this.data.bind(this),s=this.hash.bind(this),i=this.hex.bind(this),c=this.number.bind(this);return t.transaction={hash:s,blockHash:e.allowNull(s,null),blockNumber:e.allowNull(c,null),transactionIndex:e.allowNull(c,null),confirmations:e.allowNull(c,null),from:f,gasPrice:n,gasLimit:n,to:e.allowNull(f,null),value:n,nonce:c,data:d,r:e.allowNull(this.uint256),s:e.allowNull(this.uint256),v:e.allowNull(c),creates:e.allowNull(f,null),raw:e.allowNull(d)},t.transactionRequest={from:e.allowNull(f),nonce:e.allowNull(c),gasLimit:e.allowNull(n),gasPrice:e.allowNull(n),to:e.allowNull(f),value:e.allowNull(n),data:e.allowNull((function(e){return a.data(e,!0)}))},t.receiptLog={transactionIndex:c,blockNumber:c,transactionHash:s,address:f,topics:e.arrayOf(s),data:d,logIndex:c,blockHash:s},t.receipt={to:e.allowNull(this.address,null),from:e.allowNull(this.address,null),contractAddress:e.allowNull(f,null),transactionIndex:c,root:e.allowNull(s),gasUsed:n,logsBloom:e.allowNull(d),blockHash:s,transactionHash:s,logs:e.arrayOf(this.receiptLog.bind(this)),blockNumber:c,confirmations:e.allowNull(c,null),cumulativeGasUsed:n,status:e.allowNull(c)},t.block={hash:s,parentHash:s,number:c,timestamp:c,nonce:e.allowNull(i),difficulty:this.difficulty.bind(this),gasLimit:n,gasUsed:n,miner:f,extraData:d,transactions:e.allowNull(e.arrayOf(s))},t.blockWithTransactions=v.shallowCopy(t.block),t.blockWithTransactions.transactions=e.allowNull(e.arrayOf(this.transactionResponse.bind(this))),t.filter={fromBlock:e.allowNull(b,void 0),toBlock:e.allowNull(b,void 0),blockHash:e.allowNull(s,void 0),address:e.allowNull(f,void 0),topics:e.allowNull(this.topics.bind(this),void 0)},t.filterLog={blockNumber:e.allowNull(c),blockHash:e.allowNull(s),transactionIndex:c,removed:e.allowNull(this.boolean.bind(this)),address:f,data:e.allowFalsish(d,"0x"),topics:e.arrayOf(s),transactionHash:s,logIndex:c},t},e.prototype.number=function(e){return x.BigNumber.from(e).toNumber()},e.prototype.bigNumber=function(e){return x.BigNumber.from(e)},e.prototype.boolean=function(e){if("boolean"==typeof e)return e;if("string"==typeof e){if("true"===(e=e.toLowerCase()))return!0;if("false"===e)return!1}throw new Error("invalid boolean - "+e)},e.prototype.hex=function(e,a){return"string"==typeof e&&(a||"0x"===e.substring(0,2)||(e="0x"+e),l.isHexString(e))?e.toLowerCase():t.throwArgumentError("invalid hash","value",e)},e.prototype.data=function(e,a){var t=this.hex(e,a);if(t.length%2!=0)throw new Error("invalid data; odd-length - "+e);return t},e.prototype.address=function(e){return B.getAddress(e)},e.prototype.callAddress=function(e){if(!l.isHexString(e,32))return null;var a=B.getAddress(l.hexDataSlice(e,12));return a===N.AddressZero?null:a},e.prototype.contractAddress=function(e){return B.getContractAddress(e)},e.prototype.blockTag=function(e){if(null==e)return"latest";if("earliest"===e)return"0x0";if("latest"===e||"pending"===e)return e;if("number"==typeof e||l.isHexString(e))return l.hexValue(e);throw new Error("invalid blockTag")},e.prototype.hash=function(e,a){var f=this.hex(e,a);return 32!==l.hexDataLength(f)?t.throwArgumentError("invalid hash","value",e):f},e.prototype.difficulty=function(e){if(null==e)return null;var a=x.BigNumber.from(e);try{return a.toNumber()}catch(e){}return null},e.prototype.uint256=function(e){if(!l.isHexString(e))throw new Error("invalid uint256");return l.hexZeroPad(e,32)},e.prototype._block=function(a,t){return null!=a.author&&null==a.miner&&(a.miner=a.author),e.check(t,a)},e.prototype.block=function(e){return this._block(e,this.formats.block)},e.prototype.blockWithTransactions=function(e){return this._block(e,this.formats.blockWithTransactions)},e.prototype.transactionRequest=function(a){return e.check(this.formats.transactionRequest,a)},e.prototype.transactionResponse=function(a){null!=a.gas&&null==a.gasLimit&&(a.gasLimit=a.gas),a.to&&x.BigNumber.from(a.to).isZero()&&(a.to="0x0000000000000000000000000000000000000000"),null!=a.input&&null==a.data&&(a.data=a.input),null==a.to&&null==a.creates&&(a.creates=this.contractAddress(a));var t=e.check(this.formats.transaction,a);if(null!=a.chainId){var f=a.chainId;l.isHexString(f)&&(f=x.BigNumber.from(f).toNumber()),t.chainId=f}else null==(f=a.networkId)&&null==t.v&&(f=a.chainId),l.isHexString(f)&&(f=x.BigNumber.from(f).toNumber()),"number"!=typeof f&&null!=t.v&&((f=(t.v-35)/2)<0&&(f=0),f=parseInt(f)),"number"!=typeof f&&(f=0),t.chainId=f;return t.blockHash&&"x"===t.blockHash.replace(/0/g,"")&&(t.blockHash=null),t},e.prototype.transaction=function(e){return yt.parse(e)},e.prototype.receiptLog=function(a){return e.check(this.formats.receiptLog,a)},e.prototype.receipt=function(a){var t=e.check(this.formats.receipt,a);return null!=a.status&&(t.byzantium=!0),t},e.prototype.topics=function(e){var a=this;return Array.isArray(e)?e.map((function(e){return a.topics(e)})):null!=e?this.hash(e,!0):null},e.prototype.filter=function(a){return e.check(this.formats.filter,a)},e.prototype.filterLog=function(a){return e.check(this.formats.filterLog,a)},e.check=function(e,a){var t={};for(var f in e)try{var n=e[f](a[f]);void 0!==n&&(t[f]=n)}catch(e){throw e.checkKey=f,e.checkValue=a[f],e}return t},e.allowNull=function(e,a){return function(t){return null==t?a:e(t)}},e.allowFalsish=function(e,a){return function(t){return t?e(t):a}},e.arrayOf=function(e){return function(a){if(!Array.isArray(a))throw new Error("not an array");var t=[];return a.forEach((function(a){t.push(e(a))})),t}},e}();a.Formatter=f;var n=!1;a.showThrottleMessage=function(){n||(n=!0,console.log("========= NOTICE ========="),console.log("Request-Rate Exceeded (this message will not be repeated)"),console.log(""),console.log("The default API keys for each service are provided as a highly-throttled,"),console.log("community resource for low-traffic projects and early prototyping."),console.log(""),console.log("While your application will continue to function, we highly recommended"),console.log("signing up for your own API keys to improve performance, increase your"),console.log("request rate/limit and enable other perks, such as metrics and advanced APIs."),console.log(""),console.log("For more details: https://docs.ethers.io/api-keys/"),console.log("=========================="))}}))),Vt=(b(Zt),Zt.Formatter,Zt.showThrottleMessage,d((function(e,a){var t,f=n&&n.__extends||(t=function(e,a){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,a){e.__proto__=a}||function(e,a){for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])})(e,a)},function(e,a){function f(){this.constructor=e}t(e,a),e.prototype=null===a?Object.create(a):(f.prototype=a.prototype,new f)}),b=n&&n.__awaiter||function(e,a,t,f){return new(t||(t=Promise))((function(n,b){function d(e){try{i(f.next(e))}catch(e){b(e)}}function s(e){try{i(f.throw(e))}catch(e){b(e)}}function i(e){var a;e.done?n(e.value):(a=e.value,a instanceof t?a:new t((function(e){e(a)}))).then(d,s)}i((f=f.apply(e,a||[])).next())}))},d=n&&n.__generator||function(e,a){var t,f,n,b,d={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return b={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(b[Symbol.iterator]=function(){return this}),b;function s(b){return function(s){return function(b){if(t)throw new TypeError("Generator is already executing.");for(;d;)try{if(t=1,f&&(n=2&b[0]?f.return:b[0]?f.throw||((n=f.return)&&n.call(f),0):f.next)&&!(n=n.call(f,b[1])).done)return n;switch(f=0,n&&(b=[2&b[0],n.value]),b[0]){case 0:case 1:n=b;break;case 4:return d.label++,{value:b[1],done:!1};case 5:d.label++,f=b[1],b=[0];continue;case 7:b=d.ops.pop(),d.trys.pop();continue;default:if(!((n=(n=d.trys).length>0&&n[n.length-1])||6!==b[0]&&2!==b[0])){d=0;continue}if(3===b[0]&&(!n||b[1]>n[0]&&b[1]0&&null==e[e.length-1];)e.pop();return e.map((function(e){if(Array.isArray(e)){var a={};e.forEach((function(e){a[i(e)]=!0}));var t=Object.keys(a);return t.sort(),t.join("|")}return i(e)})).join("&")}function r(e){if("string"==typeof e){if(e=e.toLowerCase(),32===l.hexDataLength(e))return"tx:"+e;if(-1===e.indexOf(":"))return e}else{if(Array.isArray(e))return"filter:*:"+c(e);if(Y.ForkEvent.isForkEvent(e))throw s.warn("not implemented"),new Error("not implemented");if(e&&"object"==typeof e)return"filter:"+(e.address||"*")+":"+c(e.topics||[])}throw new Error("invalid event - "+e)}function u(){return(new Date).getTime()}var p=["block","network","pending","poll"],y=function(){function e(e,a,t){v.defineReadOnly(this,"tag",e),v.defineReadOnly(this,"listener",a),v.defineReadOnly(this,"once",t)}return Object.defineProperty(e.prototype,"event",{get:function(){switch(this.type){case"tx":return this.hash;case"filter":return this.filter}return this.tag},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"type",{get:function(){return this.tag.split(":")[0]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hash",{get:function(){var e=this.tag.split(":");return"tx"!==e[0]?null:e[1]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"filter",{get:function(){var e=this.tag.split(":");if("filter"!==e[0])return null;var a,t=e[1],f=""===(a=e[2])?[]:a.split(/&/g).map((function(e){if(""===e)return[];var a=e.split("|").map((function(e){return"null"===e?null:e}));return 1===a.length?a[0]:a})),n={};return f.length>0&&(n.topics=f),t&&"*"!==t&&(n.address=t),n},enumerable:!0,configurable:!0}),e.prototype.pollable=function(){return this.tag.indexOf(":")>=0||p.indexOf(this.tag)>=0},e}();a.Event=y;var m=null,h=1,g=function(e){function a(a){var t=this.constructor,f=this;if(s.checkNew(t,Y.Provider),(f=e.call(this)||this)._events=[],f._emitted={block:-2},f.formatter=t.getFormatter(),v.defineReadOnly(f,"anyNetwork","any"===a),f.anyNetwork&&(a=f.detectNetwork()),a instanceof Promise)f._networkPromise=a,a.catch((function(e){})),f._ready().catch((function(e){}));else{var n=v.getStatic(t,"getNetwork")(a);n?(v.defineReadOnly(f,"_network",n),f.emit("network",n,null)):s.throwArgumentError("invalid network","network",a)}return f._maxInternalBlockNumber=-1024,f._lastBlockNumber=-2,f._pollingInterval=4e3,f._fastQueryDate=0,f}return f(a,e),a.prototype._ready=function(){return b(this,void 0,void 0,(function(){var e;return d(this,(function(a){switch(a.label){case 0:if(null!=this._network)return[3,7];if(e=null,!this._networkPromise)return[3,4];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this._networkPromise];case 2:return e=a.sent(),[3,4];case 3:return a.sent(),[3,4];case 4:return null!=e?[3,6]:[4,this.detectNetwork()];case 5:e=a.sent(),a.label=6;case 6:e||s.throwError("no network detected",o.Logger.errors.UNKNOWN_ERROR,{}),null==this._network&&(this.anyNetwork?this._network=e:v.defineReadOnly(this,"_network",e),this.emit("network",e,null)),a.label=7;case 7:return[2,this._network]}}))}))},Object.defineProperty(a.prototype,"ready",{get:function(){var e=this;return Xt.poll((function(){return e._ready().then((function(e){return e}),(function(e){if(e.code!==o.Logger.errors.NETWORK_ERROR||"noNetwork"!==e.event)throw e}))}))},enumerable:!0,configurable:!0}),a.getFormatter=function(){return null==m&&(m=new Zt.Formatter),m},a.getNetwork=function(e){return It.getNetwork(null==e?"homestead":e)},a.prototype._getInternalBlockNumber=function(e){return b(this,void 0,void 0,(function(){var a,t,f,n,b=this;return d(this,(function(d){switch(d.label){case 0:return[4,this._ready()];case 1:return d.sent(),a=this._internalBlockNumber,e>0&&this._internalBlockNumber?[4,a]:[3,3];case 2:if(t=d.sent(),u()-t.respTime<=e)return[2,t.blockNumber];d.label=3;case 3:return f=u(),n=v.resolveProperties({blockNumber:this.perform("getBlockNumber",{}),networkError:this.getNetwork().then((function(e){return null}),(function(e){return e}))}).then((function(e){var a=e.blockNumber,t=e.networkError;if(t)throw b._internalBlockNumber===n&&(b._internalBlockNumber=null),t;var d=u();return(a=x.BigNumber.from(a).toNumber())1e3)s.warn("network block skew detected; skipping block events"),this.emit("error",s.makeError("network block skew detected",o.Logger.errors.NETWORK_ERROR,{blockNumber:t,event:"blockSkew",previousBlockNumber:this._emitted.block})),this.emit("block",t);else for(f=this._emitted.block+1;f<=t;f++)this.emit("block",f);return this._emitted.block!==t&&(this._emitted.block=t,Object.keys(this._emitted).forEach((function(e){if("block"!==e){var a=n._emitted[e];"pending"!==a&&t-a>12&&delete n._emitted[e]}}))),-2===this._lastBlockNumber&&(this._lastBlockNumber=t-1),this._events.forEach((function(e){switch(e.type){case"tx":var f=e.hash,b=n.getTransactionReceipt(f).then((function(e){return e&&null!=e.blockNumber?(n._emitted["t:"+f]=e.blockNumber,n.emit(f,e),null):null})).catch((function(e){n.emit("error",e)}));a.push(b);break;case"filter":var d=e.filter;d.fromBlock=n._lastBlockNumber+1,d.toBlock=t,b=n.getLogs(d).then((function(e){0!==e.length&&e.forEach((function(e){n._emitted["b:"+e.blockHash]=e.blockNumber,n._emitted["t:"+e.transactionHash]=e.blockNumber,n.emit(d,e)}))})).catch((function(e){n.emit("error",e)})),a.push(b)}})),this._lastBlockNumber=t,Promise.all(a).then((function(){n.emit("didPoll",e)})),[2,null]}}))}))},a.prototype.resetEventsBlock=function(e){this._lastBlockNumber=e-1,this.polling&&this.poll()},Object.defineProperty(a.prototype,"network",{get:function(){return this._network},enumerable:!0,configurable:!0}),a.prototype.detectNetwork=function(){return b(this,void 0,void 0,(function(){return d(this,(function(e){return[2,s.throwError("provider does not support network detection",o.Logger.errors.UNSUPPORTED_OPERATION,{operation:"provider.detectNetwork"})]}))}))},a.prototype.getNetwork=function(){return b(this,void 0,void 0,(function(){var e,a,t;return d(this,(function(f){switch(f.label){case 0:return[4,this._ready()];case 1:return e=f.sent(),[4,this.detectNetwork()];case 2:return a=f.sent(),e.chainId===a.chainId?[3,5]:this.anyNetwork?(this._network=a,this._lastBlockNumber=-2,this._fastBlockNumber=null,this._fastBlockNumberPromise=null,this._fastQueryDate=0,this._emitted.block=-2,this._maxInternalBlockNumber=-1024,this._internalBlockNumber=null,this.emit("network",a,e),[4,(n=0,new Promise((function(e){setTimeout(e,n)})))]):[3,4];case 3:return f.sent(),[2,this._network];case 4:throw t=s.makeError("underlying network changed",o.Logger.errors.NETWORK_ERROR,{event:"changed",network:e,detectedNetwork:a}),this.emit("error",t),t;case 5:return[2,e]}var n}))}))},Object.defineProperty(a.prototype,"blockNumber",{get:function(){var e=this;return this._getInternalBlockNumber(100+this.pollingInterval/2).then((function(a){e._setFastBlockNumber(a)})),null!=this._fastBlockNumber?this._fastBlockNumber:-1},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"polling",{get:function(){return null!=this._poller},set:function(e){var a=this;e&&!this._poller?(this._poller=setInterval(this.poll.bind(this),this.pollingInterval),this._bootstrapPoll||(this._bootstrapPoll=setTimeout((function(){a.poll(),a._bootstrapPoll=setTimeout((function(){a._poller||a.poll(),a._bootstrapPoll=null}),a.pollingInterval)}),0))):!e&&this._poller&&(clearInterval(this._poller),this._poller=null)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"pollingInterval",{get:function(){return this._pollingInterval},set:function(e){var a=this;if("number"!=typeof e||e<=0||parseInt(String(e))!=e)throw new Error("invalid polling interval");this._pollingInterval=e,this._poller&&(clearInterval(this._poller),this._poller=setInterval((function(){a.poll()}),this._pollingInterval))},enumerable:!0,configurable:!0}),a.prototype._getFastBlockNumber=function(){var e=this,a=u();return a-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=a,this._fastBlockNumberPromise=this.getBlockNumber().then((function(a){return(null==e._fastBlockNumber||a>e._fastBlockNumber)&&(e._fastBlockNumber=a),e._fastBlockNumber}))),this._fastBlockNumberPromise},a.prototype._setFastBlockNumber=function(e){null!=this._fastBlockNumber&&ethis._fastBlockNumber)&&(this._fastBlockNumber=e,this._fastBlockNumberPromise=Promise.resolve(e)))},a.prototype.waitForTransaction=function(e,a,t){return b(this,void 0,void 0,(function(){var f,n=this;return d(this,(function(b){switch(b.label){case 0:return null==a&&(a=1),[4,this.getTransactionReceipt(e)];case 1:return((f=b.sent())?f.confirmations:0)>=a?[2,f]:[2,new Promise((function(f,b){var d=null,i=!1,c=function(t){t.confirmations0&&(d=setTimeout((function(){i||(d=null,i=!0,n.removeListener(e,c),b(s.makeError("timeout exceeded",o.Logger.errors.TIMEOUT,{timeout:t})))}),t)).unref&&d.unref()}))]}}))}))},a.prototype.getBlockNumber=function(){return b(this,void 0,void 0,(function(){return d(this,(function(e){return[2,this._getInternalBlockNumber(0)]}))}))},a.prototype.getGasPrice=function(){return b(this,void 0,void 0,(function(){var e,a;return d(this,(function(t){switch(t.label){case 0:return[4,this.getNetwork()];case 1:return t.sent(),a=(e=x.BigNumber).from,[4,this.perform("getGasPrice",{})];case 2:return[2,a.apply(e,[t.sent()])]}}))}))},a.prototype.getBalance=function(e,a){return b(this,void 0,void 0,(function(){var t,f,n;return d(this,(function(b){switch(b.label){case 0:return[4,this.getNetwork()];case 1:return b.sent(),[4,v.resolveProperties({address:this._getAddress(e),blockTag:this._getBlockTag(a)})];case 2:return t=b.sent(),n=(f=x.BigNumber).from,[4,this.perform("getBalance",t)];case 3:return[2,n.apply(f,[b.sent()])]}}))}))},a.prototype.getTransactionCount=function(e,a){return b(this,void 0,void 0,(function(){var t,f,n;return d(this,(function(b){switch(b.label){case 0:return[4,this.getNetwork()];case 1:return b.sent(),[4,v.resolveProperties({address:this._getAddress(e),blockTag:this._getBlockTag(a)})];case 2:return t=b.sent(),n=(f=x.BigNumber).from,[4,this.perform("getTransactionCount",t)];case 3:return[2,n.apply(f,[b.sent()]).toNumber()]}}))}))},a.prototype.getCode=function(e,a){return b(this,void 0,void 0,(function(){var t,f;return d(this,(function(n){switch(n.label){case 0:return[4,this.getNetwork()];case 1:return n.sent(),[4,v.resolveProperties({address:this._getAddress(e),blockTag:this._getBlockTag(a)})];case 2:return t=n.sent(),f=l.hexlify,[4,this.perform("getCode",t)];case 3:return[2,f.apply(void 0,[n.sent()])]}}))}))},a.prototype.getStorageAt=function(e,a,t){return b(this,void 0,void 0,(function(){var f,n;return d(this,(function(b){switch(b.label){case 0:return[4,this.getNetwork()];case 1:return b.sent(),[4,v.resolveProperties({address:this._getAddress(e),blockTag:this._getBlockTag(t),position:Promise.resolve(a).then((function(e){return l.hexValue(e)}))})];case 2:return f=b.sent(),n=l.hexlify,[4,this.perform("getStorageAt",f)];case 3:return[2,n.apply(void 0,[b.sent()])]}}))}))},a.prototype._wrapTransaction=function(e,a){var t=this;if(null!=a&&32!==l.hexDataLength(a))throw new Error("invalid response - sendTransaction");var f=e;return null!=a&&e.hash!==a&&s.throwError("Transaction hash mismatch from Provider.sendTransaction.",o.Logger.errors.UNKNOWN_ERROR,{expectedHash:e.hash,returnedHash:a}),f.wait=function(a){return b(t,void 0,void 0,(function(){var t;return d(this,(function(f){switch(f.label){case 0:return 0!==a&&(this._emitted["t:"+e.hash]="pending"),[4,this.waitForTransaction(e.hash,a)];case 1:return null==(t=f.sent())&&0===a?[2,null]:(this._emitted["t:"+e.hash]=t.blockNumber,0===t.status&&s.throwError("transaction failed",o.Logger.errors.CALL_EXCEPTION,{transactionHash:e.hash,transaction:e,receipt:t}),[2,t])}}))}))},f},a.prototype.sendTransaction=function(e){return b(this,void 0,void 0,(function(){var a,t,f,n;return d(this,(function(b){switch(b.label){case 0:return[4,this.getNetwork()];case 1:return b.sent(),[4,Promise.resolve(e).then((function(e){return l.hexlify(e)}))];case 2:a=b.sent(),t=this.formatter.transaction(e),b.label=3;case 3:return b.trys.push([3,5,,6]),[4,this.perform("sendTransaction",{signedTransaction:a})];case 4:return f=b.sent(),[2,this._wrapTransaction(t,f)];case 5:throw(n=b.sent()).transaction=t,n.transactionHash=t.hash,n;case 6:return[2]}}))}))},a.prototype._getTransactionRequest=function(e){return b(this,void 0,void 0,(function(){var a,t,f,n,b=this;return d(this,(function(d){switch(d.label){case 0:return[4,e];case 1:return a=d.sent(),t={},["from","to"].forEach((function(e){null!=a[e]&&(t[e]=Promise.resolve(a[e]).then((function(e){return e?b._getAddress(e):null})))})),["gasLimit","gasPrice","value"].forEach((function(e){null!=a[e]&&(t[e]=Promise.resolve(a[e]).then((function(e){return e?x.BigNumber.from(e):null})))})),["data"].forEach((function(e){null!=a[e]&&(t[e]=Promise.resolve(a[e]).then((function(e){return e?l.hexlify(e):null})))})),n=(f=this.formatter).transactionRequest,[4,v.resolveProperties(t)];case 2:return[2,n.apply(f,[d.sent()])]}}))}))},a.prototype._getFilter=function(e){return b(this,void 0,void 0,(function(){var a,t,f,n=this;return d(this,(function(b){switch(b.label){case 0:return[4,e];case 1:return e=b.sent(),a={},null!=e.address&&(a.address=this._getAddress(e.address)),["blockHash","topics"].forEach((function(t){null!=e[t]&&(a[t]=e[t])})),["fromBlock","toBlock"].forEach((function(t){null!=e[t]&&(a[t]=n._getBlockTag(e[t]))})),f=(t=this.formatter).filter,[4,v.resolveProperties(a)];case 2:return[2,f.apply(t,[b.sent()])]}}))}))},a.prototype.call=function(e,a){return b(this,void 0,void 0,(function(){var t,f;return d(this,(function(n){switch(n.label){case 0:return[4,this.getNetwork()];case 1:return n.sent(),[4,v.resolveProperties({transaction:this._getTransactionRequest(e),blockTag:this._getBlockTag(a)})];case 2:return t=n.sent(),f=l.hexlify,[4,this.perform("call",t)];case 3:return[2,f.apply(void 0,[n.sent()])]}}))}))},a.prototype.estimateGas=function(e){return b(this,void 0,void 0,(function(){var a,t,f;return d(this,(function(n){switch(n.label){case 0:return[4,this.getNetwork()];case 1:return n.sent(),[4,v.resolveProperties({transaction:this._getTransactionRequest(e)})];case 2:return a=n.sent(),f=(t=x.BigNumber).from,[4,this.perform("estimateGas",a)];case 3:return[2,f.apply(t,[n.sent()])]}}))}))},a.prototype._getAddress=function(e){return b(this,void 0,void 0,(function(){var a;return d(this,(function(t){switch(t.label){case 0:return[4,this.resolveName(e)];case 1:return null==(a=t.sent())&&s.throwError("ENS name not configured",o.Logger.errors.UNSUPPORTED_OPERATION,{operation:"resolveName("+JSON.stringify(e)+")"}),[2,a]}}))}))},a.prototype._getBlock=function(e,a){return b(this,void 0,void 0,(function(){var t,f,n,i,c,r=this;return d(this,(function(u){switch(u.label){case 0:return[4,this.getNetwork()];case 1:return u.sent(),[4,e];case 2:return e=u.sent(),t=-128,f={includeTransactions:!!a},l.isHexString(e,32)?(f.blockHash=e,[3,6]):[3,3];case 3:return u.trys.push([3,5,,6]),n=f,c=(i=this.formatter).blockTag,[4,this._getBlockTag(e)];case 4:return n.blockTag=c.apply(i,[u.sent()]),l.isHexString(f.blockTag)&&(t=parseInt(f.blockTag.substring(2),16)),[3,6];case 5:return u.sent(),s.throwArgumentError("invalid block hash or block tag","blockHashOrBlockTag",e),[3,6];case 6:return[2,Xt.poll((function(){return b(r,void 0,void 0,(function(){var e,n,b,s,i;return d(this,(function(d){switch(d.label){case 0:return[4,this.perform("getBlock",f)];case 1:if(null==(e=d.sent()))return null!=f.blockHash&&null==this._emitted["b:"+f.blockHash]||null!=f.blockTag&&t>this._emitted.block?[2,null]:[2,void 0];if(!a)return[3,8];n=null,b=0,d.label=2;case 2:return bf.length?[2,null]:(s=V.toUtf8String(f.slice(0,b)),[4,this.resolveName(s)]));case 4:return d.sent()!=e?[2,null]:[2,s]}}))}))},a.prototype.perform=function(e,a){return s.throwError(e+" not implemented",o.Logger.errors.NOT_IMPLEMENTED,{operation:e})},a.prototype._startEvent=function(e){this.polling=this._events.filter((function(e){return e.pollable()})).length>0},a.prototype._stopEvent=function(e){this.polling=this._events.filter((function(e){return e.pollable()})).length>0},a.prototype._addEventListener=function(e,a,t){var f=new y(r(e),a,t);return this._events.push(f),this._startEvent(f),this},a.prototype.on=function(e,a){return this._addEventListener(e,a,!1)},a.prototype.once=function(e,a){return this._addEventListener(e,a,!0)},a.prototype.emit=function(e){for(var a=this,t=[],f=1;f0&&n[n.length-1])||6!==b[0]&&2!==b[0])){d=0;continue}if(3===b[0]&&(!n||b[1]>n[0]&&b[1]=0&&s.throwError("insufficient funds",o.Logger.errors.INSUFFICIENT_FUNDS,{transaction:f}),e.responseText.indexOf("nonce too low")>=0&&s.throwError("nonce has already been used",o.Logger.errors.NONCE_EXPIRED,{transaction:f}),e.responseText.indexOf("replacement transaction underpriced")>=0&&s.throwError("replacement fee too low",o.Logger.errors.REPLACEMENT_UNDERPRICED,{transaction:f})),e}))}))},a.prototype.signTransaction=function(e){return s.throwError("signing transactions is unsupported",o.Logger.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})},a.prototype.sendTransaction=function(e){var a=this;return this.sendUncheckedTransaction(e).then((function(e){return Xt.poll((function(){return a.provider.getTransaction(e).then((function(t){if(null!==t)return a.provider._wrapTransaction(t,e)}))}),{onceBlock:a.provider}).catch((function(a){throw a.transactionHash=e,a}))}))},a.prototype.signMessage=function(e){var a=this,t="string"==typeof e?V.toUtf8Bytes(e):e;return this.getAddress().then((function(e){return a.provider.send("eth_sign",[e.toLowerCase(),l.hexlify(t)])}))},a.prototype.unlock=function(e){var a=this.provider;return this.getAddress().then((function(t){return a.send("personal_unlockAccount",[t.toLowerCase(),e,null])}))},a}(ee.Signer);a.JsonRpcSigner=p;var y=function(e){function a(){return null!==e&&e.apply(this,arguments)||this}return f(a,e),a.prototype.sendTransaction=function(e){var a=this;return this.sendUncheckedTransaction(e).then((function(e){return{hash:e,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:function(t){return a.provider.waitForTransaction(e,t)}}}))},a}(p),m={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0},h=function(e){function a(t,f){var n=this.constructor,b=this;s.checkNew(n,a);var d=f;return null==d&&(d=new Promise((function(e,a){setTimeout((function(){b.detectNetwork().then((function(a){e(a)}),(function(e){a(e)}))}),0)}))),b=e.call(this,d)||this,t||(t=v.getStatic(b.constructor,"defaultUrl")()),"string"==typeof t?v.defineReadOnly(b,"connection",Object.freeze({url:t})):v.defineReadOnly(b,"connection",Object.freeze(v.shallowCopy(t))),b._nextId=42,b}return f(a,e),a.defaultUrl=function(){return"http://localhost:8545"},a.prototype.detectNetwork=function(){return b(this,void 0,void 0,(function(){var e,a;return d(this,(function(t){switch(t.label){case 0:return[4,i(0)];case 1:t.sent(),e=null,t.label=2;case 2:return t.trys.push([2,4,,9]),[4,this.send("eth_chainId",[])];case 3:return e=t.sent(),[3,9];case 4:t.sent(),t.label=5;case 5:return t.trys.push([5,7,,8]),[4,this.send("net_version",[])];case 6:return e=t.sent(),[3,8];case 7:return t.sent(),[3,8];case 8:return[3,9];case 9:if(null!=e){a=v.getStatic(this.constructor,"getNetwork");try{return[2,a(x.BigNumber.from(e).toNumber())]}catch(a){return[2,s.throwError("could not detect network",o.Logger.errors.NETWORK_ERROR,{chainId:e,event:"invalidNetwork",serverError:a})]}}return[2,s.throwError("could not detect network",o.Logger.errors.NETWORK_ERROR,{event:"noNetwork"})]}}))}))},a.prototype.getSigner=function(e){return new p(u,this,e)},a.prototype.getUncheckedSigner=function(e){return this.getSigner(e).connectUnchecked()},a.prototype.listAccounts=function(){var e=this;return this.send("eth_accounts",[]).then((function(a){return a.map((function(a){return e.formatter.address(a)}))}))},a.prototype.send=function(e,a){var t=this,f={method:e,params:a,id:this._nextId++,jsonrpc:"2.0"};return this.emit("debug",{action:"request",request:v.deepCopy(f),provider:this}),Xt.fetchJson(this.connection,JSON.stringify(f),c).then((function(e){return t.emit("debug",{action:"response",request:f,response:e,provider:t}),e}),(function(e){throw t.emit("debug",{action:"response",error:e,request:f,provider:t}),e}))},a.prototype.prepareRequest=function(e,a){switch(e){case"getBlockNumber":return["eth_blockNumber",[]];case"getGasPrice":return["eth_gasPrice",[]];case"getBalance":return["eth_getBalance",[r(a.address),a.blockTag]];case"getTransactionCount":return["eth_getTransactionCount",[r(a.address),a.blockTag]];case"getCode":return["eth_getCode",[r(a.address),a.blockTag]];case"getStorageAt":return["eth_getStorageAt",[r(a.address),a.position,a.blockTag]];case"sendTransaction":return["eth_sendRawTransaction",[a.signedTransaction]];case"getBlock":return a.blockTag?["eth_getBlockByNumber",[a.blockTag,!!a.includeTransactions]]:a.blockHash?["eth_getBlockByHash",[a.blockHash,!!a.includeTransactions]]:null;case"getTransaction":return["eth_getTransactionByHash",[a.transactionHash]];case"getTransactionReceipt":return["eth_getTransactionReceipt",[a.transactionHash]];case"call":return["eth_call",[v.getStatic(this.constructor,"hexlifyTransaction")(a.transaction,{from:!0}),a.blockTag]];case"estimateGas":return["eth_estimateGas",[v.getStatic(this.constructor,"hexlifyTransaction")(a.transaction,{from:!0})]];case"getLogs":return a.filter&&null!=a.filter.address&&(a.filter.address=r(a.filter.address)),["eth_getLogs",[a.filter]]}return null},a.prototype.perform=function(e,a){var t=this.prepareRequest(e,a);return null==t&&s.throwError(e+" not implemented",o.Logger.errors.NOT_IMPLEMENTED,{operation:e}),"sendTransaction"===e?this.send(t[0],t[1]).catch((function(e){throw e.responseText&&(e.responseText.indexOf("insufficient funds")>0&&s.throwError("insufficient funds",o.Logger.errors.INSUFFICIENT_FUNDS,{}),e.responseText.indexOf("nonce too low")>0&&s.throwError("nonce has already been used",o.Logger.errors.NONCE_EXPIRED,{}),e.responseText.indexOf("replacement transaction underpriced")>0&&s.throwError("replacement fee too low",o.Logger.errors.REPLACEMENT_UNDERPRICED,{})),e})):this.send(t[0],t[1])},a.prototype._startEvent=function(a){"pending"===a.tag&&this._startPending(),e.prototype._startEvent.call(this,a)},a.prototype._startPending=function(){if(null==this._pendingFilter){var e=this,a=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=a,a.then((function(t){return function f(){e.send("eth_getFilterChanges",[t]).then((function(t){if(e._pendingFilter!=a)return null;var f=Promise.resolve();return t.forEach((function(a){e._emitted["t:"+a.toLowerCase()]="pending",f=f.then((function(){return e.getTransaction(a).then((function(a){return e.emit("pending",a),null}))}))})),f.then((function(){return i(1e3)}))})).then((function(){if(e._pendingFilter==a)return setTimeout((function(){f()}),0),null;e.send("eth_uninstallFilter",[t])})).catch((function(e){}))}(),t})).catch((function(e){}))}},a.prototype._stopEvent=function(a){"pending"===a.tag&&0===this.listenerCount("pending")&&(this._pendingFilter=null),e.prototype._stopEvent.call(this,a)},a.hexlifyTransaction=function(e,a){var t=v.shallowCopy(m);if(a)for(var f in a)a[f]&&(t[f]=!0);v.checkProperties(e,t);var n={};return["gasLimit","gasPrice","nonce","value"].forEach((function(a){if(null!=e[a]){var t=l.hexValue(e[a]);"gasLimit"===a&&(a="gas"),n[a]=t}})),["from","to","data"].forEach((function(a){null!=e[a]&&(n[a]=l.hexlify(e[a]))})),n},a}(Vt.BaseProvider);a.JsonRpcProvider=h}))),zt=(b(Ht),Ht.JsonRpcSigner,Ht.JsonRpcProvider,d((function(e,a){var t,f=n&&n.__extends||(t=function(e,a){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,a){e.__proto__=a}||function(e,a){for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])})(e,a)},function(e,a){function f(){this.constructor=e}t(e,a),e.prototype=null===a?Object.create(a):(f.prototype=a.prototype,new f)}),b=n&&n.__awaiter||function(e,a,t,f){return new(t||(t=Promise))((function(n,b){function d(e){try{i(f.next(e))}catch(e){b(e)}}function s(e){try{i(f.throw(e))}catch(e){b(e)}}function i(e){var a;e.done?n(e.value):(a=e.value,a instanceof t?a:new t((function(e){e(a)}))).then(d,s)}i((f=f.apply(e,a||[])).next())}))},d=n&&n.__generator||function(e,a){var t,f,n,b,d={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return b={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(b[Symbol.iterator]=function(){return this}),b;function s(b){return function(s){return function(b){if(t)throw new TypeError("Generator is already executing.");for(;d;)try{if(t=1,f&&(n=2&b[0]?f.return:b[0]?f.throw||((n=f.return)&&n.call(f),0):f.next)&&!(n=n.call(f,b[1])).done)return n;switch(f=0,n&&(b=[2&b[0],n.value]),b[0]){case 0:case 1:n=b;break;case 4:return d.label++,{value:b[1],done:!1};case 5:d.label++,f=b[1],b=[0];continue;case 7:b=d.ops.pop(),d.trys.pop();continue;default:if(!((n=(n=d.trys).length>0&&n[n.length-1])||6!==b[0]&&2!==b[0])){d=0;continue}if(3===b[0]&&(!n||b[1]>n[0]&&b[1]0&&n[n.length-1])||6!==b[0]&&2!==b[0])){d=0;continue}if(3===b[0]&&(!n||b[1]>n[0]&&b[1]0&&n[n.length-1])||6!==b[0]&&2!==b[0])){d=0;continue}if(3===b[0]&&(!n||b[1]>n[0]&&b[1]0&&n[n.length-1])||6!==b[0]&&2!==b[0])){d=0;continue}if(3===b[0]&&(!n||b[1]>n[0]&&b[1]=0&&(a.throttleRetry=!0),a}return e.result}function r(e){if(e&&0==e.status&&"NOTOK"==e.message&&(e.result||"").toLowerCase().indexOf("rate limit")>=0)throw(a=new Error("throttled response")).result=JSON.stringify(e),a.throttleRetry=!0,a;if("2.0"!=e.jsonrpc)throw(a=new Error("invalid response")).result=JSON.stringify(e),a;if(e.error){var a=new Error(e.error.message||"unknown error");throw e.error.code&&(a.code=e.error.code),e.error.data&&(a.data=e.error.data),a}return e.result}function u(e){if("pending"===e)throw new Error("pending not supported");return"latest"===e?e:parseInt(e.substring(2),16)}var p="9D13ZE7XSBTJ94N9BNJ2MA33VMAY2YPIRB",y=function(e){function a(t,f){var n,b=this.constructor;s.checkNew(b,a);var d="invalid";(n=e.call(this,t)||this).network&&(d=n.network.name);var i=null;switch(d){case"homestead":i="https://api.etherscan.io";break;case"ropsten":i="https://api-ropsten.etherscan.io";break;case"rinkeby":i="https://api-rinkeby.etherscan.io";break;case"kovan":i="https://api-kovan.etherscan.io";break;case"goerli":i="https://api-goerli.etherscan.io";break;default:throw new Error("unsupported network")}return v.defineReadOnly(n,"baseUrl",i),v.defineReadOnly(n,"apiKey",f||p),n}return f(a,e),a.prototype.detectNetwork=function(){return b(this,void 0,void 0,(function(){return d(this,(function(e){return[2,this.network]}))}))},a.prototype.perform=function(a,t){return b(this,void 0,void 0,(function(){var f,n,l,y,m,h,x,g,T,w,E,A=this;return d(this,(function(M){switch(M.label){case 0:switch(f=this.baseUrl,n="",this.apiKey&&(n+="&apikey="+this.apiKey),l=function(e,a){return b(A,void 0,void 0,(function(){var t,f,n=this;return d(this,(function(b){switch(b.label){case 0:return this.emit("debug",{action:"request",request:e,provider:this}),t={url:e,throttleSlotInterval:1e3,throttleCallback:function(e,a){return n.apiKey===p&&Zt.showThrottleMessage(),Promise.resolve(!0)}},[4,Xt.fetchJson(t,null,a||r)];case 1:return f=b.sent(),this.emit("debug",{action:"response",request:e,response:v.deepCopy(f),provider:this}),[2,f]}}))}))},a){case"getBlockNumber":return[3,1];case"getGasPrice":return[3,2];case"getBalance":return[3,3];case"getTransactionCount":return[3,4];case"getCode":return[3,5];case"getStorageAt":return[3,6];case"sendTransaction":return[3,7];case"getBlock":return[3,8];case"getTransaction":return[3,9];case"getTransactionReceipt":return[3,10];case"call":return[3,11];case"estimateGas":return[3,12];case"getLogs":return[3,13];case"getEtherPrice":return[3,20]}return[3,22];case 1:return[2,l(f+="/api?module=proxy&action=eth_blockNumber"+n)];case 2:return[2,l(f+="/api?module=proxy&action=eth_gasPrice"+n)];case 3:return f+="/api?module=account&action=balance&address="+t.address,f+="&tag="+t.blockTag+n,[2,l(f,c)];case 4:return f+="/api?module=proxy&action=eth_getTransactionCount&address="+t.address,f+="&tag="+t.blockTag+n,[2,l(f)];case 5:return f+="/api?module=proxy&action=eth_getCode&address="+t.address,f+="&tag="+t.blockTag+n,[2,l(f)];case 6:return f+="/api?module=proxy&action=eth_getStorageAt&address="+t.address,f+="&position="+t.position,f+="&tag="+t.blockTag+n,[2,l(f)];case 7:return f+="/api?module=proxy&action=eth_sendRawTransaction&hex="+t.signedTransaction,[2,l(f+=n).catch((function(e){throw e.responseText&&(e.responseText.toLowerCase().indexOf("insufficient funds")>=0&&s.throwError("insufficient funds",o.Logger.errors.INSUFFICIENT_FUNDS,{}),e.responseText.indexOf("same hash was already imported")>=0&&s.throwError("nonce has already been used",o.Logger.errors.NONCE_EXPIRED,{}),e.responseText.indexOf("another transaction with same nonce")>=0&&s.throwError("replacement fee too low",o.Logger.errors.REPLACEMENT_UNDERPRICED,{})),e}))];case 8:if(t.blockTag)return f+="/api?module=proxy&action=eth_getBlockByNumber&tag="+t.blockTag,t.includeTransactions?f+="&boolean=true":f+="&boolean=false",[2,l(f+=n)];throw new Error("getBlock by blockHash not implemented");case 9:return f+="/api?module=proxy&action=eth_getTransactionByHash&txhash="+t.transactionHash,[2,l(f+=n)];case 10:return f+="/api?module=proxy&action=eth_getTransactionReceipt&txhash="+t.transactionHash,[2,l(f+=n)];case 11:if((y=i(t.transaction))&&(y="&"+y),f+="/api?module=proxy&action=eth_call"+y,"latest"!==t.blockTag)throw new Error("EtherscanProvider does not support blockTag for call");return[2,l(f+=n)];case 12:return(y=i(t.transaction))&&(y="&"+y),f+="/api?module=proxy&action=eth_estimateGas&"+y,[2,l(f+=n)];case 13:return f+="/api?module=logs&action=getLogs",t.filter.fromBlock&&(f+="&fromBlock="+u(t.filter.fromBlock)),t.filter.toBlock&&(f+="&toBlock="+u(t.filter.toBlock)),t.filter.address&&(f+="&address="+t.filter.address),t.filter.topics&&t.filter.topics.length>0&&(t.filter.topics.length>1&&s.throwError("unsupported topic count",o.Logger.errors.UNSUPPORTED_OPERATION,{topics:t.filter.topics}),1===t.filter.topics.length&&("string"==typeof(m=t.filter.topics[0])&&66===m.length||s.throwError("unsupported topic format",o.Logger.errors.UNSUPPORTED_OPERATION,{topic0:m}),f+="&topic0="+m)),[4,l(f+=n,c)];case 14:h=M.sent(),x={},g=0,M.label=15;case 15:return g0&&n[n.length-1])||6!==b[0]&&2!==b[0])){d=0;continue}if(3===b[0]&&(!n||b[1]>n[0]&&b[1]a?null:(f+n)/2}function u(e){if(null===e)return"null";if("number"==typeof e||"boolean"==typeof e)return JSON.stringify(e);if("string"==typeof e)return e;if(x.BigNumber.isBigNumber(e))return e.toString();if(Array.isArray(e))return JSON.stringify(e.map((function(e){return u(e)})));if("object"==typeof e){var a=Object.keys(e);return a.sort(),"{"+a.map((function(a){var t=e[a];return t="function"==typeof t?"[function]":u(t),JSON.stringify(a)+":"+t})).join(",")+"}"}throw new Error("unknown value type: "+typeof e)}var p=1;function y(e){var a=null,t=null,f=new Promise((function(f){a=function(){t&&(clearTimeout(t),t=null),f()},t=setTimeout(a,e)}));return{cancel:a,getPromise:function(){return f},wait:function(e){return f=f.then(e)}}}function m(e,a){var t={provider:e.provider,weight:e.weight};return e.start&&(t.start=e.start),a&&(t.duration=a-e.start),e.done&&(e.error?t.error=e.error:t.result=e.result||null),t}function h(e,a,t){var f=u;switch(a){case"getBlockNumber":return function(a){var t=a.map((function(e){return e.result})),f=r(a.map((function(e){return e.result})),2);if(null!=f)return f=Math.ceil(f),t.indexOf(f+1)>=0&&f++,f>=e._highestBlockNumber&&(e._highestBlockNumber=f),e._highestBlockNumber};case"getGasPrice":return function(e){var a=e.map((function(e){return e.result}));return a.sort(),a[Math.floor(a.length/2)]};case"getEtherPrice":return function(e){return r(e.map((function(e){return e.result})))};case"getBalance":case"getTransactionCount":case"getCode":case"getStorageAt":case"call":case"estimateGas":case"getLogs":break;case"getTransaction":case"getTransactionReceipt":f=function(e){return null==e?null:((e=v.shallowCopy(e)).confirmations=-1,u(e))};break;case"getBlock":f=t.includeTransactions?function(e){return null==e?null:((e=v.shallowCopy(e)).transactions=e.transactions.map((function(e){return(e=v.shallowCopy(e)).confirmations=-1,e})),u(e))}:function(e){return null==e?null:u(e)};break;default:throw new Error("unknown method: "+a)}return function(e,a){return function(t){var f={};t.forEach((function(a){var t=e(a.result);f[t]||(f[t]={count:0,result:a.result}),f[t].count++}));for(var n=Object.keys(f),b=0;b=a)return d.result}}}(f,e.quorum)}function g(e,a){return b(this,void 0,void 0,(function(){var t;return d(this,(function(f){return null!=(t=e.provider).blockNumber&&t.blockNumber>=a||-1===a?[2,t]:[2,Xt.poll((function(){return new Promise((function(f,n){setTimeout((function(){return t.blockNumber>=a?f(t):e.cancelled?f(null):f(void 0)}),0)}))}),{oncePoll:t})]}))}))}var T=function(e){function a(t,f){var n=this.constructor,b=this;s.checkNew(n,a),0===t.length&&s.throwArgumentError("missing providers","providers",t);var d=t.map((function(e,a){if(Y.Provider.isProvider(e))return Object.freeze({provider:e,weight:1,stallTimeout:750,priority:1});var t=v.shallowCopy(e);null==t.priority&&(t.priority=1),null==t.stallTimeout&&(t.stallTimeout=750),null==t.weight&&(t.weight=1);var f=t.weight;return(f%1||f>512||f<1)&&s.throwArgumentError("invalid weight; must be integer in [1, 512]","providers["+a+"].weight",f),Object.freeze(t)})),i=d.reduce((function(e,a){return e+a.weight}),0);null==f?f=i/2:f>i&&s.throwArgumentError("quorum will always fail; larger than total weight","quorum",f);var r=c(d.map((function(e){return e.provider.network})));return null==r&&(r=new Promise((function(e,a){setTimeout((function(){b.detectNetwork().then(e,a)}),0)}))),b=e.call(this,r)||this,v.defineReadOnly(b,"providerConfigs",Object.freeze(d)),v.defineReadOnly(b,"quorum",f),b._highestBlockNumber=-1,b}return f(a,e),a.prototype.detectNetwork=function(){return b(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return[4,Promise.all(this.providerConfigs.map((function(e){return e.provider.getNetwork()})))];case 1:return[2,c(e.sent())]}}))}))},a.prototype.perform=function(e,a){return b(this,void 0,void 0,(function(){var t,f,n,c,r,u,x,T,w,E,A,M=this;return d(this,(function(C){switch(C.label){case 0:return"sendTransaction"!==e?[3,2]:[4,Promise.all(this.providerConfigs.map((function(e){return e.provider.sendTransaction(a.signedTransaction).then((function(e){return e.hash}),(function(e){return e}))})))];case 1:for(t=C.sent(),f=0;f=E.quorum?void 0!==(A=c(w))?(r.forEach((function(e){e.staller&&e.staller.cancel(),e.cancelled=!0})),[2,{value:A}]):T?[3,4]:[4,y(100).getPromise()]:[3,5];case 3:C.sent(),C.label=4;case 4:T=!1,C.label=5;case 5:return 0===r.filter((function(e){return!e.done})).length?[2,"break"]:[2]}}))},E=this,C.label=5;case 5:return[5,w()];case 6:return"object"==typeof(A=C.sent())?[2,A.value]:"break"===A?[3,7]:[3,5];case 7:return r.forEach((function(e){e.staller&&e.staller.cancel(),e.cancelled=!0})),[2,s.throwError("failed to meet quorum",o.Logger.errors.SERVER_ERROR,{method:e,params:a,results:r.map((function(e){return m(e)})),provider:this})]}}))}))},a}(Vt.BaseProvider);a.FallbackProvider=T}))),Yt=(b(Jt),Jt.FallbackProvider,null),Qt=d((function(e,a){var t,f=n&&n.__extends||(t=function(e,a){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,a){e.__proto__=a}||function(e,a){for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])})(e,a)},function(e,a){function f(){this.constructor=e}t(e,a),e.prototype=null===a?Object.create(a):(f.prototype=a.prototype,new f)});Object.defineProperty(a,"__esModule",{value:!0});var b=new o.Logger(Kt.version),d="84842078b09946638c03157f83405213",s=function(e){function a(){return null!==e&&e.apply(this,arguments)||this}return f(a,e),a.getWebSocketProvider=function(e,t){var f=new a(e,t).connection;f.password&&b.throwError("INFURA WebSocket project secrets unsupported",o.Logger.errors.UNSUPPORTED_OPERATION,{operation:"InfuraProvider.getWebSocketProvider()"});var n=f.url.replace(/^http/i,"ws").replace("/v3/","/ws/v3/");return new zt.WebSocketProvider(n,e)},a.getApiKey=function(e){var a={apiKey:d,projectId:d,projectSecret:null};return null==e||("string"==typeof e?a.projectId=e:null!=e.projectSecret?(b.assertArgument("string"==typeof e.projectId,"projectSecret requires a projectId","projectId",e.projectId),b.assertArgument("string"==typeof e.projectSecret,"invalid projectSecret","projectSecret","[REDACTED]"),a.projectId=e.projectId,a.projectSecret=e.projectSecret):e.projectId&&(a.projectId=e.projectId),a.apiKey=a.projectId),a},a.getUrl=function(e,a){var t=null;switch(e?e.name:"unknown"){case"homestead":t="mainnet.infura.io";break;case"ropsten":t="ropsten.infura.io";break;case"rinkeby":t="rinkeby.infura.io";break;case"kovan":t="kovan.infura.io";break;case"goerli":t="goerli.infura.io";break;default:b.throwError("unsupported network",o.Logger.errors.INVALID_ARGUMENT,{argument:"network",value:e})}var f={url:"https://"+t+"/v3/"+a.projectId,throttleCallback:function(e,t){return a.projectId===d&&Zt.showThrottleMessage(),Promise.resolve(!0)}};return null!=a.projectSecret&&(f.user="",f.password=a.projectSecret),f},a}(jt.UrlJsonRpcProvider);a.InfuraProvider=s})),ef=(b(Qt),Qt.InfuraProvider,d((function(e,a){var t,f=n&&n.__extends||(t=function(e,a){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,a){e.__proto__=a}||function(e,a){for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])})(e,a)},function(e,a){function f(){this.constructor=e}t(e,a),e.prototype=null===a?Object.create(a):(f.prototype=a.prototype,new f)});Object.defineProperty(a,"__esModule",{value:!0});var b=new o.Logger(Kt.version),d=function(e){function a(){return null!==e&&e.apply(this,arguments)||this}return f(a,e),a.getApiKey=function(e){return e&&"string"!=typeof e&&b.throwArgumentError("invalid apiKey","apiKey",e),e||"ETHERS_JS_SHARED"},a.getUrl=function(e,a){b.warn("NodeSmith will be discontinued on 2019-12-20; please migrate to another platform.");var t=null;switch(e.name){case"homestead":t="https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc";break;case"ropsten":t="https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc";break;case"rinkeby":t="https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc";break;case"goerli":t="https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc";break;case"kovan":t="https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc";break;default:b.throwArgumentError("unsupported network","network",arguments[0])}return t+"?apiKey="+a},a}(jt.UrlJsonRpcProvider);a.NodesmithProvider=d}))),af=(b(ef),ef.NodesmithProvider,d((function(e,a){var t,f=n&&n.__extends||(t=function(e,a){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,a){e.__proto__=a}||function(e,a){for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])})(e,a)},function(e,a){function f(){this.constructor=e}t(e,a),e.prototype=null===a?Object.create(a):(f.prototype=a.prototype,new f)});Object.defineProperty(a,"__esModule",{value:!0});var b=new o.Logger(Kt.version),d=1;function s(e,a){return function(t,f){"eth_sign"==t&&e.isMetaMask&&(t="personal_sign",f=[f[1],f[0]]);var n={method:t,params:f,id:d++,jsonrpc:"2.0"};return new Promise((function(e,t){a(n,(function(a,f){if(a)return t(a);if(f.error){var n=new Error(f.error.message);return n.code=f.error.code,n.data=f.error.data,t(n)}e(f.result)}))}))}}var i=function(e){function a(t,f){var n,d=this.constructor;b.checkNew(d,a),null==t&&b.throwArgumentError("missing provider","provider",t);var i=null,c=null,r=null;return"function"==typeof t?(i="unknown:",c=t):(!(i=t.host||t.path||"")&&t.isMetaMask&&(i="metamask"),r=t,t.request?(""===i&&(i="eip-1193:"),c=function(e){return function(a,t){return null==t&&(t=[]),"eth_sign"==a&&e.isMetaMask&&(a="personal_sign",t=[t[1],t[0]]),e.request({method:a,params:t})}}(t)):t.sendAsync?c=s(t,t.sendAsync.bind(t)):t.send?c=s(t,t.send.bind(t)):b.throwArgumentError("unsupported provider","provider",t),i||(i="unknown:")),n=e.call(this,i,f)||this,v.defineReadOnly(n,"jsonRpcFetchFunc",c),v.defineReadOnly(n,"provider",r),n}return f(a,e),a.prototype.send=function(e,a){return this.jsonRpcFetchFunc(e,a)},a}(Ht.JsonRpcProvider);a.Web3Provider=i}))),tf=(b(af),af.Web3Provider,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.Provider=Y.Provider,a.getNetwork=It.getNetwork,a.BaseProvider=Vt.BaseProvider,a.AlchemyProvider=Gt.AlchemyProvider,a.CloudflareProvider=Wt.CloudflareProvider,a.EtherscanProvider=$t.EtherscanProvider,a.FallbackProvider=Jt.FallbackProvider,a.IpcProvider=Yt,a.InfuraProvider=Qt.InfuraProvider,a.JsonRpcProvider=Ht.JsonRpcProvider,a.JsonRpcSigner=Ht.JsonRpcSigner,a.NodesmithProvider=ef.NodesmithProvider,a.StaticJsonRpcProvider=jt.StaticJsonRpcProvider,a.UrlJsonRpcProvider=jt.UrlJsonRpcProvider,a.Web3Provider=af.Web3Provider,a.WebSocketProvider=zt.WebSocketProvider,a.Formatter=Zt.Formatter;var t=new o.Logger(Kt.version);a.getDefaultProvider=function(e,a){if(null==e&&(e="homestead"),"string"==typeof e){var f=e.match(/^(ws|http)s?:/i);if(f)switch(f[1]){case"http":return new Ht.JsonRpcProvider(e);case"ws":return new zt.WebSocketProvider(e);default:t.throwArgumentError("unsupported URL scheme","network",e)}}var n=It.getNetwork(e);return n&&n._defaultProvider||t.throwError("unsupported getDefaultProvider network",o.Logger.errors.NETWORK_ERROR,{operation:"getDefaultProvider",network:e}),n._defaultProvider({FallbackProvider:Jt.FallbackProvider,AlchemyProvider:Gt.AlchemyProvider,CloudflareProvider:Wt.CloudflareProvider,EtherscanProvider:$t.EtherscanProvider,InfuraProvider:Qt.InfuraProvider,JsonRpcProvider:Ht.JsonRpcProvider,NodesmithProvider:ef.NodesmithProvider,Web3Provider:af.Web3Provider,IpcProvider:Yt},a)}}))),ff=(b(tf),tf.Provider,tf.getNetwork,tf.BaseProvider,tf.AlchemyProvider,tf.CloudflareProvider,tf.EtherscanProvider,tf.FallbackProvider,tf.IpcProvider,tf.InfuraProvider,tf.JsonRpcProvider,tf.JsonRpcSigner,tf.NodesmithProvider,tf.StaticJsonRpcProvider,tf.UrlJsonRpcProvider,tf.Web3Provider,tf.WebSocketProvider,tf.Formatter,tf.getDefaultProvider,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0});var t=new RegExp("^bytes([0-9]+)$"),f=new RegExp("^(u?int)([0-9]*)$"),n=new RegExp("^(.*)\\[([0-9]*)\\]$");function b(e,a){if(e.length!=a.length)throw new Error("type/value count mismatch");var b=[];return e.forEach((function(e,d){b.push(function e(a,b,d){switch(a){case"address":return d?l.zeroPad(b,32):l.arrayify(b);case"string":return V.toUtf8Bytes(b);case"bytes":return l.arrayify(b);case"bool":return b=b?"0x01":"0x00",d?l.zeroPad(b,32):l.arrayify(b)}var s=a.match(f);if(s){var i=parseInt(s[2]||"256");if(s[2]&&String(i)!==s[2]||i%8!=0||0===i||i>256)throw new Error("invalid number type - "+a);return d&&(i=256),b=x.BigNumber.from(b).toTwos(i),l.zeroPad(b,i/8)}if(s=a.match(t)){if(i=parseInt(s[1]),String(i)!==s[1]||0===i||i>32)throw new Error("invalid bytes type - "+a);if(l.arrayify(b).byteLength!==i)throw new Error("invalid value for "+a);return d?l.arrayify((b+"0000000000000000000000000000000000000000000000000000000000000000").substring(0,66)):b}if((s=a.match(n))&&Array.isArray(b)){var c=s[1];if(parseInt(s[2]||String(b.length))!=b.length)throw new Error("invalid value for "+a);var r=[];return b.forEach((function(a){r.push(e(c,a,!0))})),l.concat(r)}throw new Error("invalid type - "+a)}(e,a[d]))})),l.hexlify(l.concat(b))}a.pack=b,a.keccak256=function(e,a){return M.keccak256(b(e,a))},a.sha256=function(e,a){return Ma.sha256(b(e,a))}}))),nf=(b(ff),ff.pack,ff.keccak256,ff.sha256,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.version="units/5.0.2"}))),bf=(b(nf),nf.version,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0});var t=new o.Logger(nf.version),f=["wei","kwei","mwei","gwei","szabo","finney","ether"];function n(e,a){if("string"==typeof a){var t=f.indexOf(a);-1!==t&&(a=3*t)}return x.formatFixed(e,null!=a?a:18)}function b(e,a){if("string"==typeof a){var t=f.indexOf(a);-1!==t&&(a=3*t)}return x.parseFixed(e,null!=a?a:18)}a.commify=function(e){var a=String(e).split(".");(a.length>2||!a[0].match(/^-?[0-9]*$/)||a[1]&&!a[1].match(/^[0-9]*$/)||"."===e||"-."===e)&&t.throwArgumentError("invalid value","value",e);var f=a[0],n="";for("-"===f.substring(0,1)&&(n="-",f=f.substring(1));"0"===f.substring(0,1);)f=f.substring(1);""===f&&(f="0");var b="";for(2===a.length&&(b="."+(a[1]||"0"));b.length>2&&"0"===b[b.length-1];)b=b.substring(0,b.length-1);for(var d=[];f.length;){if(f.length<=3){d.unshift(f);break}var s=f.length-3;d.unshift(f.substring(s)),f=f.substring(0,s)}return n+d.join(",")+b},a.formatUnits=n,a.parseUnits=b,a.formatEther=function(e){return n(e,18)},a.parseEther=function(e){return b(e,18)}}))),df=(b(bf),bf.commify,bf.formatUnits,bf.parseUnits,bf.formatEther,bf.parseEther,d((function(e,a){var t=n&&n.__importStar||function(e){if(e&&e.__esModule)return e;var a={};if(null!=e)for(var t in e)Object.hasOwnProperty.call(e,t)&&(a[t]=e[t]);return a.default=e,a};Object.defineProperty(a,"__esModule",{value:!0}),a.AbiCoder=$.AbiCoder,a.checkResultErrors=$.checkResultErrors,a.defaultAbiCoder=$.defaultAbiCoder,a.EventFragment=$.EventFragment,a.FormatTypes=$.FormatTypes,a.Fragment=$.Fragment,a.FunctionFragment=$.FunctionFragment,a.Indexed=$.Indexed,a.Interface=$.Interface,a.LogDescription=$.LogDescription,a.ParamType=$.ParamType,a.TransactionDescription=$.TransactionDescription,a.getAddress=B.getAddress,a.getCreate2Address=B.getCreate2Address,a.getContractAddress=B.getContractAddress,a.getIcapAddress=B.getIcapAddress,a.isAddress=B.isAddress;var f=t(Nt);a.base64=f,a.arrayify=l.arrayify,a.concat=l.concat,a.hexDataSlice=l.hexDataSlice,a.hexDataLength=l.hexDataLength,a.hexlify=l.hexlify,a.hexStripZeros=l.hexStripZeros,a.hexValue=l.hexValue,a.hexZeroPad=l.hexZeroPad,a.isBytes=l.isBytes,a.isBytesLike=l.isBytesLike,a.isHexString=l.isHexString,a.joinSignature=l.joinSignature,a.zeroPad=l.zeroPad,a.splitSignature=l.splitSignature,a.stripZeros=l.stripZeros,a.hashMessage=G.hashMessage,a.id=G.id,a.isValidName=G.isValidName,a.namehash=G.namehash,a.defaultPath=Tt.defaultPath,a.entropyToMnemonic=Tt.entropyToMnemonic,a.HDNode=Tt.HDNode,a.isValidMnemonic=Tt.isValidMnemonic,a.mnemonicToEntropy=Tt.mnemonicToEntropy,a.mnemonicToSeed=Tt.mnemonicToSeed,a.getJsonWalletAddress=kt.getJsonWalletAddress,a.keccak256=M.keccak256,a.Logger=o.Logger,a.computeHmac=Ma.computeHmac,a.ripemd160=Ma.ripemd160,a.sha256=Ma.sha256,a.sha512=Ma.sha512,a.solidityKeccak256=ff.keccak256,a.solidityPack=ff.pack,a.soliditySha256=ff.sha256,a.randomBytes=At.randomBytes,a.shuffled=At.shuffled,a.checkProperties=v.checkProperties,a.deepCopy=v.deepCopy,a.defineReadOnly=v.defineReadOnly,a.getStatic=v.getStatic,a.resolveProperties=v.resolveProperties,a.shallowCopy=v.shallowCopy;var b=t(D);a.RLP=b,a.computePublicKey=pt.computePublicKey,a.recoverPublicKey=pt.recoverPublicKey,a.SigningKey=pt.SigningKey,a.formatBytes32String=V.formatBytes32String,a.nameprep=V.nameprep,a.parseBytes32String=V.parseBytes32String,a._toEscapedUtf8String=V._toEscapedUtf8String,a.toUtf8Bytes=V.toUtf8Bytes,a.toUtf8CodePoints=V.toUtf8CodePoints,a.toUtf8String=V.toUtf8String,a.Utf8ErrorFuncs=V.Utf8ErrorFuncs,a.computeAddress=yt.computeAddress,a.parseTransaction=yt.parse,a.recoverAddress=yt.recoverAddress,a.serializeTransaction=yt.serialize,a.commify=bf.commify,a.formatEther=bf.formatEther,a.parseEther=bf.parseEther,a.formatUnits=bf.formatUnits,a.parseUnits=bf.parseUnits,a.verifyMessage=Pt.verifyMessage,a.fetchJson=Xt.fetchJson,a.poll=Xt.poll;var d=Ma;a.SupportedAlgorithm=d.SupportedAlgorithm;var s=V;a.UnicodeNormalizationForm=s.UnicodeNormalizationForm,a.Utf8ErrorReason=s.Utf8ErrorReason}))),sf=(b(df),df.AbiCoder,df.checkResultErrors,df.defaultAbiCoder,df.EventFragment,df.FormatTypes,df.Fragment,df.FunctionFragment,df.Indexed,df.Interface,df.LogDescription,df.ParamType,df.TransactionDescription,df.getAddress,df.getCreate2Address,df.getContractAddress,df.getIcapAddress,df.isAddress,df.base64,df.arrayify,df.concat,df.hexDataSlice,df.hexDataLength,df.hexlify,df.hexStripZeros,df.hexValue,df.hexZeroPad,df.isBytes,df.isBytesLike,df.isHexString,df.joinSignature,df.zeroPad,df.splitSignature,df.stripZeros,df.hashMessage,df.id,df.isValidName,df.namehash,df.defaultPath,df.entropyToMnemonic,df.HDNode,df.isValidMnemonic,df.mnemonicToEntropy,df.mnemonicToSeed,df.getJsonWalletAddress,df.keccak256,df.Logger,df.computeHmac,df.ripemd160,df.sha256,df.sha512,df.solidityKeccak256,df.solidityPack,df.soliditySha256,df.randomBytes,df.shuffled,df.checkProperties,df.deepCopy,df.defineReadOnly,df.getStatic,df.resolveProperties,df.shallowCopy,df.RLP,df.computePublicKey,df.recoverPublicKey,df.SigningKey,df.formatBytes32String,df.nameprep,df.parseBytes32String,df._toEscapedUtf8String,df.toUtf8Bytes,df.toUtf8CodePoints,df.toUtf8String,df.Utf8ErrorFuncs,df.computeAddress,df.parseTransaction,df.recoverAddress,df.serializeTransaction,df.commify,df.formatEther,df.parseEther,df.formatUnits,df.parseUnits,df.verifyMessage,df.fetchJson,df.poll,df.SupportedAlgorithm,df.UnicodeNormalizationForm,df.Utf8ErrorReason,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.version="ethers/5.0.7"}))),cf=(b(sf),sf.version,d((function(e,a){var t=n&&n.__importStar||function(e){if(e&&e.__esModule)return e;var a={};if(null!=e)for(var t in e)Object.hasOwnProperty.call(e,t)&&(a[t]=e[t]);return a.default=e,a};Object.defineProperty(a,"__esModule",{value:!0}),a.Contract=te.Contract,a.ContractFactory=te.ContractFactory,a.BigNumber=x.BigNumber,a.FixedNumber=x.FixedNumber,a.Signer=ee.Signer,a.VoidSigner=ee.VoidSigner,a.Wallet=Pt.Wallet;var f=t(N);a.constants=f;var b=t(tf);a.providers=b;var d=tf;a.getDefaultProvider=d.getDefaultProvider,a.Wordlist=gt.Wordlist,a.wordlists=gt.wordlists;var s=t(df);a.utils=s,a.errors=o.ErrorCode,a.version=sf.version;var i=new o.Logger(sf.version);a.logger=i}))),rf=(b(cf),cf.Contract,cf.ContractFactory,cf.BigNumber,cf.FixedNumber,cf.Signer,cf.VoidSigner,cf.Wallet,cf.constants,cf.providers,cf.getDefaultProvider,cf.Wordlist,cf.wordlists,cf.utils,cf.errors,cf.version,cf.logger,d((function(e,a){var t=n&&n.__importStar||function(e){if(e&&e.__esModule)return e;var a={};if(null!=e)for(var t in e)Object.hasOwnProperty.call(e,t)&&(a[t]=e[t]);return a.default=e,a};Object.defineProperty(a,"__esModule",{value:!0});var f=t(cf);a.ethers=f;try{var b=window;null==b._ethers&&(b._ethers=f)}catch(e){}var d=cf;a.Signer=d.Signer,a.Wallet=d.Wallet,a.VoidSigner=d.VoidSigner,a.getDefaultProvider=d.getDefaultProvider,a.providers=d.providers,a.Contract=d.Contract,a.ContractFactory=d.ContractFactory,a.BigNumber=d.BigNumber,a.FixedNumber=d.FixedNumber,a.constants=d.constants,a.errors=d.errors,a.logger=d.logger,a.utils=d.utils,a.wordlists=d.wordlists,a.version=d.version,a.Wordlist=d.Wordlist}))),uf=b(rf),of=rf.ethers,pf=rf.Signer,lf=rf.Wallet,yf=rf.VoidSigner,mf=rf.getDefaultProvider,hf=rf.providers,xf=rf.Contract,gf=rf.ContractFactory,vf=rf.BigNumber,Tf=rf.FixedNumber,wf=rf.constants,Ef=rf.errors,Af=rf.logger,Mf=rf.utils,Cf=rf.wordlists,Df=rf.version,Sf=rf.Wordlist;a.BigNumber=vf,a.Contract=xf,a.ContractFactory=gf,a.FixedNumber=Tf,a.Signer=pf,a.VoidSigner=yf,a.Wallet=lf,a.Wordlist=Sf,a.constants=wf,a.default=uf,a.errors=Ef,a.ethers=of,a.getDefaultProvider=mf,a.logger=Af,a.providers=hf,a.utils=Mf,a.version=Df,a.wordlists=Cf,Object.defineProperty(a,"__esModule",{value:!0})})(a)}).call(this,t(2),t(3),t(4).setImmediate)},function(e,a){var t;t=function(){return this}();try{t=t||new Function("return this")()}catch(e){"object"==typeof window&&(t=window)}e.exports=t},function(e,a){var t,f,n=e.exports={};function b(){throw new Error("setTimeout has not been defined")}function d(){throw new Error("clearTimeout has not been defined")}function s(e){if(t===setTimeout)return setTimeout(e,0);if((t===b||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(a){try{return t.call(null,e,0)}catch(a){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:b}catch(e){t=b}try{f="function"==typeof clearTimeout?clearTimeout:d}catch(e){f=d}}();var i,c=[],r=!1,u=-1;function o(){r&&i&&(r=!1,i.length?c=i.concat(c):u=-1,c.length&&p())}function p(){if(!r){var e=s(o);r=!0;for(var a=c.length;a;){for(i=c,c=[];++u1)for(var t=1;t=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),a))},t(5),a.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,a.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,t(2))},function(e,a,t){(function(e,a){!function(e,t){"use strict";if(!e.setImmediate){var f,n,b,d,s,i=1,c={},r=!1,u=e.document,o=Object.getPrototypeOf&&Object.getPrototypeOf(e);o=o&&o.setTimeout?o:e,"[object process]"==={}.toString.call(e.process)?f=function(e){a.nextTick((function(){l(e)}))}:!function(){if(e.postMessage&&!e.importScripts){var a=!0,t=e.onmessage;return e.onmessage=function(){a=!1},e.postMessage("","*"),e.onmessage=t,a}}()?e.MessageChannel?((b=new MessageChannel).port1.onmessage=function(e){l(e.data)},f=function(e){b.port2.postMessage(e)}):u&&"onreadystatechange"in u.createElement("script")?(n=u.documentElement,f=function(e){var a=u.createElement("script");a.onreadystatechange=function(){l(e),a.onreadystatechange=null,n.removeChild(a),a=null},n.appendChild(a)}):f=function(e){setTimeout(l,0,e)}:(d="setImmediate$"+Math.random()+"$",s=function(a){a.source===e&&"string"==typeof a.data&&0===a.data.indexOf(d)&&l(+a.data.slice(d.length))},e.addEventListener?e.addEventListener("message",s,!1):e.attachEvent("onmessage",s),f=function(a){e.postMessage(d+a,"*")}),o.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var a=new Array(arguments.length-1),t=0;t{const[n,s]=c(e,a);return{network:{id:s,name:n},networks:b.networks,networkToChainId:b.networkToChainId,decode:b.decode,defaults:b.defaults,feeds:Object(b.getFeeds)({network:n}),tokens:Object(b.getTokens)({network:n}),sources:Object(b.getSource)({network:n}),targets:Object(b.getTarget)({network:n}),synths:Object(b.getSynths)({network:n}),users:Object(b.getUsers)({network:n}),versions:Object(b.getVersions)({network:n}),stakingRewards:Object(b.getStakingRewards)({network:n}),suspensionReasons:Object(b.getSuspensionReasons)(),toBytes32:b.toBytes32,utils:d.ethers.utils,contracts:r(n,t,f)}},c=(e,a)=>{let t=f.Mainnet,d=n.Mainnet;if(a&&!b.networks.includes(a)||e&&!Object.values(b.networkToChainId).includes(e))throw new Error(s);return a&&b.networks.includes(a)?(t=a,d=b.networkToChainId[a]):e&&Object.entries(b.networkToChainId).forEach(([a,f])=>{f===e&&(t=a,d=f)}),[t,d]},r=(e,a,t)=>{const f=Object(b.getSource)({network:e}),n=Object(b.getTarget)({network:e});return Object.values(n).map(e=>{if("Synthetix"===e.name)e.address=n.ProxyERC20.address;else if("SynthsUSD"===e.name)e.address=n.ProxyERC20sUSD.address;else if("FeePool"===e.name)e.address=n.ProxyFeePool.address;else if(e.name.match(/Synth(s|i)[a-zA-Z]+$/)){const a=e.name.replace("Synth","Proxy");e.address=n[a].address}return e}).reduce((n,{name:b,source:s,address:i})=>(n[b]=new d.ethers.Contract(i,f[s].abi,a||t||d.ethers.getDefaultProvider(e)),n),{})};a.default=i}])})); \ No newline at end of file +!function(){var a="object"==typeof window?window:{};!a.JS_SHA3_NO_NODE_JS&&"object"==typeof t&&t.versions&&t.versions.node&&(a=n);for(var f=!a.JS_SHA3_NO_COMMON_JS&&e.exports,b="0123456789abcdef".split(""),d=[0,8,16,24],s=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],i=[224,256,384,512],c=["hex","buffer","arrayBuffer","array"],r=function(e,a,t){return function(f){return new T(e,a,e).update(f)[t]()}},u=function(e,a,t){return function(f,n){return new T(e,a,n).update(f)[t]()}},o=function(e,a){var t=r(e,a,"hex");t.create=function(){return new T(e,a,e)},t.update=function(e){return t.create().update(e)};for(var f=0;f>5,this.byteCount=this.blockCount<<2,this.outputBlocks=t>>5,this.extraBytes=(31&t)>>3;for(var f=0;f<50;++f)this.s[f]=0}T.prototype.update=function(e){var a="string"!=typeof e;a&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e));for(var t,f,n=e.length,b=this.blocks,s=this.byteCount,i=this.blockCount,c=0,r=this.s;c>2]|=e[c]<>2]|=f<>2]|=(192|f>>6)<>2]|=(128|63&f)<=57344?(b[t>>2]|=(224|f>>12)<>2]|=(128|f>>6&63)<>2]|=(128|63&f)<>2]|=(240|f>>18)<>2]|=(128|f>>12&63)<>2]|=(128|f>>6&63)<>2]|=(128|63&f)<=s){for(this.start=t-s,this.block=b[i],t=0;t>2]|=this.padding[3&a],this.lastByteIndex===this.byteCount)for(e[0]=e[t],a=1;a>4&15]+b[15&e]+b[e>>12&15]+b[e>>8&15]+b[e>>20&15]+b[e>>16&15]+b[e>>28&15]+b[e>>24&15];s%a==0&&(w(t),d=0)}return n&&(e=t[d],n>0&&(i+=b[e>>4&15]+b[15&e]),n>1&&(i+=b[e>>12&15]+b[e>>8&15]),n>2&&(i+=b[e>>20&15]+b[e>>16&15])),i},T.prototype.arrayBuffer=function(){this.finalize();var e,a=this.blockCount,t=this.s,f=this.outputBlocks,n=this.extraBytes,b=0,d=0,s=this.outputBits>>3;e=n?new ArrayBuffer(f+1<<2):new ArrayBuffer(s);for(var i=new Uint32Array(e);d>8&255,i[e+2]=a>>16&255,i[e+3]=a>>24&255;s%t==0&&w(f)}return b&&(e=s<<2,a=f[d],b>0&&(i[e]=255&a),b>1&&(i[e+1]=a>>8&255),b>2&&(i[e+2]=a>>16&255)),i};var w=function(e){var a,t,f,n,b,d,i,c,r,u,o,p,l,y,m,h,x,g,v,T,w,E,A,M,C,D,S,B,F,_,k,R,P,O,I,N,L,U,X,K,Z,V,q,H,z,j,G,W,$,J,Y,Q,ee,ae,te,fe,ne,be,de,se,ie,ce,re;for(f=0;f<48;f+=2)n=e[0]^e[10]^e[20]^e[30]^e[40],b=e[1]^e[11]^e[21]^e[31]^e[41],d=e[2]^e[12]^e[22]^e[32]^e[42],i=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],r=e[5]^e[15]^e[25]^e[35]^e[45],u=e[6]^e[16]^e[26]^e[36]^e[46],o=e[7]^e[17]^e[27]^e[37]^e[47],a=(p=e[8]^e[18]^e[28]^e[38]^e[48])^(d<<1|i>>>31),t=(l=e[9]^e[19]^e[29]^e[39]^e[49])^(i<<1|d>>>31),e[0]^=a,e[1]^=t,e[10]^=a,e[11]^=t,e[20]^=a,e[21]^=t,e[30]^=a,e[31]^=t,e[40]^=a,e[41]^=t,a=n^(c<<1|r>>>31),t=b^(r<<1|c>>>31),e[2]^=a,e[3]^=t,e[12]^=a,e[13]^=t,e[22]^=a,e[23]^=t,e[32]^=a,e[33]^=t,e[42]^=a,e[43]^=t,a=d^(u<<1|o>>>31),t=i^(o<<1|u>>>31),e[4]^=a,e[5]^=t,e[14]^=a,e[15]^=t,e[24]^=a,e[25]^=t,e[34]^=a,e[35]^=t,e[44]^=a,e[45]^=t,a=c^(p<<1|l>>>31),t=r^(l<<1|p>>>31),e[6]^=a,e[7]^=t,e[16]^=a,e[17]^=t,e[26]^=a,e[27]^=t,e[36]^=a,e[37]^=t,e[46]^=a,e[47]^=t,a=u^(n<<1|b>>>31),t=o^(b<<1|n>>>31),e[8]^=a,e[9]^=t,e[18]^=a,e[19]^=t,e[28]^=a,e[29]^=t,e[38]^=a,e[39]^=t,e[48]^=a,e[49]^=t,y=e[0],m=e[1],j=e[11]<<4|e[10]>>>28,G=e[10]<<4|e[11]>>>28,B=e[20]<<3|e[21]>>>29,F=e[21]<<3|e[20]>>>29,se=e[31]<<9|e[30]>>>23,ie=e[30]<<9|e[31]>>>23,V=e[40]<<18|e[41]>>>14,q=e[41]<<18|e[40]>>>14,O=e[2]<<1|e[3]>>>31,I=e[3]<<1|e[2]>>>31,h=e[13]<<12|e[12]>>>20,x=e[12]<<12|e[13]>>>20,W=e[22]<<10|e[23]>>>22,$=e[23]<<10|e[22]>>>22,_=e[33]<<13|e[32]>>>19,k=e[32]<<13|e[33]>>>19,ce=e[42]<<2|e[43]>>>30,re=e[43]<<2|e[42]>>>30,ae=e[5]<<30|e[4]>>>2,te=e[4]<<30|e[5]>>>2,N=e[14]<<6|e[15]>>>26,L=e[15]<<6|e[14]>>>26,g=e[25]<<11|e[24]>>>21,v=e[24]<<11|e[25]>>>21,J=e[34]<<15|e[35]>>>17,Y=e[35]<<15|e[34]>>>17,R=e[45]<<29|e[44]>>>3,P=e[44]<<29|e[45]>>>3,M=e[6]<<28|e[7]>>>4,C=e[7]<<28|e[6]>>>4,fe=e[17]<<23|e[16]>>>9,ne=e[16]<<23|e[17]>>>9,U=e[26]<<25|e[27]>>>7,X=e[27]<<25|e[26]>>>7,T=e[36]<<21|e[37]>>>11,w=e[37]<<21|e[36]>>>11,Q=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,H=e[8]<<27|e[9]>>>5,z=e[9]<<27|e[8]>>>5,D=e[18]<<20|e[19]>>>12,S=e[19]<<20|e[18]>>>12,be=e[29]<<7|e[28]>>>25,de=e[28]<<7|e[29]>>>25,K=e[38]<<8|e[39]>>>24,Z=e[39]<<8|e[38]>>>24,E=e[48]<<14|e[49]>>>18,A=e[49]<<14|e[48]>>>18,e[0]=y^~h&g,e[1]=m^~x&v,e[10]=M^~D&B,e[11]=C^~S&F,e[20]=O^~N&U,e[21]=I^~L&X,e[30]=H^~j&W,e[31]=z^~G&$,e[40]=ae^~fe&be,e[41]=te^~ne&de,e[2]=h^~g&T,e[3]=x^~v&w,e[12]=D^~B&_,e[13]=S^~F&k,e[22]=N^~U&K,e[23]=L^~X&Z,e[32]=j^~W&J,e[33]=G^~$&Y,e[42]=fe^~be&se,e[43]=ne^~de&ie,e[4]=g^~T&E,e[5]=v^~w&A,e[14]=B^~_&R,e[15]=F^~k&P,e[24]=U^~K&V,e[25]=X^~Z&q,e[34]=W^~J&Q,e[35]=$^~Y&ee,e[44]=be^~se&ce,e[45]=de^~ie&re,e[6]=T^~E&y,e[7]=w^~A&m,e[16]=_^~R&M,e[17]=k^~P&C,e[26]=K^~V&O,e[27]=Z^~q&I,e[36]=J^~Q&H,e[37]=Y^~ee&z,e[46]=se^~ce&ae,e[47]=ie^~re&te,e[8]=E^~y&h,e[9]=A^~m&x,e[18]=R^~M&D,e[19]=P^~C&S,e[28]=V^~O&N,e[29]=q^~I&L,e[38]=Q^~H&j,e[39]=ee^~z&G,e[48]=ce^~ae&fe,e[49]=re^~te&ne,e[0]^=s[f],e[1]^=s[f+1]};if(f)e.exports=l;else for(m=0;m>=8;return a}function n(e,a,t){for(var f=0,n=0;na+1+n&&t.throwError("child data too short",o.Logger.errors.BUFFER_OVERRUN,{})}return{consumed:1+n,result:b}}function d(e,a){if(0===e.length&&t.throwError("data too short",o.Logger.errors.BUFFER_OVERRUN,{}),e[a]>=248){a+1+(s=e[a]-247)>e.length&&t.throwError("data short segment too short",o.Logger.errors.BUFFER_OVERRUN,{});var f=n(e,a+1,s);return a+1+s+f>e.length&&t.throwError("data long segment too short",o.Logger.errors.BUFFER_OVERRUN,{}),b(e,a,a+1+s,s+f)}if(e[a]>=192){var d=e[a]-192;return a+1+d>e.length&&t.throwError("data array too short",o.Logger.errors.BUFFER_OVERRUN,{}),b(e,a,a+1,d)}if(e[a]>=184){var s;a+1+(s=e[a]-183)>e.length&&t.throwError("data array too short",o.Logger.errors.BUFFER_OVERRUN,{});var i=n(e,a+1,s);return a+1+s+i>e.length&&t.throwError("data array too short",o.Logger.errors.BUFFER_OVERRUN,{}),{consumed:1+s+i,result:l.hexlify(e.slice(a+1+s,a+1+s+i))}}if(e[a]>=128){var c=e[a]-128;return a+1+c>e.length&&t.throwError("data too short",o.Logger.errors.BUFFER_OVERRUN,{}),{consumed:1+c,result:l.hexlify(e.slice(a+1,a+1+c))}}return{consumed:1,result:l.hexlify(e[a])}}a.encode=function(e){return l.hexlify(function e(a){if(Array.isArray(a)){var n=[];if(a.forEach((function(a){n=n.concat(e(a))})),n.length<=55)return n.unshift(192+n.length),n;var b=f(n.length);return b.unshift(247+b.length),b.concat(n)}l.isBytesLike(a)||t.throwArgumentError("RLP object must be BytesLike","object",a);var d=Array.prototype.slice.call(l.arrayify(a));if(1===d.length&&d[0]<=127)return d;if(d.length<=55)return d.unshift(128+d.length),d;var s=f(d.length);return s.unshift(183+s.length),s.concat(d)}(e))},a.decode=function(e){var a=l.arrayify(e),f=d(a,0);return f.consumed!==a.length&&t.throwArgumentError("invalid rlp data","data",e),f.result}}))),S=(b(D),D.encode,D.decode,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.version="address/5.0.2"}))),B=(b(S),S.version,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0});var t=new o.Logger(S.version);function f(e){l.isHexString(e,20)||t.throwArgumentError("invalid address","address",e);for(var a=(e=e.toLowerCase()).substring(2).split(""),f=new Uint8Array(40),n=0;n<40;n++)f[n]=a[n].charCodeAt(0);var b=l.arrayify(M.keccak256(f));for(n=0;n<40;n+=2)b[n>>1]>>4>=8&&(a[n]=a[n].toUpperCase()),(15&b[n>>1])>=8&&(a[n+1]=a[n+1].toUpperCase());return"0x"+a.join("")}for(var n={},b=0;b<10;b++)n[String(b)]=String(b);for(b=0;b<26;b++)n[String.fromCharCode(65+b)]=String(10+b);var d,s=Math.floor((d=9007199254740991,Math.log10?Math.log10(d):Math.log(d)/Math.LN10));function i(e){for(var a=(e=(e=e.toUpperCase()).substring(4)+e.substring(0,2)+"00").split("").map((function(e){return n[e]})).join("");a.length>=s;){var t=a.substring(0,s);a=parseInt(t,10)%97+a.substring(t.length)}for(var f=String(98-parseInt(a,10)%97);f.length<2;)f="0"+f;return f}function c(e){var a=null;if("string"!=typeof e&&t.throwArgumentError("invalid address","address",e),e.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==e.substring(0,2)&&(e="0x"+e),a=f(e),e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&a!==e&&t.throwArgumentError("bad address checksum","address",e);else if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(e.substring(2,4)!==i(e)&&t.throwArgumentError("bad icap checksum","address",e),a=new r.BN(e.substring(4),36).toString(16);a.length<40;)a="0"+a;a=f("0x"+a)}else t.throwArgumentError("invalid address","address",e);return a}a.getAddress=c,a.isAddress=function(e){try{return c(e),!0}catch(e){}return!1},a.getIcapAddress=function(e){for(var a=new r.BN(c(e).substring(2),16).toString(36).toUpperCase();a.length<30;)a="0"+a;return"XE"+i("XE00"+a)+a},a.getContractAddress=function(e){var a=null;try{a=c(e.from)}catch(a){t.throwArgumentError("missing from address","transaction",e)}var f=l.stripZeros(l.arrayify(x.BigNumber.from(e.nonce).toHexString()));return c(l.hexDataSlice(M.keccak256(D.encode([a,f])),12))},a.getCreate2Address=function(e,a,f){return 32!==l.hexDataLength(a)&&t.throwArgumentError("salt must be 32 bytes","salt",a),32!==l.hexDataLength(f)&&t.throwArgumentError("initCodeHash must be 32 bytes","initCodeHash",f),c(l.hexDataSlice(M.keccak256(l.concat(["0xff",c(e),a,f])),12))}}))),F=(b(B),B.getAddress,B.isAddress,B.getIcapAddress,B.getContractAddress,B.getCreate2Address,d((function(e,a){var t,f=n&&n.__extends||(t=function(e,a){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,a){e.__proto__=a}||function(e,a){for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])})(e,a)},function(e,a){function f(){this.constructor=e}t(e,a),e.prototype=null===a?Object.create(a):(f.prototype=a.prototype,new f)});Object.defineProperty(a,"__esModule",{value:!0});var b=function(e){function a(a){return e.call(this,"address","address",a,!1)||this}return f(a,e),a.prototype.encode=function(e,a){try{B.getAddress(a)}catch(e){this._throwError(e.message,a)}return e.writeValue(a)},a.prototype.decode=function(e){return B.getAddress(l.hexZeroPad(e.readValue().toHexString(),20))},a}(E.Coder);a.AddressCoder=b}))),_=(b(F),F.AddressCoder,d((function(e,a){var t,f=n&&n.__extends||(t=function(e,a){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,a){e.__proto__=a}||function(e,a){for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])})(e,a)},function(e,a){function f(){this.constructor=e}t(e,a),e.prototype=null===a?Object.create(a):(f.prototype=a.prototype,new f)});Object.defineProperty(a,"__esModule",{value:!0});var b=function(e){function a(a){var t=e.call(this,a.name,a.type,void 0,a.dynamic)||this;return t.coder=a,t}return f(a,e),a.prototype.encode=function(e,a){return this.coder.encode(e,a)},a.prototype.decode=function(e){return this.coder.decode(e)},a}(E.Coder);a.AnonymousCoder=b}))),k=(b(_),_.AnonymousCoder,d((function(e,a){var t,f=n&&n.__extends||(t=function(e,a){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,a){e.__proto__=a}||function(e,a){for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])})(e,a)},function(e,a){function f(){this.constructor=e}t(e,a),e.prototype=null===a?Object.create(a):(f.prototype=a.prototype,new f)});Object.defineProperty(a,"__esModule",{value:!0});var b=new o.Logger(T.version);function d(e,a,t){var f=null;if(Array.isArray(t))f=t;else if(t&&"object"==typeof t){var n={};f=a.map((function(e){var a=e.localName;return a||b.throwError("cannot encode object for signature with missing names",o.Logger.errors.INVALID_ARGUMENT,{argument:"values",coder:e,value:t}),n[a]&&b.throwError("cannot encode object for signature with duplicate names",o.Logger.errors.INVALID_ARGUMENT,{argument:"values",coder:e,value:t}),n[a]=!0,t[a]}))}else b.throwArgumentError("invalid tuple value","tuple",t);a.length!==f.length&&b.throwArgumentError("types/value length mismatch","tuple",t);var d=new E.Writer(e.wordSize),s=new E.Writer(e.wordSize),i=[];a.forEach((function(e,a){var t=f[a];if(e.dynamic){var n=s.length;e.encode(s,t);var b=d.writeUpdatableValue();i.push((function(e){b(e+n)}))}else e.encode(d,t)})),i.forEach((function(e){e(d.length)}));var c=e.writeBytes(d.data);return c+=e.writeBytes(s.data)}function s(e,a){var t=[],f=e.subReader(0),n=0;a.forEach((function(a){var b=null;if(a.dynamic){var d=e.readValue(),s=f.subReader(d.toNumber());try{b=a.decode(s)}catch(e){if(e.code===o.Logger.errors.BUFFER_OVERRUN)throw e;(b=e).baseType=a.name,b.name=a.localName,b.type=a.type}n+=s.consumed}else try{b=a.decode(e)}catch(e){if(e.code===o.Logger.errors.BUFFER_OVERRUN)throw e;(b=e).baseType=a.name,b.name=a.localName,b.type=a.type}null!=b&&t.push(b)})),e.readBytes(n);var b=a.reduce((function(e,a){var t=a.localName;return t&&(e[t]||(e[t]=0),e[t]++),e}),{});a.forEach((function(e,a){var f=e.localName;if(f&&1===b[f]&&("length"===f&&(f="_length"),null==t[f])){var n=t[a];n instanceof Error?Object.defineProperty(t,f,{get:function(){throw n}}):t[f]=n}}));for(var d=function(e){var a=t[e];a instanceof Error&&Object.defineProperty(t,e,{get:function(){throw a}})},s=0;s=0?t:"")+"]",d=-1===t||a.dynamic;return(n=e.call(this,"array",b,f,d)||this).coder=a,n.length=t,n}return f(a,e),a.prototype.encode=function(e,a){Array.isArray(a)||this._throwError("expected array value",a);var t=this.length;-1===t&&(t=a.length,e.writeValue(a.length)),b.checkArgumentCount(t,a.length,"coder array"+(this.localName?" "+this.localName:""));for(var f=[],n=0;n>6==2;s++)d++;return d}return e===f.OVERRUN?t.length-a-1:0}function d(e,t){null==t&&(t=a.Utf8ErrorFuncs.error),e=l.arrayify(e);for(var n=[],b=0;b>7!=0){var s=null,i=null;if(192==(224&d))s=1,i=127;else if(224==(240&d))s=2,i=2047;else{if(240!=(248&d)){b+=t(128==(192&d)?f.UNEXPECTED_CONTINUE:f.BAD_PREFIX,b-1,e,n);continue}s=3,i=65535}if(b-1+s>=e.length)b+=t(f.OVERRUN,b-1,e,n);else{for(var c=d&(1<<8-s-1)-1,r=0;r1114111?b+=t(f.OUT_OF_RANGE,b-1-s,e,n,c):c>=55296&&c<=57343?b+=t(f.UTF16_SURROGATE,b-1-s,e,n,c):c<=i?b+=t(f.OVERLONG,b-1-s,e,n,c):n.push(c))}}else n.push(d)}return n}function s(e,a){void 0===a&&(a=t.current),a!=t.current&&(n.checkNormalize(),e=e.normalize(a));for(var f=[],b=0;b>6|192),f.push(63&d|128);else if(55296==(64512&d)){b++;var s=e.charCodeAt(b);if(b>=e.length||56320!=(64512&s))throw new Error("invalid utf-8 string");var i=65536+((1023&d)<<10)+(1023&s);f.push(i>>18|240),f.push(i>>12&63|128),f.push(i>>6&63|128),f.push(63&i|128)}else f.push(d>>12|224),f.push(d>>6&63|128),f.push(63&d|128)}return l.arrayify(f)}function i(e){var a="0000"+e.toString(16);return"\\u"+a.substring(a.length-4)}function c(e){return e.map((function(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10&1023),56320+(1023&e)))})).join("")}!function(e){e.current="",e.NFC="NFC",e.NFD="NFD",e.NFKC="NFKC",e.NFKD="NFKD"}(t=a.UnicodeNormalizationForm||(a.UnicodeNormalizationForm={})),function(e){e.UNEXPECTED_CONTINUE="unexpected continuation byte",e.BAD_PREFIX="bad codepoint prefix",e.OVERRUN="string overrun",e.MISSING_CONTINUE="missing continuation byte",e.OUT_OF_RANGE="out of UTF-8 range",e.UTF16_SURROGATE="UTF-16 surrogate",e.OVERLONG="overlong representation"}(f=a.Utf8ErrorReason||(a.Utf8ErrorReason={})),a.Utf8ErrorFuncs=Object.freeze({error:function(e,a,t,f,b){return n.throwArgumentError("invalid codepoint at offset "+a+"; "+e,"bytes",t)},ignore:b,replace:function(e,a,t,n,d){return e===f.OVERLONG?(n.push(d),0):(n.push(65533),b(e,a,t))}}),a.toUtf8Bytes=s,a._toEscapedUtf8String=function(e,a){return'"'+d(e,a).map((function(e){if(e<256){switch(e){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(e>=32&&e<127)return String.fromCharCode(e)}return e<=65535?i(e):i(55296+((e-=65536)>>10&1023))+i(56320+(1023&e))})).join("")+'"'},a._toUtf8String=c,a.toUtf8String=function(e,a){return c(d(e,a))},a.toUtf8CodePoints=function(e,a){return void 0===a&&(a=t.current),d(s(e,a))}}))),K=(b(X),X.UnicodeNormalizationForm,X.Utf8ErrorReason,X.Utf8ErrorFuncs,X.toUtf8Bytes,X._toEscapedUtf8String,X._toUtf8String,X.toUtf8String,X.toUtf8CodePoints,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.formatBytes32String=function(e){var a=X.toUtf8Bytes(e);if(a.length>31)throw new Error("bytes32 string must be less than 32 bytes");return l.hexlify(l.concat([a,N.HashZero]).slice(0,32))},a.parseBytes32String=function(e){var a=l.arrayify(e);if(32!==a.length)throw new Error("invalid bytes32 - not 32 bytes long");if(0!==a[31])throw new Error("invalid bytes32 string - no null terminator");for(var t=31;0===a[t-1];)t--;return X.toUtf8String(a.slice(0,t))}}))),Z=(b(K),K.formatBytes32String,K.parseBytes32String,d((function(e,a){function t(e,a){a||(a=function(e){return[parseInt(e,16)]});var t=0,f={};return e.split(",").forEach((function(e){var n=e.split(":");t+=parseInt(n[0],16),f[t]=a(n[1])})),f}function f(e){var a=0;return e.split(",").map((function(e){var t=e.split("-");return 1===t.length?t[1]="0":""===t[1]&&(t[1]="1"),{l:a+parseInt(t[0],16),h:a=parseInt(t[1],16)}}))}function n(e,a){for(var t=0,f=0;f=(t+=n.l)&&e<=t+n.h&&(e-t)%(n.d||1)==0){if(n.e&&-1!==n.e.indexOf(e-t))continue;return n}}return null}Object.defineProperty(a,"__esModule",{value:!0});var b=f("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),d="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map((function(e){return parseInt(e,16)})),s=[{h:25,s:32,l:65},{h:30,s:32,e:[23],l:127},{h:54,s:1,e:[48],l:64,d:2},{h:14,s:1,l:57,d:2},{h:44,s:1,l:17,d:2},{h:10,s:1,e:[2,6,8],l:61,d:2},{h:16,s:1,l:68,d:2},{h:84,s:1,e:[18,24,66],l:19,d:2},{h:26,s:32,e:[17],l:435},{h:22,s:1,l:71,d:2},{h:15,s:80,l:40},{h:31,s:32,l:16},{h:32,s:1,l:80,d:2},{h:52,s:1,l:42,d:2},{h:12,s:1,l:55,d:2},{h:40,s:1,e:[38],l:15,d:2},{h:14,s:1,l:48,d:2},{h:37,s:48,l:49},{h:148,s:1,l:6351,d:2},{h:88,s:1,l:160,d:2},{h:15,s:16,l:704},{h:25,s:26,l:854},{h:25,s:32,l:55915},{h:37,s:40,l:1247},{h:25,s:-119711,l:53248},{h:25,s:-119763,l:52},{h:25,s:-119815,l:52},{h:25,s:-119867,e:[1,4,5,7,8,11,12,17],l:52},{h:25,s:-119919,l:52},{h:24,s:-119971,e:[2,7,8,17],l:52},{h:24,s:-120023,e:[2,7,13,15,16,17],l:52},{h:25,s:-120075,l:52},{h:25,s:-120127,l:52},{h:25,s:-120179,l:52},{h:25,s:-120231,l:52},{h:25,s:-120283,l:52},{h:25,s:-120335,l:52},{h:24,s:-119543,e:[17],l:56},{h:24,s:-119601,e:[17],l:58},{h:24,s:-119659,e:[17],l:58},{h:24,s:-119717,e:[17],l:58},{h:24,s:-119775,e:[17],l:58}],i=t("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),c=t("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),r=t("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",(function(e){if(e.length%4!=0)throw new Error("bad data");for(var a=[],t=0;t=0)return[];if(e>=65024&&e<=65039)return[];var a=p(e);return a||[e]})),t=a.reduce((function(e,a){return a.forEach((function(a){e.push(a)})),e}),[]),(t=X.toUtf8CodePoints(X._toUtf8String(t),X.UnicodeNormalizationForm.NFKC)).forEach((function(e){if(l(e))throw new Error("STRINGPREP_CONTAINS_PROHIBITED")})),t.forEach((function(e){if(o(e))throw new Error("STRINGPREP_CONTAINS_UNASSIGNED")}));var f=X._toUtf8String(t);if("-"===f.substring(0,1)||"--"===f.substring(2,4)||"-"===f.substring(f.length-1))throw new Error("invalid hyphen");if(f.length>63)throw new Error("too long");return f}}))),V=(b(Z),Z._nameprepTableA1,Z._nameprepTableB2,Z._nameprepTableC,Z.nameprep,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.formatBytes32String=K.formatBytes32String,a.parseBytes32String=K.parseBytes32String,a.nameprep=Z.nameprep,a._toEscapedUtf8String=X._toEscapedUtf8String,a.toUtf8Bytes=X.toUtf8Bytes,a.toUtf8CodePoints=X.toUtf8CodePoints,a.toUtf8String=X.toUtf8String,a.UnicodeNormalizationForm=X.UnicodeNormalizationForm,a.Utf8ErrorFuncs=X.Utf8ErrorFuncs,a.Utf8ErrorReason=X.Utf8ErrorReason}))),q=(b(V),V.formatBytes32String,V.parseBytes32String,V.nameprep,V._toEscapedUtf8String,V.toUtf8Bytes,V.toUtf8CodePoints,V.toUtf8String,V.UnicodeNormalizationForm,V.Utf8ErrorFuncs,V.Utf8ErrorReason,d((function(e,a){var t,f=n&&n.__extends||(t=function(e,a){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,a){e.__proto__=a}||function(e,a){for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])})(e,a)},function(e,a){function f(){this.constructor=e}t(e,a),e.prototype=null===a?Object.create(a):(f.prototype=a.prototype,new f)});Object.defineProperty(a,"__esModule",{value:!0});var b=function(e){function a(a){return e.call(this,"string",a)||this}return f(a,e),a.prototype.encode=function(a,t){return e.prototype.encode.call(this,a,V.toUtf8Bytes(t))},a.prototype.decode=function(a){return V.toUtf8String(e.prototype.decode.call(this,a))},a}(P.DynamicBytesCoder);a.StringCoder=b}))),H=(b(q),q.StringCoder,d((function(e,a){var t,f=n&&n.__extends||(t=function(e,a){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,a){e.__proto__=a}||function(e,a){for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])})(e,a)},function(e,a){function f(){this.constructor=e}t(e,a),e.prototype=null===a?Object.create(a):(f.prototype=a.prototype,new f)});Object.defineProperty(a,"__esModule",{value:!0});var b=function(e){function a(a,t){var f=this,n=!1,b=[];a.forEach((function(e){e.dynamic&&(n=!0),b.push(e.type)}));var d="tuple("+b.join(",")+")";return(f=e.call(this,"tuple",d,t,n)||this).coders=a,f}return f(a,e),a.prototype.encode=function(e,a){return k.pack(e,this.coders,a)},a.prototype.decode=function(e){return e.coerce(this.name,k.unpack(e,this.coders))},a}(E.Coder);a.TupleCoder=b}))),z=(b(H),H.TupleCoder,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0});var t=new o.Logger(T.version),f=new RegExp(/^bytes([0-9]*)$/),n=new RegExp(/^(u?int)([0-9]*)$/),b=function(){function e(a){var f=this.constructor;t.checkNew(f,e),v.defineReadOnly(this,"coerceFunc",a||null)}return e.prototype._getCoder=function(e){var a=this;switch(e.baseType){case"address":return new F.AddressCoder(e.name);case"bool":return new R.BooleanCoder(e.name);case"string":return new q.StringCoder(e.name);case"bytes":return new P.BytesCoder(e.name);case"array":return new k.ArrayCoder(this._getCoder(e.arrayChildren),e.arrayLength,e.name);case"tuple":return new H.TupleCoder((e.components||[]).map((function(e){return a._getCoder(e)})),e.name);case"":return new I.NullCoder(e.name)}var b,d=e.type.match(n);return d?((0===(b=parseInt(d[2]||"256"))||b>256||b%8!=0)&&t.throwArgumentError("invalid "+d[1]+" bit length","param",e),new L.NumberCoder(b/8,"int"===d[1],e.name)):(d=e.type.match(f))?((0===(b=parseInt(d[1]))||b>32)&&t.throwArgumentError("invalid bytes length","param",e),new O.FixedBytesCoder(b,e.name)):t.throwArgumentError("invalid type","type",e.type)},e.prototype._getWordSize=function(){return 32},e.prototype._getReader=function(e){return new E.Reader(e,this._getWordSize(),this.coerceFunc)},e.prototype._getWriter=function(){return new E.Writer(this._getWordSize())},e.prototype.encode=function(e,a){var f=this;e.length!==a.length&&t.throwError("types/values length mismatch",o.Logger.errors.INVALID_ARGUMENT,{count:{types:e.length,values:a.length},value:{types:e,values:a}});var n=e.map((function(e){return f._getCoder(w.ParamType.from(e))})),b=new H.TupleCoder(n,"_"),d=this._getWriter();return b.encode(d,a),d.data},e.prototype.decode=function(e,a){var t=this,f=e.map((function(e){return t._getCoder(w.ParamType.from(e))}));return new H.TupleCoder(f,"_").decode(this._getReader(l.arrayify(a)))},e}();a.AbiCoder=b,a.defaultAbiCoder=new b}))),j=(b(z),z.AbiCoder,z.defaultAbiCoder,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.version="hash/5.0.2"}))),G=(b(j),j.version,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0});var t=new o.Logger(j.version),f=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),n=new RegExp("^((.*)\\.)?([^.]+)$");a.isValidName=function(e){try{for(var a=e.split("."),t=0;t1&&b.throwArgumentError("multiple matching functions","name",t),this.functions[f[0]]}var n=this.functions[w.FunctionFragment.fromString(e).format()];return n||b.throwArgumentError("no matching function","signature",e),n},e.prototype.getEvent=function(e){if(l.isHexString(e)){var a=e.toLowerCase();for(var t in this.events)if(a===this.getEventTopic(t))return this.events[t];b.throwArgumentError("no matching event","topichash",a)}if(-1===e.indexOf("(")){var f=e.trim(),n=Object.keys(this.events).filter((function(e){return e.split("(")[0]===f}));return 0===n.length?b.throwArgumentError("no matching event","name",f):n.length>1&&b.throwArgumentError("multiple matching events","name",f),this.events[n[0]]}var d=this.events[w.EventFragment.fromString(e).format()];return d||b.throwArgumentError("no matching event","signature",e),d},e.prototype.getSighash=function(e){return"string"==typeof e&&(e=this.getFunction(e)),v.getStatic(this.constructor,"getSighash")(e)},e.prototype.getEventTopic=function(e){return"string"==typeof e&&(e=this.getEvent(e)),v.getStatic(this.constructor,"getEventTopic")(e)},e.prototype._decodeParams=function(e,a){return this._abiCoder.decode(e,a)},e.prototype._encodeParams=function(e,a){return this._abiCoder.encode(e,a)},e.prototype.encodeDeploy=function(e){return this._encodeParams(this.deploy.inputs,e||[])},e.prototype.decodeFunctionData=function(e,a){"string"==typeof e&&(e=this.getFunction(e));var t=l.arrayify(a);return l.hexlify(t.slice(0,4))!==this.getSighash(e)&&b.throwArgumentError("data signature does not match function "+e.name+".","data",l.hexlify(t)),this._decodeParams(e.inputs,t.slice(4))},e.prototype.encodeFunctionData=function(e,a){return"string"==typeof e&&(e=this.getFunction(e)),l.hexlify(l.concat([this.getSighash(e),this._encodeParams(e.inputs,a||[])]))},e.prototype.decodeFunctionResult=function(e,a){"string"==typeof e&&(e=this.getFunction(e));var t=l.arrayify(a),f=null,n=null;switch(t.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(e.outputs,t)}catch(e){}break;case 4:"0x08c379a0"===l.hexlify(t.slice(0,4))&&(n="Error(string)",f=this._abiCoder.decode(["string"],t.slice(4))[0])}return b.throwError("call revert exception",o.Logger.errors.CALL_EXCEPTION,{method:e.format(),errorSignature:n,errorArgs:[f],reason:f})},e.prototype.encodeFunctionResult=function(e,a){return"string"==typeof e&&(e=this.getFunction(e)),l.hexlify(this._abiCoder.encode(e.outputs,a||[]))},e.prototype.encodeFilterTopics=function(e,a){var t=this;"string"==typeof e&&(e=this.getEvent(e)),a.length>e.inputs.length&&b.throwError("too many arguments for "+e.format(),o.Logger.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:a});var f=[];e.anonymous||f.push(this.getEventTopic(e));var n=function(e,a){return"string"===e.type?G.id(a):"bytes"===e.type?M.keccak256(l.hexlify(a)):("address"===e.type&&t._abiCoder.encode(["address"],[a]),l.hexZeroPad(l.hexlify(a),32))};for(a.forEach((function(a,t){var d=e.inputs[t];d.indexed?null==a?f.push(null):"array"===d.baseType||"tuple"===d.baseType?b.throwArgumentError("filtering with tuples or arrays not supported","contract."+d.name,a):Array.isArray(a)?f.push(a.map((function(e){return n(d,e)}))):f.push(n(d,a)):null!=a&&b.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+d.name,a)}));f.length&&null===f[f.length-1];)f.pop();return f},e.prototype.encodeEventLog=function(e,a){var t=this;"string"==typeof e&&(e=this.getEvent(e));var f=[],n=[],d=[];return e.anonymous||f.push(this.getEventTopic(e)),a.length!==e.inputs.length&&b.throwArgumentError("event arguments/values mismatch","values",a),e.inputs.forEach((function(e,b){var s=a[b];if(e.indexed)if("string"===e.type)f.push(G.id(s));else if("bytes"===e.type)f.push(M.keccak256(s));else{if("tuple"===e.baseType||"array"===e.baseType)throw new Error("not implemented");f.push(t._abiCoder.encode([e.type],[s]))}else n.push(e),d.push(s)})),{data:this._abiCoder.encode(n,d),topics:f}},e.prototype.decodeEventLog=function(e,a,t){if("string"==typeof e&&(e=this.getEvent(e)),null!=t&&!e.anonymous){var f=this.getEventTopic(e);l.isHexString(t[0],32)&&t[0].toLowerCase()===f||b.throwError("fragment/topic mismatch",o.Logger.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:f,value:t[0]}),t=t.slice(1)}var n=[],d=[],s=[];e.inputs.forEach((function(e,a){e.indexed?"string"===e.type||"bytes"===e.type||"tuple"===e.baseType||"array"===e.baseType?(n.push(w.ParamType.fromObject({type:"bytes32",name:e.name})),s.push(!0)):(n.push(e),s.push(!1)):(d.push(e),s.push(!1))}));var r=null!=t?this._abiCoder.decode(n,l.concat(t)):null,u=this._abiCoder.decode(d,a),p=[],y=0,m=0;e.inputs.forEach((function(e,a){if(e.indexed)if(null==r)p[a]=new i({_isIndexed:!0,hash:null});else if(s[a])p[a]=new i({_isIndexed:!0,hash:r[m++]});else try{p[a]=r[m++]}catch(e){p[a]=e}else try{p[a]=u[y++]}catch(e){p[a]=e}if(e.name&&null==p[e.name]){var t=p[a];t instanceof Error?Object.defineProperty(p,e.name,{get:function(){throw c("property "+JSON.stringify(e.name),t)}}):p[e.name]=t}}));for(var h=function(e){var a=p[e];a instanceof Error&&Object.defineProperty(p,e,{get:function(){throw c("index "+e,a)}})},x=0;x0&&n[n.length-1])||6!==b[0]&&2!==b[0])){d=0;continue}if(3===b[0]&&(!n||b[1]>n[0]&&b[1]0&&n[n.length-1])||6!==b[0]&&2!==b[0])){d=0;continue}if(3===b[0]&&(!n||b[1]>n[0]&&b[1]1)){var t=a[0];null==s[e]&&v.defineReadOnly(s,e,s[t]),null==s.functions[e]&&v.defineReadOnly(s.functions,e,s.functions[t]),null==s.callStatic[e]&&v.defineReadOnly(s.callStatic,e,s.callStatic[t]),null==s.populateTransaction[e]&&v.defineReadOnly(s.populateTransaction,e,s.populateTransaction[t]),null==s.estimateGas[e]&&v.defineReadOnly(s.estimateGas,e,s.estimateGas[t])}}))}return e.getContractAddress=function(e){return B.getContractAddress(e)},e.getInterface=function(e){return $.Interface.isInterface(e)?e:new $.Interface(e)},e.prototype.deployed=function(){return this._deployed()},e.prototype._deployed=function(e){var a=this;return this._deployedPromise||(this.deployTransaction?this._deployedPromise=this.deployTransaction.wait().then((function(){return a})):this._deployedPromise=this.provider.getCode(this.address,e).then((function(e){return"0x"===e&&i.throwError("contract not deployed",o.Logger.errors.UNSUPPORTED_OPERATION,{contractAddress:a.address,operation:"getDeployed"}),a}))),this._deployedPromise},e.prototype.fallback=function(e){var a=this;this.signer||i.throwError("sending a transactions require a signer",o.Logger.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction(fallback)"});var t=v.shallowCopy(e||{});return["from","to"].forEach((function(e){null!=t[e]&&i.throwError("cannot override "+e,o.Logger.errors.UNSUPPORTED_OPERATION,{operation:e})})),t.to=this.resolvedAddress,this.deployed().then((function(){return a.signer.sendTransaction(t)}))},e.prototype.connect=function(e){"string"==typeof e&&(e=new ee.VoidSigner(e,this.provider));var a=new this.constructor(this.address,this.interface,e);return this.deployTransaction&&v.defineReadOnly(a,"deployTransaction",this.deployTransaction),a},e.prototype.attach=function(e){return new this.constructor(e,this.interface,this.signer||this.provider)},e.isIndexed=function(e){return $.Indexed.isIndexed(e)},e.prototype._normalizeRunningEvent=function(e){return this._runningEvents[e.tag]?this._runningEvents[e.tag]:e},e.prototype._getRunningEvent=function(e){if("string"==typeof e){if("error"===e)return this._normalizeRunningEvent(new T);if("event"===e)return this._normalizeRunningEvent(new g("event",null));if("*"===e)return this._normalizeRunningEvent(new E(this.address,this.interface));var a=this.interface.getEvent(e);return this._normalizeRunningEvent(new w(this.address,this.interface,a))}if(e.topics&&e.topics.length>0){try{var t=e.topics[0];if("string"!=typeof t)throw new Error("invalid topic");return a=this.interface.getEvent(t),this._normalizeRunningEvent(new w(this.address,this.interface,a,e.topics))}catch(e){}var f={address:this.address,topics:e.topics};return this._normalizeRunningEvent(new g(h(f),f))}return this._normalizeRunningEvent(new E(this.address,this.interface))},e.prototype._checkRunningEvents=function(e){if(0===e.listenerCount()){delete this._runningEvents[e.tag];var a=this._wrappedEmits[e.tag];a&&(this.provider.off(e.filter,a),delete this._wrappedEmits[e.tag])}},e.prototype._wrapEvent=function(e,a,t){var f=this,n=v.deepCopy(a);return n.removeListener=function(){t&&(e.removeListener(t),f._checkRunningEvents(e))},n.getBlock=function(){return f.provider.getBlock(a.blockHash)},n.getTransaction=function(){return f.provider.getTransaction(a.transactionHash)},n.getTransactionReceipt=function(){return f.provider.getTransactionReceipt(a.transactionHash)},e.prepareEvent(n),n},e.prototype._addEventListener=function(e,a,t){var f=this;if(this.provider||i.throwError("events require a provider or a signer with a provider",o.Logger.errors.UNSUPPORTED_OPERATION,{operation:"once"}),e.addListener(a,t),this._runningEvents[e.tag]=e,!this._wrappedEmits[e.tag]){var n=function(t){var n=f._wrapEvent(e,t,a);if(null==n.decodeError)try{var b=e.getEmit(n);f.emit.apply(f,s([e.filter],b))}catch(e){n.decodeError=e.error}null!=e.filter&&f.emit("event",n),null!=n.decodeError&&f.emit("error",n.decodeError,n)};this._wrappedEmits[e.tag]=n,null!=e.filter&&this.provider.on(e.filter,n)}},e.prototype.queryFilter=function(e,a,t){var f=this,n=this._getRunningEvent(e),b=v.shallowCopy(n.filter);return"string"==typeof a&&l.isHexString(a,32)?(null!=t&&i.throwArgumentError("cannot specify toBlock with blockhash","toBlock",t),b.blockHash=a):(b.fromBlock=null!=a?a:0,b.toBlock=null!=t?t:"latest"),this.provider.getLogs(b).then((function(e){return e.map((function(e){return f._wrapEvent(n,e,null)}))}))},e.prototype.on=function(e,a){return this._addEventListener(this._getRunningEvent(e),a,!1),this},e.prototype.once=function(e,a){return this._addEventListener(this._getRunningEvent(e),a,!0),this},e.prototype.emit=function(e){for(var a=[],t=1;t0;return this._checkRunningEvents(f),n},e.prototype.listenerCount=function(e){return this.provider?this._getRunningEvent(e).listenerCount():0},e.prototype.listeners=function(e){if(!this.provider)return[];if(null==e){var a=[];for(var t in this._runningEvents)this._runningEvents[t].listeners().forEach((function(e){a.push(e)}));return a}return this._getRunningEvent(e).listeners()},e.prototype.removeAllListeners=function(e){if(!this.provider)return this;if(null==e){for(var a in this._runningEvents){var t=this._runningEvents[a];t.removeAllListeners(),this._checkRunningEvents(t)}return this}var f=this._getRunningEvent(e);return f.removeAllListeners(),this._checkRunningEvents(f),this},e.prototype.off=function(e,a){if(!this.provider)return this;var t=this._getRunningEvent(e);return t.removeListener(a),this._checkRunningEvents(t),this},e.prototype.removeListener=function(e,a){return this.off(e,a)},e}();a.Contract=A;var M=function(){function e(e,a,t){var f=this.constructor,n=null;"0x"!==(n="string"==typeof a?a:l.isBytes(a)?l.hexlify(a):a&&"string"==typeof a.object?a.object:"!").substring(0,2)&&(n="0x"+n),(!l.isHexString(n)||n.length%2)&&i.throwArgumentError("invalid bytecode","bytecode",a),t&&!ee.Signer.isSigner(t)&&i.throwArgumentError("invalid signer","signer",t),v.defineReadOnly(this,"bytecode",n),v.defineReadOnly(this,"interface",v.getStatic(f,"getInterface")(e)),v.defineReadOnly(this,"signer",t||null)}return e.prototype.getDeployTransaction=function(){for(var e=[],a=0;a0;)t.push(n%this.base),n=n/this.base|0}for(var d="",s=0;0===a[s]&&s=0;--i)d+=this.alphabet[t[i]];return d},e.prototype.decode=function(e){if("string"!=typeof e)throw new TypeError("Expected String");var a=[];if(0===e.length)return new Uint8Array(a);a.push(0);for(var t=0;t>=8;for(;n>0;)a.push(255&n),n>>=8}for(var d=0;e[d]===this._leader&&d>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function ie(e){return 1===e.length?"0"+e:e}function ce(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}var re={inherits:de,toArray:function(e,a){if(Array.isArray(e))return e.slice();if(!e)return[];var t=[];if("string"==typeof e)if(a){if("hex"===a)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),f=0;f>8,d=255&n;b?t.push(b,d):t.push(d)}else for(f=0;f>>0}return b},split32:function(e,a){for(var t=new Array(4*e.length),f=0,n=0;f>>24,t[n+1]=b>>>16&255,t[n+2]=b>>>8&255,t[n+3]=255&b):(t[n+3]=b>>>24,t[n+2]=b>>>16&255,t[n+1]=b>>>8&255,t[n]=255&b)}return t},rotr32:function(e,a){return e>>>a|e<<32-a},rotl32:function(e,a){return e<>>32-a},sum32:function(e,a){return e+a>>>0},sum32_3:function(e,a,t){return e+a+t>>>0},sum32_4:function(e,a,t,f){return e+a+t+f>>>0},sum32_5:function(e,a,t,f,n){return e+a+t+f+n>>>0},sum64:function(e,a,t,f){var n=e[a],b=f+e[a+1]>>>0,d=(b>>0,e[a+1]=b},sum64_hi:function(e,a,t,f){return(a+f>>>0>>0},sum64_lo:function(e,a,t,f){return a+f>>>0},sum64_4_hi:function(e,a,t,f,n,b,d,s){var i=0,c=a;return i+=(c=c+f>>>0)>>0)>>0)>>0},sum64_4_lo:function(e,a,t,f,n,b,d,s){return a+f+b+s>>>0},sum64_5_hi:function(e,a,t,f,n,b,d,s,i,c){var r=0,u=a;return r+=(u=u+f>>>0)>>0)>>0)>>0)>>0},sum64_5_lo:function(e,a,t,f,n,b,d,s,i,c){return a+f+b+s+c>>>0},rotr64_hi:function(e,a,t){return(a<<32-t|e>>>t)>>>0},rotr64_lo:function(e,a,t){return(e<<32-t|a>>>t)>>>0},shr64_hi:function(e,a,t){return e>>>t},shr64_lo:function(e,a,t){return(e<<32-t|a>>>t)>>>0}};function ue(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}var oe=ue;ue.prototype.update=function(e,a){if(e=re.toArray(e,a),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var t=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-t,e.length),0===this.pending.length&&(this.pending=null),e=re.join32(e,0,e.length-t,this.endian);for(var f=0;f>>24&255,f[n++]=e>>>16&255,f[n++]=e>>>8&255,f[n++]=255&e}else for(f[n++]=255&e,f[n++]=e>>>8&255,f[n++]=e>>>16&255,f[n++]=e>>>24&255,f[n++]=0,f[n++]=0,f[n++]=0,f[n++]=0,b=8;b>>3},g1_256:function(e){return le(e,17)^le(e,19)^e>>>10}},ge=re.sum32,ve=re.sum32_4,Te=re.sum32_5,we=xe.ch32,Ee=xe.maj32,Ae=xe.s0_256,Me=xe.s1_256,Ce=xe.g0_256,De=xe.g1_256,Se=pe.BlockHash,Be=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Fe(){if(!(this instanceof Fe))return new Fe;Se.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=Be,this.W=new Array(64)}re.inherits(Fe,Se);var _e=Fe;Fe.blockSize=512,Fe.outSize=256,Fe.hmacStrength=192,Fe.padLength=64,Fe.prototype._update=function(e,a){for(var t=this.W,f=0;f<16;f++)t[f]=e[a+f];for(;fthis.blockSize&&(e=(new this.Hash).update(e).digest()),ne(e.length<=this.blockSize);for(var a=e.length;a>24&255,r[a.length+1]=u>>16&255,r[a.length+2]=u>>8&255,r[a.length+3]=255&u;var o=l.arrayify(Ma.computeHmac(n,e,r));b||(b=o.length,s=new Uint8Array(b),d=f-((i=Math.ceil(f/b))-1)*b),s.set(o);for(var p=1;p=49&&d<=54?d-49+10:d>=17&&d<=22?d-17+10:15&d}return f}function s(e,a,t,f){for(var n=0,b=Math.min(e.length,t),d=a;d=49?s-49+10:s>=17?s-17+10:s}return n}n.isBN=function(e){return e instanceof n||null!==e&&"object"==typeof e&&e.constructor.wordSize===n.wordSize&&Array.isArray(e.words)},n.max=function(e,a){return e.cmp(a)>0?e:a},n.min=function(e,a){return e.cmp(a)<0?e:a},n.prototype._init=function(e,a,f){if("number"==typeof e)return this._initNumber(e,a,f);if("object"==typeof e)return this._initArray(e,a,f);"hex"===a&&(a=16),t(a===(0|a)&&a>=2&&a<=36);var n=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&n++,16===a?this._parseHex(e,n):this._parseBase(e,a,n),"-"===e[0]&&(this.negative=1),this.strip(),"le"===f&&this._initArray(this.toArray(),a,f)},n.prototype._initNumber=function(e,a,f){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(t(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===f&&this._initArray(this.toArray(),a,f)},n.prototype._initArray=function(e,a,f){if(t("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var n=0;n=0;n-=3)d=e[n]|e[n-1]<<8|e[n-2]<<16,this.words[b]|=d<>>26-s&67108863,(s+=24)>=26&&(s-=26,b++);else if("le"===f)for(n=0,b=0;n>>26-s&67108863,(s+=24)>=26&&(s-=26,b++);return this.strip()},n.prototype._parseHex=function(e,a){this.length=Math.ceil((e.length-a)/6),this.words=new Array(this.length);for(var t=0;t=a;t-=6)n=d(e,t,t+6),this.words[f]|=n<>>26-b&4194303,(b+=24)>=26&&(b-=26,f++);t+6!==a&&(n=d(e,a,t+6),this.words[f]|=n<>>26-b&4194303),this.strip()},n.prototype._parseBase=function(e,a,t){this.words=[0],this.length=1;for(var f=0,n=1;n<=67108863;n*=a)f++;f--,n=n/a|0;for(var b=e.length-t,d=b%f,i=Math.min(b,b-d)+t,c=0,r=t;r1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?""};var i=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],r=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],u=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function o(e,a,t){t.negative=a.negative^e.negative;var f=e.length+a.length|0;t.length=f,f=f-1|0;var n=0|e.words[0],b=0|a.words[0],d=n*b,s=67108863&d,i=d/67108864|0;t.words[0]=s;for(var c=1;c>>26,u=67108863&i,o=Math.min(c,a.length-1),p=Math.max(0,c-e.length+1);p<=o;p++){var l=c-p|0;r+=(d=(n=0|e.words[l])*(b=0|a.words[p])+u)/67108864|0,u=67108863&d}t.words[c]=0|u,i=0|r}return 0!==i?t.words[c]=0|i:t.length--,t.strip()}n.prototype.toString=function(e,a){var f;if(a=0|a||1,16===(e=e||10)||"hex"===e){f="";for(var n=0,b=0,d=0;d>>24-n&16777215)||d!==this.length-1?i[6-c.length]+c+f:c+f,(n+=2)>=26&&(n-=26,d--)}for(0!==b&&(f=b.toString(16)+f);f.length%a!=0;)f="0"+f;return 0!==this.negative&&(f="-"+f),f}if(e===(0|e)&&e>=2&&e<=36){var o=r[e],p=u[e];f="";var l=this.clone();for(l.negative=0;!l.isZero();){var y=l.modn(p).toString(e);f=(l=l.idivn(p)).isZero()?y+f:i[o-y.length]+y+f}for(this.isZero()&&(f="0"+f);f.length%a!=0;)f="0"+f;return 0!==this.negative&&(f="-"+f),f}t(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(e,a){return t(void 0!==b),this.toArrayLike(b,e,a)},n.prototype.toArray=function(e,a){return this.toArrayLike(Array,e,a)},n.prototype.toArrayLike=function(e,a,f){var n=this.byteLength(),b=f||Math.max(1,n);t(n<=b,"byte array longer than desired length"),t(b>0,"Requested array length <= 0"),this.strip();var d,s,i="le"===a,c=new e(b),r=this.clone();if(i){for(s=0;!r.isZero();s++)d=r.andln(255),r.iushrn(8),c[s]=d;for(;s=4096&&(t+=13,a>>>=13),a>=64&&(t+=7,a>>>=7),a>=8&&(t+=4,a>>>=4),a>=2&&(t+=2,a>>>=2),t+a},n.prototype._zeroBits=function(e){if(0===e)return 26;var a=e,t=0;return 0==(8191&a)&&(t+=13,a>>>=13),0==(127&a)&&(t+=7,a>>>=7),0==(15&a)&&(t+=4,a>>>=4),0==(3&a)&&(t+=2,a>>>=2),0==(1&a)&&t++,t},n.prototype.bitLength=function(){var e=this.words[this.length-1],a=this._countBits(e);return 26*(this.length-1)+a},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,a=0;ae.length?this.clone().ior(e):e.clone().ior(this)},n.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},n.prototype.iuand=function(e){var a;a=this.length>e.length?e:this;for(var t=0;te.length?this.clone().iand(e):e.clone().iand(this)},n.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},n.prototype.iuxor=function(e){var a,t;this.length>e.length?(a=this,t=e):(a=e,t=this);for(var f=0;fe.length?this.clone().ixor(e):e.clone().ixor(this)},n.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},n.prototype.inotn=function(e){t("number"==typeof e&&e>=0);var a=0|Math.ceil(e/26),f=e%26;this._expand(a),f>0&&a--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-f),this.strip()},n.prototype.notn=function(e){return this.clone().inotn(e)},n.prototype.setn=function(e,a){t("number"==typeof e&&e>=0);var f=e/26|0,n=e%26;return this._expand(f+1),this.words[f]=a?this.words[f]|1<e.length?(t=this,f=e):(t=e,f=this);for(var n=0,b=0;b>>26;for(;0!==n&&b>>26;if(this.length=t.length,0!==n)this.words[this.length]=n,this.length++;else if(t!==this)for(;be.length?this.clone().iadd(e):e.clone().iadd(this)},n.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var a=this.iadd(e);return e.negative=1,a._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var t,f,n=this.cmp(e);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(t=this,f=e):(t=e,f=this);for(var b=0,d=0;d>26,this.words[d]=67108863&a;for(;0!==b&&d>26,this.words[d]=67108863&a;if(0===b&&d>>13,p=0|d[1],l=8191&p,y=p>>>13,m=0|d[2],h=8191&m,x=m>>>13,g=0|d[3],v=8191&g,T=g>>>13,w=0|d[4],E=8191&w,A=w>>>13,M=0|d[5],C=8191&M,D=M>>>13,S=0|d[6],B=8191&S,F=S>>>13,_=0|d[7],k=8191&_,R=_>>>13,P=0|d[8],O=8191&P,I=P>>>13,N=0|d[9],L=8191&N,U=N>>>13,X=0|s[0],K=8191&X,Z=X>>>13,V=0|s[1],q=8191&V,H=V>>>13,z=0|s[2],j=8191&z,G=z>>>13,W=0|s[3],$=8191&W,J=W>>>13,Y=0|s[4],Q=8191&Y,ee=Y>>>13,ae=0|s[5],te=8191&ae,fe=ae>>>13,ne=0|s[6],be=8191&ne,de=ne>>>13,se=0|s[7],ie=8191&se,ce=se>>>13,re=0|s[8],ue=8191&re,oe=re>>>13,pe=0|s[9],le=8191&pe,ye=pe>>>13;t.negative=e.negative^a.negative,t.length=19;var me=(c+(f=Math.imul(u,K))|0)+((8191&(n=(n=Math.imul(u,Z))+Math.imul(o,K)|0))<<13)|0;c=((b=Math.imul(o,Z))+(n>>>13)|0)+(me>>>26)|0,me&=67108863,f=Math.imul(l,K),n=(n=Math.imul(l,Z))+Math.imul(y,K)|0,b=Math.imul(y,Z);var he=(c+(f=f+Math.imul(u,q)|0)|0)+((8191&(n=(n=n+Math.imul(u,H)|0)+Math.imul(o,q)|0))<<13)|0;c=((b=b+Math.imul(o,H)|0)+(n>>>13)|0)+(he>>>26)|0,he&=67108863,f=Math.imul(h,K),n=(n=Math.imul(h,Z))+Math.imul(x,K)|0,b=Math.imul(x,Z),f=f+Math.imul(l,q)|0,n=(n=n+Math.imul(l,H)|0)+Math.imul(y,q)|0,b=b+Math.imul(y,H)|0;var xe=(c+(f=f+Math.imul(u,j)|0)|0)+((8191&(n=(n=n+Math.imul(u,G)|0)+Math.imul(o,j)|0))<<13)|0;c=((b=b+Math.imul(o,G)|0)+(n>>>13)|0)+(xe>>>26)|0,xe&=67108863,f=Math.imul(v,K),n=(n=Math.imul(v,Z))+Math.imul(T,K)|0,b=Math.imul(T,Z),f=f+Math.imul(h,q)|0,n=(n=n+Math.imul(h,H)|0)+Math.imul(x,q)|0,b=b+Math.imul(x,H)|0,f=f+Math.imul(l,j)|0,n=(n=n+Math.imul(l,G)|0)+Math.imul(y,j)|0,b=b+Math.imul(y,G)|0;var ge=(c+(f=f+Math.imul(u,$)|0)|0)+((8191&(n=(n=n+Math.imul(u,J)|0)+Math.imul(o,$)|0))<<13)|0;c=((b=b+Math.imul(o,J)|0)+(n>>>13)|0)+(ge>>>26)|0,ge&=67108863,f=Math.imul(E,K),n=(n=Math.imul(E,Z))+Math.imul(A,K)|0,b=Math.imul(A,Z),f=f+Math.imul(v,q)|0,n=(n=n+Math.imul(v,H)|0)+Math.imul(T,q)|0,b=b+Math.imul(T,H)|0,f=f+Math.imul(h,j)|0,n=(n=n+Math.imul(h,G)|0)+Math.imul(x,j)|0,b=b+Math.imul(x,G)|0,f=f+Math.imul(l,$)|0,n=(n=n+Math.imul(l,J)|0)+Math.imul(y,$)|0,b=b+Math.imul(y,J)|0;var ve=(c+(f=f+Math.imul(u,Q)|0)|0)+((8191&(n=(n=n+Math.imul(u,ee)|0)+Math.imul(o,Q)|0))<<13)|0;c=((b=b+Math.imul(o,ee)|0)+(n>>>13)|0)+(ve>>>26)|0,ve&=67108863,f=Math.imul(C,K),n=(n=Math.imul(C,Z))+Math.imul(D,K)|0,b=Math.imul(D,Z),f=f+Math.imul(E,q)|0,n=(n=n+Math.imul(E,H)|0)+Math.imul(A,q)|0,b=b+Math.imul(A,H)|0,f=f+Math.imul(v,j)|0,n=(n=n+Math.imul(v,G)|0)+Math.imul(T,j)|0,b=b+Math.imul(T,G)|0,f=f+Math.imul(h,$)|0,n=(n=n+Math.imul(h,J)|0)+Math.imul(x,$)|0,b=b+Math.imul(x,J)|0,f=f+Math.imul(l,Q)|0,n=(n=n+Math.imul(l,ee)|0)+Math.imul(y,Q)|0,b=b+Math.imul(y,ee)|0;var Te=(c+(f=f+Math.imul(u,te)|0)|0)+((8191&(n=(n=n+Math.imul(u,fe)|0)+Math.imul(o,te)|0))<<13)|0;c=((b=b+Math.imul(o,fe)|0)+(n>>>13)|0)+(Te>>>26)|0,Te&=67108863,f=Math.imul(B,K),n=(n=Math.imul(B,Z))+Math.imul(F,K)|0,b=Math.imul(F,Z),f=f+Math.imul(C,q)|0,n=(n=n+Math.imul(C,H)|0)+Math.imul(D,q)|0,b=b+Math.imul(D,H)|0,f=f+Math.imul(E,j)|0,n=(n=n+Math.imul(E,G)|0)+Math.imul(A,j)|0,b=b+Math.imul(A,G)|0,f=f+Math.imul(v,$)|0,n=(n=n+Math.imul(v,J)|0)+Math.imul(T,$)|0,b=b+Math.imul(T,J)|0,f=f+Math.imul(h,Q)|0,n=(n=n+Math.imul(h,ee)|0)+Math.imul(x,Q)|0,b=b+Math.imul(x,ee)|0,f=f+Math.imul(l,te)|0,n=(n=n+Math.imul(l,fe)|0)+Math.imul(y,te)|0,b=b+Math.imul(y,fe)|0;var we=(c+(f=f+Math.imul(u,be)|0)|0)+((8191&(n=(n=n+Math.imul(u,de)|0)+Math.imul(o,be)|0))<<13)|0;c=((b=b+Math.imul(o,de)|0)+(n>>>13)|0)+(we>>>26)|0,we&=67108863,f=Math.imul(k,K),n=(n=Math.imul(k,Z))+Math.imul(R,K)|0,b=Math.imul(R,Z),f=f+Math.imul(B,q)|0,n=(n=n+Math.imul(B,H)|0)+Math.imul(F,q)|0,b=b+Math.imul(F,H)|0,f=f+Math.imul(C,j)|0,n=(n=n+Math.imul(C,G)|0)+Math.imul(D,j)|0,b=b+Math.imul(D,G)|0,f=f+Math.imul(E,$)|0,n=(n=n+Math.imul(E,J)|0)+Math.imul(A,$)|0,b=b+Math.imul(A,J)|0,f=f+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,ee)|0)+Math.imul(T,Q)|0,b=b+Math.imul(T,ee)|0,f=f+Math.imul(h,te)|0,n=(n=n+Math.imul(h,fe)|0)+Math.imul(x,te)|0,b=b+Math.imul(x,fe)|0,f=f+Math.imul(l,be)|0,n=(n=n+Math.imul(l,de)|0)+Math.imul(y,be)|0,b=b+Math.imul(y,de)|0;var Ee=(c+(f=f+Math.imul(u,ie)|0)|0)+((8191&(n=(n=n+Math.imul(u,ce)|0)+Math.imul(o,ie)|0))<<13)|0;c=((b=b+Math.imul(o,ce)|0)+(n>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,f=Math.imul(O,K),n=(n=Math.imul(O,Z))+Math.imul(I,K)|0,b=Math.imul(I,Z),f=f+Math.imul(k,q)|0,n=(n=n+Math.imul(k,H)|0)+Math.imul(R,q)|0,b=b+Math.imul(R,H)|0,f=f+Math.imul(B,j)|0,n=(n=n+Math.imul(B,G)|0)+Math.imul(F,j)|0,b=b+Math.imul(F,G)|0,f=f+Math.imul(C,$)|0,n=(n=n+Math.imul(C,J)|0)+Math.imul(D,$)|0,b=b+Math.imul(D,J)|0,f=f+Math.imul(E,Q)|0,n=(n=n+Math.imul(E,ee)|0)+Math.imul(A,Q)|0,b=b+Math.imul(A,ee)|0,f=f+Math.imul(v,te)|0,n=(n=n+Math.imul(v,fe)|0)+Math.imul(T,te)|0,b=b+Math.imul(T,fe)|0,f=f+Math.imul(h,be)|0,n=(n=n+Math.imul(h,de)|0)+Math.imul(x,be)|0,b=b+Math.imul(x,de)|0,f=f+Math.imul(l,ie)|0,n=(n=n+Math.imul(l,ce)|0)+Math.imul(y,ie)|0,b=b+Math.imul(y,ce)|0;var Ae=(c+(f=f+Math.imul(u,ue)|0)|0)+((8191&(n=(n=n+Math.imul(u,oe)|0)+Math.imul(o,ue)|0))<<13)|0;c=((b=b+Math.imul(o,oe)|0)+(n>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,f=Math.imul(L,K),n=(n=Math.imul(L,Z))+Math.imul(U,K)|0,b=Math.imul(U,Z),f=f+Math.imul(O,q)|0,n=(n=n+Math.imul(O,H)|0)+Math.imul(I,q)|0,b=b+Math.imul(I,H)|0,f=f+Math.imul(k,j)|0,n=(n=n+Math.imul(k,G)|0)+Math.imul(R,j)|0,b=b+Math.imul(R,G)|0,f=f+Math.imul(B,$)|0,n=(n=n+Math.imul(B,J)|0)+Math.imul(F,$)|0,b=b+Math.imul(F,J)|0,f=f+Math.imul(C,Q)|0,n=(n=n+Math.imul(C,ee)|0)+Math.imul(D,Q)|0,b=b+Math.imul(D,ee)|0,f=f+Math.imul(E,te)|0,n=(n=n+Math.imul(E,fe)|0)+Math.imul(A,te)|0,b=b+Math.imul(A,fe)|0,f=f+Math.imul(v,be)|0,n=(n=n+Math.imul(v,de)|0)+Math.imul(T,be)|0,b=b+Math.imul(T,de)|0,f=f+Math.imul(h,ie)|0,n=(n=n+Math.imul(h,ce)|0)+Math.imul(x,ie)|0,b=b+Math.imul(x,ce)|0,f=f+Math.imul(l,ue)|0,n=(n=n+Math.imul(l,oe)|0)+Math.imul(y,ue)|0,b=b+Math.imul(y,oe)|0;var Me=(c+(f=f+Math.imul(u,le)|0)|0)+((8191&(n=(n=n+Math.imul(u,ye)|0)+Math.imul(o,le)|0))<<13)|0;c=((b=b+Math.imul(o,ye)|0)+(n>>>13)|0)+(Me>>>26)|0,Me&=67108863,f=Math.imul(L,q),n=(n=Math.imul(L,H))+Math.imul(U,q)|0,b=Math.imul(U,H),f=f+Math.imul(O,j)|0,n=(n=n+Math.imul(O,G)|0)+Math.imul(I,j)|0,b=b+Math.imul(I,G)|0,f=f+Math.imul(k,$)|0,n=(n=n+Math.imul(k,J)|0)+Math.imul(R,$)|0,b=b+Math.imul(R,J)|0,f=f+Math.imul(B,Q)|0,n=(n=n+Math.imul(B,ee)|0)+Math.imul(F,Q)|0,b=b+Math.imul(F,ee)|0,f=f+Math.imul(C,te)|0,n=(n=n+Math.imul(C,fe)|0)+Math.imul(D,te)|0,b=b+Math.imul(D,fe)|0,f=f+Math.imul(E,be)|0,n=(n=n+Math.imul(E,de)|0)+Math.imul(A,be)|0,b=b+Math.imul(A,de)|0,f=f+Math.imul(v,ie)|0,n=(n=n+Math.imul(v,ce)|0)+Math.imul(T,ie)|0,b=b+Math.imul(T,ce)|0,f=f+Math.imul(h,ue)|0,n=(n=n+Math.imul(h,oe)|0)+Math.imul(x,ue)|0,b=b+Math.imul(x,oe)|0;var Ce=(c+(f=f+Math.imul(l,le)|0)|0)+((8191&(n=(n=n+Math.imul(l,ye)|0)+Math.imul(y,le)|0))<<13)|0;c=((b=b+Math.imul(y,ye)|0)+(n>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,f=Math.imul(L,j),n=(n=Math.imul(L,G))+Math.imul(U,j)|0,b=Math.imul(U,G),f=f+Math.imul(O,$)|0,n=(n=n+Math.imul(O,J)|0)+Math.imul(I,$)|0,b=b+Math.imul(I,J)|0,f=f+Math.imul(k,Q)|0,n=(n=n+Math.imul(k,ee)|0)+Math.imul(R,Q)|0,b=b+Math.imul(R,ee)|0,f=f+Math.imul(B,te)|0,n=(n=n+Math.imul(B,fe)|0)+Math.imul(F,te)|0,b=b+Math.imul(F,fe)|0,f=f+Math.imul(C,be)|0,n=(n=n+Math.imul(C,de)|0)+Math.imul(D,be)|0,b=b+Math.imul(D,de)|0,f=f+Math.imul(E,ie)|0,n=(n=n+Math.imul(E,ce)|0)+Math.imul(A,ie)|0,b=b+Math.imul(A,ce)|0,f=f+Math.imul(v,ue)|0,n=(n=n+Math.imul(v,oe)|0)+Math.imul(T,ue)|0,b=b+Math.imul(T,oe)|0;var De=(c+(f=f+Math.imul(h,le)|0)|0)+((8191&(n=(n=n+Math.imul(h,ye)|0)+Math.imul(x,le)|0))<<13)|0;c=((b=b+Math.imul(x,ye)|0)+(n>>>13)|0)+(De>>>26)|0,De&=67108863,f=Math.imul(L,$),n=(n=Math.imul(L,J))+Math.imul(U,$)|0,b=Math.imul(U,J),f=f+Math.imul(O,Q)|0,n=(n=n+Math.imul(O,ee)|0)+Math.imul(I,Q)|0,b=b+Math.imul(I,ee)|0,f=f+Math.imul(k,te)|0,n=(n=n+Math.imul(k,fe)|0)+Math.imul(R,te)|0,b=b+Math.imul(R,fe)|0,f=f+Math.imul(B,be)|0,n=(n=n+Math.imul(B,de)|0)+Math.imul(F,be)|0,b=b+Math.imul(F,de)|0,f=f+Math.imul(C,ie)|0,n=(n=n+Math.imul(C,ce)|0)+Math.imul(D,ie)|0,b=b+Math.imul(D,ce)|0,f=f+Math.imul(E,ue)|0,n=(n=n+Math.imul(E,oe)|0)+Math.imul(A,ue)|0,b=b+Math.imul(A,oe)|0;var Se=(c+(f=f+Math.imul(v,le)|0)|0)+((8191&(n=(n=n+Math.imul(v,ye)|0)+Math.imul(T,le)|0))<<13)|0;c=((b=b+Math.imul(T,ye)|0)+(n>>>13)|0)+(Se>>>26)|0,Se&=67108863,f=Math.imul(L,Q),n=(n=Math.imul(L,ee))+Math.imul(U,Q)|0,b=Math.imul(U,ee),f=f+Math.imul(O,te)|0,n=(n=n+Math.imul(O,fe)|0)+Math.imul(I,te)|0,b=b+Math.imul(I,fe)|0,f=f+Math.imul(k,be)|0,n=(n=n+Math.imul(k,de)|0)+Math.imul(R,be)|0,b=b+Math.imul(R,de)|0,f=f+Math.imul(B,ie)|0,n=(n=n+Math.imul(B,ce)|0)+Math.imul(F,ie)|0,b=b+Math.imul(F,ce)|0,f=f+Math.imul(C,ue)|0,n=(n=n+Math.imul(C,oe)|0)+Math.imul(D,ue)|0,b=b+Math.imul(D,oe)|0;var Be=(c+(f=f+Math.imul(E,le)|0)|0)+((8191&(n=(n=n+Math.imul(E,ye)|0)+Math.imul(A,le)|0))<<13)|0;c=((b=b+Math.imul(A,ye)|0)+(n>>>13)|0)+(Be>>>26)|0,Be&=67108863,f=Math.imul(L,te),n=(n=Math.imul(L,fe))+Math.imul(U,te)|0,b=Math.imul(U,fe),f=f+Math.imul(O,be)|0,n=(n=n+Math.imul(O,de)|0)+Math.imul(I,be)|0,b=b+Math.imul(I,de)|0,f=f+Math.imul(k,ie)|0,n=(n=n+Math.imul(k,ce)|0)+Math.imul(R,ie)|0,b=b+Math.imul(R,ce)|0,f=f+Math.imul(B,ue)|0,n=(n=n+Math.imul(B,oe)|0)+Math.imul(F,ue)|0,b=b+Math.imul(F,oe)|0;var Fe=(c+(f=f+Math.imul(C,le)|0)|0)+((8191&(n=(n=n+Math.imul(C,ye)|0)+Math.imul(D,le)|0))<<13)|0;c=((b=b+Math.imul(D,ye)|0)+(n>>>13)|0)+(Fe>>>26)|0,Fe&=67108863,f=Math.imul(L,be),n=(n=Math.imul(L,de))+Math.imul(U,be)|0,b=Math.imul(U,de),f=f+Math.imul(O,ie)|0,n=(n=n+Math.imul(O,ce)|0)+Math.imul(I,ie)|0,b=b+Math.imul(I,ce)|0,f=f+Math.imul(k,ue)|0,n=(n=n+Math.imul(k,oe)|0)+Math.imul(R,ue)|0,b=b+Math.imul(R,oe)|0;var _e=(c+(f=f+Math.imul(B,le)|0)|0)+((8191&(n=(n=n+Math.imul(B,ye)|0)+Math.imul(F,le)|0))<<13)|0;c=((b=b+Math.imul(F,ye)|0)+(n>>>13)|0)+(_e>>>26)|0,_e&=67108863,f=Math.imul(L,ie),n=(n=Math.imul(L,ce))+Math.imul(U,ie)|0,b=Math.imul(U,ce),f=f+Math.imul(O,ue)|0,n=(n=n+Math.imul(O,oe)|0)+Math.imul(I,ue)|0,b=b+Math.imul(I,oe)|0;var ke=(c+(f=f+Math.imul(k,le)|0)|0)+((8191&(n=(n=n+Math.imul(k,ye)|0)+Math.imul(R,le)|0))<<13)|0;c=((b=b+Math.imul(R,ye)|0)+(n>>>13)|0)+(ke>>>26)|0,ke&=67108863,f=Math.imul(L,ue),n=(n=Math.imul(L,oe))+Math.imul(U,ue)|0,b=Math.imul(U,oe);var Re=(c+(f=f+Math.imul(O,le)|0)|0)+((8191&(n=(n=n+Math.imul(O,ye)|0)+Math.imul(I,le)|0))<<13)|0;c=((b=b+Math.imul(I,ye)|0)+(n>>>13)|0)+(Re>>>26)|0,Re&=67108863;var Pe=(c+(f=Math.imul(L,le))|0)+((8191&(n=(n=Math.imul(L,ye))+Math.imul(U,le)|0))<<13)|0;return c=((b=Math.imul(U,ye))+(n>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,i[0]=me,i[1]=he,i[2]=xe,i[3]=ge,i[4]=ve,i[5]=Te,i[6]=we,i[7]=Ee,i[8]=Ae,i[9]=Me,i[10]=Ce,i[11]=De,i[12]=Se,i[13]=Be,i[14]=Fe,i[15]=_e,i[16]=ke,i[17]=Re,i[18]=Pe,0!==c&&(i[19]=c,t.length++),t};function l(e,a,t){return(new y).mulp(e,a,t)}function y(e,a){this.x=e,this.y=a}Math.imul||(p=o),n.prototype.mulTo=function(e,a){var t=this.length+e.length;return 10===this.length&&10===e.length?p(this,e,a):t<63?o(this,e,a):t<1024?function(e,a,t){t.negative=a.negative^e.negative,t.length=e.length+a.length;for(var f=0,n=0,b=0;b>>26)|0)>>>26,d&=67108863}t.words[b]=s,f=d,d=n}return 0!==f?t.words[b]=f:t.length--,t.strip()}(this,e,a):l(this,e,a)},y.prototype.makeRBT=function(e){for(var a=new Array(e),t=n.prototype._countBits(e)-1,f=0;f>=1;return f},y.prototype.permute=function(e,a,t,f,n,b){for(var d=0;d>>=1)n++;return 1<>>=13,f[2*d+1]=8191&b,b>>>=13;for(d=2*a;d>=26,a+=n/67108864|0,a+=b>>>26,this.words[f]=67108863&b}return 0!==a&&(this.words[f]=a,this.length++),this},n.prototype.muln=function(e){return this.clone().imuln(e)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(e){var a=function(e){for(var a=new Array(e.bitLength()),t=0;t>>n}return a}(e);if(0===a.length)return new n(1);for(var t=this,f=0;f=0);var a,f=e%26,n=(e-f)/26,b=67108863>>>26-f<<26-f;if(0!==f){var d=0;for(a=0;a>>26-f}d&&(this.words[a]=d,this.length++)}if(0!==n){for(a=this.length-1;a>=0;a--)this.words[a+n]=this.words[a];for(a=0;a=0),n=a?(a-a%26)/26:0;var b=e%26,d=Math.min((e-b)/26,this.length),s=67108863^67108863>>>b<d)for(this.length-=d,c=0;c=0&&(0!==r||c>=n);c--){var u=0|this.words[c];this.words[c]=r<<26-b|u>>>b,r=u&s}return i&&0!==r&&(i.words[i.length++]=r),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(e,a,f){return t(0===this.negative),this.iushrn(e,a,f)},n.prototype.shln=function(e){return this.clone().ishln(e)},n.prototype.ushln=function(e){return this.clone().iushln(e)},n.prototype.shrn=function(e){return this.clone().ishrn(e)},n.prototype.ushrn=function(e){return this.clone().iushrn(e)},n.prototype.testn=function(e){t("number"==typeof e&&e>=0);var a=e%26,f=(e-a)/26,n=1<=0);var a=e%26,f=(e-a)/26;if(t(0===this.negative,"imaskn works only with positive numbers"),this.length<=f)return this;if(0!==a&&f++,this.length=Math.min(f,this.length),0!==a){var n=67108863^67108863>>>a<=67108864;a++)this.words[a]-=67108864,a===this.length-1?this.words[a+1]=1:this.words[a+1]++;return this.length=Math.max(this.length,a+1),this},n.prototype.isubn=function(e){if(t("number"==typeof e),t(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var a=0;a>26)-(i/67108864|0),this.words[n+f]=67108863&b}for(;n>26,this.words[n+f]=67108863&b;if(0===s)return this.strip();for(t(-1===s),s=0,n=0;n>26,this.words[n]=67108863&b;return this.negative=1,this.strip()},n.prototype._wordDiv=function(e,a){var t=(this.length,e.length),f=this.clone(),b=e,d=0|b.words[b.length-1];0!=(t=26-this._countBits(d))&&(b=b.ushln(t),f.iushln(t),d=0|b.words[b.length-1]);var s,i=f.length-b.length;if("mod"!==a){(s=new n(null)).length=i+1,s.words=new Array(s.length);for(var c=0;c=0;u--){var o=67108864*(0|f.words[b.length+u])+(0|f.words[b.length+u-1]);for(o=Math.min(o/d|0,67108863),f._ishlnsubmul(b,o,u);0!==f.negative;)o--,f.negative=0,f._ishlnsubmul(b,1,u),f.isZero()||(f.negative^=1);s&&(s.words[u]=o)}return s&&s.strip(),f.strip(),"div"!==a&&0!==t&&f.iushrn(t),{div:s||null,mod:f}},n.prototype.divmod=function(e,a,f){return t(!e.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,a),"mod"!==a&&(b=s.div.neg()),"div"!==a&&(d=s.mod.neg(),f&&0!==d.negative&&d.iadd(e)),{div:b,mod:d}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),a),"mod"!==a&&(b=s.div.neg()),{div:b,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),a),"div"!==a&&(d=s.mod.neg(),f&&0!==d.negative&&d.isub(e)),{div:s.div,mod:d}):e.length>this.length||this.cmp(e)<0?{div:new n(0),mod:this}:1===e.length?"div"===a?{div:this.divn(e.words[0]),mod:null}:"mod"===a?{div:null,mod:new n(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new n(this.modn(e.words[0]))}:this._wordDiv(e,a);var b,d,s},n.prototype.div=function(e){return this.divmod(e,"div",!1).div},n.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},n.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},n.prototype.divRound=function(e){var a=this.divmod(e);if(a.mod.isZero())return a.div;var t=0!==a.div.negative?a.mod.isub(e):a.mod,f=e.ushrn(1),n=e.andln(1),b=t.cmp(f);return b<0||1===n&&0===b?a.div:0!==a.div.negative?a.div.isubn(1):a.div.iaddn(1)},n.prototype.modn=function(e){t(e<=67108863);for(var a=(1<<26)%e,f=0,n=this.length-1;n>=0;n--)f=(a*f+(0|this.words[n]))%e;return f},n.prototype.idivn=function(e){t(e<=67108863);for(var a=0,f=this.length-1;f>=0;f--){var n=(0|this.words[f])+67108864*a;this.words[f]=n/e|0,a=n%e}return this.strip()},n.prototype.divn=function(e){return this.clone().idivn(e)},n.prototype.egcd=function(e){t(0===e.negative),t(!e.isZero());var a=this,f=e.clone();a=0!==a.negative?a.umod(e):a.clone();for(var b=new n(1),d=new n(0),s=new n(0),i=new n(1),c=0;a.isEven()&&f.isEven();)a.iushrn(1),f.iushrn(1),++c;for(var r=f.clone(),u=a.clone();!a.isZero();){for(var o=0,p=1;0==(a.words[0]&p)&&o<26;++o,p<<=1);if(o>0)for(a.iushrn(o);o-- >0;)(b.isOdd()||d.isOdd())&&(b.iadd(r),d.isub(u)),b.iushrn(1),d.iushrn(1);for(var l=0,y=1;0==(f.words[0]&y)&&l<26;++l,y<<=1);if(l>0)for(f.iushrn(l);l-- >0;)(s.isOdd()||i.isOdd())&&(s.iadd(r),i.isub(u)),s.iushrn(1),i.iushrn(1);a.cmp(f)>=0?(a.isub(f),b.isub(s),d.isub(i)):(f.isub(a),s.isub(b),i.isub(d))}return{a:s,b:i,gcd:f.iushln(c)}},n.prototype._invmp=function(e){t(0===e.negative),t(!e.isZero());var a=this,f=e.clone();a=0!==a.negative?a.umod(e):a.clone();for(var b,d=new n(1),s=new n(0),i=f.clone();a.cmpn(1)>0&&f.cmpn(1)>0;){for(var c=0,r=1;0==(a.words[0]&r)&&c<26;++c,r<<=1);if(c>0)for(a.iushrn(c);c-- >0;)d.isOdd()&&d.iadd(i),d.iushrn(1);for(var u=0,o=1;0==(f.words[0]&o)&&u<26;++u,o<<=1);if(u>0)for(f.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(i),s.iushrn(1);a.cmp(f)>=0?(a.isub(f),d.isub(s)):(f.isub(a),s.isub(d))}return(b=0===a.cmpn(1)?d:s).cmpn(0)<0&&b.iadd(e),b},n.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var a=this.clone(),t=e.clone();a.negative=0,t.negative=0;for(var f=0;a.isEven()&&t.isEven();f++)a.iushrn(1),t.iushrn(1);for(;;){for(;a.isEven();)a.iushrn(1);for(;t.isEven();)t.iushrn(1);var n=a.cmp(t);if(n<0){var b=a;a=t,t=b}else if(0===n||0===t.cmpn(1))break;a.isub(t)}return t.iushln(f)},n.prototype.invm=function(e){return this.egcd(e).a.umod(e)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(e){return this.words[0]&e},n.prototype.bincn=function(e){t("number"==typeof e);var a=e%26,f=(e-a)/26,n=1<>>26,s&=67108863,this.words[d]=s}return 0!==b&&(this.words[d]=b,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(e){var a,f=e<0;if(0!==this.negative&&!f)return-1;if(0===this.negative&&f)return 1;if(this.strip(),this.length>1)a=1;else{f&&(e=-e),t(e<=67108863,"Number is too big");var n=0|this.words[0];a=n===e?0:ne.length)return 1;if(this.length=0;t--){var f=0|this.words[t],n=0|e.words[t];if(f!==n){fn&&(a=1);break}}return a},n.prototype.gtn=function(e){return 1===this.cmpn(e)},n.prototype.gt=function(e){return 1===this.cmp(e)},n.prototype.gten=function(e){return this.cmpn(e)>=0},n.prototype.gte=function(e){return this.cmp(e)>=0},n.prototype.ltn=function(e){return-1===this.cmpn(e)},n.prototype.lt=function(e){return-1===this.cmp(e)},n.prototype.lten=function(e){return this.cmpn(e)<=0},n.prototype.lte=function(e){return this.cmp(e)<=0},n.prototype.eqn=function(e){return 0===this.cmpn(e)},n.prototype.eq=function(e){return 0===this.cmp(e)},n.red=function(e){return new w(e)},n.prototype.toRed=function(e){return t(!this.red,"Already a number in reduction context"),t(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},n.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(e){return this.red=e,this},n.prototype.forceRed=function(e){return t(!this.red,"Already a number in reduction context"),this._forceRed(e)},n.prototype.redAdd=function(e){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},n.prototype.redIAdd=function(e){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},n.prototype.redSub=function(e){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},n.prototype.redISub=function(e){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},n.prototype.redShl=function(e){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},n.prototype.redMul=function(e){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},n.prototype.redIMul=function(e){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},n.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(e){return t(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var m={k256:null,p224:null,p192:null,p25519:null};function h(e,a){this.name=e,this.p=new n(a,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function x(){h.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function g(){h.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function v(){h.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function T(){h.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function w(e){if("string"==typeof e){var a=n._prime(e);this.m=a.p,this.prime=a}else t(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function E(e){w.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}h.prototype._tmp=function(){var e=new n(null);return e.words=new Array(Math.ceil(this.n/13)),e},h.prototype.ireduce=function(e){var a,t=e;do{this.split(t,this.tmp),a=(t=(t=this.imulK(t)).iadd(this.tmp)).bitLength()}while(a>this.n);var f=a0?t.isub(this.p):void 0!==t.strip?t.strip():t._strip(),t},h.prototype.split=function(e,a){e.iushrn(this.n,0,a)},h.prototype.imulK=function(e){return e.imul(this.k)},f(x,h),x.prototype.split=function(e,a){for(var t=Math.min(e.length,9),f=0;f>>22,n=b}n>>>=22,e.words[f-10]=n,0===n&&e.length>10?e.length-=10:e.length-=9},x.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var a=0,t=0;t>>=26,e.words[t]=n,a=f}return 0!==a&&(e.words[e.length++]=a),e},n._prime=function(e){if(m[e])return m[e];var a;if("k256"===e)a=new x;else if("p224"===e)a=new g;else if("p192"===e)a=new v;else{if("p25519"!==e)throw new Error("Unknown prime "+e);a=new T}return m[e]=a,a},w.prototype._verify1=function(e){t(0===e.negative,"red works only with positives"),t(e.red,"red works only with red numbers")},w.prototype._verify2=function(e,a){t(0==(e.negative|a.negative),"red works only with positives"),t(e.red&&e.red===a.red,"red works only with red numbers")},w.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},w.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},w.prototype.add=function(e,a){this._verify2(e,a);var t=e.add(a);return t.cmp(this.m)>=0&&t.isub(this.m),t._forceRed(this)},w.prototype.iadd=function(e,a){this._verify2(e,a);var t=e.iadd(a);return t.cmp(this.m)>=0&&t.isub(this.m),t},w.prototype.sub=function(e,a){this._verify2(e,a);var t=e.sub(a);return t.cmpn(0)<0&&t.iadd(this.m),t._forceRed(this)},w.prototype.isub=function(e,a){this._verify2(e,a);var t=e.isub(a);return t.cmpn(0)<0&&t.iadd(this.m),t},w.prototype.shl=function(e,a){return this._verify1(e),this.imod(e.ushln(a))},w.prototype.imul=function(e,a){return this._verify2(e,a),this.imod(e.imul(a))},w.prototype.mul=function(e,a){return this._verify2(e,a),this.imod(e.mul(a))},w.prototype.isqr=function(e){return this.imul(e,e.clone())},w.prototype.sqr=function(e){return this.mul(e,e)},w.prototype.sqrt=function(e){if(e.isZero())return e.clone();var a=this.m.andln(3);if(t(a%2==1),3===a){var f=this.m.add(new n(1)).iushrn(2);return this.pow(e,f)}for(var b=this.m.subn(1),d=0;!b.isZero()&&0===b.andln(1);)d++,b.iushrn(1);t(!b.isZero());var s=new n(1).toRed(this),i=s.redNeg(),c=this.m.subn(1).iushrn(1),r=this.m.bitLength();for(r=new n(2*r*r).toRed(this);0!==this.pow(r,c).cmp(i);)r.redIAdd(i);for(var u=this.pow(r,b),o=this.pow(e,b.addn(1).iushrn(1)),p=this.pow(e,b),l=d;0!==p.cmp(s);){for(var y=p,m=0;0!==y.cmp(s);m++)y=y.redSqr();t(m=0;f--){for(var c=a.words[f],r=i-1;r>=0;r--){var u=c>>r&1;b!==t[0]&&(b=this.sqr(b)),0!==u||0!==d?(d<<=1,d|=u,(4==++s||0===f&&0===r)&&(b=this.mul(b,t[d]),s=0,d=0)):s=0}i=26}return b},w.prototype.convertTo=function(e){var a=e.umod(this.m);return a===e?a.clone():a},w.prototype.convertFrom=function(e){var a=e.clone();return a.red=null,a},n.mont=function(e){return new E(e)},f(E,w),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var a=this.imod(e.mul(this.rinv));return a.red=null,a},E.prototype.imul=function(e,a){if(e.isZero()||a.isZero())return e.words[0]=0,e.length=1,e;var t=e.imul(a),f=t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=t.isub(f).iushrn(this.shift),b=n;return n.cmp(this.m)>=0?b=n.isub(this.m):n.cmpn(0)<0&&(b=n.iadd(this.m)),b._forceRed(this)},E.prototype.mul=function(e,a){if(e.isZero()||a.isZero())return new n(0)._forceRed(this);var t=e.mul(a),f=t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),b=t.isub(f).iushrn(this.shift),d=b;return b.cmp(this.m)>=0?d=b.isub(this.m):b.cmpn(0)<0&&(d=b.iadd(this.m)),d._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,n)})),Fa=d((function(e,a){var t=a;function f(e){return 1===e.length?"0"+e:e}function n(e){for(var a="",t=0;t>8,d=255&n;b?t.push(b,d):t.push(d)}return t},t.zero2=f,t.toHex=n,t.encode=function(e,a){return"hex"===a?n(e):e}})),_a=d((function(e,a){var t=a;t.assert=ne,t.toArray=Fa.toArray,t.zero2=Fa.zero2,t.toHex=Fa.toHex,t.encode=Fa.encode,t.getNAF=function(e,a,t){var f=new Array(Math.max(e.bitLength(),t)+1);f.fill(0);for(var n=1<(n>>1)-1?(n>>1)-i:i,b.isubn(s)):s=0,f[d]=s,b.iushrn(1)}return f},t.getJSF=function(e,a){var t=[[],[]];e=e.clone(),a=a.clone();for(var f=0,n=0;e.cmpn(-f)>0||a.cmpn(-n)>0;){var b,d,s,i=e.andln(3)+f&3,c=a.andln(3)+n&3;3===i&&(i=-1),3===c&&(c=-1),b=0==(1&i)?0:3!=(s=e.andln(7)+f&7)&&5!==s||2!==c?i:-i,t[0].push(b),d=0==(1&c)?0:3!=(s=a.andln(7)+n&7)&&5!==s||2!==i?c:-c,t[1].push(d),2*f===b+1&&(f=1-f),2*n===d+1&&(n=1-n),e.iushrn(1),a.iushrn(1)}return t},t.cachedProperty=function(e,a,t){var f="_"+a;e.prototype[a]=function(){return void 0!==this[f]?this[f]:this[f]=t.call(this)}},t.parseBytes=function(e){return"string"==typeof e?t.toArray(e,"hex"):e},t.intFromLE=function(e){return new Ba(e,"hex","le")}})),ka=function(e){var a=new Uint8Array(e);return(n.crypto||n.msCrypto).getRandomValues(a),a},Ra=_a.getNAF,Pa=_a.getJSF,Oa=_a.assert;function Ia(e,a){this.type=e,this.p=new Ba(a.p,16),this.red=a.prime?Ba.red(a.prime):Ba.mont(this.p),this.zero=new Ba(0).toRed(this.red),this.one=new Ba(1).toRed(this.red),this.two=new Ba(2).toRed(this.red),this.n=a.n&&new Ba(a.n,16),this.g=a.g&&this.pointFromJSON(a.g,a.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Na=Ia;function La(e,a){this.curve=e,this.type=a,this.precomputed=null}Ia.prototype.point=function(){throw new Error("Not implemented")},Ia.prototype.validate=function(){throw new Error("Not implemented")},Ia.prototype._fixedNafMul=function(e,a){Oa(e.precomputed);var t=e._getDoubles(),f=Ra(a,1,this._bitLength),n=(1<=d;a--)s=(s<<1)+f[a];b.push(s)}for(var i=this.jpoint(null,null,null),c=this.jpoint(null,null,null),r=n;r>0;r--){for(d=0;d=0;s--){for(a=0;s>=0&&0===b[s];s--)a++;if(s>=0&&a++,d=d.dblp(a),s<0)break;var i=b[s];Oa(0!==i),d="affine"===e.type?i>0?d.mixedAdd(n[i-1>>1]):d.mixedAdd(n[-i-1>>1].neg()):i>0?d.add(n[i-1>>1]):d.add(n[-i-1>>1].neg())}return"affine"===e.type?d.toP():d},Ia.prototype._wnafMulAdd=function(e,a,t,f,n){for(var b=this._wnafT1,d=this._wnafT2,s=this._wnafT3,i=0,c=0;c=1;c-=2){var u=c-1,o=c;if(1===b[u]&&1===b[o]){var p=[a[u],null,null,a[o]];0===a[u].y.cmp(a[o].y)?(p[1]=a[u].add(a[o]),p[2]=a[u].toJ().mixedAdd(a[o].neg())):0===a[u].y.cmp(a[o].y.redNeg())?(p[1]=a[u].toJ().mixedAdd(a[o]),p[2]=a[u].add(a[o].neg())):(p[1]=a[u].toJ().mixedAdd(a[o]),p[2]=a[u].toJ().mixedAdd(a[o].neg()));var l=[-3,-1,-5,-7,0,7,5,1,3],y=Pa(t[u],t[o]);i=Math.max(y[0].length,i),s[u]=new Array(i),s[o]=new Array(i);for(var m=0;m=0;c--){for(var T=0;c>=0;){var w=!0;for(m=0;m=0&&T++,g=g.dblp(T),c<0)break;for(m=0;m0?E=d[m][A-1>>1]:A<0&&(E=d[m][-A-1>>1].neg()),g="affine"===E.type?g.mixedAdd(E):g.add(E))}}for(c=0;c=Math.ceil((e.bitLength()+1)/a.step)},La.prototype._getDoubles=function(e,a){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var t=[this],f=this,n=0;n=0&&(b=a,d=t),f.negative&&(f=f.neg(),n=n.neg()),b.negative&&(b=b.neg(),d=d.neg()),[{a:f,b:n},{a:b,b:d}]},Xa.prototype._endoSplit=function(e){var a=this.endo.basis,t=a[0],f=a[1],n=f.b.mul(e).divRound(this.n),b=t.b.neg().mul(e).divRound(this.n),d=n.mul(t.a),s=b.mul(f.a),i=n.mul(t.b),c=b.mul(f.b);return{k1:e.sub(d).sub(s),k2:i.add(c).neg()}},Xa.prototype.pointFromX=function(e,a){(e=new Ba(e,16)).red||(e=e.toRed(this.red));var t=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),f=t.redSqrt();if(0!==f.redSqr().redSub(t).cmp(this.zero))throw new Error("invalid point");var n=f.fromRed().isOdd();return(a&&!n||!a&&n)&&(f=f.redNeg()),this.point(e,f)},Xa.prototype.validate=function(e){if(e.inf)return!0;var a=e.x,t=e.y,f=this.a.redMul(a),n=a.redSqr().redMul(a).redIAdd(f).redIAdd(this.b);return 0===t.redSqr().redISub(n).cmpn(0)},Xa.prototype._endoWnafMulAdd=function(e,a,t){for(var f=this._endoWnafT1,n=this._endoWnafT2,b=0;b":""},Za.prototype.isInfinity=function(){return this.inf},Za.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var a=this.y.redSub(e.y);0!==a.cmpn(0)&&(a=a.redMul(this.x.redSub(e.x).redInvm()));var t=a.redSqr().redISub(this.x).redISub(e.x),f=a.redMul(this.x.redSub(t)).redISub(this.y);return this.curve.point(t,f)},Za.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var a=this.curve.a,t=this.x.redSqr(),f=e.redInvm(),n=t.redAdd(t).redIAdd(t).redIAdd(a).redMul(f),b=n.redSqr().redISub(this.x.redAdd(this.x)),d=n.redMul(this.x.redSub(b)).redISub(this.y);return this.curve.point(b,d)},Za.prototype.getX=function(){return this.x.fromRed()},Za.prototype.getY=function(){return this.y.fromRed()},Za.prototype.mul=function(e){return e=new Ba(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},Za.prototype.mulAdd=function(e,a,t){var f=[this,a],n=[e,t];return this.curve.endo?this.curve._endoWnafMulAdd(f,n):this.curve._wnafMulAdd(1,f,n,2)},Za.prototype.jmulAdd=function(e,a,t){var f=[this,a],n=[e,t];return this.curve.endo?this.curve._endoWnafMulAdd(f,n,!0):this.curve._wnafMulAdd(1,f,n,2,!0)},Za.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},Za.prototype.neg=function(e){if(this.inf)return this;var a=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var t=this.precomputed,f=function(e){return e.neg()};a.precomputed={naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(f)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(f)}}}return a},Za.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},de(Va,Na.BasePoint),Xa.prototype.jpoint=function(e,a,t){return new Va(this,e,a,t)},Va.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),a=e.redSqr(),t=this.x.redMul(a),f=this.y.redMul(a).redMul(e);return this.curve.point(t,f)},Va.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Va.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var a=e.z.redSqr(),t=this.z.redSqr(),f=this.x.redMul(a),n=e.x.redMul(t),b=this.y.redMul(a.redMul(e.z)),d=e.y.redMul(t.redMul(this.z)),s=f.redSub(n),i=b.redSub(d);if(0===s.cmpn(0))return 0!==i.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),r=c.redMul(s),u=f.redMul(c),o=i.redSqr().redIAdd(r).redISub(u).redISub(u),p=i.redMul(u.redISub(o)).redISub(b.redMul(r)),l=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(o,p,l)},Va.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var a=this.z.redSqr(),t=this.x,f=e.x.redMul(a),n=this.y,b=e.y.redMul(a).redMul(this.z),d=t.redSub(f),s=n.redSub(b);if(0===d.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var i=d.redSqr(),c=i.redMul(d),r=t.redMul(i),u=s.redSqr().redIAdd(c).redISub(r).redISub(r),o=s.redMul(r.redISub(u)).redISub(n.redMul(c)),p=this.z.redMul(d);return this.curve.jpoint(u,o,p)},Va.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var a=this,t=0;t=0)return!1;if(t.redIAdd(n),0===this.x.cmp(t))return!0}},Va.prototype.inspect=function(){return this.isInfinity()?"":""},Va.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var qa={},Ha={},za=d((function(e,a){var t=a;t.base=Na,t.short=Ka,t.mont=qa,t.edwards=Ha})),ja=d((function(e,a){var t,f=a,n=_a.assert;function b(e){"short"===e.type?this.curve=new za.short(e):"edwards"===e.type?this.curve=new za.edwards(e):this.curve=new za.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,n(this.g.validate(),"Invalid curve"),n(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function d(e,a){Object.defineProperty(f,e,{configurable:!0,enumerable:!0,get:function(){var t=new b(a);return Object.defineProperty(f,e,{configurable:!0,enumerable:!0,value:t}),t}})}f.PresetCurve=b,d("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Ea.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),d("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Ea.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),d("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Ea.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),d("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Ea.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),d("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Ea.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),d("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Ea.sha256,gRed:!1,g:["9"]}),d("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Ea.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{t=void 0}catch(e){t=void 0}d("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Ea.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",t]})}));function Ga(e){if(!(this instanceof Ga))return new Ga(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var a=Fa.toArray(e.entropy,e.entropyEnc||"hex"),t=Fa.toArray(e.nonce,e.nonceEnc||"hex"),f=Fa.toArray(e.pers,e.persEnc||"hex");ne(a.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(a,t,f)}var Wa=Ga;Ga.prototype._init=function(e,a,t){var f=e.concat(a).concat(t);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var n=0;n=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(t||[])),this._reseed=1},Ga.prototype.generate=function(e,a,t,f){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof a&&(f=t,t=a,a=null),t&&(t=Fa.toArray(t,f||"hex"),this._update(t));for(var n=[];n.length"};var Qa=_a.assert;function et(e,a){if(e instanceof et)return e;this._importDER(e,a)||(Qa(e.r&&e.s,"Signature without r or s"),this.r=new Ba(e.r,16),this.s=new Ba(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}var at=et;function tt(){this.place=0}function ft(e,a){var t=e[a.place++];if(!(128&t))return t;var f=15&t;if(0===f||f>4)return!1;for(var n=0,b=0,d=a.place;b>>=0;return!(n<=127)&&(a.place=d,n)}function nt(e){for(var a=0,t=e.length-1;!e[a]&&!(128&e[a+1])&&a>>3);for(e.push(128|t);--t;)e.push(a>>>(t<<3)&255);e.push(a)}}et.prototype._importDER=function(e,a){e=_a.toArray(e,a);var t=new tt;if(48!==e[t.place++])return!1;var f=ft(e,t);if(!1===f)return!1;if(f+t.place!==e.length)return!1;if(2!==e[t.place++])return!1;var n=ft(e,t);if(!1===n)return!1;var b=e.slice(t.place,n+t.place);if(t.place+=n,2!==e[t.place++])return!1;var d=ft(e,t);if(!1===d)return!1;if(e.length!==d+t.place)return!1;var s=e.slice(t.place,d+t.place);if(0===b[0]){if(!(128&b[1]))return!1;b=b.slice(1)}if(0===s[0]){if(!(128&s[1]))return!1;s=s.slice(1)}return this.r=new Ba(b),this.s=new Ba(s),this.recoveryParam=null,!0},et.prototype.toDER=function(e){var a=this.r.toArray(),t=this.s.toArray();for(128&a[0]&&(a=[0].concat(a)),128&t[0]&&(t=[0].concat(t)),a=nt(a),t=nt(t);!(t[0]||128&t[1]);)t=t.slice(1);var f=[2];bt(f,a.length),(f=f.concat(a)).push(2),bt(f,t.length);var n=f.concat(t),b=[48];return bt(b,n.length),b=b.concat(n),_a.encode(b,e)};var dt=_a.assert;function st(e){if(!(this instanceof st))return new st(e);"string"==typeof e&&(dt(ja.hasOwnProperty(e),"Unknown curve "+e),e=ja[e]),e instanceof ja.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}var it=st;st.prototype.keyPair=function(e){return new Ya(this,e)},st.prototype.keyFromPrivate=function(e,a){return Ya.fromPrivate(this,e,a)},st.prototype.keyFromPublic=function(e,a){return Ya.fromPublic(this,e,a)},st.prototype.genKeyPair=function(e){e||(e={});for(var a=new Wa({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||ka(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),t=this.n.byteLength(),f=this.n.sub(new Ba(2));;){var n=new Ba(a.generate(t));if(!(n.cmp(f)>0))return n.iaddn(1),this.keyFromPrivate(n)}},st.prototype._truncateToN=function(e,a){var t=8*e.byteLength()-this.n.bitLength();return t>0&&(e=e.ushrn(t)),!a&&e.cmp(this.n)>=0?e.sub(this.n):e},st.prototype.sign=function(e,a,t,f){"object"==typeof t&&(f=t,t=null),f||(f={}),a=this.keyFromPrivate(a,t),e=this._truncateToN(new Ba(e,16));for(var n=this.n.byteLength(),b=a.getPrivate().toArray("be",n),d=e.toArray("be",n),s=new Wa({hash:this.hash,entropy:b,nonce:d,pers:f.pers,persEnc:f.persEnc||"utf8"}),i=this.n.sub(new Ba(1)),c=0;;c++){var r=f.k?f.k(c):new Ba(s.generate(this.n.byteLength()));if(!((r=this._truncateToN(r,!0)).cmpn(1)<=0||r.cmp(i)>=0)){var u=this.g.mul(r);if(!u.isInfinity()){var o=u.getX(),p=o.umod(this.n);if(0!==p.cmpn(0)){var l=r.invm(this.n).mul(p.mul(a.getPrivate()).iadd(e));if(0!==(l=l.umod(this.n)).cmpn(0)){var y=(u.getY().isOdd()?1:0)|(0!==o.cmp(p)?2:0);return f.canonical&&l.cmp(this.nh)>0&&(l=this.n.sub(l),y^=1),new at({r:p,s:l,recoveryParam:y})}}}}}},st.prototype.verify=function(e,a,t,f){e=this._truncateToN(new Ba(e,16)),t=this.keyFromPublic(t,f);var n=(a=new at(a,"hex")).r,b=a.s;if(n.cmpn(1)<0||n.cmp(this.n)>=0)return!1;if(b.cmpn(1)<0||b.cmp(this.n)>=0)return!1;var d,s=b.invm(this.n),i=s.mul(e).umod(this.n),c=s.mul(n).umod(this.n);return this.curve._maxwellTrick?!(d=this.g.jmulAdd(i,t.getPublic(),c)).isInfinity()&&d.eqXToP(n):!(d=this.g.mulAdd(i,t.getPublic(),c)).isInfinity()&&0===d.getX().umod(this.n).cmp(n)},st.prototype.recoverPubKey=function(e,a,t,f){dt((3&t)===t,"The recovery param is more than two bits"),a=new at(a,f);var n=this.n,b=new Ba(e),d=a.r,s=a.s,i=1&t,c=t>>1;if(d.cmp(this.curve.p.umod(this.curve.n))>=0&&c)throw new Error("Unable to find sencond key candinate");d=c?this.curve.pointFromX(d.add(this.curve.n),i):this.curve.pointFromX(d,i);var r=a.r.invm(n),u=n.sub(b).mul(r).umod(n),o=s.mul(r).umod(n);return this.g.mulAdd(u,d,o)},st.prototype.getKeyRecoveryParam=function(e,a,t,f){if(null!==(a=new at(a,f)).recoveryParam)return a.recoveryParam;for(var n=0;n<4;n++){var b;try{b=this.recoverPubKey(e,a,n)}catch(e){continue}if(b.eq(t))return n}throw new Error("Unable to find valid recovery factor")};var ct={},rt=s(Sa),ut=d((function(e,a){var t=a;t.version=rt.version,t.utils=_a,t.rand=ka,t.curve=za,t.curves=ja,t.ec=it,t.eddsa=ct})),ot=(ut.ec,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.version="signing-key/5.0.3"}))),pt=(b(ot),ot.version,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0});var t=new o.Logger(ot.version),f=null;function n(){return f||(f=new ut.ec("secp256k1")),f}var b=function(){function e(e){v.defineReadOnly(this,"curve","secp256k1"),v.defineReadOnly(this,"privateKey",l.hexlify(e));var a=n().keyFromPrivate(l.arrayify(this.privateKey));v.defineReadOnly(this,"publicKey","0x"+a.getPublic(!1,"hex")),v.defineReadOnly(this,"compressedPublicKey","0x"+a.getPublic(!0,"hex")),v.defineReadOnly(this,"_isSigningKey",!0)}return e.prototype._addPoint=function(e){var a=n().keyFromPublic(l.arrayify(this.publicKey)),t=n().keyFromPublic(l.arrayify(e));return"0x"+a.pub.add(t.pub).encodeCompressed("hex")},e.prototype.signDigest=function(e){var a=n().keyFromPrivate(l.arrayify(this.privateKey)).sign(l.arrayify(e),{canonical:!0});return l.splitSignature({recoveryParam:a.recoveryParam,r:l.hexZeroPad("0x"+a.r.toString(16),32),s:l.hexZeroPad("0x"+a.s.toString(16),32)})},e.prototype.computeSharedSecret=function(e){var a=n().keyFromPrivate(l.arrayify(this.privateKey)),t=n().keyFromPublic(l.arrayify(d(e)));return l.hexZeroPad("0x"+a.derive(t.getPublic()).toString(16),32)},e.isSigningKey=function(e){return!(!e||!e._isSigningKey)},e}();function d(e,a){var f=l.arrayify(e);if(32===f.length){var d=new b(f);return a?"0x"+n().keyFromPrivate(f).getPublic(!0,"hex"):d.publicKey}return 33===f.length?a?l.hexlify(f):"0x"+n().keyFromPublic(f).getPublic(!1,"hex"):65===f.length?a?"0x"+n().keyFromPublic(f).getPublic(!0,"hex"):l.hexlify(f):t.throwArgumentError("invalid public or private key","key","[REDACTED]")}a.SigningKey=b,a.recoverPublicKey=function(e,a){var t=l.splitSignature(a),f={r:l.arrayify(t.r),s:l.arrayify(t.s)};return"0x"+n().recoverPubKey(l.arrayify(e),f,t.recoveryParam).encode("hex",!1)},a.computePublicKey=d}))),lt=(b(pt),pt.SigningKey,pt.recoverPublicKey,pt.computePublicKey,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.version="transactions/5.0.2"}))),yt=(b(lt),lt.version,d((function(e,a){var t=n&&n.__importStar||function(e){if(e&&e.__esModule)return e;var a={};if(null!=e)for(var t in e)Object.hasOwnProperty.call(e,t)&&(a[t]=e[t]);return a.default=e,a};Object.defineProperty(a,"__esModule",{value:!0});var f=t(D),b=new o.Logger(lt.version);function d(e){return"0x"===e?N.Zero:x.BigNumber.from(e)}var s=[{name:"nonce",maxLength:32,numeric:!0},{name:"gasPrice",maxLength:32,numeric:!0},{name:"gasLimit",maxLength:32,numeric:!0},{name:"to",length:20},{name:"value",maxLength:32,numeric:!0},{name:"data"}],i={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function c(e){var a=pt.computePublicKey(e);return B.getAddress(l.hexDataSlice(M.keccak256(l.hexDataSlice(a,1)),12))}function r(e,a){return c(pt.recoverPublicKey(l.arrayify(e),a))}a.computeAddress=c,a.recoverAddress=r,a.serialize=function(e,a){v.checkProperties(e,i);var t=[];s.forEach((function(a){var f=e[a.name]||[],n={};a.numeric&&(n.hexPad="left"),f=l.arrayify(l.hexlify(f,n)),a.length&&f.length!==a.length&&f.length>0&&b.throwArgumentError("invalid length for "+a.name,"transaction:"+a.name,f),a.maxLength&&(f=l.stripZeros(f)).length>a.maxLength&&b.throwArgumentError("invalid length for "+a.name,"transaction:"+a.name,f),t.push(l.hexlify(f))}));var n=0;if(null!=e.chainId?"number"!=typeof(n=e.chainId)&&b.throwArgumentError("invalid transaction.chainId","transaction",e):a&&!l.isBytesLike(a)&&a.v>28&&(n=Math.floor((a.v-35)/2)),0!==n&&(t.push(l.hexlify(n)),t.push("0x"),t.push("0x")),!a)return f.encode(t);var d=l.splitSignature(a),c=27+d.recoveryParam;return 0!==n?(t.pop(),t.pop(),t.pop(),c+=2*n+8,d.v>28&&d.v!==c&&b.throwArgumentError("transaction.chainId/signature.v mismatch","signature",a)):d.v!==c&&b.throwArgumentError("transaction.chainId/signature.v mismatch","signature",a),t.push(l.hexlify(c)),t.push(l.stripZeros(l.arrayify(d.r))),t.push(l.stripZeros(l.arrayify(d.s))),f.encode(t)},a.parse=function(e){var a=f.decode(e);9!==a.length&&6!==a.length&&b.throwArgumentError("invalid raw transaction","rawTransaction",e);var t,n={nonce:d(a[0]).toNumber(),gasPrice:d(a[1]),gasLimit:d(a[2]),to:(t=a[3],"0x"===t?null:B.getAddress(t)),value:d(a[4]),data:a[5],chainId:0};if(6===a.length)return n;try{n.v=x.BigNumber.from(a[6]).toNumber()}catch(e){return console.log(e),n}if(n.r=l.hexZeroPad(a[7],32),n.s=l.hexZeroPad(a[8],32),x.BigNumber.from(n.r).isZero()&&x.BigNumber.from(n.s).isZero())n.chainId=n.v,n.v=0;else{n.chainId=Math.floor((n.v-35)/2),n.chainId<0&&(n.chainId=0);var s=n.v-27,i=a.slice(0,6);0!==n.chainId&&(i.push(l.hexlify(n.chainId)),i.push("0x"),i.push("0x"),s-=2*n.chainId+8);var c=M.keccak256(f.encode(i));try{n.from=r(c,{r:l.hexlify(n.r),s:l.hexlify(n.s),recoveryParam:s})}catch(e){console.log(e)}n.hash=M.keccak256(e)}return n}}))),mt=(b(yt),yt.computeAddress,yt.recoverAddress,yt.serialize,yt.parse,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.version="wordlists/5.0.2"}))),ht=(b(mt),mt.version,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.logger=new o.Logger(mt.version);var t=function(){function e(t){var f=this.constructor;a.logger.checkAbstract(f,e),v.defineReadOnly(this,"locale",t)}return e.prototype.split=function(e){return e.toLowerCase().split(/ +/g)},e.prototype.join=function(e){return e.join(" ")},e.check=function(e){for(var a=[],t=0;t<2048;t++){var f=e.getWord(t);if(t!==e.getWordIndex(f))return"0x";a.push(f)}return G.id(a.join("\n")+"\n")},e.register=function(e,a){a||(a=e.locale)},e}();a.Wordlist=t}))),xt=(b(ht),ht.logger,ht.Wordlist,d((function(e,a){var t,f=n&&n.__extends||(t=function(e,a){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,a){e.__proto__=a}||function(e,a){for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])})(e,a)},function(e,a){function f(){this.constructor=e}t(e,a),e.prototype=null===a?Object.create(a):(f.prototype=a.prototype,new f)});Object.defineProperty(a,"__esModule",{value:!0});var b=null;function d(e){if(null==b&&(b="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo".replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),"0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"!==ht.Wordlist.check(e)))throw b=null,new Error("BIP39 Wordlist for en (English) FAILED")}var s=new(function(e){function a(){return e.call(this,"en")||this}return f(a,e),a.prototype.getWord=function(e){return d(this),b[e]},a.prototype.getWordIndex=function(e){return d(this),b.indexOf(e)},a}(ht.Wordlist));a.langEn=s,ht.Wordlist.register(s)}))),gt=(b(xt),xt.langEn,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.Wordlist=ht.Wordlist;var t={en:xt.langEn};a.wordlists=t}))),vt=(b(gt),gt.Wordlist,gt.wordlists,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.version="hdnode/5.0.2"}))),Tt=(b(vt),vt.version,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0});var t=new o.Logger(vt.version),f=x.BigNumber.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),n=V.toUtf8Bytes("Bitcoin seed");function b(e){return(1<=256)throw new Error("Depth too large!");return s(l.concat([null!=this.privateKey?"0x0488ADE4":"0x0488B21E",l.hexlify(this.depth),this.parentFingerprint,l.hexZeroPad(l.hexlify(this.index),4),this.chainCode,null!=this.privateKey?l.concat(["0x00",this.privateKey]):this.publicKey]))},enumerable:!0,configurable:!0}),e.prototype.neuter=function(){return new e(c,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,this.path)},e.prototype._derive=function(a){if(a>4294967295)throw new Error("invalid index - "+String(a));var t=this.path;t&&(t+="/"+(2147483647&a));var n=new Uint8Array(37);if(2147483648&a){if(!this.privateKey)throw new Error("cannot derive child of neutered node");n.set(l.arrayify(this.privateKey),1),t&&(t+="'")}else n.set(l.arrayify(this.publicKey));for(var b=24;b>=0;b-=8)n[33+(b>>3)]=a>>24-b&255;var s=l.arrayify(Ma.computeHmac(Ma.SupportedAlgorithm.sha512,this.chainCode,n)),i=s.slice(0,32),r=s.slice(32),u=null,o=null;this.privateKey?u=d(x.BigNumber.from(i).add(this.privateKey).mod(f)):o=new pt.SigningKey(l.hexlify(i))._addPoint(this.publicKey);var p=t,y=this.mnemonic;return y&&(p=Object.freeze({phrase:y.phrase,path:t,locale:y.locale||"en"})),new e(c,u,o,this.fingerprint,d(r),a,this.depth+1,p)},e.prototype.derivePath=function(e){var a=e.split("/");if(0===a.length||"m"===a[0]&&0!==this.depth)throw new Error("invalid path - "+e);"m"===a[0]&&a.shift();for(var t=this,f=0;f=2147483648)throw new Error("invalid path index - "+n);t=t._derive(2147483648+b)}else{if(!n.match(/^[0-9]+$/))throw new Error("invalid path component - "+n);var b;if((b=parseInt(n))>=2147483648)throw new Error("invalid path index - "+n);t=t._derive(b)}}return t},e._fromSeed=function(a,t){var f=l.arrayify(a);if(f.length<16||f.length>64)throw new Error("invalid seed");var b=l.arrayify(Ma.computeHmac(Ma.SupportedAlgorithm.sha512,n,f));return new e(c,d(b.slice(0,32)),null,"0x00000000",d(b.slice(32)),0,0,t)},e.fromMnemonic=function(a,t,f){return a=y(p(a,f=i(f)),f),e._fromSeed(u(a,t),{phrase:a,path:"m",locale:f.locale})},e.fromSeed=function(a){return e._fromSeed(a,null)},e.fromExtendedKey=function(a){var f=fe.Base58.decode(a);82===f.length&&s(f.slice(0,78))===a||t.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");var n=f[4],b=l.hexlify(f.slice(5,9)),d=parseInt(l.hexlify(f.slice(9,13)).substring(2),16),i=l.hexlify(f.slice(13,45)),r=f.slice(45,78);switch(l.hexlify(f.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new e(c,null,l.hexlify(r),b,i,d,n,null);case"0x0488ade4":case"0x04358394 ":if(0!==r[0])break;return new e(c,l.hexlify(r.slice(1)),null,b,i,d,n,null)}return t.throwArgumentError("invalid extended key","extendedKey","[REDACTED]")},e}();function u(e,a){a||(a="");var t=V.toUtf8Bytes("mnemonic"+a,V.UnicodeNormalizationForm.NFKD);return Ca.pbkdf2(V.toUtf8Bytes(e,V.UnicodeNormalizationForm.NFKD),t,2048,64,"sha512")}function p(e,a){a=i(a),t.checkNormalize();var f=a.split(e);if(f.length%3!=0)throw new Error("invalid mnemonic");for(var n=l.arrayify(new Uint8Array(Math.ceil(11*f.length/8))),d=0,s=0;s>3]|=1<<7-d%8),d++}var u=32*f.length/3,o=b(f.length/3);if((l.arrayify(Ma.sha256(n.slice(0,u/8)))[0]&o)!=(n[n.length-1]&o))throw new Error("invalid checksum");return l.hexlify(n.slice(0,u/8))}function y(e,a){if(a=i(a),(e=l.arrayify(e)).length%4!=0||e.length<16||e.length>32)throw new Error("invalid entropy");for(var t=[0],f=11,n=0;n8?(t[t.length-1]<<=8,t[t.length-1]|=e[n],f-=8):(t[t.length-1]<<=f,t[t.length-1]|=e[n]>>8-f,t.push(e[n]&(1<<8-f)-1),f+=3);var d=e.length/4,s=l.arrayify(Ma.sha256(e))[0]&b(d);return t[t.length-1]<<=d,t[t.length-1]|=s>>8-d,a.join(t.map((function(e){return a.getWord(e)})))}a.HDNode=r,a.mnemonicToSeed=u,a.mnemonicToEntropy=p,a.entropyToMnemonic=y,a.isValidMnemonic=function(e,a){try{return p(e,a),!0}catch(e){}return!1}}))),wt=(b(Tt),Tt.defaultPath,Tt.HDNode,Tt.mnemonicToSeed,Tt.mnemonicToEntropy,Tt.entropyToMnemonic,Tt.isValidMnemonic,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.version="random/5.0.2"}))),Et=(b(wt),wt.version,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.shuffled=function(e){for(var a=(e=e.slice()).length-1;a>0;a--){var t=Math.floor(Math.random()*(a+1)),f=e[a];e[a]=e[t],e[t]=f}return e}}))),At=(b(Et),Et.shuffled,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0});var t=new o.Logger(wt.version);a.shuffled=Et.shuffled;var f=null;try{if(null==(f=window))throw new Error("try next")}catch(e){try{if(null==(f=n))throw new Error("try next")}catch(e){f={}}}var b=f.crypto||f.msCrypto;b&&b.getRandomValues||(t.warn("WARNING: Missing strong random number source"),b={getRandomValues:function(e){return t.throwError("no secure random source avaialble",o.Logger.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}}),a.randomBytes=function(e){(e<=0||e>1024||e%1)&&t.throwArgumentError("invalid length","length",e);var a=new Uint8Array(e);return b.getRandomValues(a),l.arrayify(a)}}))),Mt=(b(At),At.shuffled,At.randomBytes,d((function(e,a){!function(a){function t(e){return parseInt(e)===e}function f(e){if(!t(e.length))return!1;for(var a=0;a255)return!1;return!0}function n(e,a){if(e.buffer&&ArrayBuffer.isView(e)&&"Uint8Array"===e.name)return a&&(e=e.slice?e.slice():Array.prototype.slice.call(e)),e;if(Array.isArray(e)){if(!f(e))throw new Error("Array contains invalid value: "+e);return new Uint8Array(e)}if(t(e.length)&&f(e))return new Uint8Array(e);throw new Error("unsupported array-like object")}function b(e){return new Uint8Array(e)}function d(e,a,t,f,n){null==f&&null==n||(e=e.slice?e.slice(f,n):Array.prototype.slice.call(e,f,n)),a.set(e,t)}var s,i={toBytes:function(e){var a=[],t=0;for(e=encodeURI(e);t191&&f<224?(a.push(String.fromCharCode((31&f)<<6|63&e[t+1])),t+=2):(a.push(String.fromCharCode((15&f)<<12|(63&e[t+1])<<6|63&e[t+2])),t+=3)}return a.join("")}},c=(s="0123456789abcdef",{toBytes:function(e){for(var a=[],t=0;t>4]+s[15&f])}return a.join("")}}),r={16:10,24:12,32:14},u=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],o=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],p=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],l=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],y=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],m=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],h=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],x=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],g=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],v=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],T=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],w=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],E=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],A=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],M=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function C(e){for(var a=[],t=0;t>2,this._Ke[t][a%4]=b[a],this._Kd[e-t][a%4]=b[a];for(var d,s=0,i=n;i>16&255]<<24^o[d>>8&255]<<16^o[255&d]<<8^o[d>>24&255]^u[s]<<24,s+=1,8!=n)for(a=1;a>8&255]<<8^o[d>>16&255]<<16^o[d>>24&255]<<24,a=n/2+1;a>2,p=i%4,this._Ke[c][p]=b[a],this._Kd[e-c][p]=b[a++],i++}for(var c=1;c>24&255]^E[d>>16&255]^A[d>>8&255]^M[255&d]},D.prototype.encrypt=function(e){if(16!=e.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var a=this._Ke.length-1,t=[0,0,0,0],f=C(e),n=0;n<4;n++)f[n]^=this._Ke[0][n];for(var d=1;d>24&255]^y[f[(n+1)%4]>>16&255]^m[f[(n+2)%4]>>8&255]^h[255&f[(n+3)%4]]^this._Ke[d][n];f=t.slice()}var s,i=b(16);for(n=0;n<4;n++)s=this._Ke[a][n],i[4*n]=255&(o[f[n]>>24&255]^s>>24),i[4*n+1]=255&(o[f[(n+1)%4]>>16&255]^s>>16),i[4*n+2]=255&(o[f[(n+2)%4]>>8&255]^s>>8),i[4*n+3]=255&(o[255&f[(n+3)%4]]^s);return i},D.prototype.decrypt=function(e){if(16!=e.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var a=this._Kd.length-1,t=[0,0,0,0],f=C(e),n=0;n<4;n++)f[n]^=this._Kd[0][n];for(var d=1;d>24&255]^g[f[(n+3)%4]>>16&255]^v[f[(n+2)%4]>>8&255]^T[255&f[(n+1)%4]]^this._Kd[d][n];f=t.slice()}var s,i=b(16);for(n=0;n<4;n++)s=this._Kd[a][n],i[4*n]=255&(p[f[n]>>24&255]^s>>24),i[4*n+1]=255&(p[f[(n+3)%4]>>16&255]^s>>16),i[4*n+2]=255&(p[f[(n+2)%4]>>8&255]^s>>8),i[4*n+3]=255&(p[255&f[(n+1)%4]]^s);return i};var S=function(e){if(!(this instanceof S))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new D(e)};S.prototype.encrypt=function(e){if((e=n(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var a=b(e.length),t=b(16),f=0;f=0;--a)this._counter[a]=e%256,e>>=8},k.prototype.setBytes=function(e){if(16!=(e=n(e,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=e},k.prototype.increment=function(){for(var e=15;e>=0;e--){if(255!==this._counter[e]){this._counter[e]++;break}this._counter[e]=0}};var R=function(e,a){if(!(this instanceof R))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",a instanceof k||(a=new k(a)),this._counter=a,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new D(e)};R.prototype.encrypt=function(e){for(var a=n(e,!0),t=0;t16)throw new Error("PKCS#7 padding byte out of range");for(var t=e.length-a,f=0;f=64;){let p,l,y,m,h,x=t,g=f,v=n,T=b,w=d,E=s,A=i,M=c;for(l=0;l<16;l++)y=u+4*l,r[l]=(255&e[y])<<24|(255&e[y+1])<<16|(255&e[y+2])<<8|255&e[y+3];for(l=16;l<64;l++)p=r[l-2],m=(p>>>17|p<<15)^(p>>>19|p<<13)^p>>>10,p=r[l-15],h=(p>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,r[l]=(m+r[l-7]|0)+(h+r[l-16]|0)|0;for(l=0;l<64;l++)m=(((w>>>6|w<<26)^(w>>>11|w<<21)^(w>>>25|w<<7))+(w&E^~w&A)|0)+(M+(a[l]+r[l]|0)|0)|0,h=((x>>>2|x<<30)^(x>>>13|x<<19)^(x>>>22|x<<10))+(x&g^x&v^g&v)|0,M=A,A=E,E=w,w=T+m|0,T=v,v=g,g=x,x=m+h|0;t=t+x|0,f=f+g|0,n=n+v|0,b=b+T|0,d=d+w|0,s=s+E|0,i=i+A|0,c=c+M|0,u+=64,o-=64}}u(e);let o,p=e.length%64,l=e.length/536870912|0,y=e.length<<3,m=p<56?56:120,h=e.slice(e.length-p,e.length);for(h.push(128),o=p+1;o>>24&255),h.push(l>>>16&255),h.push(l>>>8&255),h.push(l>>>0&255),h.push(y>>>24&255),h.push(y>>>16&255),h.push(y>>>8&255),h.push(y>>>0&255),u(h),[t>>>24&255,t>>>16&255,t>>>8&255,t>>>0&255,f>>>24&255,f>>>16&255,f>>>8&255,f>>>0&255,n>>>24&255,n>>>16&255,n>>>8&255,n>>>0&255,b>>>24&255,b>>>16&255,b>>>8&255,b>>>0&255,d>>>24&255,d>>>16&255,d>>>8&255,d>>>0&255,s>>>24&255,s>>>16&255,s>>>8&255,s>>>0&255,i>>>24&255,i>>>16&255,i>>>8&255,i>>>0&255,c>>>24&255,c>>>16&255,c>>>8&255,c>>>0&255]}function n(e,a,f){e=e.length<=64?e:t(e);const n=64+a.length+4,b=new Array(n),d=new Array(64);let s,i=[];for(s=0;s<64;s++)b[s]=54;for(s=0;s=n-4;e--){if(b[e]++,b[e]<=255)return;b[e]=0}}for(;f>=32;)c(),i=i.concat(t(d.concat(t(b)))),f-=32;return f>0&&(c(),i=i.concat(t(d.concat(t(b))).slice(0,f))),i}function b(e,a,t,f,n){let b;for(c(e,16*(2*t-1),n,0,16),b=0;b<2*t;b++)i(e,16*b,n,16),s(n,f),c(n,0,e,a+16*b,16);for(b=0;b>>32-a}function s(e,a){c(e,0,a,0,16);for(let e=8;e>0;e-=2)a[4]^=d(a[0]+a[12],7),a[8]^=d(a[4]+a[0],9),a[12]^=d(a[8]+a[4],13),a[0]^=d(a[12]+a[8],18),a[9]^=d(a[5]+a[1],7),a[13]^=d(a[9]+a[5],9),a[1]^=d(a[13]+a[9],13),a[5]^=d(a[1]+a[13],18),a[14]^=d(a[10]+a[6],7),a[2]^=d(a[14]+a[10],9),a[6]^=d(a[2]+a[14],13),a[10]^=d(a[6]+a[2],18),a[3]^=d(a[15]+a[11],7),a[7]^=d(a[3]+a[15],9),a[11]^=d(a[7]+a[3],13),a[15]^=d(a[11]+a[7],18),a[1]^=d(a[0]+a[3],7),a[2]^=d(a[1]+a[0],9),a[3]^=d(a[2]+a[1],13),a[0]^=d(a[3]+a[2],18),a[6]^=d(a[5]+a[4],7),a[7]^=d(a[6]+a[5],9),a[4]^=d(a[7]+a[6],13),a[5]^=d(a[4]+a[7],18),a[11]^=d(a[10]+a[9],7),a[8]^=d(a[11]+a[10],9),a[9]^=d(a[8]+a[11],13),a[10]^=d(a[9]+a[8],18),a[12]^=d(a[15]+a[14],7),a[13]^=d(a[12]+a[15],9),a[14]^=d(a[13]+a[12],13),a[15]^=d(a[14]+a[13],18);for(let t=0;t<16;++t)e[t]+=a[t]}function i(e,a,t,f){for(let n=0;n=256)return!1}return!0}function u(e,a){if("number"!=typeof e||e%1)throw new Error("invalid "+a);return e}function o(e,a,t,d,s,o,p){if(t=u(t,"N"),d=u(d,"r"),s=u(s,"p"),o=u(o,"dkLen"),0===t||0!=(t&t-1))throw new Error("N must be power of 2");if(t>2147483647/128/d)throw new Error("N too large");if(d>2147483647/128/s)throw new Error("r too large");if(!r(e))throw new Error("password must be an array or buffer");if(e=Array.prototype.slice.call(e),!r(a))throw new Error("salt must be an array or buffer");a=Array.prototype.slice.call(a);let l=n(e,a,128*s*d);const y=new Uint32Array(32*s*d);for(let e=0;eB&&(a=B);for(let e=0;eB&&(a=B);for(let e=0;e>0&255),l.push(y[e]>>8&255),l.push(y[e]>>16&255),l.push(y[e]>>24&255);const f=n(e,l,o);return p&&p(null,1,f),f}p&&F(_)};if(!p)for(;;){const e=_();if(null!=e)return e}_()}const p={scrypt:function(e,a,t,f,n,b,d){return new Promise((function(s,i){let c=0;d&&d(0),o(e,a,t,f,n,b,(function(e,a,t){if(e)i(e);else if(t)d&&1!==c&&d(1),s(new Uint8Array(t));else if(d&&a!==c)return c=a,d(a)}))}))},syncScrypt:function(e,a,t,f,n,b){return new Uint8Array(o(e,a,t,f,n,b))}};e.exports=p}()}))),_t=(Ft.scrypt,Ft.syncScrypt,d((function(e,a){var t,f=n&&n.__extends||(t=function(e,a){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,a){e.__proto__=a}||function(e,a){for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])})(e,a)},function(e,a){function f(){this.constructor=e}t(e,a),e.prototype=null===a?Object.create(a):(f.prototype=a.prototype,new f)}),b=n&&n.__awaiter||function(e,a,t,f){return new(t||(t=Promise))((function(n,b){function d(e){try{i(f.next(e))}catch(e){b(e)}}function s(e){try{i(f.throw(e))}catch(e){b(e)}}function i(e){var a;e.done?n(e.value):(a=e.value,a instanceof t?a:new t((function(e){e(a)}))).then(d,s)}i((f=f.apply(e,a||[])).next())}))},d=n&&n.__generator||function(e,a){var t,f,n,b,d={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return b={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(b[Symbol.iterator]=function(){return this}),b;function s(b){return function(s){return function(b){if(t)throw new TypeError("Generator is already executing.");for(;d;)try{if(t=1,f&&(n=2&b[0]?f.return:b[0]?f.throw||((n=f.return)&&n.call(f),0):f.next)&&!(n=n.call(f,b[1])).done)return n;switch(f=0,n&&(b=[2&b[0],n.value]),b[0]){case 0:case 1:n=b;break;case 4:return d.label++,{value:b[1],done:!1};case 5:d.label++,f=b[1],b=[0];continue;case 7:b=d.ops.pop(),d.trys.pop();continue;default:if(!((n=(n=d.trys).length>0&&n[n.length-1])||6!==b[0]&&2!==b[0])){d=0;continue}if(3===b[0]&&(!n||b[1]>n[0]&&b[1]0&&n[n.length-1])||6!==b[0]&&2!==b[0])){d=0;continue}if(3===b[0]&&(!n||b[1]>n[0]&&b[1]0&&n[n.length-1])||6!==b[0]&&2!==b[0])){d=0;continue}if(3===b[0]&&(!n||b[1]>n[0]&&b[1]0&&s%1==0,"invalid connection throttle limit","connection.throttleLimit",s);var i="object"==typeof e?e.throttleCallback:null,c="object"==typeof e&&"number"==typeof e.throttleSlotInterval?e.throttleSlotInterval:100;b.assertArgument(c>0&&c%1==0,"invalid connection throttle slot interval","connection.throttleSlotInterval",c);var r={},u=null,p={method:"GET"},l=!1,y=12e4;if("string"==typeof e)u=e;else if("object"==typeof e){if(null!=e&&null!=e.url||b.throwArgumentError("missing URL","connection.url",e),u=e.url,"number"==typeof e.timeout&&e.timeout>0&&(y=e.timeout),e.headers)for(var m in e.headers)r[m.toLowerCase()]={key:m,value:String(e.headers[m])},["if-none-match","if-modified-since"].indexOf(m.toLowerCase())>=0&&(l=!0);if(null!=e.user&&null!=e.password){"https:"!==u.substring(0,6)&&!0!==e.allowInsecureAuthentication&&b.throwError("basic authentication requires a secure https url",o.Logger.errors.INVALID_ARGUMENT,{argument:"url",url:u,user:e.user,password:"[REDACTED]"});var h=e.user+":"+e.password;r.authorization={key:"Authorization",value:"Basic "+Nt.encode(V.toUtf8Bytes(h))}}}a&&(p.method="POST",p.body=a,r["content-type"]={key:"Content-Type",value:"application/json"});var x={};Object.keys(r).forEach((function(e){var a=r[e];x[a.key]=a.value})),p.headers=x;var g,v=(g=null,{promise:new Promise((function(e,a){y&&(g=setTimeout((function(){null!=g&&(g=null,a(b.makeError("timeout",o.Logger.errors.TIMEOUT,{requestBody:p.body||null,requestMethod:p.method,timeout:y,url:u})))}),y))})),cancel:function(){null!=g&&(clearTimeout(g),g=null)}}),T=function(){return t(this,void 0,void 0,(function(){var e,a,t,r,y,m,h,x;return f(this,(function(f){switch(f.label){case 0:e=0,f.label=1;case 1:if(!(e=300)&&(v.cancel(),b.throwError("bad response",o.Logger.errors.SERVER_ERROR,{status:a.statusCode,headers:a.headers,body:y,requestBody:p.body||null,requestMethod:p.method,url:u})),m=null,null!=y)try{m=JSON.parse(y)}catch(e){v.cancel(),b.throwError("invalid JSON",o.Logger.errors.SERVER_ERROR,{body:y,error:e,requestBody:p.body||null,requestMethod:p.method,url:u})}if(!n)return[3,17];f.label=10;case 10:return f.trys.push([10,12,,17]),[4,n(m,a)];case 11:return m=f.sent(),[3,17];case 12:return(h=f.sent()).throttleRetry&&es)return void(d()&&f(new Error("retry limit reached")));var c=a.interval*parseInt(String(Math.random()*Math.pow(2,i)));ca.ceiling&&(c=a.ceiling),setTimeout(n,c)}return null}),(function(e){d()&&f(e)}))}()}))}}))),Kt=(b(Xt),Xt.fetchJson,Xt.poll,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.version="providers/5.0.5"}))),Zt=(b(Kt),Kt.version,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0});var t=new o.Logger(Kt.version),f=function(){function e(){var a=this.constructor;t.checkNew(a,e),this.formats=this.getDefaultFormats()}return e.prototype.getDefaultFormats=function(){var a=this,t={},f=this.address.bind(this),n=this.bigNumber.bind(this),b=this.blockTag.bind(this),d=this.data.bind(this),s=this.hash.bind(this),i=this.hex.bind(this),c=this.number.bind(this);return t.transaction={hash:s,blockHash:e.allowNull(s,null),blockNumber:e.allowNull(c,null),transactionIndex:e.allowNull(c,null),confirmations:e.allowNull(c,null),from:f,gasPrice:n,gasLimit:n,to:e.allowNull(f,null),value:n,nonce:c,data:d,r:e.allowNull(this.uint256),s:e.allowNull(this.uint256),v:e.allowNull(c),creates:e.allowNull(f,null),raw:e.allowNull(d)},t.transactionRequest={from:e.allowNull(f),nonce:e.allowNull(c),gasLimit:e.allowNull(n),gasPrice:e.allowNull(n),to:e.allowNull(f),value:e.allowNull(n),data:e.allowNull((function(e){return a.data(e,!0)}))},t.receiptLog={transactionIndex:c,blockNumber:c,transactionHash:s,address:f,topics:e.arrayOf(s),data:d,logIndex:c,blockHash:s},t.receipt={to:e.allowNull(this.address,null),from:e.allowNull(this.address,null),contractAddress:e.allowNull(f,null),transactionIndex:c,root:e.allowNull(s),gasUsed:n,logsBloom:e.allowNull(d),blockHash:s,transactionHash:s,logs:e.arrayOf(this.receiptLog.bind(this)),blockNumber:c,confirmations:e.allowNull(c,null),cumulativeGasUsed:n,status:e.allowNull(c)},t.block={hash:s,parentHash:s,number:c,timestamp:c,nonce:e.allowNull(i),difficulty:this.difficulty.bind(this),gasLimit:n,gasUsed:n,miner:f,extraData:d,transactions:e.allowNull(e.arrayOf(s))},t.blockWithTransactions=v.shallowCopy(t.block),t.blockWithTransactions.transactions=e.allowNull(e.arrayOf(this.transactionResponse.bind(this))),t.filter={fromBlock:e.allowNull(b,void 0),toBlock:e.allowNull(b,void 0),blockHash:e.allowNull(s,void 0),address:e.allowNull(f,void 0),topics:e.allowNull(this.topics.bind(this),void 0)},t.filterLog={blockNumber:e.allowNull(c),blockHash:e.allowNull(s),transactionIndex:c,removed:e.allowNull(this.boolean.bind(this)),address:f,data:e.allowFalsish(d,"0x"),topics:e.arrayOf(s),transactionHash:s,logIndex:c},t},e.prototype.number=function(e){return x.BigNumber.from(e).toNumber()},e.prototype.bigNumber=function(e){return x.BigNumber.from(e)},e.prototype.boolean=function(e){if("boolean"==typeof e)return e;if("string"==typeof e){if("true"===(e=e.toLowerCase()))return!0;if("false"===e)return!1}throw new Error("invalid boolean - "+e)},e.prototype.hex=function(e,a){return"string"==typeof e&&(a||"0x"===e.substring(0,2)||(e="0x"+e),l.isHexString(e))?e.toLowerCase():t.throwArgumentError("invalid hash","value",e)},e.prototype.data=function(e,a){var t=this.hex(e,a);if(t.length%2!=0)throw new Error("invalid data; odd-length - "+e);return t},e.prototype.address=function(e){return B.getAddress(e)},e.prototype.callAddress=function(e){if(!l.isHexString(e,32))return null;var a=B.getAddress(l.hexDataSlice(e,12));return a===N.AddressZero?null:a},e.prototype.contractAddress=function(e){return B.getContractAddress(e)},e.prototype.blockTag=function(e){if(null==e)return"latest";if("earliest"===e)return"0x0";if("latest"===e||"pending"===e)return e;if("number"==typeof e||l.isHexString(e))return l.hexValue(e);throw new Error("invalid blockTag")},e.prototype.hash=function(e,a){var f=this.hex(e,a);return 32!==l.hexDataLength(f)?t.throwArgumentError("invalid hash","value",e):f},e.prototype.difficulty=function(e){if(null==e)return null;var a=x.BigNumber.from(e);try{return a.toNumber()}catch(e){}return null},e.prototype.uint256=function(e){if(!l.isHexString(e))throw new Error("invalid uint256");return l.hexZeroPad(e,32)},e.prototype._block=function(a,t){return null!=a.author&&null==a.miner&&(a.miner=a.author),e.check(t,a)},e.prototype.block=function(e){return this._block(e,this.formats.block)},e.prototype.blockWithTransactions=function(e){return this._block(e,this.formats.blockWithTransactions)},e.prototype.transactionRequest=function(a){return e.check(this.formats.transactionRequest,a)},e.prototype.transactionResponse=function(a){null!=a.gas&&null==a.gasLimit&&(a.gasLimit=a.gas),a.to&&x.BigNumber.from(a.to).isZero()&&(a.to="0x0000000000000000000000000000000000000000"),null!=a.input&&null==a.data&&(a.data=a.input),null==a.to&&null==a.creates&&(a.creates=this.contractAddress(a));var t=e.check(this.formats.transaction,a);if(null!=a.chainId){var f=a.chainId;l.isHexString(f)&&(f=x.BigNumber.from(f).toNumber()),t.chainId=f}else null==(f=a.networkId)&&null==t.v&&(f=a.chainId),l.isHexString(f)&&(f=x.BigNumber.from(f).toNumber()),"number"!=typeof f&&null!=t.v&&((f=(t.v-35)/2)<0&&(f=0),f=parseInt(f)),"number"!=typeof f&&(f=0),t.chainId=f;return t.blockHash&&"x"===t.blockHash.replace(/0/g,"")&&(t.blockHash=null),t},e.prototype.transaction=function(e){return yt.parse(e)},e.prototype.receiptLog=function(a){return e.check(this.formats.receiptLog,a)},e.prototype.receipt=function(a){var t=e.check(this.formats.receipt,a);return null!=a.status&&(t.byzantium=!0),t},e.prototype.topics=function(e){var a=this;return Array.isArray(e)?e.map((function(e){return a.topics(e)})):null!=e?this.hash(e,!0):null},e.prototype.filter=function(a){return e.check(this.formats.filter,a)},e.prototype.filterLog=function(a){return e.check(this.formats.filterLog,a)},e.check=function(e,a){var t={};for(var f in e)try{var n=e[f](a[f]);void 0!==n&&(t[f]=n)}catch(e){throw e.checkKey=f,e.checkValue=a[f],e}return t},e.allowNull=function(e,a){return function(t){return null==t?a:e(t)}},e.allowFalsish=function(e,a){return function(t){return t?e(t):a}},e.arrayOf=function(e){return function(a){if(!Array.isArray(a))throw new Error("not an array");var t=[];return a.forEach((function(a){t.push(e(a))})),t}},e}();a.Formatter=f;var n=!1;a.showThrottleMessage=function(){n||(n=!0,console.log("========= NOTICE ========="),console.log("Request-Rate Exceeded (this message will not be repeated)"),console.log(""),console.log("The default API keys for each service are provided as a highly-throttled,"),console.log("community resource for low-traffic projects and early prototyping."),console.log(""),console.log("While your application will continue to function, we highly recommended"),console.log("signing up for your own API keys to improve performance, increase your"),console.log("request rate/limit and enable other perks, such as metrics and advanced APIs."),console.log(""),console.log("For more details: https://docs.ethers.io/api-keys/"),console.log("=========================="))}}))),Vt=(b(Zt),Zt.Formatter,Zt.showThrottleMessage,d((function(e,a){var t,f=n&&n.__extends||(t=function(e,a){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,a){e.__proto__=a}||function(e,a){for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])})(e,a)},function(e,a){function f(){this.constructor=e}t(e,a),e.prototype=null===a?Object.create(a):(f.prototype=a.prototype,new f)}),b=n&&n.__awaiter||function(e,a,t,f){return new(t||(t=Promise))((function(n,b){function d(e){try{i(f.next(e))}catch(e){b(e)}}function s(e){try{i(f.throw(e))}catch(e){b(e)}}function i(e){var a;e.done?n(e.value):(a=e.value,a instanceof t?a:new t((function(e){e(a)}))).then(d,s)}i((f=f.apply(e,a||[])).next())}))},d=n&&n.__generator||function(e,a){var t,f,n,b,d={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return b={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(b[Symbol.iterator]=function(){return this}),b;function s(b){return function(s){return function(b){if(t)throw new TypeError("Generator is already executing.");for(;d;)try{if(t=1,f&&(n=2&b[0]?f.return:b[0]?f.throw||((n=f.return)&&n.call(f),0):f.next)&&!(n=n.call(f,b[1])).done)return n;switch(f=0,n&&(b=[2&b[0],n.value]),b[0]){case 0:case 1:n=b;break;case 4:return d.label++,{value:b[1],done:!1};case 5:d.label++,f=b[1],b=[0];continue;case 7:b=d.ops.pop(),d.trys.pop();continue;default:if(!((n=(n=d.trys).length>0&&n[n.length-1])||6!==b[0]&&2!==b[0])){d=0;continue}if(3===b[0]&&(!n||b[1]>n[0]&&b[1]0&&null==e[e.length-1];)e.pop();return e.map((function(e){if(Array.isArray(e)){var a={};e.forEach((function(e){a[i(e)]=!0}));var t=Object.keys(a);return t.sort(),t.join("|")}return i(e)})).join("&")}function r(e){if("string"==typeof e){if(e=e.toLowerCase(),32===l.hexDataLength(e))return"tx:"+e;if(-1===e.indexOf(":"))return e}else{if(Array.isArray(e))return"filter:*:"+c(e);if(Y.ForkEvent.isForkEvent(e))throw s.warn("not implemented"),new Error("not implemented");if(e&&"object"==typeof e)return"filter:"+(e.address||"*")+":"+c(e.topics||[])}throw new Error("invalid event - "+e)}function u(){return(new Date).getTime()}var p=["block","network","pending","poll"],y=function(){function e(e,a,t){v.defineReadOnly(this,"tag",e),v.defineReadOnly(this,"listener",a),v.defineReadOnly(this,"once",t)}return Object.defineProperty(e.prototype,"event",{get:function(){switch(this.type){case"tx":return this.hash;case"filter":return this.filter}return this.tag},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"type",{get:function(){return this.tag.split(":")[0]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hash",{get:function(){var e=this.tag.split(":");return"tx"!==e[0]?null:e[1]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"filter",{get:function(){var e=this.tag.split(":");if("filter"!==e[0])return null;var a,t=e[1],f=""===(a=e[2])?[]:a.split(/&/g).map((function(e){if(""===e)return[];var a=e.split("|").map((function(e){return"null"===e?null:e}));return 1===a.length?a[0]:a})),n={};return f.length>0&&(n.topics=f),t&&"*"!==t&&(n.address=t),n},enumerable:!0,configurable:!0}),e.prototype.pollable=function(){return this.tag.indexOf(":")>=0||p.indexOf(this.tag)>=0},e}();a.Event=y;var m=null,h=1,g=function(e){function a(a){var t=this.constructor,f=this;if(s.checkNew(t,Y.Provider),(f=e.call(this)||this)._events=[],f._emitted={block:-2},f.formatter=t.getFormatter(),v.defineReadOnly(f,"anyNetwork","any"===a),f.anyNetwork&&(a=f.detectNetwork()),a instanceof Promise)f._networkPromise=a,a.catch((function(e){})),f._ready().catch((function(e){}));else{var n=v.getStatic(t,"getNetwork")(a);n?(v.defineReadOnly(f,"_network",n),f.emit("network",n,null)):s.throwArgumentError("invalid network","network",a)}return f._maxInternalBlockNumber=-1024,f._lastBlockNumber=-2,f._pollingInterval=4e3,f._fastQueryDate=0,f}return f(a,e),a.prototype._ready=function(){return b(this,void 0,void 0,(function(){var e;return d(this,(function(a){switch(a.label){case 0:if(null!=this._network)return[3,7];if(e=null,!this._networkPromise)return[3,4];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this._networkPromise];case 2:return e=a.sent(),[3,4];case 3:return a.sent(),[3,4];case 4:return null!=e?[3,6]:[4,this.detectNetwork()];case 5:e=a.sent(),a.label=6;case 6:e||s.throwError("no network detected",o.Logger.errors.UNKNOWN_ERROR,{}),null==this._network&&(this.anyNetwork?this._network=e:v.defineReadOnly(this,"_network",e),this.emit("network",e,null)),a.label=7;case 7:return[2,this._network]}}))}))},Object.defineProperty(a.prototype,"ready",{get:function(){var e=this;return Xt.poll((function(){return e._ready().then((function(e){return e}),(function(e){if(e.code!==o.Logger.errors.NETWORK_ERROR||"noNetwork"!==e.event)throw e}))}))},enumerable:!0,configurable:!0}),a.getFormatter=function(){return null==m&&(m=new Zt.Formatter),m},a.getNetwork=function(e){return It.getNetwork(null==e?"homestead":e)},a.prototype._getInternalBlockNumber=function(e){return b(this,void 0,void 0,(function(){var a,t,f,n,b=this;return d(this,(function(d){switch(d.label){case 0:return[4,this._ready()];case 1:return d.sent(),a=this._internalBlockNumber,e>0&&this._internalBlockNumber?[4,a]:[3,3];case 2:if(t=d.sent(),u()-t.respTime<=e)return[2,t.blockNumber];d.label=3;case 3:return f=u(),n=v.resolveProperties({blockNumber:this.perform("getBlockNumber",{}),networkError:this.getNetwork().then((function(e){return null}),(function(e){return e}))}).then((function(e){var a=e.blockNumber,t=e.networkError;if(t)throw b._internalBlockNumber===n&&(b._internalBlockNumber=null),t;var d=u();return(a=x.BigNumber.from(a).toNumber())1e3)s.warn("network block skew detected; skipping block events"),this.emit("error",s.makeError("network block skew detected",o.Logger.errors.NETWORK_ERROR,{blockNumber:t,event:"blockSkew",previousBlockNumber:this._emitted.block})),this.emit("block",t);else for(f=this._emitted.block+1;f<=t;f++)this.emit("block",f);return this._emitted.block!==t&&(this._emitted.block=t,Object.keys(this._emitted).forEach((function(e){if("block"!==e){var a=n._emitted[e];"pending"!==a&&t-a>12&&delete n._emitted[e]}}))),-2===this._lastBlockNumber&&(this._lastBlockNumber=t-1),this._events.forEach((function(e){switch(e.type){case"tx":var f=e.hash,b=n.getTransactionReceipt(f).then((function(e){return e&&null!=e.blockNumber?(n._emitted["t:"+f]=e.blockNumber,n.emit(f,e),null):null})).catch((function(e){n.emit("error",e)}));a.push(b);break;case"filter":var d=e.filter;d.fromBlock=n._lastBlockNumber+1,d.toBlock=t,b=n.getLogs(d).then((function(e){0!==e.length&&e.forEach((function(e){n._emitted["b:"+e.blockHash]=e.blockNumber,n._emitted["t:"+e.transactionHash]=e.blockNumber,n.emit(d,e)}))})).catch((function(e){n.emit("error",e)})),a.push(b)}})),this._lastBlockNumber=t,Promise.all(a).then((function(){n.emit("didPoll",e)})),[2,null]}}))}))},a.prototype.resetEventsBlock=function(e){this._lastBlockNumber=e-1,this.polling&&this.poll()},Object.defineProperty(a.prototype,"network",{get:function(){return this._network},enumerable:!0,configurable:!0}),a.prototype.detectNetwork=function(){return b(this,void 0,void 0,(function(){return d(this,(function(e){return[2,s.throwError("provider does not support network detection",o.Logger.errors.UNSUPPORTED_OPERATION,{operation:"provider.detectNetwork"})]}))}))},a.prototype.getNetwork=function(){return b(this,void 0,void 0,(function(){var e,a,t;return d(this,(function(f){switch(f.label){case 0:return[4,this._ready()];case 1:return e=f.sent(),[4,this.detectNetwork()];case 2:return a=f.sent(),e.chainId===a.chainId?[3,5]:this.anyNetwork?(this._network=a,this._lastBlockNumber=-2,this._fastBlockNumber=null,this._fastBlockNumberPromise=null,this._fastQueryDate=0,this._emitted.block=-2,this._maxInternalBlockNumber=-1024,this._internalBlockNumber=null,this.emit("network",a,e),[4,(n=0,new Promise((function(e){setTimeout(e,n)})))]):[3,4];case 3:return f.sent(),[2,this._network];case 4:throw t=s.makeError("underlying network changed",o.Logger.errors.NETWORK_ERROR,{event:"changed",network:e,detectedNetwork:a}),this.emit("error",t),t;case 5:return[2,e]}var n}))}))},Object.defineProperty(a.prototype,"blockNumber",{get:function(){var e=this;return this._getInternalBlockNumber(100+this.pollingInterval/2).then((function(a){e._setFastBlockNumber(a)})),null!=this._fastBlockNumber?this._fastBlockNumber:-1},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"polling",{get:function(){return null!=this._poller},set:function(e){var a=this;e&&!this._poller?(this._poller=setInterval(this.poll.bind(this),this.pollingInterval),this._bootstrapPoll||(this._bootstrapPoll=setTimeout((function(){a.poll(),a._bootstrapPoll=setTimeout((function(){a._poller||a.poll(),a._bootstrapPoll=null}),a.pollingInterval)}),0))):!e&&this._poller&&(clearInterval(this._poller),this._poller=null)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"pollingInterval",{get:function(){return this._pollingInterval},set:function(e){var a=this;if("number"!=typeof e||e<=0||parseInt(String(e))!=e)throw new Error("invalid polling interval");this._pollingInterval=e,this._poller&&(clearInterval(this._poller),this._poller=setInterval((function(){a.poll()}),this._pollingInterval))},enumerable:!0,configurable:!0}),a.prototype._getFastBlockNumber=function(){var e=this,a=u();return a-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=a,this._fastBlockNumberPromise=this.getBlockNumber().then((function(a){return(null==e._fastBlockNumber||a>e._fastBlockNumber)&&(e._fastBlockNumber=a),e._fastBlockNumber}))),this._fastBlockNumberPromise},a.prototype._setFastBlockNumber=function(e){null!=this._fastBlockNumber&&ethis._fastBlockNumber)&&(this._fastBlockNumber=e,this._fastBlockNumberPromise=Promise.resolve(e)))},a.prototype.waitForTransaction=function(e,a,t){return b(this,void 0,void 0,(function(){var f,n=this;return d(this,(function(b){switch(b.label){case 0:return null==a&&(a=1),[4,this.getTransactionReceipt(e)];case 1:return((f=b.sent())?f.confirmations:0)>=a?[2,f]:[2,new Promise((function(f,b){var d=null,i=!1,c=function(t){t.confirmations0&&(d=setTimeout((function(){i||(d=null,i=!0,n.removeListener(e,c),b(s.makeError("timeout exceeded",o.Logger.errors.TIMEOUT,{timeout:t})))}),t)).unref&&d.unref()}))]}}))}))},a.prototype.getBlockNumber=function(){return b(this,void 0,void 0,(function(){return d(this,(function(e){return[2,this._getInternalBlockNumber(0)]}))}))},a.prototype.getGasPrice=function(){return b(this,void 0,void 0,(function(){var e,a;return d(this,(function(t){switch(t.label){case 0:return[4,this.getNetwork()];case 1:return t.sent(),a=(e=x.BigNumber).from,[4,this.perform("getGasPrice",{})];case 2:return[2,a.apply(e,[t.sent()])]}}))}))},a.prototype.getBalance=function(e,a){return b(this,void 0,void 0,(function(){var t,f,n;return d(this,(function(b){switch(b.label){case 0:return[4,this.getNetwork()];case 1:return b.sent(),[4,v.resolveProperties({address:this._getAddress(e),blockTag:this._getBlockTag(a)})];case 2:return t=b.sent(),n=(f=x.BigNumber).from,[4,this.perform("getBalance",t)];case 3:return[2,n.apply(f,[b.sent()])]}}))}))},a.prototype.getTransactionCount=function(e,a){return b(this,void 0,void 0,(function(){var t,f,n;return d(this,(function(b){switch(b.label){case 0:return[4,this.getNetwork()];case 1:return b.sent(),[4,v.resolveProperties({address:this._getAddress(e),blockTag:this._getBlockTag(a)})];case 2:return t=b.sent(),n=(f=x.BigNumber).from,[4,this.perform("getTransactionCount",t)];case 3:return[2,n.apply(f,[b.sent()]).toNumber()]}}))}))},a.prototype.getCode=function(e,a){return b(this,void 0,void 0,(function(){var t,f;return d(this,(function(n){switch(n.label){case 0:return[4,this.getNetwork()];case 1:return n.sent(),[4,v.resolveProperties({address:this._getAddress(e),blockTag:this._getBlockTag(a)})];case 2:return t=n.sent(),f=l.hexlify,[4,this.perform("getCode",t)];case 3:return[2,f.apply(void 0,[n.sent()])]}}))}))},a.prototype.getStorageAt=function(e,a,t){return b(this,void 0,void 0,(function(){var f,n;return d(this,(function(b){switch(b.label){case 0:return[4,this.getNetwork()];case 1:return b.sent(),[4,v.resolveProperties({address:this._getAddress(e),blockTag:this._getBlockTag(t),position:Promise.resolve(a).then((function(e){return l.hexValue(e)}))})];case 2:return f=b.sent(),n=l.hexlify,[4,this.perform("getStorageAt",f)];case 3:return[2,n.apply(void 0,[b.sent()])]}}))}))},a.prototype._wrapTransaction=function(e,a){var t=this;if(null!=a&&32!==l.hexDataLength(a))throw new Error("invalid response - sendTransaction");var f=e;return null!=a&&e.hash!==a&&s.throwError("Transaction hash mismatch from Provider.sendTransaction.",o.Logger.errors.UNKNOWN_ERROR,{expectedHash:e.hash,returnedHash:a}),f.wait=function(a){return b(t,void 0,void 0,(function(){var t;return d(this,(function(f){switch(f.label){case 0:return 0!==a&&(this._emitted["t:"+e.hash]="pending"),[4,this.waitForTransaction(e.hash,a)];case 1:return null==(t=f.sent())&&0===a?[2,null]:(this._emitted["t:"+e.hash]=t.blockNumber,0===t.status&&s.throwError("transaction failed",o.Logger.errors.CALL_EXCEPTION,{transactionHash:e.hash,transaction:e,receipt:t}),[2,t])}}))}))},f},a.prototype.sendTransaction=function(e){return b(this,void 0,void 0,(function(){var a,t,f,n;return d(this,(function(b){switch(b.label){case 0:return[4,this.getNetwork()];case 1:return b.sent(),[4,Promise.resolve(e).then((function(e){return l.hexlify(e)}))];case 2:a=b.sent(),t=this.formatter.transaction(e),b.label=3;case 3:return b.trys.push([3,5,,6]),[4,this.perform("sendTransaction",{signedTransaction:a})];case 4:return f=b.sent(),[2,this._wrapTransaction(t,f)];case 5:throw(n=b.sent()).transaction=t,n.transactionHash=t.hash,n;case 6:return[2]}}))}))},a.prototype._getTransactionRequest=function(e){return b(this,void 0,void 0,(function(){var a,t,f,n,b=this;return d(this,(function(d){switch(d.label){case 0:return[4,e];case 1:return a=d.sent(),t={},["from","to"].forEach((function(e){null!=a[e]&&(t[e]=Promise.resolve(a[e]).then((function(e){return e?b._getAddress(e):null})))})),["gasLimit","gasPrice","value"].forEach((function(e){null!=a[e]&&(t[e]=Promise.resolve(a[e]).then((function(e){return e?x.BigNumber.from(e):null})))})),["data"].forEach((function(e){null!=a[e]&&(t[e]=Promise.resolve(a[e]).then((function(e){return e?l.hexlify(e):null})))})),n=(f=this.formatter).transactionRequest,[4,v.resolveProperties(t)];case 2:return[2,n.apply(f,[d.sent()])]}}))}))},a.prototype._getFilter=function(e){return b(this,void 0,void 0,(function(){var a,t,f,n=this;return d(this,(function(b){switch(b.label){case 0:return[4,e];case 1:return e=b.sent(),a={},null!=e.address&&(a.address=this._getAddress(e.address)),["blockHash","topics"].forEach((function(t){null!=e[t]&&(a[t]=e[t])})),["fromBlock","toBlock"].forEach((function(t){null!=e[t]&&(a[t]=n._getBlockTag(e[t]))})),f=(t=this.formatter).filter,[4,v.resolveProperties(a)];case 2:return[2,f.apply(t,[b.sent()])]}}))}))},a.prototype.call=function(e,a){return b(this,void 0,void 0,(function(){var t,f;return d(this,(function(n){switch(n.label){case 0:return[4,this.getNetwork()];case 1:return n.sent(),[4,v.resolveProperties({transaction:this._getTransactionRequest(e),blockTag:this._getBlockTag(a)})];case 2:return t=n.sent(),f=l.hexlify,[4,this.perform("call",t)];case 3:return[2,f.apply(void 0,[n.sent()])]}}))}))},a.prototype.estimateGas=function(e){return b(this,void 0,void 0,(function(){var a,t,f;return d(this,(function(n){switch(n.label){case 0:return[4,this.getNetwork()];case 1:return n.sent(),[4,v.resolveProperties({transaction:this._getTransactionRequest(e)})];case 2:return a=n.sent(),f=(t=x.BigNumber).from,[4,this.perform("estimateGas",a)];case 3:return[2,f.apply(t,[n.sent()])]}}))}))},a.prototype._getAddress=function(e){return b(this,void 0,void 0,(function(){var a;return d(this,(function(t){switch(t.label){case 0:return[4,this.resolveName(e)];case 1:return null==(a=t.sent())&&s.throwError("ENS name not configured",o.Logger.errors.UNSUPPORTED_OPERATION,{operation:"resolveName("+JSON.stringify(e)+")"}),[2,a]}}))}))},a.prototype._getBlock=function(e,a){return b(this,void 0,void 0,(function(){var t,f,n,i,c,r=this;return d(this,(function(u){switch(u.label){case 0:return[4,this.getNetwork()];case 1:return u.sent(),[4,e];case 2:return e=u.sent(),t=-128,f={includeTransactions:!!a},l.isHexString(e,32)?(f.blockHash=e,[3,6]):[3,3];case 3:return u.trys.push([3,5,,6]),n=f,c=(i=this.formatter).blockTag,[4,this._getBlockTag(e)];case 4:return n.blockTag=c.apply(i,[u.sent()]),l.isHexString(f.blockTag)&&(t=parseInt(f.blockTag.substring(2),16)),[3,6];case 5:return u.sent(),s.throwArgumentError("invalid block hash or block tag","blockHashOrBlockTag",e),[3,6];case 6:return[2,Xt.poll((function(){return b(r,void 0,void 0,(function(){var e,n,b,s,i;return d(this,(function(d){switch(d.label){case 0:return[4,this.perform("getBlock",f)];case 1:if(null==(e=d.sent()))return null!=f.blockHash&&null==this._emitted["b:"+f.blockHash]||null!=f.blockTag&&t>this._emitted.block?[2,null]:[2,void 0];if(!a)return[3,8];n=null,b=0,d.label=2;case 2:return bf.length?[2,null]:(s=V.toUtf8String(f.slice(0,b)),[4,this.resolveName(s)]));case 4:return d.sent()!=e?[2,null]:[2,s]}}))}))},a.prototype.perform=function(e,a){return s.throwError(e+" not implemented",o.Logger.errors.NOT_IMPLEMENTED,{operation:e})},a.prototype._startEvent=function(e){this.polling=this._events.filter((function(e){return e.pollable()})).length>0},a.prototype._stopEvent=function(e){this.polling=this._events.filter((function(e){return e.pollable()})).length>0},a.prototype._addEventListener=function(e,a,t){var f=new y(r(e),a,t);return this._events.push(f),this._startEvent(f),this},a.prototype.on=function(e,a){return this._addEventListener(e,a,!1)},a.prototype.once=function(e,a){return this._addEventListener(e,a,!0)},a.prototype.emit=function(e){for(var a=this,t=[],f=1;f0&&n[n.length-1])||6!==b[0]&&2!==b[0])){d=0;continue}if(3===b[0]&&(!n||b[1]>n[0]&&b[1]=0&&s.throwError("insufficient funds",o.Logger.errors.INSUFFICIENT_FUNDS,{transaction:f}),e.responseText.indexOf("nonce too low")>=0&&s.throwError("nonce has already been used",o.Logger.errors.NONCE_EXPIRED,{transaction:f}),e.responseText.indexOf("replacement transaction underpriced")>=0&&s.throwError("replacement fee too low",o.Logger.errors.REPLACEMENT_UNDERPRICED,{transaction:f})),e}))}))},a.prototype.signTransaction=function(e){return s.throwError("signing transactions is unsupported",o.Logger.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})},a.prototype.sendTransaction=function(e){var a=this;return this.sendUncheckedTransaction(e).then((function(e){return Xt.poll((function(){return a.provider.getTransaction(e).then((function(t){if(null!==t)return a.provider._wrapTransaction(t,e)}))}),{onceBlock:a.provider}).catch((function(a){throw a.transactionHash=e,a}))}))},a.prototype.signMessage=function(e){var a=this,t="string"==typeof e?V.toUtf8Bytes(e):e;return this.getAddress().then((function(e){return a.provider.send("eth_sign",[e.toLowerCase(),l.hexlify(t)])}))},a.prototype.unlock=function(e){var a=this.provider;return this.getAddress().then((function(t){return a.send("personal_unlockAccount",[t.toLowerCase(),e,null])}))},a}(ee.Signer);a.JsonRpcSigner=p;var y=function(e){function a(){return null!==e&&e.apply(this,arguments)||this}return f(a,e),a.prototype.sendTransaction=function(e){var a=this;return this.sendUncheckedTransaction(e).then((function(e){return{hash:e,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:function(t){return a.provider.waitForTransaction(e,t)}}}))},a}(p),m={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0},h=function(e){function a(t,f){var n=this.constructor,b=this;s.checkNew(n,a);var d=f;return null==d&&(d=new Promise((function(e,a){setTimeout((function(){b.detectNetwork().then((function(a){e(a)}),(function(e){a(e)}))}),0)}))),b=e.call(this,d)||this,t||(t=v.getStatic(b.constructor,"defaultUrl")()),"string"==typeof t?v.defineReadOnly(b,"connection",Object.freeze({url:t})):v.defineReadOnly(b,"connection",Object.freeze(v.shallowCopy(t))),b._nextId=42,b}return f(a,e),a.defaultUrl=function(){return"http://localhost:8545"},a.prototype.detectNetwork=function(){return b(this,void 0,void 0,(function(){var e,a;return d(this,(function(t){switch(t.label){case 0:return[4,i(0)];case 1:t.sent(),e=null,t.label=2;case 2:return t.trys.push([2,4,,9]),[4,this.send("eth_chainId",[])];case 3:return e=t.sent(),[3,9];case 4:t.sent(),t.label=5;case 5:return t.trys.push([5,7,,8]),[4,this.send("net_version",[])];case 6:return e=t.sent(),[3,8];case 7:return t.sent(),[3,8];case 8:return[3,9];case 9:if(null!=e){a=v.getStatic(this.constructor,"getNetwork");try{return[2,a(x.BigNumber.from(e).toNumber())]}catch(a){return[2,s.throwError("could not detect network",o.Logger.errors.NETWORK_ERROR,{chainId:e,event:"invalidNetwork",serverError:a})]}}return[2,s.throwError("could not detect network",o.Logger.errors.NETWORK_ERROR,{event:"noNetwork"})]}}))}))},a.prototype.getSigner=function(e){return new p(u,this,e)},a.prototype.getUncheckedSigner=function(e){return this.getSigner(e).connectUnchecked()},a.prototype.listAccounts=function(){var e=this;return this.send("eth_accounts",[]).then((function(a){return a.map((function(a){return e.formatter.address(a)}))}))},a.prototype.send=function(e,a){var t=this,f={method:e,params:a,id:this._nextId++,jsonrpc:"2.0"};return this.emit("debug",{action:"request",request:v.deepCopy(f),provider:this}),Xt.fetchJson(this.connection,JSON.stringify(f),c).then((function(e){return t.emit("debug",{action:"response",request:f,response:e,provider:t}),e}),(function(e){throw t.emit("debug",{action:"response",error:e,request:f,provider:t}),e}))},a.prototype.prepareRequest=function(e,a){switch(e){case"getBlockNumber":return["eth_blockNumber",[]];case"getGasPrice":return["eth_gasPrice",[]];case"getBalance":return["eth_getBalance",[r(a.address),a.blockTag]];case"getTransactionCount":return["eth_getTransactionCount",[r(a.address),a.blockTag]];case"getCode":return["eth_getCode",[r(a.address),a.blockTag]];case"getStorageAt":return["eth_getStorageAt",[r(a.address),a.position,a.blockTag]];case"sendTransaction":return["eth_sendRawTransaction",[a.signedTransaction]];case"getBlock":return a.blockTag?["eth_getBlockByNumber",[a.blockTag,!!a.includeTransactions]]:a.blockHash?["eth_getBlockByHash",[a.blockHash,!!a.includeTransactions]]:null;case"getTransaction":return["eth_getTransactionByHash",[a.transactionHash]];case"getTransactionReceipt":return["eth_getTransactionReceipt",[a.transactionHash]];case"call":return["eth_call",[v.getStatic(this.constructor,"hexlifyTransaction")(a.transaction,{from:!0}),a.blockTag]];case"estimateGas":return["eth_estimateGas",[v.getStatic(this.constructor,"hexlifyTransaction")(a.transaction,{from:!0})]];case"getLogs":return a.filter&&null!=a.filter.address&&(a.filter.address=r(a.filter.address)),["eth_getLogs",[a.filter]]}return null},a.prototype.perform=function(e,a){var t=this.prepareRequest(e,a);return null==t&&s.throwError(e+" not implemented",o.Logger.errors.NOT_IMPLEMENTED,{operation:e}),"sendTransaction"===e?this.send(t[0],t[1]).catch((function(e){throw e.responseText&&(e.responseText.indexOf("insufficient funds")>0&&s.throwError("insufficient funds",o.Logger.errors.INSUFFICIENT_FUNDS,{}),e.responseText.indexOf("nonce too low")>0&&s.throwError("nonce has already been used",o.Logger.errors.NONCE_EXPIRED,{}),e.responseText.indexOf("replacement transaction underpriced")>0&&s.throwError("replacement fee too low",o.Logger.errors.REPLACEMENT_UNDERPRICED,{})),e})):this.send(t[0],t[1])},a.prototype._startEvent=function(a){"pending"===a.tag&&this._startPending(),e.prototype._startEvent.call(this,a)},a.prototype._startPending=function(){if(null==this._pendingFilter){var e=this,a=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=a,a.then((function(t){return function f(){e.send("eth_getFilterChanges",[t]).then((function(t){if(e._pendingFilter!=a)return null;var f=Promise.resolve();return t.forEach((function(a){e._emitted["t:"+a.toLowerCase()]="pending",f=f.then((function(){return e.getTransaction(a).then((function(a){return e.emit("pending",a),null}))}))})),f.then((function(){return i(1e3)}))})).then((function(){if(e._pendingFilter==a)return setTimeout((function(){f()}),0),null;e.send("eth_uninstallFilter",[t])})).catch((function(e){}))}(),t})).catch((function(e){}))}},a.prototype._stopEvent=function(a){"pending"===a.tag&&0===this.listenerCount("pending")&&(this._pendingFilter=null),e.prototype._stopEvent.call(this,a)},a.hexlifyTransaction=function(e,a){var t=v.shallowCopy(m);if(a)for(var f in a)a[f]&&(t[f]=!0);v.checkProperties(e,t);var n={};return["gasLimit","gasPrice","nonce","value"].forEach((function(a){if(null!=e[a]){var t=l.hexValue(e[a]);"gasLimit"===a&&(a="gas"),n[a]=t}})),["from","to","data"].forEach((function(a){null!=e[a]&&(n[a]=l.hexlify(e[a]))})),n},a}(Vt.BaseProvider);a.JsonRpcProvider=h}))),zt=(b(Ht),Ht.JsonRpcSigner,Ht.JsonRpcProvider,d((function(e,a){var t,f=n&&n.__extends||(t=function(e,a){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,a){e.__proto__=a}||function(e,a){for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])})(e,a)},function(e,a){function f(){this.constructor=e}t(e,a),e.prototype=null===a?Object.create(a):(f.prototype=a.prototype,new f)}),b=n&&n.__awaiter||function(e,a,t,f){return new(t||(t=Promise))((function(n,b){function d(e){try{i(f.next(e))}catch(e){b(e)}}function s(e){try{i(f.throw(e))}catch(e){b(e)}}function i(e){var a;e.done?n(e.value):(a=e.value,a instanceof t?a:new t((function(e){e(a)}))).then(d,s)}i((f=f.apply(e,a||[])).next())}))},d=n&&n.__generator||function(e,a){var t,f,n,b,d={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return b={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(b[Symbol.iterator]=function(){return this}),b;function s(b){return function(s){return function(b){if(t)throw new TypeError("Generator is already executing.");for(;d;)try{if(t=1,f&&(n=2&b[0]?f.return:b[0]?f.throw||((n=f.return)&&n.call(f),0):f.next)&&!(n=n.call(f,b[1])).done)return n;switch(f=0,n&&(b=[2&b[0],n.value]),b[0]){case 0:case 1:n=b;break;case 4:return d.label++,{value:b[1],done:!1};case 5:d.label++,f=b[1],b=[0];continue;case 7:b=d.ops.pop(),d.trys.pop();continue;default:if(!((n=(n=d.trys).length>0&&n[n.length-1])||6!==b[0]&&2!==b[0])){d=0;continue}if(3===b[0]&&(!n||b[1]>n[0]&&b[1]0&&n[n.length-1])||6!==b[0]&&2!==b[0])){d=0;continue}if(3===b[0]&&(!n||b[1]>n[0]&&b[1]0&&n[n.length-1])||6!==b[0]&&2!==b[0])){d=0;continue}if(3===b[0]&&(!n||b[1]>n[0]&&b[1]0&&n[n.length-1])||6!==b[0]&&2!==b[0])){d=0;continue}if(3===b[0]&&(!n||b[1]>n[0]&&b[1]=0&&(a.throttleRetry=!0),a}return e.result}function r(e){if(e&&0==e.status&&"NOTOK"==e.message&&(e.result||"").toLowerCase().indexOf("rate limit")>=0)throw(a=new Error("throttled response")).result=JSON.stringify(e),a.throttleRetry=!0,a;if("2.0"!=e.jsonrpc)throw(a=new Error("invalid response")).result=JSON.stringify(e),a;if(e.error){var a=new Error(e.error.message||"unknown error");throw e.error.code&&(a.code=e.error.code),e.error.data&&(a.data=e.error.data),a}return e.result}function u(e){if("pending"===e)throw new Error("pending not supported");return"latest"===e?e:parseInt(e.substring(2),16)}var p="9D13ZE7XSBTJ94N9BNJ2MA33VMAY2YPIRB",y=function(e){function a(t,f){var n,b=this.constructor;s.checkNew(b,a);var d="invalid";(n=e.call(this,t)||this).network&&(d=n.network.name);var i=null;switch(d){case"homestead":i="https://api.etherscan.io";break;case"ropsten":i="https://api-ropsten.etherscan.io";break;case"rinkeby":i="https://api-rinkeby.etherscan.io";break;case"kovan":i="https://api-kovan.etherscan.io";break;case"goerli":i="https://api-goerli.etherscan.io";break;default:throw new Error("unsupported network")}return v.defineReadOnly(n,"baseUrl",i),v.defineReadOnly(n,"apiKey",f||p),n}return f(a,e),a.prototype.detectNetwork=function(){return b(this,void 0,void 0,(function(){return d(this,(function(e){return[2,this.network]}))}))},a.prototype.perform=function(a,t){return b(this,void 0,void 0,(function(){var f,n,l,y,m,h,x,g,T,w,E,A=this;return d(this,(function(M){switch(M.label){case 0:switch(f=this.baseUrl,n="",this.apiKey&&(n+="&apikey="+this.apiKey),l=function(e,a){return b(A,void 0,void 0,(function(){var t,f,n=this;return d(this,(function(b){switch(b.label){case 0:return this.emit("debug",{action:"request",request:e,provider:this}),t={url:e,throttleSlotInterval:1e3,throttleCallback:function(e,a){return n.apiKey===p&&Zt.showThrottleMessage(),Promise.resolve(!0)}},[4,Xt.fetchJson(t,null,a||r)];case 1:return f=b.sent(),this.emit("debug",{action:"response",request:e,response:v.deepCopy(f),provider:this}),[2,f]}}))}))},a){case"getBlockNumber":return[3,1];case"getGasPrice":return[3,2];case"getBalance":return[3,3];case"getTransactionCount":return[3,4];case"getCode":return[3,5];case"getStorageAt":return[3,6];case"sendTransaction":return[3,7];case"getBlock":return[3,8];case"getTransaction":return[3,9];case"getTransactionReceipt":return[3,10];case"call":return[3,11];case"estimateGas":return[3,12];case"getLogs":return[3,13];case"getEtherPrice":return[3,20]}return[3,22];case 1:return[2,l(f+="/api?module=proxy&action=eth_blockNumber"+n)];case 2:return[2,l(f+="/api?module=proxy&action=eth_gasPrice"+n)];case 3:return f+="/api?module=account&action=balance&address="+t.address,f+="&tag="+t.blockTag+n,[2,l(f,c)];case 4:return f+="/api?module=proxy&action=eth_getTransactionCount&address="+t.address,f+="&tag="+t.blockTag+n,[2,l(f)];case 5:return f+="/api?module=proxy&action=eth_getCode&address="+t.address,f+="&tag="+t.blockTag+n,[2,l(f)];case 6:return f+="/api?module=proxy&action=eth_getStorageAt&address="+t.address,f+="&position="+t.position,f+="&tag="+t.blockTag+n,[2,l(f)];case 7:return f+="/api?module=proxy&action=eth_sendRawTransaction&hex="+t.signedTransaction,[2,l(f+=n).catch((function(e){throw e.responseText&&(e.responseText.toLowerCase().indexOf("insufficient funds")>=0&&s.throwError("insufficient funds",o.Logger.errors.INSUFFICIENT_FUNDS,{}),e.responseText.indexOf("same hash was already imported")>=0&&s.throwError("nonce has already been used",o.Logger.errors.NONCE_EXPIRED,{}),e.responseText.indexOf("another transaction with same nonce")>=0&&s.throwError("replacement fee too low",o.Logger.errors.REPLACEMENT_UNDERPRICED,{})),e}))];case 8:if(t.blockTag)return f+="/api?module=proxy&action=eth_getBlockByNumber&tag="+t.blockTag,t.includeTransactions?f+="&boolean=true":f+="&boolean=false",[2,l(f+=n)];throw new Error("getBlock by blockHash not implemented");case 9:return f+="/api?module=proxy&action=eth_getTransactionByHash&txhash="+t.transactionHash,[2,l(f+=n)];case 10:return f+="/api?module=proxy&action=eth_getTransactionReceipt&txhash="+t.transactionHash,[2,l(f+=n)];case 11:if((y=i(t.transaction))&&(y="&"+y),f+="/api?module=proxy&action=eth_call"+y,"latest"!==t.blockTag)throw new Error("EtherscanProvider does not support blockTag for call");return[2,l(f+=n)];case 12:return(y=i(t.transaction))&&(y="&"+y),f+="/api?module=proxy&action=eth_estimateGas&"+y,[2,l(f+=n)];case 13:return f+="/api?module=logs&action=getLogs",t.filter.fromBlock&&(f+="&fromBlock="+u(t.filter.fromBlock)),t.filter.toBlock&&(f+="&toBlock="+u(t.filter.toBlock)),t.filter.address&&(f+="&address="+t.filter.address),t.filter.topics&&t.filter.topics.length>0&&(t.filter.topics.length>1&&s.throwError("unsupported topic count",o.Logger.errors.UNSUPPORTED_OPERATION,{topics:t.filter.topics}),1===t.filter.topics.length&&("string"==typeof(m=t.filter.topics[0])&&66===m.length||s.throwError("unsupported topic format",o.Logger.errors.UNSUPPORTED_OPERATION,{topic0:m}),f+="&topic0="+m)),[4,l(f+=n,c)];case 14:h=M.sent(),x={},g=0,M.label=15;case 15:return g0&&n[n.length-1])||6!==b[0]&&2!==b[0])){d=0;continue}if(3===b[0]&&(!n||b[1]>n[0]&&b[1]a?null:(f+n)/2}function u(e){if(null===e)return"null";if("number"==typeof e||"boolean"==typeof e)return JSON.stringify(e);if("string"==typeof e)return e;if(x.BigNumber.isBigNumber(e))return e.toString();if(Array.isArray(e))return JSON.stringify(e.map((function(e){return u(e)})));if("object"==typeof e){var a=Object.keys(e);return a.sort(),"{"+a.map((function(a){var t=e[a];return t="function"==typeof t?"[function]":u(t),JSON.stringify(a)+":"+t})).join(",")+"}"}throw new Error("unknown value type: "+typeof e)}var p=1;function y(e){var a=null,t=null,f=new Promise((function(f){a=function(){t&&(clearTimeout(t),t=null),f()},t=setTimeout(a,e)}));return{cancel:a,getPromise:function(){return f},wait:function(e){return f=f.then(e)}}}function m(e,a){var t={provider:e.provider,weight:e.weight};return e.start&&(t.start=e.start),a&&(t.duration=a-e.start),e.done&&(e.error?t.error=e.error:t.result=e.result||null),t}function h(e,a,t){var f=u;switch(a){case"getBlockNumber":return function(a){var t=a.map((function(e){return e.result})),f=r(a.map((function(e){return e.result})),2);if(null!=f)return f=Math.ceil(f),t.indexOf(f+1)>=0&&f++,f>=e._highestBlockNumber&&(e._highestBlockNumber=f),e._highestBlockNumber};case"getGasPrice":return function(e){var a=e.map((function(e){return e.result}));return a.sort(),a[Math.floor(a.length/2)]};case"getEtherPrice":return function(e){return r(e.map((function(e){return e.result})))};case"getBalance":case"getTransactionCount":case"getCode":case"getStorageAt":case"call":case"estimateGas":case"getLogs":break;case"getTransaction":case"getTransactionReceipt":f=function(e){return null==e?null:((e=v.shallowCopy(e)).confirmations=-1,u(e))};break;case"getBlock":f=t.includeTransactions?function(e){return null==e?null:((e=v.shallowCopy(e)).transactions=e.transactions.map((function(e){return(e=v.shallowCopy(e)).confirmations=-1,e})),u(e))}:function(e){return null==e?null:u(e)};break;default:throw new Error("unknown method: "+a)}return function(e,a){return function(t){var f={};t.forEach((function(a){var t=e(a.result);f[t]||(f[t]={count:0,result:a.result}),f[t].count++}));for(var n=Object.keys(f),b=0;b=a)return d.result}}}(f,e.quorum)}function g(e,a){return b(this,void 0,void 0,(function(){var t;return d(this,(function(f){return null!=(t=e.provider).blockNumber&&t.blockNumber>=a||-1===a?[2,t]:[2,Xt.poll((function(){return new Promise((function(f,n){setTimeout((function(){return t.blockNumber>=a?f(t):e.cancelled?f(null):f(void 0)}),0)}))}),{oncePoll:t})]}))}))}var T=function(e){function a(t,f){var n=this.constructor,b=this;s.checkNew(n,a),0===t.length&&s.throwArgumentError("missing providers","providers",t);var d=t.map((function(e,a){if(Y.Provider.isProvider(e))return Object.freeze({provider:e,weight:1,stallTimeout:750,priority:1});var t=v.shallowCopy(e);null==t.priority&&(t.priority=1),null==t.stallTimeout&&(t.stallTimeout=750),null==t.weight&&(t.weight=1);var f=t.weight;return(f%1||f>512||f<1)&&s.throwArgumentError("invalid weight; must be integer in [1, 512]","providers["+a+"].weight",f),Object.freeze(t)})),i=d.reduce((function(e,a){return e+a.weight}),0);null==f?f=i/2:f>i&&s.throwArgumentError("quorum will always fail; larger than total weight","quorum",f);var r=c(d.map((function(e){return e.provider.network})));return null==r&&(r=new Promise((function(e,a){setTimeout((function(){b.detectNetwork().then(e,a)}),0)}))),b=e.call(this,r)||this,v.defineReadOnly(b,"providerConfigs",Object.freeze(d)),v.defineReadOnly(b,"quorum",f),b._highestBlockNumber=-1,b}return f(a,e),a.prototype.detectNetwork=function(){return b(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return[4,Promise.all(this.providerConfigs.map((function(e){return e.provider.getNetwork()})))];case 1:return[2,c(e.sent())]}}))}))},a.prototype.perform=function(e,a){return b(this,void 0,void 0,(function(){var t,f,n,c,r,u,x,T,w,E,A,M=this;return d(this,(function(C){switch(C.label){case 0:return"sendTransaction"!==e?[3,2]:[4,Promise.all(this.providerConfigs.map((function(e){return e.provider.sendTransaction(a.signedTransaction).then((function(e){return e.hash}),(function(e){return e}))})))];case 1:for(t=C.sent(),f=0;f=E.quorum?void 0!==(A=c(w))?(r.forEach((function(e){e.staller&&e.staller.cancel(),e.cancelled=!0})),[2,{value:A}]):T?[3,4]:[4,y(100).getPromise()]:[3,5];case 3:C.sent(),C.label=4;case 4:T=!1,C.label=5;case 5:return 0===r.filter((function(e){return!e.done})).length?[2,"break"]:[2]}}))},E=this,C.label=5;case 5:return[5,w()];case 6:return"object"==typeof(A=C.sent())?[2,A.value]:"break"===A?[3,7]:[3,5];case 7:return r.forEach((function(e){e.staller&&e.staller.cancel(),e.cancelled=!0})),[2,s.throwError("failed to meet quorum",o.Logger.errors.SERVER_ERROR,{method:e,params:a,results:r.map((function(e){return m(e)})),provider:this})]}}))}))},a}(Vt.BaseProvider);a.FallbackProvider=T}))),Yt=(b(Jt),Jt.FallbackProvider,null),Qt=d((function(e,a){var t,f=n&&n.__extends||(t=function(e,a){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,a){e.__proto__=a}||function(e,a){for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])})(e,a)},function(e,a){function f(){this.constructor=e}t(e,a),e.prototype=null===a?Object.create(a):(f.prototype=a.prototype,new f)});Object.defineProperty(a,"__esModule",{value:!0});var b=new o.Logger(Kt.version),d="84842078b09946638c03157f83405213",s=function(e){function a(){return null!==e&&e.apply(this,arguments)||this}return f(a,e),a.getWebSocketProvider=function(e,t){var f=new a(e,t).connection;f.password&&b.throwError("INFURA WebSocket project secrets unsupported",o.Logger.errors.UNSUPPORTED_OPERATION,{operation:"InfuraProvider.getWebSocketProvider()"});var n=f.url.replace(/^http/i,"ws").replace("/v3/","/ws/v3/");return new zt.WebSocketProvider(n,e)},a.getApiKey=function(e){var a={apiKey:d,projectId:d,projectSecret:null};return null==e||("string"==typeof e?a.projectId=e:null!=e.projectSecret?(b.assertArgument("string"==typeof e.projectId,"projectSecret requires a projectId","projectId",e.projectId),b.assertArgument("string"==typeof e.projectSecret,"invalid projectSecret","projectSecret","[REDACTED]"),a.projectId=e.projectId,a.projectSecret=e.projectSecret):e.projectId&&(a.projectId=e.projectId),a.apiKey=a.projectId),a},a.getUrl=function(e,a){var t=null;switch(e?e.name:"unknown"){case"homestead":t="mainnet.infura.io";break;case"ropsten":t="ropsten.infura.io";break;case"rinkeby":t="rinkeby.infura.io";break;case"kovan":t="kovan.infura.io";break;case"goerli":t="goerli.infura.io";break;default:b.throwError("unsupported network",o.Logger.errors.INVALID_ARGUMENT,{argument:"network",value:e})}var f={url:"https://"+t+"/v3/"+a.projectId,throttleCallback:function(e,t){return a.projectId===d&&Zt.showThrottleMessage(),Promise.resolve(!0)}};return null!=a.projectSecret&&(f.user="",f.password=a.projectSecret),f},a}(jt.UrlJsonRpcProvider);a.InfuraProvider=s})),ef=(b(Qt),Qt.InfuraProvider,d((function(e,a){var t,f=n&&n.__extends||(t=function(e,a){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,a){e.__proto__=a}||function(e,a){for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])})(e,a)},function(e,a){function f(){this.constructor=e}t(e,a),e.prototype=null===a?Object.create(a):(f.prototype=a.prototype,new f)});Object.defineProperty(a,"__esModule",{value:!0});var b=new o.Logger(Kt.version),d=function(e){function a(){return null!==e&&e.apply(this,arguments)||this}return f(a,e),a.getApiKey=function(e){return e&&"string"!=typeof e&&b.throwArgumentError("invalid apiKey","apiKey",e),e||"ETHERS_JS_SHARED"},a.getUrl=function(e,a){b.warn("NodeSmith will be discontinued on 2019-12-20; please migrate to another platform.");var t=null;switch(e.name){case"homestead":t="https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc";break;case"ropsten":t="https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc";break;case"rinkeby":t="https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc";break;case"goerli":t="https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc";break;case"kovan":t="https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc";break;default:b.throwArgumentError("unsupported network","network",arguments[0])}return t+"?apiKey="+a},a}(jt.UrlJsonRpcProvider);a.NodesmithProvider=d}))),af=(b(ef),ef.NodesmithProvider,d((function(e,a){var t,f=n&&n.__extends||(t=function(e,a){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,a){e.__proto__=a}||function(e,a){for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])})(e,a)},function(e,a){function f(){this.constructor=e}t(e,a),e.prototype=null===a?Object.create(a):(f.prototype=a.prototype,new f)});Object.defineProperty(a,"__esModule",{value:!0});var b=new o.Logger(Kt.version),d=1;function s(e,a){return function(t,f){"eth_sign"==t&&e.isMetaMask&&(t="personal_sign",f=[f[1],f[0]]);var n={method:t,params:f,id:d++,jsonrpc:"2.0"};return new Promise((function(e,t){a(n,(function(a,f){if(a)return t(a);if(f.error){var n=new Error(f.error.message);return n.code=f.error.code,n.data=f.error.data,t(n)}e(f.result)}))}))}}var i=function(e){function a(t,f){var n,d=this.constructor;b.checkNew(d,a),null==t&&b.throwArgumentError("missing provider","provider",t);var i=null,c=null,r=null;return"function"==typeof t?(i="unknown:",c=t):(!(i=t.host||t.path||"")&&t.isMetaMask&&(i="metamask"),r=t,t.request?(""===i&&(i="eip-1193:"),c=function(e){return function(a,t){return null==t&&(t=[]),"eth_sign"==a&&e.isMetaMask&&(a="personal_sign",t=[t[1],t[0]]),e.request({method:a,params:t})}}(t)):t.sendAsync?c=s(t,t.sendAsync.bind(t)):t.send?c=s(t,t.send.bind(t)):b.throwArgumentError("unsupported provider","provider",t),i||(i="unknown:")),n=e.call(this,i,f)||this,v.defineReadOnly(n,"jsonRpcFetchFunc",c),v.defineReadOnly(n,"provider",r),n}return f(a,e),a.prototype.send=function(e,a){return this.jsonRpcFetchFunc(e,a)},a}(Ht.JsonRpcProvider);a.Web3Provider=i}))),tf=(b(af),af.Web3Provider,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.Provider=Y.Provider,a.getNetwork=It.getNetwork,a.BaseProvider=Vt.BaseProvider,a.AlchemyProvider=Gt.AlchemyProvider,a.CloudflareProvider=Wt.CloudflareProvider,a.EtherscanProvider=$t.EtherscanProvider,a.FallbackProvider=Jt.FallbackProvider,a.IpcProvider=Yt,a.InfuraProvider=Qt.InfuraProvider,a.JsonRpcProvider=Ht.JsonRpcProvider,a.JsonRpcSigner=Ht.JsonRpcSigner,a.NodesmithProvider=ef.NodesmithProvider,a.StaticJsonRpcProvider=jt.StaticJsonRpcProvider,a.UrlJsonRpcProvider=jt.UrlJsonRpcProvider,a.Web3Provider=af.Web3Provider,a.WebSocketProvider=zt.WebSocketProvider,a.Formatter=Zt.Formatter;var t=new o.Logger(Kt.version);a.getDefaultProvider=function(e,a){if(null==e&&(e="homestead"),"string"==typeof e){var f=e.match(/^(ws|http)s?:/i);if(f)switch(f[1]){case"http":return new Ht.JsonRpcProvider(e);case"ws":return new zt.WebSocketProvider(e);default:t.throwArgumentError("unsupported URL scheme","network",e)}}var n=It.getNetwork(e);return n&&n._defaultProvider||t.throwError("unsupported getDefaultProvider network",o.Logger.errors.NETWORK_ERROR,{operation:"getDefaultProvider",network:e}),n._defaultProvider({FallbackProvider:Jt.FallbackProvider,AlchemyProvider:Gt.AlchemyProvider,CloudflareProvider:Wt.CloudflareProvider,EtherscanProvider:$t.EtherscanProvider,InfuraProvider:Qt.InfuraProvider,JsonRpcProvider:Ht.JsonRpcProvider,NodesmithProvider:ef.NodesmithProvider,Web3Provider:af.Web3Provider,IpcProvider:Yt},a)}}))),ff=(b(tf),tf.Provider,tf.getNetwork,tf.BaseProvider,tf.AlchemyProvider,tf.CloudflareProvider,tf.EtherscanProvider,tf.FallbackProvider,tf.IpcProvider,tf.InfuraProvider,tf.JsonRpcProvider,tf.JsonRpcSigner,tf.NodesmithProvider,tf.StaticJsonRpcProvider,tf.UrlJsonRpcProvider,tf.Web3Provider,tf.WebSocketProvider,tf.Formatter,tf.getDefaultProvider,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0});var t=new RegExp("^bytes([0-9]+)$"),f=new RegExp("^(u?int)([0-9]*)$"),n=new RegExp("^(.*)\\[([0-9]*)\\]$");function b(e,a){if(e.length!=a.length)throw new Error("type/value count mismatch");var b=[];return e.forEach((function(e,d){b.push(function e(a,b,d){switch(a){case"address":return d?l.zeroPad(b,32):l.arrayify(b);case"string":return V.toUtf8Bytes(b);case"bytes":return l.arrayify(b);case"bool":return b=b?"0x01":"0x00",d?l.zeroPad(b,32):l.arrayify(b)}var s=a.match(f);if(s){var i=parseInt(s[2]||"256");if(s[2]&&String(i)!==s[2]||i%8!=0||0===i||i>256)throw new Error("invalid number type - "+a);return d&&(i=256),b=x.BigNumber.from(b).toTwos(i),l.zeroPad(b,i/8)}if(s=a.match(t)){if(i=parseInt(s[1]),String(i)!==s[1]||0===i||i>32)throw new Error("invalid bytes type - "+a);if(l.arrayify(b).byteLength!==i)throw new Error("invalid value for "+a);return d?l.arrayify((b+"0000000000000000000000000000000000000000000000000000000000000000").substring(0,66)):b}if((s=a.match(n))&&Array.isArray(b)){var c=s[1];if(parseInt(s[2]||String(b.length))!=b.length)throw new Error("invalid value for "+a);var r=[];return b.forEach((function(a){r.push(e(c,a,!0))})),l.concat(r)}throw new Error("invalid type - "+a)}(e,a[d]))})),l.hexlify(l.concat(b))}a.pack=b,a.keccak256=function(e,a){return M.keccak256(b(e,a))},a.sha256=function(e,a){return Ma.sha256(b(e,a))}}))),nf=(b(ff),ff.pack,ff.keccak256,ff.sha256,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.version="units/5.0.2"}))),bf=(b(nf),nf.version,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0});var t=new o.Logger(nf.version),f=["wei","kwei","mwei","gwei","szabo","finney","ether"];function n(e,a){if("string"==typeof a){var t=f.indexOf(a);-1!==t&&(a=3*t)}return x.formatFixed(e,null!=a?a:18)}function b(e,a){if("string"==typeof a){var t=f.indexOf(a);-1!==t&&(a=3*t)}return x.parseFixed(e,null!=a?a:18)}a.commify=function(e){var a=String(e).split(".");(a.length>2||!a[0].match(/^-?[0-9]*$/)||a[1]&&!a[1].match(/^[0-9]*$/)||"."===e||"-."===e)&&t.throwArgumentError("invalid value","value",e);var f=a[0],n="";for("-"===f.substring(0,1)&&(n="-",f=f.substring(1));"0"===f.substring(0,1);)f=f.substring(1);""===f&&(f="0");var b="";for(2===a.length&&(b="."+(a[1]||"0"));b.length>2&&"0"===b[b.length-1];)b=b.substring(0,b.length-1);for(var d=[];f.length;){if(f.length<=3){d.unshift(f);break}var s=f.length-3;d.unshift(f.substring(s)),f=f.substring(0,s)}return n+d.join(",")+b},a.formatUnits=n,a.parseUnits=b,a.formatEther=function(e){return n(e,18)},a.parseEther=function(e){return b(e,18)}}))),df=(b(bf),bf.commify,bf.formatUnits,bf.parseUnits,bf.formatEther,bf.parseEther,d((function(e,a){var t=n&&n.__importStar||function(e){if(e&&e.__esModule)return e;var a={};if(null!=e)for(var t in e)Object.hasOwnProperty.call(e,t)&&(a[t]=e[t]);return a.default=e,a};Object.defineProperty(a,"__esModule",{value:!0}),a.AbiCoder=$.AbiCoder,a.checkResultErrors=$.checkResultErrors,a.defaultAbiCoder=$.defaultAbiCoder,a.EventFragment=$.EventFragment,a.FormatTypes=$.FormatTypes,a.Fragment=$.Fragment,a.FunctionFragment=$.FunctionFragment,a.Indexed=$.Indexed,a.Interface=$.Interface,a.LogDescription=$.LogDescription,a.ParamType=$.ParamType,a.TransactionDescription=$.TransactionDescription,a.getAddress=B.getAddress,a.getCreate2Address=B.getCreate2Address,a.getContractAddress=B.getContractAddress,a.getIcapAddress=B.getIcapAddress,a.isAddress=B.isAddress;var f=t(Nt);a.base64=f,a.arrayify=l.arrayify,a.concat=l.concat,a.hexDataSlice=l.hexDataSlice,a.hexDataLength=l.hexDataLength,a.hexlify=l.hexlify,a.hexStripZeros=l.hexStripZeros,a.hexValue=l.hexValue,a.hexZeroPad=l.hexZeroPad,a.isBytes=l.isBytes,a.isBytesLike=l.isBytesLike,a.isHexString=l.isHexString,a.joinSignature=l.joinSignature,a.zeroPad=l.zeroPad,a.splitSignature=l.splitSignature,a.stripZeros=l.stripZeros,a.hashMessage=G.hashMessage,a.id=G.id,a.isValidName=G.isValidName,a.namehash=G.namehash,a.defaultPath=Tt.defaultPath,a.entropyToMnemonic=Tt.entropyToMnemonic,a.HDNode=Tt.HDNode,a.isValidMnemonic=Tt.isValidMnemonic,a.mnemonicToEntropy=Tt.mnemonicToEntropy,a.mnemonicToSeed=Tt.mnemonicToSeed,a.getJsonWalletAddress=kt.getJsonWalletAddress,a.keccak256=M.keccak256,a.Logger=o.Logger,a.computeHmac=Ma.computeHmac,a.ripemd160=Ma.ripemd160,a.sha256=Ma.sha256,a.sha512=Ma.sha512,a.solidityKeccak256=ff.keccak256,a.solidityPack=ff.pack,a.soliditySha256=ff.sha256,a.randomBytes=At.randomBytes,a.shuffled=At.shuffled,a.checkProperties=v.checkProperties,a.deepCopy=v.deepCopy,a.defineReadOnly=v.defineReadOnly,a.getStatic=v.getStatic,a.resolveProperties=v.resolveProperties,a.shallowCopy=v.shallowCopy;var b=t(D);a.RLP=b,a.computePublicKey=pt.computePublicKey,a.recoverPublicKey=pt.recoverPublicKey,a.SigningKey=pt.SigningKey,a.formatBytes32String=V.formatBytes32String,a.nameprep=V.nameprep,a.parseBytes32String=V.parseBytes32String,a._toEscapedUtf8String=V._toEscapedUtf8String,a.toUtf8Bytes=V.toUtf8Bytes,a.toUtf8CodePoints=V.toUtf8CodePoints,a.toUtf8String=V.toUtf8String,a.Utf8ErrorFuncs=V.Utf8ErrorFuncs,a.computeAddress=yt.computeAddress,a.parseTransaction=yt.parse,a.recoverAddress=yt.recoverAddress,a.serializeTransaction=yt.serialize,a.commify=bf.commify,a.formatEther=bf.formatEther,a.parseEther=bf.parseEther,a.formatUnits=bf.formatUnits,a.parseUnits=bf.parseUnits,a.verifyMessage=Pt.verifyMessage,a.fetchJson=Xt.fetchJson,a.poll=Xt.poll;var d=Ma;a.SupportedAlgorithm=d.SupportedAlgorithm;var s=V;a.UnicodeNormalizationForm=s.UnicodeNormalizationForm,a.Utf8ErrorReason=s.Utf8ErrorReason}))),sf=(b(df),df.AbiCoder,df.checkResultErrors,df.defaultAbiCoder,df.EventFragment,df.FormatTypes,df.Fragment,df.FunctionFragment,df.Indexed,df.Interface,df.LogDescription,df.ParamType,df.TransactionDescription,df.getAddress,df.getCreate2Address,df.getContractAddress,df.getIcapAddress,df.isAddress,df.base64,df.arrayify,df.concat,df.hexDataSlice,df.hexDataLength,df.hexlify,df.hexStripZeros,df.hexValue,df.hexZeroPad,df.isBytes,df.isBytesLike,df.isHexString,df.joinSignature,df.zeroPad,df.splitSignature,df.stripZeros,df.hashMessage,df.id,df.isValidName,df.namehash,df.defaultPath,df.entropyToMnemonic,df.HDNode,df.isValidMnemonic,df.mnemonicToEntropy,df.mnemonicToSeed,df.getJsonWalletAddress,df.keccak256,df.Logger,df.computeHmac,df.ripemd160,df.sha256,df.sha512,df.solidityKeccak256,df.solidityPack,df.soliditySha256,df.randomBytes,df.shuffled,df.checkProperties,df.deepCopy,df.defineReadOnly,df.getStatic,df.resolveProperties,df.shallowCopy,df.RLP,df.computePublicKey,df.recoverPublicKey,df.SigningKey,df.formatBytes32String,df.nameprep,df.parseBytes32String,df._toEscapedUtf8String,df.toUtf8Bytes,df.toUtf8CodePoints,df.toUtf8String,df.Utf8ErrorFuncs,df.computeAddress,df.parseTransaction,df.recoverAddress,df.serializeTransaction,df.commify,df.formatEther,df.parseEther,df.formatUnits,df.parseUnits,df.verifyMessage,df.fetchJson,df.poll,df.SupportedAlgorithm,df.UnicodeNormalizationForm,df.Utf8ErrorReason,d((function(e,a){Object.defineProperty(a,"__esModule",{value:!0}),a.version="ethers/5.0.7"}))),cf=(b(sf),sf.version,d((function(e,a){var t=n&&n.__importStar||function(e){if(e&&e.__esModule)return e;var a={};if(null!=e)for(var t in e)Object.hasOwnProperty.call(e,t)&&(a[t]=e[t]);return a.default=e,a};Object.defineProperty(a,"__esModule",{value:!0}),a.Contract=te.Contract,a.ContractFactory=te.ContractFactory,a.BigNumber=x.BigNumber,a.FixedNumber=x.FixedNumber,a.Signer=ee.Signer,a.VoidSigner=ee.VoidSigner,a.Wallet=Pt.Wallet;var f=t(N);a.constants=f;var b=t(tf);a.providers=b;var d=tf;a.getDefaultProvider=d.getDefaultProvider,a.Wordlist=gt.Wordlist,a.wordlists=gt.wordlists;var s=t(df);a.utils=s,a.errors=o.ErrorCode,a.version=sf.version;var i=new o.Logger(sf.version);a.logger=i}))),rf=(b(cf),cf.Contract,cf.ContractFactory,cf.BigNumber,cf.FixedNumber,cf.Signer,cf.VoidSigner,cf.Wallet,cf.constants,cf.providers,cf.getDefaultProvider,cf.Wordlist,cf.wordlists,cf.utils,cf.errors,cf.version,cf.logger,d((function(e,a){var t=n&&n.__importStar||function(e){if(e&&e.__esModule)return e;var a={};if(null!=e)for(var t in e)Object.hasOwnProperty.call(e,t)&&(a[t]=e[t]);return a.default=e,a};Object.defineProperty(a,"__esModule",{value:!0});var f=t(cf);a.ethers=f;try{var b=window;null==b._ethers&&(b._ethers=f)}catch(e){}var d=cf;a.Signer=d.Signer,a.Wallet=d.Wallet,a.VoidSigner=d.VoidSigner,a.getDefaultProvider=d.getDefaultProvider,a.providers=d.providers,a.Contract=d.Contract,a.ContractFactory=d.ContractFactory,a.BigNumber=d.BigNumber,a.FixedNumber=d.FixedNumber,a.constants=d.constants,a.errors=d.errors,a.logger=d.logger,a.utils=d.utils,a.wordlists=d.wordlists,a.version=d.version,a.Wordlist=d.Wordlist}))),uf=b(rf),of=rf.ethers,pf=rf.Signer,lf=rf.Wallet,yf=rf.VoidSigner,mf=rf.getDefaultProvider,hf=rf.providers,xf=rf.Contract,gf=rf.ContractFactory,vf=rf.BigNumber,Tf=rf.FixedNumber,wf=rf.constants,Ef=rf.errors,Af=rf.logger,Mf=rf.utils,Cf=rf.wordlists,Df=rf.version,Sf=rf.Wordlist;a.BigNumber=vf,a.Contract=xf,a.ContractFactory=gf,a.FixedNumber=Tf,a.Signer=pf,a.VoidSigner=yf,a.Wallet=lf,a.Wordlist=Sf,a.constants=wf,a.default=uf,a.errors=Ef,a.ethers=of,a.getDefaultProvider=mf,a.logger=Af,a.providers=hf,a.utils=Mf,a.version=Df,a.wordlists=Cf,Object.defineProperty(a,"__esModule",{value:!0})})(a)}).call(this,t(2),t(3),t(4).setImmediate)},function(e,a){var t;t=function(){return this}();try{t=t||new Function("return this")()}catch(e){"object"==typeof window&&(t=window)}e.exports=t},function(e,a){var t,f,n=e.exports={};function b(){throw new Error("setTimeout has not been defined")}function d(){throw new Error("clearTimeout has not been defined")}function s(e){if(t===setTimeout)return setTimeout(e,0);if((t===b||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(a){try{return t.call(null,e,0)}catch(a){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:b}catch(e){t=b}try{f="function"==typeof clearTimeout?clearTimeout:d}catch(e){f=d}}();var i,c=[],r=!1,u=-1;function o(){r&&i&&(r=!1,i.length?c=i.concat(c):u=-1,c.length&&p())}function p(){if(!r){var e=s(o);r=!0;for(var a=c.length;a;){for(i=c,c=[];++u1)for(var t=1;t=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),a))},t(5),a.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,a.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,t(2))},function(e,a,t){(function(e,a){!function(e,t){"use strict";if(!e.setImmediate){var f,n,b,d,s,i=1,c={},r=!1,u=e.document,o=Object.getPrototypeOf&&Object.getPrototypeOf(e);o=o&&o.setTimeout?o:e,"[object process]"==={}.toString.call(e.process)?f=function(e){a.nextTick((function(){l(e)}))}:!function(){if(e.postMessage&&!e.importScripts){var a=!0,t=e.onmessage;return e.onmessage=function(){a=!1},e.postMessage("","*"),e.onmessage=t,a}}()?e.MessageChannel?((b=new MessageChannel).port1.onmessage=function(e){l(e.data)},f=function(e){b.port2.postMessage(e)}):u&&"onreadystatechange"in u.createElement("script")?(n=u.documentElement,f=function(e){var a=u.createElement("script");a.onreadystatechange=function(){l(e),a.onreadystatechange=null,n.removeChild(a),a=null},n.appendChild(a)}):f=function(e){setTimeout(l,0,e)}:(d="setImmediate$"+Math.random()+"$",s=function(a){a.source===e&&"string"==typeof a.data&&0===a.data.indexOf(d)&&l(+a.data.slice(d.length))},e.addEventListener?e.addEventListener("message",s,!1):e.attachEvent("onmessage",s),f=function(a){e.postMessage(d+a,"*")}),o.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var a=new Array(arguments.length-1),t=0;t{const[n,s]=c(e,a),i=r(n,t,f),o=Object.assign({},i);return{network:{id:s,name:n},networks:b.networks,networkToChainId:b.networkToChainId,decode:b.decode,defaults:b.defaults,feeds:Object(b.getFeeds)({network:n}),tokens:Object(b.getTokens)({network:n}),sources:Object(b.getSource)({network:n}),targets:Object(b.getTarget)({network:n}),synths:Object(b.getSynths)({network:n}),users:Object(b.getUsers)({network:n}),versions:Object(b.getVersions)({network:n}),stakingRewards:Object(b.getStakingRewards)({network:n}),suspensionReasons:Object(b.getSuspensionReasons)(),toBytes32:b.toBytes32,utils:d.ethers.utils,contracts:i,contractsAtBlock:e=>u(e,o)}},c=(e,a)=>{let t=f.Mainnet,d=n.Mainnet;if(a&&!b.networks.includes(a)||e&&!Object.values(b.networkToChainId).includes(e))throw new Error(s);return a&&b.networks.includes(a)?(t=a,d=b.networkToChainId[a]):e&&Object.entries(b.networkToChainId).forEach(([a,f])=>{f===e&&(t=a,d=f)}),[t,d]},r=(e,a,t)=>{const f=Object(b.getSource)({network:e}),n=Object(b.getTarget)({network:e});return Object.values(n).map(e=>{if("Synthetix"===e.name)e.address=n.ProxyERC20.address;else if("SynthsUSD"===e.name)e.address=n.ProxyERC20sUSD.address;else if("FeePool"===e.name)e.address=n.ProxyFeePool.address;else if(e.name.match(/Synth(s|i)[a-zA-Z]+$/)){const a=e.name.replace("Synth","Proxy");e.address=n[a].address}return e}).reduce((n,{name:b,source:s,address:i})=>(n[b]=new d.ethers.Contract(i,f[s].abi,a||t||d.ethers.getDefaultProvider(e)),n),{})},u=(e,a)=>Object.entries(a).reduce((a,[t,f])=>(a[t]=o(e,f),a),{}),o=(e,a)=>Object.entries(a).reduce((a,[t,f])=>{let n=null;return"function"==typeof f&&(n=p(f,e)),a[t]="functions"!=t?n||f:Object.entries(f).reduce((a,[t,f])=>(a[t]=p(f,e),a),{}),a},{}),p=(e,a)=>(...t)=>{const f=t.concat({blockTag:a});return e(...f)};a.default=i}])})); \ No newline at end of file diff --git a/build/src/types.d.ts b/build/src/types.d.ts index 74fde89..2c1e8f7 100644 --- a/build/src/types.d.ts +++ b/build/src/types.d.ts @@ -71,12 +71,12 @@ export declare type SynthetixJS = { }) => { method: { name: string; - params: Array; + params: Array; }; contract: string; }; defaults: { - [key: string]: any; + [key: string]: unknown; }; feeds: { [symbol: string]: Feed; @@ -102,11 +102,13 @@ export declare type SynthetixJS = { toBytes32: (key: string) => string; utils: typeof ethers.utils; contracts: ContractsMap; + contractsAtBlock: (block: number) => ContractsMap; }; export declare type SourceData = { bytecode: string; abi: ethers.ContractInterface; }; +export declare type FunctionUnknown = (...args: unknown[]) => unknown; export declare type Target = { name: string; source: string; diff --git a/examples/browser-example.html b/examples/browser-example.html index 45ed965..0819538 100644 --- a/examples/browser-example.html +++ b/examples/browser-example.html @@ -18,36 +18,27 @@ const { formatEther } = snxjs.utils; const synths = snxjs.synths.map(({ name }) => name); - const fromBlock = 10260987; - const blockOptions = fromBlock ? { blockTag: Number(fromBlock) } : {}; let totalInUSD = 0; const unformattedSnxPrice = await snxjs.contracts.ExchangeRates.rateForCurrency( - snxjs.toBytes32('SNX'), - blockOptions - ); // note blockOptions must be passed to `ethers.Contract` as the final parameter (and fails if no archive node) + snxjs.toBytes32('SNX') + ); const snxPrice = formatEther(unformattedSnxPrice); console.log('snxPrice', snxPrice); let results = await Promise.all( synths.map(async (synth) => { - const unformattedTotalSupply = await snxjs.contracts[`Synth${synth}`].totalSupply( - blockOptions - ); + const unformattedTotalSupply = await snxjs.contracts[`Synth${synth}`].totalSupply({}); const totalSupply = formatEther(unformattedTotalSupply); const rateForSynth = formatEther( - await snxjs.contracts.ExchangeRates.rateForCurrency( - snxjs.toBytes32(synth), - blockOptions - ) + await snxjs.contracts.ExchangeRates.rateForCurrency(snxjs.toBytes32(synth)) ); const totalSupplyInUSD = rateForSynth * totalSupply; totalInUSD += totalSupplyInUSD; const rateIsFrozen = await snxjs.contracts.ExchangeRates.rateIsFrozen( - snxjs.toBytes32(synth), - blockOptions + snxjs.toBytes32(synth) ); return { diff --git a/examples/node-example.js b/examples/node-example.js index e426e0d..1e754b2 100644 --- a/examples/node-example.js +++ b/examples/node-example.js @@ -1,14 +1,24 @@ /// const { synthetix } = require('../src/index.ts'); +const { ethers } = require('ethers'); (async () => { // this instance exposes props for the given network: synths, sources, targets, users, as well as helper function toBytes32 - as per synthetix: https://github.com/Synthetixio/synthetix/blob/develop/index.js#L199. - const snxjs = synthetix({ network: 'mainnet' }); + let snxjs; + if (process.env.INFURA_KEY) { + console.log( + 'you need to run the npm command using an archive node project id as the environment variable in order to get historic data' + ); + const provider = new ethers.providers.InfuraProvider('homestead', process.env.INFURA_KEY); + snxjs = synthetix({ network: 'mainnet', provider }); + } else { + snxjs = synthetix({ network: 'mainnet' }); + } const { formatEther } = snxjs.utils; const synths = snxjs.synths.map(({ name }) => name); - const fromBlock = 10260987; + const fromBlock = 10929392; const blockOptions = fromBlock ? { blockTag: Number(fromBlock) } : {}; let totalInUSD = 0; diff --git a/examples/node-older-blocks-example.js b/examples/node-older-blocks-example.js new file mode 100644 index 0000000..642b252 --- /dev/null +++ b/examples/node-older-blocks-example.js @@ -0,0 +1,61 @@ +/// +const { synthetix } = require('../src/index.ts'); +const { ethers } = require('ethers'); + +(async () => { + let snxjs; + if (process.env.INFURA_KEY) { + console.log( + 'you need to run the npm command using an archive node project id as the environment variable in order to get historic data' + ); + const provider = new ethers.providers.InfuraProvider('homestead', process.env.INFURA_KEY); + snxjs = synthetix({ network: 'mainnet', provider }); + } else { + snxjs = synthetix({ network: 'mainnet' }); + } + const { formatEther } = snxjs.utils; + const fromBlock = 10929392; + + // method 1: using contractsAtBlock + // NOTE: instead of using block options like we did in browser-example.html and node-example.js, + // you can use the contractsAtBlock method to store the block in the ethers contract instance and + // then every call you make will reference the old block data + const olderContracts = snxjs.contractsAtBlock(fromBlock); + try { + const unformattedSnxPriceFromOlderContracts = await olderContracts.ExchangeRates.rateForCurrency( + snxjs.toBytes32('SNX') + ); + const snxPriceFromOlderContracts = formatEther(unformattedSnxPriceFromOlderContracts); + console.log('snxPriceFromOlderContracts', snxPriceFromOlderContracts); + } catch (olderContractsErr) { + console.log('olderContractsErr', olderContractsErr); + } + + // method 2: manually adding block tag like we did in browser-example.html and node-example.js + try { + const unformattedSnxPriceFromBlockTag = await snxjs.contracts.ExchangeRates.rateForCurrency( + snxjs.toBytes32('SNX'), + { blockTag: fromBlock } + ); + const snxPriceFromBlockTag = formatEther(unformattedSnxPriceFromBlockTag); + console.log('snxPriceFromBlockTag', snxPriceFromBlockTag); + } catch (blockTagErr) { + console.log('blockTagErr', blockTagErr); + } + + try { + const unformattedSnxPrice = await snxjs.contracts.ExchangeRates.rateForCurrency( + snxjs.toBytes32('SNX') + ); // note blockOptions must be passed to `ethers.Contract` as the final parameter (and fails if no archive node) + const snxPrice = formatEther(unformattedSnxPrice); + console.log('snxPrice', snxPrice); + } catch (latestBlockErr) { + console.log('latestBlockErr', latestBlockErr); + } + + console.log( + 'there will only be a different value with prices at older blocks if you use an archive node provider' + ); +})().catch((e) => { + console.log('error', e); +}); diff --git a/package.json b/package.json index 567a5e9..b0790db 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "build-browser": "webpack --mode=production --max-old-space-size=4096", "build-report": "webpack-bundle-analyzer --port 4200 ./build/stats.json", "examples:node": "ts-node --project tsconfig.node.json ./examples/node-example.js", + "examples:node-older-blocks": "ts-node --project tsconfig.node.json ./examples/node-older-blocks-example.js", "examples:browser": "npm run build-browser && http-server -o ./examples/browser-example.html -c-1", "lint": "eslint './src/**/*.{js,ts,tsx}' && tsc", "lint:fix": "eslint --fix './src/**/*.{js,ts,tsx}'", diff --git a/src/index.ts b/src/index.ts index 8a3c179..bbc8643 100644 --- a/src/index.ts +++ b/src/index.ts @@ -26,12 +26,15 @@ import { SynthetixJS, Synth, Token, + FunctionUnknown, } from './types'; import { ERRORS } from './constants'; // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types const synthetix = ({ networkId, network, signer, provider }: Config): SynthetixJS => { const [currentNetwork, currentNetworkId] = selectNetwork(networkId, network); + const contracts = getSynthetixContracts(currentNetwork, signer, provider); + const contractsCopy = { ...contracts }; return { network: { id: currentNetworkId, @@ -52,7 +55,8 @@ const synthetix = ({ networkId, network, signer, provider }: Config): SynthetixJ suspensionReasons: getSuspensionReasons(), toBytes32, utils: ethers.utils, - contracts: getSynthetixContracts(currentNetwork, signer, provider), + contracts, + contractsAtBlock: (block: number) => memoizedBlockContracts(block, contractsCopy), }; }; @@ -110,6 +114,55 @@ const getSynthetixContracts = ( }, {}); }; +const memoizedBlockContracts = (block: number, contractsCopy: ContractsMap): ContractsMap => { + return Object.entries(contractsCopy).reduce( + (acc: ContractsMap, [contractName, contractInstance]: [string, ethers.Contract]) => { + acc[contractName] = memoizedEthersContract(block, contractInstance); + return acc; + }, + {} + ); +}; + +const memoizedEthersContract = ( + block: number, + contractInstance: ethers.Contract +): ethers.Contract => { + const returnObj = Object.entries(contractInstance).reduce( + (acc: ethers.Contract, [contractKey, contractItem]: [string, unknown | FunctionUnknown]) => { + let newContractFunction = null; + if (typeof contractItem === 'function') { + newContractFunction = updateEthersMethodWithBlock(contractItem as FunctionUnknown, block); + } + if (contractKey != 'functions') { + // @ts-ignore + acc[contractKey] = newContractFunction || contractItem; + } else { + // @ts-ignore + acc[contractKey] = Object.entries(contractItem).reduce( + // @ts-ignore + (acc: Record, [fnName, fn]: [string, FunctionUnknown]) => { + // @ts-ignore + acc[fnName] = updateEthersMethodWithBlock(fn, block); + return acc; + }, + {} + ); + } + return acc; + }, + {} as ethers.Contract + ); + return returnObj; +}; + +const updateEthersMethodWithBlock = (contractFunction: FunctionUnknown, block: number): unknown => { + return (...args: unknown[]) => { + const newArgs = args.concat({ blockTag: block }); + return contractFunction(...newArgs); + }; +}; + export { synthetix, Network, NetworkId }; export type { Config, Target, TargetsRecord, ContractsMap, SynthetixJS, Synth, Token }; export default synthetix; diff --git a/src/types.ts b/src/types.ts index ef0ffcf..a8d5acf 100644 --- a/src/types.ts +++ b/src/types.ts @@ -74,8 +74,8 @@ export type SynthetixJS = { network: Network; data: string; target: Target; - }) => { method: { name: string; params: Array }; contract: string }; - defaults: { [key: string]: any }; + }) => { method: { name: string; params: Array }; contract: string }; + defaults: { [key: string]: unknown }; feeds: { [symbol: string]: Feed }; tokens: Array; network: { @@ -92,6 +92,7 @@ export type SynthetixJS = { toBytes32: (key: string) => string; utils: typeof ethers.utils; contracts: ContractsMap; + contractsAtBlock: (block: number) => ContractsMap; }; export type SourceData = { @@ -99,6 +100,8 @@ export type SourceData = { abi: ethers.ContractInterface; }; +export type FunctionUnknown = (...args: unknown[]) => unknown; + export type Target = { name: string; source: string; diff --git a/test/index.test.js b/test/index.test.js index c47e19c..5e0483b 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -20,6 +20,7 @@ import { ERRORS } from '../src/constants'; describe('@synthetixio/js tests', () => { let snxjs; + const fromBlock = 10929392; beforeAll(() => { snxjs = synthetix({ network: Network.Kovan }); @@ -58,6 +59,19 @@ describe('@synthetixio/js tests', () => { expect(invalidContract).toBe(undefined); }); + test('should return valid older contracts at a block', () => { + const olderContracts = snxjs.contractsAtBlock(fromBlock); + const validContract = olderContracts[validContractName]; + expect(validContract).not.toBe(undefined); + expect(validContract.claimFees).not.toBe(undefined); + }); + + test('should not return invalid older contracts at a block', () => { + const olderContracts = snxjs.contractsAtBlock(fromBlock); + const invalidContract = olderContracts[badContractName]; + expect(invalidContract).toBe(undefined); + }); + test('should get the right sources data', () => { const validSource = snxjs.sources[validContractName]; expect(validSource.bytecode).not.toBe(undefined); @@ -82,7 +96,6 @@ describe('@synthetixio/js tests', () => { test('should have a list of staking rewards', () => { expect(snxjs.stakingRewards.length).toEqual(0); const mainnetSnxjs = synthetix({ network: Network.Mainnet }); - console.log(mainnetSnxjs.stakingRewards); expect(mainnetSnxjs.stakingRewards[0].name).toBeTruthy(); });