diff --git a/docs/assets/js/ganache/ganache.min.js b/docs/assets/js/ganache/ganache.min.js index f592ec0bcc..1213cdf321 100644 --- a/docs/assets/js/ganache/ganache.min.js +++ b/docs/assets/js/ganache/ganache.min.js @@ -1,3 +1,3 @@ /*! For license information please see ganache.min.js.LICENSE.txt */ -!function webpackUniversalModuleDefinition(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Ganache=t():e.Ganache=t()}(self,(function(){return(()=>{var __webpack_modules__=[(e,t,a)=>{"use strict";var r=a(423),n=a(424),c="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=Buffer,t.SlowBuffer=function SlowBuffer(e){+e!=e&&(e=0);return Buffer.alloc(+e)},t.INSPECT_MAX_BYTES=50;var o=2147483647;function createBuffer(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,Buffer.prototype),t}function Buffer(e,t,a){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return allocUnsafe(e)}return from(e,t,a)}function from(e,t,a){if("string"==typeof e)return function fromString(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!Buffer.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var a=0|byteLength(e,t),r=createBuffer(a),n=r.write(e,t);n!==a&&(r=r.slice(0,n));return r}(e,t);if(ArrayBuffer.isView(e))return function fromArrayView(e){if(isInstance(e,Uint8Array)){var t=new Uint8Array(e);return fromArrayBuffer(t.buffer,t.byteOffset,t.byteLength)}return fromArrayLike(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(isInstance(e,ArrayBuffer)||e&&isInstance(e.buffer,ArrayBuffer))return fromArrayBuffer(e,t,a);if("undefined"!=typeof SharedArrayBuffer&&(isInstance(e,SharedArrayBuffer)||e&&isInstance(e.buffer,SharedArrayBuffer)))return fromArrayBuffer(e,t,a);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var r=e.valueOf&&e.valueOf();if(null!=r&&r!==e)return Buffer.from(r,t,a);var n=function fromObject(e){if(Buffer.isBuffer(e)){var t=0|checked(e.length),a=createBuffer(t);return 0===a.length||e.copy(a,0,0,t),a}if(void 0!==e.length)return"number"!=typeof e.length||numberIsNaN(e.length)?createBuffer(0):fromArrayLike(e);if("Buffer"===e.type&&Array.isArray(e.data))return fromArrayLike(e.data)}(e);if(n)return n;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return Buffer.from(e[Symbol.toPrimitive]("string"),t,a);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function assertSize(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function allocUnsafe(e){return assertSize(e),createBuffer(e<0?0:0|checked(e))}function fromArrayLike(e){for(var t=e.length<0?0:0|checked(e.length),a=createBuffer(t),r=0;r=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function byteLength(e,t){if(Buffer.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||isInstance(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var a=e.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===a)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return a;case"utf8":case"utf-8":return utf8ToBytes(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*a;case"hex":return a>>>1;case"base64":return base64ToBytes(e).length;default:if(n)return r?-1:utf8ToBytes(e).length;t=(""+t).toLowerCase(),n=!0}}function slowToString(e,t,a){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===a||a>this.length)&&(a=this.length),a<=0)return"";if((a>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return hexSlice(this,t,a);case"utf8":case"utf-8":return utf8Slice(this,t,a);case"ascii":return asciiSlice(this,t,a);case"latin1":case"binary":return latin1Slice(this,t,a);case"base64":return base64Slice(this,t,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,t,a);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function swap(e,t,a){var r=e[t];e[t]=e[a],e[a]=r}function bidirectionalIndexOf(e,t,a,r,n){if(0===e.length)return-1;if("string"==typeof a?(r=a,a=0):a>2147483647?a=2147483647:a<-2147483648&&(a=-2147483648),numberIsNaN(a=+a)&&(a=n?0:e.length-1),a<0&&(a=e.length+a),a>=e.length){if(n)return-1;a=e.length-1}else if(a<0){if(!n)return-1;a=0}if("string"==typeof t&&(t=Buffer.from(t,r)),Buffer.isBuffer(t))return 0===t.length?-1:arrayIndexOf(e,t,a,r,n);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,a):Uint8Array.prototype.lastIndexOf.call(e,t,a):arrayIndexOf(e,[t],a,r,n);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(e,t,a,r,n){var c,o=1,d=e.length,s=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;o=2,d/=2,s/=2,a/=2}function read(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(n){var b=-1;for(c=a;cd&&(a=d-s),c=a;c>=0;c--){for(var u=!0,h=0;hn&&(r=n):r=n;var c=t.length;r>c/2&&(r=c/2);for(var o=0;o>8,n=a%256,c.push(n),c.push(r);return c}(t,e.length-a),e,a,r)}function base64Slice(e,t,a){return 0===t&&a===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,a))}function utf8Slice(e,t,a){a=Math.min(e.length,a);for(var r=[],n=t;n239?4:u>223?3:u>191?2:1;if(n+l<=a)switch(l){case 1:u<128&&(h=u);break;case 2:128==(192&(c=e[n+1]))&&(b=(31&u)<<6|63&c)>127&&(h=b);break;case 3:c=e[n+1],o=e[n+2],128==(192&c)&&128==(192&o)&&(b=(15&u)<<12|(63&c)<<6|63&o)>2047&&(b<55296||b>57343)&&(h=b);break;case 4:c=e[n+1],o=e[n+2],s=e[n+3],128==(192&c)&&128==(192&o)&&128==(192&s)&&(b=(15&u)<<18|(63&c)<<12|(63&o)<<6|63&s)>65535&&b<1114112&&(h=b)}null===h?(h=65533,l=1):h>65535&&(h-=65536,r.push(h>>>10&1023|55296),h=56320|1023&h),r.push(h),n+=l}return function decodeCodePointsArray(e){var t=e.length;if(t<=d)return String.fromCharCode.apply(String,e);var a="",r=0;for(;rr.length?Buffer.from(c).copy(r,n):Uint8Array.prototype.set.call(r,c,n);else{if(!Buffer.isBuffer(c))throw new TypeError('"list" argument must be an Array of Buffers');c.copy(r,n)}n+=c.length}return r},Buffer.byteLength=byteLength,Buffer.prototype._isBuffer=!0,Buffer.prototype.swap16=function swap16(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;ta&&(e+=" ... "),""},c&&(Buffer.prototype[c]=Buffer.prototype.inspect),Buffer.prototype.compare=function compare(e,t,a,r,n){if(isInstance(e,Uint8Array)&&(e=Buffer.from(e,e.offset,e.byteLength)),!Buffer.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===a&&(a=e?e.length:0),void 0===r&&(r=0),void 0===n&&(n=this.length),t<0||a>e.length||r<0||n>this.length)throw new RangeError("out of range index");if(r>=n&&t>=a)return 0;if(r>=n)return-1;if(t>=a)return 1;if(this===e)return 0;for(var c=(n>>>=0)-(r>>>=0),o=(a>>>=0)-(t>>>=0),d=Math.min(c,o),s=this.slice(r,n),b=e.slice(t,a),u=0;u>>=0,isFinite(a)?(a>>>=0,void 0===r&&(r="utf8")):(r=a,a=void 0)}var n=this.length-t;if((void 0===a||a>n)&&(a=n),e.length>0&&(a<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var c=!1;;)switch(r){case"hex":return hexWrite(this,e,t,a);case"utf8":case"utf-8":return utf8Write(this,e,t,a);case"ascii":case"latin1":case"binary":return asciiWrite(this,e,t,a);case"base64":return base64Write(this,e,t,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,e,t,a);default:if(c)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),c=!0}},Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var d=4096;function asciiSlice(e,t,a){var r="";a=Math.min(e.length,a);for(var n=t;nr)&&(a=r);for(var n="",c=t;ca)throw new RangeError("Trying to access beyond buffer length")}function checkInt(e,t,a,r,n,c){if(!Buffer.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||te.length)throw new RangeError("Index out of range")}function checkIEEE754(e,t,a,r,n,c){if(a+r>e.length)throw new RangeError("Index out of range");if(a<0)throw new RangeError("Index out of range")}function writeFloat(e,t,a,r,c){return t=+t,a>>>=0,c||checkIEEE754(e,0,a,4),n.write(e,t,a,r,23,4),a+4}function writeDouble(e,t,a,r,c){return t=+t,a>>>=0,c||checkIEEE754(e,0,a,8),n.write(e,t,a,r,52,8),a+8}Buffer.prototype.slice=function slice(e,t){var a=this.length;(e=~~e)<0?(e+=a)<0&&(e=0):e>a&&(e=a),(t=void 0===t?a:~~t)<0?(t+=a)<0&&(t=0):t>a&&(t=a),t>>=0,t>>>=0,a||checkOffset(e,t,this.length);for(var r=this[e],n=1,c=0;++c>>=0,t>>>=0,a||checkOffset(e,t,this.length);for(var r=this[e+--t],n=1;t>0&&(n*=256);)r+=this[e+--t]*n;return r},Buffer.prototype.readUint8=Buffer.prototype.readUInt8=function readUInt8(e,t){return e>>>=0,t||checkOffset(e,1,this.length),this[e]},Buffer.prototype.readUint16LE=Buffer.prototype.readUInt16LE=function readUInt16LE(e,t){return e>>>=0,t||checkOffset(e,2,this.length),this[e]|this[e+1]<<8},Buffer.prototype.readUint16BE=Buffer.prototype.readUInt16BE=function readUInt16BE(e,t){return e>>>=0,t||checkOffset(e,2,this.length),this[e]<<8|this[e+1]},Buffer.prototype.readUint32LE=Buffer.prototype.readUInt32LE=function readUInt32LE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Buffer.prototype.readUint32BE=Buffer.prototype.readUInt32BE=function readUInt32BE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Buffer.prototype.readIntLE=function readIntLE(e,t,a){e>>>=0,t>>>=0,a||checkOffset(e,t,this.length);for(var r=this[e],n=1,c=0;++c=(n*=128)&&(r-=Math.pow(2,8*t)),r},Buffer.prototype.readIntBE=function readIntBE(e,t,a){e>>>=0,t>>>=0,a||checkOffset(e,t,this.length);for(var r=t,n=1,c=this[e+--r];r>0&&(n*=256);)c+=this[e+--r]*n;return c>=(n*=128)&&(c-=Math.pow(2,8*t)),c},Buffer.prototype.readInt8=function readInt8(e,t){return e>>>=0,t||checkOffset(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Buffer.prototype.readInt16LE=function readInt16LE(e,t){e>>>=0,t||checkOffset(e,2,this.length);var a=this[e]|this[e+1]<<8;return 32768&a?4294901760|a:a},Buffer.prototype.readInt16BE=function readInt16BE(e,t){e>>>=0,t||checkOffset(e,2,this.length);var a=this[e+1]|this[e]<<8;return 32768&a?4294901760|a:a},Buffer.prototype.readInt32LE=function readInt32LE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Buffer.prototype.readInt32BE=function readInt32BE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Buffer.prototype.readFloatLE=function readFloatLE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),n.read(this,e,!0,23,4)},Buffer.prototype.readFloatBE=function readFloatBE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),n.read(this,e,!1,23,4)},Buffer.prototype.readDoubleLE=function readDoubleLE(e,t){return e>>>=0,t||checkOffset(e,8,this.length),n.read(this,e,!0,52,8)},Buffer.prototype.readDoubleBE=function readDoubleBE(e,t){return e>>>=0,t||checkOffset(e,8,this.length),n.read(this,e,!1,52,8)},Buffer.prototype.writeUintLE=Buffer.prototype.writeUIntLE=function writeUIntLE(e,t,a,r){(e=+e,t>>>=0,a>>>=0,r)||checkInt(this,e,t,a,Math.pow(2,8*a)-1,0);var n=1,c=0;for(this[t]=255&e;++c>>=0,a>>>=0,r)||checkInt(this,e,t,a,Math.pow(2,8*a)-1,0);var n=a-1,c=1;for(this[t+n]=255&e;--n>=0&&(c*=256);)this[t+n]=e/c&255;return t+a},Buffer.prototype.writeUint8=Buffer.prototype.writeUInt8=function writeUInt8(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,1,255,0),this[t]=255&e,t+1},Buffer.prototype.writeUint16LE=Buffer.prototype.writeUInt16LE=function writeUInt16LE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeUint16BE=Buffer.prototype.writeUInt16BE=function writeUInt16BE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeUint32LE=Buffer.prototype.writeUInt32LE=function writeUInt32LE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},Buffer.prototype.writeUint32BE=Buffer.prototype.writeUInt32BE=function writeUInt32BE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeIntLE=function writeIntLE(e,t,a,r){if(e=+e,t>>>=0,!r){var n=Math.pow(2,8*a-1);checkInt(this,e,t,a,n-1,-n)}var c=0,o=1,d=0;for(this[t]=255&e;++c>0)-d&255;return t+a},Buffer.prototype.writeIntBE=function writeIntBE(e,t,a,r){if(e=+e,t>>>=0,!r){var n=Math.pow(2,8*a-1);checkInt(this,e,t,a,n-1,-n)}var c=a-1,o=1,d=0;for(this[t+c]=255&e;--c>=0&&(o*=256);)e<0&&0===d&&0!==this[t+c+1]&&(d=1),this[t+c]=(e/o>>0)-d&255;return t+a},Buffer.prototype.writeInt8=function writeInt8(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},Buffer.prototype.writeInt16LE=function writeInt16LE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeInt16BE=function writeInt16BE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeInt32LE=function writeInt32LE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},Buffer.prototype.writeInt32BE=function writeInt32BE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeFloatLE=function writeFloatLE(e,t,a){return writeFloat(this,e,t,!0,a)},Buffer.prototype.writeFloatBE=function writeFloatBE(e,t,a){return writeFloat(this,e,t,!1,a)},Buffer.prototype.writeDoubleLE=function writeDoubleLE(e,t,a){return writeDouble(this,e,t,!0,a)},Buffer.prototype.writeDoubleBE=function writeDoubleBE(e,t,a){return writeDouble(this,e,t,!1,a)},Buffer.prototype.copy=function copy(e,t,a,r){if(!Buffer.isBuffer(e))throw new TypeError("argument should be a Buffer");if(a||(a=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t>>=0,a=void 0===a?this.length:a>>>0,e||(e=0),"number"==typeof e)for(c=t;c55295&&a<57344){if(!n){if(a>56319){(t-=3)>-1&&c.push(239,191,189);continue}if(o+1===r){(t-=3)>-1&&c.push(239,191,189);continue}n=a;continue}if(a<56320){(t-=3)>-1&&c.push(239,191,189),n=a;continue}a=65536+(n-55296<<10|a-56320)}else n&&(t-=3)>-1&&c.push(239,191,189);if(n=null,a<128){if((t-=1)<0)break;c.push(a)}else if(a<2048){if((t-=2)<0)break;c.push(a>>6|192,63&a|128)}else if(a<65536){if((t-=3)<0)break;c.push(a>>12|224,a>>6&63|128,63&a|128)}else{if(!(a<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;c.push(a>>18|240,a>>12&63|128,a>>6&63|128,63&a|128)}}return c}function base64ToBytes(e){return r.toByteArray(function base64clean(e){if((e=(e=e.split("=")[0]).trim().replace(s,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function blitBuffer(e,t,a,r){for(var n=0;n=t.length||n>=e.length);++n)t[n+a]=e[n];return n}function isInstance(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function numberIsNaN(e){return e!=e}var b=function(){for(var e="0123456789abcdef",t=new Array(256),a=0;a<16;++a)for(var r=16*a,n=0;n<16;++n)t[r+n]=e[a]+e[n];return t}()},function(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[a]}})}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||r(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),t.isHexString=t.getKeys=t.fromAscii=t.fromUtf8=t.toAscii=t.arrayContainsArray=t.getBinarySize=t.padToEven=t.stripHexPrefix=t.isHexPrefixed=void 0,n(a(317),t),n(a(296),t),n(a(680),t),n(a(191),t),n(a(1425),t),n(a(77),t),n(a(681),t),n(a(56),t),n(a(246),t);var c=a(122);Object.defineProperty(t,"isHexPrefixed",{enumerable:!0,get:function(){return c.isHexPrefixed}}),Object.defineProperty(t,"stripHexPrefix",{enumerable:!0,get:function(){return c.stripHexPrefix}}),Object.defineProperty(t,"padToEven",{enumerable:!0,get:function(){return c.padToEven}}),Object.defineProperty(t,"getBinarySize",{enumerable:!0,get:function(){return c.getBinarySize}}),Object.defineProperty(t,"arrayContainsArray",{enumerable:!0,get:function(){return c.arrayContainsArray}}),Object.defineProperty(t,"toAscii",{enumerable:!0,get:function(){return c.toAscii}}),Object.defineProperty(t,"fromUtf8",{enumerable:!0,get:function(){return c.fromUtf8}}),Object.defineProperty(t,"fromAscii",{enumerable:!0,get:function(){return c.fromAscii}}),Object.defineProperty(t,"getKeys",{enumerable:!0,get:function(){return c.getKeys}}),Object.defineProperty(t,"isHexString",{enumerable:!0,get:function(){return c.isHexString}})},(e,t,a)=>{"use strict";const r=a(1249),n=a(1250),c="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=Buffer,t.SlowBuffer=function SlowBuffer(e){+e!=e&&(e=0);return Buffer.alloc(+e)},t.INSPECT_MAX_BYTES=50;const o=2147483647;function createBuffer(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,Buffer.prototype),t}function Buffer(e,t,a){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return allocUnsafe(e)}return from(e,t,a)}function from(e,t,a){if("string"==typeof e)return function fromString(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!Buffer.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const a=0|byteLength(e,t);let r=createBuffer(a);const n=r.write(e,t);n!==a&&(r=r.slice(0,n));return r}(e,t);if(ArrayBuffer.isView(e))return function fromArrayView(e){if(isInstance(e,Uint8Array)){const t=new Uint8Array(e);return fromArrayBuffer(t.buffer,t.byteOffset,t.byteLength)}return fromArrayLike(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(isInstance(e,ArrayBuffer)||e&&isInstance(e.buffer,ArrayBuffer))return fromArrayBuffer(e,t,a);if("undefined"!=typeof SharedArrayBuffer&&(isInstance(e,SharedArrayBuffer)||e&&isInstance(e.buffer,SharedArrayBuffer)))return fromArrayBuffer(e,t,a);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const r=e.valueOf&&e.valueOf();if(null!=r&&r!==e)return Buffer.from(r,t,a);const n=function fromObject(e){if(Buffer.isBuffer(e)){const t=0|checked(e.length),a=createBuffer(t);return 0===a.length||e.copy(a,0,0,t),a}if(void 0!==e.length)return"number"!=typeof e.length||numberIsNaN(e.length)?createBuffer(0):fromArrayLike(e);if("Buffer"===e.type&&Array.isArray(e.data))return fromArrayLike(e.data)}(e);if(n)return n;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return Buffer.from(e[Symbol.toPrimitive]("string"),t,a);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function assertSize(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function allocUnsafe(e){return assertSize(e),createBuffer(e<0?0:0|checked(e))}function fromArrayLike(e){const t=e.length<0?0:0|checked(e.length),a=createBuffer(t);for(let r=0;r=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function byteLength(e,t){if(Buffer.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||isInstance(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const a=e.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===a)return 0;let n=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return a;case"utf8":case"utf-8":return utf8ToBytes(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*a;case"hex":return a>>>1;case"base64":return base64ToBytes(e).length;default:if(n)return r?-1:utf8ToBytes(e).length;t=(""+t).toLowerCase(),n=!0}}function slowToString(e,t,a){let r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===a||a>this.length)&&(a=this.length),a<=0)return"";if((a>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return hexSlice(this,t,a);case"utf8":case"utf-8":return utf8Slice(this,t,a);case"ascii":return asciiSlice(this,t,a);case"latin1":case"binary":return latin1Slice(this,t,a);case"base64":return base64Slice(this,t,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,t,a);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function swap(e,t,a){const r=e[t];e[t]=e[a],e[a]=r}function bidirectionalIndexOf(e,t,a,r,n){if(0===e.length)return-1;if("string"==typeof a?(r=a,a=0):a>2147483647?a=2147483647:a<-2147483648&&(a=-2147483648),numberIsNaN(a=+a)&&(a=n?0:e.length-1),a<0&&(a=e.length+a),a>=e.length){if(n)return-1;a=e.length-1}else if(a<0){if(!n)return-1;a=0}if("string"==typeof t&&(t=Buffer.from(t,r)),Buffer.isBuffer(t))return 0===t.length?-1:arrayIndexOf(e,t,a,r,n);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,a):Uint8Array.prototype.lastIndexOf.call(e,t,a):arrayIndexOf(e,[t],a,r,n);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(e,t,a,r,n){let c,o=1,d=e.length,s=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;o=2,d/=2,s/=2,a/=2}function read(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(n){let r=-1;for(c=a;cd&&(a=d-s),c=a;c>=0;c--){let a=!0;for(let r=0;rn&&(r=n):r=n;const c=t.length;let o;for(r>c/2&&(r=c/2),o=0;o>8,n=a%256,c.push(n),c.push(r);return c}(t,e.length-a),e,a,r)}function base64Slice(e,t,a){return 0===t&&a===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,a))}function utf8Slice(e,t,a){a=Math.min(e.length,a);const r=[];let n=t;for(;n239?4:t>223?3:t>191?2:1;if(n+o<=a){let a,r,d,s;switch(o){case 1:t<128&&(c=t);break;case 2:a=e[n+1],128==(192&a)&&(s=(31&t)<<6|63&a,s>127&&(c=s));break;case 3:a=e[n+1],r=e[n+2],128==(192&a)&&128==(192&r)&&(s=(15&t)<<12|(63&a)<<6|63&r,s>2047&&(s<55296||s>57343)&&(c=s));break;case 4:a=e[n+1],r=e[n+2],d=e[n+3],128==(192&a)&&128==(192&r)&&128==(192&d)&&(s=(15&t)<<18|(63&a)<<12|(63&r)<<6|63&d,s>65535&&s<1114112&&(c=s))}}null===c?(c=65533,o=1):c>65535&&(c-=65536,r.push(c>>>10&1023|55296),c=56320|1023&c),r.push(c),n+=o}return function decodeCodePointsArray(e){const t=e.length;if(t<=d)return String.fromCharCode.apply(String,e);let a="",r=0;for(;rr.length?(Buffer.isBuffer(t)||(t=Buffer.from(t)),t.copy(r,n)):Uint8Array.prototype.set.call(r,t,n);else{if(!Buffer.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(r,n)}n+=t.length}return r},Buffer.byteLength=byteLength,Buffer.prototype._isBuffer=!0,Buffer.prototype.swap16=function swap16(){const e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;ta&&(e+=" ... "),""},c&&(Buffer.prototype[c]=Buffer.prototype.inspect),Buffer.prototype.compare=function compare(e,t,a,r,n){if(isInstance(e,Uint8Array)&&(e=Buffer.from(e,e.offset,e.byteLength)),!Buffer.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===a&&(a=e?e.length:0),void 0===r&&(r=0),void 0===n&&(n=this.length),t<0||a>e.length||r<0||n>this.length)throw new RangeError("out of range index");if(r>=n&&t>=a)return 0;if(r>=n)return-1;if(t>=a)return 1;if(this===e)return 0;let c=(n>>>=0)-(r>>>=0),o=(a>>>=0)-(t>>>=0);const d=Math.min(c,o),s=this.slice(r,n),b=e.slice(t,a);for(let e=0;e>>=0,isFinite(a)?(a>>>=0,void 0===r&&(r="utf8")):(r=a,a=void 0)}const n=this.length-t;if((void 0===a||a>n)&&(a=n),e.length>0&&(a<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let c=!1;for(;;)switch(r){case"hex":return hexWrite(this,e,t,a);case"utf8":case"utf-8":return utf8Write(this,e,t,a);case"ascii":case"latin1":case"binary":return asciiWrite(this,e,t,a);case"base64":return base64Write(this,e,t,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,e,t,a);default:if(c)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),c=!0}},Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const d=4096;function asciiSlice(e,t,a){let r="";a=Math.min(e.length,a);for(let n=t;nr)&&(a=r);let n="";for(let r=t;ra)throw new RangeError("Trying to access beyond buffer length")}function checkInt(e,t,a,r,n,c){if(!Buffer.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||te.length)throw new RangeError("Index out of range")}function wrtBigUInt64LE(e,t,a,r,n){checkIntBI(t,r,n,e,a,7);let c=Number(t&BigInt(4294967295));e[a++]=c,c>>=8,e[a++]=c,c>>=8,e[a++]=c,c>>=8,e[a++]=c;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[a++]=o,o>>=8,e[a++]=o,o>>=8,e[a++]=o,o>>=8,e[a++]=o,a}function wrtBigUInt64BE(e,t,a,r,n){checkIntBI(t,r,n,e,a,7);let c=Number(t&BigInt(4294967295));e[a+7]=c,c>>=8,e[a+6]=c,c>>=8,e[a+5]=c,c>>=8,e[a+4]=c;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[a+3]=o,o>>=8,e[a+2]=o,o>>=8,e[a+1]=o,o>>=8,e[a]=o,a+8}function checkIEEE754(e,t,a,r,n,c){if(a+r>e.length)throw new RangeError("Index out of range");if(a<0)throw new RangeError("Index out of range")}function writeFloat(e,t,a,r,c){return t=+t,a>>>=0,c||checkIEEE754(e,0,a,4),n.write(e,t,a,r,23,4),a+4}function writeDouble(e,t,a,r,c){return t=+t,a>>>=0,c||checkIEEE754(e,0,a,8),n.write(e,t,a,r,52,8),a+8}Buffer.prototype.slice=function slice(e,t){const a=this.length;(e=~~e)<0?(e+=a)<0&&(e=0):e>a&&(e=a),(t=void 0===t?a:~~t)<0?(t+=a)<0&&(t=0):t>a&&(t=a),t>>=0,t>>>=0,a||checkOffset(e,t,this.length);let r=this[e],n=1,c=0;for(;++c>>=0,t>>>=0,a||checkOffset(e,t,this.length);let r=this[e+--t],n=1;for(;t>0&&(n*=256);)r+=this[e+--t]*n;return r},Buffer.prototype.readUint8=Buffer.prototype.readUInt8=function readUInt8(e,t){return e>>>=0,t||checkOffset(e,1,this.length),this[e]},Buffer.prototype.readUint16LE=Buffer.prototype.readUInt16LE=function readUInt16LE(e,t){return e>>>=0,t||checkOffset(e,2,this.length),this[e]|this[e+1]<<8},Buffer.prototype.readUint16BE=Buffer.prototype.readUInt16BE=function readUInt16BE(e,t){return e>>>=0,t||checkOffset(e,2,this.length),this[e]<<8|this[e+1]},Buffer.prototype.readUint32LE=Buffer.prototype.readUInt32LE=function readUInt32LE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Buffer.prototype.readUint32BE=Buffer.prototype.readUInt32BE=function readUInt32BE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Buffer.prototype.readBigUInt64LE=defineBigIntMethod((function readBigUInt64LE(e){validateNumber(e>>>=0,"offset");const t=this[e],a=this[e+7];void 0!==t&&void 0!==a||boundsError(e,this.length-8);const r=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,n=this[++e]+256*this[++e]+65536*this[++e]+a*2**24;return BigInt(r)+(BigInt(n)<>>=0,"offset");const t=this[e],a=this[e+7];void 0!==t&&void 0!==a||boundsError(e,this.length-8);const r=t*2**24+65536*this[++e]+256*this[++e]+this[++e],n=this[++e]*2**24+65536*this[++e]+256*this[++e]+a;return(BigInt(r)<>>=0,t>>>=0,a||checkOffset(e,t,this.length);let r=this[e],n=1,c=0;for(;++c=n&&(r-=Math.pow(2,8*t)),r},Buffer.prototype.readIntBE=function readIntBE(e,t,a){e>>>=0,t>>>=0,a||checkOffset(e,t,this.length);let r=t,n=1,c=this[e+--r];for(;r>0&&(n*=256);)c+=this[e+--r]*n;return n*=128,c>=n&&(c-=Math.pow(2,8*t)),c},Buffer.prototype.readInt8=function readInt8(e,t){return e>>>=0,t||checkOffset(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Buffer.prototype.readInt16LE=function readInt16LE(e,t){e>>>=0,t||checkOffset(e,2,this.length);const a=this[e]|this[e+1]<<8;return 32768&a?4294901760|a:a},Buffer.prototype.readInt16BE=function readInt16BE(e,t){e>>>=0,t||checkOffset(e,2,this.length);const a=this[e+1]|this[e]<<8;return 32768&a?4294901760|a:a},Buffer.prototype.readInt32LE=function readInt32LE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Buffer.prototype.readInt32BE=function readInt32BE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Buffer.prototype.readBigInt64LE=defineBigIntMethod((function readBigInt64LE(e){validateNumber(e>>>=0,"offset");const t=this[e],a=this[e+7];void 0!==t&&void 0!==a||boundsError(e,this.length-8);const r=this[e+4]+256*this[e+5]+65536*this[e+6]+(a<<24);return(BigInt(r)<>>=0,"offset");const t=this[e],a=this[e+7];void 0!==t&&void 0!==a||boundsError(e,this.length-8);const r=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(r)<>>=0,t||checkOffset(e,4,this.length),n.read(this,e,!0,23,4)},Buffer.prototype.readFloatBE=function readFloatBE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),n.read(this,e,!1,23,4)},Buffer.prototype.readDoubleLE=function readDoubleLE(e,t){return e>>>=0,t||checkOffset(e,8,this.length),n.read(this,e,!0,52,8)},Buffer.prototype.readDoubleBE=function readDoubleBE(e,t){return e>>>=0,t||checkOffset(e,8,this.length),n.read(this,e,!1,52,8)},Buffer.prototype.writeUintLE=Buffer.prototype.writeUIntLE=function writeUIntLE(e,t,a,r){if(e=+e,t>>>=0,a>>>=0,!r){checkInt(this,e,t,a,Math.pow(2,8*a)-1,0)}let n=1,c=0;for(this[t]=255&e;++c>>=0,a>>>=0,!r){checkInt(this,e,t,a,Math.pow(2,8*a)-1,0)}let n=a-1,c=1;for(this[t+n]=255&e;--n>=0&&(c*=256);)this[t+n]=e/c&255;return t+a},Buffer.prototype.writeUint8=Buffer.prototype.writeUInt8=function writeUInt8(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,1,255,0),this[t]=255&e,t+1},Buffer.prototype.writeUint16LE=Buffer.prototype.writeUInt16LE=function writeUInt16LE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeUint16BE=Buffer.prototype.writeUInt16BE=function writeUInt16BE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeUint32LE=Buffer.prototype.writeUInt32LE=function writeUInt32LE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},Buffer.prototype.writeUint32BE=Buffer.prototype.writeUInt32BE=function writeUInt32BE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeBigUInt64LE=defineBigIntMethod((function writeBigUInt64LE(e,t=0){return wrtBigUInt64LE(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),Buffer.prototype.writeBigUInt64BE=defineBigIntMethod((function writeBigUInt64BE(e,t=0){return wrtBigUInt64BE(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),Buffer.prototype.writeIntLE=function writeIntLE(e,t,a,r){if(e=+e,t>>>=0,!r){const r=Math.pow(2,8*a-1);checkInt(this,e,t,a,r-1,-r)}let n=0,c=1,o=0;for(this[t]=255&e;++n>0)-o&255;return t+a},Buffer.prototype.writeIntBE=function writeIntBE(e,t,a,r){if(e=+e,t>>>=0,!r){const r=Math.pow(2,8*a-1);checkInt(this,e,t,a,r-1,-r)}let n=a-1,c=1,o=0;for(this[t+n]=255&e;--n>=0&&(c*=256);)e<0&&0===o&&0!==this[t+n+1]&&(o=1),this[t+n]=(e/c>>0)-o&255;return t+a},Buffer.prototype.writeInt8=function writeInt8(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},Buffer.prototype.writeInt16LE=function writeInt16LE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeInt16BE=function writeInt16BE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeInt32LE=function writeInt32LE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},Buffer.prototype.writeInt32BE=function writeInt32BE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeBigInt64LE=defineBigIntMethod((function writeBigInt64LE(e,t=0){return wrtBigUInt64LE(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),Buffer.prototype.writeBigInt64BE=defineBigIntMethod((function writeBigInt64BE(e,t=0){return wrtBigUInt64BE(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),Buffer.prototype.writeFloatLE=function writeFloatLE(e,t,a){return writeFloat(this,e,t,!0,a)},Buffer.prototype.writeFloatBE=function writeFloatBE(e,t,a){return writeFloat(this,e,t,!1,a)},Buffer.prototype.writeDoubleLE=function writeDoubleLE(e,t,a){return writeDouble(this,e,t,!0,a)},Buffer.prototype.writeDoubleBE=function writeDoubleBE(e,t,a){return writeDouble(this,e,t,!1,a)},Buffer.prototype.copy=function copy(e,t,a,r){if(!Buffer.isBuffer(e))throw new TypeError("argument should be a Buffer");if(a||(a=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t>>=0,a=void 0===a?this.length:a>>>0,e||(e=0),"number"==typeof e)for(n=t;n=r+4;a-=3)t=`_${e.slice(a-3,a)}${t}`;return`${e.slice(0,a)}${t}`}function checkIntBI(e,t,a,r,n,c){if(e>a||e3?0===t||t===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(c+1)}${r}`:`>= -(2${r} ** ${8*(c+1)-1}${r}) and < 2 ** ${8*(c+1)-1}${r}`:`>= ${t}${r} and <= ${a}${r}`,new s.ERR_OUT_OF_RANGE("value",n,e)}!function checkBounds(e,t,a){validateNumber(t,"offset"),void 0!==e[t]&&void 0!==e[t+a]||boundsError(t,e.length-(a+1))}(r,n,c)}function validateNumber(e,t){if("number"!=typeof e)throw new s.ERR_INVALID_ARG_TYPE(t,"number",e)}function boundsError(e,t,a){if(Math.floor(e)!==e)throw validateNumber(e,a),new s.ERR_OUT_OF_RANGE(a||"offset","an integer",e);if(t<0)throw new s.ERR_BUFFER_OUT_OF_BOUNDS;throw new s.ERR_OUT_OF_RANGE(a||"offset",`>= ${a?1:0} and <= ${t}`,e)}E("ERR_BUFFER_OUT_OF_BOUNDS",(function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),E("ERR_INVALID_ARG_TYPE",(function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`}),TypeError),E("ERR_OUT_OF_RANGE",(function(e,t,a){let r=`The value of "${e}" is out of range.`,n=a;return Number.isInteger(a)&&Math.abs(a)>2**32?n=addNumericalSeparator(String(a)):"bigint"==typeof a&&(n=String(a),(a>BigInt(2)**BigInt(32)||a<-(BigInt(2)**BigInt(32)))&&(n=addNumericalSeparator(n)),n+="n"),r+=` It must be ${t}. Received ${n}`,r}),RangeError);const b=/[^+/0-9A-Za-z-_]/g;function utf8ToBytes(e,t){let a;t=t||1/0;const r=e.length;let n=null;const c=[];for(let o=0;o55295&&a<57344){if(!n){if(a>56319){(t-=3)>-1&&c.push(239,191,189);continue}if(o+1===r){(t-=3)>-1&&c.push(239,191,189);continue}n=a;continue}if(a<56320){(t-=3)>-1&&c.push(239,191,189),n=a;continue}a=65536+(n-55296<<10|a-56320)}else n&&(t-=3)>-1&&c.push(239,191,189);if(n=null,a<128){if((t-=1)<0)break;c.push(a)}else if(a<2048){if((t-=2)<0)break;c.push(a>>6|192,63&a|128)}else if(a<65536){if((t-=3)<0)break;c.push(a>>12|224,a>>6&63|128,63&a|128)}else{if(!(a<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;c.push(a>>18|240,a>>12&63|128,a>>6&63|128,63&a|128)}}return c}function base64ToBytes(e){return r.toByteArray(function base64clean(e){if((e=(e=e.split("=")[0]).trim().replace(b,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function blitBuffer(e,t,a,r){let n;for(n=0;n=t.length||n>=e.length);++n)t[n+a]=e[n];return n}function isInstance(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function numberIsNaN(e){return e!=e}const u=function(){const e="0123456789abcdef",t=new Array(256);for(let a=0;a<16;++a){const r=16*a;for(let n=0;n<16;++n)t[r+n]=e[a]+e[n]}return t}();function defineBigIntMethod(e){return"undefined"==typeof BigInt?BufferBigIntNotDefined:e}function BufferBigIntNotDefined(){throw new Error("BigInt not supported")}},(e,t,a)=>{"use strict";var r=a(5);function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function _typeof(e){return typeof e}:function _typeof(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}var n,c,o=a(825).codes,d=o.ERR_AMBIGUOUS_ARGUMENT,s=o.ERR_INVALID_ARG_TYPE,b=o.ERR_INVALID_ARG_VALUE,u=o.ERR_INVALID_RETURN_VALUE,h=o.ERR_MISSING_ARGS,l=a(834),g=a(89).inspect,p=a(89).types,B=p.isPromise,x=p.isRegExp,I=Object.assign?Object.assign:a(835).assign,m=Object.is?Object.is:a(372);new Map;function lazyLoadComparison(){var e=a(839);n=e.isDeepEqual,c=e.isDeepStrictEqual}var y=!1,C=e.exports=ok,w={};function innerFail(e){if(e.message instanceof Error)throw e.message;throw new l(e)}function innerOk(e,t,a,r){if(!a){var n=!1;if(0===t)n=!0,r="No value argument passed to `assert.ok()`";else if(r instanceof Error)throw r;var c=new l({actual:a,expected:!0,message:r,operator:"==",stackStartFn:e});throw c.generatedMessage=n,c}}function ok(){for(var e=arguments.length,t=new Array(e),a=0;a1?t-1:0),r=1;r1?t-1:0),r=1;r1?t-1:0),r=1;r1?t-1:0),r=1;r{var t,a,r=e.exports={};function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}function runTimeout(e){if(t===setTimeout)return setTimeout(e,0);if((t===defaultSetTimout||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(a){try{return t.call(null,e,0)}catch(a){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:defaultSetTimout}catch(e){t=defaultSetTimout}try{a="function"==typeof clearTimeout?clearTimeout:defaultClearTimeout}catch(e){a=defaultClearTimeout}}();var n,c=[],o=!1,d=-1;function cleanUpNextTick(){o&&n&&(o=!1,n.length?c=n.concat(c):d=-1,c.length&&drainQueue())}function drainQueue(){if(!o){var e=runTimeout(cleanUpNextTick);o=!0;for(var t=c.length;t;){for(n=c,c=[];++d1)for(var a=1;a{"function"==typeof Object.create?e.exports=function inherits(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function inherits(e,t){if(t){e.super_=t;var TempCtor=function(){};TempCtor.prototype=t.prototype,e.prototype=new TempCtor,e.prototype.constructor=e}}},(e,t,a)=>{var r=a(2),n=r.Buffer;function copyProps(e,t){for(var a in e)t[a]=e[a]}function SafeBuffer(e,t,a){return n(e,t,a)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(copyProps(r,t),t.Buffer=SafeBuffer),SafeBuffer.prototype=Object.create(n.prototype),copyProps(n,SafeBuffer),SafeBuffer.from=function(e,t,a){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,a)},SafeBuffer.alloc=function(e,t,a){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=n(e);return void 0!==t?"string"==typeof a?r.fill(t,a):r.fill(t):r.fill(0),r},SafeBuffer.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},SafeBuffer.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},(e,t,a)=>{"use strict";var r=a(1291),n=a(1292),c="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=Buffer,t.SlowBuffer=function SlowBuffer(e){+e!=e&&(e=0);return Buffer.alloc(+e)},t.INSPECT_MAX_BYTES=50;var o=2147483647;function createBuffer(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,Buffer.prototype),t}function Buffer(e,t,a){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return allocUnsafe(e)}return from(e,t,a)}function from(e,t,a){if("string"==typeof e)return function fromString(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!Buffer.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var a=0|byteLength(e,t),r=createBuffer(a),n=r.write(e,t);n!==a&&(r=r.slice(0,n));return r}(e,t);if(ArrayBuffer.isView(e))return function fromArrayView(e){if(isInstance(e,Uint8Array)){var t=new Uint8Array(e);return fromArrayBuffer(t.buffer,t.byteOffset,t.byteLength)}return fromArrayLike(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(isInstance(e,ArrayBuffer)||e&&isInstance(e.buffer,ArrayBuffer))return fromArrayBuffer(e,t,a);if("undefined"!=typeof SharedArrayBuffer&&(isInstance(e,SharedArrayBuffer)||e&&isInstance(e.buffer,SharedArrayBuffer)))return fromArrayBuffer(e,t,a);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var r=e.valueOf&&e.valueOf();if(null!=r&&r!==e)return Buffer.from(r,t,a);var n=function fromObject(e){if(Buffer.isBuffer(e)){var t=0|checked(e.length),a=createBuffer(t);return 0===a.length||e.copy(a,0,0,t),a}if(void 0!==e.length)return"number"!=typeof e.length||numberIsNaN(e.length)?createBuffer(0):fromArrayLike(e);if("Buffer"===e.type&&Array.isArray(e.data))return fromArrayLike(e.data)}(e);if(n)return n;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return Buffer.from(e[Symbol.toPrimitive]("string"),t,a);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function assertSize(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function allocUnsafe(e){return assertSize(e),createBuffer(e<0?0:0|checked(e))}function fromArrayLike(e){for(var t=e.length<0?0:0|checked(e.length),a=createBuffer(t),r=0;r=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function byteLength(e,t){if(Buffer.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||isInstance(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var a=e.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===a)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return a;case"utf8":case"utf-8":return utf8ToBytes(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*a;case"hex":return a>>>1;case"base64":return base64ToBytes(e).length;default:if(n)return r?-1:utf8ToBytes(e).length;t=(""+t).toLowerCase(),n=!0}}function slowToString(e,t,a){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===a||a>this.length)&&(a=this.length),a<=0)return"";if((a>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return hexSlice(this,t,a);case"utf8":case"utf-8":return utf8Slice(this,t,a);case"ascii":return asciiSlice(this,t,a);case"latin1":case"binary":return latin1Slice(this,t,a);case"base64":return base64Slice(this,t,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,t,a);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function swap(e,t,a){var r=e[t];e[t]=e[a],e[a]=r}function bidirectionalIndexOf(e,t,a,r,n){if(0===e.length)return-1;if("string"==typeof a?(r=a,a=0):a>2147483647?a=2147483647:a<-2147483648&&(a=-2147483648),numberIsNaN(a=+a)&&(a=n?0:e.length-1),a<0&&(a=e.length+a),a>=e.length){if(n)return-1;a=e.length-1}else if(a<0){if(!n)return-1;a=0}if("string"==typeof t&&(t=Buffer.from(t,r)),Buffer.isBuffer(t))return 0===t.length?-1:arrayIndexOf(e,t,a,r,n);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,a):Uint8Array.prototype.lastIndexOf.call(e,t,a):arrayIndexOf(e,[t],a,r,n);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(e,t,a,r,n){var c,o=1,d=e.length,s=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;o=2,d/=2,s/=2,a/=2}function read(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(n){var b=-1;for(c=a;cd&&(a=d-s),c=a;c>=0;c--){for(var u=!0,h=0;hn&&(r=n):r=n;var c=t.length;r>c/2&&(r=c/2);for(var o=0;o>8,n=a%256,c.push(n),c.push(r);return c}(t,e.length-a),e,a,r)}function base64Slice(e,t,a){return 0===t&&a===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,a))}function utf8Slice(e,t,a){a=Math.min(e.length,a);for(var r=[],n=t;n239?4:u>223?3:u>191?2:1;if(n+l<=a)switch(l){case 1:u<128&&(h=u);break;case 2:128==(192&(c=e[n+1]))&&(b=(31&u)<<6|63&c)>127&&(h=b);break;case 3:c=e[n+1],o=e[n+2],128==(192&c)&&128==(192&o)&&(b=(15&u)<<12|(63&c)<<6|63&o)>2047&&(b<55296||b>57343)&&(h=b);break;case 4:c=e[n+1],o=e[n+2],s=e[n+3],128==(192&c)&&128==(192&o)&&128==(192&s)&&(b=(15&u)<<18|(63&c)<<12|(63&o)<<6|63&s)>65535&&b<1114112&&(h=b)}null===h?(h=65533,l=1):h>65535&&(h-=65536,r.push(h>>>10&1023|55296),h=56320|1023&h),r.push(h),n+=l}return function decodeCodePointsArray(e){var t=e.length;if(t<=d)return String.fromCharCode.apply(String,e);var a="",r=0;for(;rr.length?Buffer.from(c).copy(r,n):Uint8Array.prototype.set.call(r,c,n);else{if(!Buffer.isBuffer(c))throw new TypeError('"list" argument must be an Array of Buffers');c.copy(r,n)}n+=c.length}return r},Buffer.byteLength=byteLength,Buffer.prototype._isBuffer=!0,Buffer.prototype.swap16=function swap16(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;ta&&(e+=" ... "),""},c&&(Buffer.prototype[c]=Buffer.prototype.inspect),Buffer.prototype.compare=function compare(e,t,a,r,n){if(isInstance(e,Uint8Array)&&(e=Buffer.from(e,e.offset,e.byteLength)),!Buffer.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===a&&(a=e?e.length:0),void 0===r&&(r=0),void 0===n&&(n=this.length),t<0||a>e.length||r<0||n>this.length)throw new RangeError("out of range index");if(r>=n&&t>=a)return 0;if(r>=n)return-1;if(t>=a)return 1;if(this===e)return 0;for(var c=(n>>>=0)-(r>>>=0),o=(a>>>=0)-(t>>>=0),d=Math.min(c,o),s=this.slice(r,n),b=e.slice(t,a),u=0;u>>=0,isFinite(a)?(a>>>=0,void 0===r&&(r="utf8")):(r=a,a=void 0)}var n=this.length-t;if((void 0===a||a>n)&&(a=n),e.length>0&&(a<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var c=!1;;)switch(r){case"hex":return hexWrite(this,e,t,a);case"utf8":case"utf-8":return utf8Write(this,e,t,a);case"ascii":case"latin1":case"binary":return asciiWrite(this,e,t,a);case"base64":return base64Write(this,e,t,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,e,t,a);default:if(c)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),c=!0}},Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var d=4096;function asciiSlice(e,t,a){var r="";a=Math.min(e.length,a);for(var n=t;nr)&&(a=r);for(var n="",c=t;ca)throw new RangeError("Trying to access beyond buffer length")}function checkInt(e,t,a,r,n,c){if(!Buffer.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||te.length)throw new RangeError("Index out of range")}function checkIEEE754(e,t,a,r,n,c){if(a+r>e.length)throw new RangeError("Index out of range");if(a<0)throw new RangeError("Index out of range")}function writeFloat(e,t,a,r,c){return t=+t,a>>>=0,c||checkIEEE754(e,0,a,4),n.write(e,t,a,r,23,4),a+4}function writeDouble(e,t,a,r,c){return t=+t,a>>>=0,c||checkIEEE754(e,0,a,8),n.write(e,t,a,r,52,8),a+8}Buffer.prototype.slice=function slice(e,t){var a=this.length;(e=~~e)<0?(e+=a)<0&&(e=0):e>a&&(e=a),(t=void 0===t?a:~~t)<0?(t+=a)<0&&(t=0):t>a&&(t=a),t>>=0,t>>>=0,a||checkOffset(e,t,this.length);for(var r=this[e],n=1,c=0;++c>>=0,t>>>=0,a||checkOffset(e,t,this.length);for(var r=this[e+--t],n=1;t>0&&(n*=256);)r+=this[e+--t]*n;return r},Buffer.prototype.readUint8=Buffer.prototype.readUInt8=function readUInt8(e,t){return e>>>=0,t||checkOffset(e,1,this.length),this[e]},Buffer.prototype.readUint16LE=Buffer.prototype.readUInt16LE=function readUInt16LE(e,t){return e>>>=0,t||checkOffset(e,2,this.length),this[e]|this[e+1]<<8},Buffer.prototype.readUint16BE=Buffer.prototype.readUInt16BE=function readUInt16BE(e,t){return e>>>=0,t||checkOffset(e,2,this.length),this[e]<<8|this[e+1]},Buffer.prototype.readUint32LE=Buffer.prototype.readUInt32LE=function readUInt32LE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Buffer.prototype.readUint32BE=Buffer.prototype.readUInt32BE=function readUInt32BE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Buffer.prototype.readIntLE=function readIntLE(e,t,a){e>>>=0,t>>>=0,a||checkOffset(e,t,this.length);for(var r=this[e],n=1,c=0;++c=(n*=128)&&(r-=Math.pow(2,8*t)),r},Buffer.prototype.readIntBE=function readIntBE(e,t,a){e>>>=0,t>>>=0,a||checkOffset(e,t,this.length);for(var r=t,n=1,c=this[e+--r];r>0&&(n*=256);)c+=this[e+--r]*n;return c>=(n*=128)&&(c-=Math.pow(2,8*t)),c},Buffer.prototype.readInt8=function readInt8(e,t){return e>>>=0,t||checkOffset(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Buffer.prototype.readInt16LE=function readInt16LE(e,t){e>>>=0,t||checkOffset(e,2,this.length);var a=this[e]|this[e+1]<<8;return 32768&a?4294901760|a:a},Buffer.prototype.readInt16BE=function readInt16BE(e,t){e>>>=0,t||checkOffset(e,2,this.length);var a=this[e+1]|this[e]<<8;return 32768&a?4294901760|a:a},Buffer.prototype.readInt32LE=function readInt32LE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Buffer.prototype.readInt32BE=function readInt32BE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Buffer.prototype.readFloatLE=function readFloatLE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),n.read(this,e,!0,23,4)},Buffer.prototype.readFloatBE=function readFloatBE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),n.read(this,e,!1,23,4)},Buffer.prototype.readDoubleLE=function readDoubleLE(e,t){return e>>>=0,t||checkOffset(e,8,this.length),n.read(this,e,!0,52,8)},Buffer.prototype.readDoubleBE=function readDoubleBE(e,t){return e>>>=0,t||checkOffset(e,8,this.length),n.read(this,e,!1,52,8)},Buffer.prototype.writeUintLE=Buffer.prototype.writeUIntLE=function writeUIntLE(e,t,a,r){(e=+e,t>>>=0,a>>>=0,r)||checkInt(this,e,t,a,Math.pow(2,8*a)-1,0);var n=1,c=0;for(this[t]=255&e;++c>>=0,a>>>=0,r)||checkInt(this,e,t,a,Math.pow(2,8*a)-1,0);var n=a-1,c=1;for(this[t+n]=255&e;--n>=0&&(c*=256);)this[t+n]=e/c&255;return t+a},Buffer.prototype.writeUint8=Buffer.prototype.writeUInt8=function writeUInt8(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,1,255,0),this[t]=255&e,t+1},Buffer.prototype.writeUint16LE=Buffer.prototype.writeUInt16LE=function writeUInt16LE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeUint16BE=Buffer.prototype.writeUInt16BE=function writeUInt16BE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeUint32LE=Buffer.prototype.writeUInt32LE=function writeUInt32LE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},Buffer.prototype.writeUint32BE=Buffer.prototype.writeUInt32BE=function writeUInt32BE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeIntLE=function writeIntLE(e,t,a,r){if(e=+e,t>>>=0,!r){var n=Math.pow(2,8*a-1);checkInt(this,e,t,a,n-1,-n)}var c=0,o=1,d=0;for(this[t]=255&e;++c>0)-d&255;return t+a},Buffer.prototype.writeIntBE=function writeIntBE(e,t,a,r){if(e=+e,t>>>=0,!r){var n=Math.pow(2,8*a-1);checkInt(this,e,t,a,n-1,-n)}var c=a-1,o=1,d=0;for(this[t+c]=255&e;--c>=0&&(o*=256);)e<0&&0===d&&0!==this[t+c+1]&&(d=1),this[t+c]=(e/o>>0)-d&255;return t+a},Buffer.prototype.writeInt8=function writeInt8(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},Buffer.prototype.writeInt16LE=function writeInt16LE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeInt16BE=function writeInt16BE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeInt32LE=function writeInt32LE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},Buffer.prototype.writeInt32BE=function writeInt32BE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeFloatLE=function writeFloatLE(e,t,a){return writeFloat(this,e,t,!0,a)},Buffer.prototype.writeFloatBE=function writeFloatBE(e,t,a){return writeFloat(this,e,t,!1,a)},Buffer.prototype.writeDoubleLE=function writeDoubleLE(e,t,a){return writeDouble(this,e,t,!0,a)},Buffer.prototype.writeDoubleBE=function writeDoubleBE(e,t,a){return writeDouble(this,e,t,!1,a)},Buffer.prototype.copy=function copy(e,t,a,r){if(!Buffer.isBuffer(e))throw new TypeError("argument should be a Buffer");if(a||(a=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t>>=0,a=void 0===a?this.length:a>>>0,e||(e=0),"number"==typeof e)for(c=t;c55295&&a<57344){if(!n){if(a>56319){(t-=3)>-1&&c.push(239,191,189);continue}if(o+1===r){(t-=3)>-1&&c.push(239,191,189);continue}n=a;continue}if(a<56320){(t-=3)>-1&&c.push(239,191,189),n=a;continue}a=65536+(n-55296<<10|a-56320)}else n&&(t-=3)>-1&&c.push(239,191,189);if(n=null,a<128){if((t-=1)<0)break;c.push(a)}else if(a<2048){if((t-=2)<0)break;c.push(a>>6|192,63&a|128)}else if(a<65536){if((t-=3)<0)break;c.push(a>>12|224,a>>6&63|128,63&a|128)}else{if(!(a<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;c.push(a>>18|240,a>>12&63|128,a>>6&63|128,63&a|128)}}return c}function base64ToBytes(e){return r.toByteArray(function base64clean(e){if((e=(e=e.split("=")[0]).trim().replace(s,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function blitBuffer(e,t,a,r){for(var n=0;n=t.length||n>=e.length);++n)t[n+a]=e[n];return n}function isInstance(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function numberIsNaN(e){return e!=e}var b=function(){for(var e="0123456789abcdef",t=new Array(256),a=0;a<16;++a)for(var r=16*a,n=0;n<16;++n)t[r+n]=e[a]+e[n];return t}()},e=>{"function"==typeof Object.create?e.exports=function inherits(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function inherits(e,t){if(t){e.super_=t;var TempCtor=function(){};TempCtor.prototype=t.prototype,e.prototype=new TempCtor,e.prototype.constructor=e}}},(e,t,a)=>{"use strict";var r=a(1320),n=a(1321),c="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=Buffer,t.SlowBuffer=function SlowBuffer(e){+e!=e&&(e=0);return Buffer.alloc(+e)},t.INSPECT_MAX_BYTES=50;var o=2147483647;function createBuffer(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,Buffer.prototype),t}function Buffer(e,t,a){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return allocUnsafe(e)}return from(e,t,a)}function from(e,t,a){if("string"==typeof e)return function fromString(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!Buffer.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var a=0|byteLength(e,t),r=createBuffer(a),n=r.write(e,t);n!==a&&(r=r.slice(0,n));return r}(e,t);if(ArrayBuffer.isView(e))return function fromArrayView(e){if(isInstance(e,Uint8Array)){var t=new Uint8Array(e);return fromArrayBuffer(t.buffer,t.byteOffset,t.byteLength)}return fromArrayLike(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(isInstance(e,ArrayBuffer)||e&&isInstance(e.buffer,ArrayBuffer))return fromArrayBuffer(e,t,a);if("undefined"!=typeof SharedArrayBuffer&&(isInstance(e,SharedArrayBuffer)||e&&isInstance(e.buffer,SharedArrayBuffer)))return fromArrayBuffer(e,t,a);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var r=e.valueOf&&e.valueOf();if(null!=r&&r!==e)return Buffer.from(r,t,a);var n=function fromObject(e){if(Buffer.isBuffer(e)){var t=0|checked(e.length),a=createBuffer(t);return 0===a.length||e.copy(a,0,0,t),a}if(void 0!==e.length)return"number"!=typeof e.length||numberIsNaN(e.length)?createBuffer(0):fromArrayLike(e);if("Buffer"===e.type&&Array.isArray(e.data))return fromArrayLike(e.data)}(e);if(n)return n;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return Buffer.from(e[Symbol.toPrimitive]("string"),t,a);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function assertSize(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function allocUnsafe(e){return assertSize(e),createBuffer(e<0?0:0|checked(e))}function fromArrayLike(e){for(var t=e.length<0?0:0|checked(e.length),a=createBuffer(t),r=0;r=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function byteLength(e,t){if(Buffer.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||isInstance(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var a=e.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===a)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return a;case"utf8":case"utf-8":return utf8ToBytes(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*a;case"hex":return a>>>1;case"base64":return base64ToBytes(e).length;default:if(n)return r?-1:utf8ToBytes(e).length;t=(""+t).toLowerCase(),n=!0}}function slowToString(e,t,a){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===a||a>this.length)&&(a=this.length),a<=0)return"";if((a>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return hexSlice(this,t,a);case"utf8":case"utf-8":return utf8Slice(this,t,a);case"ascii":return asciiSlice(this,t,a);case"latin1":case"binary":return latin1Slice(this,t,a);case"base64":return base64Slice(this,t,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,t,a);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function swap(e,t,a){var r=e[t];e[t]=e[a],e[a]=r}function bidirectionalIndexOf(e,t,a,r,n){if(0===e.length)return-1;if("string"==typeof a?(r=a,a=0):a>2147483647?a=2147483647:a<-2147483648&&(a=-2147483648),numberIsNaN(a=+a)&&(a=n?0:e.length-1),a<0&&(a=e.length+a),a>=e.length){if(n)return-1;a=e.length-1}else if(a<0){if(!n)return-1;a=0}if("string"==typeof t&&(t=Buffer.from(t,r)),Buffer.isBuffer(t))return 0===t.length?-1:arrayIndexOf(e,t,a,r,n);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,a):Uint8Array.prototype.lastIndexOf.call(e,t,a):arrayIndexOf(e,[t],a,r,n);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(e,t,a,r,n){var c,o=1,d=e.length,s=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;o=2,d/=2,s/=2,a/=2}function read(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(n){var b=-1;for(c=a;cd&&(a=d-s),c=a;c>=0;c--){for(var u=!0,h=0;hn&&(r=n):r=n;var c=t.length;r>c/2&&(r=c/2);for(var o=0;o>8,n=a%256,c.push(n),c.push(r);return c}(t,e.length-a),e,a,r)}function base64Slice(e,t,a){return 0===t&&a===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,a))}function utf8Slice(e,t,a){a=Math.min(e.length,a);for(var r=[],n=t;n239?4:u>223?3:u>191?2:1;if(n+l<=a)switch(l){case 1:u<128&&(h=u);break;case 2:128==(192&(c=e[n+1]))&&(b=(31&u)<<6|63&c)>127&&(h=b);break;case 3:c=e[n+1],o=e[n+2],128==(192&c)&&128==(192&o)&&(b=(15&u)<<12|(63&c)<<6|63&o)>2047&&(b<55296||b>57343)&&(h=b);break;case 4:c=e[n+1],o=e[n+2],s=e[n+3],128==(192&c)&&128==(192&o)&&128==(192&s)&&(b=(15&u)<<18|(63&c)<<12|(63&o)<<6|63&s)>65535&&b<1114112&&(h=b)}null===h?(h=65533,l=1):h>65535&&(h-=65536,r.push(h>>>10&1023|55296),h=56320|1023&h),r.push(h),n+=l}return function decodeCodePointsArray(e){var t=e.length;if(t<=d)return String.fromCharCode.apply(String,e);var a="",r=0;for(;rr.length?Buffer.from(c).copy(r,n):Uint8Array.prototype.set.call(r,c,n);else{if(!Buffer.isBuffer(c))throw new TypeError('"list" argument must be an Array of Buffers');c.copy(r,n)}n+=c.length}return r},Buffer.byteLength=byteLength,Buffer.prototype._isBuffer=!0,Buffer.prototype.swap16=function swap16(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;ta&&(e+=" ... "),""},c&&(Buffer.prototype[c]=Buffer.prototype.inspect),Buffer.prototype.compare=function compare(e,t,a,r,n){if(isInstance(e,Uint8Array)&&(e=Buffer.from(e,e.offset,e.byteLength)),!Buffer.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===a&&(a=e?e.length:0),void 0===r&&(r=0),void 0===n&&(n=this.length),t<0||a>e.length||r<0||n>this.length)throw new RangeError("out of range index");if(r>=n&&t>=a)return 0;if(r>=n)return-1;if(t>=a)return 1;if(this===e)return 0;for(var c=(n>>>=0)-(r>>>=0),o=(a>>>=0)-(t>>>=0),d=Math.min(c,o),s=this.slice(r,n),b=e.slice(t,a),u=0;u>>=0,isFinite(a)?(a>>>=0,void 0===r&&(r="utf8")):(r=a,a=void 0)}var n=this.length-t;if((void 0===a||a>n)&&(a=n),e.length>0&&(a<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var c=!1;;)switch(r){case"hex":return hexWrite(this,e,t,a);case"utf8":case"utf-8":return utf8Write(this,e,t,a);case"ascii":case"latin1":case"binary":return asciiWrite(this,e,t,a);case"base64":return base64Write(this,e,t,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,e,t,a);default:if(c)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),c=!0}},Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var d=4096;function asciiSlice(e,t,a){var r="";a=Math.min(e.length,a);for(var n=t;nr)&&(a=r);for(var n="",c=t;ca)throw new RangeError("Trying to access beyond buffer length")}function checkInt(e,t,a,r,n,c){if(!Buffer.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||te.length)throw new RangeError("Index out of range")}function checkIEEE754(e,t,a,r,n,c){if(a+r>e.length)throw new RangeError("Index out of range");if(a<0)throw new RangeError("Index out of range")}function writeFloat(e,t,a,r,c){return t=+t,a>>>=0,c||checkIEEE754(e,0,a,4),n.write(e,t,a,r,23,4),a+4}function writeDouble(e,t,a,r,c){return t=+t,a>>>=0,c||checkIEEE754(e,0,a,8),n.write(e,t,a,r,52,8),a+8}Buffer.prototype.slice=function slice(e,t){var a=this.length;(e=~~e)<0?(e+=a)<0&&(e=0):e>a&&(e=a),(t=void 0===t?a:~~t)<0?(t+=a)<0&&(t=0):t>a&&(t=a),t>>=0,t>>>=0,a||checkOffset(e,t,this.length);for(var r=this[e],n=1,c=0;++c>>=0,t>>>=0,a||checkOffset(e,t,this.length);for(var r=this[e+--t],n=1;t>0&&(n*=256);)r+=this[e+--t]*n;return r},Buffer.prototype.readUint8=Buffer.prototype.readUInt8=function readUInt8(e,t){return e>>>=0,t||checkOffset(e,1,this.length),this[e]},Buffer.prototype.readUint16LE=Buffer.prototype.readUInt16LE=function readUInt16LE(e,t){return e>>>=0,t||checkOffset(e,2,this.length),this[e]|this[e+1]<<8},Buffer.prototype.readUint16BE=Buffer.prototype.readUInt16BE=function readUInt16BE(e,t){return e>>>=0,t||checkOffset(e,2,this.length),this[e]<<8|this[e+1]},Buffer.prototype.readUint32LE=Buffer.prototype.readUInt32LE=function readUInt32LE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Buffer.prototype.readUint32BE=Buffer.prototype.readUInt32BE=function readUInt32BE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Buffer.prototype.readIntLE=function readIntLE(e,t,a){e>>>=0,t>>>=0,a||checkOffset(e,t,this.length);for(var r=this[e],n=1,c=0;++c=(n*=128)&&(r-=Math.pow(2,8*t)),r},Buffer.prototype.readIntBE=function readIntBE(e,t,a){e>>>=0,t>>>=0,a||checkOffset(e,t,this.length);for(var r=t,n=1,c=this[e+--r];r>0&&(n*=256);)c+=this[e+--r]*n;return c>=(n*=128)&&(c-=Math.pow(2,8*t)),c},Buffer.prototype.readInt8=function readInt8(e,t){return e>>>=0,t||checkOffset(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Buffer.prototype.readInt16LE=function readInt16LE(e,t){e>>>=0,t||checkOffset(e,2,this.length);var a=this[e]|this[e+1]<<8;return 32768&a?4294901760|a:a},Buffer.prototype.readInt16BE=function readInt16BE(e,t){e>>>=0,t||checkOffset(e,2,this.length);var a=this[e+1]|this[e]<<8;return 32768&a?4294901760|a:a},Buffer.prototype.readInt32LE=function readInt32LE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Buffer.prototype.readInt32BE=function readInt32BE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Buffer.prototype.readFloatLE=function readFloatLE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),n.read(this,e,!0,23,4)},Buffer.prototype.readFloatBE=function readFloatBE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),n.read(this,e,!1,23,4)},Buffer.prototype.readDoubleLE=function readDoubleLE(e,t){return e>>>=0,t||checkOffset(e,8,this.length),n.read(this,e,!0,52,8)},Buffer.prototype.readDoubleBE=function readDoubleBE(e,t){return e>>>=0,t||checkOffset(e,8,this.length),n.read(this,e,!1,52,8)},Buffer.prototype.writeUintLE=Buffer.prototype.writeUIntLE=function writeUIntLE(e,t,a,r){(e=+e,t>>>=0,a>>>=0,r)||checkInt(this,e,t,a,Math.pow(2,8*a)-1,0);var n=1,c=0;for(this[t]=255&e;++c>>=0,a>>>=0,r)||checkInt(this,e,t,a,Math.pow(2,8*a)-1,0);var n=a-1,c=1;for(this[t+n]=255&e;--n>=0&&(c*=256);)this[t+n]=e/c&255;return t+a},Buffer.prototype.writeUint8=Buffer.prototype.writeUInt8=function writeUInt8(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,1,255,0),this[t]=255&e,t+1},Buffer.prototype.writeUint16LE=Buffer.prototype.writeUInt16LE=function writeUInt16LE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeUint16BE=Buffer.prototype.writeUInt16BE=function writeUInt16BE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeUint32LE=Buffer.prototype.writeUInt32LE=function writeUInt32LE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},Buffer.prototype.writeUint32BE=Buffer.prototype.writeUInt32BE=function writeUInt32BE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeIntLE=function writeIntLE(e,t,a,r){if(e=+e,t>>>=0,!r){var n=Math.pow(2,8*a-1);checkInt(this,e,t,a,n-1,-n)}var c=0,o=1,d=0;for(this[t]=255&e;++c>0)-d&255;return t+a},Buffer.prototype.writeIntBE=function writeIntBE(e,t,a,r){if(e=+e,t>>>=0,!r){var n=Math.pow(2,8*a-1);checkInt(this,e,t,a,n-1,-n)}var c=a-1,o=1,d=0;for(this[t+c]=255&e;--c>=0&&(o*=256);)e<0&&0===d&&0!==this[t+c+1]&&(d=1),this[t+c]=(e/o>>0)-d&255;return t+a},Buffer.prototype.writeInt8=function writeInt8(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},Buffer.prototype.writeInt16LE=function writeInt16LE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeInt16BE=function writeInt16BE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeInt32LE=function writeInt32LE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},Buffer.prototype.writeInt32BE=function writeInt32BE(e,t,a){return e=+e,t>>>=0,a||checkInt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeFloatLE=function writeFloatLE(e,t,a){return writeFloat(this,e,t,!0,a)},Buffer.prototype.writeFloatBE=function writeFloatBE(e,t,a){return writeFloat(this,e,t,!1,a)},Buffer.prototype.writeDoubleLE=function writeDoubleLE(e,t,a){return writeDouble(this,e,t,!0,a)},Buffer.prototype.writeDoubleBE=function writeDoubleBE(e,t,a){return writeDouble(this,e,t,!1,a)},Buffer.prototype.copy=function copy(e,t,a,r){if(!Buffer.isBuffer(e))throw new TypeError("argument should be a Buffer");if(a||(a=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t>>=0,a=void 0===a?this.length:a>>>0,e||(e=0),"number"==typeof e)for(c=t;c55295&&a<57344){if(!n){if(a>56319){(t-=3)>-1&&c.push(239,191,189);continue}if(o+1===r){(t-=3)>-1&&c.push(239,191,189);continue}n=a;continue}if(a<56320){(t-=3)>-1&&c.push(239,191,189),n=a;continue}a=65536+(n-55296<<10|a-56320)}else n&&(t-=3)>-1&&c.push(239,191,189);if(n=null,a<128){if((t-=1)<0)break;c.push(a)}else if(a<2048){if((t-=2)<0)break;c.push(a>>6|192,63&a|128)}else if(a<65536){if((t-=3)<0)break;c.push(a>>12|224,a>>6&63|128,63&a|128)}else{if(!(a<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;c.push(a>>18|240,a>>12&63|128,a>>6&63|128,63&a|128)}}return c}function base64ToBytes(e){return r.toByteArray(function base64clean(e){if((e=(e=e.split("=")[0]).trim().replace(s,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function blitBuffer(e,t,a,r){for(var n=0;n=t.length||n>=e.length);++n)t[n+a]=e[n];return n}function isInstance(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function numberIsNaN(e){return e!=e}var b=function(){for(var e="0123456789abcdef",t=new Array(256),a=0;a<16;++a)for(var r=16*a,n=0;n<16;++n)t[r+n]=e[a]+e[n];return t}()},(e,t,a)=>{var check=function(e){return e&&e.Math==Math&&e};e.exports=check("object"==typeof globalThis&&globalThis)||check("object"==typeof window&&window)||check("object"==typeof self&&self)||check("object"==typeof a.g&&a.g)||function(){return this}()||Function("return this")()},(e,t,a)=>{"use strict";var r,n=SyntaxError,c=Function,o=TypeError,getEvalledConstructor=function(e){try{return c('"use strict"; return ('+e+").constructor;")()}catch(e){}},d=Object.getOwnPropertyDescriptor;if(d)try{d({},"")}catch(e){d=null}var throwTypeError=function(){throw new o},s=d?function(){try{return throwTypeError}catch(e){try{return d(arguments,"callee").get}catch(e){return throwTypeError}}}():throwTypeError,b=a(284)(),u=Object.getPrototypeOf||function(e){return e.__proto__},h={},l="undefined"==typeof Uint8Array?r:u(Uint8Array),g={"%AggregateError%":"undefined"==typeof AggregateError?r:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?r:ArrayBuffer,"%ArrayIteratorPrototype%":b?u([][Symbol.iterator]()):r,"%AsyncFromSyncIteratorPrototype%":r,"%AsyncFunction%":h,"%AsyncGenerator%":h,"%AsyncGeneratorFunction%":h,"%AsyncIteratorPrototype%":h,"%Atomics%":"undefined"==typeof Atomics?r:Atomics,"%BigInt%":"undefined"==typeof BigInt?r:BigInt,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?r:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":"undefined"==typeof Float32Array?r:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?r:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?r:FinalizationRegistry,"%Function%":c,"%GeneratorFunction%":h,"%Int8Array%":"undefined"==typeof Int8Array?r:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?r:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?r:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":b?u(u([][Symbol.iterator]())):r,"%JSON%":"object"==typeof JSON?JSON:r,"%Map%":"undefined"==typeof Map?r:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&b?u((new Map)[Symbol.iterator]()):r,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?r:Promise,"%Proxy%":"undefined"==typeof Proxy?r:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":"undefined"==typeof Reflect?r:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?r:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&b?u((new Set)[Symbol.iterator]()):r,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?r:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":b?u(""[Symbol.iterator]()):r,"%Symbol%":b?Symbol:r,"%SyntaxError%":n,"%ThrowTypeError%":s,"%TypedArray%":l,"%TypeError%":o,"%Uint8Array%":"undefined"==typeof Uint8Array?r:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?r:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?r:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?r:Uint32Array,"%URIError%":URIError,"%WeakMap%":"undefined"==typeof WeakMap?r:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?r:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?r:WeakSet},p=function doEval(e){var t;if("%AsyncFunction%"===e)t=getEvalledConstructor("async function () {}");else if("%GeneratorFunction%"===e)t=getEvalledConstructor("function* () {}");else if("%AsyncGeneratorFunction%"===e)t=getEvalledConstructor("async function* () {}");else if("%AsyncGenerator%"===e){var a=doEval("%AsyncGeneratorFunction%");a&&(t=a.prototype)}else if("%AsyncIteratorPrototype%"===e){var r=doEval("%AsyncGenerator%");r&&(t=u(r.prototype))}return g[e]=t,t},B={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},x=a(283),I=a(87),m=x.call(Function.call,Array.prototype.concat),y=x.call(Function.apply,Array.prototype.splice),C=x.call(Function.call,String.prototype.replace),w=x.call(Function.call,String.prototype.slice),v=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Q=/\\(\\)?/g,k=function stringToPath(e){var t=w(e,0,1),a=w(e,-1);if("%"===t&&"%"!==a)throw new n("invalid intrinsic syntax, expected closing `%`");if("%"===a&&"%"!==t)throw new n("invalid intrinsic syntax, expected opening `%`");var r=[];return C(e,v,(function(e,t,a,n){r[r.length]=a?C(n,Q,"$1"):t||e})),r},_=function getBaseIntrinsic(e,t){var a,r=e;if(I(B,r)&&(r="%"+(a=B[r])[0]+"%"),I(g,r)){var c=g[r];if(c===h&&(c=p(r)),void 0===c&&!t)throw new o("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:a,name:r,value:c}}throw new n("intrinsic "+e+" does not exist!")};e.exports=function GetIntrinsic(e,t){if("string"!=typeof e||0===e.length)throw new o("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new o('"allowMissing" argument must be a boolean');var a=k(e),r=a.length>0?a[0]:"",c=_("%"+r+"%",t),s=c.name,b=c.value,u=!1,h=c.alias;h&&(r=h[0],y(a,m([0,1],h)));for(var l=1,p=!0;l=a.length){var v=d(b,B);b=(p=!!v)&&"get"in v&&!("originalValue"in v.get)?v.get:b[B]}else p=I(b,B),b=b[B];p&&!u&&(g[s]=b)}}return b}},function(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[a]}})}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||r(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),n(a(543),t)},function(e,t,a){"use strict";var r=a(0).Buffer,n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,a=1,r=arguments.length;a0&&n[n.length-1])||6!==c[0]&&2!==c[0])){o=0;continue}if(3===c[0]&&(!n||c[1]>n[0]&&c[1]this._vm._common.param("vm","maxInitCodeSize")?[2,{gasUsed:e.gasLimit,createdAddress:e.to,execResult:{returnValue:r.alloc(0),exceptionError:new p.VmError(p.ERROR.INITCODE_SIZE_VIOLATION),gasUsed:e.gasLimit}}]:(e.code=e.data,e.data=r.alloc(0),a=e,[4,this._generateAddress(e)]);case 3:return a.to=b.sent(),this._vm.DEBUG&&C("Generated CREATE contract address ".concat(e.to)),[4,this._state.getAccount(e.to)];case 4:return(c=b.sent()).nonce&&c.nonce.gtn(0)||!c.codeHash.equals(l.KECCAK256_NULL)?(this._vm.DEBUG&&C("Returning on address collision"),[2,{gasUsed:e.gasLimit,createdAddress:e.to,execResult:{returnValue:r.alloc(0),exceptionError:new p.VmError(p.ERROR.CREATE_COLLISION),gasUsed:e.gasLimit}}]):[4,this._state.clearContractStorage(e.to)];case 5:return b.sent(),o={address:e.to,code:e.code},[4,this._vm._emit("newContract",o)];case 6:return b.sent(),[4,this._state.getAccount(e.to)];case 7:c=b.sent(),this._vm._common.gteHardfork("spuriousDragon")&&c.nonce.iaddn(1),b.label=8;case 8:return b.trys.push([8,10,,11]),[4,this._addToBalance(c,e)];case 9:return b.sent(),[3,11];case 10:return s=b.sent(),d=s,[3,11];case 11:return u=!1,e.code&&0!==e.code.length||(u=!0,this._vm.DEBUG&&C("Exit early on no code")),d&&(u=!0,this._vm.DEBUG&&C("Exit early on value transfer overflowed")),u?[2,{gasUsed:new l.BN(0),createdAddress:e.to,execResult:{gasUsed:new l.BN(0),exceptionError:d,returnValue:r.alloc(0)}}]:(this._vm.DEBUG&&C("Start bytecode processing..."),[4,this.runInterpreter(e)]);case 12:return h=b.sent(),g=h.gasUsed,B=new l.BN(0),h.exceptionError||(B=new l.BN(h.returnValue.length).imuln(this._vm._common.param("gasPrices","createData")),g=g.add(B),this._vm.DEBUG&&w("Add return value size fee (".concat(B," to gas used (-> ").concat(g,"))"))),x=!0,!h.exceptionError&&this._vm._common.gteHardfork("spuriousDragon")&&h.returnValue.length>this._vm._common.param("vm","maxCodeSize")&&(x=!1),m=!1,g.lte(e.gasLimit)&&(this._vm._allowUnlimitedContractSize||x)?this._vm._common.isActivatedEIP(3541)&&h.returnValue[0]===I.FORMAT?(this._vm._common.isActivatedEIP(3540)||(h=n(n({},h),INVALID_BYTECODE_RESULT(e.gasLimit))),(null==(y=I.codeAnalysis(h.returnValue))?void 0:y.code)?this._vm._common.isActivatedEIP(3670)&&(v=y.data>0?10:7,I.validOpcodes(h.returnValue.slice(v,v+y.code))?h.gasUsed=g:h=n(n({},h),INVALID_EOF_RESULT(e.gasLimit))):h=n(n({},h),INVALID_EOF_RESULT(e.gasLimit))):h.gasUsed=g:this._vm._common.gteHardfork("homestead")?(this._vm.DEBUG&&C("Not enough gas or code size not allowed (>= Homestead)"),h=n(n({},h),OOGResult(e.gasLimit))):(this._vm.DEBUG&&C("Not enough gas or code size not allowed (Frontier)"),g.sub(B).lte(e.gasLimit)?(h=n(n({},h),COOGResult(g.sub(B))),m=!0):h=n(n({},h),OOGResult(e.gasLimit))),h.exceptionError||!h.returnValue||""===h.returnValue.toString()?[3,14]:[4,this._state.putContractCode(e.to,h.returnValue)];case 13:return b.sent(),this._vm.DEBUG&&C("Code saved on new contract creation"),[3,17];case 14:return m?this._vm._common.gteHardfork("homestead")?[3,17]:[4,this._state.getAccount(e.to)]:[3,17];case 15:return Q=b.sent(),[4,this._state.putAccount(e.to,Q)];case 16:b.sent(),b.label=17;case 17:return[2,{gasUsed:h.gasUsed,createdAddress:e.to,execResult:h}]}}))}))},EVM.prototype.runInterpreter=function(e,t){return void 0===t&&(t={}),s(this,void 0,void 0,(function(){var a,c,o,d,s,u;return b(this,(function(b){switch(b.label){case 0:return u={blockchain:this._vm.blockchain,address:e.to||l.Address.zero(),caller:e.caller||l.Address.zero(),callData:e.data||r.from([0]),callValue:e.value||new l.BN(0),code:e.code,isStatic:e.isStatic||!1,depth:e.depth||0,gasPrice:this._tx.gasPrice,origin:this._tx.origin||e.caller||l.Address.zero(),block:this._block||new g.Block},[4,this._state.getAccount(e.to||l.Address.zero())];case 1:return u.contract=b.sent(),u.codeAddress=e.codeAddress,a=u,c=new B.default(a,this._state,this,this._vm._common,e.gasLimit.clone(),this._transientStorage),e.selfdestruct&&(c._result.selfdestruct=e.selfdestruct),[4,new m.default(this._vm,c).run(e.code,t)];case 2:return o=b.sent(),d=c._result,s=e.gasLimit.sub(c._gasLeft),o.exceptionError&&(o.exceptionError.error!==p.ERROR.REVERT&&o.exceptionError.error!==p.ERROR.INVALID_EOF_FORMAT&&(s=e.gasLimit),d=n(n({},d),{logs:[],selfdestruct:{}})),[2,n(n({},d),{runState:n(n(n({},o.runState),d),c._env),exceptionError:o.exceptionError,gas:c._gasLeft,gasUsed:s,returnValue:d.returnValue?d.returnValue:r.alloc(0)})]}}))}))},EVM.prototype.getPrecompile=function(e){return this._vm.precompiles.get(e.buf.toString("hex"))},EVM.prototype.runPrecompile=function(e,t,a){if("function"!=typeof e)throw new Error("Invalid precompile");return e({data:t,gasLimit:a,_common:this._vm._common,_VM:this._vm})},EVM.prototype._loadCode=function(e){return s(this,void 0,void 0,(function(){var t,a;return b(this,(function(r){switch(r.label){case 0:return e.code?[3,3]:(t=this.getPrecompile(e.codeAddress))?(e.code=t,e.isCompiled=!0,[3,3]):[3,1];case 1:return a=e,[4,this._state.getContractCode(e.codeAddress)];case 2:a.code=r.sent(),e.isCompiled=!1,r.label=3;case 3:return[2]}}))}))},EVM.prototype._generateAddress=function(e){return s(this,void 0,void 0,(function(){var t,a,n;return b(this,(function(c){switch(c.label){case 0:return e.salt?(t=(0,l.generateAddress2)(e.caller.buf,e.salt,e.code),[3,3]):[3,1];case 1:return[4,this._state.getAccount(e.caller)];case 2:a=c.sent(),n=a.nonce.subn(1),t=(0,l.generateAddress)(e.caller.buf,n.toArrayLike(r)),c.label=3;case 3:return[2,new l.Address(t)]}}))}))},EVM.prototype._reduceSenderBalance=function(e,t){return s(this,void 0,void 0,(function(){var a;return b(this,(function(r){return e.balance.isub(t.value),a=this._state.putAccount(t.caller,e),this._vm.DEBUG&&C("Reduced sender (".concat(t.caller,") balance (-> ").concat(e.balance,")")),[2,a]}))}))},EVM.prototype._addToBalance=function(e,t){return s(this,void 0,void 0,(function(){var a,r;return b(this,(function(n){if((a=e.balance.add(t.value)).gt(l.MAX_INTEGER))throw new p.VmError(p.ERROR.VALUE_OVERFLOW);return e.balance=a,r=this._state.putAccount(t.to,e),this._vm.DEBUG&&C("Added toAccount (".concat(t.to,") balance (-> ").concat(e.balance,")")),[2,r]}))}))},EVM.prototype._touchAccount=function(e){return s(this,void 0,void 0,(function(){var t;return b(this,(function(a){switch(a.label){case 0:return[4,this._state.getAccount(e)];case 1:return t=a.sent(),[2,this._state.putAccount(e,t)]}}))}))},EVM}();t.default=v},e=>{"function"==typeof Object.create?e.exports=function inherits(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function inherits(e,t){if(t){e.super_=t;var TempCtor=function(){};TempCtor.prototype=t.prototype,e.prototype=new TempCtor,e.prototype.constructor=e}}},e=>{"function"==typeof Object.create?e.exports=function inherits(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function inherits(e,t){if(t){e.super_=t;var TempCtor=function(){};TempCtor.prototype=t.prototype,e.prototype=new TempCtor,e.prototype.constructor=e}}},e=>{"function"==typeof Object.create?e.exports=function inherits(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function inherits(e,t){if(t){e.super_=t;var TempCtor=function(){};TempCtor.prototype=t.prototype,e.prototype=new TempCtor,e.prototype.constructor=e}}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.VmError=t.ERROR=void 0,function(e){e.OUT_OF_GAS="out of gas",e.CODESTORE_OUT_OF_GAS="code store out of gas",e.STACK_UNDERFLOW="stack underflow",e.STACK_OVERFLOW="stack overflow",e.INVALID_JUMP="invalid JUMP",e.INVALID_OPCODE="invalid opcode",e.OUT_OF_RANGE="value out of range",e.REVERT="revert",e.STATIC_STATE_CHANGE="static state change",e.INTERNAL_ERROR="internal error",e.CREATE_COLLISION="create collision",e.STOP="stop",e.REFUND_EXHAUSTED="refund exhausted",e.VALUE_OVERFLOW="value overflow",e.INVALID_BEGINSUB="invalid BEGINSUB",e.INVALID_RETURNSUB="invalid RETURNSUB",e.INVALID_JUMPSUB="invalid JUMPSUB",e.INVALID_BYTECODE_RESULT="invalid bytecode deployed",e.INVALID_EOF_FORMAT="invalid EOF format",e.INITCODE_SIZE_VIOLATION="initcode exceeds max initcode size",e.BLS_12_381_INVALID_INPUT_LENGTH="invalid input length",e.BLS_12_381_POINT_NOT_ON_CURVE="point not on curve",e.BLS_12_381_INPUT_EMPTY="input is empty",e.BLS_12_381_FP_NOT_IN_FIELD="fp point not in field"}(t.ERROR||(t.ERROR={}));t.VmError=class VmError{constructor(e){this.error=e,this.errorType="VmError"}}},e=>{var t,a,r=e.exports={};function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}function runTimeout(e){if(t===setTimeout)return setTimeout(e,0);if((t===defaultSetTimout||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(a){try{return t.call(null,e,0)}catch(a){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:defaultSetTimout}catch(e){t=defaultSetTimout}try{a="function"==typeof clearTimeout?clearTimeout:defaultClearTimeout}catch(e){a=defaultClearTimeout}}();var n,c=[],o=!1,d=-1;function cleanUpNextTick(){o&&n&&(o=!1,n.length?c=n.concat(c):d=-1,c.length&&drainQueue())}function drainQueue(){if(!o){var e=runTimeout(cleanUpNextTick);o=!0;for(var t=c.length;t;){for(n=c,c=[];++d1)for(var a=1;athis._vm._common.param("vm","maxInitCodeSize"))return{gasUsed:e.gasLimit,createdAddress:e.to,execResult:{returnValue:r.alloc(0),exceptionError:new h.VmError(h.ERROR.INITCODE_SIZE_VIOLATION),gasUsed:e.gasLimit}};e.code=e.data,e.data=r.alloc(0),e.to=await this._generateAddress(e),this._vm.DEBUG&&I(`Generated CREATE contract address ${e.to}`);let a=await this._state.getAccount(e.to);if(a.nonce&&a.nonce.gtn(0)||!a.codeHash.equals(b.KECCAK256_NULL))return this._vm.DEBUG&&I("Returning on address collision"),{gasUsed:e.gasLimit,createdAddress:e.to,execResult:{returnValue:r.alloc(0),exceptionError:new h.VmError(h.ERROR.CREATE_COLLISION),gasUsed:e.gasLimit}};await this._state.clearContractStorage(e.to);const n={address:e.to,code:e.code};let c;await this._vm._emit("newContract",n),a=await this._state.getAccount(e.to),this._vm._common.gteHardfork("spuriousDragon")&&a.nonce.iaddn(1);try{await this._addToBalance(a,e)}catch(e){c=e}let o=!1;if(e.code&&0!==e.code.length||(o=!0,this._vm.DEBUG&&I("Exit early on no code")),c&&(o=!0,this._vm.DEBUG&&I("Exit early on value transfer overflowed")),o)return{gasUsed:new b.BN(0),createdAddress:e.to,execResult:{gasUsed:new b.BN(0),exceptionError:c,returnValue:r.alloc(0)}};this._vm.DEBUG&&I("Start bytecode processing...");let d=await this.runInterpreter(e),s=d.gasUsed,u=new b.BN(0);d.exceptionError||(u=new b.BN(d.returnValue.length).imuln(this._vm._common.param("gasPrices","createData")),s=s.add(u),this._vm.DEBUG&&m(`Add return value size fee (${u} to gas used (-> ${s}))`));let l=!0;!d.exceptionError&&this._vm._common.gteHardfork("spuriousDragon")&&d.returnValue.length>this._vm._common.param("vm","maxCodeSize")&&(l=!1);let g=!1;if(s.lte(e.gasLimit)&&(this._vm._allowUnlimitedContractSize||l))if(this._vm._common.isActivatedEIP(3541)&&d.returnValue[0]===p.FORMAT){this._vm._common.isActivatedEIP(3540)||(d=Object.assign(Object.assign({},d),INVALID_BYTECODE_RESULT(e.gasLimit)));const t=p.codeAnalysis(d.returnValue);if(null==t?void 0:t.code){if(this._vm._common.isActivatedEIP(3670)){const a=t.data>0?10:7;p.validOpcodes(d.returnValue.slice(a,a+t.code))?d.gasUsed=s:d=Object.assign(Object.assign({},d),INVALID_EOF_RESULT(e.gasLimit))}}else d=Object.assign(Object.assign({},d),INVALID_EOF_RESULT(e.gasLimit))}else d.gasUsed=s;else this._vm._common.gteHardfork("homestead")?(this._vm.DEBUG&&I("Not enough gas or code size not allowed (>= Homestead)"),d=Object.assign(Object.assign({},d),OOGResult(e.gasLimit))):(this._vm.DEBUG&&I("Not enough gas or code size not allowed (Frontier)"),s.sub(u).lte(e.gasLimit)?(d=Object.assign(Object.assign({},d),COOGResult(s.sub(u))),g=!0):d=Object.assign(Object.assign({},d),OOGResult(e.gasLimit)));if(!d.exceptionError&&d.returnValue&&""!==d.returnValue.toString())await this._state.putContractCode(e.to,d.returnValue),this._vm.DEBUG&&I("Code saved on new contract creation");else if(g&&!this._vm._common.gteHardfork("homestead")){const t=await this._state.getAccount(e.to);await this._state.putAccount(e.to,t)}return{gasUsed:d.gasUsed,createdAddress:e.to,execResult:d}}async runInterpreter(e,t={}){const a={blockchain:this._vm.blockchain,address:e.to||b.Address.zero(),caller:e.caller||b.Address.zero(),callData:e.data||r.from([0]),callValue:e.value||new b.BN(0),code:e.code,isStatic:e.isStatic||!1,depth:e.depth||0,gasPrice:this._tx.gasPrice,origin:this._tx.origin||e.caller||b.Address.zero(),block:this._block||new u.Block,contract:await this._state.getAccount(e.to||b.Address.zero()),codeAddress:e.codeAddress},n=new l.default(a,this._state,this,this._vm._common,e.gasLimit.clone(),this._transientStorage);e.selfdestruct&&(n._result.selfdestruct=e.selfdestruct);const c=new B.default(this._vm,n),o=await c.run(e.code,t);let d=n._result,s=e.gasLimit.sub(n._gasLeft);return o.exceptionError&&(o.exceptionError.error!==h.ERROR.REVERT&&o.exceptionError.error!==h.ERROR.INVALID_EOF_FORMAT&&(s=e.gasLimit),d=Object.assign(Object.assign({},d),{logs:[],selfdestruct:{}})),Object.assign(Object.assign({},d),{runState:Object.assign(Object.assign(Object.assign({},o.runState),d),n._env),exceptionError:o.exceptionError,gas:n._gasLeft,gasUsed:s,returnValue:d.returnValue?d.returnValue:r.alloc(0)})}getPrecompile(e){return this._vm.precompiles.get(e.buf.toString("hex"))}runPrecompile(e,t,a){if("function"!=typeof e)throw new Error("Invalid precompile");return e({data:t,gasLimit:a,_common:this._vm._common,_VM:this._vm})}async _loadCode(e){if(!e.code){const t=this.getPrecompile(e.codeAddress);t?(e.code=t,e.isCompiled=!0):(e.code=await this._state.getContractCode(e.codeAddress),e.isCompiled=!1)}}async _generateAddress(e){let t;if(e.salt)t=(0,b.generateAddress2)(e.caller.buf,e.salt,e.code);else{const a=(await this._state.getAccount(e.caller)).nonce.subn(1);t=(0,b.generateAddress)(e.caller.buf,a.toArrayLike(r))}return new b.Address(t)}async _reduceSenderBalance(e,t){e.balance.isub(t.value);const a=this._state.putAccount(t.caller,e);return this._vm.DEBUG&&I(`Reduced sender (${t.caller}) balance (-> ${e.balance})`),a}async _addToBalance(e,t){const a=e.balance.add(t.value);if(a.gt(b.MAX_INTEGER))throw new h.VmError(h.ERROR.VALUE_OVERFLOW);e.balance=a;const r=this._state.putAccount(t.to,e);return this._vm.DEBUG&&I(`Added toAccount (${t.to}) balance (-> ${e.balance})`),r}async _touchAccount(e){const t=await this._state.getAccount(e);return this._state.putAccount(e,t)}}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.VmError=t.ERROR=void 0,function(e){e.OUT_OF_GAS="out of gas",e.CODESTORE_OUT_OF_GAS="code store out of gas",e.STACK_UNDERFLOW="stack underflow",e.STACK_OVERFLOW="stack overflow",e.INVALID_JUMP="invalid JUMP",e.INVALID_OPCODE="invalid opcode",e.OUT_OF_RANGE="value out of range",e.REVERT="revert",e.STATIC_STATE_CHANGE="static state change",e.INTERNAL_ERROR="internal error",e.CREATE_COLLISION="create collision",e.STOP="stop",e.REFUND_EXHAUSTED="refund exhausted",e.VALUE_OVERFLOW="value overflow",e.INVALID_BEGINSUB="invalid BEGINSUB",e.INVALID_RETURNSUB="invalid RETURNSUB",e.INVALID_JUMPSUB="invalid JUMPSUB",e.INVALID_BYTECODE_RESULT="invalid bytecode deployed",e.INVALID_EOF_FORMAT="invalid EOF format",e.INITCODE_SIZE_VIOLATION="initcode exceeds max initcode size",e.BLS_12_381_INVALID_INPUT_LENGTH="invalid input length",e.BLS_12_381_POINT_NOT_ON_CURVE="point not on curve",e.BLS_12_381_INPUT_EMPTY="input is empty",e.BLS_12_381_FP_NOT_IN_FIELD="fp point not in field"}(t.ERROR||(t.ERROR={}));var a=function a(e){this.error=e,this.errorType="VmError"};t.VmError=a},function(e,t,a){!function(e,t){"use strict";function assert(e,t){if(!e)throw new Error(t||"Assertion failed")}function inherits(e,t){e.super_=t;var TempCtor=function(){};TempCtor.prototype=t.prototype,e.prototype=new TempCtor,e.prototype.constructor=e}function BN(e,t,a){if(BN.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(a=t,t=10),this._init(e||0,t||10,a||"be"))}var r;"object"==typeof e?e.exports=BN:t.BN=BN,BN.BN=BN,BN.wordSize=26;try{r="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:a(1274).Buffer}catch(e){}function parseHex4Bits(e,t){var a=e.charCodeAt(t);return a>=65&&a<=70?a-55:a>=97&&a<=102?a-87:a-48&15}function parseHexByte(e,t,a){var r=parseHex4Bits(e,a);return a-1>=t&&(r|=parseHex4Bits(e,a-1)<<4),r}function parseBase(e,t,a,r){for(var n=0,c=Math.min(e.length,a),o=t;o=49?d-49+10:d>=17?d-17+10:d}return n}BN.isBN=function isBN(e){return e instanceof BN||null!==e&&"object"==typeof e&&e.constructor.wordSize===BN.wordSize&&Array.isArray(e.words)},BN.max=function max(e,t){return e.cmp(t)>0?e:t},BN.min=function min(e,t){return e.cmp(t)<0?e:t},BN.prototype._init=function init(e,t,a){if("number"==typeof e)return this._initNumber(e,t,a);if("object"==typeof e)return this._initArray(e,t,a);"hex"===t&&(t=16),assert(t===(0|t)&&t>=2&&t<=36);var r=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(r++,this.negative=1),r=0;r-=3)c=e[r]|e[r-1]<<8|e[r-2]<<16,this.words[n]|=c<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===a)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},BN.prototype._parseHex=function _parseHex(e,t,a){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=2)n=parseHexByte(e,t,r)<=18?(c-=18,o+=1,this.words[o]|=n>>>26):c+=8;else for(r=(e.length-t)%2==0?t+1:t;r=18?(c-=18,o+=1,this.words[o]|=n>>>26):c+=8;this.strip()},BN.prototype._parseBase=function _parseBase(e,t,a){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=t)r++;r--,n=n/t|0;for(var c=e.length-a,o=c%r,d=Math.min(c,c-o)+a,s=0,b=a;b1&&0===this.words[this.length-1];)this.length--;return this._normSign()},BN.prototype._normSign=function _normSign(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},BN.prototype.inspect=function inspect(){return(this.red?""};var n=["","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"],c=[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],o=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function smallMulTo(e,t,a){a.negative=t.negative^e.negative;var r=e.length+t.length|0;a.length=r,r=r-1|0;var n=0|e.words[0],c=0|t.words[0],o=n*c,d=67108863&o,s=o/67108864|0;a.words[0]=d;for(var b=1;b>>26,h=67108863&s,l=Math.min(b,t.length-1),g=Math.max(0,b-e.length+1);g<=l;g++){var p=b-g|0;u+=(o=(n=0|e.words[p])*(c=0|t.words[g])+h)/67108864|0,h=67108863&o}a.words[b]=0|h,s=0|u}return 0!==s?a.words[b]=0|s:a.length--,a.strip()}BN.prototype.toString=function toString(e,t){var a;if(t=0|t||1,16===(e=e||10)||"hex"===e){a="";for(var r=0,d=0,s=0;s>>24-r&16777215)||s!==this.length-1?n[6-u.length]+u+a:u+a,(r+=2)>=26&&(r-=26,s--)}for(0!==d&&(a=d.toString(16)+a);a.length%t!=0;)a="0"+a;return 0!==this.negative&&(a="-"+a),a}if(e===(0|e)&&e>=2&&e<=36){var h=c[e],l=o[e];a="";var g=this.clone();for(g.negative=0;!g.isZero();){var p=g.modn(l).toString(e);a=(g=g.idivn(l)).isZero()?p+a:n[h-p.length]+p+a}for(this.isZero()&&(a="0"+a);a.length%t!=0;)a="0"+a;return 0!==this.negative&&(a="-"+a),a}assert(!1,"Base should be between 2 and 36")},BN.prototype.toNumber=function toNumber(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&assert(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},BN.prototype.toJSON=function toJSON(){return this.toString(16)},BN.prototype.toBuffer=function toBuffer(e,t){return assert(void 0!==r),this.toArrayLike(r,e,t)},BN.prototype.toArray=function toArray(e,t){return this.toArrayLike(Array,e,t)},BN.prototype.toArrayLike=function toArrayLike(e,t,a){var r=this.byteLength(),n=a||Math.max(1,r);assert(r<=n,"byte array longer than desired length"),assert(n>0,"Requested array length <= 0"),this.strip();var c,o,d="le"===t,s=new e(n),b=this.clone();if(d){for(o=0;!b.isZero();o++)c=b.andln(255),b.iushrn(8),s[o]=c;for(;o=4096&&(a+=13,t>>>=13),t>=64&&(a+=7,t>>>=7),t>=8&&(a+=4,t>>>=4),t>=2&&(a+=2,t>>>=2),a+t},BN.prototype._zeroBits=function _zeroBits(e){if(0===e)return 26;var t=e,a=0;return 0==(8191&t)&&(a+=13,t>>>=13),0==(127&t)&&(a+=7,t>>>=7),0==(15&t)&&(a+=4,t>>>=4),0==(3&t)&&(a+=2,t>>>=2),0==(1&t)&&a++,a},BN.prototype.bitLength=function bitLength(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},BN.prototype.zeroBits=function zeroBits(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},BN.prototype.uor=function uor(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},BN.prototype.iuand=function iuand(e){var t;t=this.length>e.length?e:this;for(var a=0;ae.length?this.clone().iand(e):e.clone().iand(this)},BN.prototype.uand=function uand(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},BN.prototype.iuxor=function iuxor(e){var t,a;this.length>e.length?(t=this,a=e):(t=e,a=this);for(var r=0;re.length?this.clone().ixor(e):e.clone().ixor(this)},BN.prototype.uxor=function uxor(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},BN.prototype.inotn=function inotn(e){assert("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),a=e%26;this._expand(t),a>0&&t--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-a),this.strip()},BN.prototype.notn=function notn(e){return this.clone().inotn(e)},BN.prototype.setn=function setn(e,t){assert("number"==typeof e&&e>=0);var a=e/26|0,r=e%26;return this._expand(a+1),this.words[a]=t?this.words[a]|1<e.length?(a=this,r=e):(a=e,r=this);for(var n=0,c=0;c>>26;for(;0!==n&&c>>26;if(this.length=a.length,0!==n)this.words[this.length]=n,this.length++;else if(a!==this)for(;ce.length?this.clone().iadd(e):e.clone().iadd(this)},BN.prototype.isub=function isub(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var a,r,n=this.cmp(e);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(a=this,r=e):(a=e,r=this);for(var c=0,o=0;o>26,this.words[o]=67108863&t;for(;0!==c&&o>26,this.words[o]=67108863&t;if(0===c&&o>>13,g=0|o[1],p=8191&g,B=g>>>13,x=0|o[2],I=8191&x,m=x>>>13,y=0|o[3],C=8191&y,w=y>>>13,v=0|o[4],Q=8191&v,k=v>>>13,_=0|o[5],N=8191&_,D=_>>>13,G=0|o[6],L=8191&G,T=G>>>13,U=0|o[7],P=8191&U,q=U>>>13,H=0|o[8],O=8191&H,z=H>>>13,J=0|o[9],j=8191&J,Y=J>>>13,W=0|d[0],V=8191&W,X=W>>>13,$=0|d[1],et=8191&$,tt=$>>>13,at=0|d[2],rt=8191&at,it=at>>>13,nt=0|d[3],ct=8191&nt,ot=nt>>>13,dt=0|d[4],At=8191&dt,st=dt>>>13,bt=0|d[5],ut=8191&bt,ht=bt>>>13,pt=0|d[6],Bt=8191&pt,xt=pt>>>13,It=0|d[7],mt=8191&It,Et=It>>>13,yt=0|d[8],Ct=8191&yt,wt=yt>>>13,vt=0|d[9],Qt=8191&vt,Mt=vt>>>13;a.negative=e.negative^t.negative,a.length=19;var kt=(b+(r=Math.imul(h,V))|0)+((8191&(n=(n=Math.imul(h,X))+Math.imul(l,V)|0))<<13)|0;b=((c=Math.imul(l,X))+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(p,V),n=(n=Math.imul(p,X))+Math.imul(B,V)|0,c=Math.imul(B,X);var _t=(b+(r=r+Math.imul(h,et)|0)|0)+((8191&(n=(n=n+Math.imul(h,tt)|0)+Math.imul(l,et)|0))<<13)|0;b=((c=c+Math.imul(l,tt)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(I,V),n=(n=Math.imul(I,X))+Math.imul(m,V)|0,c=Math.imul(m,X),r=r+Math.imul(p,et)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(B,et)|0,c=c+Math.imul(B,tt)|0;var St=(b+(r=r+Math.imul(h,rt)|0)|0)+((8191&(n=(n=n+Math.imul(h,it)|0)+Math.imul(l,rt)|0))<<13)|0;b=((c=c+Math.imul(l,it)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(C,V),n=(n=Math.imul(C,X))+Math.imul(w,V)|0,c=Math.imul(w,X),r=r+Math.imul(I,et)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(m,et)|0,c=c+Math.imul(m,tt)|0,r=r+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(B,rt)|0,c=c+Math.imul(B,it)|0;var Nt=(b+(r=r+Math.imul(h,ct)|0)|0)+((8191&(n=(n=n+Math.imul(h,ot)|0)+Math.imul(l,ct)|0))<<13)|0;b=((c=c+Math.imul(l,ot)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,r=Math.imul(Q,V),n=(n=Math.imul(Q,X))+Math.imul(k,V)|0,c=Math.imul(k,X),r=r+Math.imul(C,et)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(w,et)|0,c=c+Math.imul(w,tt)|0,r=r+Math.imul(I,rt)|0,n=(n=n+Math.imul(I,it)|0)+Math.imul(m,rt)|0,c=c+Math.imul(m,it)|0,r=r+Math.imul(p,ct)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(B,ct)|0,c=c+Math.imul(B,ot)|0;var Dt=(b+(r=r+Math.imul(h,At)|0)|0)+((8191&(n=(n=n+Math.imul(h,st)|0)+Math.imul(l,At)|0))<<13)|0;b=((c=c+Math.imul(l,st)|0)+(n>>>13)|0)+(Dt>>>26)|0,Dt&=67108863,r=Math.imul(N,V),n=(n=Math.imul(N,X))+Math.imul(D,V)|0,c=Math.imul(D,X),r=r+Math.imul(Q,et)|0,n=(n=n+Math.imul(Q,tt)|0)+Math.imul(k,et)|0,c=c+Math.imul(k,tt)|0,r=r+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(w,rt)|0,c=c+Math.imul(w,it)|0,r=r+Math.imul(I,ct)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(m,ct)|0,c=c+Math.imul(m,ot)|0,r=r+Math.imul(p,At)|0,n=(n=n+Math.imul(p,st)|0)+Math.imul(B,At)|0,c=c+Math.imul(B,st)|0;var Rt=(b+(r=r+Math.imul(h,ut)|0)|0)+((8191&(n=(n=n+Math.imul(h,ht)|0)+Math.imul(l,ut)|0))<<13)|0;b=((c=c+Math.imul(l,ht)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(L,V),n=(n=Math.imul(L,X))+Math.imul(T,V)|0,c=Math.imul(T,X),r=r+Math.imul(N,et)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(D,et)|0,c=c+Math.imul(D,tt)|0,r=r+Math.imul(Q,rt)|0,n=(n=n+Math.imul(Q,it)|0)+Math.imul(k,rt)|0,c=c+Math.imul(k,it)|0,r=r+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,ot)|0)+Math.imul(w,ct)|0,c=c+Math.imul(w,ot)|0,r=r+Math.imul(I,At)|0,n=(n=n+Math.imul(I,st)|0)+Math.imul(m,At)|0,c=c+Math.imul(m,st)|0,r=r+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,ht)|0)+Math.imul(B,ut)|0,c=c+Math.imul(B,ht)|0;var Ft=(b+(r=r+Math.imul(h,Bt)|0)|0)+((8191&(n=(n=n+Math.imul(h,xt)|0)+Math.imul(l,Bt)|0))<<13)|0;b=((c=c+Math.imul(l,xt)|0)+(n>>>13)|0)+(Ft>>>26)|0,Ft&=67108863,r=Math.imul(P,V),n=(n=Math.imul(P,X))+Math.imul(q,V)|0,c=Math.imul(q,X),r=r+Math.imul(L,et)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(T,et)|0,c=c+Math.imul(T,tt)|0,r=r+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(D,rt)|0,c=c+Math.imul(D,it)|0,r=r+Math.imul(Q,ct)|0,n=(n=n+Math.imul(Q,ot)|0)+Math.imul(k,ct)|0,c=c+Math.imul(k,ot)|0,r=r+Math.imul(C,At)|0,n=(n=n+Math.imul(C,st)|0)+Math.imul(w,At)|0,c=c+Math.imul(w,st)|0,r=r+Math.imul(I,ut)|0,n=(n=n+Math.imul(I,ht)|0)+Math.imul(m,ut)|0,c=c+Math.imul(m,ht)|0,r=r+Math.imul(p,Bt)|0,n=(n=n+Math.imul(p,xt)|0)+Math.imul(B,Bt)|0,c=c+Math.imul(B,xt)|0;var Gt=(b+(r=r+Math.imul(h,mt)|0)|0)+((8191&(n=(n=n+Math.imul(h,Et)|0)+Math.imul(l,mt)|0))<<13)|0;b=((c=c+Math.imul(l,Et)|0)+(n>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,r=Math.imul(O,V),n=(n=Math.imul(O,X))+Math.imul(z,V)|0,c=Math.imul(z,X),r=r+Math.imul(P,et)|0,n=(n=n+Math.imul(P,tt)|0)+Math.imul(q,et)|0,c=c+Math.imul(q,tt)|0,r=r+Math.imul(L,rt)|0,n=(n=n+Math.imul(L,it)|0)+Math.imul(T,rt)|0,c=c+Math.imul(T,it)|0,r=r+Math.imul(N,ct)|0,n=(n=n+Math.imul(N,ot)|0)+Math.imul(D,ct)|0,c=c+Math.imul(D,ot)|0,r=r+Math.imul(Q,At)|0,n=(n=n+Math.imul(Q,st)|0)+Math.imul(k,At)|0,c=c+Math.imul(k,st)|0,r=r+Math.imul(C,ut)|0,n=(n=n+Math.imul(C,ht)|0)+Math.imul(w,ut)|0,c=c+Math.imul(w,ht)|0,r=r+Math.imul(I,Bt)|0,n=(n=n+Math.imul(I,xt)|0)+Math.imul(m,Bt)|0,c=c+Math.imul(m,xt)|0,r=r+Math.imul(p,mt)|0,n=(n=n+Math.imul(p,Et)|0)+Math.imul(B,mt)|0,c=c+Math.imul(B,Et)|0;var Lt=(b+(r=r+Math.imul(h,Ct)|0)|0)+((8191&(n=(n=n+Math.imul(h,wt)|0)+Math.imul(l,Ct)|0))<<13)|0;b=((c=c+Math.imul(l,wt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,r=Math.imul(j,V),n=(n=Math.imul(j,X))+Math.imul(Y,V)|0,c=Math.imul(Y,X),r=r+Math.imul(O,et)|0,n=(n=n+Math.imul(O,tt)|0)+Math.imul(z,et)|0,c=c+Math.imul(z,tt)|0,r=r+Math.imul(P,rt)|0,n=(n=n+Math.imul(P,it)|0)+Math.imul(q,rt)|0,c=c+Math.imul(q,it)|0,r=r+Math.imul(L,ct)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(T,ct)|0,c=c+Math.imul(T,ot)|0,r=r+Math.imul(N,At)|0,n=(n=n+Math.imul(N,st)|0)+Math.imul(D,At)|0,c=c+Math.imul(D,st)|0,r=r+Math.imul(Q,ut)|0,n=(n=n+Math.imul(Q,ht)|0)+Math.imul(k,ut)|0,c=c+Math.imul(k,ht)|0,r=r+Math.imul(C,Bt)|0,n=(n=n+Math.imul(C,xt)|0)+Math.imul(w,Bt)|0,c=c+Math.imul(w,xt)|0,r=r+Math.imul(I,mt)|0,n=(n=n+Math.imul(I,Et)|0)+Math.imul(m,mt)|0,c=c+Math.imul(m,Et)|0,r=r+Math.imul(p,Ct)|0,n=(n=n+Math.imul(p,wt)|0)+Math.imul(B,Ct)|0,c=c+Math.imul(B,wt)|0;var Tt=(b+(r=r+Math.imul(h,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(h,Mt)|0)+Math.imul(l,Qt)|0))<<13)|0;b=((c=c+Math.imul(l,Mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(j,et),n=(n=Math.imul(j,tt))+Math.imul(Y,et)|0,c=Math.imul(Y,tt),r=r+Math.imul(O,rt)|0,n=(n=n+Math.imul(O,it)|0)+Math.imul(z,rt)|0,c=c+Math.imul(z,it)|0,r=r+Math.imul(P,ct)|0,n=(n=n+Math.imul(P,ot)|0)+Math.imul(q,ct)|0,c=c+Math.imul(q,ot)|0,r=r+Math.imul(L,At)|0,n=(n=n+Math.imul(L,st)|0)+Math.imul(T,At)|0,c=c+Math.imul(T,st)|0,r=r+Math.imul(N,ut)|0,n=(n=n+Math.imul(N,ht)|0)+Math.imul(D,ut)|0,c=c+Math.imul(D,ht)|0,r=r+Math.imul(Q,Bt)|0,n=(n=n+Math.imul(Q,xt)|0)+Math.imul(k,Bt)|0,c=c+Math.imul(k,xt)|0,r=r+Math.imul(C,mt)|0,n=(n=n+Math.imul(C,Et)|0)+Math.imul(w,mt)|0,c=c+Math.imul(w,Et)|0,r=r+Math.imul(I,Ct)|0,n=(n=n+Math.imul(I,wt)|0)+Math.imul(m,Ct)|0,c=c+Math.imul(m,wt)|0;var Ut=(b+(r=r+Math.imul(p,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(p,Mt)|0)+Math.imul(B,Qt)|0))<<13)|0;b=((c=c+Math.imul(B,Mt)|0)+(n>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,r=Math.imul(j,rt),n=(n=Math.imul(j,it))+Math.imul(Y,rt)|0,c=Math.imul(Y,it),r=r+Math.imul(O,ct)|0,n=(n=n+Math.imul(O,ot)|0)+Math.imul(z,ct)|0,c=c+Math.imul(z,ot)|0,r=r+Math.imul(P,At)|0,n=(n=n+Math.imul(P,st)|0)+Math.imul(q,At)|0,c=c+Math.imul(q,st)|0,r=r+Math.imul(L,ut)|0,n=(n=n+Math.imul(L,ht)|0)+Math.imul(T,ut)|0,c=c+Math.imul(T,ht)|0,r=r+Math.imul(N,Bt)|0,n=(n=n+Math.imul(N,xt)|0)+Math.imul(D,Bt)|0,c=c+Math.imul(D,xt)|0,r=r+Math.imul(Q,mt)|0,n=(n=n+Math.imul(Q,Et)|0)+Math.imul(k,mt)|0,c=c+Math.imul(k,Et)|0,r=r+Math.imul(C,Ct)|0,n=(n=n+Math.imul(C,wt)|0)+Math.imul(w,Ct)|0,c=c+Math.imul(w,wt)|0;var Pt=(b+(r=r+Math.imul(I,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(I,Mt)|0)+Math.imul(m,Qt)|0))<<13)|0;b=((c=c+Math.imul(m,Mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(j,ct),n=(n=Math.imul(j,ot))+Math.imul(Y,ct)|0,c=Math.imul(Y,ot),r=r+Math.imul(O,At)|0,n=(n=n+Math.imul(O,st)|0)+Math.imul(z,At)|0,c=c+Math.imul(z,st)|0,r=r+Math.imul(P,ut)|0,n=(n=n+Math.imul(P,ht)|0)+Math.imul(q,ut)|0,c=c+Math.imul(q,ht)|0,r=r+Math.imul(L,Bt)|0,n=(n=n+Math.imul(L,xt)|0)+Math.imul(T,Bt)|0,c=c+Math.imul(T,xt)|0,r=r+Math.imul(N,mt)|0,n=(n=n+Math.imul(N,Et)|0)+Math.imul(D,mt)|0,c=c+Math.imul(D,Et)|0,r=r+Math.imul(Q,Ct)|0,n=(n=n+Math.imul(Q,wt)|0)+Math.imul(k,Ct)|0,c=c+Math.imul(k,wt)|0;var qt=(b+(r=r+Math.imul(C,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(C,Mt)|0)+Math.imul(w,Qt)|0))<<13)|0;b=((c=c+Math.imul(w,Mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863,r=Math.imul(j,At),n=(n=Math.imul(j,st))+Math.imul(Y,At)|0,c=Math.imul(Y,st),r=r+Math.imul(O,ut)|0,n=(n=n+Math.imul(O,ht)|0)+Math.imul(z,ut)|0,c=c+Math.imul(z,ht)|0,r=r+Math.imul(P,Bt)|0,n=(n=n+Math.imul(P,xt)|0)+Math.imul(q,Bt)|0,c=c+Math.imul(q,xt)|0,r=r+Math.imul(L,mt)|0,n=(n=n+Math.imul(L,Et)|0)+Math.imul(T,mt)|0,c=c+Math.imul(T,Et)|0,r=r+Math.imul(N,Ct)|0,n=(n=n+Math.imul(N,wt)|0)+Math.imul(D,Ct)|0,c=c+Math.imul(D,wt)|0;var Ht=(b+(r=r+Math.imul(Q,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(Q,Mt)|0)+Math.imul(k,Qt)|0))<<13)|0;b=((c=c+Math.imul(k,Mt)|0)+(n>>>13)|0)+(Ht>>>26)|0,Ht&=67108863,r=Math.imul(j,ut),n=(n=Math.imul(j,ht))+Math.imul(Y,ut)|0,c=Math.imul(Y,ht),r=r+Math.imul(O,Bt)|0,n=(n=n+Math.imul(O,xt)|0)+Math.imul(z,Bt)|0,c=c+Math.imul(z,xt)|0,r=r+Math.imul(P,mt)|0,n=(n=n+Math.imul(P,Et)|0)+Math.imul(q,mt)|0,c=c+Math.imul(q,Et)|0,r=r+Math.imul(L,Ct)|0,n=(n=n+Math.imul(L,wt)|0)+Math.imul(T,Ct)|0,c=c+Math.imul(T,wt)|0;var Ot=(b+(r=r+Math.imul(N,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(N,Mt)|0)+Math.imul(D,Qt)|0))<<13)|0;b=((c=c+Math.imul(D,Mt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,r=Math.imul(j,Bt),n=(n=Math.imul(j,xt))+Math.imul(Y,Bt)|0,c=Math.imul(Y,xt),r=r+Math.imul(O,mt)|0,n=(n=n+Math.imul(O,Et)|0)+Math.imul(z,mt)|0,c=c+Math.imul(z,Et)|0,r=r+Math.imul(P,Ct)|0,n=(n=n+Math.imul(P,wt)|0)+Math.imul(q,Ct)|0,c=c+Math.imul(q,wt)|0;var zt=(b+(r=r+Math.imul(L,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(L,Mt)|0)+Math.imul(T,Qt)|0))<<13)|0;b=((c=c+Math.imul(T,Mt)|0)+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863,r=Math.imul(j,mt),n=(n=Math.imul(j,Et))+Math.imul(Y,mt)|0,c=Math.imul(Y,Et),r=r+Math.imul(O,Ct)|0,n=(n=n+Math.imul(O,wt)|0)+Math.imul(z,Ct)|0,c=c+Math.imul(z,wt)|0;var Kt=(b+(r=r+Math.imul(P,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(P,Mt)|0)+Math.imul(q,Qt)|0))<<13)|0;b=((c=c+Math.imul(q,Mt)|0)+(n>>>13)|0)+(Kt>>>26)|0,Kt&=67108863,r=Math.imul(j,Ct),n=(n=Math.imul(j,wt))+Math.imul(Y,Ct)|0,c=Math.imul(Y,wt);var Jt=(b+(r=r+Math.imul(O,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(O,Mt)|0)+Math.imul(z,Qt)|0))<<13)|0;b=((c=c+Math.imul(z,Mt)|0)+(n>>>13)|0)+(Jt>>>26)|0,Jt&=67108863;var jt=(b+(r=Math.imul(j,Qt))|0)+((8191&(n=(n=Math.imul(j,Mt))+Math.imul(Y,Qt)|0))<<13)|0;return b=((c=Math.imul(Y,Mt))+(n>>>13)|0)+(jt>>>26)|0,jt&=67108863,s[0]=kt,s[1]=_t,s[2]=St,s[3]=Nt,s[4]=Dt,s[5]=Rt,s[6]=Ft,s[7]=Gt,s[8]=Lt,s[9]=Tt,s[10]=Ut,s[11]=Pt,s[12]=qt,s[13]=Ht,s[14]=Ot,s[15]=zt,s[16]=Kt,s[17]=Jt,s[18]=jt,0!==b&&(s[19]=b,a.length++),a};function jumboMulTo(e,t,a){return(new FFTM).mulp(e,t,a)}function FFTM(e,t){this.x=e,this.y=t}Math.imul||(d=smallMulTo),BN.prototype.mulTo=function mulTo(e,t){var a,r=this.length+e.length;return a=10===this.length&&10===e.length?d(this,e,t):r<63?smallMulTo(this,e,t):r<1024?function bigMulTo(e,t,a){a.negative=t.negative^e.negative,a.length=e.length+t.length;for(var r=0,n=0,c=0;c>>26)|0)>>>26,o&=67108863}a.words[c]=d,r=o,o=n}return 0!==r?a.words[c]=r:a.length--,a.strip()}(this,e,t):jumboMulTo(this,e,t),a},FFTM.prototype.makeRBT=function makeRBT(e){for(var t=new Array(e),a=BN.prototype._countBits(e)-1,r=0;r>=1;return r},FFTM.prototype.permute=function permute(e,t,a,r,n,c){for(var o=0;o>>=1)n++;return 1<>>=13,a[2*c+1]=8191&n,n>>>=13;for(c=2*t;c>=26,t+=r/67108864|0,t+=n>>>26,this.words[a]=67108863&n}return 0!==t&&(this.words[a]=t,this.length++),this},BN.prototype.muln=function muln(e){return this.clone().imuln(e)},BN.prototype.sqr=function sqr(){return this.mul(this)},BN.prototype.isqr=function isqr(){return this.imul(this.clone())},BN.prototype.pow=function pow(e){var t=function toBitArray(e){for(var t=new Array(e.bitLength()),a=0;a>>n}return t}(e);if(0===t.length)return new BN(1);for(var a=this,r=0;r=0);var t,a=e%26,r=(e-a)/26,n=67108863>>>26-a<<26-a;if(0!==a){var c=0;for(t=0;t>>26-a}c&&(this.words[t]=c,this.length++)}if(0!==r){for(t=this.length-1;t>=0;t--)this.words[t+r]=this.words[t];for(t=0;t=0),r=t?(t-t%26)/26:0;var n=e%26,c=Math.min((e-n)/26,this.length),o=67108863^67108863>>>n<c)for(this.length-=c,s=0;s=0&&(0!==b||s>=r);s--){var u=0|this.words[s];this.words[s]=b<<26-n|u>>>n,b=u&o}return d&&0!==b&&(d.words[d.length++]=b),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},BN.prototype.ishrn=function ishrn(e,t,a){return assert(0===this.negative),this.iushrn(e,t,a)},BN.prototype.shln=function shln(e){return this.clone().ishln(e)},BN.prototype.ushln=function ushln(e){return this.clone().iushln(e)},BN.prototype.shrn=function shrn(e){return this.clone().ishrn(e)},BN.prototype.ushrn=function ushrn(e){return this.clone().iushrn(e)},BN.prototype.testn=function testn(e){assert("number"==typeof e&&e>=0);var t=e%26,a=(e-t)/26,r=1<=0);var t=e%26,a=(e-t)/26;if(assert(0===this.negative,"imaskn works only with positive numbers"),this.length<=a)return this;if(0!==t&&a++,this.length=Math.min(a,this.length),0!==t){var r=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},BN.prototype.isubn=function isubn(e){if(assert("number"==typeof e),assert(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(d/67108864|0),this.words[r+a]=67108863&n}for(;r>26,this.words[r+a]=67108863&n;if(0===o)return this.strip();for(assert(-1===o),o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},BN.prototype._wordDiv=function _wordDiv(e,t){var a=(this.length,e.length),r=this.clone(),n=e,c=0|n.words[n.length-1];0!==(a=26-this._countBits(c))&&(n=n.ushln(a),r.iushln(a),c=0|n.words[n.length-1]);var o,d=r.length-n.length;if("mod"!==t){(o=new BN(null)).length=d+1,o.words=new Array(o.length);for(var s=0;s=0;u--){var h=67108864*(0|r.words[n.length+u])+(0|r.words[n.length+u-1]);for(h=Math.min(h/c|0,67108863),r._ishlnsubmul(n,h,u);0!==r.negative;)h--,r.negative=0,r._ishlnsubmul(n,1,u),r.isZero()||(r.negative^=1);o&&(o.words[u]=h)}return o&&o.strip(),r.strip(),"div"!==t&&0!==a&&r.iushrn(a),{div:o||null,mod:r}},BN.prototype.divmod=function divmod(e,t,a){return assert(!e.isZero()),this.isZero()?{div:new BN(0),mod:new BN(0)}:0!==this.negative&&0===e.negative?(c=this.neg().divmod(e,t),"mod"!==t&&(r=c.div.neg()),"div"!==t&&(n=c.mod.neg(),a&&0!==n.negative&&n.iadd(e)),{div:r,mod:n}):0===this.negative&&0!==e.negative?(c=this.divmod(e.neg(),t),"mod"!==t&&(r=c.div.neg()),{div:r,mod:c.mod}):0!=(this.negative&e.negative)?(c=this.neg().divmod(e.neg(),t),"div"!==t&&(n=c.mod.neg(),a&&0!==n.negative&&n.isub(e)),{div:c.div,mod:n}):e.length>this.length||this.cmp(e)<0?{div:new BN(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new BN(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new BN(this.modn(e.words[0]))}:this._wordDiv(e,t);var r,n,c},BN.prototype.div=function div(e){return this.divmod(e,"div",!1).div},BN.prototype.mod=function mod(e){return this.divmod(e,"mod",!1).mod},BN.prototype.umod=function umod(e){return this.divmod(e,"mod",!0).mod},BN.prototype.divRound=function divRound(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var a=0!==t.div.negative?t.mod.isub(e):t.mod,r=e.ushrn(1),n=e.andln(1),c=a.cmp(r);return c<0||1===n&&0===c?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},BN.prototype.modn=function modn(e){assert(e<=67108863);for(var t=(1<<26)%e,a=0,r=this.length-1;r>=0;r--)a=(t*a+(0|this.words[r]))%e;return a},BN.prototype.idivn=function idivn(e){assert(e<=67108863);for(var t=0,a=this.length-1;a>=0;a--){var r=(0|this.words[a])+67108864*t;this.words[a]=r/e|0,t=r%e}return this.strip()},BN.prototype.divn=function divn(e){return this.clone().idivn(e)},BN.prototype.egcd=function egcd(e){assert(0===e.negative),assert(!e.isZero());var t=this,a=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var r=new BN(1),n=new BN(0),c=new BN(0),o=new BN(1),d=0;t.isEven()&&a.isEven();)t.iushrn(1),a.iushrn(1),++d;for(var s=a.clone(),b=t.clone();!t.isZero();){for(var u=0,h=1;0==(t.words[0]&h)&&u<26;++u,h<<=1);if(u>0)for(t.iushrn(u);u-- >0;)(r.isOdd()||n.isOdd())&&(r.iadd(s),n.isub(b)),r.iushrn(1),n.iushrn(1);for(var l=0,g=1;0==(a.words[0]&g)&&l<26;++l,g<<=1);if(l>0)for(a.iushrn(l);l-- >0;)(c.isOdd()||o.isOdd())&&(c.iadd(s),o.isub(b)),c.iushrn(1),o.iushrn(1);t.cmp(a)>=0?(t.isub(a),r.isub(c),n.isub(o)):(a.isub(t),c.isub(r),o.isub(n))}return{a:c,b:o,gcd:a.iushln(d)}},BN.prototype._invmp=function _invmp(e){assert(0===e.negative),assert(!e.isZero());var t=this,a=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var r,n=new BN(1),c=new BN(0),o=a.clone();t.cmpn(1)>0&&a.cmpn(1)>0;){for(var d=0,s=1;0==(t.words[0]&s)&&d<26;++d,s<<=1);if(d>0)for(t.iushrn(d);d-- >0;)n.isOdd()&&n.iadd(o),n.iushrn(1);for(var b=0,u=1;0==(a.words[0]&u)&&b<26;++b,u<<=1);if(b>0)for(a.iushrn(b);b-- >0;)c.isOdd()&&c.iadd(o),c.iushrn(1);t.cmp(a)>=0?(t.isub(a),n.isub(c)):(a.isub(t),c.isub(n))}return(r=0===t.cmpn(1)?n:c).cmpn(0)<0&&r.iadd(e),r},BN.prototype.gcd=function gcd(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),a=e.clone();t.negative=0,a.negative=0;for(var r=0;t.isEven()&&a.isEven();r++)t.iushrn(1),a.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;a.isEven();)a.iushrn(1);var n=t.cmp(a);if(n<0){var c=t;t=a,a=c}else if(0===n||0===a.cmpn(1))break;t.isub(a)}return a.iushln(r)},BN.prototype.invm=function invm(e){return this.egcd(e).a.umod(e)},BN.prototype.isEven=function isEven(){return 0==(1&this.words[0])},BN.prototype.isOdd=function isOdd(){return 1==(1&this.words[0])},BN.prototype.andln=function andln(e){return this.words[0]&e},BN.prototype.bincn=function bincn(e){assert("number"==typeof e);var t=e%26,a=(e-t)/26,r=1<>>26,o&=67108863,this.words[c]=o}return 0!==n&&(this.words[c]=n,this.length++),this},BN.prototype.isZero=function isZero(){return 1===this.length&&0===this.words[0]},BN.prototype.cmpn=function cmpn(e){var t,a=e<0;if(0!==this.negative&&!a)return-1;if(0===this.negative&&a)return 1;if(this.strip(),this.length>1)t=1;else{a&&(e=-e),assert(e<=67108863,"Number is too big");var r=0|this.words[0];t=r===e?0:re.length)return 1;if(this.length=0;a--){var r=0|this.words[a],n=0|e.words[a];if(r!==n){rn&&(t=1);break}}return t},BN.prototype.gtn=function gtn(e){return 1===this.cmpn(e)},BN.prototype.gt=function gt(e){return 1===this.cmp(e)},BN.prototype.gten=function gten(e){return this.cmpn(e)>=0},BN.prototype.gte=function gte(e){return this.cmp(e)>=0},BN.prototype.ltn=function ltn(e){return-1===this.cmpn(e)},BN.prototype.lt=function lt(e){return-1===this.cmp(e)},BN.prototype.lten=function lten(e){return this.cmpn(e)<=0},BN.prototype.lte=function lte(e){return this.cmp(e)<=0},BN.prototype.eqn=function eqn(e){return 0===this.cmpn(e)},BN.prototype.eq=function eq(e){return 0===this.cmp(e)},BN.red=function red(e){return new Red(e)},BN.prototype.toRed=function toRed(e){return assert(!this.red,"Already a number in reduction context"),assert(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},BN.prototype.fromRed=function fromRed(){return assert(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},BN.prototype._forceRed=function _forceRed(e){return this.red=e,this},BN.prototype.forceRed=function forceRed(e){return assert(!this.red,"Already a number in reduction context"),this._forceRed(e)},BN.prototype.redAdd=function redAdd(e){return assert(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},BN.prototype.redIAdd=function redIAdd(e){return assert(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},BN.prototype.redSub=function redSub(e){return assert(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},BN.prototype.redISub=function redISub(e){return assert(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},BN.prototype.redShl=function redShl(e){return assert(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},BN.prototype.redMul=function redMul(e){return assert(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},BN.prototype.redIMul=function redIMul(e){return assert(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},BN.prototype.redSqr=function redSqr(){return assert(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},BN.prototype.redISqr=function redISqr(){return assert(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},BN.prototype.redSqrt=function redSqrt(){return assert(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},BN.prototype.redInvm=function redInvm(){return assert(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},BN.prototype.redNeg=function redNeg(){return assert(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},BN.prototype.redPow=function redPow(e){return assert(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var s={k256:null,p224:null,p192:null,p25519:null};function MPrime(e,t){this.name=e,this.p=new BN(t,16),this.n=this.p.bitLength(),this.k=new BN(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function K256(){MPrime.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function P224(){MPrime.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function P192(){MPrime.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function P25519(){MPrime.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function Red(e){if("string"==typeof e){var t=BN._prime(e);this.m=t.p,this.prime=t}else assert(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function Mont(e){Red.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new BN(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)}MPrime.prototype._tmp=function _tmp(){var e=new BN(null);return e.words=new Array(Math.ceil(this.n/13)),e},MPrime.prototype.ireduce=function ireduce(e){var t,a=e;do{this.split(a,this.tmp),t=(a=(a=this.imulK(a)).iadd(this.tmp)).bitLength()}while(t>this.n);var r=t0?a.isub(this.p):void 0!==a.strip?a.strip():a._strip(),a},MPrime.prototype.split=function split(e,t){e.iushrn(this.n,0,t)},MPrime.prototype.imulK=function imulK(e){return e.imul(this.k)},inherits(K256,MPrime),K256.prototype.split=function split(e,t){for(var a=4194303,r=Math.min(e.length,9),n=0;n>>22,c=o}c>>>=22,e.words[n-10]=c,0===c&&e.length>10?e.length-=10:e.length-=9},K256.prototype.imulK=function imulK(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,a=0;a>>=26,e.words[a]=n,t=r}return 0!==t&&(e.words[e.length++]=t),e},BN._prime=function prime(e){if(s[e])return s[e];var prime;if("k256"===e)prime=new K256;else if("p224"===e)prime=new P224;else if("p192"===e)prime=new P192;else{if("p25519"!==e)throw new Error("Unknown prime "+e);prime=new P25519}return s[e]=prime,prime},Red.prototype._verify1=function _verify1(e){assert(0===e.negative,"red works only with positives"),assert(e.red,"red works only with red numbers")},Red.prototype._verify2=function _verify2(e,t){assert(0==(e.negative|t.negative),"red works only with positives"),assert(e.red&&e.red===t.red,"red works only with red numbers")},Red.prototype.imod=function imod(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},Red.prototype.neg=function neg(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},Red.prototype.add=function add(e,t){this._verify2(e,t);var a=e.add(t);return a.cmp(this.m)>=0&&a.isub(this.m),a._forceRed(this)},Red.prototype.iadd=function iadd(e,t){this._verify2(e,t);var a=e.iadd(t);return a.cmp(this.m)>=0&&a.isub(this.m),a},Red.prototype.sub=function sub(e,t){this._verify2(e,t);var a=e.sub(t);return a.cmpn(0)<0&&a.iadd(this.m),a._forceRed(this)},Red.prototype.isub=function isub(e,t){this._verify2(e,t);var a=e.isub(t);return a.cmpn(0)<0&&a.iadd(this.m),a},Red.prototype.shl=function shl(e,t){return this._verify1(e),this.imod(e.ushln(t))},Red.prototype.imul=function imul(e,t){return this._verify2(e,t),this.imod(e.imul(t))},Red.prototype.mul=function mul(e,t){return this._verify2(e,t),this.imod(e.mul(t))},Red.prototype.isqr=function isqr(e){return this.imul(e,e.clone())},Red.prototype.sqr=function sqr(e){return this.mul(e,e)},Red.prototype.sqrt=function sqrt(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(assert(t%2==1),3===t){var a=this.m.add(new BN(1)).iushrn(2);return this.pow(e,a)}for(var r=this.m.subn(1),n=0;!r.isZero()&&0===r.andln(1);)n++,r.iushrn(1);assert(!r.isZero());var c=new BN(1).toRed(this),o=c.redNeg(),d=this.m.subn(1).iushrn(1),s=this.m.bitLength();for(s=new BN(2*s*s).toRed(this);0!==this.pow(s,d).cmp(o);)s.redIAdd(o);for(var b=this.pow(s,r),u=this.pow(e,r.addn(1).iushrn(1)),h=this.pow(e,r),l=n;0!==h.cmp(c);){for(var g=h,p=0;0!==g.cmp(c);p++)g=g.redSqr();assert(p=0;r--){for(var s=t.words[r],b=d-1;b>=0;b--){var u=s>>b&1;n!==a[0]&&(n=this.sqr(n)),0!==u||0!==c?(c<<=1,c|=u,(4===++o||0===r&&0===b)&&(n=this.mul(n,a[c]),o=0,c=0)):o=0}d=26}return n},Red.prototype.convertTo=function convertTo(e){var t=e.umod(this.m);return t===e?t.clone():t},Red.prototype.convertFrom=function convertFrom(e){var t=e.clone();return t.red=null,t},BN.mont=function mont(e){return new Mont(e)},inherits(Mont,Red),Mont.prototype.convertTo=function convertTo(e){return this.imod(e.ushln(this.shift))},Mont.prototype.convertFrom=function convertFrom(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},Mont.prototype.imul=function imul(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var a=e.imul(t),r=a.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=a.isub(r).iushrn(this.shift),c=n;return n.cmp(this.m)>=0?c=n.isub(this.m):n.cmpn(0)<0&&(c=n.iadd(this.m)),c._forceRed(this)},Mont.prototype.mul=function mul(e,t){if(e.isZero()||t.isZero())return new BN(0)._forceRed(this);var a=e.mul(t),r=a.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=a.isub(r).iushrn(this.shift),c=n;return n.cmp(this.m)>=0?c=n.isub(this.m):n.cmpn(0)<0&&(c=n.iadd(this.m)),c._forceRed(this)},Mont.prototype.invm=function invm(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e=a.nmd(e),this)},(e,t,a)=>{var r=a(0),n=r.Buffer;function copyProps(e,t){for(var a in e)t[a]=e[a]}function SafeBuffer(e,t,a){return n(e,t,a)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(copyProps(r,t),t.Buffer=SafeBuffer),SafeBuffer.prototype=Object.create(n.prototype),copyProps(n,SafeBuffer),SafeBuffer.from=function(e,t,a){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,a)},SafeBuffer.alloc=function(e,t,a){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=n(e);return void 0!==t?"string"==typeof a?r.fill(t,a):r.fill(t):r.fill(0),r},SafeBuffer.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},SafeBuffer.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},e=>{"use strict";var t,a="object"==typeof Reflect?Reflect:null,r=a&&"function"==typeof a.apply?a.apply:function ReflectApply(e,t,a){return Function.prototype.apply.call(e,t,a)};t=a&&"function"==typeof a.ownKeys?a.ownKeys:Object.getOwnPropertySymbols?function ReflectOwnKeys(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function ReflectOwnKeys(e){return Object.getOwnPropertyNames(e)};var n=Number.isNaN||function NumberIsNaN(e){return e!=e};function EventEmitter(){EventEmitter.init.call(this)}e.exports=EventEmitter,e.exports.once=function once(e,t){return new Promise((function(a,r){function errorListener(a){e.removeListener(t,resolver),r(a)}function resolver(){"function"==typeof e.removeListener&&e.removeListener("error",errorListener),a([].slice.call(arguments))}eventTargetAgnosticAddListener(e,t,resolver,{once:!0}),"error"!==t&&function addErrorHandlerIfEventEmitter(e,t,a){"function"==typeof e.on&&eventTargetAgnosticAddListener(e,"error",t,a)}(e,errorListener,{once:!0})}))},EventEmitter.EventEmitter=EventEmitter,EventEmitter.prototype._events=void 0,EventEmitter.prototype._eventsCount=0,EventEmitter.prototype._maxListeners=void 0;var c=10;function checkListener(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function _getMaxListeners(e){return void 0===e._maxListeners?EventEmitter.defaultMaxListeners:e._maxListeners}function _addListener(e,t,a,r){var n,c,o;if(checkListener(a),void 0===(c=e._events)?(c=e._events=Object.create(null),e._eventsCount=0):(void 0!==c.newListener&&(e.emit("newListener",t,a.listener?a.listener:a),c=e._events),o=c[t]),void 0===o)o=c[t]=a,++e._eventsCount;else if("function"==typeof o?o=c[t]=r?[a,o]:[o,a]:r?o.unshift(a):o.push(a),(n=_getMaxListeners(e))>0&&o.length>n&&!o.warned){o.warned=!0;var d=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");d.name="MaxListenersExceededWarning",d.emitter=e,d.type=t,d.count=o.length,function ProcessEmitWarning(e){console&&console.warn&&console.warn(e)}(d)}return e}function onceWrapper(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function _onceWrap(e,t,a){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:a},n=onceWrapper.bind(r);return n.listener=a,r.wrapFn=n,n}function _listeners(e,t,a){var r=e._events;if(void 0===r)return[];var n=r[t];return void 0===n?[]:"function"==typeof n?a?[n.listener||n]:[n]:a?function unwrapListeners(e){for(var t=new Array(e.length),a=0;a0&&(o=t[0]),o instanceof Error)throw o;var d=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw d.context=o,d}var s=c[e];if(void 0===s)return!1;if("function"==typeof s)r(s,this,t);else{var b=s.length,u=arrayClone(s,b);for(a=0;a=0;c--)if(a[c]===t||a[c].listener===t){o=a[c].listener,n=c;break}if(n<0)return this;0===n?a.shift():function spliceOne(e,t){for(;t+1=0;r--)this.removeListener(e,t[r]);return this},EventEmitter.prototype.listeners=function listeners(e){return _listeners(this,e,!0)},EventEmitter.prototype.rawListeners=function rawListeners(e){return _listeners(this,e,!1)},EventEmitter.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):listenerCount.call(e,t)},EventEmitter.prototype.listenerCount=listenerCount,EventEmitter.prototype.eventNames=function eventNames(){return this._eventsCount>0?t(this._events):[]}},e=>{"function"==typeof Object.create?e.exports=function inherits(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function inherits(e,t){if(t){e.super_=t;var TempCtor=function(){};TempCtor.prototype=t.prototype,e.prototype=new TempCtor,e.prototype.constructor=e}}},(e,t,a)=>{e.exports=Stream;var r=a(24).EventEmitter;function Stream(){r.call(this)}a(6)(Stream,r),Stream.Readable=a(201),Stream.Writable=a(202),Stream.Duplex=a(109),Stream.Transform=a(203),Stream.PassThrough=a(329),Stream.finished=a(143),Stream.pipeline=a(330),Stream.Stream=Stream,Stream.prototype.pipe=function(e,t){var a=this;function ondata(t){e.writable&&!1===e.write(t)&&a.pause&&a.pause()}function ondrain(){a.readable&&a.resume&&a.resume()}a.on("data",ondata),e.on("drain",ondrain),e._isStdio||t&&!1===t.end||(a.on("end",onend),a.on("close",onclose));var n=!1;function onend(){n||(n=!0,e.end())}function onclose(){n||(n=!0,"function"==typeof e.destroy&&e.destroy())}function onerror(e){if(cleanup(),0===r.listenerCount(this,"error"))throw e}function cleanup(){a.removeListener("data",ondata),e.removeListener("drain",ondrain),a.removeListener("end",onend),a.removeListener("close",onclose),a.removeListener("error",onerror),e.removeListener("error",onerror),a.removeListener("end",cleanup),a.removeListener("close",cleanup),e.removeListener("close",cleanup)}return a.on("error",onerror),e.on("error",onerror),a.on("end",cleanup),a.on("close",cleanup),e.on("close",cleanup),e.emit("pipe",a),e}},(e,t,a)=>{"use strict";var r=a(2).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.decode=t.encodeLength=t.encode=t.digest=t.encodeRange=t.getLength=void 0;const n=a(1308);Object.defineProperty(t,"getLength",{enumerable:!0,get:function(){return n.getLength}});const c=a(4);function encode(e){if(Array.isArray(e)){let t=0;const a=[];for(let r=0,n=e.length;r{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Address=void 0;const r=a(4);class Address extends r.Data{constructor(e){super(e,Address.ByteLength)}static from(e){return new Address(e)}}t.Address=Address,Address.ByteLength=20},e=>{e.exports=function(e){return"function"==typeof e}},function(e,t,a){!function(e,t){"use strict";function assert(e,t){if(!e)throw new Error(t||"Assertion failed")}function inherits(e,t){e.super_=t;var TempCtor=function(){};TempCtor.prototype=t.prototype,e.prototype=new TempCtor,e.prototype.constructor=e}function BN(e,t,a){if(BN.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(a=t,t=10),this._init(e||0,t||10,a||"be"))}var r;"object"==typeof e?e.exports=BN:t.BN=BN,BN.BN=BN,BN.wordSize=26;try{r="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:a(1417).Buffer}catch(e){}function parseHex4Bits(e,t){var a=e.charCodeAt(t);return a>=65&&a<=70?a-55:a>=97&&a<=102?a-87:a-48&15}function parseHexByte(e,t,a){var r=parseHex4Bits(e,a);return a-1>=t&&(r|=parseHex4Bits(e,a-1)<<4),r}function parseBase(e,t,a,r){for(var n=0,c=Math.min(e.length,a),o=t;o=49?d-49+10:d>=17?d-17+10:d}return n}BN.isBN=function isBN(e){return e instanceof BN||null!==e&&"object"==typeof e&&e.constructor.wordSize===BN.wordSize&&Array.isArray(e.words)},BN.max=function max(e,t){return e.cmp(t)>0?e:t},BN.min=function min(e,t){return e.cmp(t)<0?e:t},BN.prototype._init=function init(e,t,a){if("number"==typeof e)return this._initNumber(e,t,a);if("object"==typeof e)return this._initArray(e,t,a);"hex"===t&&(t=16),assert(t===(0|t)&&t>=2&&t<=36);var r=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(r++,this.negative=1),r=0;r-=3)c=e[r]|e[r-1]<<8|e[r-2]<<16,this.words[n]|=c<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===a)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},BN.prototype._parseHex=function _parseHex(e,t,a){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=2)n=parseHexByte(e,t,r)<=18?(c-=18,o+=1,this.words[o]|=n>>>26):c+=8;else for(r=(e.length-t)%2==0?t+1:t;r=18?(c-=18,o+=1,this.words[o]|=n>>>26):c+=8;this.strip()},BN.prototype._parseBase=function _parseBase(e,t,a){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=t)r++;r--,n=n/t|0;for(var c=e.length-a,o=c%r,d=Math.min(c,c-o)+a,s=0,b=a;b1&&0===this.words[this.length-1];)this.length--;return this._normSign()},BN.prototype._normSign=function _normSign(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},BN.prototype.inspect=function inspect(){return(this.red?""};var n=["","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"],c=[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],o=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function smallMulTo(e,t,a){a.negative=t.negative^e.negative;var r=e.length+t.length|0;a.length=r,r=r-1|0;var n=0|e.words[0],c=0|t.words[0],o=n*c,d=67108863&o,s=o/67108864|0;a.words[0]=d;for(var b=1;b>>26,h=67108863&s,l=Math.min(b,t.length-1),g=Math.max(0,b-e.length+1);g<=l;g++){var p=b-g|0;u+=(o=(n=0|e.words[p])*(c=0|t.words[g])+h)/67108864|0,h=67108863&o}a.words[b]=0|h,s=0|u}return 0!==s?a.words[b]=0|s:a.length--,a.strip()}BN.prototype.toString=function toString(e,t){var a;if(t=0|t||1,16===(e=e||10)||"hex"===e){a="";for(var r=0,d=0,s=0;s>>24-r&16777215)||s!==this.length-1?n[6-u.length]+u+a:u+a,(r+=2)>=26&&(r-=26,s--)}for(0!==d&&(a=d.toString(16)+a);a.length%t!=0;)a="0"+a;return 0!==this.negative&&(a="-"+a),a}if(e===(0|e)&&e>=2&&e<=36){var h=c[e],l=o[e];a="";var g=this.clone();for(g.negative=0;!g.isZero();){var p=g.modn(l).toString(e);a=(g=g.idivn(l)).isZero()?p+a:n[h-p.length]+p+a}for(this.isZero()&&(a="0"+a);a.length%t!=0;)a="0"+a;return 0!==this.negative&&(a="-"+a),a}assert(!1,"Base should be between 2 and 36")},BN.prototype.toNumber=function toNumber(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&assert(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},BN.prototype.toJSON=function toJSON(){return this.toString(16)},BN.prototype.toBuffer=function toBuffer(e,t){return assert(void 0!==r),this.toArrayLike(r,e,t)},BN.prototype.toArray=function toArray(e,t){return this.toArrayLike(Array,e,t)},BN.prototype.toArrayLike=function toArrayLike(e,t,a){var r=this.byteLength(),n=a||Math.max(1,r);assert(r<=n,"byte array longer than desired length"),assert(n>0,"Requested array length <= 0"),this.strip();var c,o,d="le"===t,s=new e(n),b=this.clone();if(d){for(o=0;!b.isZero();o++)c=b.andln(255),b.iushrn(8),s[o]=c;for(;o=4096&&(a+=13,t>>>=13),t>=64&&(a+=7,t>>>=7),t>=8&&(a+=4,t>>>=4),t>=2&&(a+=2,t>>>=2),a+t},BN.prototype._zeroBits=function _zeroBits(e){if(0===e)return 26;var t=e,a=0;return 0==(8191&t)&&(a+=13,t>>>=13),0==(127&t)&&(a+=7,t>>>=7),0==(15&t)&&(a+=4,t>>>=4),0==(3&t)&&(a+=2,t>>>=2),0==(1&t)&&a++,a},BN.prototype.bitLength=function bitLength(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},BN.prototype.zeroBits=function zeroBits(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},BN.prototype.uor=function uor(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},BN.prototype.iuand=function iuand(e){var t;t=this.length>e.length?e:this;for(var a=0;ae.length?this.clone().iand(e):e.clone().iand(this)},BN.prototype.uand=function uand(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},BN.prototype.iuxor=function iuxor(e){var t,a;this.length>e.length?(t=this,a=e):(t=e,a=this);for(var r=0;re.length?this.clone().ixor(e):e.clone().ixor(this)},BN.prototype.uxor=function uxor(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},BN.prototype.inotn=function inotn(e){assert("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),a=e%26;this._expand(t),a>0&&t--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-a),this.strip()},BN.prototype.notn=function notn(e){return this.clone().inotn(e)},BN.prototype.setn=function setn(e,t){assert("number"==typeof e&&e>=0);var a=e/26|0,r=e%26;return this._expand(a+1),this.words[a]=t?this.words[a]|1<e.length?(a=this,r=e):(a=e,r=this);for(var n=0,c=0;c>>26;for(;0!==n&&c>>26;if(this.length=a.length,0!==n)this.words[this.length]=n,this.length++;else if(a!==this)for(;ce.length?this.clone().iadd(e):e.clone().iadd(this)},BN.prototype.isub=function isub(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var a,r,n=this.cmp(e);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(a=this,r=e):(a=e,r=this);for(var c=0,o=0;o>26,this.words[o]=67108863&t;for(;0!==c&&o>26,this.words[o]=67108863&t;if(0===c&&o>>13,g=0|o[1],p=8191&g,B=g>>>13,x=0|o[2],I=8191&x,m=x>>>13,y=0|o[3],C=8191&y,w=y>>>13,v=0|o[4],Q=8191&v,k=v>>>13,_=0|o[5],N=8191&_,D=_>>>13,G=0|o[6],L=8191&G,T=G>>>13,U=0|o[7],P=8191&U,q=U>>>13,H=0|o[8],O=8191&H,z=H>>>13,J=0|o[9],j=8191&J,Y=J>>>13,W=0|d[0],V=8191&W,X=W>>>13,$=0|d[1],et=8191&$,tt=$>>>13,at=0|d[2],rt=8191&at,it=at>>>13,nt=0|d[3],ct=8191&nt,ot=nt>>>13,dt=0|d[4],At=8191&dt,st=dt>>>13,bt=0|d[5],ut=8191&bt,ht=bt>>>13,pt=0|d[6],Bt=8191&pt,xt=pt>>>13,It=0|d[7],mt=8191&It,Et=It>>>13,yt=0|d[8],Ct=8191&yt,wt=yt>>>13,vt=0|d[9],Qt=8191&vt,Mt=vt>>>13;a.negative=e.negative^t.negative,a.length=19;var kt=(b+(r=Math.imul(h,V))|0)+((8191&(n=(n=Math.imul(h,X))+Math.imul(l,V)|0))<<13)|0;b=((c=Math.imul(l,X))+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(p,V),n=(n=Math.imul(p,X))+Math.imul(B,V)|0,c=Math.imul(B,X);var _t=(b+(r=r+Math.imul(h,et)|0)|0)+((8191&(n=(n=n+Math.imul(h,tt)|0)+Math.imul(l,et)|0))<<13)|0;b=((c=c+Math.imul(l,tt)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(I,V),n=(n=Math.imul(I,X))+Math.imul(m,V)|0,c=Math.imul(m,X),r=r+Math.imul(p,et)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(B,et)|0,c=c+Math.imul(B,tt)|0;var St=(b+(r=r+Math.imul(h,rt)|0)|0)+((8191&(n=(n=n+Math.imul(h,it)|0)+Math.imul(l,rt)|0))<<13)|0;b=((c=c+Math.imul(l,it)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(C,V),n=(n=Math.imul(C,X))+Math.imul(w,V)|0,c=Math.imul(w,X),r=r+Math.imul(I,et)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(m,et)|0,c=c+Math.imul(m,tt)|0,r=r+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(B,rt)|0,c=c+Math.imul(B,it)|0;var Nt=(b+(r=r+Math.imul(h,ct)|0)|0)+((8191&(n=(n=n+Math.imul(h,ot)|0)+Math.imul(l,ct)|0))<<13)|0;b=((c=c+Math.imul(l,ot)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,r=Math.imul(Q,V),n=(n=Math.imul(Q,X))+Math.imul(k,V)|0,c=Math.imul(k,X),r=r+Math.imul(C,et)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(w,et)|0,c=c+Math.imul(w,tt)|0,r=r+Math.imul(I,rt)|0,n=(n=n+Math.imul(I,it)|0)+Math.imul(m,rt)|0,c=c+Math.imul(m,it)|0,r=r+Math.imul(p,ct)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(B,ct)|0,c=c+Math.imul(B,ot)|0;var Dt=(b+(r=r+Math.imul(h,At)|0)|0)+((8191&(n=(n=n+Math.imul(h,st)|0)+Math.imul(l,At)|0))<<13)|0;b=((c=c+Math.imul(l,st)|0)+(n>>>13)|0)+(Dt>>>26)|0,Dt&=67108863,r=Math.imul(N,V),n=(n=Math.imul(N,X))+Math.imul(D,V)|0,c=Math.imul(D,X),r=r+Math.imul(Q,et)|0,n=(n=n+Math.imul(Q,tt)|0)+Math.imul(k,et)|0,c=c+Math.imul(k,tt)|0,r=r+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(w,rt)|0,c=c+Math.imul(w,it)|0,r=r+Math.imul(I,ct)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(m,ct)|0,c=c+Math.imul(m,ot)|0,r=r+Math.imul(p,At)|0,n=(n=n+Math.imul(p,st)|0)+Math.imul(B,At)|0,c=c+Math.imul(B,st)|0;var Rt=(b+(r=r+Math.imul(h,ut)|0)|0)+((8191&(n=(n=n+Math.imul(h,ht)|0)+Math.imul(l,ut)|0))<<13)|0;b=((c=c+Math.imul(l,ht)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(L,V),n=(n=Math.imul(L,X))+Math.imul(T,V)|0,c=Math.imul(T,X),r=r+Math.imul(N,et)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(D,et)|0,c=c+Math.imul(D,tt)|0,r=r+Math.imul(Q,rt)|0,n=(n=n+Math.imul(Q,it)|0)+Math.imul(k,rt)|0,c=c+Math.imul(k,it)|0,r=r+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,ot)|0)+Math.imul(w,ct)|0,c=c+Math.imul(w,ot)|0,r=r+Math.imul(I,At)|0,n=(n=n+Math.imul(I,st)|0)+Math.imul(m,At)|0,c=c+Math.imul(m,st)|0,r=r+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,ht)|0)+Math.imul(B,ut)|0,c=c+Math.imul(B,ht)|0;var Ft=(b+(r=r+Math.imul(h,Bt)|0)|0)+((8191&(n=(n=n+Math.imul(h,xt)|0)+Math.imul(l,Bt)|0))<<13)|0;b=((c=c+Math.imul(l,xt)|0)+(n>>>13)|0)+(Ft>>>26)|0,Ft&=67108863,r=Math.imul(P,V),n=(n=Math.imul(P,X))+Math.imul(q,V)|0,c=Math.imul(q,X),r=r+Math.imul(L,et)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(T,et)|0,c=c+Math.imul(T,tt)|0,r=r+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(D,rt)|0,c=c+Math.imul(D,it)|0,r=r+Math.imul(Q,ct)|0,n=(n=n+Math.imul(Q,ot)|0)+Math.imul(k,ct)|0,c=c+Math.imul(k,ot)|0,r=r+Math.imul(C,At)|0,n=(n=n+Math.imul(C,st)|0)+Math.imul(w,At)|0,c=c+Math.imul(w,st)|0,r=r+Math.imul(I,ut)|0,n=(n=n+Math.imul(I,ht)|0)+Math.imul(m,ut)|0,c=c+Math.imul(m,ht)|0,r=r+Math.imul(p,Bt)|0,n=(n=n+Math.imul(p,xt)|0)+Math.imul(B,Bt)|0,c=c+Math.imul(B,xt)|0;var Gt=(b+(r=r+Math.imul(h,mt)|0)|0)+((8191&(n=(n=n+Math.imul(h,Et)|0)+Math.imul(l,mt)|0))<<13)|0;b=((c=c+Math.imul(l,Et)|0)+(n>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,r=Math.imul(O,V),n=(n=Math.imul(O,X))+Math.imul(z,V)|0,c=Math.imul(z,X),r=r+Math.imul(P,et)|0,n=(n=n+Math.imul(P,tt)|0)+Math.imul(q,et)|0,c=c+Math.imul(q,tt)|0,r=r+Math.imul(L,rt)|0,n=(n=n+Math.imul(L,it)|0)+Math.imul(T,rt)|0,c=c+Math.imul(T,it)|0,r=r+Math.imul(N,ct)|0,n=(n=n+Math.imul(N,ot)|0)+Math.imul(D,ct)|0,c=c+Math.imul(D,ot)|0,r=r+Math.imul(Q,At)|0,n=(n=n+Math.imul(Q,st)|0)+Math.imul(k,At)|0,c=c+Math.imul(k,st)|0,r=r+Math.imul(C,ut)|0,n=(n=n+Math.imul(C,ht)|0)+Math.imul(w,ut)|0,c=c+Math.imul(w,ht)|0,r=r+Math.imul(I,Bt)|0,n=(n=n+Math.imul(I,xt)|0)+Math.imul(m,Bt)|0,c=c+Math.imul(m,xt)|0,r=r+Math.imul(p,mt)|0,n=(n=n+Math.imul(p,Et)|0)+Math.imul(B,mt)|0,c=c+Math.imul(B,Et)|0;var Lt=(b+(r=r+Math.imul(h,Ct)|0)|0)+((8191&(n=(n=n+Math.imul(h,wt)|0)+Math.imul(l,Ct)|0))<<13)|0;b=((c=c+Math.imul(l,wt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,r=Math.imul(j,V),n=(n=Math.imul(j,X))+Math.imul(Y,V)|0,c=Math.imul(Y,X),r=r+Math.imul(O,et)|0,n=(n=n+Math.imul(O,tt)|0)+Math.imul(z,et)|0,c=c+Math.imul(z,tt)|0,r=r+Math.imul(P,rt)|0,n=(n=n+Math.imul(P,it)|0)+Math.imul(q,rt)|0,c=c+Math.imul(q,it)|0,r=r+Math.imul(L,ct)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(T,ct)|0,c=c+Math.imul(T,ot)|0,r=r+Math.imul(N,At)|0,n=(n=n+Math.imul(N,st)|0)+Math.imul(D,At)|0,c=c+Math.imul(D,st)|0,r=r+Math.imul(Q,ut)|0,n=(n=n+Math.imul(Q,ht)|0)+Math.imul(k,ut)|0,c=c+Math.imul(k,ht)|0,r=r+Math.imul(C,Bt)|0,n=(n=n+Math.imul(C,xt)|0)+Math.imul(w,Bt)|0,c=c+Math.imul(w,xt)|0,r=r+Math.imul(I,mt)|0,n=(n=n+Math.imul(I,Et)|0)+Math.imul(m,mt)|0,c=c+Math.imul(m,Et)|0,r=r+Math.imul(p,Ct)|0,n=(n=n+Math.imul(p,wt)|0)+Math.imul(B,Ct)|0,c=c+Math.imul(B,wt)|0;var Tt=(b+(r=r+Math.imul(h,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(h,Mt)|0)+Math.imul(l,Qt)|0))<<13)|0;b=((c=c+Math.imul(l,Mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(j,et),n=(n=Math.imul(j,tt))+Math.imul(Y,et)|0,c=Math.imul(Y,tt),r=r+Math.imul(O,rt)|0,n=(n=n+Math.imul(O,it)|0)+Math.imul(z,rt)|0,c=c+Math.imul(z,it)|0,r=r+Math.imul(P,ct)|0,n=(n=n+Math.imul(P,ot)|0)+Math.imul(q,ct)|0,c=c+Math.imul(q,ot)|0,r=r+Math.imul(L,At)|0,n=(n=n+Math.imul(L,st)|0)+Math.imul(T,At)|0,c=c+Math.imul(T,st)|0,r=r+Math.imul(N,ut)|0,n=(n=n+Math.imul(N,ht)|0)+Math.imul(D,ut)|0,c=c+Math.imul(D,ht)|0,r=r+Math.imul(Q,Bt)|0,n=(n=n+Math.imul(Q,xt)|0)+Math.imul(k,Bt)|0,c=c+Math.imul(k,xt)|0,r=r+Math.imul(C,mt)|0,n=(n=n+Math.imul(C,Et)|0)+Math.imul(w,mt)|0,c=c+Math.imul(w,Et)|0,r=r+Math.imul(I,Ct)|0,n=(n=n+Math.imul(I,wt)|0)+Math.imul(m,Ct)|0,c=c+Math.imul(m,wt)|0;var Ut=(b+(r=r+Math.imul(p,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(p,Mt)|0)+Math.imul(B,Qt)|0))<<13)|0;b=((c=c+Math.imul(B,Mt)|0)+(n>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,r=Math.imul(j,rt),n=(n=Math.imul(j,it))+Math.imul(Y,rt)|0,c=Math.imul(Y,it),r=r+Math.imul(O,ct)|0,n=(n=n+Math.imul(O,ot)|0)+Math.imul(z,ct)|0,c=c+Math.imul(z,ot)|0,r=r+Math.imul(P,At)|0,n=(n=n+Math.imul(P,st)|0)+Math.imul(q,At)|0,c=c+Math.imul(q,st)|0,r=r+Math.imul(L,ut)|0,n=(n=n+Math.imul(L,ht)|0)+Math.imul(T,ut)|0,c=c+Math.imul(T,ht)|0,r=r+Math.imul(N,Bt)|0,n=(n=n+Math.imul(N,xt)|0)+Math.imul(D,Bt)|0,c=c+Math.imul(D,xt)|0,r=r+Math.imul(Q,mt)|0,n=(n=n+Math.imul(Q,Et)|0)+Math.imul(k,mt)|0,c=c+Math.imul(k,Et)|0,r=r+Math.imul(C,Ct)|0,n=(n=n+Math.imul(C,wt)|0)+Math.imul(w,Ct)|0,c=c+Math.imul(w,wt)|0;var Pt=(b+(r=r+Math.imul(I,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(I,Mt)|0)+Math.imul(m,Qt)|0))<<13)|0;b=((c=c+Math.imul(m,Mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(j,ct),n=(n=Math.imul(j,ot))+Math.imul(Y,ct)|0,c=Math.imul(Y,ot),r=r+Math.imul(O,At)|0,n=(n=n+Math.imul(O,st)|0)+Math.imul(z,At)|0,c=c+Math.imul(z,st)|0,r=r+Math.imul(P,ut)|0,n=(n=n+Math.imul(P,ht)|0)+Math.imul(q,ut)|0,c=c+Math.imul(q,ht)|0,r=r+Math.imul(L,Bt)|0,n=(n=n+Math.imul(L,xt)|0)+Math.imul(T,Bt)|0,c=c+Math.imul(T,xt)|0,r=r+Math.imul(N,mt)|0,n=(n=n+Math.imul(N,Et)|0)+Math.imul(D,mt)|0,c=c+Math.imul(D,Et)|0,r=r+Math.imul(Q,Ct)|0,n=(n=n+Math.imul(Q,wt)|0)+Math.imul(k,Ct)|0,c=c+Math.imul(k,wt)|0;var qt=(b+(r=r+Math.imul(C,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(C,Mt)|0)+Math.imul(w,Qt)|0))<<13)|0;b=((c=c+Math.imul(w,Mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863,r=Math.imul(j,At),n=(n=Math.imul(j,st))+Math.imul(Y,At)|0,c=Math.imul(Y,st),r=r+Math.imul(O,ut)|0,n=(n=n+Math.imul(O,ht)|0)+Math.imul(z,ut)|0,c=c+Math.imul(z,ht)|0,r=r+Math.imul(P,Bt)|0,n=(n=n+Math.imul(P,xt)|0)+Math.imul(q,Bt)|0,c=c+Math.imul(q,xt)|0,r=r+Math.imul(L,mt)|0,n=(n=n+Math.imul(L,Et)|0)+Math.imul(T,mt)|0,c=c+Math.imul(T,Et)|0,r=r+Math.imul(N,Ct)|0,n=(n=n+Math.imul(N,wt)|0)+Math.imul(D,Ct)|0,c=c+Math.imul(D,wt)|0;var Ht=(b+(r=r+Math.imul(Q,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(Q,Mt)|0)+Math.imul(k,Qt)|0))<<13)|0;b=((c=c+Math.imul(k,Mt)|0)+(n>>>13)|0)+(Ht>>>26)|0,Ht&=67108863,r=Math.imul(j,ut),n=(n=Math.imul(j,ht))+Math.imul(Y,ut)|0,c=Math.imul(Y,ht),r=r+Math.imul(O,Bt)|0,n=(n=n+Math.imul(O,xt)|0)+Math.imul(z,Bt)|0,c=c+Math.imul(z,xt)|0,r=r+Math.imul(P,mt)|0,n=(n=n+Math.imul(P,Et)|0)+Math.imul(q,mt)|0,c=c+Math.imul(q,Et)|0,r=r+Math.imul(L,Ct)|0,n=(n=n+Math.imul(L,wt)|0)+Math.imul(T,Ct)|0,c=c+Math.imul(T,wt)|0;var Ot=(b+(r=r+Math.imul(N,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(N,Mt)|0)+Math.imul(D,Qt)|0))<<13)|0;b=((c=c+Math.imul(D,Mt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,r=Math.imul(j,Bt),n=(n=Math.imul(j,xt))+Math.imul(Y,Bt)|0,c=Math.imul(Y,xt),r=r+Math.imul(O,mt)|0,n=(n=n+Math.imul(O,Et)|0)+Math.imul(z,mt)|0,c=c+Math.imul(z,Et)|0,r=r+Math.imul(P,Ct)|0,n=(n=n+Math.imul(P,wt)|0)+Math.imul(q,Ct)|0,c=c+Math.imul(q,wt)|0;var zt=(b+(r=r+Math.imul(L,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(L,Mt)|0)+Math.imul(T,Qt)|0))<<13)|0;b=((c=c+Math.imul(T,Mt)|0)+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863,r=Math.imul(j,mt),n=(n=Math.imul(j,Et))+Math.imul(Y,mt)|0,c=Math.imul(Y,Et),r=r+Math.imul(O,Ct)|0,n=(n=n+Math.imul(O,wt)|0)+Math.imul(z,Ct)|0,c=c+Math.imul(z,wt)|0;var Kt=(b+(r=r+Math.imul(P,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(P,Mt)|0)+Math.imul(q,Qt)|0))<<13)|0;b=((c=c+Math.imul(q,Mt)|0)+(n>>>13)|0)+(Kt>>>26)|0,Kt&=67108863,r=Math.imul(j,Ct),n=(n=Math.imul(j,wt))+Math.imul(Y,Ct)|0,c=Math.imul(Y,wt);var Jt=(b+(r=r+Math.imul(O,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(O,Mt)|0)+Math.imul(z,Qt)|0))<<13)|0;b=((c=c+Math.imul(z,Mt)|0)+(n>>>13)|0)+(Jt>>>26)|0,Jt&=67108863;var jt=(b+(r=Math.imul(j,Qt))|0)+((8191&(n=(n=Math.imul(j,Mt))+Math.imul(Y,Qt)|0))<<13)|0;return b=((c=Math.imul(Y,Mt))+(n>>>13)|0)+(jt>>>26)|0,jt&=67108863,s[0]=kt,s[1]=_t,s[2]=St,s[3]=Nt,s[4]=Dt,s[5]=Rt,s[6]=Ft,s[7]=Gt,s[8]=Lt,s[9]=Tt,s[10]=Ut,s[11]=Pt,s[12]=qt,s[13]=Ht,s[14]=Ot,s[15]=zt,s[16]=Kt,s[17]=Jt,s[18]=jt,0!==b&&(s[19]=b,a.length++),a};function jumboMulTo(e,t,a){return(new FFTM).mulp(e,t,a)}function FFTM(e,t){this.x=e,this.y=t}Math.imul||(d=smallMulTo),BN.prototype.mulTo=function mulTo(e,t){var a,r=this.length+e.length;return a=10===this.length&&10===e.length?d(this,e,t):r<63?smallMulTo(this,e,t):r<1024?function bigMulTo(e,t,a){a.negative=t.negative^e.negative,a.length=e.length+t.length;for(var r=0,n=0,c=0;c>>26)|0)>>>26,o&=67108863}a.words[c]=d,r=o,o=n}return 0!==r?a.words[c]=r:a.length--,a.strip()}(this,e,t):jumboMulTo(this,e,t),a},FFTM.prototype.makeRBT=function makeRBT(e){for(var t=new Array(e),a=BN.prototype._countBits(e)-1,r=0;r>=1;return r},FFTM.prototype.permute=function permute(e,t,a,r,n,c){for(var o=0;o>>=1)n++;return 1<>>=13,a[2*c+1]=8191&n,n>>>=13;for(c=2*t;c>=26,t+=r/67108864|0,t+=n>>>26,this.words[a]=67108863&n}return 0!==t&&(this.words[a]=t,this.length++),this},BN.prototype.muln=function muln(e){return this.clone().imuln(e)},BN.prototype.sqr=function sqr(){return this.mul(this)},BN.prototype.isqr=function isqr(){return this.imul(this.clone())},BN.prototype.pow=function pow(e){var t=function toBitArray(e){for(var t=new Array(e.bitLength()),a=0;a>>n}return t}(e);if(0===t.length)return new BN(1);for(var a=this,r=0;r=0);var t,a=e%26,r=(e-a)/26,n=67108863>>>26-a<<26-a;if(0!==a){var c=0;for(t=0;t>>26-a}c&&(this.words[t]=c,this.length++)}if(0!==r){for(t=this.length-1;t>=0;t--)this.words[t+r]=this.words[t];for(t=0;t=0),r=t?(t-t%26)/26:0;var n=e%26,c=Math.min((e-n)/26,this.length),o=67108863^67108863>>>n<c)for(this.length-=c,s=0;s=0&&(0!==b||s>=r);s--){var u=0|this.words[s];this.words[s]=b<<26-n|u>>>n,b=u&o}return d&&0!==b&&(d.words[d.length++]=b),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},BN.prototype.ishrn=function ishrn(e,t,a){return assert(0===this.negative),this.iushrn(e,t,a)},BN.prototype.shln=function shln(e){return this.clone().ishln(e)},BN.prototype.ushln=function ushln(e){return this.clone().iushln(e)},BN.prototype.shrn=function shrn(e){return this.clone().ishrn(e)},BN.prototype.ushrn=function ushrn(e){return this.clone().iushrn(e)},BN.prototype.testn=function testn(e){assert("number"==typeof e&&e>=0);var t=e%26,a=(e-t)/26,r=1<=0);var t=e%26,a=(e-t)/26;if(assert(0===this.negative,"imaskn works only with positive numbers"),this.length<=a)return this;if(0!==t&&a++,this.length=Math.min(a,this.length),0!==t){var r=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},BN.prototype.isubn=function isubn(e){if(assert("number"==typeof e),assert(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(d/67108864|0),this.words[r+a]=67108863&n}for(;r>26,this.words[r+a]=67108863&n;if(0===o)return this.strip();for(assert(-1===o),o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},BN.prototype._wordDiv=function _wordDiv(e,t){var a=(this.length,e.length),r=this.clone(),n=e,c=0|n.words[n.length-1];0!==(a=26-this._countBits(c))&&(n=n.ushln(a),r.iushln(a),c=0|n.words[n.length-1]);var o,d=r.length-n.length;if("mod"!==t){(o=new BN(null)).length=d+1,o.words=new Array(o.length);for(var s=0;s=0;u--){var h=67108864*(0|r.words[n.length+u])+(0|r.words[n.length+u-1]);for(h=Math.min(h/c|0,67108863),r._ishlnsubmul(n,h,u);0!==r.negative;)h--,r.negative=0,r._ishlnsubmul(n,1,u),r.isZero()||(r.negative^=1);o&&(o.words[u]=h)}return o&&o.strip(),r.strip(),"div"!==t&&0!==a&&r.iushrn(a),{div:o||null,mod:r}},BN.prototype.divmod=function divmod(e,t,a){return assert(!e.isZero()),this.isZero()?{div:new BN(0),mod:new BN(0)}:0!==this.negative&&0===e.negative?(c=this.neg().divmod(e,t),"mod"!==t&&(r=c.div.neg()),"div"!==t&&(n=c.mod.neg(),a&&0!==n.negative&&n.iadd(e)),{div:r,mod:n}):0===this.negative&&0!==e.negative?(c=this.divmod(e.neg(),t),"mod"!==t&&(r=c.div.neg()),{div:r,mod:c.mod}):0!=(this.negative&e.negative)?(c=this.neg().divmod(e.neg(),t),"div"!==t&&(n=c.mod.neg(),a&&0!==n.negative&&n.isub(e)),{div:c.div,mod:n}):e.length>this.length||this.cmp(e)<0?{div:new BN(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new BN(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new BN(this.modn(e.words[0]))}:this._wordDiv(e,t);var r,n,c},BN.prototype.div=function div(e){return this.divmod(e,"div",!1).div},BN.prototype.mod=function mod(e){return this.divmod(e,"mod",!1).mod},BN.prototype.umod=function umod(e){return this.divmod(e,"mod",!0).mod},BN.prototype.divRound=function divRound(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var a=0!==t.div.negative?t.mod.isub(e):t.mod,r=e.ushrn(1),n=e.andln(1),c=a.cmp(r);return c<0||1===n&&0===c?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},BN.prototype.modn=function modn(e){assert(e<=67108863);for(var t=(1<<26)%e,a=0,r=this.length-1;r>=0;r--)a=(t*a+(0|this.words[r]))%e;return a},BN.prototype.idivn=function idivn(e){assert(e<=67108863);for(var t=0,a=this.length-1;a>=0;a--){var r=(0|this.words[a])+67108864*t;this.words[a]=r/e|0,t=r%e}return this.strip()},BN.prototype.divn=function divn(e){return this.clone().idivn(e)},BN.prototype.egcd=function egcd(e){assert(0===e.negative),assert(!e.isZero());var t=this,a=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var r=new BN(1),n=new BN(0),c=new BN(0),o=new BN(1),d=0;t.isEven()&&a.isEven();)t.iushrn(1),a.iushrn(1),++d;for(var s=a.clone(),b=t.clone();!t.isZero();){for(var u=0,h=1;0==(t.words[0]&h)&&u<26;++u,h<<=1);if(u>0)for(t.iushrn(u);u-- >0;)(r.isOdd()||n.isOdd())&&(r.iadd(s),n.isub(b)),r.iushrn(1),n.iushrn(1);for(var l=0,g=1;0==(a.words[0]&g)&&l<26;++l,g<<=1);if(l>0)for(a.iushrn(l);l-- >0;)(c.isOdd()||o.isOdd())&&(c.iadd(s),o.isub(b)),c.iushrn(1),o.iushrn(1);t.cmp(a)>=0?(t.isub(a),r.isub(c),n.isub(o)):(a.isub(t),c.isub(r),o.isub(n))}return{a:c,b:o,gcd:a.iushln(d)}},BN.prototype._invmp=function _invmp(e){assert(0===e.negative),assert(!e.isZero());var t=this,a=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var r,n=new BN(1),c=new BN(0),o=a.clone();t.cmpn(1)>0&&a.cmpn(1)>0;){for(var d=0,s=1;0==(t.words[0]&s)&&d<26;++d,s<<=1);if(d>0)for(t.iushrn(d);d-- >0;)n.isOdd()&&n.iadd(o),n.iushrn(1);for(var b=0,u=1;0==(a.words[0]&u)&&b<26;++b,u<<=1);if(b>0)for(a.iushrn(b);b-- >0;)c.isOdd()&&c.iadd(o),c.iushrn(1);t.cmp(a)>=0?(t.isub(a),n.isub(c)):(a.isub(t),c.isub(n))}return(r=0===t.cmpn(1)?n:c).cmpn(0)<0&&r.iadd(e),r},BN.prototype.gcd=function gcd(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),a=e.clone();t.negative=0,a.negative=0;for(var r=0;t.isEven()&&a.isEven();r++)t.iushrn(1),a.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;a.isEven();)a.iushrn(1);var n=t.cmp(a);if(n<0){var c=t;t=a,a=c}else if(0===n||0===a.cmpn(1))break;t.isub(a)}return a.iushln(r)},BN.prototype.invm=function invm(e){return this.egcd(e).a.umod(e)},BN.prototype.isEven=function isEven(){return 0==(1&this.words[0])},BN.prototype.isOdd=function isOdd(){return 1==(1&this.words[0])},BN.prototype.andln=function andln(e){return this.words[0]&e},BN.prototype.bincn=function bincn(e){assert("number"==typeof e);var t=e%26,a=(e-t)/26,r=1<>>26,o&=67108863,this.words[c]=o}return 0!==n&&(this.words[c]=n,this.length++),this},BN.prototype.isZero=function isZero(){return 1===this.length&&0===this.words[0]},BN.prototype.cmpn=function cmpn(e){var t,a=e<0;if(0!==this.negative&&!a)return-1;if(0===this.negative&&a)return 1;if(this.strip(),this.length>1)t=1;else{a&&(e=-e),assert(e<=67108863,"Number is too big");var r=0|this.words[0];t=r===e?0:re.length)return 1;if(this.length=0;a--){var r=0|this.words[a],n=0|e.words[a];if(r!==n){rn&&(t=1);break}}return t},BN.prototype.gtn=function gtn(e){return 1===this.cmpn(e)},BN.prototype.gt=function gt(e){return 1===this.cmp(e)},BN.prototype.gten=function gten(e){return this.cmpn(e)>=0},BN.prototype.gte=function gte(e){return this.cmp(e)>=0},BN.prototype.ltn=function ltn(e){return-1===this.cmpn(e)},BN.prototype.lt=function lt(e){return-1===this.cmp(e)},BN.prototype.lten=function lten(e){return this.cmpn(e)<=0},BN.prototype.lte=function lte(e){return this.cmp(e)<=0},BN.prototype.eqn=function eqn(e){return 0===this.cmpn(e)},BN.prototype.eq=function eq(e){return 0===this.cmp(e)},BN.red=function red(e){return new Red(e)},BN.prototype.toRed=function toRed(e){return assert(!this.red,"Already a number in reduction context"),assert(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},BN.prototype.fromRed=function fromRed(){return assert(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},BN.prototype._forceRed=function _forceRed(e){return this.red=e,this},BN.prototype.forceRed=function forceRed(e){return assert(!this.red,"Already a number in reduction context"),this._forceRed(e)},BN.prototype.redAdd=function redAdd(e){return assert(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},BN.prototype.redIAdd=function redIAdd(e){return assert(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},BN.prototype.redSub=function redSub(e){return assert(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},BN.prototype.redISub=function redISub(e){return assert(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},BN.prototype.redShl=function redShl(e){return assert(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},BN.prototype.redMul=function redMul(e){return assert(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},BN.prototype.redIMul=function redIMul(e){return assert(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},BN.prototype.redSqr=function redSqr(){return assert(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},BN.prototype.redISqr=function redISqr(){return assert(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},BN.prototype.redSqrt=function redSqrt(){return assert(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},BN.prototype.redInvm=function redInvm(){return assert(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},BN.prototype.redNeg=function redNeg(){return assert(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},BN.prototype.redPow=function redPow(e){return assert(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var s={k256:null,p224:null,p192:null,p25519:null};function MPrime(e,t){this.name=e,this.p=new BN(t,16),this.n=this.p.bitLength(),this.k=new BN(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function K256(){MPrime.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function P224(){MPrime.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function P192(){MPrime.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function P25519(){MPrime.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function Red(e){if("string"==typeof e){var t=BN._prime(e);this.m=t.p,this.prime=t}else assert(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function Mont(e){Red.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new BN(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)}MPrime.prototype._tmp=function _tmp(){var e=new BN(null);return e.words=new Array(Math.ceil(this.n/13)),e},MPrime.prototype.ireduce=function ireduce(e){var t,a=e;do{this.split(a,this.tmp),t=(a=(a=this.imulK(a)).iadd(this.tmp)).bitLength()}while(t>this.n);var r=t0?a.isub(this.p):void 0!==a.strip?a.strip():a._strip(),a},MPrime.prototype.split=function split(e,t){e.iushrn(this.n,0,t)},MPrime.prototype.imulK=function imulK(e){return e.imul(this.k)},inherits(K256,MPrime),K256.prototype.split=function split(e,t){for(var a=4194303,r=Math.min(e.length,9),n=0;n>>22,c=o}c>>>=22,e.words[n-10]=c,0===c&&e.length>10?e.length-=10:e.length-=9},K256.prototype.imulK=function imulK(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,a=0;a>>=26,e.words[a]=n,t=r}return 0!==t&&(e.words[e.length++]=t),e},BN._prime=function prime(e){if(s[e])return s[e];var prime;if("k256"===e)prime=new K256;else if("p224"===e)prime=new P224;else if("p192"===e)prime=new P192;else{if("p25519"!==e)throw new Error("Unknown prime "+e);prime=new P25519}return s[e]=prime,prime},Red.prototype._verify1=function _verify1(e){assert(0===e.negative,"red works only with positives"),assert(e.red,"red works only with red numbers")},Red.prototype._verify2=function _verify2(e,t){assert(0==(e.negative|t.negative),"red works only with positives"),assert(e.red&&e.red===t.red,"red works only with red numbers")},Red.prototype.imod=function imod(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},Red.prototype.neg=function neg(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},Red.prototype.add=function add(e,t){this._verify2(e,t);var a=e.add(t);return a.cmp(this.m)>=0&&a.isub(this.m),a._forceRed(this)},Red.prototype.iadd=function iadd(e,t){this._verify2(e,t);var a=e.iadd(t);return a.cmp(this.m)>=0&&a.isub(this.m),a},Red.prototype.sub=function sub(e,t){this._verify2(e,t);var a=e.sub(t);return a.cmpn(0)<0&&a.iadd(this.m),a._forceRed(this)},Red.prototype.isub=function isub(e,t){this._verify2(e,t);var a=e.isub(t);return a.cmpn(0)<0&&a.iadd(this.m),a},Red.prototype.shl=function shl(e,t){return this._verify1(e),this.imod(e.ushln(t))},Red.prototype.imul=function imul(e,t){return this._verify2(e,t),this.imod(e.imul(t))},Red.prototype.mul=function mul(e,t){return this._verify2(e,t),this.imod(e.mul(t))},Red.prototype.isqr=function isqr(e){return this.imul(e,e.clone())},Red.prototype.sqr=function sqr(e){return this.mul(e,e)},Red.prototype.sqrt=function sqrt(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(assert(t%2==1),3===t){var a=this.m.add(new BN(1)).iushrn(2);return this.pow(e,a)}for(var r=this.m.subn(1),n=0;!r.isZero()&&0===r.andln(1);)n++,r.iushrn(1);assert(!r.isZero());var c=new BN(1).toRed(this),o=c.redNeg(),d=this.m.subn(1).iushrn(1),s=this.m.bitLength();for(s=new BN(2*s*s).toRed(this);0!==this.pow(s,d).cmp(o);)s.redIAdd(o);for(var b=this.pow(s,r),u=this.pow(e,r.addn(1).iushrn(1)),h=this.pow(e,r),l=n;0!==h.cmp(c);){for(var g=h,p=0;0!==g.cmp(c);p++)g=g.redSqr();assert(p=0;r--){for(var s=t.words[r],b=d-1;b>=0;b--){var u=s>>b&1;n!==a[0]&&(n=this.sqr(n)),0!==u||0!==c?(c<<=1,c|=u,(4===++o||0===r&&0===b)&&(n=this.mul(n,a[c]),o=0,c=0)):o=0}d=26}return n},Red.prototype.convertTo=function convertTo(e){var t=e.umod(this.m);return t===e?t.clone():t},Red.prototype.convertFrom=function convertFrom(e){var t=e.clone();return t.red=null,t},BN.mont=function mont(e){return new Mont(e)},inherits(Mont,Red),Mont.prototype.convertTo=function convertTo(e){return this.imod(e.ushln(this.shift))},Mont.prototype.convertFrom=function convertFrom(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},Mont.prototype.imul=function imul(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var a=e.imul(t),r=a.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=a.isub(r).iushrn(this.shift),c=n;return n.cmp(this.m)>=0?c=n.isub(this.m):n.cmpn(0)<0&&(c=n.iadd(this.m)),c._forceRed(this)},Mont.prototype.mul=function mul(e,t){if(e.isZero()||t.isZero())return new BN(0)._forceRed(this);var a=e.mul(t),r=a.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=a.isub(r).iushrn(this.shift),c=n;return n.cmp(this.m)>=0?c=n.isub(this.m):n.cmpn(0)<0&&(c=n.iadd(this.m)),c._forceRed(this)},Mont.prototype.invm=function invm(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e=a.nmd(e),this)},(e,t,a)=>{var r=a(2),n=r.Buffer;function copyProps(e,t){for(var a in e)t[a]=e[a]}function SafeBuffer(e,t,a){return n(e,t,a)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(copyProps(r,t),t.Buffer=SafeBuffer),SafeBuffer.prototype=Object.create(n.prototype),copyProps(n,SafeBuffer),SafeBuffer.from=function(e,t,a){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,a)},SafeBuffer.alloc=function(e,t,a){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=n(e);return void 0!==t?"string"==typeof a?r.fill(t,a):r.fill(t):r.fill(0),r},SafeBuffer.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},SafeBuffer.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},(e,t,a)=>{"use strict";var r=a(2).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.createDecipheriv=t.createCipheriv=t.randomBytes=t.pseudoRandomBytes=t.createHash=t.createHmac=t.scrypt=void 0;const n=a(204);Object.defineProperty(t,"createCipheriv",{enumerable:!0,get:function(){return n.createCipheriv}}),Object.defineProperty(t,"createDecipheriv",{enumerable:!0,get:function(){return n.createDecipheriv}});const c=a(650),scrypt=(e,t,a,n,o)=>{(0,c.scrypt)(r.from(e,"utf8"),r.from(t,"utf8"),n.N,n.r,n.p,a).then((e=>{o(null,r.from(e))})).catch((e=>o(e,void 0)))};t.scrypt=scrypt;const o=a(1267);Object.defineProperty(t,"createHmac",{enumerable:!0,get:function(){return o.createHmac}}),Object.defineProperty(t,"createHash",{enumerable:!0,get:function(){return o.createHash}}),Object.defineProperty(t,"pseudoRandomBytes",{enumerable:!0,get:function(){return o.pseudoRandomBytes}}),Object.defineProperty(t,"randomBytes",{enumerable:!0,get:function(){return o.randomBytes}}),t.default={scrypt,createHmac:o.createHmac,createHash:o.createHash,pseudoRandomBytes:o.pseudoRandomBytes,randomBytes:o.randomBytes,createCipheriv:n.createCipheriv,createDecipheriv:n.createDecipheriv}},(e,t,a)=>{var r=a(166),n=Function.prototype,c=n.bind,o=n.call,d=r&&c.bind(o,o);e.exports=r?function(e){return e&&d(e)}:function(e){return e&&function(){return o.apply(e,arguments)}}},function(e,t,a){"use strict";var r,n=a(0).Buffer,c=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function __(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}),o=this&&this.__assign||function(){return o=Object.assign||function(e){for(var t,a=1,r=arguments.length;a=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.ConsensusAlgorithm=t.ConsensusType=t.Hardfork=t.Chain=t.CustomChain=void 0;var s,b,u=a(24),h=a(1088),l=a(1),g=a(608),p=a(1488),B=a(1505);!function(e){e.PolygonMainnet="polygon-mainnet",e.PolygonMumbai="polygon-mumbai",e.ArbitrumRinkebyTestnet="arbitrum-rinkeby-testnet",e.xDaiChain="x-dai-chain",e.OptimisticKovan="optimistic-kovan",e.OptimisticEthereum="optimistic-ethereum"}(s=t.CustomChain||(t.CustomChain={})),function(e){e[e.Mainnet=1]="Mainnet",e[e.Ropsten=3]="Ropsten",e[e.Rinkeby=4]="Rinkeby",e[e.Kovan=42]="Kovan",e[e.Goerli=5]="Goerli",e[e.Sepolia=11155111]="Sepolia"}(t.Chain||(t.Chain={})),function(e){e.Chainstart="chainstart",e.Homestead="homestead",e.Dao="dao",e.TangerineWhistle="tangerineWhistle",e.SpuriousDragon="spuriousDragon",e.Byzantium="byzantium",e.Constantinople="constantinople",e.Petersburg="petersburg",e.Istanbul="istanbul",e.MuirGlacier="muirGlacier",e.Berlin="berlin",e.London="london",e.ArrowGlacier="arrowGlacier",e.Shanghai="shanghai",e.MergeForkIdTransition="mergeForkIdTransition",e.Merge="merge"}(b=t.Hardfork||(t.Hardfork={})),function(e){e.ProofOfStake="pos",e.ProofOfWork="pow",e.ProofOfAuthority="poa"}(t.ConsensusType||(t.ConsensusType={})),function(e){e.Ethash="ethash",e.Clique="clique",e.Casper="casper"}(t.ConsensusAlgorithm||(t.ConsensusAlgorithm={}));var x=function(e){function Common(t){var a,r,n,c,o=this;(o=e.call(this)||this)._supportedHardforks=[],o._eips=[],o._customChains=null!==(n=t.customChains)&&void 0!==n?n:[],o._chainParams=o.setChain(t.chain),o.DEFAULT_HARDFORK=null!==(c=o._chainParams.defaultHardfork)&&void 0!==c?c:b.Istanbul;try{for(var s=d(o._chainParams.hardforks),u=s.next();!u.done;u=s.next()){var h=u.value;h.forkHash||(h.forkHash=o._calcForkHash(h.name))}}catch(e){a={error:e}}finally{try{u&&!u.done&&(r=s.return)&&r.call(s)}finally{if(a)throw a.error}}return o._hardfork=o.DEFAULT_HARDFORK,t.supportedHardforks&&(o._supportedHardforks=t.supportedHardforks),t.hardfork&&o.setHardfork(t.hardfork),t.eips&&o.setEIPs(t.eips),o}return c(Common,e),Common.custom=function(e,t){var a;void 0===t&&(t={});var r=null!==(a=t.baseChain)&&void 0!==a?a:"mainnet",n=o({},Common._getChainParams(r));if(n.name="custom-chain","string"!=typeof e)return new Common(o({chain:o(o({},n),e)},t));if(e===s.PolygonMainnet)return Common.custom({name:s.PolygonMainnet,chainId:137,networkId:137},t);if(e===s.PolygonMumbai)return Common.custom({name:s.PolygonMumbai,chainId:80001,networkId:80001},t);if(e===s.ArbitrumRinkebyTestnet)return Common.custom({name:s.ArbitrumRinkebyTestnet,chainId:421611,networkId:421611},t);if(e===s.xDaiChain)return Common.custom({name:s.xDaiChain,chainId:100,networkId:100},t);if(e===s.OptimisticKovan)return Common.custom({name:s.OptimisticKovan,chainId:69,networkId:69},o({hardfork:b.Berlin},t));if(e===s.OptimisticEthereum)return Common.custom({name:s.OptimisticEthereum,chainId:10,networkId:10},o({hardfork:b.Berlin},t));throw new Error("Custom chain ".concat(e," not supported"))},Common.forCustomChain=function(e,t,a,r){var n=Common._getChainParams(e);return new Common({chain:o(o({},n),t),hardfork:a,supportedHardforks:r})},Common.isSupportedChainId=function(e){var t=(0,g._getInitializedChains)();return Boolean(t.names[e.toString()])},Common._getChainParams=function(e,t){var a=(0,g._getInitializedChains)(t);if("number"==typeof e||l.BN.isBN(e)){if(e=e.toString(),a.names[e])return a[a.names[e]];throw new Error("Chain with ID ".concat(e," not supported"))}if(a[e])return a[e];throw new Error("Chain with name ".concat(e," not supported"))},Common.prototype.setChain=function(e){var t,a;if("number"==typeof e||"string"==typeof e||l.BN.isBN(e)){var r=void 0;r=this._customChains&&this._customChains.length>0&&Array.isArray(this._customChains[0])?this._customChains.map((function(e){return e[0]})):this._customChains,this._chainParams=Common._getChainParams(e,r)}else{if("object"!=typeof e)throw new Error("Wrong input format");if(this._customChains.length>0)throw new Error("Chain must be a string, number, or BN when initialized with customChains passed in");try{for(var n=d(["networkId","genesis","hardforks","bootstrapNodes"]),c=n.next();!c.done;c=n.next()){var o=c.value;if(void 0===e[o])throw new Error("Missing required chain parameter: ".concat(o))}}catch(e){t={error:e}}finally{try{c&&!c.done&&(a=n.return)&&a.call(n)}finally{if(t)throw t.error}}this._chainParams=e}return this._chainParams},Common.prototype.setHardfork=function(e){var t,a;if(!this._isSupportedHardfork(e))throw new Error("Hardfork ".concat(e," not set as supported in supportedHardforks"));var r=!1;try{for(var n=d(p.hardforks),c=n.next();!c.done;c=n.next()){c.value[0]===e&&(this._hardfork!==e&&(this._hardfork=e,this.emit("hardforkChanged",e)),r=!0)}}catch(e){t={error:e}}finally{try{c&&!c.done&&(a=n.return)&&a.call(n)}finally{if(t)throw t.error}}if(!r)throw new Error("Hardfork with name ".concat(e," not supported"))},Common.prototype.getHardforkByBlockNumber=function(e,t){var a,r;e=(0,l.toType)(e,l.TypeOutput.BN),t=(0,l.toType)(t,l.TypeOutput.BN);var n,c,o,s=b.Chainstart;try{for(var u=d(this.hardforks()),h=u.next();!h.done;h=u.next()){var g=h.value;if(null!==g.block)e.gte(new l.BN(g.block))&&(s=g.name),t&&g.td&&(t.gte(new l.BN(g.td))?n=g.name:c=o),o=g.name;else if(null!=t&&void 0!==g.td&&null!==g.td&&t.gte(new l.BN(g.td)))return g.name}}catch(e){a={error:e}}finally{try{h&&!h.done&&(r=u.return)&&r.call(u)}finally{if(a)throw a.error}}if(t){var p="block number: ".concat(e," (-> ").concat(s,"), ");if(n&&!this.hardforkGteHardfork(s,n)){var B="HF determined by block number is lower than the minimum total difficulty HF";throw p+="total difficulty: ".concat(t," (-> ").concat(n,")"),new Error("".concat(B,": ").concat(p))}if(c&&!this.hardforkGteHardfork(c,s)){B="Maximum HF determined by total difficulty is lower than the block number HF";throw p+="total difficulty: ".concat(t," (-> ").concat(c,")"),new Error("".concat(B,": ").concat(p))}}return s},Common.prototype.setHardforkByBlockNumber=function(e,t){var a=this.getHardforkByBlockNumber(e,t);return this.setHardfork(a),a},Common.prototype._chooseHardfork=function(e,t){if(void 0===t&&(t=!0),e){if(t&&!this._isSupportedHardfork(e))throw new Error("Hardfork ".concat(e," not set as supported in supportedHardforks"))}else e=this._hardfork;return e},Common.prototype._getHardfork=function(e){var t,a,r=this.hardforks();try{for(var n=d(r),c=n.next();!c.done;c=n.next()){var o=c.value;if(o.name===e)return o}}catch(e){t={error:e}}finally{try{c&&!c.done&&(a=n.return)&&a.call(n)}finally{if(t)throw t.error}}throw new Error("Hardfork ".concat(e," not defined for chain ").concat(this.chainName()))},Common.prototype._isSupportedHardfork=function(e){var t,a;if(!(this._supportedHardforks.length>0))return!0;try{for(var r=d(this._supportedHardforks),n=r.next();!n.done;n=r.next()){if(e===n.value)return!0}}catch(e){t={error:e}}finally{try{n&&!n.done&&(a=r.return)&&a.call(r)}finally{if(t)throw t.error}}return!1},Common.prototype.setEIPs=function(e){var t,a,r=this;void 0===e&&(e=[]);var _loop_1=function(t){if(!(t in B.EIPs))throw new Error("".concat(t," not supported"));var a=n.gteHardfork(B.EIPs[t].minimumHardfork);if(!a)throw new Error("".concat(t," cannot be activated on hardfork ").concat(n.hardfork(),", minimumHardfork: ").concat(a));B.EIPs[t].requiredEIPs&&B.EIPs[t].requiredEIPs.forEach((function(a){if(!e.includes(a)&&!r.isActivatedEIP(a))throw new Error("".concat(t," requires EIP ").concat(a,", but is not included in the EIP list"))}))},n=this;try{for(var c=d(e),o=c.next();!o.done;o=c.next()){_loop_1(o.value)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(a=c.return)&&a.call(c)}finally{if(t)throw t.error}}this._eips=e},Common.prototype.param=function(e,t){var a,r,n=null;try{for(var c=d(this._eips),o=c.next();!o.done;o=c.next()){var s=o.value;if(null!==(n=this.paramByEIP(e,t,s)))return n}}catch(e){a={error:e}}finally{try{o&&!o.done&&(r=c.return)&&r.call(c)}finally{if(a)throw a.error}}return this.paramByHardfork(e,t,this._hardfork)},Common.prototype.paramByHardfork=function(e,t,a){var r,n,c,o;a=this._chooseHardfork(a);var s=null;try{for(var b=d(p.hardforks),u=b.next();!u.done;u=b.next()){var h=u.value;if("eips"in h[1]){var l=h[1].eips;try{for(var g=(c=void 0,d(l)),B=g.next();!B.done;B=g.next()){var x=B.value,I=this.paramByEIP(e,t,x);s=null!==I?I:s}}catch(e){c={error:e}}finally{try{B&&!B.done&&(o=g.return)&&o.call(g)}finally{if(c)throw c.error}}}else{if(!h[1][e])throw new Error("Topic ".concat(e," not defined"));void 0!==h[1][e][t]&&(s=h[1][e][t].v)}if(h[0]===a)break}}catch(e){r={error:e}}finally{try{u&&!u.done&&(n=b.return)&&n.call(b)}finally{if(r)throw r.error}}return s},Common.prototype.paramByEIP=function(e,t,a){if(!(a in B.EIPs))throw new Error("".concat(a," not supported"));var r=B.EIPs[a];if(!(e in r))throw new Error("Topic ".concat(e," not defined"));return void 0===r[e][t]?null:r[e][t].v},Common.prototype.paramByBlock=function(e,t,a){var r=this.activeHardforks(a),n=r[r.length-1].name;return this.paramByHardfork(e,t,n)},Common.prototype.isActivatedEIP=function(e){var t,a;if(this.eips().includes(e))return!0;try{for(var r=d(p.hardforks),n=r.next();!n.done;n=r.next()){var c=n.value[1];if(this.gteHardfork(c.name)&&"eips"in c&&c.eips.includes(e))return!0}}catch(e){t={error:e}}finally{try{n&&!n.done&&(a=r.return)&&a.call(r)}finally{if(t)throw t.error}}return!1},Common.prototype.hardforkIsActiveOnBlock=function(e,t,a){var r;void 0===a&&(a={}),t=(0,l.toType)(t,l.TypeOutput.BN);var n=null!==(r=a.onlySupported)&&void 0!==r&&r;e=this._chooseHardfork(e,n);var c=this.hardforkBlockBN(e);return!(!c||!t.gte(c))},Common.prototype.activeOnBlock=function(e,t){return this.hardforkIsActiveOnBlock(null,e,t)},Common.prototype.hardforkGteHardfork=function(e,t,a){var r,n;void 0===a&&(a={});var c,o=void 0!==a.onlyActive&&a.onlyActive;e=this._chooseHardfork(e,a.onlySupported),c=o?this.activeHardforks(null,a):this.hardforks();var s=-1,b=-1,u=0;try{for(var h=d(c),l=h.next();!l.done;l=h.next()){var g=l.value;g.name===e&&(s=u),g.name===t&&(b=u),u+=1}}catch(e){r={error:e}}finally{try{l&&!l.done&&(n=h.return)&&n.call(h)}finally{if(r)throw r.error}}return s>=b&&-1!==b},Common.prototype.gteHardfork=function(e,t){return this.hardforkGteHardfork(null,e,t)},Common.prototype.hardforkIsActiveOnChain=function(e,t){var a,r,n;void 0===t&&(t={});var c=null!==(n=t.onlySupported)&&void 0!==n&&n;e=this._chooseHardfork(e,c);try{for(var o=d(this.hardforks()),s=o.next();!s.done;s=o.next()){var b=s.value;if(b.name===e&&null!==b.block)return!0}}catch(e){a={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(a)throw a.error}}return!1},Common.prototype.activeHardforks=function(e,t){var a,r;void 0===t&&(t={});var n=[],c=this.hardforks();try{for(var o=d(c),s=o.next();!s.done;s=o.next()){var b=s.value;if(null!==b.block){if(null!=e&&e0)return a[a.length-1].name;throw new Error("No (supported) active hardfork found")},Common.prototype.hardforkBlock=function(e){var t=this.hardforkBlockBN(e);return(0,l.toType)(t,l.TypeOutput.Number)},Common.prototype.hardforkBlockBN=function(e){e=this._chooseHardfork(e,!1);var t=this._getHardfork(e).block;return null==t?null:new l.BN(t)},Common.prototype.hardforkTD=function(e){e=this._chooseHardfork(e,!1);var t=this._getHardfork(e).td;return null==t?null:new l.BN(t)},Common.prototype.isHardforkBlock=function(e,t){e=(0,l.toType)(e,l.TypeOutput.BN),t=this._chooseHardfork(t,!1);var a=this.hardforkBlockBN(t);return!!a&&a.eq(e)},Common.prototype.nextHardforkBlock=function(e){var t=this.nextHardforkBlockBN(e);return(0,l.toType)(t,l.TypeOutput.Number)},Common.prototype.nextHardforkBlockBN=function(e){e=this._chooseHardfork(e,!1);var t=this.hardforkBlockBN(e);return null===t?null:this.hardforks().reduce((function(e,a){var r=new l.BN(a.block);return r.gt(t)&&null===e?r:e}),null)},Common.prototype.isNextHardforkBlock=function(e,t){e=(0,l.toType)(e,l.TypeOutput.BN),t=this._chooseHardfork(t,!1);var a=this.nextHardforkBlockBN(t);return null!==a&&a.eq(e)},Common.prototype._calcForkHash=function(e){var t,a,r=n.from(this.genesis().hash.substr(2),"hex"),c=n.alloc(0),o=0;try{for(var s=d(this.hardforks()),b=s.next();!b.done;b=s.next()){var u=b.value,g=u.block;if(0!==g&&null!==g&&g!==o){var p=n.from(g.toString(16).padStart(16,"0"),"hex");c=n.concat([c,p])}if(u.name===e)break;null!==g&&(o=g)}}catch(e){t={error:e}}finally{try{b&&!b.done&&(a=s.return)&&a.call(s)}finally{if(t)throw t.error}}var B=n.concat([r,c]),x=(0,l.intToBuffer)((0,h.buf)(B)>>>0).toString("hex");return"0x".concat(x)},Common.prototype.forkHash=function(e){e=this._chooseHardfork(e,!1);var t=this._getHardfork(e);if(null===t.block&&void 0===t.td){throw new Error("No fork hash calculation possible for future hardfork")}return void 0!==t.forkHash?t.forkHash:this._calcForkHash(e)},Common.prototype.hardforkForForkHash=function(e){var t=this.hardforks().filter((function(t){return t.forkHash===e}));return t.length>=1?t[t.length-1]:null},Common.prototype.genesis=function(){return this._chainParams.genesis},Common.prototype.genesisState=function(){var e,t;switch(this.chainName()){case"mainnet":return a(1527);case"ropsten":return a(1528);case"rinkeby":return a(1529);case"kovan":return a(1530);case"goerli":return a(1531);case"sepolia":return a(1532)}if(this._customChains&&this._customChains.length>0&&Array.isArray(this._customChains[0]))try{for(var r=d(this._customChains),n=r.next();!n.done;n=r.next()){var c=n.value;if(c[0].name===this.chainName())return c[1]}}catch(t){e={error:t}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return{}},Common.prototype.hardforks=function(){return this._chainParams.hardforks},Common.prototype.bootstrapNodes=function(){return this._chainParams.bootstrapNodes},Common.prototype.dnsNetworks=function(){return this._chainParams.dnsNetworks},Common.prototype.hardfork=function(){return this._hardfork},Common.prototype.chainId=function(){return(0,l.toType)(this.chainIdBN(),l.TypeOutput.Number)},Common.prototype.chainIdBN=function(){return new l.BN(this._chainParams.chainId)},Common.prototype.chainName=function(){return this._chainParams.name},Common.prototype.networkId=function(){return(0,l.toType)(this.networkIdBN(),l.TypeOutput.Number)},Common.prototype.networkIdBN=function(){return new l.BN(this._chainParams.networkId)},Common.prototype.eips=function(){return this._eips},Common.prototype.consensusType=function(){var e,t,a,r=this.hardfork();try{for(var n=d(p.hardforks),c=n.next();!c.done;c=n.next()){var o=c.value;if("consensus"in o[1]&&(a=o[1].consensus.type),o[0]===r)break}}catch(t){e={error:t}}finally{try{c&&!c.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return a||this._chainParams.consensus.type},Common.prototype.consensusAlgorithm=function(){var e,t,a,r=this.hardfork();try{for(var n=d(p.hardforks),c=n.next();!c.done;c=n.next()){var o=c.value;if("consensus"in o[1]&&(a=o[1].consensus.algorithm),o[0]===r)break}}catch(t){e={error:t}}finally{try{c&&!c.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return a||this._chainParams.consensus.algorithm},Common.prototype.consensusConfig=function(){var e,t,a,r=this.hardfork();try{for(var n=d(p.hardforks),c=n.next();!c.done;c=n.next()){var o=c.value;if("consensus"in o[1]&&(a=o[1].consensus[o[1].consensus.algorithm]),o[0]===r)break}}catch(t){e={error:t}}finally{try{c&&!c.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}if(a)return a;var s=this.consensusAlgorithm();return this._chainParams.consensus[s]},Common.prototype.copy=function(){var e=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return e.removeAllListeners(),e},Common}(u.EventEmitter);t.default=x},e=>{e.exports=function(e){try{return!!e()}catch(e){return!0}}},(e,t,a)=>{var r=a(8),n=r.Buffer;function copyProps(e,t){for(var a in e)t[a]=e[a]}function SafeBuffer(e,t,a){return n(e,t,a)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(copyProps(r,t),t.Buffer=SafeBuffer),SafeBuffer.prototype=Object.create(n.prototype),copyProps(n,SafeBuffer),SafeBuffer.from=function(e,t,a){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,a)},SafeBuffer.alloc=function(e,t,a){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=n(e);return void 0!==t?"string"==typeof a?r.fill(t,a):r.fill(t):r.fill(0),r},SafeBuffer.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},SafeBuffer.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},(e,t,a)=>{var r=a(10),n=r.Buffer;function copyProps(e,t){for(var a in e)t[a]=e[a]}function SafeBuffer(e,t,a){return n(e,t,a)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(copyProps(r,t),t.Buffer=SafeBuffer),SafeBuffer.prototype=Object.create(n.prototype),copyProps(n,SafeBuffer),SafeBuffer.from=function(e,t,a){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,a)},SafeBuffer.alloc=function(e,t,a){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=n(e);return void 0!==t?"string"==typeof a?r.fill(t,a):r.fill(t):r.fill(0),r},SafeBuffer.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},SafeBuffer.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},(e,t,a)=>{var r=a(2),n=r.Buffer;function copyProps(e,t){for(var a in e)t[a]=e[a]}function SafeBuffer(e,t,a){return n(e,t,a)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(copyProps(r,t),t.Buffer=SafeBuffer),SafeBuffer.prototype=Object.create(n.prototype),copyProps(n,SafeBuffer),SafeBuffer.from=function(e,t,a){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,a)},SafeBuffer.alloc=function(e,t,a){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=n(e);return void 0!==t?"string"==typeof a?r.fill(t,a):r.fill(t):r.fill(0),r},SafeBuffer.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},SafeBuffer.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},e=>{function assert(e,t){if(!e)throw new Error(t||"Assertion failed")}e.exports=assert,assert.equal=function assertEqual(e,t,a){if(e!=t)throw new Error(a||"Assertion failed: "+e+" != "+t)}},(e,t,a)=>{"use strict";var r=t,n=a(22),c=a(39),o=a(346);r.assert=c,r.toArray=o.toArray,r.zero2=o.zero2,r.toHex=o.toHex,r.encode=o.encode,r.getNAF=function getNAF(e,t,a){var r=new Array(Math.max(e.bitLength(),a)+1);r.fill(0);for(var n=1<(n>>1)-1?(n>>1)-s:s,c.isubn(d)):d=0,r[o]=d,c.iushrn(1)}return r},r.getJSF=function getJSF(e,t){var a=[[],[]];e=e.clone(),t=t.clone();for(var r,n=0,c=0;e.cmpn(-n)>0||t.cmpn(-c)>0;){var o,d,s=e.andln(3)+n&3,b=t.andln(3)+c&3;3===s&&(s=-1),3===b&&(b=-1),o=0==(1&s)?0:3!==(r=e.andln(7)+n&7)&&5!==r||2!==b?s:-s,a[0].push(o),d=0==(1&b)?0:3!==(r=t.andln(7)+c&7)&&5!==r||2!==s?b:-b,a[1].push(d),2*n===o+1&&(n=1-n),2*c===d+1&&(c=1-c),e.iushrn(1),t.iushrn(1)}return a},r.cachedProperty=function cachedProperty(e,t,a){var r="_"+t;e.prototype[t]=function cachedProperty(){return void 0!==this[r]?this[r]:this[r]=a.call(this)}},r.parseBytes=function parseBytes(e){return"string"==typeof e?r.toArray(e,"hex"):e},r.intFromLE=function intFromLE(e){return new n(e,"hex","le")}},(e,t,a)=>{"use strict";var r=t,n=a(57),c=a(79),o=a(361);r.assert=c,r.toArray=o.toArray,r.zero2=o.zero2,r.toHex=o.toHex,r.encode=o.encode,r.getNAF=function getNAF(e,t,a){var r=new Array(Math.max(e.bitLength(),a)+1);r.fill(0);for(var n=1<(n>>1)-1?(n>>1)-s:s,c.isubn(d)):d=0,r[o]=d,c.iushrn(1)}return r},r.getJSF=function getJSF(e,t){var a=[[],[]];e=e.clone(),t=t.clone();for(var r,n=0,c=0;e.cmpn(-n)>0||t.cmpn(-c)>0;){var o,d,s=e.andln(3)+n&3,b=t.andln(3)+c&3;3===s&&(s=-1),3===b&&(b=-1),o=0==(1&s)?0:3!==(r=e.andln(7)+n&7)&&5!==r||2!==b?s:-s,a[0].push(o),d=0==(1&b)?0:3!==(r=t.andln(7)+c&7)&&5!==r||2!==s?b:-b,a[1].push(d),2*n===o+1&&(n=1-n),2*c===d+1&&(c=1-c),e.iushrn(1),t.iushrn(1)}return a},r.cachedProperty=function cachedProperty(e,t,a){var r="_"+t;e.prototype[t]=function cachedProperty(){return void 0!==this[r]?this[r]:this[r]=a.call(this)}},r.parseBytes=function parseBytes(e){return"string"==typeof e?r.toArray(e,"hex"):e},r.intFromLE=function intFromLE(e){return new n(e,"hex","le")}},(e,t,a)=>{"use strict";var r=t,n=a(58),c=a(80),o=a(388);r.assert=c,r.toArray=o.toArray,r.zero2=o.zero2,r.toHex=o.toHex,r.encode=o.encode,r.getNAF=function getNAF(e,t,a){var r=new Array(Math.max(e.bitLength(),a)+1);r.fill(0);for(var n=1<(n>>1)-1?(n>>1)-s:s,c.isubn(d)):d=0,r[o]=d,c.iushrn(1)}return r},r.getJSF=function getJSF(e,t){var a=[[],[]];e=e.clone(),t=t.clone();for(var r,n=0,c=0;e.cmpn(-n)>0||t.cmpn(-c)>0;){var o,d,s=e.andln(3)+n&3,b=t.andln(3)+c&3;3===s&&(s=-1),3===b&&(b=-1),o=0==(1&s)?0:3!==(r=e.andln(7)+n&7)&&5!==r||2!==b?s:-s,a[0].push(o),d=0==(1&b)?0:3!==(r=t.andln(7)+c&7)&&5!==r||2!==s?b:-b,a[1].push(d),2*n===o+1&&(n=1-n),2*c===d+1&&(c=1-c),e.iushrn(1),t.iushrn(1)}return a},r.cachedProperty=function cachedProperty(e,t,a){var r="_"+t;e.prototype[t]=function cachedProperty(){return void 0!==this[r]?this[r]:this[r]=a.call(this)}},r.parseBytes=function parseBytes(e){return"string"==typeof e?r.toArray(e,"hex"):e},r.intFromLE=function intFromLE(e){return new n(e,"hex","le")}},(e,t,a)=>{"use strict";var r=t,n=a(59),c=a(81),o=a(405);r.assert=c,r.toArray=o.toArray,r.zero2=o.zero2,r.toHex=o.toHex,r.encode=o.encode,r.getNAF=function getNAF(e,t,a){var r=new Array(Math.max(e.bitLength(),a)+1);r.fill(0);for(var n=1<(n>>1)-1?(n>>1)-s:s,c.isubn(d)):d=0,r[o]=d,c.iushrn(1)}return r},r.getJSF=function getJSF(e,t){var a=[[],[]];e=e.clone(),t=t.clone();for(var r,n=0,c=0;e.cmpn(-n)>0||t.cmpn(-c)>0;){var o,d,s=e.andln(3)+n&3,b=t.andln(3)+c&3;3===s&&(s=-1),3===b&&(b=-1),o=0==(1&s)?0:3!==(r=e.andln(7)+n&7)&&5!==r||2!==b?s:-s,a[0].push(o),d=0==(1&b)?0:3!==(r=t.andln(7)+c&7)&&5!==r||2!==s?b:-b,a[1].push(d),2*n===o+1&&(n=1-n),2*c===d+1&&(c=1-c),e.iushrn(1),t.iushrn(1)}return a},r.cachedProperty=function cachedProperty(e,t,a){var r="_"+t;e.prototype[t]=function cachedProperty(){return void 0!==this[r]?this[r]:this[r]=a.call(this)}},r.parseBytes=function parseBytes(e){return"string"==typeof e?r.toArray(e,"hex"):e},r.intFromLE=function intFromLE(e){return new n(e,"hex","le")}},(e,t,a)=>{"use strict";var r=t,n=a(60),c=a(82),o=a(410);r.assert=c,r.toArray=o.toArray,r.zero2=o.zero2,r.toHex=o.toHex,r.encode=o.encode,r.getNAF=function getNAF(e,t,a){var r=new Array(Math.max(e.bitLength(),a)+1);r.fill(0);for(var n=1<(n>>1)-1?(n>>1)-s:s,c.isubn(d)):d=0,r[o]=d,c.iushrn(1)}return r},r.getJSF=function getJSF(e,t){var a=[[],[]];e=e.clone(),t=t.clone();for(var r,n=0,c=0;e.cmpn(-n)>0||t.cmpn(-c)>0;){var o,d,s=e.andln(3)+n&3,b=t.andln(3)+c&3;3===s&&(s=-1),3===b&&(b=-1),o=0==(1&s)?0:3!==(r=e.andln(7)+n&7)&&5!==r||2!==b?s:-s,a[0].push(o),d=0==(1&b)?0:3!==(r=t.andln(7)+c&7)&&5!==r||2!==s?b:-b,a[1].push(d),2*n===o+1&&(n=1-n),2*c===d+1&&(c=1-c),e.iushrn(1),t.iushrn(1)}return a},r.cachedProperty=function cachedProperty(e,t,a){var r="_"+t;e.prototype[t]=function cachedProperty(){return void 0!==this[r]?this[r]:this[r]=a.call(this)}},r.parseBytes=function parseBytes(e){return"string"==typeof e?r.toArray(e,"hex"):e},r.intFromLE=function intFromLE(e){return new n(e,"hex","le")}},(e,t,a)=>{"use strict";var r=t,n=a(30),c=a(83),o=a(425);r.assert=c,r.toArray=o.toArray,r.zero2=o.zero2,r.toHex=o.toHex,r.encode=o.encode,r.getNAF=function getNAF(e,t,a){var r=new Array(Math.max(e.bitLength(),a)+1);r.fill(0);for(var n=1<(n>>1)-1?(n>>1)-s:s,c.isubn(d)):d=0,r[o]=d,c.iushrn(1)}return r},r.getJSF=function getJSF(e,t){var a=[[],[]];e=e.clone(),t=t.clone();for(var r,n=0,c=0;e.cmpn(-n)>0||t.cmpn(-c)>0;){var o,d,s=e.andln(3)+n&3,b=t.andln(3)+c&3;3===s&&(s=-1),3===b&&(b=-1),o=0==(1&s)?0:3!==(r=e.andln(7)+n&7)&&5!==r||2!==b?s:-s,a[0].push(o),d=0==(1&b)?0:3!==(r=t.andln(7)+c&7)&&5!==r||2!==s?b:-b,a[1].push(d),2*n===o+1&&(n=1-n),2*c===d+1&&(c=1-c),e.iushrn(1),t.iushrn(1)}return a},r.cachedProperty=function cachedProperty(e,t,a){var r="_"+t;e.prototype[t]=function cachedProperty(){return void 0!==this[r]?this[r]:this[r]=a.call(this)}},r.parseBytes=function parseBytes(e){return"string"==typeof e?r.toArray(e,"hex"):e},r.intFromLE=function intFromLE(e){return new n(e,"hex","le")}},(e,t,a)=>{"use strict";var r=a(1183);e.exports=function Type(e){return"symbol"==typeof e?"Symbol":"bigint"==typeof e?"BigInt":r(e)}},function(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[a]}})}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||r(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),t.isHexString=t.getKeys=t.fromAscii=t.fromUtf8=t.toAscii=t.arrayContainsArray=t.getBinarySize=t.padToEven=t.stripHexPrefix=t.isHexPrefixed=void 0,n(a(315),t),n(a(294),t),n(a(667),t),n(a(189),t),n(a(1335),t),n(a(75),t),n(a(668),t),n(a(54),t),n(a(232),t);var c=a(117);Object.defineProperty(t,"isHexPrefixed",{enumerable:!0,get:function(){return c.isHexPrefixed}}),Object.defineProperty(t,"stripHexPrefix",{enumerable:!0,get:function(){return c.stripHexPrefix}}),Object.defineProperty(t,"padToEven",{enumerable:!0,get:function(){return c.padToEven}}),Object.defineProperty(t,"getBinarySize",{enumerable:!0,get:function(){return c.getBinarySize}}),Object.defineProperty(t,"arrayContainsArray",{enumerable:!0,get:function(){return c.arrayContainsArray}}),Object.defineProperty(t,"toAscii",{enumerable:!0,get:function(){return c.toAscii}}),Object.defineProperty(t,"fromUtf8",{enumerable:!0,get:function(){return c.fromUtf8}}),Object.defineProperty(t,"fromAscii",{enumerable:!0,get:function(){return c.fromAscii}}),Object.defineProperty(t,"getKeys",{enumerable:!0,get:function(){return c.getKeys}}),Object.defineProperty(t,"isHexString",{enumerable:!0,get:function(){return c.isHexString}})},function(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||r(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),t.BlockHeader=t.Block=void 0;var c=a(559);Object.defineProperty(t,"Block",{enumerable:!0,get:function(){return c.Block}});var o=a(290);Object.defineProperty(t,"BlockHeader",{enumerable:!0,get:function(){return o.BlockHeader}}),n(a(1535),t)},(e,t,a)=>{var r=a(35);e.exports=!r((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.debug=void 0;t.debug=()=>()=>{}},(e,t,a)=>{var r=a(11),n=a(505),c=a(68),o=a(270),d=a(504),s=a(503),b=n("wks"),u=r.Symbol,h=u&&u.for,l=s?u:u&&u.withoutSetter||o;e.exports=function(e){if(!c(b,e)||!d&&"string"!=typeof b[e]){var t="Symbol."+e;d&&c(u,e)?b[e]=u[e]:b[e]=s&&h?h(t):l(t)}return b[e]}},(e,t,a)=>{"use strict";var r=a(12),n=a(110),c=n(r("String.prototype.indexOf"));e.exports=function callBoundIntrinsic(e,t){var a=r(e,!!t);return"function"==typeof a&&c(e,".prototype.")>-1?n(a):a}},function(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[a]}})}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&r(t,e,a);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.rlp=t.BN=void 0;var d=o(a(657));t.BN=d.default;var s=c(a(221));t.rlp=s},function(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[a]}})}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&r(t,e,a);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.rlp=t.BN=void 0;var d=o(a(662));t.BN=d.default;var s=c(a(1323));t.rlp=s},function(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[a]}})}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&r(t,e,a);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.rlp=t.BN=void 0;var d=o(a(669));t.BN=d.default;var s=c(a(1399));t.rlp=s},function(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[a]}})}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&r(t,e,a);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.rlp=t.BN=void 0;var d=o(a(676));t.BN=d.default;var s=c(a(142));t.rlp=s},function(e,t,a){!function(e,t){"use strict";function assert(e,t){if(!e)throw new Error(t||"Assertion failed")}function inherits(e,t){e.super_=t;var TempCtor=function(){};TempCtor.prototype=t.prototype,e.prototype=new TempCtor,e.prototype.constructor=e}function BN(e,t,a){if(BN.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(a=t,t=10),this._init(e||0,t||10,a||"be"))}var r;"object"==typeof e?e.exports=BN:t.BN=BN,BN.BN=BN,BN.wordSize=26;try{r="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:a(1287).Buffer}catch(e){}function parseHex4Bits(e,t){var a=e.charCodeAt(t);return a>=65&&a<=70?a-55:a>=97&&a<=102?a-87:a-48&15}function parseHexByte(e,t,a){var r=parseHex4Bits(e,a);return a-1>=t&&(r|=parseHex4Bits(e,a-1)<<4),r}function parseBase(e,t,a,r){for(var n=0,c=Math.min(e.length,a),o=t;o=49?d-49+10:d>=17?d-17+10:d}return n}BN.isBN=function isBN(e){return e instanceof BN||null!==e&&"object"==typeof e&&e.constructor.wordSize===BN.wordSize&&Array.isArray(e.words)},BN.max=function max(e,t){return e.cmp(t)>0?e:t},BN.min=function min(e,t){return e.cmp(t)<0?e:t},BN.prototype._init=function init(e,t,a){if("number"==typeof e)return this._initNumber(e,t,a);if("object"==typeof e)return this._initArray(e,t,a);"hex"===t&&(t=16),assert(t===(0|t)&&t>=2&&t<=36);var r=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(r++,this.negative=1),r=0;r-=3)c=e[r]|e[r-1]<<8|e[r-2]<<16,this.words[n]|=c<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===a)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},BN.prototype._parseHex=function _parseHex(e,t,a){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=2)n=parseHexByte(e,t,r)<=18?(c-=18,o+=1,this.words[o]|=n>>>26):c+=8;else for(r=(e.length-t)%2==0?t+1:t;r=18?(c-=18,o+=1,this.words[o]|=n>>>26):c+=8;this.strip()},BN.prototype._parseBase=function _parseBase(e,t,a){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=t)r++;r--,n=n/t|0;for(var c=e.length-a,o=c%r,d=Math.min(c,c-o)+a,s=0,b=a;b1&&0===this.words[this.length-1];)this.length--;return this._normSign()},BN.prototype._normSign=function _normSign(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},BN.prototype.inspect=function inspect(){return(this.red?""};var n=["","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"],c=[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],o=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function smallMulTo(e,t,a){a.negative=t.negative^e.negative;var r=e.length+t.length|0;a.length=r,r=r-1|0;var n=0|e.words[0],c=0|t.words[0],o=n*c,d=67108863&o,s=o/67108864|0;a.words[0]=d;for(var b=1;b>>26,h=67108863&s,l=Math.min(b,t.length-1),g=Math.max(0,b-e.length+1);g<=l;g++){var p=b-g|0;u+=(o=(n=0|e.words[p])*(c=0|t.words[g])+h)/67108864|0,h=67108863&o}a.words[b]=0|h,s=0|u}return 0!==s?a.words[b]=0|s:a.length--,a.strip()}BN.prototype.toString=function toString(e,t){var a;if(t=0|t||1,16===(e=e||10)||"hex"===e){a="";for(var r=0,d=0,s=0;s>>24-r&16777215)||s!==this.length-1?n[6-u.length]+u+a:u+a,(r+=2)>=26&&(r-=26,s--)}for(0!==d&&(a=d.toString(16)+a);a.length%t!=0;)a="0"+a;return 0!==this.negative&&(a="-"+a),a}if(e===(0|e)&&e>=2&&e<=36){var h=c[e],l=o[e];a="";var g=this.clone();for(g.negative=0;!g.isZero();){var p=g.modn(l).toString(e);a=(g=g.idivn(l)).isZero()?p+a:n[h-p.length]+p+a}for(this.isZero()&&(a="0"+a);a.length%t!=0;)a="0"+a;return 0!==this.negative&&(a="-"+a),a}assert(!1,"Base should be between 2 and 36")},BN.prototype.toNumber=function toNumber(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&assert(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},BN.prototype.toJSON=function toJSON(){return this.toString(16)},BN.prototype.toBuffer=function toBuffer(e,t){return assert(void 0!==r),this.toArrayLike(r,e,t)},BN.prototype.toArray=function toArray(e,t){return this.toArrayLike(Array,e,t)},BN.prototype.toArrayLike=function toArrayLike(e,t,a){var r=this.byteLength(),n=a||Math.max(1,r);assert(r<=n,"byte array longer than desired length"),assert(n>0,"Requested array length <= 0"),this.strip();var c,o,d="le"===t,s=new e(n),b=this.clone();if(d){for(o=0;!b.isZero();o++)c=b.andln(255),b.iushrn(8),s[o]=c;for(;o=4096&&(a+=13,t>>>=13),t>=64&&(a+=7,t>>>=7),t>=8&&(a+=4,t>>>=4),t>=2&&(a+=2,t>>>=2),a+t},BN.prototype._zeroBits=function _zeroBits(e){if(0===e)return 26;var t=e,a=0;return 0==(8191&t)&&(a+=13,t>>>=13),0==(127&t)&&(a+=7,t>>>=7),0==(15&t)&&(a+=4,t>>>=4),0==(3&t)&&(a+=2,t>>>=2),0==(1&t)&&a++,a},BN.prototype.bitLength=function bitLength(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},BN.prototype.zeroBits=function zeroBits(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},BN.prototype.uor=function uor(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},BN.prototype.iuand=function iuand(e){var t;t=this.length>e.length?e:this;for(var a=0;ae.length?this.clone().iand(e):e.clone().iand(this)},BN.prototype.uand=function uand(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},BN.prototype.iuxor=function iuxor(e){var t,a;this.length>e.length?(t=this,a=e):(t=e,a=this);for(var r=0;re.length?this.clone().ixor(e):e.clone().ixor(this)},BN.prototype.uxor=function uxor(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},BN.prototype.inotn=function inotn(e){assert("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),a=e%26;this._expand(t),a>0&&t--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-a),this.strip()},BN.prototype.notn=function notn(e){return this.clone().inotn(e)},BN.prototype.setn=function setn(e,t){assert("number"==typeof e&&e>=0);var a=e/26|0,r=e%26;return this._expand(a+1),this.words[a]=t?this.words[a]|1<e.length?(a=this,r=e):(a=e,r=this);for(var n=0,c=0;c>>26;for(;0!==n&&c>>26;if(this.length=a.length,0!==n)this.words[this.length]=n,this.length++;else if(a!==this)for(;ce.length?this.clone().iadd(e):e.clone().iadd(this)},BN.prototype.isub=function isub(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var a,r,n=this.cmp(e);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(a=this,r=e):(a=e,r=this);for(var c=0,o=0;o>26,this.words[o]=67108863&t;for(;0!==c&&o>26,this.words[o]=67108863&t;if(0===c&&o>>13,g=0|o[1],p=8191&g,B=g>>>13,x=0|o[2],I=8191&x,m=x>>>13,y=0|o[3],C=8191&y,w=y>>>13,v=0|o[4],Q=8191&v,k=v>>>13,_=0|o[5],N=8191&_,D=_>>>13,G=0|o[6],L=8191&G,T=G>>>13,U=0|o[7],P=8191&U,q=U>>>13,H=0|o[8],O=8191&H,z=H>>>13,J=0|o[9],j=8191&J,Y=J>>>13,W=0|d[0],V=8191&W,X=W>>>13,$=0|d[1],et=8191&$,tt=$>>>13,at=0|d[2],rt=8191&at,it=at>>>13,nt=0|d[3],ct=8191&nt,ot=nt>>>13,dt=0|d[4],At=8191&dt,st=dt>>>13,bt=0|d[5],ut=8191&bt,ht=bt>>>13,pt=0|d[6],Bt=8191&pt,xt=pt>>>13,It=0|d[7],mt=8191&It,Et=It>>>13,yt=0|d[8],Ct=8191&yt,wt=yt>>>13,vt=0|d[9],Qt=8191&vt,Mt=vt>>>13;a.negative=e.negative^t.negative,a.length=19;var kt=(b+(r=Math.imul(h,V))|0)+((8191&(n=(n=Math.imul(h,X))+Math.imul(l,V)|0))<<13)|0;b=((c=Math.imul(l,X))+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(p,V),n=(n=Math.imul(p,X))+Math.imul(B,V)|0,c=Math.imul(B,X);var _t=(b+(r=r+Math.imul(h,et)|0)|0)+((8191&(n=(n=n+Math.imul(h,tt)|0)+Math.imul(l,et)|0))<<13)|0;b=((c=c+Math.imul(l,tt)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(I,V),n=(n=Math.imul(I,X))+Math.imul(m,V)|0,c=Math.imul(m,X),r=r+Math.imul(p,et)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(B,et)|0,c=c+Math.imul(B,tt)|0;var St=(b+(r=r+Math.imul(h,rt)|0)|0)+((8191&(n=(n=n+Math.imul(h,it)|0)+Math.imul(l,rt)|0))<<13)|0;b=((c=c+Math.imul(l,it)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(C,V),n=(n=Math.imul(C,X))+Math.imul(w,V)|0,c=Math.imul(w,X),r=r+Math.imul(I,et)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(m,et)|0,c=c+Math.imul(m,tt)|0,r=r+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(B,rt)|0,c=c+Math.imul(B,it)|0;var Nt=(b+(r=r+Math.imul(h,ct)|0)|0)+((8191&(n=(n=n+Math.imul(h,ot)|0)+Math.imul(l,ct)|0))<<13)|0;b=((c=c+Math.imul(l,ot)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,r=Math.imul(Q,V),n=(n=Math.imul(Q,X))+Math.imul(k,V)|0,c=Math.imul(k,X),r=r+Math.imul(C,et)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(w,et)|0,c=c+Math.imul(w,tt)|0,r=r+Math.imul(I,rt)|0,n=(n=n+Math.imul(I,it)|0)+Math.imul(m,rt)|0,c=c+Math.imul(m,it)|0,r=r+Math.imul(p,ct)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(B,ct)|0,c=c+Math.imul(B,ot)|0;var Dt=(b+(r=r+Math.imul(h,At)|0)|0)+((8191&(n=(n=n+Math.imul(h,st)|0)+Math.imul(l,At)|0))<<13)|0;b=((c=c+Math.imul(l,st)|0)+(n>>>13)|0)+(Dt>>>26)|0,Dt&=67108863,r=Math.imul(N,V),n=(n=Math.imul(N,X))+Math.imul(D,V)|0,c=Math.imul(D,X),r=r+Math.imul(Q,et)|0,n=(n=n+Math.imul(Q,tt)|0)+Math.imul(k,et)|0,c=c+Math.imul(k,tt)|0,r=r+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(w,rt)|0,c=c+Math.imul(w,it)|0,r=r+Math.imul(I,ct)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(m,ct)|0,c=c+Math.imul(m,ot)|0,r=r+Math.imul(p,At)|0,n=(n=n+Math.imul(p,st)|0)+Math.imul(B,At)|0,c=c+Math.imul(B,st)|0;var Rt=(b+(r=r+Math.imul(h,ut)|0)|0)+((8191&(n=(n=n+Math.imul(h,ht)|0)+Math.imul(l,ut)|0))<<13)|0;b=((c=c+Math.imul(l,ht)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(L,V),n=(n=Math.imul(L,X))+Math.imul(T,V)|0,c=Math.imul(T,X),r=r+Math.imul(N,et)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(D,et)|0,c=c+Math.imul(D,tt)|0,r=r+Math.imul(Q,rt)|0,n=(n=n+Math.imul(Q,it)|0)+Math.imul(k,rt)|0,c=c+Math.imul(k,it)|0,r=r+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,ot)|0)+Math.imul(w,ct)|0,c=c+Math.imul(w,ot)|0,r=r+Math.imul(I,At)|0,n=(n=n+Math.imul(I,st)|0)+Math.imul(m,At)|0,c=c+Math.imul(m,st)|0,r=r+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,ht)|0)+Math.imul(B,ut)|0,c=c+Math.imul(B,ht)|0;var Ft=(b+(r=r+Math.imul(h,Bt)|0)|0)+((8191&(n=(n=n+Math.imul(h,xt)|0)+Math.imul(l,Bt)|0))<<13)|0;b=((c=c+Math.imul(l,xt)|0)+(n>>>13)|0)+(Ft>>>26)|0,Ft&=67108863,r=Math.imul(P,V),n=(n=Math.imul(P,X))+Math.imul(q,V)|0,c=Math.imul(q,X),r=r+Math.imul(L,et)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(T,et)|0,c=c+Math.imul(T,tt)|0,r=r+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(D,rt)|0,c=c+Math.imul(D,it)|0,r=r+Math.imul(Q,ct)|0,n=(n=n+Math.imul(Q,ot)|0)+Math.imul(k,ct)|0,c=c+Math.imul(k,ot)|0,r=r+Math.imul(C,At)|0,n=(n=n+Math.imul(C,st)|0)+Math.imul(w,At)|0,c=c+Math.imul(w,st)|0,r=r+Math.imul(I,ut)|0,n=(n=n+Math.imul(I,ht)|0)+Math.imul(m,ut)|0,c=c+Math.imul(m,ht)|0,r=r+Math.imul(p,Bt)|0,n=(n=n+Math.imul(p,xt)|0)+Math.imul(B,Bt)|0,c=c+Math.imul(B,xt)|0;var Gt=(b+(r=r+Math.imul(h,mt)|0)|0)+((8191&(n=(n=n+Math.imul(h,Et)|0)+Math.imul(l,mt)|0))<<13)|0;b=((c=c+Math.imul(l,Et)|0)+(n>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,r=Math.imul(O,V),n=(n=Math.imul(O,X))+Math.imul(z,V)|0,c=Math.imul(z,X),r=r+Math.imul(P,et)|0,n=(n=n+Math.imul(P,tt)|0)+Math.imul(q,et)|0,c=c+Math.imul(q,tt)|0,r=r+Math.imul(L,rt)|0,n=(n=n+Math.imul(L,it)|0)+Math.imul(T,rt)|0,c=c+Math.imul(T,it)|0,r=r+Math.imul(N,ct)|0,n=(n=n+Math.imul(N,ot)|0)+Math.imul(D,ct)|0,c=c+Math.imul(D,ot)|0,r=r+Math.imul(Q,At)|0,n=(n=n+Math.imul(Q,st)|0)+Math.imul(k,At)|0,c=c+Math.imul(k,st)|0,r=r+Math.imul(C,ut)|0,n=(n=n+Math.imul(C,ht)|0)+Math.imul(w,ut)|0,c=c+Math.imul(w,ht)|0,r=r+Math.imul(I,Bt)|0,n=(n=n+Math.imul(I,xt)|0)+Math.imul(m,Bt)|0,c=c+Math.imul(m,xt)|0,r=r+Math.imul(p,mt)|0,n=(n=n+Math.imul(p,Et)|0)+Math.imul(B,mt)|0,c=c+Math.imul(B,Et)|0;var Lt=(b+(r=r+Math.imul(h,Ct)|0)|0)+((8191&(n=(n=n+Math.imul(h,wt)|0)+Math.imul(l,Ct)|0))<<13)|0;b=((c=c+Math.imul(l,wt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,r=Math.imul(j,V),n=(n=Math.imul(j,X))+Math.imul(Y,V)|0,c=Math.imul(Y,X),r=r+Math.imul(O,et)|0,n=(n=n+Math.imul(O,tt)|0)+Math.imul(z,et)|0,c=c+Math.imul(z,tt)|0,r=r+Math.imul(P,rt)|0,n=(n=n+Math.imul(P,it)|0)+Math.imul(q,rt)|0,c=c+Math.imul(q,it)|0,r=r+Math.imul(L,ct)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(T,ct)|0,c=c+Math.imul(T,ot)|0,r=r+Math.imul(N,At)|0,n=(n=n+Math.imul(N,st)|0)+Math.imul(D,At)|0,c=c+Math.imul(D,st)|0,r=r+Math.imul(Q,ut)|0,n=(n=n+Math.imul(Q,ht)|0)+Math.imul(k,ut)|0,c=c+Math.imul(k,ht)|0,r=r+Math.imul(C,Bt)|0,n=(n=n+Math.imul(C,xt)|0)+Math.imul(w,Bt)|0,c=c+Math.imul(w,xt)|0,r=r+Math.imul(I,mt)|0,n=(n=n+Math.imul(I,Et)|0)+Math.imul(m,mt)|0,c=c+Math.imul(m,Et)|0,r=r+Math.imul(p,Ct)|0,n=(n=n+Math.imul(p,wt)|0)+Math.imul(B,Ct)|0,c=c+Math.imul(B,wt)|0;var Tt=(b+(r=r+Math.imul(h,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(h,Mt)|0)+Math.imul(l,Qt)|0))<<13)|0;b=((c=c+Math.imul(l,Mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(j,et),n=(n=Math.imul(j,tt))+Math.imul(Y,et)|0,c=Math.imul(Y,tt),r=r+Math.imul(O,rt)|0,n=(n=n+Math.imul(O,it)|0)+Math.imul(z,rt)|0,c=c+Math.imul(z,it)|0,r=r+Math.imul(P,ct)|0,n=(n=n+Math.imul(P,ot)|0)+Math.imul(q,ct)|0,c=c+Math.imul(q,ot)|0,r=r+Math.imul(L,At)|0,n=(n=n+Math.imul(L,st)|0)+Math.imul(T,At)|0,c=c+Math.imul(T,st)|0,r=r+Math.imul(N,ut)|0,n=(n=n+Math.imul(N,ht)|0)+Math.imul(D,ut)|0,c=c+Math.imul(D,ht)|0,r=r+Math.imul(Q,Bt)|0,n=(n=n+Math.imul(Q,xt)|0)+Math.imul(k,Bt)|0,c=c+Math.imul(k,xt)|0,r=r+Math.imul(C,mt)|0,n=(n=n+Math.imul(C,Et)|0)+Math.imul(w,mt)|0,c=c+Math.imul(w,Et)|0,r=r+Math.imul(I,Ct)|0,n=(n=n+Math.imul(I,wt)|0)+Math.imul(m,Ct)|0,c=c+Math.imul(m,wt)|0;var Ut=(b+(r=r+Math.imul(p,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(p,Mt)|0)+Math.imul(B,Qt)|0))<<13)|0;b=((c=c+Math.imul(B,Mt)|0)+(n>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,r=Math.imul(j,rt),n=(n=Math.imul(j,it))+Math.imul(Y,rt)|0,c=Math.imul(Y,it),r=r+Math.imul(O,ct)|0,n=(n=n+Math.imul(O,ot)|0)+Math.imul(z,ct)|0,c=c+Math.imul(z,ot)|0,r=r+Math.imul(P,At)|0,n=(n=n+Math.imul(P,st)|0)+Math.imul(q,At)|0,c=c+Math.imul(q,st)|0,r=r+Math.imul(L,ut)|0,n=(n=n+Math.imul(L,ht)|0)+Math.imul(T,ut)|0,c=c+Math.imul(T,ht)|0,r=r+Math.imul(N,Bt)|0,n=(n=n+Math.imul(N,xt)|0)+Math.imul(D,Bt)|0,c=c+Math.imul(D,xt)|0,r=r+Math.imul(Q,mt)|0,n=(n=n+Math.imul(Q,Et)|0)+Math.imul(k,mt)|0,c=c+Math.imul(k,Et)|0,r=r+Math.imul(C,Ct)|0,n=(n=n+Math.imul(C,wt)|0)+Math.imul(w,Ct)|0,c=c+Math.imul(w,wt)|0;var Pt=(b+(r=r+Math.imul(I,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(I,Mt)|0)+Math.imul(m,Qt)|0))<<13)|0;b=((c=c+Math.imul(m,Mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(j,ct),n=(n=Math.imul(j,ot))+Math.imul(Y,ct)|0,c=Math.imul(Y,ot),r=r+Math.imul(O,At)|0,n=(n=n+Math.imul(O,st)|0)+Math.imul(z,At)|0,c=c+Math.imul(z,st)|0,r=r+Math.imul(P,ut)|0,n=(n=n+Math.imul(P,ht)|0)+Math.imul(q,ut)|0,c=c+Math.imul(q,ht)|0,r=r+Math.imul(L,Bt)|0,n=(n=n+Math.imul(L,xt)|0)+Math.imul(T,Bt)|0,c=c+Math.imul(T,xt)|0,r=r+Math.imul(N,mt)|0,n=(n=n+Math.imul(N,Et)|0)+Math.imul(D,mt)|0,c=c+Math.imul(D,Et)|0,r=r+Math.imul(Q,Ct)|0,n=(n=n+Math.imul(Q,wt)|0)+Math.imul(k,Ct)|0,c=c+Math.imul(k,wt)|0;var qt=(b+(r=r+Math.imul(C,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(C,Mt)|0)+Math.imul(w,Qt)|0))<<13)|0;b=((c=c+Math.imul(w,Mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863,r=Math.imul(j,At),n=(n=Math.imul(j,st))+Math.imul(Y,At)|0,c=Math.imul(Y,st),r=r+Math.imul(O,ut)|0,n=(n=n+Math.imul(O,ht)|0)+Math.imul(z,ut)|0,c=c+Math.imul(z,ht)|0,r=r+Math.imul(P,Bt)|0,n=(n=n+Math.imul(P,xt)|0)+Math.imul(q,Bt)|0,c=c+Math.imul(q,xt)|0,r=r+Math.imul(L,mt)|0,n=(n=n+Math.imul(L,Et)|0)+Math.imul(T,mt)|0,c=c+Math.imul(T,Et)|0,r=r+Math.imul(N,Ct)|0,n=(n=n+Math.imul(N,wt)|0)+Math.imul(D,Ct)|0,c=c+Math.imul(D,wt)|0;var Ht=(b+(r=r+Math.imul(Q,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(Q,Mt)|0)+Math.imul(k,Qt)|0))<<13)|0;b=((c=c+Math.imul(k,Mt)|0)+(n>>>13)|0)+(Ht>>>26)|0,Ht&=67108863,r=Math.imul(j,ut),n=(n=Math.imul(j,ht))+Math.imul(Y,ut)|0,c=Math.imul(Y,ht),r=r+Math.imul(O,Bt)|0,n=(n=n+Math.imul(O,xt)|0)+Math.imul(z,Bt)|0,c=c+Math.imul(z,xt)|0,r=r+Math.imul(P,mt)|0,n=(n=n+Math.imul(P,Et)|0)+Math.imul(q,mt)|0,c=c+Math.imul(q,Et)|0,r=r+Math.imul(L,Ct)|0,n=(n=n+Math.imul(L,wt)|0)+Math.imul(T,Ct)|0,c=c+Math.imul(T,wt)|0;var Ot=(b+(r=r+Math.imul(N,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(N,Mt)|0)+Math.imul(D,Qt)|0))<<13)|0;b=((c=c+Math.imul(D,Mt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,r=Math.imul(j,Bt),n=(n=Math.imul(j,xt))+Math.imul(Y,Bt)|0,c=Math.imul(Y,xt),r=r+Math.imul(O,mt)|0,n=(n=n+Math.imul(O,Et)|0)+Math.imul(z,mt)|0,c=c+Math.imul(z,Et)|0,r=r+Math.imul(P,Ct)|0,n=(n=n+Math.imul(P,wt)|0)+Math.imul(q,Ct)|0,c=c+Math.imul(q,wt)|0;var zt=(b+(r=r+Math.imul(L,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(L,Mt)|0)+Math.imul(T,Qt)|0))<<13)|0;b=((c=c+Math.imul(T,Mt)|0)+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863,r=Math.imul(j,mt),n=(n=Math.imul(j,Et))+Math.imul(Y,mt)|0,c=Math.imul(Y,Et),r=r+Math.imul(O,Ct)|0,n=(n=n+Math.imul(O,wt)|0)+Math.imul(z,Ct)|0,c=c+Math.imul(z,wt)|0;var Kt=(b+(r=r+Math.imul(P,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(P,Mt)|0)+Math.imul(q,Qt)|0))<<13)|0;b=((c=c+Math.imul(q,Mt)|0)+(n>>>13)|0)+(Kt>>>26)|0,Kt&=67108863,r=Math.imul(j,Ct),n=(n=Math.imul(j,wt))+Math.imul(Y,Ct)|0,c=Math.imul(Y,wt);var Jt=(b+(r=r+Math.imul(O,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(O,Mt)|0)+Math.imul(z,Qt)|0))<<13)|0;b=((c=c+Math.imul(z,Mt)|0)+(n>>>13)|0)+(Jt>>>26)|0,Jt&=67108863;var jt=(b+(r=Math.imul(j,Qt))|0)+((8191&(n=(n=Math.imul(j,Mt))+Math.imul(Y,Qt)|0))<<13)|0;return b=((c=Math.imul(Y,Mt))+(n>>>13)|0)+(jt>>>26)|0,jt&=67108863,s[0]=kt,s[1]=_t,s[2]=St,s[3]=Nt,s[4]=Dt,s[5]=Rt,s[6]=Ft,s[7]=Gt,s[8]=Lt,s[9]=Tt,s[10]=Ut,s[11]=Pt,s[12]=qt,s[13]=Ht,s[14]=Ot,s[15]=zt,s[16]=Kt,s[17]=Jt,s[18]=jt,0!==b&&(s[19]=b,a.length++),a};function jumboMulTo(e,t,a){return(new FFTM).mulp(e,t,a)}function FFTM(e,t){this.x=e,this.y=t}Math.imul||(d=smallMulTo),BN.prototype.mulTo=function mulTo(e,t){var a,r=this.length+e.length;return a=10===this.length&&10===e.length?d(this,e,t):r<63?smallMulTo(this,e,t):r<1024?function bigMulTo(e,t,a){a.negative=t.negative^e.negative,a.length=e.length+t.length;for(var r=0,n=0,c=0;c>>26)|0)>>>26,o&=67108863}a.words[c]=d,r=o,o=n}return 0!==r?a.words[c]=r:a.length--,a.strip()}(this,e,t):jumboMulTo(this,e,t),a},FFTM.prototype.makeRBT=function makeRBT(e){for(var t=new Array(e),a=BN.prototype._countBits(e)-1,r=0;r>=1;return r},FFTM.prototype.permute=function permute(e,t,a,r,n,c){for(var o=0;o>>=1)n++;return 1<>>=13,a[2*c+1]=8191&n,n>>>=13;for(c=2*t;c>=26,t+=r/67108864|0,t+=n>>>26,this.words[a]=67108863&n}return 0!==t&&(this.words[a]=t,this.length++),this},BN.prototype.muln=function muln(e){return this.clone().imuln(e)},BN.prototype.sqr=function sqr(){return this.mul(this)},BN.prototype.isqr=function isqr(){return this.imul(this.clone())},BN.prototype.pow=function pow(e){var t=function toBitArray(e){for(var t=new Array(e.bitLength()),a=0;a>>n}return t}(e);if(0===t.length)return new BN(1);for(var a=this,r=0;r=0);var t,a=e%26,r=(e-a)/26,n=67108863>>>26-a<<26-a;if(0!==a){var c=0;for(t=0;t>>26-a}c&&(this.words[t]=c,this.length++)}if(0!==r){for(t=this.length-1;t>=0;t--)this.words[t+r]=this.words[t];for(t=0;t=0),r=t?(t-t%26)/26:0;var n=e%26,c=Math.min((e-n)/26,this.length),o=67108863^67108863>>>n<c)for(this.length-=c,s=0;s=0&&(0!==b||s>=r);s--){var u=0|this.words[s];this.words[s]=b<<26-n|u>>>n,b=u&o}return d&&0!==b&&(d.words[d.length++]=b),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},BN.prototype.ishrn=function ishrn(e,t,a){return assert(0===this.negative),this.iushrn(e,t,a)},BN.prototype.shln=function shln(e){return this.clone().ishln(e)},BN.prototype.ushln=function ushln(e){return this.clone().iushln(e)},BN.prototype.shrn=function shrn(e){return this.clone().ishrn(e)},BN.prototype.ushrn=function ushrn(e){return this.clone().iushrn(e)},BN.prototype.testn=function testn(e){assert("number"==typeof e&&e>=0);var t=e%26,a=(e-t)/26,r=1<=0);var t=e%26,a=(e-t)/26;if(assert(0===this.negative,"imaskn works only with positive numbers"),this.length<=a)return this;if(0!==t&&a++,this.length=Math.min(a,this.length),0!==t){var r=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},BN.prototype.isubn=function isubn(e){if(assert("number"==typeof e),assert(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(d/67108864|0),this.words[r+a]=67108863&n}for(;r>26,this.words[r+a]=67108863&n;if(0===o)return this.strip();for(assert(-1===o),o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},BN.prototype._wordDiv=function _wordDiv(e,t){var a=(this.length,e.length),r=this.clone(),n=e,c=0|n.words[n.length-1];0!==(a=26-this._countBits(c))&&(n=n.ushln(a),r.iushln(a),c=0|n.words[n.length-1]);var o,d=r.length-n.length;if("mod"!==t){(o=new BN(null)).length=d+1,o.words=new Array(o.length);for(var s=0;s=0;u--){var h=67108864*(0|r.words[n.length+u])+(0|r.words[n.length+u-1]);for(h=Math.min(h/c|0,67108863),r._ishlnsubmul(n,h,u);0!==r.negative;)h--,r.negative=0,r._ishlnsubmul(n,1,u),r.isZero()||(r.negative^=1);o&&(o.words[u]=h)}return o&&o.strip(),r.strip(),"div"!==t&&0!==a&&r.iushrn(a),{div:o||null,mod:r}},BN.prototype.divmod=function divmod(e,t,a){return assert(!e.isZero()),this.isZero()?{div:new BN(0),mod:new BN(0)}:0!==this.negative&&0===e.negative?(c=this.neg().divmod(e,t),"mod"!==t&&(r=c.div.neg()),"div"!==t&&(n=c.mod.neg(),a&&0!==n.negative&&n.iadd(e)),{div:r,mod:n}):0===this.negative&&0!==e.negative?(c=this.divmod(e.neg(),t),"mod"!==t&&(r=c.div.neg()),{div:r,mod:c.mod}):0!=(this.negative&e.negative)?(c=this.neg().divmod(e.neg(),t),"div"!==t&&(n=c.mod.neg(),a&&0!==n.negative&&n.isub(e)),{div:c.div,mod:n}):e.length>this.length||this.cmp(e)<0?{div:new BN(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new BN(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new BN(this.modn(e.words[0]))}:this._wordDiv(e,t);var r,n,c},BN.prototype.div=function div(e){return this.divmod(e,"div",!1).div},BN.prototype.mod=function mod(e){return this.divmod(e,"mod",!1).mod},BN.prototype.umod=function umod(e){return this.divmod(e,"mod",!0).mod},BN.prototype.divRound=function divRound(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var a=0!==t.div.negative?t.mod.isub(e):t.mod,r=e.ushrn(1),n=e.andln(1),c=a.cmp(r);return c<0||1===n&&0===c?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},BN.prototype.modn=function modn(e){assert(e<=67108863);for(var t=(1<<26)%e,a=0,r=this.length-1;r>=0;r--)a=(t*a+(0|this.words[r]))%e;return a},BN.prototype.idivn=function idivn(e){assert(e<=67108863);for(var t=0,a=this.length-1;a>=0;a--){var r=(0|this.words[a])+67108864*t;this.words[a]=r/e|0,t=r%e}return this.strip()},BN.prototype.divn=function divn(e){return this.clone().idivn(e)},BN.prototype.egcd=function egcd(e){assert(0===e.negative),assert(!e.isZero());var t=this,a=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var r=new BN(1),n=new BN(0),c=new BN(0),o=new BN(1),d=0;t.isEven()&&a.isEven();)t.iushrn(1),a.iushrn(1),++d;for(var s=a.clone(),b=t.clone();!t.isZero();){for(var u=0,h=1;0==(t.words[0]&h)&&u<26;++u,h<<=1);if(u>0)for(t.iushrn(u);u-- >0;)(r.isOdd()||n.isOdd())&&(r.iadd(s),n.isub(b)),r.iushrn(1),n.iushrn(1);for(var l=0,g=1;0==(a.words[0]&g)&&l<26;++l,g<<=1);if(l>0)for(a.iushrn(l);l-- >0;)(c.isOdd()||o.isOdd())&&(c.iadd(s),o.isub(b)),c.iushrn(1),o.iushrn(1);t.cmp(a)>=0?(t.isub(a),r.isub(c),n.isub(o)):(a.isub(t),c.isub(r),o.isub(n))}return{a:c,b:o,gcd:a.iushln(d)}},BN.prototype._invmp=function _invmp(e){assert(0===e.negative),assert(!e.isZero());var t=this,a=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var r,n=new BN(1),c=new BN(0),o=a.clone();t.cmpn(1)>0&&a.cmpn(1)>0;){for(var d=0,s=1;0==(t.words[0]&s)&&d<26;++d,s<<=1);if(d>0)for(t.iushrn(d);d-- >0;)n.isOdd()&&n.iadd(o),n.iushrn(1);for(var b=0,u=1;0==(a.words[0]&u)&&b<26;++b,u<<=1);if(b>0)for(a.iushrn(b);b-- >0;)c.isOdd()&&c.iadd(o),c.iushrn(1);t.cmp(a)>=0?(t.isub(a),n.isub(c)):(a.isub(t),c.isub(n))}return(r=0===t.cmpn(1)?n:c).cmpn(0)<0&&r.iadd(e),r},BN.prototype.gcd=function gcd(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),a=e.clone();t.negative=0,a.negative=0;for(var r=0;t.isEven()&&a.isEven();r++)t.iushrn(1),a.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;a.isEven();)a.iushrn(1);var n=t.cmp(a);if(n<0){var c=t;t=a,a=c}else if(0===n||0===a.cmpn(1))break;t.isub(a)}return a.iushln(r)},BN.prototype.invm=function invm(e){return this.egcd(e).a.umod(e)},BN.prototype.isEven=function isEven(){return 0==(1&this.words[0])},BN.prototype.isOdd=function isOdd(){return 1==(1&this.words[0])},BN.prototype.andln=function andln(e){return this.words[0]&e},BN.prototype.bincn=function bincn(e){assert("number"==typeof e);var t=e%26,a=(e-t)/26,r=1<>>26,o&=67108863,this.words[c]=o}return 0!==n&&(this.words[c]=n,this.length++),this},BN.prototype.isZero=function isZero(){return 1===this.length&&0===this.words[0]},BN.prototype.cmpn=function cmpn(e){var t,a=e<0;if(0!==this.negative&&!a)return-1;if(0===this.negative&&a)return 1;if(this.strip(),this.length>1)t=1;else{a&&(e=-e),assert(e<=67108863,"Number is too big");var r=0|this.words[0];t=r===e?0:re.length)return 1;if(this.length=0;a--){var r=0|this.words[a],n=0|e.words[a];if(r!==n){rn&&(t=1);break}}return t},BN.prototype.gtn=function gtn(e){return 1===this.cmpn(e)},BN.prototype.gt=function gt(e){return 1===this.cmp(e)},BN.prototype.gten=function gten(e){return this.cmpn(e)>=0},BN.prototype.gte=function gte(e){return this.cmp(e)>=0},BN.prototype.ltn=function ltn(e){return-1===this.cmpn(e)},BN.prototype.lt=function lt(e){return-1===this.cmp(e)},BN.prototype.lten=function lten(e){return this.cmpn(e)<=0},BN.prototype.lte=function lte(e){return this.cmp(e)<=0},BN.prototype.eqn=function eqn(e){return 0===this.cmpn(e)},BN.prototype.eq=function eq(e){return 0===this.cmp(e)},BN.red=function red(e){return new Red(e)},BN.prototype.toRed=function toRed(e){return assert(!this.red,"Already a number in reduction context"),assert(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},BN.prototype.fromRed=function fromRed(){return assert(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},BN.prototype._forceRed=function _forceRed(e){return this.red=e,this},BN.prototype.forceRed=function forceRed(e){return assert(!this.red,"Already a number in reduction context"),this._forceRed(e)},BN.prototype.redAdd=function redAdd(e){return assert(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},BN.prototype.redIAdd=function redIAdd(e){return assert(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},BN.prototype.redSub=function redSub(e){return assert(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},BN.prototype.redISub=function redISub(e){return assert(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},BN.prototype.redShl=function redShl(e){return assert(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},BN.prototype.redMul=function redMul(e){return assert(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},BN.prototype.redIMul=function redIMul(e){return assert(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},BN.prototype.redSqr=function redSqr(){return assert(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},BN.prototype.redISqr=function redISqr(){return assert(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},BN.prototype.redSqrt=function redSqrt(){return assert(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},BN.prototype.redInvm=function redInvm(){return assert(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},BN.prototype.redNeg=function redNeg(){return assert(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},BN.prototype.redPow=function redPow(e){return assert(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var s={k256:null,p224:null,p192:null,p25519:null};function MPrime(e,t){this.name=e,this.p=new BN(t,16),this.n=this.p.bitLength(),this.k=new BN(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function K256(){MPrime.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function P224(){MPrime.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function P192(){MPrime.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function P25519(){MPrime.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function Red(e){if("string"==typeof e){var t=BN._prime(e);this.m=t.p,this.prime=t}else assert(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function Mont(e){Red.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new BN(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)}MPrime.prototype._tmp=function _tmp(){var e=new BN(null);return e.words=new Array(Math.ceil(this.n/13)),e},MPrime.prototype.ireduce=function ireduce(e){var t,a=e;do{this.split(a,this.tmp),t=(a=(a=this.imulK(a)).iadd(this.tmp)).bitLength()}while(t>this.n);var r=t0?a.isub(this.p):void 0!==a.strip?a.strip():a._strip(),a},MPrime.prototype.split=function split(e,t){e.iushrn(this.n,0,t)},MPrime.prototype.imulK=function imulK(e){return e.imul(this.k)},inherits(K256,MPrime),K256.prototype.split=function split(e,t){for(var a=4194303,r=Math.min(e.length,9),n=0;n>>22,c=o}c>>>=22,e.words[n-10]=c,0===c&&e.length>10?e.length-=10:e.length-=9},K256.prototype.imulK=function imulK(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,a=0;a>>=26,e.words[a]=n,t=r}return 0!==t&&(e.words[e.length++]=t),e},BN._prime=function prime(e){if(s[e])return s[e];var prime;if("k256"===e)prime=new K256;else if("p224"===e)prime=new P224;else if("p192"===e)prime=new P192;else{if("p25519"!==e)throw new Error("Unknown prime "+e);prime=new P25519}return s[e]=prime,prime},Red.prototype._verify1=function _verify1(e){assert(0===e.negative,"red works only with positives"),assert(e.red,"red works only with red numbers")},Red.prototype._verify2=function _verify2(e,t){assert(0==(e.negative|t.negative),"red works only with positives"),assert(e.red&&e.red===t.red,"red works only with red numbers")},Red.prototype.imod=function imod(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},Red.prototype.neg=function neg(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},Red.prototype.add=function add(e,t){this._verify2(e,t);var a=e.add(t);return a.cmp(this.m)>=0&&a.isub(this.m),a._forceRed(this)},Red.prototype.iadd=function iadd(e,t){this._verify2(e,t);var a=e.iadd(t);return a.cmp(this.m)>=0&&a.isub(this.m),a},Red.prototype.sub=function sub(e,t){this._verify2(e,t);var a=e.sub(t);return a.cmpn(0)<0&&a.iadd(this.m),a._forceRed(this)},Red.prototype.isub=function isub(e,t){this._verify2(e,t);var a=e.isub(t);return a.cmpn(0)<0&&a.iadd(this.m),a},Red.prototype.shl=function shl(e,t){return this._verify1(e),this.imod(e.ushln(t))},Red.prototype.imul=function imul(e,t){return this._verify2(e,t),this.imod(e.imul(t))},Red.prototype.mul=function mul(e,t){return this._verify2(e,t),this.imod(e.mul(t))},Red.prototype.isqr=function isqr(e){return this.imul(e,e.clone())},Red.prototype.sqr=function sqr(e){return this.mul(e,e)},Red.prototype.sqrt=function sqrt(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(assert(t%2==1),3===t){var a=this.m.add(new BN(1)).iushrn(2);return this.pow(e,a)}for(var r=this.m.subn(1),n=0;!r.isZero()&&0===r.andln(1);)n++,r.iushrn(1);assert(!r.isZero());var c=new BN(1).toRed(this),o=c.redNeg(),d=this.m.subn(1).iushrn(1),s=this.m.bitLength();for(s=new BN(2*s*s).toRed(this);0!==this.pow(s,d).cmp(o);)s.redIAdd(o);for(var b=this.pow(s,r),u=this.pow(e,r.addn(1).iushrn(1)),h=this.pow(e,r),l=n;0!==h.cmp(c);){for(var g=h,p=0;0!==g.cmp(c);p++)g=g.redSqr();assert(p=0;r--){for(var s=t.words[r],b=d-1;b>=0;b--){var u=s>>b&1;n!==a[0]&&(n=this.sqr(n)),0!==u||0!==c?(c<<=1,c|=u,(4===++o||0===r&&0===b)&&(n=this.mul(n,a[c]),o=0,c=0)):o=0}d=26}return n},Red.prototype.convertTo=function convertTo(e){var t=e.umod(this.m);return t===e?t.clone():t},Red.prototype.convertFrom=function convertFrom(e){var t=e.clone();return t.red=null,t},BN.mont=function mont(e){return new Mont(e)},inherits(Mont,Red),Mont.prototype.convertTo=function convertTo(e){return this.imod(e.ushln(this.shift))},Mont.prototype.convertFrom=function convertFrom(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},Mont.prototype.imul=function imul(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var a=e.imul(t),r=a.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=a.isub(r).iushrn(this.shift),c=n;return n.cmp(this.m)>=0?c=n.isub(this.m):n.cmpn(0)<0&&(c=n.iadd(this.m)),c._forceRed(this)},Mont.prototype.mul=function mul(e,t){if(e.isZero()||t.isZero())return new BN(0)._forceRed(this);var a=e.mul(t),r=a.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=a.isub(r).iushrn(this.shift),c=n;return n.cmp(this.m)>=0?c=n.isub(this.m):n.cmpn(0)<0&&(c=n.iadd(this.m)),c._forceRed(this)},Mont.prototype.invm=function invm(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e=a.nmd(e),this)},function(e,t,a){!function(e,t){"use strict";function assert(e,t){if(!e)throw new Error(t||"Assertion failed")}function inherits(e,t){e.super_=t;var TempCtor=function(){};TempCtor.prototype=t.prototype,e.prototype=new TempCtor,e.prototype.constructor=e}function BN(e,t,a){if(BN.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(a=t,t=10),this._init(e||0,t||10,a||"be"))}var r;"object"==typeof e?e.exports=BN:t.BN=BN,BN.BN=BN,BN.wordSize=26;try{r="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:a(1326).Buffer}catch(e){}function parseHex4Bits(e,t){var a=e.charCodeAt(t);return a>=65&&a<=70?a-55:a>=97&&a<=102?a-87:a-48&15}function parseHexByte(e,t,a){var r=parseHex4Bits(e,a);return a-1>=t&&(r|=parseHex4Bits(e,a-1)<<4),r}function parseBase(e,t,a,r){for(var n=0,c=Math.min(e.length,a),o=t;o=49?d-49+10:d>=17?d-17+10:d}return n}BN.isBN=function isBN(e){return e instanceof BN||null!==e&&"object"==typeof e&&e.constructor.wordSize===BN.wordSize&&Array.isArray(e.words)},BN.max=function max(e,t){return e.cmp(t)>0?e:t},BN.min=function min(e,t){return e.cmp(t)<0?e:t},BN.prototype._init=function init(e,t,a){if("number"==typeof e)return this._initNumber(e,t,a);if("object"==typeof e)return this._initArray(e,t,a);"hex"===t&&(t=16),assert(t===(0|t)&&t>=2&&t<=36);var r=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(r++,this.negative=1),r=0;r-=3)c=e[r]|e[r-1]<<8|e[r-2]<<16,this.words[n]|=c<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===a)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},BN.prototype._parseHex=function _parseHex(e,t,a){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=2)n=parseHexByte(e,t,r)<=18?(c-=18,o+=1,this.words[o]|=n>>>26):c+=8;else for(r=(e.length-t)%2==0?t+1:t;r=18?(c-=18,o+=1,this.words[o]|=n>>>26):c+=8;this.strip()},BN.prototype._parseBase=function _parseBase(e,t,a){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=t)r++;r--,n=n/t|0;for(var c=e.length-a,o=c%r,d=Math.min(c,c-o)+a,s=0,b=a;b1&&0===this.words[this.length-1];)this.length--;return this._normSign()},BN.prototype._normSign=function _normSign(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},BN.prototype.inspect=function inspect(){return(this.red?""};var n=["","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"],c=[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],o=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function smallMulTo(e,t,a){a.negative=t.negative^e.negative;var r=e.length+t.length|0;a.length=r,r=r-1|0;var n=0|e.words[0],c=0|t.words[0],o=n*c,d=67108863&o,s=o/67108864|0;a.words[0]=d;for(var b=1;b>>26,h=67108863&s,l=Math.min(b,t.length-1),g=Math.max(0,b-e.length+1);g<=l;g++){var p=b-g|0;u+=(o=(n=0|e.words[p])*(c=0|t.words[g])+h)/67108864|0,h=67108863&o}a.words[b]=0|h,s=0|u}return 0!==s?a.words[b]=0|s:a.length--,a.strip()}BN.prototype.toString=function toString(e,t){var a;if(t=0|t||1,16===(e=e||10)||"hex"===e){a="";for(var r=0,d=0,s=0;s>>24-r&16777215)||s!==this.length-1?n[6-u.length]+u+a:u+a,(r+=2)>=26&&(r-=26,s--)}for(0!==d&&(a=d.toString(16)+a);a.length%t!=0;)a="0"+a;return 0!==this.negative&&(a="-"+a),a}if(e===(0|e)&&e>=2&&e<=36){var h=c[e],l=o[e];a="";var g=this.clone();for(g.negative=0;!g.isZero();){var p=g.modn(l).toString(e);a=(g=g.idivn(l)).isZero()?p+a:n[h-p.length]+p+a}for(this.isZero()&&(a="0"+a);a.length%t!=0;)a="0"+a;return 0!==this.negative&&(a="-"+a),a}assert(!1,"Base should be between 2 and 36")},BN.prototype.toNumber=function toNumber(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&assert(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},BN.prototype.toJSON=function toJSON(){return this.toString(16)},BN.prototype.toBuffer=function toBuffer(e,t){return assert(void 0!==r),this.toArrayLike(r,e,t)},BN.prototype.toArray=function toArray(e,t){return this.toArrayLike(Array,e,t)},BN.prototype.toArrayLike=function toArrayLike(e,t,a){var r=this.byteLength(),n=a||Math.max(1,r);assert(r<=n,"byte array longer than desired length"),assert(n>0,"Requested array length <= 0"),this.strip();var c,o,d="le"===t,s=new e(n),b=this.clone();if(d){for(o=0;!b.isZero();o++)c=b.andln(255),b.iushrn(8),s[o]=c;for(;o=4096&&(a+=13,t>>>=13),t>=64&&(a+=7,t>>>=7),t>=8&&(a+=4,t>>>=4),t>=2&&(a+=2,t>>>=2),a+t},BN.prototype._zeroBits=function _zeroBits(e){if(0===e)return 26;var t=e,a=0;return 0==(8191&t)&&(a+=13,t>>>=13),0==(127&t)&&(a+=7,t>>>=7),0==(15&t)&&(a+=4,t>>>=4),0==(3&t)&&(a+=2,t>>>=2),0==(1&t)&&a++,a},BN.prototype.bitLength=function bitLength(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},BN.prototype.zeroBits=function zeroBits(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},BN.prototype.uor=function uor(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},BN.prototype.iuand=function iuand(e){var t;t=this.length>e.length?e:this;for(var a=0;ae.length?this.clone().iand(e):e.clone().iand(this)},BN.prototype.uand=function uand(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},BN.prototype.iuxor=function iuxor(e){var t,a;this.length>e.length?(t=this,a=e):(t=e,a=this);for(var r=0;re.length?this.clone().ixor(e):e.clone().ixor(this)},BN.prototype.uxor=function uxor(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},BN.prototype.inotn=function inotn(e){assert("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),a=e%26;this._expand(t),a>0&&t--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-a),this.strip()},BN.prototype.notn=function notn(e){return this.clone().inotn(e)},BN.prototype.setn=function setn(e,t){assert("number"==typeof e&&e>=0);var a=e/26|0,r=e%26;return this._expand(a+1),this.words[a]=t?this.words[a]|1<e.length?(a=this,r=e):(a=e,r=this);for(var n=0,c=0;c>>26;for(;0!==n&&c>>26;if(this.length=a.length,0!==n)this.words[this.length]=n,this.length++;else if(a!==this)for(;ce.length?this.clone().iadd(e):e.clone().iadd(this)},BN.prototype.isub=function isub(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var a,r,n=this.cmp(e);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(a=this,r=e):(a=e,r=this);for(var c=0,o=0;o>26,this.words[o]=67108863&t;for(;0!==c&&o>26,this.words[o]=67108863&t;if(0===c&&o>>13,g=0|o[1],p=8191&g,B=g>>>13,x=0|o[2],I=8191&x,m=x>>>13,y=0|o[3],C=8191&y,w=y>>>13,v=0|o[4],Q=8191&v,k=v>>>13,_=0|o[5],N=8191&_,D=_>>>13,G=0|o[6],L=8191&G,T=G>>>13,U=0|o[7],P=8191&U,q=U>>>13,H=0|o[8],O=8191&H,z=H>>>13,J=0|o[9],j=8191&J,Y=J>>>13,W=0|d[0],V=8191&W,X=W>>>13,$=0|d[1],et=8191&$,tt=$>>>13,at=0|d[2],rt=8191&at,it=at>>>13,nt=0|d[3],ct=8191&nt,ot=nt>>>13,dt=0|d[4],At=8191&dt,st=dt>>>13,bt=0|d[5],ut=8191&bt,ht=bt>>>13,pt=0|d[6],Bt=8191&pt,xt=pt>>>13,It=0|d[7],mt=8191&It,Et=It>>>13,yt=0|d[8],Ct=8191&yt,wt=yt>>>13,vt=0|d[9],Qt=8191&vt,Mt=vt>>>13;a.negative=e.negative^t.negative,a.length=19;var kt=(b+(r=Math.imul(h,V))|0)+((8191&(n=(n=Math.imul(h,X))+Math.imul(l,V)|0))<<13)|0;b=((c=Math.imul(l,X))+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(p,V),n=(n=Math.imul(p,X))+Math.imul(B,V)|0,c=Math.imul(B,X);var _t=(b+(r=r+Math.imul(h,et)|0)|0)+((8191&(n=(n=n+Math.imul(h,tt)|0)+Math.imul(l,et)|0))<<13)|0;b=((c=c+Math.imul(l,tt)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(I,V),n=(n=Math.imul(I,X))+Math.imul(m,V)|0,c=Math.imul(m,X),r=r+Math.imul(p,et)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(B,et)|0,c=c+Math.imul(B,tt)|0;var St=(b+(r=r+Math.imul(h,rt)|0)|0)+((8191&(n=(n=n+Math.imul(h,it)|0)+Math.imul(l,rt)|0))<<13)|0;b=((c=c+Math.imul(l,it)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(C,V),n=(n=Math.imul(C,X))+Math.imul(w,V)|0,c=Math.imul(w,X),r=r+Math.imul(I,et)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(m,et)|0,c=c+Math.imul(m,tt)|0,r=r+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(B,rt)|0,c=c+Math.imul(B,it)|0;var Nt=(b+(r=r+Math.imul(h,ct)|0)|0)+((8191&(n=(n=n+Math.imul(h,ot)|0)+Math.imul(l,ct)|0))<<13)|0;b=((c=c+Math.imul(l,ot)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,r=Math.imul(Q,V),n=(n=Math.imul(Q,X))+Math.imul(k,V)|0,c=Math.imul(k,X),r=r+Math.imul(C,et)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(w,et)|0,c=c+Math.imul(w,tt)|0,r=r+Math.imul(I,rt)|0,n=(n=n+Math.imul(I,it)|0)+Math.imul(m,rt)|0,c=c+Math.imul(m,it)|0,r=r+Math.imul(p,ct)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(B,ct)|0,c=c+Math.imul(B,ot)|0;var Dt=(b+(r=r+Math.imul(h,At)|0)|0)+((8191&(n=(n=n+Math.imul(h,st)|0)+Math.imul(l,At)|0))<<13)|0;b=((c=c+Math.imul(l,st)|0)+(n>>>13)|0)+(Dt>>>26)|0,Dt&=67108863,r=Math.imul(N,V),n=(n=Math.imul(N,X))+Math.imul(D,V)|0,c=Math.imul(D,X),r=r+Math.imul(Q,et)|0,n=(n=n+Math.imul(Q,tt)|0)+Math.imul(k,et)|0,c=c+Math.imul(k,tt)|0,r=r+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(w,rt)|0,c=c+Math.imul(w,it)|0,r=r+Math.imul(I,ct)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(m,ct)|0,c=c+Math.imul(m,ot)|0,r=r+Math.imul(p,At)|0,n=(n=n+Math.imul(p,st)|0)+Math.imul(B,At)|0,c=c+Math.imul(B,st)|0;var Rt=(b+(r=r+Math.imul(h,ut)|0)|0)+((8191&(n=(n=n+Math.imul(h,ht)|0)+Math.imul(l,ut)|0))<<13)|0;b=((c=c+Math.imul(l,ht)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(L,V),n=(n=Math.imul(L,X))+Math.imul(T,V)|0,c=Math.imul(T,X),r=r+Math.imul(N,et)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(D,et)|0,c=c+Math.imul(D,tt)|0,r=r+Math.imul(Q,rt)|0,n=(n=n+Math.imul(Q,it)|0)+Math.imul(k,rt)|0,c=c+Math.imul(k,it)|0,r=r+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,ot)|0)+Math.imul(w,ct)|0,c=c+Math.imul(w,ot)|0,r=r+Math.imul(I,At)|0,n=(n=n+Math.imul(I,st)|0)+Math.imul(m,At)|0,c=c+Math.imul(m,st)|0,r=r+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,ht)|0)+Math.imul(B,ut)|0,c=c+Math.imul(B,ht)|0;var Ft=(b+(r=r+Math.imul(h,Bt)|0)|0)+((8191&(n=(n=n+Math.imul(h,xt)|0)+Math.imul(l,Bt)|0))<<13)|0;b=((c=c+Math.imul(l,xt)|0)+(n>>>13)|0)+(Ft>>>26)|0,Ft&=67108863,r=Math.imul(P,V),n=(n=Math.imul(P,X))+Math.imul(q,V)|0,c=Math.imul(q,X),r=r+Math.imul(L,et)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(T,et)|0,c=c+Math.imul(T,tt)|0,r=r+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(D,rt)|0,c=c+Math.imul(D,it)|0,r=r+Math.imul(Q,ct)|0,n=(n=n+Math.imul(Q,ot)|0)+Math.imul(k,ct)|0,c=c+Math.imul(k,ot)|0,r=r+Math.imul(C,At)|0,n=(n=n+Math.imul(C,st)|0)+Math.imul(w,At)|0,c=c+Math.imul(w,st)|0,r=r+Math.imul(I,ut)|0,n=(n=n+Math.imul(I,ht)|0)+Math.imul(m,ut)|0,c=c+Math.imul(m,ht)|0,r=r+Math.imul(p,Bt)|0,n=(n=n+Math.imul(p,xt)|0)+Math.imul(B,Bt)|0,c=c+Math.imul(B,xt)|0;var Gt=(b+(r=r+Math.imul(h,mt)|0)|0)+((8191&(n=(n=n+Math.imul(h,Et)|0)+Math.imul(l,mt)|0))<<13)|0;b=((c=c+Math.imul(l,Et)|0)+(n>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,r=Math.imul(O,V),n=(n=Math.imul(O,X))+Math.imul(z,V)|0,c=Math.imul(z,X),r=r+Math.imul(P,et)|0,n=(n=n+Math.imul(P,tt)|0)+Math.imul(q,et)|0,c=c+Math.imul(q,tt)|0,r=r+Math.imul(L,rt)|0,n=(n=n+Math.imul(L,it)|0)+Math.imul(T,rt)|0,c=c+Math.imul(T,it)|0,r=r+Math.imul(N,ct)|0,n=(n=n+Math.imul(N,ot)|0)+Math.imul(D,ct)|0,c=c+Math.imul(D,ot)|0,r=r+Math.imul(Q,At)|0,n=(n=n+Math.imul(Q,st)|0)+Math.imul(k,At)|0,c=c+Math.imul(k,st)|0,r=r+Math.imul(C,ut)|0,n=(n=n+Math.imul(C,ht)|0)+Math.imul(w,ut)|0,c=c+Math.imul(w,ht)|0,r=r+Math.imul(I,Bt)|0,n=(n=n+Math.imul(I,xt)|0)+Math.imul(m,Bt)|0,c=c+Math.imul(m,xt)|0,r=r+Math.imul(p,mt)|0,n=(n=n+Math.imul(p,Et)|0)+Math.imul(B,mt)|0,c=c+Math.imul(B,Et)|0;var Lt=(b+(r=r+Math.imul(h,Ct)|0)|0)+((8191&(n=(n=n+Math.imul(h,wt)|0)+Math.imul(l,Ct)|0))<<13)|0;b=((c=c+Math.imul(l,wt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,r=Math.imul(j,V),n=(n=Math.imul(j,X))+Math.imul(Y,V)|0,c=Math.imul(Y,X),r=r+Math.imul(O,et)|0,n=(n=n+Math.imul(O,tt)|0)+Math.imul(z,et)|0,c=c+Math.imul(z,tt)|0,r=r+Math.imul(P,rt)|0,n=(n=n+Math.imul(P,it)|0)+Math.imul(q,rt)|0,c=c+Math.imul(q,it)|0,r=r+Math.imul(L,ct)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(T,ct)|0,c=c+Math.imul(T,ot)|0,r=r+Math.imul(N,At)|0,n=(n=n+Math.imul(N,st)|0)+Math.imul(D,At)|0,c=c+Math.imul(D,st)|0,r=r+Math.imul(Q,ut)|0,n=(n=n+Math.imul(Q,ht)|0)+Math.imul(k,ut)|0,c=c+Math.imul(k,ht)|0,r=r+Math.imul(C,Bt)|0,n=(n=n+Math.imul(C,xt)|0)+Math.imul(w,Bt)|0,c=c+Math.imul(w,xt)|0,r=r+Math.imul(I,mt)|0,n=(n=n+Math.imul(I,Et)|0)+Math.imul(m,mt)|0,c=c+Math.imul(m,Et)|0,r=r+Math.imul(p,Ct)|0,n=(n=n+Math.imul(p,wt)|0)+Math.imul(B,Ct)|0,c=c+Math.imul(B,wt)|0;var Tt=(b+(r=r+Math.imul(h,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(h,Mt)|0)+Math.imul(l,Qt)|0))<<13)|0;b=((c=c+Math.imul(l,Mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(j,et),n=(n=Math.imul(j,tt))+Math.imul(Y,et)|0,c=Math.imul(Y,tt),r=r+Math.imul(O,rt)|0,n=(n=n+Math.imul(O,it)|0)+Math.imul(z,rt)|0,c=c+Math.imul(z,it)|0,r=r+Math.imul(P,ct)|0,n=(n=n+Math.imul(P,ot)|0)+Math.imul(q,ct)|0,c=c+Math.imul(q,ot)|0,r=r+Math.imul(L,At)|0,n=(n=n+Math.imul(L,st)|0)+Math.imul(T,At)|0,c=c+Math.imul(T,st)|0,r=r+Math.imul(N,ut)|0,n=(n=n+Math.imul(N,ht)|0)+Math.imul(D,ut)|0,c=c+Math.imul(D,ht)|0,r=r+Math.imul(Q,Bt)|0,n=(n=n+Math.imul(Q,xt)|0)+Math.imul(k,Bt)|0,c=c+Math.imul(k,xt)|0,r=r+Math.imul(C,mt)|0,n=(n=n+Math.imul(C,Et)|0)+Math.imul(w,mt)|0,c=c+Math.imul(w,Et)|0,r=r+Math.imul(I,Ct)|0,n=(n=n+Math.imul(I,wt)|0)+Math.imul(m,Ct)|0,c=c+Math.imul(m,wt)|0;var Ut=(b+(r=r+Math.imul(p,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(p,Mt)|0)+Math.imul(B,Qt)|0))<<13)|0;b=((c=c+Math.imul(B,Mt)|0)+(n>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,r=Math.imul(j,rt),n=(n=Math.imul(j,it))+Math.imul(Y,rt)|0,c=Math.imul(Y,it),r=r+Math.imul(O,ct)|0,n=(n=n+Math.imul(O,ot)|0)+Math.imul(z,ct)|0,c=c+Math.imul(z,ot)|0,r=r+Math.imul(P,At)|0,n=(n=n+Math.imul(P,st)|0)+Math.imul(q,At)|0,c=c+Math.imul(q,st)|0,r=r+Math.imul(L,ut)|0,n=(n=n+Math.imul(L,ht)|0)+Math.imul(T,ut)|0,c=c+Math.imul(T,ht)|0,r=r+Math.imul(N,Bt)|0,n=(n=n+Math.imul(N,xt)|0)+Math.imul(D,Bt)|0,c=c+Math.imul(D,xt)|0,r=r+Math.imul(Q,mt)|0,n=(n=n+Math.imul(Q,Et)|0)+Math.imul(k,mt)|0,c=c+Math.imul(k,Et)|0,r=r+Math.imul(C,Ct)|0,n=(n=n+Math.imul(C,wt)|0)+Math.imul(w,Ct)|0,c=c+Math.imul(w,wt)|0;var Pt=(b+(r=r+Math.imul(I,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(I,Mt)|0)+Math.imul(m,Qt)|0))<<13)|0;b=((c=c+Math.imul(m,Mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(j,ct),n=(n=Math.imul(j,ot))+Math.imul(Y,ct)|0,c=Math.imul(Y,ot),r=r+Math.imul(O,At)|0,n=(n=n+Math.imul(O,st)|0)+Math.imul(z,At)|0,c=c+Math.imul(z,st)|0,r=r+Math.imul(P,ut)|0,n=(n=n+Math.imul(P,ht)|0)+Math.imul(q,ut)|0,c=c+Math.imul(q,ht)|0,r=r+Math.imul(L,Bt)|0,n=(n=n+Math.imul(L,xt)|0)+Math.imul(T,Bt)|0,c=c+Math.imul(T,xt)|0,r=r+Math.imul(N,mt)|0,n=(n=n+Math.imul(N,Et)|0)+Math.imul(D,mt)|0,c=c+Math.imul(D,Et)|0,r=r+Math.imul(Q,Ct)|0,n=(n=n+Math.imul(Q,wt)|0)+Math.imul(k,Ct)|0,c=c+Math.imul(k,wt)|0;var qt=(b+(r=r+Math.imul(C,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(C,Mt)|0)+Math.imul(w,Qt)|0))<<13)|0;b=((c=c+Math.imul(w,Mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863,r=Math.imul(j,At),n=(n=Math.imul(j,st))+Math.imul(Y,At)|0,c=Math.imul(Y,st),r=r+Math.imul(O,ut)|0,n=(n=n+Math.imul(O,ht)|0)+Math.imul(z,ut)|0,c=c+Math.imul(z,ht)|0,r=r+Math.imul(P,Bt)|0,n=(n=n+Math.imul(P,xt)|0)+Math.imul(q,Bt)|0,c=c+Math.imul(q,xt)|0,r=r+Math.imul(L,mt)|0,n=(n=n+Math.imul(L,Et)|0)+Math.imul(T,mt)|0,c=c+Math.imul(T,Et)|0,r=r+Math.imul(N,Ct)|0,n=(n=n+Math.imul(N,wt)|0)+Math.imul(D,Ct)|0,c=c+Math.imul(D,wt)|0;var Ht=(b+(r=r+Math.imul(Q,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(Q,Mt)|0)+Math.imul(k,Qt)|0))<<13)|0;b=((c=c+Math.imul(k,Mt)|0)+(n>>>13)|0)+(Ht>>>26)|0,Ht&=67108863,r=Math.imul(j,ut),n=(n=Math.imul(j,ht))+Math.imul(Y,ut)|0,c=Math.imul(Y,ht),r=r+Math.imul(O,Bt)|0,n=(n=n+Math.imul(O,xt)|0)+Math.imul(z,Bt)|0,c=c+Math.imul(z,xt)|0,r=r+Math.imul(P,mt)|0,n=(n=n+Math.imul(P,Et)|0)+Math.imul(q,mt)|0,c=c+Math.imul(q,Et)|0,r=r+Math.imul(L,Ct)|0,n=(n=n+Math.imul(L,wt)|0)+Math.imul(T,Ct)|0,c=c+Math.imul(T,wt)|0;var Ot=(b+(r=r+Math.imul(N,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(N,Mt)|0)+Math.imul(D,Qt)|0))<<13)|0;b=((c=c+Math.imul(D,Mt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,r=Math.imul(j,Bt),n=(n=Math.imul(j,xt))+Math.imul(Y,Bt)|0,c=Math.imul(Y,xt),r=r+Math.imul(O,mt)|0,n=(n=n+Math.imul(O,Et)|0)+Math.imul(z,mt)|0,c=c+Math.imul(z,Et)|0,r=r+Math.imul(P,Ct)|0,n=(n=n+Math.imul(P,wt)|0)+Math.imul(q,Ct)|0,c=c+Math.imul(q,wt)|0;var zt=(b+(r=r+Math.imul(L,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(L,Mt)|0)+Math.imul(T,Qt)|0))<<13)|0;b=((c=c+Math.imul(T,Mt)|0)+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863,r=Math.imul(j,mt),n=(n=Math.imul(j,Et))+Math.imul(Y,mt)|0,c=Math.imul(Y,Et),r=r+Math.imul(O,Ct)|0,n=(n=n+Math.imul(O,wt)|0)+Math.imul(z,Ct)|0,c=c+Math.imul(z,wt)|0;var Kt=(b+(r=r+Math.imul(P,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(P,Mt)|0)+Math.imul(q,Qt)|0))<<13)|0;b=((c=c+Math.imul(q,Mt)|0)+(n>>>13)|0)+(Kt>>>26)|0,Kt&=67108863,r=Math.imul(j,Ct),n=(n=Math.imul(j,wt))+Math.imul(Y,Ct)|0,c=Math.imul(Y,wt);var Jt=(b+(r=r+Math.imul(O,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(O,Mt)|0)+Math.imul(z,Qt)|0))<<13)|0;b=((c=c+Math.imul(z,Mt)|0)+(n>>>13)|0)+(Jt>>>26)|0,Jt&=67108863;var jt=(b+(r=Math.imul(j,Qt))|0)+((8191&(n=(n=Math.imul(j,Mt))+Math.imul(Y,Qt)|0))<<13)|0;return b=((c=Math.imul(Y,Mt))+(n>>>13)|0)+(jt>>>26)|0,jt&=67108863,s[0]=kt,s[1]=_t,s[2]=St,s[3]=Nt,s[4]=Dt,s[5]=Rt,s[6]=Ft,s[7]=Gt,s[8]=Lt,s[9]=Tt,s[10]=Ut,s[11]=Pt,s[12]=qt,s[13]=Ht,s[14]=Ot,s[15]=zt,s[16]=Kt,s[17]=Jt,s[18]=jt,0!==b&&(s[19]=b,a.length++),a};function jumboMulTo(e,t,a){return(new FFTM).mulp(e,t,a)}function FFTM(e,t){this.x=e,this.y=t}Math.imul||(d=smallMulTo),BN.prototype.mulTo=function mulTo(e,t){var a,r=this.length+e.length;return a=10===this.length&&10===e.length?d(this,e,t):r<63?smallMulTo(this,e,t):r<1024?function bigMulTo(e,t,a){a.negative=t.negative^e.negative,a.length=e.length+t.length;for(var r=0,n=0,c=0;c>>26)|0)>>>26,o&=67108863}a.words[c]=d,r=o,o=n}return 0!==r?a.words[c]=r:a.length--,a.strip()}(this,e,t):jumboMulTo(this,e,t),a},FFTM.prototype.makeRBT=function makeRBT(e){for(var t=new Array(e),a=BN.prototype._countBits(e)-1,r=0;r>=1;return r},FFTM.prototype.permute=function permute(e,t,a,r,n,c){for(var o=0;o>>=1)n++;return 1<>>=13,a[2*c+1]=8191&n,n>>>=13;for(c=2*t;c>=26,t+=r/67108864|0,t+=n>>>26,this.words[a]=67108863&n}return 0!==t&&(this.words[a]=t,this.length++),this},BN.prototype.muln=function muln(e){return this.clone().imuln(e)},BN.prototype.sqr=function sqr(){return this.mul(this)},BN.prototype.isqr=function isqr(){return this.imul(this.clone())},BN.prototype.pow=function pow(e){var t=function toBitArray(e){for(var t=new Array(e.bitLength()),a=0;a>>n}return t}(e);if(0===t.length)return new BN(1);for(var a=this,r=0;r=0);var t,a=e%26,r=(e-a)/26,n=67108863>>>26-a<<26-a;if(0!==a){var c=0;for(t=0;t>>26-a}c&&(this.words[t]=c,this.length++)}if(0!==r){for(t=this.length-1;t>=0;t--)this.words[t+r]=this.words[t];for(t=0;t=0),r=t?(t-t%26)/26:0;var n=e%26,c=Math.min((e-n)/26,this.length),o=67108863^67108863>>>n<c)for(this.length-=c,s=0;s=0&&(0!==b||s>=r);s--){var u=0|this.words[s];this.words[s]=b<<26-n|u>>>n,b=u&o}return d&&0!==b&&(d.words[d.length++]=b),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},BN.prototype.ishrn=function ishrn(e,t,a){return assert(0===this.negative),this.iushrn(e,t,a)},BN.prototype.shln=function shln(e){return this.clone().ishln(e)},BN.prototype.ushln=function ushln(e){return this.clone().iushln(e)},BN.prototype.shrn=function shrn(e){return this.clone().ishrn(e)},BN.prototype.ushrn=function ushrn(e){return this.clone().iushrn(e)},BN.prototype.testn=function testn(e){assert("number"==typeof e&&e>=0);var t=e%26,a=(e-t)/26,r=1<=0);var t=e%26,a=(e-t)/26;if(assert(0===this.negative,"imaskn works only with positive numbers"),this.length<=a)return this;if(0!==t&&a++,this.length=Math.min(a,this.length),0!==t){var r=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},BN.prototype.isubn=function isubn(e){if(assert("number"==typeof e),assert(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(d/67108864|0),this.words[r+a]=67108863&n}for(;r>26,this.words[r+a]=67108863&n;if(0===o)return this.strip();for(assert(-1===o),o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},BN.prototype._wordDiv=function _wordDiv(e,t){var a=(this.length,e.length),r=this.clone(),n=e,c=0|n.words[n.length-1];0!==(a=26-this._countBits(c))&&(n=n.ushln(a),r.iushln(a),c=0|n.words[n.length-1]);var o,d=r.length-n.length;if("mod"!==t){(o=new BN(null)).length=d+1,o.words=new Array(o.length);for(var s=0;s=0;u--){var h=67108864*(0|r.words[n.length+u])+(0|r.words[n.length+u-1]);for(h=Math.min(h/c|0,67108863),r._ishlnsubmul(n,h,u);0!==r.negative;)h--,r.negative=0,r._ishlnsubmul(n,1,u),r.isZero()||(r.negative^=1);o&&(o.words[u]=h)}return o&&o.strip(),r.strip(),"div"!==t&&0!==a&&r.iushrn(a),{div:o||null,mod:r}},BN.prototype.divmod=function divmod(e,t,a){return assert(!e.isZero()),this.isZero()?{div:new BN(0),mod:new BN(0)}:0!==this.negative&&0===e.negative?(c=this.neg().divmod(e,t),"mod"!==t&&(r=c.div.neg()),"div"!==t&&(n=c.mod.neg(),a&&0!==n.negative&&n.iadd(e)),{div:r,mod:n}):0===this.negative&&0!==e.negative?(c=this.divmod(e.neg(),t),"mod"!==t&&(r=c.div.neg()),{div:r,mod:c.mod}):0!=(this.negative&e.negative)?(c=this.neg().divmod(e.neg(),t),"div"!==t&&(n=c.mod.neg(),a&&0!==n.negative&&n.isub(e)),{div:c.div,mod:n}):e.length>this.length||this.cmp(e)<0?{div:new BN(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new BN(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new BN(this.modn(e.words[0]))}:this._wordDiv(e,t);var r,n,c},BN.prototype.div=function div(e){return this.divmod(e,"div",!1).div},BN.prototype.mod=function mod(e){return this.divmod(e,"mod",!1).mod},BN.prototype.umod=function umod(e){return this.divmod(e,"mod",!0).mod},BN.prototype.divRound=function divRound(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var a=0!==t.div.negative?t.mod.isub(e):t.mod,r=e.ushrn(1),n=e.andln(1),c=a.cmp(r);return c<0||1===n&&0===c?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},BN.prototype.modn=function modn(e){assert(e<=67108863);for(var t=(1<<26)%e,a=0,r=this.length-1;r>=0;r--)a=(t*a+(0|this.words[r]))%e;return a},BN.prototype.idivn=function idivn(e){assert(e<=67108863);for(var t=0,a=this.length-1;a>=0;a--){var r=(0|this.words[a])+67108864*t;this.words[a]=r/e|0,t=r%e}return this.strip()},BN.prototype.divn=function divn(e){return this.clone().idivn(e)},BN.prototype.egcd=function egcd(e){assert(0===e.negative),assert(!e.isZero());var t=this,a=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var r=new BN(1),n=new BN(0),c=new BN(0),o=new BN(1),d=0;t.isEven()&&a.isEven();)t.iushrn(1),a.iushrn(1),++d;for(var s=a.clone(),b=t.clone();!t.isZero();){for(var u=0,h=1;0==(t.words[0]&h)&&u<26;++u,h<<=1);if(u>0)for(t.iushrn(u);u-- >0;)(r.isOdd()||n.isOdd())&&(r.iadd(s),n.isub(b)),r.iushrn(1),n.iushrn(1);for(var l=0,g=1;0==(a.words[0]&g)&&l<26;++l,g<<=1);if(l>0)for(a.iushrn(l);l-- >0;)(c.isOdd()||o.isOdd())&&(c.iadd(s),o.isub(b)),c.iushrn(1),o.iushrn(1);t.cmp(a)>=0?(t.isub(a),r.isub(c),n.isub(o)):(a.isub(t),c.isub(r),o.isub(n))}return{a:c,b:o,gcd:a.iushln(d)}},BN.prototype._invmp=function _invmp(e){assert(0===e.negative),assert(!e.isZero());var t=this,a=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var r,n=new BN(1),c=new BN(0),o=a.clone();t.cmpn(1)>0&&a.cmpn(1)>0;){for(var d=0,s=1;0==(t.words[0]&s)&&d<26;++d,s<<=1);if(d>0)for(t.iushrn(d);d-- >0;)n.isOdd()&&n.iadd(o),n.iushrn(1);for(var b=0,u=1;0==(a.words[0]&u)&&b<26;++b,u<<=1);if(b>0)for(a.iushrn(b);b-- >0;)c.isOdd()&&c.iadd(o),c.iushrn(1);t.cmp(a)>=0?(t.isub(a),n.isub(c)):(a.isub(t),c.isub(n))}return(r=0===t.cmpn(1)?n:c).cmpn(0)<0&&r.iadd(e),r},BN.prototype.gcd=function gcd(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),a=e.clone();t.negative=0,a.negative=0;for(var r=0;t.isEven()&&a.isEven();r++)t.iushrn(1),a.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;a.isEven();)a.iushrn(1);var n=t.cmp(a);if(n<0){var c=t;t=a,a=c}else if(0===n||0===a.cmpn(1))break;t.isub(a)}return a.iushln(r)},BN.prototype.invm=function invm(e){return this.egcd(e).a.umod(e)},BN.prototype.isEven=function isEven(){return 0==(1&this.words[0])},BN.prototype.isOdd=function isOdd(){return 1==(1&this.words[0])},BN.prototype.andln=function andln(e){return this.words[0]&e},BN.prototype.bincn=function bincn(e){assert("number"==typeof e);var t=e%26,a=(e-t)/26,r=1<>>26,o&=67108863,this.words[c]=o}return 0!==n&&(this.words[c]=n,this.length++),this},BN.prototype.isZero=function isZero(){return 1===this.length&&0===this.words[0]},BN.prototype.cmpn=function cmpn(e){var t,a=e<0;if(0!==this.negative&&!a)return-1;if(0===this.negative&&a)return 1;if(this.strip(),this.length>1)t=1;else{a&&(e=-e),assert(e<=67108863,"Number is too big");var r=0|this.words[0];t=r===e?0:re.length)return 1;if(this.length=0;a--){var r=0|this.words[a],n=0|e.words[a];if(r!==n){rn&&(t=1);break}}return t},BN.prototype.gtn=function gtn(e){return 1===this.cmpn(e)},BN.prototype.gt=function gt(e){return 1===this.cmp(e)},BN.prototype.gten=function gten(e){return this.cmpn(e)>=0},BN.prototype.gte=function gte(e){return this.cmp(e)>=0},BN.prototype.ltn=function ltn(e){return-1===this.cmpn(e)},BN.prototype.lt=function lt(e){return-1===this.cmp(e)},BN.prototype.lten=function lten(e){return this.cmpn(e)<=0},BN.prototype.lte=function lte(e){return this.cmp(e)<=0},BN.prototype.eqn=function eqn(e){return 0===this.cmpn(e)},BN.prototype.eq=function eq(e){return 0===this.cmp(e)},BN.red=function red(e){return new Red(e)},BN.prototype.toRed=function toRed(e){return assert(!this.red,"Already a number in reduction context"),assert(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},BN.prototype.fromRed=function fromRed(){return assert(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},BN.prototype._forceRed=function _forceRed(e){return this.red=e,this},BN.prototype.forceRed=function forceRed(e){return assert(!this.red,"Already a number in reduction context"),this._forceRed(e)},BN.prototype.redAdd=function redAdd(e){return assert(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},BN.prototype.redIAdd=function redIAdd(e){return assert(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},BN.prototype.redSub=function redSub(e){return assert(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},BN.prototype.redISub=function redISub(e){return assert(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},BN.prototype.redShl=function redShl(e){return assert(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},BN.prototype.redMul=function redMul(e){return assert(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},BN.prototype.redIMul=function redIMul(e){return assert(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},BN.prototype.redSqr=function redSqr(){return assert(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},BN.prototype.redISqr=function redISqr(){return assert(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},BN.prototype.redSqrt=function redSqrt(){return assert(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},BN.prototype.redInvm=function redInvm(){return assert(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},BN.prototype.redNeg=function redNeg(){return assert(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},BN.prototype.redPow=function redPow(e){return assert(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var s={k256:null,p224:null,p192:null,p25519:null};function MPrime(e,t){this.name=e,this.p=new BN(t,16),this.n=this.p.bitLength(),this.k=new BN(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function K256(){MPrime.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function P224(){MPrime.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function P192(){MPrime.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function P25519(){MPrime.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function Red(e){if("string"==typeof e){var t=BN._prime(e);this.m=t.p,this.prime=t}else assert(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function Mont(e){Red.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new BN(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)}MPrime.prototype._tmp=function _tmp(){var e=new BN(null);return e.words=new Array(Math.ceil(this.n/13)),e},MPrime.prototype.ireduce=function ireduce(e){var t,a=e;do{this.split(a,this.tmp),t=(a=(a=this.imulK(a)).iadd(this.tmp)).bitLength()}while(t>this.n);var r=t0?a.isub(this.p):void 0!==a.strip?a.strip():a._strip(),a},MPrime.prototype.split=function split(e,t){e.iushrn(this.n,0,t)},MPrime.prototype.imulK=function imulK(e){return e.imul(this.k)},inherits(K256,MPrime),K256.prototype.split=function split(e,t){for(var a=4194303,r=Math.min(e.length,9),n=0;n>>22,c=o}c>>>=22,e.words[n-10]=c,0===c&&e.length>10?e.length-=10:e.length-=9},K256.prototype.imulK=function imulK(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,a=0;a>>=26,e.words[a]=n,t=r}return 0!==t&&(e.words[e.length++]=t),e},BN._prime=function prime(e){if(s[e])return s[e];var prime;if("k256"===e)prime=new K256;else if("p224"===e)prime=new P224;else if("p192"===e)prime=new P192;else{if("p25519"!==e)throw new Error("Unknown prime "+e);prime=new P25519}return s[e]=prime,prime},Red.prototype._verify1=function _verify1(e){assert(0===e.negative,"red works only with positives"),assert(e.red,"red works only with red numbers")},Red.prototype._verify2=function _verify2(e,t){assert(0==(e.negative|t.negative),"red works only with positives"),assert(e.red&&e.red===t.red,"red works only with red numbers")},Red.prototype.imod=function imod(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},Red.prototype.neg=function neg(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},Red.prototype.add=function add(e,t){this._verify2(e,t);var a=e.add(t);return a.cmp(this.m)>=0&&a.isub(this.m),a._forceRed(this)},Red.prototype.iadd=function iadd(e,t){this._verify2(e,t);var a=e.iadd(t);return a.cmp(this.m)>=0&&a.isub(this.m),a},Red.prototype.sub=function sub(e,t){this._verify2(e,t);var a=e.sub(t);return a.cmpn(0)<0&&a.iadd(this.m),a._forceRed(this)},Red.prototype.isub=function isub(e,t){this._verify2(e,t);var a=e.isub(t);return a.cmpn(0)<0&&a.iadd(this.m),a},Red.prototype.shl=function shl(e,t){return this._verify1(e),this.imod(e.ushln(t))},Red.prototype.imul=function imul(e,t){return this._verify2(e,t),this.imod(e.imul(t))},Red.prototype.mul=function mul(e,t){return this._verify2(e,t),this.imod(e.mul(t))},Red.prototype.isqr=function isqr(e){return this.imul(e,e.clone())},Red.prototype.sqr=function sqr(e){return this.mul(e,e)},Red.prototype.sqrt=function sqrt(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(assert(t%2==1),3===t){var a=this.m.add(new BN(1)).iushrn(2);return this.pow(e,a)}for(var r=this.m.subn(1),n=0;!r.isZero()&&0===r.andln(1);)n++,r.iushrn(1);assert(!r.isZero());var c=new BN(1).toRed(this),o=c.redNeg(),d=this.m.subn(1).iushrn(1),s=this.m.bitLength();for(s=new BN(2*s*s).toRed(this);0!==this.pow(s,d).cmp(o);)s.redIAdd(o);for(var b=this.pow(s,r),u=this.pow(e,r.addn(1).iushrn(1)),h=this.pow(e,r),l=n;0!==h.cmp(c);){for(var g=h,p=0;0!==g.cmp(c);p++)g=g.redSqr();assert(p=0;r--){for(var s=t.words[r],b=d-1;b>=0;b--){var u=s>>b&1;n!==a[0]&&(n=this.sqr(n)),0!==u||0!==c?(c<<=1,c|=u,(4===++o||0===r&&0===b)&&(n=this.mul(n,a[c]),o=0,c=0)):o=0}d=26}return n},Red.prototype.convertTo=function convertTo(e){var t=e.umod(this.m);return t===e?t.clone():t},Red.prototype.convertFrom=function convertFrom(e){var t=e.clone();return t.red=null,t},BN.mont=function mont(e){return new Mont(e)},inherits(Mont,Red),Mont.prototype.convertTo=function convertTo(e){return this.imod(e.ushln(this.shift))},Mont.prototype.convertFrom=function convertFrom(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},Mont.prototype.imul=function imul(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var a=e.imul(t),r=a.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=a.isub(r).iushrn(this.shift),c=n;return n.cmp(this.m)>=0?c=n.isub(this.m):n.cmpn(0)<0&&(c=n.iadd(this.m)),c._forceRed(this)},Mont.prototype.mul=function mul(e,t){if(e.isZero()||t.isZero())return new BN(0)._forceRed(this);var a=e.mul(t),r=a.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=a.isub(r).iushrn(this.shift),c=n;return n.cmp(this.m)>=0?c=n.isub(this.m):n.cmpn(0)<0&&(c=n.iadd(this.m)),c._forceRed(this)},Mont.prototype.invm=function invm(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e=a.nmd(e),this)},function(e,t,a){!function(e,t){"use strict";function assert(e,t){if(!e)throw new Error(t||"Assertion failed")}function inherits(e,t){e.super_=t;var TempCtor=function(){};TempCtor.prototype=t.prototype,e.prototype=new TempCtor,e.prototype.constructor=e}function BN(e,t,a){if(BN.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(a=t,t=10),this._init(e||0,t||10,a||"be"))}var r;"object"==typeof e?e.exports=BN:t.BN=BN,BN.BN=BN,BN.wordSize=26;try{r="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:a(1390).Buffer}catch(e){}function parseHex4Bits(e,t){var a=e.charCodeAt(t);return a>=65&&a<=70?a-55:a>=97&&a<=102?a-87:a-48&15}function parseHexByte(e,t,a){var r=parseHex4Bits(e,a);return a-1>=t&&(r|=parseHex4Bits(e,a-1)<<4),r}function parseBase(e,t,a,r){for(var n=0,c=Math.min(e.length,a),o=t;o=49?d-49+10:d>=17?d-17+10:d}return n}BN.isBN=function isBN(e){return e instanceof BN||null!==e&&"object"==typeof e&&e.constructor.wordSize===BN.wordSize&&Array.isArray(e.words)},BN.max=function max(e,t){return e.cmp(t)>0?e:t},BN.min=function min(e,t){return e.cmp(t)<0?e:t},BN.prototype._init=function init(e,t,a){if("number"==typeof e)return this._initNumber(e,t,a);if("object"==typeof e)return this._initArray(e,t,a);"hex"===t&&(t=16),assert(t===(0|t)&&t>=2&&t<=36);var r=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(r++,this.negative=1),r=0;r-=3)c=e[r]|e[r-1]<<8|e[r-2]<<16,this.words[n]|=c<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===a)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},BN.prototype._parseHex=function _parseHex(e,t,a){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=2)n=parseHexByte(e,t,r)<=18?(c-=18,o+=1,this.words[o]|=n>>>26):c+=8;else for(r=(e.length-t)%2==0?t+1:t;r=18?(c-=18,o+=1,this.words[o]|=n>>>26):c+=8;this.strip()},BN.prototype._parseBase=function _parseBase(e,t,a){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=t)r++;r--,n=n/t|0;for(var c=e.length-a,o=c%r,d=Math.min(c,c-o)+a,s=0,b=a;b1&&0===this.words[this.length-1];)this.length--;return this._normSign()},BN.prototype._normSign=function _normSign(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},BN.prototype.inspect=function inspect(){return(this.red?""};var n=["","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"],c=[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],o=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function smallMulTo(e,t,a){a.negative=t.negative^e.negative;var r=e.length+t.length|0;a.length=r,r=r-1|0;var n=0|e.words[0],c=0|t.words[0],o=n*c,d=67108863&o,s=o/67108864|0;a.words[0]=d;for(var b=1;b>>26,h=67108863&s,l=Math.min(b,t.length-1),g=Math.max(0,b-e.length+1);g<=l;g++){var p=b-g|0;u+=(o=(n=0|e.words[p])*(c=0|t.words[g])+h)/67108864|0,h=67108863&o}a.words[b]=0|h,s=0|u}return 0!==s?a.words[b]=0|s:a.length--,a.strip()}BN.prototype.toString=function toString(e,t){var a;if(t=0|t||1,16===(e=e||10)||"hex"===e){a="";for(var r=0,d=0,s=0;s>>24-r&16777215)||s!==this.length-1?n[6-u.length]+u+a:u+a,(r+=2)>=26&&(r-=26,s--)}for(0!==d&&(a=d.toString(16)+a);a.length%t!=0;)a="0"+a;return 0!==this.negative&&(a="-"+a),a}if(e===(0|e)&&e>=2&&e<=36){var h=c[e],l=o[e];a="";var g=this.clone();for(g.negative=0;!g.isZero();){var p=g.modn(l).toString(e);a=(g=g.idivn(l)).isZero()?p+a:n[h-p.length]+p+a}for(this.isZero()&&(a="0"+a);a.length%t!=0;)a="0"+a;return 0!==this.negative&&(a="-"+a),a}assert(!1,"Base should be between 2 and 36")},BN.prototype.toNumber=function toNumber(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&assert(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},BN.prototype.toJSON=function toJSON(){return this.toString(16)},BN.prototype.toBuffer=function toBuffer(e,t){return assert(void 0!==r),this.toArrayLike(r,e,t)},BN.prototype.toArray=function toArray(e,t){return this.toArrayLike(Array,e,t)},BN.prototype.toArrayLike=function toArrayLike(e,t,a){var r=this.byteLength(),n=a||Math.max(1,r);assert(r<=n,"byte array longer than desired length"),assert(n>0,"Requested array length <= 0"),this.strip();var c,o,d="le"===t,s=new e(n),b=this.clone();if(d){for(o=0;!b.isZero();o++)c=b.andln(255),b.iushrn(8),s[o]=c;for(;o=4096&&(a+=13,t>>>=13),t>=64&&(a+=7,t>>>=7),t>=8&&(a+=4,t>>>=4),t>=2&&(a+=2,t>>>=2),a+t},BN.prototype._zeroBits=function _zeroBits(e){if(0===e)return 26;var t=e,a=0;return 0==(8191&t)&&(a+=13,t>>>=13),0==(127&t)&&(a+=7,t>>>=7),0==(15&t)&&(a+=4,t>>>=4),0==(3&t)&&(a+=2,t>>>=2),0==(1&t)&&a++,a},BN.prototype.bitLength=function bitLength(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},BN.prototype.zeroBits=function zeroBits(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},BN.prototype.uor=function uor(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},BN.prototype.iuand=function iuand(e){var t;t=this.length>e.length?e:this;for(var a=0;ae.length?this.clone().iand(e):e.clone().iand(this)},BN.prototype.uand=function uand(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},BN.prototype.iuxor=function iuxor(e){var t,a;this.length>e.length?(t=this,a=e):(t=e,a=this);for(var r=0;re.length?this.clone().ixor(e):e.clone().ixor(this)},BN.prototype.uxor=function uxor(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},BN.prototype.inotn=function inotn(e){assert("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),a=e%26;this._expand(t),a>0&&t--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-a),this.strip()},BN.prototype.notn=function notn(e){return this.clone().inotn(e)},BN.prototype.setn=function setn(e,t){assert("number"==typeof e&&e>=0);var a=e/26|0,r=e%26;return this._expand(a+1),this.words[a]=t?this.words[a]|1<e.length?(a=this,r=e):(a=e,r=this);for(var n=0,c=0;c>>26;for(;0!==n&&c>>26;if(this.length=a.length,0!==n)this.words[this.length]=n,this.length++;else if(a!==this)for(;ce.length?this.clone().iadd(e):e.clone().iadd(this)},BN.prototype.isub=function isub(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var a,r,n=this.cmp(e);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(a=this,r=e):(a=e,r=this);for(var c=0,o=0;o>26,this.words[o]=67108863&t;for(;0!==c&&o>26,this.words[o]=67108863&t;if(0===c&&o>>13,g=0|o[1],p=8191&g,B=g>>>13,x=0|o[2],I=8191&x,m=x>>>13,y=0|o[3],C=8191&y,w=y>>>13,v=0|o[4],Q=8191&v,k=v>>>13,_=0|o[5],N=8191&_,D=_>>>13,G=0|o[6],L=8191&G,T=G>>>13,U=0|o[7],P=8191&U,q=U>>>13,H=0|o[8],O=8191&H,z=H>>>13,J=0|o[9],j=8191&J,Y=J>>>13,W=0|d[0],V=8191&W,X=W>>>13,$=0|d[1],et=8191&$,tt=$>>>13,at=0|d[2],rt=8191&at,it=at>>>13,nt=0|d[3],ct=8191&nt,ot=nt>>>13,dt=0|d[4],At=8191&dt,st=dt>>>13,bt=0|d[5],ut=8191&bt,ht=bt>>>13,pt=0|d[6],Bt=8191&pt,xt=pt>>>13,It=0|d[7],mt=8191&It,Et=It>>>13,yt=0|d[8],Ct=8191&yt,wt=yt>>>13,vt=0|d[9],Qt=8191&vt,Mt=vt>>>13;a.negative=e.negative^t.negative,a.length=19;var kt=(b+(r=Math.imul(h,V))|0)+((8191&(n=(n=Math.imul(h,X))+Math.imul(l,V)|0))<<13)|0;b=((c=Math.imul(l,X))+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(p,V),n=(n=Math.imul(p,X))+Math.imul(B,V)|0,c=Math.imul(B,X);var _t=(b+(r=r+Math.imul(h,et)|0)|0)+((8191&(n=(n=n+Math.imul(h,tt)|0)+Math.imul(l,et)|0))<<13)|0;b=((c=c+Math.imul(l,tt)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(I,V),n=(n=Math.imul(I,X))+Math.imul(m,V)|0,c=Math.imul(m,X),r=r+Math.imul(p,et)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(B,et)|0,c=c+Math.imul(B,tt)|0;var St=(b+(r=r+Math.imul(h,rt)|0)|0)+((8191&(n=(n=n+Math.imul(h,it)|0)+Math.imul(l,rt)|0))<<13)|0;b=((c=c+Math.imul(l,it)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(C,V),n=(n=Math.imul(C,X))+Math.imul(w,V)|0,c=Math.imul(w,X),r=r+Math.imul(I,et)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(m,et)|0,c=c+Math.imul(m,tt)|0,r=r+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(B,rt)|0,c=c+Math.imul(B,it)|0;var Nt=(b+(r=r+Math.imul(h,ct)|0)|0)+((8191&(n=(n=n+Math.imul(h,ot)|0)+Math.imul(l,ct)|0))<<13)|0;b=((c=c+Math.imul(l,ot)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,r=Math.imul(Q,V),n=(n=Math.imul(Q,X))+Math.imul(k,V)|0,c=Math.imul(k,X),r=r+Math.imul(C,et)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(w,et)|0,c=c+Math.imul(w,tt)|0,r=r+Math.imul(I,rt)|0,n=(n=n+Math.imul(I,it)|0)+Math.imul(m,rt)|0,c=c+Math.imul(m,it)|0,r=r+Math.imul(p,ct)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(B,ct)|0,c=c+Math.imul(B,ot)|0;var Dt=(b+(r=r+Math.imul(h,At)|0)|0)+((8191&(n=(n=n+Math.imul(h,st)|0)+Math.imul(l,At)|0))<<13)|0;b=((c=c+Math.imul(l,st)|0)+(n>>>13)|0)+(Dt>>>26)|0,Dt&=67108863,r=Math.imul(N,V),n=(n=Math.imul(N,X))+Math.imul(D,V)|0,c=Math.imul(D,X),r=r+Math.imul(Q,et)|0,n=(n=n+Math.imul(Q,tt)|0)+Math.imul(k,et)|0,c=c+Math.imul(k,tt)|0,r=r+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(w,rt)|0,c=c+Math.imul(w,it)|0,r=r+Math.imul(I,ct)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(m,ct)|0,c=c+Math.imul(m,ot)|0,r=r+Math.imul(p,At)|0,n=(n=n+Math.imul(p,st)|0)+Math.imul(B,At)|0,c=c+Math.imul(B,st)|0;var Rt=(b+(r=r+Math.imul(h,ut)|0)|0)+((8191&(n=(n=n+Math.imul(h,ht)|0)+Math.imul(l,ut)|0))<<13)|0;b=((c=c+Math.imul(l,ht)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(L,V),n=(n=Math.imul(L,X))+Math.imul(T,V)|0,c=Math.imul(T,X),r=r+Math.imul(N,et)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(D,et)|0,c=c+Math.imul(D,tt)|0,r=r+Math.imul(Q,rt)|0,n=(n=n+Math.imul(Q,it)|0)+Math.imul(k,rt)|0,c=c+Math.imul(k,it)|0,r=r+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,ot)|0)+Math.imul(w,ct)|0,c=c+Math.imul(w,ot)|0,r=r+Math.imul(I,At)|0,n=(n=n+Math.imul(I,st)|0)+Math.imul(m,At)|0,c=c+Math.imul(m,st)|0,r=r+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,ht)|0)+Math.imul(B,ut)|0,c=c+Math.imul(B,ht)|0;var Ft=(b+(r=r+Math.imul(h,Bt)|0)|0)+((8191&(n=(n=n+Math.imul(h,xt)|0)+Math.imul(l,Bt)|0))<<13)|0;b=((c=c+Math.imul(l,xt)|0)+(n>>>13)|0)+(Ft>>>26)|0,Ft&=67108863,r=Math.imul(P,V),n=(n=Math.imul(P,X))+Math.imul(q,V)|0,c=Math.imul(q,X),r=r+Math.imul(L,et)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(T,et)|0,c=c+Math.imul(T,tt)|0,r=r+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(D,rt)|0,c=c+Math.imul(D,it)|0,r=r+Math.imul(Q,ct)|0,n=(n=n+Math.imul(Q,ot)|0)+Math.imul(k,ct)|0,c=c+Math.imul(k,ot)|0,r=r+Math.imul(C,At)|0,n=(n=n+Math.imul(C,st)|0)+Math.imul(w,At)|0,c=c+Math.imul(w,st)|0,r=r+Math.imul(I,ut)|0,n=(n=n+Math.imul(I,ht)|0)+Math.imul(m,ut)|0,c=c+Math.imul(m,ht)|0,r=r+Math.imul(p,Bt)|0,n=(n=n+Math.imul(p,xt)|0)+Math.imul(B,Bt)|0,c=c+Math.imul(B,xt)|0;var Gt=(b+(r=r+Math.imul(h,mt)|0)|0)+((8191&(n=(n=n+Math.imul(h,Et)|0)+Math.imul(l,mt)|0))<<13)|0;b=((c=c+Math.imul(l,Et)|0)+(n>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,r=Math.imul(O,V),n=(n=Math.imul(O,X))+Math.imul(z,V)|0,c=Math.imul(z,X),r=r+Math.imul(P,et)|0,n=(n=n+Math.imul(P,tt)|0)+Math.imul(q,et)|0,c=c+Math.imul(q,tt)|0,r=r+Math.imul(L,rt)|0,n=(n=n+Math.imul(L,it)|0)+Math.imul(T,rt)|0,c=c+Math.imul(T,it)|0,r=r+Math.imul(N,ct)|0,n=(n=n+Math.imul(N,ot)|0)+Math.imul(D,ct)|0,c=c+Math.imul(D,ot)|0,r=r+Math.imul(Q,At)|0,n=(n=n+Math.imul(Q,st)|0)+Math.imul(k,At)|0,c=c+Math.imul(k,st)|0,r=r+Math.imul(C,ut)|0,n=(n=n+Math.imul(C,ht)|0)+Math.imul(w,ut)|0,c=c+Math.imul(w,ht)|0,r=r+Math.imul(I,Bt)|0,n=(n=n+Math.imul(I,xt)|0)+Math.imul(m,Bt)|0,c=c+Math.imul(m,xt)|0,r=r+Math.imul(p,mt)|0,n=(n=n+Math.imul(p,Et)|0)+Math.imul(B,mt)|0,c=c+Math.imul(B,Et)|0;var Lt=(b+(r=r+Math.imul(h,Ct)|0)|0)+((8191&(n=(n=n+Math.imul(h,wt)|0)+Math.imul(l,Ct)|0))<<13)|0;b=((c=c+Math.imul(l,wt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,r=Math.imul(j,V),n=(n=Math.imul(j,X))+Math.imul(Y,V)|0,c=Math.imul(Y,X),r=r+Math.imul(O,et)|0,n=(n=n+Math.imul(O,tt)|0)+Math.imul(z,et)|0,c=c+Math.imul(z,tt)|0,r=r+Math.imul(P,rt)|0,n=(n=n+Math.imul(P,it)|0)+Math.imul(q,rt)|0,c=c+Math.imul(q,it)|0,r=r+Math.imul(L,ct)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(T,ct)|0,c=c+Math.imul(T,ot)|0,r=r+Math.imul(N,At)|0,n=(n=n+Math.imul(N,st)|0)+Math.imul(D,At)|0,c=c+Math.imul(D,st)|0,r=r+Math.imul(Q,ut)|0,n=(n=n+Math.imul(Q,ht)|0)+Math.imul(k,ut)|0,c=c+Math.imul(k,ht)|0,r=r+Math.imul(C,Bt)|0,n=(n=n+Math.imul(C,xt)|0)+Math.imul(w,Bt)|0,c=c+Math.imul(w,xt)|0,r=r+Math.imul(I,mt)|0,n=(n=n+Math.imul(I,Et)|0)+Math.imul(m,mt)|0,c=c+Math.imul(m,Et)|0,r=r+Math.imul(p,Ct)|0,n=(n=n+Math.imul(p,wt)|0)+Math.imul(B,Ct)|0,c=c+Math.imul(B,wt)|0;var Tt=(b+(r=r+Math.imul(h,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(h,Mt)|0)+Math.imul(l,Qt)|0))<<13)|0;b=((c=c+Math.imul(l,Mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(j,et),n=(n=Math.imul(j,tt))+Math.imul(Y,et)|0,c=Math.imul(Y,tt),r=r+Math.imul(O,rt)|0,n=(n=n+Math.imul(O,it)|0)+Math.imul(z,rt)|0,c=c+Math.imul(z,it)|0,r=r+Math.imul(P,ct)|0,n=(n=n+Math.imul(P,ot)|0)+Math.imul(q,ct)|0,c=c+Math.imul(q,ot)|0,r=r+Math.imul(L,At)|0,n=(n=n+Math.imul(L,st)|0)+Math.imul(T,At)|0,c=c+Math.imul(T,st)|0,r=r+Math.imul(N,ut)|0,n=(n=n+Math.imul(N,ht)|0)+Math.imul(D,ut)|0,c=c+Math.imul(D,ht)|0,r=r+Math.imul(Q,Bt)|0,n=(n=n+Math.imul(Q,xt)|0)+Math.imul(k,Bt)|0,c=c+Math.imul(k,xt)|0,r=r+Math.imul(C,mt)|0,n=(n=n+Math.imul(C,Et)|0)+Math.imul(w,mt)|0,c=c+Math.imul(w,Et)|0,r=r+Math.imul(I,Ct)|0,n=(n=n+Math.imul(I,wt)|0)+Math.imul(m,Ct)|0,c=c+Math.imul(m,wt)|0;var Ut=(b+(r=r+Math.imul(p,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(p,Mt)|0)+Math.imul(B,Qt)|0))<<13)|0;b=((c=c+Math.imul(B,Mt)|0)+(n>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,r=Math.imul(j,rt),n=(n=Math.imul(j,it))+Math.imul(Y,rt)|0,c=Math.imul(Y,it),r=r+Math.imul(O,ct)|0,n=(n=n+Math.imul(O,ot)|0)+Math.imul(z,ct)|0,c=c+Math.imul(z,ot)|0,r=r+Math.imul(P,At)|0,n=(n=n+Math.imul(P,st)|0)+Math.imul(q,At)|0,c=c+Math.imul(q,st)|0,r=r+Math.imul(L,ut)|0,n=(n=n+Math.imul(L,ht)|0)+Math.imul(T,ut)|0,c=c+Math.imul(T,ht)|0,r=r+Math.imul(N,Bt)|0,n=(n=n+Math.imul(N,xt)|0)+Math.imul(D,Bt)|0,c=c+Math.imul(D,xt)|0,r=r+Math.imul(Q,mt)|0,n=(n=n+Math.imul(Q,Et)|0)+Math.imul(k,mt)|0,c=c+Math.imul(k,Et)|0,r=r+Math.imul(C,Ct)|0,n=(n=n+Math.imul(C,wt)|0)+Math.imul(w,Ct)|0,c=c+Math.imul(w,wt)|0;var Pt=(b+(r=r+Math.imul(I,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(I,Mt)|0)+Math.imul(m,Qt)|0))<<13)|0;b=((c=c+Math.imul(m,Mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(j,ct),n=(n=Math.imul(j,ot))+Math.imul(Y,ct)|0,c=Math.imul(Y,ot),r=r+Math.imul(O,At)|0,n=(n=n+Math.imul(O,st)|0)+Math.imul(z,At)|0,c=c+Math.imul(z,st)|0,r=r+Math.imul(P,ut)|0,n=(n=n+Math.imul(P,ht)|0)+Math.imul(q,ut)|0,c=c+Math.imul(q,ht)|0,r=r+Math.imul(L,Bt)|0,n=(n=n+Math.imul(L,xt)|0)+Math.imul(T,Bt)|0,c=c+Math.imul(T,xt)|0,r=r+Math.imul(N,mt)|0,n=(n=n+Math.imul(N,Et)|0)+Math.imul(D,mt)|0,c=c+Math.imul(D,Et)|0,r=r+Math.imul(Q,Ct)|0,n=(n=n+Math.imul(Q,wt)|0)+Math.imul(k,Ct)|0,c=c+Math.imul(k,wt)|0;var qt=(b+(r=r+Math.imul(C,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(C,Mt)|0)+Math.imul(w,Qt)|0))<<13)|0;b=((c=c+Math.imul(w,Mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863,r=Math.imul(j,At),n=(n=Math.imul(j,st))+Math.imul(Y,At)|0,c=Math.imul(Y,st),r=r+Math.imul(O,ut)|0,n=(n=n+Math.imul(O,ht)|0)+Math.imul(z,ut)|0,c=c+Math.imul(z,ht)|0,r=r+Math.imul(P,Bt)|0,n=(n=n+Math.imul(P,xt)|0)+Math.imul(q,Bt)|0,c=c+Math.imul(q,xt)|0,r=r+Math.imul(L,mt)|0,n=(n=n+Math.imul(L,Et)|0)+Math.imul(T,mt)|0,c=c+Math.imul(T,Et)|0,r=r+Math.imul(N,Ct)|0,n=(n=n+Math.imul(N,wt)|0)+Math.imul(D,Ct)|0,c=c+Math.imul(D,wt)|0;var Ht=(b+(r=r+Math.imul(Q,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(Q,Mt)|0)+Math.imul(k,Qt)|0))<<13)|0;b=((c=c+Math.imul(k,Mt)|0)+(n>>>13)|0)+(Ht>>>26)|0,Ht&=67108863,r=Math.imul(j,ut),n=(n=Math.imul(j,ht))+Math.imul(Y,ut)|0,c=Math.imul(Y,ht),r=r+Math.imul(O,Bt)|0,n=(n=n+Math.imul(O,xt)|0)+Math.imul(z,Bt)|0,c=c+Math.imul(z,xt)|0,r=r+Math.imul(P,mt)|0,n=(n=n+Math.imul(P,Et)|0)+Math.imul(q,mt)|0,c=c+Math.imul(q,Et)|0,r=r+Math.imul(L,Ct)|0,n=(n=n+Math.imul(L,wt)|0)+Math.imul(T,Ct)|0,c=c+Math.imul(T,wt)|0;var Ot=(b+(r=r+Math.imul(N,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(N,Mt)|0)+Math.imul(D,Qt)|0))<<13)|0;b=((c=c+Math.imul(D,Mt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,r=Math.imul(j,Bt),n=(n=Math.imul(j,xt))+Math.imul(Y,Bt)|0,c=Math.imul(Y,xt),r=r+Math.imul(O,mt)|0,n=(n=n+Math.imul(O,Et)|0)+Math.imul(z,mt)|0,c=c+Math.imul(z,Et)|0,r=r+Math.imul(P,Ct)|0,n=(n=n+Math.imul(P,wt)|0)+Math.imul(q,Ct)|0,c=c+Math.imul(q,wt)|0;var zt=(b+(r=r+Math.imul(L,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(L,Mt)|0)+Math.imul(T,Qt)|0))<<13)|0;b=((c=c+Math.imul(T,Mt)|0)+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863,r=Math.imul(j,mt),n=(n=Math.imul(j,Et))+Math.imul(Y,mt)|0,c=Math.imul(Y,Et),r=r+Math.imul(O,Ct)|0,n=(n=n+Math.imul(O,wt)|0)+Math.imul(z,Ct)|0,c=c+Math.imul(z,wt)|0;var Kt=(b+(r=r+Math.imul(P,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(P,Mt)|0)+Math.imul(q,Qt)|0))<<13)|0;b=((c=c+Math.imul(q,Mt)|0)+(n>>>13)|0)+(Kt>>>26)|0,Kt&=67108863,r=Math.imul(j,Ct),n=(n=Math.imul(j,wt))+Math.imul(Y,Ct)|0,c=Math.imul(Y,wt);var Jt=(b+(r=r+Math.imul(O,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(O,Mt)|0)+Math.imul(z,Qt)|0))<<13)|0;b=((c=c+Math.imul(z,Mt)|0)+(n>>>13)|0)+(Jt>>>26)|0,Jt&=67108863;var jt=(b+(r=Math.imul(j,Qt))|0)+((8191&(n=(n=Math.imul(j,Mt))+Math.imul(Y,Qt)|0))<<13)|0;return b=((c=Math.imul(Y,Mt))+(n>>>13)|0)+(jt>>>26)|0,jt&=67108863,s[0]=kt,s[1]=_t,s[2]=St,s[3]=Nt,s[4]=Dt,s[5]=Rt,s[6]=Ft,s[7]=Gt,s[8]=Lt,s[9]=Tt,s[10]=Ut,s[11]=Pt,s[12]=qt,s[13]=Ht,s[14]=Ot,s[15]=zt,s[16]=Kt,s[17]=Jt,s[18]=jt,0!==b&&(s[19]=b,a.length++),a};function jumboMulTo(e,t,a){return(new FFTM).mulp(e,t,a)}function FFTM(e,t){this.x=e,this.y=t}Math.imul||(d=smallMulTo),BN.prototype.mulTo=function mulTo(e,t){var a,r=this.length+e.length;return a=10===this.length&&10===e.length?d(this,e,t):r<63?smallMulTo(this,e,t):r<1024?function bigMulTo(e,t,a){a.negative=t.negative^e.negative,a.length=e.length+t.length;for(var r=0,n=0,c=0;c>>26)|0)>>>26,o&=67108863}a.words[c]=d,r=o,o=n}return 0!==r?a.words[c]=r:a.length--,a.strip()}(this,e,t):jumboMulTo(this,e,t),a},FFTM.prototype.makeRBT=function makeRBT(e){for(var t=new Array(e),a=BN.prototype._countBits(e)-1,r=0;r>=1;return r},FFTM.prototype.permute=function permute(e,t,a,r,n,c){for(var o=0;o>>=1)n++;return 1<>>=13,a[2*c+1]=8191&n,n>>>=13;for(c=2*t;c>=26,t+=r/67108864|0,t+=n>>>26,this.words[a]=67108863&n}return 0!==t&&(this.words[a]=t,this.length++),this},BN.prototype.muln=function muln(e){return this.clone().imuln(e)},BN.prototype.sqr=function sqr(){return this.mul(this)},BN.prototype.isqr=function isqr(){return this.imul(this.clone())},BN.prototype.pow=function pow(e){var t=function toBitArray(e){for(var t=new Array(e.bitLength()),a=0;a>>n}return t}(e);if(0===t.length)return new BN(1);for(var a=this,r=0;r=0);var t,a=e%26,r=(e-a)/26,n=67108863>>>26-a<<26-a;if(0!==a){var c=0;for(t=0;t>>26-a}c&&(this.words[t]=c,this.length++)}if(0!==r){for(t=this.length-1;t>=0;t--)this.words[t+r]=this.words[t];for(t=0;t=0),r=t?(t-t%26)/26:0;var n=e%26,c=Math.min((e-n)/26,this.length),o=67108863^67108863>>>n<c)for(this.length-=c,s=0;s=0&&(0!==b||s>=r);s--){var u=0|this.words[s];this.words[s]=b<<26-n|u>>>n,b=u&o}return d&&0!==b&&(d.words[d.length++]=b),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},BN.prototype.ishrn=function ishrn(e,t,a){return assert(0===this.negative),this.iushrn(e,t,a)},BN.prototype.shln=function shln(e){return this.clone().ishln(e)},BN.prototype.ushln=function ushln(e){return this.clone().iushln(e)},BN.prototype.shrn=function shrn(e){return this.clone().ishrn(e)},BN.prototype.ushrn=function ushrn(e){return this.clone().iushrn(e)},BN.prototype.testn=function testn(e){assert("number"==typeof e&&e>=0);var t=e%26,a=(e-t)/26,r=1<=0);var t=e%26,a=(e-t)/26;if(assert(0===this.negative,"imaskn works only with positive numbers"),this.length<=a)return this;if(0!==t&&a++,this.length=Math.min(a,this.length),0!==t){var r=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},BN.prototype.isubn=function isubn(e){if(assert("number"==typeof e),assert(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(d/67108864|0),this.words[r+a]=67108863&n}for(;r>26,this.words[r+a]=67108863&n;if(0===o)return this.strip();for(assert(-1===o),o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},BN.prototype._wordDiv=function _wordDiv(e,t){var a=(this.length,e.length),r=this.clone(),n=e,c=0|n.words[n.length-1];0!==(a=26-this._countBits(c))&&(n=n.ushln(a),r.iushln(a),c=0|n.words[n.length-1]);var o,d=r.length-n.length;if("mod"!==t){(o=new BN(null)).length=d+1,o.words=new Array(o.length);for(var s=0;s=0;u--){var h=67108864*(0|r.words[n.length+u])+(0|r.words[n.length+u-1]);for(h=Math.min(h/c|0,67108863),r._ishlnsubmul(n,h,u);0!==r.negative;)h--,r.negative=0,r._ishlnsubmul(n,1,u),r.isZero()||(r.negative^=1);o&&(o.words[u]=h)}return o&&o.strip(),r.strip(),"div"!==t&&0!==a&&r.iushrn(a),{div:o||null,mod:r}},BN.prototype.divmod=function divmod(e,t,a){return assert(!e.isZero()),this.isZero()?{div:new BN(0),mod:new BN(0)}:0!==this.negative&&0===e.negative?(c=this.neg().divmod(e,t),"mod"!==t&&(r=c.div.neg()),"div"!==t&&(n=c.mod.neg(),a&&0!==n.negative&&n.iadd(e)),{div:r,mod:n}):0===this.negative&&0!==e.negative?(c=this.divmod(e.neg(),t),"mod"!==t&&(r=c.div.neg()),{div:r,mod:c.mod}):0!=(this.negative&e.negative)?(c=this.neg().divmod(e.neg(),t),"div"!==t&&(n=c.mod.neg(),a&&0!==n.negative&&n.isub(e)),{div:c.div,mod:n}):e.length>this.length||this.cmp(e)<0?{div:new BN(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new BN(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new BN(this.modn(e.words[0]))}:this._wordDiv(e,t);var r,n,c},BN.prototype.div=function div(e){return this.divmod(e,"div",!1).div},BN.prototype.mod=function mod(e){return this.divmod(e,"mod",!1).mod},BN.prototype.umod=function umod(e){return this.divmod(e,"mod",!0).mod},BN.prototype.divRound=function divRound(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var a=0!==t.div.negative?t.mod.isub(e):t.mod,r=e.ushrn(1),n=e.andln(1),c=a.cmp(r);return c<0||1===n&&0===c?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},BN.prototype.modn=function modn(e){assert(e<=67108863);for(var t=(1<<26)%e,a=0,r=this.length-1;r>=0;r--)a=(t*a+(0|this.words[r]))%e;return a},BN.prototype.idivn=function idivn(e){assert(e<=67108863);for(var t=0,a=this.length-1;a>=0;a--){var r=(0|this.words[a])+67108864*t;this.words[a]=r/e|0,t=r%e}return this.strip()},BN.prototype.divn=function divn(e){return this.clone().idivn(e)},BN.prototype.egcd=function egcd(e){assert(0===e.negative),assert(!e.isZero());var t=this,a=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var r=new BN(1),n=new BN(0),c=new BN(0),o=new BN(1),d=0;t.isEven()&&a.isEven();)t.iushrn(1),a.iushrn(1),++d;for(var s=a.clone(),b=t.clone();!t.isZero();){for(var u=0,h=1;0==(t.words[0]&h)&&u<26;++u,h<<=1);if(u>0)for(t.iushrn(u);u-- >0;)(r.isOdd()||n.isOdd())&&(r.iadd(s),n.isub(b)),r.iushrn(1),n.iushrn(1);for(var l=0,g=1;0==(a.words[0]&g)&&l<26;++l,g<<=1);if(l>0)for(a.iushrn(l);l-- >0;)(c.isOdd()||o.isOdd())&&(c.iadd(s),o.isub(b)),c.iushrn(1),o.iushrn(1);t.cmp(a)>=0?(t.isub(a),r.isub(c),n.isub(o)):(a.isub(t),c.isub(r),o.isub(n))}return{a:c,b:o,gcd:a.iushln(d)}},BN.prototype._invmp=function _invmp(e){assert(0===e.negative),assert(!e.isZero());var t=this,a=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var r,n=new BN(1),c=new BN(0),o=a.clone();t.cmpn(1)>0&&a.cmpn(1)>0;){for(var d=0,s=1;0==(t.words[0]&s)&&d<26;++d,s<<=1);if(d>0)for(t.iushrn(d);d-- >0;)n.isOdd()&&n.iadd(o),n.iushrn(1);for(var b=0,u=1;0==(a.words[0]&u)&&b<26;++b,u<<=1);if(b>0)for(a.iushrn(b);b-- >0;)c.isOdd()&&c.iadd(o),c.iushrn(1);t.cmp(a)>=0?(t.isub(a),n.isub(c)):(a.isub(t),c.isub(n))}return(r=0===t.cmpn(1)?n:c).cmpn(0)<0&&r.iadd(e),r},BN.prototype.gcd=function gcd(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),a=e.clone();t.negative=0,a.negative=0;for(var r=0;t.isEven()&&a.isEven();r++)t.iushrn(1),a.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;a.isEven();)a.iushrn(1);var n=t.cmp(a);if(n<0){var c=t;t=a,a=c}else if(0===n||0===a.cmpn(1))break;t.isub(a)}return a.iushln(r)},BN.prototype.invm=function invm(e){return this.egcd(e).a.umod(e)},BN.prototype.isEven=function isEven(){return 0==(1&this.words[0])},BN.prototype.isOdd=function isOdd(){return 1==(1&this.words[0])},BN.prototype.andln=function andln(e){return this.words[0]&e},BN.prototype.bincn=function bincn(e){assert("number"==typeof e);var t=e%26,a=(e-t)/26,r=1<>>26,o&=67108863,this.words[c]=o}return 0!==n&&(this.words[c]=n,this.length++),this},BN.prototype.isZero=function isZero(){return 1===this.length&&0===this.words[0]},BN.prototype.cmpn=function cmpn(e){var t,a=e<0;if(0!==this.negative&&!a)return-1;if(0===this.negative&&a)return 1;if(this.strip(),this.length>1)t=1;else{a&&(e=-e),assert(e<=67108863,"Number is too big");var r=0|this.words[0];t=r===e?0:re.length)return 1;if(this.length=0;a--){var r=0|this.words[a],n=0|e.words[a];if(r!==n){rn&&(t=1);break}}return t},BN.prototype.gtn=function gtn(e){return 1===this.cmpn(e)},BN.prototype.gt=function gt(e){return 1===this.cmp(e)},BN.prototype.gten=function gten(e){return this.cmpn(e)>=0},BN.prototype.gte=function gte(e){return this.cmp(e)>=0},BN.prototype.ltn=function ltn(e){return-1===this.cmpn(e)},BN.prototype.lt=function lt(e){return-1===this.cmp(e)},BN.prototype.lten=function lten(e){return this.cmpn(e)<=0},BN.prototype.lte=function lte(e){return this.cmp(e)<=0},BN.prototype.eqn=function eqn(e){return 0===this.cmpn(e)},BN.prototype.eq=function eq(e){return 0===this.cmp(e)},BN.red=function red(e){return new Red(e)},BN.prototype.toRed=function toRed(e){return assert(!this.red,"Already a number in reduction context"),assert(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},BN.prototype.fromRed=function fromRed(){return assert(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},BN.prototype._forceRed=function _forceRed(e){return this.red=e,this},BN.prototype.forceRed=function forceRed(e){return assert(!this.red,"Already a number in reduction context"),this._forceRed(e)},BN.prototype.redAdd=function redAdd(e){return assert(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},BN.prototype.redIAdd=function redIAdd(e){return assert(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},BN.prototype.redSub=function redSub(e){return assert(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},BN.prototype.redISub=function redISub(e){return assert(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},BN.prototype.redShl=function redShl(e){return assert(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},BN.prototype.redMul=function redMul(e){return assert(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},BN.prototype.redIMul=function redIMul(e){return assert(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},BN.prototype.redSqr=function redSqr(){return assert(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},BN.prototype.redISqr=function redISqr(){return assert(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},BN.prototype.redSqrt=function redSqrt(){return assert(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},BN.prototype.redInvm=function redInvm(){return assert(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},BN.prototype.redNeg=function redNeg(){return assert(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},BN.prototype.redPow=function redPow(e){return assert(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var s={k256:null,p224:null,p192:null,p25519:null};function MPrime(e,t){this.name=e,this.p=new BN(t,16),this.n=this.p.bitLength(),this.k=new BN(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function K256(){MPrime.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function P224(){MPrime.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function P192(){MPrime.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function P25519(){MPrime.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function Red(e){if("string"==typeof e){var t=BN._prime(e);this.m=t.p,this.prime=t}else assert(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function Mont(e){Red.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new BN(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)}MPrime.prototype._tmp=function _tmp(){var e=new BN(null);return e.words=new Array(Math.ceil(this.n/13)),e},MPrime.prototype.ireduce=function ireduce(e){var t,a=e;do{this.split(a,this.tmp),t=(a=(a=this.imulK(a)).iadd(this.tmp)).bitLength()}while(t>this.n);var r=t0?a.isub(this.p):void 0!==a.strip?a.strip():a._strip(),a},MPrime.prototype.split=function split(e,t){e.iushrn(this.n,0,t)},MPrime.prototype.imulK=function imulK(e){return e.imul(this.k)},inherits(K256,MPrime),K256.prototype.split=function split(e,t){for(var a=4194303,r=Math.min(e.length,9),n=0;n>>22,c=o}c>>>=22,e.words[n-10]=c,0===c&&e.length>10?e.length-=10:e.length-=9},K256.prototype.imulK=function imulK(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,a=0;a>>=26,e.words[a]=n,t=r}return 0!==t&&(e.words[e.length++]=t),e},BN._prime=function prime(e){if(s[e])return s[e];var prime;if("k256"===e)prime=new K256;else if("p224"===e)prime=new P224;else if("p192"===e)prime=new P192;else{if("p25519"!==e)throw new Error("Unknown prime "+e);prime=new P25519}return s[e]=prime,prime},Red.prototype._verify1=function _verify1(e){assert(0===e.negative,"red works only with positives"),assert(e.red,"red works only with red numbers")},Red.prototype._verify2=function _verify2(e,t){assert(0==(e.negative|t.negative),"red works only with positives"),assert(e.red&&e.red===t.red,"red works only with red numbers")},Red.prototype.imod=function imod(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},Red.prototype.neg=function neg(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},Red.prototype.add=function add(e,t){this._verify2(e,t);var a=e.add(t);return a.cmp(this.m)>=0&&a.isub(this.m),a._forceRed(this)},Red.prototype.iadd=function iadd(e,t){this._verify2(e,t);var a=e.iadd(t);return a.cmp(this.m)>=0&&a.isub(this.m),a},Red.prototype.sub=function sub(e,t){this._verify2(e,t);var a=e.sub(t);return a.cmpn(0)<0&&a.iadd(this.m),a._forceRed(this)},Red.prototype.isub=function isub(e,t){this._verify2(e,t);var a=e.isub(t);return a.cmpn(0)<0&&a.iadd(this.m),a},Red.prototype.shl=function shl(e,t){return this._verify1(e),this.imod(e.ushln(t))},Red.prototype.imul=function imul(e,t){return this._verify2(e,t),this.imod(e.imul(t))},Red.prototype.mul=function mul(e,t){return this._verify2(e,t),this.imod(e.mul(t))},Red.prototype.isqr=function isqr(e){return this.imul(e,e.clone())},Red.prototype.sqr=function sqr(e){return this.mul(e,e)},Red.prototype.sqrt=function sqrt(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(assert(t%2==1),3===t){var a=this.m.add(new BN(1)).iushrn(2);return this.pow(e,a)}for(var r=this.m.subn(1),n=0;!r.isZero()&&0===r.andln(1);)n++,r.iushrn(1);assert(!r.isZero());var c=new BN(1).toRed(this),o=c.redNeg(),d=this.m.subn(1).iushrn(1),s=this.m.bitLength();for(s=new BN(2*s*s).toRed(this);0!==this.pow(s,d).cmp(o);)s.redIAdd(o);for(var b=this.pow(s,r),u=this.pow(e,r.addn(1).iushrn(1)),h=this.pow(e,r),l=n;0!==h.cmp(c);){for(var g=h,p=0;0!==g.cmp(c);p++)g=g.redSqr();assert(p=0;r--){for(var s=t.words[r],b=d-1;b>=0;b--){var u=s>>b&1;n!==a[0]&&(n=this.sqr(n)),0!==u||0!==c?(c<<=1,c|=u,(4===++o||0===r&&0===b)&&(n=this.mul(n,a[c]),o=0,c=0)):o=0}d=26}return n},Red.prototype.convertTo=function convertTo(e){var t=e.umod(this.m);return t===e?t.clone():t},Red.prototype.convertFrom=function convertFrom(e){var t=e.clone();return t.red=null,t},BN.mont=function mont(e){return new Mont(e)},inherits(Mont,Red),Mont.prototype.convertTo=function convertTo(e){return this.imod(e.ushln(this.shift))},Mont.prototype.convertFrom=function convertFrom(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},Mont.prototype.imul=function imul(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var a=e.imul(t),r=a.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=a.isub(r).iushrn(this.shift),c=n;return n.cmp(this.m)>=0?c=n.isub(this.m):n.cmpn(0)<0&&(c=n.iadd(this.m)),c._forceRed(this)},Mont.prototype.mul=function mul(e,t){if(e.isZero()||t.isZero())return new BN(0)._forceRed(this);var a=e.mul(t),r=a.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=a.isub(r).iushrn(this.shift),c=n;return n.cmp(this.m)>=0?c=n.isub(this.m):n.cmpn(0)<0&&(c=n.iadd(this.m)),c._forceRed(this)},Mont.prototype.invm=function invm(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e=a.nmd(e),this)},function(e,t,a){!function(e,t){"use strict";function assert(e,t){if(!e)throw new Error(t||"Assertion failed")}function inherits(e,t){e.super_=t;var TempCtor=function(){};TempCtor.prototype=t.prototype,e.prototype=new TempCtor,e.prototype.constructor=e}function BN(e,t,a){if(BN.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(a=t,t=10),this._init(e||0,t||10,a||"be"))}var r;"object"==typeof e?e.exports=BN:t.BN=BN,BN.BN=BN,BN.wordSize=26;try{r="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:a(1402).Buffer}catch(e){}function parseHex4Bits(e,t){var a=e.charCodeAt(t);return a>=65&&a<=70?a-55:a>=97&&a<=102?a-87:a-48&15}function parseHexByte(e,t,a){var r=parseHex4Bits(e,a);return a-1>=t&&(r|=parseHex4Bits(e,a-1)<<4),r}function parseBase(e,t,a,r){for(var n=0,c=Math.min(e.length,a),o=t;o=49?d-49+10:d>=17?d-17+10:d}return n}BN.isBN=function isBN(e){return e instanceof BN||null!==e&&"object"==typeof e&&e.constructor.wordSize===BN.wordSize&&Array.isArray(e.words)},BN.max=function max(e,t){return e.cmp(t)>0?e:t},BN.min=function min(e,t){return e.cmp(t)<0?e:t},BN.prototype._init=function init(e,t,a){if("number"==typeof e)return this._initNumber(e,t,a);if("object"==typeof e)return this._initArray(e,t,a);"hex"===t&&(t=16),assert(t===(0|t)&&t>=2&&t<=36);var r=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(r++,this.negative=1),r=0;r-=3)c=e[r]|e[r-1]<<8|e[r-2]<<16,this.words[n]|=c<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===a)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},BN.prototype._parseHex=function _parseHex(e,t,a){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=2)n=parseHexByte(e,t,r)<=18?(c-=18,o+=1,this.words[o]|=n>>>26):c+=8;else for(r=(e.length-t)%2==0?t+1:t;r=18?(c-=18,o+=1,this.words[o]|=n>>>26):c+=8;this.strip()},BN.prototype._parseBase=function _parseBase(e,t,a){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=t)r++;r--,n=n/t|0;for(var c=e.length-a,o=c%r,d=Math.min(c,c-o)+a,s=0,b=a;b1&&0===this.words[this.length-1];)this.length--;return this._normSign()},BN.prototype._normSign=function _normSign(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},BN.prototype.inspect=function inspect(){return(this.red?""};var n=["","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"],c=[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],o=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function smallMulTo(e,t,a){a.negative=t.negative^e.negative;var r=e.length+t.length|0;a.length=r,r=r-1|0;var n=0|e.words[0],c=0|t.words[0],o=n*c,d=67108863&o,s=o/67108864|0;a.words[0]=d;for(var b=1;b>>26,h=67108863&s,l=Math.min(b,t.length-1),g=Math.max(0,b-e.length+1);g<=l;g++){var p=b-g|0;u+=(o=(n=0|e.words[p])*(c=0|t.words[g])+h)/67108864|0,h=67108863&o}a.words[b]=0|h,s=0|u}return 0!==s?a.words[b]=0|s:a.length--,a.strip()}BN.prototype.toString=function toString(e,t){var a;if(t=0|t||1,16===(e=e||10)||"hex"===e){a="";for(var r=0,d=0,s=0;s>>24-r&16777215)||s!==this.length-1?n[6-u.length]+u+a:u+a,(r+=2)>=26&&(r-=26,s--)}for(0!==d&&(a=d.toString(16)+a);a.length%t!=0;)a="0"+a;return 0!==this.negative&&(a="-"+a),a}if(e===(0|e)&&e>=2&&e<=36){var h=c[e],l=o[e];a="";var g=this.clone();for(g.negative=0;!g.isZero();){var p=g.modn(l).toString(e);a=(g=g.idivn(l)).isZero()?p+a:n[h-p.length]+p+a}for(this.isZero()&&(a="0"+a);a.length%t!=0;)a="0"+a;return 0!==this.negative&&(a="-"+a),a}assert(!1,"Base should be between 2 and 36")},BN.prototype.toNumber=function toNumber(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&assert(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},BN.prototype.toJSON=function toJSON(){return this.toString(16)},BN.prototype.toBuffer=function toBuffer(e,t){return assert(void 0!==r),this.toArrayLike(r,e,t)},BN.prototype.toArray=function toArray(e,t){return this.toArrayLike(Array,e,t)},BN.prototype.toArrayLike=function toArrayLike(e,t,a){var r=this.byteLength(),n=a||Math.max(1,r);assert(r<=n,"byte array longer than desired length"),assert(n>0,"Requested array length <= 0"),this.strip();var c,o,d="le"===t,s=new e(n),b=this.clone();if(d){for(o=0;!b.isZero();o++)c=b.andln(255),b.iushrn(8),s[o]=c;for(;o=4096&&(a+=13,t>>>=13),t>=64&&(a+=7,t>>>=7),t>=8&&(a+=4,t>>>=4),t>=2&&(a+=2,t>>>=2),a+t},BN.prototype._zeroBits=function _zeroBits(e){if(0===e)return 26;var t=e,a=0;return 0==(8191&t)&&(a+=13,t>>>=13),0==(127&t)&&(a+=7,t>>>=7),0==(15&t)&&(a+=4,t>>>=4),0==(3&t)&&(a+=2,t>>>=2),0==(1&t)&&a++,a},BN.prototype.bitLength=function bitLength(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},BN.prototype.zeroBits=function zeroBits(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},BN.prototype.uor=function uor(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},BN.prototype.iuand=function iuand(e){var t;t=this.length>e.length?e:this;for(var a=0;ae.length?this.clone().iand(e):e.clone().iand(this)},BN.prototype.uand=function uand(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},BN.prototype.iuxor=function iuxor(e){var t,a;this.length>e.length?(t=this,a=e):(t=e,a=this);for(var r=0;re.length?this.clone().ixor(e):e.clone().ixor(this)},BN.prototype.uxor=function uxor(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},BN.prototype.inotn=function inotn(e){assert("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),a=e%26;this._expand(t),a>0&&t--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-a),this.strip()},BN.prototype.notn=function notn(e){return this.clone().inotn(e)},BN.prototype.setn=function setn(e,t){assert("number"==typeof e&&e>=0);var a=e/26|0,r=e%26;return this._expand(a+1),this.words[a]=t?this.words[a]|1<e.length?(a=this,r=e):(a=e,r=this);for(var n=0,c=0;c>>26;for(;0!==n&&c>>26;if(this.length=a.length,0!==n)this.words[this.length]=n,this.length++;else if(a!==this)for(;ce.length?this.clone().iadd(e):e.clone().iadd(this)},BN.prototype.isub=function isub(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var a,r,n=this.cmp(e);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(a=this,r=e):(a=e,r=this);for(var c=0,o=0;o>26,this.words[o]=67108863&t;for(;0!==c&&o>26,this.words[o]=67108863&t;if(0===c&&o>>13,g=0|o[1],p=8191&g,B=g>>>13,x=0|o[2],I=8191&x,m=x>>>13,y=0|o[3],C=8191&y,w=y>>>13,v=0|o[4],Q=8191&v,k=v>>>13,_=0|o[5],N=8191&_,D=_>>>13,G=0|o[6],L=8191&G,T=G>>>13,U=0|o[7],P=8191&U,q=U>>>13,H=0|o[8],O=8191&H,z=H>>>13,J=0|o[9],j=8191&J,Y=J>>>13,W=0|d[0],V=8191&W,X=W>>>13,$=0|d[1],et=8191&$,tt=$>>>13,at=0|d[2],rt=8191&at,it=at>>>13,nt=0|d[3],ct=8191&nt,ot=nt>>>13,dt=0|d[4],At=8191&dt,st=dt>>>13,bt=0|d[5],ut=8191&bt,ht=bt>>>13,pt=0|d[6],Bt=8191&pt,xt=pt>>>13,It=0|d[7],mt=8191&It,Et=It>>>13,yt=0|d[8],Ct=8191&yt,wt=yt>>>13,vt=0|d[9],Qt=8191&vt,Mt=vt>>>13;a.negative=e.negative^t.negative,a.length=19;var kt=(b+(r=Math.imul(h,V))|0)+((8191&(n=(n=Math.imul(h,X))+Math.imul(l,V)|0))<<13)|0;b=((c=Math.imul(l,X))+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(p,V),n=(n=Math.imul(p,X))+Math.imul(B,V)|0,c=Math.imul(B,X);var _t=(b+(r=r+Math.imul(h,et)|0)|0)+((8191&(n=(n=n+Math.imul(h,tt)|0)+Math.imul(l,et)|0))<<13)|0;b=((c=c+Math.imul(l,tt)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(I,V),n=(n=Math.imul(I,X))+Math.imul(m,V)|0,c=Math.imul(m,X),r=r+Math.imul(p,et)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(B,et)|0,c=c+Math.imul(B,tt)|0;var St=(b+(r=r+Math.imul(h,rt)|0)|0)+((8191&(n=(n=n+Math.imul(h,it)|0)+Math.imul(l,rt)|0))<<13)|0;b=((c=c+Math.imul(l,it)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(C,V),n=(n=Math.imul(C,X))+Math.imul(w,V)|0,c=Math.imul(w,X),r=r+Math.imul(I,et)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(m,et)|0,c=c+Math.imul(m,tt)|0,r=r+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(B,rt)|0,c=c+Math.imul(B,it)|0;var Nt=(b+(r=r+Math.imul(h,ct)|0)|0)+((8191&(n=(n=n+Math.imul(h,ot)|0)+Math.imul(l,ct)|0))<<13)|0;b=((c=c+Math.imul(l,ot)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,r=Math.imul(Q,V),n=(n=Math.imul(Q,X))+Math.imul(k,V)|0,c=Math.imul(k,X),r=r+Math.imul(C,et)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(w,et)|0,c=c+Math.imul(w,tt)|0,r=r+Math.imul(I,rt)|0,n=(n=n+Math.imul(I,it)|0)+Math.imul(m,rt)|0,c=c+Math.imul(m,it)|0,r=r+Math.imul(p,ct)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(B,ct)|0,c=c+Math.imul(B,ot)|0;var Dt=(b+(r=r+Math.imul(h,At)|0)|0)+((8191&(n=(n=n+Math.imul(h,st)|0)+Math.imul(l,At)|0))<<13)|0;b=((c=c+Math.imul(l,st)|0)+(n>>>13)|0)+(Dt>>>26)|0,Dt&=67108863,r=Math.imul(N,V),n=(n=Math.imul(N,X))+Math.imul(D,V)|0,c=Math.imul(D,X),r=r+Math.imul(Q,et)|0,n=(n=n+Math.imul(Q,tt)|0)+Math.imul(k,et)|0,c=c+Math.imul(k,tt)|0,r=r+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(w,rt)|0,c=c+Math.imul(w,it)|0,r=r+Math.imul(I,ct)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(m,ct)|0,c=c+Math.imul(m,ot)|0,r=r+Math.imul(p,At)|0,n=(n=n+Math.imul(p,st)|0)+Math.imul(B,At)|0,c=c+Math.imul(B,st)|0;var Rt=(b+(r=r+Math.imul(h,ut)|0)|0)+((8191&(n=(n=n+Math.imul(h,ht)|0)+Math.imul(l,ut)|0))<<13)|0;b=((c=c+Math.imul(l,ht)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(L,V),n=(n=Math.imul(L,X))+Math.imul(T,V)|0,c=Math.imul(T,X),r=r+Math.imul(N,et)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(D,et)|0,c=c+Math.imul(D,tt)|0,r=r+Math.imul(Q,rt)|0,n=(n=n+Math.imul(Q,it)|0)+Math.imul(k,rt)|0,c=c+Math.imul(k,it)|0,r=r+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,ot)|0)+Math.imul(w,ct)|0,c=c+Math.imul(w,ot)|0,r=r+Math.imul(I,At)|0,n=(n=n+Math.imul(I,st)|0)+Math.imul(m,At)|0,c=c+Math.imul(m,st)|0,r=r+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,ht)|0)+Math.imul(B,ut)|0,c=c+Math.imul(B,ht)|0;var Ft=(b+(r=r+Math.imul(h,Bt)|0)|0)+((8191&(n=(n=n+Math.imul(h,xt)|0)+Math.imul(l,Bt)|0))<<13)|0;b=((c=c+Math.imul(l,xt)|0)+(n>>>13)|0)+(Ft>>>26)|0,Ft&=67108863,r=Math.imul(P,V),n=(n=Math.imul(P,X))+Math.imul(q,V)|0,c=Math.imul(q,X),r=r+Math.imul(L,et)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(T,et)|0,c=c+Math.imul(T,tt)|0,r=r+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(D,rt)|0,c=c+Math.imul(D,it)|0,r=r+Math.imul(Q,ct)|0,n=(n=n+Math.imul(Q,ot)|0)+Math.imul(k,ct)|0,c=c+Math.imul(k,ot)|0,r=r+Math.imul(C,At)|0,n=(n=n+Math.imul(C,st)|0)+Math.imul(w,At)|0,c=c+Math.imul(w,st)|0,r=r+Math.imul(I,ut)|0,n=(n=n+Math.imul(I,ht)|0)+Math.imul(m,ut)|0,c=c+Math.imul(m,ht)|0,r=r+Math.imul(p,Bt)|0,n=(n=n+Math.imul(p,xt)|0)+Math.imul(B,Bt)|0,c=c+Math.imul(B,xt)|0;var Gt=(b+(r=r+Math.imul(h,mt)|0)|0)+((8191&(n=(n=n+Math.imul(h,Et)|0)+Math.imul(l,mt)|0))<<13)|0;b=((c=c+Math.imul(l,Et)|0)+(n>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,r=Math.imul(O,V),n=(n=Math.imul(O,X))+Math.imul(z,V)|0,c=Math.imul(z,X),r=r+Math.imul(P,et)|0,n=(n=n+Math.imul(P,tt)|0)+Math.imul(q,et)|0,c=c+Math.imul(q,tt)|0,r=r+Math.imul(L,rt)|0,n=(n=n+Math.imul(L,it)|0)+Math.imul(T,rt)|0,c=c+Math.imul(T,it)|0,r=r+Math.imul(N,ct)|0,n=(n=n+Math.imul(N,ot)|0)+Math.imul(D,ct)|0,c=c+Math.imul(D,ot)|0,r=r+Math.imul(Q,At)|0,n=(n=n+Math.imul(Q,st)|0)+Math.imul(k,At)|0,c=c+Math.imul(k,st)|0,r=r+Math.imul(C,ut)|0,n=(n=n+Math.imul(C,ht)|0)+Math.imul(w,ut)|0,c=c+Math.imul(w,ht)|0,r=r+Math.imul(I,Bt)|0,n=(n=n+Math.imul(I,xt)|0)+Math.imul(m,Bt)|0,c=c+Math.imul(m,xt)|0,r=r+Math.imul(p,mt)|0,n=(n=n+Math.imul(p,Et)|0)+Math.imul(B,mt)|0,c=c+Math.imul(B,Et)|0;var Lt=(b+(r=r+Math.imul(h,Ct)|0)|0)+((8191&(n=(n=n+Math.imul(h,wt)|0)+Math.imul(l,Ct)|0))<<13)|0;b=((c=c+Math.imul(l,wt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,r=Math.imul(j,V),n=(n=Math.imul(j,X))+Math.imul(Y,V)|0,c=Math.imul(Y,X),r=r+Math.imul(O,et)|0,n=(n=n+Math.imul(O,tt)|0)+Math.imul(z,et)|0,c=c+Math.imul(z,tt)|0,r=r+Math.imul(P,rt)|0,n=(n=n+Math.imul(P,it)|0)+Math.imul(q,rt)|0,c=c+Math.imul(q,it)|0,r=r+Math.imul(L,ct)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(T,ct)|0,c=c+Math.imul(T,ot)|0,r=r+Math.imul(N,At)|0,n=(n=n+Math.imul(N,st)|0)+Math.imul(D,At)|0,c=c+Math.imul(D,st)|0,r=r+Math.imul(Q,ut)|0,n=(n=n+Math.imul(Q,ht)|0)+Math.imul(k,ut)|0,c=c+Math.imul(k,ht)|0,r=r+Math.imul(C,Bt)|0,n=(n=n+Math.imul(C,xt)|0)+Math.imul(w,Bt)|0,c=c+Math.imul(w,xt)|0,r=r+Math.imul(I,mt)|0,n=(n=n+Math.imul(I,Et)|0)+Math.imul(m,mt)|0,c=c+Math.imul(m,Et)|0,r=r+Math.imul(p,Ct)|0,n=(n=n+Math.imul(p,wt)|0)+Math.imul(B,Ct)|0,c=c+Math.imul(B,wt)|0;var Tt=(b+(r=r+Math.imul(h,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(h,Mt)|0)+Math.imul(l,Qt)|0))<<13)|0;b=((c=c+Math.imul(l,Mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(j,et),n=(n=Math.imul(j,tt))+Math.imul(Y,et)|0,c=Math.imul(Y,tt),r=r+Math.imul(O,rt)|0,n=(n=n+Math.imul(O,it)|0)+Math.imul(z,rt)|0,c=c+Math.imul(z,it)|0,r=r+Math.imul(P,ct)|0,n=(n=n+Math.imul(P,ot)|0)+Math.imul(q,ct)|0,c=c+Math.imul(q,ot)|0,r=r+Math.imul(L,At)|0,n=(n=n+Math.imul(L,st)|0)+Math.imul(T,At)|0,c=c+Math.imul(T,st)|0,r=r+Math.imul(N,ut)|0,n=(n=n+Math.imul(N,ht)|0)+Math.imul(D,ut)|0,c=c+Math.imul(D,ht)|0,r=r+Math.imul(Q,Bt)|0,n=(n=n+Math.imul(Q,xt)|0)+Math.imul(k,Bt)|0,c=c+Math.imul(k,xt)|0,r=r+Math.imul(C,mt)|0,n=(n=n+Math.imul(C,Et)|0)+Math.imul(w,mt)|0,c=c+Math.imul(w,Et)|0,r=r+Math.imul(I,Ct)|0,n=(n=n+Math.imul(I,wt)|0)+Math.imul(m,Ct)|0,c=c+Math.imul(m,wt)|0;var Ut=(b+(r=r+Math.imul(p,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(p,Mt)|0)+Math.imul(B,Qt)|0))<<13)|0;b=((c=c+Math.imul(B,Mt)|0)+(n>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,r=Math.imul(j,rt),n=(n=Math.imul(j,it))+Math.imul(Y,rt)|0,c=Math.imul(Y,it),r=r+Math.imul(O,ct)|0,n=(n=n+Math.imul(O,ot)|0)+Math.imul(z,ct)|0,c=c+Math.imul(z,ot)|0,r=r+Math.imul(P,At)|0,n=(n=n+Math.imul(P,st)|0)+Math.imul(q,At)|0,c=c+Math.imul(q,st)|0,r=r+Math.imul(L,ut)|0,n=(n=n+Math.imul(L,ht)|0)+Math.imul(T,ut)|0,c=c+Math.imul(T,ht)|0,r=r+Math.imul(N,Bt)|0,n=(n=n+Math.imul(N,xt)|0)+Math.imul(D,Bt)|0,c=c+Math.imul(D,xt)|0,r=r+Math.imul(Q,mt)|0,n=(n=n+Math.imul(Q,Et)|0)+Math.imul(k,mt)|0,c=c+Math.imul(k,Et)|0,r=r+Math.imul(C,Ct)|0,n=(n=n+Math.imul(C,wt)|0)+Math.imul(w,Ct)|0,c=c+Math.imul(w,wt)|0;var Pt=(b+(r=r+Math.imul(I,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(I,Mt)|0)+Math.imul(m,Qt)|0))<<13)|0;b=((c=c+Math.imul(m,Mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(j,ct),n=(n=Math.imul(j,ot))+Math.imul(Y,ct)|0,c=Math.imul(Y,ot),r=r+Math.imul(O,At)|0,n=(n=n+Math.imul(O,st)|0)+Math.imul(z,At)|0,c=c+Math.imul(z,st)|0,r=r+Math.imul(P,ut)|0,n=(n=n+Math.imul(P,ht)|0)+Math.imul(q,ut)|0,c=c+Math.imul(q,ht)|0,r=r+Math.imul(L,Bt)|0,n=(n=n+Math.imul(L,xt)|0)+Math.imul(T,Bt)|0,c=c+Math.imul(T,xt)|0,r=r+Math.imul(N,mt)|0,n=(n=n+Math.imul(N,Et)|0)+Math.imul(D,mt)|0,c=c+Math.imul(D,Et)|0,r=r+Math.imul(Q,Ct)|0,n=(n=n+Math.imul(Q,wt)|0)+Math.imul(k,Ct)|0,c=c+Math.imul(k,wt)|0;var qt=(b+(r=r+Math.imul(C,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(C,Mt)|0)+Math.imul(w,Qt)|0))<<13)|0;b=((c=c+Math.imul(w,Mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863,r=Math.imul(j,At),n=(n=Math.imul(j,st))+Math.imul(Y,At)|0,c=Math.imul(Y,st),r=r+Math.imul(O,ut)|0,n=(n=n+Math.imul(O,ht)|0)+Math.imul(z,ut)|0,c=c+Math.imul(z,ht)|0,r=r+Math.imul(P,Bt)|0,n=(n=n+Math.imul(P,xt)|0)+Math.imul(q,Bt)|0,c=c+Math.imul(q,xt)|0,r=r+Math.imul(L,mt)|0,n=(n=n+Math.imul(L,Et)|0)+Math.imul(T,mt)|0,c=c+Math.imul(T,Et)|0,r=r+Math.imul(N,Ct)|0,n=(n=n+Math.imul(N,wt)|0)+Math.imul(D,Ct)|0,c=c+Math.imul(D,wt)|0;var Ht=(b+(r=r+Math.imul(Q,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(Q,Mt)|0)+Math.imul(k,Qt)|0))<<13)|0;b=((c=c+Math.imul(k,Mt)|0)+(n>>>13)|0)+(Ht>>>26)|0,Ht&=67108863,r=Math.imul(j,ut),n=(n=Math.imul(j,ht))+Math.imul(Y,ut)|0,c=Math.imul(Y,ht),r=r+Math.imul(O,Bt)|0,n=(n=n+Math.imul(O,xt)|0)+Math.imul(z,Bt)|0,c=c+Math.imul(z,xt)|0,r=r+Math.imul(P,mt)|0,n=(n=n+Math.imul(P,Et)|0)+Math.imul(q,mt)|0,c=c+Math.imul(q,Et)|0,r=r+Math.imul(L,Ct)|0,n=(n=n+Math.imul(L,wt)|0)+Math.imul(T,Ct)|0,c=c+Math.imul(T,wt)|0;var Ot=(b+(r=r+Math.imul(N,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(N,Mt)|0)+Math.imul(D,Qt)|0))<<13)|0;b=((c=c+Math.imul(D,Mt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,r=Math.imul(j,Bt),n=(n=Math.imul(j,xt))+Math.imul(Y,Bt)|0,c=Math.imul(Y,xt),r=r+Math.imul(O,mt)|0,n=(n=n+Math.imul(O,Et)|0)+Math.imul(z,mt)|0,c=c+Math.imul(z,Et)|0,r=r+Math.imul(P,Ct)|0,n=(n=n+Math.imul(P,wt)|0)+Math.imul(q,Ct)|0,c=c+Math.imul(q,wt)|0;var zt=(b+(r=r+Math.imul(L,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(L,Mt)|0)+Math.imul(T,Qt)|0))<<13)|0;b=((c=c+Math.imul(T,Mt)|0)+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863,r=Math.imul(j,mt),n=(n=Math.imul(j,Et))+Math.imul(Y,mt)|0,c=Math.imul(Y,Et),r=r+Math.imul(O,Ct)|0,n=(n=n+Math.imul(O,wt)|0)+Math.imul(z,Ct)|0,c=c+Math.imul(z,wt)|0;var Kt=(b+(r=r+Math.imul(P,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(P,Mt)|0)+Math.imul(q,Qt)|0))<<13)|0;b=((c=c+Math.imul(q,Mt)|0)+(n>>>13)|0)+(Kt>>>26)|0,Kt&=67108863,r=Math.imul(j,Ct),n=(n=Math.imul(j,wt))+Math.imul(Y,Ct)|0,c=Math.imul(Y,wt);var Jt=(b+(r=r+Math.imul(O,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(O,Mt)|0)+Math.imul(z,Qt)|0))<<13)|0;b=((c=c+Math.imul(z,Mt)|0)+(n>>>13)|0)+(Jt>>>26)|0,Jt&=67108863;var jt=(b+(r=Math.imul(j,Qt))|0)+((8191&(n=(n=Math.imul(j,Mt))+Math.imul(Y,Qt)|0))<<13)|0;return b=((c=Math.imul(Y,Mt))+(n>>>13)|0)+(jt>>>26)|0,jt&=67108863,s[0]=kt,s[1]=_t,s[2]=St,s[3]=Nt,s[4]=Dt,s[5]=Rt,s[6]=Ft,s[7]=Gt,s[8]=Lt,s[9]=Tt,s[10]=Ut,s[11]=Pt,s[12]=qt,s[13]=Ht,s[14]=Ot,s[15]=zt,s[16]=Kt,s[17]=Jt,s[18]=jt,0!==b&&(s[19]=b,a.length++),a};function jumboMulTo(e,t,a){return(new FFTM).mulp(e,t,a)}function FFTM(e,t){this.x=e,this.y=t}Math.imul||(d=smallMulTo),BN.prototype.mulTo=function mulTo(e,t){var a,r=this.length+e.length;return a=10===this.length&&10===e.length?d(this,e,t):r<63?smallMulTo(this,e,t):r<1024?function bigMulTo(e,t,a){a.negative=t.negative^e.negative,a.length=e.length+t.length;for(var r=0,n=0,c=0;c>>26)|0)>>>26,o&=67108863}a.words[c]=d,r=o,o=n}return 0!==r?a.words[c]=r:a.length--,a.strip()}(this,e,t):jumboMulTo(this,e,t),a},FFTM.prototype.makeRBT=function makeRBT(e){for(var t=new Array(e),a=BN.prototype._countBits(e)-1,r=0;r>=1;return r},FFTM.prototype.permute=function permute(e,t,a,r,n,c){for(var o=0;o>>=1)n++;return 1<>>=13,a[2*c+1]=8191&n,n>>>=13;for(c=2*t;c>=26,t+=r/67108864|0,t+=n>>>26,this.words[a]=67108863&n}return 0!==t&&(this.words[a]=t,this.length++),this},BN.prototype.muln=function muln(e){return this.clone().imuln(e)},BN.prototype.sqr=function sqr(){return this.mul(this)},BN.prototype.isqr=function isqr(){return this.imul(this.clone())},BN.prototype.pow=function pow(e){var t=function toBitArray(e){for(var t=new Array(e.bitLength()),a=0;a>>n}return t}(e);if(0===t.length)return new BN(1);for(var a=this,r=0;r=0);var t,a=e%26,r=(e-a)/26,n=67108863>>>26-a<<26-a;if(0!==a){var c=0;for(t=0;t>>26-a}c&&(this.words[t]=c,this.length++)}if(0!==r){for(t=this.length-1;t>=0;t--)this.words[t+r]=this.words[t];for(t=0;t=0),r=t?(t-t%26)/26:0;var n=e%26,c=Math.min((e-n)/26,this.length),o=67108863^67108863>>>n<c)for(this.length-=c,s=0;s=0&&(0!==b||s>=r);s--){var u=0|this.words[s];this.words[s]=b<<26-n|u>>>n,b=u&o}return d&&0!==b&&(d.words[d.length++]=b),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},BN.prototype.ishrn=function ishrn(e,t,a){return assert(0===this.negative),this.iushrn(e,t,a)},BN.prototype.shln=function shln(e){return this.clone().ishln(e)},BN.prototype.ushln=function ushln(e){return this.clone().iushln(e)},BN.prototype.shrn=function shrn(e){return this.clone().ishrn(e)},BN.prototype.ushrn=function ushrn(e){return this.clone().iushrn(e)},BN.prototype.testn=function testn(e){assert("number"==typeof e&&e>=0);var t=e%26,a=(e-t)/26,r=1<=0);var t=e%26,a=(e-t)/26;if(assert(0===this.negative,"imaskn works only with positive numbers"),this.length<=a)return this;if(0!==t&&a++,this.length=Math.min(a,this.length),0!==t){var r=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},BN.prototype.isubn=function isubn(e){if(assert("number"==typeof e),assert(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(d/67108864|0),this.words[r+a]=67108863&n}for(;r>26,this.words[r+a]=67108863&n;if(0===o)return this.strip();for(assert(-1===o),o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},BN.prototype._wordDiv=function _wordDiv(e,t){var a=(this.length,e.length),r=this.clone(),n=e,c=0|n.words[n.length-1];0!==(a=26-this._countBits(c))&&(n=n.ushln(a),r.iushln(a),c=0|n.words[n.length-1]);var o,d=r.length-n.length;if("mod"!==t){(o=new BN(null)).length=d+1,o.words=new Array(o.length);for(var s=0;s=0;u--){var h=67108864*(0|r.words[n.length+u])+(0|r.words[n.length+u-1]);for(h=Math.min(h/c|0,67108863),r._ishlnsubmul(n,h,u);0!==r.negative;)h--,r.negative=0,r._ishlnsubmul(n,1,u),r.isZero()||(r.negative^=1);o&&(o.words[u]=h)}return o&&o.strip(),r.strip(),"div"!==t&&0!==a&&r.iushrn(a),{div:o||null,mod:r}},BN.prototype.divmod=function divmod(e,t,a){return assert(!e.isZero()),this.isZero()?{div:new BN(0),mod:new BN(0)}:0!==this.negative&&0===e.negative?(c=this.neg().divmod(e,t),"mod"!==t&&(r=c.div.neg()),"div"!==t&&(n=c.mod.neg(),a&&0!==n.negative&&n.iadd(e)),{div:r,mod:n}):0===this.negative&&0!==e.negative?(c=this.divmod(e.neg(),t),"mod"!==t&&(r=c.div.neg()),{div:r,mod:c.mod}):0!=(this.negative&e.negative)?(c=this.neg().divmod(e.neg(),t),"div"!==t&&(n=c.mod.neg(),a&&0!==n.negative&&n.isub(e)),{div:c.div,mod:n}):e.length>this.length||this.cmp(e)<0?{div:new BN(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new BN(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new BN(this.modn(e.words[0]))}:this._wordDiv(e,t);var r,n,c},BN.prototype.div=function div(e){return this.divmod(e,"div",!1).div},BN.prototype.mod=function mod(e){return this.divmod(e,"mod",!1).mod},BN.prototype.umod=function umod(e){return this.divmod(e,"mod",!0).mod},BN.prototype.divRound=function divRound(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var a=0!==t.div.negative?t.mod.isub(e):t.mod,r=e.ushrn(1),n=e.andln(1),c=a.cmp(r);return c<0||1===n&&0===c?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},BN.prototype.modn=function modn(e){assert(e<=67108863);for(var t=(1<<26)%e,a=0,r=this.length-1;r>=0;r--)a=(t*a+(0|this.words[r]))%e;return a},BN.prototype.idivn=function idivn(e){assert(e<=67108863);for(var t=0,a=this.length-1;a>=0;a--){var r=(0|this.words[a])+67108864*t;this.words[a]=r/e|0,t=r%e}return this.strip()},BN.prototype.divn=function divn(e){return this.clone().idivn(e)},BN.prototype.egcd=function egcd(e){assert(0===e.negative),assert(!e.isZero());var t=this,a=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var r=new BN(1),n=new BN(0),c=new BN(0),o=new BN(1),d=0;t.isEven()&&a.isEven();)t.iushrn(1),a.iushrn(1),++d;for(var s=a.clone(),b=t.clone();!t.isZero();){for(var u=0,h=1;0==(t.words[0]&h)&&u<26;++u,h<<=1);if(u>0)for(t.iushrn(u);u-- >0;)(r.isOdd()||n.isOdd())&&(r.iadd(s),n.isub(b)),r.iushrn(1),n.iushrn(1);for(var l=0,g=1;0==(a.words[0]&g)&&l<26;++l,g<<=1);if(l>0)for(a.iushrn(l);l-- >0;)(c.isOdd()||o.isOdd())&&(c.iadd(s),o.isub(b)),c.iushrn(1),o.iushrn(1);t.cmp(a)>=0?(t.isub(a),r.isub(c),n.isub(o)):(a.isub(t),c.isub(r),o.isub(n))}return{a:c,b:o,gcd:a.iushln(d)}},BN.prototype._invmp=function _invmp(e){assert(0===e.negative),assert(!e.isZero());var t=this,a=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var r,n=new BN(1),c=new BN(0),o=a.clone();t.cmpn(1)>0&&a.cmpn(1)>0;){for(var d=0,s=1;0==(t.words[0]&s)&&d<26;++d,s<<=1);if(d>0)for(t.iushrn(d);d-- >0;)n.isOdd()&&n.iadd(o),n.iushrn(1);for(var b=0,u=1;0==(a.words[0]&u)&&b<26;++b,u<<=1);if(b>0)for(a.iushrn(b);b-- >0;)c.isOdd()&&c.iadd(o),c.iushrn(1);t.cmp(a)>=0?(t.isub(a),n.isub(c)):(a.isub(t),c.isub(n))}return(r=0===t.cmpn(1)?n:c).cmpn(0)<0&&r.iadd(e),r},BN.prototype.gcd=function gcd(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),a=e.clone();t.negative=0,a.negative=0;for(var r=0;t.isEven()&&a.isEven();r++)t.iushrn(1),a.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;a.isEven();)a.iushrn(1);var n=t.cmp(a);if(n<0){var c=t;t=a,a=c}else if(0===n||0===a.cmpn(1))break;t.isub(a)}return a.iushln(r)},BN.prototype.invm=function invm(e){return this.egcd(e).a.umod(e)},BN.prototype.isEven=function isEven(){return 0==(1&this.words[0])},BN.prototype.isOdd=function isOdd(){return 1==(1&this.words[0])},BN.prototype.andln=function andln(e){return this.words[0]&e},BN.prototype.bincn=function bincn(e){assert("number"==typeof e);var t=e%26,a=(e-t)/26,r=1<>>26,o&=67108863,this.words[c]=o}return 0!==n&&(this.words[c]=n,this.length++),this},BN.prototype.isZero=function isZero(){return 1===this.length&&0===this.words[0]},BN.prototype.cmpn=function cmpn(e){var t,a=e<0;if(0!==this.negative&&!a)return-1;if(0===this.negative&&a)return 1;if(this.strip(),this.length>1)t=1;else{a&&(e=-e),assert(e<=67108863,"Number is too big");var r=0|this.words[0];t=r===e?0:re.length)return 1;if(this.length=0;a--){var r=0|this.words[a],n=0|e.words[a];if(r!==n){rn&&(t=1);break}}return t},BN.prototype.gtn=function gtn(e){return 1===this.cmpn(e)},BN.prototype.gt=function gt(e){return 1===this.cmp(e)},BN.prototype.gten=function gten(e){return this.cmpn(e)>=0},BN.prototype.gte=function gte(e){return this.cmp(e)>=0},BN.prototype.ltn=function ltn(e){return-1===this.cmpn(e)},BN.prototype.lt=function lt(e){return-1===this.cmp(e)},BN.prototype.lten=function lten(e){return this.cmpn(e)<=0},BN.prototype.lte=function lte(e){return this.cmp(e)<=0},BN.prototype.eqn=function eqn(e){return 0===this.cmpn(e)},BN.prototype.eq=function eq(e){return 0===this.cmp(e)},BN.red=function red(e){return new Red(e)},BN.prototype.toRed=function toRed(e){return assert(!this.red,"Already a number in reduction context"),assert(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},BN.prototype.fromRed=function fromRed(){return assert(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},BN.prototype._forceRed=function _forceRed(e){return this.red=e,this},BN.prototype.forceRed=function forceRed(e){return assert(!this.red,"Already a number in reduction context"),this._forceRed(e)},BN.prototype.redAdd=function redAdd(e){return assert(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},BN.prototype.redIAdd=function redIAdd(e){return assert(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},BN.prototype.redSub=function redSub(e){return assert(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},BN.prototype.redISub=function redISub(e){return assert(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},BN.prototype.redShl=function redShl(e){return assert(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},BN.prototype.redMul=function redMul(e){return assert(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},BN.prototype.redIMul=function redIMul(e){return assert(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},BN.prototype.redSqr=function redSqr(){return assert(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},BN.prototype.redISqr=function redISqr(){return assert(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},BN.prototype.redSqrt=function redSqrt(){return assert(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},BN.prototype.redInvm=function redInvm(){return assert(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},BN.prototype.redNeg=function redNeg(){return assert(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},BN.prototype.redPow=function redPow(e){return assert(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var s={k256:null,p224:null,p192:null,p25519:null};function MPrime(e,t){this.name=e,this.p=new BN(t,16),this.n=this.p.bitLength(),this.k=new BN(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function K256(){MPrime.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function P224(){MPrime.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function P192(){MPrime.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function P25519(){MPrime.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function Red(e){if("string"==typeof e){var t=BN._prime(e);this.m=t.p,this.prime=t}else assert(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function Mont(e){Red.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new BN(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)}MPrime.prototype._tmp=function _tmp(){var e=new BN(null);return e.words=new Array(Math.ceil(this.n/13)),e},MPrime.prototype.ireduce=function ireduce(e){var t,a=e;do{this.split(a,this.tmp),t=(a=(a=this.imulK(a)).iadd(this.tmp)).bitLength()}while(t>this.n);var r=t0?a.isub(this.p):void 0!==a.strip?a.strip():a._strip(),a},MPrime.prototype.split=function split(e,t){e.iushrn(this.n,0,t)},MPrime.prototype.imulK=function imulK(e){return e.imul(this.k)},inherits(K256,MPrime),K256.prototype.split=function split(e,t){for(var a=4194303,r=Math.min(e.length,9),n=0;n>>22,c=o}c>>>=22,e.words[n-10]=c,0===c&&e.length>10?e.length-=10:e.length-=9},K256.prototype.imulK=function imulK(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,a=0;a>>=26,e.words[a]=n,t=r}return 0!==t&&(e.words[e.length++]=t),e},BN._prime=function prime(e){if(s[e])return s[e];var prime;if("k256"===e)prime=new K256;else if("p224"===e)prime=new P224;else if("p192"===e)prime=new P192;else{if("p25519"!==e)throw new Error("Unknown prime "+e);prime=new P25519}return s[e]=prime,prime},Red.prototype._verify1=function _verify1(e){assert(0===e.negative,"red works only with positives"),assert(e.red,"red works only with red numbers")},Red.prototype._verify2=function _verify2(e,t){assert(0==(e.negative|t.negative),"red works only with positives"),assert(e.red&&e.red===t.red,"red works only with red numbers")},Red.prototype.imod=function imod(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},Red.prototype.neg=function neg(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},Red.prototype.add=function add(e,t){this._verify2(e,t);var a=e.add(t);return a.cmp(this.m)>=0&&a.isub(this.m),a._forceRed(this)},Red.prototype.iadd=function iadd(e,t){this._verify2(e,t);var a=e.iadd(t);return a.cmp(this.m)>=0&&a.isub(this.m),a},Red.prototype.sub=function sub(e,t){this._verify2(e,t);var a=e.sub(t);return a.cmpn(0)<0&&a.iadd(this.m),a._forceRed(this)},Red.prototype.isub=function isub(e,t){this._verify2(e,t);var a=e.isub(t);return a.cmpn(0)<0&&a.iadd(this.m),a},Red.prototype.shl=function shl(e,t){return this._verify1(e),this.imod(e.ushln(t))},Red.prototype.imul=function imul(e,t){return this._verify2(e,t),this.imod(e.imul(t))},Red.prototype.mul=function mul(e,t){return this._verify2(e,t),this.imod(e.mul(t))},Red.prototype.isqr=function isqr(e){return this.imul(e,e.clone())},Red.prototype.sqr=function sqr(e){return this.mul(e,e)},Red.prototype.sqrt=function sqrt(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(assert(t%2==1),3===t){var a=this.m.add(new BN(1)).iushrn(2);return this.pow(e,a)}for(var r=this.m.subn(1),n=0;!r.isZero()&&0===r.andln(1);)n++,r.iushrn(1);assert(!r.isZero());var c=new BN(1).toRed(this),o=c.redNeg(),d=this.m.subn(1).iushrn(1),s=this.m.bitLength();for(s=new BN(2*s*s).toRed(this);0!==this.pow(s,d).cmp(o);)s.redIAdd(o);for(var b=this.pow(s,r),u=this.pow(e,r.addn(1).iushrn(1)),h=this.pow(e,r),l=n;0!==h.cmp(c);){for(var g=h,p=0;0!==g.cmp(c);p++)g=g.redSqr();assert(p=0;r--){for(var s=t.words[r],b=d-1;b>=0;b--){var u=s>>b&1;n!==a[0]&&(n=this.sqr(n)),0!==u||0!==c?(c<<=1,c|=u,(4===++o||0===r&&0===b)&&(n=this.mul(n,a[c]),o=0,c=0)):o=0}d=26}return n},Red.prototype.convertTo=function convertTo(e){var t=e.umod(this.m);return t===e?t.clone():t},Red.prototype.convertFrom=function convertFrom(e){var t=e.clone();return t.red=null,t},BN.mont=function mont(e){return new Mont(e)},inherits(Mont,Red),Mont.prototype.convertTo=function convertTo(e){return this.imod(e.ushln(this.shift))},Mont.prototype.convertFrom=function convertFrom(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},Mont.prototype.imul=function imul(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var a=e.imul(t),r=a.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=a.isub(r).iushrn(this.shift),c=n;return n.cmp(this.m)>=0?c=n.isub(this.m):n.cmpn(0)<0&&(c=n.iadd(this.m)),c._forceRed(this)},Mont.prototype.mul=function mul(e,t){if(e.isZero()||t.isZero())return new BN(0)._forceRed(this);var a=e.mul(t),r=a.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=a.isub(r).iushrn(this.shift),c=n;return n.cmp(this.m)>=0?c=n.isub(this.m):n.cmpn(0)<0&&(c=n.iadd(this.m)),c._forceRed(this)},Mont.prototype.invm=function invm(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e=a.nmd(e),this)},(e,t,a)=>{"use strict";var r=a(39),n=a(6);function isSurrogatePair(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function htonl(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function zero2(e){return 1===e.length?"0"+e:e}function zero8(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}t.inherits=n,t.toArray=function toArray(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var a=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n>6|192,a[r++]=63&c|128):isSurrogatePair(e,n)?(c=65536+((1023&c)<<10)+(1023&e.charCodeAt(++n)),a[r++]=c>>18|240,a[r++]=c>>12&63|128,a[r++]=c>>6&63|128,a[r++]=63&c|128):(a[r++]=c>>12|224,a[r++]=c>>6&63|128,a[r++]=63&c|128)}else for(n=0;n>>0}return o},t.split32=function split32(e,t){for(var a=new Array(4*e.length),r=0,n=0;r>>24,a[n+1]=c>>>16&255,a[n+2]=c>>>8&255,a[n+3]=255&c):(a[n+3]=c>>>24,a[n+2]=c>>>16&255,a[n+1]=c>>>8&255,a[n]=255&c)}return a},t.rotr32=function rotr32(e,t){return e>>>t|e<<32-t},t.rotl32=function rotl32(e,t){return e<>>32-t},t.sum32=function sum32(e,t){return e+t>>>0},t.sum32_3=function sum32_3(e,t,a){return e+t+a>>>0},t.sum32_4=function sum32_4(e,t,a,r){return e+t+a+r>>>0},t.sum32_5=function sum32_5(e,t,a,r,n){return e+t+a+r+n>>>0},t.sum64=function sum64(e,t,a,r){var n=e[t],c=r+e[t+1]>>>0,o=(c>>0,e[t+1]=c},t.sum64_hi=function sum64_hi(e,t,a,r){return(t+r>>>0>>0},t.sum64_lo=function sum64_lo(e,t,a,r){return t+r>>>0},t.sum64_4_hi=function sum64_4_hi(e,t,a,r,n,c,o,d){var s=0,b=t;return s+=(b=b+r>>>0)>>0)>>0)>>0},t.sum64_4_lo=function sum64_4_lo(e,t,a,r,n,c,o,d){return t+r+c+d>>>0},t.sum64_5_hi=function sum64_5_hi(e,t,a,r,n,c,o,d,s,b){var u=0,h=t;return u+=(h=h+r>>>0)>>0)>>0)>>0)>>0},t.sum64_5_lo=function sum64_5_lo(e,t,a,r,n,c,o,d,s,b){return t+r+c+d+b>>>0},t.rotr64_hi=function rotr64_hi(e,t,a){return(t<<32-a|e>>>a)>>>0},t.rotr64_lo=function rotr64_lo(e,t,a){return(e<<32-a|t>>>a)>>>0},t.shr64_hi=function shr64_hi(e,t,a){return e>>>a},t.shr64_lo=function shr64_lo(e,t,a){return(e<<32-a|t>>>a)>>>0}},(e,t,a)=>{"use strict";var r=a(79),n=a(15);function isSurrogatePair(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function htonl(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function zero2(e){return 1===e.length?"0"+e:e}function zero8(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}t.inherits=n,t.toArray=function toArray(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var a=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n>6|192,a[r++]=63&c|128):isSurrogatePair(e,n)?(c=65536+((1023&c)<<10)+(1023&e.charCodeAt(++n)),a[r++]=c>>18|240,a[r++]=c>>12&63|128,a[r++]=c>>6&63|128,a[r++]=63&c|128):(a[r++]=c>>12|224,a[r++]=c>>6&63|128,a[r++]=63&c|128)}else for(n=0;n>>0}return o},t.split32=function split32(e,t){for(var a=new Array(4*e.length),r=0,n=0;r>>24,a[n+1]=c>>>16&255,a[n+2]=c>>>8&255,a[n+3]=255&c):(a[n+3]=c>>>24,a[n+2]=c>>>16&255,a[n+1]=c>>>8&255,a[n]=255&c)}return a},t.rotr32=function rotr32(e,t){return e>>>t|e<<32-t},t.rotl32=function rotl32(e,t){return e<>>32-t},t.sum32=function sum32(e,t){return e+t>>>0},t.sum32_3=function sum32_3(e,t,a){return e+t+a>>>0},t.sum32_4=function sum32_4(e,t,a,r){return e+t+a+r>>>0},t.sum32_5=function sum32_5(e,t,a,r,n){return e+t+a+r+n>>>0},t.sum64=function sum64(e,t,a,r){var n=e[t],c=r+e[t+1]>>>0,o=(c>>0,e[t+1]=c},t.sum64_hi=function sum64_hi(e,t,a,r){return(t+r>>>0>>0},t.sum64_lo=function sum64_lo(e,t,a,r){return t+r>>>0},t.sum64_4_hi=function sum64_4_hi(e,t,a,r,n,c,o,d){var s=0,b=t;return s+=(b=b+r>>>0)>>0)>>0)>>0},t.sum64_4_lo=function sum64_4_lo(e,t,a,r,n,c,o,d){return t+r+c+d>>>0},t.sum64_5_hi=function sum64_5_hi(e,t,a,r,n,c,o,d,s,b){var u=0,h=t;return u+=(h=h+r>>>0)>>0)>>0)>>0)>>0},t.sum64_5_lo=function sum64_5_lo(e,t,a,r,n,c,o,d,s,b){return t+r+c+d+b>>>0},t.rotr64_hi=function rotr64_hi(e,t,a){return(t<<32-a|e>>>a)>>>0},t.rotr64_lo=function rotr64_lo(e,t,a){return(e<<32-a|t>>>a)>>>0},t.shr64_hi=function shr64_hi(e,t,a){return e>>>a},t.shr64_lo=function shr64_lo(e,t,a){return(e<<32-a|t>>>a)>>>0}},(e,t,a)=>{"use strict";var r=a(80),n=a(16);function isSurrogatePair(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function htonl(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function zero2(e){return 1===e.length?"0"+e:e}function zero8(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}t.inherits=n,t.toArray=function toArray(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var a=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n>6|192,a[r++]=63&c|128):isSurrogatePair(e,n)?(c=65536+((1023&c)<<10)+(1023&e.charCodeAt(++n)),a[r++]=c>>18|240,a[r++]=c>>12&63|128,a[r++]=c>>6&63|128,a[r++]=63&c|128):(a[r++]=c>>12|224,a[r++]=c>>6&63|128,a[r++]=63&c|128)}else for(n=0;n>>0}return o},t.split32=function split32(e,t){for(var a=new Array(4*e.length),r=0,n=0;r>>24,a[n+1]=c>>>16&255,a[n+2]=c>>>8&255,a[n+3]=255&c):(a[n+3]=c>>>24,a[n+2]=c>>>16&255,a[n+1]=c>>>8&255,a[n]=255&c)}return a},t.rotr32=function rotr32(e,t){return e>>>t|e<<32-t},t.rotl32=function rotl32(e,t){return e<>>32-t},t.sum32=function sum32(e,t){return e+t>>>0},t.sum32_3=function sum32_3(e,t,a){return e+t+a>>>0},t.sum32_4=function sum32_4(e,t,a,r){return e+t+a+r>>>0},t.sum32_5=function sum32_5(e,t,a,r,n){return e+t+a+r+n>>>0},t.sum64=function sum64(e,t,a,r){var n=e[t],c=r+e[t+1]>>>0,o=(c>>0,e[t+1]=c},t.sum64_hi=function sum64_hi(e,t,a,r){return(t+r>>>0>>0},t.sum64_lo=function sum64_lo(e,t,a,r){return t+r>>>0},t.sum64_4_hi=function sum64_4_hi(e,t,a,r,n,c,o,d){var s=0,b=t;return s+=(b=b+r>>>0)>>0)>>0)>>0},t.sum64_4_lo=function sum64_4_lo(e,t,a,r,n,c,o,d){return t+r+c+d>>>0},t.sum64_5_hi=function sum64_5_hi(e,t,a,r,n,c,o,d,s,b){var u=0,h=t;return u+=(h=h+r>>>0)>>0)>>0)>>0)>>0},t.sum64_5_lo=function sum64_5_lo(e,t,a,r,n,c,o,d,s,b){return t+r+c+d+b>>>0},t.rotr64_hi=function rotr64_hi(e,t,a){return(t<<32-a|e>>>a)>>>0},t.rotr64_lo=function rotr64_lo(e,t,a){return(e<<32-a|t>>>a)>>>0},t.shr64_hi=function shr64_hi(e,t,a){return e>>>a},t.shr64_lo=function shr64_lo(e,t,a){return(e<<32-a|t>>>a)>>>0}},(e,t,a)=>{"use strict";var r=a(81),n=a(141);function isSurrogatePair(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function htonl(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function zero2(e){return 1===e.length?"0"+e:e}function zero8(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}t.inherits=n,t.toArray=function toArray(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var a=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n>6|192,a[r++]=63&c|128):isSurrogatePair(e,n)?(c=65536+((1023&c)<<10)+(1023&e.charCodeAt(++n)),a[r++]=c>>18|240,a[r++]=c>>12&63|128,a[r++]=c>>6&63|128,a[r++]=63&c|128):(a[r++]=c>>12|224,a[r++]=c>>6&63|128,a[r++]=63&c|128)}else for(n=0;n>>0}return o},t.split32=function split32(e,t){for(var a=new Array(4*e.length),r=0,n=0;r>>24,a[n+1]=c>>>16&255,a[n+2]=c>>>8&255,a[n+3]=255&c):(a[n+3]=c>>>24,a[n+2]=c>>>16&255,a[n+1]=c>>>8&255,a[n]=255&c)}return a},t.rotr32=function rotr32(e,t){return e>>>t|e<<32-t},t.rotl32=function rotl32(e,t){return e<>>32-t},t.sum32=function sum32(e,t){return e+t>>>0},t.sum32_3=function sum32_3(e,t,a){return e+t+a>>>0},t.sum32_4=function sum32_4(e,t,a,r){return e+t+a+r>>>0},t.sum32_5=function sum32_5(e,t,a,r,n){return e+t+a+r+n>>>0},t.sum64=function sum64(e,t,a,r){var n=e[t],c=r+e[t+1]>>>0,o=(c>>0,e[t+1]=c},t.sum64_hi=function sum64_hi(e,t,a,r){return(t+r>>>0>>0},t.sum64_lo=function sum64_lo(e,t,a,r){return t+r>>>0},t.sum64_4_hi=function sum64_4_hi(e,t,a,r,n,c,o,d){var s=0,b=t;return s+=(b=b+r>>>0)>>0)>>0)>>0},t.sum64_4_lo=function sum64_4_lo(e,t,a,r,n,c,o,d){return t+r+c+d>>>0},t.sum64_5_hi=function sum64_5_hi(e,t,a,r,n,c,o,d,s,b){var u=0,h=t;return u+=(h=h+r>>>0)>>0)>>0)>>0)>>0},t.sum64_5_lo=function sum64_5_lo(e,t,a,r,n,c,o,d,s,b){return t+r+c+d+b>>>0},t.rotr64_hi=function rotr64_hi(e,t,a){return(t<<32-a|e>>>a)>>>0},t.rotr64_lo=function rotr64_lo(e,t,a){return(e<<32-a|t>>>a)>>>0},t.shr64_hi=function shr64_hi(e,t,a){return e>>>a},t.shr64_lo=function shr64_lo(e,t,a){return(e<<32-a|t>>>a)>>>0}},(e,t,a)=>{"use strict";var r=a(82),n=a(17);function isSurrogatePair(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function htonl(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function zero2(e){return 1===e.length?"0"+e:e}function zero8(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}t.inherits=n,t.toArray=function toArray(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var a=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n>6|192,a[r++]=63&c|128):isSurrogatePair(e,n)?(c=65536+((1023&c)<<10)+(1023&e.charCodeAt(++n)),a[r++]=c>>18|240,a[r++]=c>>12&63|128,a[r++]=c>>6&63|128,a[r++]=63&c|128):(a[r++]=c>>12|224,a[r++]=c>>6&63|128,a[r++]=63&c|128)}else for(n=0;n>>0}return o},t.split32=function split32(e,t){for(var a=new Array(4*e.length),r=0,n=0;r>>24,a[n+1]=c>>>16&255,a[n+2]=c>>>8&255,a[n+3]=255&c):(a[n+3]=c>>>24,a[n+2]=c>>>16&255,a[n+1]=c>>>8&255,a[n]=255&c)}return a},t.rotr32=function rotr32(e,t){return e>>>t|e<<32-t},t.rotl32=function rotl32(e,t){return e<>>32-t},t.sum32=function sum32(e,t){return e+t>>>0},t.sum32_3=function sum32_3(e,t,a){return e+t+a>>>0},t.sum32_4=function sum32_4(e,t,a,r){return e+t+a+r>>>0},t.sum32_5=function sum32_5(e,t,a,r,n){return e+t+a+r+n>>>0},t.sum64=function sum64(e,t,a,r){var n=e[t],c=r+e[t+1]>>>0,o=(c>>0,e[t+1]=c},t.sum64_hi=function sum64_hi(e,t,a,r){return(t+r>>>0>>0},t.sum64_lo=function sum64_lo(e,t,a,r){return t+r>>>0},t.sum64_4_hi=function sum64_4_hi(e,t,a,r,n,c,o,d){var s=0,b=t;return s+=(b=b+r>>>0)>>0)>>0)>>0},t.sum64_4_lo=function sum64_4_lo(e,t,a,r,n,c,o,d){return t+r+c+d>>>0},t.sum64_5_hi=function sum64_5_hi(e,t,a,r,n,c,o,d,s,b){var u=0,h=t;return u+=(h=h+r>>>0)>>0)>>0)>>0)>>0},t.sum64_5_lo=function sum64_5_lo(e,t,a,r,n,c,o,d,s,b){return t+r+c+d+b>>>0},t.rotr64_hi=function rotr64_hi(e,t,a){return(t<<32-a|e>>>a)>>>0},t.rotr64_lo=function rotr64_lo(e,t,a){return(e<<32-a|t>>>a)>>>0},t.shr64_hi=function shr64_hi(e,t,a){return e>>>a},t.shr64_lo=function shr64_lo(e,t,a){return(e<<32-a|t>>>a)>>>0}},(e,t,a)=>{"use strict";var r=a(83),n=a(9);function isSurrogatePair(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function htonl(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function zero2(e){return 1===e.length?"0"+e:e}function zero8(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}t.inherits=n,t.toArray=function toArray(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var a=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n>6|192,a[r++]=63&c|128):isSurrogatePair(e,n)?(c=65536+((1023&c)<<10)+(1023&e.charCodeAt(++n)),a[r++]=c>>18|240,a[r++]=c>>12&63|128,a[r++]=c>>6&63|128,a[r++]=63&c|128):(a[r++]=c>>12|224,a[r++]=c>>6&63|128,a[r++]=63&c|128)}else for(n=0;n>>0}return o},t.split32=function split32(e,t){for(var a=new Array(4*e.length),r=0,n=0;r>>24,a[n+1]=c>>>16&255,a[n+2]=c>>>8&255,a[n+3]=255&c):(a[n+3]=c>>>24,a[n+2]=c>>>16&255,a[n+1]=c>>>8&255,a[n]=255&c)}return a},t.rotr32=function rotr32(e,t){return e>>>t|e<<32-t},t.rotl32=function rotl32(e,t){return e<>>32-t},t.sum32=function sum32(e,t){return e+t>>>0},t.sum32_3=function sum32_3(e,t,a){return e+t+a>>>0},t.sum32_4=function sum32_4(e,t,a,r){return e+t+a+r>>>0},t.sum32_5=function sum32_5(e,t,a,r,n){return e+t+a+r+n>>>0},t.sum64=function sum64(e,t,a,r){var n=e[t],c=r+e[t+1]>>>0,o=(c>>0,e[t+1]=c},t.sum64_hi=function sum64_hi(e,t,a,r){return(t+r>>>0>>0},t.sum64_lo=function sum64_lo(e,t,a,r){return t+r>>>0},t.sum64_4_hi=function sum64_4_hi(e,t,a,r,n,c,o,d){var s=0,b=t;return s+=(b=b+r>>>0)>>0)>>0)>>0},t.sum64_4_lo=function sum64_4_lo(e,t,a,r,n,c,o,d){return t+r+c+d>>>0},t.sum64_5_hi=function sum64_5_hi(e,t,a,r,n,c,o,d,s,b){var u=0,h=t;return u+=(h=h+r>>>0)>>0)>>0)>>0)>>0},t.sum64_5_lo=function sum64_5_lo(e,t,a,r,n,c,o,d,s,b){return t+r+c+d+b>>>0},t.rotr64_hi=function rotr64_hi(e,t,a){return(t<<32-a|e>>>a)>>>0},t.rotr64_lo=function rotr64_lo(e,t,a){return(e<<32-a|t>>>a)>>>0},t.shr64_hi=function shr64_hi(e,t,a){return e>>>a},t.shr64_lo=function shr64_lo(e,t,a){return(e<<32-a|t>>>a)>>>0}},(e,t,a)=>{var r=a(29);e.exports=function(e){return"object"==typeof e?null!==e:r(e)}},(e,t,a)=>{var r=a(33),n=a(269),c=r({}.hasOwnProperty);e.exports=Object.hasOwn||function hasOwn(e,t){return c(n(e),t)}},(e,t,a)=>{var r=a(7).Buffer,n=a(26).Transform,c=a(642).a;function CipherBase(e){n.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}a(6)(CipherBase,n),CipherBase.prototype.update=function(e,t,a){"string"==typeof e&&(e=r.from(e,t));var n=this._update(e);return this.hashMode?this:(a&&(n=this._toString(n,a)),n)},CipherBase.prototype.setAutoPadding=function(){},CipherBase.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},CipherBase.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},CipherBase.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},CipherBase.prototype._transform=function(e,t,a){var r;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){r=e}finally{a(r)}},CipherBase.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},CipherBase.prototype._finalOrDigest=function(e){var t=this.__final()||r.alloc(0);return e&&(t=this._toString(t,e,!0)),t},CipherBase.prototype._toString=function(e,t,a){if(this._decoder||(this._decoder=new c(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var r=this._decoder.write(e);return a&&(r+=this._decoder.end()),r},e.exports=CipherBase},(e,t,a)=>{var r=a(11),n=a(49),c=a(499),o=a(501),d=a(85),s=a(263),b=r.TypeError,u=Object.defineProperty,h=Object.getOwnPropertyDescriptor,l="enumerable",g="configurable",p="writable";t.f=n?o?function defineProperty(e,t,a){if(d(e),t=s(t),d(a),"function"==typeof e&&"prototype"===t&&"value"in a&&p in a&&!a.writable){var r=h(e,t);r&&r.writable&&(e[t]=a.value,a={configurable:g in a?a.configurable:r.configurable,enumerable:l in a?a.enumerable:r.enumerable,writable:!1})}return u(e,t,a)}:u:function defineProperty(e,t,a){if(d(e),t=s(t),d(a),c)try{return u(e,t,a)}catch(e){}if("get"in a||"set"in a)throw b("Accessors not supported");return"value"in a&&(e[t]=a.value),e}},(e,t,a)=>{"use strict";var r=a(0).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.BLS12_381_ToFp2Point=t.BLS12_381_ToFpPoint=t.BLS12_381_ToFrPoint=t.BLS12_381_FromG2Point=t.BLS12_381_ToG2Point=t.BLS12_381_FromG1Point=t.BLS12_381_ToG1Point=void 0;var n=a(1),c=a(21),o=new n.BN("1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab",16);function BLS12_381_ToFp2Point(e,t,a){if(new n.BN(e).gte(o))throw new c.VmError(c.ERROR.BLS_12_381_FP_NOT_IN_FIELD);if(new n.BN(t).gte(o))throw new c.VmError(c.ERROR.BLS_12_381_FP_NOT_IN_FIELD);var r=new a.Fp,d=new a.Fp,s=new a.Fp2;return r.setStr(e.slice(16).toString("hex"),16),d.setStr(t.slice(16).toString("hex"),16),s.set_a(r),s.set_b(d),s}t.BLS12_381_ToG1Point=function BLS12_381_ToG1Point(e,t){var a=e.slice(16,64).toString("hex"),r=e.slice(80,128).toString("hex"),n="0".repeat(96);if(a==r&&a==n)return new t.G1;var o=new t.Fp,d=new t.Fp,s=new t.Fp;o.setStr(a,16),d.setStr(r,16),s.setStr("1",16);var b=new t.G1;if(b.setX(o),b.setY(d),b.setZ(s),!b.isValidOrder())throw new c.VmError(c.ERROR.BLS_12_381_POINT_NOT_ON_CURVE);if(!b.isValid())throw new c.VmError(c.ERROR.BLS_12_381_POINT_NOT_ON_CURVE);return b},t.BLS12_381_FromG1Point=function BLS12_381_FromG1Point(e){var t=e.getStr(16),a=t.match(/"?[0-9a-f]+"?/g);if("0"==t)return r.alloc(128,0);var c=(0,n.padToEven)(a[1]),o=(0,n.padToEven)(a[2]),d=r.concat([r.alloc(64-c.length/2,0),r.from(c,"hex")]),s=r.concat([r.alloc(64-o.length/2,0),r.from(o,"hex")]);return r.concat([d,s])},t.BLS12_381_ToG2Point=function BLS12_381_ToG2Point(e,t){var a=e.slice(0,64),n=e.slice(64,128),o=e.slice(128,192),d=e.slice(192,256),s=r.alloc(64,0);if(a.equals(n)&&a.equals(o)&&a.equals(d)&&a.equals(s))return new t.G2;var b=BLS12_381_ToFp2Point(a,n,t),u=BLS12_381_ToFp2Point(o,d,t),h=new t.Fp;h.setStr("1",16);var l=new t.Fp;l.setStr("0",16);var g=new t.Fp2;g.set_a(h),g.set_b(l);var p=new t.G2;if(p.setX(b),p.setY(u),p.setZ(g),!p.isValidOrder())throw new c.VmError(c.ERROR.BLS_12_381_POINT_NOT_ON_CURVE);if(!p.isValid())throw new c.VmError(c.ERROR.BLS_12_381_POINT_NOT_ON_CURVE);return p},t.BLS12_381_FromG2Point=function BLS12_381_FromG2Point(e){var t=e.getStr(16);if("0"==t)return r.alloc(256,0);var a=t.match(/"?[0-9a-f]+"?/g),c=(0,n.padToEven)(a[1]),o=(0,n.padToEven)(a[2]),d=(0,n.padToEven)(a[3]),s=(0,n.padToEven)(a[4]),b=r.concat([r.alloc(64-c.length/2,0),r.from(c,"hex")]),u=r.concat([r.alloc(64-o.length/2,0),r.from(o,"hex")]),h=r.concat([r.alloc(64-d.length/2,0),r.from(d,"hex")]),l=r.concat([r.alloc(64-s.length/2,0),r.from(s,"hex")]);return r.concat([b,u,h,l])},t.BLS12_381_ToFrPoint=function BLS12_381_ToFrPoint(e,t){var a=t.fromHexStr(e.toString("hex")),r=new t.Fr;return r.setBigEndianMod(a),r},t.BLS12_381_ToFpPoint=function BLS12_381_ToFpPoint(e,t){if(new n.BN(e).gte(o))throw new c.VmError(c.ERROR.BLS_12_381_FP_NOT_IN_FIELD);var a=new t.Fp;return a.setBigEndianMod(t.fromHexStr(e.toString("hex"))),a},t.BLS12_381_ToFp2Point=BLS12_381_ToFp2Point},(e,t,a)=>{"use strict";var r=a(0).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.BLS12_381_ToFp2Point=t.BLS12_381_ToFpPoint=t.BLS12_381_ToFrPoint=t.BLS12_381_FromG2Point=t.BLS12_381_ToG2Point=t.BLS12_381_FromG1Point=t.BLS12_381_ToG1Point=void 0;const n=a(1),c=a(18),o=new n.BN("1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab",16);function BLS12_381_ToFp2Point(e,t,a){if(new n.BN(e).gte(o))throw new c.VmError(c.ERROR.BLS_12_381_FP_NOT_IN_FIELD);if(new n.BN(t).gte(o))throw new c.VmError(c.ERROR.BLS_12_381_FP_NOT_IN_FIELD);const r=new a.Fp,d=new a.Fp,s=new a.Fp2;return r.setStr(e.slice(16).toString("hex"),16),d.setStr(t.slice(16).toString("hex"),16),s.set_a(r),s.set_b(d),s}t.BLS12_381_ToG1Point=function BLS12_381_ToG1Point(e,t){const a=e.slice(16,64).toString("hex"),r=e.slice(80,128).toString("hex"),n="0".repeat(96);if(a==r&&a==n)return new t.G1;const o=new t.Fp,d=new t.Fp,s=new t.Fp;o.setStr(a,16),d.setStr(r,16),s.setStr("1",16);const b=new t.G1;if(b.setX(o),b.setY(d),b.setZ(s),!b.isValidOrder())throw new c.VmError(c.ERROR.BLS_12_381_POINT_NOT_ON_CURVE);if(!b.isValid())throw new c.VmError(c.ERROR.BLS_12_381_POINT_NOT_ON_CURVE);return b},t.BLS12_381_FromG1Point=function BLS12_381_FromG1Point(e){const t=e.getStr(16),a=t.match(/"?[0-9a-f]+"?/g);if("0"==t)return r.alloc(128,0);const c=(0,n.padToEven)(a[1]),o=(0,n.padToEven)(a[2]),d=r.concat([r.alloc(64-c.length/2,0),r.from(c,"hex")]),s=r.concat([r.alloc(64-o.length/2,0),r.from(o,"hex")]);return r.concat([d,s])},t.BLS12_381_ToG2Point=function BLS12_381_ToG2Point(e,t){const a=e.slice(0,64),n=e.slice(64,128),o=e.slice(128,192),d=e.slice(192,256),s=r.alloc(64,0);if(a.equals(n)&&a.equals(o)&&a.equals(d)&&a.equals(s))return new t.G2;const b=BLS12_381_ToFp2Point(a,n,t),u=BLS12_381_ToFp2Point(o,d,t),h=new t.Fp;h.setStr("1",16);const l=new t.Fp;l.setStr("0",16);const g=new t.Fp2;g.set_a(h),g.set_b(l);const p=new t.G2;if(p.setX(b),p.setY(u),p.setZ(g),!p.isValidOrder())throw new c.VmError(c.ERROR.BLS_12_381_POINT_NOT_ON_CURVE);if(!p.isValid())throw new c.VmError(c.ERROR.BLS_12_381_POINT_NOT_ON_CURVE);return p},t.BLS12_381_FromG2Point=function BLS12_381_FromG2Point(e){const t=e.getStr(16);if("0"==t)return r.alloc(256,0);const a=t.match(/"?[0-9a-f]+"?/g),c=(0,n.padToEven)(a[1]),o=(0,n.padToEven)(a[2]),d=(0,n.padToEven)(a[3]),s=(0,n.padToEven)(a[4]),b=r.concat([r.alloc(64-c.length/2,0),r.from(c,"hex")]),u=r.concat([r.alloc(64-o.length/2,0),r.from(o,"hex")]),h=r.concat([r.alloc(64-d.length/2,0),r.from(d,"hex")]),l=r.concat([r.alloc(64-s.length/2,0),r.from(s,"hex")]);return r.concat([b,u,h,l])},t.BLS12_381_ToFrPoint=function BLS12_381_ToFrPoint(e,t){const a=t.fromHexStr(e.toString("hex")),r=new t.Fr;return r.setBigEndianMod(a),r},t.BLS12_381_ToFpPoint=function BLS12_381_ToFpPoint(e,t){if(new n.BN(e).gte(o))throw new c.VmError(c.ERROR.BLS_12_381_FP_NOT_IN_FIELD);const a=new t.Fp;return a.setBigEndianMod(t.fromHexStr(e.toString("hex"))),a},t.BLS12_381_ToFp2Point=BLS12_381_ToFp2Point},function(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[a]}})}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||r(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),n(a(319),t),n(a(320),t),n(a(401),t),n(a(1393),t),n(a(927),t),n(a(402),t),n(a(1394),t),n(a(1395),t),n(a(133),t),n(a(309),t),n(a(928),t),n(a(1396),t),n(a(1397),t)},function(e,t,a){"use strict";var r=a(8).Buffer,n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,a=t&&e[t],r=0;if(a)return a.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},c=this&&this.__read||function(e,t){var a="function"==typeof Symbol&&e[Symbol.iterator];if(!a)return e;var r,n,c=a.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(r=c.next()).done;)o.push(r.value)}catch(e){n={error:e}}finally{try{r&&!r.done&&(a=c.return)&&a.call(c)}finally{if(n)throw n.error}}return o};Object.defineProperty(t,"__esModule",{value:!0}),t.bufArrToArr=t.arrToBufArr=t.validateNoLeadingZeroes=t.baToJSON=t.toUtf8=t.addHexPrefix=t.toUnsigned=t.fromSigned=t.bufferToHex=t.bufferToInt=t.toBuffer=t.unpadHexString=t.unpadArray=t.unpadBuffer=t.setLengthRight=t.setLengthLeft=t.zeros=t.intToBuffer=t.intToHex=void 0;var o=a(53),d=a(116),s=a(226);t.intToHex=function(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("Received an invalid integer type: ".concat(e));return"0x".concat(e.toString(16))};t.intToBuffer=function(e){var a=(0,t.intToHex)(e);return r.from((0,d.padToEven)(a.slice(2)),"hex")};t.zeros=function(e){return r.allocUnsafe(e).fill(0)};var setLength=function(e,a,r){var n=(0,t.zeros)(a);return r?e.length0&&"0"===t.toString();)t=(e=e.slice(1))[0];return e};t.unpadBuffer=function(e){return(0,s.assertIsBuffer)(e),stripZeros(e)};t.unpadArray=function(e){return(0,s.assertIsArray)(e),stripZeros(e)};t.unpadHexString=function(e){return(0,s.assertIsHexString)(e),e=(0,d.stripHexPrefix)(e),stripZeros(e)};t.toBuffer=function(e){if(null==e)return r.allocUnsafe(0);if(r.isBuffer(e))return r.from(e);if(Array.isArray(e)||e instanceof Uint8Array)return r.from(e);if("string"==typeof e){if(!(0,d.isHexString)(e))throw new Error("Cannot convert string to buffer. toBuffer only supports 0x-prefixed hex strings and this string was given: ".concat(e));return r.from((0,d.padToEven)((0,d.stripHexPrefix)(e)),"hex")}if("number"==typeof e)return(0,t.intToBuffer)(e);if(o.BN.isBN(e)){if(e.isNeg())throw new Error("Cannot convert negative BN to buffer. Given: ".concat(e));return e.toArrayLike(r)}if(e.toArray)return r.from(e.toArray());if(e.toBuffer)return r.from(e.toBuffer());throw new Error("invalid type")};t.bufferToInt=function(e){return new o.BN((0,t.toBuffer)(e)).toNumber()};t.bufferToHex=function(e){return"0x"+(e=(0,t.toBuffer)(e)).toString("hex")};t.fromSigned=function(e){return new o.BN(e).fromTwos(256)};t.toUnsigned=function(e){return r.from(e.toTwos(256).toArray())};t.addHexPrefix=function(e){return"string"!=typeof e||(0,d.isHexPrefixed)(e)?e:"0x"+e};t.toUtf8=function(e){if((e=(0,d.stripHexPrefix)(e)).length%2!=0)throw new Error("Invalid non-even hex string input for toUtf8() provided");return r.from(e.replace(/^(00)+|(00)+$/g,""),"hex").toString("utf8")};t.baToJSON=function(e){if(r.isBuffer(e))return"0x".concat(e.toString("hex"));if(e instanceof Array){for(var a=[],n=0;n0&&0===b[0])throw new Error("".concat(s," cannot have leading zeroes, received: ").concat(b.toString("hex")))}}catch(e){t={error:e}}finally{try{o&&!o.done&&(a=r.return)&&a.call(r)}finally{if(t)throw t.error}}},t.arrToBufArr=function arrToBufArr(e){return Array.isArray(e)?e.map((function(e){return arrToBufArr(e)})):r.from(e)},t.bufArrToArr=function bufArrToArr(e){return Array.isArray(e)?e.map((function(e){return bufArrToArr(e)})):Uint8Array.from(null!=e?e:[])}},function(e,t,a){"use strict";var r=a(10).Buffer,n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,a=t&&e[t],r=0;if(a)return a.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},c=this&&this.__read||function(e,t){var a="function"==typeof Symbol&&e[Symbol.iterator];if(!a)return e;var r,n,c=a.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(r=c.next()).done;)o.push(r.value)}catch(e){n={error:e}}finally{try{r&&!r.done&&(a=c.return)&&a.call(c)}finally{if(n)throw n.error}}return o};Object.defineProperty(t,"__esModule",{value:!0}),t.bufArrToArr=t.arrToBufArr=t.validateNoLeadingZeroes=t.baToJSON=t.toUtf8=t.addHexPrefix=t.toUnsigned=t.fromSigned=t.bufferToHex=t.bufferToInt=t.toBuffer=t.unpadHexString=t.unpadArray=t.unpadBuffer=t.setLengthRight=t.setLengthLeft=t.zeros=t.intToBuffer=t.intToHex=void 0;var o=a(54),d=a(117),s=a(230);t.intToHex=function(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("Received an invalid integer type: ".concat(e));return"0x".concat(e.toString(16))};t.intToBuffer=function(e){var a=(0,t.intToHex)(e);return r.from((0,d.padToEven)(a.slice(2)),"hex")};t.zeros=function(e){return r.allocUnsafe(e).fill(0)};var setLength=function(e,a,r){var n=(0,t.zeros)(a);return r?e.length0&&"0"===t.toString();)t=(e=e.slice(1))[0];return e};t.unpadBuffer=function(e){return(0,s.assertIsBuffer)(e),stripZeros(e)};t.unpadArray=function(e){return(0,s.assertIsArray)(e),stripZeros(e)};t.unpadHexString=function(e){return(0,s.assertIsHexString)(e),e=(0,d.stripHexPrefix)(e),stripZeros(e)};t.toBuffer=function(e){if(null==e)return r.allocUnsafe(0);if(r.isBuffer(e))return r.from(e);if(Array.isArray(e)||e instanceof Uint8Array)return r.from(e);if("string"==typeof e){if(!(0,d.isHexString)(e))throw new Error("Cannot convert string to buffer. toBuffer only supports 0x-prefixed hex strings and this string was given: ".concat(e));return r.from((0,d.padToEven)((0,d.stripHexPrefix)(e)),"hex")}if("number"==typeof e)return(0,t.intToBuffer)(e);if(o.BN.isBN(e)){if(e.isNeg())throw new Error("Cannot convert negative BN to buffer. Given: ".concat(e));return e.toArrayLike(r)}if(e.toArray)return r.from(e.toArray());if(e.toBuffer)return r.from(e.toBuffer());throw new Error("invalid type")};t.bufferToInt=function(e){return new o.BN((0,t.toBuffer)(e)).toNumber()};t.bufferToHex=function(e){return"0x"+(e=(0,t.toBuffer)(e)).toString("hex")};t.fromSigned=function(e){return new o.BN(e).fromTwos(256)};t.toUnsigned=function(e){return r.from(e.toTwos(256).toArray())};t.addHexPrefix=function(e){return"string"!=typeof e||(0,d.isHexPrefixed)(e)?e:"0x"+e};t.toUtf8=function(e){if((e=(0,d.stripHexPrefix)(e)).length%2!=0)throw new Error("Invalid non-even hex string input for toUtf8() provided");return r.from(e.replace(/^(00)+|(00)+$/g,""),"hex").toString("utf8")};t.baToJSON=function(e){if(r.isBuffer(e))return"0x".concat(e.toString("hex"));if(e instanceof Array){for(var a=[],n=0;n0&&0===b[0])throw new Error("".concat(s," cannot have leading zeroes, received: ").concat(b.toString("hex")))}}catch(e){t={error:e}}finally{try{o&&!o.done&&(a=r.return)&&a.call(r)}finally{if(t)throw t.error}}},t.arrToBufArr=function arrToBufArr(e){return Array.isArray(e)?e.map((function(e){return arrToBufArr(e)})):r.from(e)},t.bufArrToArr=function bufArrToArr(e){return Array.isArray(e)?e.map((function(e){return bufArrToArr(e)})):Uint8Array.from(null!=e?e:[])}},function(e,t,a){"use strict";var r=a(2).Buffer,n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,a=t&&e[t],r=0;if(a)return a.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},c=this&&this.__read||function(e,t){var a="function"==typeof Symbol&&e[Symbol.iterator];if(!a)return e;var r,n,c=a.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(r=c.next()).done;)o.push(r.value)}catch(e){n={error:e}}finally{try{r&&!r.done&&(a=c.return)&&a.call(c)}finally{if(n)throw n.error}}return o};Object.defineProperty(t,"__esModule",{value:!0}),t.bufArrToArr=t.arrToBufArr=t.validateNoLeadingZeroes=t.baToJSON=t.toUtf8=t.addHexPrefix=t.toUnsigned=t.fromSigned=t.bufferToHex=t.bufferToInt=t.toBuffer=t.unpadHexString=t.unpadArray=t.unpadBuffer=t.setLengthRight=t.setLengthLeft=t.zeros=t.intToBuffer=t.intToHex=void 0;var o=a(55),d=a(120),s=a(237);t.intToHex=function(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("Received an invalid integer type: ".concat(e));return"0x".concat(e.toString(16))};t.intToBuffer=function(e){var a=(0,t.intToHex)(e);return r.from((0,d.padToEven)(a.slice(2)),"hex")};t.zeros=function(e){return r.allocUnsafe(e).fill(0)};var setLength=function(e,a,r){var n=(0,t.zeros)(a);return r?e.length0&&"0"===t.toString();)t=(e=e.slice(1))[0];return e};t.unpadBuffer=function(e){return(0,s.assertIsBuffer)(e),stripZeros(e)};t.unpadArray=function(e){return(0,s.assertIsArray)(e),stripZeros(e)};t.unpadHexString=function(e){return(0,s.assertIsHexString)(e),e=(0,d.stripHexPrefix)(e),stripZeros(e)};t.toBuffer=function(e){if(null==e)return r.allocUnsafe(0);if(r.isBuffer(e))return r.from(e);if(Array.isArray(e)||e instanceof Uint8Array)return r.from(e);if("string"==typeof e){if(!(0,d.isHexString)(e))throw new Error("Cannot convert string to buffer. toBuffer only supports 0x-prefixed hex strings and this string was given: ".concat(e));return r.from((0,d.padToEven)((0,d.stripHexPrefix)(e)),"hex")}if("number"==typeof e)return(0,t.intToBuffer)(e);if(o.BN.isBN(e)){if(e.isNeg())throw new Error("Cannot convert negative BN to buffer. Given: ".concat(e));return e.toArrayLike(r)}if(e.toArray)return r.from(e.toArray());if(e.toBuffer)return r.from(e.toBuffer());throw new Error("invalid type")};t.bufferToInt=function(e){return new o.BN((0,t.toBuffer)(e)).toNumber()};t.bufferToHex=function(e){return"0x"+(e=(0,t.toBuffer)(e)).toString("hex")};t.fromSigned=function(e){return new o.BN(e).fromTwos(256)};t.toUnsigned=function(e){return r.from(e.toTwos(256).toArray())};t.addHexPrefix=function(e){return"string"!=typeof e||(0,d.isHexPrefixed)(e)?e:"0x"+e};t.toUtf8=function(e){if((e=(0,d.stripHexPrefix)(e)).length%2!=0)throw new Error("Invalid non-even hex string input for toUtf8() provided");return r.from(e.replace(/^(00)+|(00)+$/g,""),"hex").toString("utf8")};t.baToJSON=function(e){if(r.isBuffer(e))return"0x".concat(e.toString("hex"));if(e instanceof Array){for(var a=[],n=0;n0&&0===b[0])throw new Error("".concat(s," cannot have leading zeroes, received: ").concat(b.toString("hex")))}}catch(e){t={error:e}}finally{try{o&&!o.done&&(a=r.return)&&a.call(r)}finally{if(t)throw t.error}}},t.arrToBufArr=function arrToBufArr(e){return Array.isArray(e)?e.map((function(e){return arrToBufArr(e)})):r.from(e)},t.bufArrToArr=function bufArrToArr(e){return Array.isArray(e)?e.map((function(e){return bufArrToArr(e)})):Uint8Array.from(null!=e?e:[])}},function(e,t,a){"use strict";var r=a(0).Buffer,n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,a=t&&e[t],r=0;if(a)return a.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},c=this&&this.__read||function(e,t){var a="function"==typeof Symbol&&e[Symbol.iterator];if(!a)return e;var r,n,c=a.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(r=c.next()).done;)o.push(r.value)}catch(e){n={error:e}}finally{try{r&&!r.done&&(a=c.return)&&a.call(c)}finally{if(n)throw n.error}}return o};Object.defineProperty(t,"__esModule",{value:!0}),t.bufArrToArr=t.arrToBufArr=t.validateNoLeadingZeroes=t.baToJSON=t.toUtf8=t.addHexPrefix=t.toUnsigned=t.fromSigned=t.bufferToHex=t.bufferToInt=t.toBuffer=t.unpadHexString=t.unpadArray=t.unpadBuffer=t.setLengthRight=t.setLengthLeft=t.zeros=t.intToBuffer=t.intToHex=void 0;var o=a(56),d=a(122),s=a(244);t.intToHex=function(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("Received an invalid integer type: ".concat(e));return"0x".concat(e.toString(16))};t.intToBuffer=function(e){var a=(0,t.intToHex)(e);return r.from((0,d.padToEven)(a.slice(2)),"hex")};t.zeros=function(e){return r.allocUnsafe(e).fill(0)};var setLength=function(e,a,r){var n=(0,t.zeros)(a);return r?e.length0&&"0"===t.toString();)t=(e=e.slice(1))[0];return e};t.unpadBuffer=function(e){return(0,s.assertIsBuffer)(e),stripZeros(e)};t.unpadArray=function(e){return(0,s.assertIsArray)(e),stripZeros(e)};t.unpadHexString=function(e){return(0,s.assertIsHexString)(e),e=(0,d.stripHexPrefix)(e),stripZeros(e)};t.toBuffer=function(e){if(null==e)return r.allocUnsafe(0);if(r.isBuffer(e))return r.from(e);if(Array.isArray(e)||e instanceof Uint8Array)return r.from(e);if("string"==typeof e){if(!(0,d.isHexString)(e))throw new Error("Cannot convert string to buffer. toBuffer only supports 0x-prefixed hex strings and this string was given: ".concat(e));return r.from((0,d.padToEven)((0,d.stripHexPrefix)(e)),"hex")}if("number"==typeof e)return(0,t.intToBuffer)(e);if(o.BN.isBN(e)){if(e.isNeg())throw new Error("Cannot convert negative BN to buffer. Given: ".concat(e));return e.toArrayLike(r)}if(e.toArray)return r.from(e.toArray());if(e.toBuffer)return r.from(e.toBuffer());throw new Error("invalid type")};t.bufferToInt=function(e){return new o.BN((0,t.toBuffer)(e)).toNumber()};t.bufferToHex=function(e){return"0x"+(e=(0,t.toBuffer)(e)).toString("hex")};t.fromSigned=function(e){return new o.BN(e).fromTwos(256)};t.toUnsigned=function(e){return r.from(e.toTwos(256).toArray())};t.addHexPrefix=function(e){return"string"!=typeof e||(0,d.isHexPrefixed)(e)?e:"0x"+e};t.toUtf8=function(e){if((e=(0,d.stripHexPrefix)(e)).length%2!=0)throw new Error("Invalid non-even hex string input for toUtf8() provided");return r.from(e.replace(/^(00)+|(00)+$/g,""),"hex").toString("utf8")};t.baToJSON=function(e){if(r.isBuffer(e))return"0x".concat(e.toString("hex"));if(e instanceof Array){for(var a=[],n=0;n0&&0===b[0])throw new Error("".concat(s," cannot have leading zeroes, received: ").concat(b.toString("hex")))}}catch(e){t={error:e}}finally{try{o&&!o.done&&(a=r.return)&&a.call(r)}finally{if(t)throw t.error}}},t.arrToBufArr=function arrToBufArr(e){return Array.isArray(e)?e.map((function(e){return arrToBufArr(e)})):r.from(e)},t.bufArrToArr=function bufArrToArr(e){return Array.isArray(e)?e.map((function(e){return bufArrToArr(e)})):Uint8Array.from(null!=e?e:[])}},function(e,t,a){!function(e,t){"use strict";function assert(e,t){if(!e)throw new Error(t||"Assertion failed")}function inherits(e,t){e.super_=t;var TempCtor=function(){};TempCtor.prototype=t.prototype,e.prototype=new TempCtor,e.prototype.constructor=e}function BN(e,t,a){if(BN.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(a=t,t=10),this._init(e||0,t||10,a||"be"))}var r;"object"==typeof e?e.exports=BN:t.BN=BN,BN.BN=BN,BN.wordSize=26;try{r="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:a(1294).Buffer}catch(e){}function parseHex4Bits(e,t){var a=e.charCodeAt(t);return a>=65&&a<=70?a-55:a>=97&&a<=102?a-87:a-48&15}function parseHexByte(e,t,a){var r=parseHex4Bits(e,a);return a-1>=t&&(r|=parseHex4Bits(e,a-1)<<4),r}function parseBase(e,t,a,r){for(var n=0,c=Math.min(e.length,a),o=t;o=49?d-49+10:d>=17?d-17+10:d}return n}BN.isBN=function isBN(e){return e instanceof BN||null!==e&&"object"==typeof e&&e.constructor.wordSize===BN.wordSize&&Array.isArray(e.words)},BN.max=function max(e,t){return e.cmp(t)>0?e:t},BN.min=function min(e,t){return e.cmp(t)<0?e:t},BN.prototype._init=function init(e,t,a){if("number"==typeof e)return this._initNumber(e,t,a);if("object"==typeof e)return this._initArray(e,t,a);"hex"===t&&(t=16),assert(t===(0|t)&&t>=2&&t<=36);var r=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(r++,this.negative=1),r=0;r-=3)c=e[r]|e[r-1]<<8|e[r-2]<<16,this.words[n]|=c<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===a)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},BN.prototype._parseHex=function _parseHex(e,t,a){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=2)n=parseHexByte(e,t,r)<=18?(c-=18,o+=1,this.words[o]|=n>>>26):c+=8;else for(r=(e.length-t)%2==0?t+1:t;r=18?(c-=18,o+=1,this.words[o]|=n>>>26):c+=8;this.strip()},BN.prototype._parseBase=function _parseBase(e,t,a){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=t)r++;r--,n=n/t|0;for(var c=e.length-a,o=c%r,d=Math.min(c,c-o)+a,s=0,b=a;b1&&0===this.words[this.length-1];)this.length--;return this._normSign()},BN.prototype._normSign=function _normSign(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},BN.prototype.inspect=function inspect(){return(this.red?""};var n=["","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"],c=[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],o=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function smallMulTo(e,t,a){a.negative=t.negative^e.negative;var r=e.length+t.length|0;a.length=r,r=r-1|0;var n=0|e.words[0],c=0|t.words[0],o=n*c,d=67108863&o,s=o/67108864|0;a.words[0]=d;for(var b=1;b>>26,h=67108863&s,l=Math.min(b,t.length-1),g=Math.max(0,b-e.length+1);g<=l;g++){var p=b-g|0;u+=(o=(n=0|e.words[p])*(c=0|t.words[g])+h)/67108864|0,h=67108863&o}a.words[b]=0|h,s=0|u}return 0!==s?a.words[b]=0|s:a.length--,a.strip()}BN.prototype.toString=function toString(e,t){var a;if(t=0|t||1,16===(e=e||10)||"hex"===e){a="";for(var r=0,d=0,s=0;s>>24-r&16777215)||s!==this.length-1?n[6-u.length]+u+a:u+a,(r+=2)>=26&&(r-=26,s--)}for(0!==d&&(a=d.toString(16)+a);a.length%t!=0;)a="0"+a;return 0!==this.negative&&(a="-"+a),a}if(e===(0|e)&&e>=2&&e<=36){var h=c[e],l=o[e];a="";var g=this.clone();for(g.negative=0;!g.isZero();){var p=g.modn(l).toString(e);a=(g=g.idivn(l)).isZero()?p+a:n[h-p.length]+p+a}for(this.isZero()&&(a="0"+a);a.length%t!=0;)a="0"+a;return 0!==this.negative&&(a="-"+a),a}assert(!1,"Base should be between 2 and 36")},BN.prototype.toNumber=function toNumber(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&assert(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},BN.prototype.toJSON=function toJSON(){return this.toString(16)},BN.prototype.toBuffer=function toBuffer(e,t){return assert(void 0!==r),this.toArrayLike(r,e,t)},BN.prototype.toArray=function toArray(e,t){return this.toArrayLike(Array,e,t)},BN.prototype.toArrayLike=function toArrayLike(e,t,a){var r=this.byteLength(),n=a||Math.max(1,r);assert(r<=n,"byte array longer than desired length"),assert(n>0,"Requested array length <= 0"),this.strip();var c,o,d="le"===t,s=new e(n),b=this.clone();if(d){for(o=0;!b.isZero();o++)c=b.andln(255),b.iushrn(8),s[o]=c;for(;o=4096&&(a+=13,t>>>=13),t>=64&&(a+=7,t>>>=7),t>=8&&(a+=4,t>>>=4),t>=2&&(a+=2,t>>>=2),a+t},BN.prototype._zeroBits=function _zeroBits(e){if(0===e)return 26;var t=e,a=0;return 0==(8191&t)&&(a+=13,t>>>=13),0==(127&t)&&(a+=7,t>>>=7),0==(15&t)&&(a+=4,t>>>=4),0==(3&t)&&(a+=2,t>>>=2),0==(1&t)&&a++,a},BN.prototype.bitLength=function bitLength(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},BN.prototype.zeroBits=function zeroBits(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},BN.prototype.uor=function uor(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},BN.prototype.iuand=function iuand(e){var t;t=this.length>e.length?e:this;for(var a=0;ae.length?this.clone().iand(e):e.clone().iand(this)},BN.prototype.uand=function uand(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},BN.prototype.iuxor=function iuxor(e){var t,a;this.length>e.length?(t=this,a=e):(t=e,a=this);for(var r=0;re.length?this.clone().ixor(e):e.clone().ixor(this)},BN.prototype.uxor=function uxor(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},BN.prototype.inotn=function inotn(e){assert("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),a=e%26;this._expand(t),a>0&&t--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-a),this.strip()},BN.prototype.notn=function notn(e){return this.clone().inotn(e)},BN.prototype.setn=function setn(e,t){assert("number"==typeof e&&e>=0);var a=e/26|0,r=e%26;return this._expand(a+1),this.words[a]=t?this.words[a]|1<e.length?(a=this,r=e):(a=e,r=this);for(var n=0,c=0;c>>26;for(;0!==n&&c>>26;if(this.length=a.length,0!==n)this.words[this.length]=n,this.length++;else if(a!==this)for(;ce.length?this.clone().iadd(e):e.clone().iadd(this)},BN.prototype.isub=function isub(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var a,r,n=this.cmp(e);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(a=this,r=e):(a=e,r=this);for(var c=0,o=0;o>26,this.words[o]=67108863&t;for(;0!==c&&o>26,this.words[o]=67108863&t;if(0===c&&o>>13,g=0|o[1],p=8191&g,B=g>>>13,x=0|o[2],I=8191&x,m=x>>>13,y=0|o[3],C=8191&y,w=y>>>13,v=0|o[4],Q=8191&v,k=v>>>13,_=0|o[5],N=8191&_,D=_>>>13,G=0|o[6],L=8191&G,T=G>>>13,U=0|o[7],P=8191&U,q=U>>>13,H=0|o[8],O=8191&H,z=H>>>13,J=0|o[9],j=8191&J,Y=J>>>13,W=0|d[0],V=8191&W,X=W>>>13,$=0|d[1],et=8191&$,tt=$>>>13,at=0|d[2],rt=8191&at,it=at>>>13,nt=0|d[3],ct=8191&nt,ot=nt>>>13,dt=0|d[4],At=8191&dt,st=dt>>>13,bt=0|d[5],ut=8191&bt,ht=bt>>>13,pt=0|d[6],Bt=8191&pt,xt=pt>>>13,It=0|d[7],mt=8191&It,Et=It>>>13,yt=0|d[8],Ct=8191&yt,wt=yt>>>13,vt=0|d[9],Qt=8191&vt,Mt=vt>>>13;a.negative=e.negative^t.negative,a.length=19;var kt=(b+(r=Math.imul(h,V))|0)+((8191&(n=(n=Math.imul(h,X))+Math.imul(l,V)|0))<<13)|0;b=((c=Math.imul(l,X))+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(p,V),n=(n=Math.imul(p,X))+Math.imul(B,V)|0,c=Math.imul(B,X);var _t=(b+(r=r+Math.imul(h,et)|0)|0)+((8191&(n=(n=n+Math.imul(h,tt)|0)+Math.imul(l,et)|0))<<13)|0;b=((c=c+Math.imul(l,tt)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(I,V),n=(n=Math.imul(I,X))+Math.imul(m,V)|0,c=Math.imul(m,X),r=r+Math.imul(p,et)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(B,et)|0,c=c+Math.imul(B,tt)|0;var St=(b+(r=r+Math.imul(h,rt)|0)|0)+((8191&(n=(n=n+Math.imul(h,it)|0)+Math.imul(l,rt)|0))<<13)|0;b=((c=c+Math.imul(l,it)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(C,V),n=(n=Math.imul(C,X))+Math.imul(w,V)|0,c=Math.imul(w,X),r=r+Math.imul(I,et)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(m,et)|0,c=c+Math.imul(m,tt)|0,r=r+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(B,rt)|0,c=c+Math.imul(B,it)|0;var Nt=(b+(r=r+Math.imul(h,ct)|0)|0)+((8191&(n=(n=n+Math.imul(h,ot)|0)+Math.imul(l,ct)|0))<<13)|0;b=((c=c+Math.imul(l,ot)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,r=Math.imul(Q,V),n=(n=Math.imul(Q,X))+Math.imul(k,V)|0,c=Math.imul(k,X),r=r+Math.imul(C,et)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(w,et)|0,c=c+Math.imul(w,tt)|0,r=r+Math.imul(I,rt)|0,n=(n=n+Math.imul(I,it)|0)+Math.imul(m,rt)|0,c=c+Math.imul(m,it)|0,r=r+Math.imul(p,ct)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(B,ct)|0,c=c+Math.imul(B,ot)|0;var Dt=(b+(r=r+Math.imul(h,At)|0)|0)+((8191&(n=(n=n+Math.imul(h,st)|0)+Math.imul(l,At)|0))<<13)|0;b=((c=c+Math.imul(l,st)|0)+(n>>>13)|0)+(Dt>>>26)|0,Dt&=67108863,r=Math.imul(N,V),n=(n=Math.imul(N,X))+Math.imul(D,V)|0,c=Math.imul(D,X),r=r+Math.imul(Q,et)|0,n=(n=n+Math.imul(Q,tt)|0)+Math.imul(k,et)|0,c=c+Math.imul(k,tt)|0,r=r+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(w,rt)|0,c=c+Math.imul(w,it)|0,r=r+Math.imul(I,ct)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(m,ct)|0,c=c+Math.imul(m,ot)|0,r=r+Math.imul(p,At)|0,n=(n=n+Math.imul(p,st)|0)+Math.imul(B,At)|0,c=c+Math.imul(B,st)|0;var Rt=(b+(r=r+Math.imul(h,ut)|0)|0)+((8191&(n=(n=n+Math.imul(h,ht)|0)+Math.imul(l,ut)|0))<<13)|0;b=((c=c+Math.imul(l,ht)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(L,V),n=(n=Math.imul(L,X))+Math.imul(T,V)|0,c=Math.imul(T,X),r=r+Math.imul(N,et)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(D,et)|0,c=c+Math.imul(D,tt)|0,r=r+Math.imul(Q,rt)|0,n=(n=n+Math.imul(Q,it)|0)+Math.imul(k,rt)|0,c=c+Math.imul(k,it)|0,r=r+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,ot)|0)+Math.imul(w,ct)|0,c=c+Math.imul(w,ot)|0,r=r+Math.imul(I,At)|0,n=(n=n+Math.imul(I,st)|0)+Math.imul(m,At)|0,c=c+Math.imul(m,st)|0,r=r+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,ht)|0)+Math.imul(B,ut)|0,c=c+Math.imul(B,ht)|0;var Ft=(b+(r=r+Math.imul(h,Bt)|0)|0)+((8191&(n=(n=n+Math.imul(h,xt)|0)+Math.imul(l,Bt)|0))<<13)|0;b=((c=c+Math.imul(l,xt)|0)+(n>>>13)|0)+(Ft>>>26)|0,Ft&=67108863,r=Math.imul(P,V),n=(n=Math.imul(P,X))+Math.imul(q,V)|0,c=Math.imul(q,X),r=r+Math.imul(L,et)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(T,et)|0,c=c+Math.imul(T,tt)|0,r=r+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(D,rt)|0,c=c+Math.imul(D,it)|0,r=r+Math.imul(Q,ct)|0,n=(n=n+Math.imul(Q,ot)|0)+Math.imul(k,ct)|0,c=c+Math.imul(k,ot)|0,r=r+Math.imul(C,At)|0,n=(n=n+Math.imul(C,st)|0)+Math.imul(w,At)|0,c=c+Math.imul(w,st)|0,r=r+Math.imul(I,ut)|0,n=(n=n+Math.imul(I,ht)|0)+Math.imul(m,ut)|0,c=c+Math.imul(m,ht)|0,r=r+Math.imul(p,Bt)|0,n=(n=n+Math.imul(p,xt)|0)+Math.imul(B,Bt)|0,c=c+Math.imul(B,xt)|0;var Gt=(b+(r=r+Math.imul(h,mt)|0)|0)+((8191&(n=(n=n+Math.imul(h,Et)|0)+Math.imul(l,mt)|0))<<13)|0;b=((c=c+Math.imul(l,Et)|0)+(n>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,r=Math.imul(O,V),n=(n=Math.imul(O,X))+Math.imul(z,V)|0,c=Math.imul(z,X),r=r+Math.imul(P,et)|0,n=(n=n+Math.imul(P,tt)|0)+Math.imul(q,et)|0,c=c+Math.imul(q,tt)|0,r=r+Math.imul(L,rt)|0,n=(n=n+Math.imul(L,it)|0)+Math.imul(T,rt)|0,c=c+Math.imul(T,it)|0,r=r+Math.imul(N,ct)|0,n=(n=n+Math.imul(N,ot)|0)+Math.imul(D,ct)|0,c=c+Math.imul(D,ot)|0,r=r+Math.imul(Q,At)|0,n=(n=n+Math.imul(Q,st)|0)+Math.imul(k,At)|0,c=c+Math.imul(k,st)|0,r=r+Math.imul(C,ut)|0,n=(n=n+Math.imul(C,ht)|0)+Math.imul(w,ut)|0,c=c+Math.imul(w,ht)|0,r=r+Math.imul(I,Bt)|0,n=(n=n+Math.imul(I,xt)|0)+Math.imul(m,Bt)|0,c=c+Math.imul(m,xt)|0,r=r+Math.imul(p,mt)|0,n=(n=n+Math.imul(p,Et)|0)+Math.imul(B,mt)|0,c=c+Math.imul(B,Et)|0;var Lt=(b+(r=r+Math.imul(h,Ct)|0)|0)+((8191&(n=(n=n+Math.imul(h,wt)|0)+Math.imul(l,Ct)|0))<<13)|0;b=((c=c+Math.imul(l,wt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,r=Math.imul(j,V),n=(n=Math.imul(j,X))+Math.imul(Y,V)|0,c=Math.imul(Y,X),r=r+Math.imul(O,et)|0,n=(n=n+Math.imul(O,tt)|0)+Math.imul(z,et)|0,c=c+Math.imul(z,tt)|0,r=r+Math.imul(P,rt)|0,n=(n=n+Math.imul(P,it)|0)+Math.imul(q,rt)|0,c=c+Math.imul(q,it)|0,r=r+Math.imul(L,ct)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(T,ct)|0,c=c+Math.imul(T,ot)|0,r=r+Math.imul(N,At)|0,n=(n=n+Math.imul(N,st)|0)+Math.imul(D,At)|0,c=c+Math.imul(D,st)|0,r=r+Math.imul(Q,ut)|0,n=(n=n+Math.imul(Q,ht)|0)+Math.imul(k,ut)|0,c=c+Math.imul(k,ht)|0,r=r+Math.imul(C,Bt)|0,n=(n=n+Math.imul(C,xt)|0)+Math.imul(w,Bt)|0,c=c+Math.imul(w,xt)|0,r=r+Math.imul(I,mt)|0,n=(n=n+Math.imul(I,Et)|0)+Math.imul(m,mt)|0,c=c+Math.imul(m,Et)|0,r=r+Math.imul(p,Ct)|0,n=(n=n+Math.imul(p,wt)|0)+Math.imul(B,Ct)|0,c=c+Math.imul(B,wt)|0;var Tt=(b+(r=r+Math.imul(h,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(h,Mt)|0)+Math.imul(l,Qt)|0))<<13)|0;b=((c=c+Math.imul(l,Mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(j,et),n=(n=Math.imul(j,tt))+Math.imul(Y,et)|0,c=Math.imul(Y,tt),r=r+Math.imul(O,rt)|0,n=(n=n+Math.imul(O,it)|0)+Math.imul(z,rt)|0,c=c+Math.imul(z,it)|0,r=r+Math.imul(P,ct)|0,n=(n=n+Math.imul(P,ot)|0)+Math.imul(q,ct)|0,c=c+Math.imul(q,ot)|0,r=r+Math.imul(L,At)|0,n=(n=n+Math.imul(L,st)|0)+Math.imul(T,At)|0,c=c+Math.imul(T,st)|0,r=r+Math.imul(N,ut)|0,n=(n=n+Math.imul(N,ht)|0)+Math.imul(D,ut)|0,c=c+Math.imul(D,ht)|0,r=r+Math.imul(Q,Bt)|0,n=(n=n+Math.imul(Q,xt)|0)+Math.imul(k,Bt)|0,c=c+Math.imul(k,xt)|0,r=r+Math.imul(C,mt)|0,n=(n=n+Math.imul(C,Et)|0)+Math.imul(w,mt)|0,c=c+Math.imul(w,Et)|0,r=r+Math.imul(I,Ct)|0,n=(n=n+Math.imul(I,wt)|0)+Math.imul(m,Ct)|0,c=c+Math.imul(m,wt)|0;var Ut=(b+(r=r+Math.imul(p,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(p,Mt)|0)+Math.imul(B,Qt)|0))<<13)|0;b=((c=c+Math.imul(B,Mt)|0)+(n>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,r=Math.imul(j,rt),n=(n=Math.imul(j,it))+Math.imul(Y,rt)|0,c=Math.imul(Y,it),r=r+Math.imul(O,ct)|0,n=(n=n+Math.imul(O,ot)|0)+Math.imul(z,ct)|0,c=c+Math.imul(z,ot)|0,r=r+Math.imul(P,At)|0,n=(n=n+Math.imul(P,st)|0)+Math.imul(q,At)|0,c=c+Math.imul(q,st)|0,r=r+Math.imul(L,ut)|0,n=(n=n+Math.imul(L,ht)|0)+Math.imul(T,ut)|0,c=c+Math.imul(T,ht)|0,r=r+Math.imul(N,Bt)|0,n=(n=n+Math.imul(N,xt)|0)+Math.imul(D,Bt)|0,c=c+Math.imul(D,xt)|0,r=r+Math.imul(Q,mt)|0,n=(n=n+Math.imul(Q,Et)|0)+Math.imul(k,mt)|0,c=c+Math.imul(k,Et)|0,r=r+Math.imul(C,Ct)|0,n=(n=n+Math.imul(C,wt)|0)+Math.imul(w,Ct)|0,c=c+Math.imul(w,wt)|0;var Pt=(b+(r=r+Math.imul(I,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(I,Mt)|0)+Math.imul(m,Qt)|0))<<13)|0;b=((c=c+Math.imul(m,Mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(j,ct),n=(n=Math.imul(j,ot))+Math.imul(Y,ct)|0,c=Math.imul(Y,ot),r=r+Math.imul(O,At)|0,n=(n=n+Math.imul(O,st)|0)+Math.imul(z,At)|0,c=c+Math.imul(z,st)|0,r=r+Math.imul(P,ut)|0,n=(n=n+Math.imul(P,ht)|0)+Math.imul(q,ut)|0,c=c+Math.imul(q,ht)|0,r=r+Math.imul(L,Bt)|0,n=(n=n+Math.imul(L,xt)|0)+Math.imul(T,Bt)|0,c=c+Math.imul(T,xt)|0,r=r+Math.imul(N,mt)|0,n=(n=n+Math.imul(N,Et)|0)+Math.imul(D,mt)|0,c=c+Math.imul(D,Et)|0,r=r+Math.imul(Q,Ct)|0,n=(n=n+Math.imul(Q,wt)|0)+Math.imul(k,Ct)|0,c=c+Math.imul(k,wt)|0;var qt=(b+(r=r+Math.imul(C,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(C,Mt)|0)+Math.imul(w,Qt)|0))<<13)|0;b=((c=c+Math.imul(w,Mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863,r=Math.imul(j,At),n=(n=Math.imul(j,st))+Math.imul(Y,At)|0,c=Math.imul(Y,st),r=r+Math.imul(O,ut)|0,n=(n=n+Math.imul(O,ht)|0)+Math.imul(z,ut)|0,c=c+Math.imul(z,ht)|0,r=r+Math.imul(P,Bt)|0,n=(n=n+Math.imul(P,xt)|0)+Math.imul(q,Bt)|0,c=c+Math.imul(q,xt)|0,r=r+Math.imul(L,mt)|0,n=(n=n+Math.imul(L,Et)|0)+Math.imul(T,mt)|0,c=c+Math.imul(T,Et)|0,r=r+Math.imul(N,Ct)|0,n=(n=n+Math.imul(N,wt)|0)+Math.imul(D,Ct)|0,c=c+Math.imul(D,wt)|0;var Ht=(b+(r=r+Math.imul(Q,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(Q,Mt)|0)+Math.imul(k,Qt)|0))<<13)|0;b=((c=c+Math.imul(k,Mt)|0)+(n>>>13)|0)+(Ht>>>26)|0,Ht&=67108863,r=Math.imul(j,ut),n=(n=Math.imul(j,ht))+Math.imul(Y,ut)|0,c=Math.imul(Y,ht),r=r+Math.imul(O,Bt)|0,n=(n=n+Math.imul(O,xt)|0)+Math.imul(z,Bt)|0,c=c+Math.imul(z,xt)|0,r=r+Math.imul(P,mt)|0,n=(n=n+Math.imul(P,Et)|0)+Math.imul(q,mt)|0,c=c+Math.imul(q,Et)|0,r=r+Math.imul(L,Ct)|0,n=(n=n+Math.imul(L,wt)|0)+Math.imul(T,Ct)|0,c=c+Math.imul(T,wt)|0;var Ot=(b+(r=r+Math.imul(N,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(N,Mt)|0)+Math.imul(D,Qt)|0))<<13)|0;b=((c=c+Math.imul(D,Mt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,r=Math.imul(j,Bt),n=(n=Math.imul(j,xt))+Math.imul(Y,Bt)|0,c=Math.imul(Y,xt),r=r+Math.imul(O,mt)|0,n=(n=n+Math.imul(O,Et)|0)+Math.imul(z,mt)|0,c=c+Math.imul(z,Et)|0,r=r+Math.imul(P,Ct)|0,n=(n=n+Math.imul(P,wt)|0)+Math.imul(q,Ct)|0,c=c+Math.imul(q,wt)|0;var zt=(b+(r=r+Math.imul(L,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(L,Mt)|0)+Math.imul(T,Qt)|0))<<13)|0;b=((c=c+Math.imul(T,Mt)|0)+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863,r=Math.imul(j,mt),n=(n=Math.imul(j,Et))+Math.imul(Y,mt)|0,c=Math.imul(Y,Et),r=r+Math.imul(O,Ct)|0,n=(n=n+Math.imul(O,wt)|0)+Math.imul(z,Ct)|0,c=c+Math.imul(z,wt)|0;var Kt=(b+(r=r+Math.imul(P,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(P,Mt)|0)+Math.imul(q,Qt)|0))<<13)|0;b=((c=c+Math.imul(q,Mt)|0)+(n>>>13)|0)+(Kt>>>26)|0,Kt&=67108863,r=Math.imul(j,Ct),n=(n=Math.imul(j,wt))+Math.imul(Y,Ct)|0,c=Math.imul(Y,wt);var Jt=(b+(r=r+Math.imul(O,Qt)|0)|0)+((8191&(n=(n=n+Math.imul(O,Mt)|0)+Math.imul(z,Qt)|0))<<13)|0;b=((c=c+Math.imul(z,Mt)|0)+(n>>>13)|0)+(Jt>>>26)|0,Jt&=67108863;var jt=(b+(r=Math.imul(j,Qt))|0)+((8191&(n=(n=Math.imul(j,Mt))+Math.imul(Y,Qt)|0))<<13)|0;return b=((c=Math.imul(Y,Mt))+(n>>>13)|0)+(jt>>>26)|0,jt&=67108863,s[0]=kt,s[1]=_t,s[2]=St,s[3]=Nt,s[4]=Dt,s[5]=Rt,s[6]=Ft,s[7]=Gt,s[8]=Lt,s[9]=Tt,s[10]=Ut,s[11]=Pt,s[12]=qt,s[13]=Ht,s[14]=Ot,s[15]=zt,s[16]=Kt,s[17]=Jt,s[18]=jt,0!==b&&(s[19]=b,a.length++),a};function jumboMulTo(e,t,a){return(new FFTM).mulp(e,t,a)}function FFTM(e,t){this.x=e,this.y=t}Math.imul||(d=smallMulTo),BN.prototype.mulTo=function mulTo(e,t){var a,r=this.length+e.length;return a=10===this.length&&10===e.length?d(this,e,t):r<63?smallMulTo(this,e,t):r<1024?function bigMulTo(e,t,a){a.negative=t.negative^e.negative,a.length=e.length+t.length;for(var r=0,n=0,c=0;c>>26)|0)>>>26,o&=67108863}a.words[c]=d,r=o,o=n}return 0!==r?a.words[c]=r:a.length--,a.strip()}(this,e,t):jumboMulTo(this,e,t),a},FFTM.prototype.makeRBT=function makeRBT(e){for(var t=new Array(e),a=BN.prototype._countBits(e)-1,r=0;r>=1;return r},FFTM.prototype.permute=function permute(e,t,a,r,n,c){for(var o=0;o>>=1)n++;return 1<>>=13,a[2*c+1]=8191&n,n>>>=13;for(c=2*t;c>=26,t+=r/67108864|0,t+=n>>>26,this.words[a]=67108863&n}return 0!==t&&(this.words[a]=t,this.length++),this},BN.prototype.muln=function muln(e){return this.clone().imuln(e)},BN.prototype.sqr=function sqr(){return this.mul(this)},BN.prototype.isqr=function isqr(){return this.imul(this.clone())},BN.prototype.pow=function pow(e){var t=function toBitArray(e){for(var t=new Array(e.bitLength()),a=0;a>>n}return t}(e);if(0===t.length)return new BN(1);for(var a=this,r=0;r=0);var t,a=e%26,r=(e-a)/26,n=67108863>>>26-a<<26-a;if(0!==a){var c=0;for(t=0;t>>26-a}c&&(this.words[t]=c,this.length++)}if(0!==r){for(t=this.length-1;t>=0;t--)this.words[t+r]=this.words[t];for(t=0;t=0),r=t?(t-t%26)/26:0;var n=e%26,c=Math.min((e-n)/26,this.length),o=67108863^67108863>>>n<c)for(this.length-=c,s=0;s=0&&(0!==b||s>=r);s--){var u=0|this.words[s];this.words[s]=b<<26-n|u>>>n,b=u&o}return d&&0!==b&&(d.words[d.length++]=b),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},BN.prototype.ishrn=function ishrn(e,t,a){return assert(0===this.negative),this.iushrn(e,t,a)},BN.prototype.shln=function shln(e){return this.clone().ishln(e)},BN.prototype.ushln=function ushln(e){return this.clone().iushln(e)},BN.prototype.shrn=function shrn(e){return this.clone().ishrn(e)},BN.prototype.ushrn=function ushrn(e){return this.clone().iushrn(e)},BN.prototype.testn=function testn(e){assert("number"==typeof e&&e>=0);var t=e%26,a=(e-t)/26,r=1<=0);var t=e%26,a=(e-t)/26;if(assert(0===this.negative,"imaskn works only with positive numbers"),this.length<=a)return this;if(0!==t&&a++,this.length=Math.min(a,this.length),0!==t){var r=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},BN.prototype.isubn=function isubn(e){if(assert("number"==typeof e),assert(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(d/67108864|0),this.words[r+a]=67108863&n}for(;r>26,this.words[r+a]=67108863&n;if(0===o)return this.strip();for(assert(-1===o),o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},BN.prototype._wordDiv=function _wordDiv(e,t){var a=(this.length,e.length),r=this.clone(),n=e,c=0|n.words[n.length-1];0!==(a=26-this._countBits(c))&&(n=n.ushln(a),r.iushln(a),c=0|n.words[n.length-1]);var o,d=r.length-n.length;if("mod"!==t){(o=new BN(null)).length=d+1,o.words=new Array(o.length);for(var s=0;s=0;u--){var h=67108864*(0|r.words[n.length+u])+(0|r.words[n.length+u-1]);for(h=Math.min(h/c|0,67108863),r._ishlnsubmul(n,h,u);0!==r.negative;)h--,r.negative=0,r._ishlnsubmul(n,1,u),r.isZero()||(r.negative^=1);o&&(o.words[u]=h)}return o&&o.strip(),r.strip(),"div"!==t&&0!==a&&r.iushrn(a),{div:o||null,mod:r}},BN.prototype.divmod=function divmod(e,t,a){return assert(!e.isZero()),this.isZero()?{div:new BN(0),mod:new BN(0)}:0!==this.negative&&0===e.negative?(c=this.neg().divmod(e,t),"mod"!==t&&(r=c.div.neg()),"div"!==t&&(n=c.mod.neg(),a&&0!==n.negative&&n.iadd(e)),{div:r,mod:n}):0===this.negative&&0!==e.negative?(c=this.divmod(e.neg(),t),"mod"!==t&&(r=c.div.neg()),{div:r,mod:c.mod}):0!=(this.negative&e.negative)?(c=this.neg().divmod(e.neg(),t),"div"!==t&&(n=c.mod.neg(),a&&0!==n.negative&&n.isub(e)),{div:c.div,mod:n}):e.length>this.length||this.cmp(e)<0?{div:new BN(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new BN(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new BN(this.modn(e.words[0]))}:this._wordDiv(e,t);var r,n,c},BN.prototype.div=function div(e){return this.divmod(e,"div",!1).div},BN.prototype.mod=function mod(e){return this.divmod(e,"mod",!1).mod},BN.prototype.umod=function umod(e){return this.divmod(e,"mod",!0).mod},BN.prototype.divRound=function divRound(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var a=0!==t.div.negative?t.mod.isub(e):t.mod,r=e.ushrn(1),n=e.andln(1),c=a.cmp(r);return c<0||1===n&&0===c?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},BN.prototype.modn=function modn(e){assert(e<=67108863);for(var t=(1<<26)%e,a=0,r=this.length-1;r>=0;r--)a=(t*a+(0|this.words[r]))%e;return a},BN.prototype.idivn=function idivn(e){assert(e<=67108863);for(var t=0,a=this.length-1;a>=0;a--){var r=(0|this.words[a])+67108864*t;this.words[a]=r/e|0,t=r%e}return this.strip()},BN.prototype.divn=function divn(e){return this.clone().idivn(e)},BN.prototype.egcd=function egcd(e){assert(0===e.negative),assert(!e.isZero());var t=this,a=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var r=new BN(1),n=new BN(0),c=new BN(0),o=new BN(1),d=0;t.isEven()&&a.isEven();)t.iushrn(1),a.iushrn(1),++d;for(var s=a.clone(),b=t.clone();!t.isZero();){for(var u=0,h=1;0==(t.words[0]&h)&&u<26;++u,h<<=1);if(u>0)for(t.iushrn(u);u-- >0;)(r.isOdd()||n.isOdd())&&(r.iadd(s),n.isub(b)),r.iushrn(1),n.iushrn(1);for(var l=0,g=1;0==(a.words[0]&g)&&l<26;++l,g<<=1);if(l>0)for(a.iushrn(l);l-- >0;)(c.isOdd()||o.isOdd())&&(c.iadd(s),o.isub(b)),c.iushrn(1),o.iushrn(1);t.cmp(a)>=0?(t.isub(a),r.isub(c),n.isub(o)):(a.isub(t),c.isub(r),o.isub(n))}return{a:c,b:o,gcd:a.iushln(d)}},BN.prototype._invmp=function _invmp(e){assert(0===e.negative),assert(!e.isZero());var t=this,a=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var r,n=new BN(1),c=new BN(0),o=a.clone();t.cmpn(1)>0&&a.cmpn(1)>0;){for(var d=0,s=1;0==(t.words[0]&s)&&d<26;++d,s<<=1);if(d>0)for(t.iushrn(d);d-- >0;)n.isOdd()&&n.iadd(o),n.iushrn(1);for(var b=0,u=1;0==(a.words[0]&u)&&b<26;++b,u<<=1);if(b>0)for(a.iushrn(b);b-- >0;)c.isOdd()&&c.iadd(o),c.iushrn(1);t.cmp(a)>=0?(t.isub(a),n.isub(c)):(a.isub(t),c.isub(n))}return(r=0===t.cmpn(1)?n:c).cmpn(0)<0&&r.iadd(e),r},BN.prototype.gcd=function gcd(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),a=e.clone();t.negative=0,a.negative=0;for(var r=0;t.isEven()&&a.isEven();r++)t.iushrn(1),a.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;a.isEven();)a.iushrn(1);var n=t.cmp(a);if(n<0){var c=t;t=a,a=c}else if(0===n||0===a.cmpn(1))break;t.isub(a)}return a.iushln(r)},BN.prototype.invm=function invm(e){return this.egcd(e).a.umod(e)},BN.prototype.isEven=function isEven(){return 0==(1&this.words[0])},BN.prototype.isOdd=function isOdd(){return 1==(1&this.words[0])},BN.prototype.andln=function andln(e){return this.words[0]&e},BN.prototype.bincn=function bincn(e){assert("number"==typeof e);var t=e%26,a=(e-t)/26,r=1<>>26,o&=67108863,this.words[c]=o}return 0!==n&&(this.words[c]=n,this.length++),this},BN.prototype.isZero=function isZero(){return 1===this.length&&0===this.words[0]},BN.prototype.cmpn=function cmpn(e){var t,a=e<0;if(0!==this.negative&&!a)return-1;if(0===this.negative&&a)return 1;if(this.strip(),this.length>1)t=1;else{a&&(e=-e),assert(e<=67108863,"Number is too big");var r=0|this.words[0];t=r===e?0:re.length)return 1;if(this.length=0;a--){var r=0|this.words[a],n=0|e.words[a];if(r!==n){rn&&(t=1);break}}return t},BN.prototype.gtn=function gtn(e){return 1===this.cmpn(e)},BN.prototype.gt=function gt(e){return 1===this.cmp(e)},BN.prototype.gten=function gten(e){return this.cmpn(e)>=0},BN.prototype.gte=function gte(e){return this.cmp(e)>=0},BN.prototype.ltn=function ltn(e){return-1===this.cmpn(e)},BN.prototype.lt=function lt(e){return-1===this.cmp(e)},BN.prototype.lten=function lten(e){return this.cmpn(e)<=0},BN.prototype.lte=function lte(e){return this.cmp(e)<=0},BN.prototype.eqn=function eqn(e){return 0===this.cmpn(e)},BN.prototype.eq=function eq(e){return 0===this.cmp(e)},BN.red=function red(e){return new Red(e)},BN.prototype.toRed=function toRed(e){return assert(!this.red,"Already a number in reduction context"),assert(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},BN.prototype.fromRed=function fromRed(){return assert(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},BN.prototype._forceRed=function _forceRed(e){return this.red=e,this},BN.prototype.forceRed=function forceRed(e){return assert(!this.red,"Already a number in reduction context"),this._forceRed(e)},BN.prototype.redAdd=function redAdd(e){return assert(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},BN.prototype.redIAdd=function redIAdd(e){return assert(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},BN.prototype.redSub=function redSub(e){return assert(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},BN.prototype.redISub=function redISub(e){return assert(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},BN.prototype.redShl=function redShl(e){return assert(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},BN.prototype.redMul=function redMul(e){return assert(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},BN.prototype.redIMul=function redIMul(e){return assert(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},BN.prototype.redSqr=function redSqr(){return assert(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},BN.prototype.redISqr=function redISqr(){return assert(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},BN.prototype.redSqrt=function redSqrt(){return assert(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},BN.prototype.redInvm=function redInvm(){return assert(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},BN.prototype.redNeg=function redNeg(){return assert(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},BN.prototype.redPow=function redPow(e){return assert(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var s={k256:null,p224:null,p192:null,p25519:null};function MPrime(e,t){this.name=e,this.p=new BN(t,16),this.n=this.p.bitLength(),this.k=new BN(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function K256(){MPrime.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function P224(){MPrime.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function P192(){MPrime.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function P25519(){MPrime.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function Red(e){if("string"==typeof e){var t=BN._prime(e);this.m=t.p,this.prime=t}else assert(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function Mont(e){Red.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new BN(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)}MPrime.prototype._tmp=function _tmp(){var e=new BN(null);return e.words=new Array(Math.ceil(this.n/13)),e},MPrime.prototype.ireduce=function ireduce(e){var t,a=e;do{this.split(a,this.tmp),t=(a=(a=this.imulK(a)).iadd(this.tmp)).bitLength()}while(t>this.n);var r=t0?a.isub(this.p):void 0!==a.strip?a.strip():a._strip(),a},MPrime.prototype.split=function split(e,t){e.iushrn(this.n,0,t)},MPrime.prototype.imulK=function imulK(e){return e.imul(this.k)},inherits(K256,MPrime),K256.prototype.split=function split(e,t){for(var a=4194303,r=Math.min(e.length,9),n=0;n>>22,c=o}c>>>=22,e.words[n-10]=c,0===c&&e.length>10?e.length-=10:e.length-=9},K256.prototype.imulK=function imulK(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,a=0;a>>=26,e.words[a]=n,t=r}return 0!==t&&(e.words[e.length++]=t),e},BN._prime=function prime(e){if(s[e])return s[e];var prime;if("k256"===e)prime=new K256;else if("p224"===e)prime=new P224;else if("p192"===e)prime=new P192;else{if("p25519"!==e)throw new Error("Unknown prime "+e);prime=new P25519}return s[e]=prime,prime},Red.prototype._verify1=function _verify1(e){assert(0===e.negative,"red works only with positives"),assert(e.red,"red works only with red numbers")},Red.prototype._verify2=function _verify2(e,t){assert(0==(e.negative|t.negative),"red works only with positives"),assert(e.red&&e.red===t.red,"red works only with red numbers")},Red.prototype.imod=function imod(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},Red.prototype.neg=function neg(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},Red.prototype.add=function add(e,t){this._verify2(e,t);var a=e.add(t);return a.cmp(this.m)>=0&&a.isub(this.m),a._forceRed(this)},Red.prototype.iadd=function iadd(e,t){this._verify2(e,t);var a=e.iadd(t);return a.cmp(this.m)>=0&&a.isub(this.m),a},Red.prototype.sub=function sub(e,t){this._verify2(e,t);var a=e.sub(t);return a.cmpn(0)<0&&a.iadd(this.m),a._forceRed(this)},Red.prototype.isub=function isub(e,t){this._verify2(e,t);var a=e.isub(t);return a.cmpn(0)<0&&a.iadd(this.m),a},Red.prototype.shl=function shl(e,t){return this._verify1(e),this.imod(e.ushln(t))},Red.prototype.imul=function imul(e,t){return this._verify2(e,t),this.imod(e.imul(t))},Red.prototype.mul=function mul(e,t){return this._verify2(e,t),this.imod(e.mul(t))},Red.prototype.isqr=function isqr(e){return this.imul(e,e.clone())},Red.prototype.sqr=function sqr(e){return this.mul(e,e)},Red.prototype.sqrt=function sqrt(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(assert(t%2==1),3===t){var a=this.m.add(new BN(1)).iushrn(2);return this.pow(e,a)}for(var r=this.m.subn(1),n=0;!r.isZero()&&0===r.andln(1);)n++,r.iushrn(1);assert(!r.isZero());var c=new BN(1).toRed(this),o=c.redNeg(),d=this.m.subn(1).iushrn(1),s=this.m.bitLength();for(s=new BN(2*s*s).toRed(this);0!==this.pow(s,d).cmp(o);)s.redIAdd(o);for(var b=this.pow(s,r),u=this.pow(e,r.addn(1).iushrn(1)),h=this.pow(e,r),l=n;0!==h.cmp(c);){for(var g=h,p=0;0!==g.cmp(c);p++)g=g.redSqr();assert(p=0;r--){for(var s=t.words[r],b=d-1;b>=0;b--){var u=s>>b&1;n!==a[0]&&(n=this.sqr(n)),0!==u||0!==c?(c<<=1,c|=u,(4===++o||0===r&&0===b)&&(n=this.mul(n,a[c]),o=0,c=0)):o=0}d=26}return n},Red.prototype.convertTo=function convertTo(e){var t=e.umod(this.m);return t===e?t.clone():t},Red.prototype.convertFrom=function convertFrom(e){var t=e.clone();return t.red=null,t},BN.mont=function mont(e){return new Mont(e)},inherits(Mont,Red),Mont.prototype.convertTo=function convertTo(e){return this.imod(e.ushln(this.shift))},Mont.prototype.convertFrom=function convertFrom(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},Mont.prototype.imul=function imul(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var a=e.imul(t),r=a.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=a.isub(r).iushrn(this.shift),c=n;return n.cmp(this.m)>=0?c=n.isub(this.m):n.cmpn(0)<0&&(c=n.iadd(this.m)),c._forceRed(this)},Mont.prototype.mul=function mul(e,t){if(e.isZero()||t.isZero())return new BN(0)._forceRed(this);var a=e.mul(t),r=a.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=a.isub(r).iushrn(this.shift),c=n;return n.cmp(this.m)>=0?c=n.isub(this.m):n.cmpn(0)<0&&(c=n.iadd(this.m)),c._forceRed(this)},Mont.prototype.invm=function invm(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e=a.nmd(e),this)},e=>{function assert(e,t){if(!e)throw new Error(t||"Assertion failed")}e.exports=assert,assert.equal=function assertEqual(e,t,a){if(e!=t)throw new Error(a||"Assertion failed: "+e+" != "+t)}},e=>{function assert(e,t){if(!e)throw new Error(t||"Assertion failed")}e.exports=assert,assert.equal=function assertEqual(e,t,a){if(e!=t)throw new Error(a||"Assertion failed: "+e+" != "+t)}},e=>{function assert(e,t){if(!e)throw new Error(t||"Assertion failed")}e.exports=assert,assert.equal=function assertEqual(e,t,a){if(e!=t)throw new Error(a||"Assertion failed: "+e+" != "+t)}},e=>{function assert(e,t){if(!e)throw new Error(t||"Assertion failed")}e.exports=assert,assert.equal=function assertEqual(e,t,a){if(e!=t)throw new Error(a||"Assertion failed: "+e+" != "+t)}},e=>{function assert(e,t){if(!e)throw new Error(t||"Assertion failed")}e.exports=assert,assert.equal=function assertEqual(e,t,a){if(e!=t)throw new Error(a||"Assertion failed: "+e+" != "+t)}},(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalkController=t.BaseTrie=t.SecureTrie=t.CheckpointTrie=void 0;var r=a(297);Object.defineProperty(t,"CheckpointTrie",{enumerable:!0,get:function(){return r.CheckpointTrie}});var n=a(558);Object.defineProperty(t,"SecureTrie",{enumerable:!0,get:function(){return n.SecureTrie}});var c=a(184);Object.defineProperty(t,"BaseTrie",{enumerable:!0,get:function(){return c.Trie}});var o=a(305);Object.defineProperty(t,"WalkController",{enumerable:!0,get:function(){return o.WalkController}})},(e,t,a)=>{var r=a(11),n=a(67),c=r.String,o=r.TypeError;e.exports=function(e){if(n(e))return e;throw o(c(e)+" is not an object")}},(e,t,a)=>{var r=a(166),n=Function.prototype.call;e.exports=r?n.bind(n):function(){return n.apply(n,arguments)}},(e,t,a)=>{"use strict";var r=a(283);e.exports=r.call(Function.call,Object.prototype.hasOwnProperty)},function(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[a]}})}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||r(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),n(a(1475),t),n(a(1476),t),n(a(1477),t),n(a(606),t),n(a(1478),t)},(e,t,a)=>{var r=a(5),n=Object.getOwnPropertyDescriptors||function getOwnPropertyDescriptors(e){for(var t=Object.keys(e),a={},r=0;r=n)return e;switch(e){case"%s":return String(r[a++]);case"%d":return Number(r[a++]);case"%j":try{return JSON.stringify(r[a++])}catch(e){return"[Circular]"}default:return e}})),d=r[a];a=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),isBoolean(a)?r.showHidden=a:a&&t._extend(r,a),isUndefined(r.showHidden)&&(r.showHidden=!1),isUndefined(r.depth)&&(r.depth=2),isUndefined(r.colors)&&(r.colors=!1),isUndefined(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=stylizeWithColor),formatValue(r,e,r.depth)}function stylizeWithColor(e,t){var a=inspect.styles[t];return a?"["+inspect.colors[a][0]+"m"+e+"["+inspect.colors[a][1]+"m":e}function stylizeNoColor(e,t){return e}function formatValue(e,a,r){if(e.customInspect&&a&&isFunction(a.inspect)&&a.inspect!==t.inspect&&(!a.constructor||a.constructor.prototype!==a)){var n=a.inspect(r,e);return isString(n)||(n=formatValue(e,n,r)),n}var c=function formatPrimitive(e,t){if(isUndefined(t))return e.stylize("undefined","undefined");if(isString(t)){var a="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(a,"string")}if(isNumber(t))return e.stylize(""+t,"number");if(isBoolean(t))return e.stylize(""+t,"boolean");if(isNull(t))return e.stylize("null","null")}(e,a);if(c)return c;var o=Object.keys(a),d=function arrayToHash(e){var t={};return e.forEach((function(e,a){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(a)),isError(a)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return formatError(a);if(0===o.length){if(isFunction(a)){var s=a.name?": "+a.name:"";return e.stylize("[Function"+s+"]","special")}if(isRegExp(a))return e.stylize(RegExp.prototype.toString.call(a),"regexp");if(isDate(a))return e.stylize(Date.prototype.toString.call(a),"date");if(isError(a))return formatError(a)}var b,u="",h=!1,l=["{","}"];(isArray(a)&&(h=!0,l=["[","]"]),isFunction(a))&&(u=" [Function"+(a.name?": "+a.name:"")+"]");return isRegExp(a)&&(u=" "+RegExp.prototype.toString.call(a)),isDate(a)&&(u=" "+Date.prototype.toUTCString.call(a)),isError(a)&&(u=" "+formatError(a)),0!==o.length||h&&0!=a.length?r<0?isRegExp(a)?e.stylize(RegExp.prototype.toString.call(a),"regexp"):e.stylize("[Object]","special"):(e.seen.push(a),b=h?function formatArray(e,t,a,r,n){for(var c=[],o=0,d=t.length;o=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return a[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+a[1];return a[0]+t+" "+e.join(", ")+" "+a[1]}(b,u,l)):l[0]+u+l[1]}function formatError(e){return"["+Error.prototype.toString.call(e)+"]"}function formatProperty(e,t,a,r,n,c){var o,d,s;if((s=Object.getOwnPropertyDescriptor(t,n)||{value:t[n]}).get?d=s.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):s.set&&(d=e.stylize("[Setter]","special")),hasOwnProperty(r,n)||(o="["+n+"]"),d||(e.seen.indexOf(s.value)<0?(d=isNull(a)?formatValue(e,s.value,null):formatValue(e,s.value,a-1)).indexOf("\n")>-1&&(d=c?d.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+d.split("\n").map((function(e){return" "+e})).join("\n")):d=e.stylize("[Circular]","special")),isUndefined(o)){if(c&&n.match(/^\d+$/))return d;(o=JSON.stringify(""+n)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=e.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=e.stylize(o,"string"))}return o+": "+d}function isArray(e){return Array.isArray(e)}function isBoolean(e){return"boolean"==typeof e}function isNull(e){return null===e}function isNumber(e){return"number"==typeof e}function isString(e){return"string"==typeof e}function isUndefined(e){return void 0===e}function isRegExp(e){return isObject(e)&&"[object RegExp]"===objectToString(e)}function isObject(e){return"object"==typeof e&&null!==e}function isDate(e){return isObject(e)&&"[object Date]"===objectToString(e)}function isError(e){return isObject(e)&&("[object Error]"===objectToString(e)||e instanceof Error)}function isFunction(e){return"function"==typeof e}function objectToString(e){return Object.prototype.toString.call(e)}function pad(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(e){if(e=e.toUpperCase(),!o[e])if(d.test(e)){var a=r.pid;o[e]=function(){var r=t.format.apply(t,arguments);console.error("%s %d: %s",e,a,r)}}else o[e]=function(){};return o[e]},t.inspect=inspect,inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},inspect.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.types=a(826),t.isArray=isArray,t.isBoolean=isBoolean,t.isNull=isNull,t.isNullOrUndefined=function isNullOrUndefined(e){return null==e},t.isNumber=isNumber,t.isString=isString,t.isSymbol=function isSymbol(e){return"symbol"==typeof e},t.isUndefined=isUndefined,t.isRegExp=isRegExp,t.types.isRegExp=isRegExp,t.isObject=isObject,t.isDate=isDate,t.types.isDate=isDate,t.isError=isError,t.types.isNativeError=isError,t.isFunction=isFunction,t.isPrimitive=function isPrimitive(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=a(833);var b=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function timestamp(){var e=new Date,t=[pad(e.getHours()),pad(e.getMinutes()),pad(e.getSeconds())].join(":");return[e.getDate(),b[e.getMonth()],t].join(" ")}function hasOwnProperty(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){console.log("%s - %s",timestamp(),t.format.apply(t,arguments))},t.inherits=a(6),t._extend=function(e,t){if(!t||!isObject(t))return e;for(var a=Object.keys(t),r=a.length;r--;)e[a[r]]=t[a[r]];return e};var u="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function callbackifyOnRejected(e,t){if(!e){var a=new Error("Promise was rejected with a falsy value");a.reason=e,e=a}return t(e)}t.promisify=function promisify(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(u&&e[u]){var t;if("function"!=typeof(t=e[u]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,u,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,a,r=new Promise((function(e,r){t=e,a=r})),n=[],c=0;c{"use strict";var r=a(5);function assertPath(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function normalizeStringPosix(e,t){for(var a,r="",n=0,c=-1,o=0,d=0;d<=e.length;++d){if(d2){var s=r.lastIndexOf("/");if(s!==r.length-1){-1===s?(r="",n=0):n=(r=r.slice(0,s)).length-1-r.lastIndexOf("/"),c=d,o=0;continue}}else if(2===r.length||1===r.length){r="",n=0,c=d,o=0;continue}t&&(r.length>0?r+="/..":r="..",n=2)}else r.length>0?r+="/"+e.slice(c+1,d):r=e.slice(c+1,d),n=d-c-1;c=d,o=0}else 46===a&&-1!==o?++o:o=-1}return r}var n={resolve:function resolve(){for(var e,t="",a=!1,n=arguments.length-1;n>=-1&&!a;n--){var c;n>=0?c=arguments[n]:(void 0===e&&(e=r.cwd()),c=e),assertPath(c),0!==c.length&&(t=c+"/"+t,a=47===c.charCodeAt(0))}return t=normalizeStringPosix(t,!a),a?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function normalize(e){if(assertPath(e),0===e.length)return".";var t=47===e.charCodeAt(0),a=47===e.charCodeAt(e.length-1);return 0!==(e=normalizeStringPosix(e,!t)).length||t||(e="."),e.length>0&&a&&(e+="/"),t?"/"+e:e},isAbsolute:function isAbsolute(e){return assertPath(e),e.length>0&&47===e.charCodeAt(0)},join:function join(){if(0===arguments.length)return".";for(var e,t=0;t0&&(void 0===e?e=a:e+="/"+a)}return void 0===e?".":n.normalize(e)},relative:function relative(e,t){if(assertPath(e),assertPath(t),e===t)return"";if((e=n.resolve(e))===(t=n.resolve(t)))return"";for(var a=1;as){if(47===t.charCodeAt(o+u))return t.slice(o+u+1);if(0===u)return t.slice(o+u)}else c>s&&(47===e.charCodeAt(a+u)?b=u:0===u&&(b=0));break}var h=e.charCodeAt(a+u);if(h!==t.charCodeAt(o+u))break;47===h&&(b=u)}var l="";for(u=a+b+1;u<=r;++u)u!==r&&47!==e.charCodeAt(u)||(0===l.length?l+="..":l+="/..");return l.length>0?l+t.slice(o+b):(o+=b,47===t.charCodeAt(o)&&++o,t.slice(o))},_makeLong:function _makeLong(e){return e},dirname:function dirname(e){if(assertPath(e),0===e.length)return".";for(var t=e.charCodeAt(0),a=47===t,r=-1,n=!0,c=e.length-1;c>=1;--c)if(47===(t=e.charCodeAt(c))){if(!n){r=c;break}}else n=!1;return-1===r?a?"/":".":a&&1===r?"//":e.slice(0,r)},basename:function basename(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');assertPath(e);var a,r=0,n=-1,c=!0;if(void 0!==t&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var o=t.length-1,d=-1;for(a=e.length-1;a>=0;--a){var s=e.charCodeAt(a);if(47===s){if(!c){r=a+1;break}}else-1===d&&(c=!1,d=a+1),o>=0&&(s===t.charCodeAt(o)?-1==--o&&(n=a):(o=-1,n=d))}return r===n?n=d:-1===n&&(n=e.length),e.slice(r,n)}for(a=e.length-1;a>=0;--a)if(47===e.charCodeAt(a)){if(!c){r=a+1;break}}else-1===n&&(c=!1,n=a+1);return-1===n?"":e.slice(r,n)},extname:function extname(e){assertPath(e);for(var t=-1,a=0,r=-1,n=!0,c=0,o=e.length-1;o>=0;--o){var d=e.charCodeAt(o);if(47!==d)-1===r&&(n=!1,r=o+1),46===d?-1===t?t=o:1!==c&&(c=1):-1!==t&&(c=-1);else if(!n){a=o+1;break}}return-1===t||-1===r||0===c||1===c&&t===r-1&&t===a+1?"":e.slice(t,r)},format:function format(e){if(null===e||"object"!=typeof e)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return function _format(e,t){var a=t.dir||t.root,r=t.base||(t.name||"")+(t.ext||"");return a?a===t.root?a+r:a+e+r:r}("/",e)},parse:function parse(e){assertPath(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return t;var a,r=e.charCodeAt(0),n=47===r;n?(t.root="/",a=1):a=0;for(var c=-1,o=0,d=-1,s=!0,b=e.length-1,u=0;b>=a;--b)if(47!==(r=e.charCodeAt(b)))-1===d&&(s=!1,d=b+1),46===r?-1===c?c=b:1!==u&&(u=1):-1!==c&&(u=-1);else if(!s){o=b+1;break}return-1===c||-1===d||0===u||1===u&&c===d-1&&c===o+1?-1!==d&&(t.base=t.name=0===o&&n?e.slice(1,d):e.slice(o,d)):(0===o&&n?(t.name=e.slice(1,c),t.base=e.slice(1,d)):(t.name=e.slice(o,c),t.base=e.slice(o,d)),t.ext=e.slice(c,d)),o>0?t.dir=e.slice(0,o-1):n&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};n.posix=n,e.exports=n},(e,t,a)=>{"use strict";var r=a(5),n=65536,c=4294967295;var o=a(7).Buffer,d=a.g.crypto||a.g.msCrypto;d&&d.getRandomValues?e.exports=function randomBytes(e,t){if(e>c)throw new RangeError("requested too many random bytes");var a=o.allocUnsafe(e);if(e>0)if(e>n)for(var s=0;s{var r=a(7).Buffer;function Hash(e,t){this._block=r.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}Hash.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=r.from(e,t));for(var a=this._block,n=this._blockSize,c=e.length,o=this._len,d=0;d=this._finalSize&&(this._update(this._block),this._block.fill(0));var a=8*this._len;if(a<=4294967295)this._block.writeUInt32BE(a,this._blockSize-4);else{var r=(4294967295&a)>>>0,n=(a-r)/4294967296;this._block.writeUInt32BE(n,this._blockSize-8),this._block.writeUInt32BE(r,this._blockSize-4)}this._update(this._block);var c=this._hash();return e?c.toString(e):c},Hash.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e.exports=Hash},(e,t,a)=>{"use strict";var r=a(19);const n=new WeakMap,c=new WeakMap,o=new WeakMap,d=Symbol("anyProducer"),s=Promise.resolve(),b=Symbol("listenerAdded"),u=Symbol("listenerRemoved");let h=!1;function assertEventName(e){if("string"!=typeof e&&"symbol"!=typeof e)throw new TypeError("eventName must be a string or a symbol")}function assertListener(e){if("function"!=typeof e)throw new TypeError("listener must be a function")}function getListeners(e,t){const a=c.get(e);return a.has(t)||a.set(t,new Set),a.get(t)}function getEventProducers(e,t){const a="string"==typeof t||"symbol"==typeof t?t:d,r=o.get(e);return r.has(a)||r.set(a,new Set),r.get(a)}function iterator(e,t){t=Array.isArray(t)?t:[t];let a=!1,flush=()=>{},r=[];const n={enqueue(e){r.push(e),flush()},finish(){a=!0,flush()}};for(const a of t)getEventProducers(e,a).add(n);return{async next(){return r?0===r.length?a?(r=void 0,this.next()):(await new Promise((e=>{flush=e})),this.next()):{done:!1,value:await r.shift()}:{done:!0}},async return(a){r=void 0;for(const a of t)getEventProducers(e,a).delete(n);return flush(),arguments.length>0?{done:!0,value:await a}:{done:!0}},[Symbol.asyncIterator](){return this}}}function defaultMethodNamesOrAssert(e){if(void 0===e)return l;if(!Array.isArray(e))throw new TypeError("`methodNames` must be an array of strings");for(const t of e)if(!l.includes(t)){if("string"!=typeof t)throw new TypeError("`methodNames` element must be a string");throw new Error(`${t} is not Emittery method`)}return e}const isListenerSymbol=e=>e===b||e===u;class Emittery{static mixin(e,t){return t=defaultMethodNamesOrAssert(t),a=>{if("function"!=typeof a)throw new TypeError("`target` must be function");for(const e of t)if(void 0!==a.prototype[e])throw new Error(`The property \`${e}\` already exists on \`target\``);Object.defineProperty(a.prototype,e,{enumerable:!1,get:function getEmitteryProperty(){return Object.defineProperty(this,e,{enumerable:!1,value:new Emittery}),this[e]}});const emitteryMethodCaller=t=>function(...a){return this[e][t](...a)};for(const e of t)Object.defineProperty(a.prototype,e,{enumerable:!1,value:emitteryMethodCaller(e)});return a}}static get isDebugEnabled(){if("object"!=typeof r)return h;const{env:e}=r||{env:{}};return"emittery"===e.DEBUG||"*"===e.DEBUG||h}static set isDebugEnabled(e){h=e}constructor(e={}){n.set(this,new Set),c.set(this,new Map),o.set(this,new Map),this.debug=e.debug||{},void 0===this.debug.enabled&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(e,t,a,r)=>{r=JSON.stringify(r),"symbol"==typeof a&&(a=a.toString());const n=new Date,c=`${n.getHours()}:${n.getMinutes()}:${n.getSeconds()}.${n.getMilliseconds()}`;console.log(`[${c}][emittery:${e}][${t}] Event Name: ${a}\n\tdata: ${r}`)})}logIfDebugEnabled(e,t,a){(Emittery.isDebugEnabled||this.debug.enabled)&&this.debug.logger(e,this.debug.name,t,a)}on(e,t){assertListener(t),e=Array.isArray(e)?e:[e];for(const a of e)assertEventName(a),getListeners(this,a).add(t),this.logIfDebugEnabled("subscribe",a,void 0),isListenerSymbol(a)||this.emit(b,{eventName:a,listener:t});return this.off.bind(this,e,t)}off(e,t){assertListener(t),e=Array.isArray(e)?e:[e];for(const a of e)assertEventName(a),getListeners(this,a).delete(t),this.logIfDebugEnabled("unsubscribe",a,void 0),isListenerSymbol(a)||this.emit(u,{eventName:a,listener:t})}once(e){return new Promise((t=>{const a=this.on(e,(e=>{a(),t(e)}))}))}events(e){e=Array.isArray(e)?e:[e];for(const t of e)assertEventName(t);return iterator(this,e)}async emit(e,t){assertEventName(e),this.logIfDebugEnabled("emit",e,t),function enqueueProducers(e,t,a){const r=o.get(e);if(r.has(t))for(const e of r.get(t))e.enqueue(a);if(r.has(d)){const e=Promise.all([t,a]);for(const t of r.get(d))t.enqueue(e)}}(this,e,t);const a=getListeners(this,e),r=n.get(this),c=[...a],b=isListenerSymbol(e)?[]:[...r];await s,await Promise.all([...c.map((async e=>{if(a.has(e))return e(t)})),...b.map((async a=>{if(r.has(a))return a(e,t)}))])}async emitSerial(e,t){assertEventName(e),this.logIfDebugEnabled("emitSerial",e,t);const a=getListeners(this,e),r=n.get(this),c=[...a],o=[...r];await s;for(const e of c)a.has(e)&&await e(t);for(const a of o)r.has(a)&&await a(e,t)}onAny(e){return assertListener(e),this.logIfDebugEnabled("subscribeAny",void 0,void 0),n.get(this).add(e),this.emit(b,{listener:e}),this.offAny.bind(this,e)}anyEvent(){return iterator(this)}offAny(e){assertListener(e),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),this.emit(u,{listener:e}),n.get(this).delete(e)}clearListeners(e){e=Array.isArray(e)?e:[e];for(const t of e)if(this.logIfDebugEnabled("clear",t,void 0),"string"==typeof t||"symbol"==typeof t){getListeners(this,t).clear();const e=getEventProducers(this,t);for(const t of e)t.finish();e.clear()}else{n.get(this).clear();for(const e of c.get(this).values())e.clear();for(const e of o.get(this).values()){for(const t of e)t.finish();e.clear()}}}listenerCount(e){e=Array.isArray(e)?e:[e];let t=0;for(const a of e)if("string"!=typeof a){void 0!==a&&assertEventName(a),t+=n.get(this).size;for(const e of c.get(this).values())t+=e.size;for(const e of o.get(this).values())t+=e.size}else t+=n.get(this).size+getListeners(this,a).size+getEventProducers(this,a).size+getEventProducers(this).size;return t}bindMethods(e,t){if("object"!=typeof e||null===e)throw new TypeError("`target` must be an object");t=defaultMethodNamesOrAssert(t);for(const a of t){if(void 0!==e[a])throw new Error(`The property \`${a}\` already exists on \`target\``);Object.defineProperty(e,a,{enumerable:!1,value:this[a].bind(this)})}}}const l=Object.getOwnPropertyNames(Emittery.prototype).filter((e=>"constructor"!==e));Object.defineProperty(Emittery,"listenerAdded",{value:b,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(Emittery,"listenerRemoved",{value:u,writable:!1,enumerable:!0,configurable:!1}),e.exports=Emittery},(e,t,a)=>{var r=a(36).Buffer;function Hash(e,t){this._block=r.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}Hash.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=r.from(e,t));for(var a=this._block,n=this._blockSize,c=e.length,o=this._len,d=0;d=this._finalSize&&(this._update(this._block),this._block.fill(0));var a=8*this._len;if(a<=4294967295)this._block.writeUInt32BE(a,this._blockSize-4);else{var r=(4294967295&a)>>>0,n=(a-r)/4294967296;this._block.writeUInt32BE(n,this._blockSize-8),this._block.writeUInt32BE(r,this._blockSize-4)}this._update(this._block);var c=this._hash();return e?c.toString(e):c},Hash.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e.exports=Hash},(e,t,a)=>{var r=a(37).Buffer;function Hash(e,t){this._block=r.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}Hash.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=r.from(e,t));for(var a=this._block,n=this._blockSize,c=e.length,o=this._len,d=0;d=this._finalSize&&(this._update(this._block),this._block.fill(0));var a=8*this._len;if(a<=4294967295)this._block.writeUInt32BE(a,this._blockSize-4);else{var r=(4294967295&a)>>>0,n=(a-r)/4294967296;this._block.writeUInt32BE(n,this._blockSize-8),this._block.writeUInt32BE(r,this._blockSize-4)}this._update(this._block);var c=this._hash();return e?c.toString(e):c},Hash.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e.exports=Hash},(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.N_DIV_2=t.isAccessList=t.isAccessListBuffer=t.Capability=void 0;var r=a(47);function isAccessListBuffer(e){if(0===e.length)return!0;var t=e[0];return!!Array.isArray(t)}!function(e){e[e.EIP155ReplayProtection=155]="EIP155ReplayProtection",e[e.EIP1559FeeMarket=1559]="EIP1559FeeMarket",e[e.EIP2718TypedTransaction=2718]="EIP2718TypedTransaction",e[e.EIP2930AccessLists=2930]="EIP2930AccessLists"}(t.Capability||(t.Capability={})),t.isAccessListBuffer=isAccessListBuffer,t.isAccessList=function isAccessList(e){return!isAccessListBuffer(e)},t.N_DIV_2=new r.BN("7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0",16)},(e,t,a)=>{var r=a(38).Buffer;function Hash(e,t){this._block=r.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}Hash.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=r.from(e,t));for(var a=this._block,n=this._blockSize,c=e.length,o=this._len,d=0;d=this._finalSize&&(this._update(this._block),this._block.fill(0));var a=8*this._len;if(a<=4294967295)this._block.writeUInt32BE(a,this._blockSize-4);else{var r=(4294967295&a)>>>0,n=(a-r)/4294967296;this._block.writeUInt32BE(n,this._blockSize-8),this._block.writeUInt32BE(r,this._blockSize-4)}this._update(this._block);var c=this._hash();return e?c.toString(e):c},Hash.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e.exports=Hash},(e,t,a)=>{var r=a(23).Buffer;function Hash(e,t){this._block=r.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}Hash.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=r.from(e,t));for(var a=this._block,n=this._blockSize,c=e.length,o=this._len,d=0;d=this._finalSize&&(this._update(this._block),this._block.fill(0));var a=8*this._len;if(a<=4294967295)this._block.writeUInt32BE(a,this._blockSize-4);else{var r=(4294967295&a)>>>0,n=(a-r)/4294967296;this._block.writeUInt32BE(n,this._blockSize-8),this._block.writeUInt32BE(r,this._blockSize-4)}this._update(this._block);var c=this._hash();return e?c.toString(e):c},Hash.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e.exports=Hash},e=>{e.exports=function extend(){for(var e={},a=0;a{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalize=void 0;t.normalize=e=>e},(e,t,a)=>{var r=a(31).Buffer;function Hash(e,t){this._block=r.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}Hash.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=r.from(e,t));for(var a=this._block,n=this._blockSize,c=e.length,o=this._len,d=0;d=this._finalSize&&(this._update(this._block),this._block.fill(0));var a=8*this._len;if(a<=4294967295)this._block.writeUInt32BE(a,this._blockSize-4);else{var r=(4294967295&a)>>>0,n=(a-r)/4294967296;this._block.writeUInt32BE(n,this._blockSize-8),this._block.writeUInt32BE(r,this._blockSize-4)}this._update(this._block);var c=this._hash();return e?c.toString(e):c},Hash.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e.exports=Hash},(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.N_DIV_2=t.isAccessList=t.isAccessListBuffer=t.Capability=void 0;var r=a(1);function isAccessListBuffer(e){if(0===e.length)return!0;var t=e[0];return!!Array.isArray(t)}!function(e){e[e.EIP155ReplayProtection=155]="EIP155ReplayProtection",e[e.EIP1559FeeMarket=1559]="EIP1559FeeMarket",e[e.EIP2718TypedTransaction=2718]="EIP2718TypedTransaction",e[e.EIP2930AccessLists=2930]="EIP2930AccessLists"}(t.Capability||(t.Capability={})),t.isAccessListBuffer=isAccessListBuffer,t.isAccessList=function isAccessList(e){return!isAccessListBuffer(e)},t.N_DIV_2=new r.BN("7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0",16)},(e,t,a)=>{var r=a(497),n=a(261);e.exports=function(e){return r(n(e))}},(e,t,a)=>{var r=a(49),n=a(70),c=a(169);e.exports=r?function(e,t,a){return n.f(e,t,c(1,a))}:function(e,t,a){return e[t]=a,e}},(e,t,a)=>{var r=a(0).Buffer;const n=a(706),c=n.cwrap("ec_add","string",["string"]),o=n.cwrap("ec_mul","string",["string"]),d=n.cwrap("ec_pairing","string",["string"]);e.exports={add:function bn128add(e){return r.from(c(e.toString("hex")),"hex")},mul:function bn128mul(e){return r.from(o(e.toString("hex")),"hex")},pairing:function bn128pairing(e){return r.from(d(e.toString("hex")),"hex")}}},e=>{"use strict";e.exports=function IsPropertyKey(e){return"string"==typeof e||"symbol"==typeof e}},(e,t,a)=>{"use strict";var r=a(8).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.baToJSON=t.addHexPrefix=t.toUnsigned=t.fromSigned=t.bufferToHex=t.bufferToInt=t.toBuffer=t.stripZeros=t.unpad=t.setLengthRight=t.setLength=t.setLengthLeft=t.zeros=void 0;var n=a(114),c=a(78);t.zeros=function(e){return r.allocUnsafe(e).fill(0)},t.setLengthLeft=function(e,a,r){void 0===r&&(r=!1);var n=t.zeros(a);return e=t.toBuffer(e),r?e.length0&&"0"===t.toString();)t=(e=e.slice(1))[0];return e},t.stripZeros=t.unpad,t.toBuffer=function(e){if(!r.isBuffer(e))if(Array.isArray(e))e=r.from(e);else if("string"==typeof e){if(!n.isHexString(e))throw new Error("Cannot convert string to buffer. toBuffer only supports 0x-prefixed hex strings and this string was given: "+e);e=r.from(n.padToEven(n.stripHexPrefix(e)),"hex")}else if("number"==typeof e)e=n.intToBuffer(e);else if(null==e)e=r.allocUnsafe(0);else if(c.isBN(e))e=e.toArrayLike(r);else{if(!e.toArray)throw new Error("invalid type");e=r.from(e.toArray())}return e},t.bufferToInt=function(e){return new c(t.toBuffer(e)).toNumber()},t.bufferToHex=function(e){return"0x"+(e=t.toBuffer(e)).toString("hex")},t.fromSigned=function(e){return new c(e).fromTwos(256)},t.toUnsigned=function(e){return r.from(e.toTwos(256).toArray())},t.addHexPrefix=function(e){return"string"!=typeof e||n.isHexPrefixed(e)?e:"0x"+e},t.baToJSON=function(e){if(r.isBuffer(e))return"0x"+e.toString("hex");if(e instanceof Array){for(var a=[],n=0;n{"use strict";var r=a(5),n=Object.keys||function(e){var t=[];for(var a in e)t.push(a);return t};e.exports=Duplex;var c=a(201),o=a(202);a(6)(Duplex,c);for(var d=n(o.prototype),s=0;s{"use strict";var r=a(283),n=a(12),c=n("%Function.prototype.apply%"),o=n("%Function.prototype.call%"),d=n("%Reflect.apply%",!0)||r.call(o,c),s=n("%Object.getOwnPropertyDescriptor%",!0),b=n("%Object.defineProperty%",!0),u=n("%Math.max%");if(b)try{b({},"a",{value:1})}catch(e){b=null}e.exports=function callBind(e){var t=d(r,o,arguments);if(s&&b){var a=s(t,"length");a.configurable&&b(t,"length",{value:1+u(0,e.length-(arguments.length-1))})}return t};var h=function applyBind(){return d(r,c,arguments)};b?b(e.exports,"apply",{value:h}):e.exports.apply=h},e=>{"use strict";var t={};function createErrorType(e,a,r){r||(r=Error);var n=function(e){function NodeError(t,r,n){return e.call(this,function getMessage(e,t,r){return"string"==typeof a?a:a(e,t,r)}(t,r,n))||this}return function _inheritsLoose(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}(NodeError,e),NodeError}(r);n.prototype.name=r.name,n.prototype.code=e,t[e]=n}function oneOf(e,t){if(Array.isArray(e)){var a=e.length;return e=e.map((function(e){return String(e)})),a>2?"one of ".concat(t," ").concat(e.slice(0,a-1).join(", "),", or ")+e[a-1]:2===a?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}createErrorType("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),createErrorType("ERR_INVALID_ARG_TYPE",(function(e,t,a){var r,n;if("string"==typeof t&&function startsWith(e,t,a){return e.substr(!a||a<0?0:+a,t.length)===t}(t,"not ")?(r="must not be",t=t.replace(/^not /,"")):r="must be",function endsWith(e,t,a){return(void 0===a||a>e.length)&&(a=e.length),e.substring(a-t.length,a)===t}(e," argument"))n="The ".concat(e," ").concat(r," ").concat(oneOf(t,"type"));else{var c=function includes(e,t,a){return"number"!=typeof a&&(a=0),!(a+t.length>e.length)&&-1!==e.indexOf(t,a)}(e,".")?"property":"argument";n='The "'.concat(e,'" ').concat(c," ").concat(r," ").concat(oneOf(t,"type"))}return n+=". Received type ".concat(typeof a)}),TypeError),createErrorType("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),createErrorType("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),createErrorType("ERR_STREAM_PREMATURE_CLOSE","Premature close"),createErrorType("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),createErrorType("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),createErrorType("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),createErrorType("ERR_STREAM_WRITE_AFTER_END","write after end"),createErrorType("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),createErrorType("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),createErrorType("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.a=t},(e,t,a)=>{var r=a(2).Buffer;e.exports=function xor(e,t){for(var a=Math.min(e.length,t.length),n=new r(a),c=0;c{"use strict";var r=a(6),n=a(207),c=a(208),o=a(209),d=a(69);function Hash(e){d.call(this,"digest"),this._hash=e}r(Hash,d),Hash.prototype._update=function(e){this._hash.update(e)},Hash.prototype._final=function(){return this._hash.digest()},e.exports=function createHash(e){return"md5"===(e=e.toLowerCase())?new n:"rmd160"===e||"ripemd160"===e?new c:new Hash(o(e))}},(e,t,a)=>{"use strict";var r=a(8).Buffer,n=a(366),c=a(824);function padToEven(e){var t=e;if("string"!=typeof t)throw new Error("[ethjs-util] while padding to even, value must be string, is currently "+typeof t+", while padToEven.");return t.length%2&&(t="0"+t),t}function intToHex(e){return"0x"+e.toString(16)}e.exports={arrayContainsArray:function arrayContainsArray(e,t,a){if(!0!==Array.isArray(e))throw new Error("[ethjs-util] method arrayContainsArray requires input 'superset' to be an array got type '"+typeof e+"'");if(!0!==Array.isArray(t))throw new Error("[ethjs-util] method arrayContainsArray requires input 'subset' to be an array got type '"+typeof t+"'");return t[Boolean(a)?"some":"every"]((function(t){return e.indexOf(t)>=0}))},intToBuffer:function intToBuffer(e){var t=intToHex(e);return new r(padToEven(t.slice(2)),"hex")},getBinarySize:function getBinarySize(e){if("string"!=typeof e)throw new Error("[ethjs-util] while getting binary size, method getBinarySize requires input 'str' to be type String, got '"+typeof e+"'.");return r.byteLength(e,"utf8")},isHexPrefixed:n,stripHexPrefix:c,padToEven,intToHex,fromAscii:function fromAscii(e){for(var t="",a=0;a{"use strict";var t={};function createErrorType(e,a,r){r||(r=Error);var n=function(e){function NodeError(t,r,n){return e.call(this,function getMessage(e,t,r){return"string"==typeof a?a:a(e,t,r)}(t,r,n))||this}return function _inheritsLoose(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}(NodeError,e),NodeError}(r);n.prototype.name=r.name,n.prototype.code=e,t[e]=n}function oneOf(e,t){if(Array.isArray(e)){var a=e.length;return e=e.map((function(e){return String(e)})),a>2?"one of ".concat(t," ").concat(e.slice(0,a-1).join(", "),", or ")+e[a-1]:2===a?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}createErrorType("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),createErrorType("ERR_INVALID_ARG_TYPE",(function(e,t,a){var r,n;if("string"==typeof t&&function startsWith(e,t,a){return e.substr(!a||a<0?0:+a,t.length)===t}(t,"not ")?(r="must not be",t=t.replace(/^not /,"")):r="must be",function endsWith(e,t,a){return(void 0===a||a>e.length)&&(a=e.length),e.substring(a-t.length,a)===t}(e," argument"))n="The ".concat(e," ").concat(r," ").concat(oneOf(t,"type"));else{var c=function includes(e,t,a){return"number"!=typeof a&&(a=0),!(a+t.length>e.length)&&-1!==e.indexOf(t,a)}(e,".")?"property":"argument";n='The "'.concat(e,'" ').concat(c," ").concat(r," ").concat(oneOf(t,"type"))}return n+=". Received type ".concat(typeof a)}),TypeError),createErrorType("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),createErrorType("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),createErrorType("ERR_STREAM_PREMATURE_CLOSE","Premature close"),createErrorType("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),createErrorType("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),createErrorType("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),createErrorType("ERR_STREAM_WRITE_AFTER_END","write after end"),createErrorType("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),createErrorType("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),createErrorType("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.a=t},(e,t,a)=>{"use strict";var r=a(8).Buffer;function isHexPrefixed(e){if("string"!=typeof e)throw new Error("[isHexPrefixed] input must be type 'string', received type ".concat(typeof e));return"0"===e[0]&&"x"===e[1]}Object.defineProperty(t,"__esModule",{value:!0}),t.isHexString=t.getKeys=t.fromAscii=t.fromUtf8=t.toAscii=t.arrayContainsArray=t.getBinarySize=t.padToEven=t.stripHexPrefix=t.isHexPrefixed=void 0,t.isHexPrefixed=isHexPrefixed;function padToEven(e){var t=e;if("string"!=typeof t)throw new Error("[padToEven] value must be type 'string', received ".concat(typeof t));return t.length%2&&(t="0".concat(t)),t}t.stripHexPrefix=function(e){if("string"!=typeof e)throw new Error("[stripHexPrefix] input must be type 'string', received ".concat(typeof e));return isHexPrefixed(e)?e.slice(2):e},t.padToEven=padToEven,t.getBinarySize=function getBinarySize(e){if("string"!=typeof e)throw new Error("[getBinarySize] method requires input type 'string', recieved ".concat(typeof e));return r.byteLength(e,"utf8")},t.arrayContainsArray=function arrayContainsArray(e,t,a){if(!0!==Array.isArray(e))throw new Error("[arrayContainsArray] method requires input 'superset' to be an array, got type '".concat(typeof e,"'"));if(!0!==Array.isArray(t))throw new Error("[arrayContainsArray] method requires input 'subset' to be an array, got type '".concat(typeof t,"'"));return t[a?"some":"every"]((function(t){return e.indexOf(t)>=0}))},t.toAscii=function toAscii(e){var t="",a=0,r=e.length;for("0x"===e.substring(0,2)&&(a=2);a{"use strict";var r=a(10).Buffer;function isHexPrefixed(e){if("string"!=typeof e)throw new Error("[isHexPrefixed] input must be type 'string', received type ".concat(typeof e));return"0"===e[0]&&"x"===e[1]}Object.defineProperty(t,"__esModule",{value:!0}),t.isHexString=t.getKeys=t.fromAscii=t.fromUtf8=t.toAscii=t.arrayContainsArray=t.getBinarySize=t.padToEven=t.stripHexPrefix=t.isHexPrefixed=void 0,t.isHexPrefixed=isHexPrefixed;function padToEven(e){var t=e;if("string"!=typeof t)throw new Error("[padToEven] value must be type 'string', received ".concat(typeof t));return t.length%2&&(t="0".concat(t)),t}t.stripHexPrefix=function(e){if("string"!=typeof e)throw new Error("[stripHexPrefix] input must be type 'string', received ".concat(typeof e));return isHexPrefixed(e)?e.slice(2):e},t.padToEven=padToEven,t.getBinarySize=function getBinarySize(e){if("string"!=typeof e)throw new Error("[getBinarySize] method requires input type 'string', recieved ".concat(typeof e));return r.byteLength(e,"utf8")},t.arrayContainsArray=function arrayContainsArray(e,t,a){if(!0!==Array.isArray(e))throw new Error("[arrayContainsArray] method requires input 'superset' to be an array, got type '".concat(typeof e,"'"));if(!0!==Array.isArray(t))throw new Error("[arrayContainsArray] method requires input 'subset' to be an array, got type '".concat(typeof t,"'"));return t[a?"some":"every"]((function(t){return e.indexOf(t)>=0}))},t.toAscii=function toAscii(e){var t="",a=0,r=e.length;for("0x"===e.substring(0,2)&&(a=2);a{"use strict";var t={};function createErrorType(e,a,r){r||(r=Error);var n=function(e){function NodeError(t,r,n){return e.call(this,function getMessage(e,t,r){return"string"==typeof a?a:a(e,t,r)}(t,r,n))||this}return function _inheritsLoose(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}(NodeError,e),NodeError}(r);n.prototype.name=r.name,n.prototype.code=e,t[e]=n}function oneOf(e,t){if(Array.isArray(e)){var a=e.length;return e=e.map((function(e){return String(e)})),a>2?"one of ".concat(t," ").concat(e.slice(0,a-1).join(", "),", or ")+e[a-1]:2===a?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}createErrorType("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),createErrorType("ERR_INVALID_ARG_TYPE",(function(e,t,a){var r,n;if("string"==typeof t&&function startsWith(e,t,a){return e.substr(!a||a<0?0:+a,t.length)===t}(t,"not ")?(r="must not be",t=t.replace(/^not /,"")):r="must be",function endsWith(e,t,a){return(void 0===a||a>e.length)&&(a=e.length),e.substring(a-t.length,a)===t}(e," argument"))n="The ".concat(e," ").concat(r," ").concat(oneOf(t,"type"));else{var c=function includes(e,t,a){return"number"!=typeof a&&(a=0),!(a+t.length>e.length)&&-1!==e.indexOf(t,a)}(e,".")?"property":"argument";n='The "'.concat(e,'" ').concat(c," ").concat(r," ").concat(oneOf(t,"type"))}return n+=". Received type ".concat(typeof a)}),TypeError),createErrorType("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),createErrorType("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),createErrorType("ERR_STREAM_PREMATURE_CLOSE","Premature close"),createErrorType("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),createErrorType("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),createErrorType("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),createErrorType("ERR_STREAM_WRITE_AFTER_END","write after end"),createErrorType("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),createErrorType("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),createErrorType("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.a=t},(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SECP256K1_MAX_PRIVATE_KEY_DIV_2=exports.SECP256K1_N=void 0;const path_1=__webpack_require__(90);let secp256k1;exports.SECP256K1_N=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,exports.SECP256K1_MAX_PRIVATE_KEY_DIV_2=0x7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0n;try{const nodeRequire=eval("require"),path=nodeRequire.resolve("secp256k1/package.json"),dir=(0,path_1.dirname)(path),nodeGypBuild=__webpack_require__(908),{Secp256k1}=nodeGypBuild(dir);secp256k1=new Secp256k1}catch{secp256k1=__webpack_require__(909)}exports.default=secp256k1},(e,t,a)=>{"use strict";var r=a(2).Buffer;function isHexPrefixed(e){if("string"!=typeof e)throw new Error("[isHexPrefixed] input must be type 'string', received type ".concat(typeof e));return"0"===e[0]&&"x"===e[1]}Object.defineProperty(t,"__esModule",{value:!0}),t.isHexString=t.getKeys=t.fromAscii=t.fromUtf8=t.toAscii=t.arrayContainsArray=t.getBinarySize=t.padToEven=t.stripHexPrefix=t.isHexPrefixed=void 0,t.isHexPrefixed=isHexPrefixed;function padToEven(e){var t=e;if("string"!=typeof t)throw new Error("[padToEven] value must be type 'string', received ".concat(typeof t));return t.length%2&&(t="0".concat(t)),t}t.stripHexPrefix=function(e){if("string"!=typeof e)throw new Error("[stripHexPrefix] input must be type 'string', received ".concat(typeof e));return isHexPrefixed(e)?e.slice(2):e},t.padToEven=padToEven,t.getBinarySize=function getBinarySize(e){if("string"!=typeof e)throw new Error("[getBinarySize] method requires input type 'string', recieved ".concat(typeof e));return r.byteLength(e,"utf8")},t.arrayContainsArray=function arrayContainsArray(e,t,a){if(!0!==Array.isArray(e))throw new Error("[arrayContainsArray] method requires input 'superset' to be an array, got type '".concat(typeof e,"'"));if(!0!==Array.isArray(t))throw new Error("[arrayContainsArray] method requires input 'subset' to be an array, got type '".concat(typeof t,"'"));return t[a?"some":"every"]((function(t){return e.indexOf(t)>=0}))},t.toAscii=function toAscii(e){var t="",a=0,r=e.length;for("0x"===e.substring(0,2)&&(a=2);a{"use strict";var t={};function createErrorType(e,a,r){r||(r=Error);var n=function(e){function NodeError(t,r,n){return e.call(this,function getMessage(e,t,r){return"string"==typeof a?a:a(e,t,r)}(t,r,n))||this}return function _inheritsLoose(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}(NodeError,e),NodeError}(r);n.prototype.name=r.name,n.prototype.code=e,t[e]=n}function oneOf(e,t){if(Array.isArray(e)){var a=e.length;return e=e.map((function(e){return String(e)})),a>2?"one of ".concat(t," ").concat(e.slice(0,a-1).join(", "),", or ")+e[a-1]:2===a?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}createErrorType("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),createErrorType("ERR_INVALID_ARG_TYPE",(function(e,t,a){var r,n;if("string"==typeof t&&function startsWith(e,t,a){return e.substr(!a||a<0?0:+a,t.length)===t}(t,"not ")?(r="must not be",t=t.replace(/^not /,"")):r="must be",function endsWith(e,t,a){return(void 0===a||a>e.length)&&(a=e.length),e.substring(a-t.length,a)===t}(e," argument"))n="The ".concat(e," ").concat(r," ").concat(oneOf(t,"type"));else{var c=function includes(e,t,a){return"number"!=typeof a&&(a=0),!(a+t.length>e.length)&&-1!==e.indexOf(t,a)}(e,".")?"property":"argument";n='The "'.concat(e,'" ').concat(c," ").concat(r," ").concat(oneOf(t,"type"))}return n+=". Received type ".concat(typeof a)}),TypeError),createErrorType("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),createErrorType("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),createErrorType("ERR_STREAM_PREMATURE_CLOSE","Premature close"),createErrorType("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),createErrorType("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),createErrorType("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),createErrorType("ERR_STREAM_WRITE_AFTER_END","write after end"),createErrorType("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),createErrorType("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),createErrorType("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.a=t},(e,t,a)=>{"use strict";var r=a(0).Buffer;function isHexPrefixed(e){if("string"!=typeof e)throw new Error("[isHexPrefixed] input must be type 'string', received type ".concat(typeof e));return"0"===e[0]&&"x"===e[1]}Object.defineProperty(t,"__esModule",{value:!0}),t.isHexString=t.getKeys=t.fromAscii=t.fromUtf8=t.toAscii=t.arrayContainsArray=t.getBinarySize=t.padToEven=t.stripHexPrefix=t.isHexPrefixed=void 0,t.isHexPrefixed=isHexPrefixed;function padToEven(e){var t=e;if("string"!=typeof t)throw new Error("[padToEven] value must be type 'string', received ".concat(typeof t));return t.length%2&&(t="0".concat(t)),t}t.stripHexPrefix=function(e){if("string"!=typeof e)throw new Error("[stripHexPrefix] input must be type 'string', received ".concat(typeof e));return isHexPrefixed(e)?e.slice(2):e},t.padToEven=padToEven,t.getBinarySize=function getBinarySize(e){if("string"!=typeof e)throw new Error("[getBinarySize] method requires input type 'string', recieved ".concat(typeof e));return r.byteLength(e,"utf8")},t.arrayContainsArray=function arrayContainsArray(e,t,a){if(!0!==Array.isArray(e))throw new Error("[arrayContainsArray] method requires input 'superset' to be an array, got type '".concat(typeof e,"'"));if(!0!==Array.isArray(t))throw new Error("[arrayContainsArray] method requires input 'subset' to be an array, got type '".concat(typeof t,"'"));return t[a?"some":"every"]((function(t){return e.indexOf(t)>=0}))},t.toAscii=function toAscii(e){var t="",a=0,r=e.length;for("0x"===e.substring(0,2)&&(a=2);a{"use strict";var t={};function createErrorType(e,a,r){r||(r=Error);var n=function(e){function NodeError(t,r,n){return e.call(this,function getMessage(e,t,r){return"string"==typeof a?a:a(e,t,r)}(t,r,n))||this}return function _inheritsLoose(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}(NodeError,e),NodeError}(r);n.prototype.name=r.name,n.prototype.code=e,t[e]=n}function oneOf(e,t){if(Array.isArray(e)){var a=e.length;return e=e.map((function(e){return String(e)})),a>2?"one of ".concat(t," ").concat(e.slice(0,a-1).join(", "),", or ")+e[a-1]:2===a?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}createErrorType("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),createErrorType("ERR_INVALID_ARG_TYPE",(function(e,t,a){var r,n;if("string"==typeof t&&function startsWith(e,t,a){return e.substr(!a||a<0?0:+a,t.length)===t}(t,"not ")?(r="must not be",t=t.replace(/^not /,"")):r="must be",function endsWith(e,t,a){return(void 0===a||a>e.length)&&(a=e.length),e.substring(a-t.length,a)===t}(e," argument"))n="The ".concat(e," ").concat(r," ").concat(oneOf(t,"type"));else{var c=function includes(e,t,a){return"number"!=typeof a&&(a=0),!(a+t.length>e.length)&&-1!==e.indexOf(t,a)}(e,".")?"property":"argument";n='The "'.concat(e,'" ').concat(c," ").concat(r," ").concat(oneOf(t,"type"))}return n+=". Received type ".concat(typeof a)}),TypeError),createErrorType("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),createErrorType("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),createErrorType("ERR_STREAM_PREMATURE_CLOSE","Premature close"),createErrorType("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),createErrorType("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),createErrorType("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),createErrorType("ERR_STREAM_WRITE_AFTER_END","write after end"),createErrorType("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),createErrorType("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),createErrorType("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.a=t},e=>{"use strict";var t={};function createErrorType(e,a,r){r||(r=Error);var n=function(e){function NodeError(t,r,n){return e.call(this,function getMessage(e,t,r){return"string"==typeof a?a:a(e,t,r)}(t,r,n))||this}return function _inheritsLoose(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}(NodeError,e),NodeError}(r);n.prototype.name=r.name,n.prototype.code=e,t[e]=n}function oneOf(e,t){if(Array.isArray(e)){var a=e.length;return e=e.map((function(e){return String(e)})),a>2?"one of ".concat(t," ").concat(e.slice(0,a-1).join(", "),", or ")+e[a-1]:2===a?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}createErrorType("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),createErrorType("ERR_INVALID_ARG_TYPE",(function(e,t,a){var r,n;if("string"==typeof t&&function startsWith(e,t,a){return e.substr(!a||a<0?0:+a,t.length)===t}(t,"not ")?(r="must not be",t=t.replace(/^not /,"")):r="must be",function endsWith(e,t,a){return(void 0===a||a>e.length)&&(a=e.length),e.substring(a-t.length,a)===t}(e," argument"))n="The ".concat(e," ").concat(r," ").concat(oneOf(t,"type"));else{var c=function includes(e,t,a){return"number"!=typeof a&&(a=0),!(a+t.length>e.length)&&-1!==e.indexOf(t,a)}(e,".")?"property":"argument";n='The "'.concat(e,'" ').concat(c," ").concat(r," ").concat(oneOf(t,"type"))}return n+=". Received type ".concat(typeof a)}),TypeError),createErrorType("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),createErrorType("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),createErrorType("ERR_STREAM_PREMATURE_CLOSE","Premature close"),createErrorType("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),createErrorType("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),createErrorType("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),createErrorType("ERR_STREAM_WRITE_AFTER_END","write after end"),createErrorType("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),createErrorType("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),createErrorType("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.a=t},(e,t,a)=>{var r=a(33),n=r({}.toString),c=r("".slice);e.exports=function(e){return c(n(e),8,-1)}},e=>{e.exports={}},(e,t,a)=>{var r=a(264),n=a(11),c=a(29),aFunction=function(e){return c(e)?e:void 0};e.exports=function(e,t){return arguments.length<2?aFunction(r[e])||aFunction(n[e]):r[e]&&r[e][t]||n[e]&&n[e][t]}},(e,t,a)=>{"use strict";var r=a(0).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.updateSstoreGas=t.writeCallOutput=t.subMemUsage=t.maxCallGas=t.jumpSubIsValid=t.jumpIsValid=t.getFullname=t.getDataSlice=t.short=t.divCeil=t.describeLocation=t.addressToBuffer=t.trap=t.setLengthLeftStorage=void 0;var n=a(1),c=a(21),o=new n.BN(1).shln(160).subn(1);function divCeil(e,t){var a=e.div(t);return e.mod(t).isZero()?a:a.isNeg()?a.isubn(1):a.iaddn(1)}function getDataSlice(e,t,a){var r=new n.BN(e.length);t.gt(r)&&(t=r);var c=t.add(a);return c.gt(r)&&(c=r),e=e.slice(t.toNumber(),c.toNumber()),e=(0,n.setLengthRight)(e,a.toNumber())}t.setLengthLeftStorage=function setLengthLeftStorage(e){return e.equals(r.alloc(e.length,0))?r.alloc(0):(0,n.setLengthLeft)(e,32)},t.trap=function trap(e){throw new c.VmError(e)},t.addressToBuffer=function addressToBuffer(e){return r.isBuffer(e)?e:e.and(o).toArrayLike(r,"be",20)},t.describeLocation=function describeLocation(e){var t=(0,n.keccak256)(e.eei.getCode()).toString("hex"),a=e.eei.getAddress().buf.toString("hex"),r=e.programCounter-1;return"".concat(t,"/").concat(a,":").concat(r)},t.divCeil=divCeil,t.short=function short(e){var t=e.toString("hex");return t.length<=50?t:t.slice(0,50)+"..."},t.getDataSlice=getDataSlice,t.getFullname=function getFullname(e,t){switch(t){case"LOG":t+=e-160;break;case"PUSH":t+=e-95;break;case"DUP":t+=e-127;break;case"SWAP":t+=e-143}return t},t.jumpIsValid=function jumpIsValid(e,t){return 1===e.validJumps[t]},t.jumpSubIsValid=function jumpSubIsValid(e,t){return 2===e.validJumps[t]},t.maxCallGas=function maxCallGas(e,t,a,r){if(r.gteHardfork("tangerineWhistle")){var n=t.sub(t.divn(64));return e.gt(n)?n:e}return e},t.subMemUsage=function subMemUsage(e,t,a,r){if(a.isZero())return new n.BN(0);var c=divCeil(t.add(a),new n.BN(32));if(c.lte(e.memoryWordCount))return new n.BN(0);var o=c,d=new n.BN(r.param("gasPrices","memory")),s=new n.BN(r.param("gasPrices","quadCoeffDiv")),b=o.mul(d).add(o.mul(o).div(s));if(b.gt(e.highestMemCost)){var u=e.highestMemCost;e.highestMemCost=b.clone(),b.isub(u)}return e.memoryWordCount=c,b},t.writeCallOutput=function writeCallOutput(e,t,a){var r=e.eei.getReturnData();if(r.length>0){var c=t.toNumber(),o=a.toNumber();r.length0&&t.length>0)return c=new n.BN(r.param("gasPrices","sstoreReset"));if(0===a.length&&t.length>0){var c=new n.BN(r.param("gasPrices","sstoreReset"));return e.eei.refundGas(new n.BN(r.param("gasPrices","sstoreRefund")),"updateSstoreGas"),c}return new n.BN(r.param("gasPrices","sstoreSet"))}},function(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[a]}})}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||r(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),n(a(865),t),n(a(929),t),n(a(1413),t),n(a(970),t)},(e,t,a)=>{var r=a(19),n=Object.getOwnPropertyDescriptors||function getOwnPropertyDescriptors(e){for(var t=Object.keys(e),a={},r=0;r=n)return e;switch(e){case"%s":return String(r[a++]);case"%d":return Number(r[a++]);case"%j":try{return JSON.stringify(r[a++])}catch(e){return"[Circular]"}default:return e}})),d=r[a];a=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),isBoolean(a)?r.showHidden=a:a&&t._extend(r,a),isUndefined(r.showHidden)&&(r.showHidden=!1),isUndefined(r.depth)&&(r.depth=2),isUndefined(r.colors)&&(r.colors=!1),isUndefined(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=stylizeWithColor),formatValue(r,e,r.depth)}function stylizeWithColor(e,t){var a=inspect.styles[t];return a?"["+inspect.colors[a][0]+"m"+e+"["+inspect.colors[a][1]+"m":e}function stylizeNoColor(e,t){return e}function formatValue(e,a,r){if(e.customInspect&&a&&isFunction(a.inspect)&&a.inspect!==t.inspect&&(!a.constructor||a.constructor.prototype!==a)){var n=a.inspect(r,e);return isString(n)||(n=formatValue(e,n,r)),n}var c=function formatPrimitive(e,t){if(isUndefined(t))return e.stylize("undefined","undefined");if(isString(t)){var a="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(a,"string")}if(isNumber(t))return e.stylize(""+t,"number");if(isBoolean(t))return e.stylize(""+t,"boolean");if(isNull(t))return e.stylize("null","null")}(e,a);if(c)return c;var o=Object.keys(a),d=function arrayToHash(e){var t={};return e.forEach((function(e,a){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(a)),isError(a)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return formatError(a);if(0===o.length){if(isFunction(a)){var s=a.name?": "+a.name:"";return e.stylize("[Function"+s+"]","special")}if(isRegExp(a))return e.stylize(RegExp.prototype.toString.call(a),"regexp");if(isDate(a))return e.stylize(Date.prototype.toString.call(a),"date");if(isError(a))return formatError(a)}var b,u="",h=!1,l=["{","}"];(isArray(a)&&(h=!0,l=["[","]"]),isFunction(a))&&(u=" [Function"+(a.name?": "+a.name:"")+"]");return isRegExp(a)&&(u=" "+RegExp.prototype.toString.call(a)),isDate(a)&&(u=" "+Date.prototype.toUTCString.call(a)),isError(a)&&(u=" "+formatError(a)),0!==o.length||h&&0!=a.length?r<0?isRegExp(a)?e.stylize(RegExp.prototype.toString.call(a),"regexp"):e.stylize("[Object]","special"):(e.seen.push(a),b=h?function formatArray(e,t,a,r,n){for(var c=[],o=0,d=t.length;o=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return a[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+a[1];return a[0]+t+" "+e.join(", ")+" "+a[1]}(b,u,l)):l[0]+u+l[1]}function formatError(e){return"["+Error.prototype.toString.call(e)+"]"}function formatProperty(e,t,a,r,n,c){var o,d,s;if((s=Object.getOwnPropertyDescriptor(t,n)||{value:t[n]}).get?d=s.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):s.set&&(d=e.stylize("[Setter]","special")),hasOwnProperty(r,n)||(o="["+n+"]"),d||(e.seen.indexOf(s.value)<0?(d=isNull(a)?formatValue(e,s.value,null):formatValue(e,s.value,a-1)).indexOf("\n")>-1&&(d=c?d.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+d.split("\n").map((function(e){return" "+e})).join("\n")):d=e.stylize("[Circular]","special")),isUndefined(o)){if(c&&n.match(/^\d+$/))return d;(o=JSON.stringify(""+n)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=e.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=e.stylize(o,"string"))}return o+": "+d}function isArray(e){return Array.isArray(e)}function isBoolean(e){return"boolean"==typeof e}function isNull(e){return null===e}function isNumber(e){return"number"==typeof e}function isString(e){return"string"==typeof e}function isUndefined(e){return void 0===e}function isRegExp(e){return isObject(e)&&"[object RegExp]"===objectToString(e)}function isObject(e){return"object"==typeof e&&null!==e}function isDate(e){return isObject(e)&&"[object Date]"===objectToString(e)}function isError(e){return isObject(e)&&("[object Error]"===objectToString(e)||e instanceof Error)}function isFunction(e){return"function"==typeof e}function objectToString(e){return Object.prototype.toString.call(e)}function pad(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(e){if(e=e.toUpperCase(),!o[e])if(d.test(e)){var a=r.pid;o[e]=function(){var r=t.format.apply(t,arguments);console.error("%s %d: %s",e,a,r)}}else o[e]=function(){};return o[e]},t.inspect=inspect,inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},inspect.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.types=a(1016),t.isArray=isArray,t.isBoolean=isBoolean,t.isNull=isNull,t.isNullOrUndefined=function isNullOrUndefined(e){return null==e},t.isNumber=isNumber,t.isString=isString,t.isSymbol=function isSymbol(e){return"symbol"==typeof e},t.isUndefined=isUndefined,t.isRegExp=isRegExp,t.types.isRegExp=isRegExp,t.isObject=isObject,t.isDate=isDate,t.types.isDate=isDate,t.isError=isError,t.types.isNativeError=isError,t.isFunction=isFunction,t.isPrimitive=function isPrimitive(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=a(1023);var b=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function timestamp(){var e=new Date,t=[pad(e.getHours()),pad(e.getMinutes()),pad(e.getSeconds())].join(":");return[e.getDate(),b[e.getMonth()],t].join(" ")}function hasOwnProperty(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){console.log("%s - %s",timestamp(),t.format.apply(t,arguments))},t.inherits=a(9),t._extend=function(e,t){if(!t||!isObject(t))return e;for(var a=Object.keys(t),r=a.length;r--;)e[a[r]]=t[a[r]];return e};var u="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function callbackifyOnRejected(e,t){if(!e){var a=new Error("Promise was rejected with a falsy value");a.reason=e,e=a}return t(e)}t.promisify=function promisify(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(u&&e[u]){var t;if("function"!=typeof(t=e[u]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,u,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,a,r=new Promise((function(e,r){t=e,a=r})),n=[],c=0;c0&&n[n.length-1])||6!==c[0]&&2!==c[0])){o=0;continue}if(3===c[0]&&(!n||c[1]>n[0]&&c[1]{"use strict";var r=a(5),n=a(10).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.RuntimeTransaction=t.hasPartialSignature=t.toValidLengthAddress=void 0;const c=a(13),o=a(4),d=a(27),s=a(401),b=a(309),u=a(28);t.toValidLengthAddress=(e,t)=>{const a=o.Data.from(e).toBuffer();if(a.byteLength!==u.Address.ByteLength)throw new Error(`The field ${t} must have byte length of ${u.Address.ByteLength}`);return u.Address.from(a)};t.hasPartialSignature=e=>null!=e.v||null!=e.r||null!=e.s;const h=o.RPCQUANTITY_ONE.toBuffer();class RuntimeTransaction extends s.BaseTransaction{constructor(e,a,n){let c;if(super(a,n),this.locked=!1,this.validateAndSetSignature=e=>{if((0,t.hasPartialSignature)(e)){if(null==e.v||null==e.r||null==e.s)throw new Error("Transaction signature is incomplete; v, r, and s are required.");if(null==e.nonce)throw new Error("Signed transaction is incomplete; nonce is required.");this.v=o.Quantity.from(e.v,!0),this.r=o.Quantity.from(e.r,!0),this.s=o.Quantity.from(e.s,!0);const a=this.toEthRawTransaction(this.v.toBuffer(),this.r.toBuffer(),this.s.toBuffer());if(this.raw=a,!this.from){const{from:r,serialized:n,hash:c,encodedData:o,encodedSignature:d}=this.computeIntrinsics(this.v,a,this.common.chainId());if(null!==e.from){const a=(0,t.toValidLengthAddress)(e.from,"from");if(!r.toBuffer().equals(a.toBuffer()))throw new Error("Transaction is signed and contains a `from` field, but the signature doesn't match.")}this.from=r,this.serialized=n,this.hash=c,this.encodedData=o,this.encodedSignature=d}}else null!=e.from&&(this.from=(0,t.toValidLengthAddress)(e.from,"from"))},this.finalized=new Promise((e=>{c=(...t)=>r.nextTick(e,...t)})),this.finalizer=c,!Array.isArray(e)){this.nonce=o.Quantity.from(e.nonce,!0),this.gas=o.Quantity.from(null==e.gas?e.gasLimit:e.gas),this.to=null==e.to?o.RPCQUANTITY_EMPTY:(0,t.toValidLengthAddress)(e.to,"to"),this.value=o.Quantity.from(e.value||0);const a=null==e.data?null==e.input?"0x":e.input:e.data;this.data=o.Data.from(a)}}serializeForDb(e,t,a){const r=[this.raw,[this.from.toBuffer(),this.hash.toBuffer(),e.toBuffer(),t.toBuffer(),a.toBuffer(),this.effectiveGasPrice.toBuffer()]];return(0,d.encode)(r)}fillFromResult(e,t){const a=e.execResult;let r;a.exceptionError?(r=o.BUFFER_ZERO,this.execException=new c.RuntimeError(this.hash,e,c.RETURN_TYPES.TRANSACTION_HASH)):r=h;return(this.receipt=b.TransactionReceipt.fromValues(r,o.Quantity.from(t).toBuffer(),e.bloom.bitvector,this.logs=a.logs||[],e.gasUsed.toArrayLike(n),e.createdAddress?e.createdAddress.buf:null,this.type)).serialize(!1)}getReceipt(){return this.receipt}getLogs(){return this.logs}once(e){return this.finalized}finalize(e,t=null){this.finalizer({status:e,error:t})}}t.RuntimeTransaction=RuntimeTransaction},function(e,t,a){"use strict";var r,n,c=this&&this.__classPrivateFieldSet||function(e,t,a,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,a):n?n.value=a:t.set(e,a),a},o=this&&this.__classPrivateFieldGet||function(e,t,a,r){if("a"===a&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?r:"a"===a?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0});const d=a(4);t.default=class Manager{constructor(e,t,a){r.set(this,void 0),n.set(this,void 0),c(this,r,t,"f"),c(this,n,a,"f"),this.base=e}getRaw(e){return"string"==typeof e&&(e=d.Data.from(e).toBuffer()),0===e.length&&(e=d.BUFFER_ZERO),this.base.get(e).catch((e=>{if(404===e.status)return null;throw e}))}async get(e){const t=await this.getRaw(e);return t?new(o(this,r,"f"))(t,o(this,n,"f")):null}set(e,t){return this.base.put(e,t)}del(e){return this.base.del(e)}},r=new WeakMap,n=new WeakMap},(e,t,a)=>{"use strict";var r=a(5),n=Object.keys||function(e){var t=[];for(var a in e)t.push(a);return t};e.exports=Duplex;var c=a(380),o=a(383);a(15)(Duplex,c);for(var d=n(o.prototype),s=0;s{"use strict";var r=a(5),n=Object.keys||function(e){var t=[];for(var a in e)t.push(a);return t};e.exports=Duplex;var c=a(394),o=a(397);a(16)(Duplex,c);for(var d=n(o.prototype),s=0;s{"use strict";var r=a(5),n=Object.keys||function(e){var t=[];for(var a in e)t.push(a);return t};e.exports=Duplex;var c=a(416),o=a(419);a(17)(Duplex,c);for(var d=n(o.prototype),s=0;s{(t=e.exports=a(433)).Stream=t,t.Readable=t,t.Writable=a(436),t.Duplex=a(139),t.Transform=a(437),t.PassThrough=a(998),t.finished=a(245),t.pipeline=a(999)},(e,t,a)=>{"use strict";var r=a(19),n=Object.keys||function(e){var t=[];for(var a in e)t.push(a);return t};e.exports=Duplex;var c=a(433),o=a(436);a(9)(Duplex,c);for(var d=n(o.prototype),s=0;s{"use strict";var r=a(5),n=Object.keys||function(e){var t=[];for(var a in e)t.push(a);return t};e.exports=Duplex;var c=a(466),o=a(469);a(25)(Duplex,c);for(var d=n(o.prototype),s=0;s{"function"==typeof Object.create?e.exports=function inherits(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function inherits(e,t){if(t){e.super_=t;var TempCtor=function(){};TempCtor.prototype=t.prototype,e.prototype=new TempCtor,e.prototype.constructor=e}}},function(e,t,a){"use strict";var r=a(0).Buffer,n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getLength=t.decode=t.encode=void 0;var c=n(a(677));function safeParseInt(e,t){if("0"===e[0]&&"0"===e[1])throw new Error("invalid RLP: extra zeros");return parseInt(e,t)}function encodeLength(e,t){if(e<56)return r.from([e+t]);var a=intToHex(e),n=intToHex(t+55+a.length/2);return r.from(n+a,"hex")}function _decode(e){var t,a,n,c,o,d=[],s=e[0];if(s<=127)return{data:e.slice(0,1),remainder:e.slice(1)};if(s<=183){if(t=s-127,n=128===s?r.from([]):e.slice(1,t),2===t&&n[0]<128)throw new Error("invalid rlp encoding: byte must be less 0x80");return{data:n,remainder:e.slice(t)}}if(s<=191){if(a=s-182,e.length-1e.length)throw new Error("invalid rlp: total length is larger than the data");if(0===(c=e.slice(a,b)).length)throw new Error("invalid rlp, List has a invalid length");for(;c.length;)o=_decode(c),d.push(o.data),c=o.remainder;return{data:d,remainder:e.slice(b)}}function isHexPrefixed(e){return"0x"===e.slice(0,2)}function intToHex(e){if(e<0)throw new Error("Invalid integer as argument, must be unsigned!");var t=e.toString(16);return t.length%2?"0"+t:t}function toBuffer(e){if(!r.isBuffer(e)){if("string"==typeof e)return isHexPrefixed(e)?r.from(function padToEven(e){return e.length%2?"0"+e:e}(function stripHexPrefix(e){return"string"!=typeof e?e:isHexPrefixed(e)?e.slice(2):e}(e)),"hex"):r.from(e);if("number"==typeof e||"bigint"==typeof e)return e?function intToBuffer(e){var t=intToHex(e);return r.from(t,"hex")}(e):r.from([]);if(null==e)return r.from([]);if(e instanceof Uint8Array)return r.from(e);if(c.default.isBN(e))return r.from(e.toArray());throw new Error("invalid type")}return e}t.encode=function encode(e){if(Array.isArray(e)){for(var t=[],a=0;a{"use strict";var r=a(111).a.ERR_STREAM_PREMATURE_CLOSE;function noop(){}e.exports=function eos(e,t,a){if("function"==typeof t)return eos(e,null,t);t||(t={}),a=function once(e){var t=!1;return function(){if(!t){t=!0;for(var a=arguments.length,r=new Array(a),n=0;n{var r=a(7).Buffer,n=a(207);e.exports=function EVP_BytesToKey(e,t,a,c){if(r.isBuffer(e)||(e=r.from(e,"binary")),t&&(r.isBuffer(t)||(t=r.from(t,"binary")),8!==t.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var o=a/8,d=r.alloc(o),s=r.alloc(c||0),b=r.alloc(0);o>0||c>0;){var u=new n;u.update(b),u.update(e),t&&u.update(t),b=u.digest();var h=0;if(o>0){var l=d.length-o;h=Math.min(o,b.length),b.copy(d,l,0,h),o-=h}if(h0){var g=s.length-c,p=Math.min(c,b.length-h);b.copy(s,g,h,h+p),c-=p}}return b.fill(0),{key:d,iv:s}}},(e,t,a)=>{"use strict";var r=a(22),n=a(40),c=n.getNAF,o=n.getJSF,d=n.assert;function BaseCurve(e,t){this.type=e,this.p=new r(t.p,16),this.red=t.prime?r.red(t.prime):r.mont(this.p),this.zero=new r(0).toRed(this.red),this.one=new r(1).toRed(this.red),this.two=new r(2).toRed(this.red),this.n=t.n&&new r(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var a=this.n&&this.p.div(this.n);!a||a.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function BasePoint(e,t){this.curve=e,this.type=t,this.precomputed=null}e.exports=BaseCurve,BaseCurve.prototype.point=function point(){throw new Error("Not implemented")},BaseCurve.prototype.validate=function validate(){throw new Error("Not implemented")},BaseCurve.prototype._fixedNafMul=function _fixedNafMul(e,t){d(e.precomputed);var a=e._getDoubles(),r=c(t,1,this._bitLength),n=(1<=o;u--)s=(s<<1)+r[u];b.push(s)}for(var h=this.jpoint(null,null,null),l=this.jpoint(null,null,null),g=n;g>0;g--){for(o=0;o=0;b--){for(var u=0;b>=0&&0===o[b];b--)u++;if(b>=0&&u++,s=s.dblp(u),b<0)break;var h=o[b];d(0!==h),s="affine"===e.type?h>0?s.mixedAdd(n[h-1>>1]):s.mixedAdd(n[-h-1>>1].neg()):h>0?s.add(n[h-1>>1]):s.add(n[-h-1>>1].neg())}return"affine"===e.type?s.toP():s},BaseCurve.prototype._wnafMulAdd=function _wnafMulAdd(e,t,a,r,n){var d,s,b,u=this._wnafT1,h=this._wnafT2,l=this._wnafT3,g=0;for(d=0;d=1;d-=2){var B=d-1,x=d;if(1===u[B]&&1===u[x]){var I=[t[B],null,null,t[x]];0===t[B].y.cmp(t[x].y)?(I[1]=t[B].add(t[x]),I[2]=t[B].toJ().mixedAdd(t[x].neg())):0===t[B].y.cmp(t[x].y.redNeg())?(I[1]=t[B].toJ().mixedAdd(t[x]),I[2]=t[B].add(t[x].neg())):(I[1]=t[B].toJ().mixedAdd(t[x]),I[2]=t[B].toJ().mixedAdd(t[x].neg()));var m=[-3,-1,-5,-7,0,7,5,1,3],y=o(a[B],a[x]);for(g=Math.max(y[0].length,g),l[B]=new Array(g),l[x]=new Array(g),s=0;s=0;d--){for(var k=0;d>=0;){var _=!0;for(s=0;s=0&&k++,v=v.dblp(k),d<0)break;for(s=0;s0?b=h[s][N-1>>1]:N<0&&(b=h[s][-N-1>>1].neg()),v="affine"===b.type?v.mixedAdd(b):v.add(b))}}for(d=0;d=Math.ceil((e.bitLength()+1)/t.step)},BasePoint.prototype._getDoubles=function _getDoubles(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var a=[this],r=this,n=0;n{"use strict";var r=a(61),n=a(39);function BlockHash(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}t.BlockHash=BlockHash,BlockHash.prototype.update=function update(e,t){if(e=r.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var a=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-a,e.length),0===this.pending.length&&(this.pending=null),e=r.join32(e,0,e.length-a,this.endian);for(var n=0;n>>24&255,r[n++]=e>>>16&255,r[n++]=e>>>8&255,r[n++]=255&e}else for(r[n++]=255&e,r[n++]=e>>>8&255,r[n++]=e>>>16&255,r[n++]=e>>>24&255,r[n++]=0,r[n++]=0,r[n++]=0,r[n++]=0,c=8;c{var r=a(1281),n=a(1282),c=a(796),o=a(204),d=a(766),s=a(7).Buffer;function parseKeys(e){var t;"object"!=typeof e||s.isBuffer(e)||(t=e.passphrase,e=e.key),"string"==typeof e&&(e=s.from(e));var a,b,u=c(e,t),h=u.tag,l=u.data;switch(h){case"CERTIFICATE":b=r.certificate.decode(l,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(b||(b=r.PublicKey.decode(l,"der")),a=b.algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return r.RSAPublicKey.decode(b.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return b.subjectPrivateKey=b.subjectPublicKey,{type:"ec",data:b};case"1.2.840.10040.4.1":return b.algorithm.params.pub_key=r.DSAparam.decode(b.subjectPublicKey.data,"der"),{type:"dsa",data:b.algorithm.params};default:throw new Error("unknown key id "+a)}case"ENCRYPTED PRIVATE KEY":l=function decrypt(e,t){var a=e.algorithm.decrypt.kde.kdeparams.salt,r=parseInt(e.algorithm.decrypt.kde.kdeparams.iters.toString(),10),c=n[e.algorithm.decrypt.cipher.algo.join(".")],b=e.algorithm.decrypt.cipher.iv,u=e.subjectPrivateKey,h=parseInt(c.split("-")[1],10)/8,l=d.pbkdf2Sync(t,a,r,h,"sha1"),g=o.createDecipheriv(c,l,b),p=[];return p.push(g.update(u)),p.push(g.final()),s.concat(p)}(l=r.EncryptedPrivateKey.decode(l,"der"),t);case"PRIVATE KEY":switch(a=(b=r.PrivateKey.decode(l,"der")).algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return r.RSAPrivateKey.decode(b.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:b.algorithm.curve,privateKey:r.ECPrivateKey.decode(b.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return b.algorithm.params.priv_key=r.DSAparam.decode(b.subjectPrivateKey,"der"),{type:"dsa",params:b.algorithm.params};default:throw new Error("unknown key id "+a)}case"RSA PUBLIC KEY":return r.RSAPublicKey.decode(l,"der");case"RSA PRIVATE KEY":return r.RSAPrivateKey.decode(l,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:r.DSAPrivateKey.decode(l,"der")};case"EC PRIVATE KEY":return{curve:(l=r.ECPrivateKey.decode(l,"der")).parameters.value,privateKey:l.privateKey};default:throw new Error("unknown key type "+h)}}e.exports=parseKeys,parseKeys.signature=r.signature},(e,t,a)=>{"use strict";var r=a(57),n=a(41),c=n.getNAF,o=n.getJSF,d=n.assert;function BaseCurve(e,t){this.type=e,this.p=new r(t.p,16),this.red=t.prime?r.red(t.prime):r.mont(this.p),this.zero=new r(0).toRed(this.red),this.one=new r(1).toRed(this.red),this.two=new r(2).toRed(this.red),this.n=t.n&&new r(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var a=this.n&&this.p.div(this.n);!a||a.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function BasePoint(e,t){this.curve=e,this.type=t,this.precomputed=null}e.exports=BaseCurve,BaseCurve.prototype.point=function point(){throw new Error("Not implemented")},BaseCurve.prototype.validate=function validate(){throw new Error("Not implemented")},BaseCurve.prototype._fixedNafMul=function _fixedNafMul(e,t){d(e.precomputed);var a=e._getDoubles(),r=c(t,1,this._bitLength),n=(1<=o;u--)s=(s<<1)+r[u];b.push(s)}for(var h=this.jpoint(null,null,null),l=this.jpoint(null,null,null),g=n;g>0;g--){for(o=0;o=0;b--){for(var u=0;b>=0&&0===o[b];b--)u++;if(b>=0&&u++,s=s.dblp(u),b<0)break;var h=o[b];d(0!==h),s="affine"===e.type?h>0?s.mixedAdd(n[h-1>>1]):s.mixedAdd(n[-h-1>>1].neg()):h>0?s.add(n[h-1>>1]):s.add(n[-h-1>>1].neg())}return"affine"===e.type?s.toP():s},BaseCurve.prototype._wnafMulAdd=function _wnafMulAdd(e,t,a,r,n){var d,s,b,u=this._wnafT1,h=this._wnafT2,l=this._wnafT3,g=0;for(d=0;d=1;d-=2){var B=d-1,x=d;if(1===u[B]&&1===u[x]){var I=[t[B],null,null,t[x]];0===t[B].y.cmp(t[x].y)?(I[1]=t[B].add(t[x]),I[2]=t[B].toJ().mixedAdd(t[x].neg())):0===t[B].y.cmp(t[x].y.redNeg())?(I[1]=t[B].toJ().mixedAdd(t[x]),I[2]=t[B].add(t[x].neg())):(I[1]=t[B].toJ().mixedAdd(t[x]),I[2]=t[B].toJ().mixedAdd(t[x].neg()));var m=[-3,-1,-5,-7,0,7,5,1,3],y=o(a[B],a[x]);for(g=Math.max(y[0].length,g),l[B]=new Array(g),l[x]=new Array(g),s=0;s=0;d--){for(var k=0;d>=0;){var _=!0;for(s=0;s=0&&k++,v=v.dblp(k),d<0)break;for(s=0;s0?b=h[s][N-1>>1]:N<0&&(b=h[s][-N-1>>1].neg()),v="affine"===b.type?v.mixedAdd(b):v.add(b))}}for(d=0;d=Math.ceil((e.bitLength()+1)/t.step)},BasePoint.prototype._getDoubles=function _getDoubles(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var a=[this],r=this,n=0;n{"use strict";var r=a(62),n=a(79);function BlockHash(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}t.BlockHash=BlockHash,BlockHash.prototype.update=function update(e,t){if(e=r.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var a=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-a,e.length),0===this.pending.length&&(this.pending=null),e=r.join32(e,0,e.length-a,this.endian);for(var n=0;n>>24&255,r[n++]=e>>>16&255,r[n++]=e>>>8&255,r[n++]=255&e}else for(r[n++]=255&e,r[n++]=e>>>8&255,r[n++]=e>>>16&255,r[n++]=e>>>24&255,r[n++]=0,r[n++]=0,r[n++]=0,r[n++]=0,c=8;c{"use strict";var r=a(367);e.exports=function hasToStringTagShams(){return r()&&!!Symbol.toStringTag}},(e,t,a)=>{"use strict";var r=a(836),n="function"==typeof Symbol&&"symbol"==typeof Symbol("foo"),c=Object.prototype.toString,o=Array.prototype.concat,d=Object.defineProperty,s=d&&function(){var e={};try{for(var t in d(e,"x",{enumerable:!1,value:e}),e)return!1;return e.x===e}catch(e){return!1}}(),defineProperty=function(e,t,a,r){var n;(!(t in e)||"function"==typeof(n=r)&&"[object Function]"===c.call(n)&&r())&&(s?d(e,t,{configurable:!0,enumerable:!1,value:a,writable:!0}):e[t]=a)},defineProperties=function(e,t){var a=arguments.length>2?arguments[2]:{},c=r(t);n&&(c=o.call(c,Object.getOwnPropertySymbols(t)));for(var d=0;d{"use strict";var r=a(58),n=a(42),c=n.getNAF,o=n.getJSF,d=n.assert;function BaseCurve(e,t){this.type=e,this.p=new r(t.p,16),this.red=t.prime?r.red(t.prime):r.mont(this.p),this.zero=new r(0).toRed(this.red),this.one=new r(1).toRed(this.red),this.two=new r(2).toRed(this.red),this.n=t.n&&new r(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var a=this.n&&this.p.div(this.n);!a||a.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function BasePoint(e,t){this.curve=e,this.type=t,this.precomputed=null}e.exports=BaseCurve,BaseCurve.prototype.point=function point(){throw new Error("Not implemented")},BaseCurve.prototype.validate=function validate(){throw new Error("Not implemented")},BaseCurve.prototype._fixedNafMul=function _fixedNafMul(e,t){d(e.precomputed);var a=e._getDoubles(),r=c(t,1,this._bitLength),n=(1<=o;u--)s=(s<<1)+r[u];b.push(s)}for(var h=this.jpoint(null,null,null),l=this.jpoint(null,null,null),g=n;g>0;g--){for(o=0;o=0;b--){for(var u=0;b>=0&&0===o[b];b--)u++;if(b>=0&&u++,s=s.dblp(u),b<0)break;var h=o[b];d(0!==h),s="affine"===e.type?h>0?s.mixedAdd(n[h-1>>1]):s.mixedAdd(n[-h-1>>1].neg()):h>0?s.add(n[h-1>>1]):s.add(n[-h-1>>1].neg())}return"affine"===e.type?s.toP():s},BaseCurve.prototype._wnafMulAdd=function _wnafMulAdd(e,t,a,r,n){var d,s,b,u=this._wnafT1,h=this._wnafT2,l=this._wnafT3,g=0;for(d=0;d=1;d-=2){var B=d-1,x=d;if(1===u[B]&&1===u[x]){var I=[t[B],null,null,t[x]];0===t[B].y.cmp(t[x].y)?(I[1]=t[B].add(t[x]),I[2]=t[B].toJ().mixedAdd(t[x].neg())):0===t[B].y.cmp(t[x].y.redNeg())?(I[1]=t[B].toJ().mixedAdd(t[x]),I[2]=t[B].add(t[x].neg())):(I[1]=t[B].toJ().mixedAdd(t[x]),I[2]=t[B].toJ().mixedAdd(t[x].neg()));var m=[-3,-1,-5,-7,0,7,5,1,3],y=o(a[B],a[x]);for(g=Math.max(y[0].length,g),l[B]=new Array(g),l[x]=new Array(g),s=0;s=0;d--){for(var k=0;d>=0;){var _=!0;for(s=0;s=0&&k++,v=v.dblp(k),d<0)break;for(s=0;s0?b=h[s][N-1>>1]:N<0&&(b=h[s][-N-1>>1].neg()),v="affine"===b.type?v.mixedAdd(b):v.add(b))}}for(d=0;d=Math.ceil((e.bitLength()+1)/t.step)},BasePoint.prototype._getDoubles=function _getDoubles(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var a=[this],r=this,n=0;n{"use strict";var r=a(63),n=a(80);function BlockHash(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}t.BlockHash=BlockHash,BlockHash.prototype.update=function update(e,t){if(e=r.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var a=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-a,e.length),0===this.pending.length&&(this.pending=null),e=r.join32(e,0,e.length-a,this.endian);for(var n=0;n>>24&255,r[n++]=e>>>16&255,r[n++]=e>>>8&255,r[n++]=255&e}else for(r[n++]=255&e,r[n++]=e>>>8&255,r[n++]=e>>>16&255,r[n++]=e>>>24&255,r[n++]=0,r[n++]=0,r[n++]=0,r[n++]=0,c=8;c{"use strict";var r=a(59),n=a(43),c=n.getNAF,o=n.getJSF,d=n.assert;function BaseCurve(e,t){this.type=e,this.p=new r(t.p,16),this.red=t.prime?r.red(t.prime):r.mont(this.p),this.zero=new r(0).toRed(this.red),this.one=new r(1).toRed(this.red),this.two=new r(2).toRed(this.red),this.n=t.n&&new r(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var a=this.n&&this.p.div(this.n);!a||a.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function BasePoint(e,t){this.curve=e,this.type=t,this.precomputed=null}e.exports=BaseCurve,BaseCurve.prototype.point=function point(){throw new Error("Not implemented")},BaseCurve.prototype.validate=function validate(){throw new Error("Not implemented")},BaseCurve.prototype._fixedNafMul=function _fixedNafMul(e,t){d(e.precomputed);var a=e._getDoubles(),r=c(t,1,this._bitLength),n=(1<=o;u--)s=(s<<1)+r[u];b.push(s)}for(var h=this.jpoint(null,null,null),l=this.jpoint(null,null,null),g=n;g>0;g--){for(o=0;o=0;b--){for(var u=0;b>=0&&0===o[b];b--)u++;if(b>=0&&u++,s=s.dblp(u),b<0)break;var h=o[b];d(0!==h),s="affine"===e.type?h>0?s.mixedAdd(n[h-1>>1]):s.mixedAdd(n[-h-1>>1].neg()):h>0?s.add(n[h-1>>1]):s.add(n[-h-1>>1].neg())}return"affine"===e.type?s.toP():s},BaseCurve.prototype._wnafMulAdd=function _wnafMulAdd(e,t,a,r,n){var d,s,b,u=this._wnafT1,h=this._wnafT2,l=this._wnafT3,g=0;for(d=0;d=1;d-=2){var B=d-1,x=d;if(1===u[B]&&1===u[x]){var I=[t[B],null,null,t[x]];0===t[B].y.cmp(t[x].y)?(I[1]=t[B].add(t[x]),I[2]=t[B].toJ().mixedAdd(t[x].neg())):0===t[B].y.cmp(t[x].y.redNeg())?(I[1]=t[B].toJ().mixedAdd(t[x]),I[2]=t[B].add(t[x].neg())):(I[1]=t[B].toJ().mixedAdd(t[x]),I[2]=t[B].toJ().mixedAdd(t[x].neg()));var m=[-3,-1,-5,-7,0,7,5,1,3],y=o(a[B],a[x]);for(g=Math.max(y[0].length,g),l[B]=new Array(g),l[x]=new Array(g),s=0;s=0;d--){for(var k=0;d>=0;){var _=!0;for(s=0;s=0&&k++,v=v.dblp(k),d<0)break;for(s=0;s0?b=h[s][N-1>>1]:N<0&&(b=h[s][-N-1>>1].neg()),v="affine"===b.type?v.mixedAdd(b):v.add(b))}}for(d=0;d=Math.ceil((e.bitLength()+1)/t.step)},BasePoint.prototype._getDoubles=function _getDoubles(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var a=[this],r=this,n=0;n{"use strict";var r=a(64),n=a(81);function BlockHash(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}t.BlockHash=BlockHash,BlockHash.prototype.update=function update(e,t){if(e=r.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var a=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-a,e.length),0===this.pending.length&&(this.pending=null),e=r.join32(e,0,e.length-a,this.endian);for(var n=0;n>>24&255,r[n++]=e>>>16&255,r[n++]=e>>>8&255,r[n++]=255&e}else for(r[n++]=255&e,r[n++]=e>>>8&255,r[n++]=e>>>16&255,r[n++]=e>>>24&255,r[n++]=0,r[n++]=0,r[n++]=0,r[n++]=0,c=8;c{"use strict";var r=a(60),n=a(44),c=n.getNAF,o=n.getJSF,d=n.assert;function BaseCurve(e,t){this.type=e,this.p=new r(t.p,16),this.red=t.prime?r.red(t.prime):r.mont(this.p),this.zero=new r(0).toRed(this.red),this.one=new r(1).toRed(this.red),this.two=new r(2).toRed(this.red),this.n=t.n&&new r(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var a=this.n&&this.p.div(this.n);!a||a.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function BasePoint(e,t){this.curve=e,this.type=t,this.precomputed=null}e.exports=BaseCurve,BaseCurve.prototype.point=function point(){throw new Error("Not implemented")},BaseCurve.prototype.validate=function validate(){throw new Error("Not implemented")},BaseCurve.prototype._fixedNafMul=function _fixedNafMul(e,t){d(e.precomputed);var a=e._getDoubles(),r=c(t,1,this._bitLength),n=(1<=o;u--)s=(s<<1)+r[u];b.push(s)}for(var h=this.jpoint(null,null,null),l=this.jpoint(null,null,null),g=n;g>0;g--){for(o=0;o=0;b--){for(var u=0;b>=0&&0===o[b];b--)u++;if(b>=0&&u++,s=s.dblp(u),b<0)break;var h=o[b];d(0!==h),s="affine"===e.type?h>0?s.mixedAdd(n[h-1>>1]):s.mixedAdd(n[-h-1>>1].neg()):h>0?s.add(n[h-1>>1]):s.add(n[-h-1>>1].neg())}return"affine"===e.type?s.toP():s},BaseCurve.prototype._wnafMulAdd=function _wnafMulAdd(e,t,a,r,n){var d,s,b,u=this._wnafT1,h=this._wnafT2,l=this._wnafT3,g=0;for(d=0;d=1;d-=2){var B=d-1,x=d;if(1===u[B]&&1===u[x]){var I=[t[B],null,null,t[x]];0===t[B].y.cmp(t[x].y)?(I[1]=t[B].add(t[x]),I[2]=t[B].toJ().mixedAdd(t[x].neg())):0===t[B].y.cmp(t[x].y.redNeg())?(I[1]=t[B].toJ().mixedAdd(t[x]),I[2]=t[B].add(t[x].neg())):(I[1]=t[B].toJ().mixedAdd(t[x]),I[2]=t[B].toJ().mixedAdd(t[x].neg()));var m=[-3,-1,-5,-7,0,7,5,1,3],y=o(a[B],a[x]);for(g=Math.max(y[0].length,g),l[B]=new Array(g),l[x]=new Array(g),s=0;s=0;d--){for(var k=0;d>=0;){var _=!0;for(s=0;s=0&&k++,v=v.dblp(k),d<0)break;for(s=0;s0?b=h[s][N-1>>1]:N<0&&(b=h[s][-N-1>>1].neg()),v="affine"===b.type?v.mixedAdd(b):v.add(b))}}for(d=0;d=Math.ceil((e.bitLength()+1)/t.step)},BasePoint.prototype._getDoubles=function _getDoubles(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var a=[this],r=this,n=0;n{"use strict";var r=a(65),n=a(82);function BlockHash(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}t.BlockHash=BlockHash,BlockHash.prototype.update=function update(e,t){if(e=r.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var a=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-a,e.length),0===this.pending.length&&(this.pending=null),e=r.join32(e,0,e.length-a,this.endian);for(var n=0;n>>24&255,r[n++]=e>>>16&255,r[n++]=e>>>8&255,r[n++]=255&e}else for(r[n++]=255&e,r[n++]=e>>>8&255,r[n++]=e>>>16&255,r[n++]=e>>>24&255,r[n++]=0,r[n++]=0,r[n++]=0,r[n++]=0,c=8;c{"use strict";var r=a(30),n=a(45),c=n.getNAF,o=n.getJSF,d=n.assert;function BaseCurve(e,t){this.type=e,this.p=new r(t.p,16),this.red=t.prime?r.red(t.prime):r.mont(this.p),this.zero=new r(0).toRed(this.red),this.one=new r(1).toRed(this.red),this.two=new r(2).toRed(this.red),this.n=t.n&&new r(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var a=this.n&&this.p.div(this.n);!a||a.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function BasePoint(e,t){this.curve=e,this.type=t,this.precomputed=null}e.exports=BaseCurve,BaseCurve.prototype.point=function point(){throw new Error("Not implemented")},BaseCurve.prototype.validate=function validate(){throw new Error("Not implemented")},BaseCurve.prototype._fixedNafMul=function _fixedNafMul(e,t){d(e.precomputed);var a=e._getDoubles(),r=c(t,1,this._bitLength),n=(1<=o;u--)s=(s<<1)+r[u];b.push(s)}for(var h=this.jpoint(null,null,null),l=this.jpoint(null,null,null),g=n;g>0;g--){for(o=0;o=0;b--){for(var u=0;b>=0&&0===o[b];b--)u++;if(b>=0&&u++,s=s.dblp(u),b<0)break;var h=o[b];d(0!==h),s="affine"===e.type?h>0?s.mixedAdd(n[h-1>>1]):s.mixedAdd(n[-h-1>>1].neg()):h>0?s.add(n[h-1>>1]):s.add(n[-h-1>>1].neg())}return"affine"===e.type?s.toP():s},BaseCurve.prototype._wnafMulAdd=function _wnafMulAdd(e,t,a,r,n){var d,s,b,u=this._wnafT1,h=this._wnafT2,l=this._wnafT3,g=0;for(d=0;d=1;d-=2){var B=d-1,x=d;if(1===u[B]&&1===u[x]){var I=[t[B],null,null,t[x]];0===t[B].y.cmp(t[x].y)?(I[1]=t[B].add(t[x]),I[2]=t[B].toJ().mixedAdd(t[x].neg())):0===t[B].y.cmp(t[x].y.redNeg())?(I[1]=t[B].toJ().mixedAdd(t[x]),I[2]=t[B].add(t[x].neg())):(I[1]=t[B].toJ().mixedAdd(t[x]),I[2]=t[B].toJ().mixedAdd(t[x].neg()));var m=[-3,-1,-5,-7,0,7,5,1,3],y=o(a[B],a[x]);for(g=Math.max(y[0].length,g),l[B]=new Array(g),l[x]=new Array(g),s=0;s=0;d--){for(var k=0;d>=0;){var _=!0;for(s=0;s=0&&k++,v=v.dblp(k),d<0)break;for(s=0;s0?b=h[s][N-1>>1]:N<0&&(b=h[s][-N-1>>1].neg()),v="affine"===b.type?v.mixedAdd(b):v.add(b))}}for(d=0;d=Math.ceil((e.bitLength()+1)/t.step)},BasePoint.prototype._getDoubles=function _getDoubles(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var a=[this],r=this,n=0;n{"use strict";var r=a(66),n=a(83);function BlockHash(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}t.BlockHash=BlockHash,BlockHash.prototype.update=function update(e,t){if(e=r.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var a=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-a,e.length),0===this.pending.length&&(this.pending=null),e=r.join32(e,0,e.length-a,this.endian);for(var n=0;n>>24&255,r[n++]=e>>>16&255,r[n++]=e>>>8&255,r[n++]=255&e}else for(r[n++]=255&e,r[n++]=e>>>8&255,r[n++]=e>>>16&255,r[n++]=e>>>24&255,r[n++]=0,r[n++]=0,r[n++]=0,r[n++]=0,c=8;c{"use strict";var r=a(9),n=a(431),c=a(438),o=a(439),d=a(1004);function Hash(e){d.call(this,"digest"),this._hash=e}r(Hash,d),Hash.prototype._update=function(e){this._hash.update(e)},Hash.prototype._final=function(){return this._hash.digest()},e.exports=function createHash(e){return"md5"===(e=e.toLowerCase())?new n:"rmd160"===e||"ripemd160"===e?new c:new Hash(o(e))}},(e,t,a)=>{e.exports=a(1014)(a(1035))},(e,t,a)=>{"use strict";var r=a(447);e.exports=function hasToStringTagShams(){return r()&&!!Symbol.toStringTag}},(e,t,a)=>{"use strict";var r=a(99),n=a(1027);e.exports=function supports(){var e=r.apply(null,arguments);return n(e,{bufferKeys:e.bufferKeys||!1,snapshots:e.snapshots||!1,permanence:e.permanence||!1,seek:e.seek||!1,clear:e.clear||!1,status:e.status||!1,createIfMissing:e.createIfMissing||!1,errorIfExists:e.errorIfExists||!1,deferredOpen:e.deferredOpen||!1,openCallback:e.openCallback||!1,promises:e.promises||!1,streams:e.streams||!1,encodings:e.encodings||!1,additionalMethods:r(e.additionalMethods)})}},(e,t,a)=>{"use strict";var r=a(1057);t.fromCallback=function(e,t){if(void 0===e){var a=new Promise((function(t,a){e=function(e,r){e?a(e):t(r)}}));e[void 0!==t?t:"promise"]=a}else if("function"!=typeof e)throw new TypeError("Callback must be a function");return e},t.fromPromise=function(e,t){if(void 0===t)return e;e.then((function(e){r((()=>t(null,e)))})).catch((function(e){r((()=>t(e)))}))}},(e,t,a)=>{let r;e.exports="function"==typeof queueMicrotask?queueMicrotask.bind("undefined"!=typeof window?window:a.g):e=>(r||(r=Promise.resolve())).then(e).catch((e=>setTimeout((()=>{throw e}),0)))},(e,t,a)=>{var r=a(35);e.exports=!r((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}))},(e,t,a)=>{var r,n,c,o=a(1097),d=a(11),s=a(33),b=a(67),u=a(104),h=a(68),l=a(262),g=a(271),p=a(170),B="Object already initialized",x=d.TypeError,I=d.WeakMap;if(o||l.state){var m=l.state||(l.state=new I),y=s(m.get),C=s(m.has),w=s(m.set);r=function(e,t){if(C(m,e))throw new x(B);return t.facade=e,w(m,e,t),t},n=function(e){return y(m,e)||{}},c=function(e){return C(m,e)}}else{var v=g("state");p[v]=!0,r=function(e,t){if(h(e,v))throw new x(B);return t.facade=e,u(e,v,t),t},n=function(e){return h(e,v)?e[v]:{}},c=function(e){return h(e,v)}}e.exports={set:r,get:n,has:c,enforce:function(e){return c(e)?n(e):r(e,{})},getterFor:function(e){return function(t){var a;if(!b(t)||(a=n(t)).type!==e)throw x("Incompatible receiver, "+e+" required");return a}}}},e=>{e.exports=!0},e=>{e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},e=>{e.exports={}},(e,t,a)=>{var r=a(33),n=a(267),c=a(166),o=r(r.bind);e.exports=function(e,t){return n(e),void 0===t?e:c?o(e,t):function(){return e.apply(t,arguments)}}},(e,t,a)=>{var r=a(1109);e.exports=function(e){return r(e.length)}},(e,t,a)=>{var r=a(11),n=a(279),c=a(29),o=a(125),d=a(51)("toStringTag"),s=r.Object,b="Arguments"==o(function(){return arguments}());e.exports=n?o:function(e){var t,a,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(a=function(e,t){try{return e[t]}catch(e){}}(t=s(e),d))?a:b?o(t):"Object"==(r=o(t))&&c(t.callee)?"Arguments":r}},(e,t,a)=>{"use strict";var r=a(0).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.updateSstoreGas=t.writeCallOutput=t.subMemUsage=t.maxCallGas=t.jumpSubIsValid=t.jumpIsValid=t.getFullname=t.getDataSlice=t.short=t.divCeil=t.describeLocation=t.addressToBuffer=t.trap=t.setLengthLeftStorage=void 0;const n=a(1),c=a(18),o=new n.BN(1).shln(160).subn(1);function divCeil(e,t){const a=e.div(t);return e.mod(t).isZero()?a:a.isNeg()?a.isubn(1):a.iaddn(1)}function getDataSlice(e,t,a){const r=new n.BN(e.length);t.gt(r)&&(t=r);let c=t.add(a);return c.gt(r)&&(c=r),e=e.slice(t.toNumber(),c.toNumber()),e=(0,n.setLengthRight)(e,a.toNumber())}t.setLengthLeftStorage=function setLengthLeftStorage(e){return e.equals(r.alloc(e.length,0))?r.alloc(0):(0,n.setLengthLeft)(e,32)},t.trap=function trap(e){throw new c.VmError(e)},t.addressToBuffer=function addressToBuffer(e){return r.isBuffer(e)?e:e.and(o).toArrayLike(r,"be",20)},t.describeLocation=function describeLocation(e){return`${(0,n.keccak256)(e.eei.getCode()).toString("hex")}/${e.eei.getAddress().buf.toString("hex")}:${e.programCounter-1}`},t.divCeil=divCeil,t.short=function short(e){const t=e.toString("hex");return t.length<=50?t:t.slice(0,50)+"..."},t.getDataSlice=getDataSlice,t.getFullname=function getFullname(e,t){switch(t){case"LOG":t+=e-160;break;case"PUSH":t+=e-95;break;case"DUP":t+=e-127;break;case"SWAP":t+=e-143}return t},t.jumpIsValid=function jumpIsValid(e,t){return 1===e.validJumps[t]},t.jumpSubIsValid=function jumpSubIsValid(e,t){return 2===e.validJumps[t]},t.maxCallGas=function maxCallGas(e,t,a,r){if(r.gteHardfork("tangerineWhistle")){const a=t.sub(t.divn(64));return e.gt(a)?a:e}return e},t.subMemUsage=function subMemUsage(e,t,a,r){if(a.isZero())return new n.BN(0);const c=divCeil(t.add(a),new n.BN(32));if(c.lte(e.memoryWordCount))return new n.BN(0);const o=c,d=new n.BN(r.param("gasPrices","memory")),s=new n.BN(r.param("gasPrices","quadCoeffDiv")),b=o.mul(d).add(o.mul(o).div(s));if(b.gt(e.highestMemCost)){const t=e.highestMemCost;e.highestMemCost=b.clone(),b.isub(t)}return e.memoryWordCount=c,b},t.writeCallOutput=function writeCallOutput(e,t,a){const r=e.eei.getReturnData();if(r.length>0){const c=t.toNumber();let o=a.toNumber();r.length0&&t.length>0){return new n.BN(r.param("gasPrices","sstoreReset"))}if(0===a.length&&t.length>0){const t=new n.BN(r.param("gasPrices","sstoreReset"));return e.eei.refundGas(new n.BN(r.param("gasPrices","sstoreRefund")),"updateSstoreGas"),t}return new n.BN(r.param("gasPrices","sstoreSet"))}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalize=void 0;t.normalize=e=>e},(e,t,a)=>{"use strict";var r=a(1180),n="function"==typeof Symbol&&"symbol"==typeof Symbol("foo"),c=Object.prototype.toString,o=Array.prototype.concat,d=Object.defineProperty,s=d&&function(){var e={};try{for(var t in d(e,"x",{enumerable:!1,value:e}),e)return!1;return e.x===e}catch(e){return!1}}(),defineProperty=function(e,t,a,r){var n;(!(t in e)||"function"==typeof(n=r)&&"[object Function]"===c.call(n)&&r())&&(s?d(e,t,{configurable:!0,enumerable:!1,value:a,writable:!0}):e[t]=a)},defineProperties=function(e,t){var a=arguments.length>2?arguments[2]:{},c=r(t);n&&(c=o.call(c,Object.getOwnPropertySymbols(t)));for(var d=0;d{"use strict";e.exports=function requirePromise(){if("function"!=typeof Promise)throw new TypeError("`Promise.allSettled` requires a global `Promise` be available.")}},(e,t,a)=>{"use strict";var r=a(285);e.exports=function hasToStringTagShams(){return r()&&!!Symbol.toStringTag}},function(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[a]}})}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||r(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),n(a(1247),t),n(a(1251),t),n(a(600),t),n(a(1252),t),n(a(601),t),n(a(1253),t),n(a(744),t),n(a(743),t),n(a(301),t),n(a(1254),t),n(a(641),t),n(a(1258),t),n(a(643),t)},function(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&r(t,e,a);return n(t,e),t},o=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,a=t&&e[t],r=0;if(a)return a.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},d=this&&this.__read||function(e,t){var a="function"==typeof Symbol&&e[Symbol.iterator];if(!a)return e;var r,n,c=a.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(r=c.next()).done;)o.push(r.value)}catch(e){n={error:e}}finally{try{r&&!r.done&&(a=c.return)&&a.call(c)}finally{if(n)throw n.error}}return o};Object.defineProperty(t,"__esModule",{value:!0}),t.BaseTransaction=void 0;var s=c(a(555)),b=a(47),u=a(96),h=function(){function BaseTransaction(e){this.cache={hash:void 0,dataFee:void 0},this.activeCapabilities=[],this.DEFAULT_CHAIN=s.Chain.Mainnet,this.DEFAULT_HARDFORK=s.Hardfork.Istanbul;var t=e.nonce,a=e.gasLimit,r=e.to,n=e.value,c=e.data,o=e.v,d=e.r,u=e.s,h=e.type;this._type=new b.BN((0,b.toBuffer)(h)).toNumber();var l=(0,b.toBuffer)(""===r?"0x":r),g=(0,b.toBuffer)(""===o?"0x":o),p=(0,b.toBuffer)(""===d?"0x":d),B=(0,b.toBuffer)(""===u?"0x":u);this.nonce=new b.BN((0,b.toBuffer)(""===t?"0x":t)),this.gasLimit=new b.BN((0,b.toBuffer)(""===a?"0x":a)),this.to=l.length>0?new b.Address(l):void 0,this.value=new b.BN((0,b.toBuffer)(""===n?"0x":n)),this.data=(0,b.toBuffer)(""===c?"0x":c),this.v=g.length>0?new b.BN(g):void 0,this.r=p.length>0?new b.BN(p):void 0,this.s=B.length>0?new b.BN(B):void 0,this._validateCannotExceedMaxInteger({value:this.value,r:this.r,s:this.s}),this._validateCannotExceedMaxInteger({gasLimit:this.gasLimit},64),this._validateCannotExceedMaxInteger({nonce:this.nonce},64,!0)}return Object.defineProperty(BaseTransaction.prototype,"transactionType",{get:function(){return this.type},enumerable:!1,configurable:!0}),Object.defineProperty(BaseTransaction.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),BaseTransaction.prototype.supports=function(e){return this.activeCapabilities.includes(e)},BaseTransaction.prototype.validate=function(e){void 0===e&&(e=!1);var t=[];return this.getBaseFee().gt(this.gasLimit)&&t.push("gasLimit is too low. given ".concat(this.gasLimit,", need at least ").concat(this.getBaseFee())),this.isSigned()&&!this.verifySignature()&&t.push("Invalid Signature"),e?t:0===t.length},BaseTransaction.prototype.getBaseFee=function(){var e=this.getDataFee().addn(this.common.param("gasPrices","tx"));return this.common.gteHardfork("homestead")&&this.toCreationAddress()&&e.iaddn(this.common.param("gasPrices","txCreation")),e},BaseTransaction.prototype.getDataFee=function(){for(var e=this.common.param("gasPrices","txDataZero"),t=this.common.param("gasPrices","txDataNonZero"),a=0,r=0;r-1&&this.activeCapabilities.splice(h,1)}return s},BaseTransaction.prototype._getCommon=function(e,t){var a;if(t){var r=new b.BN((0,b.toBuffer)(t));if(e){if(!e.chainIdBN().eq(r)){var n=this._errorMsg("The chain ID does not match the chain ID of Common");throw new Error(n)}return e.copy()}return s.default.isSupportedChainId(r)?new s.default({chain:r,hardfork:this.DEFAULT_HARDFORK}):s.default.forCustomChain(this.DEFAULT_CHAIN,{name:"custom-chain",networkId:r,chainId:r},this.DEFAULT_HARDFORK)}return null!==(a=null==e?void 0:e.copy())&&void 0!==a?a:new s.default({chain:this.DEFAULT_CHAIN,hardfork:this.DEFAULT_HARDFORK})},BaseTransaction.prototype._validateCannotExceedMaxInteger=function(e,t,a){var r,n;void 0===t&&(t=256),void 0===a&&(a=!1);try{for(var c=o(Object.entries(e)),s=c.next();!s.done;s=c.next()){var u=d(s.value,2),h=u[0],l=u[1];switch(t){case 64:if(a){if(null==l?void 0:l.gte(b.MAX_UINT64)){var g=this._errorMsg("".concat(h," cannot equal or exceed MAX_UINT64 (2^64-1), given ").concat(l));throw new Error(g)}}else if(null==l?void 0:l.gt(b.MAX_UINT64)){g=this._errorMsg("".concat(h," cannot exceed MAX_UINT64 (2^64-1), given ").concat(l));throw new Error(g)}break;case 256:if(a){if(null==l?void 0:l.gte(b.MAX_INTEGER)){g=this._errorMsg("".concat(h," cannot equal or exceed MAX_INTEGER (2^256-1), given ").concat(l));throw new Error(g)}}else if(null==l?void 0:l.gt(b.MAX_INTEGER)){g=this._errorMsg("".concat(h," cannot exceed MAX_INTEGER (2^256-1), given ").concat(l));throw new Error(g)}break;default:g=this._errorMsg("unimplemented bits value");throw new Error(g)}}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=c.return)&&n.call(c)}finally{if(r)throw r.error}}},BaseTransaction.prototype._getSharedErrorPostfix=function(){var e="";try{e=this.isSigned()?(0,b.bufferToHex)(this.hash()):"not available (unsigned)"}catch(t){e="error"}var t="";try{t=this.isSigned().toString()}catch(t){e="error"}var a="";try{a=this.common.hardfork()}catch(e){a="error"}var r="tx type=".concat(this.type," hash=").concat(e," nonce=").concat(this.nonce," value=").concat(this.value," ");return r+="signed=".concat(t," hf=").concat(a)},BaseTransaction}();t.BaseTransaction=h},function(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&r(t,e,a);return n(t,e),t},o=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,a=t&&e[t],r=0;if(a)return a.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},d=this&&this.__read||function(e,t){var a="function"==typeof Symbol&&e[Symbol.iterator];if(!a)return e;var r,n,c=a.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(r=c.next()).done;)o.push(r.value)}catch(e){n={error:e}}finally{try{r&&!r.done&&(a=c.return)&&a.call(c)}finally{if(n)throw n.error}}return o};Object.defineProperty(t,"__esModule",{value:!0}),t.BaseTransaction=void 0;var s=c(a(34)),b=a(1),u=a(102),h=function(){function BaseTransaction(e){this.cache={hash:void 0,dataFee:void 0},this.activeCapabilities=[],this.DEFAULT_CHAIN=s.Chain.Mainnet,this.DEFAULT_HARDFORK=s.Hardfork.Istanbul;var t=e.nonce,a=e.gasLimit,r=e.to,n=e.value,c=e.data,o=e.v,d=e.r,u=e.s,h=e.type;this._type=new b.BN((0,b.toBuffer)(h)).toNumber();var l=(0,b.toBuffer)(""===r?"0x":r),g=(0,b.toBuffer)(""===o?"0x":o),p=(0,b.toBuffer)(""===d?"0x":d),B=(0,b.toBuffer)(""===u?"0x":u);this.nonce=new b.BN((0,b.toBuffer)(""===t?"0x":t)),this.gasLimit=new b.BN((0,b.toBuffer)(""===a?"0x":a)),this.to=l.length>0?new b.Address(l):void 0,this.value=new b.BN((0,b.toBuffer)(""===n?"0x":n)),this.data=(0,b.toBuffer)(""===c?"0x":c),this.v=g.length>0?new b.BN(g):void 0,this.r=p.length>0?new b.BN(p):void 0,this.s=B.length>0?new b.BN(B):void 0,this._validateCannotExceedMaxInteger({value:this.value,r:this.r,s:this.s}),this._validateCannotExceedMaxInteger({gasLimit:this.gasLimit},64),this._validateCannotExceedMaxInteger({nonce:this.nonce},64,!0)}return Object.defineProperty(BaseTransaction.prototype,"transactionType",{get:function(){return this.type},enumerable:!1,configurable:!0}),Object.defineProperty(BaseTransaction.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),BaseTransaction.prototype.supports=function(e){return this.activeCapabilities.includes(e)},BaseTransaction.prototype.validate=function(e){void 0===e&&(e=!1);var t=[];return this.getBaseFee().gt(this.gasLimit)&&t.push("gasLimit is too low. given ".concat(this.gasLimit,", need at least ").concat(this.getBaseFee())),this.isSigned()&&!this.verifySignature()&&t.push("Invalid Signature"),e?t:0===t.length},BaseTransaction.prototype.getBaseFee=function(){var e=this.getDataFee().addn(this.common.param("gasPrices","tx"));return this.common.gteHardfork("homestead")&&this.toCreationAddress()&&e.iaddn(this.common.param("gasPrices","txCreation")),e},BaseTransaction.prototype.getDataFee=function(){for(var e=this.common.param("gasPrices","txDataZero"),t=this.common.param("gasPrices","txDataNonZero"),a=0,r=0;r-1&&this.activeCapabilities.splice(h,1)}return s},BaseTransaction.prototype._getCommon=function(e,t){var a;if(t){var r=new b.BN((0,b.toBuffer)(t));if(e){if(!e.chainIdBN().eq(r)){var n=this._errorMsg("The chain ID does not match the chain ID of Common");throw new Error(n)}return e.copy()}return s.default.isSupportedChainId(r)?new s.default({chain:r,hardfork:this.DEFAULT_HARDFORK}):s.default.forCustomChain(this.DEFAULT_CHAIN,{name:"custom-chain",networkId:r,chainId:r},this.DEFAULT_HARDFORK)}return null!==(a=null==e?void 0:e.copy())&&void 0!==a?a:new s.default({chain:this.DEFAULT_CHAIN,hardfork:this.DEFAULT_HARDFORK})},BaseTransaction.prototype._validateCannotExceedMaxInteger=function(e,t,a){var r,n;void 0===t&&(t=256),void 0===a&&(a=!1);try{for(var c=o(Object.entries(e)),s=c.next();!s.done;s=c.next()){var u=d(s.value,2),h=u[0],l=u[1];switch(t){case 64:if(a){if(null==l?void 0:l.gte(b.MAX_UINT64)){var g=this._errorMsg("".concat(h," cannot equal or exceed MAX_UINT64 (2^64-1), given ").concat(l));throw new Error(g)}}else if(null==l?void 0:l.gt(b.MAX_UINT64)){g=this._errorMsg("".concat(h," cannot exceed MAX_UINT64 (2^64-1), given ").concat(l));throw new Error(g)}break;case 256:if(a){if(null==l?void 0:l.gte(b.MAX_INTEGER)){g=this._errorMsg("".concat(h," cannot equal or exceed MAX_INTEGER (2^256-1), given ").concat(l));throw new Error(g)}}else if(null==l?void 0:l.gt(b.MAX_INTEGER)){g=this._errorMsg("".concat(h," cannot exceed MAX_INTEGER (2^256-1), given ").concat(l));throw new Error(g)}break;default:g=this._errorMsg("unimplemented bits value");throw new Error(g)}}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=c.return)&&n.call(c)}finally{if(r)throw r.error}}},BaseTransaction.prototype._getSharedErrorPostfix=function(){var e="";try{e=this.isSigned()?(0,b.bufferToHex)(this.hash()):"not available (unsigned)"}catch(t){e="error"}var t="";try{t=this.isSigned().toString()}catch(t){e="error"}var a="";try{a=this.common.hardfork()}catch(e){a="error"}var r="tx type=".concat(this.type," hash=").concat(e," nonce=").concat(this.nonce," value=").concat(this.value," ");return r+="signed=".concat(t," hf=").concat(a)},BaseTransaction}();t.BaseTransaction=h},function(__unused_webpack_module,exports,__webpack_require__){"use strict";var process=__webpack_require__(5),__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GetConnector=exports.DefaultOptionsByName=exports.DefaultFlavor=exports.FilecoinFlavorName=exports.EthereumFlavorName=void 0;const ethereum_1=__webpack_require__(596),ethereum_options_1=__webpack_require__(308),filecoin_options_1=__webpack_require__(1597),colors_1=__webpack_require__(598),chalk_1=__importDefault(__webpack_require__(1169));__webpack_require__(88);const NEED_HELP="Need help? Reach out to the Truffle community at",COMMUNITY_LINK="https://trfl.io/support";function GetConnector(flavor,providerOptions,executor){if(flavor===exports.DefaultFlavor)return new ethereum_1.Connector(providerOptions,executor);try{if(flavor===exports.FilecoinFlavorName){flavor="@ganache/filecoin";const f=eval("require")(flavor),Connector=void 0!==f.default?f.default.Connector:f.Connector;return new Connector(providerOptions,executor)}{const{Connector:e}=__webpack_require__(1603)(flavor);return new e(providerOptions,executor)}}catch(e){if(!e.message.includes(`Cannot find module '${flavor}'`))throw e;console.warn(chalk_1.default`\n\n{red.bold ERROR:} Could not find Ganache flavor "{bold filecoin}" (${flavor}); `+"it probably\nneeds to be installed.\n ▸ if you're using Ganache as a library run: \n"+chalk_1.default` {blue.bold $ npm install ${flavor}}\n`+" ▸ if you're using Ganache as a CLI run: \n"+chalk_1.default` {blue.bold $ npm install --global ${flavor}}\n\n`+chalk_1.default`{hex("${colors_1.TruffleColors.porsche}").bold ${NEED_HELP}}\n`+chalk_1.default`{hex("${colors_1.TruffleColors.turquoise}") ${COMMUNITY_LINK}}\n\n`),process.exit(1)}}exports.EthereumFlavorName="ethereum",exports.FilecoinFlavorName="filecoin",exports.DefaultFlavor=exports.EthereumFlavorName,exports.DefaultOptionsByName={[exports.EthereumFlavorName]:ethereum_options_1.EthereumDefaults,[exports.FilecoinFlavorName]:filecoin_options_1.FilecoinDefaults},exports.GetConnector=GetConnector},function(e,t,a){"use strict";var r=a(10).Buffer,n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.computeIntrinsicsFeeMarketTx=t.computeIntrinsicsAccessListTx=t.computeIntrinsicsLegacyTx=t.computeFromAddress=t.publicKeyConvert=t.ecdsaRecover=t.isValidSigRecovery=void 0;const c=a(4),o=a(27),d=a(28),s=n(a(119));function copyOrFill(e,t,a,r){if(e.byteLength>r)throw new Error("Invalid signature");const n=r-e.byteLength,c=a+n;let o=a;for(;o1===e||0===e;function _ecdsaRecover(e,a,r,n,o){if(!(0,t.isValidSigRecovery)(o))throw new Error("Invalid signature v value");const d=(0,c.keccak)(e),b=a.slice(0,64);copyOrFill(r,b,0,32),copyOrFill(n,b,32,32);const u=a.slice(0,33);if(0!==s.default.ecdsaRecover(u,b,o,d))throw new Error("Invalid Signature");return u}t.ecdsaRecover=(e,t,a,r,n,d)=>{let s,b;const u=2*r+35;if(a===u||a===u+1){const t=[0===(h=r)?c.BUFFER_EMPTY:(0,c.uintToBuffer)(h),c.BUFFER_EMPTY,c.BUFFER_EMPTY],n=(0,o.encodeRange)(t,0,3);s=(0,o.digest)([e.output,n.output],e.length+n.length),b=a-u}else s=(0,o.digest)([e.output],e.length),b=a-27;var h;return _ecdsaRecover(s,t,n,d,b)};t.publicKeyConvert=(e,t)=>{const a=e.slice(0,65);if(0!==s.default.publicKeyConvert(a,t))throw new Error("Invalid Signature");return a};const b=r.allocUnsafe(65);t.computeFromAddress=(e,a,r,n,o)=>{const s=(0,t.ecdsaRecover)(e,b,a,o,r,n),u=(0,t.publicKeyConvert)(b,s);return d.Address.from((0,c.keccak)(u.slice(1)).slice(-20))};t.computeIntrinsicsLegacyTx=(e,a,r)=>{const n=(0,o.encodeRange)(a,0,6),d=(0,o.encodeRange)(a,6,3),s=(0,o.digest)([n.output,d.output],n.length+d.length);return{from:(0,t.computeFromAddress)(n,e.toNumber(),a[7],a[8],r),hash:c.Data.from((0,c.keccak)(s),32),serialized:s,encodedData:n,encodedSignature:d}};t.computeIntrinsicsAccessListTx=(e,a)=>{const n=a[0],s=(0,o.encodeRange)(a,1,8),u=(0,o.encodeRange)(a,9,3),h=r.concat([n,(0,o.digest)([s.output,u.output],s.length+u.length)]),l=_ecdsaRecover(r.concat([n,(0,o.digest)([s.output],s.length)]),b,a[10],a[11],e.toNumber()),g=(0,t.publicKeyConvert)(b,l);return{from:d.Address.from((0,c.keccak)(g.slice(1)).slice(-20)),hash:c.Data.from((0,c.keccak)(h),32),serialized:h,encodedData:s,encodedSignature:u}};t.computeIntrinsicsFeeMarketTx=(e,a)=>{const n=a[0],s=(0,o.encodeRange)(a,1,9),u=(0,o.encodeRange)(a,10,3),h=r.concat([n,(0,o.digest)([s.output,u.output],s.length+u.length)]),l=_ecdsaRecover(r.concat([n,(0,o.digest)([s.output],s.length)]),b,a[11],a[12],e.toNumber()),g=(0,t.publicKeyConvert)(b,l);return{from:d.Address.from((0,c.keccak)(g.slice(1)).slice(-20)),hash:c.Data.from((0,c.keccak)(h),32),serialized:h,encodedData:s,encodedSignature:u}}},function(e,t,a){"use strict";var r=this&&this.__awaiter||function(e,t,a,r){return new(a||(a=Promise))((function(n,c){function fulfilled(e){try{step(r.next(e))}catch(e){c(e)}}function rejected(e){try{step(r.throw(e))}catch(e){c(e)}}function step(e){e.done?n(e.value):function adopt(e){return e instanceof a?e:new a((function(t){t(e)}))}(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())}))},n=this&&this.__generator||function(e,t){var a,r,n,c,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return c={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function verb(c){return function(d){return function step(c){if(a)throw new TypeError("Generator is already executing.");for(;o;)try{if(a=1,r&&(n=2&c[0]?r.return:c[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,c[1])).done)return n;switch(r=0,n&&(c=[2&c[0],n.value]),c[0]){case 0:case 1:n=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,r=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!(n=o.trys,(n=n.length>0&&n[n.length-1])||6!==c[0]&&2!==c[0])){o=0;continue}if(3===c[0]&&(!n||c[1]>n[0]&&c[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Trie=void 0;var d=o(a(322)),s=a(1),b=a(299),u=a(582),h=a(252),l=a(305),g=a(192),p=a(557),B=a(3),x=function(){function Trie(e,t,a){void 0===a&&(a=!1),this.EMPTY_TRIE_ROOT=s.KECCAK256_RLP,this.lock=new d.default(1),this.db=e?new b.DB(e):new b.DB,this._root=this.EMPTY_TRIE_ROOT,this._deleteFromDB=a,t&&(this.root=t)}return Object.defineProperty(Trie.prototype,"root",{get:function(){return this._root},set:function(e){e||(e=this.EMPTY_TRIE_ROOT),B(32===e.length,"Invalid root length. Roots are 32 bytes"),this._root=e},enumerable:!1,configurable:!0}),Trie.prototype.setRoot=function(e){this.root=null!=e?e:this.EMPTY_TRIE_ROOT},Trie.prototype.checkRoot=function(e){return r(this,void 0,void 0,(function(){var t;return n(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,this._lookupNode(e)];case 1:return[2,null!==a.sent()];case 2:if("Missing node in DB"==(t=a.sent()).message)return[2,!1];throw t;case 3:return[2]}}))}))},Object.defineProperty(Trie.prototype,"isCheckpoint",{get:function(){return!1},enumerable:!1,configurable:!0}),Trie.prototype.get=function(e,t){return void 0===t&&(t=!1),r(this,void 0,void 0,(function(){var a,r,c,o;return n(this,(function(n){switch(n.label){case 0:return[4,this.findPath(e,t)];case 1:return a=n.sent(),r=a.node,c=a.remaining,o=null,r&&0===c.length&&(o=r.value),[2,o]}}))}))},Trie.prototype.put=function(e,t){return r(this,void 0,void 0,(function(){var a,r,c;return n(this,(function(n){switch(n.label){case 0:return t&&""!==t.toString()?[3,2]:[4,this.del(e)];case 1:return[2,n.sent()];case 2:return[4,this.lock.wait()];case 3:return n.sent(),this.root.equals(s.KECCAK256_RLP)?[4,this._createInitialNode(e,t)]:[3,5];case 4:return n.sent(),[3,8];case 5:return[4,this.findPath(e)];case 6:return a=n.sent(),r=a.remaining,c=a.stack,[4,this._updateNode(e,t,r,c)];case 7:n.sent(),n.label=8;case 8:return this.lock.signal(),[2]}}))}))},Trie.prototype.del=function(e){return r(this,void 0,void 0,(function(){var t,a,r;return n(this,(function(n){switch(n.label){case 0:return[4,this.lock.wait()];case 1:return n.sent(),[4,this.findPath(e)];case 2:return t=n.sent(),a=t.node,r=t.stack,a?[4,this._deleteNode(e,r)]:[3,4];case 3:n.sent(),n.label=4;case 4:return this.lock.signal(),[2]}}))}))},Trie.prototype.findPath=function(e,t){return void 0===t&&(t=!1),r(this,void 0,void 0,(function(){var a=this;return n(this,(function(c){return[2,new Promise((function(c,o){return r(a,void 0,void 0,(function(){var a,d,s,b,u=this;return n(this,(function(l){switch(l.label){case 0:a=[],d=(0,h.bufferToNibbles)(e),s=function(e,t,s,b){return r(u,void 0,void 0,(function(){var e,r;return n(this,(function(n){return null===t?[2,o(new Error("Path not found"))]:(e=d.slice((0,h.matchingNibbleLength)(s,d)),a.push(t),t instanceof g.BranchNode?0===e.length?c({node:t,remaining:[],stack:a}):(r=e[0],t.getBranch(r)?b.onlyBranchIndex(t,s,r):c({node:null,remaining:e,stack:a})):t instanceof g.LeafNode?(0,h.doKeysMatch)(e,t.key)?c({node:t,remaining:[],stack:a}):c({node:null,remaining:e,stack:a}):t instanceof g.ExtensionNode&&((0,h.matchingNibbleLength)(e,t.key)!==t.key.length?c({node:null,remaining:e,stack:a}):b.allChildren(t,s)),[2])}))}))},l.label=1;case 1:return l.trys.push([1,3,,4]),[4,this.walkTrie(this.root,s)];case 2:return l.sent(),[3,4];case 3:return("Missing node in DB"!=(b=l.sent()).message||t)&&o(b),[3,4];case 4:return c({node:null,remaining:[],stack:a}),[2]}}))}))}))]}))}))},Trie.prototype.walkTrie=function(e,t){return r(this,void 0,void 0,(function(){return n(this,(function(a){switch(a.label){case 0:return[4,l.WalkController.newWalk(t,this,e)];case 1:return a.sent(),[2]}}))}))},Trie.prototype._walkTrie=function(e,t){return r(this,void 0,void 0,(function(){return n(this,(function(a){switch(a.label){case 0:return[4,this.walkTrie(e,t)];case 1:return a.sent(),[2]}}))}))},Trie.prototype._createInitialNode=function(e,t){return r(this,void 0,void 0,(function(){var a;return n(this,(function(r){switch(r.label){case 0:return a=new g.LeafNode((0,h.bufferToNibbles)(e),t),this.root=a.hash(),[4,this.db.put(this.root,a.serialize())];case 1:return r.sent(),[2]}}))}))},Trie.prototype.lookupNode=function(e){return r(this,void 0,void 0,(function(){var t;return n(this,(function(a){switch(a.label){case 0:return(0,g.isRawNode)(e)?[2,(0,g.decodeRawNode)(e)]:(t=null,null,[4,this.db.get(e)]);case 1:if(!(t=a.sent()))throw new Error("Missing node in DB");return[2,(0,g.decodeNode)(t)]}}))}))},Trie.prototype._lookupNode=function(e){return r(this,void 0,void 0,(function(){return n(this,(function(t){return[2,this.lookupNode(e)]}))}))},Trie.prototype._updateNode=function(e,t,a,c){return r(this,void 0,void 0,(function(){var r,o,d,s,b,u,l,p,B,x,I,m,y,C,w,v;return n(this,(function(n){switch(n.label){case 0:if(r=[],!(o=c.pop()))throw new Error("Stack underflow");if(d=(0,h.bufferToNibbles)(e),s=!1,o instanceof g.LeafNode){for(b=0,u=0;u=32||t){var c=(0,s.keccak)(n);return r?this._deleteFromDB&&a.push({type:"del",key:c}):a.push({type:"put",key:c,value:n}),c}return e.raw()},Trie.prototype.batch=function(e){return r(this,void 0,void 0,(function(){var t,a,r,o,d,s;return n(this,(function(n){switch(n.label){case 0:n.trys.push([0,7,8,9]),t=c(e),a=t.next(),n.label=1;case 1:if(a.done)return[3,6];if("put"!==(r=a.value).type)return[3,3];if(!r.value)throw new Error("Invalid batch db operation");return[4,this.put(r.key,r.value)];case 2:return n.sent(),[3,5];case 3:return"del"!==r.type?[3,5]:[4,this.del(r.key)];case 4:n.sent(),n.label=5;case 5:return a=t.next(),[3,1];case 6:return[3,9];case 7:return o=n.sent(),d={error:o},[3,9];case 8:try{a&&!a.done&&(s=t.return)&&s.call(t)}finally{if(d)throw d.error}return[7];case 9:return[2]}}))}))},Trie.fromProof=function(e,t){return r(this,void 0,void 0,(function(){var a;return n(this,(function(r){switch(r.label){case 0:return a=e.map((function(e){return{type:"put",key:(0,s.keccak)(e),value:e}})),t||(t=new Trie,a[0]&&(t.root=a[0].key)),[4,t.db.batch(a)];case 1:return r.sent(),[2,t]}}))}))},Trie.prove=function(e,t){return r(this,void 0,void 0,(function(){return n(this,(function(a){return[2,this.createProof(e,t)]}))}))},Trie.createProof=function(e,t){return r(this,void 0,void 0,(function(){var a;return n(this,(function(r){switch(r.label){case 0:return[4,e.findPath(t)];case 1:return a=r.sent().stack,[2,a.map((function(e){return e.serialize()}))]}}))}))},Trie.verifyProof=function(e,t,a){return r(this,void 0,void 0,(function(){var r,c;return n(this,(function(n){switch(n.label){case 0:r=new Trie(null,e),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,Trie.fromProof(a,r)];case 2:return r=n.sent(),[3,4];case 3:throw n.sent(),new Error("Invalid proof nodes given");case 4:return n.trys.push([4,6,,7]),[4,r.get(t,!0)];case 5:return[2,n.sent()];case 6:throw"Missing node in DB"==(c=n.sent()).message?new Error("Invalid proof provided"):c;case 7:return[2]}}))}))},Trie.verifyRangeProof=function(e,t,a,r,n,c){return(0,p.verifyRangeProof)(e,t&&(0,h.bufferToNibbles)(t),a&&(0,h.bufferToNibbles)(a),r.map(h.bufferToNibbles),n,c)},Trie.prototype.createReadStream=function(){return new u.TrieReadStream(this)},Trie.prototype.copy=function(){return new Trie(this.db.copy()._leveldb,this.root)},Trie.prototype._findDbNodes=function(e){return r(this,void 0,void 0,(function(){var t,a=this;return n(this,(function(c){switch(c.label){case 0:return t=function(t,c,o,d){return r(a,void 0,void 0,(function(){return n(this,(function(a){return(0,g.isRawNode)(t)?null!==c&&d.allChildren(c,o):e(t,c,o,d),[2]}))}))},[4,this.walkTrie(this.root,t)];case 1:return c.sent(),[2]}}))}))},Trie.prototype._findValueNodes=function(e){return r(this,void 0,void 0,(function(){var t,a=this;return n(this,(function(c){switch(c.label){case 0:return t=function(t,c,o,d){return r(a,void 0,void 0,(function(){var a;return n(this,(function(r){return a=o,c instanceof g.LeafNode?(a=o.concat(c.key),e(t,c,a,d)):c instanceof g.BranchNode&&c.value?e(t,c,a,d):null!==c&&d.allChildren(c,o),[2]}))}))},[4,this.walkTrie(this.root,t)];case 1:return c.sent(),[2]}}))}))},Trie}();t.Trie=x},function(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||r(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),n(a(1563),t),n(a(300),t),n(a(174),t)},function(e,t,a){"use strict";var r=this&&this.__awaiter||function(e,t,a,r){return new(a||(a=Promise))((function(n,c){function fulfilled(e){try{step(r.next(e))}catch(e){c(e)}}function rejected(e){try{step(r.throw(e))}catch(e){c(e)}}function step(e){e.done?n(e.value):function adopt(e){return e instanceof a?e:new a((function(t){t(e)}))}(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())}))},n=this&&this.__generator||function(e,t){var a,r,n,c,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return c={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function verb(c){return function(d){return function step(c){if(a)throw new TypeError("Generator is already executing.");for(;o;)try{if(a=1,r&&(n=2&c[0]?r.return:c[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,c[1])).done)return n;switch(r=0,n&&(c=[2&c[0],n.value]),c[0]){case 0:case 1:n=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,r=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!(n=o.trys,(n=n.length>0&&n[n.length-1])||6!==c[0]&&2!==c[0])){o=0;continue}if(3===c[0]&&(!n||c[1]>n[0]&&c[1]{"use strict";var r=a(8).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.rlphash=t.ripemd160FromArray=t.ripemd160FromString=t.ripemd160=t.sha256FromArray=t.sha256FromString=t.sha256=t.keccakFromArray=t.keccakFromHexString=t.keccakFromString=t.keccak256=t.keccak=void 0;var n=a(842),c=a(378),o=a(53),d=a(74),s=a(226);t.keccak=function(e,t){switch(void 0===t&&(t=256),(0,s.assertIsBuffer)(e),t){case 224:return(0,n.keccak224)(e);case 256:return(0,n.keccak256)(e);case 384:return(0,n.keccak384)(e);case 512:return(0,n.keccak512)(e);default:throw new Error("Invald algorithm: keccak".concat(t))}};t.keccak256=function(e){return(0,t.keccak)(e)};t.keccakFromString=function(e,a){void 0===a&&(a=256),(0,s.assertIsString)(e);var n=r.from(e,"utf8");return(0,t.keccak)(n,a)};t.keccakFromHexString=function(e,a){return void 0===a&&(a=256),(0,s.assertIsHexString)(e),(0,t.keccak)((0,d.toBuffer)(e),a)};t.keccakFromArray=function(e,a){return void 0===a&&(a=256),(0,s.assertIsArray)(e),(0,t.keccak)((0,d.toBuffer)(e),a)};var _sha256=function(e){return e=(0,d.toBuffer)(e),c("sha256").update(e).digest()};t.sha256=function(e){return(0,s.assertIsBuffer)(e),_sha256(e)};t.sha256FromString=function(e){return(0,s.assertIsString)(e),_sha256(e)};t.sha256FromArray=function(e){return(0,s.assertIsArray)(e),_sha256(e)};var _ripemd160=function(e,t){e=(0,d.toBuffer)(e);var a=c("rmd160").update(e).digest();return!0===t?(0,d.setLengthLeft)(a,32):a};t.ripemd160=function(e,t){return(0,s.assertIsBuffer)(e),_ripemd160(e,t)};t.ripemd160FromString=function(e,t){return(0,s.assertIsString)(e),_ripemd160(e,t)};t.ripemd160FromArray=function(e,t){return(0,s.assertIsArray)(e),_ripemd160(e,t)};t.rlphash=function(e){return(0,t.keccak)(o.rlp.encode(e))}},(e,t,a)=>{"use strict";var r=a(10).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.rlphash=t.ripemd160FromArray=t.ripemd160FromString=t.ripemd160=t.sha256FromArray=t.sha256FromString=t.sha256=t.keccakFromArray=t.keccakFromHexString=t.keccakFromString=t.keccak256=t.keccak=void 0;var n=a(1330),c=a(890),o=a(54),d=a(75),s=a(230);t.keccak=function(e,t){switch(void 0===t&&(t=256),(0,s.assertIsBuffer)(e),t){case 224:return(0,n.keccak224)(e);case 256:return(0,n.keccak256)(e);case 384:return(0,n.keccak384)(e);case 512:return(0,n.keccak512)(e);default:throw new Error("Invald algorithm: keccak".concat(t))}};t.keccak256=function(e){return(0,t.keccak)(e)};t.keccakFromString=function(e,a){void 0===a&&(a=256),(0,s.assertIsString)(e);var n=r.from(e,"utf8");return(0,t.keccak)(n,a)};t.keccakFromHexString=function(e,a){return void 0===a&&(a=256),(0,s.assertIsHexString)(e),(0,t.keccak)((0,d.toBuffer)(e),a)};t.keccakFromArray=function(e,a){return void 0===a&&(a=256),(0,s.assertIsArray)(e),(0,t.keccak)((0,d.toBuffer)(e),a)};var _sha256=function(e){return e=(0,d.toBuffer)(e),c("sha256").update(e).digest()};t.sha256=function(e){return(0,s.assertIsBuffer)(e),_sha256(e)};t.sha256FromString=function(e){return(0,s.assertIsString)(e),_sha256(e)};t.sha256FromArray=function(e){return(0,s.assertIsArray)(e),_sha256(e)};var _ripemd160=function(e,t){e=(0,d.toBuffer)(e);var a=c("rmd160").update(e).digest();return!0===t?(0,d.setLengthLeft)(a,32):a};t.ripemd160=function(e,t){return(0,s.assertIsBuffer)(e),_ripemd160(e,t)};t.ripemd160FromString=function(e,t){return(0,s.assertIsString)(e),_ripemd160(e,t)};t.ripemd160FromArray=function(e,t){return(0,s.assertIsArray)(e),_ripemd160(e,t)};t.rlphash=function(e){return(0,t.keccak)(o.rlp.encode(e))}},(e,t,a)=>{"use strict";var r=a(2).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.rlphash=t.ripemd160FromArray=t.ripemd160FromString=t.ripemd160=t.sha256FromArray=t.sha256FromString=t.sha256=t.keccakFromArray=t.keccakFromHexString=t.keccakFromString=t.keccak256=t.keccak=void 0;var n=a(1406),c=a(954),o=a(55),d=a(76),s=a(237);t.keccak=function(e,t){switch(void 0===t&&(t=256),(0,s.assertIsBuffer)(e),t){case 224:return(0,n.keccak224)(e);case 256:return(0,n.keccak256)(e);case 384:return(0,n.keccak384)(e);case 512:return(0,n.keccak512)(e);default:throw new Error("Invald algorithm: keccak".concat(t))}};t.keccak256=function(e){return(0,t.keccak)(e)};t.keccakFromString=function(e,a){void 0===a&&(a=256),(0,s.assertIsString)(e);var n=r.from(e,"utf8");return(0,t.keccak)(n,a)};t.keccakFromHexString=function(e,a){return void 0===a&&(a=256),(0,s.assertIsHexString)(e),(0,t.keccak)((0,d.toBuffer)(e),a)};t.keccakFromArray=function(e,a){return void 0===a&&(a=256),(0,s.assertIsArray)(e),(0,t.keccak)((0,d.toBuffer)(e),a)};var _sha256=function(e){return e=(0,d.toBuffer)(e),c("sha256").update(e).digest()};t.sha256=function(e){return(0,s.assertIsBuffer)(e),_sha256(e)};t.sha256FromString=function(e){return(0,s.assertIsString)(e),_sha256(e)};t.sha256FromArray=function(e){return(0,s.assertIsArray)(e),_sha256(e)};var _ripemd160=function(e,t){e=(0,d.toBuffer)(e);var a=c("rmd160").update(e).digest();return!0===t?(0,d.setLengthLeft)(a,32):a};t.ripemd160=function(e,t){return(0,s.assertIsBuffer)(e),_ripemd160(e,t)};t.ripemd160FromString=function(e,t){return(0,s.assertIsString)(e),_ripemd160(e,t)};t.ripemd160FromArray=function(e,t){return(0,s.assertIsArray)(e),_ripemd160(e,t)};t.rlphash=function(e){return(0,t.keccak)(o.rlp.encode(e))}},(e,t,a)=>{"use strict";var r=a(0).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.rlphash=t.ripemd160FromArray=t.ripemd160FromString=t.ripemd160=t.sha256FromArray=t.sha256FromString=t.sha256=t.keccakFromArray=t.keccakFromHexString=t.keccakFromString=t.keccak256=t.keccak=void 0;var n=a(429),c=a(160),o=a(56),d=a(77),s=a(244);t.keccak=function(e,t){switch(void 0===t&&(t=256),(0,s.assertIsBuffer)(e),t){case 224:return(0,n.keccak224)(e);case 256:return(0,n.keccak256)(e);case 384:return(0,n.keccak384)(e);case 512:return(0,n.keccak512)(e);default:throw new Error("Invald algorithm: keccak".concat(t))}};t.keccak256=function(e){return(0,t.keccak)(e)};t.keccakFromString=function(e,a){void 0===a&&(a=256),(0,s.assertIsString)(e);var n=r.from(e,"utf8");return(0,t.keccak)(n,a)};t.keccakFromHexString=function(e,a){return void 0===a&&(a=256),(0,s.assertIsHexString)(e),(0,t.keccak)((0,d.toBuffer)(e),a)};t.keccakFromArray=function(e,a){return void 0===a&&(a=256),(0,s.assertIsArray)(e),(0,t.keccak)((0,d.toBuffer)(e),a)};var _sha256=function(e){return e=(0,d.toBuffer)(e),c("sha256").update(e).digest()};t.sha256=function(e){return(0,s.assertIsBuffer)(e),_sha256(e)};t.sha256FromString=function(e){return(0,s.assertIsString)(e),_sha256(e)};t.sha256FromArray=function(e){return(0,s.assertIsArray)(e),_sha256(e)};var _ripemd160=function(e,t){e=(0,d.toBuffer)(e);var a=c("rmd160").update(e).digest();return!0===t?(0,d.setLengthLeft)(a,32):a};t.ripemd160=function(e,t){return(0,s.assertIsBuffer)(e),_ripemd160(e,t)};t.ripemd160FromString=function(e,t){return(0,s.assertIsString)(e),_ripemd160(e,t)};t.ripemd160FromArray=function(e,t){return(0,s.assertIsArray)(e),_ripemd160(e,t)};t.rlphash=function(e){return(0,t.keccak)(o.rlp.encode(e))}},function(e,t,a){"use strict";var r=a(0).Buffer,n=this&&this.__read||function(e,t){var a="function"==typeof Symbol&&e[Symbol.iterator];if(!a)return e;var r,n,c=a.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(r=c.next()).done;)o.push(r.value)}catch(e){n={error:e}}finally{try{r&&!r.done&&(a=c.return)&&a.call(c)}finally{if(n)throw n.error}}return o},c=this&&this.__spreadArray||function(e,t,a){if(a||2===arguments.length)for(var r,n=0,c=t.length;n0?this._value:null},set:function(e){this._value=e},enumerable:!1,configurable:!0}),BranchNode.prototype.setBranch=function(e,t){this._branches[e]=t},BranchNode.prototype.raw=function(){return c(c([],n(this._branches),!1),[this._value],!1)},BranchNode.prototype.serialize=function(){return o.rlp.encode(this.raw())},BranchNode.prototype.hash=function(){return(0,o.keccak256)(this.serialize())},BranchNode.prototype.getBranch=function(e){var t=this._branches[e];return null!==t&&t.length>0?t:null},BranchNode.prototype.getChildren=function(){for(var e=[],t=0;t<16;t++){var a=this._branches[t];null!==a&&a.length>0&&e.push([t,a])}return e},BranchNode}();t.BranchNode=b;var u=function(){function ExtensionNode(e,t){this._nibbles=e,this._value=t}return ExtensionNode.encodeKey=function(e){return(0,s.addHexPrefix)(e,!1)},ExtensionNode.decodeKey=function(e){return(0,s.removeHexPrefix)(e)},Object.defineProperty(ExtensionNode.prototype,"key",{get:function(){return this._nibbles.slice(0)},set:function(e){this._nibbles=e},enumerable:!1,configurable:!0}),Object.defineProperty(ExtensionNode.prototype,"keyLength",{get:function(){return this._nibbles.length},enumerable:!1,configurable:!0}),Object.defineProperty(ExtensionNode.prototype,"value",{get:function(){return this._value},set:function(e){this._value=e},enumerable:!1,configurable:!0}),ExtensionNode.prototype.encodedKey=function(){return ExtensionNode.encodeKey(this._nibbles.slice(0))},ExtensionNode.prototype.raw=function(){return[(0,d.nibblesToBuffer)(this.encodedKey()),this._value]},ExtensionNode.prototype.serialize=function(){return o.rlp.encode(this.raw())},ExtensionNode.prototype.hash=function(){return(0,o.keccak256)(this.serialize())},ExtensionNode}();t.ExtensionNode=u;var h=function(){function LeafNode(e,t){this._nibbles=e,this._value=t}return LeafNode.encodeKey=function(e){return(0,s.addHexPrefix)(e,!0)},LeafNode.decodeKey=function(e){return(0,s.removeHexPrefix)(e)},Object.defineProperty(LeafNode.prototype,"key",{get:function(){return this._nibbles.slice(0)},set:function(e){this._nibbles=e},enumerable:!1,configurable:!0}),Object.defineProperty(LeafNode.prototype,"keyLength",{get:function(){return this._nibbles.length},enumerable:!1,configurable:!0}),Object.defineProperty(LeafNode.prototype,"value",{get:function(){return this._value},set:function(e){this._value=e},enumerable:!1,configurable:!0}),LeafNode.prototype.encodedKey=function(){return LeafNode.encodeKey(this._nibbles.slice(0))},LeafNode.prototype.raw=function(){return[(0,d.nibblesToBuffer)(this.encodedKey()),this._value]},LeafNode.prototype.serialize=function(){return o.rlp.encode(this.raw())},LeafNode.prototype.hash=function(){return(0,o.keccak256)(this.serialize())},LeafNode}();function decodeRawNode(e){if(17===e.length)return b.fromArray(e);if(2===e.length){var t=(0,d.bufferToNibbles)(e[0]);return(0,s.isTerminator)(t)?new h(h.decodeKey(t),e[1]):new u(u.decodeKey(t),e[1])}throw new Error("Invalid node")}t.LeafNode=h,t.decodeRawNode=decodeRawNode,t.decodeNode=function decodeNode(e){var t=o.rlp.decode(e);if(!Array.isArray(t))throw new Error("Invalid node");return decodeRawNode(t)},t.isRawNode=function isRawNode(e){return Array.isArray(e)&&!r.isBuffer(e)}},(e,t)=>{"use strict";function reverse(e){const t={};return Object.keys(e).forEach((function(a){(0|a)==a&&(a|=0);const r=e[a];t[r]=a})),t}t.tagClass={0:"universal",1:"application",2:"context",3:"private"},t.tagClassByName=reverse(t.tagClass),t.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},t.tagByName=reverse(t.tag)},(e,t,a)=>{"use strict";var r=a(224),n=a(223),c=n("%Function.prototype.apply%"),o=n("%Function.prototype.call%"),d=n("%Reflect.apply%",!0)||r.call(o,c),s=n("%Object.getOwnPropertyDescriptor%",!0),b=n("%Object.defineProperty%",!0),u=n("%Math.max%");if(b)try{b({},"a",{value:1})}catch(e){b=null}e.exports=function callBind(e){var t=d(r,o,arguments);if(s&&b){var a=s(t,"length");a.configurable&&b(t,"length",{value:1+u(0,e.length-(arguments.length-1))})}return t};var h=function applyBind(){return d(r,c,arguments)};b?b(e.exports,"apply",{value:h}):e.exports.apply=h},(e,t,a)=>{"use strict";var r=a(8).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.rlphash=t.ripemd160=t.sha256=t.keccak256=t.keccak=void 0;var n=a(842),c=n.keccak224,o=n.keccak384,d=n.keccak256,s=n.keccak512,b=a(378),u=a(114),h=a(221),l=a(107);t.keccak=function(e,t){switch(void 0===t&&(t=256),e="string"!=typeof e||u.isHexString(e)?l.toBuffer(e):r.from(e,"utf8"),t||(t=256),t){case 224:return c(e);case 256:return d(e);case 384:return o(e);case 512:return s(e);default:throw new Error("Invald algorithm: keccak"+t)}},t.keccak256=function(e){return t.keccak(e)},t.sha256=function(e){return e=l.toBuffer(e),b("sha256").update(e).digest()},t.ripemd160=function(e,t){e=l.toBuffer(e);var a=b("rmd160").update(e).digest();return!0===t?l.setLength(a,32):a},t.rlphash=function(e){return t.keccak(h.encode(e))}},(e,t,a)=>{"use strict";const r=a(1054),n=a(256),c=a(1070);e.exports=function(t,a,o){return"object"!=typeof a||o?(o||(o={}),n(c(r(t,a,o),o),o)):e.exports(t,null,a)}},function(e,t,a){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.TransientStorage=t.DefaultStateManager=t.BaseStateManager=void 0;var n=a(546);Object.defineProperty(t,"BaseStateManager",{enumerable:!0,get:function(){return n.BaseStateManager}});var c=a(561);Object.defineProperty(t,"DefaultStateManager",{enumerable:!0,get:function(){return r(c).default}});var o=a(619);Object.defineProperty(t,"TransientStorage",{enumerable:!0,get:function(){return r(o).default}})},function(e,t,a){"use strict";var r=a(0).Buffer,n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var c=n(a(3)),o=a(1),d=256,s=function(){function Bloom(e){e?((0,c.default)(e.length===d,"bitvectors must be 2048 bits long"),this.bitvector=e):this.bitvector=(0,o.zeros)(d)}return Bloom.prototype.add=function(e){(0,c.default)(r.isBuffer(e),"Element should be buffer"),e=(0,o.keccak256)(e);for(var t=0;t<3;t++){var a=2047&e.readUInt16BE(2*t),n=a>>3,s=1<>3,b=1<e.length+t.length}),n){const e={"user-agent":c};s&&(e.origin=s),n.password=n.username="";const t=n.host.endsWith(".infura.io");BaseHandler.setAuthHeaders(a,e),BaseHandler.setUserHeaders(a,e,!t),this.headers=e}}setCache(e){this.persistentCache=e}static setAuthHeaders(e,t){if(null!=e.username||null!=e.password){if(null!=e.jwt)throw new Error("Authentication via both username/password (Basic) and JWT (Bearer) is not possible");t.authorization=`Basic ${r.from(`${e.username||""}:${e.password||""}`).toString("base64")}`}else e.jwt&&(t.authorization=`Bearer ${e.jwt}`)}static setUserHeaders(e,t,a){const r=e.headers;if(r)for(let e=0,n=r.length;e{if(e.notFound)return null;throw e}));return null!=r?{result:JSON.parse(r).result,raw:r}:void 0}async queueRequest(e,t,a,n,o={disableCache:!1}){if(!o.disableCache){const n=this.getFromMemCache(a);if(void 0!==n)return n;const c=await this.getFromSlowCache(e,t,a);if(void 0!==c)return this.valueCache.set(a,r.from(c.raw)),c.result}const d=this.limiter.handle(n).then((async({response:n,raw:d})=>{if(this.abortSignal.aborted)return Promise.reject(new s.AbortError);if((0,c.hasOwn)(n,"result")){if(!o.disableCache&&(this.valueCache.set(a,d),this.persistentCache)){const n=this.persistentCache.put(e,t,a,"string"==typeof d?r.from(d):d).catch((e=>{}));this.fireForget.add(n),n.finally((()=>{this.fireForget.delete(n)}))}return n.result}if((0,c.hasOwn)(n,"error")&&null!=n.error){const{error:e}=n;throw new s.CodedError(e.message,e.code)}throw new Error(`Invalid response from fork provider: \`${JSON.stringify(n)}\``)}));return this.requestCache.set(a,d),await d}async close(){await Promise.all(this.fireForget.keys()),this.persistentCache&&await this.persistentCache.close()}}t.BaseHandler=BaseHandler,BaseHandler.JSONRPC_PREFIX='{"jsonrpc":"2.0","id":'},(e,t,a)=>{"use strict";var r,n=a(5);e.exports=Readable,Readable.ReadableState=ReadableState;a(24).EventEmitter;var c=function EElistenerCount(e,t){return e.listeners(t).length},o=a(750),d=a(2).Buffer,s=a.g.Uint8Array||function(){};var b,u=a(1255);b=u&&u.debuglog?u.debuglog("stream"):function debug(){};var h,l,g,p=a(751),B=a(327),x=a(328).getHighWaterMark,I=a(111).a,m=I.ERR_INVALID_ARG_TYPE,y=I.ERR_STREAM_PUSH_AFTER_EOF,C=I.ERR_METHOD_NOT_IMPLEMENTED,w=I.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;a(6)(Readable,o);var v=B.errorOrDestroy,Q=["error","close","destroy","pause","resume"];function ReadableState(e,t,n){r=r||a(109),e=e||{},"boolean"!=typeof n&&(n=t instanceof r),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=x(this,e,"readableHighWaterMark",n),this.buffer=new p,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(h||(h=a(642).a),this.decoder=new h(e.encoding),this.encoding=e.encoding)}function Readable(e){if(r=r||a(109),!(this instanceof Readable))return new Readable(e);var t=this instanceof r;this._readableState=new ReadableState(e,this,t),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),o.call(this)}function readableAddChunk(e,t,a,r,n){b("readableAddChunk",t);var c,o=e._readableState;if(null===t)o.reading=!1,function onEofChunk(e,t){if(b("onEofChunk"),t.ended)return;if(t.decoder){var a=t.decoder.end();a&&a.length&&(t.buffer.push(a),t.length+=t.objectMode?1:a.length)}t.ended=!0,t.sync?emitReadable(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,emitReadable_(e)))}(e,o);else if(n||(c=function chunkInvalid(e,t){var a;(function _isUint8Array(e){return d.isBuffer(e)||e instanceof s})(t)||"string"==typeof t||void 0===t||e.objectMode||(a=new m("chunk",["string","Buffer","Uint8Array"],t));return a}(o,t)),c)v(e,c);else if(o.objectMode||t&&t.length>0)if("string"==typeof t||o.objectMode||Object.getPrototypeOf(t)===d.prototype||(t=function _uint8ArrayToBuffer(e){return d.from(e)}(t)),r)o.endEmitted?v(e,new w):addChunk(e,o,t,!0);else if(o.ended)v(e,new y);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!a?(t=o.decoder.write(t),o.objectMode||0!==t.length?addChunk(e,o,t,!1):maybeReadMore(e,o)):addChunk(e,o,t,!1)}else r||(o.reading=!1,maybeReadMore(e,o));return!o.ended&&(o.lengtht.highWaterMark&&(t.highWaterMark=function computeNewHighWaterMark(e){return e>=k?e=k:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function emitReadable(e){var t=e._readableState;b("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(b("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(emitReadable_,e))}function emitReadable_(e){var t=e._readableState;b("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,flow(e)}function maybeReadMore(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(maybeReadMore_,e,t))}function maybeReadMore_(e,t){for(;!t.reading&&!t.ended&&(t.length0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function nReadingNextTick(e){b("readable nexttick read 0"),e.read(0)}function resume_(e,t){b("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),flow(e),t.flowing&&!t.reading&&e.read(0)}function flow(e){var t=e._readableState;for(b("flow",t.flowing);t.flowing&&null!==e.read(););}function fromList(e,t){return 0===t.length?null:(t.objectMode?a=t.buffer.shift():!e||e>=t.length?(a=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):a=t.buffer.consume(e,t.decoder),a);var a}function endReadable(e){var t=e._readableState;b("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(endReadableNT,t,e))}function endReadableNT(e,t){if(b("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var a=t._writableState;(!a||a.autoDestroy&&a.finished)&&t.destroy()}}function indexOf(e,t){for(var a=0,r=e.length;a=t.highWaterMark:t.length>0)||t.ended))return b("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?endReadable(this):emitReadable(this),null;if(0===(e=howMuchToRead(e,t))&&t.ended)return 0===t.length&&endReadable(this),null;var r,n=t.needReadable;return b("need readable",n),(0===t.length||t.length-e0?fromList(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),a!==e&&t.ended&&endReadable(this)),null!==r&&this.emit("data",r),r},Readable.prototype._read=function(e){v(this,new C("_read()"))},Readable.prototype.pipe=function(e,t){var a=this,r=this._readableState;switch(r.pipesCount){case 0:r.pipes=e;break;case 1:r.pipes=[r.pipes,e];break;default:r.pipes.push(e)}r.pipesCount+=1,b("pipe count=%d opts=%j",r.pipesCount,t);var o=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?onend:unpipe;function onunpipe(t,n){b("onunpipe"),t===a&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,function cleanup(){b("cleanup"),e.removeListener("close",onclose),e.removeListener("finish",onfinish),e.removeListener("drain",d),e.removeListener("error",onerror),e.removeListener("unpipe",onunpipe),a.removeListener("end",onend),a.removeListener("end",unpipe),a.removeListener("data",ondata),s=!0,!r.awaitDrain||e._writableState&&!e._writableState.needDrain||d()}())}function onend(){b("onend"),e.end()}r.endEmitted?n.nextTick(o):a.once("end",o),e.on("unpipe",onunpipe);var d=function pipeOnDrain(e){return function pipeOnDrainFunctionResult(){var t=e._readableState;b("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&c(e,"data")&&(t.flowing=!0,flow(e))}}(a);e.on("drain",d);var s=!1;function ondata(t){b("ondata");var n=e.write(t);b("dest.write",n),!1===n&&((1===r.pipesCount&&r.pipes===e||r.pipesCount>1&&-1!==indexOf(r.pipes,e))&&!s&&(b("false write response, pause",r.awaitDrain),r.awaitDrain++),a.pause())}function onerror(t){b("onerror",t),unpipe(),e.removeListener("error",onerror),0===c(e,"error")&&v(e,t)}function onclose(){e.removeListener("finish",onfinish),unpipe()}function onfinish(){b("onfinish"),e.removeListener("close",onclose),unpipe()}function unpipe(){b("unpipe"),a.unpipe(e)}return a.on("data",ondata),function prependListener(e,t,a){if("function"==typeof e.prependListener)return e.prependListener(t,a);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(a):e._events[t]=[a,e._events[t]]:e.on(t,a)}(e,"error",onerror),e.once("close",onclose),e.once("finish",onfinish),e.emit("pipe",a),r.flowing||(b("pipe resume"),a.resume()),e},Readable.prototype.unpipe=function(e){var t=this._readableState,a={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,a)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var c=0;c0,!1!==r.flowing&&this.resume()):"readable"===e&&(r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.flowing=!1,r.emittedReadable=!1,b("on readable",r.length,r.reading),r.length?emitReadable(this):r.reading||n.nextTick(nReadingNextTick,this))),a},Readable.prototype.addListener=Readable.prototype.on,Readable.prototype.removeListener=function(e,t){var a=o.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(updateReadableListening,this),a},Readable.prototype.removeAllListeners=function(e){var t=o.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||n.nextTick(updateReadableListening,this),t},Readable.prototype.resume=function(){var e=this._readableState;return e.flowing||(b("resume"),e.flowing=!e.readableListening,function resume(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(resume_,e,t))}(this,e)),e.paused=!1,this},Readable.prototype.pause=function(){return b("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(b("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},Readable.prototype.wrap=function(e){var t=this,a=this._readableState,r=!1;for(var n in e.on("end",(function(){if(b("wrapped end"),a.decoder&&!a.ended){var e=a.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(n){(b("wrapped data"),a.decoder&&(n=a.decoder.write(n)),a.objectMode&&null==n)||(a.objectMode||n&&n.length)&&(t.push(n)||(r=!0,e.pause()))})),e)void 0===this[n]&&"function"==typeof e[n]&&(this[n]=function methodWrap(t){return function methodWrapReturnFunction(){return e[t].apply(e,arguments)}}(n));for(var c=0;c{"use strict";var r,n=a(5);function CorkedRequest(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function onCorkedFinish(e,t,a){var r=e.entry;e.entry=null;for(;r;){var n=r.callback;t.pendingcb--,n(a),r=r.next}t.corkedRequestsFree.next=e}(t,e)}}e.exports=Writable,Writable.WritableState=WritableState;var c={deprecate:a(752)},o=a(750),d=a(2).Buffer,s=a.g.Uint8Array||function(){};var b,u=a(327),h=a(328).getHighWaterMark,l=a(111).a,g=l.ERR_INVALID_ARG_TYPE,p=l.ERR_METHOD_NOT_IMPLEMENTED,B=l.ERR_MULTIPLE_CALLBACK,x=l.ERR_STREAM_CANNOT_PIPE,I=l.ERR_STREAM_DESTROYED,m=l.ERR_STREAM_NULL_VALUES,y=l.ERR_STREAM_WRITE_AFTER_END,C=l.ERR_UNKNOWN_ENCODING,w=u.errorOrDestroy;function nop(){}function WritableState(e,t,c){r=r||a(109),e=e||{},"boolean"!=typeof c&&(c=t instanceof r),this.objectMode=!!e.objectMode,c&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=h(this,e,"writableHighWaterMark",c),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var o=!1===e.decodeStrings;this.decodeStrings=!o,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function onwrite(e,t){var a=e._writableState,r=a.sync,c=a.writecb;if("function"!=typeof c)throw new B;if(function onwriteStateUpdate(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(a),t)!function onwriteError(e,t,a,r,c){--t.pendingcb,a?(n.nextTick(c,r),n.nextTick(finishMaybe,e,t),e._writableState.errorEmitted=!0,w(e,r)):(c(r),e._writableState.errorEmitted=!0,w(e,r),finishMaybe(e,t))}(e,a,r,t,c);else{var o=needFinish(a)||e.destroyed;o||a.corked||a.bufferProcessing||!a.bufferedRequest||clearBuffer(e,a),r?n.nextTick(afterWrite,e,a,o,c):afterWrite(e,a,o,c)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new CorkedRequest(this)}function Writable(e){var t=this instanceof(r=r||a(109));if(!t&&!b.call(Writable,this))return new Writable(e);this._writableState=new WritableState(e,this,t),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),o.call(this)}function doWrite(e,t,a,r,n,c,o){t.writelen=r,t.writecb=o,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new I("write")):a?e._writev(n,t.onwrite):e._write(n,c,t.onwrite),t.sync=!1}function afterWrite(e,t,a,r){a||function onwriteDrain(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,r(),finishMaybe(e,t)}function clearBuffer(e,t){t.bufferProcessing=!0;var a=t.bufferedRequest;if(e._writev&&a&&a.next){var r=t.bufferedRequestCount,n=new Array(r),c=t.corkedRequestsFree;c.entry=a;for(var o=0,d=!0;a;)n[o]=a,a.isBuf||(d=!1),a=a.next,o+=1;n.allBuffers=d,doWrite(e,t,!0,t.length,n,"",c.finish),t.pendingcb++,t.lastBufferedRequest=null,c.next?(t.corkedRequestsFree=c.next,c.next=null):t.corkedRequestsFree=new CorkedRequest(t),t.bufferedRequestCount=0}else{for(;a;){var s=a.chunk,b=a.encoding,u=a.callback;if(doWrite(e,t,!1,t.objectMode?1:s.length,s,b,u),a=a.next,t.bufferedRequestCount--,t.writing)break}null===a&&(t.lastBufferedRequest=null)}t.bufferedRequest=a,t.bufferProcessing=!1}function needFinish(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function callFinal(e,t){e._final((function(a){t.pendingcb--,a&&w(e,a),t.prefinished=!0,e.emit("prefinish"),finishMaybe(e,t)}))}function finishMaybe(e,t){var a=needFinish(t);if(a&&(function prefinish(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,n.nextTick(callFinal,e,t)))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var r=e._readableState;(!r||r.autoDestroy&&r.endEmitted)&&e.destroy()}return a}a(6)(Writable,o),WritableState.prototype.getBuffer=function getBuffer(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(WritableState.prototype,"buffer",{get:c.deprecate((function writableStateBufferGetter(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(b=Function.prototype[Symbol.hasInstance],Object.defineProperty(Writable,Symbol.hasInstance,{value:function value(e){return!!b.call(this,e)||this===Writable&&(e&&e._writableState instanceof WritableState)}})):b=function realHasInstance(e){return e instanceof this},Writable.prototype.pipe=function(){w(this,new x)},Writable.prototype.write=function(e,t,a){var r=this._writableState,c=!1,o=!r.objectMode&&function _isUint8Array(e){return d.isBuffer(e)||e instanceof s}(e);return o&&!d.isBuffer(e)&&(e=function _uint8ArrayToBuffer(e){return d.from(e)}(e)),"function"==typeof t&&(a=t,t=null),o?t="buffer":t||(t=r.defaultEncoding),"function"!=typeof a&&(a=nop),r.ending?function writeAfterEnd(e,t){var a=new y;w(e,a),n.nextTick(t,a)}(this,a):(o||function validChunk(e,t,a,r){var c;return null===a?c=new m:"string"==typeof a||t.objectMode||(c=new g("chunk",["string","Buffer"],a)),!c||(w(e,c),n.nextTick(r,c),!1)}(this,r,e,a))&&(r.pendingcb++,c=function writeOrBuffer(e,t,a,r,n,c){if(!a){var o=function decodeChunk(e,t,a){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=d.from(t,a));return t}(t,r,n);r!==o&&(a=!0,n="buffer",r=o)}var s=t.objectMode?1:r.length;t.length+=s;var b=t.length-1))throw new C(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(Writable.prototype,"writableBuffer",{enumerable:!1,get:function get(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(Writable.prototype,"writableHighWaterMark",{enumerable:!1,get:function get(){return this._writableState.highWaterMark}}),Writable.prototype._write=function(e,t,a){a(new p("_write()"))},Writable.prototype._writev=null,Writable.prototype.end=function(e,t,a){var r=this._writableState;return"function"==typeof e?(a=e,e=null,t=null):"function"==typeof t&&(a=t,t=null),null!=e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||function endWritable(e,t,a){t.ending=!0,finishMaybe(e,t),a&&(t.finished?n.nextTick(a):e.once("finish",a));t.ended=!0,e.writable=!1}(this,r,a),this},Object.defineProperty(Writable.prototype,"writableLength",{enumerable:!1,get:function get(){return this._writableState.length}}),Object.defineProperty(Writable.prototype,"destroyed",{enumerable:!1,get:function get(){return void 0!==this._writableState&&this._writableState.destroyed},set:function set(e){this._writableState&&(this._writableState.destroyed=e)}}),Writable.prototype.destroy=u.destroy,Writable.prototype._undestroy=u.undestroy,Writable.prototype._destroy=function(e,t){t(e)}},(e,t,a)=>{"use strict";e.exports=Transform;var r=a(111).a,n=r.ERR_METHOD_NOT_IMPLEMENTED,c=r.ERR_MULTIPLE_CALLBACK,o=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,d=r.ERR_TRANSFORM_WITH_LENGTH_0,s=a(109);function afterTransform(e,t){var a=this._transformState;a.transforming=!1;var r=a.writecb;if(null===r)return this.emit("error",new c);a.writechunk=null,a.writecb=null,null!=t&&this.push(t),r(e);var n=this._readableState;n.reading=!1,(n.needReadable||n.length{var r=a(1259),n=a(1266),c=a(758);t.createCipher=t.Cipher=r.createCipher,t.createCipheriv=t.Cipheriv=r.createCipheriv,t.createDecipher=t.Decipher=n.createDecipher,t.createDecipheriv=t.Decipheriv=n.createDecipheriv,t.listCiphers=t.getCiphers=function getCiphers(){return Object.keys(c)}},(e,t,a)=>{var r={ECB:a(1260),CBC:a(1261),CFB:a(1262),CFB8:a(1263),CFB1:a(1264),OFB:a(1265),CTR:a(1231),GCM:a(1231)},n=a(758);for(var c in n)n[c].module=r[n[c].mode];e.exports=n},(e,t,a)=>{var r=a(7).Buffer;function asUInt32Array(e){r.isBuffer(e)||(e=r.from(e));for(var t=e.length/4|0,a=new Array(t),n=0;n>>24]^u[p>>>16&255]^h[B>>>8&255]^l[255&x]^t[I++],o=b[p>>>24]^u[B>>>16&255]^h[x>>>8&255]^l[255&g]^t[I++],d=b[B>>>24]^u[x>>>16&255]^h[g>>>8&255]^l[255&p]^t[I++],s=b[x>>>24]^u[g>>>16&255]^h[p>>>8&255]^l[255&B]^t[I++],g=c,p=o,B=d,x=s;return c=(r[g>>>24]<<24|r[p>>>16&255]<<16|r[B>>>8&255]<<8|r[255&x])^t[I++],o=(r[p>>>24]<<24|r[B>>>16&255]<<16|r[x>>>8&255]<<8|r[255&g])^t[I++],d=(r[B>>>24]<<24|r[x>>>16&255]<<16|r[g>>>8&255]<<8|r[255&p])^t[I++],s=(r[x>>>24]<<24|r[g>>>16&255]<<16|r[p>>>8&255]<<8|r[255&B])^t[I++],[c>>>=0,o>>>=0,d>>>=0,s>>>=0]}var n=[0,1,2,4,8,16,32,64,128,27,54],c=function(){for(var e=new Array(256),t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var a=[],r=[],n=[[],[],[],[]],c=[[],[],[],[]],o=0,d=0,s=0;s<256;++s){var b=d^d<<1^d<<2^d<<3^d<<4;b=b>>>8^255&b^99,a[o]=b,r[b]=o;var u=e[o],h=e[u],l=e[h],g=257*e[b]^16843008*b;n[0][o]=g<<24|g>>>8,n[1][o]=g<<16|g>>>16,n[2][o]=g<<8|g>>>24,n[3][o]=g,g=16843009*l^65537*h^257*u^16843008*o,c[0][b]=g<<24|g>>>8,c[1][b]=g<<16|g>>>16,c[2][b]=g<<8|g>>>24,c[3][b]=g,0===o?o=d=1:(o=u^e[e[e[l^u]]],d^=e[e[d]])}return{SBOX:a,INV_SBOX:r,SUB_MIX:n,INV_SUB_MIX:c}}();function AES(e){this._key=asUInt32Array(e),this._reset()}AES.blockSize=16,AES.keySize=32,AES.prototype.blockSize=AES.blockSize,AES.prototype.keySize=AES.keySize,AES.prototype._reset=function(){for(var e=this._key,t=e.length,a=t+6,r=4*(a+1),o=[],d=0;d>>24,s=c.SBOX[s>>>24]<<24|c.SBOX[s>>>16&255]<<16|c.SBOX[s>>>8&255]<<8|c.SBOX[255&s],s^=n[d/t|0]<<24):t>6&&d%t==4&&(s=c.SBOX[s>>>24]<<24|c.SBOX[s>>>16&255]<<16|c.SBOX[s>>>8&255]<<8|c.SBOX[255&s]),o[d]=o[d-t]^s}for(var b=[],u=0;u>>24]]^c.INV_SUB_MIX[1][c.SBOX[l>>>16&255]]^c.INV_SUB_MIX[2][c.SBOX[l>>>8&255]]^c.INV_SUB_MIX[3][c.SBOX[255&l]]}this._nRounds=a,this._keySchedule=o,this._invKeySchedule=b},AES.prototype.encryptBlockRaw=function(e){return cryptBlock(e=asUInt32Array(e),this._keySchedule,c.SUB_MIX,c.SBOX,this._nRounds)},AES.prototype.encryptBlock=function(e){var t=this.encryptBlockRaw(e),a=r.allocUnsafe(16);return a.writeUInt32BE(t[0],0),a.writeUInt32BE(t[1],4),a.writeUInt32BE(t[2],8),a.writeUInt32BE(t[3],12),a},AES.prototype.decryptBlock=function(e){var t=(e=asUInt32Array(e))[1];e[1]=e[3],e[3]=t;var a=cryptBlock(e,this._invKeySchedule,c.INV_SUB_MIX,c.INV_SBOX,this._nRounds),n=r.allocUnsafe(16);return n.writeUInt32BE(a[0],0),n.writeUInt32BE(a[3],4),n.writeUInt32BE(a[2],8),n.writeUInt32BE(a[1],12),n},AES.prototype.scrub=function(){scrubVec(this._keySchedule),scrubVec(this._invKeySchedule),scrubVec(this._key)},e.exports.AES=AES},(e,t,a)=>{"use strict";var r=a(6),n=a(334),c=a(7).Buffer,o=new Array(16);function MD5(){n.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function rotl(e,t){return e<>>32-t}function fnF(e,t,a,r,n,c,o){return rotl(e+(t&a|~t&r)+n+c|0,o)+t|0}function fnG(e,t,a,r,n,c,o){return rotl(e+(t&r|a&~r)+n+c|0,o)+t|0}function fnH(e,t,a,r,n,c,o){return rotl(e+(t^a^r)+n+c|0,o)+t|0}function fnI(e,t,a,r,n,c,o){return rotl(e+(a^(t|~r))+n+c|0,o)+t|0}r(MD5,n),MD5.prototype._update=function(){for(var e=o,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var a=this._a,r=this._b,n=this._c,c=this._d;a=fnF(a,r,n,c,e[0],3614090360,7),c=fnF(c,a,r,n,e[1],3905402710,12),n=fnF(n,c,a,r,e[2],606105819,17),r=fnF(r,n,c,a,e[3],3250441966,22),a=fnF(a,r,n,c,e[4],4118548399,7),c=fnF(c,a,r,n,e[5],1200080426,12),n=fnF(n,c,a,r,e[6],2821735955,17),r=fnF(r,n,c,a,e[7],4249261313,22),a=fnF(a,r,n,c,e[8],1770035416,7),c=fnF(c,a,r,n,e[9],2336552879,12),n=fnF(n,c,a,r,e[10],4294925233,17),r=fnF(r,n,c,a,e[11],2304563134,22),a=fnF(a,r,n,c,e[12],1804603682,7),c=fnF(c,a,r,n,e[13],4254626195,12),n=fnF(n,c,a,r,e[14],2792965006,17),a=fnG(a,r=fnF(r,n,c,a,e[15],1236535329,22),n,c,e[1],4129170786,5),c=fnG(c,a,r,n,e[6],3225465664,9),n=fnG(n,c,a,r,e[11],643717713,14),r=fnG(r,n,c,a,e[0],3921069994,20),a=fnG(a,r,n,c,e[5],3593408605,5),c=fnG(c,a,r,n,e[10],38016083,9),n=fnG(n,c,a,r,e[15],3634488961,14),r=fnG(r,n,c,a,e[4],3889429448,20),a=fnG(a,r,n,c,e[9],568446438,5),c=fnG(c,a,r,n,e[14],3275163606,9),n=fnG(n,c,a,r,e[3],4107603335,14),r=fnG(r,n,c,a,e[8],1163531501,20),a=fnG(a,r,n,c,e[13],2850285829,5),c=fnG(c,a,r,n,e[2],4243563512,9),n=fnG(n,c,a,r,e[7],1735328473,14),a=fnH(a,r=fnG(r,n,c,a,e[12],2368359562,20),n,c,e[5],4294588738,4),c=fnH(c,a,r,n,e[8],2272392833,11),n=fnH(n,c,a,r,e[11],1839030562,16),r=fnH(r,n,c,a,e[14],4259657740,23),a=fnH(a,r,n,c,e[1],2763975236,4),c=fnH(c,a,r,n,e[4],1272893353,11),n=fnH(n,c,a,r,e[7],4139469664,16),r=fnH(r,n,c,a,e[10],3200236656,23),a=fnH(a,r,n,c,e[13],681279174,4),c=fnH(c,a,r,n,e[0],3936430074,11),n=fnH(n,c,a,r,e[3],3572445317,16),r=fnH(r,n,c,a,e[6],76029189,23),a=fnH(a,r,n,c,e[9],3654602809,4),c=fnH(c,a,r,n,e[12],3873151461,11),n=fnH(n,c,a,r,e[15],530742520,16),a=fnI(a,r=fnH(r,n,c,a,e[2],3299628645,23),n,c,e[0],4096336452,6),c=fnI(c,a,r,n,e[7],1126891415,10),n=fnI(n,c,a,r,e[14],2878612391,15),r=fnI(r,n,c,a,e[5],4237533241,21),a=fnI(a,r,n,c,e[12],1700485571,6),c=fnI(c,a,r,n,e[3],2399980690,10),n=fnI(n,c,a,r,e[10],4293915773,15),r=fnI(r,n,c,a,e[1],2240044497,21),a=fnI(a,r,n,c,e[8],1873313359,6),c=fnI(c,a,r,n,e[15],4264355552,10),n=fnI(n,c,a,r,e[6],2734768916,15),r=fnI(r,n,c,a,e[13],1309151649,21),a=fnI(a,r,n,c,e[4],4149444226,6),c=fnI(c,a,r,n,e[11],3174756917,10),n=fnI(n,c,a,r,e[2],718787259,15),r=fnI(r,n,c,a,e[9],3951481745,21),this._a=this._a+a|0,this._b=this._b+r|0,this._c=this._c+n|0,this._d=this._d+c|0},MD5.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=c.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e},e.exports=MD5},(e,t,a)=>{"use strict";var r=a(2).Buffer,n=a(6),c=a(334),o=new Array(16),d=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],s=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],b=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],u=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],h=[0,1518500249,1859775393,2400959708,2840853838],l=[1352829926,1548603684,1836072691,2053994217,0];function RIPEMD160(){c.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function rotl(e,t){return e<>>32-t}function fn1(e,t,a,r,n,c,o,d){return rotl(e+(t^a^r)+c+o|0,d)+n|0}function fn2(e,t,a,r,n,c,o,d){return rotl(e+(t&a|~t&r)+c+o|0,d)+n|0}function fn3(e,t,a,r,n,c,o,d){return rotl(e+((t|~a)^r)+c+o|0,d)+n|0}function fn4(e,t,a,r,n,c,o,d){return rotl(e+(t&r|a&~r)+c+o|0,d)+n|0}function fn5(e,t,a,r,n,c,o,d){return rotl(e+(t^(a|~r))+c+o|0,d)+n|0}n(RIPEMD160,c),RIPEMD160.prototype._update=function(){for(var e=o,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);for(var a=0|this._a,r=0|this._b,n=0|this._c,c=0|this._d,g=0|this._e,p=0|this._a,B=0|this._b,x=0|this._c,I=0|this._d,m=0|this._e,y=0;y<80;y+=1){var C,w;y<16?(C=fn1(a,r,n,c,g,e[d[y]],h[0],b[y]),w=fn5(p,B,x,I,m,e[s[y]],l[0],u[y])):y<32?(C=fn2(a,r,n,c,g,e[d[y]],h[1],b[y]),w=fn4(p,B,x,I,m,e[s[y]],l[1],u[y])):y<48?(C=fn3(a,r,n,c,g,e[d[y]],h[2],b[y]),w=fn3(p,B,x,I,m,e[s[y]],l[2],u[y])):y<64?(C=fn4(a,r,n,c,g,e[d[y]],h[3],b[y]),w=fn2(p,B,x,I,m,e[s[y]],l[3],u[y])):(C=fn5(a,r,n,c,g,e[d[y]],h[4],b[y]),w=fn1(p,B,x,I,m,e[s[y]],l[4],u[y])),a=g,g=c,c=rotl(n,10),n=r,r=C,p=m,m=I,I=rotl(x,10),x=B,B=w}var v=this._b+n+I|0;this._b=this._c+c+m|0,this._c=this._d+g+p|0,this._d=this._e+a+B|0,this._e=this._a+r+x|0,this._a=v},RIPEMD160.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=r.alloc?r.alloc(20):new r(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e},e.exports=RIPEMD160},(e,t,a)=>{var r=e.exports=function SHA(e){e=e.toLowerCase();var t=r[e];if(!t)throw new Error(e+" is not supported (we accept pull requests)");return new t};r.sha=a(760),r.sha1=a(761),r.sha224=a(762),r.sha256=a(335),r.sha384=a(763),r.sha512=a(336)},(e,t,a)=>{"use strict";var r=a(39);function Cipher(e){this.options=e,this.type=this.options.type,this.blockSize=8,this._init(),this.buffer=new Array(this.blockSize),this.bufferOff=0}e.exports=Cipher,Cipher.prototype._init=function _init(){},Cipher.prototype.update=function update(e){return 0===e.length?[]:"decrypt"===this.type?this._updateDecrypt(e):this._updateEncrypt(e)},Cipher.prototype._buffer=function _buffer(e,t){for(var a=Math.min(this.buffer.length-this.bufferOff,e.length-t),r=0;r0;r--)t+=this._buffer(e,t),a+=this._flushBuffer(n,a);return t+=this._buffer(e,t),n},Cipher.prototype.final=function final(e){var t,a;return e&&(t=this.update(e)),a="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),t?t.concat(a):a},Cipher.prototype._pad=function _pad(e,t){if(0===t)return!1;for(;t{var r;function Rand(e){this.rand=e}if(e.exports=function rand(e){return r||(r=new Rand(null)),r.generate(e)},e.exports.Rand=Rand,Rand.prototype.generate=function generate(e){return this._rand(e)},Rand.prototype._rand=function _rand(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),a=0;a{var r=a(2).Buffer,n=a(651),c=a(91);function getr(e){var t,a=e.modulus.byteLength();do{t=new n(c(a))}while(t.cmp(e.modulus)>=0||!t.umod(e.prime1)||!t.umod(e.prime2));return t}function crt(e,t){var a=function blind(e){var t=getr(e);return{blinder:t.toRed(n.mont(e.modulus)).redPow(new n(e.publicExponent)).fromRed(),unblinder:t.invm(e.modulus)}}(t),c=t.modulus.byteLength(),o=new n(e).mul(a.blinder).umod(t.modulus),d=o.toRed(n.mont(t.prime1)),s=o.toRed(n.mont(t.prime2)),b=t.coefficient,u=t.prime1,h=t.prime2,l=d.redPow(t.exponent1).fromRed(),g=s.redPow(t.exponent2).fromRed(),p=l.isub(g).imul(b).umod(u).imul(h);return g.iadd(p).imul(a.unblinder).umod(t.modulus).toArrayLike(r,"be",c)}crt.getr=getr,e.exports=crt},(e,t,a)=>{"use strict";var r=t;r.version=a(1277).a,r.utils=a(40),r.rand=a(211),r.curve=a(347),r.curves=a(214),r.ec=a(783),r.eddsa=a(787)},(e,t,a)=>{"use strict";var r,n=t,c=a(215),o=a(347),d=a(40).assert;function PresetCurve(e){"short"===e.type?this.curve=new o.short(e):"edwards"===e.type?this.curve=new o.edwards(e):this.curve=new o.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,d(this.g.validate(),"Invalid curve"),d(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function defineCurve(e,t){Object.defineProperty(n,e,{configurable:!0,enumerable:!0,get:function(){var a=new PresetCurve(t);return Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:a}),a}})}n.PresetCurve=PresetCurve,defineCurve("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:c.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),defineCurve("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:c.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),defineCurve("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:c.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),defineCurve("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:c.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),defineCurve("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:c.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),defineCurve("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:c.sha256,gRed:!1,g:["9"]}),defineCurve("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:c.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=a(782)}catch(e){r=void 0}defineCurve("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:c.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})},(e,t,a)=>{var r=t;r.utils=a(61),r.common=a(146),r.sha=a(1278),r.ripemd=a(1279),r.hmac=a(781),r.sha1=r.sha.sha1,r.sha256=r.sha.sha256,r.sha224=r.sha.sha224,r.sha384=r.sha.sha384,r.sha512=r.sha.sha512,r.ripemd160=r.ripemd.ripemd160},(e,t,a)=>{"use strict";var r,n=a(5),c=a(2),o=c.Buffer,d={};for(r in c)c.hasOwnProperty(r)&&"SlowBuffer"!==r&&"Buffer"!==r&&(d[r]=c[r]);var s=d.Buffer={};for(r in o)o.hasOwnProperty(r)&&"allocUnsafe"!==r&&"allocUnsafeSlow"!==r&&(s[r]=o[r]);if(d.Buffer.prototype=o.prototype,s.from&&s.from!==Uint8Array.from||(s.from=function(e,t,a){if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof e);if(e&&void 0===e.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);return o(e,t,a)}),s.alloc||(s.alloc=function(e,t,a){if("number"!=typeof e)throw new TypeError('The "size" argument must be of type number. Received type '+typeof e);if(e<0||e>=2*(1<<30))throw new RangeError('The value "'+e+'" is invalid for option "size"');var r=o(e);return t&&0!==t.length?"string"==typeof a?r.fill(t,a):r.fill(t):r.fill(0),r}),!d.kStringMaxLength)try{d.kStringMaxLength=n.binding("buffer").kStringMaxLength}catch(e){}d.constants||(d.constants={MAX_LENGTH:d.kMaxLength},d.kStringMaxLength&&(d.constants.MAX_STRING_LENGTH=d.kStringMaxLength)),e.exports=d},(e,t,a)=>{"use strict";const r=a(353).a,n=a(313).b,c=a(313).a,o=a(39),d=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],s=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(d);function Node(e,t,a){const r={};this._baseState=r,r.name=a,r.enc=e,r.parent=t||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r.default=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}e.exports=Node;const b=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];Node.prototype.clone=function clone(){const e=this._baseState,t={};b.forEach((function(a){t[a]=e[a]}));const a=new this.constructor(t.parent);return a._baseState=t,a},Node.prototype._wrap=function wrap(){const e=this._baseState;s.forEach((function(t){this[t]=function _wrappedMethod(){const a=new this.constructor(this);return e.children.push(a),a[t].apply(a,arguments)}}),this)},Node.prototype._init=function init(e){const t=this._baseState;o(null===t.parent),e.call(this),t.children=t.children.filter((function(e){return e._baseState.parent===this}),this),o.equal(t.children.length,1,"Root node can have only one child")},Node.prototype._useArgs=function useArgs(e){const t=this._baseState,a=e.filter((function(e){return e instanceof this.constructor}),this);e=e.filter((function(e){return!(e instanceof this.constructor)}),this),0!==a.length&&(o(null===t.children),t.children=a,a.forEach((function(e){e._baseState.parent=this}),this)),0!==e.length&&(o(null===t.args),t.args=e,t.reverseArgs=e.map((function(e){if("object"!=typeof e||e.constructor!==Object)return e;const t={};return Object.keys(e).forEach((function(a){a==(0|a)&&(a|=0);const r=e[a];t[r]=a})),t})))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach((function(e){Node.prototype[e]=function _overrided(){const t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}})),d.forEach((function(e){Node.prototype[e]=function _tagMethod(){const t=this._baseState,a=Array.prototype.slice.call(arguments);return o(null===t.tag),t.tag=e,this._useArgs(a),this}})),Node.prototype.use=function use(e){o(e);const t=this._baseState;return o(null===t.use),t.use=e,this},Node.prototype.optional=function optional(){return this._baseState.optional=!0,this},Node.prototype.def=function def(e){const t=this._baseState;return o(null===t.default),t.default=e,t.optional=!0,this},Node.prototype.explicit=function explicit(e){const t=this._baseState;return o(null===t.explicit&&null===t.implicit),t.explicit=e,this},Node.prototype.implicit=function implicit(e){const t=this._baseState;return o(null===t.explicit&&null===t.implicit),t.implicit=e,this},Node.prototype.obj=function obj(){const e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},Node.prototype.key=function key(e){const t=this._baseState;return o(null===t.key),t.key=e,this},Node.prototype.any=function any(){return this._baseState.any=!0,this},Node.prototype.choice=function choice(e){const t=this._baseState;return o(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map((function(t){return e[t]}))),this},Node.prototype.contains=function contains(e){const t=this._baseState;return o(null===t.use),t.contains=e,this},Node.prototype._decode=function decode(e,t){const a=this._baseState;if(null===a.parent)return e.wrapResult(a.children[0]._decode(e,t));let r,n=a.default,o=!0,d=null;if(null!==a.key&&(d=e.enterKey(a.key)),a.optional){let r=null;if(null!==a.explicit?r=a.explicit:null!==a.implicit?r=a.implicit:null!==a.tag&&(r=a.tag),null!==r||a.any){if(o=this._peekTag(e,r,a.any),e.isError(o))return o}else{const r=e.save();try{null===a.choice?this._decodeGeneric(a.tag,e,t):this._decodeChoice(e,t),o=!0}catch(e){o=!1}e.restore(r)}}if(a.obj&&o&&(r=e.enterObject()),o){if(null!==a.explicit){const t=this._decodeTag(e,a.explicit);if(e.isError(t))return t;e=t}const r=e.offset;if(null===a.use&&null===a.choice){let t;a.any&&(t=e.save());const r=this._decodeTag(e,null!==a.implicit?a.implicit:a.tag,a.any);if(e.isError(r))return r;a.any?n=e.raw(t):e=r}if(t&&t.track&&null!==a.tag&&t.track(e.path(),r,e.length,"tagged"),t&&t.track&&null!==a.tag&&t.track(e.path(),e.offset,e.length,"content"),a.any||(n=null===a.choice?this._decodeGeneric(a.tag,e,t):this._decodeChoice(e,t)),e.isError(n))return n;if(a.any||null!==a.choice||null===a.children||a.children.forEach((function decodeChildren(a){a._decode(e,t)})),a.contains&&("octstr"===a.tag||"bitstr"===a.tag)){const r=new c(n);n=this._getUse(a.contains,e._reporterState.obj)._decode(r,t)}}return a.obj&&o&&(n=e.leaveObject(r)),null===a.key||null===n&&!0!==o?null!==d&&e.exitKey(d):e.leaveKey(d,a.key,n),n},Node.prototype._decodeGeneric=function decodeGeneric(e,t,a){const r=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,r.args[0],a):/str$/.test(e)?this._decodeStr(t,e,a):"objid"===e&&r.args?this._decodeObjid(t,r.args[0],r.args[1],a):"objid"===e?this._decodeObjid(t,null,null,a):"gentime"===e||"utctime"===e?this._decodeTime(t,e,a):"null_"===e?this._decodeNull(t,a):"bool"===e?this._decodeBool(t,a):"objDesc"===e?this._decodeStr(t,e,a):"int"===e||"enum"===e?this._decodeInt(t,r.args&&r.args[0],a):null!==r.use?this._getUse(r.use,t._reporterState.obj)._decode(t,a):t.error("unknown tag: "+e)},Node.prototype._getUse=function _getUse(e,t){const a=this._baseState;return a.useDecoder=this._use(e,t),o(null===a.useDecoder._baseState.parent),a.useDecoder=a.useDecoder._baseState.children[0],a.implicit!==a.useDecoder._baseState.implicit&&(a.useDecoder=a.useDecoder.clone(),a.useDecoder._baseState.implicit=a.implicit),a.useDecoder},Node.prototype._decodeChoice=function decodeChoice(e,t){const a=this._baseState;let r=null,n=!1;return Object.keys(a.choice).some((function(c){const o=e.save(),d=a.choice[c];try{const a=d._decode(e,t);if(e.isError(a))return!1;r={type:c,value:a},n=!0}catch(t){return e.restore(o),!1}return!0}),this),n?r:e.error("Choice not matched")},Node.prototype._createEncoderBuffer=function createEncoderBuffer(e){return new n(e,this.reporter)},Node.prototype._encode=function encode(e,t,a){const r=this._baseState;if(null!==r.default&&r.default===e)return;const n=this._encodeValue(e,t,a);return void 0===n||this._skipDefault(n,t,a)?void 0:n},Node.prototype._encodeValue=function encode(e,t,a){const n=this._baseState;if(null===n.parent)return n.children[0]._encode(e,t||new r);let c=null;if(this.reporter=t,n.optional&&void 0===e){if(null===n.default)return;e=n.default}let o=null,d=!1;if(n.any)c=this._createEncoderBuffer(e);else if(n.choice)c=this._encodeChoice(e,t);else if(n.contains)o=this._getUse(n.contains,a)._encode(e,t),d=!0;else if(n.children)o=n.children.map((function(a){if("null_"===a._baseState.tag)return a._encode(null,t,e);if(null===a._baseState.key)return t.error("Child should have a key");const r=t.enterKey(a._baseState.key);if("object"!=typeof e)return t.error("Child expected, but input is not object");const n=a._encode(e[a._baseState.key],t,e);return t.leaveKey(r),n}),this).filter((function(e){return e})),o=this._createEncoderBuffer(o);else if("seqof"===n.tag||"setof"===n.tag){if(!n.args||1!==n.args.length)return t.error("Too many args for : "+n.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");const a=this.clone();a._baseState.implicit=null,o=this._createEncoderBuffer(e.map((function(a){const r=this._baseState;return this._getUse(r.args[0],e)._encode(a,t)}),a))}else null!==n.use?c=this._getUse(n.use,a)._encode(e,t):(o=this._encodePrimitive(n.tag,e),d=!0);if(!n.any&&null===n.choice){const e=null!==n.implicit?n.implicit:n.tag,a=null===n.implicit?"universal":"context";null===e?null===n.use&&t.error("Tag could be omitted only for .use()"):null===n.use&&(c=this._encodeComposite(e,d,a,o))}return null!==n.explicit&&(c=this._encodeComposite(n.explicit,!1,"context",c)),c},Node.prototype._encodeChoice=function encodeChoice(e,t){const a=this._baseState,r=a.choice[e.type];return r||o(!1,e.type+" not found in "+JSON.stringify(Object.keys(a.choice))),r._encode(e.value,t)},Node.prototype._encodePrimitive=function encodePrimitive(e,t){const a=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&a.args)return this._encodeObjid(t,a.reverseArgs[0],a.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,a.args&&a.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},Node.prototype._isNumstr=function isNumstr(e){return/^[0-9 ]*$/.test(e)},Node.prototype._isPrintstr=function isPrintstr(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(e)}},(e,t,a)=>{"use strict";var r=a(8).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.ecdhUnsafe=t.ecdh=t.recover=t.verify=t.sign=t.signatureImportLax=t.signatureImport=t.signatureExport=t.signatureNormalize=t.publicKeyCombine=t.publicKeyTweakMul=t.publicKeyTweakAdd=t.publicKeyVerify=t.publicKeyConvert=t.publicKeyCreate=t.privateKeyTweakMul=t.privateKeyTweakAdd=t.privateKeyModInverse=t.privateKeyNegate=t.privateKeyImport=t.privateKeyExport=t.privateKeyVerify=void 0;var n=a(186),c=a(1293),o=a(1295);t.privateKeyVerify=function(e){return 32===e.length&&n.privateKeyVerify(Uint8Array.from(e))},t.privateKeyExport=function(e,t){if(32!==e.length)throw new RangeError("private key length is invalid");var a=c.privateKeyExport(e,t);return o.privateKeyExport(e,a,t)},t.privateKeyImport=function(e){if(null!==(e=o.privateKeyImport(e))&&32===e.length&&t.privateKeyVerify(e))return e;throw new Error("couldn't import from DER format")},t.privateKeyNegate=function(e){return r.from(n.privateKeyNegate(Uint8Array.from(e)))},t.privateKeyModInverse=function(e){if(32!==e.length)throw new Error("private key length is invalid");return r.from(c.privateKeyModInverse(Uint8Array.from(e)))},t.privateKeyTweakAdd=function(e,t){return r.from(n.privateKeyTweakAdd(Uint8Array.from(e),t))},t.privateKeyTweakMul=function(e,t){return r.from(n.privateKeyTweakMul(Uint8Array.from(e),Uint8Array.from(t)))},t.publicKeyCreate=function(e,t){return r.from(n.publicKeyCreate(Uint8Array.from(e),t))},t.publicKeyConvert=function(e,t){return r.from(n.publicKeyConvert(Uint8Array.from(e),t))},t.publicKeyVerify=function(e){return(33===e.length||65===e.length)&&n.publicKeyVerify(Uint8Array.from(e))},t.publicKeyTweakAdd=function(e,t,a){return r.from(n.publicKeyTweakAdd(Uint8Array.from(e),Uint8Array.from(t),a))},t.publicKeyTweakMul=function(e,t,a){return r.from(n.publicKeyTweakMul(Uint8Array.from(e),Uint8Array.from(t),a))},t.publicKeyCombine=function(e,t){var a=[];return e.forEach((function(e){a.push(Uint8Array.from(e))})),r.from(n.publicKeyCombine(a,t))},t.signatureNormalize=function(e){return r.from(n.signatureNormalize(Uint8Array.from(e)))},t.signatureExport=function(e){return r.from(n.signatureExport(Uint8Array.from(e)))},t.signatureImport=function(e){return r.from(n.signatureImport(Uint8Array.from(e)))},t.signatureImportLax=function(e){if(0===e.length)throw new RangeError("signature length is invalid");var t=o.signatureImportLax(e);if(null===t)throw new Error("couldn't parse DER signature");return c.signatureImport(t)},t.sign=function(e,t,a){if(null===a)throw new TypeError("options should be an Object");var c=void 0;if(a){if(c={},null===a.data)throw new TypeError("options.data should be a Buffer");if(a.data){if(32!=a.data.length)throw new RangeError("options.data length is invalid");c.data=new Uint8Array(a.data)}if(null===a.noncefn)throw new TypeError("options.noncefn should be a Function");a.noncefn&&(c.noncefn=function(e,t,n,c,o){var d=null!=n?r.from(n):null,s=null!=c?r.from(c):null,b=r.from("");return a.noncefn&&(b=a.noncefn(r.from(e),r.from(t),d,s,o)),new Uint8Array(b)})}var o=n.ecdsaSign(Uint8Array.from(e),Uint8Array.from(t),c);return{signature:r.from(o.signature),recovery:o.recid}},t.verify=function(e,t,a){return n.ecdsaVerify(Uint8Array.from(t),Uint8Array.from(e),a)},t.recover=function(e,t,a,c){return r.from(n.ecdsaRecover(Uint8Array.from(t),a,Uint8Array.from(e),c))},t.ecdh=function(e,t){return r.from(n.ecdh(Uint8Array.from(e),Uint8Array.from(t),{}))},t.ecdhUnsafe=function(e,t,a){if(33!==e.length&&65!==e.length)throw new RangeError("public key length is invalid");if(32!==t.length)throw new RangeError("private key length is invalid");return r.from(c.ecdhUnsafe(Uint8Array.from(e),Uint8Array.from(t),a))}},(e,t,a)=>{"use strict";var r,n=t,c=a(220),o=a(363),d=a(41).assert;function PresetCurve(e){"short"===e.type?this.curve=new o.short(e):"edwards"===e.type?this.curve=new o.edwards(e):this.curve=new o.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,d(this.g.validate(),"Invalid curve"),d(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function defineCurve(e,t){Object.defineProperty(n,e,{configurable:!0,enumerable:!0,get:function(){var a=new PresetCurve(t);return Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:a}),a}})}n.PresetCurve=PresetCurve,defineCurve("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:c.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),defineCurve("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:c.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),defineCurve("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:c.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),defineCurve("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:c.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),defineCurve("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:c.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),defineCurve("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:c.sha256,gRed:!1,g:["9"]}),defineCurve("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:c.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=a(816)}catch(e){r=void 0}defineCurve("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:c.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})},(e,t,a)=>{var r=t;r.utils=a(62),r.common=a(149),r.sha=a(1288),r.ripemd=a(1289),r.hmac=a(815),r.sha1=r.sha.sha1,r.sha256=r.sha.sha256,r.sha224=r.sha.sha224,r.sha384=r.sha.sha384,r.sha512=r.sha.sha512,r.ripemd160=r.ripemd.ripemd160},(e,t,a)=>{"use strict";var r=a(8).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.getLength=t.decode=t.encode=void 0;var n=a(655);function safeParseInt(e,t){if("00"===e.slice(0,2))throw new Error("invalid RLP: extra zeros");return parseInt(e,t)}function encodeLength(e,t){if(e<56)return r.from([e+t]);var a=intToHex(e),n=intToHex(t+55+a.length/2);return r.from(n+a,"hex")}function _decode(e){var t,a,n,c,o,d=[],s=e[0];if(s<=127)return{data:e.slice(0,1),remainder:e.slice(1)};if(s<=183){if(t=s-127,n=128===s?r.from([]):e.slice(1,t),2===t&&n[0]<128)throw new Error("invalid rlp encoding: byte must be less 0x80");return{data:n,remainder:e.slice(t)}}if(s<=191){if(a=s-182,e.length-1e.length)throw new Error("invalid rlp: total length is larger than the data");if(0===(c=e.slice(a,b)).length)throw new Error("invalid rlp, List has a invalid length");for(;c.length;)o=_decode(c),d.push(o.data),c=o.remainder;return{data:d,remainder:e.slice(b)}}function isHexPrefixed(e){return"0x"===e.slice(0,2)}function intToHex(e){if(e<0)throw new Error("Invalid integer as argument, must be unsigned!");var t=e.toString(16);return t.length%2?"0"+t:t}function toBuffer(e){if(!r.isBuffer(e)){if("string"==typeof e)return isHexPrefixed(e)?r.from(function padToEven(e){return e.length%2?"0"+e:e}(function stripHexPrefix(e){return"string"!=typeof e?e:isHexPrefixed(e)?e.slice(2):e}(e)),"hex"):r.from(e);if("number"==typeof e||"bigint"==typeof e)return e?function intToBuffer(e){var t=intToHex(e);return r.from(t,"hex")}(e):r.from([]);if(null==e)return r.from([]);if(e instanceof Uint8Array)return r.from(e);if(n.isBN(e))return r.from(e.toArray());throw new Error("invalid type")}return e}t.encode=function encode(e){if(Array.isArray(e)){for(var t=[],a=0;a{"use strict";var r=a(223),n=a(194),c=n(r("String.prototype.indexOf"));e.exports=function callBoundIntrinsic(e,t){var a=r(e,!!t);return"function"==typeof a&&c(e,".prototype.")>-1?n(a):a}},(e,t,a)=>{"use strict";var r,n=SyntaxError,c=Function,o=TypeError,getEvalledConstructor=function(e){try{return c('"use strict"; return ('+e+").constructor;")()}catch(e){}},d=Object.getOwnPropertyDescriptor;if(d)try{d({},"")}catch(e){d=null}var throwTypeError=function(){throw new o},s=d?function(){try{return throwTypeError}catch(e){try{return d(arguments,"callee").get}catch(e){return throwTypeError}}}():throwTypeError,b=a(828)(),u=Object.getPrototypeOf||function(e){return e.__proto__},h={},l="undefined"==typeof Uint8Array?r:u(Uint8Array),g={"%AggregateError%":"undefined"==typeof AggregateError?r:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?r:ArrayBuffer,"%ArrayIteratorPrototype%":b?u([][Symbol.iterator]()):r,"%AsyncFromSyncIteratorPrototype%":r,"%AsyncFunction%":h,"%AsyncGenerator%":h,"%AsyncGeneratorFunction%":h,"%AsyncIteratorPrototype%":h,"%Atomics%":"undefined"==typeof Atomics?r:Atomics,"%BigInt%":"undefined"==typeof BigInt?r:BigInt,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?r:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":"undefined"==typeof Float32Array?r:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?r:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?r:FinalizationRegistry,"%Function%":c,"%GeneratorFunction%":h,"%Int8Array%":"undefined"==typeof Int8Array?r:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?r:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?r:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":b?u(u([][Symbol.iterator]())):r,"%JSON%":"object"==typeof JSON?JSON:r,"%Map%":"undefined"==typeof Map?r:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&b?u((new Map)[Symbol.iterator]()):r,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?r:Promise,"%Proxy%":"undefined"==typeof Proxy?r:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":"undefined"==typeof Reflect?r:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?r:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&b?u((new Set)[Symbol.iterator]()):r,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?r:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":b?u(""[Symbol.iterator]()):r,"%Symbol%":b?Symbol:r,"%SyntaxError%":n,"%ThrowTypeError%":s,"%TypedArray%":l,"%TypeError%":o,"%Uint8Array%":"undefined"==typeof Uint8Array?r:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?r:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?r:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?r:Uint32Array,"%URIError%":URIError,"%WeakMap%":"undefined"==typeof WeakMap?r:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?r:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?r:WeakSet},p=function doEval(e){var t;if("%AsyncFunction%"===e)t=getEvalledConstructor("async function () {}");else if("%GeneratorFunction%"===e)t=getEvalledConstructor("function* () {}");else if("%AsyncGeneratorFunction%"===e)t=getEvalledConstructor("async function* () {}");else if("%AsyncGenerator%"===e){var a=doEval("%AsyncGeneratorFunction%");a&&(t=a.prototype)}else if("%AsyncIteratorPrototype%"===e){var r=doEval("%AsyncGenerator%");r&&(t=u(r.prototype))}return g[e]=t,t},B={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},x=a(224),I=a(830),m=x.call(Function.call,Array.prototype.concat),y=x.call(Function.apply,Array.prototype.splice),C=x.call(Function.call,String.prototype.replace),w=x.call(Function.call,String.prototype.slice),v=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Q=/\\(\\)?/g,k=function stringToPath(e){var t=w(e,0,1),a=w(e,-1);if("%"===t&&"%"!==a)throw new n("invalid intrinsic syntax, expected closing `%`");if("%"===a&&"%"!==t)throw new n("invalid intrinsic syntax, expected opening `%`");var r=[];return C(e,v,(function(e,t,a,n){r[r.length]=a?C(n,Q,"$1"):t||e})),r},_=function getBaseIntrinsic(e,t){var a,r=e;if(I(B,r)&&(r="%"+(a=B[r])[0]+"%"),I(g,r)){var c=g[r];if(c===h&&(c=p(r)),void 0===c&&!t)throw new o("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:a,name:r,value:c}}throw new n("intrinsic "+e+" does not exist!")};e.exports=function GetIntrinsic(e,t){if("string"!=typeof e||0===e.length)throw new o("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new o('"allowMissing" argument must be a boolean');var a=k(e),r=a.length>0?a[0]:"",c=_("%"+r+"%",t),s=c.name,b=c.value,u=!1,h=c.alias;h&&(r=h[0],y(a,m([0,1],h)));for(var l=1,p=!0;l=a.length){var v=d(b,B);b=(p=!!v)&&"get"in v&&!("originalValue"in v.get)?v.get:b[B]}else p=I(b,B),b=b[B];p&&!u&&(g[s]=b)}}return b}},(e,t,a)=>{"use strict";var r=a(829);e.exports=Function.prototype.bind||r},(e,t,a)=>{"use strict";var r=a(115).a.ERR_STREAM_PREMATURE_CLOSE;function noop(){}e.exports=function eos(e,t,a){if("function"==typeof t)return eos(e,null,t);t||(t={}),a=function once(e){var t=!1;return function(){if(!t){t=!0;for(var a=arguments.length,r=new Array(a),n=0;n{"use strict";var r=a(8).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.assertIsString=t.assertIsArray=t.assertIsBuffer=t.assertIsHexString=void 0;var n=a(116);t.assertIsHexString=function(e){if(!(0,n.isHexString)(e)){var t="This method only supports 0x-prefixed hex strings but input was: ".concat(e);throw new Error(t)}};t.assertIsBuffer=function(e){if(!r.isBuffer(e)){var t="This method only supports Buffer but input was: ".concat(e);throw new Error(t)}};t.assertIsArray=function(e){if(!Array.isArray(e)){var t="This method only supports number arrays but input was: ".concat(e);throw new Error(t)}};t.assertIsString=function(e){if("string"!=typeof e){var t="This method only supports strings but input was: ".concat(e);throw new Error(t)}}},(e,t,a)=>{"use strict";var r=a(8).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.toType=t.TypeOutput=t.bnToRlp=t.bnToUnpaddedBuffer=t.bnToHex=void 0;var n,c=a(53),o=a(116),d=a(74);function bnToUnpaddedBuffer(e){return(0,d.unpadBuffer)(e.toArrayLike(r))}t.bnToHex=function bnToHex(e){return"0x".concat(e.toString(16))},t.bnToUnpaddedBuffer=bnToUnpaddedBuffer,t.bnToRlp=function bnToRlp(e){return bnToUnpaddedBuffer(e)},function(e){e[e.Number=0]="Number",e[e.BN=1]="BN",e[e.Buffer=2]="Buffer",e[e.PrefixedHexString=3]="PrefixedHexString"}(n=t.TypeOutput||(t.TypeOutput={})),t.toType=function toType(e,t){if(null===e)return null;if(void 0!==e){if("string"==typeof e&&!(0,o.isHexString)(e))throw new Error("A string must be provided with a 0x-prefix, given: ".concat(e));if("number"==typeof e&&!Number.isSafeInteger(e))throw new Error("The provided number is greater than MAX_SAFE_INTEGER (please use an alternative input type)");var a=(0,d.toBuffer)(e);if(t===n.Buffer)return a;if(t===n.BN)return new c.BN(a);if(t===n.Number){var r=new c.BN(a),s=new c.BN(Number.MAX_SAFE_INTEGER.toString());if(r.gt(s))throw new Error("The provided number is greater than MAX_SAFE_INTEGER (please use an alternative output type)");return r.toNumber()}return"0x".concat(a.toString("hex"))}}},(e,t,a)=>{"use strict";var r,n=t,c=a(229),o=a(390),d=a(42).assert;function PresetCurve(e){"short"===e.type?this.curve=new o.short(e):"edwards"===e.type?this.curve=new o.edwards(e):this.curve=new o.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,d(this.g.validate(),"Invalid curve"),d(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function defineCurve(e,t){Object.defineProperty(n,e,{configurable:!0,enumerable:!0,get:function(){var a=new PresetCurve(t);return Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:a}),a}})}n.PresetCurve=PresetCurve,defineCurve("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:c.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),defineCurve("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:c.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),defineCurve("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:c.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),defineCurve("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:c.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),defineCurve("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:c.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),defineCurve("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:c.sha256,gRed:!1,g:["9"]}),defineCurve("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:c.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=a(877)}catch(e){r=void 0}defineCurve("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:c.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})},(e,t,a)=>{var r=t;r.utils=a(63),r.common=a(153),r.sha=a(1327),r.ripemd=a(1328),r.hmac=a(876),r.sha1=r.sha.sha1,r.sha256=r.sha.sha256,r.sha224=r.sha.sha224,r.sha384=r.sha.sha384,r.sha512=r.sha.sha512,r.ripemd160=r.ripemd.ripemd160},(e,t,a)=>{"use strict";var r=a(10).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.assertIsString=t.assertIsArray=t.assertIsBuffer=t.assertIsHexString=void 0;var n=a(117);t.assertIsHexString=function(e){if(!(0,n.isHexString)(e)){var t="This method only supports 0x-prefixed hex strings but input was: ".concat(e);throw new Error(t)}};t.assertIsBuffer=function(e){if(!r.isBuffer(e)){var t="This method only supports Buffer but input was: ".concat(e);throw new Error(t)}};t.assertIsArray=function(e){if(!Array.isArray(e)){var t="This method only supports number arrays but input was: ".concat(e);throw new Error(t)}};t.assertIsString=function(e){if("string"!=typeof e){var t="This method only supports strings but input was: ".concat(e);throw new Error(t)}}},(e,t,a)=>{"use strict";var r=a(118).a.ERR_STREAM_PREMATURE_CLOSE;function noop(){}e.exports=function eos(e,t,a){if("function"==typeof t)return eos(e,null,t);t||(t={}),a=function once(e){var t=!1;return function(){if(!t){t=!0;for(var a=arguments.length,r=new Array(a),n=0;n{"use strict";var r=a(10).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.toType=t.TypeOutput=t.bnToRlp=t.bnToUnpaddedBuffer=t.bnToHex=void 0;var n,c=a(54),o=a(117),d=a(75);function bnToUnpaddedBuffer(e){return(0,d.unpadBuffer)(e.toArrayLike(r))}t.bnToHex=function bnToHex(e){return"0x".concat(e.toString(16))},t.bnToUnpaddedBuffer=bnToUnpaddedBuffer,t.bnToRlp=function bnToRlp(e){return bnToUnpaddedBuffer(e)},function(e){e[e.Number=0]="Number",e[e.BN=1]="BN",e[e.Buffer=2]="Buffer",e[e.PrefixedHexString=3]="PrefixedHexString"}(n=t.TypeOutput||(t.TypeOutput={})),t.toType=function toType(e,t){if(null===e)return null;if(void 0!==e){if("string"==typeof e&&!(0,o.isHexString)(e))throw new Error("A string must be provided with a 0x-prefix, given: ".concat(e));if("number"==typeof e&&!Number.isSafeInteger(e))throw new Error("The provided number is greater than MAX_SAFE_INTEGER (please use an alternative input type)");var a=(0,d.toBuffer)(e);if(t===n.Buffer)return a;if(t===n.BN)return new c.BN(a);if(t===n.Number){var r=new c.BN(a),s=new c.BN(Number.MAX_SAFE_INTEGER.toString());if(r.gt(s))throw new Error("The provided number is greater than MAX_SAFE_INTEGER (please use an alternative output type)");return r.toNumber()}return"0x".concat(a.toString("hex"))}}},(e,t,a)=>{"use strict";var r,n=t,c=a(234),o=a(407),d=a(43).assert;function PresetCurve(e){"short"===e.type?this.curve=new o.short(e):"edwards"===e.type?this.curve=new o.edwards(e):this.curve=new o.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,d(this.g.validate(),"Invalid curve"),d(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function defineCurve(e,t){Object.defineProperty(n,e,{configurable:!0,enumerable:!0,get:function(){var a=new PresetCurve(t);return Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:a}),a}})}n.PresetCurve=PresetCurve,defineCurve("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:c.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),defineCurve("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:c.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),defineCurve("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:c.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),defineCurve("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:c.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),defineCurve("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:c.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),defineCurve("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:c.sha256,gRed:!1,g:["9"]}),defineCurve("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:c.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=a(919)}catch(e){r=void 0}defineCurve("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:c.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})},(e,t,a)=>{var r=t;r.utils=a(64),r.common=a(155),r.sha=a(1391),r.ripemd=a(1392),r.hmac=a(918),r.sha1=r.sha.sha1,r.sha256=r.sha.sha256,r.sha224=r.sha.sha224,r.sha384=r.sha.sha384,r.sha512=r.sha.sha512,r.ripemd160=r.ripemd.ripemd160},(e,t,a)=>{"use strict";var r,n=t,c=a(236),o=a(412),d=a(44).assert;function PresetCurve(e){"short"===e.type?this.curve=new o.short(e):"edwards"===e.type?this.curve=new o.edwards(e):this.curve=new o.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,d(this.g.validate(),"Invalid curve"),d(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function defineCurve(e,t){Object.defineProperty(n,e,{configurable:!0,enumerable:!0,get:function(){var a=new PresetCurve(t);return Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:a}),a}})}n.PresetCurve=PresetCurve,defineCurve("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:c.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),defineCurve("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:c.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),defineCurve("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:c.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),defineCurve("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:c.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),defineCurve("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:c.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),defineCurve("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:c.sha256,gRed:!1,g:["9"]}),defineCurve("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:c.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=a(941)}catch(e){r=void 0}defineCurve("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:c.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})},(e,t,a)=>{var r=t;r.utils=a(65),r.common=a(157),r.sha=a(1403),r.ripemd=a(1404),r.hmac=a(940),r.sha1=r.sha.sha1,r.sha256=r.sha.sha256,r.sha224=r.sha.sha224,r.sha384=r.sha.sha384,r.sha512=r.sha.sha512,r.ripemd160=r.ripemd.ripemd160},(e,t,a)=>{"use strict";var r=a(2).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.assertIsString=t.assertIsArray=t.assertIsBuffer=t.assertIsHexString=void 0;var n=a(120);t.assertIsHexString=function(e){if(!(0,n.isHexString)(e)){var t="This method only supports 0x-prefixed hex strings but input was: ".concat(e);throw new Error(t)}};t.assertIsBuffer=function(e){if(!r.isBuffer(e)){var t="This method only supports Buffer but input was: ".concat(e);throw new Error(t)}};t.assertIsArray=function(e){if(!Array.isArray(e)){var t="This method only supports number arrays but input was: ".concat(e);throw new Error(t)}};t.assertIsString=function(e){if("string"!=typeof e){var t="This method only supports strings but input was: ".concat(e);throw new Error(t)}}},(e,t,a)=>{"use strict";var r=a(121).a.ERR_STREAM_PREMATURE_CLOSE;function noop(){}e.exports=function eos(e,t,a){if("function"==typeof t)return eos(e,null,t);t||(t={}),a=function once(e){var t=!1;return function(){if(!t){t=!0;for(var a=arguments.length,r=new Array(a),n=0;n{"use strict";var r=a(2).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.toType=t.TypeOutput=t.bnToRlp=t.bnToUnpaddedBuffer=t.bnToHex=void 0;var n,c=a(55),o=a(120),d=a(76);function bnToUnpaddedBuffer(e){return(0,d.unpadBuffer)(e.toArrayLike(r))}t.bnToHex=function bnToHex(e){return"0x".concat(e.toString(16))},t.bnToUnpaddedBuffer=bnToUnpaddedBuffer,t.bnToRlp=function bnToRlp(e){return bnToUnpaddedBuffer(e)},function(e){e[e.Number=0]="Number",e[e.BN=1]="BN",e[e.Buffer=2]="Buffer",e[e.PrefixedHexString=3]="PrefixedHexString"}(n=t.TypeOutput||(t.TypeOutput={})),t.toType=function toType(e,t){if(null===e)return null;if(void 0!==e){if("string"==typeof e&&!(0,o.isHexString)(e))throw new Error("A string must be provided with a 0x-prefix, given: ".concat(e));if("number"==typeof e&&!Number.isSafeInteger(e))throw new Error("The provided number is greater than MAX_SAFE_INTEGER (please use an alternative input type)");var a=(0,d.toBuffer)(e);if(t===n.Buffer)return a;if(t===n.BN)return new c.BN(a);if(t===n.Number){var r=new c.BN(a),s=new c.BN(Number.MAX_SAFE_INTEGER.toString());if(r.gt(s))throw new Error("The provided number is greater than MAX_SAFE_INTEGER (please use an alternative output type)");return r.toNumber()}return"0x".concat(a.toString("hex"))}}},(e,t,a)=>{"use strict";var r=t;r.version=a(1416).a,r.utils=a(45),r.rand=a(241),r.curve=a(426),r.curves=a(242),r.ec=a(982),r.eddsa=a(986)},(e,t,a)=>{var r;function Rand(e){this.rand=e}if(e.exports=function rand(e){return r||(r=new Rand(null)),r.generate(e)},e.exports.Rand=Rand,Rand.prototype.generate=function generate(e){return this._rand(e)},Rand.prototype._rand=function _rand(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),a=0;a{"use strict";var r,n=t,c=a(243),o=a(426),d=a(45).assert;function PresetCurve(e){"short"===e.type?this.curve=new o.short(e):"edwards"===e.type?this.curve=new o.edwards(e):this.curve=new o.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,d(this.g.validate(),"Invalid curve"),d(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function defineCurve(e,t){Object.defineProperty(n,e,{configurable:!0,enumerable:!0,get:function(){var a=new PresetCurve(t);return Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:a}),a}})}n.PresetCurve=PresetCurve,defineCurve("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:c.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),defineCurve("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:c.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),defineCurve("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:c.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),defineCurve("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:c.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),defineCurve("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:c.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),defineCurve("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:c.sha256,gRed:!1,g:["9"]}),defineCurve("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:c.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=a(981)}catch(e){r=void 0}defineCurve("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:c.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})},(e,t,a)=>{var r=t;r.utils=a(66),r.common=a(159),r.sha=a(1418),r.ripemd=a(1419),r.hmac=a(980),r.sha1=r.sha.sha1,r.sha256=r.sha.sha256,r.sha224=r.sha.sha224,r.sha384=r.sha.sha384,r.sha512=r.sha.sha512,r.ripemd160=r.ripemd.ripemd160},(e,t,a)=>{"use strict";var r=a(0).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.assertIsString=t.assertIsArray=t.assertIsBuffer=t.assertIsHexString=void 0;var n=a(122);t.assertIsHexString=function(e){if(!(0,n.isHexString)(e)){var t="This method only supports 0x-prefixed hex strings but input was: ".concat(e);throw new Error(t)}};t.assertIsBuffer=function(e){if(!r.isBuffer(e)){var t="This method only supports Buffer but input was: ".concat(e);throw new Error(t)}};t.assertIsArray=function(e){if(!Array.isArray(e)){var t="This method only supports number arrays but input was: ".concat(e);throw new Error(t)}};t.assertIsString=function(e){if("string"!=typeof e){var t="This method only supports strings but input was: ".concat(e);throw new Error(t)}}},(e,t,a)=>{"use strict";var r=a(123).a.ERR_STREAM_PREMATURE_CLOSE;function noop(){}e.exports=function eos(e,t,a){if("function"==typeof t)return eos(e,null,t);t||(t={}),a=function once(e){var t=!1;return function(){if(!t){t=!0;for(var a=arguments.length,r=new Array(a),n=0;n{"use strict";var r=a(0).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.toType=t.TypeOutput=t.bnToRlp=t.bnToUnpaddedBuffer=t.bnToHex=void 0;var n,c=a(56),o=a(122),d=a(77);function bnToUnpaddedBuffer(e){return(0,d.unpadBuffer)(e.toArrayLike(r))}t.bnToHex=function bnToHex(e){return"0x".concat(e.toString(16))},t.bnToUnpaddedBuffer=bnToUnpaddedBuffer,t.bnToRlp=function bnToRlp(e){return bnToUnpaddedBuffer(e)},function(e){e[e.Number=0]="Number",e[e.BN=1]="BN",e[e.Buffer=2]="Buffer",e[e.PrefixedHexString=3]="PrefixedHexString"}(n=t.TypeOutput||(t.TypeOutput={})),t.toType=function toType(e,t){if(null===e)return null;if(void 0!==e){if("string"==typeof e&&!(0,o.isHexString)(e))throw new Error("A string must be provided with a 0x-prefix, given: ".concat(e));if("number"==typeof e&&!Number.isSafeInteger(e))throw new Error("The provided number is greater than MAX_SAFE_INTEGER (please use an alternative input type)");var a=(0,d.toBuffer)(e);if(t===n.Buffer)return a;if(t===n.BN)return new c.BN(a);if(t===n.Number){var r=new c.BN(a),s=new c.BN(Number.MAX_SAFE_INTEGER.toString());if(r.gt(s))throw new Error("The provided number is greater than MAX_SAFE_INTEGER (please use an alternative output type)");return r.toNumber()}return"0x".concat(a.toString("hex"))}}},(e,t,a)=>{"use strict";var r=a(248),n=a(692),c=n(r("String.prototype.indexOf"));e.exports=function callBoundIntrinsic(e,t){var a=r(e,!!t);return"function"==typeof a&&c(e,".prototype.")>-1?n(a):a}},(e,t,a)=>{"use strict";var r,n=SyntaxError,c=Function,o=TypeError,getEvalledConstructor=function(e){try{return c('"use strict"; return ('+e+").constructor;")()}catch(e){}},d=Object.getOwnPropertyDescriptor;if(d)try{d({},"")}catch(e){d=null}var throwTypeError=function(){throw new o},s=d?function(){try{return throwTypeError}catch(e){try{return d(arguments,"callee").get}catch(e){return throwTypeError}}}():throwTypeError,b=a(1018)(),u=Object.getPrototypeOf||function(e){return e.__proto__},h={},l="undefined"==typeof Uint8Array?r:u(Uint8Array),g={"%AggregateError%":"undefined"==typeof AggregateError?r:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?r:ArrayBuffer,"%ArrayIteratorPrototype%":b?u([][Symbol.iterator]()):r,"%AsyncFromSyncIteratorPrototype%":r,"%AsyncFunction%":h,"%AsyncGenerator%":h,"%AsyncGeneratorFunction%":h,"%AsyncIteratorPrototype%":h,"%Atomics%":"undefined"==typeof Atomics?r:Atomics,"%BigInt%":"undefined"==typeof BigInt?r:BigInt,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?r:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":"undefined"==typeof Float32Array?r:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?r:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?r:FinalizationRegistry,"%Function%":c,"%GeneratorFunction%":h,"%Int8Array%":"undefined"==typeof Int8Array?r:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?r:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?r:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":b?u(u([][Symbol.iterator]())):r,"%JSON%":"object"==typeof JSON?JSON:r,"%Map%":"undefined"==typeof Map?r:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&b?u((new Map)[Symbol.iterator]()):r,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?r:Promise,"%Proxy%":"undefined"==typeof Proxy?r:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":"undefined"==typeof Reflect?r:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?r:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&b?u((new Set)[Symbol.iterator]()):r,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?r:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":b?u(""[Symbol.iterator]()):r,"%Symbol%":b?Symbol:r,"%SyntaxError%":n,"%ThrowTypeError%":s,"%TypedArray%":l,"%TypeError%":o,"%Uint8Array%":"undefined"==typeof Uint8Array?r:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?r:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?r:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?r:Uint32Array,"%URIError%":URIError,"%WeakMap%":"undefined"==typeof WeakMap?r:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?r:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?r:WeakSet},p=function doEval(e){var t;if("%AsyncFunction%"===e)t=getEvalledConstructor("async function () {}");else if("%GeneratorFunction%"===e)t=getEvalledConstructor("function* () {}");else if("%AsyncGeneratorFunction%"===e)t=getEvalledConstructor("async function* () {}");else if("%AsyncGenerator%"===e){var a=doEval("%AsyncGeneratorFunction%");a&&(t=a.prototype)}else if("%AsyncIteratorPrototype%"===e){var r=doEval("%AsyncGenerator%");r&&(t=u(r.prototype))}return g[e]=t,t},B={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},x=a(249),I=a(1020),m=x.call(Function.call,Array.prototype.concat),y=x.call(Function.apply,Array.prototype.splice),C=x.call(Function.call,String.prototype.replace),w=x.call(Function.call,String.prototype.slice),v=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Q=/\\(\\)?/g,k=function stringToPath(e){var t=w(e,0,1),a=w(e,-1);if("%"===t&&"%"!==a)throw new n("invalid intrinsic syntax, expected closing `%`");if("%"===a&&"%"!==t)throw new n("invalid intrinsic syntax, expected opening `%`");var r=[];return C(e,v,(function(e,t,a,n){r[r.length]=a?C(n,Q,"$1"):t||e})),r},_=function getBaseIntrinsic(e,t){var a,r=e;if(I(B,r)&&(r="%"+(a=B[r])[0]+"%"),I(g,r)){var c=g[r];if(c===h&&(c=p(r)),void 0===c&&!t)throw new o("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:a,name:r,value:c}}throw new n("intrinsic "+e+" does not exist!")};e.exports=function GetIntrinsic(e,t){if("string"!=typeof e||0===e.length)throw new o("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new o('"allowMissing" argument must be a boolean');var a=k(e),r=a.length>0?a[0]:"",c=_("%"+r+"%",t),s=c.name,b=c.value,u=!1,h=c.alias;h&&(r=h[0],y(a,m([0,1],h)));for(var l=1,p=!0;l=a.length){var v=d(b,B);b=(p=!!v)&&"get"in v&&!("originalValue"in v.get)?v.get:b[B]}else p=I(b,B),b=b[B];p&&!u&&(g[s]=b)}}return b}},(e,t,a)=>{"use strict";var r=a(1019);e.exports=Function.prototype.bind||r},(e,t,a)=>{var r=a(604).create,n=r("LevelUPError"),c=r("NotFoundError",n);c.prototype.notFound=!0,c.prototype.status=404,e.exports={LevelUPError:n,InitializationError:r("InitializationError",n),OpenError:r("OpenError",n),ReadError:r("ReadError",n),WriteError:r("WriteError",n),NotFoundError:c,EncodingError:r("EncodingError",n)}},e=>{"use strict";e.exports=function createRBTree(e){return new RedBlackTree(e||defaultCompare,null)};function RBNode(e,t,a,r,n,c){this._color=e,this.key=t,this.value=a,this.left=r,this.right=n,this._count=c}function cloneNode(e){return new RBNode(e._color,e.key,e.value,e.left,e.right,e._count)}function repaint(e,t){return new RBNode(e,t.key,t.value,t.left,t.right,t._count)}function recount(e){e._count=1+(e.left?e.left._count:0)+(e.right?e.right._count:0)}function RedBlackTree(e,t){this._compare=e,this.root=t}var t=RedBlackTree.prototype;function doVisitFull(e,t){var a;if(t.left&&(a=doVisitFull(e,t.left)))return a;return(a=e(t.key,t.value))||(t.right?doVisitFull(e,t.right):void 0)}function doVisitHalf(e,t,a,r){if(t(e,r.key)<=0){var n;if(r.left)if(n=doVisitHalf(e,t,a,r.left))return n;if(n=a(r.key,r.value))return n}if(r.right)return doVisitHalf(e,t,a,r.right)}function doVisit(e,t,a,r,n){var c,o=a(e,n.key),d=a(t,n.key);if(o<=0){if(n.left&&(c=doVisit(e,t,a,r,n.left)))return c;if(d>0&&(c=r(n.key,n.value)))return c}if(d>0&&n.right)return doVisit(e,t,a,r,n.right)}function RedBlackTreeIterator(e,t){this.tree=e,this._stack=t}Object.defineProperty(t,"keys",{get:function(){var e=[];return this.forEach((function(t,a){e.push(t)})),e}}),Object.defineProperty(t,"values",{get:function(){var e=[];return this.forEach((function(t,a){e.push(a)})),e}}),Object.defineProperty(t,"length",{get:function(){return this.root?this.root._count:0}}),t.insert=function(e,t){for(var a=this._compare,r=this.root,n=[],c=[];r;){var o=a(e,r.key);n.push(r),c.push(o),r=o<=0?r.left:r.right}n.push(new RBNode(0,e,t,null,null,1));for(var d=n.length-2;d>=0;--d){r=n[d];c[d]<=0?n[d]=new RBNode(r._color,r.key,r.value,n[d+1],r.right,r._count+1):n[d]=new RBNode(r._color,r.key,r.value,r.left,n[d+1],r._count+1)}for(d=n.length-1;d>1;--d){var s=n[d-1];r=n[d];if(1===s._color||1===r._color)break;var b=n[d-2];if(b.left===s)if(s.left===r){if(!(u=b.right)||0!==u._color){if(b._color=0,b.left=s.right,s._color=1,s.right=b,n[d-2]=s,n[d-1]=r,recount(b),recount(s),d>=3)(h=n[d-3]).left===b?h.left=s:h.right=s;break}s._color=1,b.right=repaint(1,u),b._color=0,d-=1}else{if(!(u=b.right)||0!==u._color){if(s.right=r.left,b._color=0,b.left=r.right,r._color=1,r.left=s,r.right=b,n[d-2]=r,n[d-1]=s,recount(b),recount(s),recount(r),d>=3)(h=n[d-3]).left===b?h.left=r:h.right=r;break}s._color=1,b.right=repaint(1,u),b._color=0,d-=1}else if(s.right===r){if(!(u=b.left)||0!==u._color){if(b._color=0,b.right=s.left,s._color=1,s.left=b,n[d-2]=s,n[d-1]=r,recount(b),recount(s),d>=3)(h=n[d-3]).right===b?h.right=s:h.left=s;break}s._color=1,b.left=repaint(1,u),b._color=0,d-=1}else{var u;if(!(u=b.left)||0!==u._color){var h;if(s.left=r.right,b._color=0,b.right=r.left,r._color=1,r.right=s,r.left=b,n[d-2]=r,n[d-1]=s,recount(b),recount(s),recount(r),d>=3)(h=n[d-3]).right===b?h.right=r:h.left=r;break}s._color=1,b.left=repaint(1,u),b._color=0,d-=1}}return n[0]._color=1,new RedBlackTree(a,n[0])},t.forEach=function rbTreeForEach(e,t,a){if(this.root)switch(arguments.length){case 1:return doVisitFull(e,this.root);case 2:return doVisitHalf(t,this._compare,e,this.root);case 3:if(this._compare(t,a)>=0)return;return doVisit(t,a,this._compare,e,this.root)}},Object.defineProperty(t,"begin",{get:function(){for(var e=[],t=this.root;t;)e.push(t),t=t.left;return new RedBlackTreeIterator(this,e)}}),Object.defineProperty(t,"end",{get:function(){for(var e=[],t=this.root;t;)e.push(t),t=t.right;return new RedBlackTreeIterator(this,e)}}),t.at=function(e){if(e<0)return new RedBlackTreeIterator(this,[]);for(var t=this.root,a=[];;){if(a.push(t),t.left){if(e=t.right._count)break;t=t.right}return new RedBlackTreeIterator(this,[])},t.ge=function(e){for(var t=this._compare,a=this.root,r=[],n=0;a;){var c=t(e,a.key);r.push(a),c<=0&&(n=r.length),a=c<=0?a.left:a.right}return r.length=n,new RedBlackTreeIterator(this,r)},t.gt=function(e){for(var t=this._compare,a=this.root,r=[],n=0;a;){var c=t(e,a.key);r.push(a),c<0&&(n=r.length),a=c<0?a.left:a.right}return r.length=n,new RedBlackTreeIterator(this,r)},t.lt=function(e){for(var t=this._compare,a=this.root,r=[],n=0;a;){var c=t(e,a.key);r.push(a),c>0&&(n=r.length),a=c<=0?a.left:a.right}return r.length=n,new RedBlackTreeIterator(this,r)},t.le=function(e){for(var t=this._compare,a=this.root,r=[],n=0;a;){var c=t(e,a.key);r.push(a),c>=0&&(n=r.length),a=c<0?a.left:a.right}return r.length=n,new RedBlackTreeIterator(this,r)},t.find=function(e){for(var t=this._compare,a=this.root,r=[];a;){var n=t(e,a.key);if(r.push(a),0===n)return new RedBlackTreeIterator(this,r);a=n<=0?a.left:a.right}return new RedBlackTreeIterator(this,[])},t.remove=function(e){var t=this.find(e);return t?t.remove():this},t.get=function(e){for(var t=this._compare,a=this.root;a;){var r=t(e,a.key);if(0===r)return a.value;a=r<=0?a.left:a.right}};var a=RedBlackTreeIterator.prototype;function swapNode(e,t){e.key=t.key,e.value=t.value,e.left=t.left,e.right=t.right,e._color=t._color,e._count=t._count}function defaultCompare(e,t){return et?1:0}Object.defineProperty(a,"valid",{get:function(){return this._stack.length>0}}),Object.defineProperty(a,"node",{get:function(){return this._stack.length>0?this._stack[this._stack.length-1]:null},enumerable:!0}),a.clone=function(){return new RedBlackTreeIterator(this.tree,this._stack.slice())},a.remove=function(){var e=this._stack;if(0===e.length)return this.tree;var t=new Array(e.length),a=e[e.length-1];t[t.length-1]=new RBNode(a._color,a.key,a.value,a.left,a.right,a._count);for(var r=e.length-2;r>=0;--r){(a=e[r]).left===e[r+1]?t[r]=new RBNode(a._color,a.key,a.value,t[r+1],a.right,a._count):t[r]=new RBNode(a._color,a.key,a.value,a.left,t[r+1],a._count)}if((a=t[t.length-1]).left&&a.right){var n=t.length;for(a=a.left;a.right;)t.push(a),a=a.right;var c=t[n-1];t.push(new RBNode(a._color,c.key,c.value,a.left,a.right,a._count)),t[n-1].key=a.key,t[n-1].value=a.value;for(r=t.length-2;r>=n;--r)a=t[r],t[r]=new RBNode(a._color,a.key,a.value,a.left,t[r+1],a._count);t[n-1].left=t[n]}if(0===(a=t[t.length-1])._color){var o=t[t.length-2];o.left===a?o.left=null:o.right===a&&(o.right=null),t.pop();for(r=0;r=0;--c){if(t=e[c],0===c)return void(t._color=1);if((a=e[c-1]).left===t){if((r=a.right).right&&0===r.right._color)return n=(r=a.right=cloneNode(r)).right=cloneNode(r.right),a.right=r.left,r.left=a,r.right=n,r._color=a._color,t._color=1,a._color=1,n._color=1,recount(a),recount(r),c>1&&((o=e[c-2]).left===a?o.left=r:o.right=r),void(e[c-1]=r);if(r.left&&0===r.left._color)return n=(r=a.right=cloneNode(r)).left=cloneNode(r.left),a.right=n.left,r.left=n.right,n.left=a,n.right=r,n._color=a._color,a._color=1,r._color=1,t._color=1,recount(a),recount(r),recount(n),c>1&&((o=e[c-2]).left===a?o.left=n:o.right=n),void(e[c-1]=n);if(1===r._color){if(0===a._color)return a._color=1,void(a.right=repaint(0,r));a.right=repaint(0,r);continue}r=cloneNode(r),a.right=r.left,r.left=a,r._color=a._color,a._color=0,recount(a),recount(r),c>1&&((o=e[c-2]).left===a?o.left=r:o.right=r),e[c-1]=r,e[c]=a,c+11&&((o=e[c-2]).right===a?o.right=r:o.left=r),void(e[c-1]=r);if(r.right&&0===r.right._color)return n=(r=a.left=cloneNode(r)).right=cloneNode(r.right),a.left=n.right,r.right=n.left,n.right=a,n.left=r,n._color=a._color,a._color=1,r._color=1,t._color=1,recount(a),recount(r),recount(n),c>1&&((o=e[c-2]).right===a?o.right=n:o.left=n),void(e[c-1]=n);if(1===r._color){if(0===a._color)return a._color=1,void(a.left=repaint(0,r));a.left=repaint(0,r);continue}var o;r=cloneNode(r),a.left=r.right,r.right=a,r._color=a._color,a._color=0,recount(a),recount(r),c>1&&((o=e[c-2]).right===a?o.right=r:o.left=r),e[c-1]=r,e[c]=a,c+10)return this._stack[this._stack.length-1].key},enumerable:!0}),Object.defineProperty(a,"value",{get:function(){if(this._stack.length>0)return this._stack[this._stack.length-1].value},enumerable:!0}),Object.defineProperty(a,"index",{get:function(){var e=0,t=this._stack;if(0===t.length){var a=this.tree.root;return a?a._count:0}t[t.length-1].left&&(e=t[t.length-1].left._count);for(var r=t.length-2;r>=0;--r)t[r+1]===t[r].right&&(++e,t[r].left&&(e+=t[r].left._count));return e},enumerable:!0}),a.next=function(){var e=this._stack;if(0!==e.length){var t=e[e.length-1];if(t.right)for(t=t.right;t;)e.push(t),t=t.left;else for(e.pop();e.length>0&&e[e.length-1].right===t;)t=e[e.length-1],e.pop()}},Object.defineProperty(a,"hasNext",{get:function(){var e=this._stack;if(0===e.length)return!1;if(e[e.length-1].right)return!0;for(var t=e.length-1;t>0;--t)if(e[t-1].left===e[t])return!0;return!1}}),a.update=function(e){var t=this._stack;if(0===t.length)throw new Error("Can't update empty node!");var a=new Array(t.length),r=t[t.length-1];a[a.length-1]=new RBNode(r._color,r.key,e,r.left,r.right,r._count);for(var n=t.length-2;n>=0;--n)(r=t[n]).left===t[n+1]?a[n]=new RBNode(r._color,r.key,r.value,a[n+1],r.right,r._count):a[n]=new RBNode(r._color,r.key,r.value,r.left,a[n+1],r._count);return new RedBlackTree(this.tree._compare,a[0])},a.prev=function(){var e=this._stack;if(0!==e.length){var t=e[e.length-1];if(t.left)for(t=t.left;t;)e.push(t),t=t.right;else for(e.pop();e.length>0&&e[e.length-1].left===t;)t=e[e.length-1],e.pop()}},Object.defineProperty(a,"hasPrev",{get:function(){var e=this._stack;if(0===e.length)return!1;if(e[e.length-1].left)return!0;for(var t=e.length-1;t>0;--t)if(e[t-1].right===e[t])return!0;return!1}})},(e,t,a)=>{"use strict";var r=a(0).Buffer;function matchingNibbleLength(e,t){for(var a=0;e[a]===t[a]&&e.length>a;)a++;return a}Object.defineProperty(t,"__esModule",{value:!0}),t.doKeysMatch=t.matchingNibbleLength=t.nibblesCompare=t.nibblesToBuffer=t.bufferToNibbles=void 0,t.bufferToNibbles=function bufferToNibbles(e){for(var t=r.from(e),a=[],n=0;n>4,a[++c]=t[n]%16}return a},t.nibblesToBuffer=function nibblesToBuffer(e){for(var t=r.alloc(e.length/2),a=0;at[n]){r=1;break}}return 0===r&&(e.lengtht.length&&(r=1)),r},t.matchingNibbleLength=matchingNibbleLength,t.doKeysMatch=function doKeysMatch(e,t){var a=matchingNibbleLength(e,t);return a===e.length&&a===t.length}},(e,t,a)=>{"use strict";var r=a(124).a.ERR_STREAM_PREMATURE_CLOSE;function noop(){}e.exports=function eos(e,t,a){if("function"==typeof t)return eos(e,null,t);t||(t={}),a=function once(e){var t=!1;return function(){if(!t){t=!0;for(var a=arguments.length,r=new Array(a),n=0;n{e.exports=function isBuffer(e){return null!=e&&null!=e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}},(e,t,a)=>{"use strict";const r=a(165);e.exports=function(e,...t){0===t.length?r(e):r((()=>e(...t)))}},(e,t,a)=>{"use strict";const r=a(24).EventEmitter,n=a(130).inherits,c=a(1062),o=a(1067),d=a(1068),s=a(485),b=a(482),u=a(164),h=a(637).a,l=a(637).b,g=a(1069),p=s.WriteError,B=s.ReadError,x=s.NotFoundError,I=s.OpenError,m=s.InitializationError;function LevelUP(e,t,a){if(!(this instanceof LevelUP))return new LevelUP(e,t,a);let n;if(r.call(this),this.setMaxListeners(1/0),"function"==typeof t&&(a=t,t={}),t=t||{},!e||"object"!=typeof e){if(n=new m("First argument must be an abstract-leveldown compliant store"),"function"==typeof a)return g(a,n);throw n}if("string"!=typeof e.status)throw new Error(".status required, old abstract-leveldown");this.options=l(t),this._db=e,this.db=null,this.open(a||(e=>{e&&this.emit("error",e)})),this.supports=b(this.db.supports,{status:!0,deferredOpen:!0,openCallback:!0,promises:!0,streams:!0});for(const e of Object.keys(this.supports.additionalMethods))null==this[e]&&(this[e]=function(...t){return this.db[e](...t)})}function maybeError(e,t){return!e.isOperational()&&(g(t,new B("Database is not open")),!0)}LevelUP.prototype.emit=r.prototype.emit,LevelUP.prototype.once=r.prototype.once,n(LevelUP,r),Object.defineProperty(LevelUP.prototype,"status",{enumerable:!0,get(){return this.db.status}}),LevelUP.prototype.isOperational=function(){return"open"===this.db.status||"opening"===this.db.status},LevelUP.prototype.open=function(e,t){return"function"==typeof e&&(t=e,e=null),t=u.fromCallback(t),e||(e=this.options),this.db&&this.isOpen()?(g(t,null,this),t.promise):this.db&&this._isOpening()?(this.once("open",(()=>{t(null,this)})),t.promise):(this.db=new c(this._db),this.emit("opening"),this.db.open(e,(e=>{if(e)return t(new I(e));this.db=this._db,t(null,this),this.emit("open"),this.emit("ready")})),t.promise)},LevelUP.prototype.close=function(e){return e=u.fromCallback(e),this.isOpen()?(this.db.close(((t,...a)=>{this.emit("closed"),e(t,...a)})),this.emit("closing")):this.isClosed()?g(e):"closing"===this.db.status?this.once("closed",e):this._isOpening()&&this.once("open",(()=>{this.close(e)})),e.promise},LevelUP.prototype.isOpen=function(){return"open"===this.db.status},LevelUP.prototype._isOpening=function(){return"opening"===this.db.status},LevelUP.prototype.isClosed=function(){return/^clos|new/.test(this.db.status)},LevelUP.prototype.get=function(e,t,a){return a=h(t,a),maybeError(this,a=u.fromCallback(a))||(t=l(t),this.db.get(e,t,(function(t,r){if(t)return t=/notfound/i.test(t)||t.notFound?new x("Key not found in database ["+e+"]",t):new B(t),a(t);a(null,r)}))),a.promise},LevelUP.prototype.getMany=function(e,t,a){return this.db.getMany(e,t,a)},LevelUP.prototype.put=function(e,t,a,r){return r=h(a,r),maybeError(this,r=u.fromCallback(r))||(a=l(a),this.db.put(e,t,a,(a=>{if(a)return r(new p(a));this.emit("put",e,t),r()}))),r.promise},LevelUP.prototype.del=function(e,t,a){return a=h(t,a),maybeError(this,a=u.fromCallback(a))||(t=l(t),this.db.del(e,t,(t=>{if(t)return a(new p(t));this.emit("del",e),a()}))),a.promise},LevelUP.prototype.batch=function(e,t,a){return arguments.length?(a="function"==typeof e?e:h(t,a),maybeError(this,a=u.fromCallback(a))||(t=l(t),this.db.batch(e,t,(t=>{if(t)return a(new p(t));this.emit("batch",e),a()}))),a.promise):new d(this)},LevelUP.prototype.iterator=function(e){return this.db.iterator(e)},LevelUP.prototype.clear=function(e,t){return t=h(e,t),e=l(e),maybeError(this,t=u.fromCallback(t))||this.db.clear(e,(a=>{if(a)return t(new p(a));this.emit("clear",e),t()})),t.promise},LevelUP.prototype.readStream=LevelUP.prototype.createReadStream=function(e){return"number"!=typeof(e=Object.assign({keys:!0,values:!0},e)).limit&&(e.limit=-1),new o(this.db.iterator(e),e)},LevelUP.prototype.keyStream=LevelUP.prototype.createKeyStream=function(e){return this.createReadStream(Object.assign({},e,{keys:!0,values:!1}))},LevelUP.prototype.valueStream=LevelUP.prototype.createValueStream=function(e){return this.createReadStream(Object.assign({},e,{keys:!1,values:!0}))},LevelUP.prototype.toString=function(){return"LevelUP"},LevelUP.prototype.type="levelup",LevelUP.prototype._nextTick=g,LevelUP.errors=s,e.exports=LevelUP},(e,t,a)=>{"use strict";const r=a(165);e.exports=function(e,...t){0===t.length?r(e):r((()=>e(...t)))}},(e,t,a)=>{"use strict";const r=a(165);e.exports=function(e,...t){0===t.length?r(e):r((()=>e(...t)))}},(e,t,a)=>{"use strict";const r=a(491);e.exports=function(e,...t){0===t.length?r(e):r((()=>e(...t)))}},(e,t,a)=>{"use strict";var r=a(0).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.DBOp=t.DBTarget=void 0;var n,c=a(1094);!function(e){e[e.Heads=0]="Heads",e[e.HeadHeader=1]="HeadHeader",e[e.HeadBlock=2]="HeadBlock",e[e.HashToNumber=3]="HashToNumber",e[e.NumberToHash=4]="NumberToHash",e[e.TotalDifficulty=5]="TotalDifficulty",e[e.Body=6]="Body",e[e.Header=7]="Header",e[e.CliqueSignerStates=8]="CliqueSignerStates",e[e.CliqueVotes=9]="CliqueVotes",e[e.CliqueBlockSigners=10]="CliqueBlockSigners"}(n=t.DBTarget||(t.DBTarget={}));var o=function(){function DBOp(e,t){switch(this.operationTarget=e,this.baseDBOp={key:"",keyEncoding:"binary",valueEncoding:"binary"},e){case n.Heads:this.baseDBOp.key=c.HEADS_KEY,this.baseDBOp.valueEncoding="json";break;case n.HeadHeader:this.baseDBOp.key=c.HEAD_HEADER_KEY;break;case n.HeadBlock:this.baseDBOp.key=c.HEAD_BLOCK_KEY;break;case n.HashToNumber:this.baseDBOp.key=(0,c.hashToNumberKey)(t.blockHash),this.cacheString="hashToNumber";break;case n.NumberToHash:this.baseDBOp.key=(0,c.numberToHashKey)(t.blockNumber),this.cacheString="numberToHash";break;case n.TotalDifficulty:this.baseDBOp.key=(0,c.tdKey)(t.blockNumber,t.blockHash),this.cacheString="td";break;case n.Body:this.baseDBOp.key=(0,c.bodyKey)(t.blockNumber,t.blockHash),this.cacheString="body";break;case n.Header:this.baseDBOp.key=(0,c.headerKey)(t.blockNumber,t.blockHash),this.cacheString="header";break;case n.CliqueSignerStates:this.baseDBOp.key=c.CLIQUE_SIGNERS_KEY;break;case n.CliqueVotes:this.baseDBOp.key=c.CLIQUE_VOTES_KEY;break;case n.CliqueBlockSigners:this.baseDBOp.key=c.CLIQUE_BLOCK_SIGNERS_KEY}}return DBOp.get=function(e,t){return new DBOp(e,t)},DBOp.set=function(e,t,a){var r=new DBOp(e,a);return r.baseDBOp.value=t,r.baseDBOp.type="put",e==n.Heads?r.baseDBOp.valueEncoding="json":r.baseDBOp.valueEncoding="binary",r},DBOp.del=function(e,t){var a=new DBOp(e,t);return a.baseDBOp.type="del",a},DBOp.prototype.updateCache=function(e){if(this.cacheString&&e[this.cacheString])if("put"==this.baseDBOp.type)r.isBuffer(this.baseDBOp.value)&&e[this.cacheString].set(this.baseDBOp.key,this.baseDBOp.value);else{if("del"!=this.baseDBOp.type)throw new Error("unsupported db operation on cache");e[this.cacheString].del(this.baseDBOp.key)}},DBOp}();t.DBOp=o},(e,t,a)=>{var r=a(11).TypeError;e.exports=function(e){if(null==e)throw r("Can't call method on "+e);return e}},(e,t,a)=>{var r=a(11),n=a(1098),c="__core-js_shared__",o=r[c]||n(c,{});e.exports=o},(e,t,a)=>{var r=a(1099),n=a(502);e.exports=function(e){var t=r(e,"string");return n(t)?t:t+""}},e=>{e.exports={}},(e,t,a)=>{var r=a(33);e.exports=r({}.isPrototypeOf)},(e,t,a)=>{var r=a(267);e.exports=function(e,t){var a=e[t];return null==a?void 0:r(a)}},(e,t,a)=>{var r=a(11),n=a(29),c=a(268),o=r.TypeError;e.exports=function(e){if(n(e))return e;throw o(c(e)+" is not a function")}},(e,t,a)=>{var r=a(11).String;e.exports=function(e){try{return r(e)}catch(e){return"Object"}}},(e,t,a)=>{var r=a(11),n=a(261),c=r.Object;e.exports=function(e){return c(n(e))}},(e,t,a)=>{var r=a(33),n=0,c=Math.random(),o=r(1..toString);e.exports=function(e){return"Symbol("+(void 0===e?"":e)+")_"+o(++n+c,36)}},(e,t,a)=>{var r=a(505),n=a(270),c=r("keys");e.exports=function(e){return c[e]||(c[e]=n(e))}},(e,t,a)=>{"use strict";var r=a(273),n=a(86),c=a(168),o=a(1105),d=a(29),s=a(1106),b=a(509),u=a(1113),h=a(278),l=a(104),g=a(277),p=a(51),B=a(126),x=a(506),I=o.PROPER,m=o.CONFIGURABLE,y=x.IteratorPrototype,C=x.BUGGY_SAFARI_ITERATORS,w=p("iterator"),v="keys",Q="values",k="entries",returnThis=function(){return this};e.exports=function(e,t,a,o,p,x,_){s(a,t,o);var N,D,G,getIterationMethod=function(e){if(e===p&&q)return q;if(!C&&e in U)return U[e];switch(e){case v:return function keys(){return new a(this,e)};case Q:return function values(){return new a(this,e)};case k:return function entries(){return new a(this,e)}}return function(){return new a(this)}},L=t+" Iterator",T=!1,U=e.prototype,P=U[w]||U["@@iterator"]||p&&U[p],q=!C&&P||getIterationMethod(p),H="Array"==t&&U.entries||P;if(H&&(N=b(H.call(new e)))!==Object.prototype&&N.next&&(c||b(N)===y||(u?u(N,y):d(N[w])||g(N,w,returnThis)),h(N,L,!0,!0),c&&(B[L]=returnThis)),I&&p==Q&&P&&P.name!==Q&&(!c&&m?l(U,"name",Q):(T=!0,q=function values(){return n(P,this)})),p)if(D={values:getIterationMethod(Q),keys:x?q:getIterationMethod(v),entries:getIterationMethod(k)},_)for(G in D)(C||T||!(G in U))&&g(U,G,D[G]);else r({target:t,proto:!0,forced:C||T},D);return c&&!_||U[w]===q||g(U,w,q,{name:p}),B[t]=q,D}},(e,t,a)=>{"use strict";var r=a(11),n=a(1103),c=a(33),o=a(29),d=a(1538).f,s=a(1104),b=a(264),u=a(171),h=a(104),l=a(68),wrapConstructor=function(e){var Wrapper=function(t,a,r){if(this instanceof Wrapper){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,a)}return new e(t,a,r)}return n(e,this,arguments)};return Wrapper.prototype=e.prototype,Wrapper};e.exports=function(e,t){var a,n,g,p,B,x,I,m,y=e.target,C=e.global,w=e.stat,v=e.proto,Q=C?r:w?r[y]:(r[y]||{}).prototype,k=C?b:b[y]||h(b,y,{})[y],_=k.prototype;for(g in t)a=!s(C?g:y+(w?".":"#")+g,e.forced)&&Q&&l(Q,g),B=k[g],a&&(x=e.noTargetGet?(m=d(Q,g))&&m.value:Q[g]),p=a&&x?x:t[g],a&&typeof B==typeof p||(I=e.bind&&a?u(p,r):e.wrap&&a?wrapConstructor(p):v&&o(p)?c(p):p,(e.sham||p&&p.sham||B&&B.sham)&&h(I,"sham",!0),h(k,g,I),v&&(l(b,n=y+"Prototype")||h(b,n,{}),h(b[n],g,p),e.real&&_&&!_[g]&&h(_,g,p)))}},(e,t,a)=>{var r,n=a(85),c=a(1540),o=a(276),d=a(170),s=a(1110),b=a(500),u=a(271),h=u("IE_PROTO"),EmptyConstructor=function(){},scriptTag=function(e){return"
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • default

Implements

  • Api

Indexable

[index: string]: (...args: any) => Promise<any>
    • (...args: any): Promise<any>
    • Parameters

      • Rest ...args: any

      Returns Promise<any>

Index

Constructors

Properties

Methods

Constructors

constructor

  • new default(options: EthereumInternalOptions, wallet: default, blockchain: default): default

Properties

Private Readonly #blockchain

#blockchain: default

Private Readonly #filters

#filters: Map<string, Filter> = ...

Private Readonly #getId

#getId: () => Quantity = ...

Type declaration

    • (): Quantity
    • Returns Quantity

Private Readonly #options

#options: EthereumInternalOptions

Private Readonly #subscriptions

#subscriptions: Map<string, UnsubscribeFn> = ...

Private Readonly #wallet

#wallet: default

Methods

bzz_hive

  • bzz_hive(): Promise<any[]>

Returns default

Properties

Private Readonly #blockchain

#blockchain: default

Private Readonly #filters

#filters: Map<string, InternalFilter> = ...

Private Readonly #getId

#getId: () => Quantity = ...

Type declaration

    • (): Quantity
    • Returns Quantity

Private Readonly #options

#options: EthereumInternalOptions

Private Readonly #subscriptions

#subscriptions: Map<string, UnsubscribeFn> = ...

Private Readonly #wallet

#wallet: default

Methods

bzz_hive

  • bzz_hive(): Promise<any[]>
  • Returns the kademlia table in a readable table format.

    example
    console.log(await provider.send("bzz_hive"));
     

    Returns Promise<any[]>

    Returns the kademlia table in a readable table format.

    -

bzz_info

  • bzz_info(): Promise<any[]>

bzz_info

  • bzz_info(): Promise<any[]>
  • Returns details about the swarm node.

    example
    console.log(await provider.send("bzz_info"));
     

    Returns Promise<any[]>

    Returns details about the swarm node.

    -

db_getHex

  • db_getHex(dbName: string, key: string): Promise<string>

db_getHex

  • db_getHex(dbName: string, key: string): Promise<string>
  • Returns binary data from the local database.

    example
    console.log(await provider.send("db_getHex", ["testDb", "testKey"] ));
     
    @@ -29,7 +29,7 @@
  • key: string

    Key name.

  • Returns Promise<string>

    The previously stored data.

    -

    db_getString

    • db_getString(dbName: string, key: string): Promise<string>

    db_getString

    • db_getString(dbName: string, key: string): Promise<string>
    • Returns string from the local database.

      example
      console.log(await provider.send("db_getString", ["testDb", "testKey"] ));
       
      @@ -38,7 +38,7 @@
  • key: string

    Key name.

  • Returns Promise<string>

    The previously stored string.

    -

    db_putHex

    • db_putHex(dbName: string, key: string, data: string): Promise<boolean>

    db_putHex

    • db_putHex(dbName: string, key: string, data: string): Promise<boolean>
    • Stores binary data in the local database.

      example
      console.log(await provider.send("db_putHex", ["testDb", "testKey", "0x0"] ));
       
      @@ -49,7 +49,7 @@
  • data: string

    Data to store.

  • Returns Promise<boolean>

    true if the value was stored, otherwise false.

    -

    db_putString

    • db_putString(dbName: string, key: string, value: string): Promise<boolean>

    db_putString

    • db_putString(dbName: string, key: string, value: string): Promise<boolean>
    • Stores a string in the local database.

      example
      console.log(await provider.send("db_putString", ["testDb", "testKey", "testValue"] ));
       
      @@ -60,7 +60,7 @@
    • value: string

      String to store.

    Returns Promise<boolean>

    returns true if the value was stored, otherwise false.

    -

    debug_storageRangeAt

    • debug_storageRangeAt(blockHash: string, transactionIndex: number, contractAddress: string, startKey: string, maxResult: number): Promise<StorageRangeResult>

    debug_storageRangeAt

    • debug_storageRangeAt(blockHash: string, transactionIndex: number, contractAddress: string, startKey: string, maxResult: number): Promise<StorageRangeAtResult>
    • Attempts to replay the transaction as it was executed on the network and return storage data given a starting key and max number of entries to return.

      example
      // Simple.sol
      // // SPDX-License-Identifier: MIT
      // pragma solidity ^0.7.4;
      //
      // contract Simple {
      // uint256 public value;
      // constructor() payable {
      // value = 5;
      // }
      // }
      const simpleSol = "0x6080604052600560008190555060858060196000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80633fa4f24514602d575b600080fd5b60336049565b6040518082815260200191505060405180910390f35b6000548156fea26469706673582212200897f7766689bf7a145227297912838b19bcad29039258a293be78e3bf58e20264736f6c63430007040033";
      const [from] = await provider.request({ method: "eth_accounts", params: [] });
      await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
      const initialTxHash = await provider.request({ method: "eth_sendTransaction", params: [{ from, gas: "0x5b8d80", data: simpleSol }] });
      await provider.once("message"); // Note: `await provider.once` is non-standard

      const {contractAddress} = await provider.request({ method: "eth_getTransactionReceipt", params: [initialTxHash] });

      // set value to 19
      const data = "0x552410770000000000000000000000000000000000000000000000000000000000000019";
      const txHash = await provider.request({ method: "eth_sendTransaction", params: [{ from, to: contractAddress, data }] });
      await provider.once("message"); // Note: `await provider.once` is non-standard

      const { blockHash, transactionIndex } = await provider.request({ method: "eth_getTransactionReceipt", params: [txHash] });
      const storage = await provider.request({ method: "debug_storageRangeAt", params: [blockHash, transactionIndex, contractAddress, "0x01", 1] });
      console.log(storage); @@ -75,10 +75,10 @@

      Hash of the start key for grabbing storage entries.

    • maxResult: number

      Integer of maximum number of storage entries to return.

      -

    Returns Promise<StorageRangeResult>

    Returns a storage object with the keys being keccak-256 hashes of the storage keys, +

    Returns Promise<StorageRangeAtResult>

    Returns a storage object with the keys being keccak-256 hashes of the storage keys, and the values being the raw, unhashed key and value for that specific storage slot. Also returns a next key which is the keccak-256 hash of the next key in storage for continuous downloading.

    -

    debug_traceTransaction

    • debug_traceTransaction(transactionHash: string, options?: TransactionTraceOptions): Promise<TraceTransactionResult>

    debug_traceTransaction

    • debug_traceTransaction(transactionHash: string, options?: TraceTransactionOptions): Promise<TraceTransactionResult>
    • Attempt to run the transaction in the exact same manner as it was executed on the network. It will replay any transaction that may have been executed prior to this one before it will finally attempt to execute the transaction @@ -95,7 +95,7 @@

      Parameters

      • transactionHash: string

        Hash of the transaction to trace.

        -
      • Optional options: TransactionTraceOptions
        +
      • Optional options: TraceTransactionOptions

        See options in source.

      Returns Promise<TraceTransactionResult>

      Returns the gas, structLogs, and returnValue for the traced transaction.

      The structLogs are an array of logs, which contains the following fields:

      @@ -110,17 +110,17 @@
    • stack: The EVM execution stack.
    • storage: An object containing the contract's storage data.
    -

    eth_accounts

    • eth_accounts(): Promise<string[]>

    eth_accounts

    • eth_accounts(): Promise<string[]>
    • Returns a list of addresses owned by client.

      example
      const accounts = await provider.request({ method: "eth_accounts", params: [] });
      console.log(accounts);

      Returns Promise<string[]>

      Array of 20 Bytes - addresses owned by the client.

      -

    eth_blockNumber

    • eth_blockNumber(): Promise<Quantity>

    eth_blockNumber

    • eth_blockNumber(): Promise<Quantity>
    • Returns the number of the most recent block.

      example
      const blockNumber = await provider.request({ method: "eth_blockNumber" });
      console.log(blockNumber);

      Returns Promise<Quantity>

      The current block number the client is on.

      -

    eth_call

    • eth_call(transaction: any, blockNumber?: string, overrides?: CallOverrides): Promise<Data>

    eth_call

    • eth_call(transaction: Transaction, blockNumber?: string, overrides?: CallOverrides): Promise<Data>
    • Executes a new message call immediately without creating a transaction on the block chain.

      Transaction call object:

        @@ -144,7 +144,7 @@
      example
      // Simple.sol
      // // SPDX-License-Identifier: MIT
      // pragma solidity ^0.7.4;
      //
      // contract Simple {
      // uint256 public value;
      // constructor() payable {
      // value = 5;
      // }
      // }
      const simpleSol = "0x6080604052600560008190555060858060196000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80633fa4f24514602d575b600080fd5b60336049565b6040518082815260200191505060405180910390f35b6000548156fea26469706673582212200897f7766689bf7a145227297912838b19bcad29039258a293be78e3bf58e20264736f6c63430007040033";
      const [from] = await provider.request({ method: "eth_accounts", params: [] });
      const txObj = { from, gas: "0x5b8d80", gasPrice: "0x1dfd14000", value:"0x0", data: simpleSol };
      const slot = "0x0000000000000000000000000000000000000000000000000000000000000005"
      const overrides = { [from]: { balance: "0x3e8", "nonce: "0x5", code: "0xbaddad42", stateDiff: { [slot]: "0xbaddad42"}}}
      const result = await provider.request({ method: "eth_call", params: [txObj, "latest", overrides] });
      console.log(result);
      -

      Parameters

      • transaction: any
        +

        Parameters

        • transaction: Transaction

          The transaction call object as seen in source.

        • blockNumber: string = Tag.latest

          Integer block number, or the string "latest", "earliest" @@ -152,19 +152,19 @@

        • overrides: CallOverrides = {}

          State overrides to apply during the simulation.

        Returns Promise<Data>

        The return value of executed contract.

        -

    eth_chainId

    • eth_chainId(): Promise<Quantity>

    eth_chainId

    • eth_chainId(): Promise<Quantity>
    • Returns the currently configured chain id, a value used in replay-protected transaction signing as introduced by EIP-155.

      eip

      155 – Simple replay attack protection

      example
      const chainId = await provider.send("eth_chainId");
      console.log(chainId);

      Returns Promise<Quantity>

      The chain id as a string.

      -

    eth_coinbase

    • eth_coinbase(): Promise<Address>

    eth_coinbase

    • eth_coinbase(): Promise<Address>
    • Returns the client coinbase address.

      example
      const coinbaseAddress = await provider.request({ method: "eth_coinbase" });
      console.log(coinbaseAddress);

      Returns Promise<Address>

      The current coinbase address.

      -

    eth_estimateGas

    • eth_estimateGas(transaction: TypedRpcTransaction, blockNumber?: string): Promise<Quantity>

    eth_estimateGas

    • eth_estimateGas(transaction: Transaction, blockNumber?: string): Promise<Quantity>
    • Generates and returns an estimate of how much gas is necessary to allow the transaction to complete. The transaction will not be added to the blockchain. Note that the estimate may be significantly more than the @@ -181,18 +181,18 @@

    example
    const [from, to] = await provider.request({ method: "eth_accounts", params: [] });
    const gasEstimate = await provider.request({ method: "eth_estimateGas", params: [{ from, to }, "latest" ] });
    console.log(gasEstimate);
    -

    Parameters

    • transaction: TypedRpcTransaction
      +

      Parameters

      • transaction: Transaction

        The transaction call object as seen in source.

      • blockNumber: string = Tag.latest

        Integer block number, or the string "latest", "earliest" or "pending".

      Returns Promise<Quantity>

      The amount of gas used.

      -

    eth_gasPrice

    • eth_gasPrice(): Promise<Quantity>

    eth_gasPrice

    • eth_gasPrice(): Promise<Quantity>
    • Returns the current price per gas in wei.

      example
      const gasPrice = await provider.request({ method: "eth_gasPrice", params: [] });
      console.log(gasPrice);

      Returns Promise<Quantity>

      Integer of the current gas price in wei.

      -

    eth_getBalance

    • eth_getBalance(address: string, blockNumber?: string): Promise<Quantity>

    eth_getBalance

    • eth_getBalance(address: string, blockNumber?: string): Promise<Quantity>
    • Returns the balance of the account of given address.

      example
      const accounts = await provider.request({ method: "eth_accounts", params: [] });
      const balance = await provider.request({ method: "eth_getBalance", params: [accounts[0], "latest"] });
      console.log(balance);
      @@ -202,16 +202,16 @@

      Integer block number, or the string "latest", "earliest" or "pending".

    Returns Promise<Quantity>

    Integer of the account balance in wei.

    -

    eth_getBlockByHash

    • eth_getBlockByHash(hash: string, transactions?: boolean): Promise<{ baseFeePerGas?: Quantity; difficulty: Quantity; extraData: Data; gasLimit: Quantity; gasUsed: Quantity; hash: Data; logsBloom: Data; miner: Data; mixHash: Data; nonce: Data; number: Quantity; parentHash: Data; receiptsRoot: Data; sha3Uncles: Data; size: Quantity; stateRoot: Data; timestamp: Quantity; totalDifficulty: Quantity; transactions: (Data | LegacyTransactionJSON | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON)[]; transactionsRoot: Data; uncles: string[] }>

    eth_getBlockByHash

    • eth_getBlockByHash<IncludeTransactions>(hash: string, transactions?: IncludeTransactions): Promise<{ hash: Data; size: Quantity; transactions: IncludeTransactions extends true ? (LegacyTransactionJSON | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON | Transaction<"private">)[] : Data[]; uncles: Data[] } & BlockHeader>
    • Returns information about a block by block hash.

      example
      // Simple.sol
      // // SPDX-License-Identifier: MIT
      // pragma solidity ^0.7.4;
      //
      // contract Simple {
      // uint256 public value;
      // constructor() payable {
      // value = 5;
      // }
      // }
      const simpleSol = "0x6080604052600560008190555060858060196000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80633fa4f24514602d575b600080fd5b60336049565b6040518082815260200191505060405180910390f35b6000548156fea26469706673582212200897f7766689bf7a145227297912838b19bcad29039258a293be78e3bf58e20264736f6c63430007040033";
      const [from] = await provider.request({ method: "eth_accounts", params: [] });
      await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
      const txHash = await provider.request({ method: "eth_sendTransaction", params: [{ from, gas: "0x5b8d80", data: simpleSol }] });
      await provider.once("message"); // Note: `await provider.once` is non-standard
      const txReceipt = await provider.request({ method: "eth_getTransactionReceipt", params: [txHash] });
      const block = await provider.request({ method: "eth_getBlockByHash", params: [txReceipt.blockHash, true] });
      console.log(block);
      -

      Parameters

      • hash: string
        +

        Type parameters

        • IncludeTransactions: boolean = false

        Parameters

        • hash: string

          Hash of a block.

          -
        • transactions: boolean = false
          +
        • Optional transactions: IncludeTransactions

          If true it returns the full transaction objects, if false only the hashes of the transactions.

          -

        Returns Promise<{ baseFeePerGas?: Quantity; difficulty: Quantity; extraData: Data; gasLimit: Quantity; gasUsed: Quantity; hash: Data; logsBloom: Data; miner: Data; mixHash: Data; nonce: Data; number: Quantity; parentHash: Data; receiptsRoot: Data; sha3Uncles: Data; size: Quantity; stateRoot: Data; timestamp: Quantity; totalDifficulty: Quantity; transactions: (Data | LegacyTransactionJSON | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON)[]; transactionsRoot: Data; uncles: string[] }>

        The block, null if the block doesn't exist.

        +

      Returns Promise<{ hash: Data; size: Quantity; transactions: IncludeTransactions extends true ? (LegacyTransactionJSON | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON | Transaction<"private">)[] : Data[]; uncles: Data[] } & BlockHeader>

      The block, null if the block doesn't exist.

      • hash: DATA, 32 Bytes - Hash of the block. null when pending.
      • parentHash: DATA, 32 Bytes - Hash of the parent block.
      • @@ -234,17 +234,17 @@
      • transactions: Array - Array of transaction objects or 32 Bytes transaction hashes depending on the last parameter.
      • uncles: Array - Array of uncle hashes.
      -

    eth_getBlockByNumber

    • eth_getBlockByNumber(number: string, transactions?: boolean): Promise<{ baseFeePerGas?: Quantity; difficulty: Quantity; extraData: Data; gasLimit: Quantity; gasUsed: Quantity; hash: Data; logsBloom: Data; miner: Data; mixHash: Data; nonce: Data; number: Quantity; parentHash: Data; receiptsRoot: Data; sha3Uncles: Data; size: Quantity; stateRoot: Data; timestamp: Quantity; totalDifficulty: Quantity; transactions: (Data | LegacyTransactionJSON | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON)[]; transactionsRoot: Data; uncles: string[] }>

    eth_getBlockByNumber

    • eth_getBlockByNumber<IncludeTransactions>(number: string, transactions?: IncludeTransactions): Promise<{ hash: Data; size: Quantity; transactions: IncludeTransactions extends true ? (LegacyTransactionJSON | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON | Transaction<"private">)[] : Data[]; uncles: Data[] } & BlockHeader>
    • Returns information about a block by block number.

      example
      const block = await provider.request({ method: "eth_getBlockByNumber", params: ["0x0", false] });
      console.log(block);
      -

      Parameters

      • number: string
        +

        Type parameters

        • IncludeTransactions: boolean = false

        Parameters

        • number: string

          Integer of a block number, or the string "earliest", "latest" or "pending", as in the default block parameter.

          -
        • transactions: boolean = false
          +
        • Optional transactions: IncludeTransactions

          If true it returns the full transaction objects, if false only the hashes of the transactions.

          -

        Returns Promise<{ baseFeePerGas?: Quantity; difficulty: Quantity; extraData: Data; gasLimit: Quantity; gasUsed: Quantity; hash: Data; logsBloom: Data; miner: Data; mixHash: Data; nonce: Data; number: Quantity; parentHash: Data; receiptsRoot: Data; sha3Uncles: Data; size: Quantity; stateRoot: Data; timestamp: Quantity; totalDifficulty: Quantity; transactions: (Data | LegacyTransactionJSON | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON)[]; transactionsRoot: Data; uncles: string[] }>

        The block, null if the block doesn't exist.

        +

      Returns Promise<{ hash: Data; size: Quantity; transactions: IncludeTransactions extends true ? (LegacyTransactionJSON | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON | Transaction<"private">)[] : Data[]; uncles: Data[] } & BlockHeader>

      The block, null if the block doesn't exist.

      • hash: DATA, 32 Bytes - Hash of the block. null when pending.
      • parentHash: DATA, 32 Bytes - Hash of the parent block.
      • @@ -267,19 +267,19 @@
      • transactions: Array - Array of transaction objects or 32 Bytes transaction hashes depending on the last parameter.
      • uncles: Array - Array of uncle hashes.
      -

    eth_getBlockTransactionCountByHash

    • eth_getBlockTransactionCountByHash(hash: string): Promise<Quantity>

    eth_getBlockTransactionCountByHash

    • eth_getBlockTransactionCountByHash(hash: string): Promise<Quantity>
    • Returns the number of transactions in a block from a block matching the given block hash.

      example
      // Simple.sol
      // // SPDX-License-Identifier: MIT
      // pragma solidity ^0.7.4;
      //
      // contract Simple {
      // uint256 public value;
      // constructor() payable {
      // value = 5;
      // }
      // }
      const simpleSol = "0x6080604052600560008190555060858060196000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80633fa4f24514602d575b600080fd5b60336049565b6040518082815260200191505060405180910390f35b6000548156fea26469706673582212200897f7766689bf7a145227297912838b19bcad29039258a293be78e3bf58e20264736f6c63430007040033";
      const [from] = await provider.request({ method: "eth_accounts", params: [] });
      await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
      const txHash = await provider.request({ method: "eth_sendTransaction", params: [{ from, gas: "0x5b8d80", data: simpleSol }] });
      await provider.once("message"); // Note: `await provider.once` is non-standard
      const txReceipt = await provider.request({ method: "eth_getTransactionReceipt", params: [txHash] });
      const txCount = await provider.request({ method: "eth_getBlockTransactionCountByHash", params: [txReceipt.blockHash] });
      console.log(txCount);

      Parameters

      • hash: string

        Hash of a block.

      Returns Promise<Quantity>

      Number of transactions in the block.

      -

    eth_getBlockTransactionCountByNumber

    • eth_getBlockTransactionCountByNumber(blockNumber: string): Promise<Quantity>

    eth_getBlockTransactionCountByNumber

    • eth_getBlockTransactionCountByNumber(blockNumber: string): Promise<Quantity>
    • Returns the number of transactions in a block from a block matching the given block number.

      example
      const txCount = await provider.request({ method: "eth_getBlockTransactionCountByNumber", params: ["0x0"] });
      console.log(txCount);

      Parameters

      • blockNumber: string

      Returns Promise<Quantity>

      Integer of the number of transactions in the block.

      -

    eth_getCode

    • eth_getCode(address: string, blockNumber?: string): Promise<Data>

    eth_getCode

    • eth_getCode(address: string, blockNumber?: string): Promise<Data>
    • Returns code at a given address.

      example
      // Simple.sol
      // // SPDX-License-Identifier: MIT
      // pragma solidity ^0.7.4;
      //
      // contract Simple {
      // uint256 public value;
      // constructor() payable {
      // value = 5;
      // }
      // }
      const simpleSol = "0x6080604052600560008190555060858060196000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80633fa4f24514602d575b600080fd5b60336049565b6040518082815260200191505060405180910390f35b6000548156fea26469706673582212200897f7766689bf7a145227297912838b19bcad29039258a293be78e3bf58e20264736f6c63430007040033";
      const [from] = await provider.request({ method: "eth_accounts", params: [] });
      await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
      const txHash = await provider.request({ method: "eth_sendTransaction", params: [{ from, gas: "0x5b8d80", data: simpleSol }] });
      await provider.once("message"); // Note: `await provider.once` is non-standard
      const txReceipt = await provider.request({ method: "eth_getTransactionReceipt", params: [txHash] });
      const code = await provider.request({ method: "eth_getCode", params: [txReceipt.contractAddress, "latest"] });
      console.log(code);
      @@ -288,12 +288,12 @@
    • blockNumber: string = Tag.latest

      Integer block number, or the string "latest", "earliest" or "pending".

    Returns Promise<Data>

    The code from the given address.

    -

    eth_getCompilers

    • eth_getCompilers(): Promise<string[]>

    eth_getCompilers

    • eth_getCompilers(): Promise<string[]>
    • Returns a list of available compilers.

      example
      const compilers = await provider.send("eth_getCompilers");
      console.log(compilers);

      Returns Promise<string[]>

      List of available compilers.

      -

    eth_getFilterChanges

    • eth_getFilterChanges(filterId: string): Promise<Data[]>

    eth_getFilterChanges

    • eth_getFilterChanges(filterId: string): Promise<Data[]>
    • Polling method for a filter, which returns an array of logs, block hashes, or transaction hashes, depending on the filter type, which occurred since last poll.

      @@ -317,14 +317,14 @@
    • data: DATA - Contains one or more 32 Bytes non-indexed arguments of the log.
    • topics: Array of DATA - Array of 0 to 4 32 Bytes DATA of indexed log arguments.
    -

    eth_getFilterLogs

    • eth_getFilterLogs(filterId: string): Promise<{ address: Address; blockHash: Data; blockNumber: Quantity; data: Data | Data[]; logIndex: Quantity; removed: boolean; topics: Data | Data[]; transactionHash: Data; transactionIndex: Quantity }[]>

    eth_getFilterLogs

    • eth_getFilterLogs(filterId: string): Promise<Logs>
    • Returns an array of all logs matching filter with given id.

      example
      // Logs.sol
      // // SPDX-License-Identifier: MIT
      // pragma solidity ^0.7.4;
      // contract Logs {
      // event Event(uint256 indexed first, uint256 indexed second);
      // constructor() {
      // emit Event(1, 2);
      // }
      //
      // function logNTimes(uint8 n) public {
      // for (uint8 i = 0; i < n; i++) {
      // emit Event(i, i);
      // }
      // }
      // }

      const logsContract = "0x608060405234801561001057600080fd5b50600260017f34e802e5ebd1f132e05852c5064046c1b535831ec52f1c4997fc6fdc4d5345b360405160405180910390a360e58061004f6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80635e19e69f14602d575b600080fd5b605960048036036020811015604157600080fd5b81019080803560ff169060200190929190505050605b565b005b60005b8160ff168160ff16101560ab578060ff168160ff167f34e802e5ebd1f132e05852c5064046c1b535831ec52f1c4997fc6fdc4d5345b360405160405180910390a38080600101915050605e565b505056fea26469706673582212201af9c13c7b00e2b628c1258d45f9f62d2aad8cd32fc32fd9515d8ad1e792679064736f6c63430007040033";
      const [from] = await provider.send("eth_accounts");
      const filterId = await provider.send("eth_newFilter");

      await provider.send("eth_subscribe", ["newHeads"]);
      await provider.send("eth_sendTransaction", [{ from, data: logsContract, gas: "0x5b8d80" }] );
      await provider.once("message");

      const logs = await provider.request({ method: "eth_getFilterLogs", params: [filterId] });
      console.log(logs);

      Parameters

      • filterId: string

        The filter id.

        -

      Returns Promise<{ address: Address; blockHash: Data; blockNumber: Quantity; data: Data | Data[]; logIndex: Quantity; removed: boolean; topics: Data | Data[]; transactionHash: Data; transactionIndex: Quantity }[]>

      Array of log objects, or an empty array.

      -

    eth_getLogs

    • eth_getLogs(filter: FilterArgs): Promise<{ address: Address; blockHash: Data; blockNumber: Quantity; data: Data | Data[]; logIndex: Quantity; removed: boolean; topics: Data | Data[]; transactionHash: Data; transactionIndex: Quantity }[]>

    Returns Promise<Logs>

    Array of log objects, or an empty array.

    +

    eth_getLogs

    • eth_getLogs(filter: FilterArgs): Promise<Logs>
    • Returns an array of all logs matching a given filter object.

      Filter options:

        @@ -333,7 +333,7 @@
      • toBlock: QUANTITY | TAG (optional) - Integer block number, or the string "latest", "earliest" or "pending".
      • address: DATA | Array (optional) - Contract address or a list of addresses from which the logs should originate.
      • -
      • topics: Array of DATA (optional) - Array of 32 Bytes DATA topcis. Topics are order-dependent. Each topic can also +
      • topics: Array of DATA (optional) - Array of 32 Bytes DATA topics. Topics are order-dependent. Each topic can also be an array of DATA with "or" options.
      • blockHash: DATA, 32 Bytes (optional) - Hash of the block to restrict logs from. If blockHash is present, then neither fromBlock or toBlock are allowed.
      • @@ -342,8 +342,8 @@

      Parameters

      • filter: FilterArgs

        The filter options as seen in source.

        -

      Returns Promise<{ address: Address; blockHash: Data; blockNumber: Quantity; data: Data | Data[]; logIndex: Quantity; removed: boolean; topics: Data | Data[]; transactionHash: Data; transactionIndex: Quantity }[]>

      Array of log objects, or an empty array.

      -

    eth_getStorageAt

    • eth_getStorageAt(address: string, position: string, blockNumber?: string): Promise<Data>

    Returns Promise<Logs>

    Array of log objects, or an empty array.

    +

    eth_getStorageAt

    • eth_getStorageAt(address: string, position: string, blockNumber?: string): Promise<Data>
    • Returns the value from a storage position at a given address.

      example
      // Simple.sol
      // // SPDX-License-Identifier: MIT
      // pragma solidity ^0.7.4;
      //
      // contract Simple {
      // uint256 public value;
      // constructor() payable {
      // value = 5;
      // }
      // }
      const simpleSol = "0x6080604052600560008190555060858060196000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80633fa4f24514602d575b600080fd5b60336049565b6040518082815260200191505060405180910390f35b6000548156fea26469706673582212200897f7766689bf7a145227297912838b19bcad29039258a293be78e3bf58e20264736f6c63430007040033";
      const [from] = await provider.request({ method: "eth_accounts", params: [] });
      await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
      const txHash = await provider.request({ method: "eth_sendTransaction", params: [{ from, gas: "0x5b8d80", data: simpleSol }] });
      await provider.once("message"); // Note: `await provider.once` is non-standard
      const txReceipt = await provider.request({ method: "eth_getTransactionReceipt", params: [txHash] });
      const storageValue = await provider.request({ method: "eth_getStorageAt", params: [txReceipt.contractAddress, "0x0", "latest"] });
      console.log(storageValue);
      @@ -355,7 +355,7 @@

      Integer block number, or the string "latest", "earliest" or "pending".

    Returns Promise<Data>

    The value in storage at the requested position.

    -

    eth_getTransactionByBlockHashAndIndex

    • eth_getTransactionByBlockHashAndIndex(hash: string, index: string): Promise<LegacyTransactionJSON>

    eth_getTransactionByBlockHashAndIndex

    • eth_getTransactionByBlockHashAndIndex(hash: string, index: string): Promise<LegacyTransactionJSON | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON>
    • Returns information about a transaction by block hash and transaction index position.

      example
      const [from, to] = await provider.request({ method: "eth_accounts", params: [] });
      await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
      const txHash = await provider.request({ method: "eth_sendTransaction", params: [{ from, to, gas: "0x5b8d80" }] });
      await provider.once("message"); // Note: `await provider.once` is non-standard
      const { blockHash, transactionIndex } = await provider.request({ method: "eth_getTransactionReceipt", params: [txHash] });

      const tx = await provider.request({ method: "eth_getTransactionByBlockHashAndIndex", params: [ blockHash, transactionIndex ] });
      console.log(tx);
      @@ -363,7 +363,7 @@

      Hash of a block.

    • index: string

      Integer of the transaction index position.

      -

    Returns Promise<LegacyTransactionJSON>

    The transaction object or null if no transaction was found.

    +

    Returns Promise<LegacyTransactionJSON | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON>

    The transaction object or null if no transaction was found.

    • hash: DATA, 32 Bytes - The transaction hash.
    • nonce: QUANTITY - The number of transactions made by the sender prior to this one.
    • @@ -380,7 +380,7 @@
    • r: DATA, 32 Bytes - ECDSA signature r.
    • s: DATA, 32 Bytes - ECDSA signature s.
    -

    eth_getTransactionByBlockNumberAndIndex

    • eth_getTransactionByBlockNumberAndIndex(number: string, index: string): Promise<LegacyTransactionJSON>

    eth_getTransactionByBlockNumberAndIndex

    • eth_getTransactionByBlockNumberAndIndex(number: string, index: string): Promise<LegacyTransactionJSON | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON>
    • Returns information about a transaction by block number and transaction index position.

      example
      const [from, to] = await provider.request({ method: "eth_accounts", params: [] });
      await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
      const txHash = await provider.request({ method: "eth_sendTransaction", params: [{ from, to, gas: "0x5b8d80" }] });
      await provider.once("message"); // Note: `await provider.once` is non-standard
      const { transactionIndex } = await provider.request({ method: "eth_getTransactionReceipt", params: [txHash] });

      const tx = await provider.request({ method: "eth_getTransactionByBlockNumberAndIndex", params: [ "latest", transactionIndex ] });
      console.log(tx);
      @@ -388,7 +388,7 @@

      A block number, or the string "earliest", "latest" or "pending".

    • index: string

      Integer of the transaction index position.

      -

    Returns Promise<LegacyTransactionJSON>

    The transaction object or null if no transaction was found.

    +

    Returns Promise<LegacyTransactionJSON | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON>

    The transaction object or null if no transaction was found.

    • hash: DATA, 32 Bytes - The transaction hash.
    • nonce: QUANTITY - The number of transactions made by the sender prior to this one.
    • @@ -405,13 +405,13 @@
    • r: DATA, 32 Bytes - ECDSA signature r.
    • s: DATA, 32 Bytes - ECDSA signature s.
    -

    eth_getTransactionByHash

    • eth_getTransactionByHash(transactionHash: string): Promise<LegacyTransactionJSON>

    eth_getTransactionByHash

    • eth_getTransactionByHash(transactionHash: string): Promise<LegacyTransactionJSON | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON | Transaction<"private">>
    • Returns the information about a transaction requested by transaction hash.

      example
      const [from, to] = await provider.request({ method: "eth_accounts", params: [] });
      await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
      const txHash = await provider.request({ method: "eth_sendTransaction", params: [{ from, to, gas: "0x5b8d80" }] });
      await provider.once("message"); // Note: `await provider.once` is non-standard

      const tx = await provider.request({ method: "eth_getTransactionByHash", params: [ txHash ] });
      console.log(tx);

      Parameters

      • transactionHash: string

        Hash of a transaction.

        -

      Returns Promise<LegacyTransactionJSON>

      The transaction object or null if no transaction was found.

      +

    Returns Promise<LegacyTransactionJSON | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON | Transaction<"private">>

    The transaction object or null if no transaction was found.

    • hash: DATA, 32 Bytes - The transaction hash.
    • nonce: QUANTITY - The number of transactions made by the sender prior to this one.
    • @@ -428,7 +428,7 @@
    • r: DATA, 32 Bytes - ECDSA signature r.
    • s: DATA, 32 Bytes - ECDSA signature s.
    -

    eth_getTransactionCount

    • eth_getTransactionCount(address: string, blockNumber?: string): Promise<Quantity>

    eth_getTransactionCount

    • eth_getTransactionCount(address: string, blockNumber?: string): Promise<Quantity>
    • Returns the number of transactions sent from an address.

      example
      const [from, to] = await provider.request({ method: "eth_accounts", params: [] });
      await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
      await provider.request({ method: "eth_sendTransaction", params: [{ from, to, gas: "0x5b8d80" }] });
      await provider.once("message"); // Note: `await provider.once` is non-standard

      const txCount = await provider.request({ method: "eth_getTransactionCount", params: [ from, "latest" ] });
      console.log(txCount);
      @@ -438,15 +438,15 @@

      Integer block number, or the string "latest", "earliest" or "pending".

    Returns Promise<Quantity>

    Number of transactions sent from this address.

    -

    eth_getTransactionReceipt

    • eth_getTransactionReceipt(transactionHash: string): Promise<TransactionReceiptJSON>

    eth_getTransactionReceipt

    • eth_getTransactionReceipt(transactionHash: string): Promise<TransactionReceipt>
    • Returns the receipt of a transaction by transaction hash.

      Note: The receipt is not available for pending transactions.

      example
      const [from, to] = await provider.request({ method: "eth_accounts", params: [] });
      await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
      const txHash = await provider.request({ method: "eth_sendTransaction", params: [{ from, to, gas: "0x5b8d80" }] });
      await provider.once("message"); // Note: `await provider.once` is non-standard

      const txReceipt = await provider.request({ method: "eth_getTransactionReceipt", params: [ txHash ] });
      console.log(txReceipt);

      Parameters

      • transactionHash: string

        Hash of a transaction.

        -

      Returns Promise<TransactionReceiptJSON>

      Returns the receipt of a transaction by transaction hash.

      -

    eth_getUncleByBlockHashAndIndex

    • eth_getUncleByBlockHashAndIndex(hash: string, index: string): Promise<{ baseFeePerGas?: Quantity; difficulty: Quantity; extraData: Data; gasLimit: Quantity; gasUsed: Quantity; hash: Data; logsBloom: Data; miner: Data; mixHash: Data; nonce: Data; number: Quantity; parentHash: Data; receiptsRoot: Data; sha3Uncles: Data; size: Quantity; stateRoot: Data; timestamp: Quantity; totalDifficulty: Quantity; transactions: (Data | LegacyTransactionJSON | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON)[]; transactionsRoot: Data; uncles: string[] }>

    Returns Promise<TransactionReceipt>

    Returns the receipt of a transaction by transaction hash.

    +

    eth_getUncleByBlockHashAndIndex

    • eth_getUncleByBlockHashAndIndex(hash: string, index: string): Promise<Omit<{ baseFeePerGas?: string; difficulty: string; extraData: string; gasLimit: string; gasUsed: string; hash: string; logsBloom: string; miner: string; mixHash: string; nonce: string; number: string; parentHash: string; receiptsRoot: string; sha3Uncles: string; size: string; stateRoot: string; timestamp: string; totalDifficulty: string; transactions: ({ hash: string; type?: string; nonce: string; blockHash: string; blockNumber: string; transactionIndex: string; from: string; to: string; value: string; gas: string; gasPrice: string; input: string; v: string; r: string; s: string; } | { hash: string; type: string; chainId: string; nonce: string; blockHash: string; blockNumber: string; transactionIndex: string; from: string; to: string; value: string; gas: string; gasPrice: string; input: string; accessList: { address: string; storageKeys: string[]; }[]; v: string; r: string; s: string; } | { hash: string; type: string; chainId: string; nonce: string; blockHash: string; blockNumber: string; transactionIndex: string; from: string; to: string; value: string; maxPriorityFeePerGas: string; maxFeePerGas: string; gasPrice: string; gas: string; input: string; accessList: { address: string; storageKeys: string[]; }[]; v: string; r: string; s: string; } | { type?: string; from: string; nonce: string; gas: string; to: string; value: string; input: string; v: string; r: string; s: string; gasPrice: string; blockNumber: null; blockHash: null; transactionIndex: null; hash: string; })[]; transactionsRoot: string; uncles: string[] }, "transactions">>
    • Returns information about a uncle of a block by hash and uncle index position.

      example
      const blockHash = await provider.send("eth_getBlockByNumber", ["latest"] );
      const block = await provider.send("eth_getUncleByBlockHashAndIndex", [blockHash, "0x0"] );
      console.log(block);
      @@ -454,7 +454,7 @@

      Hash of a block.

    • index: string

      The uncle's index position.

      -

    Returns Promise<{ baseFeePerGas?: Quantity; difficulty: Quantity; extraData: Data; gasLimit: Quantity; gasUsed: Quantity; hash: Data; logsBloom: Data; miner: Data; mixHash: Data; nonce: Data; number: Quantity; parentHash: Data; receiptsRoot: Data; sha3Uncles: Data; size: Quantity; stateRoot: Data; timestamp: Quantity; totalDifficulty: Quantity; transactions: (Data | LegacyTransactionJSON | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON)[]; transactionsRoot: Data; uncles: string[] }>

    A block object or null when no block is found.

    +

    Returns Promise<Omit<{ baseFeePerGas?: string; difficulty: string; extraData: string; gasLimit: string; gasUsed: string; hash: string; logsBloom: string; miner: string; mixHash: string; nonce: string; number: string; parentHash: string; receiptsRoot: string; sha3Uncles: string; size: string; stateRoot: string; timestamp: string; totalDifficulty: string; transactions: ({ hash: string; type?: string; nonce: string; blockHash: string; blockNumber: string; transactionIndex: string; from: string; to: string; value: string; gas: string; gasPrice: string; input: string; v: string; r: string; s: string; } | { hash: string; type: string; chainId: string; nonce: string; blockHash: string; blockNumber: string; transactionIndex: string; from: string; to: string; value: string; gas: string; gasPrice: string; input: string; accessList: { address: string; storageKeys: string[]; }[]; v: string; r: string; s: string; } | { hash: string; type: string; chainId: string; nonce: string; blockHash: string; blockNumber: string; transactionIndex: string; from: string; to: string; value: string; maxPriorityFeePerGas: string; maxFeePerGas: string; gasPrice: string; gas: string; input: string; accessList: { address: string; storageKeys: string[]; }[]; v: string; r: string; s: string; } | { type?: string; from: string; nonce: string; gas: string; to: string; value: string; input: string; v: string; r: string; s: string; gasPrice: string; blockNumber: null; blockHash: null; transactionIndex: null; hash: string; })[]; transactionsRoot: string; uncles: string[] }, "transactions">>

    A block object or null when no block is found.

    • hash: DATA, 32 Bytes - Hash of the block. null when pending.
    • parentHash: DATA, 32 Bytes - Hash of the parent block.
    • @@ -474,10 +474,11 @@
    • nonce: DATA, 8 Bytes - Hash of the generated proof-of-work. null when pending.
    • totalDifficulty: QUANTITY - Integer of the total difficulty of the chain until this block.
    • size: QUANTITY - Integer the size of the block in bytes.
    • -
    • transactions: Array - Array of transaction objects or 32 Bytes transaction hashes depending on the last parameter.
    • uncles: Array - Array of uncle hashes.
    -

    eth_getUncleByBlockNumberAndIndex

    • eth_getUncleByBlockNumberAndIndex(blockNumber: string, uncleIndex: string): Promise<{ baseFeePerGas?: Quantity; difficulty: Quantity; extraData: Data; gasLimit: Quantity; gasUsed: Quantity; hash: Data; logsBloom: Data; miner: Data; mixHash: Data; nonce: Data; number: Quantity; parentHash: Data; receiptsRoot: Data; sha3Uncles: Data; size: Quantity; stateRoot: Data; timestamp: Quantity; totalDifficulty: Quantity; transactions: (Data | LegacyTransactionJSON | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON)[]; transactionsRoot: Data; uncles: string[] }>
    • +

      **NOTE: **The return does not contain a list of transactions in the uncle +block, to get this, make another request to eth_getBlockByHash.

      +

    eth_getUncleByBlockNumberAndIndex

    • eth_getUncleByBlockNumberAndIndex(blockNumber: string, uncleIndex: string): Promise<Omit<{ baseFeePerGas?: string; difficulty: string; extraData: string; gasLimit: string; gasUsed: string; hash: string; logsBloom: string; miner: string; mixHash: string; nonce: string; number: string; parentHash: string; receiptsRoot: string; sha3Uncles: string; size: string; stateRoot: string; timestamp: string; totalDifficulty: string; transactions: ({ hash: string; type?: string; nonce: string; blockHash: string; blockNumber: string; transactionIndex: string; from: string; to: string; value: string; gas: string; gasPrice: string; input: string; v: string; r: string; s: string; } | { hash: string; type: string; chainId: string; nonce: string; blockHash: string; blockNumber: string; transactionIndex: string; from: string; to: string; value: string; gas: string; gasPrice: string; input: string; accessList: { address: string; storageKeys: string[]; }[]; v: string; r: string; s: string; } | { hash: string; type: string; chainId: string; nonce: string; blockHash: string; blockNumber: string; transactionIndex: string; from: string; to: string; value: string; maxPriorityFeePerGas: string; maxFeePerGas: string; gasPrice: string; gas: string; input: string; accessList: { address: string; storageKeys: string[]; }[]; v: string; r: string; s: string; } | { type?: string; from: string; nonce: string; gas: string; to: string; value: string; input: string; v: string; r: string; s: string; gasPrice: string; blockNumber: null; blockHash: null; transactionIndex: null; hash: string; })[]; transactionsRoot: string; uncles: string[] }, "transactions">>
    • Returns information about a uncle of a block by hash and uncle index position.

      example
      const block = await provider.send("eth_getUncleByBlockNumberAndIndex", ["latest", "0x0"] );
      console.log(block);
      @@ -485,44 +486,65 @@

      A block number, or the string "earliest", "latest" or "pending".

    • uncleIndex: string

      The uncle's index position.

      -

    Returns Promise<{ baseFeePerGas?: Quantity; difficulty: Quantity; extraData: Data; gasLimit: Quantity; gasUsed: Quantity; hash: Data; logsBloom: Data; miner: Data; mixHash: Data; nonce: Data; number: Quantity; parentHash: Data; receiptsRoot: Data; sha3Uncles: Data; size: Quantity; stateRoot: Data; timestamp: Quantity; totalDifficulty: Quantity; transactions: (Data | LegacyTransactionJSON | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON)[]; transactionsRoot: Data; uncles: string[] }>

    A block object or null when no block is found.

    +

    Returns Promise<Omit<{ baseFeePerGas?: string; difficulty: string; extraData: string; gasLimit: string; gasUsed: string; hash: string; logsBloom: string; miner: string; mixHash: string; nonce: string; number: string; parentHash: string; receiptsRoot: string; sha3Uncles: string; size: string; stateRoot: string; timestamp: string; totalDifficulty: string; transactions: ({ hash: string; type?: string; nonce: string; blockHash: string; blockNumber: string; transactionIndex: string; from: string; to: string; value: string; gas: string; gasPrice: string; input: string; v: string; r: string; s: string; } | { hash: string; type: string; chainId: string; nonce: string; blockHash: string; blockNumber: string; transactionIndex: string; from: string; to: string; value: string; gas: string; gasPrice: string; input: string; accessList: { address: string; storageKeys: string[]; }[]; v: string; r: string; s: string; } | { hash: string; type: string; chainId: string; nonce: string; blockHash: string; blockNumber: string; transactionIndex: string; from: string; to: string; value: string; maxPriorityFeePerGas: string; maxFeePerGas: string; gasPrice: string; gas: string; input: string; accessList: { address: string; storageKeys: string[]; }[]; v: string; r: string; s: string; } | { type?: string; from: string; nonce: string; gas: string; to: string; value: string; input: string; v: string; r: string; s: string; gasPrice: string; blockNumber: null; blockHash: null; transactionIndex: null; hash: string; })[]; transactionsRoot: string; uncles: string[] }, "transactions">>

    A block object or null when no block is found.

      -
    • hash: DATA, 32 Bytes - Hash of the block. null when pending.
    • -
    • parentHash: DATA, 32 Bytes - Hash of the parent block.
    • -
    • sha3Uncles: DATA, 32 Bytes - SHA3 of the uncles data in the block.
    • -
    • miner: DATA, 20 Bytes - Address of the miner.
    • -
    • stateRoot: DATA, 32 Bytes - The root of the state trie of the block.
    • -
    • transactionsRoot: DATA, 32 Bytes - The root of the transaction trie of the block.
    • -
    • receiptsRoot: DATA, 32 Bytes - The root of the receipts trie of the block.
    • -
    • logsBloom: DATA, 256 Bytes - The bloom filter for the logs of the block. null when pending.
    • -
    • difficulty: QUANTITY - Integer of the difficulty of this block.
    • -
    • number: QUANTITY - The block number. null when pending.
    • -
    • gasLimit: QUANTITY - The maximum gas allowed in the block.
    • -
    • gasUsed: QUANTITY - Total gas used by all transactions in the block.
    • -
    • timestamp: QUANTITY - The unix timestamp for when the block was collated.
    • -
    • extraData: DATA - Extra data for the block.
    • -
    • mixHash: DATA, 256 Bytes - Hash identifier for the block.
    • -
    • nonce: DATA, 8 Bytes - Hash of the generated proof-of-work. null when pending.
    • -
    • totalDifficulty: QUANTITY - Integer of the total difficulty of the chain until this block.
    • -
    • size: QUANTITY - Integer the size of the block in bytes.
    • -
    • transactions: Array - Array of transaction objects or 32 Bytes transaction hashes depending on the last parameter.
    • -
    • uncles: Array - Array of uncle hashes.
    • +
    • hash: DATA, 32 Bytes - Hash of the block. null when pending.

      +
    • +
    • parentHash: DATA, 32 Bytes - Hash of the parent block.

      +
    • +
    • sha3Uncles: DATA, 32 Bytes - SHA3 of the uncles data in the block.

      +
    • +
    • miner: DATA, 20 Bytes - Address of the miner.

      +
    • +
    • stateRoot: DATA, 32 Bytes - The root of the state trie of the block.

      +
    • +
    • transactionsRoot: DATA, 32 Bytes - The root of the transaction trie of the block.

      +
    • +
    • receiptsRoot: DATA, 32 Bytes - The root of the receipts trie of the block.

      +
    • +
    • logsBloom: DATA, 256 Bytes - The bloom filter for the logs of the block. null when pending.

      +
    • +
    • difficulty: QUANTITY - Integer of the difficulty of this block.

      +
    • +
    • number: QUANTITY - The block number. null when pending.

      +
    • +
    • gasLimit: QUANTITY - The maximum gas allowed in the block.

      +
    • +
    • gasUsed: QUANTITY - Total gas used by all transactions in the block.

      +
    • +
    • timestamp: QUANTITY - The unix timestamp for when the block was collated.

      +
    • +
    • extraData: DATA - Extra data for the block.

      +
    • +
    • mixHash: DATA, 256 Bytes - Hash identifier for the block.

      +
    • +
    • nonce: DATA, 8 Bytes - Hash of the generated proof-of-work. null when pending.

      +
    • +
    • totalDifficulty: QUANTITY - Integer of the total difficulty of the chain until this block.

      +
    • +
    • size: QUANTITY - Integer the size of the block in bytes.

      +
    • +
    • uncles: Array - Array of uncle hashes.

      +
    • +
    • **NOTE: **The return does not contain a list of transactions in the uncle +block, to get this, make another request to eth_getBlockByHash.

      +
    -

    eth_getUncleCountByBlockHash

    • eth_getUncleCountByBlockHash(hash: string): Promise<Quantity>

    eth_getUncleCountByBlockHash

    • eth_getUncleCountByBlockHash(hash: string): Promise<Quantity>
    • Returns the number of uncles in a block from a block matching the given block hash.

      example
      const blockHash = await provider.send("eth_getBlockByNumber", ["latest"] );
      const uncleCount = await provider.send("eth_getUncleCountByBlockHash", [blockHash] );
      console.log(uncleCount);

      Parameters

      • hash: string

        Hash of a block.

      Returns Promise<Quantity>

      The number of uncles in a block.

      -

    eth_getUncleCountByBlockNumber

    • eth_getUncleCountByBlockNumber(blockNumber: string): Promise<Quantity>

    eth_getUncleCountByBlockNumber

    • eth_getUncleCountByBlockNumber(blockNumber: string): Promise<Quantity>
    • Returns the number of uncles in a block from a block matching the given block hash.

      example
      const uncleCount = await provider.send("eth_getUncleCountByBlockNumber", ["latest"] );
      console.log(uncleCount);

      Parameters

      • blockNumber: string

        A block number, or the string "earliest", "latest" or "pending".

      Returns Promise<Quantity>

      The number of uncles in a block.

      -

    eth_getWork

    • eth_getWork(filterId: string): Promise<[] | [string, string, string]>

    eth_getWork

    • eth_getWork(filterId: string): Promise<[] | [string, string, string]>
    • Returns: An Array with the following elements 1: DATA, 32 Bytes - current block header pow-hash 2: DATA, 32 Bytes - the seed hash used for the DAG. @@ -532,28 +554,28 @@

      Parameters

      • filterId: string

        A filter id.

      Returns Promise<[] | [string, string, string]>

      The hash of the current block, the seedHash, and the boundary condition to be met ("target").

      -

    eth_hashrate

    • eth_hashrate(): Promise<Quantity>

    eth_hashrate

    • eth_hashrate(): Promise<Quantity>
    • Returns the number of hashes per second that the node is mining with.

      example
      const hashrate = await provider.request({ method: "eth_hashrate", params: [] });
      console.log(hashrate);

      Returns Promise<Quantity>

      Number of hashes per second.

      -

    eth_maxPriorityFeePerGas

    • eth_maxPriorityFeePerGas(): Promise<Quantity>

    eth_maxPriorityFeePerGas

    • eth_maxPriorityFeePerGas(): Promise<Quantity>
    • Returns a maxPriorityFeePerGas value suitable for quick transaction inclusion.

      example
      const suggestedTip = await provider.request({ method: "eth_maxPriorityFeePerGas", params: [] });
      console.log(suggestedTip);

      Returns Promise<Quantity>

      The maxPriorityFeePerGas in wei.

      -

    eth_mining

    • eth_mining(): Promise<boolean>

    eth_mining

    • eth_mining(): Promise<boolean>
    • Returns true if client is actively mining new blocks.

      example
      const isMining = await provider.request({ method: "eth_mining", params: [] });
      console.log(isMining);

      Returns Promise<boolean>

      returns true if the client is mining, otherwise false.

      -

    eth_newBlockFilter

    • eth_newBlockFilter(): Promise<Quantity>

    eth_newBlockFilter

    • eth_newBlockFilter(): Promise<Quantity>
    • Creates a filter in the node, to notify when a new block arrives. To check if the state has changed, call eth_getFilterChanges.

      example
      const filterId = await provider.request({ method: "eth_newBlockFilter", params: [] });
      console.log(filterId);

      Returns Promise<Quantity>

      A filter id.

      -

    eth_newFilter

    • eth_newFilter(filter?: RangeFilterArgs): Promise<Quantity>

    eth_newFilter

    • eth_newFilter(filter?: RangeFilterArgs): Promise<Quantity>
    • Creates a filter object, based on filter options, to notify when the state changes (logs). To check if the state has changed, call eth_getFilterChanges.

      @@ -584,7 +606,7 @@

      A note on specifying topic filters:

    • toBlock: QUANTITY | TAG (optional) - Integer block number, or the string "latest", "earliest" or "pending".
    • address: DATA | Array (optional) - Contract address or a list of addresses from which the logs should originate.
    • -
    • topics: Array of DATA (optional) - Array of 32 Bytes DATA topcis. Topics are order-dependent. Each topic can also +
    • topics: Array of DATA (optional) - Array of 32 Bytes DATA topics. Topics are order-dependent. Each topic can also be an array of DATA with "or" options.
    example
    const filterId = await provider.request({ method: "eth_newFilter", params: [] });
    console.log(filterId); @@ -592,25 +614,25 @@

    A note on specifying topic filters:

    Parameters

    • Optional filter: RangeFilterArgs

      The filter options as seen in source.

    Returns Promise<Quantity>

    A filter id.

    -

    eth_newPendingTransactionFilter

    • eth_newPendingTransactionFilter(): Promise<Quantity>

    eth_newPendingTransactionFilter

    • eth_newPendingTransactionFilter(): Promise<Quantity>
    • Creates a filter in the node, to notify when new pending transactions arrive. To check if the state has changed, call eth_getFilterChanges.

      example
      const filterId = await provider.request({ method: "eth_newPendingTransactionFilter", params: [] });
      console.log(filterId);

      Returns Promise<Quantity>

      A filter id.

      -

    eth_protocolVersion

    • eth_protocolVersion(): Promise<Data>

    eth_protocolVersion

    • eth_protocolVersion(): Promise<Data>
    • Returns the current ethereum protocol version.

      example
      const version = await provider.request({ method: "eth_protocolVersion", params: [] });
      console.log(version);

      Returns Promise<Data>

      The current ethereum protocol version.

      -

    eth_sendRawTransaction

    • eth_sendRawTransaction(transaction: string): Promise<Data>

    eth_sendRawTransaction

    • eth_sendRawTransaction(transaction: string): Promise<Data>
    • Creates new message call transaction or a contract creation for signed transactions.

      example
      const [from, to] = await provider.request({ method: "eth_accounts", params: [] });
      const signedTx = await provider.request({ method: "eth_signTransaction", params: [{ from, to, gas: "0x5b8d80" }] });
      const txHash = await provider.send("eth_sendRawTransaction", [signedTx] );
      console.log(txHash);

      Parameters

      • transaction: string

        The signed transaction data.

      Returns Promise<Data>

      The transaction hash.

      -

    eth_sendTransaction

    • eth_sendTransaction(transaction: TypedRpcTransaction): Promise<Data>

    eth_sendTransaction

    • eth_sendTransaction(transaction: Transaction): Promise<Data>
    • Creates new message call transaction or a contract creation, if the data field contains code.

      Transaction call object:

        @@ -623,10 +645,10 @@

        A note on specifying topic filters:

      example
      const [from, to] = await provider.request({ method: "eth_accounts", params: [] });
      await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
      const txHash = await provider.request({ method: "eth_sendTransaction", params: [{ from, to, gas: "0x5b8d80" }] });
      await provider.once("message"); // Note: `await provider.once` is non-standard
      console.log(txHash);
      -

      Parameters

      • transaction: TypedRpcTransaction
        +

        Parameters

        • transaction: Transaction

          The transaction call object as seen in source.

        Returns Promise<Data>

        The transaction hash.

        -

    eth_sign

    • eth_sign(address: string, message: string): Promise<string>

    eth_sign

    • eth_sign(address: string, message: string): Promise<string>
    • The sign method calculates an Ethereum specific signature with: sign(keccak256("\x19Ethereum Signed Message:\n" + message.length + message))).

      By adding a prefix to the message makes the calculated signature @@ -645,7 +667,7 @@

      A note on specifying topic filters:

      in big-endian format. Bytes 0...64 contain the r parameter, bytes 64...128 the s parameter, and the last byte the v parameter. Note that the v parameter includes the chain id as specified in EIP-155.

      -

    eth_signTransaction

    • eth_signTransaction(transaction: TypedRpcTransaction): Promise<string>

    eth_signTransaction

    • eth_signTransaction(transaction: Transaction): Promise<Data>
    • Signs a transaction that can be submitted to the network at a later time using eth_sendRawTransaction.

      Transaction call object:

        @@ -658,10 +680,10 @@

        A note on specifying topic filters:

      example
      const [from, to] = await provider.request({ method: "eth_accounts", params: [] });
      const signedTx = await provider.request({ method: "eth_signTransaction", params: [{ from, to }] });
      console.log(signedTx)
      -

      Parameters

      • transaction: TypedRpcTransaction
        +

        Parameters

        • transaction: Transaction

          The transaction call object as seen in source.

          -

        Returns Promise<string>

        The raw, signed transaction.

        -

    eth_signTypedData

    • eth_signTypedData(address: string, typedData: TypedMessage<MessageTypes>): Promise<string>

    Returns Promise<Data>

    The raw, signed transaction.

    +

    eth_signTypedData

    • eth_signTypedData(address: string, typedData: TypedMessage<MessageTypes>): Promise<string>
    • Identical to eth_signTypedData_v4.

      eip

      712

      example
      const [account] = await provider.request({ method: "eth_accounts", params: [] });
      const typedData = {
      types: {
      EIP712Domain: [
      { name: 'name', type: 'string' },
      { name: 'version', type: 'string' },
      { name: 'chainId', type: 'uint256' },
      { name: 'verifyingContract', type: 'address' },
      ],
      Person: [
      { name: 'name', type: 'string' },
      { name: 'wallet', type: 'address' }
      ],
      Mail: [
      { name: 'from', type: 'Person' },
      { name: 'to', type: 'Person' },
      { name: 'contents', type: 'string' }
      ],
      },
      primaryType: 'Mail',
      domain: {
      name: 'Ether Mail',
      version: '1',
      chainId: 1,
      verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
      },
      message: {
      from: {
      name: 'Cow',
      wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
      },
      to: {
      name: 'Bob',
      wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
      },
      contents: 'Hello, Bob!',
      },
      };
      const signature = await provider.request({ method: "eth_signTypedData", params: [account, typedData] });
      console.log(signature); @@ -676,7 +698,7 @@

      A note on specifying topic filters:

      in big-endian format. Bytes 0...64 contain the r parameter, bytes 64...128 the s parameter, and the last byte the v parameter. Note that the v parameter includes the chain id as specified in EIP-155.

      -

    eth_signTypedData_v4

    • eth_signTypedData_v4(address: string, typedData: TypedMessage<MessageTypes>): Promise<string>

    eth_signTypedData_v4

    • eth_signTypedData_v4(address: string, typedData: TypedMessage<MessageTypes>): Promise<string>
    • eip

      712

      example
      const [account] = await provider.request({ method: "eth_accounts", params: [] });
      const typedData = {
      types: {
      EIP712Domain: [
      { name: 'name', type: 'string' },
      { name: 'version', type: 'string' },
      { name: 'chainId', type: 'uint256' },
      { name: 'verifyingContract', type: 'address' },
      ],
      Person: [
      { name: 'name', type: 'string' },
      { name: 'wallet', type: 'address' }
      ],
      Mail: [
      { name: 'from', type: 'Person' },
      { name: 'to', type: 'Person' },
      { name: 'contents', type: 'string' }
      ],
      },
      primaryType: 'Mail',
      domain: {
      name: 'Ether Mail',
      version: '1',
      chainId: 1,
      verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
      },
      message: {
      from: {
      name: 'Cow',
      wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
      },
      to: {
      name: 'Bob',
      wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
      },
      contents: 'Hello, Bob!',
      },
      };
      const signature = await provider.request({ method: "eth_signTypedData_v4", params: [account, typedData] });
      console.log(signature);

      Parameters

      • address: string
        @@ -689,7 +711,7 @@

        A note on specifying topic filters:

        in big-endian format. Bytes 0...64 contain the r parameter, bytes 64...128 the s parameter, and the last byte the v parameter. Note that the v parameter includes the chain id as specified in EIP-155.

        -

    eth_submitHashrate

    • eth_submitHashrate(hashRate: string, clientID: string): Promise<boolean>

    eth_submitHashrate

    • eth_submitHashrate(hashRate: string, clientID: string): Promise<boolean>
    • Used for submitting mining hashrate.

      example
      const hashRate = "0x0000000000000000000000000000000000000000000000000000000000000001";
      const clientId = "0xb2222a74119abd18dbcb7d1f661c6578b7bbeb4984c50e66ed538347f606b971";
      const result = await provider.request({ method: "eth_submitHashrate", params: [hashRate, clientId] });
      console.log(result);
      @@ -697,8 +719,8 @@

      A note on specifying topic filters:

      A hexadecimal string representation (32 bytes) of the hash rate.

    • clientID: string

      A random hexadecimal(32 bytes) ID identifying the client.

      -

    Returns Promise<boolean>

    true if submitting went through succesfully and false otherwise.

    -

    eth_submitWork

    • eth_submitWork(nonce: string, powHash: string, digest: string): Promise<boolean>

    Returns Promise<boolean>

    true if submitting went through successfully and false otherwise.

    +

    eth_submitWork

    • eth_submitWork(nonce: string, powHash: string, digest: string): Promise<boolean>
    • Used for submitting a proof-of-work solution.

      example
      const nonce = "0xe0df4bd14ab39a71";
      const powHash = "0x0000000000000000000000000000000000000000000000000000000000000001";
      const digest = "0xb2222a74119abd18dbcb7d1f661c6578b7bbeb4984c50e66ed538347f606b971";
      const result = await provider.request({ method: "eth_submitWork", params: [nonce, powHash, digest] });
      console.log(result);
      @@ -709,7 +731,7 @@

      A note on specifying topic filters:

    • digest: string

      The mix digest (256 bits).

    Returns Promise<boolean>

    true if the provided solution is valid, otherwise false.

    -

    eth_subscribe

    • eth_subscribe(subscriptionName: SubscriptionName): PromiEvent<Quantity>
    • eth_subscribe(subscriptionName: "logs", options: BaseFilterArgs): PromiEvent<Quantity>

    eth_subscribe

    • eth_subscribe(subscriptionName: SubscriptionName): PromiEvent<Quantity>
    • eth_subscribe(subscriptionName: "logs", options: BaseFilterArgs): PromiEvent<Quantity>
    • Starts a subscription to a particular event. For every event that matches the subscription a JSON-RPC notification with event details and subscription ID will be sent to a client.

      @@ -718,7 +740,7 @@

      A note on specifying topic filters:

      Parameters

      • subscriptionName: SubscriptionName

        Name for the subscription.

      Returns PromiEvent<Quantity>

      A subscription id.

      -
    • +
    • Starts a subscription to a particular event. For every event that matches the subscription a JSON-RPC notification with event details and subscription ID will be sent to a client.

      @@ -734,7 +756,7 @@

      A note on specifying topic filters:

    • topics, only logs which match the specified topics

    Returns PromiEvent<Quantity>

    A subscription id.

    -

    eth_syncing

    • eth_syncing(): Promise<boolean>

    eth_syncing

    • eth_syncing(): Promise<boolean>
    • Returns an object containing data about the sync status or false when not syncing.

      example
      const result = await provider.request({ method: "eth_syncing", params: [] });
      console.log(result);
      @@ -745,7 +767,7 @@

      A note on specifying topic filters:

    • currentBlock: {bigint} The current block, same as eth_blockNumber.
    • highestBlock: {bigint} The estimated highest block.
    -

    eth_uninstallFilter

    • eth_uninstallFilter(filterId: string): Promise<boolean>

    eth_uninstallFilter

    • eth_uninstallFilter(filterId: string): Promise<boolean>
    • Uninstalls a filter with given id. Should always be called when watch is no longer needed.

      example
      const filterId = await provider.request({ method: "eth_newFilter", params: [] });
      const result = await provider.request({ method: "eth_uninstallFilter", params: [filterId] });
      console.log(result); @@ -754,7 +776,7 @@

      A note on specifying topic filters:

      The filter id.

    Returns Promise<boolean>

    true if the filter was successfully uninstalled, otherwise false.

    -

    eth_unsubscribe

    • eth_unsubscribe(subscriptionId: string): Promise<boolean>

    eth_unsubscribe

    • eth_unsubscribe(subscriptionId: string): Promise<boolean>
    • Cancel a subscription to a particular event. Returns a boolean indicating if the subscription was successfully cancelled.

      example
      const subscriptionId = await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
      const result = await provider.request({ method: "eth_unsubscribe", params: [subscriptionId] });
      console.log(result); @@ -762,7 +784,7 @@

      A note on specifying topic filters:

      Parameters

      • subscriptionId: string

        The ID of the subscription to unsubscribe to.

      Returns Promise<boolean>

      true if subscription was cancelled successfully, otherwise false.

      -

    evm_addAccount

    • evm_addAccount(address: string, passphrase: string): Promise<boolean>

    evm_addAccount

    • evm_addAccount(address: string, passphrase: string): Promise<boolean>
    • Adds any arbitrary account to the personal namespace.

      Note: accounts already known to the personal namespace and accounts returned by eth_accounts cannot be re-added using this method.

      @@ -777,14 +799,14 @@

      A note on specifying topic filters:

      that require a password.

    Returns Promise<boolean>

    true if the account was successfully added. false if the account is already in the personal namespace.

    -

    evm_increaseTime

    • evm_increaseTime(seconds: string | number): Promise<number>

    evm_increaseTime

    • evm_increaseTime(seconds: string | number): Promise<number>
    • Jump forward in time by the given amount of time, in seconds.

      example
      const seconds = 10;
      const timeAdjustment = await provider.send("evm_increaseTime", [seconds] );
      console.log(timeAdjustment);

      Parameters

      • seconds: string | number

        Number of seconds to jump forward in time by. Must be greater than or equal to 0.

      Returns Promise<number>

      Returns the total time adjustment, in seconds.

      -

    evm_mine

    • evm_mine(timestamp: number): Promise<"0x0">
    • evm_mine(options: { blocks?: number; timestamp?: number }): Promise<"0x0">

    evm_mine

    • evm_mine(timestamp: number): Promise<"0x0">
    • evm_mine(options: MineOptions): Promise<"0x0">
    • Force a single block to be mined.

      Mines a block independent of whether or not mining is started or stopped. Will mine an empty block if there are no available transactions to mine.

      @@ -797,7 +819,7 @@

      A note on specifying topic filters:

      number of blocks, regardless of any other blocks mined or reverted during it's operation. This behavior is subject to change!

    Returns Promise<"0x0">

    The string "0x0". May return additional meta-data in the future.

    -
  • Parameters

    • options: { blocks?: number; timestamp?: number }
      • Optional blocks?: number
      • Optional timestamp?: number

    Returns Promise<"0x0">

  • evm_removeAccount

    • evm_removeAccount(address: string, passphrase: string): Promise<boolean>

    evm_removeAccount

    • evm_removeAccount(address: string, passphrase: string): Promise<boolean>
    • Removes an account from the personal namespace.

      Note: accounts not known to the personal namespace cannot be removed using this method.

      @@ -810,7 +832,7 @@

      A note on specifying topic filters:

      The passphrase used to decrypt the account's private key.

    Returns Promise<boolean>

    true if the account was successfully removed. false if the account was not in the personal namespace.

    -

    evm_revert

    • evm_revert(snapshotId: string): Promise<boolean>

    evm_revert

    • evm_revert(snapshotId: string): Promise<boolean>
    • Revert the state of the blockchain to a previous snapshot. Takes a single parameter, which is the snapshot id to revert to. This deletes the given snapshot, as well as any snapshots taken after (e.g.: reverting to id 0x1 @@ -820,7 +842,7 @@

      A note on specifying topic filters:

      Parameters

      • snapshotId: string

        The snapshot id to revert.

      Returns Promise<boolean>

      true if a snapshot was reverted, otherwise false.

      -

    evm_setAccountBalance

    • evm_setAccountBalance(address: string, balance: string): Promise<boolean>

    evm_setAccountBalance

    • evm_setAccountBalance(address: string, balance: string): Promise<boolean>
    • Sets the given account's balance to the specified WEI value. Mines a new block before returning.

      Warning: this will result in an invalid state tree.

      @@ -831,7 +853,7 @@

      A note on specifying topic filters:

    • balance: string

      The balance value, in WEI, to be set.

    Returns Promise<boolean>

    true if it worked, otherwise false.

    -

    evm_setAccountCode

    • evm_setAccountCode(address: string, code: string): Promise<boolean>

    evm_setAccountCode

    • evm_setAccountCode(address: string, code: string): Promise<boolean>
    • Sets the given account's code to the specified data. Mines a new block before returning.

      Warning: this will result in an invalid state tree.

      @@ -842,7 +864,7 @@

      A note on specifying topic filters:

    • code: string

      The code to be set.

    Returns Promise<boolean>

    true if it worked, otherwise false.

    -

    evm_setAccountNonce

    • evm_setAccountNonce(address: string, nonce: string): Promise<boolean>

    evm_setAccountNonce

    • evm_setAccountNonce(address: string, nonce: string): Promise<boolean>
    • Sets the given account's nonce to the specified value. Mines a new block before returning.

      Warning: this will result in an invalid state tree.

      @@ -853,7 +875,7 @@

      A note on specifying topic filters:

    • nonce: string

      The nonce value to be set.

    Returns Promise<boolean>

    true if it worked, otherwise false.

    -

    evm_setAccountStorageAt

    • evm_setAccountStorageAt(address: string, slot: string, value: string): Promise<boolean>

    evm_setAccountStorageAt

    • evm_setAccountStorageAt(address: string, slot: string, value: string): Promise<boolean>
    • Sets the given account's storage slot to the specified data. Mines a new block before returning.

      Warning: this will result in an invalid state tree.

      @@ -866,7 +888,7 @@

      A note on specifying topic filters:

    • value: string

      The value to be set.

    Returns Promise<boolean>

    true if it worked, otherwise false.

    -

    evm_setTime

    • evm_setTime(time: string | number | Date): Promise<number>

    evm_setTime

    • evm_setTime(time: string | number | Date): Promise<number>
    • Sets the internal clock time to the given timestamp.

      Warning: This will allow you to move backwards in time, which may cause new blocks to appear to be mined before old blocks. This will result in @@ -876,7 +898,7 @@

      A note on specifying topic filters:

      Parameters

      • time: string | number | Date

        JavaScript timestamp (millisecond precision).

      Returns Promise<number>

      The amount of seconds between the given timestamp and now.

      -

    evm_snapshot

    • evm_snapshot(): Promise<Quantity>

    evm_snapshot

    • evm_snapshot(): Promise<Quantity>
    • Snapshot the state of the blockchain at the current block. Takes no parameters. Returns the id of the snapshot that was created. A snapshot can only be reverted once. After a successful evm_revert, the same snapshot @@ -885,21 +907,21 @@

      A note on specifying topic filters:

      example
      const provider = ganache.provider();
      const [from, to] = await provider.send("eth_accounts");
      const startingBalance = BigInt(await provider.send("eth_getBalance", [from] ));

      // take a snapshot
      const snapshotId = await provider.send("evm_snapshot");

      // send value to another account (over-simplified example)
      await provider.send("eth_subscribe", ["newHeads"] );
      await provider.send("eth_sendTransaction", [{from, to, value: "0xffff"}] );
      await provider.once("message"); // Note: `await provider.once` is non-standard

      // ensure balance has updated
      const newBalance = await provider.send("eth_getBalance", [from] );
      assert(BigInt(newBalance) < startingBalance);

      // revert the snapshot
      const isReverted = await provider.send("evm_revert", [snapshotId] );
      assert(isReverted);

      // ensure balance has reverted
      const endingBalance = await provider.send("eth_getBalance", [from] );
      const isBalanceReverted = assert.strictEqual(BigInt(endingBalance), startingBalance);
      console.log({isBalanceReverted: isBalanceReverted});

      Returns Promise<Quantity>

      The hex-encoded identifier for this snapshot.

      -

    miner_setEtherbase

    • miner_setEtherbase(address: string): Promise<boolean>

    miner_setEtherbase

    • miner_setEtherbase(address: string): Promise<boolean>
    • Sets the etherbase, where mining rewards will go.

      example
      const [account] = await provider.request({ method: "eth_accounts", params: [] });
      console.log(await provider.send("miner_setEtherbase", [account] ));

      Parameters

      • address: string

        The address where the mining rewards will go.

      Returns Promise<boolean>

      true.

      -

    miner_setExtra

    • miner_setExtra(extra: string): Promise<boolean>

    miner_setExtra

    • miner_setExtra(extra: string): Promise<boolean>
    • Set the extraData block header field a miner can include.

      example
      console.log(await provider.send("miner_setExtra", ["0x0"] ));
       

      Parameters

      • extra: string

        The extraData to include.

      Returns Promise<boolean>

      If successfully set returns true, otherwise returns an error.

      -

    miner_setGasPrice

    • miner_setGasPrice(number: string): Promise<boolean>

    miner_setGasPrice

    • miner_setGasPrice(number: string): Promise<boolean>
    • Sets the default accepted gas price when mining transactions. Any transactions that don't specify a gas price will use this amount. Transactions that are below this limit are excluded from the mining process.

      @@ -908,7 +930,7 @@

      A note on specifying topic filters:

      Parameters

      • number: string

        Default accepted gas price.

      Returns Promise<boolean>

      true.

      -

    miner_start

    • miner_start(threads?: number): Promise<boolean>

    miner_start

    • miner_start(threads?: number): Promise<boolean>
    • Resume the CPU mining process with the given number of threads.

      Note: threads is ignored.

      example
      await provider.send("miner_stop");
      // check that eth_mining returns false
      console.log(await provider.send("eth_mining"));
      await provider.send("miner_start");
      // check that eth_mining returns true
      console.log(await provider.send("eth_mining")); @@ -916,28 +938,28 @@

      A note on specifying topic filters:

      Parameters

      • threads: number = 1

        Number of threads to resume the CPU mining process with.

      Returns Promise<boolean>

      true.

      -

    miner_stop

    • miner_stop(): Promise<boolean>

    miner_stop

    • miner_stop(): Promise<boolean>
    • Stop the CPU mining operation.

      example
      // check that eth_mining returns true
      console.log(await provider.send("eth_mining"));
      await provider.send("miner_stop");
      // check that eth_mining returns false
      console.log(await provider.send("eth_mining"));

      Returns Promise<boolean>

      true.

      -

    net_listening

    • net_listening(): Promise<boolean>

    net_listening

    • net_listening(): Promise<boolean>
    • Returns true if client is actively listening for network connections.

      example
      console.log(await provider.send("net_listening"));
       

      Returns Promise<boolean>

      true when listening, otherwise false.

      -

    net_peerCount

    • net_peerCount(): Promise<Quantity>

    net_peerCount

    • net_peerCount(): Promise<Quantity>
    • Returns number of peers currently connected to the client.

      example
      console.log(await provider.send("net_peerCount"));
       

      Returns Promise<Quantity>

      Number of connected peers.

      -

    net_version

    • net_version(): Promise<string>

    net_version

    • net_version(): Promise<string>
    • Returns the current network id.

      example
      console.log(await provider.send("net_version"));
       

      Returns Promise<string>

      The current network id. This value should NOT be JSON-RPC Quantity/Data encoded.

      -

    personal_importRawKey

    • personal_importRawKey(rawKey: string, passphrase: string): Promise<Address>

    personal_importRawKey

    • personal_importRawKey(rawKey: string, passphrase: string): Promise<Address>
    • Imports the given unencrypted private key (hex string) into the key store, encrypting it with the passphrase.

      example
      const rawKey = "0x0123456789012345678901234567890123456789012345678901234567890123";
      const passphrase = "passphrase";

      const address = await provider.send("personal_importRawKey",[rawKey, passphrase] );
      console.log(address);
      @@ -946,20 +968,20 @@

      A note on specifying topic filters:

    • passphrase: string

      The passphrase to encrypt with.

    Returns Promise<Address>

    Returns the address of the new account.

    -

    personal_listAccounts

    • personal_listAccounts(): Promise<string[]>

    personal_listAccounts

    • personal_listAccounts(): Promise<string[]>
    • Returns all the Ethereum account addresses of all keys that have been added.

      example
      console.log(await provider.send("personal_listAccounts"));
       

      Returns Promise<string[]>

      The Ethereum account addresses of all keys that have been added.

      -

    personal_lockAccount

    • personal_lockAccount(address: string): Promise<boolean>

    personal_lockAccount

    • personal_lockAccount(address: string): Promise<boolean>
    • Locks the account. The account can no longer be used to send transactions.

      example
      const [account] = await provider.send("personal_listAccounts");
      const isLocked = await provider.send("personal_lockAccount", [account] );
      console.log(isLocked);

      Parameters

      • address: string

        The account address to be locked.

      Returns Promise<boolean>

      Returns true if the account was locked, otherwise false.

      -

    personal_newAccount

    • personal_newAccount(passphrase: string): Promise<Address>

    personal_newAccount

    • personal_newAccount(passphrase: string): Promise<Address>
    • Generates a new account with private key. Returns the address of the new account.

      example
      const passphrase = "passphrase";
      const address = await provider.send("personal_newAccount", [passphrase] );
      console.log(address); @@ -967,7 +989,7 @@

      A note on specifying topic filters:

      Parameters

      • passphrase: string

        The passphrase to encrypt the private key with.

      Returns Promise<Address>

      The new account's address.

      -

    personal_sendTransaction

    • personal_sendTransaction(transaction: TypedRpcTransaction, passphrase: string): Promise<Data>

    personal_sendTransaction

    • personal_sendTransaction(transaction: Transaction, passphrase: string): Promise<Data>
    • Validate the given passphrase and submit transaction.

      The transaction is the same argument as for eth_sendTransaction and contains the from address. If the passphrase can be used to decrypt the @@ -985,10 +1007,10 @@

      A note on specifying topic filters:

    example
    const passphrase = "passphrase";
    const newAccount = await provider.send("personal_newAccount", [passphrase] );
    const [to] = await provider.send("personal_listAccounts");

    // use account and passphrase to send the transaction
    const txHash = await provider.send("personal_sendTransaction", [{ from: newAccount, to, gasLimit: "0x5b8d80" }, passphrase] );
    console.log(txHash);
    -

    Parameters

    • transaction: TypedRpcTransaction
    • passphrase: string
      +

      Parameters

      • transaction: Transaction
      • passphrase: string

        The passphrase to decrpyt the private key belonging to tx.from.

      Returns Promise<Data>

      The transaction hash or if unsuccessful an error.

      -

    personal_signTransaction

    • personal_signTransaction(transaction: TypedRpcTransaction, passphrase: string): Promise<string>

    personal_signTransaction

    • personal_signTransaction(transaction: Transaction, passphrase: string): Promise<Data>
    • Validates the given passphrase and signs a transaction that can be submitted to the network at a later time using eth_sendRawTransaction.

      The transaction is the same argument as for eth_signTransaction and @@ -1006,10 +1028,10 @@

      A note on specifying topic filters:

    example
    const [to] = await provider.request({ method: "eth_accounts", params: [] });
    const passphrase = "passphrase";
    const from = await provider.send("personal_newAccount", [passphrase] );
    await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
    const signedTx = await provider.request({ method: "personal_signTransaction", params: [{ from, to }, passphrase] });
    console.log(signedTx)
    -

    Parameters

    • transaction: TypedRpcTransaction
      +

      Parameters

      • transaction: Transaction

        The transaction call object as seen in source.

        -
      • passphrase: string

      Returns Promise<string>

      The raw, signed transaction.

      -

    personal_unlockAccount

    • personal_unlockAccount(address: string, passphrase: string, duration?: number): Promise<boolean>

    Returns Promise<Data>

    The raw, signed transaction.

    +

    personal_unlockAccount

    • personal_unlockAccount(address: string, passphrase: string, duration?: number): Promise<boolean>
    • Unlocks the account for use.

      The unencrypted key will be held in memory until the unlock duration expires. The unlock duration defaults to 300 seconds. An explicit duration @@ -1026,40 +1048,40 @@

      A note on specifying topic filters:

      (default: 300) Duration in seconds how long the account should remain unlocked for. Set to 0 to disable automatic locking.

    Returns Promise<boolean>

    true if it worked. Throws an error or returns false if it did not.

    -

    rpc_modules

    • rpc_modules(): Promise<{ eth: "1.0"; evm: "1.0"; net: "1.0"; personal: "1.0"; rpc: "1.0"; web3: "1.0" }>

    rpc_modules

    • rpc_modules(): Promise<{ eth: "1.0"; evm: "1.0"; net: "1.0"; personal: "1.0"; rpc: "1.0"; web3: "1.0" }>
    • Returns object of RPC modules.

      example
      console.log(await provider.send("rpc_modules"));
       

      Returns Promise<{ eth: "1.0"; evm: "1.0"; net: "1.0"; personal: "1.0"; rpc: "1.0"; web3: "1.0" }>

      RPC modules.

      -

    shh_addToGroup

    • shh_addToGroup(address: string): Promise<boolean>

    shh_addToGroup

    • shh_addToGroup(address: string): Promise<boolean>
    • Adds a whisper identity to the group.

      example
      console.log(await provider.send("shh_addToGroup", ["0x0"] ));
       

      Parameters

      • address: string

        The identity address to add to a group.

      Returns Promise<boolean>

      true if the identity was successfully added to the group, otherwise false.

      -

    shh_getFilterChanges

    • shh_getFilterChanges(id: string): Promise<any[]>

    shh_getFilterChanges

    • shh_getFilterChanges(id: string): Promise<[]>

    shh_getMessages

    • shh_getMessages(id: string): Promise<boolean>

    Returns Promise<[]>

    shh_getMessages

    • shh_getMessages(id: string): Promise<boolean>
    • Get all messages matching a filter. Unlike shh_getFilterChanges this returns all messages.

      example
      console.log(await provider.send("shh_getMessages", ["0x0"] ));
       

      Parameters

      • id: string

        The filter id. Ex: "0x7"

      Returns Promise<boolean>

      See: shh_getFilterChanges.

      -

    shh_hasIdentity

    • shh_hasIdentity(address: string): Promise<boolean>

    shh_hasIdentity

    • shh_hasIdentity(address: string): Promise<boolean>
    • Checks if the client hold the private keys for a given identity.

      example
      console.log(await provider.send("shh_hasIdentity", ["0x0"] ));
       

      Parameters

      • address: string

        The identity address to check.

      Returns Promise<boolean>

      Returns true if the client holds the private key for that identity, otherwise false.

      -

    shh_newFilter

    • shh_newFilter(to: string, topics: string[]): Promise<boolean>

    shh_newFilter

    • shh_newFilter(to: string, topics: string[]): Promise<boolean>
    • Creates filter to notify, when client receives whisper message matching the filter options.

      example
      console.log(await provider.send("shh_newFilter", ["0x0", []] ));
       
      @@ -1069,17 +1091,17 @@

      A note on specifying topic filters:

    • topics: string[]

      Array of topics which the incoming message's topics should match.

    Returns Promise<boolean>

    Returns true if the identity was successfully added to the group, otherwise false.

    -

    shh_newGroup

    • shh_newGroup(): Promise<string>

    shh_newGroup

    • shh_newGroup(): Promise<string>

    shh_newIdentity

    • shh_newIdentity(): Promise<string>

    shh_newIdentity

    • shh_newIdentity(): Promise<string>
    • Creates new whisper identity in the client.

      example
      console.log(await provider.send("shh_newIdentity"));
       

      Returns Promise<string>

      • The address of the new identity.
      -

    shh_post

    • shh_post(postData: any): Promise<boolean>

    shh_post

    • shh_post(postData: any): Promise<boolean>
    • Creates a whisper message and injects it into the network for distribution.

      example
      console.log(await provider.send("shh_post", [{}] ));
       
      @@ -1088,7 +1110,7 @@

      A note on specifying topic filters:

    Returns Promise<boolean>

    Returns true if the message was sent, otherwise false.

    -

    shh_uninstallFilter

    • shh_uninstallFilter(id: string): Promise<boolean>

    shh_uninstallFilter

    • shh_uninstallFilter(id: string): Promise<boolean>
    • Uninstalls a filter with given id. Should always be called when watch is no longer needed. Additionally filters timeout when they aren't requested with shh_getFilterChanges for a period of time.

      example
      console.log(await provider.send("shh_uninstallFilter", ["0x0"] ));
      @@ -1096,26 +1118,26 @@ 

      A note on specifying topic filters:

      Parameters

      • id: string

        The filter id. Ex: "0x7"

      Returns Promise<boolean>

      true if the filter was successfully uninstalled, otherwise false.

      -

    shh_version

    • shh_version(): Promise<string>

    shh_version

    • shh_version(): Promise<string>
    • Returns the current whisper protocol version.

      example
      console.log(await provider.send("shh_version"));
       

      Returns Promise<string>

      The current whisper protocol version.

      -

    txpool_content

    • txpool_content(): Promise<{ pending: Map<string, Map<string, TypedTransactionJSON>>; queued: Map<string, Map<string, TypedTransactionJSON>> }>

    txpool_content

    • txpool_content(): Promise<Content<"private">>
    • Returns the current content of the transaction pool.

      example
      const [from] = await provider.request({ method: "eth_accounts", params: [] });
      const pendingTx = await provider.request({ method: "eth_sendTransaction", params: [{ from, gas: "0x5b8d80", nonce:"0x0" }] });
      const queuedTx = await provider.request({ method: "eth_sendTransaction", params: [{ from, gas: "0x5b8d80", nonce:"0x2" }] });
      const pool = await provider.send("txpool_content");
      console.log(pool);
      -

      Returns Promise<{ pending: Map<string, Map<string, TypedTransactionJSON>>; queued: Map<string, Map<string, TypedTransactionJSON>> }>

      The transactions currently pending or queued in the transaction pool.

      -

    web3_clientVersion

    • web3_clientVersion(): Promise<string>
    • +

      Returns Promise<Content<"private">>

      The transactions currently pending or queued in the transaction pool.

      +

    web3_clientVersion

    • web3_clientVersion(): Promise<string>
    • Returns the current client version.

      example
      console.log(await provider.send("web3_clientVersion"));
       

      Returns Promise<string>

      The current client version.

      -

    web3_sha3

    • web3_sha3(data: string): Promise<Data>

    web3_sha3

    • web3_sha3(data: string): Promise<Data>
    • Returns Keccak-256 (not the standardized SHA3-256) of the given data.

      example
      const data = "hello trufflers";
      const sha3 = await provider.send("web3_sha3", [data] );
      console.log(sha3);

      Parameters

      • data: string

        the data to convert into a SHA3 hash.

      Returns Promise<Data>

      The SHA3 result of the given string.

      -

    Legend

    • Constructor
    • Method
    • Private property

    Settings

    Theme

    Generated using TypeDoc

    \ No newline at end of file +

    Legend

    • Constructor
    • Method
    • Private property

    Settings

    Theme

    Generated using TypeDoc

    \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index a40dd0c55f..abb3397d44 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7732,9 +7732,9 @@ } }, "typescript": { - "version": "4.5.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.4.tgz", - "integrity": "sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==", + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", "dev": true }, "uglify-js": { diff --git a/package.json b/package.json index 826a3ce505..0e5970e5f9 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "semver": "7.3.5", "shx": "0.3.3", "ts-node": "10.4.0", - "typescript": "4.5.4", + "typescript": "4.6.4", "validate-npm-package-name": "3.0.0", "yargs": "16.2.0" }, diff --git a/scripts/build-docs/index.ts b/scripts/build-docs/index.ts index e67f2df1e4..17a13f3993 100644 --- a/scripts/build-docs/index.ts +++ b/scripts/build-docs/index.ts @@ -60,6 +60,7 @@ type Type = { elements: Type[]; elementType: Type; value?: any; + declaration?: Child; }; type Comment = { @@ -271,7 +272,15 @@ function getTypeAsString(type: Type): string { case "array": return `${getTypeAsString(type.elementType)}[]`; case "reflection": - return "object"; + if (type.declaration) { + return `{ ${type.declaration.children + .map(child => { + return `${child.name}: ${getTypeAsString(child.type)}`; + }) + .join(", ")} }`; + } else { + return "object"; + } case "intrinsic": case "reference": return x(type.name); @@ -283,6 +292,10 @@ function getTypeAsString(type: Type): string { // outputs a string literal like `He said, "hello, world"!` as // the string `"He said, \"hello, world\"!"` return `"${type.value.replace(/"/g, '\\"')}"`; + case "intersection": + return type.types.map(getTypeAsString).join(" & "); + case "conditional": + return getTypeAsString((type as any).checkType); default: console.error(type); throw new Error(`Unhandled type: ${type.type}`); @@ -295,13 +308,7 @@ function renderReturnType(method: Method) { if (signature.type.typeArguments.length) { let typeArgs = signature.type.typeArguments.map(getTypeAsString); typeArgs = typeArgs.map((arg: string) => { - if (arg.includes("Quantity")) { - return arg.replace("Quantity", "QUANTITY"); - } else if (arg.includes("Data")) { - return arg.replace("Data", "DATA"); - } else { - return arg; - } + return arg.replace(/Quantity/g, "QUANTITY").replace(/Data/g, "DATA"); }); returnType = `${returnType}<${typeArgs.join(", ")}>`; } diff --git a/src/chains/ethereum/address/package-lock.json b/src/chains/ethereum/address/package-lock.json index ec61261a5f..6f6605e302 100644 --- a/src/chains/ethereum/address/package-lock.json +++ b/src/chains/ethereum/address/package-lock.json @@ -1872,9 +1872,9 @@ } }, "typescript": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", - "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==", + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", "dev": true }, "uuid": { diff --git a/src/chains/ethereum/address/package.json b/src/chains/ethereum/address/package.json index 15498c0e95..f5b954c366 100644 --- a/src/chains/ethereum/address/package.json +++ b/src/chains/ethereum/address/package.json @@ -53,7 +53,7 @@ "mocha": "9.1.3", "nyc": "15.1.0", "ts-node": "10.4.0", - "typescript": "4.5.2" + "typescript": "4.6.4" }, "dependencies": { "@ganache/utils": "0.3.0" diff --git a/src/chains/ethereum/block/package-lock.json b/src/chains/ethereum/block/package-lock.json index 699a9ab704..875227af56 100644 --- a/src/chains/ethereum/block/package-lock.json +++ b/src/chains/ethereum/block/package-lock.json @@ -2225,9 +2225,9 @@ } }, "typescript": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", - "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==", + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", "dev": true }, "util-deprecate": { diff --git a/src/chains/ethereum/block/package.json b/src/chains/ethereum/block/package.json index dae4e365be..55b18b00e0 100644 --- a/src/chains/ethereum/block/package.json +++ b/src/chains/ethereum/block/package.json @@ -53,7 +53,7 @@ "mocha": "9.1.3", "nyc": "15.1.0", "ts-node": "10.4.0", - "typescript": "4.5.2" + "typescript": "4.6.4" }, "dependencies": { "@ethereumjs/common": "2.6.4", diff --git a/src/chains/ethereum/block/src/block.ts b/src/chains/ethereum/block/src/block.ts index 157482618e..93ae787d3d 100644 --- a/src/chains/ethereum/block/src/block.ts +++ b/src/chains/ethereum/block/src/block.ts @@ -4,7 +4,8 @@ import { GanacheRawExtraTx, TransactionFactory, TypedDatabaseTransaction, - TypedTransaction + TypedTransaction, + TypedTransactionJSON } from "@ganache/ethereum-transaction"; import type Common from "@ethereumjs/common"; import { encode, decode } from "@ganache/rlp"; @@ -69,9 +70,11 @@ export class Block { }); } - toJSON(includeFullTransactions = false) { + toJSON( + includeFullTransactions: IncludeTransactions + ) { const hash = this.hash(); - const txFn = this.getTxFn(includeFullTransactions); + const txFn = this.getTxFn(includeFullTransactions); const hashBuffer = hash.toBuffer(); const header = this.header; const number = header.number.toBuffer(); @@ -92,19 +95,19 @@ export class Block { // leave it out of extra and update the effectiveGasPrice after like this tx.updateEffectiveGasPrice(header.baseFeePerGas); return txFn(tx); - }); + }) as IncludeTransactions extends true ? TypedTransactionJSON[] : Data[]; return { hash, ...header, size: Quantity.from(this._size), transactions: jsonTxs, - uncles: [] as string[] // this.value.uncleHeaders.map(function(uncleHash) {return to.hex(uncleHash)}) + uncles: [] as Data[] // this.value.uncleHeaders.map(function(uncleHash) {return to.hex(uncleHash)}) }; } - getTxFn( - include = false + getTxFn( + include: IncludeTransactions = false ): (tx: TypedTransaction) => ReturnType | Data { if (include) { return (tx: TypedTransaction) => tx.toJSON(this._common); diff --git a/src/chains/ethereum/block/src/runtime-block.ts b/src/chains/ethereum/block/src/runtime-block.ts index 4fe6d5efac..990d51a7a9 100644 --- a/src/chains/ethereum/block/src/runtime-block.ts +++ b/src/chains/ethereum/block/src/runtime-block.ts @@ -51,7 +51,7 @@ export type BlockHeader = { /** * Returns the size of the serialized data as it would have been calculated had - * we stored things geth does, i.e., `totalDfficulty` is not usually stored in + * we stored things geth does, i.e., `totalDifficulty` is not usually stored in * the block header. * * @param serialized - diff --git a/src/chains/ethereum/block/tests/index.test.ts b/src/chains/ethereum/block/tests/index.test.ts index f6ac6e367a..a642ac9c4e 100644 --- a/src/chains/ethereum/block/tests/index.test.ts +++ b/src/chains/ethereum/block/tests/index.test.ts @@ -3,10 +3,7 @@ import { Address } from "@ganache/ethereum-address"; import { BUFFER_ZERO, Data, Quantity } from "@ganache/utils"; import Common from "@ethereumjs/common"; import Wallet from "../../ethereum/src/wallet"; -import { - TypedRpcTransaction, - TransactionFactory -} from "@ganache/ethereum-transaction"; +import { Transaction, TransactionFactory } from "@ganache/ethereum-transaction"; import Blockchain from "../../ethereum/src/blockchain"; import { EthereumOptionsConfig } from "../../options/src/index"; @@ -36,7 +33,7 @@ describe("@ganache/ethereum-block", async () => { const wallet = new Wallet(options.wallet); const [from, to] = wallet.addresses; const fromAddress = new Address(from); - const tx: TypedRpcTransaction = { + const tx: Transaction = { type: "0x2", from: from, to: to, diff --git a/src/chains/ethereum/ethereum/RPC-METHODS.md b/src/chains/ethereum/ethereum/RPC-METHODS.md index 1be531140a..1f38fa1326 100644 --- a/src/chains/ethereum/ethereum/RPC-METHODS.md +++ b/src/chains/ethereum/ethereum/RPC-METHODS.md @@ -98,7 +98,7 @@ Attempts to replay the transaction as it was executed on the network and return ##### Returns -`Promise` : Returns a storage object with the keys being keccak-256 hashes of the storage keys, and the values being the raw, unhashed key and value for that specific storage slot. Also returns a next key which is the keccak-256 hash of the next key in storage for continuous downloading. +`Promise` : Returns a storage object with the keys being keccak-256 hashes of the storage keys, and the values being the raw, unhashed key and value for that specific storage slot. Also returns a next key which is the keccak-256 hash of the next key in storage for continuous downloading. --- @@ -109,11 +109,11 @@ Attempt to run the transaction in the exact same manner as it was executed on th ##### Arguments - `transactionHash: DATA` : Hash of the transaction to trace. -- `options?: TransactionTraceOptions` : See options in source. +- `options?: Ethereum.TransactionTraceOptions` : See options in source. ##### Returns -`Promise` : Returns the `gas`, `structLogs`, and `returnValue` for the traced transaction. The `structLogs` are an array of logs, which contains the following fields: +`Promise` : Returns the `gas`, `structLogs`, and `returnValue` for the traced transaction. The `structLogs` are an array of logs, which contains the following fields: - `depth`: The execution depth. - `error`: Information about an error, if one occurred. @@ -156,15 +156,11 @@ Executes a new message call immediately without creating a transaction on the bl - `transaction: any` : The transaction call object as seen in source. - `blockNumber: QUANTITY | TAG` : Integer block number, or the string "latest", "earliest" or "pending". - `overrides: CallOverrides`: State overrides to apply during the simulation. + - `CallOverrides` - An address-to-state mapping, where each entry specifies some -state to be ephemerally overridden prior to executing the call. Each address maps to an object containing: - - `balance: QUANTITY` (optional) - The balance to set for the account before executing the call. - - `nonce: QUANTITY` (optional) - The nonce to set for the account before executing the call. - - `code: DATA` (optional) - The EVM bytecode to set for the account before executing the call. - - `state: OBJECT` (optional\*) - Key-value mapping to override _all_ slots in the account storage before executing the call. - - `stateDiff: OBJECT` (optional\*) - Key-value mapping to override _individual_ slots in the account storage before executing the call. + state to be ephemerally overridden prior to executing the call. Each address maps to an object containing: - `balance: QUANTITY` (optional) - The balance to set for the account before executing the call. - `nonce: QUANTITY` (optional) - The nonce to set for the account before executing the call. - `code: DATA` (optional) - The EVM bytecode to set for the account before executing the call. - `state: OBJECT` (optional\*) - Key-value mapping to override _all_ slots in the account storage before executing the call. - `stateDiff: OBJECT` (optional\*) - Key-value mapping to override _individual_ slots in the account storage before executing the call. - _\*Note - `state` and `stateDiff` fields are mutually exclusive._ + _\*Note - `state` and `stateDiff` fields are mutually exclusive._ ##### Returns @@ -198,7 +194,7 @@ Generates and returns an estimate of how much gas is necessary to allow the tran ##### Arguments -- `transaction: TypedRpcTransaction` : The transaction call object as seen in source. +- `transaction: Ethereum.Transaction` : The transaction call object as seen in source. - `blockNumber: QUANTITY | TAG` : Integer block number, or the string "latest", "earliest" or "pending". ##### Returns @@ -243,7 +239,7 @@ Returns information about a block by block hash. ##### Returns -`Promise` : The block, `null` if the block doesn't exist. +`Promise>` : The block, `null` if the block doesn't exist. --- @@ -258,7 +254,7 @@ Returns information about a block by block number. ##### Returns -`Promise` : The block, `null` if the block doesn't exist. +`Promise>` : The block, `null` if the block doesn't exist. --- @@ -359,7 +355,7 @@ Returns an array of all logs matching a given filter object. ##### Arguments -- `filter: FilterArgs` : The filter options as seen in source. +- `filter: Ethereum.LogsFilter` : The filter options as seen in source. ##### Returns @@ -452,7 +448,7 @@ Returns the receipt of a transaction by transaction hash. ##### Returns -`Promise` : Returns the receipt of a transaction by transaction hash. +`Promise` : Returns the receipt of a transaction by transaction hash. --- @@ -578,7 +574,7 @@ Creates a filter object, based on filter options, to notify when the state chang ##### Arguments -- `filter?: RangeFilterArgs` : The filter options as seen in source. +- `filter?: Ethereum.Filter` : The filter options as seen in source. ##### Returns @@ -626,7 +622,7 @@ Creates new message call transaction or a contract creation, if the data field c ##### Arguments -- `transaction: TypedRpcTransaction` : The transaction call object as seen in source. +- `transaction: Ethereum.Transaction` : The transaction call object as seen in source. ##### Returns @@ -655,7 +651,7 @@ Signs a transaction that can be submitted to the network at a later time using ` ##### Arguments -- `transaction: TypedRpcTransaction` : The transaction call object as seen in source. +- `transaction: Ethereum.Transaction` : The transaction call object as seen in source. ##### Returns @@ -670,7 +666,7 @@ Identical to eth_signTypedData_v4. ##### Arguments - `address: DATA` : Address of the account that will sign the messages. -- `typedData: TypedData` : Typed structured data to be signed. +- `typedData: Ethereum.TypedData` : Typed structured data to be signed. ##### Returns @@ -683,7 +679,7 @@ Identical to eth_signTypedData_v4. ##### Arguments - `address: DATA` : Address of the account that will sign the messages. -- `typedData: TypedData` : Typed structured data to be signed. +- `typedData: Ethereum.TypedData` : Typed structured data to be signed. ##### Returns @@ -728,7 +724,7 @@ Starts a subscription to a particular event. For every event that matches the su ##### Arguments -- `subscriptionName: SubscriptionName` : Name for the subscription. +- `subscriptionName: Ethereum.SubscriptionName` : Name for the subscription. ##### Returns @@ -766,7 +762,7 @@ Cancel a subscription to a particular event. Returns a boolean indicating if the ##### Arguments -- `subscriptionId: SubscriptionId` : The ID of the subscription to unsubscribe to. +- `subscriptionId: Ethereum.SubscriptionId` : The ID of the subscription to unsubscribe to. ##### Returns @@ -1086,8 +1082,8 @@ Validate the given passphrase and submit transaction. ##### Arguments -- `transaction: TypedRpcTransaction` -- `passphrase: string` : The passphrase to decrpyt the private key belonging to `tx.from`. +- `transaction: Ethereum.Transaction` +- `passphrase: string` : The passphrase to decrypt the private key belonging to `tx.from`. ##### Returns @@ -1101,7 +1097,7 @@ Validates the given passphrase and signs a transaction that can be submitted to ##### Arguments -- `transaction: TypedRpcTransaction` : The transaction call object as seen in source. +- `transaction: Ethereum.Transaction` : The transaction call object as seen in source. - `passphrase: string` ##### Returns @@ -1233,7 +1229,7 @@ Creates a whisper message and injects it into the network for distribution. ##### Arguments -- `postData: WhisperPostObject` +- `postData: Ethereum.WhisperPostObject` ##### Returns @@ -1265,6 +1261,16 @@ Returns the current whisper protocol version. --- +#### txpool_content() + +Returns the current content of the transaction pool. + +##### Returns + +`Promise` : The transactions currently pending or queued in the transaction pool. + +--- + #### web3_clientVersion Returns the current client version. diff --git a/src/chains/ethereum/ethereum/index.ts b/src/chains/ethereum/ethereum/index.ts index a5ac925b01..8693d5d928 100644 --- a/src/chains/ethereum/ethereum/index.ts +++ b/src/chains/ethereum/ethereum/index.ts @@ -6,3 +6,4 @@ */ export * from "./src/connector"; +export * from "./src/api-types"; diff --git a/src/chains/ethereum/ethereum/package-lock.json b/src/chains/ethereum/ethereum/package-lock.json index 2f2dbaca3d..92a2932380 100644 --- a/src/chains/ethereum/ethereum/package-lock.json +++ b/src/chains/ethereum/ethereum/package-lock.json @@ -7182,9 +7182,9 @@ } }, "typescript": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", - "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==", + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", "dev": true }, "typical": { diff --git a/src/chains/ethereum/ethereum/package.json b/src/chains/ethereum/ethereum/package.json index 343bc16a3e..9ca077017d 100644 --- a/src/chains/ethereum/ethereum/package.json +++ b/src/chains/ethereum/ethereum/package.json @@ -112,7 +112,7 @@ "superagent": "6.1.0", "ts-node": "10.4.0", "typedoc": "0.22.10", - "typescript": "4.5.2", + "typescript": "4.6.4", "web3": "1.7.0" }, "optionalDependencies": { diff --git a/src/chains/ethereum/ethereum/src/api-types.ts b/src/chains/ethereum/ethereum/src/api-types.ts new file mode 100644 index 0000000000..3a7c97c1e8 --- /dev/null +++ b/src/chains/ethereum/ethereum/src/api-types.ts @@ -0,0 +1,197 @@ +import type * as EthSigUtil from "eth-sig-util"; +import type * as TransactionTypes from "@ganache/ethereum-transaction"; +import type * as UtilTypes from "@ganache/ethereum-utils"; +import type { EthereumProvider, Externalize } from "./provider"; +import { BlockHeader } from "@ganache/ethereum-block"; +import { Data, Quantity } from "@ganache/utils"; +import { CallOverrides } from "./helpers/run-call"; +import { Log, InternalTag } from "@ganache/ethereum-utils"; + +type EthSignedDataParams = Parameters< + typeof EthSigUtil.signTypedData_v4 +>[1]["data"]; + +type AsCall = Flatten< + Omit & { + readonly from?: string; + } +>; +type AsPooled = Flatten< + Omit & { + blockNumber: null; + blockHash: null; + transactionIndex: null; + } +>; + +type PublicPrivate = "public" | "private"; + +/** + * Since our types come from all over the place and get smushed together and + * pulled apart, we "Flatten" (there is probably a + * better word) these type complexities by using a TypeScript trick: + * `Pick`. This picks all the keys (and their values) from T, + * resulting in the same type shape, but the intermediate types are all skipped + * and intersections are simplified. + * + * ``` + * type SomeTypes = {prop: string, prop2: number}; + * type Thing = Omit & {addProp: true}; + * ``` + * gets turned into + * ``` + * type Thing = {prop: string, addProp: true} + * ``` + */ +type Flatten = Pick; + +/** Public types */ +export namespace Ethereum { + export type Provider = EthereumProvider; + export type Tag = keyof typeof InternalTag; + + //#region trace/debug + export type TraceTransactionOptions = UtilTypes.TraceTransactionOptions; + export type TraceTransactionResult

    = + P extends "public" + ? Externalize> + : UtilTypes.TraceTransactionResult; + export type StorageRangeAtResult

    = + P extends "public" + ? Externalize> + : UtilTypes.StorageRangeAtResult; + //#endregion + + //#region subscriptions/filters + export type SubscriptionOptions = UtilTypes.BaseFilterArgs; + export type LogsFilter = UtilTypes.FilterArgs; + export type Filter = UtilTypes.RangeFilterArgs; + export type SubscriptionName = UtilTypes.SubscriptionName; + export type SubscriptionId = UtilTypes.SubscriptionId; + export type Logs = Log[]; + //#endregion subscriptions/filters + + //#region transactions + export namespace Transaction { + export type Legacy = Flatten; + export type EIP1559 = + Flatten; + export type EIP2930 = + Flatten; + + /** + * Transaction receipt returned from `eth_getTransactionReceipt` + */ + export type Receipt

    = P extends "public" + ? Externalize> + : TransactionTypes.TransactionReceipt; + } + + /** + * Transaction types sent to `eth_sendTransaction` and + * `personal_sendTransaction` + */ + export type Transaction = + | Ethereum.Transaction.Legacy + | Ethereum.Transaction.EIP1559 + | Ethereum.Transaction.EIP2930; + //#endregion transactions + + //#region call/estimate + export namespace Call { + export namespace Transaction { + export type Legacy = AsCall; + export type EIP1559 = AsCall; + export type EIP2930 = AsCall; + } + + export type Transaction = + | Ethereum.Call.Transaction.Legacy + | Ethereum.Call.Transaction.EIP1559 + | Ethereum.Call.Transaction.EIP2930; + + export type Overrides = CallOverrides; + } + + //#endregion call/estimate + + //#region Pool + export namespace Pool { + export namespace Transaction { + export type Legacy = AsPooled; + export type EIP1559 = AsPooled; + export type EIP2930 = AsPooled; + } + /** + * Pending and Executable transactions that are still in the transaction pool + * and do not yet have a blockNumber, blockHash, and transactionIndex. + */ + export type Transaction

    = AsPooled< + Ethereum.Block.Transaction

    + >; + + // txpool_content + export type Content

    = { + pending: Record>>; + queued: Record>>; + }; + } + //#endregion Pool + + //#region blocks + export namespace Block { + export type Header

    = P extends "public" + ? Externalize> + : BlockHeader; + export namespace Transaction { + export type Legacy = Externalize; + + export type EIP2930 = + Externalize; + + export type EIP1559 = + Externalize; + } + + export type Transaction

    = + P extends "public" + ? Externalize> + : + | TransactionTypes.LegacyTransactionJSON + | TransactionTypes.EIP2930AccessListTransactionJSON + | TransactionTypes.EIP1559FeeMarketTransactionJSON; + } + + /** + * A Block as it is returned from eth_getBlockByNumber and eth_getBlockByHash. + */ + export type Block< + // TODO: the actual type should be `IncludeTransactions extends boolean = false` + // but TypeScript can't yet infer it all the way to our `provider.request` method. + // See: https://github.com/trufflesuite/ganache/issues/2907 + IncludeTransactions extends boolean = true | false, + P extends PublicPrivate = "public" + > = P extends "public" + ? Externalize> + : { + hash: Data; + size: Quantity; + transactions: IncludeTransactions extends true + ? (Ethereum.Block.Transaction

    | Ethereum.Pool.Transaction

    )[] + : Data[]; + uncles: Data[]; + } & Ethereum.Block.Header

    ; + //#endregion blocks + + // Mine (evm_mine) + export type MineOptions = { + timestamp?: number; + blocks?: number; + }; + + // Sign Typed Data + export type TypedData = Exclude; + + // whisper + export type WhisperPostObject = UtilTypes.WhisperPostObject; +} diff --git a/src/chains/ethereum/ethereum/src/api.ts b/src/chains/ethereum/ethereum/src/api.ts index 4158871f3a..78092ee40c 100644 --- a/src/chains/ethereum/ethereum/src/api.ts +++ b/src/chains/ethereum/ethereum/src/api.ts @@ -6,26 +6,16 @@ import { VM_EXCEPTIONS, CodedError, DATA, - WhisperPostObject, - BaseFilterArgs, - Filter, - FilterArgs, + InternalFilter, FilterTypes, QUANTITY, - RangeFilterArgs, - StorageRangeResult, - SubscriptionId, - SubscriptionName, - EthereumRawAccount, - TransactionTraceOptions, - TraceTransactionResult + EthereumRawAccount } from "@ganache/ethereum-utils"; import { BaseFeeHeader, Block, RuntimeBlock } from "@ganache/ethereum-block"; import { - TypedRpcTransaction, + Transaction, TransactionFactory, - TypedTransaction, - TypedTransactionJSON + TypedTransaction } from "@ganache/ethereum-transaction"; import { toRpcSig, @@ -33,7 +23,7 @@ import { hashPersonalMessage, KECCAK256_NULL } from "ethereumjs-util"; -import { TypedData as NotTypedData, signTypedData_v4 } from "eth-sig-util"; +import { signTypedData_v4 } from "eth-sig-util"; import { Data, Heap, @@ -58,16 +48,16 @@ import { decode } from "@ganache/rlp"; import { Address } from "@ganache/ethereum-address"; import { GanacheRawBlock } from "@ganache/ethereum-block"; import { Capacity } from "./miner/miner"; -import { CallOverrides } from "./helpers/run-call"; +import { Ethereum } from "./api-types"; async function autofillDefaultTransactionValues( tx: TypedTransaction, eth_estimateGas: ( - tx: TypedRpcTransaction, - tag: QUANTITY | Tag + tx: Ethereum.Transaction, + tag: QUANTITY | Ethereum.Tag ) => Promise, eth_maxPriorityFeePerGas: () => Promise, - transaction: TypedRpcTransaction, + transaction: Ethereum.Transaction, blockchain: Blockchain, options: EthereumInternalOptions ) { @@ -112,13 +102,6 @@ const RPC_MODULES = { } as const; //#endregion -//#region misc types -type TypedData = Exclude< - Parameters[1]["data"], - NotTypedData ->; -//#endregion - //#region helpers /** * Combines RuntimeErrors for a list of rejected or reverted transactions. @@ -163,7 +146,7 @@ export default class EthereumApi implements Api { id => () => Quantity.from(++id) )(0); - readonly #filters = new Map(); + readonly #filters = new Map(); readonly #subscriptions = new Map(); readonly #options: EthereumInternalOptions; readonly #blockchain: Blockchain; @@ -201,7 +184,11 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(3) - async db_putString(dbName: string, key: string, value: string) { + async db_putString( + dbName: string, + key: string, + value: string + ): Promise { return false; } @@ -306,14 +293,9 @@ export default class EthereumApi implements Api { * ``` */ async evm_mine(timestamp: number): Promise<"0x0">; - async evm_mine(options: { - timestamp?: number; - blocks?: number; - }): Promise<"0x0">; + async evm_mine(options: Ethereum.MineOptions): Promise<"0x0">; @assertArgLength(0, 1) - async evm_mine( - arg?: number | { timestamp?: number; blocks?: number } - ): Promise<"0x0"> { + async evm_mine(arg?: number | Ethereum.MineOptions): Promise<"0x0"> { const blockchain = this.#blockchain; const options = this.#options; const vmErrorsOnRPCResponse = options.chain.vmErrorsOnRPCResponse; @@ -929,8 +911,8 @@ export default class EthereumApi implements Api { */ @assertArgLength(1, 2) async eth_estimateGas( - transaction: TypedRpcTransaction, - blockNumber: QUANTITY | Tag = Tag.latest + transaction: Ethereum.Transaction, + blockNumber: QUANTITY | Ethereum.Tag = Tag.latest ): Promise { const blockchain = this.#blockchain; const blocks = blockchain.blocks; @@ -943,7 +925,10 @@ export default class EthereumApi implements Api { }; return new Promise((resolve, reject) => { const { coinbase } = blockchain; - const tx = TransactionFactory.fromRpc(transaction, blockchain.common); + const tx = TransactionFactory.fromRpc( + transaction as Transaction, + blockchain.common + ); if (tx.from == null) { tx.from = coinbase; } @@ -1061,11 +1046,18 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(1, 2) - async eth_getBlockByNumber(number: QUANTITY | Tag, transactions = false) { + async eth_getBlockByNumber( + number: QUANTITY | Ethereum.Tag, + transactions?: IncludeTransactions + ): Promise | null> { + if (typeof transactions === "undefined") { + transactions = false as IncludeTransactions; + } const block = await this.#blockchain.blocks .get(number) .catch(_ => null); - return block ? block.toJSON(transactions) : null; + // @ts-ignore + return block ? block.toJSON(transactions) : null; } /** @@ -1119,11 +1111,17 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(1, 2) - async eth_getBlockByHash(hash: DATA, transactions = false) { + async eth_getBlockByHash( + hash: DATA, + transactions?: IncludeTransactions + ): Promise | null> { + if (typeof transactions === "undefined") { + transactions = false as IncludeTransactions; + } const block = await this.#blockchain.blocks .getByHash(hash) .catch(_ => null); - return block ? block.toJSON(transactions) : null; + return block ? block.toJSON(transactions) : null; } /** @@ -1138,7 +1136,9 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(1) - async eth_getBlockTransactionCountByNumber(blockNumber: QUANTITY | Tag) { + async eth_getBlockTransactionCountByNumber( + blockNumber: QUANTITY | Ethereum.Tag + ) { const { blocks } = this.#blockchain; const blockNum = blocks.getEffectiveNumber(blockNumber); const rawBlock = await blocks.getRawByBlockNumber(blockNum); @@ -1235,7 +1235,10 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(2) - async eth_getTransactionByBlockHashAndIndex(hash: DATA, index: QUANTITY) { + async eth_getTransactionByBlockHashAndIndex( + hash: DATA, + index: QUANTITY + ): Promise | null> { const blockchain = this.#blockchain; const block = await blockchain.blocks .getByHash(hash) @@ -1282,9 +1285,9 @@ export default class EthereumApi implements Api { */ @assertArgLength(2) async eth_getTransactionByBlockNumberAndIndex( - number: QUANTITY | Tag, + number: QUANTITY | Ethereum.Tag, index: QUANTITY - ) { + ): Promise | null> { const blockchain = this.#blockchain; const block = await blockchain.blocks.get(number).catch(_ => null); if (!block) return null; @@ -1321,7 +1324,7 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(1) - async eth_getUncleCountByBlockNumber(blockNumber: QUANTITY | Tag) { + async eth_getUncleCountByBlockNumber(blockNumber: QUANTITY | Ethereum.Tag) { return RPCQUANTITY_ZERO; } @@ -1350,9 +1353,11 @@ export default class EthereumApi implements Api { * * `nonce`: `DATA`, 8 Bytes - Hash of the generated proof-of-work. `null` when pending. * * `totalDifficulty`: `QUANTITY` - Integer of the total difficulty of the chain until this block. * * `size`: `QUANTITY` - Integer the size of the block in bytes. - * * `transactions`: `Array` - Array of transaction objects or 32 Bytes transaction hashes depending on the last parameter. * * `uncles`: `Array` - Array of uncle hashes. * + * **NOTE: **The return does not contain a list of transactions in the uncle + * block, to get this, make another request to `eth_getBlockByHash`. + * * @example * ```javascript * const blockHash = await provider.send("eth_getBlockByNumber", ["latest"] ); @@ -1362,7 +1367,7 @@ export default class EthereumApi implements Api { */ @assertArgLength(2) async eth_getUncleByBlockHashAndIndex(hash: DATA, index: QUANTITY) { - return null as ReturnType; + return null as Omit, "transactions">; } /** @@ -1390,9 +1395,11 @@ export default class EthereumApi implements Api { * * `nonce`: `DATA`, 8 Bytes - Hash of the generated proof-of-work. `null` when pending. * * `totalDifficulty`: `QUANTITY` - Integer of the total difficulty of the chain until this block. * * `size`: `QUANTITY` - Integer the size of the block in bytes. - * * `transactions`: `Array` - Array of transaction objects or 32 Bytes transaction hashes depending on the last parameter. * * `uncles`: `Array` - Array of uncle hashes. * + * * **NOTE: **The return does not contain a list of transactions in the uncle + * block, to get this, make another request to `eth_getBlockByHash`. + * * @example * ```javascript * const block = await provider.send("eth_getUncleByBlockNumberAndIndex", ["latest", "0x0"] ); @@ -1401,10 +1408,10 @@ export default class EthereumApi implements Api { */ @assertArgLength(2) async eth_getUncleByBlockNumberAndIndex( - blockNumber: QUANTITY | Tag, + blockNumber: QUANTITY | Ethereum.Tag, uncleIndex: QUANTITY ) { - return null as ReturnType; + return null as Omit, "transactions">; } /** @@ -1451,7 +1458,7 @@ export default class EthereumApi implements Api { * * @param hashRate - A hexadecimal string representation (32 bytes) of the hash rate. * @param clientID - A random hexadecimal(32 bytes) ID identifying the client. - * @returns `true` if submitting went through succesfully and `false` otherwise. + * @returns `true` if submitting went through successfully and `false` otherwise. * @example * ```javascript * const hashRate = "0x0000000000000000000000000000000000000000000000000000000000000001"; @@ -1585,7 +1592,7 @@ export default class EthereumApi implements Api { @assertArgLength(1, 2) async eth_getBalance( address: DATA, - blockNumber: QUANTITY | Tag = Tag.latest + blockNumber: QUANTITY | Ethereum.Tag = Tag.latest ) { return this.#blockchain.accounts.getBalance( Address.from(address), @@ -1622,7 +1629,10 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(1, 2) - async eth_getCode(address: DATA, blockNumber: QUANTITY | Tag = Tag.latest) { + async eth_getCode( + address: DATA, + blockNumber: QUANTITY | Ethereum.Tag = Tag.latest + ) { const { accounts } = this.#blockchain; return accounts.getCode(Address.from(address), blockNumber); } @@ -1660,7 +1670,7 @@ export default class EthereumApi implements Api { async eth_getStorageAt( address: DATA, position: QUANTITY, - blockNumber: QUANTITY | Tag = Tag.latest + blockNumber: QUANTITY | Ethereum.Tag = Tag.latest ) { const blockchain = this.#blockchain; const blockNum = blockchain.blocks.getEffectiveNumber(blockNumber); @@ -1730,7 +1740,13 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(1) - async eth_getTransactionByHash(transactionHash: DATA) { + async eth_getTransactionByHash( + transactionHash: DATA + ): Promise< + | Ethereum.Block.Transaction<"private"> + | Ethereum.Pool.Transaction<"private"> + | null + > { const { transactions } = this.#blockchain; const hashBuffer = Data.from(transactionHash).toBuffer(); @@ -1767,7 +1783,9 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(1) - async eth_getTransactionReceipt(transactionHash: DATA) { + async eth_getTransactionReceipt( + transactionHash: DATA + ): Promise> { const { transactions, transactionReceipts, blocks, common } = this.#blockchain; const dataHash = Data.from(transactionHash); @@ -1831,10 +1849,13 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(1) - async eth_sendTransaction(transaction: TypedRpcTransaction) { + async eth_sendTransaction(transaction: Ethereum.Transaction): Promise { const blockchain = this.#blockchain; - const tx = TransactionFactory.fromRpc(transaction, blockchain.common); + const tx = TransactionFactory.fromRpc( + transaction as Transaction, + blockchain.common + ); if (tx.from == null) { throw new Error("from not found; is required"); } @@ -1884,9 +1905,12 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(1) - async eth_signTransaction(transaction: TypedRpcTransaction) { + async eth_signTransaction(transaction: Ethereum.Transaction): Promise { const blockchain = this.#blockchain; - const tx = TransactionFactory.fromRpc(transaction, blockchain.common); + const tx = TransactionFactory.fromRpc( + transaction as Transaction, + blockchain.common + ); if (tx.from == null) { throw new Error("from not found; is required"); @@ -1905,7 +1929,7 @@ export default class EthereumApi implements Api { } tx.signAndHash(privateKey.toBuffer()); - return Data.from(tx.serialized).toString(); + return Data.from(tx.serialized); } /** * Creates new message call transaction or a contract creation for signed transactions. @@ -2023,7 +2047,7 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(2) - async eth_signTypedData(address: DATA, typedData: TypedData) { + async eth_signTypedData(address: DATA, typedData: Ethereum.TypedData) { return this.eth_signTypedData_v4(address, typedData); } @@ -2083,7 +2107,7 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(2) - async eth_signTypedData_v4(address: DATA, typedData: TypedData) { + async eth_signTypedData_v4(address: DATA, typedData: Ethereum.TypedData) { const account = Address.from(address).toString().toLowerCase(); const privateKey = this.#wallet.unlockedAccounts.get(account); @@ -2131,7 +2155,9 @@ export default class EthereumApi implements Api { * console.log(subscriptionId); * ``` */ - eth_subscribe(subscriptionName: SubscriptionName): PromiEvent; + eth_subscribe( + subscriptionName: Ethereum.SubscriptionName + ): PromiEvent; /** * Starts a subscription to a particular event. For every event that matches * the subscription a JSON-RPC notification with event details and @@ -2145,13 +2171,13 @@ export default class EthereumApi implements Api { * @returns A subscription id. */ eth_subscribe( - subscriptionName: Extract, - options: BaseFilterArgs + subscriptionName: Extract, + options: Ethereum.SubscriptionOptions ): PromiEvent; @assertArgLength(1, 2) eth_subscribe( - subscriptionName: SubscriptionName, - options?: BaseFilterArgs + subscriptionName: Ethereum.SubscriptionName, + options?: Ethereum.SubscriptionOptions ): PromiEvent { const subscriptions = this.#subscriptions; switch (subscriptionName) { @@ -2269,7 +2295,7 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(1) - async eth_unsubscribe(subscriptionId: SubscriptionId) { + async eth_unsubscribe(subscriptionId: Ethereum.SubscriptionId) { const subscriptions = this.#subscriptions; const unsubscribe = subscriptions.get(subscriptionId); if (unsubscribe) { @@ -2293,7 +2319,7 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(0) - async eth_newBlockFilter() { + async eth_newBlockFilter(): Promise { const unsubscribe = this.#blockchain.on("block", (block: Block) => { value.updates.push(block.hash()); }); @@ -2320,7 +2346,7 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(0) - async eth_newPendingTransactionFilter() { + async eth_newPendingTransactionFilter(): Promise { const unsubscribe = this.#blockchain.on( "pendingTransaction", (transaction: TypedTransaction) => { @@ -2366,7 +2392,7 @@ export default class EthereumApi implements Api { * * `toBlock`: `QUANTITY | TAG` (optional) - Integer block number, or the string "latest", "earliest" * or "pending". * * `address`: `DATA | Array` (optional) - Contract address or a list of addresses from which the logs should originate. - * * `topics`: `Array of DATA` (optional) - Array of 32 Bytes `DATA` topcis. Topics are order-dependent. Each topic can also + * * `topics`: `Array of DATA` (optional) - Array of 32 Bytes `DATA` topics. Topics are order-dependent. Each topic can also * be an array of `DATA` with "or" options. * * @param filter - The filter options as seen in source. @@ -2379,7 +2405,7 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(0, 1) - async eth_newFilter(filter?: RangeFilterArgs) { + async eth_newFilter(filter?: Ethereum.Filter): Promise { const blockchain = this.#blockchain; if (filter == null) filter = {}; const { addresses, topics } = parseFilterDetails(filter || {}); @@ -2457,7 +2483,7 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(1) - async eth_getFilterChanges(filterId: QUANTITY) { + async eth_getFilterChanges(filterId: QUANTITY): Promise { const filter = this.#filters.get(Quantity.from(filterId).toString()); if (filter) { const updates = filter.updates; @@ -2483,7 +2509,7 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(1) - async eth_uninstallFilter(filterId: QUANTITY) { + async eth_uninstallFilter(filterId: QUANTITY): Promise { const id = Quantity.from(filterId).toString(); const filter = this.#filters.get(id); if (!filter) return false; @@ -2527,7 +2553,7 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(1) - async eth_getFilterLogs(filterId: QUANTITY) { + async eth_getFilterLogs(filterId: QUANTITY): Promise { const filter = this.#filters.get(Quantity.from(filterId).toString()); if (filter && filter.type === FilterTypes.log) { return this.eth_getLogs(filter.filter); @@ -2545,7 +2571,7 @@ export default class EthereumApi implements Api { * * `toBlock`: `QUANTITY | TAG` (optional) - Integer block number, or the string "latest", "earliest" * or "pending". * * `address`: `DATA | Array` (optional) - Contract address or a list of addresses from which the logs should originate. - * * `topics`: `Array of DATA` (optional) - Array of 32 Bytes `DATA` topcis. Topics are order-dependent. Each topic can also + * * `topics`: `Array of DATA` (optional) - Array of 32 Bytes `DATA` topics. Topics are order-dependent. Each topic can also * be an array of `DATA` with "or" options. * * `blockHash`: `DATA`, 32 Bytes (optional) - Hash of the block to restrict logs from. If `blockHash` is present, * then neither `fromBlock` or `toBlock` are allowed. @@ -2584,7 +2610,7 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(1) - async eth_getLogs(filter: FilterArgs) { + async eth_getLogs(filter: Ethereum.LogsFilter): Promise { return this.#blockchain.blockLogs.getLogs(filter); } @@ -2609,8 +2635,8 @@ export default class EthereumApi implements Api { @assertArgLength(1, 2) async eth_getTransactionCount( address: DATA, - blockNumber: QUANTITY | Tag = Tag.latest - ) { + blockNumber: QUANTITY | Ethereum.Tag = Tag.latest + ): Promise { return this.#blockchain.accounts.getNonce( Address.from(address), blockNumber @@ -2666,10 +2692,10 @@ export default class EthereumApi implements Api { */ @assertArgLength(1, 3) async eth_call( - transaction: any, - blockNumber: QUANTITY | Tag = Tag.latest, - overrides: CallOverrides = {} - ) { + transaction: Ethereum.Call.Transaction, + blockNumber: QUANTITY | Ethereum.Tag = Tag.latest, + overrides: Ethereum.Call.Overrides = {} + ): Promise { const blockchain = this.#blockchain; const common = blockchain.common; const blocks = blockchain.blocks; @@ -2830,8 +2856,8 @@ export default class EthereumApi implements Api { */ async debug_traceTransaction( transactionHash: DATA, - options?: TransactionTraceOptions - ): Promise { + options?: Ethereum.TraceTransactionOptions + ): Promise> { return this.#blockchain.traceTransaction(transactionHash, options || {}); } @@ -2884,7 +2910,7 @@ export default class EthereumApi implements Api { contractAddress: DATA, startKey: DATA, maxResult: number - ): Promise { + ): Promise> { return this.#blockchain.storageRangeAt( blockHash, Quantity.from(transactionIndex).toNumber(), @@ -2907,7 +2933,7 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(0) - async personal_listAccounts() { + async personal_listAccounts(): Promise { return this.#wallet.addresses; } @@ -2925,7 +2951,7 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(1) - async personal_newAccount(passphrase: string) { + async personal_newAccount(passphrase: string): Promise

    { if (typeof passphrase !== "string") { throw new Error("missing value for required argument `passphrase`"); } @@ -2956,7 +2982,10 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(2) - async personal_importRawKey(rawKey: DATA, passphrase: string) { + async personal_importRawKey( + rawKey: DATA, + passphrase: string + ): Promise
    { if (typeof passphrase !== "string") { throw new Error("missing value for required argument `passphrase`"); } @@ -2983,7 +3012,7 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(1) - async personal_lockAccount(address: DATA) { + async personal_lockAccount(address: DATA): Promise { return this.#wallet.lockAccount(address.toLowerCase()); } @@ -3016,7 +3045,7 @@ export default class EthereumApi implements Api { address: DATA, passphrase: string, duration: number = 300 - ) { + ): Promise { const addy = new Address(address); return this.#wallet.unlockAccount(addy, passphrase, duration); } @@ -3054,11 +3083,14 @@ export default class EthereumApi implements Api { */ @assertArgLength(2) async personal_sendTransaction( - transaction: TypedRpcTransaction, + transaction: Ethereum.Transaction, passphrase: string - ) { + ): Promise { const blockchain = this.#blockchain; - const tx = TransactionFactory.fromRpc(transaction, blockchain.common); + const tx = TransactionFactory.fromRpc( + transaction as Transaction, + blockchain.common + ); const from = tx.from; if (from == null) { throw new Error("from not found; is required"); @@ -3110,11 +3142,14 @@ export default class EthereumApi implements Api { */ @assertArgLength(2) async personal_signTransaction( - transaction: TypedRpcTransaction, + transaction: Ethereum.Transaction, passphrase: string - ) { + ): Promise { const blockchain = this.#blockchain; - const tx = TransactionFactory.fromRpc(transaction, blockchain.common); + const tx = TransactionFactory.fromRpc( + transaction as Transaction, + blockchain.common + ); if (tx.from == null) { throw new Error("from not found; is required"); @@ -3123,7 +3158,7 @@ export default class EthereumApi implements Api { const wallet = this.#wallet; const secretKey = await wallet.getFromKeyFile(tx.from, passphrase); tx.signAndHash(secretKey); - return Data.from(tx.serialized).toString(); + return Data.from(tx.serialized); } //#endregion @@ -3137,7 +3172,7 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(0) - async rpc_modules() { + async rpc_modules(): Promise { return RPC_MODULES; } //#endregion @@ -3154,7 +3189,7 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(0) - async shh_newIdentity() { + async shh_newIdentity(): Promise { return "0x00"; } @@ -3169,7 +3204,7 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(1) - async shh_hasIdentity(address: DATA) { + async shh_hasIdentity(address: DATA): Promise { return false; } @@ -3179,7 +3214,7 @@ export default class EthereumApi implements Api { * @returns The address of the new group. */ @assertArgLength(0) - async shh_newGroup() { + async shh_newGroup(): Promise { return "0x00"; } @@ -3194,7 +3229,7 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(1) - async shh_addToGroup(address: DATA) { + async shh_addToGroup(address: DATA): Promise { return false; } @@ -3211,7 +3246,7 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(2) - async shh_newFilter(to: DATA, topics: DATA[]) { + async shh_newFilter(to: DATA, topics: DATA[]): Promise { return false; } @@ -3227,7 +3262,7 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(1) - async shh_uninstallFilter(id: QUANTITY) { + async shh_uninstallFilter(id: QUANTITY): Promise { return false; } @@ -3242,7 +3277,7 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(1) - async shh_getFilterChanges(id: QUANTITY) { + async shh_getFilterChanges(id: QUANTITY): Promise<[]> { return []; } @@ -3257,7 +3292,7 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(1) - async shh_getMessages(id: QUANTITY) { + async shh_getMessages(id: QUANTITY): Promise { return false; } @@ -3272,7 +3307,7 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(1) - async shh_post(postData: WhisperPostObject) { + async shh_post(postData: Ethereum.WhisperPostObject): Promise { return false; } @@ -3286,7 +3321,7 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(0) - async shh_version() { + async shh_version(): Promise { return "2"; } //#endregion @@ -3307,35 +3342,38 @@ export default class EthereumApi implements Api { * ``` */ @assertArgLength(0) - async txpool_content(): Promise<{ - pending: Map>; - queued: Map>; - }> { + async txpool_content(): Promise> { const { transactions, common } = this.#blockchain; - const { transactionPool } = transactions; + const { + transactionPool: { executables, origins } + } = transactions; const processMap = (map: Map>) => { - let res = new Map>(); - for (let [_, transactions] of map) { - const arr = transactions.array; - for (let i = 0; i < transactions.length; ++i) { - const tx = arr[i]; - const from = tx.from.toString(); + let res: Record< + string, + Record> + > = {}; + for (let [_, { array, length }] of map) { + for (let i = 0; i < length; ++i) { + const transaction = array[i]; + const from = transaction.from.toString(); if (res[from] === undefined) { res[from] = {}; } // The nonce keys are actual decimal numbers (as strings) and not // hex literals (based on what geth returns). - const nonce = tx.nonce.toBigInt().toString(); - res[from][nonce] = tx.toJSON(common); + const nonce = transaction.nonce.toBigInt().toString(); + res[from][nonce] = transaction.toJSON( + common + ) as Ethereum.Pool.Transaction<"private">; } } return res; }; return { - pending: processMap(transactionPool.executables.pending), - queued: processMap(transactionPool.origins) + pending: processMap(executables.pending), + queued: processMap(origins) }; } diff --git a/src/chains/ethereum/ethereum/src/blockchain.ts b/src/chains/ethereum/ethereum/src/blockchain.ts index 846c2f9d3e..573ffc2091 100644 --- a/src/chains/ethereum/ethereum/src/blockchain.ts +++ b/src/chains/ethereum/ethereum/src/blockchain.ts @@ -11,11 +11,11 @@ import { RuntimeError, CallError, StorageKeys, - StorageRangeResult, + StorageRangeAtResult, StorageRecords, RangedStorageKeys, StructLog, - TransactionTraceOptions, + TraceTransactionOptions, EthereumRawAccount, TraceTransactionResult } from "@ganache/ethereum-utils"; @@ -48,7 +48,7 @@ import { Fork } from "./forking/fork"; import { Address } from "@ganache/ethereum-address"; import { calculateIntrinsicGas, - TransactionReceipt, + InternalTransactionReceipt, VmTransaction, TypedTransaction } from "@ganache/ethereum-transaction"; @@ -503,7 +503,7 @@ export default class Blockchain extends Emittery { #getTransactionLogOutput = ( hash: Buffer, - receipt: TransactionReceipt, + receipt: InternalTransactionReceipt, blockNumber: Quantity, timestamp: string, error: RuntimeError | undefined @@ -1114,7 +1114,7 @@ export default class Blockchain extends Emittery { transaction: VmTransaction, trie: GanacheTrie, newBlock: RuntimeBlock & { transactions: VmTransaction[] }, - options: TransactionTraceOptions, + options: TraceTransactionOptions, keys?: Buffer[], contractAddress?: Buffer ): Promise => { @@ -1399,7 +1399,7 @@ export default class Blockchain extends Emittery { */ public async traceTransaction( transactionHash: string, - options: TransactionTraceOptions + options: TraceTransactionOptions ) { const transactionHashBuffer = Data.from(transactionHash).toBuffer(); // #1 - get block via transaction object @@ -1473,7 +1473,7 @@ export default class Blockchain extends Emittery { contractAddress: string, startKey: string, maxResult: number - ): Promise { + ): Promise { // #1 - get block information const targetBlock = await this.blocks.getByHash(blockHash); diff --git a/src/chains/ethereum/ethereum/src/connector.ts b/src/chains/ethereum/ethereum/src/connector.ts index aaf8e8fbdd..d38dc48f80 100644 --- a/src/chains/ethereum/ethereum/src/connector.ts +++ b/src/chains/ethereum/ethereum/src/connector.ts @@ -10,7 +10,8 @@ import { JsonRpcErrorCode, KnownKeys } from "@ganache/utils"; -import EthereumProvider from "./provider"; +export type { EthereumProvider } from "./provider"; +import { EthereumProvider } from "./provider"; import { RecognizedString, WebSocket, @@ -24,8 +25,6 @@ import { import { bufferify } from "./helpers/bufferify"; type ProviderOptions = EthereumProviderOptions | EthereumLegacyProviderOptions; -export type Provider = EthereumProvider; -export const Provider = EthereumProvider; function isHttp( connection: HttpRequest | WebSocket @@ -43,7 +42,8 @@ export class Connector< > = JsonRpcRequest> > extends Emittery<{ ready: undefined; close: undefined }> - implements IConnector { + implements IConnector +{ #provider: EthereumProvider; static BUFFERIFY_THRESHOLD: number = 100000; diff --git a/src/chains/ethereum/ethereum/src/data-managers/blocklog-manager.ts b/src/chains/ethereum/ethereum/src/data-managers/blocklog-manager.ts index e2ab5803ab..e1ff42187a 100644 --- a/src/chains/ethereum/ethereum/src/data-managers/blocklog-manager.ts +++ b/src/chains/ethereum/ethereum/src/data-managers/blocklog-manager.ts @@ -4,6 +4,7 @@ import Manager from "./manager"; import { Quantity } from "@ganache/utils"; import Blockchain from "../blockchain"; import { parseFilter, parseFilterDetails } from "../helpers/filter-parsing"; +import { Ethereum } from "../api-types"; export default class BlockLogManager extends Manager { #blockchain: Blockchain; @@ -27,7 +28,7 @@ export default class BlockLogManager extends Manager { return log; } - async getLogs(filter: FilterArgs) { + async getLogs(filter: FilterArgs): Promise { const blockchain = this.#blockchain; if ("blockHash" in filter) { const { addresses, topics } = parseFilterDetails(filter); @@ -60,9 +61,7 @@ export default class BlockLogManager extends Manager { // now filter and compute all the blocks' blockLogs (in block order) return Promise.all(pendingLogsPromises).then(blockLogsRange => { - const filteredBlockLogs: ReturnType< - typeof BlockLogs["logToJSON"] - >[] = []; + const filteredBlockLogs: Ethereum.Logs = []; blockLogsRange.forEach(blockLogs => { // TODO(perf): this loops over all addresses for every block. // Maybe make it loop only once? diff --git a/src/chains/ethereum/ethereum/src/data-managers/transaction-manager.ts b/src/chains/ethereum/ethereum/src/data-managers/transaction-manager.ts index f30a21bffc..7e0b5844f0 100644 --- a/src/chains/ethereum/ethereum/src/data-managers/transaction-manager.ts +++ b/src/chains/ethereum/ethereum/src/data-managers/transaction-manager.ts @@ -9,7 +9,7 @@ import { Data, Quantity } from "@ganache/utils"; import { GanacheRawExtraTx, TransactionFactory, - TypedRpcTransaction, + Transaction, TypedTransaction } from "@ganache/ethereum-transaction"; @@ -43,10 +43,9 @@ export default class TransactionManager extends Manager { fromFallback = async (transactionHash: Buffer) => { const { fallback } = this.#blockchain; - const tx = await fallback.request( - "eth_getTransactionByHash", - [Data.from(transactionHash).toString()] - ); + const tx = await fallback.request("eth_getTransactionByHash", [ + Data.from(transactionHash).toString() + ]); if (tx == null) return null; const blockHash = Data.from((tx as any).blockHash, 32); diff --git a/src/chains/ethereum/ethereum/src/data-managers/transaction-receipt-manager.ts b/src/chains/ethereum/ethereum/src/data-managers/transaction-receipt-manager.ts index 3664609502..3d0b633b3b 100644 --- a/src/chains/ethereum/ethereum/src/data-managers/transaction-receipt-manager.ts +++ b/src/chains/ethereum/ethereum/src/data-managers/transaction-receipt-manager.ts @@ -8,13 +8,13 @@ import { BUFFER_ZERO } from "@ganache/utils"; import Blockchain from "../blockchain"; -import { TransactionReceipt } from "@ganache/ethereum-transaction"; +import { InternalTransactionReceipt } from "@ganache/ethereum-transaction"; import { Address } from "@ganache/ethereum-address"; -export default class TransactionReceiptManager extends Manager { +export default class TransactionReceiptManager extends Manager { #blockchain: Blockchain; constructor(base: LevelUp, blockchain: Blockchain) { - super(base, TransactionReceipt); + super(base, InternalTransactionReceipt); this.#blockchain = blockchain; } @@ -45,7 +45,7 @@ export default class TransactionReceiptManager extends Manager = X extends Primitives - ? X - : X extends Quantity | Data | ITraceData - ? string - : { [N in keyof X]: Clean }; -type cleanAndMergePromiseGenerics = Promise< - Type extends Promise ? Clean : never +// Externalize changes any `Quantity`, `Data`, `ITraceData` types into `string` +// as that's how they are after being serialized to JSON. It's be nice if +// `JSON.stringify` did that for us, as our types implement `toJSON()`, but it +// doesn't +export type Externalize = + // if X is a Primitive return it as is + X extends Primitives + ? X + : // if X is a Quantity | Data | ITraceData return `string` + X extends Quantity | Data | ITraceData + ? string + : // if X can be iterated iterate and recurse on each element + { [N in keyof X]: Externalize }; + +// Simplify makes the types more readable +type Simplify = Promise< + Type extends Promise ? Externalize : never >; interface Callback { @@ -113,7 +123,7 @@ type RequestParams = { readonly method: Method; readonly params: OverloadedParameters | undefined; }; -export default class EthereumProvider +export class EthereumProvider extends Emittery<{ message: MessageEvent; data: DataEvent; @@ -124,7 +134,8 @@ export default class EthereumProvider connect: undefined; disconnect: undefined; }> - implements Provider { + implements Provider +{ #options: EthereumInternalOptions; #api: EthereumApi; #executor: Executor; @@ -216,7 +227,7 @@ export default class EthereumProvider public send( method: Method, params?: OverloadedParameters - ): cleanAndMergePromiseGenerics>; + ): Simplify>; /** * @param payload - payload * @param callback - callback @@ -302,7 +313,7 @@ export default class EthereumProvider // this signature is (not) non-standard and is only a ganache thing!!! // we should probably remove it, but I really like it so I haven't yet. method = arg1; - params = (arg2 as unknown) as OverloadedParameters; + params = arg2 as unknown as OverloadedParameters; response = this.request({ method, params }); } else if (typeof arg2 === "function") { // handle backward compatibility with callback-style ganache-core @@ -335,7 +346,7 @@ export default class EthereumProvider */ public async request( args: RequestParams - ): cleanAndMergePromiseGenerics> { + ): Simplify> { const rawResult = await this._requestRaw(args); const value = await rawResult.value; return JSON.parse(JSON.stringify(value)); @@ -354,9 +365,7 @@ export default class EthereumProvider this.#logRequest(method, params); const result = await this.#executor.execute(this.#api, method, params); - const promise = result.value as cleanAndMergePromiseGenerics< - typeof result.value - >; + const promise = result.value as Simplify; if (promise instanceof PromiEvent) { promise.on("message", data => { const normalizedData = JSON.parse(JSON.stringify(data)); diff --git a/src/chains/ethereum/ethereum/tests/api/bzz/bzz.test.ts b/src/chains/ethereum/ethereum/tests/api/bzz/bzz.test.ts index 156264e3bc..023c3dfde1 100644 --- a/src/chains/ethereum/ethereum/tests/api/bzz/bzz.test.ts +++ b/src/chains/ethereum/ethereum/tests/api/bzz/bzz.test.ts @@ -1,6 +1,6 @@ import getProvider from "../../helpers/getProvider"; import assert from "assert"; -import EthereumProvider from "../../../src/provider"; +import { EthereumProvider } from "../../../src/provider"; describe("api", () => { describe("bzz", () => { diff --git a/src/chains/ethereum/ethereum/tests/api/db/db.test.ts b/src/chains/ethereum/ethereum/tests/api/db/db.test.ts index 26a0489706..85b3706eac 100644 --- a/src/chains/ethereum/ethereum/tests/api/db/db.test.ts +++ b/src/chains/ethereum/ethereum/tests/api/db/db.test.ts @@ -1,6 +1,6 @@ import getProvider from "../../helpers/getProvider"; import assert from "assert"; -import EthereumProvider from "../../../src/provider"; +import { EthereumProvider } from "../../../src/provider"; describe("api", () => { describe("db", () => { diff --git a/src/chains/ethereum/ethereum/tests/api/debug/debug.test.ts b/src/chains/ethereum/ethereum/tests/api/debug/debug.test.ts index d539ea0d19..ad5780a30d 100644 --- a/src/chains/ethereum/ethereum/tests/api/debug/debug.test.ts +++ b/src/chains/ethereum/ethereum/tests/api/debug/debug.test.ts @@ -1,7 +1,7 @@ import getProvider from "../../helpers/getProvider"; import compile, { CompileOutput } from "../../helpers/compile"; import assert from "assert"; -import EthereumProvider from "../../../src/provider"; +import { EthereumProvider } from "../../../src/provider"; import path from "path"; import { Quantity, Data } from "@ganache/utils"; diff --git a/src/chains/ethereum/ethereum/tests/api/debug/debug_storageRangeAt.test.ts b/src/chains/ethereum/ethereum/tests/api/debug/debug_storageRangeAt.test.ts index 41fe77c3bb..0ab45df113 100644 --- a/src/chains/ethereum/ethereum/tests/api/debug/debug_storageRangeAt.test.ts +++ b/src/chains/ethereum/ethereum/tests/api/debug/debug_storageRangeAt.test.ts @@ -1,5 +1,5 @@ import assert from "assert"; -import EthereumProvider from "../../../src/provider"; +import { EthereumProvider } from "../../../src/provider"; import getProvider from "../../helpers/getProvider"; import compile from "../../helpers/compile"; import path from "path"; @@ -75,18 +75,18 @@ describe("api", () => { ]); const storage = { - "0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563": { - key: - "0x0000000000000000000000000000000000000000000000000000000000000000", - value: - "0x0000000000000000000000000000000000000000000000000000000000000005" - }, - "0x405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace": { - key: - "0x0000000000000000000000000000000000000000000000000000000000000002", - value: - "0x68656c6c6f207270647200000000000000000000000000000000000000000014" - } + "0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563": + { + key: "0x0000000000000000000000000000000000000000000000000000000000000000", + value: + "0x0000000000000000000000000000000000000000000000000000000000000005" + }, + "0x405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace": + { + key: "0x0000000000000000000000000000000000000000000000000000000000000002", + value: + "0x68656c6c6f207270647200000000000000000000000000000000000000000014" + } }; assert.deepStrictEqual(result.storage, storage); @@ -108,24 +108,24 @@ describe("api", () => { // although we asked for a total number of 4 entries, we only have 3 // and should return the 3 we have const storage = { - "0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563": { - key: - "0x0000000000000000000000000000000000000000000000000000000000000000", - value: - "0x0000000000000000000000000000000000000000000000000000000000000005" - }, - "0x405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace": { - key: - "0x0000000000000000000000000000000000000000000000000000000000000002", - value: - "0x68656c6c6f207270647200000000000000000000000000000000000000000014" - }, - "0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6": { - key: - "0x0000000000000000000000000000000000000000000000000000000000000001", - value: - "0x0000000000000000000000000000000000000000000000000000000000000001" - } + "0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563": + { + key: "0x0000000000000000000000000000000000000000000000000000000000000000", + value: + "0x0000000000000000000000000000000000000000000000000000000000000005" + }, + "0x405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace": + { + key: "0x0000000000000000000000000000000000000000000000000000000000000002", + value: + "0x68656c6c6f207270647200000000000000000000000000000000000000000014" + }, + "0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6": + { + key: "0x0000000000000000000000000000000000000000000000000000000000000001", + value: + "0x0000000000000000000000000000000000000000000000000000000000000001" + } }; assert.deepStrictEqual(result.storage, storage); @@ -156,18 +156,18 @@ describe("api", () => { ]); const storage = { - "0x405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace": { - key: - "0x0000000000000000000000000000000000000000000000000000000000000002", - value: - "0x68656c6c6f207270647200000000000000000000000000000000000000000014" - }, - "0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6": { - key: - "0x0000000000000000000000000000000000000000000000000000000000000001", - value: - "0x0000000000000000000000000000000000000000000000000000000000000001" - } + "0x405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace": + { + key: "0x0000000000000000000000000000000000000000000000000000000000000002", + value: + "0x68656c6c6f207270647200000000000000000000000000000000000000000014" + }, + "0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6": + { + key: "0x0000000000000000000000000000000000000000000000000000000000000001", + value: + "0x0000000000000000000000000000000000000000000000000000000000000001" + } }; assert.deepStrictEqual(result.storage, storage); @@ -184,12 +184,12 @@ describe("api", () => { ]); const storage = { - "0x405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace": { - key: - "0x0000000000000000000000000000000000000000000000000000000000000002", - value: - "0x68656c6c6f207270647200000000000000000000000000000000000000000014" - } + "0x405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace": + { + key: "0x0000000000000000000000000000000000000000000000000000000000000002", + value: + "0x68656c6c6f207270647200000000000000000000000000000000000000000014" + } }; assert.deepStrictEqual(result.storage, storage); @@ -209,18 +209,18 @@ describe("api", () => { ]); const storage = { - "0x405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace": { - key: - "0x0000000000000000000000000000000000000000000000000000000000000002", - value: - "0x68656c6c6f207270647200000000000000000000000000000000000000000014" - }, - "0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6": { - key: - "0x0000000000000000000000000000000000000000000000000000000000000001", - value: - "0x0000000000000000000000000000000000000000000000000000000000000001" - } + "0x405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace": + { + key: "0x0000000000000000000000000000000000000000000000000000000000000002", + value: + "0x68656c6c6f207270647200000000000000000000000000000000000000000014" + }, + "0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6": + { + key: "0x0000000000000000000000000000000000000000000000000000000000000001", + value: + "0x0000000000000000000000000000000000000000000000000000000000000001" + } }; assert.deepStrictEqual(result.storage, storage); assert.strictEqual(result.nextKey, null); @@ -236,24 +236,24 @@ describe("api", () => { ]); const storage = { - "0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563": { - key: - "0x0000000000000000000000000000000000000000000000000000000000000000", - value: - "0x0000000000000000000000000000000000000000000000000000000000000005" - }, - "0x405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace": { - key: - "0x0000000000000000000000000000000000000000000000000000000000000002", - value: - "0x68656c6c6f207270647200000000000000000000000000000000000000000014" - }, - "0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6": { - key: - "0x0000000000000000000000000000000000000000000000000000000000000001", - value: - "0x0000000000000000000000000000000000000000000000000000000000000001" - } + "0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563": + { + key: "0x0000000000000000000000000000000000000000000000000000000000000000", + value: + "0x0000000000000000000000000000000000000000000000000000000000000005" + }, + "0x405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace": + { + key: "0x0000000000000000000000000000000000000000000000000000000000000002", + value: + "0x68656c6c6f207270647200000000000000000000000000000000000000000014" + }, + "0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6": + { + key: "0x0000000000000000000000000000000000000000000000000000000000000001", + value: + "0x0000000000000000000000000000000000000000000000000000000000000001" + } }; assert.deepStrictEqual(result.storage, storage); @@ -342,28 +342,28 @@ describe("api", () => { ]); assert.deepStrictEqual(resultForTx1.storage, { - "0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563": { - key: - "0x0000000000000000000000000000000000000000000000000000000000000000", - value: - "0x0000000000000000000000000000000000000000000000000000000000000019" - } + "0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563": + { + key: "0x0000000000000000000000000000000000000000000000000000000000000000", + value: + "0x0000000000000000000000000000000000000000000000000000000000000019" + } }); assert.deepStrictEqual(resultForTx2.storage, { - "0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563": { - key: - "0x0000000000000000000000000000000000000000000000000000000000000000", - value: - "0x0000000000000000000000000000000000000000000000000000000000000001" - } + "0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563": + { + key: "0x0000000000000000000000000000000000000000000000000000000000000000", + value: + "0x0000000000000000000000000000000000000000000000000000000000000001" + } }); assert.deepStrictEqual(resultForTx3.storage, { - "0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563": { - key: - "0x0000000000000000000000000000000000000000000000000000000000000000", - value: - "0x0000000000000000000000000000000000000000000000000000000000000002" - } + "0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563": + { + key: "0x0000000000000000000000000000000000000000000000000000000000000000", + value: + "0x0000000000000000000000000000000000000000000000000000000000000002" + } }); } finally { await provider.send("evm_revert", [snapshotId]); @@ -459,18 +459,18 @@ describe("api", () => { ]); const storage = { - "0x0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db9": { - key: - "0x000000000000000000000000000000000000000000000000000000000000000b", - value: - "0x776561724c6576656c3300000000000000000000000000000000000000000014" - }, - "0x0ad2b1b513cb2993be7f47396bf45627c5f483cf774fd5875730b55a1dbcc856": { - key: - "0x720c187f2880b2567f9fccc279625ea13024b8b82a6f73e26d9ca6d82ede1cc7", - value: - "0x776561724c6576656c0000000000000000000000000000000000000000000012" - } + "0x0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db9": + { + key: "0x000000000000000000000000000000000000000000000000000000000000000b", + value: + "0x776561724c6576656c3300000000000000000000000000000000000000000014" + }, + "0x0ad2b1b513cb2993be7f47396bf45627c5f483cf774fd5875730b55a1dbcc856": + { + key: "0x720c187f2880b2567f9fccc279625ea13024b8b82a6f73e26d9ca6d82ede1cc7", + value: + "0x776561724c6576656c0000000000000000000000000000000000000000000012" + } }; assert.deepStrictEqual(result.storage, storage); @@ -492,12 +492,12 @@ describe("api", () => { // although we asked for a total number of 4 entries, we only have 1 // left at this point so that's the only one we should see const storage = { - "0xf3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee3": { - key: - "0x0000000000000000000000000000000000000000000000000000000000000008", - value: - "0x0000000000000000000000000000000000000000000000000000000000000002" - } + "0xf3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee3": + { + key: "0x0000000000000000000000000000000000000000000000000000000000000008", + value: + "0x0000000000000000000000000000000000000000000000000000000000000002" + } }; assert.deepStrictEqual(result.storage, storage); diff --git a/src/chains/ethereum/ethereum/tests/api/eth/call.test.ts b/src/chains/ethereum/ethereum/tests/api/eth/call.test.ts index b414f0a16f..ded2448ad4 100644 --- a/src/chains/ethereum/ethereum/tests/api/eth/call.test.ts +++ b/src/chains/ethereum/ethereum/tests/api/eth/call.test.ts @@ -1,5 +1,5 @@ import assert from "assert"; -import EthereumProvider from "../../../src/provider"; +import { EthereumProvider } from "../../../src/provider"; import getProvider from "../../helpers/getProvider"; import compile, { CompileOutput } from "../../helpers/compile"; import { join } from "path"; @@ -17,6 +17,7 @@ import { } from "@ganache/ethereum-transaction"; import { EthereumOptionsConfig } from "@ganache/ethereum-options"; import { GanacheTrie } from "../../../src/helpers/trie"; +import { Transaction } from "@ganache/ethereum-transaction"; const encodeValue = (val: number | string) => { return Quantity.from(val).toBuffer().toString("hex").padStart(64, "0"); @@ -48,7 +49,7 @@ describe("api", () => { let provider: EthereumProvider; let from, to: string; let contractAddress: string; - let tx: object; + let tx: Transaction; before("compile", () => { contract = compile(join(__dirname, "./contracts/EthCall.sol"), { @@ -103,7 +104,7 @@ describe("api", () => { }); it("allows eip-1559 fee market transactions", async () => { - const tx = { + const tx: Transaction = { from, to: contractAddress, data: "0x3fa4f245", @@ -123,7 +124,8 @@ describe("api", () => { }); it("rejects transactions that specify both legacy and eip-1559 transaction fields", async () => { - const tx = { + // `any` because this tests how we handle an invalid transaction + const tx: any = { from, to: contractAddress, data: "0x3fa4f245", diff --git a/src/chains/ethereum/ethereum/tests/api/eth/eth.test.ts b/src/chains/ethereum/ethereum/tests/api/eth/eth.test.ts index eb5c3e1ab3..7959f9280c 100644 --- a/src/chains/ethereum/ethereum/tests/api/eth/eth.test.ts +++ b/src/chains/ethereum/ethereum/tests/api/eth/eth.test.ts @@ -1,6 +1,6 @@ import { RPCQUANTITY_GWEI } from "@ganache/utils"; import assert from "assert"; -import EthereumProvider from "../../../src/provider"; +import { EthereumProvider } from "../../../src/provider"; import getProvider, { mnemonic } from "../../helpers/getProvider"; function hex(length: number) { diff --git a/src/chains/ethereum/ethereum/tests/api/eth/getBlockByNumber.test.ts b/src/chains/ethereum/ethereum/tests/api/eth/getBlockByNumber.test.ts index 7f6eea6268..d2d9698a5a 100644 --- a/src/chains/ethereum/ethereum/tests/api/eth/getBlockByNumber.test.ts +++ b/src/chains/ethereum/ethereum/tests/api/eth/getBlockByNumber.test.ts @@ -1,7 +1,6 @@ import assert from "assert"; -import EthereumProvider from "../../../src/provider"; +import { EthereumProvider } from "../../../src/provider"; import getProvider from "../../helpers/getProvider"; -import compile from "../../helpers/compile"; const DEFAULT_DIFFICULTY = 1; let provider: EthereumProvider; diff --git a/src/chains/ethereum/ethereum/tests/api/eth/getCode.test.ts b/src/chains/ethereum/ethereum/tests/api/eth/getCode.test.ts index 826d09cd40..5db6525293 100644 --- a/src/chains/ethereum/ethereum/tests/api/eth/getCode.test.ts +++ b/src/chains/ethereum/ethereum/tests/api/eth/getCode.test.ts @@ -1,5 +1,5 @@ import assert from "assert"; -import EthereumProvider from "../../../src/provider"; +import { EthereumProvider } from "../../../src/provider"; import getProvider from "../../helpers/getProvider"; import compile from "../../helpers/compile"; import { join } from "path"; diff --git a/src/chains/ethereum/ethereum/tests/api/eth/getStorageAt.test.ts b/src/chains/ethereum/ethereum/tests/api/eth/getStorageAt.test.ts index 0fd0c518da..b92cc382d4 100644 --- a/src/chains/ethereum/ethereum/tests/api/eth/getStorageAt.test.ts +++ b/src/chains/ethereum/ethereum/tests/api/eth/getStorageAt.test.ts @@ -1,6 +1,6 @@ import getProvider from "../../helpers/getProvider"; import assert from "assert"; -import EthereumProvider from "../../../src/provider"; +import { EthereumProvider } from "../../../src/provider"; import compile, { CompileOutput } from "../../helpers/compile"; import { join } from "path"; const THIRTY_TWO_BYES = "0".repeat(64); diff --git a/src/chains/ethereum/ethereum/tests/api/eth/getTransactionReceipt.test.ts b/src/chains/ethereum/ethereum/tests/api/eth/getTransactionReceipt.test.ts index 0499dd8249..77010ce948 100644 --- a/src/chains/ethereum/ethereum/tests/api/eth/getTransactionReceipt.test.ts +++ b/src/chains/ethereum/ethereum/tests/api/eth/getTransactionReceipt.test.ts @@ -1,6 +1,6 @@ import getProvider, { mnemonic } from "../../helpers/getProvider"; import assert from "assert"; -import EthereumProvider from "../../../src/provider"; +import { EthereumProvider } from "../../../src/provider"; describe("api", () => { describe("eth", () => { diff --git a/src/chains/ethereum/ethereum/tests/api/eth/logs.test.ts b/src/chains/ethereum/ethereum/tests/api/eth/logs.test.ts index 341a9acdba..a9591bc4b2 100644 --- a/src/chains/ethereum/ethereum/tests/api/eth/logs.test.ts +++ b/src/chains/ethereum/ethereum/tests/api/eth/logs.test.ts @@ -1,9 +1,8 @@ import getProvider from "../../helpers/getProvider"; import assert from "assert"; -import EthereumProvider from "../../../src/provider"; +import { EthereumProvider } from "../../../src/provider"; import compile from "../../helpers/compile"; import { join } from "path"; -import { promises } from "fs-extra"; describe("api", () => { describe("eth", () => { diff --git a/src/chains/ethereum/ethereum/tests/api/eth/sendRawTransaction.test.ts b/src/chains/ethereum/ethereum/tests/api/eth/sendRawTransaction.test.ts index dbb8182c30..07082f277b 100644 --- a/src/chains/ethereum/ethereum/tests/api/eth/sendRawTransaction.test.ts +++ b/src/chains/ethereum/ethereum/tests/api/eth/sendRawTransaction.test.ts @@ -1,6 +1,6 @@ import getProvider from "../../helpers/getProvider"; import assert from "assert"; -import EthereumProvider from "../../../src/provider"; +import { EthereumProvider } from "../../../src/provider"; import Transaction from "@ethereumjs/tx/dist/legacyTransaction"; import Common from "@ethereumjs/common"; import { join } from "path"; diff --git a/src/chains/ethereum/ethereum/tests/api/eth/sendTransaction.test.ts b/src/chains/ethereum/ethereum/tests/api/eth/sendTransaction.test.ts index d9b350d3dc..8c5c79a5ff 100644 --- a/src/chains/ethereum/ethereum/tests/api/eth/sendTransaction.test.ts +++ b/src/chains/ethereum/ethereum/tests/api/eth/sendTransaction.test.ts @@ -2,7 +2,7 @@ import assert from "assert"; import getProvider from "../../helpers/getProvider"; import compile from "../../helpers/compile"; import { join } from "path"; -import EthereumProvider from "../../../src/provider"; +import { EthereumProvider } from "../../../src/provider"; import { EthereumOptionsConfig, EthereumProviderOptions diff --git a/src/chains/ethereum/ethereum/tests/api/eth/subscribe.test.ts b/src/chains/ethereum/ethereum/tests/api/eth/subscribe.test.ts index abe001dc9e..da768a506b 100644 --- a/src/chains/ethereum/ethereum/tests/api/eth/subscribe.test.ts +++ b/src/chains/ethereum/ethereum/tests/api/eth/subscribe.test.ts @@ -1,6 +1,6 @@ import getProvider from "../../helpers/getProvider"; import assert from "assert"; -import EthereumProvider from "../../../src/provider"; +import { EthereumProvider } from "../../../src/provider"; import { Quantity } from "@ganache/utils"; describe("api", () => { diff --git a/src/chains/ethereum/ethereum/tests/api/eth/uncles.test.ts b/src/chains/ethereum/ethereum/tests/api/eth/uncles.test.ts index 638cf9e196..2227dd4f3b 100644 --- a/src/chains/ethereum/ethereum/tests/api/eth/uncles.test.ts +++ b/src/chains/ethereum/ethereum/tests/api/eth/uncles.test.ts @@ -1,6 +1,6 @@ import getProvider from "../../helpers/getProvider"; import assert from "assert"; -import EthereumProvider from "../../../src/provider"; +import { EthereumProvider } from "../../../src/provider"; describe("api", () => { describe("eth", () => { diff --git a/src/chains/ethereum/ethereum/tests/api/evm/evm.test.ts b/src/chains/ethereum/ethereum/tests/api/evm/evm.test.ts index 5665ee3a20..fea66b43e9 100644 --- a/src/chains/ethereum/ethereum/tests/api/evm/evm.test.ts +++ b/src/chains/ethereum/ethereum/tests/api/evm/evm.test.ts @@ -1,8 +1,8 @@ import getProvider from "../../helpers/getProvider"; import assert from "assert"; import { Data, Quantity } from "@ganache/utils"; -import EthereumProvider from "../../../src/provider"; -import { TypedRpcTransaction } from "@ganache/ethereum-transaction"; +import { EthereumProvider } from "../../../src/provider"; +import { Transaction } from "@ganache/ethereum-transaction"; function between(x: number, min: number, max: number) { return x >= min && x <= max; @@ -207,9 +207,13 @@ describe("api", () => { it("should set storage slot and delete after", async () => { const provider = await getProvider(); const [account] = await provider.send("eth_accounts"); - const slot = "0x0000000000000000000000000000000000000000000000000000000000000005"; + const slot = + "0x0000000000000000000000000000000000000000000000000000000000000005"; const newStorage = Data.from("0xbaddad42"); - const initialStorage = await provider.send("eth_getStorageAt", [account, slot]); + const initialStorage = await provider.send("eth_getStorageAt", [ + account, + slot + ]); assert.strictEqual(initialStorage, "0x"); const setStatus = await provider.send("evm_setAccountStorageAt", [ account, @@ -217,7 +221,10 @@ describe("api", () => { newStorage.toString() ]); assert.strictEqual(setStatus, true); - const afterCode = await provider.send("eth_getStorageAt", [account, slot]); + const afterCode = await provider.send("eth_getStorageAt", [ + account, + slot + ]); assert.strictEqual(afterCode, newStorage.toString()); // Check that the storage can be deleted @@ -228,7 +235,10 @@ describe("api", () => { emptyStorage.toString() ]); assert.strictEqual(deletedStatus, true); - const deletedStorage = await provider.send("eth_getStorageAt", [account, slot]); + const deletedStorage = await provider.send("eth_getStorageAt", [ + account, + slot + ]); assert.strictEqual(deletedStorage, emptyStorage.toString()); }); }); @@ -252,7 +262,7 @@ describe("api", () => { { from, to: address, value: "0xffffffffffffffff" } ]); await provider.once("message"); - const tx: TypedRpcTransaction = { from: address }; + const tx: Transaction = { from: address }; // account is unknown on startup await assert.rejects(provider.send("eth_sendTransaction", [tx]), { message: "sender account not recognized" @@ -307,7 +317,7 @@ describe("api", () => { it("should remove an account from the personal namespace", async () => { const [address] = await provider.send("eth_accounts"); - const tx: TypedRpcTransaction = { from: address }; + const tx: Transaction = { from: address }; // account is known on startup await assert.doesNotReject(provider.send("eth_sendTransaction", [tx])); diff --git a/src/chains/ethereum/ethereum/tests/api/evm/snapshot.test.ts b/src/chains/ethereum/ethereum/tests/api/evm/snapshot.test.ts index 87eafd8313..1930ef848a 100644 --- a/src/chains/ethereum/ethereum/tests/api/evm/snapshot.test.ts +++ b/src/chains/ethereum/ethereum/tests/api/evm/snapshot.test.ts @@ -47,6 +47,7 @@ describe("api", () => { context.instance = { n: () => { const tx = { + from: "0x123", to, data: "0x" + methods["n()"] }; diff --git a/src/chains/ethereum/ethereum/tests/api/miner/miner.test.ts b/src/chains/ethereum/ethereum/tests/api/miner/miner.test.ts index 6e4003b069..6bf0c6fd45 100644 --- a/src/chains/ethereum/ethereum/tests/api/miner/miner.test.ts +++ b/src/chains/ethereum/ethereum/tests/api/miner/miner.test.ts @@ -1,5 +1,5 @@ import assert from "assert"; -import EthereumProvider from "../../../src/provider"; +import { EthereumProvider } from "../../../src/provider"; import getProvider from "../../helpers/getProvider"; describe("api", () => { diff --git a/src/chains/ethereum/ethereum/tests/api/personal/personal.test.ts b/src/chains/ethereum/ethereum/tests/api/personal/personal.test.ts index fdeb42ce3e..d6974a12cf 100644 --- a/src/chains/ethereum/ethereum/tests/api/personal/personal.test.ts +++ b/src/chains/ethereum/ethereum/tests/api/personal/personal.test.ts @@ -1,7 +1,7 @@ import assert from "assert"; import getProvider from "../../helpers/getProvider"; import { Quantity } from "@ganache/utils"; -import EthereumProvider from "../../../src/provider"; +import { EthereumProvider } from "../../../src/provider"; describe("api", () => { describe("personal", () => { diff --git a/src/chains/ethereum/ethereum/tests/api/rpc/modules.test.ts b/src/chains/ethereum/ethereum/tests/api/rpc/modules.test.ts index d4fe8f4c1b..3b50cc2b07 100644 --- a/src/chains/ethereum/ethereum/tests/api/rpc/modules.test.ts +++ b/src/chains/ethereum/ethereum/tests/api/rpc/modules.test.ts @@ -1,6 +1,6 @@ import getProvider from "../../helpers/getProvider"; import assert from "assert"; -import EthereumProvider from "../../../src/provider"; +import { EthereumProvider } from "../../../src/provider"; const RPC_MODULES = { eth: "1.0", net: "1.0", diff --git a/src/chains/ethereum/ethereum/tests/api/shh/shh.test.ts b/src/chains/ethereum/ethereum/tests/api/shh/shh.test.ts index 51e8053178..40d41f5476 100644 --- a/src/chains/ethereum/ethereum/tests/api/shh/shh.test.ts +++ b/src/chains/ethereum/ethereum/tests/api/shh/shh.test.ts @@ -1,6 +1,6 @@ import getProvider from "../../helpers/getProvider"; import assert from "assert"; -import EthereumProvider from "../../../src/provider"; +import { EthereumProvider } from "../../../src/provider"; describe("api", () => { describe("shh", () => { diff --git a/src/chains/ethereum/ethereum/tests/api/txpool/content.test.ts b/src/chains/ethereum/ethereum/tests/api/txpool/content.test.ts index 2d343242d4..f01ff0b46d 100644 --- a/src/chains/ethereum/ethereum/tests/api/txpool/content.test.ts +++ b/src/chains/ethereum/ethereum/tests/api/txpool/content.test.ts @@ -1,6 +1,6 @@ import getProvider from "../../helpers/getProvider"; import assert from "assert"; -import EthereumProvider from "../../../src/provider"; +import { EthereumProvider } from "../../../src/provider"; describe("txpool", () => { describe("content", () => { @@ -119,6 +119,5 @@ describe("txpool", () => { assert.deepStrictEqual(pending, {}); assert.deepStrictEqual(queued, {}); }); - }); }); diff --git a/src/chains/ethereum/ethereum/tests/api/web3/web3.test.ts b/src/chains/ethereum/ethereum/tests/api/web3/web3.test.ts index eedc93724e..0d06a02cd1 100644 --- a/src/chains/ethereum/ethereum/tests/api/web3/web3.test.ts +++ b/src/chains/ethereum/ethereum/tests/api/web3/web3.test.ts @@ -1,6 +1,6 @@ import getProvider from "../../helpers/getProvider"; import assert from "assert"; -import EthereumProvider from "../../../src/provider"; +import { EthereumProvider } from "../../../src/provider"; describe("api", () => { describe("web3", () => { diff --git a/src/chains/ethereum/ethereum/tests/database.test.ts b/src/chains/ethereum/ethereum/tests/database.test.ts index 8cd8421ddd..6d8a7942b9 100644 --- a/src/chains/ethereum/ethereum/tests/database.test.ts +++ b/src/chains/ethereum/ethereum/tests/database.test.ts @@ -2,7 +2,7 @@ import assert from "assert"; import { readdir } from "fs-extra"; import tmp from "tmp-promise"; import getProvider from "./helpers/getProvider"; -import EthereumProvider from "../src/provider"; +import { EthereumProvider } from "../src/provider"; describe("database", () => { let dbPath: string; @@ -10,7 +10,10 @@ describe("database", () => { let accounts: string[]; function startProvider() { - return getProvider({ database: { dbPath }, wallet: { deterministic: true } }) + return getProvider({ + database: { dbPath }, + wallet: { deterministic: true } + }); } before(async () => { @@ -35,25 +38,55 @@ describe("database", () => { await provider.request({ method: "evm_mine", params: [{ blocks: 256 }] }); // send some value const [from, to] = accounts; - const startingBalance = await provider.request({ method: "eth_getBalance", params: [from] }); - await provider.request({ method: "eth_sendTransaction", params: [{ from, to, value: "0xffffffffff" }] }) - const endingBalance = await provider.request({ method: "eth_getBalance", params: [from] }); - const latestBlock = await provider.request({ method: "eth_blockNumber", params: [] }); + const startingBalance = await provider.request({ + method: "eth_getBalance", + params: [from] + }); + await provider.request({ + method: "eth_sendTransaction", + params: [{ from, to, value: "0xffffffffff" }] + }); + const endingBalance = await provider.request({ + method: "eth_getBalance", + params: [from] + }); + const latestBlock = await provider.request({ + method: "eth_blockNumber", + params: [] + }); assert.notStrictEqual(endingBalance, startingBalance); await provider.disconnect(); provider = await startProvider(); - const currentBalanceBeforeRevert = await provider.request({ method: "eth_getBalance", params: [from] }); + const currentBalanceBeforeRevert = await provider.request({ + method: "eth_getBalance", + params: [from] + }); assert.strictEqual(currentBalanceBeforeRevert, endingBalance); - const currentBlockBeforeRevert = await provider.request({ method: "eth_blockNumber", params: [] }); + const currentBlockBeforeRevert = await provider.request({ + method: "eth_blockNumber", + params: [] + }); assert.strictEqual(currentBlockBeforeRevert, latestBlock); - const snapshotId = await provider.request({ method: "evm_snapshot", params: [] }); - await provider.request({ method: "eth_sendTransaction", params: [{ from, to, value: "0xffffffffff" }] }) - const endingBalanceAfterSnapshot = await provider.request({ method: "eth_getBalance", params: [from] }); - const latestBlockAfterSnapshot = await provider.request({ method: "eth_blockNumber", params: [] }); + const snapshotId = await provider.request({ + method: "evm_snapshot", + params: [] + }); + await provider.request({ + method: "eth_sendTransaction", + params: [{ from, to, value: "0xffffffffff" }] + }); + const endingBalanceAfterSnapshot = await provider.request({ + method: "eth_getBalance", + params: [from] + }); + const latestBlockAfterSnapshot = await provider.request({ + method: "eth_blockNumber", + params: [] + }); // make sure the transaction made changes: assert.notStrictEqual(endingBalanceAfterSnapshot, endingBalance); assert.notStrictEqual(latestBlockAfterSnapshot, latestBlock); @@ -61,8 +94,14 @@ describe("database", () => { // undo those changes by reverting the snapshot await provider.request({ method: "evm_revert", params: [snapshotId] }); - const endingBalanceAfterRevert = await provider.request({ method: "eth_getBalance", params: [from] }); - const latestBlockAfterRevert = await provider.request({ method: "eth_blockNumber", params: [] }); + const endingBalanceAfterRevert = await provider.request({ + method: "eth_getBalance", + params: [from] + }); + const latestBlockAfterRevert = await provider.request({ + method: "eth_blockNumber", + params: [] + }); // make sure the revert worked (only checks in memory state, not the db): assert.strictEqual(endingBalanceAfterRevert, endingBalance); @@ -72,10 +111,16 @@ describe("database", () => { provider = await startProvider(); // make sure the revert changes were persisted to the db: - const balanceAfterRestart = await provider.request({ method: "eth_getBalance", params: [from] }); + const balanceAfterRestart = await provider.request({ + method: "eth_getBalance", + params: [from] + }); assert.strictEqual(balanceAfterRestart, endingBalance); - const latestBlockAfterRestart = await provider.request({ method: "eth_blockNumber", params: [] }); + const latestBlockAfterRestart = await provider.request({ + method: "eth_blockNumber", + params: [] + }); assert.strictEqual(latestBlockAfterRestart, latestBlock); }); }); diff --git a/src/chains/ethereum/ethereum/tests/forking/account.test.ts b/src/chains/ethereum/ethereum/tests/forking/account.test.ts index f7938b903e..8e95bdb762 100644 --- a/src/chains/ethereum/ethereum/tests/forking/account.test.ts +++ b/src/chains/ethereum/ethereum/tests/forking/account.test.ts @@ -1,6 +1,6 @@ import assert from "assert"; import getProvider from "../helpers/getProvider"; -import EthereumProvider from "../../src/provider"; +import { EthereumProvider } from "../../src/provider"; import request from "superagent"; describe("forking", function () { diff --git a/src/chains/ethereum/ethereum/tests/forking/auth.test.ts b/src/chains/ethereum/ethereum/tests/forking/auth.test.ts index 0d9f5f7f65..1dbd13e294 100644 --- a/src/chains/ethereum/ethereum/tests/forking/auth.test.ts +++ b/src/chains/ethereum/ethereum/tests/forking/auth.test.ts @@ -1,6 +1,6 @@ import assert from "assert"; import getProvider from "../helpers/getProvider"; -import EthereumProvider from "../../src/provider"; +import { EthereumProvider } from "../../src/provider"; describe("forking", () => { describe("auth", () => { diff --git a/src/chains/ethereum/ethereum/tests/forking/block.test.ts b/src/chains/ethereum/ethereum/tests/forking/block.test.ts index 1d2216abb7..8b88a76bd1 100644 --- a/src/chains/ethereum/ethereum/tests/forking/block.test.ts +++ b/src/chains/ethereum/ethereum/tests/forking/block.test.ts @@ -1,6 +1,6 @@ import assert from "assert"; import getProvider from "../helpers/getProvider"; -import EthereumProvider from "../../src/provider"; +import { EthereumProvider } from "../../src/provider"; import request from "superagent"; describe("forking", function () { diff --git a/src/chains/ethereum/ethereum/tests/forking/forking.test.ts b/src/chains/ethereum/ethereum/tests/forking/forking.test.ts index c60df49f5f..727a8eeb7d 100644 --- a/src/chains/ethereum/ethereum/tests/forking/forking.test.ts +++ b/src/chains/ethereum/ethereum/tests/forking/forking.test.ts @@ -3,7 +3,7 @@ import getProvider from "../helpers/getProvider"; import http from "http"; import ganache from "../../../../../packages/core"; import assert from "assert"; -import EthereumProvider from "../../src/provider"; +import { EthereumProvider } from "../../src/provider"; import Server from "../../../../../packages/core/lib/src/server"; import { Quantity, WEI } from "@ganache/utils"; import { diff --git a/src/chains/ethereum/ethereum/tests/forking/helpers.ts b/src/chains/ethereum/ethereum/tests/forking/helpers.ts index 011c4eba38..e07815936f 100644 --- a/src/chains/ethereum/ethereum/tests/forking/helpers.ts +++ b/src/chains/ethereum/ethereum/tests/forking/helpers.ts @@ -1,6 +1,6 @@ import { Quantity, WEI } from "@ganache/utils"; import getProvider from "../helpers/getProvider"; -import EthereumProvider from "../../src/provider"; +import { EthereumProvider } from "../../src/provider"; import { EthereumProviderOptions } from "@ganache/ethereum-options"; export const logging = { diff --git a/src/chains/ethereum/ethereum/tests/forking/transaction.test.ts b/src/chains/ethereum/ethereum/tests/forking/transaction.test.ts index 90560855d9..a04e23e9d1 100644 --- a/src/chains/ethereum/ethereum/tests/forking/transaction.test.ts +++ b/src/chains/ethereum/ethereum/tests/forking/transaction.test.ts @@ -1,6 +1,6 @@ import assert from "assert"; import getProvider from "../helpers/getProvider"; -import EthereumProvider from "../../src/provider"; +import { EthereumProvider } from "../../src/provider"; import request from "superagent"; describe("forking", () => { diff --git a/src/chains/ethereum/ethereum/tests/helpers/getProvider.ts b/src/chains/ethereum/ethereum/tests/helpers/getProvider.ts index e8042300a5..6fc6ddeac2 100644 --- a/src/chains/ethereum/ethereum/tests/helpers/getProvider.ts +++ b/src/chains/ethereum/ethereum/tests/helpers/getProvider.ts @@ -1,5 +1,5 @@ import { RequestCoordinator, Executor } from "@ganache/utils"; -import EthereumProvider from "../../src/provider"; +import { EthereumProvider } from "../../src/provider"; import { EthereumProviderOptions } from "@ganache/ethereum-options"; export const mnemonic = diff --git a/src/chains/ethereum/ethereum/tests/miner/miner.test.ts b/src/chains/ethereum/ethereum/tests/miner/miner.test.ts index dccae9ecf5..2665c083dc 100644 --- a/src/chains/ethereum/ethereum/tests/miner/miner.test.ts +++ b/src/chains/ethereum/ethereum/tests/miner/miner.test.ts @@ -3,7 +3,7 @@ import { Address } from "@ganache/ethereum-address"; import Common from "@ethereumjs/common"; import { TransactionFactory, - TypedRpcTransaction, + Transaction, TypedTransaction } from "@ganache/ethereum-transaction"; import Blockchain from "../../src/blockchain"; @@ -73,7 +73,7 @@ describe("miner", async () => { For the highGasLimitBlockchain: all three would be mined in one block with the order: tx1, tx3, tx2 */ - const txs: TypedRpcTransaction[] = [ + const txs: Transaction[] = [ { type: "0x0", from: from1, diff --git a/src/chains/ethereum/ethereum/tests/provider.test.ts b/src/chains/ethereum/ethereum/tests/provider.test.ts index a468c72134..4eb2eaaa19 100644 --- a/src/chains/ethereum/ethereum/tests/provider.test.ts +++ b/src/chains/ethereum/ethereum/tests/provider.test.ts @@ -3,7 +3,7 @@ import { join } from "path"; import Transaction from "@ethereumjs/tx/dist/legacyTransaction"; import { Data, JsonRpcRequest } from "@ganache/utils"; import Common from "@ethereumjs/common"; -import EthereumProvider from "../src/provider"; +import { EthereumProvider } from "../src/provider"; import EthereumApi from "../src/api"; import getProvider from "./helpers/getProvider"; import compile from "./helpers/compile"; diff --git a/src/chains/ethereum/ethereum/tests/transaction-pool.test.ts b/src/chains/ethereum/ethereum/tests/transaction-pool.test.ts index da360e88e3..89d0ec41e9 100644 --- a/src/chains/ethereum/ethereum/tests/transaction-pool.test.ts +++ b/src/chains/ethereum/ethereum/tests/transaction-pool.test.ts @@ -3,7 +3,7 @@ import Common from "@ethereumjs/common"; import { EIP1559FeeMarketRpcTransaction, TransactionFactory, - TypedRpcTransaction, + Transaction, TypedTransaction } from "@ganache/ethereum-transaction"; import { EthereumOptionsConfig } from "@ganache/ethereum-options"; @@ -28,7 +28,7 @@ function findIn( } describe("transaction pool", async () => { - let rpcTx: TypedRpcTransaction; + let rpcTx: Transaction; let from: string; let secretKey: Data; let common: Common; @@ -40,7 +40,7 @@ describe("transaction pool", async () => { miner: { priceBump: priceBump } }; const options = EthereumOptionsConfig.normalize(optionsJson); - let futureNonceRpc, executableRpc: TypedRpcTransaction; + let futureNonceRpc, executableRpc: Transaction; before(function () { const wallet = new Wallet(options.wallet); [from] = wallet.addresses; @@ -119,7 +119,7 @@ describe("transaction pool", async () => { it("rejects transactions whose gasLimit is not enough to run the transaction", async () => { const txPool = new TransactionPool(options.miner, blockchain); // the tx should have a very low gas limit to be rejected - const lowGasRpc: TypedRpcTransaction = { + const lowGasRpc: Transaction = { from: from, type: "0x2", maxFeePerGas: "0xffffffff", @@ -204,7 +204,7 @@ describe("transaction pool", async () => { "replacement transaction with insufficient gas price to replace should have been rejected" ); - const legacyReplacementRpc: TypedRpcTransaction = { + const legacyReplacementRpc: Transaction = { from: from, type: "0x0", gasPrice: "0xffffffff", @@ -330,7 +330,7 @@ describe("transaction pool", async () => { const maxFeePremium = originalMaxFee + (originalMaxFee * priceBump) / 100n; const tipPremium = originalTip + (originalTip * priceBump) / 100n; // our replacement transaction needs to have a sufficiently higher gasPrice - const replacementRpc: TypedRpcTransaction = { + const replacementRpc: Transaction = { from: from, type: "0x2", maxFeePerGas: Quantity.from(maxFeePremium).toString(), @@ -372,7 +372,7 @@ describe("transaction pool", async () => { ); // our replacement transaction needs to have a sufficiently higher gasPrice - const replacementRpc: TypedRpcTransaction = { + const replacementRpc: Transaction = { from: from, type: "0x2", maxFeePerGas: "0xffffffffff", diff --git a/src/chains/ethereum/options/package-lock.json b/src/chains/ethereum/options/package-lock.json index 3e65e01c76..c9def1afb2 100644 --- a/src/chains/ethereum/options/package-lock.json +++ b/src/chains/ethereum/options/package-lock.json @@ -964,9 +964,9 @@ "dev": true }, "typescript": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", - "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==", + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", "dev": true }, "util-deprecate": { diff --git a/src/chains/ethereum/options/package.json b/src/chains/ethereum/options/package.json index 31e4f786ac..df7f077244 100644 --- a/src/chains/ethereum/options/package.json +++ b/src/chains/ethereum/options/package.json @@ -62,6 +62,6 @@ "mocha": "9.1.3", "sinon": "12.0.1", "ts-node": "10.4.0", - "typescript": "4.5.2" + "typescript": "4.6.4" } } diff --git a/src/chains/ethereum/transaction/package-lock.json b/src/chains/ethereum/transaction/package-lock.json index 7698f20704..67445c4d3d 100644 --- a/src/chains/ethereum/transaction/package-lock.json +++ b/src/chains/ethereum/transaction/package-lock.json @@ -2689,9 +2689,9 @@ } }, "typescript": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", - "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==", + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", "dev": true }, "util-deprecate": { diff --git a/src/chains/ethereum/transaction/package.json b/src/chains/ethereum/transaction/package.json index eda049146a..ce29b4be7f 100644 --- a/src/chains/ethereum/transaction/package.json +++ b/src/chains/ethereum/transaction/package.json @@ -64,6 +64,6 @@ "mocha": "9.1.3", "nyc": "15.1.0", "ts-node": "10.4.0", - "typescript": "4.5.2" + "typescript": "4.6.4" } } diff --git a/src/chains/ethereum/transaction/src/eip1559-fee-market-transaction.ts b/src/chains/ethereum/transaction/src/eip1559-fee-market-transaction.ts index 26a04a25ca..c75dbe4755 100644 --- a/src/chains/ethereum/transaction/src/eip1559-fee-market-transaction.ts +++ b/src/chains/ethereum/transaction/src/eip1559-fee-market-transaction.ts @@ -10,7 +10,7 @@ import { import { Address } from "@ganache/ethereum-address"; import type Common from "@ethereumjs/common"; import { BN } from "ethereumjs-util"; -import { TypedRpcTransaction } from "./rpc-transaction"; +import { Transaction } from "./rpc-transaction"; import { encodeRange, digest } from "@ganache/rlp"; import { RuntimeTransaction } from "./runtime-transaction"; import { @@ -54,7 +54,7 @@ export class EIP1559FeeMarketTransaction extends RuntimeTransaction { public type: Quantity = Quantity.from("0x2"); public constructor( - data: EIP1559FeeMarketDatabasePayload | TypedRpcTransaction, + data: EIP1559FeeMarketDatabasePayload | Transaction, common: Common, extra?: GanacheRawExtraTx ) { @@ -87,13 +87,8 @@ export class EIP1559FeeMarketTransaction extends RuntimeTransaction { ); } - const { - from, - serialized, - hash, - encodedData, - encodedSignature - } = this.computeIntrinsics(this.v, this.raw); + const { from, serialized, hash, encodedData, encodedSignature } = + this.computeIntrinsics(this.v, this.raw); this.from = from; this.serialized = serialized; @@ -146,7 +141,7 @@ export class EIP1559FeeMarketTransaction extends RuntimeTransaction { } public static fromTxData( - data: EIP1559FeeMarketDatabasePayload | TypedRpcTransaction, + data: EIP1559FeeMarketDatabasePayload | Transaction, common: Common, extra?: GanacheRawExtraTx ) { diff --git a/src/chains/ethereum/transaction/src/eip2930-access-list-transaction.ts b/src/chains/ethereum/transaction/src/eip2930-access-list-transaction.ts index 2d8c917500..dd23ff2bda 100644 --- a/src/chains/ethereum/transaction/src/eip2930-access-list-transaction.ts +++ b/src/chains/ethereum/transaction/src/eip2930-access-list-transaction.ts @@ -10,7 +10,7 @@ import { import { Address } from "@ganache/ethereum-address"; import type Common from "@ethereumjs/common"; import { BN } from "ethereumjs-util"; -import { TypedRpcTransaction } from "./rpc-transaction"; +import { Transaction } from "./rpc-transaction"; import { encodeRange, digest } from "@ganache/rlp"; import { RuntimeTransaction } from "./runtime-transaction"; import { @@ -54,7 +54,7 @@ export class EIP2930AccessListTransaction extends RuntimeTransaction { public type: Quantity = Quantity.from("0x1"); public constructor( - data: EIP2930AccessListDatabasePayload | TypedRpcTransaction, + data: EIP2930AccessListDatabasePayload | Transaction, common: Common, extra?: GanacheRawExtraTx ) { @@ -86,13 +86,8 @@ export class EIP2930AccessListTransaction extends RuntimeTransaction { JsonRpcErrorCode.INVALID_INPUT ); } - const { - from, - serialized, - hash, - encodedData, - encodedSignature - } = this.computeIntrinsics(this.v, this.raw); + const { from, serialized, hash, encodedData, encodedSignature } = + this.computeIntrinsics(this.v, this.raw); this.from = from; this.serialized = serialized; @@ -148,7 +143,7 @@ export class EIP2930AccessListTransaction extends RuntimeTransaction { }; } public static fromTxData( - data: EIP2930AccessListDatabasePayload | TypedRpcTransaction, + data: EIP2930AccessListDatabasePayload | Transaction, common: Common, extra?: GanacheRawExtraTx ) { diff --git a/src/chains/ethereum/transaction/src/legacy-transaction.ts b/src/chains/ethereum/transaction/src/legacy-transaction.ts index b2a9be245a..245a963d10 100644 --- a/src/chains/ethereum/transaction/src/legacy-transaction.ts +++ b/src/chains/ethereum/transaction/src/legacy-transaction.ts @@ -12,7 +12,7 @@ import { ECDSASignature, ECDSASignatureBuffer, ecsign } from "ethereumjs-util"; import { encodeRange, digest, EncodedPart } from "@ganache/rlp"; import { BN } from "ethereumjs-util"; import { RuntimeTransaction } from "./runtime-transaction"; -import { TypedRpcTransaction } from "./rpc-transaction"; +import { Transaction } from "./rpc-transaction"; import { EIP2930AccessListDatabasePayload, GanacheRawExtraTx, @@ -27,7 +27,7 @@ export class LegacyTransaction extends RuntimeTransaction { public type: Quantity = Quantity.from("0x0"); public constructor( - data: LegacyDatabasePayload | TypedRpcTransaction, + data: LegacyDatabasePayload | Transaction, common: Common, extra?: GanacheRawExtraTx ) { @@ -93,7 +93,7 @@ export class LegacyTransaction extends RuntimeTransaction { } public static fromTxData( - data: LegacyDatabasePayload | TypedRpcTransaction, + data: LegacyDatabasePayload | Transaction, common: Common, extra?: GanacheRawExtraTx ) { @@ -101,7 +101,7 @@ export class LegacyTransaction extends RuntimeTransaction { } public static fromEIP2930AccessListTransaction( - data: EIP2930AccessListDatabasePayload | TypedRpcTransaction, + data: EIP2930AccessListDatabasePayload | Transaction, common: Common ) { if (Array.isArray(data)) { diff --git a/src/chains/ethereum/transaction/src/rpc-transaction.ts b/src/chains/ethereum/transaction/src/rpc-transaction.ts index b989b6243f..e5e933be19 100644 --- a/src/chains/ethereum/transaction/src/rpc-transaction.ts +++ b/src/chains/ethereum/transaction/src/rpc-transaction.ts @@ -21,11 +21,13 @@ type HexChar = type HexPair = `${oneThroughSeven}${HexChar}`; type TxType = `0x${HexChar}` | `0x${HexPair}`; // tx types are valid 0 through 7f -export type TypedRpcTransaction = +export type Transaction = | LegacyRpcTransaction | EIP2930AccessListRpcTransaction | EIP1559FeeMarketRpcTransaction; +export type CallTransaction = Omit & { from?: string }; + export type LegacyRpcTransaction = Readonly & { readonly gasPrice?: string; readonly chainId?: never; @@ -34,7 +36,7 @@ export type LegacyRpcTransaction = Readonly & { readonly maxFeePerGas?: never; }; export type EIP2930AccessListRpcTransaction = Readonly & { - readonly type: TxType; + readonly type?: TxType; readonly chainId?: string; readonly gasPrice?: string; readonly accessList?: AccessList; @@ -43,7 +45,7 @@ export type EIP2930AccessListRpcTransaction = Readonly & { }; export type EIP1559FeeMarketRpcTransaction = Readonly & { - readonly type: TxType; + readonly type?: TxType; readonly chainId?: string; readonly gasPrice?: never; readonly maxPriorityFeePerGas?: string; diff --git a/src/chains/ethereum/transaction/src/runtime-transaction.ts b/src/chains/ethereum/transaction/src/runtime-transaction.ts index 8983ecf38d..e6ea2e1834 100644 --- a/src/chains/ethereum/transaction/src/runtime-transaction.ts +++ b/src/chains/ethereum/transaction/src/runtime-transaction.ts @@ -10,7 +10,7 @@ import { BUFFER_ZERO, RPCQUANTITY_EMPTY } from "@ganache/utils"; -import { TypedRpcTransaction } from "./rpc-transaction"; +import { Transaction } from "./rpc-transaction"; import type Common from "@ethereumjs/common"; import { GanacheRawExtraTx, @@ -20,7 +20,7 @@ import { import type { RunTxResult } from "@ethereumjs/vm/dist/runTx"; import { EncodedPart, encode } from "@ganache/rlp"; import { BaseTransaction } from "./base-transaction"; -import { TransactionReceipt } from "./transaction-receipt"; +import { InternalTransactionReceipt } from "./transaction-receipt"; import { Address } from "@ganache/ethereum-address"; export const toValidLengthAddress = (address: string, fieldName: string) => { @@ -34,8 +34,8 @@ export const toValidLengthAddress = (address: string, fieldName: string) => { }; export const hasPartialSignature = ( - data: TypedRpcTransaction -): data is TypedRpcTransaction & { + data: Transaction +): data is Transaction & { from?: string; v?: string; r?: string; @@ -64,7 +64,7 @@ export abstract class RuntimeTransaction extends BaseTransaction { public locked: boolean = false; public logs: TransactionLog[]; - public receipt: TransactionReceipt; + public receipt: InternalTransactionReceipt; public execException: RuntimeError; public raw: TypedDatabaseTransaction | null; @@ -75,7 +75,7 @@ export abstract class RuntimeTransaction extends BaseTransaction { private finalized: Promise; constructor( - data: TypedDatabasePayload | TypedRpcTransaction, + data: TypedDatabasePayload | Transaction, common: Common, extra?: GanacheRawExtraTx ) { @@ -154,7 +154,7 @@ export abstract class RuntimeTransaction extends BaseTransaction { status = ONE_BUFFER; } - const receipt = (this.receipt = TransactionReceipt.fromValues( + const receipt = (this.receipt = InternalTransactionReceipt.fromValues( status, Quantity.from(cumulativeGasUsed).toBuffer(), result.bloom.bitvector, @@ -166,7 +166,7 @@ export abstract class RuntimeTransaction extends BaseTransaction { return receipt.serialize(false); } - public getReceipt(): TransactionReceipt { + public getReceipt(): InternalTransactionReceipt { return this.receipt; } @@ -174,7 +174,7 @@ export abstract class RuntimeTransaction extends BaseTransaction { return this.logs; } - validateAndSetSignature = (data: TypedRpcTransaction) => { + validateAndSetSignature = (data: Transaction) => { // If we have v, r, or s validate and use them if (hasPartialSignature(data)) { if (data.v == null || data.r == null || data.s == null) { @@ -200,13 +200,8 @@ export abstract class RuntimeTransaction extends BaseTransaction { ); this.raw = raw; if (!this.from) { - const { - from, - serialized, - hash, - encodedData, - encodedSignature - } = this.computeIntrinsics(this.v, raw, this.common.chainId()); + const { from, serialized, hash, encodedData, encodedSignature } = + this.computeIntrinsics(this.v, raw, this.common.chainId()); // if the user specified a `from` address in addition to the `v`, `r`, // and `s` values, make sure the `from` address matches diff --git a/src/chains/ethereum/transaction/src/transaction-factory.ts b/src/chains/ethereum/transaction/src/transaction-factory.ts index 41e609a3b4..c6b3386c26 100644 --- a/src/chains/ethereum/transaction/src/transaction-factory.ts +++ b/src/chains/ethereum/transaction/src/transaction-factory.ts @@ -7,7 +7,7 @@ import { import type Common from "@ethereumjs/common"; import { LegacyTransaction } from "./legacy-transaction"; import { EIP2930AccessListTransaction } from "./eip2930-access-list-transaction"; -import { TypedRpcTransaction } from "./rpc-transaction"; +import { Transaction } from "./rpc-transaction"; import { EIP1559FeeMarketDatabasePayload, EIP2930AccessListDatabasePayload, @@ -61,7 +61,7 @@ export class TransactionFactory { this.tx = TransactionFactory.fromDatabaseTx(txData, common, extra); } private static _fromData( - txData: TypedRpcTransaction | TypedDatabasePayload, + txData: Transaction | TypedDatabasePayload, txType: TransactionType, common: Common, extra?: GanacheRawExtraTx @@ -70,21 +70,17 @@ export class TransactionFactory { // return legacy txs as is and convert typed txs to legacy if (!common.isActivatedEIP(2718)) { return LegacyTransaction.fromTxData( - txData, + txData, common, extra ); } else if (!common.isActivatedEIP(1559)) { if (txType === TransactionType.Legacy) { - return LegacyTransaction.fromTxData( - txData, - common, - extra - ); + return LegacyTransaction.fromTxData(txData, common, extra); } else if (txType === TransactionType.EIP2930AccessList) { if (common.isActivatedEIP(2930)) { return EIP2930AccessListTransaction.fromTxData( - txData, + txData, common, extra ); @@ -178,7 +174,7 @@ export class TransactionFactory { * @param common - Options to pass on to the constructor of the transaction */ public static fromRpc( - txData: TypedRpcTransaction, + txData: Transaction, common: Common, extra?: GanacheRawExtraTx ) { @@ -294,7 +290,7 @@ export class TransactionFactory { return this.typeOf(type); } - public static typeOfRPC(rpc: TypedRpcTransaction) { + public static typeOfRPC(rpc: Transaction) { if (!("type" in rpc) || rpc.type === undefined) { return TransactionType.Legacy; } else { diff --git a/src/chains/ethereum/transaction/src/transaction-receipt.ts b/src/chains/ethereum/transaction/src/transaction-receipt.ts index 026a9effac..2ca0c0b5cc 100644 --- a/src/chains/ethereum/transaction/src/transaction-receipt.ts +++ b/src/chains/ethereum/transaction/src/transaction-receipt.ts @@ -23,7 +23,7 @@ type GanacheExtrasRawReceipt = [ type GanacheRawReceipt = [...EthereumRawReceipt, ...GanacheExtrasRawReceipt]; -export interface TransactionReceiptJSON { +export interface TransactionReceipt { transactionHash: Data; transactionIndex: Quantity; blockNumber: Quantity; @@ -52,7 +52,7 @@ export interface TransactionReceiptJSON { effectiveGasPrice: Quantity; } -export class TransactionReceipt { +export class InternalTransactionReceipt { public contractAddress: Buffer; #gasUsed: Buffer; raw: EthereumRawReceipt; @@ -96,7 +96,7 @@ export class TransactionReceipt { contractAddress: Buffer, type: Quantity = null ) { - const receipt = new TransactionReceipt(); + const receipt = new InternalTransactionReceipt(); receipt.#init( status, cumulativeGasUsed, @@ -158,7 +158,7 @@ export class TransactionReceipt { if (block.header.baseFeePerGas) { transaction.updateEffectiveGasPrice(block.header.baseFeePerGas); } - const json: TransactionReceiptJSON = { + const json: TransactionReceipt = { transactionHash, transactionIndex, blockNumber, diff --git a/src/chains/ethereum/transaction/src/transaction-types.ts b/src/chains/ethereum/transaction/src/transaction-types.ts index 3605120432..f39fa6d67d 100644 --- a/src/chains/ethereum/transaction/src/transaction-types.ts +++ b/src/chains/ethereum/transaction/src/transaction-types.ts @@ -3,7 +3,6 @@ import { Address } from "@ganache/ethereum-address"; import { EIP1559FeeMarketTransaction } from "./eip1559-fee-market-transaction"; import { EIP2930AccessListTransaction } from "./eip2930-access-list-transaction"; import { LegacyTransaction } from "./legacy-transaction"; -import { EIP2930AccessListDatabaseTx } from "./raw"; import { AccessList } from "./access-lists"; export type TypedTransaction = @@ -14,7 +13,7 @@ export type TypedTransaction = export type Capability = 2718 | 2930 | 1559; export type TypedTransactionJSON = | LegacyTransactionJSON - | EIP2930AccessListDatabaseTx + | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON; export type LegacyTransactionJSON = { diff --git a/src/chains/ethereum/transaction/tests/index.test.ts b/src/chains/ethereum/transaction/tests/index.test.ts index faa92078c9..2f2c7a656d 100644 --- a/src/chains/ethereum/transaction/tests/index.test.ts +++ b/src/chains/ethereum/transaction/tests/index.test.ts @@ -11,7 +11,7 @@ import { TransactionFactory, TransactionType, TypedDatabaseTransaction, - TypedRpcTransaction + Transaction } from "../../transaction"; import Common from "@ethereumjs/common"; import Wallet from "../../ethereum/src/wallet"; @@ -50,12 +50,12 @@ describe("@ganache/ethereum-transaction", async () => { // #region configure transaction constants // #region legacy transaction - const untypedTx: TypedRpcTransaction = { + const untypedTx: Transaction = { from: from, to: to, gasPrice: "0xffff" }; - const typedLegacyTx: TypedRpcTransaction = { + const typedLegacyTx: Transaction = { from: from, to: to, type: "0x0", @@ -75,7 +75,7 @@ describe("@ganache/ethereum-transaction", async () => { // #region access list transactions const accessListStorageKey = "0x0000000000000000000000000000000000000000000000000000000000000004"; - const accessListTx: TypedRpcTransaction = { + const accessListTx: Transaction = { from: from, to: to, type: "0x1", @@ -100,7 +100,7 @@ describe("@ganache/ethereum-transaction", async () => { // #endregion access list transactions //#region fee market transactions - const feeMarketTx: TypedRpcTransaction = { + const feeMarketTx: Transaction = { from: from, to: to, type: "0x2", @@ -558,7 +558,7 @@ describe("@ganache/ethereum-transaction", async () => { describe("Error and helper cases", () => { it("does not allow unsupported tx types from rpc data", async () => { - const rpc: TypedRpcTransaction = { + const rpc: Transaction = { from: from, to: to, type: "0x55", diff --git a/src/chains/ethereum/utils/package-lock.json b/src/chains/ethereum/utils/package-lock.json index 3a793951de..477bb70363 100644 --- a/src/chains/ethereum/utils/package-lock.json +++ b/src/chains/ethereum/utils/package-lock.json @@ -1527,9 +1527,9 @@ } }, "typescript": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", - "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==", + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", "dev": true }, "util-deprecate": { diff --git a/src/chains/ethereum/utils/package.json b/src/chains/ethereum/utils/package.json index f71e302fed..10e1b69d24 100644 --- a/src/chains/ethereum/utils/package.json +++ b/src/chains/ethereum/utils/package.json @@ -63,6 +63,6 @@ "cross-env": "7.0.3", "mocha": "9.1.3", "ts-node": "10.4.0", - "typescript": "4.5.2" + "typescript": "4.6.4" } } diff --git a/src/chains/ethereum/utils/src/things/blocklogs.ts b/src/chains/ethereum/utils/src/things/blocklogs.ts index 6f3336b98a..01a01c5893 100644 --- a/src/chains/ethereum/utils/src/things/blocklogs.ts +++ b/src/chains/ethereum/utils/src/things/blocklogs.ts @@ -18,6 +18,18 @@ export type BlockLog = [ data: TransactionLog[2] ]; +export type Log = { + address: Address; + blockHash: Data; + blockNumber: Quantity; + data: Data | Data[]; + logIndex: Quantity; + removed: boolean; + topics: Data | Data[]; + transactionHash: Data; + transactionIndex: Quantity; +}; + const _raw = Symbol("raw"); const _logs = Symbol("logs"); @@ -54,7 +66,7 @@ export class BlockLogs { constructor(data: Buffer) { if (data) { - const decoded = (decode(data) as unknown) as [Buffer, BlockLog[]]; + const decoded = decode(data) as unknown as [Buffer, BlockLog[]]; this[_raw] = decoded; } } @@ -192,7 +204,7 @@ export class BlockLogs { logIndex: Quantity, blockHash: Data, blockNumber: Quantity - ) { + ): Log { const topics = log[4]; const data = log[5]; diff --git a/src/chains/ethereum/utils/src/types/debug-storage.ts b/src/chains/ethereum/utils/src/types/debug-storage.ts index 5ec08cd5ea..5c500f4eb9 100644 --- a/src/chains/ethereum/utils/src/types/debug-storage.ts +++ b/src/chains/ethereum/utils/src/types/debug-storage.ts @@ -8,7 +8,7 @@ export type StorageRecords = Record< } >; -export type StorageRangeResult = { +export type StorageRangeAtResult = { nextKey: Data | null; storage: StorageRecords; }; diff --git a/src/chains/ethereum/utils/src/types/filters.ts b/src/chains/ethereum/utils/src/types/filters.ts index f564de35e7..6748f02e55 100644 --- a/src/chains/ethereum/utils/src/types/filters.ts +++ b/src/chains/ethereum/utils/src/types/filters.ts @@ -16,7 +16,7 @@ export type RangeFilterArgs = BaseFilterArgs & { }; export type FilterArgs = BlockHashFilterArgs | RangeFilterArgs; -export type Filter = { +export type InternalFilter = { type: FilterTypes; updates: Data[]; unsubscribe: Emittery.UnsubscribeFn; diff --git a/src/chains/ethereum/utils/src/types/trace-transaction.ts b/src/chains/ethereum/utils/src/types/trace-transaction.ts index 9e6222ba25..86e98babee 100644 --- a/src/chains/ethereum/utils/src/types/trace-transaction.ts +++ b/src/chains/ethereum/utils/src/types/trace-transaction.ts @@ -2,7 +2,7 @@ import { Data } from "@ganache/utils"; import { ITraceData } from "../things/trace-data"; import { TraceStorageMap } from "../things/trace-storage-map"; -export type TransactionTraceOptions = { +export type TraceTransactionOptions = { disableStorage?: boolean; disableMemory?: boolean; disableStack?: boolean; diff --git a/src/chains/filecoin/filecoin/index.ts b/src/chains/filecoin/filecoin/index.ts index 03d6aa0d57..e3ca2be0a5 100644 --- a/src/chains/filecoin/filecoin/index.ts +++ b/src/chains/filecoin/filecoin/index.ts @@ -5,11 +5,19 @@ * @license MIT */ -import { Connector, Provider, StorageDealStatus } from "./src/connector"; -export type { Connector, Provider, StorageDealStatus } from "./src/connector"; +import { + Connector as FilecoinConnector, + FilecoinProvider, + StorageDealStatus +} from "./src/connector"; +export type { + Connector as FilecoinConnector, + FilecoinProvider, + StorageDealStatus +} from "./src/connector"; export default { - Connector, - Provider, + Connector: FilecoinConnector, + FilecoinProvider, StorageDealStatus }; diff --git a/src/chains/filecoin/filecoin/package-lock.json b/src/chains/filecoin/filecoin/package-lock.json index 19134debdb..2376e23454 100644 --- a/src/chains/filecoin/filecoin/package-lock.json +++ b/src/chains/filecoin/filecoin/package-lock.json @@ -10263,9 +10263,9 @@ } }, "typescript": { - "version": "4.5.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.4.tgz", - "integrity": "sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==", + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", "dev": true }, "typical": { diff --git a/src/chains/filecoin/filecoin/package.json b/src/chains/filecoin/filecoin/package.json index b5fceba0cb..b49db62354 100644 --- a/src/chains/filecoin/filecoin/package.json +++ b/src/chains/filecoin/filecoin/package.json @@ -96,7 +96,7 @@ "ts-loader": "9.2.6", "ts-node": "10.4.0", "typedoc": "0.22.10", - "typescript": "4.5.4", + "typescript": "4.6.4", "webpack": "5.65.0", "webpack-cli": "4.9.1", "ws": "8.2.3" diff --git a/src/chains/filecoin/filecoin/src/@types/@trufflesuite/uws-js-unofficial.d.ts b/src/chains/filecoin/filecoin/src/@types/@trufflesuite/uws-js-unofficial.d.ts index 952d40d7a9..005c70fe5f 100644 --- a/src/chains/filecoin/filecoin/src/@types/@trufflesuite/uws-js-unofficial.d.ts +++ b/src/chains/filecoin/filecoin/src/@types/@trufflesuite/uws-js-unofficial.d.ts @@ -1,11 +1,11 @@ -import "@trufflesuite/uws-js-unofficial"; +import "uWebsockets.js"; enum ListenOptions { LIBUS_LISTEN_DEFAULT = 0, LIBUS_LISTEN_EXCLUSIVE_PORT = 1 } // uWebSockets.js doesn't include these in its TS def file. -declare module "@trufflesuite/uws-js-unofficial" { +declare module "uWebsockets.js" { export interface TemplatedApp { listen( host: RecognizedString, diff --git a/src/chains/filecoin/filecoin/src/api.ts b/src/chains/filecoin/filecoin/src/api.ts index 1a7160dbdd..55fb03c5fb 100644 --- a/src/chains/filecoin/filecoin/src/api.ts +++ b/src/chains/filecoin/filecoin/src/api.ts @@ -17,6 +17,9 @@ import { SerializedQueryOffer } from "./things/query-offer"; import Emittery from "emittery"; import { HeadChange, HeadChangeType } from "./things/head-change"; import { SubscriptionMethod, SubscriptionId } from "./types/subscriptions"; +// same as SubscriptionMethod.ChannelClosed, but api-extractor doesn't like the +// enum so I just hardcoded it here +const ChannelClosed = "xrpc.ch.close" as const; import { FileRef, SerializedFileRef } from "./things/file-ref"; import { MinerPower, SerializedMinerPower } from "./things/miner-power"; import { PowerClaim } from "./things/power-claim"; @@ -42,7 +45,10 @@ import { StorageDealStatus } from "./types/storage-deal-status"; export default class FilecoinApi implements Api { readonly [index: string]: (...args: any) => Promise; - readonly #getId = (id => () => Quantity.from(++id))(0); + readonly #getId = ( + id => () => + Quantity.from(++id) + )(0); readonly #subscriptions = new Map(); readonly #blockchain: Blockchain; @@ -199,9 +205,7 @@ export default class FilecoinApi implements Api { * @returns `false` if the subscription ID doesn't exist or * if the subscription is already canceled, `true` otherwise. */ - [SubscriptionMethod.ChannelClosed]( - subscriptionId: SubscriptionId - ): Promise { + [ChannelClosed](subscriptionId: SubscriptionId): Promise { const subscriptions = this.#subscriptions; const unsubscribe = this.#subscriptions.get(subscriptionId); @@ -302,9 +306,10 @@ export default class FilecoinApi implements Api { await this.#blockchain.waitForReady(); const blockCid = new RootCID(serializedBlockCid); - const blockMessages = await this.#blockchain.blockMessagesManager!.getBlockMessages( - blockCid.root - ); + const blockMessages = + await this.#blockchain.blockMessagesManager!.getBlockMessages( + blockCid.root + ); if (!blockMessages) { throw new Error("Could not find a block for the provided CID"); @@ -687,7 +692,8 @@ export default class FilecoinApi implements Api { */ async "Filecoin.WalletDefaultAddress"(): Promise { await this.#blockchain.waitForReady(); - const accounts = await this.#blockchain.accountManager!.getControllableAccounts(); + const accounts = + await this.#blockchain.accountManager!.getControllableAccounts(); return accounts[0].address.serialize(); } @@ -763,7 +769,8 @@ export default class FilecoinApi implements Api { async "Filecoin.WalletList"(): Promise> { await this.#blockchain.waitForReady(); - const accounts = await this.#blockchain.accountManager!.getControllableAccounts(); + const accounts = + await this.#blockchain.accountManager!.getControllableAccounts(); return accounts.map(account => account.address.serialize()); } diff --git a/src/chains/filecoin/filecoin/src/blockchain.ts b/src/chains/filecoin/filecoin/src/blockchain.ts index 5e53aa61b0..d03eb53e6e 100644 --- a/src/chains/filecoin/filecoin/src/blockchain.ts +++ b/src/chains/filecoin/filecoin/src/blockchain.ts @@ -25,7 +25,7 @@ import { Ticket } from "./things/ticket"; import { FileRef } from "./things/file-ref"; import fs from "fs"; import path from "path"; -import { IPFS, CID as IPFS_CID } from "ipfs"; +import { CID as IPFS_CID } from "ipfs"; import { Account } from "./things/account"; import Database from "./database"; import TipsetManager from "./data-managers/tipset-manager"; @@ -161,7 +161,8 @@ export default class Blockchain extends Emittery { this.#database.dealExpirations! ); - const controllableAccounts = await this.accountManager.getControllableAccounts(); + const controllableAccounts = + await this.accountManager.getControllableAccounts(); if (controllableAccounts.length === 0) { for (let i = 0; i < this.options.wallet.totalAccounts; i++) { await this.accountManager.putAccount( @@ -257,7 +258,9 @@ export default class Blockchain extends Emittery { } } - get ipfs(): IPFS | null { + // using `any` because the IPFS type that should be here can't be exported by + // api-extractor :-() + get ipfs(): any | null { return this.ipfsServer.node; } @@ -474,7 +477,8 @@ export default class Blockchain extends Emittery { if (local) { this.messagePool = []; } else { - const localAccounts = await this.accountManager!.getControllableAccounts(); + const localAccounts = + await this.accountManager!.getControllableAccounts(); const localAddressStrings = localAccounts.map( account => account.address.value ); diff --git a/src/chains/filecoin/filecoin/src/connector.ts b/src/chains/filecoin/filecoin/src/connector.ts index 0913e91afd..6d7db10bc9 100644 --- a/src/chains/filecoin/filecoin/src/connector.ts +++ b/src/chains/filecoin/filecoin/src/connector.ts @@ -9,7 +9,8 @@ import { makeError, KnownKeys } from "@ganache/utils"; -import FilecoinProvider from "./provider"; +import { FilecoinProvider } from "./provider"; +export { FilecoinProvider } from "./provider"; import { RecognizedString, HttpRequest, @@ -18,9 +19,6 @@ import { import { FilecoinProviderOptions } from "@ganache/filecoin-options"; export { StorageDealStatus } from "./types/storage-deal-status"; -export type Provider = FilecoinProvider; -export const Provider = FilecoinProvider; - /** * @internal */ @@ -31,7 +29,8 @@ export class Connector< > = JsonRpcRequest> > extends Emittery<{ ready: undefined; close: undefined }> - implements IConnector { + implements IConnector +{ #provider: FilecoinProvider; get provider() { diff --git a/src/chains/filecoin/filecoin/src/provider.ts b/src/chains/filecoin/filecoin/src/provider.ts index a7f6cc2c66..2bd9f51697 100644 --- a/src/chains/filecoin/filecoin/src/provider.ts +++ b/src/chains/filecoin/filecoin/src/provider.ts @@ -9,8 +9,8 @@ import { } from "@ganache/utils"; import FilecoinApi from "./api"; -import GanacheSchema from "./schema"; -import { Schema } from "@filecoin-shipyard/lotus-client-schema"; +import GanacheSchema, { Schema } from "./schema"; + import Blockchain from "./blockchain"; import { FilecoinOptionsConfig, @@ -21,7 +21,7 @@ import cloneDeep from "lodash.clonedeep"; // Meant to mimic this provider: // https://github.com/filecoin-shipyard/js-lotus-client-provider-browser -export default class FilecoinProvider< +export class FilecoinProvider< R extends JsonRpcRequest< FilecoinApi, KnownKeys @@ -29,7 +29,8 @@ export default class FilecoinProvider< > extends Emittery<{ connect: undefined; disconnect: undefined }> // Do I actually need this? `types.Provider` doesn't actually define anything behavior - implements Provider { + implements Provider +{ #options: FilecoinInternalOptions; #api: FilecoinApi; #executor: Executor; @@ -74,7 +75,8 @@ export default class FilecoinProvider< { unlocked: boolean; secretKey: string; balance: bigint } > = {}; - const controllableAccounts = await this.blockchain.accountManager!.getControllableAccounts(); + const controllableAccounts = + await this.blockchain.accountManager!.getControllableAccounts(); for (const account of controllableAccounts) { accounts[account.address.serialize()] = { unlocked: true, @@ -105,7 +107,7 @@ export default class FilecoinProvider< ...(payload.params || []), payload.id ] as any); - const promise = (result.value as unknown) as PromiseLike< + const promise = result.value as unknown as PromiseLike< ReturnType >; @@ -154,7 +156,7 @@ export default class FilecoinProvider< ...(payload.params || []), payload.id ] as any); - const promiEvent = (result.value as unknown) as PromiEvent; + const promiEvent = result.value as unknown as PromiEvent; if (promiEvent instanceof PromiEvent) { promiEvent.on("message", data => { diff --git a/src/chains/filecoin/filecoin/src/schema.ts b/src/chains/filecoin/filecoin/src/schema.ts index 5ebbc0a309..80d016c996 100644 --- a/src/chains/filecoin/filecoin/src/schema.ts +++ b/src/chains/filecoin/filecoin/src/schema.ts @@ -1,5 +1,13 @@ import FilecoinApi from "./api"; -import LotusSchema, { Schema } from "@filecoin-shipyard/lotus-client-schema"; +import LotusSchema from "@filecoin-shipyard/lotus-client-schema"; +export type Schema = { + methods: { + [propertyName: string]: { + subscription?: boolean; + namespace?: string; + }; + }; +}; const GanacheSchema: Schema = { methods: {} diff --git a/src/chains/filecoin/filecoin/tests/api/filecoin/deals.test.ts b/src/chains/filecoin/filecoin/tests/api/filecoin/deals.test.ts index 1704c48154..e8e1bb6c3f 100644 --- a/src/chains/filecoin/filecoin/tests/api/filecoin/deals.test.ts +++ b/src/chains/filecoin/filecoin/tests/api/filecoin/deals.test.ts @@ -1,5 +1,5 @@ import assert from "assert"; -import FilecoinProvider from "../../../src/provider"; +import { FilecoinProvider } from "../../../src/provider"; import getProvider from "../../helpers/getProvider"; import getIpfsClient from "../../helpers/getIpfsClient"; import { CID } from "../../../src/things/cid"; @@ -80,7 +80,8 @@ describe("api", () => { it("should accept a new deal", async () => { const miners = await client.stateListMiners(); - const accounts = await provider.blockchain.accountManager.getControllableAccounts(); + const accounts = + await provider.blockchain.accountManager.getControllableAccounts(); const address = accounts[0].address; const beginningBalance = await client.walletBalance(address.value); diff --git a/src/chains/filecoin/filecoin/tests/api/filecoin/generic.test.ts b/src/chains/filecoin/filecoin/tests/api/filecoin/generic.test.ts index 3d2b3fe3e4..c9826e7765 100644 --- a/src/chains/filecoin/filecoin/tests/api/filecoin/generic.test.ts +++ b/src/chains/filecoin/filecoin/tests/api/filecoin/generic.test.ts @@ -1,5 +1,5 @@ import assert from "assert"; -import FilecoinProvider from "../../../src/provider"; +import { FilecoinProvider } from "../../../src/provider"; import getProvider from "../../helpers/getProvider"; import { CID } from "../../../src/things/cid"; import LotusSchema from "@filecoin-shipyard/lotus-client-schema"; diff --git a/src/chains/filecoin/filecoin/tests/api/filecoin/messages.test.ts b/src/chains/filecoin/filecoin/tests/api/filecoin/messages.test.ts index ab5feff6e7..2e5a7160f8 100644 --- a/src/chains/filecoin/filecoin/tests/api/filecoin/messages.test.ts +++ b/src/chains/filecoin/filecoin/tests/api/filecoin/messages.test.ts @@ -1,5 +1,5 @@ import assert from "assert"; -import FilecoinProvider from "../../../src/provider"; +import { FilecoinProvider } from "../../../src/provider"; import getProvider from "../../helpers/getProvider"; import { Address, AddressProtocol } from "../../../src/things/address"; import { Message, SerializedMessage } from "../../../src/things/message"; @@ -29,7 +29,8 @@ describe("api", () => { before(async () => { provider = await getProvider(); client = new LotusRPC(provider, { schema: FilecoinProvider.Schema }); - accounts = await provider.blockchain.accountManager.getControllableAccounts(); + accounts = + await provider.blockchain.accountManager.getControllableAccounts(); }); after(async () => { @@ -72,10 +73,8 @@ describe("api", () => { const priorFromBalance: string = await client.walletBalance(From); const priorToBalance: string = await client.walletBalance(To); - const signedMessage: SerializedSignedMessage = await client.mpoolPushMessage( - message, - messageSendSpec - ); + const signedMessage: SerializedSignedMessage = + await client.mpoolPushMessage(message, messageSendSpec); expectedHeight++; assert.ok(signedMessage); await waitForExpectedHeight(); @@ -129,10 +128,8 @@ describe("api", () => { MaxFee: "0" }; - const signedMessage: SerializedSignedMessage = await client.mpoolPushMessage( - message, - messageSendSpec - ); + const signedMessage: SerializedSignedMessage = + await client.mpoolPushMessage(message, messageSendSpec); expectedHeight++; assert.strictEqual(signedMessage.Message.Nonce, priorFromNonce); @@ -471,8 +468,7 @@ describe("api", () => { const message: SerializedMessage = { Version: 0, From, - To: - "t3yaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaby2smx7a", + To: "t3yaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaby2smx7a", Nonce: 0, Value: "1", GasLimit: 0, @@ -1058,8 +1054,7 @@ describe("api", () => { const message = new Message({ Version: 0, - To: - "t3yaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaby2smx7a", + To: "t3yaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaby2smx7a", From, Nonce: nonce, Value: "1", @@ -1452,10 +1447,11 @@ describe("api", () => { const priorFromBalance: string = await client.walletBalance(From); const priorToBalance: string = await client.walletBalance(To); - const signedMessages: SerializedSignedMessage[] = await client.mpoolBatchPushMessage( - [message, message], - messageSendSpec - ); + const signedMessages: SerializedSignedMessage[] = + await client.mpoolBatchPushMessage( + [message, message], + messageSendSpec + ); expectedHeight += 2; // theres a block per transaction assert.ok(signedMessages); await waitForExpectedHeight(); @@ -1567,7 +1563,8 @@ describe("api", () => { } }); client2 = new LotusRPC(provider2, { schema: FilecoinProvider.Schema }); - accounts2 = await provider2.blockchain.accountManager.getControllableAccounts(); + accounts2 = + await provider2.blockchain.accountManager.getControllableAccounts(); }); after(async () => { @@ -1607,16 +1604,13 @@ describe("api", () => { MaxFee: "0" }; - const signedMessage1: SerializedSignedMessage = await client2.mpoolPushMessage( - message, - messageSendSpec - ); - const signedMessage2: SerializedSignedMessage = await client2.mpoolPushMessage( - message, - messageSendSpec - ); + const signedMessage1: SerializedSignedMessage = + await client2.mpoolPushMessage(message, messageSendSpec); + const signedMessage2: SerializedSignedMessage = + await client2.mpoolPushMessage(message, messageSendSpec); - const pendingMessages: SerializedSignedMessage[] = await client2.mpoolPending(); + const pendingMessages: SerializedSignedMessage[] = + await client2.mpoolPending(); assert.strictEqual(pendingMessages.length, 2); assert.deepStrictEqual(pendingMessages[0], signedMessage1); @@ -1630,12 +1624,14 @@ describe("api", () => { it("clears messages from the message pool", async () => { // This should not clear local messages (all of them are local currently) await client2.mpoolClear(false); - const localPendingMessages: SerializedSignedMessage[] = await client2.mpoolPending(); + const localPendingMessages: SerializedSignedMessage[] = + await client2.mpoolPending(); assert.strictEqual(localPendingMessages.length, 2); // This should clear all messages await client2.mpoolClear(true); - const allPendingMessages: SerializedSignedMessage[] = await client2.mpoolPending(); + const allPendingMessages: SerializedSignedMessage[] = + await client2.mpoolPending(); assert.strictEqual(allPendingMessages.length, 0); // make sure we didn't mine a block which would cause the pool to clear diff --git a/src/chains/filecoin/filecoin/tests/api/filecoin/miners.test.ts b/src/chains/filecoin/filecoin/tests/api/filecoin/miners.test.ts index e5554e8f0e..860ffa41ea 100644 --- a/src/chains/filecoin/filecoin/tests/api/filecoin/miners.test.ts +++ b/src/chains/filecoin/filecoin/tests/api/filecoin/miners.test.ts @@ -1,5 +1,5 @@ import assert from "assert"; -import FilecoinProvider from "../../../src/provider"; +import { FilecoinProvider } from "../../../src/provider"; import { Address } from "../../../src/things/address"; import getProvider from "../../helpers/getProvider"; diff --git a/src/chains/filecoin/filecoin/tests/api/filecoin/subscriptions.test.ts b/src/chains/filecoin/filecoin/tests/api/filecoin/subscriptions.test.ts index 224bb50918..8af9c78733 100644 --- a/src/chains/filecoin/filecoin/tests/api/filecoin/subscriptions.test.ts +++ b/src/chains/filecoin/filecoin/tests/api/filecoin/subscriptions.test.ts @@ -1,6 +1,6 @@ import assert from "assert"; import Emittery from "emittery"; -import FilecoinProvider from "../../../src/provider"; +import { FilecoinProvider } from "../../../src/provider"; import { SubscriptionMethod } from "../../../src/types/subscriptions"; import getProvider from "../../helpers/getProvider"; diff --git a/src/chains/filecoin/filecoin/tests/api/filecoin/wallet.test.ts b/src/chains/filecoin/filecoin/tests/api/filecoin/wallet.test.ts index 823783fa41..44845762f2 100644 --- a/src/chains/filecoin/filecoin/tests/api/filecoin/wallet.test.ts +++ b/src/chains/filecoin/filecoin/tests/api/filecoin/wallet.test.ts @@ -1,5 +1,5 @@ import assert from "assert"; -import FilecoinProvider from "../../../src/provider"; +import { FilecoinProvider } from "../../../src/provider"; import getProvider from "../../helpers/getProvider"; import { Address, AddressProtocol } from "../../../src/things/address"; import { KeyType } from "../../../src/things/key-type"; @@ -279,10 +279,11 @@ describe("api", () => { const directSignature = await account.address.signMessage( new Message(serializedMessage) ); - const apiSignature: SerializedSignedMessage = await client.walletSignMessage( - account.address.value, - serializedMessage - ); + const apiSignature: SerializedSignedMessage = + await client.walletSignMessage( + account.address.value, + serializedMessage + ); assert.strictEqual(apiSignature.Signature.Type, SigType.SigTypeBLS); assert.strictEqual( directSignature.toString("base64"), diff --git a/src/chains/filecoin/filecoin/tests/api/ganache/ganache.test.ts b/src/chains/filecoin/filecoin/tests/api/ganache/ganache.test.ts index 8aeab9053e..2922335ff0 100644 --- a/src/chains/filecoin/filecoin/tests/api/ganache/ganache.test.ts +++ b/src/chains/filecoin/filecoin/tests/api/ganache/ganache.test.ts @@ -1,5 +1,5 @@ import assert from "assert"; -import FilecoinProvider from "../../../src/provider"; +import { FilecoinProvider } from "../../../src/provider"; import { SerializedMessage } from "../../../src/things/message"; import { SerializedMessageSendSpec } from "../../../src/things/message-send-spec"; import { SubscriptionMethod } from "../../../src/types/subscriptions"; @@ -107,7 +107,8 @@ describe("api", () => { const head2 = await client.chainHead(); assert.strictEqual(head2.Height, head1.Height); - const accounts = await provider.blockchain.accountManager.getControllableAccounts(); + const accounts = + await provider.blockchain.accountManager.getControllableAccounts(); const From = accounts[0].address.value; const To = accounts[1].address.value; const message: SerializedMessage = { @@ -153,7 +154,8 @@ describe("api", () => { const head2 = await client.chainHead(); assert(head2.Height > head1.Height); - const accounts = await provider.blockchain.accountManager.getControllableAccounts(); + const accounts = + await provider.blockchain.accountManager.getControllableAccounts(); const From = accounts[0].address.value; const To = accounts[1].address.value; const message: SerializedMessage = { diff --git a/src/chains/filecoin/filecoin/tests/helpers/getProvider.ts b/src/chains/filecoin/filecoin/tests/helpers/getProvider.ts index 21d2b27e8d..940123709c 100644 --- a/src/chains/filecoin/filecoin/tests/helpers/getProvider.ts +++ b/src/chains/filecoin/filecoin/tests/helpers/getProvider.ts @@ -1,6 +1,6 @@ import { FilecoinProviderOptions } from "@ganache/filecoin-options"; import { Executor, RequestCoordinator } from "@ganache/utils"; -import FilecoinProvider from "../../src/provider"; +import { FilecoinProvider } from "../../src/provider"; const getProvider = async (options?: Partial) => { const requestCoordinator = new RequestCoordinator(0); @@ -12,7 +12,7 @@ const getProvider = async (options?: Partial) => { }, logging: { logger: { - log: () => {} + log: () => { } } }, ...options diff --git a/src/chains/filecoin/options/package-lock.json b/src/chains/filecoin/options/package-lock.json index 78fac3add2..4a6b2cd8af 100644 --- a/src/chains/filecoin/options/package-lock.json +++ b/src/chains/filecoin/options/package-lock.json @@ -1659,9 +1659,9 @@ } }, "typescript": { - "version": "4.5.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.4.tgz", - "integrity": "sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==", + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", "dev": true }, "uri-js": { diff --git a/src/chains/filecoin/options/package.json b/src/chains/filecoin/options/package.json index c4e2e18b99..03302bb05d 100644 --- a/src/chains/filecoin/options/package.json +++ b/src/chains/filecoin/options/package.json @@ -61,7 +61,7 @@ "terser-webpack-plugin": "5.2.5", "ts-loader": "9.2.6", "ts-node": "10.4.0", - "typescript": "4.5.4", + "typescript": "4.6.4", "webpack": "5.65.0", "webpack-cli": "4.9.1" }, diff --git a/src/chains/tezos/options/package-lock.json b/src/chains/tezos/options/package-lock.json index 153527b418..c48f8cfd7d 100644 --- a/src/chains/tezos/options/package-lock.json +++ b/src/chains/tezos/options/package-lock.json @@ -721,9 +721,9 @@ } }, "typescript": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", - "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==", + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", "dev": true }, "which": { diff --git a/src/chains/tezos/options/package.json b/src/chains/tezos/options/package.json index ee81d71135..a15e38fb95 100644 --- a/src/chains/tezos/options/package.json +++ b/src/chains/tezos/options/package.json @@ -52,6 +52,6 @@ "cross-env": "7.0.3", "mocha": "9.1.3", "ts-node": "10.4.0", - "typescript": "4.5.2" + "typescript": "4.6.4" } } diff --git a/src/chains/tezos/tezos/index.ts b/src/chains/tezos/tezos/index.ts index da5f78b246..2ec3c5db36 100644 --- a/src/chains/tezos/tezos/index.ts +++ b/src/chains/tezos/tezos/index.ts @@ -9,7 +9,8 @@ export const TezosProvider = Provider; export class TezosConnector extends Emittery<{ ready: undefined; close: undefined }> - implements Connector { + implements Connector +{ provider: Provider; #api: TezosApi; diff --git a/src/chains/tezos/tezos/package-lock.json b/src/chains/tezos/tezos/package-lock.json index 1783533fd3..f5a5a38284 100644 --- a/src/chains/tezos/tezos/package-lock.json +++ b/src/chains/tezos/tezos/package-lock.json @@ -2381,9 +2381,9 @@ } }, "typescript": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", - "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==", + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", "dev": true }, "typical": { diff --git a/src/chains/tezos/tezos/package.json b/src/chains/tezos/tezos/package.json index d0ec859e02..f0448bea23 100644 --- a/src/chains/tezos/tezos/package.json +++ b/src/chains/tezos/tezos/package.json @@ -55,6 +55,6 @@ "mocha": "9.1.3", "ts-node": "10.4.0", "typedoc": "0.22.10", - "typescript": "4.5.2" + "typescript": "4.6.4" } } diff --git a/src/packages/cli/package-lock.json b/src/packages/cli/package-lock.json index 01f72dea4a..ed008ec551 100644 --- a/src/packages/cli/package-lock.json +++ b/src/packages/cli/package-lock.json @@ -1131,9 +1131,9 @@ "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==" }, "typescript": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", - "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==", + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", "dev": true }, "util-deprecate": { diff --git a/src/packages/cli/package.json b/src/packages/cli/package.json index caf7dc2e6f..c1fb7229b9 100644 --- a/src/packages/cli/package.json +++ b/src/packages/cli/package.json @@ -59,7 +59,7 @@ "cross-env": "7.0.3", "mocha": "9.1.3", "ts-node": "10.4.0", - "typescript": "4.5.2" + "typescript": "4.6.4" }, "dependencies": { "@ganache/colors": "0.2.0", diff --git a/src/packages/cli/src/cli.ts b/src/packages/cli/src/cli.ts index ac155afb86..47d430dbf8 100644 --- a/src/packages/cli/src/cli.ts +++ b/src/packages/cli/src/cli.ts @@ -6,8 +6,8 @@ import args from "./args"; import { EthereumFlavorName, FilecoinFlavorName } from "@ganache/flavors"; import initializeEthereum from "./initialize/ethereum"; import initializeFilecoin from "./initialize/filecoin"; -import type { Provider as FilecoinProvider } from "@ganache/filecoin"; -import type { Provider as EthereumProvider } from "@ganache/ethereum"; +import type { FilecoinProvider } from "@ganache/filecoin"; +import type { EthereumProvider } from "@ganache/ethereum"; const logAndForceExit = (messages: any[], exitCode = 0) => { // https://nodejs.org/api/process.html#process_process_exit_code diff --git a/src/packages/cli/src/initialize/ethereum.ts b/src/packages/cli/src/initialize/ethereum.ts index cf62a7b6f1..8021af2c8a 100644 --- a/src/packages/cli/src/initialize/ethereum.ts +++ b/src/packages/cli/src/initialize/ethereum.ts @@ -1,7 +1,7 @@ import chalk from "chalk"; import { TruffleColors } from "@ganache/colors"; import { WEI } from "@ganache/utils"; -import type { Provider } from "@ganache/ethereum"; +import type { EthereumProvider } from "@ganache/ethereum"; import { toChecksumAddress } from "ethereumjs-util"; import { CliSettings } from "../types"; @@ -12,7 +12,7 @@ function color(str: string) { return chalk`{hex("${TruffleColors.porsche}") ${str}}`; } -export default function (provider: Provider, cliSettings: CliSettings) { +export default function (provider: EthereumProvider, cliSettings: CliSettings) { const liveOptions = provider.getOptions(); const accounts = provider.getInitialAccounts(); diff --git a/src/packages/cli/src/initialize/filecoin.ts b/src/packages/cli/src/initialize/filecoin.ts index 0c0a391f22..5434e691d2 100644 --- a/src/packages/cli/src/initialize/filecoin.ts +++ b/src/packages/cli/src/initialize/filecoin.ts @@ -1,7 +1,7 @@ -import type { Provider } from "@ganache/filecoin"; +import type { FilecoinProvider } from "@ganache/filecoin"; export default async function ( - provider: Provider, + provider: FilecoinProvider, serverSettings: { host: string; port: number } ) { const liveOptions = provider.getOptions(); diff --git a/src/packages/colors/package-lock.json b/src/packages/colors/package-lock.json index a5aae9bc19..123e610ae8 100644 --- a/src/packages/colors/package-lock.json +++ b/src/packages/colors/package-lock.json @@ -721,9 +721,9 @@ } }, "typescript": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", - "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==", + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", "dev": true }, "which": { diff --git a/src/packages/colors/package.json b/src/packages/colors/package.json index dc9523043c..9129ccf192 100644 --- a/src/packages/colors/package.json +++ b/src/packages/colors/package.json @@ -44,6 +44,6 @@ "cross-env": "7.0.3", "mocha": "9.1.3", "ts-node": "10.4.0", - "typescript": "4.5.2" + "typescript": "4.6.4" } } diff --git a/src/packages/core/index.ts b/src/packages/core/index.ts index 41f23a2fd4..981289c5e8 100644 --- a/src/packages/core/index.ts +++ b/src/packages/core/index.ts @@ -4,10 +4,16 @@ import ConnectorLoader from "./src/connector-loader"; import { ProviderOptions, ServerOptions } from "./src/options"; import Server from "./src/server"; export { Server, ServerStatus, _DefaultServerOptions } from "./src/server"; -export type { Provider, EthereumProvider, FilecoinProvider } from "@ganache/flavors"; + +export type { + Provider, + Ethereum, + EthereumProvider, + FilecoinProvider +} from "@ganache/flavors"; export type { ProviderOptions, ServerOptions } from "./src/options"; export type _ExperimentalInfo = Readonly<{ - version: string, + version: string; fork: Readonly<{ /** * Chains Ganache is known to be compatible with. Operations performed @@ -15,10 +21,9 @@ export type _ExperimentalInfo = Readonly<{ * OPCODEs, gas prices, and EIPs that were active at the time the historic * block originally took place. */ - knownChainIds: number[], - }> -}> - + knownChainIds: number[]; + }>; +}>; const version = process.env.VERSION || "DEV"; @@ -56,14 +61,14 @@ const Ganache = { * @returns A provider instance for the flavor * `options.flavor` which defaults to `ethereum`. */ - provider: ( - options?: ProviderOptions - ): ConnectorsByName[T]["provider"] => { - const loader = ConnectorLoader.initialize(options); + provider: ( + options?: ProviderOptions + ): ConnectorsByName[Flavor]["provider"] => { + const loader = ConnectorLoader.initialize(options); return loader.connector.provider; }, /** - * + * * @experimental */ __experimental_info(): _ExperimentalInfo { diff --git a/src/packages/core/package-lock.json b/src/packages/core/package-lock.json index 6e82b8ddd4..dc6777edf0 100644 --- a/src/packages/core/package-lock.json +++ b/src/packages/core/package-lock.json @@ -2424,9 +2424,9 @@ } }, "typescript": { - "version": "4.5.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.4.tgz", - "integrity": "sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==", + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", "dev": true }, "unbox-primitive": { diff --git a/src/packages/core/package.json b/src/packages/core/package.json index 4fce103de2..f6121fb80c 100644 --- a/src/packages/core/package.json +++ b/src/packages/core/package.json @@ -67,7 +67,7 @@ "nyc": "15.1.0", "superagent": "6.1.0", "ts-node": "10.4.0", - "typescript": "4.5.4", + "typescript": "4.6.4", "ws": "8.2.3" } } diff --git a/src/packages/core/src/connector-loader.ts b/src/packages/core/src/connector-loader.ts index d05359728a..c6734f80fb 100644 --- a/src/packages/core/src/connector-loader.ts +++ b/src/packages/core/src/connector-loader.ts @@ -1,12 +1,12 @@ import { Executor, RequestCoordinator } from "@ganache/utils"; import { DefaultFlavor, FlavorName } from "@ganache/flavors"; -import { GetConnector, Options as ProviderOptions } from "@ganache/flavors"; +import { GetConnector, FlavorOptions } from "@ganache/flavors"; const initialize = ( - options: ProviderOptions = { + options: FlavorOptions = { flavor: DefaultFlavor, chain: { asyncRequestProcessing: true } - } as ProviderOptions + } as FlavorOptions ) => { const flavor = (options.flavor || DefaultFlavor) as T; diff --git a/src/packages/core/src/options/index.ts b/src/packages/core/src/options/index.ts index efd542bce5..e371663ffd 100644 --- a/src/packages/core/src/options/index.ts +++ b/src/packages/core/src/options/index.ts @@ -1,8 +1,4 @@ -import { - DefaultFlavor, - FlavorName, - Options as FlavorOptions -} from "@ganache/flavors"; +import { DefaultFlavor, FlavorName, FlavorOptions } from "@ganache/flavors"; import { ServerConfig, ServerOptions } from "./server-options"; import { Defaults, @@ -15,7 +11,8 @@ import { /** * @public */ -export type ProviderOptions = FlavorOptions; +export type ProviderOptions = + FlavorOptions; export type Options = { server: ServerConfig; @@ -24,14 +21,11 @@ export type Options = { /** * @public */ -export type ServerOptions< - T extends FlavorName = typeof DefaultFlavor -> = Partial< - { +export type ServerOptions = + Partial<{ [K in keyof Options]: ExternalConfig; - } -> & - ProviderOptions; + }> & + ProviderOptions; export type InternalOptions = { [K in keyof Options]: InternalConfig; diff --git a/src/packages/core/src/server.ts b/src/packages/core/src/server.ts index 9c2a7139c3..08f3108743 100644 --- a/src/packages/core/src/server.ts +++ b/src/packages/core/src/server.ts @@ -36,7 +36,7 @@ import { ConnectorsByName, DefaultFlavor, FlavorName, - Options + FlavorOptions } from "@ganache/flavors"; import ConnectorLoader from "./connector-loader"; import WebsocketServer, { WebSocketCapableFlavor } from "./servers/ws-server"; @@ -108,20 +108,20 @@ export const _DefaultServerOptions = serverDefaults; * @public */ export class Server< - T extends FlavorName = typeof DefaultFlavor - > extends Emittery<{ open: undefined; close: undefined }> { + Flavor extends FlavorName = typeof DefaultFlavor +> extends Emittery<{ open: undefined; close: undefined }> { #options: InternalOptions; - #providerOptions: Options; + #providerOptions: FlavorOptions; #status: number = ServerStatus.unknown; #app: TemplatedApp | null = null; #httpServer: HttpServer | null = null; #listenSocket: us_listen_socket | null = null; - #connector: ConnectorsByName[T]; + #connector: ConnectorsByName[Flavor]; #websocketServer: WebsocketServer | null = null; #initializer: Promise<[void, void]>; - public get provider(): ConnectorsByName[T]["provider"] { + public get provider(): ConnectorsByName[Flavor]["provider"] { return this.#connector.provider; } @@ -130,9 +130,9 @@ export class Server< } constructor( - providerAndServerOptions: ServerOptions = { + providerAndServerOptions: ServerOptions = { flavor: DefaultFlavor - } as ServerOptions + } as ServerOptions ) { super(); this.#options = serverOptionsConfig.normalize(providerAndServerOptions); @@ -189,12 +189,16 @@ export class Server< // Method signature specifies port: number, but we parse a string if provided // inspiration taken from nodejs internal port validator // https://github.com/nodejs/node/blob/8c4b8b201ada6b76d5306c9c7f352e45087fb4a9/lib/internal/validators.js#L208-L219 - if ((typeof port !== 'number' && typeof port !== 'string') || - (typeof port === 'string' && (port).trim().length === 0) || - +port !== (+port >>> 0) || - port > 0xFFFF || - port === 0) { - const err = new Error(`Port should be >= 0 and < 65536. Received ${port}.`); + if ( + (typeof port !== "number" && typeof port !== "string") || + (typeof port === "string" && (port).trim().length === 0) || + +port !== +port >>> 0 || + port > 0xffff || + port === 0 + ) { + const err = new Error( + `Port should be >= 0 and < 65536. Received ${port}.` + ); return callbackIsFunction ? process.nextTick(callback!, err) @@ -230,12 +234,16 @@ export class Server< const LIBUS_LISTEN_EXCLUSIVE_PORT = 1; host ? (this.#app as any).listen( - host, - portNumber, - LIBUS_LISTEN_EXCLUSIVE_PORT, - resolve - ) - : this.#app.listen(portNumber, LIBUS_LISTEN_EXCLUSIVE_PORT, resolve); + host as string, + portNumber, + LIBUS_LISTEN_EXCLUSIVE_PORT, + resolve + ) + : this.#app.listen( + portNumber, + LIBUS_LISTEN_EXCLUSIVE_PORT, + resolve + ); } ).then(listenSocket => { if (listenSocket) { @@ -244,7 +252,8 @@ export class Server< } else { this.#status = ServerStatus.closed; const err = new Error( - `listen EADDRINUSE: address already in use ${host || DEFAULT_HOST + `listen EADDRINUSE: address already in use ${ + host || DEFAULT_HOST }:${portNumber}.` ); throw err; diff --git a/src/packages/core/src/servers/ws-server.ts b/src/packages/core/src/servers/ws-server.ts index 2be5ad6d25..7b4e63fc2c 100644 --- a/src/packages/core/src/servers/ws-server.ts +++ b/src/packages/core/src/servers/ws-server.ts @@ -6,8 +6,7 @@ import { import WebSocketCloseCodes from "./utils/websocket-close-codes"; import { InternalOptions } from "../options"; import * as Flavors from "@ganache/flavors"; -import { hasOwn, PromiEvent } from "@ganache/utils"; -import { isGeneratorFunction, isGeneratorObject } from "util/types"; +import { PromiEvent } from "@ganache/utils"; import { types } from "util"; type MergePromiseT = Promise ? X : never>; diff --git a/src/packages/core/tests/server.test.ts b/src/packages/core/tests/server.test.ts index ade973a12e..88cf9514c8 100644 --- a/src/packages/core/tests/server.test.ts +++ b/src/packages/core/tests/server.test.ts @@ -17,7 +17,7 @@ import intoStream = require("into-stream"); import { PromiEvent } from "@ganache/utils"; import { promisify } from "util"; import { ServerOptions } from "../src/options"; -import { Connector, Provider as EthereumProvider } from "@ganache/ethereum"; +import { Connector, EthereumProvider } from "@ganache/ethereum"; import { NetworkInterfaceInfo, NetworkInterfaceInfoIPv6, @@ -36,7 +36,7 @@ describe("server", () => { params: [] }; const logger = { - log: (_message: string) => { } + log: (_message: string) => {} }; let s: Server; @@ -47,10 +47,11 @@ describe("server", () => { logging: { logger } - } + }; async function setup( - options: ServerOptions = defaultOptions, host: string | null = null + options: ServerOptions = defaultOptions, + host: string | null = null ) { // @ts-ignore - `s` errors if you run tsc and then test // because it tries to compare the built declaration file to @@ -102,10 +103,10 @@ describe("server", () => { req.on("response", (res: http.IncomingMessage) => { let data = ""; res - .on("data", d => data += d.toString("utf8")) + .on("data", d => (data += d.toString("utf8"))) .on("end", () => resolve({ status: 200, body: JSON.parse(data) })); }); - req.on("error", (err) => reject(err)); + req.on("error", err => reject(err)); req.write(data); req.end(); return deferred; @@ -167,13 +168,20 @@ describe("server", () => { for (const info of interfaceInfo) { const host = getHost(info, interfaceName); const response = await post(host, port, jsonRpcJson); - assert.strictEqual(response.status, 200, `Wrong status code when connecting to http://${host}:${port}`); - assert.strictEqual(response.body.result, "1234", `Wrong result when connecting to http://${host}:${port}`); + assert.strictEqual( + response.status, + 200, + `Wrong status code when connecting to http://${host}:${port}` + ); + assert.strictEqual( + response.body.result, + "1234", + `Wrong result when connecting to http://${host}:${port}` + ); } } - } - finally { - await teardown() + } finally { + await teardown(); } }); @@ -223,7 +231,7 @@ describe("server", () => { } } }).timeout(50000); // we need a long timeout because the OS may take a while to refuse connections, especially on Windows. - }) + }); describe("http", () => { async function simpleTest() { @@ -315,8 +323,10 @@ describe("server", () => { it("accepts port as number type or binary, octal, decimal or hexadecimal string", async () => { const validPorts = [ - port, `0b${port.toString(2)}`, - `0o${port.toString(8)}`, port.toString(10), + port, + `0b${port.toString(2)}`, + `0o${port.toString(8)}`, + port.toString(10), `0x${port.toString(16)}` ]; @@ -335,10 +345,28 @@ describe("server", () => { it("fails with invalid ports", async () => { const invalidPorts = [ - -1, 'a', {}, [], false, true, - 0xFFFF + 1, Infinity, -Infinity, NaN, - undefined, null, '', ' ', 1.1, '0x', - '-0x1', '-0o1', '-0b1', '0o', '0b', 0 + -1, + "a", + {}, + [], + false, + true, + 0xffff + 1, + Infinity, + -Infinity, + NaN, + undefined, + null, + "", + " ", + 1.1, + "0x", + "-0x1", + "-0o1", + "-0b1", + "0o", + "0b", + 0 ]; for (const specificPort of invalidPorts) { @@ -451,7 +479,6 @@ describe("server", () => { // a request is required in order to actually close the connection // see https://github.com/trufflesuite/ganache/issues/2788 await post("localhost", port, jsonRpcJson, agent); - } finally { teardown(); } @@ -1362,8 +1389,8 @@ describe("server", () => { reject( new Error( "Possible false positive: Didn't detect backpressure" + - " before receiving a message. Ensure `s.provider.send` is" + - " sending enough data." + " before receiving a message. Ensure `s.provider.send` is" + + " sending enough data." ) ); } diff --git a/src/packages/core/tsconfig.json b/src/packages/core/tsconfig.json index d0a323a59c..365a53d71b 100644 --- a/src/packages/core/tsconfig.json +++ b/src/packages/core/tsconfig.json @@ -5,10 +5,7 @@ "declarationDir": "typings", "composite": true }, - "include": [ - "index.ts", - "src/**/*" - ], + "include": ["index.ts", "src/**/*"], "references": [ { "name": "@ganache/ethereum", @@ -31,4 +28,4 @@ "path": "../utils" } ] -} \ No newline at end of file +} diff --git a/src/packages/flavors/index.ts b/src/packages/flavors/index.ts index 700d31a2dd..4c93a568bd 100644 --- a/src/packages/flavors/index.ts +++ b/src/packages/flavors/index.ts @@ -1,13 +1,10 @@ import { Connector as EthereumConnector, - Provider as EthereumProvider + EthereumProvider } from "@ganache/ethereum"; -export type {Provider as EthereumProvider} from "@ganache/ethereum"; -export type {Provider as FilecoinProvider} from "@ganache/filecoin"; -import type { - Connector as FilecoinConnector, - Provider as FilecoinProvider -} from "@ganache/filecoin"; +export type { EthereumProvider, Ethereum } from "@ganache/ethereum"; +export type { FilecoinProvider } from "@ganache/filecoin"; +import type { FilecoinConnector, FilecoinProvider } from "@ganache/filecoin"; import { EthereumDefaults, EthereumProviderOptions, @@ -51,19 +48,19 @@ export type OptionsByName = { export type FlavorName = keyof ConnectorsByName; export type Connector = { - [K in keyof ConnectorsByName]: ConnectorsByName[K]; -}[keyof ConnectorsByName]; + [K in FlavorName]: ConnectorsByName[K]; +}[FlavorName]; -export function GetConnector( - flavor: T, - providerOptions: Options, +export function GetConnector( + flavor: Flavor, + providerOptions: FlavorOptions, executor: Executor -): ConnectorsByName[T] { +): ConnectorsByName[Flavor] { if (flavor === DefaultFlavor) { return new EthereumConnector( providerOptions, executor - ) as ConnectorsByName[T]; + ) as ConnectorsByName[Flavor]; } try { switch (flavor) { @@ -74,6 +71,7 @@ export function GetConnector( const f = eval("require")(flavor); const Connector: FilecoinConnector = typeof f.default != "undefined" ? f.default.Connector : f.Connector; + console.log(Connector, f); // @ts-ignore return new Connector(providerOptions, executor); } @@ -117,8 +115,9 @@ type FilecoinOptions = { flavor: T; } & (FilecoinProviderOptions | FilecoinLegacyProviderOptions); -export type Options = T extends "filecoin" - ? FilecoinOptions - : T extends "ethereum" - ? EthereumOptions - : never; +export type FlavorOptions = + T extends "filecoin" + ? FilecoinOptions + : T extends "ethereum" + ? EthereumOptions + : never; diff --git a/src/packages/flavors/package-lock.json b/src/packages/flavors/package-lock.json index 08b2d1fb64..2ed0c85a8c 100644 --- a/src/packages/flavors/package-lock.json +++ b/src/packages/flavors/package-lock.json @@ -715,9 +715,9 @@ } }, "typescript": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", - "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==", + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", "dev": true }, "which": { diff --git a/src/packages/flavors/package.json b/src/packages/flavors/package.json index 63da63f602..338d2806e1 100644 --- a/src/packages/flavors/package.json +++ b/src/packages/flavors/package.json @@ -61,6 +61,6 @@ "cross-env": "7.0.3", "mocha": "9.1.3", "ts-node": "10.4.0", - "typescript": "4.5.2" + "typescript": "4.6.4" } } diff --git a/src/packages/ganache/api-extractor.json b/src/packages/ganache/api-extractor.json index 39784e5296..cf17a4202f 100644 --- a/src/packages/ganache/api-extractor.json +++ b/src/packages/ganache/api-extractor.json @@ -82,7 +82,9 @@ "@ganache/filecoin", "@ganache/filecoin-options", "levelup", - "ipfs" + "ipfs", + "level-errors", + "abstract-leveldown" ], /** * Determines how the TypeScript compiler engine will be invoked by API Extractor. diff --git a/src/packages/ganache/index.ts b/src/packages/ganache/index.ts index 124acd2880..802c35cf86 100644 --- a/src/packages/ganache/index.ts +++ b/src/packages/ganache/index.ts @@ -10,10 +10,15 @@ export type { Provider, ServerOptions, ProviderOptions, - EthereumProvider, - FilecoinProvider, + Ethereum, _ExperimentalInfo } from "@ganache/core"; + +// for backwards compatibility with previous versions of v7 +// we introduce a top-level `EthereumProvider` +export { EthereumProvider } from "@ganache/core"; +import type { ConnectorsByName } from "@ganache/flavors"; +export type FilecoinProvider = ConnectorsByName["filecoin"]; export { server, provider, diff --git a/src/packages/ganache/npm-shrinkwrap.json b/src/packages/ganache/npm-shrinkwrap.json index f5ed901cef..02bf161cc1 100644 --- a/src/packages/ganache/npm-shrinkwrap.json +++ b/src/packages/ganache/npm-shrinkwrap.json @@ -1,6 +1,6 @@ { "name": "ganache", - "version": "7.1.0", + "version": "7.2.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -26,17 +26,17 @@ "dev": true }, "@microsoft/api-extractor": { - "version": "7.19.2", - "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.19.2.tgz", - "integrity": "sha512-LxSa9lwp7eYtM4i5y/1n79QpotPKlmpCrVQbkb0LAHE1sCRHpZDTb6p3cMJthDhYPMjAYKOLfq639GwtZrg23Q==", + "version": "7.20.1", + "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.20.1.tgz", + "integrity": "sha512-T7cqcK+JpvHGOj7cD2ZCCWS7Xgru1uOqZwrV/FSUdyKVs5fopZcbBSuetwD/akst3O7Ypryg3UOLP54S/vnVmA==", "dev": true, "requires": { - "@microsoft/api-extractor-model": "7.15.1", + "@microsoft/api-extractor-model": "7.16.0", "@microsoft/tsdoc": "0.13.2", "@microsoft/tsdoc-config": "~0.15.2", - "@rushstack/node-core-library": "3.44.2", - "@rushstack/rig-package": "0.3.6", - "@rushstack/ts-command-line": "4.10.5", + "@rushstack/node-core-library": "3.45.1", + "@rushstack/rig-package": "0.3.8", + "@rushstack/ts-command-line": "4.10.7", "colors": "~1.2.1", "lodash": "~4.17.15", "resolve": "~1.17.0", @@ -53,18 +53,24 @@ "requires": { "path-parse": "^1.0.6" } + }, + "typescript": { + "version": "4.5.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", + "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", + "dev": true } } }, "@microsoft/api-extractor-model": { - "version": "7.15.1", - "resolved": "https://registry.npmjs.org/@microsoft/api-extractor-model/-/api-extractor-model-7.15.1.tgz", - "integrity": "sha512-DWfS1o3oMY0mzdO3OuQbD/9vzn80jwM6tFd7XbiYnkpxwhD83LMGXz7NZWwSh+IaA+9w3LF4w62fT31Qq+dAMw==", + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/@microsoft/api-extractor-model/-/api-extractor-model-7.16.0.tgz", + "integrity": "sha512-0FOrbNIny8mzBrzQnSIkEjAXk0JMSnPmWYxt3ZDTPVg9S8xIPzB6lfgTg9+Mimu0RKCpGKBpd+v2WcR5vGzyUQ==", "dev": true, "requires": { "@microsoft/tsdoc": "0.13.2", "@microsoft/tsdoc-config": "~0.15.2", - "@rushstack/node-core-library": "3.44.2" + "@rushstack/node-core-library": "3.45.1" } }, "@microsoft/tsdoc": { @@ -98,9 +104,9 @@ } }, "@rushstack/node-core-library": { - "version": "3.44.2", - "resolved": "https://registry.npmjs.org/@rushstack/node-core-library/-/node-core-library-3.44.2.tgz", - "integrity": "sha512-lQ8Ct267UKkNSJSDxpBWn7SyyITWQ9l3Xqww0V+YY0rMt02r9eiGvwwPaU1ugJW7IMVo6r/HXvgbmpOSPyzGyg==", + "version": "3.45.1", + "resolved": "https://registry.npmjs.org/@rushstack/node-core-library/-/node-core-library-3.45.1.tgz", + "integrity": "sha512-BwdssTNe007DNjDBxJgInHg8ePytIPyT0La7ZZSQZF9+rSkT42AygXPGvbGsyFfEntjr4X37zZSJI7yGzL16cQ==", "dev": true, "requires": { "@types/node": "12.20.24", @@ -132,9 +138,9 @@ } }, "@rushstack/rig-package": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/@rushstack/rig-package/-/rig-package-0.3.6.tgz", - "integrity": "sha512-H/uFsAT6cD4JCYrlQXYMZg+wPVECByFoJLGqfGRiTwSS5ngQw9QxnFV2mPG2LrxFUsMjLQ2lsrYr523700XzfA==", + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/@rushstack/rig-package/-/rig-package-0.3.8.tgz", + "integrity": "sha512-MDWg1xovea99PWloSiYMjFcCLsrdjFtYt6aOyHNs5ojn5mxrzR6U9F83hvbQjTWnKPMvZtr0vcek+4n+OQOp3Q==", "dev": true, "requires": { "resolve": "~1.17.0", @@ -153,9 +159,9 @@ } }, "@rushstack/ts-command-line": { - "version": "4.10.5", - "resolved": "https://registry.npmjs.org/@rushstack/ts-command-line/-/ts-command-line-4.10.5.tgz", - "integrity": "sha512-5fVlTDbKsJ5WyT6L7NrnOlLG3uoITKxoqTPP2j0QZEi95kPbVT4+VPZaXXDJtkrao9qrIyig8pLK9WABY1bb3w==", + "version": "4.10.7", + "resolved": "https://registry.npmjs.org/@rushstack/ts-command-line/-/ts-command-line-4.10.7.tgz", + "integrity": "sha512-CjS+DfNXUSO5Ab2wD1GBGtUTnB02OglRWGqfaTcac9Jn45V5MeUOsq/wA8wEeS5Y/3TZ2P1k+IWdVDiuOFP9Og==", "dev": true, "requires": { "@types/argparse": "1.0.38", @@ -213,6 +219,14 @@ "integrity": "sha512-ebDJ9b0e702Yr7pWgB0jzm+CX4Srzz8RcXtLJDJB+BSccqMa36uyH/zUsSYao5+BD1ytv3k3rPYCq4mAE1hsXA==", "dev": true }, + "@types/bn.js": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.0.tgz", + "integrity": "sha512-QSSVYj7pYFN49kW77o2s9xTCwZ8F2xLbjLLSEVh8D2F4JUhZtPAGOFLTD+ffqksBx/u4cE/KImFjyhqCjn/LIA==", + "requires": { + "@types/node": "*" + } + }, "@types/eslint": { "version": "8.2.1", "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.2.1.tgz", @@ -245,6 +259,11 @@ "integrity": "sha512-YSBPTLTVm2e2OoQIDYx8HaeWJ5tTToLH67kXR7zYNGupXMEHa2++G8k+DczX2cFVgalypqtyZIcU19AFcmOpmg==", "dev": true }, + "@types/lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@types/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-ssE3Vlrys7sdIzs5LOxCzTVMsU7i9oa/IaW92wF32JFb3CVczqOkru2xspuKczHEbG3nvmPY7IFqVmGGHdNbYw==" + }, "@types/mocha": { "version": "9.0.0", "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-9.0.0.tgz", @@ -254,8 +273,12 @@ "@types/node": { "version": "17.0.0", "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.0.tgz", - "integrity": "sha512-eMhwJXc931Ihh4tkU+Y7GiLzT/y/DBNpNtr4yU9O2w3SYBsr9NaOPhQlLKRmoWtI54uNwuo0IOUFQjVOTZYRvw==", - "dev": true + "integrity": "sha512-eMhwJXc931Ihh4tkU+Y7GiLzT/y/DBNpNtr4yU9O2w3SYBsr9NaOPhQlLKRmoWtI54uNwuo0IOUFQjVOTZYRvw==" + }, + "@types/seedrandom": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@types/seedrandom/-/seedrandom-3.0.1.tgz", + "integrity": "sha512-giB9gzDeiCeloIXDgzFBCgjj1k4WxcDrZtGl6h1IqmUPlxF+Nx8Ve+96QCyDZ/HseB/uvDsKbpib9hU5cU53pw==" }, "@ungap/promise-all-settled": { "version": "1.1.2", @@ -545,6 +568,14 @@ "inherits": "^2.0.1", "minimalistic-assert": "^1.0.0", "safer-buffer": "^2.1.0" + }, + "dependencies": { + "bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + } } }, "assert": { @@ -588,11 +619,6 @@ "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", "dev": true }, - "bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" - }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -898,6 +924,14 @@ "requires": { "bn.js": "^4.1.0", "elliptic": "^6.5.3" + }, + "dependencies": { + "bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + } } }, "create-hash": { @@ -1029,6 +1063,14 @@ "bn.js": "^4.1.0", "miller-rabin": "^4.0.0", "randombytes": "^2.0.0" + }, + "dependencies": { + "bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + } } }, "electron-to-chromium": { @@ -1049,6 +1091,13 @@ "inherits": "^2.0.4", "minimalistic-assert": "^1.0.1", "minimalistic-crypto-utils": "^1.0.1" + }, + "dependencies": { + "bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" + } } }, "emittery": { @@ -1979,6 +2028,14 @@ "requires": { "bn.js": "^4.0.0", "brorand": "^1.0.1" + }, + "dependencies": { + "bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + } } }, "mime-db": { @@ -2364,6 +2421,14 @@ "parse-asn1": "^5.0.0", "randombytes": "^2.0.1", "safe-buffer": "^5.1.2" + }, + "dependencies": { + "bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + } } }, "punycode": { @@ -2828,9 +2893,9 @@ } }, "typescript": { - "version": "4.5.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.4.tgz", - "integrity": "sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==", + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", "dev": true }, "unbox-primitive": { @@ -3110,12 +3175,12 @@ "dev": true }, "z-schema": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/z-schema/-/z-schema-5.0.2.tgz", - "integrity": "sha512-40TH47ukMHq5HrzkeVE40Ad7eIDKaRV2b+Qpi2prLc9X9eFJFzV7tMe5aH12e6avaSS/u5l653EQOv+J9PirPw==", + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/z-schema/-/z-schema-5.0.3.tgz", + "integrity": "sha512-sGvEcBOTNum68x9jCpCVGPFJ6mWnkD0YxOcddDlJHRx3tKdB2q8pCHExMVZo/AV/6geuVJXG7hljDaWG8+5GDw==", "dev": true, "requires": { - "commander": "^2.7.1", + "commander": "^2.20.3", "lodash.get": "^4.4.2", "lodash.isequal": "^4.5.0", "validator": "^13.7.0" diff --git a/src/packages/ganache/package.json b/src/packages/ganache/package.json index 1e48790c3d..03d1728a4b 100644 --- a/src/packages/ganache/package.json +++ b/src/packages/ganache/package.json @@ -55,7 +55,7 @@ "@ganache/cli": "0.3.0", "@ganache/core": "0.3.0", "@ganache/flavors": "0.3.0", - "@microsoft/api-extractor": "7.19.2", + "@microsoft/api-extractor": "7.20.1", "@types/mocha": "9.0.0", "@types/node": "17.0.0", "assert": "2.0.0", @@ -79,7 +79,7 @@ "terser-webpack-plugin": "5.2.5", "ts-loader": "9.2.6", "ts-node": "10.4.0", - "typescript": "4.5.4", + "typescript": "4.6.4", "util": "0.12.4", "webpack": "5.65.0", "webpack-cli": "4.9.1" @@ -89,10 +89,23 @@ "emittery": "0.10.0", "keccak": "3.0.1", "leveldown": "6.1.0", - "secp256k1": "4.0.2" + "secp256k1": "4.0.2", + "@types/bn.js": "^5.1.0", + "@types/lru-cache": "5.1.1", + "@types/seedrandom": "3.0.1" }, "optionalDependencies": { "bufferutil": "4.0.5", "utf-8-validate": "5.0.7" - } + }, + "bundledDependencies": [ + "@trufflesuite/bigint-buffer", + "emittery", + "keccak", + "leveldown", + "secp256k1", + "@types/bn.js", + "@types/lru-cache", + "@types/seedrandom" + ] } diff --git a/src/packages/ganache/tests/types.test.ts b/src/packages/ganache/tests/types.test.ts new file mode 100644 index 0000000000..801d5b89d1 --- /dev/null +++ b/src/packages/ganache/tests/types.test.ts @@ -0,0 +1,183 @@ +import { Ethereum } from "../"; // <- same as `from "ganache"` + +//#region type helpers +/** + * Converts a union into an intersection, as long as the types don't collide: + * + * ```typescript + * // this is fine: + * UnionToIntersection<{prop: string} | {other: boolean}> // `{prop: string;} & {other: boolean;}` + * ``` + * ``` + * // returns `never`: + * UnionToIntersection<{prop: string} | {prop: boolean}> // never + * ``` + */ +type UnionToIntersection = (U extends any ? (k: U) => void : never) extends ( + k: infer I +) => void + ? I + : never; + +/** + * Returns only the last item in a Tuple + */ +type LastOf = UnionToIntersection< + T extends any ? () => T : never +> extends () => infer R + ? R + : never; + +/** + * Pushes a new value, V, on to the Tuple, T + **/ +type Push = [...T, V]; + +/** + * `TuplifyUnion` splits booleans into [true, false], but we really want to represent that as just `boolean` + */ +type NormalizeBoolean = MaybeBoolean extends + | [true, false] + | [false, true] + ? [boolean] + : MaybeBoolean; + +/** + * Convert a Union into a Tuple. + * example: + * `"latest" | "earliest" | "pending"` turns into `["latest", "earliest", "pending"]` + */ +type TuplifyUnion< + U, + L = LastOf, + // Done detects if we are done or not, by checking if T exists + Done = [U] extends [never] ? true : false +> = true extends Done + ? [] + : NormalizeBoolean>, L>>; + +// mock an instance of our Ethereum provider +declare const Provider: Ethereum.Provider; +// use the mocked provider instance to extract all its method names +type Method = Parameters[0]["method"]; + +/** + * This class provides an entrance into the Provider's types + */ +class Wrapper { + // wrapped has no explicit return type so we can infer it + async wrapped() { + return await Provider.request({} as any); + } +} +// Returns the type within the Promise +type UnPromisify = R extends Promise ? U : R; +// Returns the method's return type (Promises removed) +type InnerReturnType = UnPromisify< + ReturnType["wrapped"]> +>; +// Converts the return type of the method into a union +type ReturnTypeAsTuple = TuplifyUnion>; +// Returns the number of return types for this method +type CountReturnTypes = ReturnTypeAsTuple["length"] & + number; + +/** + * expectMethodReturn type checks the return type of the given method + * It requires all possible types are given at `ExpectedType`. + * + * Other `expectType` tests are too loose, in that is the `ExpectedType` + * _partially_ matches (like unions) the tests still pass. + * + * `expectMethodReturn` attempts to check if the types are complete and exact, + * rather than just "matching": + * + * There are certainly cases where `expectMethodReturn` won't work + */ +const expectMethodReturn = function < + MethodName extends Method, + ExpectedType extends InnerReturnType, + ExpectedUnionSize extends CountReturnTypes extends TuplifyUnion["length"] + ? CountReturnTypes + : `Size of union for ExpectedType (${TuplifyUnion["length"] & + number}) and Method (${CountReturnTypes}) don't match` +>(): void {}; +//#endregion types helpers + +describe("types", () => { + it("returns the type for db_putString", async () => { + expectMethodReturn<"db_putString", boolean, 1>(); + }); + + it("return the type for db_getString", () => { + expectMethodReturn<"db_getString", string, 1>(); + }); + + it("return the type for db_putHex", () => { + expectMethodReturn<"db_putHex", boolean, 1>(); + }); + + it("returns the type for eth_sendTransaction", () => { + expectMethodReturn<"eth_sendTransaction", string, 1>(); + }); + it("returns the type for eth_personalTransaction", () => { + expectMethodReturn<"personal_sendTransaction", string, 1>(); + }); + + it("returns the type for eth_sendRawTransaction", () => { + expectMethodReturn<"eth_sendRawTransaction", string, 1>(); + }); + + it("returns the type for eth_getTransactionByHash", async () => { + expectMethodReturn< + "eth_getTransactionByHash", + Ethereum.Block.Transaction | Ethereum.Pool.Transaction | null, + 4 + >(); + }); + + it("returns the type for txpool_content", async () => { + expectMethodReturn<"txpool_content", Ethereum.Pool.Content, 1>(); + }); + + it("returns the type for eth_getTransactionReceipt", async () => { + expectMethodReturn< + "eth_getTransactionReceipt", + Ethereum.Transaction.Receipt, + 1 + >(); + }); + + it("returns the type for debug_traceTransaction", async () => { + expectMethodReturn< + "debug_traceTransaction", + Ethereum.TraceTransactionResult, + 1 + >(); + }); + + it("returns the type for StorageRangeAtResult", async () => { + const t: Ethereum.Block.Header = {} as any; + expectMethodReturn< + "debug_storageRangeAt", + Ethereum.StorageRangeAtResult, + 1 + >(); + }); + + it("returns the type for eth_getBlockByNumber", async () => { + // eth_getBlockByHash (and eth_getBlockByNumber) return a different type + // based on the arguments passed in, specifically the second argument: + // `includeTransactions`. TypeScript currently isn't capable of supporting + // the the Polymorphic type the way we need it to, but TypeScript 4.7.0 will + // support it. Once 4.7.0 is released we should be able to modify our types + // to handle the polymorphism. Note: this will require we update the way we + // test types, as `expectMethod` doesn't care about the arguments passed in. + // see: https://github.com/trufflesuite/ganache/issues/2907 + expectMethodReturn<"eth_getBlockByNumber", Ethereum.Block, 1>(); + }); + + it("returns the type for eth_getBlockByHash", async () => { + expectMethodReturn<"eth_getBlockByHash", Ethereum.Block, 1>(); + }); +}); diff --git a/src/packages/ganache/tsconfig.json b/src/packages/ganache/tsconfig.json index 0855445cde..b64d313d96 100644 --- a/src/packages/ganache/tsconfig.json +++ b/src/packages/ganache/tsconfig.json @@ -3,15 +3,9 @@ "compilerOptions": { "outDir": "lib" }, - "include": [ - "index.ts", - "src/**/*", - "src/cli.ts" - ], + "include": ["index.ts", "src/**/*", "src/cli.ts"], "paths": { - "@ganache/cli/src/cli": [ - "../cli/src/cli" - ] + "@ganache/cli/src/cli": ["../cli/src/cli"] }, "references": [ { @@ -27,4 +21,4 @@ "path": "../core" } ] -} \ No newline at end of file +} diff --git a/src/packages/ganache/webpack/webpack.node.config.ts b/src/packages/ganache/webpack/webpack.node.config.ts index ab193dea7c..2b5d6ea27a 100644 --- a/src/packages/ganache/webpack/webpack.node.config.ts +++ b/src/packages/ganache/webpack/webpack.node.config.ts @@ -52,7 +52,9 @@ const config: webpack.Configuration = merge({}, base, { "bufferutil", "utf-8-validate", //#endregion - "@ganache/filecoin" + "@ganache/filecoin", + // things api-extractor can't handle, so we don't bundle them: + "emittery" ], module: { rules: [ diff --git a/src/packages/options/package-lock.json b/src/packages/options/package-lock.json index 1049c0ed00..28ff83ea9c 100644 --- a/src/packages/options/package-lock.json +++ b/src/packages/options/package-lock.json @@ -841,9 +841,9 @@ } }, "typescript": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", - "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==", + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", "dev": true }, "util-deprecate": { diff --git a/src/packages/options/package.json b/src/packages/options/package.json index 592bcce158..fa68bb5b01 100644 --- a/src/packages/options/package.json +++ b/src/packages/options/package.json @@ -54,6 +54,6 @@ "cross-env": "7.0.3", "mocha": "9.1.3", "ts-node": "10.4.0", - "typescript": "4.5.2" + "typescript": "4.6.4" } } diff --git a/src/packages/promise-queue/package-lock.json b/src/packages/promise-queue/package-lock.json index 421bcfc1e0..c394ef6747 100644 --- a/src/packages/promise-queue/package-lock.json +++ b/src/packages/promise-queue/package-lock.json @@ -726,9 +726,9 @@ } }, "typescript": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", - "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==", + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", "dev": true }, "which": { diff --git a/src/packages/promise-queue/package.json b/src/packages/promise-queue/package.json index f9a6db281e..7dda6ea723 100644 --- a/src/packages/promise-queue/package.json +++ b/src/packages/promise-queue/package.json @@ -54,6 +54,6 @@ "cross-env": "7.0.3", "mocha": "9.1.3", "ts-node": "10.4.0", - "typescript": "4.5.2" + "typescript": "4.6.4" } } diff --git a/src/packages/rlp/package-lock.json b/src/packages/rlp/package-lock.json index c290880f5a..5d80bc4745 100644 --- a/src/packages/rlp/package-lock.json +++ b/src/packages/rlp/package-lock.json @@ -1885,9 +1885,9 @@ } }, "typescript": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", - "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==", + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", "dev": true }, "uuid": { diff --git a/src/packages/rlp/package.json b/src/packages/rlp/package.json index 6a2a8247fd..775577fa28 100644 --- a/src/packages/rlp/package.json +++ b/src/packages/rlp/package.json @@ -57,6 +57,6 @@ "mocha": "9.1.3", "nyc": "15.1.0", "ts-node": "10.4.0", - "typescript": "4.5.2" + "typescript": "4.6.4" } } diff --git a/src/packages/secp256k1/package-lock.json b/src/packages/secp256k1/package-lock.json index 93c65ab101..aaab6db361 100644 --- a/src/packages/secp256k1/package-lock.json +++ b/src/packages/secp256k1/package-lock.json @@ -1944,9 +1944,9 @@ } }, "typescript": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", - "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==", + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", "dev": true }, "uuid": { diff --git a/src/packages/secp256k1/package.json b/src/packages/secp256k1/package.json index 3903b5a4eb..c9f84481b0 100644 --- a/src/packages/secp256k1/package.json +++ b/src/packages/secp256k1/package.json @@ -53,7 +53,7 @@ "mocha": "9.1.3", "nyc": "15.1.0", "ts-node": "10.4.0", - "typescript": "4.5.2" + "typescript": "4.6.4" }, "dependencies": { "node-gyp-build": "4.3.0", diff --git a/src/packages/utils/package-lock.json b/src/packages/utils/package-lock.json index fcbb9fe785..d3622c5d8c 100644 --- a/src/packages/utils/package-lock.json +++ b/src/packages/utils/package-lock.json @@ -909,9 +909,9 @@ "dev": true }, "typescript": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", - "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==", + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", "dev": true }, "utf-8-validate": { diff --git a/src/packages/utils/package.json b/src/packages/utils/package.json index 458c54207d..08219b85e1 100644 --- a/src/packages/utils/package.json +++ b/src/packages/utils/package.json @@ -59,7 +59,7 @@ "mocha": "9.1.3", "sinon": "11.1.2", "ts-node": "10.4.0", - "typescript": "4.5.2" + "typescript": "4.6.4" }, "optionalDependencies": { "@trufflesuite/bigint-buffer": "1.1.9"