ethjs-query
Version:
A simple query layer for the Ethereum RPC.
2 lines • 83.2 kB
JavaScript
!function(t,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("Eth",[],r):"object"==typeof exports?exports.Eth=r():t.Eth=r()}(this,function(){return function(t){function r(e){if(i[e])return i[e].exports;var n=i[e]={i:e,l:!1,exports:{}};return t[e].call(n.exports,n,n.exports,r),n.l=!0,n.exports}var i={};return r.m=t,r.c=i,r.i=function(t){return t},r.d=function(t,r,i){Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:i})},r.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},r.p="",r(r.s=7)}([function(t,r,i){"use strict";var e=i(4);t.exports=function(t){return"string"!=typeof t?t:e(t)?t.slice(2):t}},function(t,r,i){"use strict";(function(t,e){function n(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(r){return!1}}function o(){return t.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function h(r,i){if(o()<i)throw new RangeError("Invalid typed array length");return t.TYPED_ARRAY_SUPPORT?(r=new Uint8Array(i),r.__proto__=t.prototype):(null===r&&(r=new t(i)),r.length=i),r}function t(r,i,e){if(!(t.TYPED_ARRAY_SUPPORT||this instanceof t))return new t(r,i,e);if("number"==typeof r){if("string"==typeof i)throw Error("If encoding is specified then the first argument must be a string");return l(this,r)}return s(this,r,i,e)}function s(t,r,i,e){if("number"==typeof r)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&r instanceof ArrayBuffer?p(t,r,i,e):"string"==typeof r?f(t,r,i):m(t,r)}function u(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(0>t)throw new RangeError('"size" argument must not be negative')}function a(t,r,i,e){return u(r),r>0&&void 0!==i?"string"==typeof e?h(t,r).fill(i,e):h(t,r).fill(i):h(t,r)}function l(r,i){if(u(i),r=h(r,0>i?0:0|d(i)),!t.TYPED_ARRAY_SUPPORT)for(var e=0;i>e;++e)r[e]=0;return r}function f(r,i,e){if("string"==typeof e&&""!==e||(e="utf8"),!t.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var n=0|v(i,e);r=h(r,n);var o=r.write(i,e);return o!==n&&(r=r.slice(0,o)),r}function c(t,r){var i=0>r.length?0:0|d(r.length);t=h(t,i);for(var e=0;i>e;e+=1)t[e]=255&r[e];return t}function p(r,i,e,n){if(0>e||e>i.byteLength)throw new RangeError("'offset' is out of bounds");if(e+(n||0)>i.byteLength)throw new RangeError("'length' is out of bounds");return i=void 0===e&&void 0===n?new Uint8Array(i):void 0===n?new Uint8Array(i,e):new Uint8Array(i,e,n),t.TYPED_ARRAY_SUPPORT?(r=i,r.__proto__=t.prototype):r=c(r,i),r}function m(r,i){if(t.isBuffer(i)){var e=0|d(i.length);return r=h(r,e),0===r.length?r:(i.copy(r,0,0,e),r)}if(i){if("undefined"!=typeof ArrayBuffer&&i.buffer instanceof ArrayBuffer||"length"in i)return"number"!=typeof i.length||V(i.length)?h(r,0):c(r,i);if("Buffer"===i.type&&X(i.data))return c(r,i.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function d(t){if(t>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function g(r){return+r!=r&&(r=0),t.alloc(+r)}function v(r,i){if(t.isBuffer(r))return r.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(r)||r instanceof ArrayBuffer))return r.byteLength;"string"!=typeof r&&(r=""+r);var e=r.length;if(0===e)return 0;for(var n=!1;;)switch(i){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return Z(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*e;case"hex":return e>>>1;case"base64":return $(r).length;default:if(n)return Z(r).length;i=(""+i).toLowerCase(),n=!0}}function y(t,r,i){var e=!1;if((void 0===r||0>r)&&(r=0),r>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),0>=i)return"";if(i>>>=0,r>>>=0,r>=i)return"";for(t||(t="utf8");;)switch(t){case"hex":return Q(this,r,i);case"utf8":case"utf-8":return x(this,r,i);case"ascii":return P(this,r,i);case"latin1":case"binary":return k(this,r,i);case"base64":return D(this,r,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return j(this,r,i);default:if(e)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),e=!0}}function w(t,r,i){var e=t[r];t[r]=t[i],t[i]=e}function M(r,i,e,n,o){if(0===r.length)return-1;if("string"==typeof e?(n=e,e=0):e>2147483647?e=2147483647:-2147483648>e&&(e=-2147483648),e=+e,isNaN(e)&&(e=o?0:r.length-1),0>e&&(e=r.length+e),r.length>e){if(0>e){if(!o)return-1;e=0}}else{if(o)return-1;e=r.length-1}if("string"==typeof i&&(i=t.from(i,n)),t.isBuffer(i))return 0===i.length?-1:b(r,i,e,n,o);if("number"==typeof i)return i=255&i,t.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(r,i,e):Uint8Array.prototype.lastIndexOf.call(r,i,e):b(r,[i],e,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,r,i,e,n){function o(t,r){return 1===h?t[r]:t.readUInt16BE(r*h)}var h=1,s=t.length,u=r.length;if(void 0!==e&&(e=(e+"").toLowerCase(),"ucs2"===e||"ucs-2"===e||"utf16le"===e||"utf-16le"===e)){if(2>t.length||2>r.length)return-1;h=2,s/=2,u/=2,i/=2}var a;if(n){var l=-1;for(a=i;s>a;a++)if(o(t,a)===o(r,l===-1?0:a-l)){if(l===-1&&(l=a),a-l+1===u)return l*h}else l!==-1&&(a-=a-l),l=-1}else for(i+u>s&&(i=s-u),a=i;a>=0;a--){for(var f=!0,c=0;u>c;c++)if(o(t,a+c)!==o(r,c)){f=!1;break}if(f)return a}return-1}function _(t,r,i,e){i=+i||0;var n=t.length-i;e?(e=+e,e>n&&(e=n)):e=n;var o=r.length;if(o%2!==0)throw new TypeError("Invalid hex string");e>o/2&&(e=o/2);for(var h=0;e>h;++h){var s=parseInt(r.substr(2*h,2),16);if(isNaN(s))return h;t[i+h]=s}return h}function A(t,r,i,e){return K(Z(r,t.length-i),t,i,e)}function S(t,r,i,e){return K(z(r),t,i,e)}function E(t,r,i,e){return S(t,r,i,e)}function T(t,r,i,e){return K($(r),t,i,e)}function B(t,r,i,e){return K(J(r,t.length-i),t,i,e)}function D(t,r,i){return G.fromByteArray(0===r&&i===t.length?t:t.slice(r,i))}function x(t,r,i){i=Math.min(t.length,i);for(var e=[],n=r;i>n;){var o=t[n],h=null,s=o>239?4:o>223?3:o>191?2:1;if(i>=n+s){var u,a,l,f;switch(s){case 1:128>o&&(h=o);break;case 2:u=t[n+1],128===(192&u)&&(f=(31&o)<<6|63&u,f>127&&(h=f));break;case 3:u=t[n+1],a=t[n+2],128===(192&u)&&128===(192&a)&&(f=(15&o)<<12|(63&u)<<6|63&a,f>2047&&(55296>f||f>57343)&&(h=f));break;case 4:u=t[n+1],a=t[n+2],l=t[n+3],128===(192&u)&&128===(192&a)&&128===(192&l)&&(f=(15&o)<<18|(63&u)<<12|(63&a)<<6|63&l,f>65535&&1114112>f&&(h=f))}}null===h?(h=65533,s=1):h>65535&&(h-=65536,e.push(h>>>10&1023|55296),h=56320|1023&h),e.push(h),n+=s}return R(e)}function R(t){var r=t.length;if(tt>=r)return String.fromCharCode.apply(String,t);for(var i="",e=0;r>e;)i+=String.fromCharCode.apply(String,t.slice(e,e+=tt));return i}function P(t,r,i){var e="";i=Math.min(t.length,i);for(var n=r;i>n;++n)e+=String.fromCharCode(127&t[n]);return e}function k(t,r,i){var e="";i=Math.min(t.length,i);for(var n=r;i>n;++n)e+=String.fromCharCode(t[n]);return e}function Q(t,r,i){var e=t.length;r&&r>=0||(r=0),(!i||0>i||i>e)&&(i=e);for(var n="",o=r;i>o;++o)n+=H(t[o]);return n}function j(t,r,i){for(var e=t.slice(r,i),n="",o=0;e.length>o;o+=2)n+=String.fromCharCode(e[o]+256*e[o+1]);return n}function I(t,r,i){if(t%1!==0||0>t)throw new RangeError("offset is not uint");if(t+r>i)throw new RangeError("Trying to access beyond buffer length")}function O(r,i,e,n,o,h){if(!t.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(i>o||h>i)throw new RangeError('"value" argument is out of bounds');if(e+n>r.length)throw new RangeError("Index out of range")}function C(t,r,i,e){0>r&&(r=65535+r+1);for(var n=0,o=Math.min(t.length-i,2);o>n;++n)t[i+n]=(r&255<<8*(e?n:1-n))>>>8*(e?n:1-n)}function U(t,r,i,e){0>r&&(r=4294967295+r+1);for(var n=0,o=Math.min(t.length-i,4);o>n;++n)t[i+n]=r>>>8*(e?n:3-n)&255}function N(t,r,i,e,n,o){if(i+e>t.length)throw new RangeError("Index out of range");if(0>i)throw new RangeError("Index out of range")}function L(t,r,i,e,n){return n||N(t,r,i,4,3.4028234663852886e38,-3.4028234663852886e38),W.write(t,r,i,e,23,4),i+4}function q(t,r,i,e,n){return n||N(t,r,i,8,1.7976931348623157e308,-1.7976931348623157e308),W.write(t,r,i,e,52,8),i+8}function F(t){if(t=Y(t).replace(rt,""),2>t.length)return"";for(;t.length%4!==0;)t+="=";return t}function Y(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function H(t){return 16>t?"0"+t.toString(16):t.toString(16)}function Z(t,r){r=r||1/0;for(var i,e=t.length,n=null,o=[],h=0;e>h;++h){if(i=t.charCodeAt(h),i>55295&&57344>i){if(!n){if(i>56319){(r-=3)>-1&&o.push(239,191,189);continue}if(h+1===e){(r-=3)>-1&&o.push(239,191,189);continue}n=i;continue}if(56320>i){(r-=3)>-1&&o.push(239,191,189),n=i;continue}i=(n-55296<<10|i-56320)+65536}else n&&(r-=3)>-1&&o.push(239,191,189);if(n=null,128>i){if((r-=1)<0)break;o.push(i)}else if(2048>i){if((r-=2)<0)break;o.push(i>>6|192,63&i|128)}else if(65536>i){if((r-=3)<0)break;o.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(i>=1114112)throw Error("Invalid code point");if((r-=4)<0)break;o.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return o}function z(t){for(var r=[],i=0;t.length>i;++i)r.push(255&t.charCodeAt(i));return r}function J(t,r){for(var i,e,n,o=[],h=0;t.length>h&&(r-=2)>=0;++h)i=t.charCodeAt(h),e=i>>8,n=i%256,o.push(n),o.push(e);return o}function $(t){return G.toByteArray(F(t))}function K(t,r,i,e){for(var n=0;e>n&&(n+i<r.length&&n<t.length);++n)r[n+i]=t[n];return n}function V(t){return t!==t}var G=i(9),W=i(12),X=i(14);r.Buffer=t,r.SlowBuffer=g,r.INSPECT_MAX_BYTES=50,t.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:n(),r.kMaxLength=o(),t.poolSize=8192,t._augment=function(r){return r.__proto__=t.prototype,r},t.from=function(t,r,i){return s(null,t,r,i)},t.TYPED_ARRAY_SUPPORT&&(t.prototype.__proto__=Uint8Array.prototype,t.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&t[Symbol.species]===t&&Object.defineProperty(t,Symbol.species,{value:null,configurable:!0})),t.alloc=function(t,r,i){return a(null,t,r,i)},t.allocUnsafe=function(t){return l(null,t)},t.allocUnsafeSlow=function(t){return l(null,t)},t.isBuffer=function(t){return!(null==t||!t._isBuffer)},t.compare=function(r,i){if(!t.isBuffer(r)||!t.isBuffer(i))throw new TypeError("Arguments must be Buffers");if(r===i)return 0;for(var e=r.length,n=i.length,o=0,h=Math.min(e,n);h>o;++o)if(r[o]!==i[o]){e=r[o],n=i[o];break}return n>e?-1:e>n?1:0},t.isEncoding=function(t){switch((t+"").toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},t.concat=function(r,i){if(!X(r))throw new TypeError('"list" argument must be an Array of Buffers');if(0===r.length)return t.alloc(0);var e;if(void 0===i)for(i=0,e=0;r.length>e;++e)i+=r[e].length;var n=t.allocUnsafe(i),o=0;for(e=0;r.length>e;++e){var h=r[e];if(!t.isBuffer(h))throw new TypeError('"list" argument must be an Array of Buffers');h.copy(n,o),o+=h.length}return n},t.byteLength=v,t.prototype._isBuffer=!0,t.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;t>r;r+=2)w(this,r,r+1);return this},t.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;t>r;r+=4)w(this,r,r+3),w(this,r+1,r+2);return this},t.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;t>r;r+=8)w(this,r,r+7),w(this,r+1,r+6),w(this,r+2,r+5),w(this,r+3,r+4);return this},t.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?x(this,0,t):y.apply(this,arguments)},t.prototype.equals=function(r){if(!t.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r||0===t.compare(this,r)},t.prototype.inspect=function(){var t="",i=r.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(t+=" ... ")),"<Buffer "+t+">"},t.prototype.compare=function(r,i,e,n,o){if(!t.isBuffer(r))throw new TypeError("Argument must be a Buffer");if(void 0===i&&(i=0),void 0===e&&(e=r?r.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),0>i||e>r.length||0>n||o>this.length)throw new RangeError("out of range index");if(n>=o&&i>=e)return 0;if(n>=o)return-1;if(i>=e)return 1;if(i>>>=0,e>>>=0,n>>>=0,o>>>=0,this===r)return 0;for(var h=o-n,s=e-i,u=Math.min(h,s),a=this.slice(n,o),l=r.slice(i,e),f=0;u>f;++f)if(a[f]!==l[f]){h=a[f],s=l[f];break}return s>h?-1:h>s?1:0},t.prototype.includes=function(t,r,i){return this.indexOf(t,r,i)!==-1},t.prototype.indexOf=function(t,r,i){return M(this,t,r,i,!0)},t.prototype.lastIndexOf=function(t,r,i){return M(this,t,r,i,!1)},t.prototype.write=function(t,r,i,e){if(void 0===r)e="utf8",i=this.length,r=0;else if(void 0===i&&"string"==typeof r)e=r,i=this.length,r=0;else{if(!isFinite(r))throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");r=0|r,isFinite(i)?(i=0|i,void 0===e&&(e="utf8")):(e=i,i=void 0)}var n=this.length-r;if((void 0===i||i>n)&&(i=n),t.length>0&&(0>i||0>r)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");e||(e="utf8");for(var o=!1;;)switch(e){case"hex":return _(this,t,r,i);case"utf8":case"utf-8":return A(this,t,r,i);case"ascii":return S(this,t,r,i);case"latin1":case"binary":return E(this,t,r,i);case"base64":return T(this,t,r,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,t,r,i);default:if(o)throw new TypeError("Unknown encoding: "+e);e=(""+e).toLowerCase(),o=!0}},t.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var tt=4096;t.prototype.slice=function(r,i){var e=this.length;r=~~r,i=void 0===i?e:~~i,0>r?(r+=e,0>r&&(r=0)):r>e&&(r=e),0>i?(i+=e,0>i&&(i=0)):i>e&&(i=e),r>i&&(i=r);var n;if(t.TYPED_ARRAY_SUPPORT)n=this.subarray(r,i),n.__proto__=t.prototype;else{var o=i-r;n=new t(o,(void 0));for(var h=0;o>h;++h)n[h]=this[h+r]}return n},t.prototype.readUIntLE=function(t,r,i){t=0|t,r=0|r,i||I(t,r,this.length);for(var e=this[t],n=1,o=0;++o<r&&(n*=256);)e+=this[t+o]*n;return e},t.prototype.readUIntBE=function(t,r,i){t=0|t,r=0|r,i||I(t,r,this.length);for(var e=this[t+--r],n=1;r>0&&(n*=256);)e+=this[t+--r]*n;return e},t.prototype.readUInt8=function(t,r){return r||I(t,1,this.length),this[t]},t.prototype.readUInt16LE=function(t,r){return r||I(t,2,this.length),this[t]|this[t+1]<<8},t.prototype.readUInt16BE=function(t,r){return r||I(t,2,this.length),this[t]<<8|this[t+1]},t.prototype.readUInt32LE=function(t,r){return r||I(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},t.prototype.readUInt32BE=function(t,r){return r||I(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},t.prototype.readIntLE=function(t,r,i){t=0|t,r=0|r,i||I(t,r,this.length);for(var e=this[t],n=1,o=0;++o<r&&(n*=256);)e+=this[t+o]*n;return n*=128,n>e||(e-=Math.pow(2,8*r)),e},t.prototype.readIntBE=function(t,r,i){t=0|t,r=0|r,i||I(t,r,this.length);for(var e=r,n=1,o=this[t+--e];e>0&&(n*=256);)o+=this[t+--e]*n;return n*=128,n>o||(o-=Math.pow(2,8*r)),o},t.prototype.readInt8=function(t,r){return r||I(t,1,this.length),128&this[t]?(255-this[t]+1)*-1:this[t]},t.prototype.readInt16LE=function(t,r){r||I(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},t.prototype.readInt16BE=function(t,r){r||I(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},t.prototype.readInt32LE=function(t,r){return r||I(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},t.prototype.readInt32BE=function(t,r){return r||I(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},t.prototype.readFloatLE=function(t,r){return r||I(t,4,this.length),W.read(this,t,!0,23,4)},t.prototype.readFloatBE=function(t,r){return r||I(t,4,this.length),W.read(this,t,!1,23,4)},t.prototype.readDoubleLE=function(t,r){return r||I(t,8,this.length),W.read(this,t,!0,52,8)},t.prototype.readDoubleBE=function(t,r){return r||I(t,8,this.length),W.read(this,t,!1,52,8)},t.prototype.writeUIntLE=function(t,r,i,e){if(t=+t,r=0|r,i=0|i,!e){var n=Math.pow(2,8*i)-1;O(this,t,r,i,n,0)}var o=1,h=0;for(this[r]=255&t;++h<i&&(o*=256);)this[r+h]=t/o&255;return r+i},t.prototype.writeUIntBE=function(t,r,i,e){if(t=+t,r=0|r,i=0|i,!e){var n=Math.pow(2,8*i)-1;O(this,t,r,i,n,0)}var o=i-1,h=1;for(this[r+o]=255&t;--o>=0&&(h*=256);)this[r+o]=t/h&255;return r+i},t.prototype.writeUInt8=function(r,i,e){return r=+r,i=0|i,e||O(this,r,i,1,255,0),t.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),this[i]=255&r,i+1},t.prototype.writeUInt16LE=function(r,i,e){return r=+r,i=0|i,e||O(this,r,i,2,65535,0),t.TYPED_ARRAY_SUPPORT?(this[i]=255&r,this[i+1]=r>>>8):C(this,r,i,!0),i+2},t.prototype.writeUInt16BE=function(r,i,e){return r=+r,i=0|i,e||O(this,r,i,2,65535,0),t.TYPED_ARRAY_SUPPORT?(this[i]=r>>>8,this[i+1]=255&r):C(this,r,i,!1),i+2},t.prototype.writeUInt32LE=function(r,i,e){return r=+r,i=0|i,e||O(this,r,i,4,4294967295,0),t.TYPED_ARRAY_SUPPORT?(this[i+3]=r>>>24,this[i+2]=r>>>16,this[i+1]=r>>>8,this[i]=255&r):U(this,r,i,!0),i+4},t.prototype.writeUInt32BE=function(r,i,e){return r=+r,i=0|i,e||O(this,r,i,4,4294967295,0),t.TYPED_ARRAY_SUPPORT?(this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=255&r):U(this,r,i,!1),i+4},t.prototype.writeIntLE=function(t,r,i,e){if(t=+t,r=0|r,!e){var n=Math.pow(2,8*i-1);O(this,t,r,i,n-1,-n)}var o=0,h=1,s=0;for(this[r]=255&t;++o<i&&(h*=256);)0>t&&0===s&&0!==this[r+o-1]&&(s=1),this[r+o]=(t/h>>0)-s&255;return r+i},t.prototype.writeIntBE=function(t,r,i,e){if(t=+t,r=0|r,!e){var n=Math.pow(2,8*i-1);O(this,t,r,i,n-1,-n)}var o=i-1,h=1,s=0;for(this[r+o]=255&t;--o>=0&&(h*=256);)0>t&&0===s&&0!==this[r+o+1]&&(s=1),this[r+o]=(t/h>>0)-s&255;return r+i},t.prototype.writeInt8=function(r,i,e){return r=+r,i=0|i,e||O(this,r,i,1,127,-128),t.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),0>r&&(r=255+r+1),this[i]=255&r,i+1},t.prototype.writeInt16LE=function(r,i,e){return r=+r,i=0|i,e||O(this,r,i,2,32767,-32768),t.TYPED_ARRAY_SUPPORT?(this[i]=255&r,this[i+1]=r>>>8):C(this,r,i,!0),i+2},t.prototype.writeInt16BE=function(r,i,e){return r=+r,i=0|i,e||O(this,r,i,2,32767,-32768),t.TYPED_ARRAY_SUPPORT?(this[i]=r>>>8,this[i+1]=255&r):C(this,r,i,!1),i+2},t.prototype.writeInt32LE=function(r,i,e){return r=+r,i=0|i,e||O(this,r,i,4,2147483647,-2147483648),t.TYPED_ARRAY_SUPPORT?(this[i]=255&r,this[i+1]=r>>>8,this[i+2]=r>>>16,this[i+3]=r>>>24):U(this,r,i,!0),i+4},t.prototype.writeInt32BE=function(r,i,e){return r=+r,i=0|i,e||O(this,r,i,4,2147483647,-2147483648),0>r&&(r=4294967295+r+1),t.TYPED_ARRAY_SUPPORT?(this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=255&r):U(this,r,i,!1),i+4},t.prototype.writeFloatLE=function(t,r,i){return L(this,t,r,!0,i)},t.prototype.writeFloatBE=function(t,r,i){return L(this,t,r,!1,i)},t.prototype.writeDoubleLE=function(t,r,i){return q(this,t,r,!0,i)},t.prototype.writeDoubleBE=function(t,r,i){return q(this,t,r,!1,i)},t.prototype.copy=function(r,i,e,n){if(e||(e=0),n||0===n||(n=this.length),r.length>i||(i=r.length),i||(i=0),n>0&&e>n&&(n=e),n===e)return 0;if(0===r.length||0===this.length)return 0;if(0>i)throw new RangeError("targetStart out of bounds");if(0>e||e>=this.length)throw new RangeError("sourceStart out of bounds");if(0>n)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),n-e>r.length-i&&(n=r.length-i+e);var o,h=n-e;if(this===r&&i>e&&n>i)for(o=h-1;o>=0;--o)r[o+i]=this[o+e];else if(1e3>h||!t.TYPED_ARRAY_SUPPORT)for(o=0;h>o;++o)r[o+i]=this[o+e];else Uint8Array.prototype.set.call(r,this.subarray(e,e+h),i);return h},t.prototype.fill=function(r,i,e,n){if("string"==typeof r){if("string"==typeof i?(n=i,i=0,e=this.length):"string"==typeof e&&(n=e,e=this.length),1===r.length){var o=r.charCodeAt(0);256>o&&(r=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!t.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof r&&(r=255&r);if(0>i||i>this.length||e>this.length)throw new RangeError("Out of range index");if(i>=e)return this;i>>>=0,e=void 0===e?this.length:e>>>0,r||(r=0);var h;if("number"==typeof r)for(h=i;e>h;++h)this[h]=r;else{var s=t.isBuffer(r)?r:Z(""+new t(r,n)),u=s.length;for(h=0;e-i>h;++h)this[h+i]=s[h%u]}return this};var rt=/[^+\/0-9A-Za-z-_]/g}).call(r,i(1).Buffer,i(18))},function(t,r,i){(function(t,e){function n(t,r){this._id=t,this._clearFn=r}var o=i(17).nextTick,h=Function.prototype.apply,s=Array.prototype.slice,u={},a=0;r.setTimeout=function(){return new n(h.call(setTimeout,window,arguments),clearTimeout)},r.setInterval=function(){return new n(h.call(setInterval,window,arguments),clearInterval)},r.clearTimeout=r.clearInterval=function(t){t.close()},n.prototype.unref=n.prototype.ref=function(){},n.prototype.close=function(){this._clearFn.call(window,this._id)},r.enroll=function(t,r){clearTimeout(t._idleTimeoutId),t._idleTimeout=r},r.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},r._unrefActive=r.active=function(t){clearTimeout(t._idleTimeoutId);var r=t._idleTimeout;0>r||(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},r))},r.setImmediate="function"==typeof t?t:function(t){var i=a++,e=arguments.length>=2&&s.call(arguments,1);return u[i]=!0,o(function(){u[i]&&(e?t.apply(null,e):t.call(null),r.clearImmediate(i))}),i},r.clearImmediate="function"==typeof e?e:function(t){delete u[t]}}).call(r,i(2).setImmediate,i(2).clearImmediate)},function(t,r,i){"use strict";var e=i(13),n=i(16);t.exports=function(t){if(!e(t.then))throw new TypeError("Expected a promise");return function(r){t.then(function(t){n(r,null,t)},function(t){n(r,t)})}}},function(t,r){"use strict";t.exports=function(t){if("string"!=typeof t)throw Error("[is-hex-prefixed] value must be type 'string', is currently type "+typeof t+", while checking isHexPrefixed.");return"0x"===t.slice(0,2)}},function(t,r,i){"use strict";function e(t,r,i){if(["string","number","object"].indexOf(typeof t)===-1||null===t)return t;var e=p(t),n=i&&e.toString(16).length%2?"0":"";if(p(t).isNeg())throw Error("[ethjs-format] while formatting quantity '"+e.toString(10)+"', invalid negative number. Number must be positive or zero.");return r?"0x"+n+e.toString(16):e}function n(t,r){var i=t;return f.tags.indexOf(t)===-1&&(i=e(t,r)),i}function o(t,r){var i=t,e=0;if("string"==typeof t&&(i="0x"+d(m(t)),e=v(i)),"0x00"===i&&(i="0x0"),"number"==typeof r&&null!==t&&"0x"!==i&&"0x0"!==i&&(!/^[0-9A-Fa-f]+$/.test(m(i))||e!==2+2*r))throw Error("[ethjs-format] hex string '"+i+"' must be an alphanumeric "+(2+2*r)+" utf8 byte hex (chars: a-fA-F) string, is "+e+" bytes");return i}function h(t,r,i){var e=Object.assign({},r),n=null;if("string"==typeof t&&(n="Boolean|EthSyncing"===t?Object.assign({},f.objects.EthSyncing):"DATA|Transaction"===t?Object.assign({},f.objects.Transaction):Object.assign({},f.objects[t])),!g(Object.keys(r),n.__required))throw Error("[ethjs-format] object "+JSON.stringify(r)+" must contain properties: "+n.__required.join(", "));return Object.keys(n).forEach(function(t){"__required"!==t&&void 0!==r[t]&&(e[t]=u(n[t],r[t],i))}),e}function s(t,r,i,e){var n=r.slice(),o=t;if("Array|DATA"===t&&(o=["D"]),"FilterChange"===t&&"string"==typeof r[0]&&(o=["D32"]),i===!0&&"number"==typeof e&&e>r.length)throw Error("array "+JSON.stringify(r)+" must contain at least "+e+" params, but only contains "+r.length+".");return o=o.slice(),r.forEach(function(t,r){var e=0;o.length>1&&(e=r),n[r]=u(o[e],t,i)}),n}function u(t,r,i,u){var a=r;return"Q"===t?a=e(r,i):"QP"===t?a=e(r,i,!0):"Q|T"===t?a=n(r,i):"D"===t?a=o(r):"D20"===t?a=o(r,20):"D32"===t?a=o(r,32):"object"==typeof r&&null!==r&&Array.isArray(r)===!1?a=h(t,r,i):Array.isArray(r)&&(a=s(t,r,i,u)),a}function a(t,r){return u(f.methods[t][0],r,!0,f.methods[t][2])}function l(t,r){return u(f.methods[t][1],r,!1)}var f=i(15),c=i(11),p=i(8),m=i(0),d=c.padToEven,g=c.arrayContainsArray,v=c.getBinarySize;t.exports={schema:f,formatQuantity:e,formatQuantityOrTag:n,formatObject:h,formatArray:s,format:u,formatInputs:a,formatOutputs:l}},function(t,r,i){"use strict";function e(t,r){var i=this,n=r||{};if(!(this instanceof e))throw Error('[ethjs-rpc] the EthRPC object requires the "new" flag in order to function normally (i.e. `const eth = new EthRPC(provider);`).');i.options=Object.assign({jsonSpace:n.jsonSpace||0,max:n.max||9999999999999}),i.idCounter=Math.floor(Math.random()*i.options.max),(i.setProvider=function(t){if("object"!=typeof t)throw Error("[ethjs-rpc] the EthRPC object requires that the first input 'provider' must be an object, got '"+typeof t+"' (i.e. 'const eth = new EthRPC(provider);')");i.currentProvider=t})(t)}function n(t,r){return Object.assign({},{id:r,jsonrpc:"2.0",params:[]},t)}var o=i(3);t.exports=e,e.prototype.sendAsync=function(t,r){var i=this;i.idCounter=i.idCounter%i.options.max;var e=n(t,i.idCounter++),h=new Promise(function(t,r){i.currentProvider.sendAsync(e,function(n,o){var h=o||{};if(n||h.error){var s="[ethjs-rpc] "+(h.error&&"rpc"||"")+" error with payload "+JSON.stringify(e,null,i.options.jsonSpace)+" "+(n?n+"":JSON.stringify(h.error,null,i.options.jsonSpace)),u=Error(s);return u.value=n||h.error,void r(u)}t(h.result)})});return r?o(h)(r):h}},function(t,r,i){"use strict";function e(t,r){var i=this,n=r||{};if(!(this instanceof e))throw Error('[ethjs-query] the Eth object requires the "new" flag in order to function normally (i.e. `const eth = new Eth(provider);`).');if("object"!=typeof t)throw Error("[ethjs-query] the Eth object requires that the first input 'provider' must be an object, got '"+typeof t+"' (i.e. 'const eth = new Eth(provider);')");i.options=Object.assign({debug:n.debug||!1,logger:n.logger||console,jsonSpace:n.jsonSpace||0}),i.rpc=new h(t),i.setProvider=i.rpc.setProvider}function n(t,r){return function(){function i(){var i=this;return new Promise(function(e,s){if(r[2]>u.length)return void s(Error("[ethjs-query] method '"+a+"' requires at least "+r[2]+" input (format type "+r[0][0]+"), "+u.length+" provided. For more information visit: https://github.com/ethereum/wiki/wiki/JSON-RPC#"+t.toLowerCase()));if(u.length>r[0].length)return void s(Error("[ethjs-query] method '"+a+"' requires at most "+r[0].length+" params, "+u.length+" provided '"+JSON.stringify(u,null,h.options.jsonSpace)+"'. For more information visit: https://github.com/ethereum/wiki/wiki/JSON-RPC#"+t.toLowerCase()));r[3]&&r[3]>u.length&&u.push("latest"),i.log("attempting method formatting for '"+a+"' with inputs "+JSON.stringify(u,null,i.options.jsonSpace));try{n=o.formatInputs(t,u),i.log("method formatting success for '"+a+"' with formatted result: "+JSON.stringify(n,null,i.options.jsonSpace))}catch(l){return void s(Error("[ethjs-query] while formatting inputs '"+JSON.stringify(u,null,i.options.jsonSpace)+"' for method '"+a+"' error: "+l))}i.rpc.sendAsync({method:t,params:n}).then(function(r){try{i.log("attempting method formatting for '"+a+"' with raw outputs: "+JSON.stringify(r,null,i.options.jsonSpace));var n=o.formatOutputs(t,r);return i.log("method formatting success for '"+a+"' formatted result: "+JSON.stringify(n,null,i.options.jsonSpace)),void e(n)}catch(h){var u=Error("[ethjs-query] while formatting outputs from RPC '"+JSON.stringify(r,null,i.options.jsonSpace)+"' for method '"+a+"' "+h);return void s(u)}})["catch"](function(t){var r=Error("[ethjs-query] while formatting outputs from RPC '"+JSON.stringify(t,null,i.options.jsonSpace)+"'");s(r)})})}var e=null,n=null,h=this,u=[].slice.call(arguments),a=t.replace("eth_","");u.length>0&&"function"==typeof u[u.length-1]&&(e=u.pop());var l=i.call(this);return e?s(l)(e):l}}var o=i(5),h=i(6),s=i(3);t.exports=e,e.prototype.log=function(t){var r=this;r.options.debug&&r.options.logger.log("[ethjs-query log] "+t)},Object.keys(o.schema.methods).forEach(function(t){Object.defineProperty(e.prototype,t.replace("eth_",""),{enumerable:!0,value:n(t,o.schema.methods[t])})})},function(t,r,i){"use strict";var e=i(10),n=i(0);t.exports=function(t){if("string"==typeof t||"number"==typeof t){var r=new e(1),i=(t+"").toLowerCase().trim(),o="0x"===i.substr(0,2)||"-0x"===i.substr(0,3),h=n(i);if("-"===h.substr(0,1)&&(h=n(h.slice(1)),r=new e((-1),10)),h=""===h?"0":h,!h.match(/^-?[0-9]+$/)&&h.match(/^[0-9A-Fa-f]+$/)||h.match(/^[a-fA-F]+$/)||o===!0&&h.match(/^[0-9A-Fa-f]+$/))return new e(h,16).mul(r);if((h.match(/^-?[0-9]+$/)||""===h)&&o===!1)return new e(h,10).mul(r)}else if("object"==typeof t&&t.toString&&!t.pop&&!t.push&&t.toString(10).match(/^-?[0-9]+$/)&&(t.mul||t.dividedToIntegerBy))return new e(t.toString(10),10);throw Error("[number-to-bn] while converting number "+JSON.stringify(t)+" to BN.js instance, error: invalid number value. Value must be an integer, hex string, BN or BigNumber instance. Note, decimals are not supported.")}},function(t,r){"use strict";function i(t){var r=t.length;if(r%4>0)throw Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");i===-1&&(i=r);var e=i===r?0:4-i%4;return[i,e]}function e(t){var r=i(t),e=r[0],n=r[1];return 3*(e+n)/4-n}function n(t,r,i){return 3*(r+i)/4-i}function o(t){for(var r,e=i(t),o=e[0],h=e[1],s=new f(n(t,o,h)),u=0,a=h>0?o-4:o,c=0;a>c;c+=4)r=l[t.charCodeAt(c)]<<18|l[t.charCodeAt(c+1)]<<12|l[t.charCodeAt(c+2)]<<6|l[t.charCodeAt(c+3)],s[u++]=r>>16&255,s[u++]=r>>8&255,s[u++]=255&r;return 2===h&&(r=l[t.charCodeAt(c)]<<2|l[t.charCodeAt(c+1)]>>4,s[u++]=255&r),1===h&&(r=l[t.charCodeAt(c)]<<10|l[t.charCodeAt(c+1)]<<4|l[t.charCodeAt(c+2)]>>2,s[u++]=r>>8&255,s[u++]=255&r),s}function h(t){return a[t>>18&63]+a[t>>12&63]+a[t>>6&63]+a[63&t]}function s(t,r,i){for(var e,n=[],o=r;i>o;o+=3)e=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),n.push(h(e));return n.join("")}function u(t){for(var r,i=t.length,e=i%3,n=[],o=16383,h=0,u=i-e;u>h;h+=o)n.push(s(t,h,h+o>u?u:h+o));return 1===e?(r=t[i-1],n.push(a[r>>2]+a[r<<4&63]+"==")):2===e&&(r=(t[i-2]<<8)+t[i-1],n.push(a[r>>10]+a[r>>4&63]+a[r<<2&63]+"=")),n.join("")}r.byteLength=e,r.toByteArray=o,r.fromByteArray=u;for(var a=[],l=[],f="undefined"!=typeof Uint8Array?Uint8Array:Array,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,m=c.length;m>p;++p)a[p]=c[p],l[c.charCodeAt(p)]=p;l["-".charCodeAt(0)]=62,l["_".charCodeAt(0)]=63},function(t,r,i){(function(t){!function(t,r){"use strict";function e(t,r){if(!t)throw Error(r||"Assertion failed")}function n(t,r){t.super_=r;var i=function(){};i.prototype=r.prototype,t.prototype=new i,t.prototype.constructor=t}function o(t,r,i){return o.isBN(t)?t:(this.negative=0,this.words=null,this.length=0,this.red=null,void(null!==t&&("le"!==r&&"be"!==r||(i=r,r=10),this._init(t||0,r||10,i||"be"))))}function h(t,r,i){for(var e=0,n=Math.min(t.length,i),o=r;n>o;o++){var h=t.charCodeAt(o)-48;e<<=4,e|=49>h||h>54?17>h||h>22?15&h:h-17+10:h-49+10}return e}function s(t,r,i,e){for(var n=0,o=Math.min(t.length,i),h=r;o>h;h++){var s=t.charCodeAt(h)-48;n*=e,n+=49>s?17>s?s:s-17+10:s-49+10}return n}function u(t){for(var r=Array(t.bitLength()),i=0;r.length>i;i++){var e=i/26|0,n=i%26;r[i]=(t.words[e]&1<<n)>>>n}return r}function a(t,r,i){i.negative=r.negative^t.negative;var e=t.length+r.length|0;i.length=e,e=e-1|0;var n=0|t.words[0],o=0|r.words[0],h=n*o,s=67108863&h,u=h/67108864|0;i.words[0]=s;for(var a=1;e>a;a++){for(var l=u>>>26,f=67108863&u,c=Math.min(a,r.length-1),p=Math.max(0,a-t.length+1);c>=p;p++){var m=a-p|0;n=0|t.words[m],o=0|r.words[p],h=n*o+f,l+=h/67108864|0,f=67108863&h}i.words[a]=0|f,u=0|l}return 0!==u?i.words[a]=0|u:i.length--,i.strip()}function l(t,r,i){i.negative=r.negative^t.negative,i.length=t.length+r.length;for(var e=0,n=0,o=0;i.length-1>o;o++){var h=n;n=0;for(var s=67108863&e,u=Math.min(o,r.length-1),a=Math.max(0,o-t.length+1);u>=a;a++){var l=o-a,f=0|t.words[l],c=0|r.words[a],p=f*c,m=67108863&p;h=h+(p/67108864|0)|0,m=m+s|0,
s=67108863&m,h=h+(m>>>26)|0,n+=h>>>26,h&=67108863}i.words[o]=s,e=h,h=n}return 0!==e?i.words[o]=e:i.length--,i.strip()}function f(t,r,i){var e=new c;return e.mulp(t,r,i)}function c(t,r){this.x=t,this.y=r}function p(t,r){this.name=t,this.p=new o(r,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function m(){p.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function d(){p.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function g(){p.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function v(){p.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function y(t){if("string"==typeof t){var r=o._prime(t);this.m=r.p,this.prime=r}else e(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function w(t){y.call(this,t),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new o(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)}"object"==typeof t?t.exports=o:r.BN=o,o.BN=o,o.wordSize=26;var M;try{M=i(1).Buffer}catch(b){}o.isBN=function(t){return t instanceof o||null!==t&&"object"==typeof t&&t.constructor.wordSize===o.wordSize&&Array.isArray(t.words)},o.max=function(t,r){return t.cmp(r)>0?t:r},o.min=function(t,r){return t.cmp(r)<0?t:r},o.prototype._init=function(t,r,i){if("number"==typeof t)return this._initNumber(t,r,i);if("object"==typeof t)return this._initArray(t,r,i);"hex"===r&&(r=16),e(r===(0|r)&&r>=2&&36>=r),t=(""+t).replace(/\s+/g,"");var n=0;"-"===t[0]&&n++,16===r?this._parseHex(t,n):this._parseBase(t,r,n),"-"===t[0]&&(this.negative=1),this.strip(),"le"===i&&this._initArray(this.toArray(),r,i)},o.prototype._initNumber=function(t,r,i){0>t&&(this.negative=1,t=-t),67108864>t?(this.words=[67108863&t],this.length=1):4503599627370496>t?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(e(9007199254740992>t),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),r,i)},o.prototype._initArray=function(t,r,i){if(e("number"==typeof t.length),0>=t.length)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=Array(this.length);for(var n=0;this.length>n;n++)this.words[n]=0;var o,h,s=0;if("be"===i)for(n=t.length-1,o=0;n>=0;n-=3)h=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=h<<s&67108863,this.words[o+1]=h>>>26-s&67108863,s+=24,26>s||(s-=26,o++);else if("le"===i)for(n=0,o=0;t.length>n;n+=3)h=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[o]|=h<<s&67108863,this.words[o+1]=h>>>26-s&67108863,s+=24,26>s||(s-=26,o++);return this.strip()},o.prototype._parseHex=function(t,r){this.length=Math.ceil((t.length-r)/6),this.words=Array(this.length);for(var i=0;this.length>i;i++)this.words[i]=0;var e,n,o=0;for(i=t.length-6,e=0;i>=r;i-=6)n=h(t,i,i+6),this.words[e]|=n<<o&67108863,this.words[e+1]|=n>>>26-o&4194303,o+=24,26>o||(o-=26,e++);i+6!==r&&(n=h(t,r,i+6),this.words[e]|=n<<o&67108863,this.words[e+1]|=n>>>26-o&4194303),this.strip()},o.prototype._parseBase=function(t,r,i){this.words=[0],this.length=1;for(var e=0,n=1;67108863>=n;n*=r)e++;e--,n=n/r|0;for(var o=t.length-i,h=o%e,u=Math.min(o,o-h)+i,a=0,l=i;u>l;l+=e)a=s(t,l,l+e,r),this.imuln(n),67108864>this.words[0]+a?this.words[0]+=a:this._iaddn(a);if(0!==h){var f=1;for(a=s(t,l,t.length,r),l=0;h>l;l++)f*=r;this.imuln(f),67108864>this.words[0]+a?this.words[0]+=a:this._iaddn(a)}},o.prototype.copy=function(t){t.words=Array(this.length);for(var r=0;this.length>r;r++)t.words[r]=this.words[r];t.length=this.length,t.negative=this.negative,t.red=this.red},o.prototype.clone=function(){var t=new o(null);return this.copy(t),t},o.prototype._expand=function(t){for(;t>this.length;)this.words[this.length++]=0;return this},o.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var _=["","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"],A=[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],S=[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];o.prototype.toString=function(t,r){t=t||10,r=0|r||1;var i;if(16===t||"hex"===t){i="";for(var n=0,o=0,h=0;this.length>h;h++){var s=this.words[h],u=(16777215&(s<<n|o)).toString(16);o=s>>>24-n&16777215,i=0!==o||h!==this.length-1?_[6-u.length]+u+i:u+i,n+=2,26>n||(n-=26,h--)}for(0!==o&&(i=o.toString(16)+i);i.length%r!==0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&36>=t){var a=A[t],l=S[t];i="";var f=this.clone();for(f.negative=0;!f.isZero();){var c=f.modn(l).toString(t);f=f.idivn(l),i=f.isZero()?c+i:_[a-c.length]+c+i}for(this.isZero()&&(i="0"+i);i.length%r!==0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}e(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&e(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(t,r){return e(void 0!==M),this.toArrayLike(M,t,r)},o.prototype.toArray=function(t,r){return this.toArrayLike(Array,t,r)},o.prototype.toArrayLike=function(t,r,i){var n=this.byteLength(),o=i||Math.max(1,n);e(o>=n,"byte array longer than desired length"),e(o>0,"Requested array length <= 0"),this.strip();var h,s,u="le"===r,a=new t(o),l=this.clone();if(u){for(s=0;!l.isZero();s++)h=l.andln(255),l.iushrn(8),a[s]=h;for(;o>s;s++)a[s]=0}else{for(s=0;o-n>s;s++)a[s]=0;for(s=0;!l.isZero();s++)h=l.andln(255),l.iushrn(8),a[o-s-1]=h}return a},o.prototype._countBits=Math.clz32?function(t){return 32-Math.clz32(t)}:function(t){var r=t,i=0;return 4096>r||(i+=13,r>>>=13),64>r||(i+=7,r>>>=7),8>r||(i+=4,r>>>=4),2>r||(i+=2,r>>>=2),i+r},o.prototype._zeroBits=function(t){if(0===t)return 26;var r=t,i=0;return 0===(8191&r)&&(i+=13,r>>>=13),0===(127&r)&&(i+=7,r>>>=7),0===(15&r)&&(i+=4,r>>>=4),0===(3&r)&&(i+=2,r>>>=2),0===(1&r)&&i++,i},o.prototype.bitLength=function(){var t=this.words[this.length-1],r=this._countBits(t);return 26*(this.length-1)+r},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,r=0;this.length>r;r++){var i=this._zeroBits(this.words[r]);if(t+=i,26!==i)break}return t},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},o.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return 0!==this.negative},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(t){for(;t.length>this.length;)this.words[this.length++]=0;for(var r=0;t.length>r;r++)this.words[r]=this.words[r]|t.words[r];return this.strip()},o.prototype.ior=function(t){return e(0===(this.negative|t.negative)),this.iuor(t)},o.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},o.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},o.prototype.iuand=function(t){var r;r=this.length>t.length?t:this;for(var i=0;r.length>i;i++)this.words[i]=this.words[i]&t.words[i];return this.length=r.length,this.strip()},o.prototype.iand=function(t){return e(0===(this.negative|t.negative)),this.iuand(t)},o.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},o.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},o.prototype.iuxor=function(t){var r,i;this.length>t.length?(r=this,i=t):(r=t,i=this);for(var e=0;i.length>e;e++)this.words[e]=r.words[e]^i.words[e];if(this!==r)for(;r.length>e;e++)this.words[e]=r.words[e];return this.length=r.length,this.strip()},o.prototype.ixor=function(t){return e(0===(this.negative|t.negative)),this.iuxor(t)},o.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},o.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},o.prototype.inotn=function(t){e("number"==typeof t&&t>=0);var r=0|Math.ceil(t/26),i=t%26;this._expand(r),i>0&&r--;for(var n=0;r>n;n++)this.words[n]=67108863&~this.words[n];return i>0&&(this.words[n]=~this.words[n]&67108863>>26-i),this.strip()},o.prototype.notn=function(t){return this.clone().inotn(t)},o.prototype.setn=function(t,r){e("number"==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=r?this.words[i]|1<<n:this.words[i]&~(1<<n),this.strip()},o.prototype.iadd=function(t){var r;if(0!==this.negative&&0===t.negative)return this.negative=0,r=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,r=this.isub(t),t.negative=1,r._normSign();var i,e;this.length>t.length?(i=this,e=t):(i=t,e=this);for(var n=0,o=0;e.length>o;o++)r=(0|i.words[o])+(0|e.words[o])+n,this.words[o]=67108863&r,n=r>>>26;for(;0!==n&&i.length>o;o++)r=(0|i.words[o])+n,this.words[o]=67108863&r,n=r>>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;i.length>o;o++)this.words[o]=i.words[o];return this},o.prototype.add=function(t){var r;return 0!==t.negative&&0===this.negative?(t.negative=0,r=this.sub(t),t.negative^=1,r):0===t.negative&&0!==this.negative?(this.negative=0,r=t.sub(this),this.negative=1,r):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},o.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var r=this.iadd(t);return t.negative=1,r._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;var e,n;i>0?(e=this,n=t):(e=t,n=this);for(var o=0,h=0;n.length>h;h++)r=(0|e.words[h])-(0|n.words[h])+o,o=r>>26,this.words[h]=67108863&r;for(;0!==o&&e.length>h;h++)r=(0|e.words[h])+o,o=r>>26,this.words[h]=67108863&r;if(0===o&&e.length>h&&e!==this)for(;e.length>h;h++)this.words[h]=e.words[h];return this.length=Math.max(this.length,h),e!==this&&(this.negative=1),this.strip()},o.prototype.sub=function(t){return this.clone().isub(t)};var E=function(t,r,i){var e,n,o,h=t.words,s=r.words,u=i.words,a=0,l=0|h[0],f=8191&l,c=l>>>13,p=0|h[1],m=8191&p,d=p>>>13,g=0|h[2],v=8191&g,y=g>>>13,w=0|h[3],M=8191&w,b=w>>>13,_=0|h[4],A=8191&_,S=_>>>13,E=0|h[5],T=8191&E,B=E>>>13,D=0|h[6],x=8191&D,R=D>>>13,P=0|h[7],k=8191&P,Q=P>>>13,j=0|h[8],I=8191&j,O=j>>>13,C=0|h[9],U=8191&C,N=C>>>13,L=0|s[0],q=8191&L,F=L>>>13,Y=0|s[1],H=8191&Y,Z=Y>>>13,z=0|s[2],J=8191&z,$=z>>>13,K=0|s[3],V=8191&K,G=K>>>13,W=0|s[4],X=8191&W,tt=W>>>13,rt=0|s[5],it=8191&rt,et=rt>>>13,nt=0|s[6],ot=8191&nt,ht=nt>>>13,st=0|s[7],ut=8191&st,at=st>>>13,lt=0|s[8],ft=8191<,ct=lt>>>13,pt=0|s[9],mt=8191&pt,dt=pt>>>13;i.negative=t.negative^r.negative,i.length=19,e=Math.imul(f,q),n=Math.imul(f,F),n=n+Math.imul(c,q)|0,o=Math.imul(c,F);var gt=(a+e|0)+((8191&n)<<13)|0;a=(o+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,e=Math.imul(m,q),n=Math.imul(m,F),n=n+Math.imul(d,q)|0,o=Math.imul(d,F),e=e+Math.imul(f,H)|0,n=n+Math.imul(f,Z)|0,n=n+Math.imul(c,H)|0,o=o+Math.imul(c,Z)|0;var vt=(a+e|0)+((8191&n)<<13)|0;a=(o+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,e=Math.imul(v,q),n=Math.imul(v,F),n=n+Math.imul(y,q)|0,o=Math.imul(y,F),e=e+Math.imul(m,H)|0,n=n+Math.imul(m,Z)|0,n=n+Math.imul(d,H)|0,o=o+Math.imul(d,Z)|0,e=e+Math.imul(f,J)|0,n=n+Math.imul(f,$)|0,n=n+Math.imul(c,J)|0,o=o+Math.imul(c,$)|0;var yt=(a+e|0)+((8191&n)<<13)|0;a=(o+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,e=Math.imul(M,q),n=Math.imul(M,F),n=n+Math.imul(b,q)|0,o=Math.imul(b,F),e=e+Math.imul(v,H)|0,n=n+Math.imul(v,Z)|0,n=n+Math.imul(y,H)|0,o=o+Math.imul(y,Z)|0,e=e+Math.imul(m,J)|0,n=n+Math.imul(m,$)|0,n=n+Math.imul(d,J)|0,o=o+Math.imul(d,$)|0,e=e+Math.imul(f,V)|0,n=n+Math.imul(f,G)|0,n=n+Math.imul(c,V)|0,o=o+Math.imul(c,G)|0;var wt=(a+e|0)+((8191&n)<<13)|0;a=(o+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,e=Math.imul(A,q),n=Math.imul(A,F),n=n+Math.imul(S,q)|0,o=Math.imul(S,F),e=e+Math.imul(M,H)|0,n=n+Math.imul(M,Z)|0,n=n+Math.imul(b,H)|0,o=o+Math.imul(b,Z)|0,e=e+Math.imul(v,J)|0,n=n+Math.imul(v,$)|0,n=n+Math.imul(y,J)|0,o=o+Math.imul(y,$)|0,e=e+Math.imul(m,V)|0,n=n+Math.imul(m,G)|0,n=n+Math.imul(d,V)|0,o=o+Math.imul(d,G)|0,e=e+Math.imul(f,X)|0,n=n+Math.imul(f,tt)|0,n=n+Math.imul(c,X)|0,o=o+Math.imul(c,tt)|0;var Mt=(a+e|0)+((8191&n)<<13)|0;a=(o+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,e=Math.imul(T,q),n=Math.imul(T,F),n=n+Math.imul(B,q)|0,o=Math.imul(B,F),e=e+Math.imul(A,H)|0,n=n+Math.imul(A,Z)|0,n=n+Math.imul(S,H)|0,o=o+Math.imul(S,Z)|0,e=e+Math.imul(M,J)|0,n=n+Math.imul(M,$)|0,n=n+Math.imul(b,J)|0,o=o+Math.imul(b,$)|0,e=e+Math.imul(v,V)|0,n=n+Math.imul(v,G)|0,n=n+Math.imul(y,V)|0,o=o+Math.imul(y,G)|0,e=e+Math.imul(m,X)|0,n=n+Math.imul(m,tt)|0,n=n+Math.imul(d,X)|0,o=o+Math.imul(d,tt)|0,e=e+Math.imul(f,it)|0,n=n+Math.imul(f,et)|0,n=n+Math.imul(c,it)|0,o=o+Math.imul(c,et)|0;var bt=(a+e|0)+((8191&n)<<13)|0;a=(o+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,e=Math.imul(x,q),n=Math.imul(x,F),n=n+Math.imul(R,q)|0,o=Math.imul(R,F),e=e+Math.imul(T,H)|0,n=n+Math.imul(T,Z)|0,n=n+Math.imul(B,H)|0,o=o+Math.imul(B,Z)|0,e=e+Math.imul(A,J)|0,n=n+Math.imul(A,$)|0,n=n+Math.imul(S,J)|0,o=o+Math.imul(S,$)|0,e=e+Math.imul(M,V)|0,n=n+Math.imul(M,G)|0,n=n+Math.imul(b,V)|0,o=o+Math.imul(b,G)|0,e=e+Math.imul(v,X)|0,n=n+Math.imul(v,tt)|0,n=n+Math.imul(y,X)|0,o=o+Math.imul(y,tt)|0,e=e+Math.imul(m,it)|0,n=n+Math.imul(m,et)|0,n=n+Math.imul(d,it)|0,o=o+Math.imul(d,et)|0,e=e+Math.imul(f,ot)|0,n=n+Math.imul(f,ht)|0,n=n+Math.imul(c,ot)|0,o=o+Math.imul(c,ht)|0;var _t=(a+e|0)+((8191&n)<<13)|0;a=(o+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,e=Math.imul(k,q),n=Math.imul(k,F),n=n+Math.imul(Q,q)|0,o=Math.imul(Q,F),e=e+Math.imul(x,H)|0,n=n+Math.imul(x,Z)|0,n=n+Math.imul(R,H)|0,o=o+Math.imul(R,Z)|0,e=e+Math.imul(T,J)|0,n=n+Math.imul(T,$)|0,n=n+Math.imul(B,J)|0,o=o+Math.imul(B,$)|0,e=e+Math.imul(A,V)|0,n=n+Math.imul(A,G)|0,n=n+Math.imul(S,V)|0,o=o+Math.imul(S,G)|0,e=e+Math.imul(M,X)|0,n=n+Math.imul(M,tt)|0,n=n+Math.imul(b,X)|0,o=o+Math.imul(b,tt)|0,e=e+Math.imul(v,it)|0,n=n+Math.imul(v,et)|0,n=n+Math.imul(y,it)|0,o=o+Math.imul(y,et)|0,e=e+Math.imul(m,ot)|0,n=n+Math.imul(m,ht)|0,n=n+Math.imul(d,ot)|0,o=o+Math.imul(d,ht)|0,e=e+Math.imul(f,ut)|0,n=n+Math.imul(f,at)|0,n=n+Math.imul(c,ut)|0,o=o+Math.imul(c,at)|0;var At=(a+e|0)+((8191&n)<<13)|0;a=(o+(n>>>13)|0)+(At>>>26)|0,At&=67108863,e=Math.imul(I,q),n=Math.imul(I,F),n=n+Math.imul(O,q)|0,o=Math.imul(O,F),e=e+Math.imul(k,H)|0,n=n+Math.imul(k,Z)|0,n=n+Math.imul(Q,H)|0,o=o+Math.imul(Q,Z)|0,e=e+Math.imul(x,J)|0,n=n+Math.imul(x,$)|0,n=n+Math.imul(R,J)|0,o=o+Math.imul(R,$)|0,e=e+Math.imul(T,V)|0,n=n+Math.imul(T,G)|0,n=n+Math.imul(B,V)|0,o=o+Math.imul(B,G)|0,e=e+Math.imul(A,X)|0,n=n+Math.imul(A,tt)|0,n=n+Math.imul(S,X)|0,o=o+Math.imul(S,tt)|0,e=e+Math.imul(M,it)|0,n=n+Math.imul(M,et)|0,n=n+Math.imul(b,it)|0,o=o+Math.imul(b,et)|0,e=e+Math.imul(v,ot)|0,n=n+Math.imul(v,ht)|0,n=n+Math.imul(y,ot)|0,o=o+Math.imul(y,ht)|0,e=e+Math.imul(m,ut)|0,n=n+Math.imul(m,at)|0,n=n+Math.imul(d,ut)|0,o=o+Math.imul(d,at)|0,e=e+Math.imul(f,ft)|0,n=n+Math.imul(f,ct)|0,n=n+Math.imul(c,ft)|0,o=o+Math.imul(c,ct)|0;var St=(a+e|0)+((8191&n)<<13)|0;a=(o+(n>>>13)|0)+(St>>>26)|0,St&=67108863,e=Math.imul(U,q),n=Math.imul(U,F),n=n+Math.imul(N,q)|0,o=Math.imul(N,F),e=e+Math.imul(I,H)|0,n=n+Math.imul(I,Z)|0,n=n+Math.imul(O,H)|0,o=o+Math.imul(O,Z)|0,e=e+Math.imul(k,J)|0,n=n+Math.imul(k,$)|0,n=n+Math.imul(Q,J)|0,o=o+Math.imul(Q,$)|0,e=e+Math.imul(x,V)|0,n=n+Math.imul(x,G)|0,n=n+Math.imul(R,V)|0,o=o+Math.imul(R,G)|0,e=e+Math.imul(T,X)|0,n=n+Math.imul(T,tt)|0,n=n+Math.imul(B,X)|0,o=o+Math.imul(B,tt)|0,e=e+Math.imul(A,it)|0,n=n+Math.imul(A,et)|0,n=n+Math.imul(S,it)|0,o=o+Math.imul(S,et)|0,e=e+Math.imul(M,ot)|0,n=n+Math.imul(M,ht)|0,n=n+Math.imul(b,ot)|0,o=o+Math.imul(b,ht)|0,e=e+Math.imul(v,ut)|0,n=n+Math.imul(v,at)|0,n=n+Math.imul(y,ut)|0,o=o+Math.imul(y,at)|0,e=e+Math.imul(m,ft)|0,n=n+Math.imul(m,ct)|0,n=n+Math.imul(d,ft)|0,o=o+Math.imul(d,ct)|0,e=e+Math.imul(f,mt)|0,n=n+Math.imul(f,dt)|0,n=n+Math.imul(c,mt)|0,o=o+Math.imul(c,dt)|0;var Et=(a+e|0)+((8191&n)<<13)|0;a=(o+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,e=Math.imul(U,H),n=Math.imul(U,Z),n=n+Math.imul(N,H)|0,o=Math.imul(N,Z),e=e+Math.imul(I,J)|0,n=n+Math.imul(I,$)|0,n=n+Math.imul(O,J)|0,o=o+Math.imul(O,$)|0,e=e+Math.imul(k,V)|0,n=n+Math.imul(k,G)|0,n=n+Math.imul(Q,V)|0,o=o+Math.imul(Q,G)|0,e=e+Math.imul(x,X)|0,n=n+Math.imul(x,tt)|0,n=n+Math.imul(R,X)|0,o=o+Math.imul(R,tt)|0,e=e+Math.imul(T,it)|0,n=n+Math.imul(T,et)|0,n=n+Math.imul(B,it)|0,o=o+Math.imul(B,et)|0,e=e+Math.imul(A,ot)|0,n=n+Math.imul(A,ht)|0,n=n+Math.imul(S,ot)|0,o=o+Math.imul(S,ht)|0,e=e+Math.imul(M,ut)|0,n=n+Math.imul(M,at)|0,n=n+Math.imul(b,ut)|0,o=o+Math.imul(b,at)|0,e=e+Math.imul(v,ft)|0,n=n+Math.imul(v,ct)|0,n=n+Math.imul(y,ft)|0,o=o+Math.imul(y,ct)|0,e=e+Math.imul(m,mt)|0,n=n+Math.imul(m,dt)|0,n=n+Math.imul(d,mt)|0