ethers.js/dist/ethers.min.js

8 lines
237 KiB
JavaScript
Raw Normal View History

!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.ethers=a()}}(function(){var a;return function b(a,c,d){function e(g,h){if(!c[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};a[g][0].call(k.exports,function(b){var c=a[g][1][b];return e(c?c:b)},k,k.exports,b,a,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){"use strict";function d(a){var b={};for(var c in a)b[c]=a[c];return b}function e(a,b,c){function i(c,e){return function(){var f={},i=Array.prototype.slice.call(arguments);if(i.length==c.inputs.types.length+1){if(f=i.pop(),"object"!=typeof f)throw new Error("invalid transaction overrides");f=d(f);for(var l in f)if(!h[l])throw new Error("unknown transaction override "+l)}["data","to"].forEach(function(a){if(null!=f[a])throw new Error("cannot override "+a)});var m=c.apply(b,i);switch(f.to=a,f.data=m.data,m.type){case"call":if(e)return Promise.resolve(new g.bigNumberify(0));["gasLimit","gasPrice","value"].forEach(function(a){if(null!=f[a])throw new Error("call cannot override "+a)});var n=null;return null==f.from&&j&&j.getAddress?(n=j.getAddress(),n instanceof Promise||(n=Promise.resolve(n))):n=Promise.resolve(null),n.then(function(a){return a&&(f.from=g.getAddress(a)),k.call(f)}).then(function(a){var b=m.parse(a);return 1===c.outputs.types.length&&(b=b[0]),b});case"transaction":if(!j)return Promise.reject(new Error("missing signer"));if(null!=f.from)throw new Error("transaction cannot override from");if(e)return j&&j.estimateGas?j.estimateGas(f):k.estimateGas(f);if(j.sendTransaction)return j.sendTransaction(f);if(!j.sign)return Promise.reject(new Error("custom signer does not support signing"));null==f.gasLimit&&(f.gasLimit=j.defaultGasLimit||2e6);var o=null;if(f.nonce)o=Promise.resolve(f.nonce);else if(j.getTransactionCount)o=j.getTransactionCount(),o instanceof Promise||(o=Promise.resolve(o));else{var p=j.getAddress();p instanceof Promise||(p=Promise.resolve(p)),o=p.then(function(a){return k.getTransactionCount(a,"pending")})}var q=null;return q=f.gasPrice?Promise.resolve(f.gasPrice):k.getGasPrice(),Promise.all([o,q]).then(function(a){return f.nonce=a[0],f.gasPrice=a[1],j.sign(f)}).then(function(a){return k.sendTransaction(a)})}}}if(!(this instanceof e))throw new Error("missing new");if(b instanceof f||(b=new f(b)),!c)throw new Error("missing signer or provider");var j=c,k=null;c.provider?k=c.provider:(k=c,j=null),g.defineProperty(this,"address",a),g.defineProperty(this,"interface",b),g.defineProperty(this,"signer",j),g.defineProperty(this,"provider",k);var l=k.resolveName(a),m={};g.defineProperty(this,"estimate",m);var n={};g.defineProperty(this,"functions",n);var o={};g.defineProperty(this,"events",o),Object.keys(b.functions).forEach(function(a){var c=b.functions[a],d=i(c,!1);null==this[a]?g.defineProperty(this,a,d):console.log("WARNING: Multiple definitions for "+c),null==n[c]&&(g.defineProperty(n,a,d),g.defineProperty(m,a,i(c,!0)))},this),Object.keys(b.events).forEach(function(a){function c(b){l.then(function(f){if(f==b.address)try{var g=d.parse(b.topics,b.data);b.args=g,b.event=a,b.parse=d.parse,b.removeListener=function(){k.removeListener(d.topics,c)};var h=function(a,c){return new Promise(function(d,e){function f(){k[a](b[c]).then(function(a){return null==a?void setTimeout(f,1e3):void d(a)},function(a){e(a)})}f()})};b.getBlock=function(){return h("getBlock","blockHash")},b.getTransaction=function(){return h("getTransaction","transactionHash")},b.getTransactionReceipt=function(){return h("getTransactionReceipt","transactionHash")},b.eventSignature=d.signature,e.apply(b,Array.prototype.slice.call(g))}catch(i){console.log(i)}})}var d=b.events[a],e=null,f={enumerable:!0,get
if(!(this instanceof E))throw Error("AES must be instanitated with `new`");Object.defineProperty(this,"key",{value:g(a,!0)}),this._prepare()};E.prototype._prepare=function(){var a=o[this.key.length];if(null==a)throw new Error("invalid key size (must be 16, 24 or 32 bytes)");this._Ke=[],this._Kd=[];for(var b=0;b<=a;b++)this._Ke.push([0,0,0,0]),this._Kd.push([0,0,0,0]);for(var c,d=4*(a+1),e=this.key.length/4,f=j(this.key),b=0;b<e;b++)c=b>>2,this._Ke[c][b%4]=f[b],this._Kd[a-c][b%4]=f[b];for(var g,h=0,i=e;i<d;){if(g=f[e-1],f[0]^=q[g>>16&255]<<24^q[g>>8&255]<<16^q[255&g]<<8^q[g>>24&255]^p[h]<<24,h+=1,8!=e)for(var b=1;b<e;b++)f[b]^=f[b-1];else{for(var b=1;b<e/2;b++)f[b]^=f[b-1];g=f[e/2-1],f[e/2]^=q[255&g]^q[g>>8&255]<<8^q[g>>16&255]<<16^q[g>>24&255]<<24;for(var b=e/2+1;b<e;b++)f[b]^=f[b-1]}for(var k,l,b=0;b<e&&i<d;)k=i>>2,l=i%4,this._Ke[k][l]=f[b],this._Kd[a-k][l]=f[b++],i++}for(var k=1;k<a;k++)for(var l=0;l<4;l++)g=this._Kd[k][l],this._Kd[k][l]=A[g>>24&255]^B[g>>16&255]^C[g>>8&255]^D[255&g]},E.prototype.encrypt=function(a){if(16!=a.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var b=this._Ke.length-1,c=[0,0,0,0],d=j(a),e=0;e<4;e++)d[e]^=this._Ke[0][e];for(var f=1;f<b;f++){for(var e=0;e<4;e++)c[e]=s[d[e]>>24&255]^t[d[(e+1)%4]>>16&255]^u[d[(e+2)%4]>>8&255]^v[255&d[(e+3)%4]]^this._Ke[f][e];d=c.slice()}for(var g,i=h(16),e=0;e<4;e++)g=this._Ke[b][e],i[4*e]=255&(q[d[e]>>24&255]^g>>24),i[4*e+1]=255&(q[d[(e+1)%4]>>16&255]^g>>16),i[4*e+2]=255&(q[d[(e+2)%4]>>8&255]^g>>8),i[4*e+3]=255&(q[255&d[(e+3)%4]]^g);return i},E.prototype.decrypt=function(a){if(16!=a.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var b=this._Kd.length-1,c=[0,0,0,0],d=j(a),e=0;e<4;e++)d[e]^=this._Kd[0][e];for(var f=1;f<b;f++){for(var e=0;e<4;e++)c[e]=w[d[e]>>24&255]^x[d[(e+3)%4]>>16&255]^y[d[(e+2)%4]>>8&255]^z[255&d[(e+1)%4]]^this._Kd[f][e];d=c.slice()}for(var g,i=h(16),e=0;e<4;e++)g=this._Kd[b][e],i[4*e]=255&(r[d[e]>>24&255]^g>>24),i[4*e+1]=255&(r[d[(e+3)%4]>>16&255]^g>>16),i[4*e+2]=255&(r[d[(e+2)%4]>>8&255]^g>>8),i[4*e+3]=255&(r[255&d[(e+1)%4]]^g);return i};var F=function(a){if(!(this instanceof F))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new E(a)};F.prototype.encrypt=function(a){if(a=g(a),a.length%16!==0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var b=h(a.length),c=h(16),d=0;d<a.length;d+=16)i(a,c,0,d,d+16),c=this._aes.encrypt(c),i(c,b,d);return b},F.prototype.decrypt=function(a){if(a=g(a),a.length%16!==0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var b=h(a.length),c=h(16),d=0;d<a.length;d+=16)i(a,c,0,d,d+16),c=this._aes.decrypt(c),i(c,b,d);return b};var G=function(a,b){if(!(this instanceof G))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Block Chaining",this.name="cbc",b){if(16!=b.length)throw new Error("invalid initialation vector size (must be 16 bytes)")}else b=h(16);this._lastCipherblock=g(b,!0),this._aes=new E(a)};G.prototype.encrypt=function(a){if(a=g(a),a.length%16!==0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var b=h(a.length),c=h(16),d=0;d<a.length;d+=16){i(a,c,0,d,d+16);for(var e=0;e<16;e++)c[e]^=this._lastCipherblock[e];this._lastCipherblock=this._aes.encrypt(c),i(this._lastCipherblock,b,d)}return b},G.prototype.decrypt=function(a){if(a=g(a),a.length%16!==0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var b=h(a.length),c=h(16),d=0;d<a.length;d+=16){i(a,c,0,d,d+16),c=this._aes.decrypt(c);for(var e=0;e<16;e++)b[d+e]=c[e]^this._lastCipherblock[e];i(a,this._lastCipherblock,0,d,d+16)}return b};var H=function(a,b,c){if(!(this instanceof H))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Feedback",this.name="cfb",b){if(16!=b.length)throw new Error("invalid initialation vector size (must be 16 size)")}else b=h(16);c||(c=1),this.segmentSize=c,this._shiftRegister=g(b,!0),this._aes=new E(a)};H.prototype.encrypt=function(a){if(a.length%
f>>>=13,c[2*g+1]=8191&f,f>>>=13;for(g=2*b;g<e;++g)c[g]=0;d(0===f),d(0===(f&-8192))},m.prototype.stub=function(a){for(var b=new Array(a),c=0;c<a;c++)b[c]=0;return b},m.prototype.mulp=function(a,b,c){var d=2*this.guessLen13b(a.length,b.length),e=this.makeRBT(d),f=this.stub(d),g=new Array(d),h=new Array(d),i=new Array(d),j=new Array(d),k=new Array(d),l=new Array(d),m=c.words;m.length=d,this.convert13b(a.words,a.length,g,d),this.convert13b(b.words,b.length,j,d),this.transform(g,f,h,i,d,e),this.transform(j,f,k,l,d,e);for(var n=0;n<d;n++){var o=h[n]*k[n]-i[n]*l[n];i[n]=h[n]*l[n]+i[n]*k[n],h[n]=o}return this.conjugate(h,i,d),this.transform(h,i,m,f,d,e),this.conjugate(m,f,d),this.normalize13b(m,d),c.negative=a.negative^b.negative,c.length=a.length+b.length,c.strip()},f.prototype.mul=function(a){var b=new f(null);return b.words=new Array(this.length+a.length),this.mulTo(a,b)},f.prototype.mulf=function(a){var b=new f(null);return b.words=new Array(this.length+a.length),l(this,a,b)},f.prototype.imul=function(a){return this.clone().mulTo(a,this)},f.prototype.imuln=function(a){d("number"==typeof a),d(a<67108864);for(var b=0,c=0;c<this.length;c++){var e=(0|this.words[c])*a,f=(67108863&e)+(67108863&b);b>>=26,b+=e/67108864|0,b+=f>>>26,this.words[c]=67108863&f}return 0!==b&&(this.words[c]=b,this.length++),this},f.prototype.muln=function(a){return this.clone().imuln(a)},f.prototype.sqr=function(){return this.mul(this)},f.prototype.isqr=function(){return this.imul(this.clone())},f.prototype.pow=function(a){var b=i(a);if(0===b.length)return new f(1);for(var c=this,d=0;d<b.length&&0===b[d];d++,c=c.sqr());if(++d<b.length)for(var e=c.sqr();d<b.length;d++,e=e.sqr())0!==b[d]&&(c=c.mul(e));return c},f.prototype.iushln=function(a){d("number"==typeof a&&a>=0);var b,c=a%26,e=(a-c)/26,f=67108863>>>26-c<<26-c;if(0!==c){var g=0;for(b=0;b<this.length;b++){var h=this.words[b]&f,i=(0|this.words[b])-h<<c;this.words[b]=i|g,g=h>>>26-c}g&&(this.words[b]=g,this.length++)}if(0!==e){for(b=this.length-1;b>=0;b--)this.words[b+e]=this.words[b];for(b=0;b<e;b++)this.words[b]=0;this.length+=e}return this.strip()},f.prototype.ishln=function(a){return d(0===this.negative),this.iushln(a)},f.prototype.iushrn=function(a,b,c){d("number"==typeof a&&a>=0);var e;e=b?(b-b%26)/26:0;var f=a%26,g=Math.min((a-f)/26,this.length),h=67108863^67108863>>>f<<f,i=c;if(e-=g,e=Math.max(0,e),i){for(var j=0;j<g;j++)i.words[j]=this.words[j];i.length=g}if(0===g);else if(this.length>g)for(this.length-=g,j=0;j<this.length;j++)this.words[j]=this.words[j+g];else this.words[0]=0,this.length=1;var k=0;for(j=this.length-1;j>=0&&(0!==k||j>=e);j--){var l=0|this.words[j];this.words[j]=k<<26-f|l>>>f,k=l&h}return i&&0!==k&&(i.words[i.length++]=k),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},f.prototype.ishrn=function(a,b,c){return d(0===this.negative),this.iushrn(a,b,c)},f.prototype.shln=function(a){return this.clone().ishln(a)},f.prototype.ushln=function(a){return this.clone().iushln(a)},f.prototype.shrn=function(a){return this.clone().ishrn(a)},f.prototype.ushrn=function(a){return this.clone().iushrn(a)},f.prototype.testn=function(a){d("number"==typeof a&&a>=0);var b=a%26,c=(a-b)/26,e=1<<b;if(this.length<=c)return!1;var f=this.words[c];return!!(f&e)},f.prototype.imaskn=function(a){d("number"==typeof a&&a>=0);var b=a%26,c=(a-b)/26;if(d(0===this.negative,"imaskn works only with positive numbers"),this.length<=c)return this;if(0!==b&&c++,this.length=Math.min(c,this.length),0!==b){var e=67108863^67108863>>>b<<b;this.words[this.length-1]&=e}return this.strip()},f.prototype.maskn=function(a){return this.clone().imaskn(a)},f.prototype.iaddn=function(a){return d("number"==typeof a),d(a<67108864),a<0?this.isubn(-a):0!==this.negative?1===this.length&&(0|this.words[0])<a?(this.words[0]=a-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(a),this.negative=1,this):this._iaddn(a)},f.prototype._iaddn=function(a){this.words[0]+=a;for(var b=0;b<this.length&&this.words[b]>=67108864;b++)this.words[b]-=67108864,b===this.length-1?this.words[b+1]=1:this.words[b+1]++;return this.length=Math.
return this.curve.jpoint(l,m,n)},f.prototype.dblp=function(a){if(0===a)return this;if(this.isInfinity())return this;if(!a)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var b=this,c=0;c<a;c++)b=b.dbl();return b}for(var d=this.curve.a,e=this.curve.tinv,f=this.x,g=this.y,h=this.z,i=h.redSqr().redSqr(),j=g.redAdd(g),c=0;c<a;c++){var k=f.redSqr(),l=j.redSqr(),m=l.redSqr(),n=k.redAdd(k).redIAdd(k).redIAdd(d.redMul(i)),o=f.redMul(l),p=n.redSqr().redISub(o.redAdd(o)),q=o.redISub(p),r=n.redMul(q);r=r.redIAdd(r).redISub(m);var s=j.redMul(h);c+1<a&&(i=i.redMul(m)),f=p,h=s,j=r}return this.curve.jpoint(f,j.redMul(e),h)},f.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},f.prototype._zeroDbl=function(){var a,b,c;if(this.zOne){var d=this.x.redSqr(),e=this.y.redSqr(),f=e.redSqr(),g=this.x.redAdd(e).redSqr().redISub(d).redISub(f);g=g.redIAdd(g);var h=d.redAdd(d).redIAdd(d),i=h.redSqr().redISub(g).redISub(g),j=f.redIAdd(f);j=j.redIAdd(j),j=j.redIAdd(j),a=i,b=h.redMul(g.redISub(i)).redISub(j),c=this.y.redAdd(this.y)}else{var k=this.x.redSqr(),l=this.y.redSqr(),m=l.redSqr(),n=this.x.redAdd(l).redSqr().redISub(k).redISub(m);n=n.redIAdd(n);var o=k.redAdd(k).redIAdd(k),p=o.redSqr(),q=m.redIAdd(m);q=q.redIAdd(q),q=q.redIAdd(q),a=p.redISub(n).redISub(n),b=o.redMul(n.redISub(a)).redISub(q),c=this.y.redMul(this.z),c=c.redIAdd(c)}return this.curve.jpoint(a,b,c)},f.prototype._threeDbl=function(){var a,b,c;if(this.zOne){var d=this.x.redSqr(),e=this.y.redSqr(),f=e.redSqr(),g=this.x.redAdd(e).redSqr().redISub(d).redISub(f);g=g.redIAdd(g);var h=d.redAdd(d).redIAdd(d).redIAdd(this.curve.a),i=h.redSqr().redISub(g).redISub(g);a=i;var j=f.redIAdd(f);j=j.redIAdd(j),j=j.redIAdd(j),b=h.redMul(g.redISub(i)).redISub(j),c=this.y.redAdd(this.y)}else{var k=this.z.redSqr(),l=this.y.redSqr(),m=this.x.redMul(l),n=this.x.redSub(k).redMul(this.x.redAdd(k));n=n.redAdd(n).redIAdd(n);var o=m.redIAdd(m);o=o.redIAdd(o);var p=o.redAdd(o);a=n.redSqr().redISub(p),c=this.y.redAdd(this.z).redSqr().redISub(l).redISub(k);var q=l.redSqr();q=q.redIAdd(q),q=q.redIAdd(q),q=q.redIAdd(q),b=n.redMul(o.redISub(a)).redISub(q)}return this.curve.jpoint(a,b,c)},f.prototype._dbl=function(){var a=this.curve.a,b=this.x,c=this.y,d=this.z,e=d.redSqr().redSqr(),f=b.redSqr(),g=c.redSqr(),h=f.redAdd(f).redIAdd(f).redIAdd(a.redMul(e)),i=b.redAdd(b);i=i.redIAdd(i);var j=i.redMul(g),k=h.redSqr().redISub(j.redAdd(j)),l=j.redISub(k),m=g.redSqr();m=m.redIAdd(m),m=m.redIAdd(m),m=m.redIAdd(m);var n=h.redMul(l).redISub(m),o=c.redAdd(c).redMul(d);return this.curve.jpoint(k,n,o)},f.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var a=this.x.redSqr(),b=this.y.redSqr(),c=this.z.redSqr(),d=b.redSqr(),e=a.redAdd(a).redIAdd(a),f=e.redSqr(),g=this.x.redAdd(b).redSqr().redISub(a).redISub(d);g=g.redIAdd(g),g=g.redAdd(g).redIAdd(g),g=g.redISub(f);var h=g.redSqr(),i=d.redIAdd(d);i=i.redIAdd(i),i=i.redIAdd(i),i=i.redIAdd(i);var j=e.redIAdd(g).redSqr().redISub(f).redISub(h).redISub(i),k=b.redMul(j);k=k.redIAdd(k),k=k.redIAdd(k);var l=this.x.redMul(h).redISub(k);l=l.redIAdd(l),l=l.redIAdd(l);var m=this.y.redMul(j.redMul(i.redISub(j)).redISub(g.redMul(h)));m=m.redIAdd(m),m=m.redIAdd(m),m=m.redIAdd(m);var n=this.z.redAdd(g).redSqr().redISub(c).redISub(h);return this.curve.jpoint(l,m,n)},f.prototype.mul=function(a,b){return a=new i(a,b),this.curve._wnafMul(this,a)},f.prototype.eq=function(a){if("affine"===a.type)return this.eq(a.toJ());if(this===a)return!0;var b=this.z.redSqr(),c=a.z.redSqr();if(0!==this.x.redMul(c).redISub(a.x.redMul(b)).cmpn(0))return!1;var d=b.redMul(this.z),e=c.redMul(a.z);return 0===this.y.redMul(e).redISub(a.y.redMul(d)).cmpn(0)},f.prototype.eqXToP=function(a){var b=this.z.redSqr(),c=a.toRed(this.curve.red).redMul(b);if(0===this.x.cmp(c))return!0;for(var d=a.clone(),e=this.curve.redN.redMul(b);;){if(d.iadd(this.curve.n),d.cmp(this.curve.p)>=0)return!1;if(c.redIAdd(e),0===this.x.cmp(c))return!0}return!1},f.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infin
2018-03-05 09:55:20 +03:00
}function z(a,b,c){var d=a<<32-c|b>>>c;return d>>>0}function A(a,b,c){return a>>>c}function B(a,b,c){var d=a<<32-c|b>>>c;return d>>>0}var C=a("minimalistic-assert"),D=a("inherits");c.inherits=D,c.toArray=d,c.toHex=e,c.htonl=f,c.toHex32=g,c.zero2=h,c.zero8=i,c.join32=j,c.split32=k,c.rotr32=l,c.rotl32=m,c.sum32=n,c.sum32_3=o,c.sum32_4=p,c.sum32_5=q,c.sum64=r,c.sum64_hi=s,c.sum64_lo=t,c.sum64_4_hi=u,c.sum64_4_lo=v,c.sum64_5_hi=w,c.sum64_5_lo=x,c.rotr64_hi=y,c.rotr64_lo=z,c.shr64_hi=A,c.shr64_lo=B},{inherits:36,"minimalistic-assert":39}],36:[function(a,b,c){"function"==typeof Object.create?b.exports=function(a,b){a.super_=b,a.prototype=Object.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})}:b.exports=function(a,b){a.super_=b;var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a}},{}],37:[function(a,b,c){arguments[4][36][0].apply(c,arguments)},{dup:36}],38:[function(a,b,c){(function(a,c){!function(){"use strict";function d(a,b,c){this.blocks=[],this.s=[],this.padding=b,this.outputBits=c,this.reset=!0,this.block=0,this.start=0,this.blockCount=1600-(a<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=c>>5,this.extraBytes=(31&c)>>3;for(var d=0;d<50;++d)this.s[d]=0}var e="object"==typeof window?window:{},f=!e.JS_SHA3_NO_NODE_JS&&"object"==typeof a&&a.versions&&a.versions.node;f&&(e=c);for(var g=!e.JS_SHA3_NO_COMMON_JS&&"object"==typeof b&&b.exports,h="0123456789abcdef".split(""),i=[31,7936,2031616,520093696],j=[1,256,65536,16777216],k=[6,1536,393216,100663296],l=[0,8,16,24],m=[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],n=[224,256,384,512],o=[128,256],p=["hex","buffer","arrayBuffer","array"],q=function(a,b,c){return function(e){return new d(a,b,a).update(e)[c]()}},r=function(a,b,c){return function(e,f){return new d(a,b,f).update(e)[c]()}},s=function(a,b){var c=q(a,b,"hex");c.create=function(){return new d(a,b,a)},c.update=function(a){return c.create().update(a)};for(var e=0;e<p.length;++e){var f=p[e];c[f]=q(a,b,f)}return c},t=function(a,b){var c=r(a,b,"hex");c.create=function(c){return new d(a,b,c)},c.update=function(a,b){return c.create(b).update(a)};for(var e=0;e<p.length;++e){var f=p[e];c[f]=r(a,b,f)}return c},u=[{name:"keccak",padding:j,bits:n,createMethod:s},{name:"sha3",padding:k,bits:n,createMethod:s},{name:"shake",padding:i,bits:o,createMethod:t}],v={},w=[],x=0;x<u.length;++x)for(var y=u[x],z=y.bits,A=0;A<z.length;++A){var B=y.name+"_"+z[A];w.push(B),v[B]=y.createMethod(z[A],y.padding)}d.prototype.update=function(a){var b="string"!=typeof a;b&&a.constructor===ArrayBuffer&&(a=new Uint8Array(a));for(var c,d,e=a.length,f=this.blocks,g=this.byteCount,h=this.blockCount,i=0,j=this.s;i<e;){if(this.reset)for(this.reset=!1,f[0]=this.block,c=1;c<h+1;++c)f[c]=0;if(b)for(c=this.start;i<e&&c<g;++i)f[c>>2]|=a[i]<<l[3&c++];else for(c=this.start;i<e&&c<g;++i)d=a.charCodeAt(i),d<128?f[c>>2]|=d<<l[3&c++]:d<2048?(f[c>>2]|=(192|d>>6)<<l[3&c++],f[c>>2]|=(128|63&d)<<l[3&c++]):d<55296||d>=57344?(f[c>>2]|=(224|d>>12)<<l[3&c++],f[c>>2]|=(128|d>>6&63)<<l[3&c++],f[c>>2]|=(128|63&d)<<l[3&c++]):(d=65536+((1023&d)<<10|1023&a.charCodeAt(++i)),f[c>>2]|=(240|d>>18)<<l[3&c++],f[c>>2]|=(128|d>>12&63)<<l[3&c++],f[c>>2]|=(128|d>>6&63)<<l[3&c++],f[c>>2]|=(128|63&d)<<l[3&c++]);if(this.lastByteIndex=c,c>=g){for(this.start=c-g,this.block=f[h],c=0;c<h;++c)j[c]^=f[c];C(j),this.reset=!0}else this.start=c}return this},d.prototype.finalize=function(){var a=this.blocks,b=this.lastByteIndex,c=this.blockCount,d=this.s;if(a[b>>2]|=this.padding[3&b],this.lastByteIndex===this.byteCount)for(a[0]=a[c],b=1;b<c+1;++b)a[b]=0;for(a[c-1]|=2147483648,b=0;b<c;++b)d[b]^=a[b];C(d)},d.prototype.toString=d.prototype.hex=function(){this.finalize();for(var a,b=this.blockCount,c=this.s,d=this.outputBlocks,e=thi
b&&a.eq(b)||(g[d.address]=a,e.emit(d.address,a))})):"topic"===d.type&&e.getLogs({fromBlock:f+1,toBlock:a,topics:d.topic}).then(function(a){0!==a.length&&a.forEach(function(a){e.emit(d.topic,a)})})}),f=a,g=c}}),e.doPoll()}if(!(this instanceof v))throw new Error("missing new");a=v.getNetwork(a);var c=null;a.ensAddress&&(c=D.getAddress(a.ensAddress)),D.defineProperty(this,"chainId",a.chainId),D.defineProperty(this,"ensAddress",c),D.defineProperty(this,"name",a.name);var d={};D.defineProperty(this,"_events",d);var e=this,f=null,g={};D.defineProperty(this,"resetEventsBlock",function(a){f=a,e.doPoll()});var h=null;Object.defineProperty(this,"polling",{get:function(){return null!=h},set:function(a){setTimeout(function(){a&&!h?h=setInterval(b,4e3):!a&&h&&(clearInterval(h),h=null)},0)}})}function w(a){return function(b){A(b,a),D.defineProperty(b,"inherits",w(b))}}function x(a,b){if(Array.isArray(a)){var c=[];return a.forEach(function(a){c.push(x(a,b))}),c}return b(a)}function y(a){try{return"address:"+D.getAddress(a)}catch(b){}if("block"===a)return"block";if("pending"===a)return"pending";if(D.isHexString(a)){if(66===a.length)return"tx:"+a}else if(Array.isArray(a)){a=x(a,function(a){return null==a&&(a="0x"),a});try{return"topic:"+D.RLP.encode(a)}catch(b){console.log(b)}}throw new Error("invalid event - "+a)}function z(a){if("tx:"===a.substring(0,3))return{type:"transaction",hash:a.substring(3)};if("block"===a)return{type:"block"};if("pending"===a)return{type:"pending"};if("address:"===a.substring(0,8))return{type:"address",address:a.substring(8)};if("topic:"===a.substring(0,6))try{var b=D.RLP.decode(a.substring(6));return b=x(b,function(a){return"0x"===a&&(a=null),a}),{type:"topic",topic:b}}catch(c){console.log(c)}throw new Error("invalid event string")}var A=a("inherits"),B=a("xmlhttprequest").XMLHttpRequest,C=a("./networks.json"),D=function(){var b=a("../utils/convert");return{defineProperty:a("../utils/properties").defineProperty,getAddress:a("../utils/address").getAddress,getContractAddress:a("../utils/contract-address").getContractAddress,bigNumberify:a("../utils/bignumber").bigNumberify,arrayify:b.arrayify,hexlify:b.hexlify,isHexString:b.isHexString,concat:b.concat,stripZeros:b.stripZeros,namehash:a("../utils/namehash"),toUtf8String:a("../utils/utf8").toUtf8String,RLP:a("../utils/rlp")}}(),E={hash:i,parentHash:i,number:j,timestamp:j,nonce:f(D.hexlify),difficulty:f(j),gasLimit:D.bigNumberify,gasUsed:D.bigNumberify,miner:D.getAddress,extraData:D.hexlify,transactions:f(h(i))},F={hash:i,blockHash:f(i,null),blockNumber:f(j,null),transactionIndex:f(j,null),from:D.getAddress,gasPrice:D.bigNumberify,gasLimit:D.bigNumberify,to:f(D.getAddress,null),value:D.bigNumberify,nonce:j,data:D.hexlify,r:f(l),s:f(l),v:f(j),creates:f(D.getAddress,null),raw:f(D.hexlify)},G={from:f(D.getAddress),nonce:f(j),gasLimit:f(D.bigNumberify),gasPrice:f(D.bigNumberify),to:f(D.getAddress),value:f(D.bigNumberify),data:f(D.hexlify)},H={transactionLogIndex:f(j),transactionIndex:j,blockNumber:j,transactionHash:i,address:D.getAddress,topics:h(i),data:D.hexlify,logIndex:j,blockHash:i},I={contractAddress:f(D.getAddress,null),transactionIndex:j,root:f(i),gasUsed:D.bigNumberify,logsBloom:D.hexlify,blockHash:i,transactionHash:i,logs:h(q),blockNumber:j,cumulativeGasUsed:D.bigNumberify,status:f(j)},J={fromBlock:f(m,void 0),toBlock:f(m,void 0),address:f(D.getAddress,void 0),topics:f(s,void 0)},K={blockNumber:f(j),blockHash:f(i),transactionIndex:j,removed:f(k),address:D.getAddress,data:g(D.hexlify,"0x"),topics:h(i),transactionHash:i,logIndex:j};D.defineProperty(v,"inherits",w(v)),D.defineProperty(v,"getNetwork",function(a){if("string"==typeof a){if(a=C[a],!a)throw new Error("unknown network")}else null==a&&(a=C.homestead);if("number"!=typeof a.chainId)throw new Error("invalid chainId");return a}),D.defineProperty(v,"networks",C),D.defineProperty(v,"fetchJSON",function(a,b,c){return new Promise(function(d,e){var f=new B;b?(f.open("POST",a,!0),f.setRequestHeader("Content-Type","application/json")):f.open("GET",a,!0),f.onreadystatechange=function(){if(4===f.readyState){try{v
a;var c=d(a.length);return c.unshift(183+c.length),c.concat(a)}function g(a){return k.hexlify(f(a))}function h(a,b,c,d){for(var e=[];c<b+1+d;){var f=i(a,c);if(e.push(f.result),c+=f.consumed,c>b+1+d)throw new Error("invalid rlp")}return{consumed:1+d,result:e}}function i(a,b){if(0===a.length)throw new Error("invalid rlp data");if(a[b]>=248){var c=a[b]-247;if(b+1+c>a.length)throw new Error("too short");var d=e(a,b+1,c);if(b+1+c+d>a.length)throw new Error("to short");return h(a,b,b+1+c,c+d)}if(a[b]>=192){var d=a[b]-192;if(b+1+d>a.length)throw new Error("invalid rlp data");return h(a,b,b+1,d)}if(a[b]>=184){var c=a[b]-183;if(b+1+c>a.length)throw new Error("invalid rlp data");var d=e(a,b+1,c);if(b+1+c+d>a.length)throw new Error("invalid rlp data");var f=k.hexlify(a.slice(b+1+c,b+1+c+d));return{consumed:1+c+d,result:f}}if(a[b]>=128){var d=a[b]-128;if(b+1+d>a.offset)throw new Error("invlaid rlp data");var f=k.hexlify(a.slice(b+1,b+1+d));return{consumed:1+d,result:f}}return{consumed:1,result:k.hexlify(a[b])}}function j(a){a=k.arrayify(a);var b=i(a,0);if(b.consumed!==a.length)throw new Error("invalid rlp data");return b.result}var k=a("./convert.js");b.exports={encode:g,decode:j}},{"./convert.js":60}],69:[function(a,b,c){"use strict";function d(a){return a=g.arrayify(a),"0x"+f.sha256().update(a).digest("hex")}function e(a){return a=g.arrayify(a),"0x"+f.sha512().update(a).digest("hex")}var f=a("hash.js"),g=a("./convert.js");b.exports={sha256:d,sha512:e,createSha256:f.sha256,createSha512:f.sha512}},{"./convert.js":60,"hash.js":24}],70:[function(a,b,c){"use strict";function d(a,b,c){switch(a){case"address":return c?i.padZeros(b,32):i.arrayify(b);case"string":return j.toUtf8Bytes(b);case"bytes":return i.arrayify(b);case"bool":return b=b?"0x01":"0x00",c?i.padZeros(b,32):i.arrayify(b)}var e=a.match(n);if(e){var f=("int"===e[1],parseInt(e[2]||"256"));if(f%8!=0||0===f||f>256)throw new Error("invalid number type - "+a);return c&&(f=256),b=h(b).toTwos(f),i.padZeros(b,f/8)}if(e=a.match(m)){var f=e[1];if(f!=parseInt(f)||0===f||f>32)throw new Error("invalid number type - "+a);if(f=parseInt(f),i.arrayify(b).byteLength!==f)throw new Error("invalid value for "+a);return c?(b+p).substring(0,66):b}if(e=a.match(o)){var g=e[1],k=parseInt(e[2]||b.length);if(k!=b.length)throw new Error("invalid value for "+a);var l=[];return b.forEach(function(a){a=d(g,a,!0),l.push(a)}),i.concat(l)}throw new Error("unknown type - "+a)}function e(a,b){if(a.length!=b.length)throw new Error("type/value count mismatch");var c=[];return a.forEach(function(a,e){c.push(d(a,b[e]))}),i.hexlify(i.concat(c))}function f(a,b){return k(e(a,b))}function g(a,b){return l(e(a,b))}var h=a("./bignumber").bigNumberify,i=a("./convert"),j=(a("./address").getAddress,a("./utf8")),k=a("./keccak256"),l=a("./sha2").sha256,m=new RegExp("^bytes([0-9]+)$"),n=new RegExp("^(u?int)([0-9]*)$"),o=new RegExp("^(.*)\\[([0-9]*)\\]$"),p="0000000000000000000000000000000000000000000000000000000000000000";b.exports={pack:e,keccak256:f,sha256:g}},{"./address":56,"./bignumber":57,"./convert":60,"./keccak256":64,"./sha2":69,"./utf8":73}],71:[function(a,b,c){"use strict";function d(a,b){var c=new Error(a);for(var d in b)c[d]=b[d];throw c}b.exports=d},{}],72:[function(a,b,c){function d(a,b,c){"object"!=typeof b||c||(c=b,b=void 0),null==b&&(b=18);var d=m(b);a=h(a),c||(c={});var e=a.lt(j);e&&(a=a.mul(k));for(var f=a.mod(d.tenPower).toString(10);f.length<d.decimals;)f="0"+f;c.pad||(f=f.match(/^([0-9]*[1-9]|0)(0*)/)[1]);var g=a.div(d.tenPower).toString(10);c.commify&&(g=g.replace(/\B(?=(\d{3})+(?!\d))/g,","));var a=g+"."+f;return e&&(a="-"+a),a}function e(a,b){var c=m(b||18);c||i("invalid unitType",{unitType:b}),"string"==typeof a&&a.match(/^-?[0-9.,]+$/)||i("invalid value",{input:a});var a=a.replace(/,/g,""),d="-"===a.substring(0,1);d&&(a=a.substring(1)),"."===a&&i("invalid value",{input:a});var e=a.split(".");e.length>2&&i("too many decimal points",{input:a});var f=e[0],g=e[1];for(f||(f="0"),g||(g="0"),g.length>c.decimals&&i("too many decimal places",{input:a,decimals:g.length});g.length<c.decimals;)g+="0";f=h(f),g=h(
},{}]},{},[4])(4)});