ethers.js/dist/ethers-utils.min.js

3 lines
76 KiB
JavaScript
Raw Normal View History

2017-10-20 22:44:54 +03:00
!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[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:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,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){b.exports=void 0},{}],2:[function(a,b,c){function d(a){"string"==typeof a&&a.match(/^0x[0-9A-Fa-f]{40}$/)||h("invalid address",{input:a}),a=a.toLowerCase();for(var b=a.substring(2).split(""),c=0;c<b.length;c++)b[c]=b[c].charCodeAt(0);b=g.arrayify(i(b)),a=a.substring(2).split("");for(var c=0;c<40;c+=2)b[c>>1]>>4>=8&&(a[c]=a[c].toUpperCase()),(15&b[c>>1])>=8&&(a[c+1]=a[c+1].toUpperCase());return"0x"+a.join("")}function e(a,b){var c=null;if("string"!=typeof a&&h("invalid address",{input:a}),a.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==a.substring(0,2)&&(a="0x"+a),c=d(a),a.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&c!==a&&h("invalid address checksum",{input:a,expected:c});else if(a.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(a.substring(2,4)!==j(a)&&h("invalid address icap checksum",{input:a}),c=new f(a.substring(4),36).toString(16);c.length<40;)c="0"+c;c=d("0x"+c)}else h("invalid address",{input:a});if(b){for(var e=new f(c.substring(2),16).toString(36).toUpperCase();e.length<30;)e="0"+e;return"XE"+j("XE00"+e)+e}return c}var f=a("bn.js"),g=a("./convert"),h=a("./throw-error"),i=a("./keccak256"),j=function(){for(var a={},b=0;b<10;b++)a[String(b)]=String(b);for(var b=0;b<26;b++)a[String.fromCharCode(65+b)]=String(10+b);var c=Math.floor(Math.log10(Number.MAX_SAFE_INTEGER));return function(b){b=b.toUpperCase(),b=b.substring(4)+b.substring(0,2)+"00";for(var d=b.split(""),e=0;e<d.length;e++)d[e]=a[d[e]];for(d=d.join("");d.length>=c;){var f=d.substring(0,c);d=parseInt(f,10)%97+d.substring(f.length)}for(var g=String(98-parseInt(d,10)%97);g.length<2;)g="0"+g;return g}}();b.exports={getAddress:e}},{"./convert":6,"./keccak256":9,"./throw-error":24,"bn.js":11}],3:[function(a,b,c){function d(a){if(!(this instanceof d))throw new Error("missing new");i.isHexString(a)?("0x"==a&&(a="0x0"),a=new g(a.substring(2),16)):"string"==typeof a&&a.match(/^-?[0-9]*$/)?(""==a&&(a="0"),a=new g(a)):"number"==typeof a&&parseInt(a)==a?a=new g(a):g.isBN(a)||(e(a)?a=a._bn:i.isArrayish(a)?a=new g(i.hexlify(a).substring(2),16):j("invalid BigNumber value",{input:a})),h(this,"_bn",a)}function e(a){return a._bn&&a._bn.mod}function f(a){return e(a)?a:new d(a)}var g=a("bn.js"),h=a("./properties").defineProperty,i=a("./convert"),j=a("./throw-error");h(d,"constantNegativeOne",f(-1)),h(d,"constantZero",f(0)),h(d,"constantOne",f(1)),h(d,"constantTwo",f(2)),h(d,"constantWeiPerEther",f(new g("1000000000000000000"))),h(d.prototype,"fromTwos",function(a){return new d(this._bn.fromTwos(a))}),h(d.prototype,"toTwos",function(a){return new d(this._bn.toTwos(a))}),h(d.prototype,"add",function(a){return new d(this._bn.add(f(a)._bn))}),h(d.prototype,"sub",function(a){return new d(this._bn.sub(f(a)._bn))}),h(d.prototype,"div",function(a){return new d(this._bn.div(f(a)._bn))}),h(d.prototype,"mul",function(a){return new d(this._bn.mul(f(a)._bn))}),h(d.prototype,"mod",function(a){return new d(this._bn.mod(f(a)._bn))}),h(d.prototype,"maskn",function(a){return new d(this._bn.maskn(a))}),h(d.prototype,"eq",function(a){return this._bn.eq(f(a)._bn)}),h(d.prototype,"lt",function(a){return this._bn.lt(f(a)._bn)}),h(d.prototype,"lte",function(a){return this._bn.lte(f(a)._bn)}),h(d.prototype,"gt",function(a){return this._bn.gt(f(a)._bn)}),h(d.prototype,"gte",function(a){return this._bn.gte(f(a)._bn)}),h(d.prototype,"isZero",function(){return this._bn.isZero()}),h(d.prototype,"toNumber",function(a){return this._bn.toNumber()}),h(d.prototype,"toString",function(){return this._bn.toString(10)}),h(d.prototype,"toHexString",function(){var a=this._bn.toString(16);return a.length%2&&(a="0"+a),"0x"+a}),b.exports={isBigNumber:e,bigNumberify:f}},{"./convert":6
Ia&=67108863,i[0]=qa,i[1]=ra,i[2]=sa,i[3]=ta,i[4]=ua,i[5]=va,i[6]=wa,i[7]=xa,i[8]=ya,i[9]=za,i[10]=Aa,i[11]=Ba,i[12]=Ca,i[13]=Da,i[14]=Ea,i[15]=Fa,i[16]=Ga,i[17]=Ha,i[18]=Ia,0!==j&&(i[19]=j,c.length++),c};Math.imul||(z=j),f.prototype.mulTo=function(a,b){var c,d=this.length+a.length;return c=10===this.length&&10===a.length?z(this,a,b):d<63?j(this,a,b):d<1024?k(this,a,b):l(this,a,b)},m.prototype.makeRBT=function(a){for(var b=new Array(a),c=f.prototype._countBits(a)-1,d=0;d<a;d++)b[d]=this.revBin(d,c,a);return b},m.prototype.revBin=function(a,b,c){if(0===a||a===c-1)return a;for(var d=0,e=0;e<b;e++)d|=(1&a)<<b-e-1,a>>=1;return d},m.prototype.permute=function(a,b,c,d,e,f){for(var g=0;g<f;g++)d[g]=b[a[g]],e[g]=c[a[g]]},m.prototype.transform=function(a,b,c,d,e,f){this.permute(f,a,b,c,d,e);for(var g=1;g<e;g<<=1)for(var h=g<<1,i=Math.cos(2*Math.PI/h),j=Math.sin(2*Math.PI/h),k=0;k<e;k+=h)for(var l=i,m=j,n=0;n<g;n++){var o=c[k+n],p=d[k+n],q=c[k+n+g],r=d[k+n+g],s=l*q-m*r;r=l*r+m*q,q=s,c[k+n]=o+q,d[k+n]=p+r,c[k+n+g]=o-q,d[k+n+g]=p-r,n!==h&&(s=i*l-j*m,m=i*m+j*l,l=s)}},m.prototype.guessLen13b=function(a,b){var c=1|Math.max(b,a),d=1&c,e=0;for(c=c/2|0;c;c>>>=1)e++;return 1<<e+1+d},m.prototype.conjugate=function(a,b,c){if(!(c<=1))for(var d=0;d<c/2;d++){var e=a[d];a[d]=a[c-d-1],a[c-d-1]=e,e=b[d],b[d]=-b[c-d-1],b[c-d-1]=-e}},m.prototype.normalize13b=function(a,b){for(var c=0,d=0;d<b/2;d++){var e=8192*Math.round(a[2*d+1]/b)+Math.round(a[2*d]/b)+c;a[d]=67108863&e,c=e<67108864?0:e/67108864|0}return a},m.prototype.convert13b=function(a,b,c,e){for(var f=0,g=0;g<b;g++)f+=0|a[g],c[2*g]=8191&f,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.wo
}function m(a,b){return a<<b|a>>>32-b}function n(a,b){return a+b>>>0}function o(a,b,c){return a+b+c>>>0}function p(a,b,c,d){return a+b+c+d>>>0}function q(a,b,c,d,e){return a+b+c+d+e>>>0}function r(a,b){if(!a)throw new Error(b||"Assertion failed")}function s(a,b,c,d){var e=a[b],f=a[b+1],g=d+f>>>0,h=(g<d?1:0)+c+e;a[b]=h>>>0,a[b+1]=g}function t(a,b,c,d){var e=b+d>>>0,f=(e<b?1:0)+a+c;return f>>>0}function u(a,b,c,d){var e=b+d;return e>>>0}function v(a,b,c,d,e,f,g,h){var i=0,j=b;j=j+d>>>0,i+=j<b?1:0,j=j+f>>>0,i+=j<f?1:0,j=j+h>>>0,i+=j<h?1:0;var k=a+c+e+g+i;return k>>>0}function w(a,b,c,d,e,f,g,h){var i=b+d+f+h;return i>>>0}function x(a,b,c,d,e,f,g,h,i,j){var k=0,l=b;l=l+d>>>0,k+=l<b?1:0,l=l+f>>>0,k+=l<f?1:0,l=l+h>>>0,k+=l<h?1:0,l=l+j>>>0,k+=l<j?1:0;var m=a+c+e+g+i+k;return m>>>0}function y(a,b,c,d,e,f,g,h,i,j){var k=b+d+f+h+j;return k>>>0}function z(a,b,c){var d=b<<32-c|a>>>c;return d>>>0}function A(a,b,c){var d=a<<32-c|b>>>c;return d>>>0}function B(a,b,c){return a>>>c}function C(a,b,c){var d=a<<32-c|b>>>c;return d>>>0}var D=c,E=a("inherits");D.toArray=d,D.toHex=e,D.htonl=f,D.toHex32=g,D.zero2=h,D.zero8=i,D.join32=j,D.split32=k,D.rotr32=l,D.rotl32=m,D.sum32=n,D.sum32_3=o,D.sum32_4=p,D.sum32_5=q,D.assert=r,D.inherits=E,c.sum64=s,c.sum64_hi=t,c.sum64_lo=u,c.sum64_4_hi=v,c.sum64_4_lo=w,c.sum64_5_hi=x,c.sum64_5_lo=y,c.rotr64_hi=z,c.rotr64_lo=A,c.shr64_hi=B,c.shr64_lo=C},{inherits:18}],18:[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}},{}],19:[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>=5734