ethers.js/dist/ethers-contracts.min.js

3 lines
82 KiB
JavaScript
Raw Normal View History

2018-06-06 02:40:28 +03:00
!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(){return function(){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}return a}()({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 j(c,e){return function(){var f={},j=Array.prototype.slice.call(arguments);if(j.length===c.inputs.types.length+1&&"object"==typeof j[j.length-1]){f=d(j.pop());for(var m in f)if(!i[m])throw new Error("unknown transaction override "+m)}["data","to"].forEach(function(a){if(null!=f[a])throw new Error("cannot override "+a)});var n=c.apply(b,j);switch(f.to=a,f.data=n.data,n.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 o=null;return null==f.from&&k&&k.getAddress?(o=k.getAddress(),o instanceof Promise||(o=Promise.resolve(o))):o=Promise.resolve(null),o.then(function(a){return a&&(f.from=g.getAddress(a)),l.call(f)}).then(function(b){try{var d=n.parse(b)}catch(e){throw"0x"===b&&c.outputs.types.length>0&&h.throwError("call exception",h.CALL_EXCEPTION,{address:a,method:n.signature,value:j}),e}return 1===c.outputs.types.length&&(d=d[0]),d});case"transaction":if(!k)return Promise.reject(new Error("missing signer"));if(null!=f.from)throw new Error("transaction cannot override from");if(e)return k&&k.estimateGas?k.estimateGas(f):l.estimateGas(f);if(k.sendTransaction)return k.sendTransaction(f);if(!k.sign)return Promise.reject(new Error("custom signer does not support signing"));null==f.gasLimit&&(f.gasLimit=k.defaultGasLimit||2e6);var p=null;if(f.nonce)p=Promise.resolve(f.nonce);else if(k.getTransactionCount)p=k.getTransactionCount(),p instanceof Promise||(p=Promise.resolve(p));else{var q=k.getAddress();q instanceof Promise||(q=Promise.resolve(q)),p=q.then(function(a){return l.getTransactionCount(a,"pending")})}var r=null;return r=f.gasPrice?Promise.resolve(f.gasPrice):l.getGasPrice(),Promise.all([p,r]).then(function(a){return f.nonce=a[0],f.gasPrice=a[1],k.sign(f)}).then(function(a){return l.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 k=c,l=null;c.provider?l=c.provider:(l=c,k=null),g.defineProperty(this,"address",a),g.defineProperty(this,"interface",b),g.defineProperty(this,"signer",k),g.defineProperty(this,"provider",l);var m=l.resolveName(a),n={};g.defineProperty(this,"estimate",n);var o={};g.defineProperty(this,"functions",o);var p={};g.defineProperty(this,"events",p),Object.keys(b.functions).forEach(function(a){var c=b.functions[a],d=j(c,!1);null==this[a]?g.defineProperty(this,a,d):console.log("WARNING: Multiple definitions for "+c),null==o[c]&&(g.defineProperty(o,a,d),g.defineProperty(n,a,j(c,!0)))},this),Object.keys(b.events).forEach(function(a){function c(b){m.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(){l.removeListener(d.topics,c)},b.getBlock=function(){return l.getBlock(b.blockHash)},b.getTransaction=function(){return l.getTransaction(b.transactionHash)},b.getTransactionReceipt=function(){return l.getTransactionReceipt(b.transactionHash)},b.eventSignature=d.signature,e.apply(b,Array.prototype.slice.call(g))}catch(h){console.log(h)}})}var d=b.events[a],e=null,f={enumerable:!0,get:function(){return e},set:function(a){a||(a=null),!a&&e?l.
e=e+Math.imul(G,ga)|0,e=e+Math.imul(H,fa)|0,f=f+Math.imul(H,ga)|0,d=d+Math.imul(D,ia)|0,e=e+Math.imul(D,ja)|0,e=e+Math.imul(E,ia)|0,f=f+Math.imul(E,ja)|0,d=d+Math.imul(A,la)|0,e=e+Math.imul(A,ma)|0,e=e+Math.imul(B,la)|0,f=f+Math.imul(B,ma)|0,d=d+Math.imul(x,oa)|0,e=e+Math.imul(x,pa)|0,e=e+Math.imul(y,oa)|0,f=f+Math.imul(y,pa)|0;var Da=(j+d|0)+((8191&e)<<13)|0;j=(f+(e>>>13)|0)+(Da>>>26)|0,Da&=67108863,d=Math.imul(M,ca),e=Math.imul(M,da),e=e+Math.imul(N,ca)|0,f=Math.imul(N,da),d=d+Math.imul(J,fa)|0,e=e+Math.imul(J,ga)|0,e=e+Math.imul(K,fa)|0,f=f+Math.imul(K,ga)|0,d=d+Math.imul(G,ia)|0,e=e+Math.imul(G,ja)|0,e=e+Math.imul(H,ia)|0,f=f+Math.imul(H,ja)|0,d=d+Math.imul(D,la)|0,e=e+Math.imul(D,ma)|0,e=e+Math.imul(E,la)|0,f=f+Math.imul(E,ma)|0,d=d+Math.imul(A,oa)|0,e=e+Math.imul(A,pa)|0,e=e+Math.imul(B,oa)|0,f=f+Math.imul(B,pa)|0;var Ea=(j+d|0)+((8191&e)<<13)|0;j=(f+(e>>>13)|0)+(Ea>>>26)|0,Ea&=67108863,d=Math.imul(M,fa),e=Math.imul(M,ga),e=e+Math.imul(N,fa)|0,f=Math.imul(N,ga),d=d+Math.imul(J,ia)|0,e=e+Math.imul(J,ja)|0,e=e+Math.imul(K,ia)|0,f=f+Math.imul(K,ja)|0,d=d+Math.imul(G,la)|0,e=e+Math.imul(G,ma)|0,e=e+Math.imul(H,la)|0,f=f+Math.imul(H,ma)|0,d=d+Math.imul(D,oa)|0,e=e+Math.imul(D,pa)|0,e=e+Math.imul(E,oa)|0,f=f+Math.imul(E,pa)|0;var Fa=(j+d|0)+((8191&e)<<13)|0;j=(f+(e>>>13)|0)+(Fa>>>26)|0,Fa&=67108863,d=Math.imul(M,ia),e=Math.imul(M,ja),e=e+Math.imul(N,ia)|0,f=Math.imul(N,ja),d=d+Math.imul(J,la)|0,e=e+Math.imul(J,ma)|0,e=e+Math.imul(K,la)|0,f=f+Math.imul(K,ma)|0,d=d+Math.imul(G,oa)|0,e=e+Math.imul(G,pa)|0,e=e+Math.imul(H,oa)|0,f=f+Math.imul(H,pa)|0;var Ga=(j+d|0)+((8191&e)<<13)|0;j=(f+(e>>>13)|0)+(Ga>>>26)|0,Ga&=67108863,d=Math.imul(M,la),e=Math.imul(M,ma),e=e+Math.imul(N,la)|0,f=Math.imul(N,ma),d=d+Math.imul(J,oa)|0,e=e+Math.imul(J,pa)|0,e=e+Math.imul(K,oa)|0,f=f+Math.imul(K,pa)|0;var Ha=(j+d|0)+((8191&e)<<13)|0;j=(f+(e>>>13)|0)+(Ha>>>26)|0,Ha&=67108863,d=Math.imul(M,oa),e=Math.imul(M,pa),e=e+Math.imul(N,oa)|0,f=Math.imul(N,pa);var Ia=(j+d|0)+((8191&e)<<13)|0;return j=(f+(e>>>13)|0)+(Ia>>>26)|0,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.transfo
break;case"]":f.state.readArray||c(g),f.type+=h,delete f.state.readArray,f.state.allowArray=!0,f.state.allowName=!0;break;default:f.state.allowType?(f.type+=h,f.state.allowParams=!0,f.state.allowArray=!0):f.state.allowName?(f.name+=h,delete f.state.allowArray):f.state.readArray?f.type+=h:c(g)}}if(f.parent)throw new Error("unexpected eof");return delete e.state,e.type=d(e.type),e}function f(a){var b={anonymous:!1,inputs:[],type:"event"},c=a.match(A);if(!c)throw new Error("invalid event: "+a);if(b.name=c[1].trim(),p(c[2]).forEach(function(a){a=e(a,!0),a.indexed=!!a.indexed,b.inputs.push(a)}),c[3].split(" ").forEach(function(a){switch(a){case"anonymous":b.anonymous=!0;break;case"":break;default:console.log("unknown modifier: "+mdifier)}}),b.name&&!b.name.match(B))throw new Error('invalid identifier: "'+result.name+'"');return b}function g(a){var b={constant:!1,inputs:[],outputs:[],payable:!1,type:"function"},c=a.split(" returns "),d=c[0].match(A);if(!d)throw new Error("invalid signature");if(b.name=d[1].trim(),!b.name.match(B))throw new Error('invalid identifier: "'+d[1]+'"');if(p(d[2]).forEach(function(a){b.inputs.push(e(a))}),d[3].split(" ").forEach(function(a){switch(a){case"constant":b.constant=!0;break;case"payable":b.payable=!0;break;case"pure":b.constant=!0,b.stateMutability="pure";break;case"view":b.constant=!0,b.stateMutability="view";break;case"":break;default:console.log("unknown modifier: "+a)}}),c.length>1){var f=c[1].match(A);if(""!=f[1].trim()||""!=f[3].trim())throw new Error("unexpected tokens");p(f[2]).forEach(function(a){b.outputs.push(e(a))})}return b}function h(a){if("string"==typeof a)return a=a.replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," "),a=a.trim(),"event "===a.substring(0,6)?f(a.substring(6).trim()):("function "===a.substring(0,9)&&(a=a.substring(9)),g(a.trim()));throw new Error("unknown fragment")}function i(a){var b=parseInt(32*Math.ceil(a.length/32)),c=new Uint8Array(b-a.length);return u.concat([E.encode(a.length),a,c])}function j(a,b,c){a.length<b+32&&v.throwError("insufficient data for dynamicBytes length",v.INVALID_ARGUMENT,{arg:c,coderType:"dynamicBytes",value:u.hexlify(a.slice(b,b+32))});var d=E.decode(a,b).value;try{d=d.toNumber()}catch(e){v.throwError("dynamic bytes count too large",v.INVALID_ARGUMENT,{arg:c,coderType:"dynamicBytes",value:d.toString()})}return a.length<b+32+d&&v.throwError("insufficient data for dynamicBytes type",v.INVALID_ARGUMENT,{arg:c,coderType:"dynamicBytes",value:u.hexlify(a.slice(b,b+32+d))}),{consumed:parseInt(32+32*Math.ceil(d/32)),value:a.slice(b+32,b+32+d)}}function k(a){return parseInt(32*Math.ceil(a/32))}function l(a,b){if(Array.isArray(b));else if(b&&"object"==typeof b){var c=[];a.forEach(function(a){c.push(b[a.localName])}),b=c}else v.throwError("invalid tuple value",v.INVALID_ARGUMENT,{coderType:"tuple",type:typeof b,value:b});a.length!==b.length&&v.throwError("types/value length mismatch",v.INVALID_ARGUMENT,{coderType:"tuple",value:b});var d=[];a.forEach(function(a,c){d.push({dynamic:a.dynamic,value:a.encode(b[c])})});var e=0,f=0;d.forEach(function(a,b){a.dynamic?(e+=32,f+=k(a.value.length)):e+=k(a.value.length)});var g=0,h=e,i=new Uint8Array(e+f);return d.forEach(function(a,b){a.dynamic?(i.set(E.encode(h),g),g+=32,i.set(a.value,h),h+=k(a.value.length)):(i.set(a.value,g),g+=k(a.value.length))}),i}function m(a,b,c){var d=c,e=0,f=[];return a.forEach(function(a){if(a.dynamic){var g=E.decode(b,c),h=a.decode(b,d+g.value.toNumber());h.consumed=g.consumed}else var h=a.decode(b,c);void 0!=h.value&&f.push(h.value),c+=h.consumed,e+=h.consumed}),a.forEach(function(a,b){var c=a.localName;c&&("object"==typeof c&&(c=c.name),c&&("length"===c&&(c="_length"),null==f[c]&&(f[c]=f[b])))}),{value:f,consumed:e}}function n(a,b,c,d){var e=b.type+"["+(c>=0?c:"")+"]";return{coder:b,localName:d,length:c,name:"array",type:e,encode:function(a){Array.isArray(a)||v.throwError("expected array value",v.INVALID_ARGUMENT,{arg:d,coderType:"array",type:typeof a,value:a});var e=c,f=new Uint8Array(0);e===-1&&(e=a.length,f=E.encode(e)),e!==a.length&&error.throwError("array value